Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

i2c: qcom-geni: Support systems with 32MHz serial engine clock

In existing socs, I2C serial engine is sourced from XO (19.2MHz).
Where as in IPQ5424, I2C serial engine is sourced from GPLL0 (32MHz).

The existing map table is based on 19.2MHz. This patch incorporates
the clock map table to derive the SCL clock from the 32MHz source
clock frequency.

Signed-off-by: Manikanta Mylavarapu <quic_mmanikan@quicinc.com>
Reviewed-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>

authored by

Manikanta Mylavarapu and committed by
Andi Shyti
506bb2ab 8284750a

+19 -4
+19 -4
drivers/i2c/busses/i2c-qcom-geni.c
··· 16 16 #include <linux/pm_runtime.h> 17 17 #include <linux/soc/qcom/geni-se.h> 18 18 #include <linux/spinlock.h> 19 + #include <linux/units.h> 19 20 20 21 #define SE_I2C_TX_TRANS_LEN 0x26c 21 22 #define SE_I2C_RX_TRANS_LEN 0x270 ··· 147 146 * clk_freq_out = t / t_cycle 148 147 * source_clock = 19.2 MHz 149 148 */ 150 - static const struct geni_i2c_clk_fld geni_i2c_clk_map[] = { 149 + static const struct geni_i2c_clk_fld geni_i2c_clk_map_19p2mhz[] = { 151 150 {KHZ(100), 7, 10, 11, 26}, 152 151 {KHZ(400), 2, 5, 12, 24}, 153 152 {KHZ(1000), 1, 3, 9, 18}, 153 + {}, 154 + }; 155 + 156 + /* source_clock = 32 MHz */ 157 + static const struct geni_i2c_clk_fld geni_i2c_clk_map_32mhz[] = { 158 + {KHZ(100), 8, 14, 18, 40}, 159 + {KHZ(400), 4, 3, 11, 20}, 160 + {KHZ(1000), 2, 3, 6, 15}, 161 + {}, 154 162 }; 155 163 156 164 static int geni_i2c_clk_map_idx(struct geni_i2c_dev *gi2c) 157 165 { 158 - int i; 159 - const struct geni_i2c_clk_fld *itr = geni_i2c_clk_map; 166 + const struct geni_i2c_clk_fld *itr; 160 167 161 - for (i = 0; i < ARRAY_SIZE(geni_i2c_clk_map); i++, itr++) { 168 + if (clk_get_rate(gi2c->se.clk) == 32 * HZ_PER_MHZ) 169 + itr = geni_i2c_clk_map_32mhz; 170 + else 171 + itr = geni_i2c_clk_map_19p2mhz; 172 + 173 + while (itr->clk_freq_out != 0) { 162 174 if (itr->clk_freq_out == gi2c->clk_freq_out) { 163 175 gi2c->clk_fld = itr; 164 176 return 0; 165 177 } 178 + itr++; 166 179 } 167 180 return -EINVAL; 168 181 }