Device Tree probing for bcm63xx-uart
Subsystems (2)
cover Device Tree probing for bcm63xx-uart
Hi Greg,
This patchset make the bcm63xx_uart architecture agnostic such that it can be built on something else than MIPS now. Finally it adds support for Device Tree probing to the driver along with a DT binding documentation.
I would appreciate if this could go via your tree for consistency.
Thanks!
Florian Fainelli (4):
tty: serial: bcm63xx_uart: include linux/io.h
tty: serial: bcm63xx_uart: define UART_REG_SIZE constant
tty: serial: bcm63xx_uart: add support for DT probing
Documentation: devicetree: add bindings documentation for bcm63xx-uart
.../devicetree/bindings/serial/bcm63xx-uart.txt | 24 ++++++++++++++++++++++ drivers/tty/serial/bcm63xx_uart.c | 16 +++++++++++++-- include/linux/serial_bcm63xx.h | 2 ++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/serial/bcm63xx-uart.txt
Signature · 1 line
1.8.3.2
PATCH 1/4 tty: serial: bcm63xx_uart: include linux/io.h
Include linux/io.h which provides the definition for __raw_{readl,writel}, this is not necessary on MIPS since there is an implicit inclusion, but it is on ARM for instance.
--- drivers/tty/serial/bcm63xx_uart.c | 1 + 1 file changed, 1 insertion(+)
drivers/tty/serial/bcm63xx_uart.c +1 -0
@@ -30,6 +30,7 @@#include <linux/serial.h> #include <linux/serial_core.h> #include <linux/serial_bcm63xx.h> +#include <linux/io.h> #define BCM63XX_NR_UARTS 2
Signature · 1 line
1.8.3.2
PATCH 2/4 tty: serial: bcm63xx_uart: define UART_REG_SIZE constant
In reply to Florian FainelliThe bcm63xx_uart driver uses RSET_UART_SIZE which is a constant defined for MIPS-based BCM63xx platforms, pull this constant value from the MIPS-specific header and put it in include/linux/serial_bcm63xx.h to make the driver platform agnostic.
--- drivers/tty/serial/bcm63xx_uart.c | 4 ++-- include/linux/serial_bcm63xx.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/tty/serial/bcm63xx_uart.c +2 -2
@@ -589,7 +589,7 @@ static int bcm_uart_request_port(struct uart_port *port) {unsigned int size; - size =RSET_UART_SIZE ; + size =UART_REG_SIZE ;if (!request_mem_region (port->mapbase, size,"bcm63xx" )) {dev_err (port->dev,"Memory region busy\n" );return -EBUSY ;
@@ -609,7 +609,7 @@ static int bcm_uart_request_port(struct uart_port *port)*/ static void bcm_uart_release_port (struct uart_port *port) { -release_mem_region (port->mapbase,RSET_UART_SIZE ); +release_mem_region (port->mapbase,UART_REG_SIZE );iounmap (port->membase); }
include/linux/serial_bcm63xx.h +2 -0
@@ -116,4 +116,6 @@ UART_FIFO_PARERR_MASK | \ UART_FIFO_BRKDET_MASK) +#define UART_REG_SIZE 24 +#endif /* _LINUX_SERIAL_BCM63XX_H */
Signature · 1 line
1.8.3.2
PATCH 3/4 tty: serial: bcm63xx_uart: add support for DT probing
In reply to Florian FainelliAdd a matching table for the the bcm63xx_uart driver on the compatible string "brcm,bcm63xx-uart" which covers all BCM63xx implementations. Also make sure that we convert the id based on the uart aliases provided by the relevant Device Tree.
--- drivers/tty/serial/bcm63xx_uart.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/tty/serial/bcm63xx_uart.c +11 -0
@@ -31,6 +31,7 @@#include <linux/serial_core.h> #include <linux/serial_bcm63xx.h> #include <linux/io.h> +#include <linux/of.h> #define BCM63XX_NR_UARTS 2
@@ -806,6 +807,9 @@ static int bcm_uart_probe(struct platform_device *pdev)struct clk *clk;int ret; +if (pdev->dev.of_node) + pdev->id =of_alias_get_id (pdev->dev.of_node,"uart" ); +if (pdev->id <0 || pdev->id >=BCM63XX_NR_UARTS )return -EINVAL ;
@@ -857,6 +861,12 @@ static int bcm_uart_remove(struct platform_device *pdev)return 0 ; } +static const struct of_device_id bcm63xx_of_match[] = { + { .compatible ="brcm,bcm63xx-uart" }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (of, bcm63xx_of_match); +/* * platform driver stuff */
@@ -866,6 +876,7 @@ static struct platform_driver bcm_uart_platform_driver = { .driver = { .owner = THIS_MODULE, .name = "bcm63xx_uart", + .of_match_table = bcm63xx_of_match, }, };
Signature · 1 line
1.8.3.2
PATCH 4/4 Documentation: devicetree: add bindings documentation for bcm63xx-uart
In reply to Florian FainelliAdd the Device Tree binding documentation for the non-standard BCM63xx UART hardware block found in the BCM63xx DSL SoCs.
--- .../devicetree/bindings/serial/bcm63xx-uart.txt | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Documentation/devicetree/bindings/serial/bcm63xx-uart.txt
Documentation/devicetree/bindings/serial/bcm63xx-uart.txt new file +24 -0
@@ -0,0 +1,24 @@ +Broadcom BCM63xx UART: Non standard UART used in the Broadcom BCM63xx DSL SoCs + +Required properties: +- compatible: must be "brcm,bcm63xx-uart" +- reg: offset and length of the register set for the device +- interrupts: device interrupt +- clocks: a phandle to the functional clock node +- clock-names: must be "periph" + +Note: each UART port must have an alias correctly numbered in the "aliases" +node, e.g: + +serial0: uart@600 { + compatible = "brcm,bcm63xx-uart"; + reg = <0x600 0x1b>; + interrupts = <GIC_SPI 32 0>; + clocks = <&periph_clk>; + clock-names = "periph"; +}; + +aliases { + uart0 = &serial0; + uart1 = &serial1; +};
Signature · 1 line
1.8.3.2
Re: [PATCH 3/4] tty: serial: bcm63xx_uart: add support for DT probing
In reply to Florian FainelliQuoted 39 lines · Florian Fainelli
Add a matching table for the the
bcm63xx_uartdriver on the compatible string "brcm,bcm63xx-uart" which covers all BCM63xx implementations. Also make sure that we convert the id based on the uart aliases provided by the relevant Device Tree.Signed-off-by Florian Fainelli <[email protected]>--- drivers/tty/serial/bcm63xx_uart.c | 11 +++++++++++ 1 file changed, 11 insertions(+)drivers/tty/serial/bcm63xx_uart.c +6
-0@@ -31,6 +31,7 @@#include <linux/serial_core.h> #include <linux/serial_bcm63xx.h> #include <linux/io.h> +#include <linux/of.h> #define BCM63XX_NR_UARTS 2@@ -806,6 +807,9 @@ static int bcm_uart_probe(struct platform_device *pdev)struct clk *clk;int ret; +if (pdev->dev.of_node) + pdev->id =of_alias_get_id (pdev->dev.of_node,"uart" ); +if (pdev->id <0 || pdev->id >=BCM63XX_NR_UARTS )return -EINVAL ;@@ -857,6 +861,12 @@ static int bcm_uart_remove(struct platform_device *pdev)return 0 ; } +static const struct of_device_id bcm63xx_of_match[] = { + { .compatible ="brcm,bcm63xx-uart" },
Quoted 1 line
From my understanding, this should be "brcm,bcm6345-uart", because
this kind of uart appeared first on bcm6345 (well, maybe bcm6335, no idea which one of these two was first, but the latter was never supported in mainline anyway).
The same applies to 4/4.
drivers/tty/serial/bcm63xx_uart.c static struct platform_driver bcm_uart_platform_driver = { · line 879
Quoted 12 lines
drivers/tty/serial/bcm63xx_uart.c +5
-0+ {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (of, bcm63xx_of_match); +/* * platform driver stuff */ @@ -866,6 +876,7 @@ static struct platform_driver bcm_uart_platform_driver = { .driver = { .owner = THIS_MODULE, .name = "bcm63xx_uart", + .of_match_table = bcm63xx_of_match,
You could guard this one with of_match_ptr (and then bcm63xx_of_match with CONFIG_OF. Probably not much, but it's the little things ;-)
Regards
Jonas
Re: [PATCH 3/4] tty: serial: bcm63xx_uart: add support for DT probing
2014-02-19 16:00 GMT-08:00 Jonas Gorski <[email protected]>:
Quoted 37 lines · Florian Fainelli
Quoted 36 lines
Add a matching table for the the
bcm63xx_uartdriver on the compatible string "brcm,bcm63xx-uart" which covers all BCM63xx implementations. Also make sure that we convert the id based on the uart aliases provided by the relevant Device Tree.Signed-off-by Florian Fainelli <[email protected]>--- drivers/tty/serial/bcm63xx_uart.c | 11 +++++++++++ 1 file changed, 11 insertions(+)drivers/tty/serial/bcm63xx_uart.c +4
-0@@ -31,6 +31,7 @@#include <linux/serial_core.h> #include <linux/serial_bcm63xx.h> #include <linux/io.h> +#include <linux/of.h> #define BCM63XX_NR_UARTS 2@@ -806,6 +807,9 @@ static int bcm_uart_probe(struct platform_device *pdev)struct clk *clk;int ret; +if (pdev->dev.of_node) + pdev->id =of_alias_get_id (pdev->dev.of_node,"uart" ); +if (pdev->id <0 || pdev->id >=BCM63XX_NR_UARTS )return -EINVAL ;@@ -857,6 +861,12 @@ static int bcm_uart_remove(struct platform_device *pdev)return 0 ; }
Quoted 7 lines
drivers/tty/serial/bcm63xx_uart.c static int bcm_uart_remove(struct platform_device *pdev) · line 865
Quoted 2 lines
drivers/tty/serial/bcm63xx_uart.c +2
-0+static const struct of_device_id bcm63xx_of_match[] = { + { .compatible ="brcm,bcm63xx-uart" },From my understanding, this should be "brcm,bcm6345-uart", because this kind of uart appeared first on bcm6345 (well, maybe bcm6335, no idea which one of these two was first, but the latter was never supported in mainline anyway).
That's right, in fact, I think it might be desirable to handle both compatible string, just as a hint that it is compatible with the entire bcm63xx family. Would that work for you?
Quoted 17 lines
The same applies to 4/4.
drivers/tty/serial/bcm63xx_uart.c static struct platform_driver bcm_uart_platform_driver = { · line 879
Quoted 12 lines
drivers/tty/serial/bcm63xx_uart.c +5
-0+ {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (of, bcm63xx_of_match); +/* * platform driver stuff */ @@ -866,6 +876,7 @@ static struct platform_driver bcm_uart_platform_driver = { .driver = { .owner = THIS_MODULE, .name = "bcm63xx_uart", + .of_match_table = bcm63xx_of_match,You could guard this one with
of_match_ptr(and thenbcm63xx_of_matchwithCONFIG_OF. Probably not much, but it's the little things ;-)
Good catch.
Signature · 1 line
Florian
Re: [PATCH 4/4] Documentation: devicetree: add bindings documentation for bcm63xx-uart
In reply to Florian FainelliQuoted 15 lines · Florian Fainelli
Add the Device Tree binding documentation for the non-standard BCM63xx UART hardware block found in the BCM63xx DSL SoCs.
Signed-off-by Florian Fainelli <[email protected]>--- .../devicetree/bindings/serial/bcm63xx-uart.txt | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Documentation/devicetree/bindings/serial/bcm63xx-uart.txtDocumentation/devicetree/bindings/serial/bcm63xx-uart.txt new file +0
-0
Documentation/devicetree/bindings/serial/bcm63xx-uart.txt line 8
Quoted 8 lines
Documentation/devicetree/bindings/serial/bcm63xx-uart.txt new file +8
-0@@ -0,0 +1,24 @@ +Broadcom BCM63xx UART: Non standard UART used in the Broadcom BCM63xx DSL SoCs + +Required properties: +- compatible: must be "brcm,bcm63xx-uart" +- reg: offset and length of the register set for the device +- interrupts: device interrupt +- clocks: a phandle to the functional clock node +- clock-names: must be "periph"
Minor issues: clocks aren't just phandles, and as the clock is expected to be named it would be nice to define clocks in terms of clock-names:
- clocks: a list of phandles + clock-specifiers, one for each entry in clock-names
- clock-names: should contain "periph" for the functional clock
Thanks,
Mark.
Quoted 24 lines
Documentation/devicetree/bindings/serial/bcm63xx-uart.txt new file +16
-0+ +Note: each UART port must have an alias correctly numbered in the "aliases" +node, e.g: + +serial0: uart@600 { + compatible = "brcm,bcm63xx-uart"; + reg = <0x600 0x1b>; + interrupts = <GIC_SPI 32 0>; + clocks = <&periph_clk>; + clock-names = "periph"; +}; + +aliases { + uart0 = &serial0; + uart1 = &serial1; +};Signature · 6 lines
1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/4] tty: serial: bcm63xx_uart: add support for DT probing
In reply to Florian FainelliQuoted 14 lines · Florian Fainelli
2014-02-19 16:00 GMT-08:00 Jonas Gorski <[email protected]>:
Quoted 5 lines · Florian Fainelli
Quoted 4 lines
drivers/tty/serial/bcm63xx_uart.c +0
-0@@ -857,6 +861,12 @@ static int bcm_uart_remove(struct platform_device *pdev)return 0 ; }Quoted 7 lines
drivers/tty/serial/bcm63xx_uart.c static int bcm_uart_remove(struct platform_device *pdev) · line 865
Quoted 2 lines
drivers/tty/serial/bcm63xx_uart.c +2
-0+static const struct of_device_id bcm63xx_of_match[] = { + { .compatible ="brcm,bcm63xx-uart" },From my understanding, this should be "brcm,bcm6345-uart", because this kind of uart appeared first on bcm6345 (well, maybe bcm6335, no idea which one of these two was first, but the latter was never supported in mainline anyway).
Quoted 3 lines
That's right, in fact, I think it might be desirable to handle both compatible string, just as a hint that it is compatible with the entire bcm63xx family. Would that work for you?
I think using a "generic" compatible string is rather frowned upon (what do you do if there is eventually a bcm63xx chip with an incompatible uart?), but I'm no device tree expert.
Jonas
Re: [PATCH 3/4] tty: serial: bcm63xx_uart: add support for DT probing
Quoted 15 lines · On Thursday 20 February 2014 11:59:04 Jonas Gorski wrote:
Quoted 14 lines · Florian Fainelli
2014-02-19 16:00 GMT-08:00 Jonas Gorski <[email protected]>:
Quoted 12 lines · Florian Fainelli
drivers/tty/serial/bcm63xx_uart.c static int bcm_uart_remove(struct platform_device *pdev) · line 865
Quoted 6 lines
drivers/tty/serial/bcm63xx_uart.c +2
-0@@ -857,6 +861,12 @@ static int bcm_uart_remove(struct platform_device *pdev)return 0 ; } +static const struct of_device_id bcm63xx_of_match[] = { + { .compatible ="brcm,bcm63xx-uart" },From my understanding, this should be "brcm,bcm6345-uart", because this kind of uart appeared first on bcm6345 (well, maybe bcm6335, no idea which one of these two was first, but the latter was never supported in mainline anyway).
Quoted 7 lines
Quoted 3 lines
That's right, in fact, I think it might be desirable to handle both compatible string, just as a hint that it is compatible with the entire bcm63xx family. Would that work for you?
I think using a "generic" compatible string is rather frowned upon (what do you do if there is eventually a bcm63xx chip with an incompatible uart?), but I'm no device tree expert.
It's ok to have a generic name, it's wildcards like the xx above that we try to avoid, since that breaks down when you get another device in the same SoC family that is not compatible. This is different from the Linux way of naming things.
brcm,bcm6345-uart sounds good, if that is the closest we can get to a generic name, working under the assumption that it's the oldest implementation of this UART. Ideally we'd find someone with access to the design documents of the SoC to tell us what the UART is really called by whoever designed it (which may not even be Broadcom).
If we think there may be some level of variation between the UARTS in the various bcm63xx SoCs, it would be good to list both the specific model of the SoC as well as the generic name in "compatible", so the driver can later detect those differences without requiring an updated DT.
A BCM63138 for instance could list this as
compatible = "brcm,bcm62138-uart", "brcm-bcm6345-uart"; Arnd
Re: [PATCH 3/4] tty: serial: bcm63xx_uart: add support for DT probing
In reply to Jonas GorskiQuoted 15 lines · Jonas Gorski
Quoted 14 lines · Florian Fainelli
2014-02-19 16:00 GMT-08:00 Jonas Gorski <[email protected]>:
Quoted 12 lines · Florian Fainelli
drivers/tty/serial/bcm63xx_uart.c static int bcm_uart_remove(struct platform_device *pdev) · line 865
Quoted 6 lines
drivers/tty/serial/bcm63xx_uart.c +2
-0@@ -857,6 +861,12 @@ static int bcm_uart_remove(struct platform_device *pdev)return 0 ; } +static const struct of_device_id bcm63xx_of_match[] = { + { .compatible ="brcm,bcm63xx-uart" },From my understanding, this should be "brcm,bcm6345-uart", because this kind of uart appeared first on bcm6345 (well, maybe bcm6335, no idea which one of these two was first, but the latter was never supported in mainline anyway).
Quoted 7 lines
Quoted 3 lines
That's right, in fact, I think it might be desirable to handle both compatible string, just as a hint that it is compatible with the entire bcm63xx family. Would that work for you?
I think using a "generic" compatible string is rather frowned upon (what do you do if there is eventually a bcm63xx chip with an incompatible uart?), but I'm no device tree expert.
As long as each compatible string entry describes something that has a compatible programming model, there's no problem. The new UART wouldn't be described with a string it's not compatible with.
I think "brcm,bcm6345-uart," is a nicer name to use for the moment than "brcm,bcm63xx-uart" as it clearly describes a specific UART and is less likely to be problematic in future if an incompatible UART appears. Additionally, each compatible UART can have a more specific compatible string entry that allows them to be more uniquely identified in case they need to be handled specially in future. e.g:
compatible = "brcm,bcm634x-uart", "brcm,bcm6345-uart";
Then if a bcm634y comes out with a UART that's not compatible with the bcm6345 UART, it just needs:
compatible = "brcm,bcm634y-uart";
Thanks,
Mark.
Re: [PATCH 3/4] tty: serial: bcm63xx_uart: add support for DT probing
In reply to Arnd BergmannHi Arnd,
Quoted 29 lines · Arnd Bergmann
Quoted 15 lines · On Thursday 20 February 2014 11:59:04 Jonas Gorski wrote:
Quoted 14 lines · Florian Fainelli
2014-02-19 16:00 GMT-08:00 Jonas Gorski <[email protected]>:
Quoted 12 lines · Florian Fainelli
drivers/tty/serial/bcm63xx_uart.c static int bcm_uart_remove(struct platform_device *pdev) · line 865
Quoted 6 lines
drivers/tty/serial/bcm63xx_uart.c +2
-0@@ -857,6 +861,12 @@ static int bcm_uart_remove(struct platform_device *pdev)return 0 ; } +static const struct of_device_id bcm63xx_of_match[] = { + { .compatible ="brcm,bcm63xx-uart" },From my understanding, this should be "brcm,bcm6345-uart", because
this kind of uart appeared first on bcm6345 (well, maybe bcm6335, no idea which one of these two was first, but the latter was never supported in mainline anyway).Quoted 7 lines
Quoted 3 lines
That's right, in fact, I think it might be desirable to handle both compatible string, just as a hint that it is compatible with the entire bcm63xx family. Would that work for you?
I think using a "generic" compatible string is rather frowned upon (what do you do if there is eventually a bcm63xx chip with an incompatible uart?), but I'm no device tree expert.
It's ok to have a generic name, it's wildcards like the xx above that we try to avoid, since that breaks down when you get another device in the same SoC family that is not compatible. This is different from the Linux way of naming things.
Quoted 5 lines
brcm,bcm6345-uart sounds good, if that is the closest we can get to a generic name, working under the assumption that it's the oldest implementation of this UART. Ideally we'd find someone with access to the design documents of the SoC to tell us what the UART is really called by whoever designed it (which may not even be Broadcom).
This is just called an uart, it does not have any specific project name as far as I could see, and BCM6345 was indeed the very first SoC using it.
Quoted 6 lines
If we think there may be some level of variation between the UARTS in the various bcm63xx SoCs, it would be good to list both the specific model of the SoC as well as the generic name in "compatible", so the driver can later detect those differences without requiring an updated DT.
Makes sense. So far this UART has been not modified (as far as a programmer may be concerned) since its very first design in a BCM6345.
Quoted 7 lines
A BCM63138 for instance could list this as
compatible = "brcm,bcm62138-uart", "brcm-bcm6345-uart"; Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html