[PATCH v2 2/2] i2c: amlogic: Add Amlogic A9 I2C controller driver

Markus Elfring Markus.Elfring at web.de
Mon Oct 26 10:28:40 PDT 2026


…
> +++ b/drivers/i2c/busses/i2c-amlogic-a9.c
> @@ -0,0 +1,469 @@
…

How do you think about to avoid a bit of duplicate source code?


…
> +static void aml_i2c_prepare_xfer(struct aml_i2c *i2c, enum fifo_fill_mode mode)
> +{
…
> +	if (mode == A9_FIFO_FILL_FULL)
> +		i2c->count = min(i2c->msg->len - i2c->pos, A9_I2C_FIFO_DEPTH);
> +	else
> +		i2c->count = min(i2c->msg->len - i2c->pos, A9_I2C_HALF_FIFO);
…

+	i2c->count = min(i2c->msg->len - i2c->pos,
+			 (mode == A9_FIFO_FILL_FULL ? A9_I2C_FIFO_DEPTH : A9_I2C_HALF_FIFO));


…
> +static int aml_i2c_xfer_msg(struct aml_i2c *i2c, struct i2c_msg *msg, bool last)
> +{
…
> +	if (last)
> +		aml_i2c_set_mask(i2c, REG_CFG_BUS, BUS_NO_STOP, 0);
> +	else
> +		aml_i2c_set_mask(i2c, REG_CFG_BUS, BUS_NO_STOP, BUS_NO_STOP);
…

+	aml_i2c_set_mask(i2c, REG_CFG_BUS, BUS_NO_STOP, (last ? 0 : BUS_NO_STOP));


Regards,
Markus



More information about the linux-amlogic mailing list