serial: sprd: Modification of UNISOC Platform UART Driver
v2 cover serial: sprd: Modification of UNISOC Platform UART Driver
In order to be compatible with UNISOC's new UART IP, the UART driver uses private data for adaptation. Patch1 adds UART timeout interrupt BIT17, and the old project uses BIT13. In order to be compatible with all projects, private data is used for adaptation. Patch2 adds a new compatible string.
Change in V2:
-Change commit message in PATCH 2/2.
-Add a new items supports sc9832 compatible string in PATCH 2/2.
Wenhua Lin (2):
dt-bindings: serial: Add a new compatible string for UMS9632
serial: sprd: Add support for sc9632
.../devicetree/bindings/serial/sprd-uart.yaml | 5 +++ drivers/tty/serial/sprd_serial.c | 41 ++++++++++++++++--- 2 files changed, 41 insertions(+), 5 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/2 dt-bindings: serial: Add a new compatible string for UMS9632
The UMS9632 uses the SC9632 serial device.
--- Documentation/devicetree/bindings/serial/sprd-uart.yaml | 5 +++++ 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/serial/sprd-uart.yaml +5 -0
@@ -23,6 +23,11 @@ properties: - sprd,ums9620-uart - const: sprd,sc9836-uart - const: sprd,sc9836-uart + - items: + - enum: + - sprd,ums9632-uart + - const: sprd,sc9632-uart + - const: sprd,sc9632-uart reg: maxItems: 1
Signature · 1 line
2.34.1
Re: [PATCH V2 1/2] dt-bindings: serial: Add a new compatible string for UMS9632
Quoted 1 line · Wenhua Lin
The UMS9632 uses the SC9632 serial device.
Why are you sending accepted patches?
Quoted 11 lines
Signed-off-by Wenhua Lin <[email protected]>--- Documentation/devicetree/bindings/serial/sprd-uart.yaml | 5 +++++ 1 file changed, 5 insertions(+)Documentation/devicetree/bindings/serial/sprd-uart.yaml +0
-0
Documentation/devicetree/bindings/serial/sprd-uart.yaml properties: · line 30
Quoted 8 lines
Documentation/devicetree/bindings/serial/sprd-uart.yaml +5
-0@@ -23,6 +23,11 @@ properties: - sprd,ums9620-uart - const: sprd,sc9836-uart - const: sprd,sc9836-uart + - items: + - enum: + - sprd,ums9632-uart + - const: sprd,sc9632-uart + - const: sprd,sc9632-uart
NAK, you are duplicating entries.
Best regards,
Krzysztof
PATCH v2 2/2 serial: sprd: Add support for sc9632
In reply to Wenhua LinDue to the platform's new project uart ip upgrade, the new project's timeout interrupt needs to use bit17 while other projects' timeout interrupt needs to use bit13, using private data to adapt and be compatible with all projects.
--- drivers/tty/serial/sprd_serial.c | 41 ++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 5 deletions(-)
drivers/tty/serial/sprd_serial.c +36 -5
@@ -53,10 +53,12 @@#define SPRD_IEN_TX_EMPTY BIT(1)#define SPRD_IEN_BREAK_DETECT BIT(7)#define SPRD_IEN_TIMEOUT BIT(13) +#define SPRD_IEN_DATA_TIMEOUT BIT(17)/* interrupt clear register */ #define SPRD_ICLR 0x0014#define SPRD_ICLR_TIMEOUT BIT(13) +#define SPRD_ICLR_DATA_TIMEOUT BIT(17)/* line control register */ #define SPRD_LCR 0x0018
@@ -102,6 +104,7 @@#define SPRD_IMSR_TX_FIFO_EMPTY BIT(1)#define SPRD_IMSR_BREAK_DETECT BIT(7)#define SPRD_IMSR_TIMEOUT BIT(13) +#define SPRD_IMSR_DATA_TIMEOUT BIT(17)#define SPRD_DEFAULT_SOURCE_CLK 26000000#define SPRD_RX_DMA_STEP 1
@@ -118,6 +121,12 @@ struct sprd_uart_dma {bool enable; }; +struct sprd_uart_data { +unsigned int timeout_ien; +unsigned int timeout_iclr; +unsigned int timeout_imsr; +}; +struct sprd_uart_port {struct uart_port port;char name[16 ];
@@ -126,6 +135,7 @@ struct sprd_uart_port {struct sprd_uart_dma rx_dma;dma_addr_t pos;unsigned char *rx_buf_tail; +const struct sprd_uart_data *pdata; };static struct sprd_uart_port *sprd_port[UART_NR_MAX ];
@@ -134,6 +144,18 @@ static int sprd_ports_num;static int sprd_start_dma_rx (struct uart_port *port);static int sprd_tx_dma_config (struct uart_port *port); +static const struct sprd_uart_data sc9836_data = { + .timeout_ien =SPRD_IEN_TIMEOUT , + .timeout_iclr =SPRD_ICLR_TIMEOUT , + .timeout_imsr =SPRD_IMSR_TIMEOUT , +}; + +static const struct sprd_uart_data sc9632_data = { + .timeout_ien =SPRD_IEN_DATA_TIMEOUT , + .timeout_iclr =SPRD_ICLR_DATA_TIMEOUT , + .timeout_imsr =SPRD_IMSR_DATA_TIMEOUT , +}; +static inline unsigned int serial_in (struct uart_port *port,unsigned int offset) {
@@ -637,6 +659,8 @@ static irqreturn_t sprd_handle_irq(int irq, void *dev_id) {struct uart_port *port = dev_id;unsigned int ims; +struct sprd_uart_port *sp = + container_of(port, struct sprd_uart_port, port);uart_port_lock (port);
@@ -647,14 +671,14 @@ static irqreturn_t sprd_handle_irq(int irq, void *dev_id)return IRQ_NONE ; } -if (ims &SPRD_IMSR_TIMEOUT ) -serial_out (port,SPRD_ICLR ,SPRD_ICLR_TIMEOUT ); +if (ims & sp->pdata->timeout_imsr) +serial_out (port,SPRD_ICLR , sp->pdata->timeout_iclr);if (ims &SPRD_IMSR_BREAK_DETECT )serial_out (port,SPRD_ICLR ,SPRD_IMSR_BREAK_DETECT );if (ims & (SPRD_IMSR_RX_FIFO_FULL |SPRD_IMSR_BREAK_DETECT | -SPRD_IMSR_TIMEOUT )) + sp->pdata->timeout_imsr))sprd_rx (port);if (ims &SPRD_IMSR_TX_FIFO_EMPTY )
@@ -729,7 +753,7 @@ static int sprd_startup(struct uart_port *port)/* enable interrupt */ uart_port_lock_irqsave (port, &flags); ien =serial_in (port,SPRD_IEN ); - ien |=SPRD_IEN_BREAK_DETECT |SPRD_IEN_TIMEOUT ; + ien |=SPRD_IEN_BREAK_DETECT | sp->pdata->timeout_ien;if (!sp->rx_dma.enable) ien |=SPRD_IEN_RX_FULL ;serial_out (port,SPRD_IEN , ien);
@@ -1184,6 +1208,12 @@ static int sprd_probe(struct platform_device *pdev) up->mapbase = res->start; + sport->pdata =of_device_get_match_data (&pdev->dev); +if (!sport->pdata) { +dev_err (&pdev->dev,"get match data failed!\n" ); +return -EINVAL ; + } + irq =platform_get_irq (pdev,0 );if (irq <0 )return irq;
@@ -1248,7 +1278,8 @@ static int sprd_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(sprd_pm_ops, sprd_suspend, sprd_resume);static const struct of_device_id serial_ids[] = { - {.compatible ="sprd,sc9836-uart" ,}, + {.compatible ="sprd,sc9836-uart" , .data = &sc9836_data}, + {.compatible ="sprd,sc9632-uart" , .data = &sc9632_data}, {} };MODULE_DEVICE_TABLE (of, serial_ids);
Signature · 1 line
2.34.1
Re: [PATCH V2 2/2] serial: sprd: Add support for sc9632
Quoted 7 lines · Wenhua Lin
Due to the platform's new project uart ip upgrade, the new project's timeout interrupt needs to use bit17 while other projects' timeout interrupt needs to use bit13, using private data to adapt and be compatible with all projects.
Signed-off-by Wenhua Lin <[email protected]>
People have already given you reviewed or acked tags[1], if you did not change the code, please keep them in the next version.
Re: [PATCH V2 2/2] serial: sprd: Add support for sc9632
Quoted 10 lines · Baolin Wang
Quoted 6 lines · Wenhua Lin
Due to the platform's new project uart ip upgrade, the new project's timeout interrupt needs to use bit17 while other projects' timeout interrupt needs to use bit13, using private data to adapt and be compatible with all projects.
Quoted 7 lines
Quoted 1 line
Signed-off-by Wenhua Lin <[email protected]>People have already given you reviewed or acked tags[1], if you did not change the code, please keep them in the next version.
Hi Baolin:
OK, the issue with tags[1] will be resolved through a new submission. Thank you for your reminder.
Thanks
Chunyan Zhang
reviewerRe: [PATCH V2 2/2] serial: sprd: Add support for sc9632
In reply to Wenhua LinQuoted 7 lines · Wenhua Lin
Due to the platform's new project uart ip upgrade, the new project's timeout interrupt needs to use bit17 while other projects' timeout interrupt needs to use bit13, using private data to adapt and be compatible with all projects.
It seems that this patch has got merged into the last release, why do you resend this?
Quoted 132 lines
Signed-off-by Wenhua Lin <[email protected]>--- drivers/tty/serial/sprd_serial.c | 41 ++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 5 deletions(-)drivers/tty/serial/sprd_serial.c +36
-6@@ -53,10 +53,12 @@#define SPRD_IEN_TX_EMPTY BIT(1)#define SPRD_IEN_BREAK_DETECT BIT(7)#define SPRD_IEN_TIMEOUT BIT(13) +#define SPRD_IEN_DATA_TIMEOUT BIT(17)/* interrupt clear register */ #define SPRD_ICLR 0x0014#define SPRD_ICLR_TIMEOUT BIT(13) +#define SPRD_ICLR_DATA_TIMEOUT BIT(17)/* line control register */ #define SPRD_LCR 0x0018@@ -102,6 +104,7 @@#define SPRD_IMSR_TX_FIFO_EMPTY BIT(1)#define SPRD_IMSR_BREAK_DETECT BIT(7)#define SPRD_IMSR_TIMEOUT BIT(13) +#define SPRD_IMSR_DATA_TIMEOUT BIT(17)#define SPRD_DEFAULT_SOURCE_CLK 26000000#define SPRD_RX_DMA_STEP 1@@ -118,6 +121,12 @@ struct sprd_uart_dma {bool enable; }; +struct sprd_uart_data { +unsigned int timeout_ien; +unsigned int timeout_iclr; +unsigned int timeout_imsr; +}; +struct sprd_uart_port {struct uart_port port;char name[16 ];@@ -126,6 +135,7 @@ struct sprd_uart_port {struct sprd_uart_dma rx_dma;dma_addr_t pos;unsigned char *rx_buf_tail; +const struct sprd_uart_data *pdata; };static struct sprd_uart_port *sprd_port[UART_NR_MAX ];@@ -134,6 +144,18 @@ static int sprd_ports_num;static int sprd_start_dma_rx (struct uart_port *port);static int sprd_tx_dma_config (struct uart_port *port); +static const struct sprd_uart_data sc9836_data = { + .timeout_ien =SPRD_IEN_TIMEOUT , + .timeout_iclr =SPRD_ICLR_TIMEOUT , + .timeout_imsr =SPRD_IMSR_TIMEOUT , +}; + +static const struct sprd_uart_data sc9632_data = { + .timeout_ien =SPRD_IEN_DATA_TIMEOUT , + .timeout_iclr =SPRD_ICLR_DATA_TIMEOUT , + .timeout_imsr =SPRD_IMSR_DATA_TIMEOUT , +}; +static inline unsigned int serial_in (struct uart_port *port,unsigned int offset) {@@ -637,6 +659,8 @@ static irqreturn_t sprd_handle_irq(int irq, void *dev_id) {struct uart_port *port = dev_id;unsigned int ims; +struct sprd_uart_port *sp = + container_of(port, struct sprd_uart_port, port);uart_port_lock (port);@@ -647,14 +671,14 @@ static irqreturn_t sprd_handle_irq(int irq, void *dev_id)return IRQ_NONE ; } -if (ims &SPRD_IMSR_TIMEOUT ) -serial_out (port,SPRD_ICLR ,SPRD_ICLR_TIMEOUT ); +if (ims & sp->pdata->timeout_imsr) +serial_out (port,SPRD_ICLR , sp->pdata->timeout_iclr);if (ims &SPRD_IMSR_BREAK_DETECT )serial_out (port,SPRD_ICLR ,SPRD_IMSR_BREAK_DETECT );if (ims & (SPRD_IMSR_RX_FIFO_FULL |SPRD_IMSR_BREAK_DETECT | -SPRD_IMSR_TIMEOUT )) + sp->pdata->timeout_imsr))sprd_rx (port);if (ims &SPRD_IMSR_TX_FIFO_EMPTY )@@ -729,7 +753,7 @@ static int sprd_startup(struct uart_port *port)/* enable interrupt */ uart_port_lock_irqsave (port, &flags); ien =serial_in (port,SPRD_IEN ); - ien |=SPRD_IEN_BREAK_DETECT |SPRD_IEN_TIMEOUT ; + ien |=SPRD_IEN_BREAK_DETECT | sp->pdata->timeout_ien;if (!sp->rx_dma.enable) ien |=SPRD_IEN_RX_FULL ;serial_out (port,SPRD_IEN , ien);@@ -1184,6 +1208,12 @@ static int sprd_probe(struct platform_device *pdev) up->mapbase = res->start; + sport->pdata =of_device_get_match_data (&pdev->dev); +if (!sport->pdata) { +dev_err (&pdev->dev,"get match data failed!\n" ); +return -EINVAL ; + } + irq =platform_get_irq (pdev,0 );if (irq <0 )return irq;@@ -1248,7 +1278,8 @@ static int sprd_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(sprd_pm_ops, sprd_suspend, sprd_resume);static const struct of_device_id serial_ids[] = { - {.compatible ="sprd,sc9836-uart" ,}, + {.compatible ="sprd,sc9836-uart" , .data = &sc9836_data}, + {.compatible ="sprd,sc9632-uart" , .data = &sc9632_data}, {} };MODULE_DEVICE_TABLE (of, serial_ids); --2.34.1
Re: [PATCH V2 2/2] serial: sprd: Add support for sc9632
Quoted 10 lines · Chunyan Zhang
Quoted 7 lines · Wenhua Lin
Due to the platform's new project uart ip upgrade, the new project's timeout interrupt needs to use bit17 while other projects' timeout interrupt needs to use bit13, using private data to adapt and be compatible with all projects.
Quoted 2 lines
It seems that this patch has got merged into the last release, why do you resend this?
Hi Chunyan:
I'm sorry, I didn't realize that this commit had already been merged. I resubmitted PATCH V2 to fix the issue with tags[1].
I made a mistake. Thank you for reminding me.
Thanks
Quoted 133 lines
Quoted 133 lines
Signed-off-by Wenhua Lin <[email protected]>--- drivers/tty/serial/sprd_serial.c | 41 ++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 5 deletions(-)drivers/tty/serial/sprd_serial.c +36
-6@@ -53,10 +53,12 @@#define SPRD_IEN_TX_EMPTY BIT(1)#define SPRD_IEN_BREAK_DETECT BIT(7)#define SPRD_IEN_TIMEOUT BIT(13) +#define SPRD_IEN_DATA_TIMEOUT BIT(17)/* interrupt clear register */ #define SPRD_ICLR 0x0014#define SPRD_ICLR_TIMEOUT BIT(13) +#define SPRD_ICLR_DATA_TIMEOUT BIT(17)/* line control register */ #define SPRD_LCR 0x0018@@ -102,6 +104,7 @@#define SPRD_IMSR_TX_FIFO_EMPTY BIT(1)#define SPRD_IMSR_BREAK_DETECT BIT(7)#define SPRD_IMSR_TIMEOUT BIT(13) +#define SPRD_IMSR_DATA_TIMEOUT BIT(17)#define SPRD_DEFAULT_SOURCE_CLK 26000000#define SPRD_RX_DMA_STEP 1@@ -118,6 +121,12 @@ struct sprd_uart_dma {bool enable; }; +struct sprd_uart_data { +unsigned int timeout_ien; +unsigned int timeout_iclr; +unsigned int timeout_imsr; +}; +struct sprd_uart_port {struct uart_port port;char name[16 ];@@ -126,6 +135,7 @@ struct sprd_uart_port {struct sprd_uart_dma rx_dma;dma_addr_t pos;unsigned char *rx_buf_tail; +const struct sprd_uart_data *pdata; };static struct sprd_uart_port *sprd_port[UART_NR_MAX ];@@ -134,6 +144,18 @@ static int sprd_ports_num;static int sprd_start_dma_rx (struct uart_port *port);static int sprd_tx_dma_config (struct uart_port *port); +static const struct sprd_uart_data sc9836_data = { + .timeout_ien =SPRD_IEN_TIMEOUT , + .timeout_iclr =SPRD_ICLR_TIMEOUT , + .timeout_imsr =SPRD_IMSR_TIMEOUT , +}; + +static const struct sprd_uart_data sc9632_data = { + .timeout_ien =SPRD_IEN_DATA_TIMEOUT , + .timeout_iclr =SPRD_ICLR_DATA_TIMEOUT , + .timeout_imsr =SPRD_IMSR_DATA_TIMEOUT , +}; +static inline unsigned int serial_in (struct uart_port *port,unsigned int offset) {@@ -637,6 +659,8 @@ static irqreturn_t sprd_handle_irq(int irq, void *dev_id) {struct uart_port *port = dev_id;unsigned int ims; +struct sprd_uart_port *sp = + container_of(port, struct sprd_uart_port, port);uart_port_lock (port);@@ -647,14 +671,14 @@ static irqreturn_t sprd_handle_irq(int irq, void *dev_id)return IRQ_NONE ; } -if (ims &SPRD_IMSR_TIMEOUT ) -serial_out (port,SPRD_ICLR ,SPRD_ICLR_TIMEOUT ); +if (ims & sp->pdata->timeout_imsr) +serial_out (port,SPRD_ICLR , sp->pdata->timeout_iclr);if (ims &SPRD_IMSR_BREAK_DETECT )serial_out (port,SPRD_ICLR ,SPRD_IMSR_BREAK_DETECT );if (ims & (SPRD_IMSR_RX_FIFO_FULL |SPRD_IMSR_BREAK_DETECT | -SPRD_IMSR_TIMEOUT )) + sp->pdata->timeout_imsr))sprd_rx (port);if (ims &SPRD_IMSR_TX_FIFO_EMPTY )@@ -729,7 +753,7 @@ static int sprd_startup(struct uart_port *port)/* enable interrupt */ uart_port_lock_irqsave (port, &flags); ien =serial_in (port,SPRD_IEN ); - ien |=SPRD_IEN_BREAK_DETECT |SPRD_IEN_TIMEOUT ; + ien |=SPRD_IEN_BREAK_DETECT | sp->pdata->timeout_ien;if (!sp->rx_dma.enable) ien |=SPRD_IEN_RX_FULL ;serial_out (port,SPRD_IEN , ien);@@ -1184,6 +1208,12 @@ static int sprd_probe(struct platform_device *pdev) up->mapbase = res->start; + sport->pdata =of_device_get_match_data (&pdev->dev); +if (!sport->pdata) { +dev_err (&pdev->dev,"get match data failed!\n" ); +return -EINVAL ; + } + irq =platform_get_irq (pdev,0 );if (irq <0 )return irq;@@ -1248,7 +1278,8 @@ static int sprd_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(sprd_pm_ops, sprd_suspend, sprd_resume);static const struct of_device_id serial_ids[] = { - {.compatible ="sprd,sc9836-uart" ,}, + {.compatible ="sprd,sc9836-uart" , .data = &sc9836_data}, + {.compatible ="sprd,sc9632-uart" , .data = &sc9632_data}, {} };MODULE_DEVICE_TABLE (of, serial_ids); --2.34.1
Quoted 7 lines · Wenhua Lin
In order to be compatible with UNISOC's new UART IP, the UART driver uses private data for adaptation. Patch1 adds UART timeout interrupt BIT17, and the old project uses BIT13. In order to be compatible with all projects, private data is used for adaptation. Patch2 adds a new compatible string.
Change in V2:
-Change commit message in PATCH 2/2.
You did NOT change any commit messages compared to V1[1]! Please write correct commit messages.
[1] https://lore.kernel.org/lkml/[email protected]/
Quoted 10 lines
-Add a new items supports sc9832 compatible string in PATCH 2/2.
Wenhua Lin (2):
dt-bindings: serial: Add a new compatible string for UMS9632
serial: sprd: Add support for sc9632.../devicetree/bindings/serial/sprd-uart.yaml | 5 +++ drivers/tty/serial/sprd_serial.c | 41 ++++++++++++++++--- 2 files changed, 41 insertions(+), 5 deletions(-)