Add Spreadtrum SoC bindings and serial driver support
A message that is not in the archive (sent off-list or not yet received): sc9836-serial-v9
v9 cover Add Spreadtrum SoC bindings and serial driver support
Changes from v8:
- Moved a few unuseful code lines.
Chunyan Zhang (2):
Documentation: DT: Add bindings for Spreadtrum SoC Platform tty/serial: Add Spreadtrum sc9836-uart driver support
Documentation/devicetree/bindings/arm/sprd.txt | 11 + .../devicetree/bindings/serial/sprd-uart.txt | 7 + .../devicetree/bindings/vendor-prefixes.txt | 1 + drivers/tty/serial/Kconfig | 18 + drivers/tty/serial/Makefile | 1 + drivers/tty/serial/sprd_serial.c | 789 ++++++++++++++++++++ include/uapi/linux/serial_core.h | 3 + 7 files changed, 830 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/sprd.txt create mode 100644 Documentation/devicetree/bindings/serial/sprd-uart.txt create mode 100644 drivers/tty/serial/sprd_serial.c
Signature · 6 lines
1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v9 1/2 Documentation: DT: Add bindings for Spreadtrum SoC Platform
Adds Spreadtrum's prefix "sprd" to vendor-prefixes file. Adds the devicetree binding documentations for Spreadtrum's sc9836-uart and SC9836 SoC based on the Sharkl64 Platform which is a 64-bit SoC Platform of Spreadtrum.
--- Documentation/devicetree/bindings/arm/sprd.txt | 11 +++++++++++ .../devicetree/bindings/serial/sprd-uart.txt | 7 +++++++ .../devicetree/bindings/vendor-prefixes.txt | 1 + 3 files changed, 19 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/sprd.txt create mode 100644 Documentation/devicetree/bindings/serial/sprd-uart.txt
Documentation/devicetree/bindings/arm/sprd.txt new file +11 -0
@@ -0,0 +1,11 @@ +Spreadtrum SoC Platforms Device Tree Bindings +---------------------------------------------------- + +Sharkl64 is a Spreadtrum's SoC Platform which is based +on ARM 64-bit processor. + +SC9836 openphone board with SC9836 SoC based on the +Sharkl64 Platform shall have the following properties. + +Required root node properties: + - compatible = "sprd,sc9836-openphone", "sprd,sc9836";
Documentation/devicetree/bindings/serial/sprd-uart.txt new file +7 -0
@@ -0,0 +1,7 @@ +* Spreadtrum serial UART + +Required properties: +- compatible: must be "sprd,sc9836-uart" +- reg: offset and length of the register set for the device +- interrupts: exactly one interrupt specifier +- clocks: phandles to input clocks.
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
@@ -153,6 +153,7 @@ snps Synopsys, Inc. solidrun SolidRun sony Sony Corporation spansion Spansion Inc. +sprd Spreadtrum Communications Inc. st STMicroelectronics ste ST-Ericsson stericsson ST-Ericsson
Signature · 6 lines
1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v9 2/2 tty/serial: Add Spreadtrum sc9836-uart driver support
In reply to Chunyan ZhangAdd a full sc9836-uart driver for SC9836 SoC which is based on the spreadtrum sharkl64 platform.
This driver also support earlycon.
--- drivers/tty/serial/Kconfig | 18 + drivers/tty/serial/Makefile | 1 + drivers/tty/serial/sprd_serial.c | 789 ++++++++++++++++++++++++++++++++++++++ include/uapi/linux/serial_core.h | 3 + 4 files changed, 811 insertions(+) create mode 100644 drivers/tty/serial/sprd_serial.c
drivers/tty/serial/Kconfig +18 -0
@@ -1577,6 +1577,24 @@ config SERIAL_MEN_Z135 This driver can also be build as a module. If so, the module will be called men_z135_uart.ko +config SERIAL_SPRD + tristate "Support for Spreadtrum serial" + depends on ARCH_SPRD + select SERIAL_CORE + help + This enables the driver for the Spreadtrum's serial. + +config SERIAL_SPRD_CONSOLE + bool "Spreadtrum UART console support" + depends on SERIAL_SPRD=y + select SERIAL_CORE_CONSOLE + select SERIAL_EARLYCON + help + Support for early debug console using Spreadtrum's serial. This enables + the console before standard serial driver is probed. This is enabled + with "earlycon" on the kernel command line. The console is + enabled when early_param is processed. + endmenu config SERIAL_MCTRL_GPIO
drivers/tty/serial/Makefile +1 -0
@@ -93,6 +93,7 @@ obj-$(CONFIG_SERIAL_ARC) += arc_uart.o obj-$(CONFIG_SERIAL_RP2) += rp2.o obj-$(CONFIG_SERIAL_FSL_LPUART) += fsl_lpuart.o obj-$(CONFIG_SERIAL_MEN_Z135) += men_z135_uart.o +obj-$(CONFIG_SERIAL_SPRD) += sprd_serial.o # GPIOLIB helpers for modem control lines obj-$(CONFIG_SERIAL_MCTRL_GPIO) += serial_mctrl_gpio.o
drivers/tty/serial/sprd_serial.c new file +789 -0
789 lines not on this page · raw message
include/uapi/linux/serial_core.h +3 -0
@@ -248,4 +248,7 @@/* MESON */ #define PORT_MESON 109 +/* SPRD SERIAL */ +#define PORT_SPRD 110 +#endif /* _UAPILINUX_SERIAL_CORE_H */
Signature · 6 lines
1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v9 2/2] tty/serial: Add Spreadtrum sc9836-uart driver support
Quoted 3 lines · Chunyan Zhang
Add a full sc9836-uart driver for SC9836 SoC which is based on the spreadtrum sharkl64 platform.
This driver also support earlycon.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v9 2/2] tty/serial: Add Spreadtrum sc9836-uart driver support
In reply to Chunyan ZhangHi Chunyan Zhang,
On Wed, Jan 28, 2015 at 10:47:41AM +0800, Chunyan Zhang wrote:
[...]
Quoted 7 lines
drivers/tty/serial/sprd_serial.c new file +7
-0+static inline void sprd_rx (struct uart_port *port) +{ +struct tty_port *tty = &port->state->port; +unsigned int ch, flag, lsr, max_count =SPRD_TIMEOUT ; + +while ((serial_in (port,SPRD_STS1 ) &0x00ff ) && max_count--) { + lsr =serial_in (port,SPRD_LSR );
drivers/tty/serial/sprd_serial.c line 241
Quoted 10 lines
drivers/tty/serial/sprd_serial.c new file +10
-0+ ch =serial_in (port,SPRD_RXD ); + flag =TTY_NORMAL ; + port->icount.rx++; + +if (lsr & (SPRD_LSR_BI |SPRD_LSR_PE | +SPRD_LSR_FE |SPRD_LSR_OE )) +if (handle_lsr_errors (port, &lsr, &flag)) +continue ; +if (uart_handle_sysrq_char (port, ch)) +continue ;
My comment[1] on a previous version of this patch still stands. uart_handle_sysrq_char is a NOP when SUPPORT_SYSRQ is not defined.
Quoted 6 lines
drivers/tty/serial/sprd_serial.c new file +6
-0+ +uart_insert_char (port, lsr,SPRD_LSR_OE , ch, flag); + } + +tty_flip_buffer_push (tty); +}
[...]
drivers/tty/serial/sprd_serial.c line 539
Quoted 9 lines
drivers/tty/serial/sprd_serial.c new file +9
-0+static void sprd_console_write (struct console *co,const char *s, +unsigned int count) +{ +struct uart_port *port = &sprd_port[co->index]->port; +int locked =1 ; +unsigned long flags; + +if (port->sysrq) + locked =0 ;
The sysrq field of struct uart_port is only defined when CONFIG_SERIAL_CORE_CONSOLE or SUPPORT_SYSRQ are defined. You should #ifdef this part accordingly to avoid build breakage.
drivers/tty/serial/sprd_serial.c line 552
Quoted 13 lines
drivers/tty/serial/sprd_serial.c new file +13
-0+else if (oops_in_progress) + locked =spin_trylock_irqsave (&port->lock, flags); +else +spin_lock_irqsave (&port->lock, flags); + +uart_console_write (port, s, count, sprd_console_putchar); + +/* wait for transmitter to become empty */ +wait_for_xmitr (port); + +if (locked) +spin_unlock_irqrestore (&port->lock, flags); +}
[1]
http://article.gmane.org/gmane.linux.drivers.devicetree/106483
baruch
Signature · 3 lines
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- [email protected] - tel: +972.2.679.5364, http://www.tkos.co.il -Lyra Zhang
reviewerRe: [PATCH v9 2/2] tty/serial: Add Spreadtrum sc9836-uart driver support
Hi, Baruch
I'm sorry that I didn't receive your previous email. and my explanations are below.
Quoted 16 lines · Baruch Siach
Hi Chunyan Zhang,
On Wed, Jan 28, 2015 at 10:47:41AM +0800, Chunyan Zhang wrote:
[...]Quoted 12 lines
drivers/tty/serial/sprd_serial.c new file +12
-0+static inline void sprd_rx (struct uart_port *port) +{ +struct tty_port *tty = &port->state->port; +unsigned int ch, flag, lsr, max_count =SPRD_TIMEOUT ; + +while ((serial_in (port,SPRD_STS1 ) &0x00ff ) && max_count--) { + lsr =serial_in (port,SPRD_LSR ); + ch =serial_in (port,SPRD_RXD ); + flag =TTY_NORMAL ; + port->icount.rx++; + + if (lsr & (SPRD_LSR_BI | SPRD_LSR_PE |
Quoted 9 lines
drivers/tty/serial/sprd_serial.c line 241
Quoted 5 lines
drivers/tty/serial/sprd_serial.c new file +5
-0+ SPRD_LSR_FE | SPRD_LSR_OE)) +if (handle_lsr_errors (port, &lsr, &flag)) +continue ; +if (uart_handle_sysrq_char (port, ch)) +continue ;My comment[1] on a previous version of this patch still stands.
uart_handle_sysrq_charis a NOP whenSUPPORT_SYSRQis not defined.
yes, there are two definitions in serial_core.h, and it returns 0 when SUPPORT_SYSRQ is not defined.
so, I think my code behavior does not hurt, right?
Quoted 9 lines
Quoted 6 lines
drivers/tty/serial/sprd_serial.c new file +6
-0+ +uart_insert_char (port, lsr,SPRD_LSR_OE , ch, flag); + } + +tty_flip_buffer_push (tty); +}[...]
Quoted 14 lines
drivers/tty/serial/sprd_serial.c line 539
Quoted 9 lines
drivers/tty/serial/sprd_serial.c new file +9
-0+static void sprd_console_write (struct console *co,const char *s, +unsigned int count) +{ +struct uart_port *port = &sprd_port[co->index]->port; +int locked =1 ; +unsigned long flags; + +if (port->sysrq) + locked =0 ;The sysrq field of struct
uart_portis only defined whenCONFIG_SERIAL_CORE_CONSOLEorSUPPORT_SYSRQare defined. You should #ifdef this part accordingly to avoid build breakage.
we have this part to been included under #ifdef CONFIG_SERIAL_SPRD_CONSOLE which is selected with SERIAL_CORE_CONSOLE.
Thank you very much!
Chunyan
Quoted 23 lines
drivers/tty/serial/sprd_serial.c line 552
Quoted 13 lines
drivers/tty/serial/sprd_serial.c new file +13
-0+else if (oops_in_progress) + locked =spin_trylock_irqsave (&port->lock, flags); +else +spin_lock_irqsave (&port->lock, flags); + +uart_console_write (port, s, count, sprd_console_putchar); + +/* wait for transmitter to become empty */ +wait_for_xmitr (port); + +if (locked) +spin_unlock_irqrestore (&port->lock, flags); +}[1]
http://article.gmane.org/gmane.linux.drivers.devicetree/106483baruch
--
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- [email protected] - tel: +972.2.679.5364, http://www.tkos.co.il -
Re: [PATCH v9 2/2] tty/serial: Add Spreadtrum sc9836-uart driver support
Hi Lyra Zhang,
Quoted 11 lines · Lyra Zhang
Quoted 6 lines · Baruch Siach
drivers/tty/serial/sprd_serial.c line 241
Quoted 2 lines · Chunyan Zhang
drivers/tty/serial/sprd_serial.c new file +2
-0+if (uart_handle_sysrq_char (port, ch)) +continue ;My comment[1] on a previous version of this patch still stands.
uart_handle_sysrq_charis a NOP whenSUPPORT_SYSRQis not defined.yes, there are two definitions in
serial_core.h, and it returns 0 whenSUPPORT_SYSRQis not defined.
so, I think my code behavior does not hurt, right?
Right. I just wanted to point out that you can easily define SUPPORT_SYSRQ as appropriate like many other serial drivers do to get sysrq support.
baruch
Signature · 3 lines
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- [email protected] - tel: +972.2.679.5364, http://www.tkos.co.il -Lyra Zhang
reviewerRe: [PATCH v9 2/2] tty/serial: Add Spreadtrum sc9836-uart driver support
Quoted 11 lines · Baruch Siach
Hi Lyra Zhang,
Quoted 8 lines · Lyra Zhang
Quoted 6 lines · Baruch Siach
drivers/tty/serial/sprd_serial.c line 241
Quoted 2 lines · Chunyan Zhang
drivers/tty/serial/sprd_serial.c new file +2
-0+if (uart_handle_sysrq_char (port, ch)) +continue ;My comment[1] on a previous version of this patch still stands.
uart_handle_sysrq_charis a NOP whenSUPPORT_SYSRQis not defined.
Quoted 7 lines
Quoted 3 lines
yes, there are two definitions in
serial_core.h, and it returns 0 whenSUPPORT_SYSRQis not defined.
so, I think my code behavior does not hurt, right?Right. I just wanted to point out that you can easily define
SUPPORT_SYSRQas appropriate like many other serial drivers do to get sysrq support.
Ok, I got it. I'll add SUPPORT_SYSRQ definition, and send v10 to Greg.
thanks,
Chunyan
Quoted 6 lines
baruch
--
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- [email protected] - tel: +972.2.679.5364, http://www.tkos.co.il -