Re: [PATCH v6] i2c: imx: add slave support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Zhang Ying,

On 11/12/2018 08:34 AM, Zhang Ying-22455 wrote:
> From: Joshua Frkuska <joshua_frkuska@xxxxxxxxxx>
> 
> This patch adds hardware supported slave-mode with master arbitration
> via the i2c generic slave interface. This allows master transactions
> to be supported while a slave-mode device is in idle.
> 
> To enable this functionality enable i2c slave support.
> 
> CONFIG_I2C_SLAVE=y
> 
> If i2c-slave support is not enabled in the kernel config, we support
> master-mode only and the slave-mode support is not compiled in.
> 
> A queue backed event-driven state machine is implemented in order to
> handle events in the order they occur in the hardware. The states
> for the most part follow the logic charts in the imx reference manual
> 
> Signed-off-by: Maxim Syrchin <msyrchin@xxxxxxxxxxxxx>
> [joshua_frkuska@xxxxxxxxxx: Reworked patchset for upstream submission]
> Signed-off-by: Joshua Frkuska <joshua_frkuska@xxxxxxxxxx>
> Signed-off-by: Zhang Ying-22455 <ying.zhang22455@xxxxxxx>

[snip]

> +static int i2c_imx_reg_slave(struct i2c_client *slave)
> +{
> +	struct imx_i2c_struct *i2c_imx = i2c_get_adapdata(slave->adapter);
> +	int result;
> +	struct sched_param param = { .sched_priority = MAX_RT_PRIO - 1 };
> +
> +	dev_dbg(&i2c_imx->adapter.dev, "<%s>\n", __func__);
> +
> +	if (i2c_imx->slave)
> +		return -EBUSY;
> +
> +	if (slave->flags & I2C_CLIENT_TEN)
> +		return -EAFNOSUPPORT;
> +
> +	i2c_imx->slave = slave;
> +
> +	/* Set the Slave address */
> +	imx_i2c_write_reg((i2c_imx->slave->addr << 1), i2c_imx, IMX_I2C_IADR);
> +	result = i2c_imx_hw_start(i2c_imx);
> +	if (result)
> +		return result;
> +
> +	i2c_imx->slave_task = kthread_run(i2c_imx_slave_threadfn,
> +					  i2c_imx, "i2c-slave-%s",
> +					  i2c_imx->adapter.name);
> +
> +	if (IS_ERR(i2c_imx->slave_task))
> +		return PTR_ERR(i2c_imx->slave_task);
> +
> +	sched_setscheduler(i2c_imx->slave_task, SCHED_FIFO, &param);

kernel thread priority setting done by a kernel driver is NAKed, because it
affects the whole running system and thus it shall (as implied by "it can")
be done on a higher level, for instance from userspace.

Decisively remove sched_setscheduler() call from the change.

> +
> +	i2c_imx_slave_init(i2c_imx);
> +
> +	return 0;
> +}
> +

--
Best wishes,
Vladimir



[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux