[PATCH] serial: mxs-auart: support CMSPAR termios cflag

2016-12-11 Thread Wolfgang Ocker
If CMSPAR is set in the c_cflag of termios, "stick" parity is enabled.

Tested on an i.MX28 system

Signed-off-by: Wolfgang Ocker <w...@reccoware.de>
---
v2: require PARENB to be also set in termios' c_cflag for CMSPAR
---
 drivers/tty/serial/mxs-auart.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index 770454e0dfa3..fd819ea26762 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -95,6 +95,7 @@
 #define AUART_LINECTRL_BAUD_DIVFRAC_SHIFT  8
 #define AUART_LINECTRL_BAUD_DIVFRAC_MASK   0x3f00
 #define AUART_LINECTRL_BAUD_DIVFRAC(v) (((v) & 0x3f) << 8)
+#define AUART_LINECTRL_SPS (1 << 7)
 #define AUART_LINECTRL_WLEN_MASK   0x0060
 #define AUART_LINECTRL_WLEN(v) (((v) & 0x3) << 5)
 #define AUART_LINECTRL_FEN (1 << 4)
@@ -1014,6 +1015,8 @@ static void mxs_auart_settermios(struct uart_port *u,
ctrl |= AUART_LINECTRL_PEN;
if ((cflag & PARODD) == 0)
ctrl |= AUART_LINECTRL_EPS;
+   if (cflag & CMSPAR)
+   ctrl |= AUART_LINECTRL_SPS;
}
 
u->read_status_mask = 0;
-- 
2.10.0



[PATCH] serial: mxs-auart: support CMSPAR termios cflag

2016-12-11 Thread Wolfgang Ocker
If CMSPAR is set in the c_cflag of termios, "stick" parity is enabled.

Tested on an i.MX28 system

Signed-off-by: Wolfgang Ocker 
---
v2: require PARENB to be also set in termios' c_cflag for CMSPAR
---
 drivers/tty/serial/mxs-auart.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index 770454e0dfa3..fd819ea26762 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -95,6 +95,7 @@
 #define AUART_LINECTRL_BAUD_DIVFRAC_SHIFT  8
 #define AUART_LINECTRL_BAUD_DIVFRAC_MASK   0x3f00
 #define AUART_LINECTRL_BAUD_DIVFRAC(v) (((v) & 0x3f) << 8)
+#define AUART_LINECTRL_SPS (1 << 7)
 #define AUART_LINECTRL_WLEN_MASK   0x0060
 #define AUART_LINECTRL_WLEN(v) (((v) & 0x3) << 5)
 #define AUART_LINECTRL_FEN (1 << 4)
@@ -1014,6 +1015,8 @@ static void mxs_auart_settermios(struct uart_port *u,
ctrl |= AUART_LINECTRL_PEN;
if ((cflag & PARODD) == 0)
ctrl |= AUART_LINECTRL_EPS;
+   if (cflag & CMSPAR)
+   ctrl |= AUART_LINECTRL_SPS;
}
 
u->read_status_mask = 0;
-- 
2.10.0



Re: [PATCH] serial: mxs-auart: support CMSPAR termios cflag

2016-12-06 Thread Wolfgang Ocker
On Tue, 2016-12-06 at 14:36 +0100, Stefan Wahren wrote:
> Hi Wolfgang,
> 
> > --- a/drivers/tty/serial/mxs-auart.c
> > +++ b/drivers/tty/serial/mxs-auart.c
> > @@ -95,6 +95,7 @@
> >  #define AUART_LINECTRL_BAUD_DIVFRAC_SHIFT  8
> >  #define AUART_LINECTRL_BAUD_DIVFRAC_MASK   0x3f00
> >  #define AUART_LINECTRL_BAUD_DIVFRAC(v) (((v) & 0x3f) << 8)
> > +#define AUART_LINECTRL_SPS (1 << 7)
> >  #define AUART_LINECTRL_WLEN_MASK   0x0060
> >  #define AUART_LINECTRL_WLEN(v) (((v) & 0x3) << 5)
> >  #define AUART_LINECTRL_FEN (1 << 4)
> > @@ -1010,10 +1011,12 @@ static void mxs_auart_settermios(struct uart_port
> > *u,
> > ctrl |= AUART_LINECTRL_WLEN(bm);
> > 
> > /* parity */
> > -   if (cflag & PARENB) {
> > +   if (cflag & (PARENB|CMSPAR)) {
> 
> does it make sense to enable stick parity in case parity is disabled?
> 
> The i.MX28 reference manual doesn't describe this case explicit.

Thanks Stefan for the hint. I think it's okay on the hardware side since the
PEN bit is always set and therefore it can not happen that SPS is set but not
PEN.

But on the termios side it makes sense to require PARENB to be set in c_cflag
if CMSPAR is requested.

So I will provide an updated patch soon.

Wolfgang


Re: [PATCH] serial: mxs-auart: support CMSPAR termios cflag

2016-12-06 Thread Wolfgang Ocker
On Tue, 2016-12-06 at 14:36 +0100, Stefan Wahren wrote:
> Hi Wolfgang,
> 
> > --- a/drivers/tty/serial/mxs-auart.c
> > +++ b/drivers/tty/serial/mxs-auart.c
> > @@ -95,6 +95,7 @@
> >  #define AUART_LINECTRL_BAUD_DIVFRAC_SHIFT  8
> >  #define AUART_LINECTRL_BAUD_DIVFRAC_MASK   0x3f00
> >  #define AUART_LINECTRL_BAUD_DIVFRAC(v) (((v) & 0x3f) << 8)
> > +#define AUART_LINECTRL_SPS (1 << 7)
> >  #define AUART_LINECTRL_WLEN_MASK   0x0060
> >  #define AUART_LINECTRL_WLEN(v) (((v) & 0x3) << 5)
> >  #define AUART_LINECTRL_FEN (1 << 4)
> > @@ -1010,10 +1011,12 @@ static void mxs_auart_settermios(struct uart_port
> > *u,
> > ctrl |= AUART_LINECTRL_WLEN(bm);
> > 
> > /* parity */
> > -   if (cflag & PARENB) {
> > +   if (cflag & (PARENB|CMSPAR)) {
> 
> does it make sense to enable stick parity in case parity is disabled?
> 
> The i.MX28 reference manual doesn't describe this case explicit.

Thanks Stefan for the hint. I think it's okay on the hardware side since the
PEN bit is always set and therefore it can not happen that SPS is set but not
PEN.

But on the termios side it makes sense to require PARENB to be set in c_cflag
if CMSPAR is requested.

So I will provide an updated patch soon.

Wolfgang


[PATCH] serial: mxs-auart: support CMSPAR termios cflag

2016-11-30 Thread Wolfgang Ocker
If CMSPAR is set in the c_cflag of termios, "stick" parity is enabled.

Tested on an i.MX28 system

Signed-off-by: Wolfgang Ocker <w...@reccoware.de>
---
 drivers/tty/serial/mxs-auart.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index 770454e0dfa3..9d344f734d44 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -95,6 +95,7 @@
 #define AUART_LINECTRL_BAUD_DIVFRAC_SHIFT  8
 #define AUART_LINECTRL_BAUD_DIVFRAC_MASK   0x3f00
 #define AUART_LINECTRL_BAUD_DIVFRAC(v) (((v) & 0x3f) << 8)
+#define AUART_LINECTRL_SPS (1 << 7)
 #define AUART_LINECTRL_WLEN_MASK   0x0060
 #define AUART_LINECTRL_WLEN(v) (((v) & 0x3) << 5)
 #define AUART_LINECTRL_FEN (1 << 4)
@@ -1010,10 +1011,12 @@ static void mxs_auart_settermios(struct uart_port *u,
ctrl |= AUART_LINECTRL_WLEN(bm);
 
/* parity */
-   if (cflag & PARENB) {
+   if (cflag & (PARENB|CMSPAR)) {
ctrl |= AUART_LINECTRL_PEN;
if ((cflag & PARODD) == 0)
ctrl |= AUART_LINECTRL_EPS;
+   if (cflag & CMSPAR)
+   ctrl |= AUART_LINECTRL_SPS;
}
 
u->read_status_mask = 0;
-- 
2.10.0



[PATCH] serial: mxs-auart: support CMSPAR termios cflag

2016-11-30 Thread Wolfgang Ocker
If CMSPAR is set in the c_cflag of termios, "stick" parity is enabled.

Tested on an i.MX28 system

Signed-off-by: Wolfgang Ocker 
---
 drivers/tty/serial/mxs-auart.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index 770454e0dfa3..9d344f734d44 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -95,6 +95,7 @@
 #define AUART_LINECTRL_BAUD_DIVFRAC_SHIFT  8
 #define AUART_LINECTRL_BAUD_DIVFRAC_MASK   0x3f00
 #define AUART_LINECTRL_BAUD_DIVFRAC(v) (((v) & 0x3f) << 8)
+#define AUART_LINECTRL_SPS (1 << 7)
 #define AUART_LINECTRL_WLEN_MASK   0x0060
 #define AUART_LINECTRL_WLEN(v) (((v) & 0x3) << 5)
 #define AUART_LINECTRL_FEN (1 << 4)
@@ -1010,10 +1011,12 @@ static void mxs_auart_settermios(struct uart_port *u,
ctrl |= AUART_LINECTRL_WLEN(bm);
 
/* parity */
-   if (cflag & PARENB) {
+   if (cflag & (PARENB|CMSPAR)) {
ctrl |= AUART_LINECTRL_PEN;
if ((cflag & PARODD) == 0)
ctrl |= AUART_LINECTRL_EPS;
+   if (cflag & CMSPAR)
+   ctrl |= AUART_LINECTRL_SPS;
}
 
u->read_status_mask = 0;
-- 
2.10.0



[PATCH v2] mxs-auart: count FIFO overrun errors

2016-11-16 Thread Wolfgang Ocker
The mxs-auart driver does not count FIFO overrun errors. These errors never
appear in /proc/tty/driver/ttyAPP. This is because the OERR status bit is
masked by read_status_mask in the rx interrupt function, but the
AUART_STAT_OERR bit is never set in read_status_mask. The patch enables the
counting of overrun errors.

Signed-off-by: Wolfgang Ocker <w...@reccoware.de>
---
 v2: sent with git-send-email. Evolution changes a leading space to 0xa0 :(

 drivers/tty/serial/mxs-auart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index 770454e0dfa3..8c1c9112b3fd 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -1016,7 +1016,7 @@ static void mxs_auart_settermios(struct uart_port *u,
ctrl |= AUART_LINECTRL_EPS;
}
 
-   u->read_status_mask = 0;
+   u->read_status_mask = AUART_STAT_OERR;
 
if (termios->c_iflag & INPCK)
u->read_status_mask |= AUART_STAT_PERR;
-- 
2.10.0



[PATCH v2] mxs-auart: count FIFO overrun errors

2016-11-16 Thread Wolfgang Ocker
The mxs-auart driver does not count FIFO overrun errors. These errors never
appear in /proc/tty/driver/ttyAPP. This is because the OERR status bit is
masked by read_status_mask in the rx interrupt function, but the
AUART_STAT_OERR bit is never set in read_status_mask. The patch enables the
counting of overrun errors.

Signed-off-by: Wolfgang Ocker 
---
 v2: sent with git-send-email. Evolution changes a leading space to 0xa0 :(

 drivers/tty/serial/mxs-auart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index 770454e0dfa3..8c1c9112b3fd 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -1016,7 +1016,7 @@ static void mxs_auart_settermios(struct uart_port *u,
ctrl |= AUART_LINECTRL_EPS;
}
 
-   u->read_status_mask = 0;
+   u->read_status_mask = AUART_STAT_OERR;
 
if (termios->c_iflag & INPCK)
u->read_status_mask |= AUART_STAT_PERR;
-- 
2.10.0



[PATCH] mxs-auart: count FIFO overrun errors

2016-11-15 Thread Wolfgang Ocker
The mxs-auart driver does not count FIFO overrun errors. These errors never
appear in /proc/tty/driver/ttyAPP. This is because the OERR status bit is
masked by read_status_mask in the rx interrupt function, but the
AUART_STAT_OERR bit is never set in read_status_mask. The patch enables the
counting of overrun errors.

Signed-off-by: Wolfgang Ocker <w...@reccoware.de>
---
 drivers/tty/serial/mxs-auart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index 770454e0dfa3..8c1c9112b3fd 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -1016,7 +1016,7 @@ static void mxs_auart_settermios(struct uart_port *u,
    ctrl |= AUART_LINECTRL_EPS;
    }
 
-   u->read_status_mask = 0;
+   u->read_status_mask = AUART_STAT_OERR;
 
    if (termios->c_iflag & INPCK)
    u->read_status_mask |= AUART_STAT_PERR;
-- 
2.10.0



[PATCH] mxs-auart: count FIFO overrun errors

2016-11-15 Thread Wolfgang Ocker
The mxs-auart driver does not count FIFO overrun errors. These errors never
appear in /proc/tty/driver/ttyAPP. This is because the OERR status bit is
masked by read_status_mask in the rx interrupt function, but the
AUART_STAT_OERR bit is never set in read_status_mask. The patch enables the
counting of overrun errors.

Signed-off-by: Wolfgang Ocker 
---
 drivers/tty/serial/mxs-auart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index 770454e0dfa3..8c1c9112b3fd 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -1016,7 +1016,7 @@ static void mxs_auart_settermios(struct uart_port *u,
    ctrl |= AUART_LINECTRL_EPS;
    }
 
-   u->read_status_mask = 0;
+   u->read_status_mask = AUART_STAT_OERR;
 
    if (termios->c_iflag & INPCK)
    u->read_status_mask |= AUART_STAT_PERR;
-- 
2.10.0