linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: mediatek: Fix generic definitions for bus frequencies
@ 2020-09-12  5:57 qii.wang
  2020-09-13 15:15 ` Yingjoe Chen
  2020-09-14 12:48 ` Andy Shevchenko
  0 siblings, 2 replies; 5+ messages in thread
From: qii.wang @ 2020-09-12  5:57 UTC (permalink / raw)
  To: wsa
  Cc: linux-i2c, devicetree, linux-arm-kernel, linux-kernel,
	linux-mediatek, srv_heupstream, leilk.liu, qii.wang

From: Qii Wang <qii.wang@mediatek.com>

The master code needs to being sent when the speed is more than
I2C_MAX_FAST_MODE_PLUS_FREQ instead of
I2C_MAX_HIGH_SPEED_MODE_FREQ. Fix it.

Signed-off-by: Qii Wang <qii.wang@mediatek.com>
---
 drivers/i2c/busses/i2c-mt65xx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
index efc1404..0cbdfbe 100644
--- a/drivers/i2c/busses/i2c-mt65xx.c
+++ b/drivers/i2c/busses/i2c-mt65xx.c
@@ -681,8 +681,8 @@ static int mtk_i2c_calculate_speed(struct mtk_i2c *i2c, unsigned int clk_src,
 	unsigned int cnt_mul;
 	int ret = -EINVAL;
 
-	if (target_speed > I2C_MAX_FAST_MODE_PLUS_FREQ)
-		target_speed = I2C_MAX_FAST_MODE_PLUS_FREQ;
+	if (target_speed > I2C_MAX_HIGH_SPEED_MODE_FREQ)
+		target_speed = I2C_MAX_HIGH_SPEED_MODE_FREQ;
 
 	max_step_cnt = mtk_i2c_max_step_cnt(target_speed);
 	base_step_cnt = max_step_cnt;
@@ -759,7 +759,7 @@ static int mtk_i2c_set_speed(struct mtk_i2c *i2c, unsigned int parent_clk)
 	for (clk_div = 1; clk_div <= max_clk_div; clk_div++) {
 		clk_src = parent_clk / clk_div;
 
-		if (target_speed > I2C_MAX_FAST_MODE_FREQ) {
+		if (target_speed > I2C_MAX_FAST_MODE_PLUS_FREQ) {
 			/* Set master code speed register */
 			ret = mtk_i2c_calculate_speed(i2c, clk_src,
 						      I2C_MAX_FAST_MODE_FREQ,
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] i2c: mediatek: Fix generic definitions for bus frequencies
  2020-09-12  5:57 [PATCH] i2c: mediatek: Fix generic definitions for bus frequencies qii.wang
@ 2020-09-13 15:15 ` Yingjoe Chen
  2020-09-14 12:48 ` Andy Shevchenko
  1 sibling, 0 replies; 5+ messages in thread
From: Yingjoe Chen @ 2020-09-13 15:15 UTC (permalink / raw)
  To: qii.wang
  Cc: wsa, devicetree, srv_heupstream, leilk.liu, linux-kernel,
	linux-mediatek, linux-i2c, linux-arm-kernel, Andy Shevchenko

On Sat, 2020-09-12 at 13:57 +0800, qii.wang@mediatek.com wrote:
> From: Qii Wang <qii.wang@mediatek.com>
> 
> The master code needs to being sent when the speed is more than
> I2C_MAX_FAST_MODE_PLUS_FREQ instead of
> I2C_MAX_HIGH_SPEED_MODE_FREQ. Fix it.

This was introduced by "i2c: drivers: Use generic definitions for bus
frequencies". You should have
Fixes: 90224e6468e1 ("i2c: drivers: Use generic definitions for bus
frequencies")

You can have my reviewed by after you add fixes.
Reviewed-by: Yingjoe Chen <yingjoe.chen@mediatek.com>

Joe.C

> 
> Signed-off-by: Qii Wang <qii.wang@mediatek.com>
> ---
>  drivers/i2c/busses/i2c-mt65xx.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
> index efc1404..0cbdfbe 100644
> --- a/drivers/i2c/busses/i2c-mt65xx.c
> +++ b/drivers/i2c/busses/i2c-mt65xx.c
> @@ -681,8 +681,8 @@ static int mtk_i2c_calculate_speed(struct mtk_i2c *i2c, unsigned int clk_src,
>  	unsigned int cnt_mul;
>  	int ret = -EINVAL;
>  
> -	if (target_speed > I2C_MAX_FAST_MODE_PLUS_FREQ)
> -		target_speed = I2C_MAX_FAST_MODE_PLUS_FREQ;
> +	if (target_speed > I2C_MAX_HIGH_SPEED_MODE_FREQ)
> +		target_speed = I2C_MAX_HIGH_SPEED_MODE_FREQ;
>  
>  	max_step_cnt = mtk_i2c_max_step_cnt(target_speed);
>  	base_step_cnt = max_step_cnt;
> @@ -759,7 +759,7 @@ static int mtk_i2c_set_speed(struct mtk_i2c *i2c, unsigned int parent_clk)
>  	for (clk_div = 1; clk_div <= max_clk_div; clk_div++) {
>  		clk_src = parent_clk / clk_div;
>  
> -		if (target_speed > I2C_MAX_FAST_MODE_FREQ) {
> +		if (target_speed > I2C_MAX_FAST_MODE_PLUS_FREQ) {
>  			/* Set master code speed register */
>  			ret = mtk_i2c_calculate_speed(i2c, clk_src,
>  						      I2C_MAX_FAST_MODE_FREQ,


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] i2c: mediatek: Fix generic definitions for bus frequencies
  2020-09-12  5:57 [PATCH] i2c: mediatek: Fix generic definitions for bus frequencies qii.wang
  2020-09-13 15:15 ` Yingjoe Chen
@ 2020-09-14 12:48 ` Andy Shevchenko
  2020-09-15  1:24   ` Qii Wang
  2020-09-18 20:45   ` Wolfram Sang
  1 sibling, 2 replies; 5+ messages in thread
From: Andy Shevchenko @ 2020-09-14 12:48 UTC (permalink / raw)
  To: qii.wang
  Cc: Wolfram Sang, linux-i2c, devicetree, linux-arm Mailing List,
	Linux Kernel Mailing List,
	moderated list:ARM/Mediatek SoC support, srv_heupstream,
	Leilk Liu

On Sat, Sep 12, 2020 at 9:02 AM <qii.wang@mediatek.com> wrote:
>
> From: Qii Wang <qii.wang@mediatek.com>
>
> The master code needs to being sent when the speed is more than
> I2C_MAX_FAST_MODE_PLUS_FREQ instead of
> I2C_MAX_HIGH_SPEED_MODE_FREQ. Fix it.
>
> Signed-off-by: Qii Wang <qii.wang@mediatek.com>
> ---
>  drivers/i2c/busses/i2c-mt65xx.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
> index efc1404..0cbdfbe 100644
> --- a/drivers/i2c/busses/i2c-mt65xx.c
> +++ b/drivers/i2c/busses/i2c-mt65xx.c
> @@ -681,8 +681,8 @@ static int mtk_i2c_calculate_speed(struct mtk_i2c *i2c, unsigned int clk_src,
>         unsigned int cnt_mul;
>         int ret = -EINVAL;
>
> -       if (target_speed > I2C_MAX_FAST_MODE_PLUS_FREQ)
> -               target_speed = I2C_MAX_FAST_MODE_PLUS_FREQ;
> +       if (target_speed > I2C_MAX_HIGH_SPEED_MODE_FREQ)
> +               target_speed = I2C_MAX_HIGH_SPEED_MODE_FREQ;

Thanks for fixing this. Indeed, somehow I messed these up.

>
>         max_step_cnt = mtk_i2c_max_step_cnt(target_speed);
>         base_step_cnt = max_step_cnt;
> @@ -759,7 +759,7 @@ static int mtk_i2c_set_speed(struct mtk_i2c *i2c, unsigned int parent_clk)
>         for (clk_div = 1; clk_div <= max_clk_div; clk_div++) {
>                 clk_src = parent_clk / clk_div;
>
> -               if (target_speed > I2C_MAX_FAST_MODE_FREQ) {
> +               if (target_speed > I2C_MAX_FAST_MODE_PLUS_FREQ) {

But this one is not related. Original code used to have

#define MAX_FS_MODE_SPEED              400000

       if (target_speed > MAX_FS_MODE_SPEED) {

And this change doesn't fix the above mentioned problem.

So, please split into two separate changes.

>                         /* Set master code speed register */
>                         ret = mtk_i2c_calculate_speed(i2c, clk_src,
>                                                       I2C_MAX_FAST_MODE_FREQ,
> --
> 1.9.1



-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] i2c: mediatek: Fix generic definitions for bus frequencies
  2020-09-14 12:48 ` Andy Shevchenko
@ 2020-09-15  1:24   ` Qii Wang
  2020-09-18 20:45   ` Wolfram Sang
  1 sibling, 0 replies; 5+ messages in thread
From: Qii Wang @ 2020-09-15  1:24 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Wolfram Sang, linux-i2c, devicetree, linux-arm Mailing List,
	Linux Kernel Mailing List,
	moderated list:ARM/Mediatek SoC support, srv_heupstream,
	Leilk Liu

On Mon, 2020-09-14 at 15:48 +0300, Andy Shevchenko wrote:
> On Sat, Sep 12, 2020 at 9:02 AM <qii.wang@mediatek.com> wrote:
> >
> > From: Qii Wang <qii.wang@mediatek.com>
> >
> > The master code needs to being sent when the speed is more than
> > I2C_MAX_FAST_MODE_PLUS_FREQ instead of
> > I2C_MAX_HIGH_SPEED_MODE_FREQ. Fix it.
> >
> > Signed-off-by: Qii Wang <qii.wang@mediatek.com>
> > ---
> >  drivers/i2c/busses/i2c-mt65xx.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
> > index efc1404..0cbdfbe 100644
> > --- a/drivers/i2c/busses/i2c-mt65xx.c
> > +++ b/drivers/i2c/busses/i2c-mt65xx.c
> > @@ -681,8 +681,8 @@ static int mtk_i2c_calculate_speed(struct mtk_i2c *i2c, unsigned int clk_src,
> >         unsigned int cnt_mul;
> >         int ret = -EINVAL;
> >
> > -       if (target_speed > I2C_MAX_FAST_MODE_PLUS_FREQ)
> > -               target_speed = I2C_MAX_FAST_MODE_PLUS_FREQ;
> > +       if (target_speed > I2C_MAX_HIGH_SPEED_MODE_FREQ)
> > +               target_speed = I2C_MAX_HIGH_SPEED_MODE_FREQ;
> 
> Thanks for fixing this. Indeed, somehow I messed these up.
> 
> >
> >         max_step_cnt = mtk_i2c_max_step_cnt(target_speed);
> >         base_step_cnt = max_step_cnt;
> > @@ -759,7 +759,7 @@ static int mtk_i2c_set_speed(struct mtk_i2c *i2c, unsigned int parent_clk)
> >         for (clk_div = 1; clk_div <= max_clk_div; clk_div++) {
> >                 clk_src = parent_clk / clk_div;
> >
> > -               if (target_speed > I2C_MAX_FAST_MODE_FREQ) {
> > +               if (target_speed > I2C_MAX_FAST_MODE_PLUS_FREQ) {
> 
> But this one is not related. Original code used to have
> 
> #define MAX_FS_MODE_SPEED              400000
> 
>        if (target_speed > MAX_FS_MODE_SPEED) {
> 
> And this change doesn't fix the above mentioned problem.
> 
> So, please split into two separate changes.
> 

ok, Thank you for your comments

> >                         /* Set master code speed register */
> >                         ret = mtk_i2c_calculate_speed(i2c, clk_src,
> >                                                       I2C_MAX_FAST_MODE_FREQ,
> > --
> > 1.9.1
> 
> 
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] i2c: mediatek: Fix generic definitions for bus frequencies
  2020-09-14 12:48 ` Andy Shevchenko
  2020-09-15  1:24   ` Qii Wang
@ 2020-09-18 20:45   ` Wolfram Sang
  1 sibling, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2020-09-18 20:45 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: qii.wang, linux-i2c, devicetree, linux-arm Mailing List,
	Linux Kernel Mailing List,
	moderated list:ARM/Mediatek SoC support, srv_heupstream,
	Leilk Liu

[-- Attachment #1: Type: text/plain, Size: 365 bytes --]


> > -       if (target_speed > I2C_MAX_FAST_MODE_PLUS_FREQ)
> > -               target_speed = I2C_MAX_FAST_MODE_PLUS_FREQ;
> > +       if (target_speed > I2C_MAX_HIGH_SPEED_MODE_FREQ)
> > +               target_speed = I2C_MAX_HIGH_SPEED_MODE_FREQ;
> 
> Thanks for fixing this. Indeed, somehow I messed these up.

I read this as Rev-by for v2. Thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-09-18 20:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-12  5:57 [PATCH] i2c: mediatek: Fix generic definitions for bus frequencies qii.wang
2020-09-13 15:15 ` Yingjoe Chen
2020-09-14 12:48 ` Andy Shevchenko
2020-09-15  1:24   ` Qii Wang
2020-09-18 20:45   ` 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).