[v1,31/40] i2c: spdr: Use generic definitions for bus frequencies
diff mbox series

Message ID 20200224151530.31713-31-andriy.shevchenko@linux.intel.com
State Superseded
Headers show
Series
  • [v1,01/40] i2c: qup: Move bus frequency definitions to i2c.h
Related show

Commit Message

Andy Shevchenko Feb. 24, 2020, 3:15 p.m. UTC
Since we have generic definitions for bus frequencies, let's use them.

Cc: Orson Zhai <orsonzhai@gmail.com>
Cc: Baolin Wang <baolin.wang7@gmail.com>
Cc: Chunyan Zhang <zhang.lyra@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/busses/i2c-sprd.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Baolin Wang Feb. 25, 2020, 12:49 a.m. UTC | #1
Hi Andy,

On Mon, Feb 24, 2020 at 11:15 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> Since we have generic definitions for bus frequencies, let's use them.
>
> Cc: Orson Zhai <orsonzhai@gmail.com>
> Cc: Baolin Wang <baolin.wang7@gmail.com>
> Cc: Chunyan Zhang <zhang.lyra@gmail.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Can you fix the typo in the subject line by changing 'spdr' to 'sprd'?
Otherwise looks good to me. Thanks.
Reviewed-by: Baolin Wang <baolin.wang7@gmail.com>

> ---
>  drivers/i2c/busses/i2c-sprd.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-sprd.c b/drivers/i2c/busses/i2c-sprd.c
> index b432e7580458..4eb3ad1e5ab5 100644
> --- a/drivers/i2c/busses/i2c-sprd.c
> +++ b/drivers/i2c/busses/i2c-sprd.c
> @@ -337,9 +337,9 @@ static void sprd_i2c_set_clk(struct sprd_i2c *i2c_dev, u32 freq)
>         writel(div1, i2c_dev->base + ADDR_DVD1);
>
>         /* Start hold timing = hold time(us) * source clock */
> -       if (freq == 400000)
> +       if (freq == I2C_FAST_MODE_FREQ)
>                 writel((6 * apb_clk) / 10000000, i2c_dev->base + ADDR_STA0_DVD);
> -       else if (freq == 100000)
> +       else if (freq == I2C_STANDARD_MODE_FREQ)
>                 writel((4 * apb_clk) / 1000000, i2c_dev->base + ADDR_STA0_DVD);
>  }
>
> @@ -502,7 +502,7 @@ static int sprd_i2c_probe(struct platform_device *pdev)
>         snprintf(i2c_dev->adap.name, sizeof(i2c_dev->adap.name),
>                  "%s", "sprd-i2c");
>
> -       i2c_dev->bus_freq = 100000;
> +       i2c_dev->bus_freq = I2C_STANDARD_MODE_FREQ;
>         i2c_dev->adap.owner = THIS_MODULE;
>         i2c_dev->dev = dev;
>         i2c_dev->adap.retries = 3;
> @@ -516,7 +516,8 @@ static int sprd_i2c_probe(struct platform_device *pdev)
>                 i2c_dev->bus_freq = prop;
>
>         /* We only support 100k and 400k now, otherwise will return error. */
> -       if (i2c_dev->bus_freq != 100000 && i2c_dev->bus_freq != 400000)
> +       if (i2c_dev->bus_freq != I2C_STANDARD_MODE_FREQ &&
> +           i2c_dev->bus_freq != I2C_FAST_MODE_FREQ)
>                 return -EINVAL;
>
>         ret = sprd_i2c_clk_init(i2c_dev);
> --
> 2.25.0
>
Andy Shevchenko Feb. 25, 2020, 10:38 a.m. UTC | #2
On Tue, Feb 25, 2020 at 08:49:24AM +0800, Baolin Wang wrote:
> On Mon, Feb 24, 2020 at 11:15 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > Since we have generic definitions for bus frequencies, let's use them.
> >
> > Cc: Orson Zhai <orsonzhai@gmail.com>
> > Cc: Baolin Wang <baolin.wang7@gmail.com>
> > Cc: Chunyan Zhang <zhang.lyra@gmail.com>
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> Can you fix the typo in the subject line by changing 'spdr' to 'sprd'?

Sure.

> Otherwise looks good to me. Thanks.
> Reviewed-by: Baolin Wang <baolin.wang7@gmail.com>

Thanks!

Patch
diff mbox series

diff --git a/drivers/i2c/busses/i2c-sprd.c b/drivers/i2c/busses/i2c-sprd.c
index b432e7580458..4eb3ad1e5ab5 100644
--- a/drivers/i2c/busses/i2c-sprd.c
+++ b/drivers/i2c/busses/i2c-sprd.c
@@ -337,9 +337,9 @@  static void sprd_i2c_set_clk(struct sprd_i2c *i2c_dev, u32 freq)
 	writel(div1, i2c_dev->base + ADDR_DVD1);
 
 	/* Start hold timing = hold time(us) * source clock */
-	if (freq == 400000)
+	if (freq == I2C_FAST_MODE_FREQ)
 		writel((6 * apb_clk) / 10000000, i2c_dev->base + ADDR_STA0_DVD);
-	else if (freq == 100000)
+	else if (freq == I2C_STANDARD_MODE_FREQ)
 		writel((4 * apb_clk) / 1000000, i2c_dev->base + ADDR_STA0_DVD);
 }
 
@@ -502,7 +502,7 @@  static int sprd_i2c_probe(struct platform_device *pdev)
 	snprintf(i2c_dev->adap.name, sizeof(i2c_dev->adap.name),
 		 "%s", "sprd-i2c");
 
-	i2c_dev->bus_freq = 100000;
+	i2c_dev->bus_freq = I2C_STANDARD_MODE_FREQ;
 	i2c_dev->adap.owner = THIS_MODULE;
 	i2c_dev->dev = dev;
 	i2c_dev->adap.retries = 3;
@@ -516,7 +516,8 @@  static int sprd_i2c_probe(struct platform_device *pdev)
 		i2c_dev->bus_freq = prop;
 
 	/* We only support 100k and 400k now, otherwise will return error. */
-	if (i2c_dev->bus_freq != 100000 && i2c_dev->bus_freq != 400000)
+	if (i2c_dev->bus_freq != I2C_STANDARD_MODE_FREQ &&
+	    i2c_dev->bus_freq != I2C_FAST_MODE_FREQ)
 		return -EINVAL;
 
 	ret = sprd_i2c_clk_init(i2c_dev);