Skip to contentSkip to conversation

i2c: mediatek: Fix generic definitions for bus frequencies

PATCH In review [email protected] 4 participants 5 messages Sep 12, 2020 – Sep 18, 2020

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 i2c: mediatek: Fix generic definitions for bus frequencies

From: Qii Wang <[email protected]>

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.

---
 drivers/i2c/busses/i2c-mt65xx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-mt65xx.c +3 -3
index efc1404..0cbdfbe 100644
@@ -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,
Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · On Sat, 2020-09-12 at 13:57 +0800, [email protected] wrote:

From: Qii Wang <[email protected]>

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.

Joe.C

Quoted 30 lines
---
 drivers/i2c/busses/i2c-mt65xx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-mt65xx.c +3 -3
index efc1404..0cbdfbe 100644
@@ -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,
#2 lore raw
In reply to [email protected]
Quoted 17 lines · On Sat, Sep 12, 2020 at 9:02 AM <[email protected]> wrote:

From: Qii Wang <[email protected]>

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.

---
 drivers/i2c/busses/i2c-mt65xx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-mt65xx.c +0 -0
index efc1404..0cbdfbe 100644

drivers/i2c/busses/i2c-mt65xx.c static int mtk_i2c_calculate_speed(struct mtk_i2c *i2c, unsigned int clk_src, · line 685

Quoted 7 lines
drivers/i2c/busses/i2c-mt65xx.c +2 -2
@@ -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.

drivers/i2c/busses/i2c-mt65xx.c static int mtk_i2c_set_speed(struct mtk_i2c *i2c, unsigned int parent_clk) · line 762

Quoted 9 lines
drivers/i2c/busses/i2c-mt65xx.c +1 -1
        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.

Quoted 5 lines
drivers/i2c/busses/i2c-mt65xx.c +0 -1
                        /* Set master code speed register */
                        ret = mtk_i2c_calculate_speed(i2c, clk_src,
                                                      I2C_MAX_FAST_MODE_FREQ,
--

1.9.1

Signature · 7 lines
With Best Regards,
Andy Shevchenko

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
author maintainer
#3 lore raw
Quoted 40 lines · Andy Shevchenko
Quoted 17 lines · On Sat, Sep 12, 2020 at 9:02 AM <[email protected]> wrote:

From: Qii Wang <[email protected]>

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.

---
 drivers/i2c/busses/i2c-mt65xx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-mt65xx.c +0 -0
index efc1404..0cbdfbe 100644

drivers/i2c/busses/i2c-mt65xx.c static int mtk_i2c_calculate_speed(struct mtk_i2c *i2c, unsigned int clk_src, · line 685

Quoted 7 lines
drivers/i2c/busses/i2c-mt65xx.c +2 -2
@@ -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.

drivers/i2c/busses/i2c-mt65xx.c static int mtk_i2c_set_speed(struct mtk_i2c *i2c, unsigned int parent_clk) · line 762

Quoted 9 lines
drivers/i2c/busses/i2c-mt65xx.c +1 -1
        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

Quoted 8 lines

#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

Quoted 8 lines
Quoted 5 lines
drivers/i2c/busses/i2c-mt65xx.c +0 -1
                        /* Set master code speed register */
                        ret = mtk_i2c_calculate_speed(i2c, clk_src,
                                                      I2C_MAX_FAST_MODE_FREQ,
--

1.9.1

#4 lore raw
In reply to Andy Shevchenko
Quoted 7 lines

drivers/i2c/busses/i2c-mt65xx.c static int mtk_i2c_calculate_speed(struct mtk_i2c *i2c, unsigned int clk_src, · line 685

Quoted 5 lines
drivers/i2c/busses/i2c-mt65xx.c +2 -2
-       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!