Skip to contentSkip to conversation

Serial: silabs si4455 serial driver

PATCH Superseded József Horváth 3 participants 4 messages Dec 15, 2020

Subsystems (2)

v5 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 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

---
 .../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
new file mode 100644
index 000000000000..ddff67e6a667
@@ -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
index a008b70f3c16..0b544267d67b 100644
@@ -15952,6 +15952,12 @@ M:	Jérôme Pouiller <[email protected]>
 S:	Supported
 F:	drivers/staging/wfx/
 
+SILICON LABS SI4455 SERIAL DRIVER
+M:	József Horváth <[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
index 28f22e58639c..560aa311cd03 100644
@@ -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
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 +1372 -0

1,372 lines not on this page · raw message

Signature · 1 line
2.17.1
#1 lore raw
Thank you for the patch! Perhaps something to improve:

Hi "József,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on tty/tty-testing]
[also build test WARNING on usb/usb-testing robh/for-next linus/master v5.10] [cannot apply to next-20201215]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/J-zsef-Horv-th/Serial-silabs-si4455-serial-driver/20201215-152422
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing
config: arm-randconfig-r035-20201215 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project a29ecca7819a6ed4250d3689b12b1f664bb790d7)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://github.com/0day-ci/linux/commit/52689786f9d510c9f4da3a56a3f049e2128f9730
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review J-zsef-Horv-th/Serial-silabs-si4455-serial-driver/20201215-152422 git checkout 52689786f9d510c9f4da3a56a3f049e2128f9730
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

>> drivers/tty/serial/si4455.c:1371:17: warning: illegal character encoding in string literal [-Winvalid-source-encoding]
   MODULE_AUTHOR("J<F3>zsef Horv<E1>th <[email protected]>");
                   ^~~~         ~~~~
   include/linux/module.h:233:52: note: expanded from macro 'MODULE_AUTHOR'
   #define MODULE_AUTHOR(_author) MODULE_INFO(author, _author)
                                                      ^~~~~~~
   include/linux/module.h:163:56: note: expanded from macro 'MODULE_INFO'
   #define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
                                                          ^~~~

include/linux/moduleparam.h:26:47: note: expanded from macro '__MODULE_INFO'
= __MODULE_INFO_PREFIX __stringify(tag) "=" info
^~~~
1 warning generated.

vim +1371 drivers/tty/serial/si4455.c

1369
1370 MODULE_LICENSE("GPL");

> 1371	MODULE_AUTHOR("J�zsef Horv�th <[email protected]>");

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

maintainer
#2 lore raw
In reply to József Horváth
Quoted 57 lines · József Horváth

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,

Quoted 8 lines

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

The revision history should be after the '---' so it is not in the git history when applied.

Quoted 3 lines
---
 .../bindings/serial/silabs,si4455.yaml        |   98 ++

Please make the binding a separate patch.

Quoted 70 lines
 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 +56 -0
new file mode 100644
index 000000000000..ddff67e6a667
@@ -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.

Documentation/devicetree/bindings/serial/silabs,si4455.yaml line 66

Quoted 10 lines
Documentation/devicetree/bindings/serial/silabs,si4455.yaml new file +10 -0
+    $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}$

We use 'firmware-name' property for this purpose.

Looks good otherwise.

Quoted 32 lines
Documentation/devicetree/bindings/serial/silabs,si4455.yaml new file +32 -0
+
+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";
+      };
+    };
+...
#3 lore raw
Quoted 23 lines · Rob Herring
Quoted 4 lines · József Horváth

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

- fixed: dt-bindings: silabs,si4455: serial.yaml reference added

The revision history should be after the '---' so it is not in the git history when applied.

Quoted 3 lines
---
 .../bindings/serial/silabs,si4455.yaml        |   98 ++

Please make the binding a separate patch.

Documentation/devicetree/bindings/serial/silabs,si4455.yaml line 66

Quoted 7 lines
 MAINTAINERS                                   |    6 +
Documentation/devicetree/bindings/serial/silabs,si4455.yaml new file +6 -0
+  silabs,ez-config:
+    description:
+      Radio configuration data file name.
+    $ref: /schemas/types.yaml#/definitions/string
+    items:
+      pattern: ^[0-9a-z\._\-]{1,255}$
Quoted 1 line

We use 'firmware-name' property for this purpose.

Yes, I saw it, but in my mind it is still a configuration
and this name covers the meaning,
but I can rename it, the "description" above describes the real meaning.

Quoted 2 lines

Looks good otherwise.

Thank you and everyone who read or commented my code.

Quoted 25 lines
Quoted 25 lines
Documentation/devicetree/bindings/serial/silabs,si4455.yaml new file +24 -0
+
+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>;
Quoted 8 lines

Documentation/devicetree/bindings/serial/silabs,si4455.yaml line 98

Quoted 8 lines
Documentation/devicetree/bindings/serial/silabs,si4455.yaml new file +8 -0
+        spi-max-frequency = <300000>;
+        silabs,package-size = <30>;
+        silabs,tx-channel = <1>;
+        silabs,rx-channel = <2>;
+        silabs,ez-config = "si4455_spi0_0.ez.bin";
+      };
+    };
+...

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