tty/serial: Add support for Altera serial port
Subsystems (2)
PATCH 1/1 tty/serial: Add support for Altera serial port
Add support for Altera 8250/16550 compatible serial port.
--- .../devicetree/bindings/tty/serial/of-serial.txt | 3 ++ drivers/tty/serial/8250/8250.c | 23 +++++++++++++++++++- drivers/tty/serial/of_serial.c | 6 +++++ include/uapi/linux/serial_core.h | 5 +++- 4 files changed, 35 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/tty/serial/of-serial.txt +3 -0
@@ -11,6 +11,9 @@ Required properties: - "nvidia,tegra20-uart" - "nxp,lpc3220-uart" - "ibm,qpace-nwp-serial" + - "altr,16550-FIFO32" + - "altr,16550-FIFO64" + - "altr,16550-FIFO128" - "serial" if the port type is unknown. - reg : offset and length of the register set for the device. - interrupts : should contain uart interrupt.
drivers/tty/serial/8250/8250.c +22 -1
@@ -301,7 +301,28 @@ static const struct serial8250_config uart_config[] = { }, [PORT_8250_CIR ] = { .name ="CIR port" - } + }, + [PORT_ALTR_16550_F32 ] = { + .name ="Altera 16550 FIFO32" , + .fifo_size =32 , + .tx_loadsz =32 , + .fcr =UART_FCR_ENABLE_FIFO |UART_FCR_R_TRIG_10 , + .flags =UART_CAP_FIFO |UART_CAP_AFE , + }, + [PORT_ALTR_16550_F64 ] = { + .name ="Altera 16550 FIFO64" , + .fifo_size =64 , + .tx_loadsz =64 , + .fcr =UART_FCR_ENABLE_FIFO |UART_FCR_R_TRIG_10 , + .flags =UART_CAP_FIFO |UART_CAP_AFE , + }, + [PORT_ALTR_16550_F128 ] = { + .name ="Altera 16550 FIFO128" , + .fifo_size =128 , + .tx_loadsz =128 , + .fcr =UART_FCR_ENABLE_FIFO |UART_FCR_R_TRIG_10 , + .flags =UART_CAP_FIFO |UART_CAP_AFE , + }, };/* Uart divisor latch read */
drivers/tty/serial/of_serial.c +6 -0
@@ -241,6 +241,12 @@ static struct of_device_id of_platform_serial_table[] = { { .compatible = "ns16850", .data = (void *)PORT_16850, }, { .compatible = "nvidia,tegra20-uart", .data = (void *)PORT_TEGRA, }, { .compatible = "nxp,lpc3220-uart", .data = (void *)PORT_LPC3220, }, + { .compatible = "altr,16550-FIFO32", + .data = (void *)PORT_ALTR_16550_F32, }, + { .compatible = "altr,16550-FIFO64", + .data = (void *)PORT_ALTR_16550_F64, }, + { .compatible = "altr,16550-FIFO128", + .data = (void *)PORT_ALTR_16550_F128, }, #ifdef CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL { .compatible = "ibm,qpace-nwp-serial", .data = (void *)PORT_NWPSERIAL, },
include/uapi/linux/serial_core.h +4 -1
@@ -51,7 +51,10 @@#define PORT_8250_CIR 23/* CIR infrared port, has its own driver */ #define PORT_XR17V35X 24/* Exar XR17V35x UARTs */ #define PORT_BRCM_TRUMANAGE 25 -#define PORT_MAX_8250 25/* max port ID */ +#define PORT_ALTR_16550_F32 26/* Altera 16550 UART with 32 FIFOs */ +#define PORT_ALTR_16550_F64 27/* Altera 16550 UART with 64 FIFOs */ +#define PORT_ALTR_16550_F128 28/* Altera 16550 UART with 128 FIFOs */ +#define PORT_MAX_8250 28/* max port ID */ /* * ARM specific type numbers. These are not currently guaranteed
Signature · 1 line
1.7.7.4
Hi,
Quoted 21 lines · Ley Foon Tan
drivers/tty/serial/8250/8250.c +12
-1@@ -301,7 +301,28 @@ static const struct serial8250_config uart_config[] = { }, [PORT_8250_CIR] = { .name ="CIR port" - } + }, + [PORT_ALTR_16550_F32] = { + .name = "Altera 16550 FIFO32", + .fifo_size = 32, + .tx_loadsz = 32, + .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10, + .flags = UART_CAP_FIFO | UART_CAP_AFE, + }, + [PORT_ALTR_16550_F64] = { + .name = "Altera 16550 FIFO64", + .fifo_size = 64, + .tx_loadsz = 64,
drivers/tty/serial/8250/8250.c static const struct serial8250_config uart_config[] = { · line 325
Quoted 10 lines
drivers/tty/serial/8250/8250.c +10
-0+ .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10, + .flags = UART_CAP_FIFO | UART_CAP_AFE, + }, + [PORT_ALTR_16550_F128] = { + .name = "Altera 16550 FIFO128", + .fifo_size = 128, + .tx_loadsz = 128, + .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10, + .flags = UART_CAP_FIFO | UART_CAP_AFE, + },
Adding three new types for what are basically the same UART, just with different fifosizes, feels a bit silly to me, so in the future the fifosize should be delivered as DT property. The following patches fill uart_port.fifosize with the value from the property. I can see the fifosize property is already used with some uarts, at least under arch/arm/boot/dts/, but I guess not for of_serial.c driver.
Maybe there should also be DT property for auto flow control. It seems to be quite common feature. Then in this case the type could just be PORT_16550A.
Signature · 1 line
heikki
PATCH 1/2 serial: 8250: Allow probe drivers to ignore tx_loadsz
In most cases the tx_loadsz is the same as fifosize. This will store the fifosize in it if it was not separately delivered from the driver.
--- drivers/tty/serial/8250/8250.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/tty/serial/8250/8250.c +4 -0
@@ -3247,6 +3247,10 @@ int serial8250_register_8250_port(struct uart_8250_port *up) uart->tx_loadsz = up->tx_loadsz; uart->capabilities = up->capabilities; +/* Take tx_loadsz from fifosize if it wasn't set separately */ +if (uart->port.fifosize && !uart->tx_loadsz) + uart->tx_loadsz = uart->port.fifosize; +if (up->port.dev) uart->port.dev = up->port.dev;
Signature · 1 line
1.7.10.4
PATCH 2/2 serial: of_serial: Handle fifosize property
In reply to Heikki Krogerusfifosize property is already used with a number of serial devices. This should reduce the need for extra types in 8250.c just in case the fifosize differs from the standard.
--- Documentation/devicetree/bindings/tty/serial/of-serial.txt | 1 + drivers/tty/serial/of_serial.c | 4 ++++ 2 files changed, 5 insertions(+)
Documentation/devicetree/bindings/tty/serial/of-serial.txt +1 -0
@@ -33,6 +33,7 @@ Optional properties: RTAS and should not be registered. - no-loopback-test: set to indicate that the port does not implements loopback test mode +- fifosize: the fifo size of the UART. Example:
drivers/tty/serial/of_serial.c +4 -0
@@ -97,6 +97,10 @@ static int of_platform_serial_setup(struct platform_device *ofdev,if (of_property_read_u32 (np,"reg-shift" , &prop) ==0 ) port->regshift = prop; +/* Check for fifo size */ +if (of_property_read_u32 (np,"fifosize" , &prop) ==0 ) + port->fifosize = prop; + port->irq =irq_of_parse_and_map (np,0 ); port->iotype =UPIO_MEM ;if (of_property_read_u32 (np,"reg-io-width" , &prop) ==0 ) {
Signature · 1 line
1.7.10.4
Re: [PATCH 2/2] serial: of_serial: Handle fifosize property
Quoted 27 lines · Heikki Krogerus
fifosize property is already used with a number of serial devices. This should reduce the need for extra types in 8250.c just in case the fifosize differs from the standard.
Signed-off-by Heikki Krogerus <[email protected]>--- Documentation/devicetree/bindings/tty/serial/of-serial.txt | 1 + drivers/tty/serial/of_serial.c | 4 ++++ 2 files changed, 5 insertions(+)Documentation/devicetree/bindings/tty/serial/of-serial.txt +1
-0@@ -33,6 +33,7 @@ Optional properties: RTAS and should not be registered. - no-loopback-test: set to indicate that the port does not implements loopback test mode +- fifosize: the fifo size of the UART. Example:drivers/tty/serial/of_serial.c +0
-0
drivers/tty/serial/of_serial.c static int of_platform_serial_setup(struct platform_device *ofdev, · line 103
Quoted 7 lines
drivers/tty/serial/of_serial.c +4
-0@@ -97,6 +97,10 @@ static int of_platform_serial_setup(struct platform_device *ofdev,if (of_property_read_u32 (np,"reg-shift" , &prop) ==0 ) port->regshift = prop; +/* Check for fifo size */ +if (of_property_read_u32 (np,"fifosize" , &prop) ==0 ) + port->fifosize = prop; +
Suggest to use "fifo-size" for the device tree property, to align with other DT properties.
drivers/tty/serial/of_serial.c static int of_platform_serial_setup(struct platform_device *ofdev, · line 106
Quoted 3 lines
drivers/tty/serial/of_serial.c +0
-0port->irq =irq_of_parse_and_map (np,0 ); port->iotype =UPIO_MEM ;if (of_property_read_u32 (np,"reg-io-width" , &prop) ==0 ) {
I think you need to remove the UPF_FIXED_TYPE from port-flags as well to use the fifo size from device tree. Otherwise, it will get from the static array in 8250.c.
LFTan
Re: [PATCH 2/2] serial: of_serial: Handle fifosize property
Hi,
Quoted 7 lines · Ley Foon Tan
drivers/tty/serial/of_serial.c static int of_platform_serial_setup(struct platform_device *ofdev, · line 103
Quoted 4 lines · Heikki Krogerus
drivers/tty/serial/of_serial.c +4
-0+/* Check for fifo size */ +if (of_property_read_u32 (np,"fifosize" , &prop) ==0 ) + port->fifosize = prop; +Suggest to use "fifo-size" for the device tree property, to align with other DT properties.
I was going to, but then I noticed that in some .dtsi files "fifosize" is used with uarts. Should I still change it?
Quoted 7 lines
drivers/tty/serial/of_serial.c static int of_platform_serial_setup(struct platform_device *ofdev, · line 106
Quoted 3 lines
drivers/tty/serial/of_serial.c +0
-0port->irq =irq_of_parse_and_map (np,0 ); port->iotype =UPIO_MEM ;if (of_property_read_u32 (np,"reg-io-width" , &prop) ==0 ) {I think you need to remove the
UPF_FIXED_TYPEfrom port-flags as well to use the fifo size from device tree. Otherwise, it will get from the static array in 8250.c.
No, it's the other way around. It is picked from the array conditionally, only in case it was not already set. However, if UPF_FIXED_TYPE is removed then autoconfig() will override it.
Thanks,
Signature · 1 line
heikki
Re: [PATCH 2/2] serial: of_serial: Handle fifosize property
Quoted 11 lines · Heikki Krogerus
Hi,
Quoted 7 lines · Ley Foon Tan
drivers/tty/serial/of_serial.c static int of_platform_serial_setup(struct platform_device *ofdev, · line 103
Quoted 4 lines · Heikki Krogerus
drivers/tty/serial/of_serial.c +4
-0+/* Check for fifo size */ +if (of_property_read_u32 (np,"fifosize" , &prop) ==0 ) + port->fifosize = prop; +Suggest to use "fifo-size" for the device tree property, to align with other DT properties.
Quoted 2 lines
I was going to, but then I noticed that in some .dtsi files "fifosize" is used with uarts. Should I still change it?
I just make the grep for "fifosize" in arch/. It is used by other serial drivers (not of_serial.c). So, you are safe to change it to "fifo-size".
Quoted 9 lines
Quoted 8 lines
drivers/tty/serial/of_serial.c static int of_platform_serial_setup(struct platform_device *ofdev, · line 106
Quoted 4 lines
drivers/tty/serial/of_serial.c +0
-0port->irq =irq_of_parse_and_map (np,0 ); port->iotype =UPIO_MEM ;if (of_property_read_u32 (np,"reg-io-width" , &prop) ==0 ) {I think you need to remove the
UPF_FIXED_TYPEfrom port-flags as well to use the fifo size from device tree. Otherwise, it will get from the static array in 8250.c.
Quoted 6 lines
No, it's the other way around. It is picked from the array conditionally, only in case it was not already set. However, if
UPF_FIXED_TYPEis removed thenautoconfig()will override it.Thanks,
Okay, I got what you means now. I think someone updated the 8250.c recently, previously it is always take from static array. Thanks.
Re: [PATCH 2/2] serial: of_serial: Handle fifosize property
Quoted 9 lines · Ley Foon Tan
Quoted 6 lines · Heikki Krogerus
Quoted 2 lines · Ley Foon Tan
Suggest to use "fifo-size" for the device tree property, to align with other DT properties.
I was going to, but then I noticed that in some .dtsi files "fifosize" is used with uarts. Should I still change it?
I just make the grep for "fifosize" in
arch/. It is used by other serial drivers (notof_serial.c). So, you are safe to change it to "fifo-size".
OK, I'll change it.
Thanks!
Signature · 1 line
heikki
PATCH v2 2/2 serial: of_serial: Handle fifo-size property
This will reduce the need for extra types in 8250.c just in case the fifo size differs from the standard.
--- Documentation/devicetree/bindings/tty/serial/of-serial.txt | 1 + drivers/tty/serial/of_serial.c | 4 ++++ 2 files changed, 5 insertions(+)
Documentation/devicetree/bindings/tty/serial/of-serial.txt +1 -0
@@ -33,6 +33,7 @@ Optional properties: RTAS and should not be registered. - no-loopback-test: set to indicate that the port does not implements loopback test mode +- fifo-size: the fifo size of the UART. Example:
drivers/tty/serial/of_serial.c +4 -0
@@ -97,6 +97,10 @@ static int of_platform_serial_setup(struct platform_device *ofdev,if (of_property_read_u32 (np,"reg-shift" , &prop) ==0 ) port->regshift = prop; +/* Check for fifo size */ +if (of_property_read_u32 (np,"fifo-size" , &prop) ==0 ) + port->fifosize = prop; + port->irq =irq_of_parse_and_map (np,0 ); port->iotype =UPIO_MEM ;if (of_property_read_u32 (np,"reg-io-width" , &prop) ==0 ) {
Signature · 1 line
1.7.10.4
Re: [PATCHv2 2/2] serial: of_serial: Handle fifo-size property
Quoted 2 lines · Heikki Krogerus
This will reduce the need for extra types in 8250.c just in case the fifo size differs from the standard.
Besides the fifo size, we need to have hardware flow control setting from device tree as well.
Thanks.
Quoted 17 lines
Signed-off-by Heikki Krogerus <[email protected]>--- Documentation/devicetree/bindings/tty/serial/of-serial.txt | 1 + drivers/tty/serial/of_serial.c | 4 ++++ 2 files changed, 5 insertions(+)Documentation/devicetree/bindings/tty/serial/of-serial.txt +1
-0@@ -33,6 +33,7 @@ Optional properties: RTAS and should not be registered. - no-loopback-test: set to indicate that the port does not implements loopback test mode +- fifo-size: the fifo size of the UART.
Re: [PATCHv2 2/2] serial: of_serial: Handle fifo-size property
Hi,
Quoted 5 lines · Ley Foon Tan
Quoted 2 lines · Heikki Krogerus
This will reduce the need for extra types in 8250.c just in case the fifo size differs from the standard.
Besides the fifo size, we need to have hardware flow control setting from device tree as well.
This is a bit problematic. We can set the uart_8250_port.capabilities flag UART_CAP_AFE based on "hw-flow-control" property, but then the properties from the type will not be used, just like in case of fifosize. We would need to know all the flags of the type that are normally taken from the uart_config[] array.
The UART_CAP_FIFO can be set by checking if we have set the port.fifosize or not, so if the bellow is acceptable then I can make a patch. There is no risk of overriding the capabilities for the existing uarts, as we only touch the uart_8250_port.capabilities if the new properties are used. So is it OK?
drivers/tty/serial/of_serial.c +7 -2
@@ -171,11 +171,16 @@ static int of_platform_serial_probe(struct platform_device *ofdev)#ifdef CONFIG_SERIAL_8250 case PORT_8250 ... PORT_MAX_8250: { -/* For now the of bindings don't support the extra -8250 specific bits */ struct uart_8250_port port8250;memset (&port8250,0 ,sizeof (port8250)); port8250.port = port; + +if (port.fifosize) + port8250.capabilities =UART_CAP_FIFO ; + +if (of_property_read_u32 (np,"hw-flow-control" , &prop) ==0 ) + port8250.capabilities |=UART_CAP_AFE ; + ret =serial8250_register_8250_port (&port8250);break ; }
Signature · 1 line
heikki
Re: [PATCHv2 2/2] serial: of_serial: Handle fifo-size property
Hi,
Quoted 10 lines · Heikki Krogerus
Quoted 2 lines · Ley Foon Tan
Besides the fifo size, we need to have hardware flow control setting from device tree as well.
This is a bit problematic. We can set the uart_8250_port.capabilities flag
UART_CAP_AFEbased on "hw-flow-control" property, but then the properties from the type will not be used, just like in case of fifosize. We would need to know all the flags of the type that are normally taken from the uart_config[] array.
Quoted 5 lines
The
UART_CAP_FIFOcan be set by checking if we have set the port.fifosize or not, so if the bellow is acceptable then I can make a patch. There is no risk of overriding the capabilities for the existing uarts, as we only touch the uart_8250_port.capabilities if the new properties are used. So is it OK?
I'll resend these two patches and add the support for hardware flow control.
Signature · 1 line
heikki