I3C target mode support
Subsystems (6)
Frank Li
maintainerv9 cover I3C target mode support
This patch introduces support for I3C target mode, which is referenced with a PCIe Endpoint system. It also establishes a configuration framework (configfs) for the I3C target controller driver and the I3C target function driver
Typic usage as
The user can configure the i3c-target-tty device using configfs entry. In order to change the vendorid, the following commands can be used
# echo 0x011b > functions/tty/func1/vendor_id
# echo 0x1000 > functions/tty/func1/part_id
# echo 0x6 > functions/tty/t/bcrBinding i3c-target-tty Device to target Controller
------------------------------------------------
In order for the target function device to be useful, it has to be bound to a I3C target controller driver. Use the configfs to bind the function device to one of the controller driver present in the system::
# ln -s functions/pci_epf_test/func1 controllers/44330000.i3c-target/
Host side:
cat /dev/ttyI3C0
Taret side:
echo abc >/dev/ttyI3C0
Notes about header files.
About Ilpo Järvinen's header file comments, it can pass build, some header should be included by other header files.
I added some, but I am not sure that is all needs. There may have tools, which can help check, but I don't know.
Chagne from v2 to v3
- using 'mode' distingiush master and target.
- move svc-i3c-target.c to under master,
- built together with svc-i3c-master.c
Change from v1 to v2
- change "slave" to "target"
- include master side tty patch
- fixed dtbcheck problem
- fixed kerne-doc check warning
Some review comment may be lost since it is quite long time since v1. Now master side dependent patches already in linux-next. So sent target side patches with tty support again.
No sure why an additional "\r\n" appended.
Frank Li (8):
i3c: add target mode support
dt-bindings: i3c: svc: add proptery mode
Documentation: i3c: Add I3C target mode controller and function
i3c: svc: Add svc-i3c-main.c and svc-i3c.h
i3c: target: add svc target controller support
i3c: target: func: add tty driver
i3c: add API i3c_dev_gettstatus_format1() to get target device status
tty: i3c: add TTY over I3C master support
.../bindings/i3c/silvaco,i3c-master.yaml | 11 +- Documentation/driver-api/i3c/index.rst | 1 + .../driver-api/i3c/target/i3c-target-cfs.rst | 109 +++ .../driver-api/i3c/target/i3c-target.rst | 189 +++++ .../driver-api/i3c/target/i3c-tty-howto.rst | 109 +++ Documentation/driver-api/i3c/target/index.rst | 13 + drivers/i3c/Kconfig | 31 +- drivers/i3c/Makefile | 3 + drivers/i3c/device.c | 24 + drivers/i3c/func/Kconfig | 9 + drivers/i3c/func/Makefile | 3 + drivers/i3c/func/tty.c | 481 +++++++++++ drivers/i3c/i3c-cfs.c | 389 +++++++++ drivers/i3c/internals.h | 1 + drivers/i3c/master.c | 26 + drivers/i3c/master/Makefile | 3 +- drivers/i3c/master/svc-i3c-main.c | 80 ++ drivers/i3c/master/svc-i3c-master.c | 34 +- drivers/i3c/master/svc-i3c-target.c | 776 ++++++++++++++++++ drivers/i3c/master/svc-i3c.h | 15 + drivers/i3c/target.c | 453 ++++++++++ drivers/tty/Kconfig | 13 + drivers/tty/Makefile | 1 + drivers/tty/i3c_tty.c | 432 ++++++++++ include/linux/i3c/device.h | 1 + include/linux/i3c/target.h | 548 +++++++++++++ 26 files changed, 3724 insertions(+), 31 deletions(-) create mode 100644 Documentation/driver-api/i3c/target/i3c-target-cfs.rst create mode 100644 Documentation/driver-api/i3c/target/i3c-target.rst create mode 100644 Documentation/driver-api/i3c/target/i3c-tty-howto.rst create mode 100644 Documentation/driver-api/i3c/target/index.rst create mode 100644 drivers/i3c/func/Kconfig create mode 100644 drivers/i3c/func/Makefile create mode 100644 drivers/i3c/func/tty.c create mode 100644 drivers/i3c/i3c-cfs.c create mode 100644 drivers/i3c/master/svc-i3c-main.c create mode 100644 drivers/i3c/master/svc-i3c-target.c create mode 100644 drivers/i3c/master/svc-i3c.h create mode 100644 drivers/i3c/target.c create mode 100644 drivers/tty/i3c_tty.c create mode 100644 include/linux/i3c/target.h
Signature · 1 line
2.34.1
Frank Li
maintainerPATCH RESEND v9 1/8 i3c: add target mode support
Introduce a new target core layer in order to support target functions in linux kernel. This comprises the controller library and function library. Controller library implements functions specific to an target controller and function library implements functions specific to an target function.
Introduce a new configfs entry to configure the target function configuring and bind the target function with target controller.
---
Notes:
Change from v8 to v9
-none
Change from v7 to v8
Added missed head files
Change from v5 to v6
- fixed build error when have not CONFIG_TARGET_CONFIGFS
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Chagne from v4 to v5
- add include <linux/slab.h> to fix build error
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Chagne from v4 to v8
- add include <linux/slab.h> to fix build error
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
drivers/i3c/Kconfig | 28 +- drivers/i3c/Makefile | 2 + drivers/i3c/i3c-cfs.c | 389 ++++++++++++++++++++++++++ drivers/i3c/target.c | 453 ++++++++++++++++++++++++++++++ include/linux/i3c/target.h | 548 +++++++++++++++++++++++++++++++++++++ 5 files changed, 1419 insertions(+), 1 deletion(-) create mode 100644 drivers/i3c/i3c-cfs.c create mode 100644 drivers/i3c/target.c create mode 100644 include/linux/i3c/target.h
drivers/i3c/Kconfig +27 -1
@@ -10,7 +10,7 @@ menuconfig I3C support for high speed transfers and native interrupt support without the need for extra pins. - The I3C protocol also standardizes the slave device types and is + The I3C protocol also standardizes the target device types and is mainly designed to communicate with sensors. If you want I3C support, you should say Y here and also to the
@@ -22,3 +22,29 @@ menuconfig I3C if I3C source "drivers/i3c/master/Kconfig" endif # I3C + +config I3C_TARGET + bool "I3C Target Support" + help + Support I3C Target Mode. + + Enable this configuration option to support configurable I3C target. + This should be enabled if the platform has a I3C controller that can + operate in target mode. + + Enabling this option will build the I3C target library, which includes + target controller library and target function library. + + If in doubt, say "N" to disable target support. + +config I3C_TARGET_CONFIGFS + bool "I3C Target Configfs Support" + depends on I3C_TARGET + select CONFIGFS_FS + help + Configfs entry for target function and controller. + + This will enable the configfs entry that can be used to configure + the target function and used to bind the function with a target + controller. +
drivers/i3c/Makefile +2 -0
@@ -1,4 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 i3c-y := device.o master.o obj-$(CONFIG_I3C) += i3c.o +obj-$(CONFIG_I3C_TARGET) += target.o +obj-$(CONFIG_I3C_TARGET_CONFIGFS) += i3c-cfs.o obj-$(CONFIG_I3C) += master/
drivers/i3c/i3c-cfs.c new file +389 -0
389 lines not on this page · raw message
drivers/i3c/target.c new file +453 -0
453 lines not on this page · raw message
include/linux/i3c/target.h new file +548 -0
548 lines not on this page · raw message
Signature · 1 line
2.34.1
RE: [PATCH resend v9 1/8] i3c: add target mode support
Quoted 99 lines · Joshua Yeong
Introduce a new target core layer in order to support target functions in linux kernel. This comprises the controller library and function library. Controller library implements functions specific to an target controller and function library implements functions specific to an target function.
Introduce a new configfs entry to configure the target function configuring and bind the target function with target controller.
Signed-off-by Frank Li <[email protected]>---
Notes:
Change from v8 to v9
-noneChange from v7 to v8
Added missed head filesChange from v5 to v6
- fixed build error when have notCONFIG_TARGET_CONFIGFS
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/202402030437.GdGCrKeK-
[email protected]/Chagne from v4 to v5
- add include <linux/slab.h> to fix build error
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401270838.wdxHPaAT-
[email protected]/Chagne from v4 to v8
- add include <linux/slab.h> to fix build error
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401270838.wdxHPaAT-
[email protected]/drivers/i3c/Kconfig | 28 +- drivers/i3c/Makefile | 2 + drivers/i3c/i3c-cfs.c | 389 ++++++++++++++++++++++++++ drivers/i3c/target.c | 453 ++++++++++++++++++++++++++++++ include/linux/i3c/target.h | 548+++++++++++++++++++++++++++++++++++++
...
include/linux/i3c/target.h new file renamed from include/linux/i3c/target.h +0
-0mode 100644 index 0000000000000..b0bf06685834c
include/linux/i3c/target.h new file +24
-0+/** +* struct i3c_target_ctrl_ops - set of function pointers for performing +controller operations +* @set_config: set I3C controller configuration +* @enable: enable I3C controller +* @disable: disable I3C controller +* @raise_ibi: raise IBI interrupt to master +* @alloc_request: allocate a i3c_request, optional, default use +kmalloc +* @free_request: free a i3c_request, default use kfree +* @queue: queue an I3C transfer +* @dequeue: dequeue an I3C transfer +* @cancel_all_reqs: call all pending requests +* @fifo_status: current FIFO status +* @fifo_flush: flush hardware FIFO +* @hotjoin: raise hotjoin request to master +* @set_status_format1: set i3c status format1 +* @get_status_format1: get i3c status format1 +* @get_addr: get i3c dynmatic address +* @get_features: ops to get the features supported by the I3C target +controller +* @owner: the module owner containing the ops */ struct +i3c_target_ctrl_ops { + int (*set_config)(struct i3c_target_ctrl *ctrl, struct i3c_target_func*func);
include/linux/i3c/target.h new file +5
-0+int (*enable)(struct i3c_target_ctrl *ctrl); +int (*disable)(struct i3c_target_ctrl *ctrl); +int (*raise_ibi)(struct i3c_target_ctrl *ctrl,void *p,u8 size); + + struct i3c_request *(*alloc_request)(struct i3c_target_ctrl *ctrl, gfp_t
gfp_flags);include/linux/i3c/target.h new file +14
-0+void (*free_request)(struct i3c_request *req); + +int (*queue)(struct i3c_request *req,gfp_t gfp_flags); +int (*dequeue)(struct i3c_request *req); + +void (*cancel_all_reqs)(struct i3c_target_ctrl *ctrl,bool tx); + +int (*fifo_status)(struct i3c_target_ctrl *ctrl,bool tx); +void (*fifo_flush)(struct i3c_target_ctrl *ctrl,bool tx); +int (*hotjoin)(struct i3c_target_ctrl *ctrl); +int (*set_status_format1)(struct i3c_target_ctrl *ctrl,u16 status); +u16 (*get_status_format1)(struct i3c_target_ctrl *ctrl); +u8 (*get_addr)(struct i3c_target_ctrl *ctrl); + const struct i3c_target_ctrl_features *(*get_features)(struct
i3c_target_ctrl*ctrl);
include/linux/i3c/target.h
Quoted 2 lines
include/linux/i3c/target.h new file +2
-0+struct module *owner; +};
This structure looks very different from the master controller ops 'i3c_master_controller_ops'. I think you could probably combine 'set_config, enable' into 'bus_init', 'disable' to 'bus_cleanup'. Also using the 'struct i3c_priv_xfer' rather redefining another 'struct i3c_request' would be much cleaner.
In the master i3c side they don't abbreviate i3c_master_controller to i3c_master_ctrl. I think we should do the same here to standardize it. Thanks
Regards,
Joshua
Quoted 8 lines
--
2.34.1--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
Frank Li
maintainerRe: [PATCH resend v9 1/8] i3c: add target mode support
Quoted 98 lines · Joshua Yeong
Quoted 97 lines · Joshua Yeong
Introduce a new target core layer in order to support target functions in linux kernel. This comprises the controller library and function library. Controller library implements functions specific to an target controller and function library implements functions specific to an target function.
Introduce a new configfs entry to configure the target function configuring and bind the target function with target controller.
Signed-off-by Frank Li <[email protected]>---
Notes:
Change from v8 to v9
-noneChange from v7 to v8
Added missed head filesChange from v5 to v6
- fixed build error when have notCONFIG_TARGET_CONFIGFS
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/202402030437.GdGCrKeK-
[email protected]/Chagne from v4 to v5
- add include <linux/slab.h> to fix build error
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401270838.wdxHPaAT-
[email protected]/Chagne from v4 to v8
- add include <linux/slab.h> to fix build error
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401270838.wdxHPaAT-
[email protected]/drivers/i3c/Kconfig | 28 +- drivers/i3c/Makefile | 2 + drivers/i3c/i3c-cfs.c | 389 ++++++++++++++++++++++++++ drivers/i3c/target.c | 453 ++++++++++++++++++++++++++++++ include/linux/i3c/target.h | 548+++++++++++++++++++++++++++++++++++++
...
include/linux/i3c/target.h new file renamed from include/linux/i3c/target.h +0
-0mode 100644 index 0000000000000..b0bf06685834c
include/linux/i3c/target.h new file +24
-0+/** +* struct i3c_target_ctrl_ops - set of function pointers for performing +controller operations +* @set_config: set I3C controller configuration +* @enable: enable I3C controller +* @disable: disable I3C controller +* @raise_ibi: raise IBI interrupt to master +* @alloc_request: allocate a i3c_request, optional, default use +kmalloc +* @free_request: free a i3c_request, default use kfree +* @queue: queue an I3C transfer +* @dequeue: dequeue an I3C transfer +* @cancel_all_reqs: call all pending requests +* @fifo_status: current FIFO status +* @fifo_flush: flush hardware FIFO +* @hotjoin: raise hotjoin request to master +* @set_status_format1: set i3c status format1 +* @get_status_format1: get i3c status format1 +* @get_addr: get i3c dynmatic address +* @get_features: ops to get the features supported by the I3C target +controller +* @owner: the module owner containing the ops */ struct +i3c_target_ctrl_ops { + int (*set_config)(struct i3c_target_ctrl *ctrl, struct i3c_target_func*func);
include/linux/i3c/target.h new file +5
-0+int (*enable)(struct i3c_target_ctrl *ctrl); +int (*disable)(struct i3c_target_ctrl *ctrl); +int (*raise_ibi)(struct i3c_target_ctrl *ctrl,void *p,u8 size); + + struct i3c_request *(*alloc_request)(struct i3c_target_ctrl *ctrl, gfp_t
gfp_flags);include/linux/i3c/target.h new file +13
-0+void (*free_request)(struct i3c_request *req); + +int (*queue)(struct i3c_request *req,gfp_t gfp_flags); +int (*dequeue)(struct i3c_request *req); + +void (*cancel_all_reqs)(struct i3c_target_ctrl *ctrl,bool tx); + +int (*fifo_status)(struct i3c_target_ctrl *ctrl,bool tx); +void (*fifo_flush)(struct i3c_target_ctrl *ctrl,bool tx); +int (*hotjoin)(struct i3c_target_ctrl *ctrl); +int (*set_status_format1)(struct i3c_target_ctrl *ctrl,u16 status); +u16 (*get_status_format1)(struct i3c_target_ctrl *ctrl); +u8 (*get_addr)(struct i3c_target_ctrl *ctrl);
Quoted 8 lines
include/linux/i3c/target.h
Quoted 4 lines
include/linux/i3c/target.h new file +1
-0+ const struct i3c_target_ctrl_features *(*get_features)(struct
i3c_target_ctrl*ctrl);include/linux/i3c/target.h new file +2
-0+struct module *owner; +};This structure looks very different from the master controller ops '
i3c_master_controller_ops'. I think you could probably combine 'set_config, enable' into 'bus_init', 'disable' to 'bus_cleanup'. Also using the 'structi3c_priv_xfer' rather redefining another 'structi3c_request' would be much cleaner.
Thanks, let me think this. i3c_priv_xter may include read and write, or write and read. I3C is quite fast. Most time software are not quite enough to handle it in time.
If data len bigger than FIFO size, it have to use DMA to transfer it because there are not flow controler at target side (write direction). Read, hardware to use early terminate to tell host read too fast. but for write, 9th bit is parit check bit. Data will be lost if software have not read from FIFO in time. If use external DMA to do that, it needs switch dma channel(generally, DMA rx and tx are two channel). switch channel automatically are quite challenge at current dma engine framework.
Of course it will be possible if hardware implement simpilar I3C HCI command queue. But I still not found any hardware that can do that yet.
If only limited data size to FIFO size, there are still limiation for xfer. if write, read, write, read, two write may combined in one FIFO, target driver may not split it which depend on hardware detect repeat start and insert something into fifo.
It is hard to support all user case by I3C target software in linux.
write follow by read, generally used from get hardware register value from target side, which almost impossible by software, it is not quick enough to parse (write value) then send back data.
Quoted 3 lines
In the master i3c side they don't abbreviate
i3c_master_controllertoi3c_master_ctrl. I think we should do the same here to standardize it. Thanks
The problem is in I3C spec: "master" already depericated
from i3c spec 1.1.1
"Controller: An I3C Device that is capable of controlling the I3C Bus."
master/slave => controller/target.
It will become more confused if i3c_target_controller. "controller" are ambiguity.
If "master" => "host" would be better situation, but not happen. A point, I use "ctrl" here to avoid I3C spec defined "controller" term.
Anyway, I hope more people that involve target support discussion.
Quoted 12 lines
Regards,
JoshuaQuoted 8 lines
--
2.34.1--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
RE: [PATCH resend v9 1/8] i3c: add target mode support
Quoted 122 lines · Frank Li
Quoted 4 lines · Joshua Yeong
Quoted 3 lines · Joshua Yeong
Introduce a new target core layer in order to support target functions in linux kernel. This comprises the controller library and function
library.
Quoted 2 lines
Quoted 2 lines
Controller library implements functions specific to an target controller and function library implements functions specific to an target
function.
Quoted 95 lines
Quoted 95 lines
Introduce a new configfs entry to configure the target function configuring and bind the target function with target controller.
Signed-off-by Frank Li <[email protected]>---
Notes:
Change from v8 to v9
-noneChange from v7 to v8
Added missed head filesChange from v5 to v6
- fixed build error when have notCONFIG_TARGET_CONFIGFS| Reported-by: kernel test robot <[email protected]> | Closes:
https://lore.kernel.org/oe-kbuild-all/202402030437.GdGCrKeK-
[email protected]/Chagne from v4 to v5
- add include <linux/slab.h> to fix build error | Reported-by: kernel test robot <[email protected]> | Closes:
https://lore.kernel.org/oe-kbuild-all/202401270838.wdxHPaAT-
[email protected]/Chagne from v4 to v8
- add include <linux/slab.h> to fix build error | Reported-by: kernel test robot <[email protected]> | Closes:
https://lore.kernel.org/oe-kbuild-all/202401270838.wdxHPaAT-
[email protected]/drivers/i3c/Kconfig | 28 +- drivers/i3c/Makefile | 2 + drivers/i3c/i3c-cfs.c | 389 ++++++++++++++++++++++++++ drivers/i3c/target.c | 453 ++++++++++++++++++++++++++++++ include/linux/i3c/target.h | 548+++++++++++++++++++++++++++++++++++++
...
include/linux/i3c/target.h new file +25
-0+/** +* struct i3c_target_ctrl_ops - set of function pointers for +performing controller operations +* @set_config: set I3C controller configuration +* @enable: enable I3C controller +* @disable: disable I3C controller +* @raise_ibi: raise IBI interrupt to master +* @alloc_request: allocate a i3c_request, optional, default use +kmalloc +* @free_request: free a i3c_request, default use kfree +* @queue: queue an I3C transfer +* @dequeue: dequeue an I3C transfer +* @cancel_all_reqs: call all pending requests +* @fifo_status: current FIFO status +* @fifo_flush: flush hardware FIFO +* @hotjoin: raise hotjoin request to master +* @set_status_format1: set i3c status format1 +* @get_status_format1: get i3c status format1 +* @get_addr: get i3c dynmatic address +* @get_features: ops to get the features supported by the I3C +target controller +* @owner: the module owner containing the ops */ struct +i3c_target_ctrl_ops { +int (*set_config)(struct i3c_target_ctrl *ctrl,struct +i3c_target_func*func);
include/linux/i3c/target.h new file +6
-0+int (*enable)(struct i3c_target_ctrl *ctrl); +int (*disable)(struct i3c_target_ctrl *ctrl); +int (*raise_ibi)(struct i3c_target_ctrl *ctrl,void *p,u8 size); + +struct i3c_request *(*alloc_request)(struct i3c_target_ctrl *ctrl, +gfp_t
gfp_flags);include/linux/i3c/target.h new file +11
-0+void (*free_request)(struct i3c_request *req); + +int (*queue)(struct i3c_request *req,gfp_t gfp_flags); +int (*dequeue)(struct i3c_request *req); + +void (*cancel_all_reqs)(struct i3c_target_ctrl *ctrl,bool tx); + +int (*fifo_status)(struct i3c_target_ctrl *ctrl,bool tx); +void (*fifo_flush)(struct i3c_target_ctrl *ctrl,bool tx); +int (*hotjoin)(struct i3c_target_ctrl *ctrl); +int (*set_status_format1)(struct i3c_target_ctrl *ctrl,u16 status);Quoted 8 lines
include/linux/i3c/target.h
Quoted 6 lines
include/linux/i3c/target.h new file +3
-0+u16 (*get_status_format1)(struct i3c_target_ctrl *ctrl); +u8 (*get_addr)(struct i3c_target_ctrl *ctrl); + const struct i3c_target_ctrl_features *(*get_features)(struct
i3c_target_ctrl*ctrl);include/linux/i3c/target.h new file +2
-0+struct module *owner; +};This structure looks very different from the master controller ops
'
i3c_master_controller_ops'.Quoted 1 line
I think you could probably combine '
set_config, enable' into 'bus_init','disable' to '
bus_cleanup'.Quoted 1 line
Also using the 'struct
i3c_priv_xfer' rather redefining another 'struct
i3c_request' would be much cleaner.Thanks, let me think this.
i3c_priv_xtermay include read and write, or write and read. I3C is quite fast. Most time software are not quite enough to handle it in time.
Quoted 8 lines
If data len bigger than FIFO size, it have to use DMA to transfer it because there are not flow controler at target side (write direction).
Read, hardware to use early terminate to tell host read too fast. but for write, 9th bit is parit check bit. Data will be lost if software have not read from FIFO in time. If use external DMA to do that, it needs switch dmachannel(generally, DMA rx and tx are two channel). switch channel automatically are quite challenge at current dma engine framework.
I guess when data is larger than FIFO, the i3c controller (master) should 'aware' of this limitation when using such target device. So that appropriate handle like make new read command, or do a write then another larger read request.
Quoted 9 lines
Of course it will be possible if hardware implement simpilar I3C HCI command queue. But I still not found any hardware that can do that yet.
If only limited data size to FIFO size, there are still limiation for xfer. if write, read, write, read, two write may combined in one FIFO, target driver may not split it which depend on hardware detect repeat start and insert something into fifo.
It is hard to support all user case by I3C target software in linux.
Can I know the speed limitation that you having issue while running on silicon?
Quoted 38 lines
write follow by read, generally used from get hardware register value from target side, which almost impossible by software, it is not quick enough to parse (write value) then send back data.
Quoted 4 lines
In the master i3c side they don't abbreviate
i3c_master_controllertoi3c_master_ctrl. I think we should do the same here to standardize it. ThanksThe problem is in I3C spec: "master" already depericated
from i3c spec 1.1.1
"Controller: An I3C Device that is capable of controlling the I3C Bus."
master/slave => controller/target.
It will become more confused if
i3c_target_controller. "controller" are ambiguity.If "master" => "host" would be better situation, but not happen. A point, I use "ctrl" here to avoid I3C spec defined "controller" term.
Anyway, I hope more people that involve target support discussion.
Quoted 12 lines
Regards,
JoshuaQuoted 8 lines
--
2.34.1--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
Frank Li
maintainerRe: [PATCH resend v9 1/8] i3c: add target mode support
Quoted 132 lines · Joshua Yeong
Quoted 122 lines · Frank Li
Quoted 4 lines · Joshua Yeong
Quoted 3 lines · Joshua Yeong
Introduce a new target core layer in order to support target functions in linux kernel. This comprises the controller library and function
library.
Quoted 2 lines
Quoted 2 lines
Controller library implements functions specific to an target controller and function library implements functions specific to an target
function.
Quoted 95 lines
Quoted 95 lines
Introduce a new configfs entry to configure the target function configuring and bind the target function with target controller.
Signed-off-by Frank Li <[email protected]>---
Notes:
Change from v8 to v9
-noneChange from v7 to v8
Added missed head filesChange from v5 to v6
- fixed build error when have notCONFIG_TARGET_CONFIGFS| Reported-by: kernel test robot <[email protected]> | Closes:
https://lore.kernel.org/oe-kbuild-all/202402030437.GdGCrKeK-
[email protected]/Chagne from v4 to v5
- add include <linux/slab.h> to fix build error | Reported-by: kernel test robot <[email protected]> | Closes:
https://lore.kernel.org/oe-kbuild-all/202401270838.wdxHPaAT-
[email protected]/Chagne from v4 to v8
- add include <linux/slab.h> to fix build error | Reported-by: kernel test robot <[email protected]> | Closes:
https://lore.kernel.org/oe-kbuild-all/202401270838.wdxHPaAT-
[email protected]/drivers/i3c/Kconfig | 28 +- drivers/i3c/Makefile | 2 + drivers/i3c/i3c-cfs.c | 389 ++++++++++++++++++++++++++ drivers/i3c/target.c | 453 ++++++++++++++++++++++++++++++ include/linux/i3c/target.h | 548+++++++++++++++++++++++++++++++++++++
...
include/linux/i3c/target.h new file +25
-0+/** +* struct i3c_target_ctrl_ops - set of function pointers for +performing controller operations +* @set_config: set I3C controller configuration +* @enable: enable I3C controller +* @disable: disable I3C controller +* @raise_ibi: raise IBI interrupt to master +* @alloc_request: allocate a i3c_request, optional, default use +kmalloc +* @free_request: free a i3c_request, default use kfree +* @queue: queue an I3C transfer +* @dequeue: dequeue an I3C transfer +* @cancel_all_reqs: call all pending requests +* @fifo_status: current FIFO status +* @fifo_flush: flush hardware FIFO +* @hotjoin: raise hotjoin request to master +* @set_status_format1: set i3c status format1 +* @get_status_format1: get i3c status format1 +* @get_addr: get i3c dynmatic address +* @get_features: ops to get the features supported by the I3C +target controller +* @owner: the module owner containing the ops */ struct +i3c_target_ctrl_ops { +int (*set_config)(struct i3c_target_ctrl *ctrl,struct +i3c_target_func*func);
include/linux/i3c/target.h new file +6
-0+int (*enable)(struct i3c_target_ctrl *ctrl); +int (*disable)(struct i3c_target_ctrl *ctrl); +int (*raise_ibi)(struct i3c_target_ctrl *ctrl,void *p,u8 size); + +struct i3c_request *(*alloc_request)(struct i3c_target_ctrl *ctrl, +gfp_t
gfp_flags);include/linux/i3c/target.h new file +11
-0+void (*free_request)(struct i3c_request *req); + +int (*queue)(struct i3c_request *req,gfp_t gfp_flags); +int (*dequeue)(struct i3c_request *req); + +void (*cancel_all_reqs)(struct i3c_target_ctrl *ctrl,bool tx); + +int (*fifo_status)(struct i3c_target_ctrl *ctrl,bool tx); +void (*fifo_flush)(struct i3c_target_ctrl *ctrl,bool tx); +int (*hotjoin)(struct i3c_target_ctrl *ctrl); +int (*set_status_format1)(struct i3c_target_ctrl *ctrl,u16 status);Quoted 8 lines
include/linux/i3c/target.h
Quoted 6 lines
include/linux/i3c/target.h new file +3
-0+u16 (*get_status_format1)(struct i3c_target_ctrl *ctrl); +u8 (*get_addr)(struct i3c_target_ctrl *ctrl); + const struct i3c_target_ctrl_features *(*get_features)(struct
i3c_target_ctrl*ctrl);include/linux/i3c/target.h new file +2
-0+struct module *owner; +};This structure looks very different from the master controller ops
'
i3c_master_controller_ops'.Quoted 1 line
I think you could probably combine '
set_config, enable' into 'bus_init','disable' to '
bus_cleanup'.Quoted 1 line
Also using the 'struct
i3c_priv_xfer' rather redefining another 'struct
i3c_request' would be much cleaner.Thanks, let me think this.
i3c_priv_xtermay include read and write, or write and read. I3C is quite fast. Most time software are not quite enough to handle it in time.Quoted 8 lines
If data len bigger than FIFO size, it have to use DMA to transfer it because there are not flow controler at target side (write direction).
Read, hardware to use early terminate to tell host read too fast. but for write, 9th bit is parit check bit. Data will be lost if software have not read from FIFO in time. If use external DMA to do that, it needs switch dmachannel(generally, DMA rx and tx are two channel). switch channel automatically are quite challenge at current dma engine framework.
Quoted 4 lines
I guess when data is larger than FIFO, the i3c controller (master) should 'aware' of this limitation when using such target device. So that appropriate handle like make new read command, or do a write then another larger read request.
Between two commands, such as two write command, some data may lost because first one have not chance to fetch it from FIFO.
Function driver can add some recovery mathod. But still better to use modem async method to queue multi transfer and handle by dma automatically. One transfer each time are just special case for queue.
If DMA support, queue can work as big cycle buffer, underrun will never happen unless system wrong, such as disable irq over 1 second.
Actually, I worry about still i3c_priv_xfer, write followed read case. Most likely, host driver do like
write (cmd index/reg index) then read value or command result.
It is hard to decode cmd and send back data immedicately.
if there are not special DMA support, more realistic usage mode is
cmd1, cmd2, cmd3,....
send back
resp1, resp2, ....
instead of comebine cmd1 and resp1 at one transfer.
Host can do that just because all SCL are controller by host controllers.
Quoted 4 lines
Quoted 4 lines
Of course it will be possible if hardware implement simpilar I3C HCI command queue. But I still not found any hardware that can do that yet.
Quoted 8 lines
Quoted 6 lines
If only limited data size to FIFO size, there are still limiation for xfer. if write, read, write, read, two write may combined in one FIFO, target driver may not split it which depend on hardware detect repeat start and insert something into fifo.
It is hard to support all user case by I3C target software in linux.
Can I know the speed limitation that you having issue while running on silicon?
I am not sure what "speed limitation" here? Do you means irq latency issue.
when I get "stop", there are new data already come into FIFO. It is not for problem for tty case now.
But if it is well defined frame data, it may be problem.
I saw some data lost when target are busy without DMA support. driver can query how many fifo space avaible before send data, but it reduced bus utilities rate.
Quoted 39 lines
Quoted 39 lines
write follow by read, generally used from get hardware register value from target side, which almost impossible by software, it is not quick enough to parse (write value) then send back data.
Quoted 4 lines
In the master i3c side they don't abbreviate
i3c_master_controllertoi3c_master_ctrl. I think we should do the same here to standardize it. ThanksThe problem is in I3C spec: "master" already depericated
from i3c spec 1.1.1
"Controller: An I3C Device that is capable of controlling the I3C Bus."
master/slave => controller/target.
It will become more confused if
i3c_target_controller. "controller" are ambiguity.If "master" => "host" would be better situation, but not happen. A point, I use "ctrl" here to avoid I3C spec defined "controller" term.
Anyway, I hope more people that involve target support discussion.
Quoted 12 lines
Regards,
JoshuaQuoted 8 lines
--
2.34.1--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
RE: [PATCH resend v9 1/8] i3c: add target mode support
Quoted 167 lines · Frank Li
Quoted 102 lines · Joshua Yeong
Quoted 101 lines · Frank Li
Quoted 5 lines · Joshua Yeong
Quoted 4 lines · Joshua Yeong
Introduce a new target core layer in order to support target functions in linux kernel. This comprises the controller library and function
library.
Quoted 3 lines
Quoted 3 lines
Controller library implements functions specific to an target controller and function library implements functions specific to an target
function.
Quoted 90 lines
Quoted 90 lines
Introduce a new configfs entry to configure the target function configuring and bind the target function with target controller.
Signed-off-by Frank Li <[email protected]>---
Notes:
Change from v8 to v9
-noneChange from v7 to v8
Added missed head filesChange from v5 to v6
- fixed build error when have notCONFIG_TARGET_CONFIGFS| Reported-by: kernel test robot <[email protected]> | Closes:
https://lore.kernel.org/oe-kbuild-all/202402030437.GdGCrKeK-
[email protected]/Chagne from v4 to v5
- add include <linux/slab.h> to fix build error | Reported-by: kernel test robot <[email protected]> | Closes:
https://lore.kernel.org/oe-kbuild-all/202401270838.wdxHPaAT-
[email protected]/Chagne from v4 to v8
- add include <linux/slab.h> to fix build error | Reported-by: kernel test robot <[email protected]> | Closes:
https://lore.kernel.org/oe-kbuild-all/202401270838.wdxHPaAT-
[email protected]/drivers/i3c/Kconfig | 28 +- drivers/i3c/Makefile | 2 + drivers/i3c/i3c-cfs.c | 389 ++++++++++++++++++++++++++ drivers/i3c/target.c | 453 ++++++++++++++++++++++++++++++ include/linux/i3c/target.h | 548+++++++++++++++++++++++++++++++++++++
...
(quoted diff) +0
-0
b/include/linux/i3c/target.hnew file mode 100644 index 0000000000000..b0bf06685834cinclude/linux/i3c/target.h new file +25
-0+/** +* struct i3c_target_ctrl_ops - set of function pointers for +performing controller operations +* @set_config: set I3C controller configuration +* @enable: enable I3C controller +* @disable: disable I3C controller +* @raise_ibi: raise IBI interrupt to master +* @alloc_request: allocate a i3c_request, optional, default +use kmalloc +* @free_request: free a i3c_request, default use kfree +* @queue: queue an I3C transfer +* @dequeue: dequeue an I3C transfer +* @cancel_all_reqs: call all pending requests +* @fifo_status: current FIFO status +* @fifo_flush: flush hardware FIFO +* @hotjoin: raise hotjoin request to master +* @set_status_format1: set i3c status format1 +* @get_status_format1: get i3c status format1 +* @get_addr: get i3c dynmatic address +* @get_features: ops to get the features supported by the I3C +target controller +* @owner: the module owner containing the ops */ struct +i3c_target_ctrl_ops { +int (*set_config)(struct i3c_target_ctrl *ctrl,struct +i3c_target_func*func);
include/linux/i3c/target.h new file +7
-0+int (*enable)(struct i3c_target_ctrl *ctrl); +int (*disable)(struct i3c_target_ctrl *ctrl); +int (*raise_ibi)(struct i3c_target_ctrl *ctrl,void *p,u8 +size); + +struct i3c_request *(*alloc_request)(struct i3c_target_ctrl +*ctrl, gfp_t
gfp_flags);include/linux/i3c/target.h new file +4
-0+void (*free_request)(struct i3c_request *req); + +int (*queue)(struct i3c_request *req,gfp_t gfp_flags); +int (*dequeue)(struct i3c_request *req);Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
include/linux/i3c/target.h
Quoted 8 lines
include/linux/i3c/target.h new file +8
-0+ +void (*cancel_all_reqs)(struct i3c_target_ctrl *ctrl,bool +tx); + +int (*fifo_status)(struct i3c_target_ctrl *ctrl,bool tx); +void (*fifo_flush)(struct i3c_target_ctrl *ctrl,bool tx); +int (*hotjoin)(struct i3c_target_ctrl *ctrl); + int (*set_status_format1)(struct i3c_target_ctrl *ctrl, u16status);
Quoted 20 lines
Quoted 20 lines
Quoted 8 lines
include/linux/i3c/target.h
Quoted 6 lines
include/linux/i3c/target.h new file +3
-0+u16 (*get_status_format1)(struct i3c_target_ctrl *ctrl); +u8 (*get_addr)(struct i3c_target_ctrl *ctrl); + const struct i3c_target_ctrl_features *(*get_features)(struct
i3c_target_ctrl*ctrl);include/linux/i3c/target.h new file +2
-0+struct module *owner; +};This structure looks very different from the master controller ops
'
i3c_master_controller_ops'.Quoted 2 lines
I think you could probably combine '
set_config, enable' into 'bus_init','disable' to '
bus_cleanup'.Quoted 2 lines
Also using the 'struct
i3c_priv_xfer' rather redefining another 'struct
i3c_request' would be much cleaner.Thanks, let me think this.
i3c_priv_xtermay include read and write, or write and read. I3C is quite fast. Most time software are not quite enough to handle it in time.Quoted 7 lines
Quoted 7 lines
If data len bigger than FIFO size, it have to use DMA to transfer it because there are not flow controler at target side (write direction). Read, hardware to use early terminate to tell host read too fast. but for write, 9th bit is parit check bit. Data will be lost if software have not read from FIFO in time. If use external DMA to do that, it needs switch dma
channel(generally, DMA rx and tx are two channel). switch channel automatically are quite challenge at current dmaengine framework.
Quoted 6 lines
Quoted 1 line
I guess when data is larger than FIFO, the i3c controller (master) should 'aware' of this limitation when using such target device. So that appropriate handle like make new read command, or do a write then another larger read request.
Between two commands, such as two write command, some data may lost because first one have not chance to fetch it from FIFO.
Function driver can add some recovery mathod. But still better to use modem async method to queue multi transfer and handle by dma automatically. One transfer each time are just special case for queue.
If DMA support, queue can work as big cycle buffer, underrun will never happen unless system wrong, such as disable irq over 1 second.
Actually, I worry about still
i3c_priv_xfer, write followed read case. Most likely, host driver do likewrite (cmd index/reg index) then read value or command result.
It is hard to decode cmd and send back data immedicately.
if there are not special DMA support, more realistic usage mode is
Quoted 8 lines
cmd1, cmd2, cmd3,....
send back
resp1, resp2, ....instead of comebine cmd1 and resp1 at one transfer.
Host can do that just because all SCL are controller by host controllers.
The DMA queue mechanism should still be invisible to the framework. Target could use info from SETMRL/SETMWL to 'prepare' whether internally DMA is needed.
We can also argue that the max read length should always not larger than the FIFO size. Slave data transfer interface should still match what i3c spec expect to be, rather than the hardware limitation here.
Quoted 65 lines
Quoted 5 lines
Quoted 5 lines
Of course it will be possible if hardware implement simpilar I3C HCI command queue. But I still not found any hardware that can do that yet.
Quoted 8 lines
Quoted 6 lines
If only limited data size to FIFO size, there are still limiation for xfer. if write, read, write, read, two write may combined in one FIFO, target driver may not split it which depend on hardware detect repeat start and insert something into fifo.
It is hard to support all user case by I3C target software in linux.
Can I know the speed limitation that you having issue while running on
silicon?
I am not sure what "speed limitation" here? Do you means irq latency issue.
when I get "stop", there are new data already come into FIFO. It is not for problem for tty case now.
But if it is well defined frame data, it may be problem.
I saw some data lost when target are busy without DMA support. driver can query how many fifo space avaible before send data, but it reduced bus utilities rate.
Quoted 39 lines
Quoted 39 lines
write follow by read, generally used from get hardware register value from target side, which almost impossible by software, it is not quick enough to parse (write value) then send back data.
Quoted 4 lines
In the master i3c side they don't abbreviate
i3c_master_controllertoi3c_master_ctrl. I think we should do the same here to standardize it. ThanksThe problem is in I3C spec: "master" already depericated
from i3c spec 1.1.1
"Controller: An I3C Device that is capable of controlling the I3C Bus."
master/slave => controller/target.
It will become more confused if
i3c_target_controller. "controller" are ambiguity.If "master" => "host" would be better situation, but not happen. A point, I use "ctrl" here to avoid I3C spec defined "controller" term.
Anyway, I hope more people that involve target support discussion.
Quoted 12 lines
Regards,
JoshuaQuoted 8 lines
--
2.34.1--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
Frank Li
maintainerRe: [PATCH resend v9 1/8] i3c: add target mode support
Quoted 173 lines · Joshua Yeong
Quoted 172 lines · Frank Li
Quoted 102 lines · Joshua Yeong
Quoted 101 lines · Frank Li
Quoted 5 lines · Joshua Yeong
Quoted 4 lines · Joshua Yeong
Introduce a new target core layer in order to support target functions in linux kernel. This comprises the controller library and function
library.
Quoted 3 lines
Quoted 3 lines
Controller library implements functions specific to an target controller and function library implements functions specific to an target
function.
Quoted 90 lines
Quoted 90 lines
Introduce a new configfs entry to configure the target function configuring and bind the target function with target controller.
Signed-off-by Frank Li <[email protected]>---
Notes:
Change from v8 to v9
-noneChange from v7 to v8
Added missed head filesChange from v5 to v6
- fixed build error when have notCONFIG_TARGET_CONFIGFS| Reported-by: kernel test robot <[email protected]> | Closes:
https://lore.kernel.org/oe-kbuild-all/202402030437.GdGCrKeK-
[email protected]/Chagne from v4 to v5
- add include <linux/slab.h> to fix build error | Reported-by: kernel test robot <[email protected]> | Closes:
https://lore.kernel.org/oe-kbuild-all/202401270838.wdxHPaAT-
[email protected]/Chagne from v4 to v8
- add include <linux/slab.h> to fix build error | Reported-by: kernel test robot <[email protected]> | Closes:
https://lore.kernel.org/oe-kbuild-all/202401270838.wdxHPaAT-
[email protected]/drivers/i3c/Kconfig | 28 +- drivers/i3c/Makefile | 2 + drivers/i3c/i3c-cfs.c | 389 ++++++++++++++++++++++++++ drivers/i3c/target.c | 453 ++++++++++++++++++++++++++++++ include/linux/i3c/target.h | 548+++++++++++++++++++++++++++++++++++++
...
(quoted diff) +0
-0
b/include/linux/i3c/target.hnew file mode 100644 index 0000000000000..b0bf06685834cinclude/linux/i3c/target.h new file +25
-0+/** +* struct i3c_target_ctrl_ops - set of function pointers for +performing controller operations +* @set_config: set I3C controller configuration +* @enable: enable I3C controller +* @disable: disable I3C controller +* @raise_ibi: raise IBI interrupt to master +* @alloc_request: allocate a i3c_request, optional, default +use kmalloc +* @free_request: free a i3c_request, default use kfree +* @queue: queue an I3C transfer +* @dequeue: dequeue an I3C transfer +* @cancel_all_reqs: call all pending requests +* @fifo_status: current FIFO status +* @fifo_flush: flush hardware FIFO +* @hotjoin: raise hotjoin request to master +* @set_status_format1: set i3c status format1 +* @get_status_format1: get i3c status format1 +* @get_addr: get i3c dynmatic address +* @get_features: ops to get the features supported by the I3C +target controller +* @owner: the module owner containing the ops */ struct +i3c_target_ctrl_ops { +int (*set_config)(struct i3c_target_ctrl *ctrl,struct +i3c_target_func*func);
include/linux/i3c/target.h new file +7
-0+int (*enable)(struct i3c_target_ctrl *ctrl); +int (*disable)(struct i3c_target_ctrl *ctrl); +int (*raise_ibi)(struct i3c_target_ctrl *ctrl,void *p,u8 +size); + +struct i3c_request *(*alloc_request)(struct i3c_target_ctrl +*ctrl, gfp_t
gfp_flags);include/linux/i3c/target.h new file +4
-0+void (*free_request)(struct i3c_request *req); + +int (*queue)(struct i3c_request *req,gfp_t gfp_flags); +int (*dequeue)(struct i3c_request *req);Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
include/linux/i3c/target.h
Quoted 8 lines
include/linux/i3c/target.h new file +8
-0+ +void (*cancel_all_reqs)(struct i3c_target_ctrl *ctrl,bool +tx); + +int (*fifo_status)(struct i3c_target_ctrl *ctrl,bool tx); +void (*fifo_flush)(struct i3c_target_ctrl *ctrl,bool tx); +int (*hotjoin)(struct i3c_target_ctrl *ctrl); + int (*set_status_format1)(struct i3c_target_ctrl *ctrl, u16status);
Quoted 20 lines
Quoted 20 lines
Quoted 8 lines
include/linux/i3c/target.h
Quoted 6 lines
include/linux/i3c/target.h new file +3
-0+u16 (*get_status_format1)(struct i3c_target_ctrl *ctrl); +u8 (*get_addr)(struct i3c_target_ctrl *ctrl); + const struct i3c_target_ctrl_features *(*get_features)(struct
i3c_target_ctrl*ctrl);include/linux/i3c/target.h new file +2
-0+struct module *owner; +};This structure looks very different from the master controller ops
'
i3c_master_controller_ops'.Quoted 2 lines
I think you could probably combine '
set_config, enable' into 'bus_init','disable' to '
bus_cleanup'.Quoted 2 lines
Also using the 'struct
i3c_priv_xfer' rather redefining another 'struct
i3c_request' would be much cleaner.Thanks, let me think this.
i3c_priv_xtermay include read and write, or write and read. I3C is quite fast. Most time software are not quite enough to handle it in time.Quoted 7 lines
Quoted 7 lines
If data len bigger than FIFO size, it have to use DMA to transfer it because there are not flow controler at target side (write direction). Read, hardware to use early terminate to tell host read too fast. but for write, 9th bit is parit check bit. Data will be lost if software have not read from FIFO in time. If use external DMA to do that, it needs switch dma
channel(generally, DMA rx and tx are two channel). switch channel automatically are quite challenge at current dmaengine framework.
Quoted 6 lines
Quoted 1 line
I guess when data is larger than FIFO, the i3c controller (master) should 'aware' of this limitation when using such target device. So that appropriate handle like make new read command, or do a write then another larger read request.
Between two commands, such as two write command, some data may lost because first one have not chance to fetch it from FIFO.
Function driver can add some recovery mathod. But still better to use modem async method to queue multi transfer and handle by dma automatically. One transfer each time are just special case for queue.
If DMA support, queue can work as big cycle buffer, underrun will never happen unless system wrong, such as disable irq over 1 second.
Actually, I worry about still
i3c_priv_xfer, write followed read case. Most likely, host driver do likewrite (cmd index/reg index) then read value or command result.
It is hard to decode cmd and send back data immedicately.
if there are not special DMA support, more realistic usage mode is
cmd1, cmd2, cmd3,....
send back
resp1, resp2, ....
Quoted 7 lines
Quoted 3 lines
instead of comebine cmd1 and resp1 at one transfer.
Host can do that just because all SCL are controller by host controllers.
The DMA queue mechanism should still be invisible to the framework. Target could use info from SETMRL/SETMWL to 'prepare' whether internally DMA is needed.
You are right. DMA should be invisiable to the framework, but framework need provide API to prepare receiver buffer advance before transfer happen. Only function driver know how much data need be prepared advance. For host read/target write case, It also need cancel request function incase host have not fetch data in certain time. Data need be updated. function driver can't simple update data buffer, because it may already map to DMA. function driver need dequeue and queue request again.
framework should abstract common part of difference i3c target controller and target function driver to avoid duplicate code.
And also need consider linux's irq latency limiation, try to make the function driver can work on all target controller drivers.
I think priv_xfer, W, R, ... are hard to implement. Maybe limit priv_xfer 's len to 1 or 2. But if limited to 1, it becames no big difference with current implement.
Quoted 5 lines
We can also argue that the max read length should always not larger than the FIFO size. Slave data transfer interface should still match what i3c spec expect to be, rather than the hardware limitation here.
According to spec:
5.1.9.3.5 Maximum write length in a single command
I am not resure "singe command here". I think it should be between "start" and "repeat start/stop".
If my understand is correct, host still send out W R W R ... as whole I3C transaction, each one less than FIFO size. but totally size may exceed FIFO size.
Quoted 66 lines
Quoted 66 lines
Quoted 6 lines
Quoted 6 lines
Of course it will be possible if hardware implement simpilar I3C HCI command queue. But I still not found any hardware that can do that yet.
Quoted 8 lines
Quoted 6 lines
If only limited data size to FIFO size, there are still limiation for xfer. if write, read, write, read, two write may combined in one FIFO, target driver may not split it which depend on hardware detect repeat start and insert something into fifo.
It is hard to support all user case by I3C target software in linux.
Can I know the speed limitation that you having issue while running on
silicon?
I am not sure what "speed limitation" here? Do you means irq latency issue.
when I get "stop", there are new data already come into FIFO. It is not for problem for tty case now.
But if it is well defined frame data, it may be problem.
I saw some data lost when target are busy without DMA support. driver can query how many fifo space avaible before send data, but it reduced bus utilities rate.
Quoted 39 lines
Quoted 39 lines
write follow by read, generally used from get hardware register value from target side, which almost impossible by software, it is not quick enough to parse (write value) then send back data.
Quoted 4 lines
In the master i3c side they don't abbreviate
i3c_master_controllertoi3c_master_ctrl. I think we should do the same here to standardize it. ThanksThe problem is in I3C spec: "master" already depericated
from i3c spec 1.1.1
"Controller: An I3C Device that is capable of controlling the I3C Bus."
master/slave => controller/target.
It will become more confused if
i3c_target_controller. "controller" are ambiguity.If "master" => "host" would be better situation, but not happen. A point, I use "ctrl" here to avoid I3C spec defined "controller" term.
Anyway, I hope more people that involve target support discussion.
Quoted 12 lines
Regards,
JoshuaQuoted 8 lines
--
2.34.1--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
RE: [PATCH resend v9 1/8] i3c: add target mode support
Quoted 198 lines · Frank Li
Quoted 10 lines · Joshua Yeong
Quoted 9 lines · Frank Li
Quoted 7 lines · Joshua Yeong
Quoted 6 lines · Frank Li
Quoted 5 lines · Joshua Yeong
Quoted 4 lines · Joshua Yeong
Introduce a new target core layer in order to support target functions in linux kernel. This comprises the controller library and function
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
library.
Quoted 3 lines
Quoted 3 lines
Controller library implements functions specific to an target controller and function library implements functions specific to an target
function.
Quoted 3 lines
Quoted 3 lines
Introduce a new configfs entry to configure the target function configuring and bind the target function with target
controller.
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Signed-off-by Frank Li <[email protected]>---
Notes:
Change from v8 to v9
-noneChange from v7 to v8
Added missed head filesChange from v5 to v6
- fixed build error when have notCONFIG_TARGET_CONFIGFS| Reported-by: kernel test robot <[email protected]> | Closes:
https://lore.kernel.org/oe-kbuild-all/202402030437.GdGCrKeK-
[email protected]/Chagne from v4 to v5
- add include <linux/slab.h> to fix build error | Reported-by: kernel test robot <[email protected]> | Closes:
https://lore.kernel.org/oe-kbuild-all/202401270838.wdxHPaAT-
[email protected]/Chagne from v4 to v8
- add include <linux/slab.h> to fix build error | Reported-by: kernel test robot <[email protected]> | Closes:
https://lore.kernel.org/oe-kbuild-all/202401270838.wdxHPaAT-
[email protected]/Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/i3c/Kconfig | 28 +- drivers/i3c/Makefile | 2 + drivers/i3c/i3c-cfs.c | 389 ++++++++++++++++++++++++++ drivers/i3c/target.c | 453++++++++++++++++++++++++++++++
Quoted 77 lines
Quoted 77 lines
Quoted 52 lines
Quoted 52 lines
Quoted 52 lines
Quoted 52 lines
include/linux/i3c/target.h | 548+++++++++++++++++++++++++++++++++++++
...
(quoted diff) +0
-0
b/include/linux/i3c/target.hnew file mode 100644 index 0000000000000..b0bf06685834cinclude/linux/i3c/target.h new file +25
-0+/** +* struct i3c_target_ctrl_ops - set of function pointers +for performing controller operations +* @set_config: set I3C controller configuration +* @enable: enable I3C controller +* @disable: disable I3C controller +* @raise_ibi: raise IBI interrupt to master +* @alloc_request: allocate a i3c_request, optional, +default use kmalloc +* @free_request: free a i3c_request, default use kfree +* @queue: queue an I3C transfer +* @dequeue: dequeue an I3C transfer +* @cancel_all_reqs: call all pending requests +* @fifo_status: current FIFO status +* @fifo_flush: flush hardware FIFO +* @hotjoin: raise hotjoin request to master +* @set_status_format1: set i3c status format1 +* @get_status_format1: get i3c status format1 +* @get_addr: get i3c dynmatic address +* @get_features: ops to get the features supported by the +I3C target controller +* @owner: the module owner containing the ops */ struct +i3c_target_ctrl_ops { +int (*set_config)(struct i3c_target_ctrl *ctrl,struct +i3c_target_func*func);
include/linux/i3c/target.h new file +7
-0+int (*enable)(struct i3c_target_ctrl *ctrl); +int (*disable)(struct i3c_target_ctrl *ctrl); +int (*raise_ibi)(struct i3c_target_ctrl *ctrl,void *p,u8 +size); + +struct i3c_request *(*alloc_request)(struct +i3c_target_ctrl *ctrl, gfp_t
gfp_flags);include/linux/i3c/target.h new file +5
-0+void (*free_request)(struct i3c_request *req); + +int (*queue)(struct i3c_request *req,gfp_t gfp_flags); +int (*dequeue)(struct i3c_request *req); +Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
include/linux/i3c/target.h
Quoted 8 lines
include/linux/i3c/target.h new file +8
-0+void (*cancel_all_reqs)(struct i3c_target_ctrl *ctrl,bool +tx); + +int (*fifo_status)(struct i3c_target_ctrl *ctrl,bool tx); +void (*fifo_flush)(struct i3c_target_ctrl *ctrl,bool tx); +int (*hotjoin)(struct i3c_target_ctrl *ctrl); +int (*set_status_format1)(struct i3c_target_ctrl *ctrl, +u16status);
Quoted 16 lines
Quoted 16 lines
Quoted 10 lines
include/linux/i3c/target.h
Quoted 7 lines
include/linux/i3c/target.h new file +4
-0+u16 (*get_status_format1)(struct i3c_target_ctrl *ctrl); +u8 (*get_addr)(struct i3c_target_ctrl *ctrl); +const struct i3c_target_ctrl_features +*(*get_features)(struct
i3c_target_ctrl*ctrl);include/linux/i3c/target.h new file +2
-0+struct module *owner; +};This structure looks very different from the master controller ops
'
i3c_master_controller_ops'.Quoted 2 lines
I think you could probably combine '
set_config, enable' into 'bus_init','disable' to '
bus_cleanup'.Quoted 2 lines
Also using the 'struct
i3c_priv_xfer' rather redefining another 'structQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
i3c_request' would be much cleaner.Thanks, let me think this.
i3c_priv_xtermay include read and write, or write and read. I3C is quite fast. Most time software are not quite enough to handle it in time.If data len bigger than FIFO size, it have to use DMA to transfer it because there are not flow controler at target side (write
direction).
Quoted 38 lines
Quoted 38 lines
Quoted 6 lines
Quoted 6 lines
Read, hardware to use early terminate to tell host read too fast. but for write, 9th bit is parit check bit. Data will be lost if software have not read from FIFO in time. If use external DMA to do that, it needs switch dma
channel(generally, DMA rx and tx are two channel). switch channel automatically are quite challenge at current dmaengine framework.
Quoted 6 lines
Quoted 1 line
I guess when data is larger than FIFO, the i3c controller (master) should 'aware' of this limitation when using such target device. So that appropriate handle like make new read command, or do a write then another larger read request.
Between two commands, such as two write command, some data may lost because first one have not chance to fetch it from FIFO.
Function driver can add some recovery mathod. But still better to use modem async method to queue multi transfer and handle by dma automatically. One transfer each time are just special case for queue.
If DMA support, queue can work as big cycle buffer, underrun will never happen unless system wrong, such as disable irq over 1 second.
Actually, I worry about still
i3c_priv_xfer, write followed read case. Most likely, host driver do likewrite (cmd index/reg index) then read value or command result.
It is hard to decode cmd and send back data immedicately.
if there are not special DMA support, more realistic usage mode is
cmd1, cmd2, cmd3,....
send back
resp1, resp2, ....Quoted 7 lines
Quoted 3 lines
instead of comebine cmd1 and resp1 at one transfer.
Host can do that just because all SCL are controller by host controllers.
The DMA queue mechanism should still be invisible to the framework. Target could use info from SETMRL/SETMWL to 'prepare' whether internally DMA is needed.
You are right. DMA should be invisiable to the framework, but framework need provide API to prepare receiver buffer advance before transfer happen. Only function driver know how much data need be prepared advance. For host read/target write case, It also need cancel request function incase host have not fetch data in certain time. Data need be updated. function driver can't simple update data buffer, because it may already map to DMA. function driver need dequeue and queue request again.
Quoted 9 lines
framework should abstract common part of difference i3c target controller and target function driver to avoid duplicate code.
And also need consider linux's irq latency limiation, try to make the function driver can work on all target controller drivers.
I think
priv_xfer, W, R, ... are hard to implement. Maybe limitpriv_xfer's len to 1 or 2. But if limited to 1, it becames no big difference with current implement.
I think if the target unable to handle multiple transaction I think it is safe to throw NACK. In the case small transaction is needed we can still use the same 'struc i3c_priv_xfer'. If it is large transaction and target unable to support multiple transaction it should be the target limitation rather than limiting every target private transfer here.
Quoted 86 lines
Quoted 5 lines
We can also argue that the max read length should always not larger than the FIFO size. Slave data transfer interface should still match what i3c spec expect to be, rather than the hardware limitation here.
According to spec:
5.1.9.3.5 Maximum write length in a single commandI am not resure "singe command here". I think it should be between "start" and "repeat start/stop".
If my understand is correct, host still send out W R W R ... as whole I3C transaction, each one less than FIFO size. but totally size may exceed FIFO size.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Of course it will be possible if hardware implement simpilar I3C HCI command queue. But I still not found any hardware that can do
that yet.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
If only limited data size to FIFO size, there are still limiation for xfer. if write, read, write, read, two write may combined in one FIFO, target driver may not split it which depend on hardware detect repeat start and insert something into fifo.
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
It is hard to support all user case by I3C target software in linux.
Can I know the speed limitation that you having issue while running on
silicon?
I am not sure what "speed limitation" here? Do you means irq latency
issue.
Quoted 12 lines
Quoted 12 lines
when I get "stop", there are new data already come into FIFO. It is not for problem for tty case now.
But if it is well defined frame data, it may be problem.
I saw some data lost when target are busy without DMA support. driver can query how many fifo space avaible before send data, but it reduced bus utilities rate.
Quoted 2 lines
Quoted 2 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
write follow by read, generally used from get hardware register value from target side, which almost impossible by software, it is not quick enough to parse (write value) then send back data.
Quoted 3 lines
In the master i3c side they don't abbreviate
i3c_master_controllertoi3c_master_ctrl. I think we should do thesame here to standardize it.
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 1 line
Thanks
The problem is in I3C spec: "master" already depericated
from i3c spec 1.1.1
"Controller: An I3C Device that is capable of controlling the I3C Bus."
master/slave => controller/target.
It will become more confused if
i3c_target_controller. "controller" are ambiguity.If "master" => "host" would be better situation, but not happen. A point, I use "ctrl" here to avoid I3C spec defined "controller" term.
Anyway, I hope more people that involve target support discussion.
Quoted 12 lines
Regards,
JoshuaQuoted 8 lines
--
2.34.1--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
Frank Li
maintainerRe: [PATCH resend v9 1/8] i3c: add target mode support
Quoted 209 lines · Joshua Yeong
Quoted 198 lines · Frank Li
Quoted 10 lines · Joshua Yeong
Quoted 9 lines · Frank Li
Quoted 7 lines · Joshua Yeong
Quoted 6 lines · Frank Li
Quoted 5 lines · Joshua Yeong
Quoted 4 lines · Joshua Yeong
Introduce a new target core layer in order to support target functions in linux kernel. This comprises the controller library and function
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
library.
Quoted 3 lines
Quoted 3 lines
Controller library implements functions specific to an target controller and function library implements functions specific to an target
function.
Quoted 3 lines
Quoted 3 lines
Introduce a new configfs entry to configure the target function configuring and bind the target function with target
controller.
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Signed-off-by Frank Li <[email protected]>---
Notes:
Change from v8 to v9
-noneChange from v7 to v8
Added missed head filesChange from v5 to v6
- fixed build error when have notCONFIG_TARGET_CONFIGFS| Reported-by: kernel test robot <[email protected]> | Closes:
https://lore.kernel.org/oe-kbuild-all/202402030437.GdGCrKeK-
[email protected]/Chagne from v4 to v5
- add include <linux/slab.h> to fix build error | Reported-by: kernel test robot <[email protected]> | Closes:
https://lore.kernel.org/oe-kbuild-all/202401270838.wdxHPaAT-
[email protected]/Chagne from v4 to v8
- add include <linux/slab.h> to fix build error | Reported-by: kernel test robot <[email protected]> | Closes:
https://lore.kernel.org/oe-kbuild-all/202401270838.wdxHPaAT-
[email protected]/Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/i3c/Kconfig | 28 +- drivers/i3c/Makefile | 2 + drivers/i3c/i3c-cfs.c | 389 ++++++++++++++++++++++++++ drivers/i3c/target.c | 453++++++++++++++++++++++++++++++
Quoted 77 lines
Quoted 77 lines
Quoted 52 lines
Quoted 52 lines
Quoted 52 lines
Quoted 52 lines
include/linux/i3c/target.h | 548+++++++++++++++++++++++++++++++++++++
...
(quoted diff) +0
-0
b/include/linux/i3c/target.hnew file mode 100644 index 0000000000000..b0bf06685834cinclude/linux/i3c/target.h new file +25
-0+/** +* struct i3c_target_ctrl_ops - set of function pointers +for performing controller operations +* @set_config: set I3C controller configuration +* @enable: enable I3C controller +* @disable: disable I3C controller +* @raise_ibi: raise IBI interrupt to master +* @alloc_request: allocate a i3c_request, optional, +default use kmalloc +* @free_request: free a i3c_request, default use kfree +* @queue: queue an I3C transfer +* @dequeue: dequeue an I3C transfer +* @cancel_all_reqs: call all pending requests +* @fifo_status: current FIFO status +* @fifo_flush: flush hardware FIFO +* @hotjoin: raise hotjoin request to master +* @set_status_format1: set i3c status format1 +* @get_status_format1: get i3c status format1 +* @get_addr: get i3c dynmatic address +* @get_features: ops to get the features supported by the +I3C target controller +* @owner: the module owner containing the ops */ struct +i3c_target_ctrl_ops { +int (*set_config)(struct i3c_target_ctrl *ctrl,struct +i3c_target_func*func);
include/linux/i3c/target.h new file +7
-0+int (*enable)(struct i3c_target_ctrl *ctrl); +int (*disable)(struct i3c_target_ctrl *ctrl); +int (*raise_ibi)(struct i3c_target_ctrl *ctrl,void *p,u8 +size); + +struct i3c_request *(*alloc_request)(struct +i3c_target_ctrl *ctrl, gfp_t
gfp_flags);include/linux/i3c/target.h new file +5
-0+void (*free_request)(struct i3c_request *req); + +int (*queue)(struct i3c_request *req,gfp_t gfp_flags); +int (*dequeue)(struct i3c_request *req); +Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
include/linux/i3c/target.h
Quoted 8 lines
include/linux/i3c/target.h new file +8
-0+void (*cancel_all_reqs)(struct i3c_target_ctrl *ctrl,bool +tx); + +int (*fifo_status)(struct i3c_target_ctrl *ctrl,bool tx); +void (*fifo_flush)(struct i3c_target_ctrl *ctrl,bool tx); +int (*hotjoin)(struct i3c_target_ctrl *ctrl); +int (*set_status_format1)(struct i3c_target_ctrl *ctrl, +u16status);
Quoted 16 lines
Quoted 16 lines
Quoted 10 lines
include/linux/i3c/target.h
Quoted 7 lines
include/linux/i3c/target.h new file +4
-0+u16 (*get_status_format1)(struct i3c_target_ctrl *ctrl); +u8 (*get_addr)(struct i3c_target_ctrl *ctrl); +const struct i3c_target_ctrl_features +*(*get_features)(struct
i3c_target_ctrl*ctrl);include/linux/i3c/target.h new file +2
-0+struct module *owner; +};This structure looks very different from the master controller ops
'
i3c_master_controller_ops'.Quoted 2 lines
I think you could probably combine '
set_config, enable' into 'bus_init','disable' to '
bus_cleanup'.Quoted 2 lines
Also using the 'struct
i3c_priv_xfer' rather redefining another 'structQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
i3c_request' would be much cleaner.Thanks, let me think this.
i3c_priv_xtermay include read and write, or write and read. I3C is quite fast. Most time software are not quite enough to handle it in time.If data len bigger than FIFO size, it have to use DMA to transfer it because there are not flow controler at target side (write
direction).
Quoted 38 lines
Quoted 38 lines
Quoted 6 lines
Quoted 6 lines
Read, hardware to use early terminate to tell host read too fast. but for write, 9th bit is parit check bit. Data will be lost if software have not read from FIFO in time. If use external DMA to do that, it needs switch dma
channel(generally, DMA rx and tx are two channel). switch channel automatically are quite challenge at current dmaengine framework.
Quoted 6 lines
Quoted 1 line
I guess when data is larger than FIFO, the i3c controller (master) should 'aware' of this limitation when using such target device. So that appropriate handle like make new read command, or do a write then another larger read request.
Between two commands, such as two write command, some data may lost because first one have not chance to fetch it from FIFO.
Function driver can add some recovery mathod. But still better to use modem async method to queue multi transfer and handle by dma automatically. One transfer each time are just special case for queue.
If DMA support, queue can work as big cycle buffer, underrun will never happen unless system wrong, such as disable irq over 1 second.
Actually, I worry about still
i3c_priv_xfer, write followed read case. Most likely, host driver do likewrite (cmd index/reg index) then read value or command result.
It is hard to decode cmd and send back data immedicately.
if there are not special DMA support, more realistic usage mode is
cmd1, cmd2, cmd3,....
send back
resp1, resp2, ....Quoted 7 lines
Quoted 3 lines
instead of comebine cmd1 and resp1 at one transfer.
Host can do that just because all SCL are controller by host controllers.
The DMA queue mechanism should still be invisible to the framework. Target could use info from SETMRL/SETMWL to 'prepare' whether internally DMA is needed.
You are right. DMA should be invisiable to the framework, but framework need provide API to prepare receiver buffer advance before transfer happen. Only function driver know how much data need be prepared advance. For host read/target write case, It also need cancel request function incase host have not fetch data in certain time. Data need be updated. function driver can't simple update data buffer, because it may already map to DMA. function driver need dequeue and queue request again.
Quoted 9 lines
framework should abstract common part of difference i3c target controller and target function driver to avoid duplicate code.
And also need consider linux's irq latency limiation, try to make the function driver can work on all target controller drivers.
I think
priv_xfer, W, R, ... are hard to implement. Maybe limitpriv_xfer's len to 1 or 2. But if limited to 1, it becames no big difference with current implement.
Quoted 6 lines
I think if the target unable to handle multiple transaction I think it is safe to throw NACK. In the case small transaction is needed we can still use the same 'struc
i3c_priv_xfer'. If it is large transaction and target unable to support multiple transaction it should be the target limitation rather than limiting every target private transfer here.
Do you have any actual user case for i3c target? So I will have better overy all view?
Frank
Quoted 86 lines
Quoted 86 lines
Quoted 5 lines
We can also argue that the max read length should always not larger than the FIFO size. Slave data transfer interface should still match what i3c spec expect to be, rather than the hardware limitation here.
According to spec:
5.1.9.3.5 Maximum write length in a single commandI am not resure "singe command here". I think it should be between "start" and "repeat start/stop".
If my understand is correct, host still send out W R W R ... as whole I3C transaction, each one less than FIFO size. but totally size may exceed FIFO size.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Of course it will be possible if hardware implement simpilar I3C HCI command queue. But I still not found any hardware that can do
that yet.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
If only limited data size to FIFO size, there are still limiation for xfer. if write, read, write, read, two write may combined in one FIFO, target driver may not split it which depend on hardware detect repeat start and insert something into fifo.
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
It is hard to support all user case by I3C target software in linux.
Can I know the speed limitation that you having issue while running on
silicon?
I am not sure what "speed limitation" here? Do you means irq latency
issue.
Quoted 12 lines
Quoted 12 lines
when I get "stop", there are new data already come into FIFO. It is not for problem for tty case now.
But if it is well defined frame data, it may be problem.
I saw some data lost when target are busy without DMA support. driver can query how many fifo space avaible before send data, but it reduced bus utilities rate.
Quoted 2 lines
Quoted 2 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
write follow by read, generally used from get hardware register value from target side, which almost impossible by software, it is not quick enough to parse (write value) then send back data.
Quoted 3 lines
In the master i3c side they don't abbreviate
i3c_master_controllertoi3c_master_ctrl. I think we should do thesame here to standardize it.
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 1 line
Thanks
The problem is in I3C spec: "master" already depericated
from i3c spec 1.1.1
"Controller: An I3C Device that is capable of controlling the I3C Bus."
master/slave => controller/target.
It will become more confused if
i3c_target_controller. "controller" are ambiguity.If "master" => "host" would be better situation, but not happen. A point, I use "ctrl" here to avoid I3C spec defined "controller" term.
Anyway, I hope more people that involve target support discussion.
Quoted 12 lines
Regards,
JoshuaQuoted 8 lines
--
2.34.1--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
Frank Li
maintainerPATCH RESEND v9 2/8 dt-bindings: i3c: svc: add proptery mode
In reply to Frank LiAdd 'mode' property to distinguish between 'controller' and 'target' modes.
---
Notes:
Change from v6 to v9
- none
Change from v4 to v5
- add Krzysztof Kozlowski's review tag
Change from v3 to v4
-fix dtb check error
Change from v2 to v3
- using 'mode' distringuish master and target mode
.../devicetree/bindings/i3c/silvaco,i3c-master.yaml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/i3c/silvaco,i3c-master.yaml +10 -1
@@ -4,7 +4,7 @@ $id: http://devicetree.org/schemas/i3c/silvaco,i3c-master.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: Silvaco I3C master +title: Silvaco I3C master/target maintainers: - Conor Culhane <[email protected]>
@@ -22,6 +22,15 @@ properties: interrupts: maxItems: 1 + mode: + description: + Tells Dual-Role I3C controllers that we want to work on a particular + mode. In case this attribute isn't passed via DT, I3C controllers + should default to 'controller'. + $ref: /schemas/types.yaml#/definitions/string + enum: [controller, target] + default: controller + clocks: items: - description: system clock
Signature · 1 line
2.34.1
Frank Li
maintainerPATCH RESEND v9 3/8 Documentation: i3c: Add I3C target mode controller and function
In reply to Frank LiAdd I3C target mode and tty over i3c func driver document.
--- Documentation/driver-api/i3c/index.rst | 1 + .../driver-api/i3c/target/i3c-target-cfs.rst | 109 ++++++++++ .../driver-api/i3c/target/i3c-target.rst | 189 ++++++++++++++++++ .../driver-api/i3c/target/i3c-tty-howto.rst | 109 ++++++++++ Documentation/driver-api/i3c/target/index.rst | 13 ++ 5 files changed, 421 insertions(+) create mode 100644 Documentation/driver-api/i3c/target/i3c-target-cfs.rst create mode 100644 Documentation/driver-api/i3c/target/i3c-target.rst create mode 100644 Documentation/driver-api/i3c/target/i3c-tty-howto.rst create mode 100644 Documentation/driver-api/i3c/target/index.rst
Documentation/driver-api/i3c/index.rst +1 -0
@@ -9,3 +9,4 @@ I3C subsystem protocol device-driver-api master-driver-api + target/index
Documentation/driver-api/i3c/target/i3c-target-cfs.rst new file +109 -0
109 lines not on this page · raw message
Documentation/driver-api/i3c/target/i3c-target.rst new file +189 -0
189 lines not on this page · raw message
Documentation/driver-api/i3c/target/i3c-tty-howto.rst new file +109 -0
109 lines not on this page · raw message
Documentation/driver-api/i3c/target/index.rst new file +13 -0
@@ -0,0 +1,13 @@ +.. SPDX-License-Identifier: GPL-2.0 + +====================== +I3C Target Framework +====================== + +.. toctree:: + :maxdepth: 2 + + i3c-target + i3c-target-cfs + i3c-tty-howto +
Signature · 1 line
2.34.1
Frank Li
maintainerPATCH RESEND v9 4/8 i3c: svc: Add svc-i3c-main.c and svc-i3c.h
In reply to Frank LiSVC i3c is a dual role controller. Move probe() into svc-i3c-main.c. This prepares to support target probe depending on dts "mode" settings.
---
Notes:
Change from v7 to v9
-none
Change from v6 to v7
- using /* SPDX-License-Identifier */ for svc-i3c.h Change from v5 to v6
- none
Change from v4 to v5
- add new line at end of file
New file from v4
drivers/i3c/master/Makefile | 3 +- drivers/i3c/master/svc-i3c-main.c | 53 +++++++++++++++++++++++++++++ drivers/i3c/master/svc-i3c-master.c | 34 ++++-------------- drivers/i3c/master/svc-i3c.h | 12 +++++++ 4 files changed, 73 insertions(+), 29 deletions(-) create mode 100644 drivers/i3c/master/svc-i3c-main.c create mode 100644 drivers/i3c/master/svc-i3c.h
drivers/i3c/master/Makefile +2 -1
@@ -2,5 +2,6 @@ obj-$(CONFIG_CDNS_I3C_MASTER) += i3c-master-cdns.o obj-$(CONFIG_DW_I3C_MASTER) += dw-i3c-master.o obj-$(CONFIG_AST2600_I3C_MASTER) += ast2600-i3c-master.o -obj-$(CONFIG_SVC_I3C_MASTER) += svc-i3c-master.o +svc-i3c-objs += svc-i3c-main.o svc-i3c-master.o +obj-$(CONFIG_SVC_I3C_MASTER) += svc-i3c.o obj-$(CONFIG_MIPI_I3C_HCI) += mipi-i3c-hci/
drivers/i3c/master/svc-i3c-main.c new file +53 -0
53 lines not on this page · raw message
drivers/i3c/master/svc-i3c-master.c +6 -28
@@ -21,6 +21,8 @@#include <linux/platform_device.h> #include <linux/pm_runtime.h> +#include "svc-i3c.h" +/* Master Mode Registers */ #define SVC_I3C_MCONFIG 0x000#define SVC_I3C_MCONFIG_MASTER_EN BIT(0)
@@ -1613,7 +1615,7 @@ static void svc_i3c_master_unprepare_clks(struct svc_i3c_master *master)clk_disable_unprepare (master->sclk); } -static int svc_i3c_master_probe (struct platform_device *pdev) +int svc_i3c_master_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;struct svc_i3c_master *master;
@@ -1706,7 +1708,7 @@ static int svc_i3c_master_probe(struct platform_device *pdev)return ret; } -static void svc_i3c_master_remove (struct platform_device *pdev) +void svc_i3c_master_remove (struct platform_device *pdev) {struct svc_i3c_master *master =platform_get_drvdata (pdev);
@@ -1733,7 +1735,7 @@ static void svc_i3c_restore_regs(struct svc_i3c_master *master) } } -static int __maybe_unused svc_i3c_runtime_suspend (struct device *dev) +int svc_i3c_master_runtime_suspend (struct device *dev) {struct svc_i3c_master *master =dev_get_drvdata (dev);
@@ -1744,7 +1746,7 @@ static int __maybe_unused svc_i3c_runtime_suspend(struct device *dev)return 0 ; } -static int __maybe_unused svc_i3c_runtime_resume (struct device *dev) +int svc_i3c_master_runtime_resume (struct device *dev) {struct svc_i3c_master *master =dev_get_drvdata (dev);
@@ -1756,30 +1758,6 @@ static int __maybe_unused svc_i3c_runtime_resume(struct device *dev)return 0 ; } -static const struct dev_pm_ops svc_i3c_pm_ops = { - SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, - pm_runtime_force_resume) -SET_RUNTIME_PM_OPS (svc_i3c_runtime_suspend, - svc_i3c_runtime_resume,NULL ) -}; - -static const struct of_device_id svc_i3c_master_of_match_tbl[] = { - { .compatible ="silvaco,i3c-master-v1" }, - {/* sentinel */ }, -}; -MODULE_DEVICE_TABLE (of, svc_i3c_master_of_match_tbl); - -static struct platform_driver svc_i3c_master = { - .probe = svc_i3c_master_probe, - .remove_new = svc_i3c_master_remove, - .driver = { - .name ="silvaco-i3c-master" , - .of_match_table = svc_i3c_master_of_match_tbl, - .pm = &svc_i3c_pm_ops, - }, -}; -module_platform_driver (svc_i3c_master); -MODULE_AUTHOR ("Conor Culhane <[email protected]>" );MODULE_AUTHOR ("Miquel Raynal <[email protected]>" );MODULE_DESCRIPTION ("Silvaco dual-role I3C master driver" );
drivers/i3c/master/svc-i3c.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef SVC_I3C_H +#define SVC_I3C_H + +int svc_i3c_master_probe (struct platform_device *pdev); +void svc_i3c_master_remove (struct platform_device *pdev); +int svc_i3c_master_runtime_suspend (struct device *dev); +int svc_i3c_master_runtime_resume (struct device *dev); + +#endif +
Signature · 1 line
2.34.1
Frank Li
maintainerPATCH RESEND v9 5/8 i3c: target: add svc target controller support
In reply to Frank LiAdd Silvaco I3C target controller support
---
Notes:
Change from v8 to v9
- fix register macro define space and tab problem
Chagne from v7 to v8
-reorder header files
- add missed header files
Change from v3 to v7
- none
Change from v2 to v3
- fix build warning
Chagne from v7 to v8
-reorder header files
- add missed header files
Change from v3 to v7
- none
Change from v2 to v3
- fix build warning
drivers/i3c/master/Makefile | 2 +- drivers/i3c/master/svc-i3c-main.c | 35 +- drivers/i3c/master/svc-i3c-target.c | 776 ++++++++++++++++++++++++++++ drivers/i3c/master/svc-i3c.h | 3 + 4 files changed, 811 insertions(+), 5 deletions(-) create mode 100644 drivers/i3c/master/svc-i3c-target.c
drivers/i3c/master/Makefile +1 -1
@@ -2,6 +2,6 @@ obj-$(CONFIG_CDNS_I3C_MASTER) += i3c-master-cdns.o obj-$(CONFIG_DW_I3C_MASTER) += dw-i3c-master.o obj-$(CONFIG_AST2600_I3C_MASTER) += ast2600-i3c-master.o -svc-i3c-objs += svc-i3c-main.o svc-i3c-master.o +svc-i3c-objs += svc-i3c-main.o svc-i3c-master.o svc-i3c-target.o obj-$(CONFIG_SVC_I3C_MASTER) += svc-i3c.o obj-$(CONFIG_MIPI_I3C_HCI) += mipi-i3c-hci/
drivers/i3c/master/svc-i3c-main.c +31 -4
@@ -7,24 +7,51 @@#include "svc-i3c.h" +static bool svc_i3c_is_master (struct device *dev) +{ +const char *mode =NULL ; + +device_property_read_string (dev,"mode" , &mode); + +if (!mode) +return true; + +if (strncmp (mode,"target" ,6 ) ==0 ) +return false; + +return true; +} +static int svc_i3c_probe (struct platform_device *pdev) { -return svc_i3c_master_probe (pdev); +if (svc_i3c_is_master (&pdev->dev)) +return svc_i3c_master_probe (pdev); + +return svc_i3c_target_probe (pdev); }static void svc_i3c_remove (struct platform_device *pdev) { -svc_i3c_master_remove (pdev); +if (svc_i3c_is_master (&pdev->dev)) +return svc_i3c_master_remove (pdev); + +svc_i3c_target_remove (pdev); }static int __maybe_unused svc_i3c_runtime_suspend (struct device *dev) { -return svc_i3c_master_runtime_suspend (dev); +if (svc_i3c_is_master (dev)) +return svc_i3c_master_runtime_suspend (dev); + +return -EINVAL ; }static int __maybe_unused svc_i3c_runtime_resume (struct device *dev) { -return svc_i3c_master_runtime_resume (dev); +if (svc_i3c_is_master (dev)) +return svc_i3c_master_runtime_resume (dev); + +return -EINVAL ; }static const struct dev_pm_ops svc_i3c_pm_ops = {
drivers/i3c/master/svc-i3c-target.c new file +776 -0
776 lines not on this page · raw message
drivers/i3c/master/svc-i3c.h +3 -0
@@ -8,5 +8,8 @@ void svc_i3c_master_remove(struct platform_device *pdev);int svc_i3c_master_runtime_suspend (struct device *dev);int svc_i3c_master_runtime_resume (struct device *dev); +int svc_i3c_target_probe (struct platform_device *pdev); +void svc_i3c_target_remove (struct platform_device *pdev); +#endif
Signature · 1 line
2.34.1
Frank Li
maintainerPATCH RESEND v9 6/8 i3c: target: func: add tty driver
In reply to Frank LiAdd tty over I3C target function driver.
---
Notes:
Change from v8 to v9
- none
Change from v7 to v8
- reorder header file
- add missed header files
Change from v5 to v7
- none
Change from v4 to v5
- remove void*
- include bitfield.h
- remove extra ()
- oneline for struct ttyi3c_port *sport
drivers/i3c/Kconfig | 3 + drivers/i3c/Makefile | 1 + drivers/i3c/func/Kconfig | 9 + drivers/i3c/func/Makefile | 3 + drivers/i3c/func/tty.c | 481 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 497 insertions(+) create mode 100644 drivers/i3c/func/Kconfig create mode 100644 drivers/i3c/func/Makefile create mode 100644 drivers/i3c/func/tty.c
drivers/i3c/Kconfig +3 -0
@@ -48,3 +48,6 @@ config I3C_TARGET_CONFIGFS the target function and used to bind the function with a target controller. +if I3C_TARGET +source "drivers/i3c/func/Kconfig" +endif # I3C_TARGET
drivers/i3c/Makefile +1 -0
@@ -4,3 +4,4 @@ obj-$(CONFIG_I3C) += i3c.o obj-$(CONFIG_I3C_TARGET) += target.o obj-$(CONFIG_I3C_TARGET_CONFIGFS) += i3c-cfs.o obj-$(CONFIG_I3C) += master/ +obj-$(CONFIG_I3C_TARGET) += func/
drivers/i3c/func/Kconfig new file +9 -0
@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0 + +config I3C_TARGET_FUNC_TTY + tristate "I3C target tty driver" + depends on I3C_TARGET + help + I3C Target TTY Function Driver. + + General TTY over I3C target controller function drivers.
drivers/i3c/func/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_I3C_TARGET_FUNC_TTY) += tty.o
drivers/i3c/func/tty.c new file +481 -0
481 lines not on this page · raw message
Signature · 1 line
2.34.1
Frank Li
maintainerPATCH RESEND v9 7/8 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.
--- 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
@@ -2988,6 +2988,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
maintainerPATCH RESEND v9 8/8 tty: i3c: add TTY over I3C master support
In reply to Frank LiIn typical embedded Linux systems, UART consoles require at least two pins, TX and RX. In scenarios where I2C/I3C devices like sensors or PMICs are present, we can save these two pins by using this driver. Pins is crucial resources, especially in small chip packages.
This introduces support for using the I3C bus to transfer console tty data, effectively replacing the need for dedicated UART pins. This not only conserves valuable pin resources but also facilitates testing of I3C's advanced features, including early termination, in-band interrupt (IBI) support, and the creation of more complex data patterns. Additionally, it aids in identifying and addressing issues within the I3C controller driver.
---
Notes:
Notes:
Version number use i3c target patches.
Change from v8 to v9
- none
Change from v7 to v8
- reorder head files
- add missed head files
Change from v6 to v7
- try to fixed build warning
https://lore.kernel.org/imx/[email protected]/T/#m4e35da31a4226186b3dc6bc8f2fba28f58be1188
but I can't reproduce this error in my machine with powerpc-linux-gcc (GCC) 13.2.0 kernel test robot have not show reproduce step.
But anyway, status may not init if code through continue branch. So Move status = I3C_TTY_TARGET_RX_READY; before continue branch.
Change from v5 to v6
-none
Change from v4 to v5
- add missed header file
- add define for BIT(0)
- oneline for struct ttyi3c_port *sport
Change from v3 to v4
- add static at i3c_remove()
Change v2
- using system_unbound_wq working queue
- fixed accoring to Jiri Slaby's comments
Change before send with i3c target support
Change from v4 to v5
- send in i3c improvememtn patches.
Change from v2 to v4
- none
Change from v1 to v2
- update commit message.
- using goto for err handle
- using one working queue for all tty-i3c device
- fixed typo found by js
- update kconfig help
- using kfifo
Still below items not be fixed (according to Jiri Slaby's comments)
- rxwork thread: need trigger from two position.
- common thread queue: need some suggestion
Notes:
Version number use i3c target patches.
Change from v3 to v4
- add static at i3c_remove()
Change v2
- using system_unbound_wq working queue
- fixed accoring to Jiri Slaby's comments
Change before send with i3c target support
Change from v4 to v5
- send in i3c improvememtn patches.
Change from v2 to v4
- none
Change from v1 to v2
- update commit message.
- using goto for err handle
- using one working queue for all tty-i3c device
- fixed typo found by js
- update kconfig help
- using kfifo
Still below items not be fixed (according to Jiri Slaby's comments)
- rxwork thread: need trigger from two position.
- common thread queue: need some suggestion
drivers/tty/Kconfig | 13 ++ drivers/tty/Makefile | 1 + drivers/tty/i3c_tty.c | 432 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 446 insertions(+) create mode 100644 drivers/tty/i3c_tty.c
drivers/tty/Kconfig +13 -0
@@ -412,6 +412,19 @@ config RPMSG_TTY To compile this driver as a module, choose M here: the module will be called rpmsg_tty. +config I3C_TTY + tristate "TTY over I3C" + depends on I3C + help + Select this option to use TTY over I3C master controller. + + This makes it possible for user-space programs to send and receive + data as a standard tty protocol. I3C provide relatively higher data + transfer rate and less pin numbers, SDA/SCL are shared with other + devices. + + If unsure, say N + endif # TTY source "drivers/tty/serdev/Kconfig"
drivers/tty/Makefile +1 -0
@@ -27,5 +27,6 @@ obj-$(CONFIG_GOLDFISH_TTY) += goldfish.o obj-$(CONFIG_MIPS_EJTAG_FDC_TTY) += mips_ejtag_fdc.o obj-$(CONFIG_VCC) += vcc.o obj-$(CONFIG_RPMSG_TTY) += rpmsg_tty.o +obj-$(CONFIG_I3C_TTY) += i3c_tty.o obj-y += ipwireless/
drivers/tty/i3c_tty.c new file +432 -0
432 lines not on this page · raw message
Signature · 1 line
2.34.1