Skip to contentSkip to conversation

Serial: silabs si4455 serial driver

PATCH In review Jozsef Horvath 2 participants 5 messages Jan 12, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v8 1/2 Serial: silabs si4455 serial driver

This is a serial port driver for
Silicon Labs Si4455 Sub-GHz transciver.

The goal of this driver is to removing wires
between central(linux) device and remote serial devices/sensors, but keeping the original user software.
It represents regular serial interface for the user space.

Datasheet: https://www.silabs.com/documents/public/data-sheets/Si4455.pdf

Guide: Documentation/driver-api/serial/si4455.rst

---

changes v1:
- fixed: drivers: serial: si4455: coding style
- fixed: drivers: serial: si4455: error checking and order
- fixed: drivers: serial: si4455: remove unnecessary compatibility strings from si4455_dt_ids

changes v2:
- fixed: drivers: serial: si4455: coding style

changes v3:
- fixed: drivers: serial: si4455: coding style
- fixed: drivers: serial: si4455: replace device configuration procedure (SI4455_IOC_SEZC ioctl call) with request_firmware(...). The firmware name comes from dt (silabs,ez-config)
- fixed: drivers: serial: si4455: replace transmit/receive channel select (SI4455_IOC_STXC/SI4455_IOC_SRXC ioctl calls)
with sysfs entries (tx_channel, rx_channel).
Initial values comes from dt (silabs,tx-channel and silabs,rx-channel)
- fixed: drivers: serial: si4455: replace package size setting (SI4455_IOC_SSIZ ioctl call) with sysfs entry (package_size). Initial value comes from dt (silabs,package-size)
- fixed: drivers: serial: si4455: replace getting last rssi (SI4455_IOC_GRSSI ioctl call) with sysfs entry (current_rssi)
- fixed: drivers: serial: si4455: remove si4455_api.h
and custom ioctl definitions

changes v5:
- fixed: drivers: serial: si4455: coding style
- fixed: drivers: serial: si4455: remove struct si4455_one, members moved to struct si4455_port
- fixed: drivers: serial: si4455: fix line endings in dev_err and dev_dbg messages
- fixed: drivers: serial: si4455: remove unnecessary else { ... }
- fixed: drivers: serial: si4455: refactor si4455_do_work(...), xmit circular buffer handling and start tx moved to si4455_start_tx_xmit(...)
- fixed: drivers: serial: si4455: refactor si4455_configure
- fixed: drivers: serial: si4455: refactor interrupt handling, remove unnecessary wrapper
- fixed: drivers: serial: si4455: modem line(si4455_get_mctrl) and tx buffer status(si4455_tx_empty) conditions and signaling
- fixed: drivers: serial: si4455: remove unsafe int to pointer conversion

changes v6:
- fixed: drivers: serial: si4455: illegal characters in MODULE_AUTHOR("...") Reported-by: kernel test robot <[email protected]>

changes v7:
- added: drivers: serial: si4455: variable packet length support
- added: drivers: serial: si4455: extended error handling

changes v8:
- fixed: drivers: serial: si4455: removed unnecessary error checking around debugfs
- fixed: drivers: serial: si4455: removed unnecessary #ifdefs
- fixed: drivers: serial: kconfig: add missing module name to help text
- fixed: drivers: serial: si4455: device name ttySI changed to ttySSi because of collosion. The ttySI is allocated alredy in devices.txt
- fixed: drivers: serial: si4455: revoved unnecessary administrative definitions (major, minor)
- fixed: drivers: serial: si4455: definition PORT_SI4455 changed and moved to serial_core.h
- fixed: drivers: serial: si4455: silabs,tx-timeout property name changed
to silabs,tx-timeout-ms

---
 Documentation/driver-api/serial/index.rst  |    1 +
 Documentation/driver-api/serial/si4455.rst |  216 +++
 MAINTAINERS                                |    7 +
 drivers/tty/serial/Kconfig                 |   11 +
 drivers/tty/serial/Makefile                |    1 +
 drivers/tty/serial/si4455.c                | 1660 ++++++++++++++++++++
 include/uapi/linux/serial_core.h           |    3 +
 7 files changed, 1899 insertions(+)
 create mode 100644 Documentation/driver-api/serial/si4455.rst
 create mode 100644 drivers/tty/serial/si4455.c
Documentation/driver-api/serial/index.rst +1 -0
index 33ad10d05b26..2b71e87f1103 100644
@@ -23,6 +23,7 @@ Serial drivers
     rocket
     serial-iso7816
     serial-rs485
+    si4455
 
 .. only::  subproject and html
 
Documentation/driver-api/serial/si4455.rst new file +216 -0

217 lines not on this page · raw message

MAINTAINERS +7 -0
index a008b70f3c16..e6e9f2b1aecc 100644
@@ -15952,6 +15952,13 @@ M:	Jérôme Pouiller <[email protected]>
 S:	Supported
 F:	drivers/staging/wfx/
 
+SILICON LABS SI4455 SERIAL DRIVER
+M:	Jozsef Horvath <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/serial/silabs,si4455.yaml
+F:	Documentation/driver-api/serial/si4455.rst
+F:	drivers/tty/serial/si4455.c
+
 SILICON MOTION SM712 FRAME BUFFER DRIVER
 M:	Sudip Mukherjee <[email protected]>
 M:	Teddy Wang <[email protected]>
drivers/tty/serial/Kconfig +11 -0
index 28f22e58639c..e91cce1074df 100644
@@ -1583,6 +1583,17 @@ config SERIAL_MILBEAUT_USIO_CONSOLE
 	  receives all kernel messages and warnings and which allows logins in
 	  single user mode).
 
+config SERIAL_SI4455
+	tristate "Si4455 support"
+	depends on SPI
+	select SERIAL_CORE
+	help
+	  This driver is for Silicon Labs's Si4455 Sub-GHz transciver.
+	  Say 'Y' here if you wish to use it as serial port.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called si4455.
+
 endmenu
 
 config SERIAL_MCTRL_GPIO
drivers/tty/serial/Makefile +1 -0
index caf167f0c10a..f01ff43db1d6 100644
@@ -89,6 +89,7 @@ obj-$(CONFIG_SERIAL_MPS2_UART)	+= mps2-uart.o
 obj-$(CONFIG_SERIAL_OWL)	+= owl-uart.o
 obj-$(CONFIG_SERIAL_RDA)	+= rda-uart.o
 obj-$(CONFIG_SERIAL_MILBEAUT_USIO) += milbeaut_usio.o
+obj-$(CONFIG_SERIAL_SI4455)	+= si4455.o
 obj-$(CONFIG_SERIAL_SIFIVE)	+= sifive.o
 
 # GPIOLIB helpers for modem control lines
drivers/tty/serial/si4455.c new file +1660 -0

1,660 lines not on this page · raw message

include/uapi/linux/serial_core.h +3 -0
index 851b982f8c4b..943c5e2e27fc 100644
@@ -279,4 +279,7 @@
 /* Freescale LINFlexD UART */
 #define PORT_LINFLEXUART	122
 
+/* Silicon Labs SI4455 */
+#define PORT_SI4455     123
+
 #endif /* _UAPILINUX_SERIAL_CORE_H */
Signature · 1 line
2.17.1
#1 lore raw

include/uapi/linux/serial_core.h line 283

Quoted 8 lines · Jozsef Horvath
include/uapi/linux/serial_core.h +2 -0
@@ -279,4 +279,7 @@
 /* Freescale LINFlexD UART */
 #define PORT_LINFLEXUART	122
 
+/* Silicon Labs SI4455 */
+#define PORT_SI4455     123

What userspace tool is going to need this value?

thanks,

greg k-h

#2 lore raw
Quoted 11 lines · Greg Kroah-Hartman

include/uapi/linux/serial_core.h line 283

Quoted 8 lines · Jozsef Horvath
include/uapi/linux/serial_core.h +2 -0
@@ -279,4 +279,7 @@
 /* Freescale LINFlexD UART */
 #define PORT_LINFLEXUART	122
 
+/* Silicon Labs SI4455 */
+#define PORT_SI4455     123

What userspace tool is going to need this value?

The PORT_SI4455 is defined for using as port type value in struct uart_port. I checked other serial drivers under drivers/tty/serial and the port types used by serial drivers are defined in two places:

include/uapi/linux/serial_core.h
include/uapi/linux/serial.h

The port type is required by serial_core, and its value goes back to user space with TIOCGSERIAL ioctl call.

I can't set port type value to 0(PORT_UNKNOWN).
I think my drivers source is not the best place to defining PORT_SI4455,
but I can't find better place then include/uapi/linux/serial_core.h

Could you please help me where is the correct location for this definition?

Quoted 4 lines

thanks,

greg k-h

Üdvözlettel / Best regards:
József Horváth

#3 lore raw
Quoted 17 lines · József Horváth
Quoted 11 lines · Greg Kroah-Hartman

include/uapi/linux/serial_core.h line 283

Quoted 8 lines · Jozsef Horvath
include/uapi/linux/serial_core.h +2 -0
@@ -279,4 +279,7 @@
 /* Freescale LINFlexD UART */
 #define PORT_LINFLEXUART	122
 
+/* Silicon Labs SI4455 */
+#define PORT_SI4455     123

What userspace tool is going to need this value?

The PORT_SI4455 is defined for using as port type value in struct uart_port. I checked other serial drivers under drivers/tty/serial and the port types used by serial drivers are defined in two places:

Quoted 5 lines

include/uapi/linux/serial_core.h
include/uapi/linux/serial.h

The port type is required by serial_core, and its value goes back to user space with TIOCGSERIAL ioctl call.

What is it required for? Who uses this?

Quoted 1 line

I can't set port type value to 0(PORT_UNKNOWN).

Why not?

Quoted 4 lines

I think my drivers source is not the best place to defining PORT_SI4455,
but I can't find better place then include/uapi/linux/serial_core.h

Could you please help me where is the correct location for this definition?

I ask as I am trying to figure out why we keep adding these ids, yet no tool that i know of seems to actually use them.

If you don't have a tool that needs to use a new id, then I would recommend not adding it, right?

thanks,

greg k-h

#4 lore raw
Quoted 21 lines · Greg Kroah-Hartman
Quoted 20 lines · József Horváth
Quoted 11 lines · Greg Kroah-Hartman

include/uapi/linux/serial_core.h line 283

Quoted 8 lines · Jozsef Horvath
include/uapi/linux/serial_core.h +2 -0
@@ -279,4 +279,7 @@
 /* Freescale LINFlexD UART */
 #define PORT_LINFLEXUART	122
 
+/* Silicon Labs SI4455 */
+#define PORT_SI4455     123

What userspace tool is going to need this value?

The PORT_SI4455 is defined for using as port type value in struct uart_port. I checked other serial drivers under drivers/tty/serial and the port types used by serial drivers are defined in two places:

include/uapi/linux/serial_core.h
include/uapi/linux/serial.h

Quoted 8 lines
Quoted 2 lines

The port type is required by serial_core, and its value goes back to user space with TIOCGSERIAL ioctl call.

What is it required for? Who uses this?

Quoted 1 line

I can't set port type value to 0(PORT_UNKNOWN).

Why not?

In drivers/tty/serial/serial_core.c
1784: uart_port_activate(...)
1799: -> uart_startup(...)
260: -> uart_port_startup(...)

183: static int uart_port_startup(struct tty_struct *tty, struct uart_state *state,
184: int init_hw)
...
191: if (uport->type == PORT_UNKNOWN)
192: return 1;
...
221: retval = uport->ops->startup(uport); <--This is the reason. The drivers
startup function is not get called if type==PORT_UNKNOWN
...

Quoted 11 lines
Quoted 5 lines

I think my drivers source is not the best place to defining PORT_SI4455,
but I can't find better place then include/uapi/linux/serial_core.h

Could you please help me where is the correct location for this definition?

I ask as I am trying to figure out why we keep adding these ids, yet no tool that i know of seems to actually use them.

If you don't have a tool that needs to use a new id, then I would recommend not adding it, right?

This definition is not my requirement, but I would avoid collision with other
drivers port type value.
At this point as I understand your words, these definitions will be obsolete
or optional soon and I can choose any value for drivers port type.

Right?

I would ask you about dev name (ttySSi).
Is it okay?

I didnt find any similar.

Quoted 4 lines

thanks,

greg k-h

Üdvözlettel / Best regards:
József Horváth