* [PATCH V3 0/4] serial: bcm2835: add bcm2835 auxiliar uart driver @ 2016-01-17 12:15 kernel at martin.sperl.org 2016-01-17 12:15 ` [PATCH V3 1/4] ARM: bcm2835: follow dt uart node-naming convention kernel at martin.sperl.org ` (3 more replies) 0 siblings, 4 replies; 9+ messages in thread From: kernel at martin.sperl.org @ 2016-01-17 12:15 UTC (permalink / raw) To: linux-arm-kernel From: Martin Sperl <kernel@martin.sperl.org> This patch series adds the bcm2835aux uart driver, which is created as a wrapper arround the 8250 driver (based on recommendations by Stephen Warren) Also (as per request) the recommendation for naming conventions of nodes in the device-tree have been followed for both the primary uart as well as for the auxiliar uart: nodes should be called "serial at ...". The device tree patches will not apply cleanly as: * the bcm-auxiliar clock device tree patch has not been applied to upstream yet (but it is pending). * there is a rename of arch/arm/boot/dts/bcm2835.dtsi scheduled, which is also not upstream yet. I want to get this patch out before I go on vacation not waiting for it to appear. If necessary please modify the corresponding patches. Martin Sperl (4): ARM: bcm2835: follow dt uart node-naming convention dt/bindings: serial: bcm2835: add binding documentation for bcm2835-aux-uart serial: bcm2835: add driver for bcm2835-aux-uart ARM: bcm2835: add bcm2835-aux-uart support to default DT .../bindings/serial/brcm,bcm2835-aux-uart.txt | 18 +++ arch/arm/boot/dts/bcm2835.dtsi | 9 +- drivers/tty/serial/8250/8250_bcm2835aux.c | 146 ++++++++++++++++++++ drivers/tty/serial/8250/Kconfig | 24 ++++ drivers/tty/serial/8250/Makefile | 1 + 5 files changed, 197 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/serial/brcm,bcm2835-aux-uart.txt create mode 100644 drivers/tty/serial/8250/8250_bcm2835aux.c -- 1.7.10.4 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH V3 1/4] ARM: bcm2835: follow dt uart node-naming convention 2016-01-17 12:15 [PATCH V3 0/4] serial: bcm2835: add bcm2835 auxiliar uart driver kernel at martin.sperl.org @ 2016-01-17 12:15 ` kernel at martin.sperl.org 2016-02-03 1:34 ` Eric Anholt 2016-01-17 12:15 ` [PATCH V3 2/4] dt/bindings: serial: bcm2835: add binding documentation for bcm2835-aux-uart kernel at martin.sperl.org ` (2 subsequent siblings) 3 siblings, 1 reply; 9+ messages in thread From: kernel at martin.sperl.org @ 2016-01-17 12:15 UTC (permalink / raw) To: linux-arm-kernel From: Martin Sperl <kernel@martin.sperl.org> This patch fixes the naming of the device tree node: uart at 7e201000 to conform to the standard of: serial at 7e201000 Signed-off-by: Martin Sperl <kernel@martin.sperl.org> --- arch/arm/boot/dts/bcm2835.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/bcm2835.dtsi b/arch/arm/boot/dts/bcm2835.dtsi index aef64de..b37a088 100644 --- a/arch/arm/boot/dts/bcm2835.dtsi +++ b/arch/arm/boot/dts/bcm2835.dtsi @@ -108,7 +108,7 @@ #interrupt-cells = <2>; }; - uart0: uart at 7e201000 { + uart0: serial at 7e201000 { compatible = "brcm,bcm2835-pl011", "arm,pl011", "arm,primecell"; reg = <0x7e201000 0x1000>; interrupts = <2 25>; -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH V3 1/4] ARM: bcm2835: follow dt uart node-naming convention 2016-01-17 12:15 ` [PATCH V3 1/4] ARM: bcm2835: follow dt uart node-naming convention kernel at martin.sperl.org @ 2016-02-03 1:34 ` Eric Anholt 0 siblings, 0 replies; 9+ messages in thread From: Eric Anholt @ 2016-02-03 1:34 UTC (permalink / raw) To: linux-arm-kernel kernel at martin.sperl.org writes: > From: Martin Sperl <kernel@martin.sperl.org> > > This patch fixes the naming of the device tree node: uart at 7e201000 > to conform to the standard of: serial at 7e201000 > > Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Did the rebase and merged this one to bcm2835-dt-next. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 818 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160202/210a2996/attachment.sig> ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH V3 2/4] dt/bindings: serial: bcm2835: add binding documentation for bcm2835-aux-uart 2016-01-17 12:15 [PATCH V3 0/4] serial: bcm2835: add bcm2835 auxiliar uart driver kernel at martin.sperl.org 2016-01-17 12:15 ` [PATCH V3 1/4] ARM: bcm2835: follow dt uart node-naming convention kernel at martin.sperl.org @ 2016-01-17 12:15 ` kernel at martin.sperl.org 2016-01-20 16:51 ` Rob Herring 2016-01-28 22:25 ` Eric Anholt 2016-01-17 12:15 ` [PATCH V3 3/4] serial: bcm2835: add driver " kernel at martin.sperl.org 2016-01-17 12:15 ` [PATCH V3 4/4] ARM: bcm2835: add bcm2835-aux-uart support to default DT kernel at martin.sperl.org 3 siblings, 2 replies; 9+ messages in thread From: kernel at martin.sperl.org @ 2016-01-17 12:15 UTC (permalink / raw) To: linux-arm-kernel From: Martin Sperl <kernel@martin.sperl.org> Add binding documentation for the bcm2835-aux-uart driver. Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Changelog: V2->V3: fixed naming convention for node --- .../bindings/serial/brcm,bcm2835-aux-uart.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Documentation/devicetree/bindings/serial/brcm,bcm2835-aux-uart.txt diff --git a/Documentation/devicetree/bindings/serial/brcm,bcm2835-aux-uart.txt b/Documentation/devicetree/bindings/serial/brcm,bcm2835-aux-uart.txt new file mode 100644 index 0000000..b5cc629 --- /dev/null +++ b/Documentation/devicetree/bindings/serial/brcm,bcm2835-aux-uart.txt @@ -0,0 +1,18 @@ +* BCM2835 AUXILIAR UART + +Required properties: + +- compatible: "brcm,bcm2835-aux-uart" +- reg: The base address of the UART register bank. +- interrupts: A single interrupt specifier. +- clocks: Clock driving the hardware; used to figure out the baud rate + divisor. + +Example: + + uart1: serial at 7e215040 { + compatible = "brcm,bcm2835-aux-uart"; + reg = <0x7e215040 0x40>; + interrupts = <1 29>; + clocks = <&aux BCM2835_AUX_CLOCK_UART>; + }; -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH V3 2/4] dt/bindings: serial: bcm2835: add binding documentation for bcm2835-aux-uart 2016-01-17 12:15 ` [PATCH V3 2/4] dt/bindings: serial: bcm2835: add binding documentation for bcm2835-aux-uart kernel at martin.sperl.org @ 2016-01-20 16:51 ` Rob Herring 2016-01-28 22:25 ` Eric Anholt 1 sibling, 0 replies; 9+ messages in thread From: Rob Herring @ 2016-01-20 16:51 UTC (permalink / raw) To: linux-arm-kernel On Sun, Jan 17, 2016 at 12:15:29PM +0000, kernel at martin.sperl.org wrote: > From: Martin Sperl <kernel@martin.sperl.org> > > Add binding documentation for the bcm2835-aux-uart driver. > > Signed-off-by: Martin Sperl <kernel@martin.sperl.org> > > Changelog: > V2->V3: fixed naming convention for node > --- > .../bindings/serial/brcm,bcm2835-aux-uart.txt | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > create mode 100644 Documentation/devicetree/bindings/serial/brcm,bcm2835-aux-uart.txt Acked-by: Rob Herring <robh@kernel.org> ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH V3 2/4] dt/bindings: serial: bcm2835: add binding documentation for bcm2835-aux-uart 2016-01-17 12:15 ` [PATCH V3 2/4] dt/bindings: serial: bcm2835: add binding documentation for bcm2835-aux-uart kernel at martin.sperl.org 2016-01-20 16:51 ` Rob Herring @ 2016-01-28 22:25 ` Eric Anholt 1 sibling, 0 replies; 9+ messages in thread From: Eric Anholt @ 2016-01-28 22:25 UTC (permalink / raw) To: linux-arm-kernel kernel at martin.sperl.org writes: > From: Martin Sperl <kernel@martin.sperl.org> > > Add binding documentation for the bcm2835-aux-uart driver. > > Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Acked-by: Eric Anholt <eric@anholt.net> -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 818 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160128/f3b737d0/attachment.sig> ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH V3 3/4] serial: bcm2835: add driver for bcm2835-aux-uart 2016-01-17 12:15 [PATCH V3 0/4] serial: bcm2835: add bcm2835 auxiliar uart driver kernel at martin.sperl.org 2016-01-17 12:15 ` [PATCH V3 1/4] ARM: bcm2835: follow dt uart node-naming convention kernel at martin.sperl.org 2016-01-17 12:15 ` [PATCH V3 2/4] dt/bindings: serial: bcm2835: add binding documentation for bcm2835-aux-uart kernel at martin.sperl.org @ 2016-01-17 12:15 ` kernel at martin.sperl.org 2016-01-28 22:34 ` Eric Anholt 2016-01-17 12:15 ` [PATCH V3 4/4] ARM: bcm2835: add bcm2835-aux-uart support to default DT kernel at martin.sperl.org 3 siblings, 1 reply; 9+ messages in thread From: kernel at martin.sperl.org @ 2016-01-17 12:15 UTC (permalink / raw) To: linux-arm-kernel From: Martin Sperl <kernel@martin.sperl.org> The bcm2835 SOC contains an auxiliary uart, which is very close to the ns16550 with some differences. The big difference is that the uart HW is not using an internal divider of 16 but 8, which results in an effictive baud-rate being twice the requested baud-rate. This driver handles this device correctly and handles the difference in the HW divider by scaling up the clock by a factor of 2. The approach to write a separate (wrapper) driver instead of using a multiplying clock and "ns16550" as compatibility in the device-tree has been recommended by Stephen Warren. Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Changelog: V1->V2: made an explicit bcm2835-aux-uart driver not conrolling the settings via DT only V2->V3: added comments on UART capabilities applied recommendations by Stefan Wahren keep registered line-id in bcm2835aux_data --- drivers/tty/serial/8250/8250_bcm2835aux.c | 146 +++++++++++++++++++++++++++++ drivers/tty/serial/8250/Kconfig | 24 +++++ drivers/tty/serial/8250/Makefile | 1 + 3 files changed, 171 insertions(+) create mode 100644 drivers/tty/serial/8250/8250_bcm2835aux.c diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial/8250/8250_bcm2835aux.c new file mode 100644 index 0000000..ecf89f1 --- /dev/null +++ b/drivers/tty/serial/8250/8250_bcm2835aux.c @@ -0,0 +1,146 @@ +/* + * Serial port driver for BCM2835AUX UART + * + * Copyright (C) 2016 Martin Sperl <kernel@martin.sperl.org> + * + * Based on 8250_lpc18xx.c: + * Copyright (C) 2015 Joachim Eastwood <manabian@gmail.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#include <linux/clk.h> +#include <linux/io.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/platform_device.h> + +#include "8250.h" + +struct bcm2835aux_data { + struct uart_8250_port uart; + struct clk *clk; + int line; +}; + +static int bcm2835aux_serial_probe(struct platform_device *pdev) +{ + struct bcm2835aux_data *data; + struct resource *res; + int ret; + + /* allocate the custom structure */ + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + /* initialize data */ + spin_lock_init(&data->uart.port.lock); + data->uart.capabilities = UART_CAP_FIFO; + data->uart.port.dev = &pdev->dev; + data->uart.port.regshift = 2; + data->uart.port.type = PORT_16550; + data->uart.port.iotype = UPIO_MEM; + data->uart.port.fifosize = 8; + data->uart.port.flags = UPF_SHARE_IRQ | + UPF_FIXED_PORT | + UPF_FIXED_TYPE | + UPF_SKIP_TEST; + + /* get the clock - this also enables the HW */ + data->clk = devm_clk_get(&pdev->dev, NULL); + ret = PTR_ERR_OR_ZERO(data->clk); + if (ret) { + dev_err(&pdev->dev, "could not get clk: %d\n", ret); + return ret; + } + + /* get the interrupt */ + data->uart.port.irq = platform_get_irq(pdev, 0); + if (data->uart.port.irq < 0) { + dev_err(&pdev->dev, "irq not found - %i", + data->uart.port.irq); + return data->uart.port.irq; + } + + /* map the main registers */ + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(&pdev->dev, "memory resource not found"); + return -EINVAL; + } + data->uart.port.membase = devm_ioremap_resource(&pdev->dev, res); + ret = PTR_ERR_OR_ZERO(data->uart.port.membase); + if (ret) + return ret; + + /* Check for a fixed line number */ + ret = of_alias_get_id(pdev->dev.of_node, "serial"); + if (ret >= 0) + data->uart.port.line = ret; + + /* enable the clock as a last step */ + ret = clk_prepare_enable(data->clk); + if (ret) { + dev_err(&pdev->dev, "unable to enable uart clock - %d\n", + ret); + return ret; + } + + /* the HW-clock divider for bcm2835aux is 8, + * but 8250 expects a divider of 16, + * so we have to multiply the actual clock by 2 + * to get identical baudrates. + */ + data->uart.port.uartclk = clk_get_rate(data->clk) * 2; + + /* register the port */ + ret = serial8250_register_8250_port(&data->uart); + if (ret < 0) { + dev_err(&pdev->dev, "unable to register 8250 port - %d\n", + ret); + goto dis_clk; + } + data->line = ret; + + platform_set_drvdata(pdev, data); + + return 0; + +dis_clk: + clk_disable_unprepare(data->clk); + return ret; +} + +static int bcm2835aux_serial_remove(struct platform_device *pdev) +{ + struct bcm2835aux_data *data = platform_get_drvdata(pdev); + + serial8250_unregister_port(data->uart.port.line); + clk_disable_unprepare(data->clk); + + return 0; +} + +static const struct of_device_id bcm2835aux_serial_match[] = { + { .compatible = "brcm,bcm2835-aux-uart" }, + { }, +}; +MODULE_DEVICE_TABLE(of, bcm2835aux_serial_match); + +static struct platform_driver bcm2835aux_serial_driver = { + .driver = { + .name = "bcm2835-aux-uart", + .of_match_table = bcm2835aux_serial_match, + }, + .probe = bcm2835aux_serial_probe, + .remove = bcm2835aux_serial_remove, +}; +module_platform_driver(bcm2835aux_serial_driver); + +MODULE_DESCRIPTION("BCM2835 auxiliar UART driver"); +MODULE_AUTHOR("Martin Sperl <kernel@martin.sperl.org>"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig index 6412f14..b0a9b57 100644 --- a/drivers/tty/serial/8250/Kconfig +++ b/drivers/tty/serial/8250/Kconfig @@ -272,6 +272,30 @@ config SERIAL_8250_ACORN system, say Y to this option. The driver can handle 1, 2, or 3 port cards. If unsure, say N. +config SERIAL_8250_BCM2835AUX + tristate "BCM2835 auxiliar mini UART support" + depends on ARCH_BCM2835 || COMPILE_TEST + depends on SERIAL_8250 && SERIAL_8250_SHARE_IRQ + help + Support for the BCM2835 auxiliar mini UART. + + Features and limitations of the UART are + Registers are similar to 16650 registers, + set bits in the control registers that are unsupported + are ignored and read back as 0 + 7/8 bit operation with 1 start and 1 stop bit + 8 symbols deep fifo for rx and tx + SW controlled RTS and SW readable CTS + Clock rate derived from system clock + Uses 8 times oversampling (compared to 16 times for 16650) + Missing break detection (but break generation) + Missing framing error detection + Missing parity bit + Missing receive time-out interrupt + Missing DCD, DSR, DTR and RI signals + + If unsure, say N. + config SERIAL_8250_FSL bool depends on SERIAL_8250_CONSOLE diff --git a/drivers/tty/serial/8250/Makefile b/drivers/tty/serial/8250/Makefile index e177f86..6327d0a 100644 --- a/drivers/tty/serial/8250/Makefile +++ b/drivers/tty/serial/8250/Makefile @@ -12,6 +12,7 @@ obj-$(CONFIG_SERIAL_8250_PCI) += 8250_pci.o obj-$(CONFIG_SERIAL_8250_HP300) += 8250_hp300.o obj-$(CONFIG_SERIAL_8250_CS) += serial_cs.o obj-$(CONFIG_SERIAL_8250_ACORN) += 8250_acorn.o +obj-$(CONFIG_SERIAL_8250_BCM2835AUX) += 8250_bcm2835aux.o obj-$(CONFIG_SERIAL_8250_CONSOLE) += 8250_early.o obj-$(CONFIG_SERIAL_8250_FOURPORT) += 8250_fourport.o obj-$(CONFIG_SERIAL_8250_ACCENT) += 8250_accent.o -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH V3 3/4] serial: bcm2835: add driver for bcm2835-aux-uart 2016-01-17 12:15 ` [PATCH V3 3/4] serial: bcm2835: add driver " kernel at martin.sperl.org @ 2016-01-28 22:34 ` Eric Anholt 0 siblings, 0 replies; 9+ messages in thread From: Eric Anholt @ 2016-01-28 22:34 UTC (permalink / raw) To: linux-arm-kernel kernel at martin.sperl.org writes: > From: Martin Sperl <kernel@martin.sperl.org> > > The bcm2835 SOC contains an auxiliary uart, which is very close > to the ns16550 with some differences. > > The big difference is that the uart HW is not using an internal divider > of 16 but 8, which results in an effictive baud-rate being twice > the requested baud-rate. > > This driver handles this device correctly and handles the difference in > the HW divider by scaling up the clock by a factor of 2. > > The approach to write a separate (wrapper) driver instead of using a > multiplying clock and "ns16550" as compatibility in the device-tree > has been recommended by Stephen Warren. > > Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Acked-by: Eric Anholt <eric@anholt.net> -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 818 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160128/7a9e510a/attachment.sig> ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH V3 4/4] ARM: bcm2835: add bcm2835-aux-uart support to default DT 2016-01-17 12:15 [PATCH V3 0/4] serial: bcm2835: add bcm2835 auxiliar uart driver kernel at martin.sperl.org ` (2 preceding siblings ...) 2016-01-17 12:15 ` [PATCH V3 3/4] serial: bcm2835: add driver " kernel at martin.sperl.org @ 2016-01-17 12:15 ` kernel at martin.sperl.org 3 siblings, 0 replies; 9+ messages in thread From: kernel at martin.sperl.org @ 2016-01-17 12:15 UTC (permalink / raw) To: linux-arm-kernel From: Martin Sperl <kernel@martin.sperl.org> Add bcm2835-aux-uart support to the default device tree. Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Note that this requires the aux-clock patches to be applied first and it may also conflict with the still pending merge of the rename of bcm2835.dtsi. --- arch/arm/boot/dts/bcm2835.dtsi | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm/boot/dts/bcm2835.dtsi b/arch/arm/boot/dts/bcm2835.dtsi index b37a088..bfd42ae 100644 --- a/arch/arm/boot/dts/bcm2835.dtsi +++ b/arch/arm/boot/dts/bcm2835.dtsi @@ -149,6 +149,13 @@ status = "disabled"; }; + uart1: serial at 7e215040 { + compatible = "brcm,bcm2835-aux-uart"; + reg = <0x7e215040 0x40>; + interrupts = <1 29>; + clocks = <&aux BCM2835_AUX_CLOCK_UART>; + }; + sdhci: sdhci at 7e300000 { compatible = "brcm,bcm2835-sdhci"; reg = <0x7e300000 0x100>; -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-02-03 1:34 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-01-17 12:15 [PATCH V3 0/4] serial: bcm2835: add bcm2835 auxiliar uart driver kernel at martin.sperl.org 2016-01-17 12:15 ` [PATCH V3 1/4] ARM: bcm2835: follow dt uart node-naming convention kernel at martin.sperl.org 2016-02-03 1:34 ` Eric Anholt 2016-01-17 12:15 ` [PATCH V3 2/4] dt/bindings: serial: bcm2835: add binding documentation for bcm2835-aux-uart kernel at martin.sperl.org 2016-01-20 16:51 ` Rob Herring 2016-01-28 22:25 ` Eric Anholt 2016-01-17 12:15 ` [PATCH V3 3/4] serial: bcm2835: add driver " kernel at martin.sperl.org 2016-01-28 22:34 ` Eric Anholt 2016-01-17 12:15 ` [PATCH V3 4/4] ARM: bcm2835: add bcm2835-aux-uart support to default DT kernel at martin.sperl.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).