Add ADDRB to termbits to indicate 9th bit addressing mode.
This change is necessary for supporting devices with RS485
multipoint addressing [*]. A later patch in the patch series
adds support for Synopsys Designware UART capable for 9th bit
addressing mode. In this mode, 9th bit is used to indicate an
address (byte) within the communication line. The 9th bit
addressing mode is selected using ADDRB introduced by an earlier
patch.

[*] Technically, RS485 is just an electronic spec and does not
itself specify the 9th bit addressing mode but 9th bit seems
at least "semi-standard" way to do addressing with RS485.

Cc: linux-...@vger.kernel.org
Cc: Richard Henderson <r...@twiddle.net>
Cc: Ivan Kokshaysky <i...@jurassic.park.msu.ru>
Cc: Matt Turner <matts...@gmail.com>
Cc: linux-al...@vger.kernel.org
Cc: Thomas Bogendoerfer <tsbog...@alpha.franken.de>
Cc: linux-m...@vger.kernel.org
Cc: "James E.J. Bottomley" <james.bottom...@hansenpartnership.com>
Cc: Helge Deller <del...@gmx.de>
Cc: linux-par...@vger.kernel.org
Cc: Michael Ellerman <m...@ellerman.id.au>
Cc: Benjamin Herrenschmidt <b...@kernel.crashing.org>
Cc: Paul Mackerras <pau...@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: "David S. Miller" <da...@davemloft.net>
Cc: sparcli...@vger.kernel.org
Cc: Arnd Bergmann <a...@arndb.de>
Cc: linux-a...@vger.kernel.org
Cc: linux-...@vger.kernel.org
Signed-off-by: Ilpo Järvinen <ilpo.jarvi...@linux.intel.com>
---
 arch/alpha/include/uapi/asm/termbits.h   | 1 +
 arch/mips/include/uapi/asm/termbits.h    | 1 +
 arch/parisc/include/uapi/asm/termbits.h  | 1 +
 arch/powerpc/include/uapi/asm/termbits.h | 1 +
 arch/sparc/include/uapi/asm/termbits.h   | 1 +
 drivers/tty/amiserial.c                  | 6 +++++-
 drivers/tty/moxa.c                       | 1 +
 drivers/tty/mxser.c                      | 1 +
 drivers/tty/serial/serial_core.c         | 2 ++
 drivers/tty/tty_ioctl.c                  | 2 ++
 drivers/usb/serial/usb-serial.c          | 5 +++--
 include/uapi/asm-generic/termbits.h      | 1 +
 12 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/arch/alpha/include/uapi/asm/termbits.h 
b/arch/alpha/include/uapi/asm/termbits.h
index 4575ba34a0ea..285169c794ec 100644
--- a/arch/alpha/include/uapi/asm/termbits.h
+++ b/arch/alpha/include/uapi/asm/termbits.h
@@ -180,6 +180,7 @@ struct ktermios {
 #define HUPCL  00040000
 
 #define CLOCAL 00100000
+#define ADDRB  010000000               /* address bit */
 #define CMSPAR   010000000000          /* mark or space (stick) parity */
 #define CRTSCTS          020000000000          /* flow control */
 
diff --git a/arch/mips/include/uapi/asm/termbits.h 
b/arch/mips/include/uapi/asm/termbits.h
index dfeffba729b7..e7ea31cfec78 100644
--- a/arch/mips/include/uapi/asm/termbits.h
+++ b/arch/mips/include/uapi/asm/termbits.h
@@ -181,6 +181,7 @@ struct ktermios {
 #define         B3000000 0010015
 #define         B3500000 0010016
 #define         B4000000 0010017
+#define ADDRB    0020000       /* address bit */
 #define CIBAUD   002003600000  /* input baud rate */
 #define CMSPAR   010000000000  /* mark or space (stick) parity */
 #define CRTSCTS          020000000000  /* flow control */
diff --git a/arch/parisc/include/uapi/asm/termbits.h 
b/arch/parisc/include/uapi/asm/termbits.h
index 40e920f8d683..629be061f5d5 100644
--- a/arch/parisc/include/uapi/asm/termbits.h
+++ b/arch/parisc/include/uapi/asm/termbits.h
@@ -158,6 +158,7 @@ struct ktermios {
 #define  B3000000 0010015
 #define  B3500000 0010016
 #define  B4000000 0010017
+#define ADDRB    0020000               /* address bit */
 #define CIBAUD    002003600000         /* input baud rate */
 #define CMSPAR    010000000000          /* mark or space (stick) parity */
 #define CRTSCTS   020000000000          /* flow control */
diff --git a/arch/powerpc/include/uapi/asm/termbits.h 
b/arch/powerpc/include/uapi/asm/termbits.h
index ed18bc61f63d..1b778ac562a4 100644
--- a/arch/powerpc/include/uapi/asm/termbits.h
+++ b/arch/powerpc/include/uapi/asm/termbits.h
@@ -171,6 +171,7 @@ struct ktermios {
 #define HUPCL  00040000
 
 #define CLOCAL 00100000
+#define ADDRB  00200000                /* address bit */
 #define CMSPAR   010000000000          /* mark or space (stick) parity */
 #define CRTSCTS          020000000000          /* flow control */
 
diff --git a/arch/sparc/include/uapi/asm/termbits.h 
b/arch/sparc/include/uapi/asm/termbits.h
index ce5ad5d0f105..4ad60c4acf65 100644
--- a/arch/sparc/include/uapi/asm/termbits.h
+++ b/arch/sparc/include/uapi/asm/termbits.h
@@ -200,6 +200,7 @@ struct ktermios {
 #define B3000000  0x00001011
 #define B3500000  0x00001012
 #define B4000000  0x00001013  */
+#define ADDRB    0x00002000  /* address bit */
 #define CIBAUD   0x100f0000  /* input baud rate (not used) */
 #define CMSPAR   0x40000000  /* mark or space (stick) parity */
 #define CRTSCTS          0x80000000  /* flow control */
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 533d02b38e02..3ca97007bd6e 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -1175,7 +1175,11 @@ static void rs_set_termios(struct tty_struct *tty, 
struct ktermios *old_termios)
 {
        struct serial_state *info = tty->driver_data;
        unsigned long flags;
-       unsigned int cflag = tty->termios.c_cflag;
+       unsigned int cflag;
+
+       tty->termios.c_cflag &= ~ADDRB;
+
+       cflag = tty->termios.c_cflag;
 
        change_speed(tty, info, old_termios);
 
diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
index f3c72ab1476c..07cd88152d58 100644
--- a/drivers/tty/moxa.c
+++ b/drivers/tty/moxa.c
@@ -2050,6 +2050,7 @@ static int MoxaPortSetTermio(struct moxa_port *port, 
struct ktermios *termio,
 
        ofsAddr = port->tableAddr;
 
+       termio->c_cflag &= ~ADDRB;
        mode = termio->c_cflag & CSIZE;
        if (mode == CS5)
                mode = MX_CS5;
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 836c9eca2946..220676363a07 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -577,6 +577,7 @@ static void mxser_change_speed(struct tty_struct *tty, 
struct ktermios *old_term
        struct mxser_port *info = tty->driver_data;
        unsigned cflag, cval;
 
+       tty->termios.c_cflag &= ~ADDRB;
        cflag = tty->termios.c_cflag;
 
        if (mxser_set_baud(tty, tty_get_baud_rate(tty))) {
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 846192a7b4bf..8ab88293c917 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1489,6 +1489,8 @@ static void uart_set_termios(struct tty_struct *tty,
                goto out;
        }
 
+       tty->termios.c_cflag &= ~ADDRB;
+
        uart_change_speed(tty, state, old_termios);
        /* reload cflag from termios; port driver may have overridden flags */
        cflag = tty->termios.c_cflag;
diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c
index 63181925ec1a..934037d78868 100644
--- a/drivers/tty/tty_ioctl.c
+++ b/drivers/tty/tty_ioctl.c
@@ -319,6 +319,8 @@ unsigned char tty_get_frame_size(unsigned int cflag)
                bits++;
        if (cflag & PARENB)
                bits++;
+       if (cflag & ADDRB)
+               bits++;
 
        return bits;
 }
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 24101bd7fcad..44b73aea80bb 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -525,9 +525,10 @@ static void serial_set_termios(struct tty_struct *tty, 
struct ktermios *old)
 
        dev_dbg(&port->dev, "%s\n", __func__);
 
-       if (port->serial->type->set_termios)
+       if (port->serial->type->set_termios) {
+               tty->termios.c_cflag &= ~ADDRB;
                port->serial->type->set_termios(tty, port, old);
-       else
+       } else
                tty_termios_copy_hw(&tty->termios, old);
 }
 
diff --git a/include/uapi/asm-generic/termbits.h 
b/include/uapi/asm-generic/termbits.h
index 2fbaf9ae89dd..5f5228329d45 100644
--- a/include/uapi/asm-generic/termbits.h
+++ b/include/uapi/asm-generic/termbits.h
@@ -157,6 +157,7 @@ struct ktermios {
 #define  B3000000 0010015
 #define  B3500000 0010016
 #define  B4000000 0010017
+#define ADDRB     0020000      /* address bit */
 #define CIBAUD   002003600000  /* input baud rate */
 #define CMSPAR   010000000000  /* mark or space (stick) parity */
 #define CRTSCTS          020000000000  /* flow control */
-- 
2.30.2

Reply via email to