Serial: silabs si4455 serial driver
Subsystems (2)
PATCH v6 1/1 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
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
- fixed: dt-bindings: rename sdn-gpios to shutdown-gpios
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
- fixed: dt-bindings: silabs,si4455: more detailed description
- added: dt-bindings: silabs,si4455: properties silabs,package-size, silabs,tx-channel, silabs,rx-channel, silabs,ez-config
changes v4:
- fixed: dt-bindings: silabs,si4455: $id
from http://devicetree.org/schemas/serial/silabs,si4455.yaml
to http://devicetree.org/schemas/staging/serial/silabs,si4455.yaml
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
- fixed: dt-bindings: silabs,si4455: $id
from http://devicetree.org/schemas/staging/serial/silabs,si4455.yaml
to http://devicetree.org/schemas/serial/silabs,si4455.yaml
- fixed: dt-bindings: silabs,si4455: serial.yaml reference added
changes v6:
- fixed: drivers: serial: si4455: illegal characters in MODULE_AUTHOR("...") Reported-by: kernel test robot <[email protected]>
--- .../bindings/serial/silabs,si4455.yaml | 98 ++ MAINTAINERS | 6 + drivers/tty/serial/Kconfig | 8 + drivers/tty/serial/Makefile | 1 + drivers/tty/serial/si4455.c | 1372 +++++++++++++++++ 5 files changed, 1485 insertions(+) create mode 100644 Documentation/devicetree/bindings/serial/silabs,si4455.yaml create mode 100644 drivers/tty/serial/si4455.c
Documentation/devicetree/bindings/serial/silabs,si4455.yaml new file +98 -0
@@ -0,0 +1,98 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/serial/silabs,si4455.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Silicon Labs Si4455 device tree bindings + +maintainers: + - József Horváth <[email protected]> + +description: + This document is for describing the required device tree parameters for si4455 serial driver. + The si4455 driver tries to represent the Silicon Labs Si4455 sub-GHz transceiver device + like a serial port. The required parameters for proper operation are described below. + https://www.silabs.com/documents/public/data-sheets/Si4455.pdf + +allOf: + - $ref: "serial.yaml#" + +properties: + compatible: + const: silabs,si4455 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + spi-max-frequency: + description: maximum clock frequency on SPI port + maximum: 500000 + + shutdown-gpios: + description: gpio pin for SDN + maxItems: 1 + + silabs,package-size: + description: + Radio payload length, variable packet length is not supported by driver. + This value should equal with EZConfig payload length. + $ref: /schemas/types.yaml#/definitions/uint32 + maximum: 64 + minimum: 1 + + silabs,tx-channel: + description: + Radio transmit channel selection. + $ref: /schemas/types.yaml#/definitions/uint32 + maximum: 255 + minimum: 0 + + silabs,rx-channel: + description: + Radio receive channel selection. + $ref: /schemas/types.yaml#/definitions/uint32 + maximum: 255 + minimum: 0 + + silabs,ez-config: + description: + Radio configuration data file name. + $ref: /schemas/types.yaml#/definitions/string + items: + pattern: ^[0-9a-z\._\-]{1,255}$ + +required: + - reg + - interrupts + - spi-max-frequency + - shutdown-gpios + - silabs,package-size + - silabs,tx-channel + - silabs,rx-channel + - silabs,ez-config + +additionalProperties: false + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + si4455_0: serial@0 { + compatible = "silabs,si4455"; + reg = <0>; + interrupt-parent = <&gpio>; + interrupts = <7 2>; + shutdown-gpios = <&gpio 26 1>; + spi-max-frequency = <300000>; + silabs,package-size = <30>; + silabs,tx-channel = <1>; + silabs,rx-channel = <2>; + silabs,ez-config = "si4455_spi0_0.ez.bin"; + }; + }; +...
MAINTAINERS +6 -0
@@ -15952,6 +15952,12 @@ 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: 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 +8 -0
@@ -1583,6 +1583,14 @@ 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. + endmenu config SERIAL_MCTRL_GPIO
drivers/tty/serial/Makefile +1 -0
@@ -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 +1372 -0
1,372 lines not on this page · raw message
Signature · 1 line
2.17.1
Jiri Slaby
maintainerQuoted 3 lines · József Horváth
drivers/tty/serial/si4455.c new file +0
-0@@ -0,0 +1,1372 @@
...
Quoted 20 lines
drivers/tty/serial/si4455.c new file +20
-0+static int si4455_write_data (struct uart_port *port,u8 command,int poll, +int length,const u8 *data) +{ +int ret =0 ; +u8 *data_out; + +if (poll) { + ret =si4455_poll_cts (port); +if (ret) +return ret; + } + + data_out =kzalloc (1 + length,GFP_KERNEL ); +if (!data_out) +return -ENOMEM ; + + data_out[0 ] = command; +memcpy (&data_out[1 ], data, length); + ret =spi_write (to_spi_device (port->dev), data_out,1 + length); +if (ret) {
drivers/tty/serial/si4455.c line 279
Quoted 10 lines
drivers/tty/serial/si4455.c new file +10
-0+dev_err (port->dev, +"%s: spi_write error (%i)\n" , __func__, ret); + } + +kfree (data_out); + +return ret; +} + +static void si4455_set_power (struct si4455_port *priv,int on)
"on" can be bool here. And "poll" in earlier functions. And "on" in later ones.
drivers/tty/serial/si4455.c line 290
Quoted 11 lines
drivers/tty/serial/si4455.c new file +11
-0+{ +if (!priv->shdn_gpio) +return ; +if (on) { +gpiod_direction_output (priv->shdn_gpio,0 ); +usleep_range (4000 ,5000 ); +gpiod_set_value (priv->shdn_gpio,1 ); +usleep_range (4000 ,5000 ); + }else { +gpiod_direction_output (priv->shdn_gpio,0 ); + }
The above can be simpler:
gpiod_direction_output(priv->shdn_gpio, 0);
if (on) {
usleep_range(4000, 5000);
gpiod_set_value(priv->shdn_gpio, 1);
usleep_range(4000, 5000);
}drivers/tty/serial/si4455.c line 793
Quoted 4 lines
drivers/tty/serial/si4455.c new file +4
-0+static void si4455_handle_rx_pend (struct si4455_port *s) +{ +struct uart_port *port = &s->port; +u8 *data =NULL ;
Unused initialization.
drivers/tty/serial/si4455.c line 804
Quoted 11 lines
drivers/tty/serial/si4455.c new file +11
-0+int sret =0 ; +int i =0 ; + +if (s->package_size ==0 ) { +//TODO: variable packet length +dev_err (port->dev,"%s: variable packet length is not supported by the driver\n" , + __func__); +return ; + } + + data =kzalloc (s->package_size,GFP_KERNEL );
Missing check of data.
drivers/tty/serial/si4455.c line 817
Quoted 13 lines
drivers/tty/serial/si4455.c new file +13
-0+ sret =si4455_end_rx (port, s->package_size, data); +if (sret) { +dev_err (port->dev,"%s: si4455_end_rx error (%i)\n" , + __func__, sret); + }else { +for (i =0 ; i < s->package_size; i++) { +uart_insert_char (port,0 ,0 , data[i],TTY_NORMAL ); + port->icount.rx++; + } +tty_flip_buffer_push (&port->state->port); + } +kfree (data); +}
...
thanks,
Signature · 2 lines
js suse labs
Quoted 82 lines · Jiri Slaby
Quoted 3 lines · József Horváth
drivers/tty/serial/si4455.c new file +0
-0@@ -0,0 +1,1372 @@...
Quoted 20 lines
drivers/tty/serial/si4455.c new file +20
-0+static int si4455_write_data (struct uart_port *port,u8 command,int poll, +int length,const u8 *data) +{ +int ret =0 ; +u8 *data_out; + +if (poll) { + ret =si4455_poll_cts (port); +if (ret) +return ret; + } + + data_out =kzalloc (1 + length,GFP_KERNEL ); +if (!data_out) +return -ENOMEM ; + + data_out[0 ] = command; +memcpy (&data_out[1 ], data, length); + ret =spi_write (to_spi_device (port->dev), data_out,1 + length); +if (ret) {drivers/tty/serial/si4455.c line 279
Quoted 10 lines
drivers/tty/serial/si4455.c new file +10
-0+dev_err (port->dev, +"%s: spi_write error (%i)\n" , __func__, ret); + } + +kfree (data_out); + +return ret; +} + +static void si4455_set_power (struct si4455_port *priv,int on)"on" can be bool here. And "poll" in earlier functions. And "on" in later ones.
drivers/tty/serial/si4455.c line 290
Quoted 11 lines
drivers/tty/serial/si4455.c new file +11
-0+{ +if (!priv->shdn_gpio) +return ; +if (on) { +gpiod_direction_output (priv->shdn_gpio,0 ); +usleep_range (4000 ,5000 ); +gpiod_set_value (priv->shdn_gpio,1 ); +usleep_range (4000 ,5000 ); + }else { +gpiod_direction_output (priv->shdn_gpio,0 ); + }The above can be simpler:
gpiod_direction_output(priv->shdn_gpio, 0);if (on) { usleep_range(4000, 5000); gpiod_set_value(priv->shdn_gpio, 1); usleep_range(4000, 5000); }drivers/tty/serial/si4455.c line 793
Quoted 4 lines
drivers/tty/serial/si4455.c new file +4
-0+static void si4455_handle_rx_pend (struct si4455_port *s) +{ +struct uart_port *port = &s->port; +u8 *data =NULL ;Unused initialization.
drivers/tty/serial/si4455.c line 804
Quoted 11 lines
drivers/tty/serial/si4455.c new file +11
-0+int sret =0 ; +int i =0 ; + +if (s->package_size ==0 ) { +//TODO: variable packet length +dev_err (port->dev,"%s: variable packet length is not supported by the driver\n" , + __func__); +return ; + } + + data =kzalloc (s->package_size,GFP_KERNEL );Missing check of data.
Quoted 18 lines
drivers/tty/serial/si4455.c line 817
Quoted 13 lines
drivers/tty/serial/si4455.c new file +13
-0+ sret =si4455_end_rx (port, s->package_size, data); +if (sret) { +dev_err (port->dev,"%s: si4455_end_rx error (%i)\n" , + __func__, sret); + }else { +for (i =0 ; i < s->package_size; i++) { +uart_insert_char (port,0 ,0 , data[i],TTY_NORMAL ); + port->icount.rx++; + } +tty_flip_buffer_push (&port->state->port); + } +kfree (data); +}...
thanks,Signature · 2 lines
js suse labs
Thank you for suggestions.
Üdvözlettel / Best regards:
József Horváth