* [PATCH] i2c: exynos5: simplify timings calculation
[not found] <CGME20170223164733eucas1p11ad37a2334fe709a062ecc82b5224e1a@eucas1p1.samsung.com>
@ 2017-02-23 16:47 ` Andrzej Hajda
2017-04-03 10:06 ` Andrzej Hajda
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Andrzej Hajda @ 2017-02-23 16:47 UTC (permalink / raw)
To: Wolfram Sang, Krzysztof Kozlowski, Javier Martinez Canillas,
linux-i2c, linux-samsung-soc
Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski
Instead of using cryptic loop direct calculation of timings
can be used.
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
drivers/i2c/busses/i2c-exynos5.c | 40 ++++++++++++++--------------------------
1 file changed, 14 insertions(+), 26 deletions(-)
diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-exynos5.c
index cbd93ce..04127b8 100644
--- a/drivers/i2c/busses/i2c-exynos5.c
+++ b/drivers/i2c/busses/i2c-exynos5.c
@@ -292,9 +292,9 @@ static int exynos5_i2c_set_timing(struct exynos5_i2c *i2c, int mode)
unsigned int t_sr_release;
unsigned int t_ftl_cycle;
unsigned int clkin = clk_get_rate(i2c->clk);
- unsigned int div, utemp0 = 0, utemp1 = 0, clk_cycle;
unsigned int op_clk = (mode == HSI2C_HIGH_SPD) ?
i2c->hs_clock : i2c->fs_clock;
+ int div, clk_cycle, temp;
/*
* In case of HSI2C controller in Exynos5 series
@@ -305,33 +305,21 @@ static int exynos5_i2c_set_timing(struct exynos5_i2c *i2c, int mode)
* FPCLK / FI2C =
* (CLK_DIV + 1) * (TSCLK_L + TSCLK_H + 2) + 8 + FLT_CYCLE
*
- * utemp0 = (CLK_DIV + 1) * (TSCLK_L + TSCLK_H + 2)
- * utemp1 = (TSCLK_L + TSCLK_H + 2)
+ * clk_cycle := TSCLK_L + TSCLK_H
+ * temp := (CLK_DIV + 1) * (clk_cycle + 2)
+ *
+ * Constraints: 4 <= temp, 0 <= CLK_DIV < 256, 2 <= clk_cycle <= 510
+ *
*/
t_ftl_cycle = (readl(i2c->regs + HSI2C_CONF) >> 16) & 0x7;
- utemp0 = (clkin / op_clk) - 8;
-
- if (i2c->variant->hw == HSI2C_EXYNOS7)
- utemp0 -= t_ftl_cycle;
- else
- utemp0 -= 2 * t_ftl_cycle;
-
- /* CLK_DIV max is 256 */
- for (div = 0; div < 256; div++) {
- utemp1 = utemp0 / (div + 1);
-
- /*
- * SCL_L and SCL_H each has max value of 255
- * Hence, For the clk_cycle to the have right value
- * utemp1 has to be less then 512 and more than 4.
- */
- if ((utemp1 < 512) && (utemp1 > 4)) {
- clk_cycle = utemp1 - 2;
- break;
- } else if (div == 255) {
- dev_warn(i2c->dev, "Failed to calculate divisor");
- return -EINVAL;
- }
+ temp = clkin / op_clk - 8 - t_ftl_cycle;
+ if (i2c->variant->hw != HSI2C_EXYNOS7)
+ temp -= t_ftl_cycle;
+ div = temp / 512;
+ clk_cycle = temp / (div + 1) - 2;
+ if (temp < 4 || div >= 256 || clk_cycle < 2) {
+ dev_warn(i2c->dev, "Failed to calculate divisor");
+ return -EINVAL;
}
t_scl_l = clk_cycle / 2;
--
2.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] i2c: exynos5: simplify timings calculation
2017-02-23 16:47 ` [PATCH] i2c: exynos5: simplify timings calculation Andrzej Hajda
@ 2017-04-03 10:06 ` Andrzej Hajda
2017-04-14 9:24 ` Andrzej Hajda
2017-04-21 12:04 ` Wolfram Sang
2 siblings, 0 replies; 10+ messages in thread
From: Andrzej Hajda @ 2017-04-03 10:06 UTC (permalink / raw)
To: Wolfram Sang, Krzysztof Kozlowski, Javier Martinez Canillas,
linux-i2c, linux-samsung-soc
Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski
Hi Wolfram,
Gently ping.
Regards
Andrzej
On 23.02.2017 17:47, Andrzej Hajda wrote:
> Instead of using cryptic loop direct calculation of timings
> can be used.
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
> drivers/i2c/busses/i2c-exynos5.c | 40 ++++++++++++++--------------------------
> 1 file changed, 14 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-exynos5.c
> index cbd93ce..04127b8 100644
> --- a/drivers/i2c/busses/i2c-exynos5.c
> +++ b/drivers/i2c/busses/i2c-exynos5.c
> @@ -292,9 +292,9 @@ static int exynos5_i2c_set_timing(struct exynos5_i2c *i2c, int mode)
> unsigned int t_sr_release;
> unsigned int t_ftl_cycle;
> unsigned int clkin = clk_get_rate(i2c->clk);
> - unsigned int div, utemp0 = 0, utemp1 = 0, clk_cycle;
> unsigned int op_clk = (mode == HSI2C_HIGH_SPD) ?
> i2c->hs_clock : i2c->fs_clock;
> + int div, clk_cycle, temp;
>
> /*
> * In case of HSI2C controller in Exynos5 series
> @@ -305,33 +305,21 @@ static int exynos5_i2c_set_timing(struct exynos5_i2c *i2c, int mode)
> * FPCLK / FI2C =
> * (CLK_DIV + 1) * (TSCLK_L + TSCLK_H + 2) + 8 + FLT_CYCLE
> *
> - * utemp0 = (CLK_DIV + 1) * (TSCLK_L + TSCLK_H + 2)
> - * utemp1 = (TSCLK_L + TSCLK_H + 2)
> + * clk_cycle := TSCLK_L + TSCLK_H
> + * temp := (CLK_DIV + 1) * (clk_cycle + 2)
> + *
> + * Constraints: 4 <= temp, 0 <= CLK_DIV < 256, 2 <= clk_cycle <= 510
> + *
> */
> t_ftl_cycle = (readl(i2c->regs + HSI2C_CONF) >> 16) & 0x7;
> - utemp0 = (clkin / op_clk) - 8;
> -
> - if (i2c->variant->hw == HSI2C_EXYNOS7)
> - utemp0 -= t_ftl_cycle;
> - else
> - utemp0 -= 2 * t_ftl_cycle;
> -
> - /* CLK_DIV max is 256 */
> - for (div = 0; div < 256; div++) {
> - utemp1 = utemp0 / (div + 1);
> -
> - /*
> - * SCL_L and SCL_H each has max value of 255
> - * Hence, For the clk_cycle to the have right value
> - * utemp1 has to be less then 512 and more than 4.
> - */
> - if ((utemp1 < 512) && (utemp1 > 4)) {
> - clk_cycle = utemp1 - 2;
> - break;
> - } else if (div == 255) {
> - dev_warn(i2c->dev, "Failed to calculate divisor");
> - return -EINVAL;
> - }
> + temp = clkin / op_clk - 8 - t_ftl_cycle;
> + if (i2c->variant->hw != HSI2C_EXYNOS7)
> + temp -= t_ftl_cycle;
> + div = temp / 512;
> + clk_cycle = temp / (div + 1) - 2;
> + if (temp < 4 || div >= 256 || clk_cycle < 2) {
> + dev_warn(i2c->dev, "Failed to calculate divisor");
> + return -EINVAL;
> }
>
> t_scl_l = clk_cycle / 2;
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] i2c: exynos5: simplify timings calculation
2017-02-23 16:47 ` [PATCH] i2c: exynos5: simplify timings calculation Andrzej Hajda
2017-04-03 10:06 ` Andrzej Hajda
@ 2017-04-14 9:24 ` Andrzej Hajda
2017-04-19 19:17 ` Wolfram Sang
2017-04-21 12:04 ` Wolfram Sang
2 siblings, 1 reply; 10+ messages in thread
From: Andrzej Hajda @ 2017-04-14 9:24 UTC (permalink / raw)
To: Wolfram Sang, Krzysztof Kozlowski, Javier Martinez Canillas,
linux-i2c, linux-samsung-soc
Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski
Hi Wolfram,
Ping, 7 weeks passed.
Regards
Andrzej
On 23.02.2017 17:47, Andrzej Hajda wrote:
> Instead of using cryptic loop direct calculation of timings
> can be used.
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
> drivers/i2c/busses/i2c-exynos5.c | 40 ++++++++++++++--------------------------
> 1 file changed, 14 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-exynos5.c
> index cbd93ce..04127b8 100644
> --- a/drivers/i2c/busses/i2c-exynos5.c
> +++ b/drivers/i2c/busses/i2c-exynos5.c
> @@ -292,9 +292,9 @@ static int exynos5_i2c_set_timing(struct exynos5_i2c *i2c, int mode)
> unsigned int t_sr_release;
> unsigned int t_ftl_cycle;
> unsigned int clkin = clk_get_rate(i2c->clk);
> - unsigned int div, utemp0 = 0, utemp1 = 0, clk_cycle;
> unsigned int op_clk = (mode == HSI2C_HIGH_SPD) ?
> i2c->hs_clock : i2c->fs_clock;
> + int div, clk_cycle, temp;
>
> /*
> * In case of HSI2C controller in Exynos5 series
> @@ -305,33 +305,21 @@ static int exynos5_i2c_set_timing(struct exynos5_i2c *i2c, int mode)
> * FPCLK / FI2C =
> * (CLK_DIV + 1) * (TSCLK_L + TSCLK_H + 2) + 8 + FLT_CYCLE
> *
> - * utemp0 = (CLK_DIV + 1) * (TSCLK_L + TSCLK_H + 2)
> - * utemp1 = (TSCLK_L + TSCLK_H + 2)
> + * clk_cycle := TSCLK_L + TSCLK_H
> + * temp := (CLK_DIV + 1) * (clk_cycle + 2)
> + *
> + * Constraints: 4 <= temp, 0 <= CLK_DIV < 256, 2 <= clk_cycle <= 510
> + *
> */
> t_ftl_cycle = (readl(i2c->regs + HSI2C_CONF) >> 16) & 0x7;
> - utemp0 = (clkin / op_clk) - 8;
> -
> - if (i2c->variant->hw == HSI2C_EXYNOS7)
> - utemp0 -= t_ftl_cycle;
> - else
> - utemp0 -= 2 * t_ftl_cycle;
> -
> - /* CLK_DIV max is 256 */
> - for (div = 0; div < 256; div++) {
> - utemp1 = utemp0 / (div + 1);
> -
> - /*
> - * SCL_L and SCL_H each has max value of 255
> - * Hence, For the clk_cycle to the have right value
> - * utemp1 has to be less then 512 and more than 4.
> - */
> - if ((utemp1 < 512) && (utemp1 > 4)) {
> - clk_cycle = utemp1 - 2;
> - break;
> - } else if (div == 255) {
> - dev_warn(i2c->dev, "Failed to calculate divisor");
> - return -EINVAL;
> - }
> + temp = clkin / op_clk - 8 - t_ftl_cycle;
> + if (i2c->variant->hw != HSI2C_EXYNOS7)
> + temp -= t_ftl_cycle;
> + div = temp / 512;
> + clk_cycle = temp / (div + 1) - 2;
> + if (temp < 4 || div >= 256 || clk_cycle < 2) {
> + dev_warn(i2c->dev, "Failed to calculate divisor");
> + return -EINVAL;
> }
>
> t_scl_l = clk_cycle / 2;
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] i2c: exynos5: simplify timings calculation
2017-04-14 9:24 ` Andrzej Hajda
@ 2017-04-19 19:17 ` Wolfram Sang
2017-04-19 19:36 ` Javier Martinez Canillas
2017-04-20 0:45 ` Andi Shyti
0 siblings, 2 replies; 10+ messages in thread
From: Wolfram Sang @ 2017-04-19 19:17 UTC (permalink / raw)
To: Andrzej Hajda
Cc: Krzysztof Kozlowski, Javier Martinez Canillas, linux-i2c,
linux-samsung-soc, Bartlomiej Zolnierkiewicz, Marek Szyprowski
[-- Attachment #1: Type: text/plain, Size: 511 bytes --]
On Fri, Apr 14, 2017 at 11:24:16AM +0200, Andrzej Hajda wrote:
> Hi Wolfram,
>
> Ping, 7 weeks passed.
Known issue, there are not enough reviewers for I2C for a timely
response. I was hoping for some tags from other users of this hardware,
but that didn't happen. And I don't know this hardware, at all. So, I'll
apply your patches early in the next cycle, and we will see what happens
once they are in -next. Best would be if you could find other people to
donate tags.
Thanks,
Wolfram
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] i2c: exynos5: simplify timings calculation
2017-04-19 19:17 ` Wolfram Sang
@ 2017-04-19 19:36 ` Javier Martinez Canillas
2017-04-19 19:42 ` Wolfram Sang
2017-04-20 0:45 ` Andi Shyti
1 sibling, 1 reply; 10+ messages in thread
From: Javier Martinez Canillas @ 2017-04-19 19:36 UTC (permalink / raw)
To: Wolfram Sang, Andrzej Hajda
Cc: Krzysztof Kozlowski, linux-i2c, linux-samsung-soc,
Bartlomiej Zolnierkiewicz, Marek Szyprowski
Hello Wolfram,
On 04/19/2017 03:17 PM, Wolfram Sang wrote:
> On Fri, Apr 14, 2017 at 11:24:16AM +0200, Andrzej Hajda wrote:
>> Hi Wolfram,
>>
>> Ping, 7 weeks passed.
>
> Known issue, there are not enough reviewers for I2C for a timely
> response. I was hoping for some tags from other users of this hardware,
> but that didn't happen. And I don't know this hardware, at all. So, I'll
> apply your patches early in the next cycle, and we will see what happens
> once they are in -next. Best would be if you could find other people to
> donate tags.
>
I got a try to this patch on an Exynos5800 Peach Pi Chromebook and all
the I2C devices are working properly, so:
Tested-by: Javier Martinez Canillas <javier@osg.samsung.com>
> Thanks,
>
> Wolfram
>
Best regards,
--
Javier Martinez Canillas
Open Source Group
Samsung Research America
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] i2c: exynos5: simplify timings calculation
2017-04-19 19:36 ` Javier Martinez Canillas
@ 2017-04-19 19:42 ` Wolfram Sang
0 siblings, 0 replies; 10+ messages in thread
From: Wolfram Sang @ 2017-04-19 19:42 UTC (permalink / raw)
To: Javier Martinez Canillas
Cc: Andrzej Hajda, Krzysztof Kozlowski, linux-i2c, linux-samsung-soc,
Bartlomiej Zolnierkiewicz, Marek Szyprowski
[-- Attachment #1: Type: text/plain, Size: 986 bytes --]
On Wed, Apr 19, 2017 at 03:36:39PM -0400, Javier Martinez Canillas wrote:
> Hello Wolfram,
>
> On 04/19/2017 03:17 PM, Wolfram Sang wrote:
> > On Fri, Apr 14, 2017 at 11:24:16AM +0200, Andrzej Hajda wrote:
> >> Hi Wolfram,
> >>
> >> Ping, 7 weeks passed.
> >
> > Known issue, there are not enough reviewers for I2C for a timely
> > response. I was hoping for some tags from other users of this hardware,
> > but that didn't happen. And I don't know this hardware, at all. So, I'll
> > apply your patches early in the next cycle, and we will see what happens
> > once they are in -next. Best would be if you could find other people to
> > donate tags.
> >
>
> I got a try to this patch on an Exynos5800 Peach Pi Chromebook and all
> the I2C devices are working properly, so:
>
> Tested-by: Javier Martinez Canillas <javier@osg.samsung.com>
Cool, can you test his other patches as well?
http://patchwork.ozlabs.org/project/linux-i2c/list/?submitter=47122
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] i2c: exynos5: simplify timings calculation
2017-04-19 19:17 ` Wolfram Sang
2017-04-19 19:36 ` Javier Martinez Canillas
@ 2017-04-20 0:45 ` Andi Shyti
2017-04-20 6:42 ` Wolfram Sang
1 sibling, 1 reply; 10+ messages in thread
From: Andi Shyti @ 2017-04-20 0:45 UTC (permalink / raw)
To: Wolfram Sang
Cc: Andrzej Hajda, Krzysztof Kozlowski, Javier Martinez Canillas,
linux-i2c, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
Marek Szyprowski
Hi Andrzej,
> > Ping, 7 weeks passed.
>
> Known issue, there are not enough reviewers for I2C for a timely
> response. I was hoping for some tags from other users of this hardware,
> but that didn't happen. And I don't know this hardware, at all. So, I'll
> apply your patches early in the next cycle, and we will see what happens
> once they are in -next. Best would be if you could find other people to
> donate tags.
I'm sorry, I forgot to reply to this patch, I actually reviewed
and tested it among all your i2c patches (that's why I asked you
on IRC to add me in Cc to all your i2c patches).
So you can add also my
Reviewed-by: Andi Shyti <andi.shyti@samsung.com>
Andi
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] i2c: exynos5: simplify timings calculation
2017-04-20 0:45 ` Andi Shyti
@ 2017-04-20 6:42 ` Wolfram Sang
2017-04-24 2:07 ` Andi Shyti
0 siblings, 1 reply; 10+ messages in thread
From: Wolfram Sang @ 2017-04-20 6:42 UTC (permalink / raw)
To: Andi Shyti
Cc: Andrzej Hajda, Krzysztof Kozlowski, Javier Martinez Canillas,
linux-i2c, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
Marek Szyprowski
[-- Attachment #1: Type: text/plain, Size: 304 bytes --]
> I'm sorry, I forgot to reply to this patch, I actually reviewed
> and tested it among all your i2c patches
You mean you reviewed all his i2c patches? If so, could you add the tag
per patch. This way, patchwork will automatically collect them for me
and display the tag count in the list of patches.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] i2c: exynos5: simplify timings calculation
2017-02-23 16:47 ` [PATCH] i2c: exynos5: simplify timings calculation Andrzej Hajda
2017-04-03 10:06 ` Andrzej Hajda
2017-04-14 9:24 ` Andrzej Hajda
@ 2017-04-21 12:04 ` Wolfram Sang
2 siblings, 0 replies; 10+ messages in thread
From: Wolfram Sang @ 2017-04-21 12:04 UTC (permalink / raw)
To: Andrzej Hajda
Cc: Krzysztof Kozlowski, Javier Martinez Canillas, linux-i2c,
linux-samsung-soc, Bartlomiej Zolnierkiewicz, Marek Szyprowski
[-- Attachment #1: Type: text/plain, Size: 235 bytes --]
On Thu, Feb 23, 2017 at 05:47:26PM +0100, Andrzej Hajda wrote:
> Instead of using cryptic loop direct calculation of timings
> can be used.
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] i2c: exynos5: simplify timings calculation
2017-04-20 6:42 ` Wolfram Sang
@ 2017-04-24 2:07 ` Andi Shyti
0 siblings, 0 replies; 10+ messages in thread
From: Andi Shyti @ 2017-04-24 2:07 UTC (permalink / raw)
To: Wolfram Sang
Cc: Andrzej Hajda, Krzysztof Kozlowski, Javier Martinez Canillas,
linux-i2c, linux-samsung-soc, Bartlomiej Zolnierkiewicz,
Marek Szyprowski
Hi Wolfram,
> > I'm sorry, I forgot to reply to this patch, I actually reviewed
> > and tested it among all your i2c patches
>
> You mean you reviewed all his i2c patches? If so, could you add the tag
> per patch. This way, patchwork will automatically collect them for me
> and display the tag count in the list of patches.
yes, I reviewed, tested and used all the patches that Andrzej
has recently sent to the i2c-exynos driver. For all of them I
replied with my Reviewed-by, apparently I forgot to send the
reply to this one.
Andi
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2017-04-24 2:07 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20170223164733eucas1p11ad37a2334fe709a062ecc82b5224e1a@eucas1p1.samsung.com>
2017-02-23 16:47 ` [PATCH] i2c: exynos5: simplify timings calculation Andrzej Hajda
2017-04-03 10:06 ` Andrzej Hajda
2017-04-14 9:24 ` Andrzej Hajda
2017-04-19 19:17 ` Wolfram Sang
2017-04-19 19:36 ` Javier Martinez Canillas
2017-04-19 19:42 ` Wolfram Sang
2017-04-20 0:45 ` Andi Shyti
2017-04-20 6:42 ` Wolfram Sang
2017-04-24 2:07 ` Andi Shyti
2017-04-21 12:04 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).