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

Message ID 20200224151530.31713-36-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: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/busses/i2c-synquacer.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Ard Biesheuvel Feb. 24, 2020, 3:18 p.m. UTC | #1
On Mon, 24 Feb 2020 at 16:15, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> Since we have generic definitions for bus frequencies, let's use them.
>
> Cc: Ard Biesheuvel <ardb@kernel.org>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Acked-by: Ard Biesheuvel <ardb@kernel.org>

> ---
>  drivers/i2c/busses/i2c-synquacer.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-synquacer.c b/drivers/i2c/busses/i2c-synquacer.c
> index 86026798b4f7..ccd2ed4fa2f1 100644
> --- a/drivers/i2c/busses/i2c-synquacer.c
> +++ b/drivers/i2c/busses/i2c-synquacer.c
> @@ -67,10 +67,10 @@
>
>  /* STANDARD MODE frequency */
>  #define SYNQUACER_I2C_CLK_MASTER_STD(rate)                     \
> -       DIV_ROUND_UP(DIV_ROUND_UP((rate), 100000) - 2, 2)
> +       DIV_ROUND_UP(DIV_ROUND_UP((rate), I2C_STANDARD_MODE_FREQ) - 2, 2)
>  /* FAST MODE frequency */
>  #define SYNQUACER_I2C_CLK_MASTER_FAST(rate)                    \
> -       DIV_ROUND_UP((DIV_ROUND_UP((rate), 400000) - 2) * 2, 3)
> +       DIV_ROUND_UP((DIV_ROUND_UP((rate), I2C_FAST_MODE_FREQ) - 2) * 2, 3)
>
>  /* (clkrate <= 18000000) */
>  /* calculate the value of CS bits in CCR register on standard mode */
> @@ -111,11 +111,11 @@
>                                         & SYNQUACER_I2C_CSR_CS_MASK)
>
>  /* min I2C clock frequency 14M */
> -#define SYNQUACER_I2C_MIN_CLK_RATE     (14 * 1000000)
> +#define SYNQUACER_I2C_MIN_CLK_RATE     (14 * HZ_PER_MHZ)
>  /* max I2C clock frequency 200M */
> -#define SYNQUACER_I2C_MAX_CLK_RATE     (200 * 1000000)
> +#define SYNQUACER_I2C_MAX_CLK_RATE     (200 * HZ_PER_MHZ)
>  /* I2C clock frequency 18M */
> -#define SYNQUACER_I2C_CLK_RATE_18M     (18 * 1000000)
> +#define SYNQUACER_I2C_CLK_RATE_18M     (18 * HZ_PER_MHZ)
>
>  #define SYNQUACER_I2C_SPEED_FM         400     // Fast Mode
>  #define SYNQUACER_I2C_SPEED_SM         100     // Standard Mode
> @@ -602,7 +602,7 @@ static int synquacer_i2c_probe(struct platform_device *pdev)
>         i2c->adapter.nr = pdev->id;
>         init_completion(&i2c->completion);
>
> -       if (bus_speed < 400000)
> +       if (bus_speed < I2C_FAST_MODE_FREQ)
>                 i2c->speed_khz = SYNQUACER_I2C_SPEED_SM;
>         else
>                 i2c->speed_khz = SYNQUACER_I2C_SPEED_FM;
> --
> 2.25.0
>

Patch
diff mbox series

diff --git a/drivers/i2c/busses/i2c-synquacer.c b/drivers/i2c/busses/i2c-synquacer.c
index 86026798b4f7..ccd2ed4fa2f1 100644
--- a/drivers/i2c/busses/i2c-synquacer.c
+++ b/drivers/i2c/busses/i2c-synquacer.c
@@ -67,10 +67,10 @@ 
 
 /* STANDARD MODE frequency */
 #define SYNQUACER_I2C_CLK_MASTER_STD(rate)			\
-	DIV_ROUND_UP(DIV_ROUND_UP((rate), 100000) - 2, 2)
+	DIV_ROUND_UP(DIV_ROUND_UP((rate), I2C_STANDARD_MODE_FREQ) - 2, 2)
 /* FAST MODE frequency */
 #define SYNQUACER_I2C_CLK_MASTER_FAST(rate)			\
-	DIV_ROUND_UP((DIV_ROUND_UP((rate), 400000) - 2) * 2, 3)
+	DIV_ROUND_UP((DIV_ROUND_UP((rate), I2C_FAST_MODE_FREQ) - 2) * 2, 3)
 
 /* (clkrate <= 18000000) */
 /* calculate the value of CS bits in CCR register on standard mode */
@@ -111,11 +111,11 @@ 
 					& SYNQUACER_I2C_CSR_CS_MASK)
 
 /* min I2C clock frequency 14M */
-#define SYNQUACER_I2C_MIN_CLK_RATE	(14 * 1000000)
+#define SYNQUACER_I2C_MIN_CLK_RATE	(14 * HZ_PER_MHZ)
 /* max I2C clock frequency 200M */
-#define SYNQUACER_I2C_MAX_CLK_RATE	(200 * 1000000)
+#define SYNQUACER_I2C_MAX_CLK_RATE	(200 * HZ_PER_MHZ)
 /* I2C clock frequency 18M */
-#define SYNQUACER_I2C_CLK_RATE_18M	(18 * 1000000)
+#define SYNQUACER_I2C_CLK_RATE_18M	(18 * HZ_PER_MHZ)
 
 #define SYNQUACER_I2C_SPEED_FM		400	// Fast Mode
 #define SYNQUACER_I2C_SPEED_SM		100	// Standard Mode
@@ -602,7 +602,7 @@  static int synquacer_i2c_probe(struct platform_device *pdev)
 	i2c->adapter.nr = pdev->id;
 	init_completion(&i2c->completion);
 
-	if (bus_speed < 400000)
+	if (bus_speed < I2C_FAST_MODE_FREQ)
 		i2c->speed_khz = SYNQUACER_I2C_SPEED_SM;
 	else
 		i2c->speed_khz = SYNQUACER_I2C_SPEED_FM;