Skip to contentSkip to conversation

serial: sh-sci: byte allocated register support

PATCH Superseded Yoshinori Sato 2 participants 5 messages Jul 21, 2018 – Aug 9, 2018

Subsystems (2)
lore
Share & tools
lore

Yoshinori Sato

author maintainer
#0 lore raw

PATCH v2 1/1 serial: sh-sci: byte allocated register support

H8/300 SCI registers allocated byte address. It must support to the case where shift count is 0.

Changes v2.
more simply code.

---
 drivers/tty/serial/sh-sci.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/tty/serial/sh-sci.c +6 -4
index c181eb37f985..3c7326e11d37 100644
@@ -2863,10 +2863,12 @@ static int sci_init_single(struct platform_device *dev,
 	port->fifosize		= sci_port->params->fifosize;
 
 	if (port->type = PORT_SCI) {
-		if (sci_port->reg_size >= 0x20)
-			port->regshift = 2;
-		else
-			port->regshift = 1;
+		/*
+		 * reg_size < 0x10: BYTE aligned (scale factor=1).
+		 * reg_size >= 0x10 and < 0x20: WORD aligned (scale factor=2).
+		 * reg_size >= 0x20: DWORD aligned (scale factor=4).
+		 */
+		port->regshift = sci_port->reg_size >> 4;
 	}
 
 	/*
Signature · 1 line
2.11.0
author maintainer
#1 lore raw

PATCH v2 1/1 serial: sh-sci: byte allocated register support

H8/300 SCI registers allocated byte address. It must support to the case where shift count is 0.

Changes v2.
more simply code.

---
 drivers/tty/serial/sh-sci.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/tty/serial/sh-sci.c +6 -4
index c181eb37f985..3c7326e11d37 100644
@@ -2863,10 +2863,12 @@ static int sci_init_single(struct platform_device *dev,
 	port->fifosize		= sci_port->params->fifosize;
 
 	if (port->type = PORT_SCI) {
-		if (sci_port->reg_size >= 0x20)
-			port->regshift = 2;
-		else
-			port->regshift = 1;
+		/*
+		 * reg_size < 0x10: BYTE aligned (scale factor=1).
+		 * reg_size >= 0x10 and < 0x20: WORD aligned (scale factor=2).
+		 * reg_size >= 0x20: DWORD aligned (scale factor=4).
+		 */
+		port->regshift = sci_port->reg_size >> 4;
 	}
 
 	/*
Signature · 1 line
2.11.0
Reviewed-by on v2 1/1
#2 lore raw
In reply to Yoshinori Sato

CC gregkh, linux-serial

Quoted 8 lines · Yoshinori Sato

H8/300 SCI registers allocated byte address. It must support to the case where shift count is 0.

Changes v2.
more simply code.

Quoted 9 lines
drivers/tty/serial/sh-sci.c +0 -3
@@ -2863,10 +2863,12 @@ static int sci_init_single(struct platform_device *dev,
        port->fifosize          = sci_port->params->fifosize;
 
        if (port->type = PORT_SCI) {
-               if (sci_port->reg_size >= 0x20)
-                       port->regshift = 2;
-               else

drivers/tty/serial/sh-sci.c static int sci_init_single(struct platform_device *dev, · line 2874

Quoted 10 lines
drivers/tty/serial/sh-sci.c +6 -1
-                       port->regshift = 1;
+               /*
+                * reg_size < 0x10: BYTE aligned (scale factor=1).
+                * reg_size >= 0x10 and < 0x20: WORD aligned (scale factor=2).
+                * reg_size >= 0x20: DWORD aligned (scale factor=4).
+                */
+               port->regshift = sci_port->reg_size >> 4;
        }
 
        /*

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#3 lore raw
In reply to Yoshinori Sato

Hi Sato-san,

Quoted 33 lines · Geert Uytterhoeven

CC gregkh, linux-serial

Quoted 8 lines · Yoshinori Sato

H8/300 SCI registers allocated byte address. It must support to the case where shift count is 0.

Changes v2.
more simply code.

Quoted 18 lines
drivers/tty/serial/sh-sci.c +6 -4
@@ -2863,10 +2863,12 @@ static int sci_init_single(struct platform_device *dev,
        port->fifosize          = sci_port->params->fifosize;
 
        if (port->type = PORT_SCI) {
-               if (sci_port->reg_size >= 0x20)
-                       port->regshift = 2;
-               else
-                       port->regshift = 1;
+               /*
+                * reg_size < 0x10: BYTE aligned (scale factor=1).
+                * reg_size >= 0x10 and < 0x20: WORD aligned (scale factor=2).
+                * reg_size >= 0x20: DWORD aligned (scale factor=4).
+                */
+               port->regshift = sci_port->reg_size >> 4;
        }
 
Quoted 1 line

drivers/tty/serial/sh-sci.c static int sci_init_single(struct platform_device *dev, · line 2874

Quoted 1 line
drivers/tty/serial/sh-sci.c +0 -0
        /*

Considering the regshift issues introduced by RZ/A2 SCIF support, I think it's better to not rely on the reg_size value, and change the check to

       if (!dev->dev.of_node && port->type = PORT_SCI)

If/when SuperH receives DT support, SCI ports with regshift 1 or 2 instantiated from DT can be supported using "reg-shift = <1>" or "reg-shift = <2>" in DT.

Reference: https://www.spinics.net/lists/linux-serial/msg31573.html

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author maintainer
#4 lore raw
In reply to Yoshinori Sato
Quoted 45 lines · Geert Uytterhoeven

Hi Sato-san,

Quoted 33 lines · Geert Uytterhoeven

CC gregkh, linux-serial

Quoted 8 lines · Yoshinori Sato

H8/300 SCI registers allocated byte address. It must support to the case where shift count is 0.

Changes v2.
more simply code.

Quoted 18 lines
drivers/tty/serial/sh-sci.c +6 -4
@@ -2863,10 +2863,12 @@ static int sci_init_single(struct platform_device *dev,
        port->fifosize          = sci_port->params->fifosize;
 
        if (port->type = PORT_SCI) {
-               if (sci_port->reg_size >= 0x20)
-                       port->regshift = 2;
-               else
-                       port->regshift = 1;
+               /*
+                * reg_size < 0x10: BYTE aligned (scale factor=1).
+                * reg_size >= 0x10 and < 0x20: WORD aligned (scale factor=2).
+                * reg_size >= 0x20: DWORD aligned (scale factor=4).
+                */
+               port->regshift = sci_port->reg_size >> 4;
        }
 
Quoted 1 line

drivers/tty/serial/sh-sci.c static int sci_init_single(struct platform_device *dev, · line 2874

Quoted 1 line
drivers/tty/serial/sh-sci.c +0 -0
        /*

Considering the regshift issues introduced by RZ/A2 SCIF support, I think it's better to not rely on the reg_size value, and change the check to

       if (!dev->dev.of_node && port->type = PORT_SCI)
Quoted 9 lines

If/when SuperH receives DT support, SCI ports with regshift 1 or 2 instantiated from DT can be supported using "reg-shift = <1>" or "reg-shift = <2>" in DT.

Reference: https://www.spinics.net/lists/linux-serial/msg31573.html

Gr{oetje,eeting}s,

Geert

OK.
Thanks.

Quoted 6 lines

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

Signature · 1 line
Yosinori Sato