* [PATCH v2 1/1] i2c: qcom-geni: Support systems with 32MHz serial engine clock
@ 2024-09-26 3:43 Manikanta Mylavarapu
2024-09-26 6:14 ` Mukesh Kumar Savaliya
2024-09-26 10:28 ` Vladimir Zapolskiy
0 siblings, 2 replies; 10+ messages in thread
From: Manikanta Mylavarapu @ 2024-09-26 3:43 UTC (permalink / raw)
To: andi.shyti, quic_mmanikan, linux-arm-msm, linux-i2c, linux-kernel
Cc: quic_srichara, quic_varada
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 incorporate
the clock map table to derive the SCL clock from the 32MHz source
clock frequency.
Signed-off-by: Manikanta Mylavarapu <quic_mmanikan@quicinc.com>
---
Changes in v2:
- Dropped IPQ5424 from the commit title
- Added else part to assign geni_i2c_clk_map_19p2mhz to itr
- Dropped MHZ macro and used HZ_PER_MHZ macro
- Expanded SE to serial engine
- Added the reason for 32MHz clock in commit message
drivers/i2c/busses/i2c-qcom-geni.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
index 212336f724a6..22f2a0d83641 100644
--- a/drivers/i2c/busses/i2c-qcom-geni.c
+++ b/drivers/i2c/busses/i2c-qcom-geni.c
@@ -16,6 +16,7 @@
#include <linux/pm_runtime.h>
#include <linux/soc/qcom/geni-se.h>
#include <linux/spinlock.h>
+#include <linux/units.h>
#define SE_I2C_TX_TRANS_LEN 0x26c
#define SE_I2C_RX_TRANS_LEN 0x270
@@ -146,18 +147,30 @@ struct geni_i2c_clk_fld {
* clk_freq_out = t / t_cycle
* source_clock = 19.2 MHz
*/
-static const struct geni_i2c_clk_fld geni_i2c_clk_map[] = {
+static const struct geni_i2c_clk_fld geni_i2c_clk_map_19p2mhz[] = {
{KHZ(100), 7, 10, 11, 26},
{KHZ(400), 2, 5, 12, 24},
{KHZ(1000), 1, 3, 9, 18},
};
+/* source_clock = 32 MHz */
+static const struct geni_i2c_clk_fld geni_i2c_clk_map_32mhz[] = {
+ {KHZ(100), 7, 14, 18, 40},
+ {KHZ(400), 4, 3, 11, 20},
+ {KHZ(1000), 4, 3, 6, 15},
+};
+
static int geni_i2c_clk_map_idx(struct geni_i2c_dev *gi2c)
{
int i;
- const struct geni_i2c_clk_fld *itr = geni_i2c_clk_map;
+ const struct geni_i2c_clk_fld *itr;
+
+ if (clk_get_rate(gi2c->se.clk) == 32 * HZ_PER_MHZ)
+ itr = geni_i2c_clk_map_32mhz;
+ else
+ itr = geni_i2c_clk_map_19p2mhz;
- for (i = 0; i < ARRAY_SIZE(geni_i2c_clk_map); i++, itr++) {
+ for (i = 0; i < ARRAY_SIZE(geni_i2c_clk_map_19p2mhz); i++, itr++) {
if (itr->clk_freq_out == gi2c->clk_freq_out) {
gi2c->clk_fld = itr;
return 0;
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/1] i2c: qcom-geni: Support systems with 32MHz serial engine clock
2024-09-26 3:43 [PATCH v2 1/1] i2c: qcom-geni: Support systems with 32MHz serial engine clock Manikanta Mylavarapu
@ 2024-09-26 6:14 ` Mukesh Kumar Savaliya
2024-09-26 7:43 ` Manikanta Mylavarapu
2024-09-26 12:44 ` Bjorn Andersson
2024-09-26 10:28 ` Vladimir Zapolskiy
1 sibling, 2 replies; 10+ messages in thread
From: Mukesh Kumar Savaliya @ 2024-09-26 6:14 UTC (permalink / raw)
To: Manikanta Mylavarapu, andi.shyti, linux-arm-msm, linux-i2c, linux-kernel
Cc: quic_srichara, quic_varada
Hi Manikanta, My suggestion:
i2c: qcom-geni: Support systems with 32MHz serial engine clock
[Derive i2c clock from 32MHz Sourced clock]
On 9/26/2024 9:13 AM, Manikanta Mylavarapu wrote:
> 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 incorporate
incorporate/s/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>
> ---
> Changes in v2:
> - Dropped IPQ5424 from the commit title
> - Added else part to assign geni_i2c_clk_map_19p2mhz to itr
> - Dropped MHZ macro and used HZ_PER_MHZ macro
> - Expanded SE to serial engine
> - Added the reason for 32MHz clock in commit message
>
> drivers/i2c/busses/i2c-qcom-geni.c | 19 ++++++++++++++++---
> 1 file changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
> index 212336f724a6..22f2a0d83641 100644
> --- a/drivers/i2c/busses/i2c-qcom-geni.c
> +++ b/drivers/i2c/busses/i2c-qcom-geni.c
> @@ -16,6 +16,7 @@
> #include <linux/pm_runtime.h>
> #include <linux/soc/qcom/geni-se.h>
> #include <linux/spinlock.h>
> +#include <linux/units.h>
>
> #define SE_I2C_TX_TRANS_LEN 0x26c
> #define SE_I2C_RX_TRANS_LEN 0x270
> @@ -146,18 +147,30 @@ struct geni_i2c_clk_fld {
> * clk_freq_out = t / t_cycle
> * source_clock = 19.2 MHz
> */
> -static const struct geni_i2c_clk_fld geni_i2c_clk_map[] = {
> +static const struct geni_i2c_clk_fld geni_i2c_clk_map_19p2mhz[] = {
> {KHZ(100), 7, 10, 11, 26},
> {KHZ(400), 2, 5, 12, 24},
> {KHZ(1000), 1, 3, 9, 18},
> };
>
> +/* source_clock = 32 MHz */
> +static const struct geni_i2c_clk_fld geni_i2c_clk_map_32mhz[] = {
> + {KHZ(100), 7, 14, 18, 40},
> + {KHZ(400), 4, 3, 11, 20},
> + {KHZ(1000), 4, 3, 6, 15},
> +};
> +
> static int geni_i2c_clk_map_idx(struct geni_i2c_dev *gi2c)
> {
> int i;
> - const struct geni_i2c_clk_fld *itr = geni_i2c_clk_map;
> + const struct geni_i2c_clk_fld *itr;
> +
> + if (clk_get_rate(gi2c->se.clk) == 32 * HZ_PER_MHZ)
> + itr = geni_i2c_clk_map_32mhz;
> + else
> + itr = geni_i2c_clk_map_19p2mhz;
>
> - for (i = 0; i < ARRAY_SIZE(geni_i2c_clk_map); i++, itr++) {
> + for (i = 0; i < ARRAY_SIZE(geni_i2c_clk_map_19p2mhz); i++, itr++) {
> if (itr->clk_freq_out == gi2c->clk_freq_out) {
> gi2c->clk_fld = itr;
> return 0;
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/1] i2c: qcom-geni: Support systems with 32MHz serial engine clock
2024-09-26 6:14 ` Mukesh Kumar Savaliya
@ 2024-09-26 7:43 ` Manikanta Mylavarapu
2024-09-26 12:44 ` Bjorn Andersson
1 sibling, 0 replies; 10+ messages in thread
From: Manikanta Mylavarapu @ 2024-09-26 7:43 UTC (permalink / raw)
To: Mukesh Kumar Savaliya, andi.shyti, linux-arm-msm, linux-i2c,
linux-kernel
Cc: quic_srichara, quic_varada
On 9/26/2024 11:44 AM, Mukesh Kumar Savaliya wrote:
> Hi Manikanta, My suggestion:
>
> i2c: qcom-geni: Support systems with 32MHz serial engine clock
> [Derive i2c clock from 32MHz Sourced clock]
>
As per Bjorn suggestion, i used this commit title "i2c: qcom-geni: Support systems with 32MHz serial engine clock".
> On 9/26/2024 9:13 AM, Manikanta Mylavarapu wrote:
>> 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 incorporate
> incorporate/s/incorporates
Okay, sure.
Thanks & Regards,
Manikanta.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/1] i2c: qcom-geni: Support systems with 32MHz serial engine clock
2024-09-26 3:43 [PATCH v2 1/1] i2c: qcom-geni: Support systems with 32MHz serial engine clock Manikanta Mylavarapu
2024-09-26 6:14 ` Mukesh Kumar Savaliya
@ 2024-09-26 10:28 ` Vladimir Zapolskiy
2024-09-26 12:48 ` Bjorn Andersson
2024-09-29 6:36 ` Manikanta Mylavarapu
1 sibling, 2 replies; 10+ messages in thread
From: Vladimir Zapolskiy @ 2024-09-26 10:28 UTC (permalink / raw)
To: Manikanta Mylavarapu, andi.shyti, linux-arm-msm, linux-i2c, linux-kernel
Cc: quic_srichara, quic_varada
Hello Manikanta.
On 9/26/24 06:43, Manikanta Mylavarapu wrote:
> 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 incorporate
> the clock map table to derive the SCL clock from the 32MHz source
> clock frequency.
>
> Signed-off-by: Manikanta Mylavarapu <quic_mmanikan@quicinc.com>
> ---
> Changes in v2:
> - Dropped IPQ5424 from the commit title
> - Added else part to assign geni_i2c_clk_map_19p2mhz to itr
> - Dropped MHZ macro and used HZ_PER_MHZ macro
> - Expanded SE to serial engine
> - Added the reason for 32MHz clock in commit message
>
> drivers/i2c/busses/i2c-qcom-geni.c | 19 ++++++++++++++++---
> 1 file changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
> index 212336f724a6..22f2a0d83641 100644
> --- a/drivers/i2c/busses/i2c-qcom-geni.c
> +++ b/drivers/i2c/busses/i2c-qcom-geni.c
> @@ -16,6 +16,7 @@
> #include <linux/pm_runtime.h>
> #include <linux/soc/qcom/geni-se.h>
> #include <linux/spinlock.h>
> +#include <linux/units.h>
>
> #define SE_I2C_TX_TRANS_LEN 0x26c
> #define SE_I2C_RX_TRANS_LEN 0x270
> @@ -146,18 +147,30 @@ struct geni_i2c_clk_fld {
> * clk_freq_out = t / t_cycle
> * source_clock = 19.2 MHz
> */
> -static const struct geni_i2c_clk_fld geni_i2c_clk_map[] = {
> +static const struct geni_i2c_clk_fld geni_i2c_clk_map_19p2mhz[] = {
> {KHZ(100), 7, 10, 11, 26},
> {KHZ(400), 2, 5, 12, 24},
> {KHZ(1000), 1, 3, 9, 18},
> };
>
> +/* source_clock = 32 MHz */
> +static const struct geni_i2c_clk_fld geni_i2c_clk_map_32mhz[] = {
> + {KHZ(100), 7, 14, 18, 40},
> + {KHZ(400), 4, 3, 11, 20},
> + {KHZ(1000), 4, 3, 6, 15},
> +};
Please double check the values.
This is what I get:
* for 100KHz: 32000000 / (40 * 7) ~ 114286, apparently 32000000 / (40 * 8) would
be a better fit, however it's unclear what would be proper t_high / t_low values,
* for 400KHz: it seems good,
* for 1000KHz: 32000000 / (15 * 4) ~ 533333, which is almost 1/2 of the wanted
bus frequency, so this one looks very wrong.
Do you have any ideas how to get better bus frequency settings?
> +
> static int geni_i2c_clk_map_idx(struct geni_i2c_dev *gi2c)
> {
> int i;
> - const struct geni_i2c_clk_fld *itr = geni_i2c_clk_map;
> + const struct geni_i2c_clk_fld *itr;
> +
> + if (clk_get_rate(gi2c->se.clk) == 32 * HZ_PER_MHZ)
> + itr = geni_i2c_clk_map_32mhz;
> + else
> + itr = geni_i2c_clk_map_19p2mhz;
>
> - for (i = 0; i < ARRAY_SIZE(geni_i2c_clk_map); i++, itr++) {
> + for (i = 0; i < ARRAY_SIZE(geni_i2c_clk_map_19p2mhz); i++, itr++) {
Struct/data organization here is so weak, that here it's implicitly assumed
that sizes of two arrays are equal. It could be kept as is of course, just
pointing to it.
> if (itr->clk_freq_out == gi2c->clk_freq_out) {
> gi2c->clk_fld = itr;
> return 0;
--
Best wishes,
Vladimir
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/1] i2c: qcom-geni: Support systems with 32MHz serial engine clock
2024-09-26 6:14 ` Mukesh Kumar Savaliya
2024-09-26 7:43 ` Manikanta Mylavarapu
@ 2024-09-26 12:44 ` Bjorn Andersson
1 sibling, 0 replies; 10+ messages in thread
From: Bjorn Andersson @ 2024-09-26 12:44 UTC (permalink / raw)
To: Mukesh Kumar Savaliya
Cc: Manikanta Mylavarapu, andi.shyti, linux-arm-msm, linux-i2c,
linux-kernel, quic_srichara, quic_varada
On Thu, Sep 26, 2024 at 11:44:20AM GMT, Mukesh Kumar Savaliya wrote:
> Hi Manikanta, My suggestion:
>
> i2c: qcom-geni: Support systems with 32MHz serial engine clock
> [Derive i2c clock from 32MHz Sourced clock]
I'm fine with a more accurate subject, but to me your sentence indicates
"there's a choice of where the i2c clock is sourced from, now make it
come from the 32MHz clock".
Is this really what's going on? (Patch content and commit message
indicates no)
Is the "Sourced clock" the name of specific clock? Why does it have a
capital 'S'?
Regards,
Bjorn
>
> On 9/26/2024 9:13 AM, Manikanta Mylavarapu wrote:
> > 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 incorporate
> incorporate/s/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>
> > ---
> > Changes in v2:
> > - Dropped IPQ5424 from the commit title
> > - Added else part to assign geni_i2c_clk_map_19p2mhz to itr
> > - Dropped MHZ macro and used HZ_PER_MHZ macro
> > - Expanded SE to serial engine
> > - Added the reason for 32MHz clock in commit message
> >
> > drivers/i2c/busses/i2c-qcom-geni.c | 19 ++++++++++++++++---
> > 1 file changed, 16 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
> > index 212336f724a6..22f2a0d83641 100644
> > --- a/drivers/i2c/busses/i2c-qcom-geni.c
> > +++ b/drivers/i2c/busses/i2c-qcom-geni.c
> > @@ -16,6 +16,7 @@
> > #include <linux/pm_runtime.h>
> > #include <linux/soc/qcom/geni-se.h>
> > #include <linux/spinlock.h>
> > +#include <linux/units.h>
> > #define SE_I2C_TX_TRANS_LEN 0x26c
> > #define SE_I2C_RX_TRANS_LEN 0x270
> > @@ -146,18 +147,30 @@ struct geni_i2c_clk_fld {
> > * clk_freq_out = t / t_cycle
> > * source_clock = 19.2 MHz
> > */
> > -static const struct geni_i2c_clk_fld geni_i2c_clk_map[] = {
> > +static const struct geni_i2c_clk_fld geni_i2c_clk_map_19p2mhz[] = {
> > {KHZ(100), 7, 10, 11, 26},
> > {KHZ(400), 2, 5, 12, 24},
> > {KHZ(1000), 1, 3, 9, 18},
> > };
> > +/* source_clock = 32 MHz */
> > +static const struct geni_i2c_clk_fld geni_i2c_clk_map_32mhz[] = {
> > + {KHZ(100), 7, 14, 18, 40},
> > + {KHZ(400), 4, 3, 11, 20},
> > + {KHZ(1000), 4, 3, 6, 15},
> > +};
> > +
> > static int geni_i2c_clk_map_idx(struct geni_i2c_dev *gi2c)
> > {
> > int i;
> > - const struct geni_i2c_clk_fld *itr = geni_i2c_clk_map;
> > + const struct geni_i2c_clk_fld *itr;
> > +
> > + if (clk_get_rate(gi2c->se.clk) == 32 * HZ_PER_MHZ)
> > + itr = geni_i2c_clk_map_32mhz;
> > + else
> > + itr = geni_i2c_clk_map_19p2mhz;
> > - for (i = 0; i < ARRAY_SIZE(geni_i2c_clk_map); i++, itr++) {
> > + for (i = 0; i < ARRAY_SIZE(geni_i2c_clk_map_19p2mhz); i++, itr++) {
> > if (itr->clk_freq_out == gi2c->clk_freq_out) {
> > gi2c->clk_fld = itr;
> > return 0;
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/1] i2c: qcom-geni: Support systems with 32MHz serial engine clock
2024-09-26 10:28 ` Vladimir Zapolskiy
@ 2024-09-26 12:48 ` Bjorn Andersson
2024-09-29 6:32 ` Manikanta Mylavarapu
2024-09-29 6:36 ` Manikanta Mylavarapu
1 sibling, 1 reply; 10+ messages in thread
From: Bjorn Andersson @ 2024-09-26 12:48 UTC (permalink / raw)
To: Vladimir Zapolskiy
Cc: Manikanta Mylavarapu, andi.shyti, linux-arm-msm, linux-i2c,
linux-kernel, quic_srichara, quic_varada
On Thu, Sep 26, 2024 at 01:28:37PM GMT, Vladimir Zapolskiy wrote:
> On 9/26/24 06:43, Manikanta Mylavarapu wrote:
> > diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
[..]
> > +
> > static int geni_i2c_clk_map_idx(struct geni_i2c_dev *gi2c)
> > {
> > int i;
> > - const struct geni_i2c_clk_fld *itr = geni_i2c_clk_map;
> > + const struct geni_i2c_clk_fld *itr;
> > +
> > + if (clk_get_rate(gi2c->se.clk) == 32 * HZ_PER_MHZ)
> > + itr = geni_i2c_clk_map_32mhz;
> > + else
> > + itr = geni_i2c_clk_map_19p2mhz;
> > - for (i = 0; i < ARRAY_SIZE(geni_i2c_clk_map); i++, itr++) {
> > + for (i = 0; i < ARRAY_SIZE(geni_i2c_clk_map_19p2mhz); i++, itr++) {
>
> Struct/data organization here is so weak, that here it's implicitly assumed
> that sizes of two arrays are equal. It could be kept as is of course, just
> pointing to it.
>
Thanks for pointing this out, Vladimir.
I'd prefer we fix it by adding a sentinel value to the arrays - because
this was only spotted due to the rename, the next guy will not be so
lucky.
Regards,
Bjorn
> > if (itr->clk_freq_out == gi2c->clk_freq_out) {
> > gi2c->clk_fld = itr;
> > return 0;
>
> --
> Best wishes,
> Vladimir
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/1] i2c: qcom-geni: Support systems with 32MHz serial engine clock
2024-09-26 12:48 ` Bjorn Andersson
@ 2024-09-29 6:32 ` Manikanta Mylavarapu
0 siblings, 0 replies; 10+ messages in thread
From: Manikanta Mylavarapu @ 2024-09-29 6:32 UTC (permalink / raw)
To: Bjorn Andersson, Vladimir Zapolskiy
Cc: andi.shyti, linux-arm-msm, linux-i2c, linux-kernel,
quic_srichara, quic_varada
On 9/26/2024 6:18 PM, Bjorn Andersson wrote:
> On Thu, Sep 26, 2024 at 01:28:37PM GMT, Vladimir Zapolskiy wrote:
>> On 9/26/24 06:43, Manikanta Mylavarapu wrote:
>>> diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
> [..]
>>> +
>>> static int geni_i2c_clk_map_idx(struct geni_i2c_dev *gi2c)
>>> {
>>> int i;
>>> - const struct geni_i2c_clk_fld *itr = geni_i2c_clk_map;
>>> + const struct geni_i2c_clk_fld *itr;
>>> +
>>> + if (clk_get_rate(gi2c->se.clk) == 32 * HZ_PER_MHZ)
>>> + itr = geni_i2c_clk_map_32mhz;
>>> + else
>>> + itr = geni_i2c_clk_map_19p2mhz;
>>> - for (i = 0; i < ARRAY_SIZE(geni_i2c_clk_map); i++, itr++) {
>>> + for (i = 0; i < ARRAY_SIZE(geni_i2c_clk_map_19p2mhz); i++, itr++) {
>>
>> Struct/data organization here is so weak, that here it's implicitly assumed
>> that sizes of two arrays are equal. It could be kept as is of course, just
>> pointing to it.
>>
>
> Thanks for pointing this out, Vladimir.
>
> I'd prefer we fix it by adding a sentinel value to the arrays - because
> this was only spotted due to the rename, the next guy will not be so
> lucky.
>
> Regards,
> Bjorn
>
Okay, sure.
Thanks & Regards,
Manikanta.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/1] i2c: qcom-geni: Support systems with 32MHz serial engine clock
2024-09-26 10:28 ` Vladimir Zapolskiy
2024-09-26 12:48 ` Bjorn Andersson
@ 2024-09-29 6:36 ` Manikanta Mylavarapu
2024-09-30 14:45 ` Manikanta Mylavarapu
1 sibling, 1 reply; 10+ messages in thread
From: Manikanta Mylavarapu @ 2024-09-29 6:36 UTC (permalink / raw)
To: Vladimir Zapolskiy, andi.shyti, linux-arm-msm, linux-i2c, linux-kernel
Cc: quic_srichara, quic_varada
On 9/26/2024 3:58 PM, Vladimir Zapolskiy wrote:
> Hello Manikanta.
>
> On 9/26/24 06:43, Manikanta Mylavarapu wrote:
>> 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 incorporate
>> the clock map table to derive the SCL clock from the 32MHz source
>> clock frequency.
>>
>> Signed-off-by: Manikanta Mylavarapu <quic_mmanikan@quicinc.com>
>> ---
>> Changes in v2:
>> - Dropped IPQ5424 from the commit title
>> - Added else part to assign geni_i2c_clk_map_19p2mhz to itr
>> - Dropped MHZ macro and used HZ_PER_MHZ macro
>> - Expanded SE to serial engine
>> - Added the reason for 32MHz clock in commit message
>>
>> drivers/i2c/busses/i2c-qcom-geni.c | 19 ++++++++++++++++---
>> 1 file changed, 16 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
>> index 212336f724a6..22f2a0d83641 100644
>> --- a/drivers/i2c/busses/i2c-qcom-geni.c
>> +++ b/drivers/i2c/busses/i2c-qcom-geni.c
>> @@ -16,6 +16,7 @@
>> #include <linux/pm_runtime.h>
>> #include <linux/soc/qcom/geni-se.h>
>> #include <linux/spinlock.h>
>> +#include <linux/units.h>
>> #define SE_I2C_TX_TRANS_LEN 0x26c
>> #define SE_I2C_RX_TRANS_LEN 0x270
>> @@ -146,18 +147,30 @@ struct geni_i2c_clk_fld {
>> * clk_freq_out = t / t_cycle
>> * source_clock = 19.2 MHz
>> */
>> -static const struct geni_i2c_clk_fld geni_i2c_clk_map[] = {
>> +static const struct geni_i2c_clk_fld geni_i2c_clk_map_19p2mhz[] = {
>> {KHZ(100), 7, 10, 11, 26},
>> {KHZ(400), 2, 5, 12, 24},
>> {KHZ(1000), 1, 3, 9, 18},
>> };
>> +/* source_clock = 32 MHz */
>> +static const struct geni_i2c_clk_fld geni_i2c_clk_map_32mhz[] = {
>> + {KHZ(100), 7, 14, 18, 40},
>> + {KHZ(400), 4, 3, 11, 20},
>> + {KHZ(1000), 4, 3, 6, 15},
>> +};
>
> Please double check the values.
>
> This is what I get:
> * for 100KHz: 32000000 / (40 * 7) ~ 114286, apparently 32000000 / (40 * 8) would
> be a better fit, however it's unclear what would be proper t_high / t_low values,
> * for 400KHz: it seems good,
> * for 1000KHz: 32000000 / (15 * 4) ~ 533333, which is almost 1/2 of the wanted
> bus frequency, so this one looks very wrong.
>
> Do you have any ideas how to get better bus frequency settings?
>
Thanks for pointing this out.
I will double check and get back with the proper data.
Thanks & Regards,
Manikanta.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/1] i2c: qcom-geni: Support systems with 32MHz serial engine clock
2024-09-29 6:36 ` Manikanta Mylavarapu
@ 2024-09-30 14:45 ` Manikanta Mylavarapu
2024-10-03 7:51 ` Vladimir Zapolskiy
0 siblings, 1 reply; 10+ messages in thread
From: Manikanta Mylavarapu @ 2024-09-30 14:45 UTC (permalink / raw)
To: Vladimir Zapolskiy, andi.shyti, linux-arm-msm, linux-i2c, linux-kernel
Cc: quic_srichara, quic_varada
On 9/29/2024 12:06 PM, Manikanta Mylavarapu wrote:
>
>
> On 9/26/2024 3:58 PM, Vladimir Zapolskiy wrote:
>> Hello Manikanta.
>>
>> On 9/26/24 06:43, Manikanta Mylavarapu wrote:
>>> 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 incorporate
>>> the clock map table to derive the SCL clock from the 32MHz source
>>> clock frequency.
>>>
>>> Signed-off-by: Manikanta Mylavarapu <quic_mmanikan@quicinc.com>
>>> ---
>>> Changes in v2:
>>> - Dropped IPQ5424 from the commit title
>>> - Added else part to assign geni_i2c_clk_map_19p2mhz to itr
>>> - Dropped MHZ macro and used HZ_PER_MHZ macro
>>> - Expanded SE to serial engine
>>> - Added the reason for 32MHz clock in commit message
>>>
>>> drivers/i2c/busses/i2c-qcom-geni.c | 19 ++++++++++++++++---
>>> 1 file changed, 16 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
>>> index 212336f724a6..22f2a0d83641 100644
>>> --- a/drivers/i2c/busses/i2c-qcom-geni.c
>>> +++ b/drivers/i2c/busses/i2c-qcom-geni.c
>>> @@ -16,6 +16,7 @@
>>> #include <linux/pm_runtime.h>
>>> #include <linux/soc/qcom/geni-se.h>
>>> #include <linux/spinlock.h>
>>> +#include <linux/units.h>
>>> #define SE_I2C_TX_TRANS_LEN 0x26c
>>> #define SE_I2C_RX_TRANS_LEN 0x270
>>> @@ -146,18 +147,30 @@ struct geni_i2c_clk_fld {
>>> * clk_freq_out = t / t_cycle
>>> * source_clock = 19.2 MHz
>>> */
>>> -static const struct geni_i2c_clk_fld geni_i2c_clk_map[] = {
>>> +static const struct geni_i2c_clk_fld geni_i2c_clk_map_19p2mhz[] = {
>>> {KHZ(100), 7, 10, 11, 26},
>>> {KHZ(400), 2, 5, 12, 24},
>>> {KHZ(1000), 1, 3, 9, 18},
>>> };
>>> +/* source_clock = 32 MHz */
>>> +static const struct geni_i2c_clk_fld geni_i2c_clk_map_32mhz[] = {
>>> + {KHZ(100), 7, 14, 18, 40},
>>> + {KHZ(400), 4, 3, 11, 20},
>>> + {KHZ(1000), 4, 3, 6, 15},
>>> +};
>>
>> Please double check the values.
>>
>> This is what I get:
>> * for 100KHz: 32000000 / (40 * 7) ~ 114286, apparently 32000000 / (40 * 8) would
>> be a better fit, however it's unclear what would be proper t_high / t_low values,
>> * for 400KHz: it seems good,
>> * for 1000KHz: 32000000 / (15 * 4) ~ 533333, which is almost 1/2 of the wanted
>> bus frequency, so this one looks very wrong.
>>
>> Do you have any ideas how to get better bus frequency settings?
>>
>
> Thanks for pointing this out.
>
> I will double check and get back with the proper data.
>
> Thanks & Regards,
> Manikanta.
>
Based on Qualcomm's internal hardware programming guide, below values need to be used for 100K & 1000K.
{KHZ(100), 8, 14, 18, 40}
{KHZ(1000), 2, 3, 6, 15}
I will update these values in next version.
Thanks & Regards,
Manikanta.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/1] i2c: qcom-geni: Support systems with 32MHz serial engine clock
2024-09-30 14:45 ` Manikanta Mylavarapu
@ 2024-10-03 7:51 ` Vladimir Zapolskiy
0 siblings, 0 replies; 10+ messages in thread
From: Vladimir Zapolskiy @ 2024-10-03 7:51 UTC (permalink / raw)
To: Manikanta Mylavarapu, andi.shyti, linux-arm-msm, linux-i2c, linux-kernel
Cc: quic_srichara, quic_varada
On 9/30/24 17:45, Manikanta Mylavarapu wrote:
>
>
> On 9/29/2024 12:06 PM, Manikanta Mylavarapu wrote:
>>
>>
>> On 9/26/2024 3:58 PM, Vladimir Zapolskiy wrote:
>>> Hello Manikanta.
>>>
>>> On 9/26/24 06:43, Manikanta Mylavarapu wrote:
>>>> 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 incorporate
>>>> the clock map table to derive the SCL clock from the 32MHz source
>>>> clock frequency.
>>>>
>>>> Signed-off-by: Manikanta Mylavarapu <quic_mmanikan@quicinc.com>
>>>> ---
>>>> Changes in v2:
>>>> - Dropped IPQ5424 from the commit title
>>>> - Added else part to assign geni_i2c_clk_map_19p2mhz to itr
>>>> - Dropped MHZ macro and used HZ_PER_MHZ macro
>>>> - Expanded SE to serial engine
>>>> - Added the reason for 32MHz clock in commit message
>>>>
>>>> drivers/i2c/busses/i2c-qcom-geni.c | 19 ++++++++++++++++---
>>>> 1 file changed, 16 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
>>>> index 212336f724a6..22f2a0d83641 100644
>>>> --- a/drivers/i2c/busses/i2c-qcom-geni.c
>>>> +++ b/drivers/i2c/busses/i2c-qcom-geni.c
>>>> @@ -16,6 +16,7 @@
>>>> #include <linux/pm_runtime.h>
>>>> #include <linux/soc/qcom/geni-se.h>
>>>> #include <linux/spinlock.h>
>>>> +#include <linux/units.h>
>>>> #define SE_I2C_TX_TRANS_LEN 0x26c
>>>> #define SE_I2C_RX_TRANS_LEN 0x270
>>>> @@ -146,18 +147,30 @@ struct geni_i2c_clk_fld {
>>>> * clk_freq_out = t / t_cycle
>>>> * source_clock = 19.2 MHz
>>>> */
>>>> -static const struct geni_i2c_clk_fld geni_i2c_clk_map[] = {
>>>> +static const struct geni_i2c_clk_fld geni_i2c_clk_map_19p2mhz[] = {
>>>> {KHZ(100), 7, 10, 11, 26},
>>>> {KHZ(400), 2, 5, 12, 24},
>>>> {KHZ(1000), 1, 3, 9, 18},
>>>> };
>>>> +/* source_clock = 32 MHz */
>>>> +static const struct geni_i2c_clk_fld geni_i2c_clk_map_32mhz[] = {
>>>> + {KHZ(100), 7, 14, 18, 40},
>>>> + {KHZ(400), 4, 3, 11, 20},
>>>> + {KHZ(1000), 4, 3, 6, 15},
>>>> +};
>>>
>>> Please double check the values.
>>>
>>> This is what I get:
>>> * for 100KHz: 32000000 / (40 * 7) ~ 114286, apparently 32000000 / (40 * 8) would
>>> be a better fit, however it's unclear what would be proper t_high / t_low values,
>>> * for 400KHz: it seems good,
>>> * for 1000KHz: 32000000 / (15 * 4) ~ 533333, which is almost 1/2 of the wanted
>>> bus frequency, so this one looks very wrong.
>>>
>>> Do you have any ideas how to get better bus frequency settings?
>>>
>>
>> Thanks for pointing this out.
>>
>> I will double check and get back with the proper data.
>>
>> Thanks & Regards,
>> Manikanta.
>>
>
> Based on Qualcomm's internal hardware programming guide, below values need to be used for 100K & 1000K.
> {KHZ(100), 8, 14, 18, 40}
> {KHZ(1000), 2, 3, 6, 15}
>
> I will update these values in next version.
Great! These values make much more sence, thank you.
--
Best wishes,
Vladimir
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-10-03 7:51 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-26 3:43 [PATCH v2 1/1] i2c: qcom-geni: Support systems with 32MHz serial engine clock Manikanta Mylavarapu
2024-09-26 6:14 ` Mukesh Kumar Savaliya
2024-09-26 7:43 ` Manikanta Mylavarapu
2024-09-26 12:44 ` Bjorn Andersson
2024-09-26 10:28 ` Vladimir Zapolskiy
2024-09-26 12:48 ` Bjorn Andersson
2024-09-29 6:32 ` Manikanta Mylavarapu
2024-09-29 6:36 ` Manikanta Mylavarapu
2024-09-30 14:45 ` Manikanta Mylavarapu
2024-10-03 7:51 ` Vladimir Zapolskiy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®