From: Jonas Gorski <jonas.gorski@gmail.com>
To: linux-mips@linux-mips.org
Cc: Ralf Baechle <ralf@linux-mips.org>,
John Crispin <blogic@openwrt.org>,
Maxime Bizon <mbizon@freebox.fr>,
Florian Fainelli <florian@openwrt.org>,
Kevin Cernekee <cernekee@gmail.com>,
devicetree-discuss@lists.ozlabs.org,
linux-kernel@vger.kernel.org
Subject: [RFC] serial: bcm63xx_uart: allow probing through Device Tree
Date: Sun, 11 Nov 2012 13:50:46 +0100 [thread overview]
Message-ID: <1352638249-29298-13-git-send-email-jonas.gorski@gmail.com> (raw)
In-Reply-To: <1352638249-29298-1-git-send-email-jonas.gorski@gmail.com>
Add support for probing the serial ports through Device Tree.
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
.../bindings/tty/serial/bcm63xx-uart.txt | 17 +++++++++
drivers/tty/serial/bcm63xx_uart.c | 35 ++++++++++++++------
2 files changed, 42 insertions(+), 10 deletions(-)
create mode 100644 Documentation/devicetree/bindings/tty/serial/bcm63xx-uart.txt
diff --git a/Documentation/devicetree/bindings/tty/serial/bcm63xx-uart.txt b/Documentation/devicetree/bindings/tty/serial/bcm63xx-uart.txt
new file mode 100644
index 0000000..7623604
--- /dev/null
+++ b/Documentation/devicetree/bindings/tty/serial/bcm63xx-uart.txt
@@ -0,0 +1,17 @@
+* Broadcom BCM63XX UART
+
+Required properties:
+- compatible: "brcm,bcm63xx-uart"
+ Compatible with all BCM63XX SoCs.
+
+- reg: address and length of the register block.
+
+- interrupts: the uart's interrupt number.
+
+Example:
+
+ uart0: serial@100 {
+ compatible = "brcm,bcm63xx";
+ reg = <0x100 0x18>;
+ interrupts = <2>;
+ };
diff --git a/drivers/tty/serial/bcm63xx_uart.c b/drivers/tty/serial/bcm63xx_uart.c
index 0187aff..4521a52 100644
--- a/drivers/tty/serial/bcm63xx_uart.c
+++ b/drivers/tty/serial/bcm63xx_uart.c
@@ -802,23 +802,32 @@ static struct uart_driver bcm_uart_driver = {
*/
static int __devinit bcm_uart_probe(struct platform_device *pdev)
{
- struct resource *res_mem, *res_irq;
+ struct resource *res_mem;
struct uart_port *port;
struct clk *clk;
- int ret;
+ int ret, irq;
- if (pdev->id < 0 || pdev->id >= BCM63XX_NR_UARTS)
- return -EINVAL;
+ res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res_mem)
+ return -ENODEV;
+
+ if (pdev->id < 0) {
+ void __iomem *membase;
+
+ membase = ioremap(res_mem->start, resource_size(res_mem));
+ if (membase == (void *)bcm63xx_regset_address(RSET_UART0))
+ pdev->id = 0;
+ else
+ pdev->id = 1;
+ iounmap(membase);
+ }
if (ports[pdev->id].membase)
return -EBUSY;
- res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res_mem)
- return -ENODEV;
- res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
- if (!res_irq)
+ irq = platform_get_irq(pdev, 0);
+ if (!irq)
return -ENODEV;
clk = clk_get(&pdev->dev, "periph");
@@ -829,7 +838,7 @@ static int __devinit bcm_uart_probe(struct platform_device *pdev)
memset(port, 0, sizeof(*port));
port->iotype = UPIO_MEM;
port->mapbase = res_mem->start;
- port->irq = res_irq->start;
+ port->irq = irq;
port->ops = &bcm_uart_ops;
port->flags = UPF_BOOT_AUTOCONF;
port->dev = &pdev->dev;
@@ -862,12 +871,18 @@ static int __devexit bcm_uart_remove(struct platform_device *pdev)
/*
* platform driver stuff
*/
+static const struct of_device_id bcm_uart_match[] = {
+ { .compatible = "brcm,bcm63xx-uart" },
+ { },
+};
+
static struct platform_driver bcm_uart_platform_driver = {
.probe = bcm_uart_probe,
.remove = __devexit_p(bcm_uart_remove),
.driver = {
.owner = THIS_MODULE,
.name = "bcm63xx_uart",
+ .of_match_table = bcm_uart_match,
},
};
--
1.7.2.5
next prev parent reply other threads:[~2012-11-11 12:50 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-11 12:50 [RFC] MIPS: BCM63XX: add initial Device Tree support Jonas Gorski
2012-11-11 12:50 ` [RFC] MIPS: BCM63XX: add generic fallback device trees Jonas Gorski
2012-11-11 12:50 ` [RFC] MIPS: BCM63XX: add Device Tree glue code for IRQ handling Jonas Gorski
2012-11-13 5:00 ` Stephen Warren
2012-11-14 12:09 ` Jonas Gorski
2012-11-17 4:13 ` Stephen Warren
2012-11-11 12:50 ` [RFC] net: ethernet: bcm63xx_enet: use clk_{prepare_enable,disable_unprepare} Jonas Gorski
[not found] ` <1352638249-29298-1-git-send-email-jonas.gorski-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-11-11 12:50 ` [RFC] MIPS: BCM63XX: add support for loading DTB Jonas Gorski
2012-11-11 12:50 ` [RFC] MIPS: BCM63XX: add simple Device Tree includes for all SoCs Jonas Gorski
2012-11-13 4:54 ` Stephen Warren
[not found] ` <50A1D290.3050409-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-11-13 17:56 ` David Daney
2012-11-11 12:50 ` [RFC] SPI: spi-bcm63xx: use clk_{prepare_enable,disable_unprepare} Jonas Gorski
2012-11-11 12:50 ` [RFC] bcm63xx-rng: " Jonas Gorski
2012-11-11 12:50 ` [RFC] serial: bcm63xx_uart: remove unnecessary include Jonas Gorski
2012-11-11 12:59 ` [RFC] MIPS: BCM63XX: add initial Device Tree support Jonas Gorski
2012-11-11 12:50 ` [RFC] MIPS: BCM63XX: add Device Tree clock definitions Jonas Gorski
2012-11-13 5:02 ` Stephen Warren
2012-11-14 12:11 ` Jonas Gorski
2012-11-17 4:15 ` Stephen Warren
2012-11-11 12:50 ` [RFC] MIPS: BCM63XX: switch to common clock and Device Tree Jonas Gorski
2012-11-13 5:04 ` Stephen Warren
2012-11-14 12:12 ` Jonas Gorski
2012-11-11 12:50 ` [RFC] MIPS: BCM63XX: register GPIO controller through " Jonas Gorski
2012-11-13 5:06 ` Stephen Warren
2012-11-14 12:13 ` Jonas Gorski
2012-11-11 12:50 ` Jonas Gorski [this message]
2012-11-11 12:50 ` [RFC] MIPS: BCM63XX: add serial blocks to Device Tree includes Jonas Gorski
2012-11-11 12:50 ` [RFC] MIPS: BCM63XX: add empty Device Trees for all supported boards Jonas Gorski
2012-11-13 5:12 ` Stephen Warren
2012-11-14 12:15 ` Jonas Gorski
2012-11-11 12:50 ` [RFC] MIPS: BCM63XX: enable serial through Device Tree Jonas Gorski
[not found] ` <1352638249-29298-16-git-send-email-jonas.gorski-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-11-13 5:13 ` Stephen Warren
[not found] ` <50A1D6ED.50001-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-11-14 12:17 ` Jonas Gorski
2012-11-12 11:18 ` [RFC] MIPS: BCM63XX: add initial Device Tree support Maxime Bizon
2012-11-14 12:07 ` Jonas Gorski
2012-11-14 14:47 ` Maxime Bizon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1352638249-29298-13-git-send-email-jonas.gorski@gmail.com \
--to=jonas.gorski@gmail.com \
--cc=blogic@openwrt.org \
--cc=cernekee@gmail.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=florian@openwrt.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=mbizon@freebox.fr \
--cc=ralf@linux-mips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).