Add UART driver for Suplus SP7021 SoC
Hammer Hsieh
maintainerPATCH v7 1/2 dt-bindings:serial:Add bindings doc for Sunplus SoC UART Driver
In reply to Hammer HsiehAdd bindings doc for Sunplus SoC UART Driver
---
Changes in v7:
- no change.
.../bindings/serial/sunplus,sp7021-uart.yaml | 56 ++++++++++++++++++++++ MAINTAINERS | 5 ++ 2 files changed, 61 insertions(+) create mode 100644 Documentation/devicetree/bindings/serial/sunplus,sp7021-uart.yaml
Documentation/devicetree/bindings/serial/sunplus,sp7021-uart.yaml new file +56 -0
@@ -0,0 +1,56 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) Sunplus Co., Ltd. 2021 +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/serial/sunplus,sp7021-uart.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Sunplus SoC SP7021 UART Controller Device Tree Bindings + +maintainers: + - Hammer Hsieh <[email protected]> + +allOf: + - $ref: serial.yaml# + +properties: + compatible: + const: sunplus,sp7021-uart + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + + resets: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + - clocks + - resets + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + aliases { + serial0 = &uart0; + }; + + uart0: serial@9c000900 { + compatible = "sunplus,sp7021-uart"; + reg = <0x9c000900 0x80>; + interrupt-parent = <&intc>; + interrupts = <53 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clkc 0x28>; + resets = <&rstc 0x18>; + }; +...
MAINTAINERS +5 -0
@@ -17945,6 +17945,11 @@ L: [email protected] S: Maintained F: drivers/net/ethernet/dlink/sundance.c +SUNPLUS UART DRIVER +M: Hammer Hsieh <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/serial/sunplus,sp7021-uart.yaml + SUPERH M: Yoshinori Sato <[email protected]> M: Rich Felker <[email protected]>
Signature · 1 line
2.7.4
Hammer Hsieh
maintainerv7 cover Add UART driver for Suplus SP7021 SoC
This is a patch series for UART driver for Suplus SP7021 SoC.
Sunplus SP7021 is an ARM Cortex A7 (4 cores) based SoC. It integrates many peripherals (ex: UART. I2C, SPI, SDIO, eMMC, USB, SD card and etc.) into a single chip. It is designed for industrial control.
Refer to:
https://sunplus-tibbo.atlassian.net/wiki/spaces/doc/overview
https://tibbo.com/store/plus1.html
Refer to (UART):
https://sunplus.atlassian.net/wiki/spaces/doc/pages/1873412290/13.+Universal+Asynchronous+Receiver+Transmitter+UART
Hammer Hsieh (2):
dt-bindings:serial:Add bindings doc for Sunplus SoC UART Driver serial:sunplus-uart:Add Sunplus SoC UART Driver
.../bindings/serial/sunplus,sp7021-uart.yaml | 56 ++ MAINTAINERS | 6 + drivers/tty/serial/Kconfig | 25 + drivers/tty/serial/Makefile | 1 + drivers/tty/serial/sunplus-uart.c | 762 +++++++++++++++++++++ include/uapi/linux/serial_core.h | 3 + 6 files changed, 853 insertions(+) create mode 100644 Documentation/devicetree/bindings/serial/sunplus,sp7021-uart.yaml create mode 100644 drivers/tty/serial/sunplus-uart.c
Signature · 1 line
2.7.4
Hammer Hsieh
maintainerPATCH v7 2/2 serial:sunplus-uart:Add Sunplus SoC UART Driver
Add Sunplus SoC UART Driver
---
Changes in v7:
- Addressed all comments from Jiri Slaby and Greg KH.
MAINTAINERS | 1 + drivers/tty/serial/Kconfig | 25 ++ drivers/tty/serial/Makefile | 1 + drivers/tty/serial/sunplus-uart.c | 762 ++++++++++++++++++++++++++++++++++++++ include/uapi/linux/serial_core.h | 3 + 5 files changed, 792 insertions(+) create mode 100644 drivers/tty/serial/sunplus-uart.c
MAINTAINERS +1 -0
@@ -17949,6 +17949,7 @@ SUNPLUS UART DRIVER M: Hammer Hsieh <[email protected]> S: Maintained F: Documentation/devicetree/bindings/serial/sunplus,sp7021-uart.yaml +F: drivers/tty/serial/sunplus-uart.c SUPERH M: Yoshinori Sato <[email protected]>
drivers/tty/serial/Kconfig +25 -0
@@ -1561,6 +1561,31 @@ config SERIAL_LITEUART_CONSOLE and warnings and which allows logins in single user mode). Otherwise, say 'N'. +config SERIAL_SUNPLUS + tristate "Sunplus UART support" + depends on OF || COMPILE_TEST + select SERIAL_CORE + help + Select this option if you would like to use Sunplus serial port on + Sunplus SoC SP7021. + If you enable this option, Sunplus serial ports in the system will + be registered as ttySUPx. + This driver can also be built as a module. If so, the module will be + called sunplus-uart. + +config SERIAL_SUNPLUS_CONSOLE + bool "Console on Sunplus UART" + depends on SERIAL_SUNPLUS + select SERIAL_CORE_CONSOLE + select SERIAL_EARLYCON + help + Select this option if you would like to use a Sunplus UART as the + system console. + Even if you say Y here, the currently visible virtual console + (/dev/tty0) will still be used as the system console by default, but + you can alter that using a kernel command line option such as + "console=ttySUPx". + endmenu config SERIAL_MCTRL_GPIO
drivers/tty/serial/Makefile +1 -0
@@ -87,6 +87,7 @@ obj-$(CONFIG_SERIAL_RDA) += rda-uart.o obj-$(CONFIG_SERIAL_MILBEAUT_USIO) += milbeaut_usio.o obj-$(CONFIG_SERIAL_SIFIVE) += sifive.o obj-$(CONFIG_SERIAL_LITEUART) += liteuart.o +obj-$(CONFIG_SERIAL_SUNPLUS) += sunplus-uart.o # GPIOLIB helpers for modem control lines obj-$(CONFIG_SERIAL_MCTRL_GPIO) += serial_mctrl_gpio.o
drivers/tty/serial/sunplus-uart.c new file +762 -0
762 lines not on this page · raw message
include/uapi/linux/serial_core.h +3 -0
@@ -274,4 +274,7 @@/* Freescale LINFlexD UART */ #define PORT_LINFLEXUART 122 +/* Sunplus UART */ +#define PORT_SUNPLUS 123 +#endif /* _UAPILINUX_SERIAL_CORE_H */
Signature · 1 line
2.7.4
Greg KH
maintainerRe: [PATCH v7 2/2] serial:sunplus-uart:Add Sunplus SoC UART Driver
Quoted 2 lines · Hammer Hsieh
Add Sunplus SoC UART Driver
We need more of a changelog comment here please. Describe the hardware, what the new tty name you are using, and other stuff. Be descriptive.
include/uapi/linux/serial_core.h line 278
Quoted 8 lines
include/uapi/linux/serial_core.h +2
-0@@ -274,4 +274,7 @@/* Freescale LINFlexD UART */ #define PORT_LINFLEXUART 122 +/* Sunplus UART */ +#define PORT_SUNPLUS 123
Why is this needed? Are you going to require this in some userspace code? If not, please do not add it.
thanks,
greg k-h
kernel test robot
build botRe: [PATCH v7 2/2] serial:sunplus-uart:Add Sunplus SoC UART Driver
In reply to Hammer HsiehI love your patch! Perhaps something to improve:
Hi Hammer,
I love your patch! Perhaps something to improve:
[auto build test WARNING on linux/master]
[cannot apply to tty/tty-testing robh/for-next linus/master v5.17-rc3 next-20220207] [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/Hammer-Hsieh/Add-UART-driver-for-Suplus-SP7021-SoC/20220207-144451 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 2c271fe77d52a0555161926c232cd5bc07178b39 config: ia64-allmodconfig (https://download.01.org/0day-ci/archive/20220207/202202071924.YLKjNyyr-lkp(a)intel.com/config) compiler: ia64-linux-gcc (GCC) 11.2.0
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
# https://github.com/0day-ci/linux/commit/423c8dea29f94c6fe20e3864a2424e7bc4b79b27
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Hammer-Hsieh/Add-UART-driver-for-Suplus-SP7021-SoC/20220207-144451 git checkout 423c8dea29f94c6fe20e3864a2424e7bc4b79b27
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/tty/serial/
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
drivers/tty/serial/sunplus-uart.c: In function 'sunplus_uart_probe':
>> drivers/tty/serial/sunplus-uart.c:630:40: warning: cast between incompatible function types from 'int (*)(struct reset_control *)' to 'void (*)(void *)' [-Wcast-function-type]
630 | (void(*)(void *))reset_control_assert,
| ^
In file included from drivers/tty/serial/sunplus-uart.c:13:
drivers/tty/serial/sunplus-uart.c: At top level:
include/linux/module.h:131:49: error: redefinition of '__inittest'
131 | static inline initcall_t __maybe_unused __inittest(void) \
| ^~~~~~~~~~
drivers/tty/serial/sunplus-uart.c:717:1: note: in expansion of macro 'module_init'
717 | module_init(sunplus_uart_init);
| ^~~~~~~~~~~
include/linux/module.h:131:49: note: previous definition of '__inittest' with type 'int (*(void))(void)'
131 | static inline initcall_t __maybe_unused __inittest(void) \
| ^~~~~~~~~~
include/linux/module.h:127:41: note: in expansion of macro 'module_init'
127 | #define console_initcall(fn) module_init(fn)
| ^~~~~~~~~~~
drivers/tty/serial/sunplus-uart.c:558:1: note: in expansion of macro 'console_initcall'
558 | console_initcall(sunplus_console_init);
| ^~~~~~~~~~~~~~~~
include/linux/module.h:133:13: error: redefinition of 'init_module'
133 | int init_module(void) __copy(initfn) \
| ^~~~~~~~~~~
drivers/tty/serial/sunplus-uart.c:717:1: note: in expansion of macro 'module_init'
717 | module_init(sunplus_uart_init);
| ^~~~~~~~~~~
include/linux/module.h:133:13: note: previous definition of 'init_module' with type 'int(void)'
133 | int init_module(void) __copy(initfn) \
| ^~~~~~~~~~~
include/linux/module.h:127:41: note: in expansion of macro 'module_init'
127 | #define console_initcall(fn) module_init(fn)
| ^~~~~~~~~~~
drivers/tty/serial/sunplus-uart.c:558:1: note: in expansion of macro 'console_initcall'
558 | console_initcall(sunplus_console_init);
| ^~~~~~~~~~~~~~~~ drivers/tty/serial/sunplus-uart.c:669:12: warning: 'sunplus_uart_resume' defined but not used [-Wunused-function]
669 | static int sunplus_uart_resume(struct device *dev)
| ^~~~~~~~~~~~~~~~~~~
drivers/tty/serial/sunplus-uart.c:659:12: warning: 'sunplus_uart_suspend' defined but not used [-Wunused-function]
659 | static int sunplus_uart_suspend(struct device *dev)
| ^~~~~~~~~~~~~~~~~~~~
vim +630 drivers/tty/serial/sunplus-uart.c
570
571 static int sunplus_uart_probe(struct platform_device *pdev)
572 {
573 struct sunplus_uart_port *sup;
574 struct uart_port *port;
575 struct resource *res;
576 int ret, irq;
577
578 pdev->id = of_alias_get_id(pdev->dev.of_node, "serial");
579
580 if (pdev->id < 0 || pdev->id >= SUP_UART_NR)
581 return -EINVAL;
582
583 sup = devm_kzalloc(&pdev->dev, sizeof(*sup), GFP_KERNEL);
584 if (!sup)
585 return -ENOMEM;
586
587 sup->clk = devm_clk_get_optional(&pdev->dev, NULL);
588 if (IS_ERR(sup->clk))
589 return dev_err_probe(&pdev->dev, PTR_ERR(sup->clk), "clk not found\n");
590
591 ret = clk_prepare_enable(sup->clk);
592 if (ret)
593 return ret;
594
595 ret = devm_add_action_or_reset(&pdev->dev,
596 (void(*)(void *))clk_disable_unprepare,
597 sup->clk);
598 if (ret)
599 return ret;
600
601 sup->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
602 if (IS_ERR(sup->rstc))
603 return dev_err_probe(&pdev->dev, PTR_ERR(sup->rstc), "rstc not found\n");
604
605 port = &sup->port;
606
607 port->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
608 if (IS_ERR(port->membase))
609 return dev_err_probe(&pdev->dev, PTR_ERR(port->membase), "membase not found\n");
610
611 irq = platform_get_irq(pdev, 0);
612 if (irq < 0)
613 return irq;
614
615 port->mapbase = res->start;
616 port->uartclk = clk_get_rate(sup->clk);
617 port->line = pdev->id;
618 port->irq = irq;
619 port->dev = &pdev->dev;
620 port->iotype = UPIO_MEM;
621 port->ops = &sunplus_uart_ops;
622 port->flags = UPF_BOOT_AUTOCONF;
623 port->fifosize = 128;
624
625 ret = reset_control_deassert(sup->rstc);
626 if (ret)
627 return ret;
628
629 ret = devm_add_action_or_reset(&pdev->dev,
> 630 (void(*)(void *))reset_control_assert,
631 sup->rstc);
632 if (ret)
633 return ret;
634
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
hammer hsieh
maintainerRe: [PATCH v7 2/2] serial:sunplus-uart:Add Sunplus SoC UART Driver
In reply to Greg KHGreg KH <[email protected]> 於 2022年2月7日 週一 下午3:18寫道:
Quoted 8 lines · Hammer Hsieh
Quoted 2 lines
Add Sunplus SoC UART Driver
We need more of a changelog comment here please. Describe the hardware, what the new tty name you are using, and other stuff. Be descriptive.
I will describe as below.
Add Sunplus SoC UART Driver.
SP7021 UART block contains 5 UARTs.
There are UART0~4 that supported in SP7021, the features list as below. Support Full-duplex communication.
Support data packet length configurable.
Support stop bit number configurable.
Support force break condition.
Support baud rate configurable.
Support error detection and report.
Support RXD Noise Rejection Vote configurable.
UART0 pinout only support TX/RX two pins.
UART1 to UART4 pinout support TX/RX/CTS/RTS four pins. Normally UART0 used for kernel console, also can be used for normal uart. Command line set "console=ttySUP0,115200", SUP means Sunplus Uart Port. UART driver probe will create path named "/dev/ttySUPx".
Quoted 6 lines
Quoted 6 lines
include/uapi/linux/serial_core.h +0
-0@@ -274,4 +274,7 @@/* Freescale LINFlexD UART */ #define PORT_LINFLEXUART 122
Quoted 6 lines
include/uapi/linux/serial_core.h line 278
Quoted 2 lines
include/uapi/linux/serial_core.h +2
-0+/* Sunplus UART */ +#define PORT_SUNPLUS 123Why is this needed? Are you going to require this in some userspace code? If not, please do not add it.
In serial_core.c (line 3014) uart_add_one_port( )
It will call uart_configure_port( ).
In my uart driver probe set port->flags=UPF_BOOT_AUTOCONF. I try to remove port define and remove sunplus_config_port( )
and just add a "sunplus_uart" for in sunplus_type( ).
And my uart console not work with PuTTY tool.
I try to do another test as below.
static const char *sunplus_type(struct uart_port *port)
{
return "sunplus_uart";
}static void sunplus_config_port(struct uart_port *port, int type) {
if (type & UART_CONFIG_TYPE)
port->type = "sunplus_uart"; //type define is unsigned int
}
Uart console works, but port->type should be unsigned int , not string. So compile will warning " assignment makes integer from pointer without a cast [-Wint-conversion]".
I think I should keep the current submit code.
Quoted 3 lines
thanks,
greg k-h
kernel test robot
build botRe: [PATCH v7 2/2] serial:sunplus-uart:Add Sunplus SoC UART Driver
In reply to Hammer HsiehI love your patch! Yet something to improve:
Hi Hammer,
I love your patch! Yet something to improve:
[auto build test ERROR on linux/master]
[cannot apply to tty/tty-testing robh/for-next linus/master v5.17-rc3 next-20220207] [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/Hammer-Hsieh/Add-UART-driver-for-Suplus-SP7021-SoC/20220207-144451 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 2c271fe77d52a0555161926c232cd5bc07178b39 config: powerpc-allmodconfig (https://download.01.org/0day-ci/archive/20220207/202202072009.s4knQBpy-lkp(a)intel.com/config) compiler: powerpc-linux-gcc (GCC) 11.2.0
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
# https://github.com/0day-ci/linux/commit/423c8dea29f94c6fe20e3864a2424e7bc4b79b27
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Hammer-Hsieh/Add-UART-driver-for-Suplus-SP7021-SoC/20220207-144451 git checkout 423c8dea29f94c6fe20e3864a2424e7bc4b79b27
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/tty/serial/
If you fix the issue, kindly add following tag as appropriate
All error/warnings (new ones prefixed by >>):
drivers/tty/serial/sunplus-uart.c: In function 'sunplus_poll_put_char':
>> drivers/tty/serial/sunplus-uart.c:436:9: error: implicit declaration of function 'wait_for_xmitr'; did you mean 'wait_on_bit'? [-Werror=implicit-function-declaration]
436 | wait_for_xmitr(port);
| ^~~~~~~~~~~~~~
| wait_on_bit
drivers/tty/serial/sunplus-uart.c: At top level:
>> drivers/tty/serial/sunplus-uart.c:475:13: warning: conflicting types for 'wait_for_xmitr'; have 'void(struct uart_port *)'
475 | static void wait_for_xmitr(struct uart_port *port)
| ^~~~~~~~~~~~~~
>> drivers/tty/serial/sunplus-uart.c:475:13: error: static declaration of 'wait_for_xmitr' follows non-static declaration
drivers/tty/serial/sunplus-uart.c:436:9: note: previous implicit declaration of 'wait_for_xmitr' with type 'void(struct uart_port *)'
436 | wait_for_xmitr(port);
| ^~~~~~~~~~~~~~
drivers/tty/serial/sunplus-uart.c: In function 'sunplus_uart_probe':
drivers/tty/serial/sunplus-uart.c:630:40: warning: cast between incompatible function types from 'int (*)(struct reset_control *)' to 'void (*)(void *)' [-Wcast-function-type]
630 | (void(*)(void *))reset_control_assert,
| ^
In file included from include/linux/device/driver.h:21,
from include/linux/device.h:32,
from arch/powerpc/include/asm/io.h:27,
from include/linux/io.h:13,
from include/linux/irq.h:20,
from arch/powerpc/include/asm/hardirq.h:6,
from include/linux/hardirq.h:11,
from include/linux/interrupt.h:11,
from drivers/tty/serial/sunplus-uart.c:10:
drivers/tty/serial/sunplus-uart.c: At top level:
include/linux/module.h:131:49: error: redefinition of '__inittest'
131 | static inline initcall_t __maybe_unused __inittest(void) \
| ^~~~~~~~~~
drivers/tty/serial/sunplus-uart.c:717:1: note: in expansion of macro 'module_init'
717 | module_init(sunplus_uart_init);
| ^~~~~~~~~~~
include/linux/module.h:131:49: note: previous definition of '__inittest' with type 'int (*(void))(void)'
131 | static inline initcall_t __maybe_unused __inittest(void) \
| ^~~~~~~~~~
include/linux/module.h:127:41: note: in expansion of macro 'module_init'
127 | #define console_initcall(fn) module_init(fn)
| ^~~~~~~~~~~
drivers/tty/serial/sunplus-uart.c:558:1: note: in expansion of macro 'console_initcall'
558 | console_initcall(sunplus_console_init);
| ^~~~~~~~~~~~~~~~
include/linux/module.h:133:13: error: redefinition of 'init_module'
133 | int init_module(void) __copy(initfn) \
| ^~~~~~~~~~~
drivers/tty/serial/sunplus-uart.c:717:1: note: in expansion of macro 'module_init'
717 | module_init(sunplus_uart_init);
| ^~~~~~~~~~~
include/linux/module.h:133:13: note: previous definition of 'init_module' with type 'int(void)'
133 | int init_module(void) __copy(initfn) \
| ^~~~~~~~~~~
include/linux/module.h:127:41: note: in expansion of macro 'module_init'
127 | #define console_initcall(fn) module_init(fn)
| ^~~~~~~~~~~
drivers/tty/serial/sunplus-uart.c:558:1: note: in expansion of macro 'console_initcall'
558 | console_initcall(sunplus_console_init);
| ^~~~~~~~~~~~~~~~cc1: some warnings being treated as errors
vim +436 drivers/tty/serial/sunplus-uart.c
432
433 #ifdef CONFIG_CONSOLE_POLL
434 static void sunplus_poll_put_char(struct uart_port *port, unsigned char data)
435 {
> 436 wait_for_xmitr(port);
437 sp_uart_put_char(port, data);
438 }
439
440 static int sunplus_poll_get_char(struct uart_port *port)
441 {
442 unsigned int lsr = readl(port->membase + SUP_UART_LSR);
443
444 if (!(lsr & SUP_UART_LSR_RX))
445 return NO_POLL_CHAR;
446
447 return readl(port->membase + SUP_UART_DATA);
448 }
449 #endif
450
451 static const struct uart_ops sunplus_uart_ops = {
452 .tx_empty = sunplus_tx_empty,
453 .set_mctrl = sunplus_set_mctrl,
454 .get_mctrl = sunplus_get_mctrl,
455 .stop_tx = sunplus_stop_tx,
456 .start_tx = sunplus_start_tx,
457 .stop_rx = sunplus_stop_rx,
458 .break_ctl = sunplus_break_ctl,
459 .startup = sunplus_startup,
460 .shutdown = sunplus_shutdown,
461 .set_termios = sunplus_set_termios,
462 .set_ldisc = sunplus_set_ldisc,
463 .type = sunplus_type,
464 .config_port = sunplus_config_port,
465 .verify_port = sunplus_verify_port,
466 #ifdef CONFIG_CONSOLE_POLL
467 .poll_put_char = sunplus_poll_put_char,
468 .poll_get_char = sunplus_poll_get_char,
469 #endif
470 };
471
472 #ifdef CONFIG_SERIAL_SUNPLUS_CONSOLE
473 struct sunplus_uart_port *sunplus_console_ports[SUP_UART_NR];
474
> 475 static void wait_for_xmitr(struct uart_port *port) 476 {
477 unsigned int val;
478 int ret;
479
480 /* Wait while FIFO is full or timeout */
481 ret = readl_poll_timeout_atomic(port->membase + SUP_UART_LSR, val,
482 (val & SUP_UART_LSR_TX), 1, 10000);
483
484 if (ret == -ETIMEDOUT) {
485 dev_err(port->dev, "Timeout waiting while UART TX FULL\n");
486 return;
487 }
488 }
489
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Jiri Slaby
maintainerRe: [PATCH v7 2/2] serial:sunplus-uart:Add Sunplus SoC UART Driver
In reply to Hammer HsiehHi,
drivers/tty/serial/sunplus-uart.c line 315
Quoted 9 lines · Hammer Hsieh
drivers/tty/serial/sunplus-uart.c new file +9
-0+static void sunplus_shutdown (struct uart_port *port) +{ +unsigned long flags; +unsigned int isc; + +spin_lock_irqsave (&port->lock, flags); + + isc =readl (port->membase +SUP_UART_ISC ); + isc &= ~(SUP_UART_ISC_RXM |SUP_UART_ISC_TXM );
Is this correct? I mean: will the SUP_UART_ISC read contain the control bits, not only status bits?
drivers/tty/serial/sunplus-uart.c line 320
Quoted 5 lines
drivers/tty/serial/sunplus-uart.c new file +5
-0+writel (isc, port->membase +SUP_UART_ISC ); + +spin_unlock_irqrestore (&port->lock, flags); + +free_irq (port->irq, port);
I am still waiting for explanation why this is safe with respect to posted writes.
regards,
Signature · 2 lines
js suse labs
hammer hsieh
maintainerRe: [PATCH v7 2/2] serial:sunplus-uart:Add Sunplus SoC UART Driver
Jiri Slaby <[email protected]> 於 2022年2月8日 週二 下午2:27寫道:
Quoted 4 lines
Hi,
On 07. 02. 22, 6:58, Hammer Hsieh wrote:
Quoted 13 lines
drivers/tty/serial/sunplus-uart.c line 315
Quoted 9 lines
drivers/tty/serial/sunplus-uart.c new file +9
-0+static void sunplus_shutdown (struct uart_port *port) +{ +unsigned long flags; +unsigned int isc; + +spin_lock_irqsave (&port->lock, flags); + + isc =readl (port->membase +SUP_UART_ISC ); + isc &= ~(SUP_UART_ISC_RXM |SUP_UART_ISC_TXM );Is this correct? I mean: will the
SUP_UART_ISCread contain the control bits, not only status bits?
I assume reviewers don't like writel(0,xxx).
So I use definition to let the code easy to read. The purpose is to clear all interrupt.
Bit[3:0] status bit only for read, write 1 or 0 no effect.
Quoted 9 lines
drivers/tty/serial/sunplus-uart.c line 320
Quoted 5 lines
drivers/tty/serial/sunplus-uart.c new file +5
-0+writel (isc, port->membase +SUP_UART_ISC ); + +spin_unlock_irqrestore (&port->lock, flags); + +free_irq (port->irq, port);I am still waiting for explanation why this is safe with respect to posted writes.
Actually I'm not IC designer, not expert for bus design.
About data incoherence issue between memory bus and peripheral bus. In case of AXI bus, use non-posted write can avoid data incoherence issue. What if in case of posted write:
Send a specific command after last write command.
SDCTRL identify specific command, means previous write command done. Then send interrupt signal to interrupt controller.
And then interrupt controller send done signal to Master. Master receive done signal, means write command done.
Then issue a interrupt or proceed next write command.
IC designer told us no problem, and as a uart driver maintainer. It is not my concern, but glad you ask.
Let me have chance to know it from IC designer.
Quoted 4 lines
regards,
--
js
suse labs
Greg KH
maintainerRe: [PATCH v7 2/2] serial:sunplus-uart:Add Sunplus SoC UART Driver
Quoted 34 lines · hammer hsieh
Jiri Slaby <[email protected]> 於 2022年2月8日 週二 下午2:27寫道:
Quoted 4 lines
Hi,
On 07. 02. 22, 6:58, Hammer Hsieh wrote:
Quoted 13 lines
drivers/tty/serial/sunplus-uart.c line 315
Quoted 9 lines
drivers/tty/serial/sunplus-uart.c new file +9
-0+static void sunplus_shutdown (struct uart_port *port) +{ +unsigned long flags; +unsigned int isc; + +spin_lock_irqsave (&port->lock, flags); + + isc =readl (port->membase +SUP_UART_ISC ); + isc &= ~(SUP_UART_ISC_RXM |SUP_UART_ISC_TXM );Is this correct? I mean: will the
SUP_UART_ISCread contain the control bits, not only status bits?I assume reviewers don't like
writel(0,xxx).
So I use definition to let the code easy to read. The purpose is to clear all interrupt.
Bit[3:0] status bit only for read, write 1 or 0 no effect.Quoted 9 lines
drivers/tty/serial/sunplus-uart.c line 320
Quoted 5 lines
drivers/tty/serial/sunplus-uart.c new file +5
-0+writel (isc, port->membase +SUP_UART_ISC ); + +spin_unlock_irqrestore (&port->lock, flags); + +free_irq (port->irq, port);I am still waiting for explanation why this is safe with respect to posted writes.
Quoted 10 lines
Actually I'm not IC designer, not expert for bus design.
About data incoherence issue between memory bus and peripheral bus. In case of AXI bus, use non-posted write can avoid data incoherence issue. What if in case of posted write:
Send a specific command after last write command.
SDCTRL identify specific command, means previous write command done. Then send interrupt signal to interrupt controller.
And then interrupt controller send done signal to Master. Master receive done signal, means write command done.
Then issue a interrupt or proceed next write command.
But how does the kernel know when the write is completed? The kernel seems to ignore that here entirely, so the write could actually complete seconds later, which would not be a good thing, right?
Traditionally, we want to ensure that a write() completes, so on some busses, we have to do a read to ensure that the write made it to the hardware before we can continue on. That is not happening here which is why Jiri keeps bringing it up. It looks broken to us, and you need to document it somewhere (in the changelog? In the top of the file?) as to why this is not needed.
thanks,
greg k-h
hammer hsieh
maintainerRe: [PATCH v7 2/2] serial:sunplus-uart:Add Sunplus SoC UART Driver
Ok, thanks for your explaination, I got it now.
I will document "posted write" info in the top of the file or top of startup/shutdown function.
And kernel test robot report me build error and warning with gcc 11.2.0 ia64 / powerpc.
I will fix it and send next patch.
Greg KH <[email protected]> 於 2022年2月8日 週二 下午7:31寫道:
Quoted 61 lines · hammer hsieh
Quoted 34 lines
Jiri Slaby <[email protected]> 於 2022年2月8日 週二 下午2:27寫道:
Quoted 4 lines
Hi,
On 07. 02. 22, 6:58, Hammer Hsieh wrote:
Quoted 13 lines
drivers/tty/serial/sunplus-uart.c line 315
Quoted 9 lines
drivers/tty/serial/sunplus-uart.c new file +9
-0+static void sunplus_shutdown (struct uart_port *port) +{ +unsigned long flags; +unsigned int isc; + +spin_lock_irqsave (&port->lock, flags); + + isc =readl (port->membase +SUP_UART_ISC ); + isc &= ~(SUP_UART_ISC_RXM |SUP_UART_ISC_TXM );Is this correct? I mean: will the
SUP_UART_ISCread contain the control bits, not only status bits?I assume reviewers don't like
writel(0,xxx).
So I use definition to let the code easy to read. The purpose is to clear all interrupt.
Bit[3:0] status bit only for read, write 1 or 0 no effect.Quoted 9 lines
drivers/tty/serial/sunplus-uart.c line 320
Quoted 5 lines
drivers/tty/serial/sunplus-uart.c new file +5
-0+writel (isc, port->membase +SUP_UART_ISC ); + +spin_unlock_irqrestore (&port->lock, flags); + +free_irq (port->irq, port);I am still waiting for explanation why this is safe with respect to posted writes.
Quoted 10 lines
Actually I'm not IC designer, not expert for bus design.
About data incoherence issue between memory bus and peripheral bus. In case of AXI bus, use non-posted write can avoid data incoherence issue. What if in case of posted write:
Send a specific command after last write command.
SDCTRL identify specific command, means previous write command done. Then send interrupt signal to interrupt controller.
And then interrupt controller send done signal to Master. Master receive done signal, means write command done.
Then issue a interrupt or proceed next write command.But how does the kernel know when the write is completed? The kernel seems to ignore that here entirely, so the write could actually complete seconds later, which would not be a good thing, right?
Traditionally, we want to ensure that a
write()completes, so on some busses, we have to do a read to ensure that the write made it to the hardware before we can continue on. That is not happening here which is why Jiri keeps bringing it up. It looks broken to us, and you need to document it somewhere (in the changelog? In the top of the file?) as to why this is not needed.thanks,
greg k-h