Re: [PATCH V2 4/7] i2c: sprd: Add I2C controller driver to support dynamic switching of 400K/1M/3.4M frequency

Andi Shyti
2023-10-24T21:28:56Z

Hi Huangzheng,

On Mon, Oct 23, 2023 at 04:11:55PM +0800, Huangzheng Lai wrote:
> When I2C-slaves supporting different frequencies use the same I2C
> controller, the I2C controller usually only operates at lower frequencies.
> In order to improve the performance of I2C-slaves transmission supporting
> faster frequencies, we dynamically configure the I2C operating frequency
> based on the value of the input parameter msg ->flag.
>
> Signed-off-by: Huangzheng Lai <Huangzheng.Lai@unisoc.com>
> ---
> drivers/i2c/busses/i2c-sprd.c | 101 +++++++++++++++++++---------------
> 1 file changed, 57 insertions(+), 44 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-sprd.c b/drivers/i2c/busses/i2c-sprd.c
> index dec627ef408c..f1f7fad42ecd 100644
> --- a/drivers/i2c/busses/i2c-sprd.c
> +++ b/drivers/i2c/busses/i2c-sprd.c
> @@ -75,7 +75,14 @@
> #define SPRD_I2C_PM_TIMEOUT 1000
> /* timeout (ms) for transfer message */
> #define I2C_XFER_TIMEOUT 1000
> -
> +/* dynamic modify clk_freq flag */
> +#define I2C_3M4_FLAG 0x0100
> +#define I2C_1M_FLAG 0x0080
> +#define I2C_400K_FLAG 0x0040
> +
> +#define I2C_FREQ_400K 400000
> +#define I2C_FREQ_1M 1000000
> +#define I2C_FREQ_3_4M 3400000

Why are you redefining these values?

You could use the defines you already have or, if you really want
a different name you could do:

#define I2C_FREQ_3_4M I2C_MAX_HIGH_SPEED_MODE_FREQ

Rest looks good.

Andi