i3c: master: some improvment for i3c master
Subsystems (3)
Frank Li
maintainerv5 cover i3c: master: some improvment for i3c master
There are three major improvement
1. Add actual size in i3c_transfer because i3c allow target early termiate transfer.
2. Add API for i3c_dev_gettstatus_format1 for i3c comand GET_STATUS.
3. svc master support hotjoin
Change log see each patches
Frank Li (6):
i3c: master: add enable(disable) hot join in sys entry
i3c: master: svc: add hot join support
i3c: add actual_len in i3c_priv_xfer
i3c: master: svc: rename read_len as actual_len
i3c: master: svc: return actual transfer data len
i3c: add API i3c_dev_gettstatus_format1() to get target device status
drivers/i3c/device.c | 24 ++++++ drivers/i3c/internals.h | 1 + drivers/i3c/master.c | 109 ++++++++++++++++++++++++++++ drivers/i3c/master/svc-i3c-master.c | 95 +++++++++++++++++++----- include/linux/i3c/device.h | 3 + include/linux/i3c/master.h | 5 ++ 6 files changed, 220 insertions(+), 17 deletions(-)
Signature · 1 line
2.34.1
Frank Li
maintainerPATCH RESEND v5 1/6 i3c: master: add enable(disable) hot join in sys entry
Add hotjoin entry in sys file system allow user enable/disable hotjoin feature.
Add (*enable(disable)_hotjoin)() to i3c_master_controller_ops. Add api i3c_master_enable(disable)_hotjoin();
---
Notes:
Change from v4 to v5
- using kstrtobool()
> + if (!master ||
> + !master->ops ||
> + !master->ops->enable_hotjoin ||
> + !master->ops->disable_hotjoin
> + )
break into two if, which will be more clear. and one line is 101 chars.
Change from v3 to v4
-none
Change from v1 to v2.
- Hotjoin control by sys entry, default enable hotjoin, which standard i3c feature, user can disable by echo 0 > /sys/bus/i3c/i3c-0/hotjoin
drivers/i3c/master.c | 83 ++++++++++++++++++++++++++++++++++++++ include/linux/i3c/master.h | 5 +++ 2 files changed, 88 insertions(+)
drivers/i3c/master.c +83 -0
@@ -526,6 +526,88 @@ static ssize_t i2c_scl_frequency_show(struct device *dev, }static DEVICE_ATTR_RO (i2c_scl_frequency); +static int i3c_set_hotjoin (struct i3c_master_controller *master,bool enable) +{ +int ret; + +if (!master || !master->ops) +return -EINVAL ; + +if (!master->ops->enable_hotjoin || !master->ops->disable_hotjoin) +return -EINVAL ; + +i3c_bus_normaluse_lock (&master->bus); + +if (enable) + ret = master->ops->enable_hotjoin (master); +else + ret = master->ops->disable_hotjoin (master); + + master->hotjoin = enable; + +i3c_bus_normaluse_unlock (&master->bus); + +return ret; +} + +static ssize_t hotjoin_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) +{ +struct i3c_bus *i3cbus =dev_to_i3cbus (dev); +int ret; +bool res; + +if (!i3cbus->cur_master) +return -EINVAL ; + +if (kstrtobool (buf, &res)) +return -EINVAL ; + + ret =i3c_set_hotjoin (i3cbus->cur_master->common.master, res); +if (ret) +return ret; + +return count; +} + +/* +* i3c_master_enable_hotjoin - Enable hotjoin +* @master: I3C master object +* +* Return: a 0 in case of success, an negative error code otherwise. +*/ +int i3c_master_enable_hotjoin (struct i3c_master_controller *master) +{ +return i3c_set_hotjoin (master, true); +} +EXPORT_SYMBOL_GPL (i3c_master_enable_hotjoin); + +/* +* i3c_master_disable_hotjoin - Disable hotjoin +* @master: I3C master object +* +* Return: a 0 in case of success, an negative error code otherwise. +*/ +int i3c_master_disable_hotjoin (struct i3c_master_controller *master) +{ +return i3c_set_hotjoin (master, false); +} +EXPORT_SYMBOL_GPL (i3c_master_disable_hotjoin); + +static ssize_t hotjoin_show (struct device *dev,struct device_attribute *da,char *buf) +{ +struct i3c_bus *i3cbus =dev_to_i3cbus (dev); +ssize_t ret; + +i3c_bus_normaluse_lock (i3cbus); + ret =sysfs_emit (buf,"%d\n" , i3cbus->cur_master->common.master->hotjoin); +i3c_bus_normaluse_unlock (i3cbus); + +return ret; +} + +static DEVICE_ATTR_RW (hotjoin); +static struct attribute *i3c_masterdev_attrs[] = { &dev_attr_mode.attr, &dev_attr_current_master.attr,
@@ -536,6 +618,7 @@ static struct attribute *i3c_masterdev_attrs[] = { &dev_attr_pid.attr, &dev_attr_dynamic_address.attr, &dev_attr_hdrcap.attr, + &dev_attr_hotjoin.attr,NULL , };ATTRIBUTE_GROUPS (i3c_masterdev);
include/linux/i3c/master.h +5 -0
@@ -452,6 +452,8 @@ struct i3c_master_controller_ops {int (*disable_ibi)(struct i3c_dev_desc *dev);void (*recycle_ibi_slot)(struct i3c_dev_desc *dev,struct i3c_ibi_slot *slot); +int (*enable_hotjoin)(struct i3c_master_controller *master); +int (*disable_hotjoin)(struct i3c_master_controller *master); };/**
@@ -487,6 +489,7 @@ struct i3c_master_controller {const struct i3c_master_controller_ops *ops; unsigned int secondary : 1; unsigned int init_done : 1; + unsigned int hotjoin: 1;struct {struct list_head i3c;struct list_head i2c;
@@ -543,6 +546,8 @@ int i3c_master_register(struct i3c_master_controller *master,const struct i3c_master_controller_ops *ops, bool secondary);void i3c_master_unregister (struct i3c_master_controller *master); +int i3c_master_enable_hotjoin (struct i3c_master_controller *master); +int i3c_master_disable_hotjoin (struct i3c_master_controller *master);/** * i3c_dev_get_master_data() - get master private data attached to an I3C
Signature · 1 line
2.34.1
Frank Li
maintainerPATCH RESEND v5 2/6 i3c: master: svc: add hot join support
In reply to Frank LiAdd hot join support for svc master controller. Disable hot join defaultly. User can use sys entry to enable hot join.
---
Notes:
Change from v4 to v5
- default disable hotjoin
- add help func is_events_enabled()
Change from v3 to v4
-fix build warning
All warnings (new ones prefixed by >>):
drivers/i3c/master/svc-i3c-master.c:212: warning: Function parameter or member 'lock' not described in 'svc_i3c_master'
>> drivers/i3c/master/svc-i3c-master.c:212: warning: Function parameter or member 'enabled_events' not described in 'svc_i3c_master'
2 warnings as Errors
drivers/i3c/master/svc-i3c-master.c | 61 +++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 4 deletions(-)
drivers/i3c/master/svc-i3c-master.c +57 -4
@@ -128,6 +128,9 @@/* This parameter depends on the implementation and may be tuned */ #define SVC_I3C_FIFO_SIZE 16 +#define SVC_I3C_EVENT_IBI BIT(0) +#define SVC_I3C_EVENT_HOTJOIN BIT(1) +struct svc_i3c_cmd {u8 addr;bool rnw;
@@ -176,6 +179,7 @@ struct svc_i3c_regs_save {* @ibi.tbq_slot: To be queued IBI slot * @ibi.lock: IBI lock * @lock: Transfer lock, protect between IBI work thread and callbacks from master +* @enabled_events: Bit masks for enable events (IBI, HotJoin). */ struct svc_i3c_master {struct i3c_master_controller base;
@@ -205,6 +209,7 @@ struct svc_i3c_master {spinlock_t lock; } ibi;struct mutex lock; +int enabled_events; };/**
@@ -219,6 +224,11 @@ struct svc_i3c_i2c_dev_data {struct i3c_generic_ibi_pool *ibi_pool; }; +static inline bool is_events_enabled (struct svc_i3c_master *master,u32 mask) +{ +return !!(master->enabled_events & mask); +} +static bool svc_i3c_master_error (struct svc_i3c_master *master) {u32 mstatus, merrwarn;
@@ -428,13 +438,16 @@ static void svc_i3c_master_ibi_work(struct work_struct *work)switch (ibitype) {case SVC_I3C_MSTATUS_IBITYPE_IBI : dev =svc_i3c_master_dev_from_addr (master, ibiaddr); -if (!dev) +if (!dev || !is_events_enabled (master,SVC_I3C_EVENT_IBI ))svc_i3c_master_nack_ibi (master);else svc_i3c_master_handle_ibi (master, dev);break ;case SVC_I3C_MSTATUS_IBITYPE_HOT_JOIN : -svc_i3c_master_ack_ibi (master, false); +if (is_events_enabled (master,SVC_I3C_EVENT_HOTJOIN )) +svc_i3c_master_ack_ibi (master, false); +else +svc_i3c_master_nack_ibi (master);break ;case SVC_I3C_MSTATUS_IBITYPE_MASTER_REQUEST :svc_i3c_master_nack_ibi (master);
@@ -471,7 +484,9 @@ static void svc_i3c_master_ibi_work(struct work_struct *work)svc_i3c_master_emit_stop (master);break ;case SVC_I3C_MSTATUS_IBITYPE_HOT_JOIN : -queue_work (master->base.wq, &master->hj_work); +svc_i3c_master_emit_stop (master); +if (is_events_enabled (master,SVC_I3C_EVENT_HOTJOIN )) +queue_work (master->base.wq, &master->hj_work);break ;case SVC_I3C_MSTATUS_IBITYPE_MASTER_REQUEST :default :
@@ -1471,6 +1486,7 @@ static int svc_i3c_master_enable_ibi(struct i3c_dev_desc *dev)return ret; } + master->enabled_events |=SVC_I3C_EVENT_IBI ;svc_i3c_master_enable_interrupts (master,SVC_I3C_MINT_SLVSTART );return i3c_master_enec_locked (m, dev->info.dyn_addr,I3C_CCC_EVENT_SIR );
@@ -1482,7 +1498,9 @@ static int svc_i3c_master_disable_ibi(struct i3c_dev_desc *dev)struct svc_i3c_master *master =to_svc_i3c_master (m);int ret; -svc_i3c_master_disable_interrupts (master); + master->enabled_events &= ~SVC_I3C_EVENT_IBI ; +if (!master->enabled_events) +svc_i3c_master_disable_interrupts (master); ret =i3c_master_disec_locked (m, dev->info.dyn_addr,I3C_CCC_EVENT_SIR );
@@ -1492,6 +1510,39 @@ static int svc_i3c_master_disable_ibi(struct i3c_dev_desc *dev)return ret; } +static int svc_i3c_master_enable_hotjoin (struct i3c_master_controller *m) +{ +struct svc_i3c_master *master =to_svc_i3c_master (m); +int ret; + + ret =pm_runtime_resume_and_get (master->dev); +if (ret <0 ) { +dev_err (master->dev,"<%s> Cannot get runtime PM.\n" , __func__); +return ret; + } + + master->enabled_events |=SVC_I3C_EVENT_HOTJOIN ; + +svc_i3c_master_enable_interrupts (master,SVC_I3C_MINT_SLVSTART ); + +return 0 ; +} + +static int svc_i3c_master_disable_hotjoin (struct i3c_master_controller *m) +{ +struct svc_i3c_master *master =to_svc_i3c_master (m); + + master->enabled_events &= ~SVC_I3C_EVENT_HOTJOIN ; + +if (!master->enabled_events) +svc_i3c_master_disable_interrupts (master); + +pm_runtime_mark_last_busy (master->dev); +pm_runtime_put_autosuspend (master->dev); + +return 0 ; +} +static void svc_i3c_master_recycle_ibi_slot (struct i3c_dev_desc *dev,struct i3c_ibi_slot *slot) {
@@ -1518,6 +1569,8 @@ static const struct i3c_master_controller_ops svc_i3c_master_ops = { .recycle_ibi_slot = svc_i3c_master_recycle_ibi_slot, .enable_ibi = svc_i3c_master_enable_ibi, .disable_ibi = svc_i3c_master_disable_ibi, + .enable_hotjoin = svc_i3c_master_enable_hotjoin, + .disable_hotjoin = svc_i3c_master_disable_hotjoin, };static int svc_i3c_master_prepare_clks (struct svc_i3c_master *master)
Signature · 1 line
2.34.1
Frank Li
maintainerPATCH RESEND v5 3/6 i3c: add actual_len in i3c_priv_xfer
In reply to Frank LiIn MIPI I3C Specification:
"Ninth Bit of SDR Target Returned (Read) Data as End-of-Data: In I2C, the ninth Data bit from Target to Controller is an ACK by the Controller. By contrast, in I3C this bit allows the Target to end a Read, and allows the Controller to Abort a Read. In SDR terms, the ninth bit of Read data is referred to as the T-Bit (for ‘Transition’)"
I3C allow devices early terminate data transfer. So need "actual_len" field to indicate how much get by i3c_priv_xfer.
---
Notes:
change from v4 to v5
- Add Miquel review tag
include/linux/i3c/device.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/i3c/device.h +2 -0
@@ -54,6 +54,7 @@ enum i3c_hdr_mode {* struct i3c_priv_xfer - I3C SDR private transfer * @rnw: encodes the transfer direction. true for a read, false for a write * @len: transfer length in bytes of the transfer +* @actual_len: actual length in bytes are transferred by the controller * @data: input/output buffer * @data.in: input buffer. Must point to a DMA-able buffer * @data.out: output buffer. Must point to a DMA-able buffer
@@ -62,6 +63,7 @@ enum i3c_hdr_mode {struct i3c_priv_xfer {u8 rnw;u16 len; +u16 actual_len;union {void *in;const void *out;
Signature · 1 line
2.34.1
Re: [v5 resend 3/6] i3c: add actual_len in i3c_priv_xfer
Quoted 35 lines · Frank Li
In MIPI I3C Specification:
"Ninth Bit of SDR Target Returned (Read) Data as End-of-Data: In I2C, the ninth Data bit from Target to Controller is an ACK by the Controller. By contrast, in I3C this bit allows the Target to end a Read, and allows the Controller to Abort a Read. In SDR terms, the ninth bit of Read data is referred to as the T-Bit (for ‘Transition’)"
I3C allow devices early terminate data transfer. So need "
actual_len" field to indicate how much get byi3c_priv_xfer.Reviewed-by Miquel Raynal <[email protected]>Signed-off-by Frank Li <[email protected]>---
Notes:
change from v4 to v5
- Add Miquel review taginclude/linux/i3c/device.h | 2 ++ 1 file changed, 2 insertions(+)include/linux/i3c/device.h +1
-0@@ -54,6 +54,7 @@ enum i3c_hdr_mode {* struct i3c_priv_xfer - I3C SDR private transfer * @rnw: encodes the transfer direction. true for a read, false for a write * @len: transfer length in bytes of the transfer +* @actual_len: actual length in bytes are transferred by the controller * @data: input/output buffer * @data.in: input buffer. Must point to a DMA-able buffer * @data.out: output buffer. Must point to a DMA-able buffer
include/linux/i3c/device.h enum i3c_hdr_mode { · line 65
Quoted 3 lines
include/linux/i3c/device.h +0
-0@@ -62,6 +63,7 @@ enum i3c_hdr_mode {struct i3c_priv_xfer {u8 rnw;u16 len;
What happens if I3C device does not terminate the T-Bit because it expects extra length from master?
Quoted 4 lines
include/linux/i3c/device.h +1
-0+u16 actual_len;union {void *in;const void *out;
Signature · 3 lines
linux-i3c mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-i3c
Re: [v5 resend 3/6] i3c: add actual_len in i3c_priv_xfer
In reply to Frank LiQuoted 35 lines · Frank Li
In MIPI I3C Specification:
"Ninth Bit of SDR Target Returned (Read) Data as End-of-Data: In I2C, the ninth Data bit from Target to Controller is an ACK by the Controller. By contrast, in I3C this bit allows the Target to end a Read, and allows the Controller to Abort a Read. In SDR terms, the ninth bit of Read data is referred to as the T-Bit (for ‘Transition’)"
I3C allow devices early terminate data transfer. So need "
actual_len" field to indicate how much get byi3c_priv_xfer.Reviewed-by Miquel Raynal <[email protected]>Signed-off-by Frank Li <[email protected]>---
Notes:
change from v4 to v5
- Add Miquel review taginclude/linux/i3c/device.h | 2 ++ 1 file changed, 2 insertions(+)include/linux/i3c/device.h +1
-0@@ -54,6 +54,7 @@ enum i3c_hdr_mode {* struct i3c_priv_xfer - I3C SDR private transfer * @rnw: encodes the transfer direction. true for a read, false for a write * @len: transfer length in bytes of the transfer +* @actual_len: actual length in bytes are transferred by the controller * @data: input/output buffer * @data.in: input buffer. Must point to a DMA-able buffer * @data.out: output buffer. Must point to a DMA-able buffer
include/linux/i3c/device.h enum i3c_hdr_mode { · line 65
Quoted 3 lines
include/linux/i3c/device.h +0
-0@@ -62,6 +63,7 @@ enum i3c_hdr_mode {struct i3c_priv_xfer {u8 rnw;u16 len;
What happens if I3C device does not terminate the T-Bit because it expects extra length from master?
Quoted 4 lines
include/linux/i3c/device.h +1
-0+u16 actual_len;union {void *in;const void *out;
Frank Li
maintainerRe: [v5 resend 3/6] i3c: add actual_len in i3c_priv_xfer
Quoted 34 lines · Joshua Yeong
Quoted 32 lines · Frank Li
In MIPI I3C Specification:
"Ninth Bit of SDR Target Returned (Read) Data as End-of-Data: In I2C, the ninth Data bit from Target to Controller is an ACK by the Controller. By contrast, in I3C this bit allows the Target to end a Read, and allows the Controller to Abort a Read. In SDR terms, the ninth bit of Read data is referred to as the T-Bit (for ‘Transition’)"
I3C allow devices early terminate data transfer. So need "
actual_len" field to indicate how much get byi3c_priv_xfer.Reviewed-by Miquel Raynal <[email protected]>Signed-off-by Frank Li <[email protected]>---
Notes:
change from v4 to v5
- Add Miquel review taginclude/linux/i3c/device.h | 2 ++ 1 file changed, 2 insertions(+)include/linux/i3c/device.h +1
-0@@ -54,6 +54,7 @@ enum i3c_hdr_mode {* struct i3c_priv_xfer - I3C SDR private transfer * @rnw: encodes the transfer direction. true for a read, false for a write * @len: transfer length in bytes of the transfer +* @actual_len: actual length in bytes are transferred by the controller * @data: input/output buffer
Quoted 8 lines
include/linux/i3c/device.h enum i3c_hdr_mode { · line 65
Quoted 6 lines
include/linux/i3c/device.h +0
-0* @data.in: input buffer. Must point to a DMA-able buffer * @data.out: output buffer. Must point to a DMA-able buffer @@ -62,6 +63,7 @@ enum i3c_hdr_mode {struct i3c_priv_xfer {u8 rnw;u16 len;What happens if I3C device does not terminate the T-Bit because it expects extra length from master?
If devices don't terminate T, there are two cases.
1. Master send STOP, then START new transfer. I3C Devices can decide start new transfer, or continue transfer left data, which is totally up to how I3C device and devices' driver implementation.
2. Master continue toggle SCL to get extra data. Just like a low frequency at short period.
Frank
Quoted 4 lines
Quoted 4 lines
include/linux/i3c/device.h +1
-0+u16 actual_len;union {void *in;const void *out;
Frank Li
maintainerPATCH RESEND v5 4/6 i3c: master: svc: rename read_len as actual_len
In reply to Frank LiI3C transfer (SDR), target can early terminate read transfer. I3C transfer (HDR), target can end write transfer. I2C transfer, target can NACK write transfer.
'actual_len' is better name than 'read_len'.
---
Notes:
change from v4 to v5:
use i3c: master: svc: prefix
drivers/i3c/master/svc-i3c-master.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/i3c/master/svc-i3c-master.c +13 -13
@@ -137,7 +137,7 @@ struct svc_i3c_cmd {u8 *in;const void *out;unsigned int len; -unsigned int read_len; +unsigned int actual_len;bool continued; };
@@ -1038,7 +1038,7 @@ static int svc_i3c_master_write(struct svc_i3c_master *master,static int svc_i3c_master_xfer (struct svc_i3c_master *master,bool rnw,unsigned int xfer_type,u8 addr,u8 *in,const u8 *out,unsigned int xfer_len, -unsigned int *read_len,bool continued) +unsigned int *actual_len,bool continued) {u32 reg;int ret;
@@ -1051,7 +1051,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,SVC_I3C_MCTRL_IBIRESP_NACK |SVC_I3C_MCTRL_DIR (rnw) |SVC_I3C_MCTRL_ADDR (addr) | -SVC_I3C_MCTRL_RDTERM (*read_len), +SVC_I3C_MCTRL_RDTERM (*actual_len), master->regs + SVC_I3C_MCTRL); ret = readl_poll_timeout(master->regs + SVC_I3C_MSTATUS, reg,
@@ -1089,7 +1089,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master, goto emit_stop;if (rnw) - *read_len = ret; + *actual_len = ret; ret =readl_poll_timeout (master->regs +SVC_I3C_MSTATUS , reg,SVC_I3C_MSTATUS_COMPLETE (reg),0 ,1000 );
@@ -1171,7 +1171,7 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master) ret =svc_i3c_master_xfer (master, cmd->rnw, xfer->type, cmd->addr, cmd->in, cmd->out, - cmd->len, &cmd->read_len, + cmd->len, &cmd->actual_len, cmd->continued);if (ret)break ;
@@ -1257,7 +1257,7 @@ static int svc_i3c_master_send_bdcast_ccc_cmd(struct svc_i3c_master *master, cmd->in =NULL ; cmd->out = buf; cmd->len = xfer_len; - cmd->read_len =0 ; + cmd->actual_len =0 ; cmd->continued = false;mutex_lock (&master->lock);
@@ -1277,7 +1277,7 @@ static int svc_i3c_master_send_direct_ccc_cmd(struct svc_i3c_master *master, struct i3c_ccc_cmd *ccc) {unsigned int xfer_len = ccc->dests[0 ].payload.len; -unsigned int read_len = ccc->rnw ? xfer_len :0 ; +unsigned int actual_len = ccc->rnw ? xfer_len :0 ;struct svc_i3c_xfer *xfer;struct svc_i3c_cmd *cmd;int ret;
@@ -1295,7 +1295,7 @@ static int svc_i3c_master_send_direct_ccc_cmd(struct svc_i3c_master *master, cmd->in =NULL ; cmd->out = &ccc->id; cmd->len =1 ; - cmd->read_len =0 ; + cmd->actual_len =0 ; cmd->continued = true;/* Directed message */
@@ -1305,7 +1305,7 @@ static int svc_i3c_master_send_direct_ccc_cmd(struct svc_i3c_master *master, cmd->in = ccc->rnw ? ccc->dests[0 ].payload.data :NULL ; cmd->out = ccc->rnw ?NULL : ccc->dests[0 ].payload.data, cmd->len = xfer_len; - cmd->read_len = read_len; + cmd->actual_len = actual_len; cmd->continued = false;mutex_lock (&master->lock);
@@ -1314,8 +1314,8 @@ static int svc_i3c_master_send_direct_ccc_cmd(struct svc_i3c_master *master,svc_i3c_master_dequeue_xfer (master, xfer);mutex_unlock (&master->lock); -if (cmd->read_len != xfer_len) - ccc->dests[0 ].payload.len = cmd->read_len; +if (cmd->actual_len != xfer_len) + ccc->dests[0 ].payload.len = cmd->actual_len; ret = xfer->ret;svc_i3c_master_free_xfer (xfer);
@@ -1365,7 +1365,7 @@ static int svc_i3c_master_priv_xfers(struct i3c_dev_desc *dev, cmd->in = xfers[i].rnw ? xfers[i].data.in :NULL ; cmd->out = xfers[i].rnw ?NULL : xfers[i].data.out; cmd->len = xfers[i].len; - cmd->read_len = xfers[i].rnw ? xfers[i].len :0 ; + cmd->actual_len = xfers[i].rnw ? xfers[i].len :0 ; cmd->continued = (i +1 ) < nxfers; }
@@ -1405,7 +1405,7 @@ static int svc_i3c_master_i2c_xfers(struct i2c_dev_desc *dev, cmd->in = cmd->rnw ? xfers[i].buf :NULL ; cmd->out = cmd->rnw ?NULL : xfers[i].buf; cmd->len = xfers[i].len; - cmd->read_len = cmd->rnw ? xfers[i].len :0 ; + cmd->actual_len = cmd->rnw ? xfers[i].len :0 ; cmd->continued = (i +1 < nxfers); }
Signature · 1 line
2.34.1
Frank Li
maintainerPATCH RESEND v5 5/6 i3c: master: svc: return actual transfer data len
In reply to Frank LiI3C allow devices early terminate data transfer. So set "actual_len" to indicate how much data get by i3c_priv_xfer.
---
Notes:
change from v4 to v5
update prefix
add Miquel's review tag
drivers/i3c/master/svc-i3c-master.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/i3c/master/svc-i3c-master.c +8 -0
@@ -138,6 +138,7 @@ struct svc_i3c_cmd {const void *out;unsigned int len;unsigned int actual_len; +struct i3c_priv_xfer *xfer;bool continued; };
@@ -1061,6 +1062,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,if (readl (master->regs +SVC_I3C_MERRWARN ) &SVC_I3C_MERRWARN_NACK ) { ret = -ENXIO ; + *actual_len =0 ; goto emit_stop; }
@@ -1078,6 +1080,7 @@ static int svc_i3c_master_xfer(struct svc_i3c_master *master,*/ if (SVC_I3C_MSTATUS_IBIWON (reg)) { ret = -ENXIO ; + *actual_len =0 ; goto emit_stop; }
@@ -1173,6 +1176,10 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master) cmd->addr, cmd->in, cmd->out, cmd->len, &cmd->actual_len, cmd->continued); +/* cmd->xfer is NULL if I2C or CCC transfer */ +if (cmd->xfer) + cmd->xfer->actual_len = cmd->actual_len; +if (ret)break ; }
@@ -1360,6 +1367,7 @@ static int svc_i3c_master_priv_xfers(struct i3c_dev_desc *dev,for (i =0 ; i < nxfers; i++) {struct svc_i3c_cmd *cmd = &xfer->cmds[i]; + cmd->xfer = &xfers[i]; cmd->addr = master->addrs[data->index]; cmd->rnw = xfers[i].rnw; cmd->in = xfers[i].rnw ? xfers[i].data.in :NULL ;
Signature · 1 line
2.34.1
Frank Li
maintainerPATCH RESEND v5 6/6 i3c: add API i3c_dev_gettstatus_format1() to get target device status
In reply to Frank LiI3C standard 5.1.9.3.15 Get Device Status (GETSTATUS):
Get request for one I3C Target Device to return its current status.
Add API to fetch it with format1.
---
Notes:
See below patch, which call i3c_dev_gettstatus_format1()
https://lore.kernel.org/imx/[email protected]/T/#t
Change from v4 to v5
- none
drivers/i3c/device.c | 24 ++++++++++++++++++++++++ drivers/i3c/internals.h | 1 + drivers/i3c/master.c | 26 ++++++++++++++++++++++++++ include/linux/i3c/device.h | 1 + 4 files changed, 52 insertions(+)
drivers/i3c/device.c +24 -0
@@ -196,6 +196,30 @@ void i3c_device_free_ibi(struct i3c_device *dev) }EXPORT_SYMBOL_GPL (i3c_device_free_ibi); +/** +* i3c_device_getstatus_format1() - Get device status with format 1. +* @dev: device for which you want to get status. +* @status: I3C status format 1 +* +* Return: 0 in case of success, a negative error core otherwise. +*/ +int i3c_device_getstatus_format1 (struct i3c_device *dev,u16 *status) +{ +int ret = -EINVAL ; + +if (!status) +return -EINVAL ; + +i3c_bus_normaluse_lock (dev->bus); +if (dev->desc) + ret =i3c_dev_getstatus_format1_locked (dev->desc, status); + +i3c_bus_normaluse_unlock (dev->bus); + +return ret; +} +EXPORT_SYMBOL_GPL (i3c_device_getstatus_format1); +/** * i3cdev_to_dev() - Returns the device embedded in @i3cdev * @i3cdev: I3C device
drivers/i3c/internals.h +1 -0
@@ -24,4 +24,5 @@ int i3c_dev_enable_ibi_locked(struct i3c_dev_desc *dev);int i3c_dev_request_ibi_locked (struct i3c_dev_desc *dev,const struct i3c_ibi_setup *req);void i3c_dev_free_ibi_locked (struct i3c_dev_desc *dev); +int i3c_dev_getstatus_format1_locked (struct i3c_dev_desc *dev,u16 *status);#endif /* I3C_INTERNAL_H */
drivers/i3c/master.c +26 -0
@@ -2923,6 +2923,32 @@ void i3c_dev_free_ibi_locked(struct i3c_dev_desc *dev) dev->ibi =NULL ; } +int i3c_dev_getstatus_format1_locked (struct i3c_dev_desc *dev,u16 *status) +{ +struct i3c_master_controller *master =i3c_dev_get_master (dev); +struct i3c_ccc_getstatus *format1; +struct i3c_ccc_cmd_dest dest; +struct i3c_ccc_cmd cmd; +int ret; + + format1 =i3c_ccc_cmd_dest_init (&dest, dev->info.dyn_addr,sizeof (*format1)); +if (!format1) +return -ENOMEM ; + +i3c_ccc_cmd_init (&cmd, true,I3C_CCC_GETSTATUS , &dest,1 ); + + ret =i3c_master_send_ccc_cmd_locked (master, &cmd); +if (ret) + goto out; + + *status =be16_to_cpu (format1->status); + +out: +i3c_ccc_cmd_dest_cleanup (&dest); + +return ret; +} +static int __init i3c_init (void ) {int res;
include/linux/i3c/device.h +1 -0
@@ -345,4 +345,5 @@ void i3c_device_free_ibi(struct i3c_device *dev);int i3c_device_enable_ibi (struct i3c_device *dev);int i3c_device_disable_ibi (struct i3c_device *dev); +int i3c_device_getstatus_format1 (struct i3c_device *dev,u16 *status);#endif /* I3C_DEV_H */
Signature · 1 line
2.34.1
Frank Li
maintainerQuoted 6 lines · Frank Li
There are three major improvement
1. Add actual size in
i3c_transferbecause i3c allow target early termiate transfer.
2. Add API fori3c_dev_gettstatus_format1for i3c comandGET_STATUS.
3. svc master support hotjoin
Friendly ping. Any addtional comment about these patches?
Frank LI
Quoted 22 lines
Change log see each patches
Frank Li (6):
i3c: master: add enable(disable) hot join in sys entry
i3c: master: svc: add hot join support
i3c: addactual_lenini3c_priv_xfer
i3c: master: svc: renameread_lenasactual_len
i3c: master: svc: return actual transfer data len
i3c: add APIi3c_dev_gettstatus_format1()to get target device statusdrivers/i3c/device.c | 24 ++++++ drivers/i3c/internals.h | 1 + drivers/i3c/master.c | 109 ++++++++++++++++++++++++++++ drivers/i3c/master/svc-i3c-master.c | 95 +++++++++++++++++++----- include/linux/i3c/device.h | 3 + include/linux/i3c/master.h | 5 ++ 6 files changed, 220 insertions(+), 17 deletions(-)Signature · 1 line
2.34.1
Re: (subset) [v5 resend 0/6] i3c: master: some improvment for i3c master
In reply to Frank LiQuoted 8 lines · Frank Li
There are three major improvement
1. Add actual size in
i3c_transferbecause i3c allow target early termiate transfer.
2. Add API fori3c_dev_gettstatus_format1for i3c comandGET_STATUS.
3. svc master support hotjoin[...]
Applied, thanks!
[1/6] i3c: master: add enable(disable) hot join in sys entry
commit: 317bacf960a4879af22d12175f47d284930b3273
[2/6] i3c: master: svc: add hot join support
commit: 05b26c31a4859af9e75b7de77458e99358364fe1
[3/6] i3c: add actual_len in i3c_priv_xfer
commit: e5e3df06ac98d15cfb10bb5c12356709365e91b2
[4/6] i3c: master: svc: rename read_len as actual_len
commit: 6fb61734a74eaa307a5b6a0bee770e736d8acf89
[5/6] i3c: master: svc: return actual transfer data len
commit: 6d1a19d34e2cc07ca9cdad8892da94e716e9d15fBest regards,
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Frank Li
maintainerRe: (subset) [v5 resend 0/6] i3c: master: some improvment for i3c master
Quoted 14 lines · Alexandre Belloni
Quoted 8 lines · Frank Li
There are three major improvement
1. Add actual size in
i3c_transferbecause i3c allow target early termiate transfer.
2. Add API fori3c_dev_gettstatus_format1for i3c comandGET_STATUS.
3. svc master support hotjoin[...]
Applied, thanks!
[1/6] i3c: master: add enable(disable) hot join in sys entry
Quoted 9 lines
commit: 317bacf960a4879af22d12175f47d284930b3273
[2/6] i3c: master: svc: add hot join support
commit: 05b26c31a4859af9e75b7de77458e99358364fe1
[3/6] i3c: add actual_len in i3c_priv_xfer
commit: e5e3df06ac98d15cfb10bb5c12356709365e91b2
[4/6] i3c: master: svc: rename read_len as actual_len
commit: 6fb61734a74eaa307a5b6a0bee770e736d8acf89
[5/6] i3c: master: svc: return actual transfer data len
commit: 6d1a19d34e2cc07ca9cdad8892da94e716e9d15fWhy not pckup 6/6:
i3c: add API i3c_dev_gettstatus_format1() to get target device status
Frank
Quoted 7 lines
Best regards,
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Alexandre Belloni
maintainerRe: (subset) [v5 resend 0/6] i3c: master: some improvment for i3c master
Quoted 25 lines · Frank Li
Quoted 14 lines · Alexandre Belloni
Quoted 8 lines · Frank Li
There are three major improvement
1. Add actual size in
i3c_transferbecause i3c allow target early termiate transfer.
2. Add API fori3c_dev_gettstatus_format1for i3c comandGET_STATUS.
3. svc master support hotjoin[...]
Applied, thanks!
[1/6] i3c: master: add enable(disable) hot join in sys entry
Quoted 9 lines
commit: 317bacf960a4879af22d12175f47d284930b3273 [2/6] i3c: master: svc: add hot join support commit: 05b26c31a4859af9e75b7de77458e99358364fe1 [3/6] i3c: add actual_len in i3c_priv_xfer commit: e5e3df06ac98d15cfb10bb5c12356709365e91b2 [4/6] i3c: master: svc: rename read_len as actual_len commit: 6fb61734a74eaa307a5b6a0bee770e736d8acf89 [5/6] i3c: master: svc: return actual transfer data len commit: 6d1a19d34e2cc07ca9cdad8892da94e716e9d15f
Quoted 3 lines
Why not pckup 6/6:
i3c: add APIi3c_dev_gettstatus_format1()to get target device status
As it was discussed, it doesn't have any users.
Quoted 9 lines
Frank
Quoted 7 lines
Best regards,
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com