tty: i3c: add TTY over I3C master support
Subsystems (3)
Frank Li
maintainerPATCH v2 1/1 tty: i3c: add TTY over I3C master support
In 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:
This patch depend on
https://lore.kernel.org/imx/[email protected]/T/#t
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
Some idea about i3c tty in future
1. early console support
- early console is useful to debug boot problem. It requires as simple
as possible.
i3c SDR mode, 9th bit is parity. I3C target can't block master send out
data. so never block kernel boot even without any expected target connected. i3c master may send out a boardcast message as early console to every target devices. Only a "i3c-usb-acm" can show it to host's minicom. And this "i3c-usb-acm" can plug in at any time. Write a boardcast message is quite simple at I3C controller. After kernel system boot to certain phase, switch to this driver.
2. multi port supports. create multi virtual uart ports, so firmware, such as arm trust firmware can dump message to difference virtual ports.
3. compatible with UART network adaptor, which defined at MIPI DEBUG for I3C spec.
This driver is just first step.
This patch depend on
https://lore.kernel.org/imx/[email protected]/T/#t
drivers/tty/Kconfig | 13 ++ drivers/tty/Makefile | 1 + drivers/tty/i3c_tty.c | 443 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 457 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 options if you'd like 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 +443 -0
443 lines not on this page · raw message
Signature · 1 line
2.34.1
Greg KH
maintainerNote, your subject line needs to change.
Quoted 3 lines · Frank Li
In 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
"Pins are crucial"
Quoted 9 lines
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.
But where is the serial data ending up at? Not a normal uart, what is on the other end? And do line settings mean anything here?
Quoted 7 lines
Signed-off-by Frank Li <[email protected]>---
Notes:
This patch depend on
https://lore.kernel.org/imx/[email protected]/T/#t
Let's wait for those to be accepted first, right?
drivers/tty/i3c_tty.c line 22
Quoted 2 lines
drivers/tty/i3c_tty.c new file +2
-0+static DEFINE_IDR (i3c_tty_minors); +static DEFINE_MUTEX (i3c_tty_minors_lock);
I thought idr didn't need a mutex anymore, are you sure this is still needed?
drivers/tty/i3c_tty.c line 26
Quoted 3 lines
drivers/tty/i3c_tty.c new file +3
-0+static struct tty_driver *i3c_tty_driver; + +#define I3C_TTY_MINORS 256
Do you really need 256 minors?
Quoted 7 lines
drivers/tty/i3c_tty.c new file +7
-0+#define I3C_TTY_TRANS_SIZE 16 +#define I3C_TTY_RX_STOP 0 +#define I3C_TTY_RETRY 20 +#define I3C_TTY_YIELD_US 100 + +struct ttyi3c_port { +struct tty_port port;
drivers/tty/i3c_tty.c line 43
Quoted 10 lines
drivers/tty/i3c_tty.c new file +10
-0+int minor; +spinlock_t xlock;/* protect xmit */ +char tx_buff[I3C_TTY_TRANS_SIZE ]; +char rx_buff[I3C_TTY_TRANS_SIZE ]; +struct i3c_device *i3cdev; +struct work_struct txwork; +struct work_struct rxwork; +struct completion txcomplete; +unsigned long status; +int buf_overrun;
You set buf_overrun but never do anything with it. Why care about it?
Other than these minor things, looks sane, nice work.
thanks,
greg k-h
Frank Li
maintainerQuoted 19 lines · Greg KH
Note, your subject line needs to change.
Quoted 3 lines · Frank Li
In 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
"Pins are crucial"
Quoted 9 lines
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.
Quoted 2 lines
But where is the serial data ending up at? Not a normal uart, what is on the other end? And do line settings mean anything here?
Currently, it use slave i3c code.
https://lore.kernel.org/imx/[email protected]/T/#t
idealy build an i3c->usb dongle to bride it to usb acm.
Quoted 10 lines
Quoted 8 lines
Signed-off-by Frank Li <[email protected]>---
Notes:
This patch depend on
https://lore.kernel.org/imx/[email protected]/T/#tLet's wait for those to be accepted first, right?
Yes.
Quoted 7 lines
drivers/tty/i3c_tty.c line 22
Quoted 3 lines
drivers/tty/i3c_tty.c new file +2
-0+static DEFINE_IDR (i3c_tty_minors); +static DEFINE_MUTEX (i3c_tty_minors_lock);I thought idr didn't need a mutex anymore, are you sure this is still needed?
Quoted 5 lines
drivers/tty/i3c_tty.c line 26
Quoted 3 lines
drivers/tty/i3c_tty.c new file +3
-0+static struct tty_driver *i3c_tty_driver; + +#define I3C_TTY_MINORS 256Do you really need 256 minors?
Any resource concern about it. Maybe 32/64 is enough. I refer from USB tty driver.
Quoted 26 lines
Quoted 8 lines
drivers/tty/i3c_tty.c new file +7
-0+#define I3C_TTY_TRANS_SIZE 16 +#define I3C_TTY_RX_STOP 0 +#define I3C_TTY_RETRY 20 +#define I3C_TTY_YIELD_US 100 + +struct ttyi3c_port { +struct tty_port port;drivers/tty/i3c_tty.c line 43
Quoted 10 lines
drivers/tty/i3c_tty.c new file +10
-0+int minor; +spinlock_t xlock;/* protect xmit */ +char tx_buff[I3C_TTY_TRANS_SIZE ]; +char rx_buff[I3C_TTY_TRANS_SIZE ]; +struct i3c_device *i3cdev; +struct work_struct txwork; +struct work_struct rxwork; +struct completion txcomplete; +unsigned long status; +int buf_overrun;You set
buf_overrunbut never do anything with it. Why care about it?Other than these minor things, looks sane, nice work.
thanks,
greg k-h
Greg KH
maintainerQuoted 20 lines · Frank Li
Quoted 19 lines · Greg KH
Note, your subject line needs to change.
Quoted 3 lines · Frank Li
In 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
"Pins are crucial"
Quoted 9 lines
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.
Quoted 7 lines
Quoted 2 lines
But where is the serial data ending up at? Not a normal uart, what is on the other end? And do line settings mean anything here?
Currently, it use slave i3c code.
https://lore.kernel.org/imx/[email protected]/T/#tidealy build an
i3c->usbdongle to bride it to usb acm.
So no one has built such a thing yet to determine if any of this works?
Quoted 6 lines
Quoted 6 lines
drivers/tty/i3c_tty.c line 22
Quoted 2 lines
drivers/tty/i3c_tty.c new file +2
-0+static DEFINE_IDR (i3c_tty_minors); +static DEFINE_MUTEX (i3c_tty_minors_lock);I thought idr didn't need a mutex anymore, are you sure this is still needed?
Quoted 8 lines
Quoted 5 lines
drivers/tty/i3c_tty.c line 26
Quoted 3 lines
drivers/tty/i3c_tty.c new file +3
-0+static struct tty_driver *i3c_tty_driver; + +#define I3C_TTY_MINORS 256Do you really need 256 minors?
Any resource concern about it. Maybe 32/64 is enough. I refer from USB tty driver.
USB serial devices are quite common, and in some places, replaced PCI serial cards for modem connections. So for them, we do actually use all 256 minors.
But for this, it's a debugging device, how are you going to have so many different debugging ports on a system at once?
How about making it small, like 8, and see if you ever actually exceed that in real life?
thanks,
greg k-h
Frank Li
maintainerQuoted 24 lines · Greg KH
Quoted 23 lines · Frank Li
Quoted 21 lines · Greg KH
Note, your subject line needs to change.
Quoted 3 lines · Frank Li
In 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
"Pins are crucial"
Quoted 9 lines
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.
But where is the serial data ending up at? Not a normal uart, what is on the other end? And do line settings mean anything here?
Quoted 6 lines
Quoted 4 lines
Currently, it use slave i3c code.
https://lore.kernel.org/imx/[email protected]/T/#tidealy build an
i3c->usbdongle to bride it to usb acm.So no one has built such a thing yet to determine if any of this works?
It is easy to proof concept by I3C slave code and USB gadget ACM, then pipe two tty (ttyACM0 and ttySI3C0 together).
Of we also can implement a USB to I3C class standard, base on this, reuse this tty driver at host side.
Frank
Quoted 29 lines
Quoted 7 lines
Quoted 7 lines
drivers/tty/i3c_tty.c line 22
Quoted 3 lines
drivers/tty/i3c_tty.c new file +2
-0+static DEFINE_IDR (i3c_tty_minors); +static DEFINE_MUTEX (i3c_tty_minors_lock);I thought idr didn't need a mutex anymore, are you sure this is still needed?
Quoted 8 lines
Quoted 5 lines
drivers/tty/i3c_tty.c line 26
Quoted 3 lines
drivers/tty/i3c_tty.c new file +3
-0+static struct tty_driver *i3c_tty_driver; + +#define I3C_TTY_MINORS 256Do you really need 256 minors?
Any resource concern about it. Maybe 32/64 is enough. I refer from USB tty driver.
USB serial devices are quite common, and in some places, replaced PCI serial cards for modem connections. So for them, we do actually use all 256 minors.
But for this, it's a debugging device, how are you going to have so many different debugging ports on a system at once?
How about making it small, like 8, and see if you ever actually exceed that in real life?
thanks,
greg k-h
Greg KH
maintainerQuoted 28 lines · Frank Li
Quoted 27 lines · Greg KH
Quoted 26 lines · Frank Li
Quoted 19 lines · Greg KH
Note, your subject line needs to change.
Quoted 3 lines · Frank Li
In 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
"Pins are crucial"
Quoted 9 lines
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.
Quoted 2 lines
But where is the serial data ending up at? Not a normal uart, what is on the other end? And do line settings mean anything here?
Currently, it use slave i3c code.
https://lore.kernel.org/imx/[email protected]/T/#t
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
idealy build an
i3c->usbdongle to bride it to usb acm.So no one has built such a thing yet to determine if any of this works?
It is easy to proof concept by I3C slave code and USB gadget ACM, then pipe two tty (ttyACM0 and ttySI3C0 together).
So you have not actually tested this? why write a driver that no one is using?
Quoted 2 lines
Of we also can implement a USB to I3C class standard, base on this, reuse this tty driver at host side.
Is there a USB I3C standard? I see i3c descriptors assigned by the USB-IF, but haven't dug to see if there's more than that anywhere...
thanks,
greg k-h
Frank Li
maintainerQuoted 31 lines · Greg KH
Quoted 30 lines · Frank Li
Quoted 29 lines · Greg KH
Quoted 27 lines · Frank Li
Quoted 19 lines · Greg KH
Note, your subject line needs to change.
Quoted 3 lines · Frank Li
In 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
"Pins are crucial"
Quoted 9 lines
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.
Quoted 2 lines
But where is the serial data ending up at? Not a normal uart, what is on the other end? And do line settings mean anything here?
Currently, it use slave i3c code.
https://lore.kernel.org/imx/[email protected]/T/#tidealy build an
i3c->usbdongle to bride it to usb acm.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
So no one has built such a thing yet to determine if any of this works?
It is easy to proof concept by I3C slave code and USB gadget ACM, then pipe two tty (ttyACM0 and ttySI3C0 together).
So you have not actually tested this? why write a driver that no one is using?
I3c slave side tty at
https://lore.kernel.org/imx/[email protected]/T/#t
I just have not tested tty to USB part. This patch is major for tty -> i3c master -> i3c taret -> tty now.
As my previous said, two major purpose now.
1. Save two pads.
2. Test i3c master and i3c target driver. I3C target driver frame was written by me and posted. It needs a driver to verify it works. In stead of write a test driver (such as i2c slave, pci-endpoint), it is better to write an actual function driver, such as tty. It can exchange message between two boards, which connected by SDA/SCL.
Frank
Quoted 10 lines
Quoted 3 lines
Of we also can implement a USB to I3C class standard, base on this, reuse this tty driver at host side.
Is there a USB I3C standard? I see i3c descriptors assigned by the USB-IF, but haven't dug to see if there's more than that anywhere...
thanks,
greg k-h
Frank Li
maintainerQuoted 54 lines · Frank Li
Quoted 31 lines · Greg KH
Quoted 30 lines · Frank Li
Quoted 29 lines · Greg KH
Quoted 27 lines · Frank Li
Quoted 19 lines · Greg KH
Note, your subject line needs to change.
Quoted 3 lines · Frank Li
In 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
"Pins are crucial"
Quoted 9 lines
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.
Quoted 2 lines
But where is the serial data ending up at? Not a normal uart, what is on the other end? And do line settings mean anything here?
Currently, it use slave i3c code.
https://lore.kernel.org/imx/[email protected]/T/#tidealy build an
i3c->usbdongle to bride it to usb acm.Quoted 7 lines
Quoted 4 lines
Quoted 1 line
So no one has built such a thing yet to determine if any of this works?
It is easy to proof concept by I3C slave code and USB gadget ACM, then pipe two tty (ttyACM0 and ttySI3C0 together).
So you have not actually tested this? why write a driver that no one is using?
I3c slave side tty at
https://lore.kernel.org/imx/[email protected]/T/#tI just have not tested tty to USB part. This patch is major for tty -> i3c master -> i3c taret -> tty now.
As my previous said, two major purpose now.
1. Save two pads.
2. Test i3c master and i3c target driver. I3C target driver frame was written by me and posted. It needs a driver to verify it works. In stead of write a test driver (such as i2c slave, pci-endpoint), it is better to write an actual function driver, such as tty. It can exchange message between two boards, which connected by SDA/SCL.
Quoted 7 lines
Frank
Quoted 6 lines
Quoted 3 lines
Of we also can implement a USB to I3C class standard, base on this, reuse this tty driver at host side.
Is there a USB I3C standard? I see i3c descriptors assigned by the USB-IF, but haven't dug to see if there's more than that anywhere...
Sorry, forget answer this quesiton. Yes, it is standard class. Spec is in usb.org. I have not found actual usage mode yet.
Quoted 4 lines
Quoted 4 lines
thanks,
greg k-h