Skip to contentSkip to conversation

ns16550-related patches

PATCH Superseded Antony Pavlov 1 participant 3 messages Jan 17, 2012

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover ns16550-related patches

This patch series consist of two ns16550-related patches.

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.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#1 lore raw

PATCH v3 1/2 ns16550: support for UART with broken FIFO

---
 drivers/serial/serial_ns16550.c |   18 ++++++++++++++++--
 include/ns16550.h               |    2 ++
 2 files changed, 18 insertions(+), 2 deletions(-)
drivers/serial/serial_ns16550.c +16 -2
index 1217a5f..4cef469 100644
@@ -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;
 }
 
include/ns16550.h +2 -0
index 5fd52fa..4a41b93 100644
@@ -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_ */
Signature · 7 lines
1.7.8.3


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH v3 2/2 ns16550: make ns16550_serial_init_port() shorter

In reply to Antony Pavlov
---
 drivers/serial/serial_ns16550.c |   14 ++------------
 1 files changed, 2 insertions(+), 12 deletions(-)
drivers/serial/serial_ns16550.c +2 -12
index 4cef469..a09ad07 100644
@@ -47,6 +47,7 @@
 #include <ns16550.h>
 
 /*********** Private Functions **********************************/
+static int ns16550_setbaudrate(struct console_device *cdev, int baud_rate);
 
 /**
  * @brief read register
@@ -139,8 +140,6 @@ 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);
@@ -150,16 +149,7 @@ static void ns16550_serial_init_port(struct console_device *cdev)
 #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);
Signature · 7 lines
1.7.8.3


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox