* [PATCH v4 0/2] ns16550-related patches
@ 2012-01-18 6:31 Antony Pavlov
2012-01-18 6:31 ` [PATCH v4 1/4] ns16550: support for UART with broken FIFO Antony Pavlov
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Antony Pavlov @ 2012-01-18 6:31 UTC (permalink / raw)
To: barebox
This patch series consist of two ns16550-related patches.
[PATCH v4 1/4] ns16550: support for UART with broken FIFO
[PATCH v4 2/4] ns16550: make ns16550_serial_init_port() shorter
[PATCH v4 3/4] ns16550: write zero to ier only once
[PATCH v4 4/4] ns16550: fix ier selection
The 1st one adds the flag (NS16650_FLAG_DISABLE_FIFO) in internal
ns16550 data structure to recognise UART with broken FIFO
(or UART without FIFO at all) and the code to use this flag.
The flag can be set in board-related code.
The 2nd one use the fact that ns16550_serial_init_port() and
ns16550_setbaudrate() functions have many common code.
It change the most of ns16550_serial_init_port() code for
one ns16550_setbaudrate() call.
The 3rd one removes unnecessary interrupt disable on every
speed change operation.
The 4th one adds explicit IER register selection before accessing it.
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v4 1/4] ns16550: support for UART with broken FIFO
2012-01-18 6:31 [PATCH v4 0/2] ns16550-related patches Antony Pavlov
@ 2012-01-18 6:31 ` Antony Pavlov
2012-01-18 6:31 ` [PATCH v4 2/4] ns16550: make ns16550_serial_init_port() shorter Antony Pavlov
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Antony Pavlov @ 2012-01-18 6:31 UTC (permalink / raw)
To: barebox
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
drivers/serial/serial_ns16550.c | 18 ++++++++++++++++--
include/ns16550.h | 2 ++
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index 1217a5f..4cef469 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -139,6 +139,8 @@ static unsigned int ns16550_calc_divisor(struct console_device *cdev,
static void ns16550_serial_init_port(struct console_device *cdev)
{
unsigned int baud_divisor;
+ struct NS16550_plat *plat = (struct NS16550_plat *)
+ cdev->dev->platform_data;
/* Setup the serial port with the defaults first */
baud_divisor = ns16550_calc_divisor(cdev, CONFIG_BAUDRATE);
@@ -153,7 +155,12 @@ static void ns16550_serial_init_port(struct console_device *cdev)
ns16550_write(cdev, (baud_divisor >> 8) & 0xff, dlm);
ns16550_write(cdev, LCRVAL, lcr);
ns16550_write(cdev, MCRVAL, mcr);
- ns16550_write(cdev, FCRVAL, fcr);
+
+ if (plat->flags & NS16650_FLAG_DISABLE_FIFO)
+ ns16550_write(cdev, FCRVAL & ~FCR_FIFO_EN, fcr);
+ else
+ ns16550_write(cdev, FCRVAL, fcr);
+
#ifdef CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS
ns16550_write(cdev, 0x00, mdr1);
#endif
@@ -211,6 +218,8 @@ static int ns16550_tstc(struct console_device *cdev)
static int ns16550_setbaudrate(struct console_device *cdev, int baud_rate)
{
unsigned int baud_divisor = ns16550_calc_divisor(cdev, baud_rate);
+ struct NS16550_plat *plat = (struct NS16550_plat *)
+ cdev->dev->platform_data;
ns16550_write(cdev, 0x00, ier);
ns16550_write(cdev, LCR_BKSE, lcr);
@@ -218,7 +227,12 @@ static int ns16550_setbaudrate(struct console_device *cdev, int baud_rate)
ns16550_write(cdev, (baud_divisor >> 8) & 0xff, dlm);
ns16550_write(cdev, LCRVAL, lcr);
ns16550_write(cdev, MCRVAL, mcr);
- ns16550_write(cdev, FCRVAL, fcr);
+
+ if (plat->flags & NS16650_FLAG_DISABLE_FIFO)
+ ns16550_write(cdev, FCRVAL & ~FCR_FIFO_EN, fcr);
+ else
+ ns16550_write(cdev, FCRVAL, fcr);
+
return 0;
}
diff --git a/include/ns16550.h b/include/ns16550.h
index 5fd52fa..4a41b93 100644
--- a/include/ns16550.h
+++ b/include/ns16550.h
@@ -52,6 +52,8 @@ struct NS16550_plat {
unsigned char reg_offset);
int shift;
+ unsigned int flags;
+#define NS16650_FLAG_DISABLE_FIFO 1
};
#endif /* __NS16650_PLATFORM_H_ */
--
1.7.8.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v4 2/4] ns16550: make ns16550_serial_init_port() shorter
2012-01-18 6:31 [PATCH v4 0/2] ns16550-related patches Antony Pavlov
2012-01-18 6:31 ` [PATCH v4 1/4] ns16550: support for UART with broken FIFO Antony Pavlov
@ 2012-01-18 6:31 ` Antony Pavlov
2012-01-18 6:31 ` [PATCH v4 3/4] ns16550: write zero to ier only once Antony Pavlov
2012-01-18 6:31 ` [PATCH v4 4/4] ns16550: fix ier selection Antony Pavlov
3 siblings, 0 replies; 5+ messages in thread
From: Antony Pavlov @ 2012-01-18 6:31 UTC (permalink / raw)
To: barebox
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
drivers/serial/serial_ns16550.c | 20 +++-----------------
1 files changed, 3 insertions(+), 17 deletions(-)
diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index 4cef469..3382acd 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -47,6 +47,7 @@
#include <ns16550.h>
/*********** Private Functions **********************************/
+static int ns16550_setbaudrate(struct console_device *cdev, int baud_rate);
/**
* @brief read register
@@ -120,7 +121,7 @@ static void ns16550_write(struct console_device *cdev, uint32_t val,
*
* @return divisor to be set
*/
-static unsigned int ns16550_calc_divisor(struct console_device *cdev,
+static inline unsigned int ns16550_calc_divisor(struct console_device *cdev,
unsigned int baudrate)
{
struct NS16550_plat *plat = (struct NS16550_plat *)
@@ -138,28 +139,13 @@ static unsigned int ns16550_calc_divisor(struct console_device *cdev,
*/
static void ns16550_serial_init_port(struct console_device *cdev)
{
- unsigned int baud_divisor;
- struct NS16550_plat *plat = (struct NS16550_plat *)
- cdev->dev->platform_data;
-
- /* Setup the serial port with the defaults first */
- baud_divisor = ns16550_calc_divisor(cdev, CONFIG_BAUDRATE);
-
/* initializing the device for the first time */
ns16550_write(cdev, 0x00, ier);
#ifdef CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS
ns16550_write(cdev, 0x07, mdr1); /* Disable */
#endif
- ns16550_write(cdev, LCR_BKSE | LCRVAL, lcr);
- ns16550_write(cdev, baud_divisor & 0xFF, dll);
- ns16550_write(cdev, (baud_divisor >> 8) & 0xff, dlm);
- ns16550_write(cdev, LCRVAL, lcr);
- ns16550_write(cdev, MCRVAL, mcr);
- if (plat->flags & NS16650_FLAG_DISABLE_FIFO)
- ns16550_write(cdev, FCRVAL & ~FCR_FIFO_EN, fcr);
- else
- ns16550_write(cdev, FCRVAL, fcr);
+ ns16550_setbaudrate(cdev, CONFIG_BAUDRATE);
#ifdef CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS
ns16550_write(cdev, 0x00, mdr1);
--
1.7.8.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v4 3/4] ns16550: write zero to ier only once
2012-01-18 6:31 [PATCH v4 0/2] ns16550-related patches Antony Pavlov
2012-01-18 6:31 ` [PATCH v4 1/4] ns16550: support for UART with broken FIFO Antony Pavlov
2012-01-18 6:31 ` [PATCH v4 2/4] ns16550: make ns16550_serial_init_port() shorter Antony Pavlov
@ 2012-01-18 6:31 ` Antony Pavlov
2012-01-18 6:31 ` [PATCH v4 4/4] ns16550: fix ier selection Antony Pavlov
3 siblings, 0 replies; 5+ messages in thread
From: Antony Pavlov @ 2012-01-18 6:31 UTC (permalink / raw)
To: barebox
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
drivers/serial/serial_ns16550.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index 3382acd..802331d 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -207,7 +207,6 @@ static int ns16550_setbaudrate(struct console_device *cdev, int baud_rate)
struct NS16550_plat *plat = (struct NS16550_plat *)
cdev->dev->platform_data;
- ns16550_write(cdev, 0x00, ier);
ns16550_write(cdev, LCR_BKSE, lcr);
ns16550_write(cdev, baud_divisor & 0xff, dll);
ns16550_write(cdev, (baud_divisor >> 8) & 0xff, dlm);
--
1.7.8.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v4 4/4] ns16550: fix ier selection
2012-01-18 6:31 [PATCH v4 0/2] ns16550-related patches Antony Pavlov
` (2 preceding siblings ...)
2012-01-18 6:31 ` [PATCH v4 3/4] ns16550: write zero to ier only once Antony Pavlov
@ 2012-01-18 6:31 ` Antony Pavlov
3 siblings, 0 replies; 5+ messages in thread
From: Antony Pavlov @ 2012-01-18 6:31 UTC (permalink / raw)
To: barebox
The document "PC16550D Universal Asynchronous
Receiver Transmitter with FIFOs" (vers. June 1995,
http://www.national.com/ds/PC/PC16550D.pdf) states
that IER (Interrupt Enable Register) is accessible
if the bit DLAB = 0 (DLAB is bit 7 in LCR; in barebox
DLAB known as LCR_BKSE).
So before IER access we need set DLAB to 0.
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
drivers/serial/serial_ns16550.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index 802331d..88ba836 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -140,7 +140,9 @@ static inline unsigned int ns16550_calc_divisor(struct console_device *cdev,
static void ns16550_serial_init_port(struct console_device *cdev)
{
/* initializing the device for the first time */
+ ns16550_write(cdev, 0x00, lcr); /* select ier reg */
ns16550_write(cdev, 0x00, ier);
+
#ifdef CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS
ns16550_write(cdev, 0x07, mdr1); /* Disable */
#endif
--
1.7.8.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-01-18 6:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-18 6:31 [PATCH v4 0/2] ns16550-related patches Antony Pavlov
2012-01-18 6:31 ` [PATCH v4 1/4] ns16550: support for UART with broken FIFO Antony Pavlov
2012-01-18 6:31 ` [PATCH v4 2/4] ns16550: make ns16550_serial_init_port() shorter Antony Pavlov
2012-01-18 6:31 ` [PATCH v4 3/4] ns16550: write zero to ier only once Antony Pavlov
2012-01-18 6:31 ` [PATCH v4 4/4] ns16550: fix ier selection Antony Pavlov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox