ns16550: support for UART with broken FIFO
RFC 1/1 ns16550: support for UART with broken FIFO
--- drivers/serial/serial_ns16550.c | 19 +++++++++++++++++-- include/ns16550.h | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-)
drivers/serial/serial_ns16550.c +17 -2
@@ -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,13 @@ 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 +219,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 +228,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
@@ -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
Quoted 20 lines · Antony Pavlov
Signed-off-by Antony Pavlov <[email protected]>--- drivers/serial/serial_ns16550.c | 19 +++++++++++++++++-- include/ns16550.h | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-)drivers/serial/serial_ns16550.c +2
-0@@ -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 );
drivers/serial/serial_ns16550.c static void ns16550_serial_init_port(struct console_device *cdev) · line 163
Quoted 10 lines
drivers/serial/serial_ns16550.c +6
-1@@ -153,7 +155,13 @@ 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); + }
unnecessary braces here..
Quoted 14 lines
drivers/serial/serial_ns16550.c +3
-0+#ifdef CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS ns16550_write (cdev,0x00 , mdr1);#endif @@ -211,6 +219,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);
drivers/serial/serial_ns16550.c static int ns16550_setbaudrate(struct console_device *cdev, int baud_rate) · line 235
Quoted 9 lines
drivers/serial/serial_ns16550.c +5
-1@@ -218,7 +228,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); + }
and here. Otherwise this looks ok.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 45 lines · Sascha Hauer
Quoted 20 lines · Antony Pavlov
Signed-off-by Antony Pavlov <[email protected]>---
drivers/serial/serial_ns16550.c | 19 +++++++++++++++++--include/ns16550.h| 2 ++2 files changed, 19 insertions(+), 2 deletions(-)drivers/serial/serial_ns16550.c +2
-0@@ -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);drivers/serial/serial_ns16550.c static void ns16550_serial_init_port(struct console_device *cdev) · line 163
Quoted 10 lines
drivers/serial/serial_ns16550.c +6
-1@@ -153,7 +155,13 @@ 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); + }unnecessary braces here..
Quoted 11 lines
drivers/serial/serial_ns16550.c +3
-0+ #ifdef CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS ns16550_write(cdev, 0x00, mdr1); #endif@@ -211,6 +219,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;
Quoted 14 lines
drivers/serial/serial_ns16550.c static int ns16550_setbaudrate(struct console_device *cdev, int baud_rate) · line 235
Quoted 12 lines
drivers/serial/serial_ns16550.c +5
-1ns16550_write(cdev, 0x00, ier); ns16550_write(cdev, LCR_BKSE, lcr);@@ -218,7 +228,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); + }and here. Otherwise this looks ok.
Ok, I shall remove the braces.
Sascha!
We have special OMAP code, e.g.:
#ifdef CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS
ns16550_write(cdev, 0x07, mdr1); /* Disable */#endif
I think, that we can change it to something like this:
if (plat->flags & NS16650_FLAG_OMAP_EXTENSIONS)
ns16550_write(cdev, 0x07, mdr1); /* Disable */Signature · 7 lines
Best regards, Antony Pavlov _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 67 lines · Antony Pavlov
Quoted 45 lines · Sascha Hauer
Quoted 20 lines · Antony Pavlov
Signed-off-by Antony Pavlov <[email protected]>---
drivers/serial/serial_ns16550.c | 19 +++++++++++++++++--include/ns16550.h| 2 ++2 files changed, 19 insertions(+), 2 deletions(-)drivers/serial/serial_ns16550.c +2
-0@@ -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);drivers/serial/serial_ns16550.c static void ns16550_serial_init_port(struct console_device *cdev) · line 163
Quoted 10 lines
drivers/serial/serial_ns16550.c +6
-1@@ -153,7 +155,13 @@ 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); + }unnecessary braces here..
Quoted 11 lines
drivers/serial/serial_ns16550.c +3
-0+ #ifdef CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS ns16550_write(cdev, 0x00, mdr1); #endif@@ -211,6 +219,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;Quoted 14 lines
drivers/serial/serial_ns16550.c static int ns16550_setbaudrate(struct console_device *cdev, int baud_rate) · line 235
Quoted 12 lines
drivers/serial/serial_ns16550.c +5
-1ns16550_write(cdev, 0x00, ier); ns16550_write(cdev, LCR_BKSE, lcr);@@ -218,7 +228,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); + }and here. Otherwise this looks ok.
Ok, I shall remove the braces.
Sascha!
We have special OMAP code, e.g.:
Quoted 8 lines
#ifdef CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS ns16550_write(cdev, 0x07, mdr1); /* Disable */#endif
I think, that we can change it to something like this:
if (plat->flags & NS16650_FLAG_OMAP_EXTENSIONS) ns16550_write(cdev, 0x07, mdr1); /* Disable */
I don't like to add dead code in the binary
just use
if (IS_ENABLED(CONFIG_...)
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 72 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 71 lines · Antony Pavlov
Quoted 45 lines · Sascha Hauer
Quoted 20 lines · Antony Pavlov
Signed-off-by Antony Pavlov <[email protected]>---
drivers/serial/serial_ns16550.c | 19 +++++++++++++++++--include/ns16550.h| 2 ++2 files changed, 19 insertions(+), 2 deletions(-)drivers/serial/serial_ns16550.c +2
-0@@ -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);drivers/serial/serial_ns16550.c static void ns16550_serial_init_port(struct console_device *cdev) · line 163
Quoted 10 lines
drivers/serial/serial_ns16550.c +6
-1@@ -153,7 +155,13 @@ 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); + }unnecessary braces here..
Quoted 11 lines
drivers/serial/serial_ns16550.c +3
-0+ #ifdef CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS ns16550_write(cdev, 0x00, mdr1); #endif@@ -211,6 +219,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;Quoted 14 lines
drivers/serial/serial_ns16550.c static int ns16550_setbaudrate(struct console_device *cdev, int baud_rate) · line 235
Quoted 12 lines
drivers/serial/serial_ns16550.c +5
-1ns16550_write(cdev, 0x00, ier); ns16550_write(cdev, LCR_BKSE, lcr);@@ -218,7 +228,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); + }and here. Otherwise this looks ok.
Ok, I shall remove the braces.
Sascha!
We have special OMAP code, e.g.:
#ifdef
CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONSns16550_write(cdev, 0x07, mdr1); /* Disable */ #endif
Quoted 7 lines
Quoted 4 lines
I think, that we can change it to something like this:
if (
plat->flags&NS16650_FLAG_OMAP_EXTENSIONS)ns16550_write(cdev, 0x07, mdr1); /* Disable */I don't like to add dead code in the binary
just use
if (IS_ENABLED(CONFIG_...)
You is right, but there is another point of view.
If you have defined CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS macro, then you will use OMAP extensions for __ALL__ ports, not only for OMAP internal port. May be OMAP have no other ports, only internal ports with extensions. But in any case it is bad design example: we have very special code (OMAP EXTENSIONS) in universal driver (ns16550), and this special code works without checking presents of the extensions.
I don't like dead code too. So there are another solutions:
#ifdef CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS
if (plat->flags & NS16650_FLAG_OMAP_EXTENSIONS)
ns16550_write(cdev, 0x07, mdr1); /* Disable */#endif
or even
if (IS_ENABLED(CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS) &&
plat->flags & NS16650_FLAG_OMAP_EXTENSIONS)
ns16550_write(cdev, 0x07, mdr1); /* Disable */Signature · 7 lines
Best regards, Antony Pavlov _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 97 lines · Antony Pavlov
Quoted 72 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 71 lines · Antony Pavlov
Quoted 45 lines · Sascha Hauer
Quoted 20 lines · Antony Pavlov
Signed-off-by Antony Pavlov <[email protected]>---
drivers/serial/serial_ns16550.c | 19 +++++++++++++++++--include/ns16550.h| 2 ++2 files changed, 19 insertions(+), 2 deletions(-)drivers/serial/serial_ns16550.c +2
-0@@ -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);drivers/serial/serial_ns16550.c static void ns16550_serial_init_port(struct console_device *cdev) · line 163
Quoted 10 lines
drivers/serial/serial_ns16550.c +6
-1@@ -153,7 +155,13 @@ 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); + }unnecessary braces here..
Quoted 11 lines
drivers/serial/serial_ns16550.c +3
-0+ #ifdef CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS ns16550_write(cdev, 0x00, mdr1); #endif@@ -211,6 +219,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;Quoted 14 lines
drivers/serial/serial_ns16550.c static int ns16550_setbaudrate(struct console_device *cdev, int baud_rate) · line 235
Quoted 12 lines
drivers/serial/serial_ns16550.c +5
-1ns16550_write(cdev, 0x00, ier); ns16550_write(cdev, LCR_BKSE, lcr);@@ -218,7 +228,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); + }and here. Otherwise this looks ok.
Ok, I shall remove the braces.
Sascha!
We have special OMAP code, e.g.:
#ifdef
CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONSns16550_write(cdev, 0x07, mdr1); /* Disable */ #endifQuoted 7 lines
Quoted 4 lines
I think, that we can change it to something like this:
if (
plat->flags&NS16650_FLAG_OMAP_EXTENSIONS)ns16550_write(cdev, 0x07, mdr1); /* Disable */I don't like to add dead code in the binary
just use
if (IS_ENABLED(CONFIG_...)You is right, but there is another point of view.
If you have defined
CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONSmacro, then you will use OMAP extensions for__ALL__ports, not only for OMAP internal port. May be OMAP have no other ports, only internal ports with extensions. But in any case it is bad design example: we have very special code (OMAP EXTENSIONS) in universal driver (ns16550), and this special code works without checking presents of the extensions.I don't like dead code too. So there are another solutions:
#ifdef CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS if (plat->flags & NS16650_FLAG_OMAP_EXTENSIONS) ns16550_write(cdev, 0x07, mdr1); /* Disable */
Quoted 6 lines
#endif
or even
if (IS_ENABLED(CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS) && plat->flags & NS16650_FLAG_OMAP_EXTENSIONS) ns16550_write(cdev, 0x07, mdr1); /* Disable */
this one
Best Regards,
J.
Quoted 3 lines
Signature · 2 lines
Best regards, Antony Pavlov
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox