Skip to content

serial: wk2xxx: Add WK2xxx SPI UART driver - #7595

Open
zjzhao-eda wants to merge 2 commits into
raspberrypi:rpi-6.18.yfrom
edatec:wk2xxx-driver
Open

serial: wk2xxx: Add WK2xxx SPI UART driver#7595
zjzhao-eda wants to merge 2 commits into
raspberrypi:rpi-6.18.yfrom
edatec:wk2xxx-driver

Conversation

@zjzhao-eda

Copy link
Copy Markdown
Contributor

Add a driver for the WK2xxx SPI to UART bridge ICs (WK2124, WK2132, WK2168, WK2202 and WK2204) from WKmic (Chengdu Weikai Microelectronics). Each IC exposes two or four full-duplex UART channels with 256-byte RX/TX FIFOs through a single SPI slave interface and one interrupt line.

The driver is a rework of the vendor driver (https://github.com/britus/ wk2xxx) modeled after the NXP sc16is7xx driver. It registers ttyWK0..N lines (IDA-allocated), uses devm_request_threaded_irq with a kthread worker for register access, falls back to polling when the interrupt line is not described, and supports hardware flow control and RS485 where the IC provides them.

Also allocate PORT_WK2XXX (126), add the SERIAL_WK2XXX Kconfig option and document the DT binding with the wkmic vendor prefix.

Tested on Raspberry Pi 5 boards (EDATEC IPC1200 with WK2132 on SPI0 and SBC2300 with WK2204 on SPI1); loopback TX/RX tests pass.

Add a driver for the WK2xxx SPI to UART bridge ICs (WK2124, WK2132,
WK2168, WK2202 and WK2204) from WKmic (Chengdu Weikai Microelectronics).
Each IC exposes two or four full-duplex UART channels with 256-byte
RX/TX FIFOs through a single SPI slave interface and one interrupt line.

The driver is a rework of the vendor driver (https://github.com/britus/
wk2xxx) modeled after the NXP sc16is7xx driver. It registers ttyWK0..N
lines (IDA-allocated), uses devm_request_threaded_irq with a kthread
worker for register access, falls back to polling when the interrupt
line is not described, and supports hardware flow control and RS485
where the IC provides them.

Also allocate PORT_WK2XXX (126), add the SERIAL_WK2XXX Kconfig option
and document the DT binding with the wkmic vendor prefix.

Tested on Raspberry Pi 5 boards (EDATEC IPC1200 with WK2132 on SPI0 and
SBC2300 with WK2204 on SPI1); loopback TX/RX tests pass.

Signed-off-by: zjzhao <zjzhao@edatec.cn>
Enable CONFIG_SERIAL_WK2XXX in all Pi kernel configurations so the
kernel build produces wk2xxx.ko for the WK2xxx SPI UART driver and
the wk2xxx-uart overlay:

- arch/arm64/configs/bcm2711_defconfig
- arch/arm64/configs/bcm2712_defconfig
- arch/arm64/configs/bcm2711_rt_defconfig
- arch/arm/configs/bcm2709_defconfig
- arch/arm/configs/bcmrpi_defconfig

Signed-off-by: zjzhao <zjzhao@edatec.cn>

@pelwell pelwell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you've done a decent job with this, but I'm reluctant to accept a complete driver downstream, along with the maintenance burden, for a device which isn't Pi-specific.

@popcornmix

Copy link
Copy Markdown
Collaborator

Submit it upstream. Once you've got it accepted, let us know and we can backport it.

@zjzhao-eda

Copy link
Copy Markdown
Contributor Author

OK, I will submit the driver upstream first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants