Skip to content

Commit 506bb2a

Browse files
Manikanta MylavarapuAndi Shyti
authored andcommitted
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 <[email protected]> Reviewed-by: Bjorn Andersson <[email protected]> Signed-off-by: Andi Shyti <[email protected]>
1 parent 8284750 commit 506bb2a

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

drivers/i2c/busses/i2c-qcom-geni.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/pm_runtime.h>
1717
#include <linux/soc/qcom/geni-se.h>
1818
#include <linux/spinlock.h>
19+
#include <linux/units.h>
1920

2021
#define SE_I2C_TX_TRANS_LEN 0x26c
2122
#define SE_I2C_RX_TRANS_LEN 0x270
@@ -146,22 +147,36 @@ struct geni_i2c_clk_fld {
146147
* clk_freq_out = t / t_cycle
147148
* source_clock = 19.2 MHz
148149
*/
149-
static const struct geni_i2c_clk_fld geni_i2c_clk_map[] = {
150+
static const struct geni_i2c_clk_fld geni_i2c_clk_map_19p2mhz[] = {
150151
{KHZ(100), 7, 10, 11, 26},
151152
{KHZ(400), 2, 5, 12, 24},
152153
{KHZ(1000), 1, 3, 9, 18},
154+
{},
155+
};
156+
157+
/* source_clock = 32 MHz */
158+
static const struct geni_i2c_clk_fld geni_i2c_clk_map_32mhz[] = {
159+
{KHZ(100), 8, 14, 18, 40},
160+
{KHZ(400), 4, 3, 11, 20},
161+
{KHZ(1000), 2, 3, 6, 15},
162+
{},
153163
};
154164

155165
static int geni_i2c_clk_map_idx(struct geni_i2c_dev *gi2c)
156166
{
157-
int i;
158-
const struct geni_i2c_clk_fld *itr = geni_i2c_clk_map;
167+
const struct geni_i2c_clk_fld *itr;
168+
169+
if (clk_get_rate(gi2c->se.clk) == 32 * HZ_PER_MHZ)
170+
itr = geni_i2c_clk_map_32mhz;
171+
else
172+
itr = geni_i2c_clk_map_19p2mhz;
159173

160-
for (i = 0; i < ARRAY_SIZE(geni_i2c_clk_map); i++, itr++) {
174+
while (itr->clk_freq_out != 0) {
161175
if (itr->clk_freq_out == gi2c->clk_freq_out) {
162176
gi2c->clk_fld = itr;
163177
return 0;
164178
}
179+
itr++;
165180
}
166181
return -EINVAL;
167182
}

0 commit comments

Comments
 (0)