From: Haojian Zhuang <haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: arnd-r2nGTMty4D4@public.gmane.org,
eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Cc: Haojian Zhuang <haojian.zhuang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
Subject: [PATCH v3 1/6] serial: pxa: add OF support
Date: Wed, 7 Mar 2012 09:42:05 +0800 [thread overview]
Message-ID: <1331084525-4638-1-git-send-email-haojian.zhuang@gmail.com> (raw)
In-Reply-To: <201203061502.08097.arnd-r2nGTMty4D4@public.gmane.org>
From: Haojian Zhuang <haojian.zhuang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
Parse uart device id from alias in DTS file.
Signed-off-by: Haojian Zhuang <haojian.zhuang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
---
drivers/tty/serial/pxa.c | 49 ++++++++++++++++++++++++++++++++++-----------
1 files changed, 37 insertions(+), 12 deletions(-)
diff --git a/drivers/tty/serial/pxa.c b/drivers/tty/serial/pxa.c
index 5c8e3bb..cdf4b2b 100644
--- a/drivers/tty/serial/pxa.c
+++ b/drivers/tty/serial/pxa.c
@@ -36,6 +36,7 @@
#include <linux/circ_buf.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
+#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
@@ -44,6 +45,8 @@
#include <linux/io.h>
#include <linux/slab.h>
+#define PXA_NAME_LEN 8
+
struct uart_pxa_port {
struct uart_port port;
unsigned char ier;
@@ -51,7 +54,7 @@ struct uart_pxa_port {
unsigned char mcr;
unsigned int lsr_break_flag;
struct clk *clk;
- char *name;
+ char name[PXA_NAME_LEN];
};
static inline unsigned int serial_in(struct uart_pxa_port *up, int offset)
@@ -781,6 +784,31 @@ static const struct dev_pm_ops serial_pxa_pm_ops = {
};
#endif
+static struct of_device_id serial_pxa_dt_ids[] = {
+ { .compatible = "mrvl,pxa-uart", },
+ { .compatible = "mrvl,mmp-uart", },
+ {}
+};
+MODULE_DEVICE_TABLE(of, serial_pxa_dt_ids);
+
+static int serial_pxa_probe_dt(struct platform_device *pdev,
+ struct uart_pxa_port *sport)
+{
+ struct device_node *np = pdev->dev.of_node;
+ int ret;
+
+ if (!np)
+ return 1;
+
+ ret = of_alias_get_id(np, "serial");
+ if (ret < 0) {
+ dev_err(&pdev->dev, "failed to get alias id, errno %d\n", ret);
+ return ret;
+ }
+ sport->port.line = ret;
+ return 0;
+}
+
static int serial_pxa_probe(struct platform_device *dev)
{
struct uart_pxa_port *sport;
@@ -808,20 +836,16 @@ static int serial_pxa_probe(struct platform_device *dev)
sport->port.irq = irqres->start;
sport->port.fifosize = 64;
sport->port.ops = &serial_pxa_pops;
- sport->port.line = dev->id;
sport->port.dev = &dev->dev;
sport->port.flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF;
sport->port.uartclk = clk_get_rate(sport->clk);
- switch (dev->id) {
- case 0: sport->name = "FFUART"; break;
- case 1: sport->name = "BTUART"; break;
- case 2: sport->name = "STUART"; break;
- case 3: sport->name = "HWUART"; break;
- default:
- sport->name = "???";
- break;
- }
+ ret = serial_pxa_probe_dt(dev, sport);
+ if (ret > 0)
+ sport->port.line = dev->id;
+ else if (ret < 0)
+ goto err_clk;
+ snprintf(sport->name, PXA_NAME_LEN - 1, "UART%d", sport->port.line + 1);
sport->port.membase = ioremap(mmres->start, resource_size(mmres));
if (!sport->port.membase) {
@@ -829,7 +853,7 @@ static int serial_pxa_probe(struct platform_device *dev)
goto err_clk;
}
- serial_pxa_ports[dev->id] = sport;
+ serial_pxa_ports[sport->port.line] = sport;
uart_add_one_port(&serial_pxa_reg, &sport->port);
platform_set_drvdata(dev, sport);
@@ -866,6 +890,7 @@ static struct platform_driver serial_pxa_driver = {
#ifdef CONFIG_PM
.pm = &serial_pxa_pm_ops,
#endif
+ .of_match_table = serial_pxa_dt_ids,
},
};
--
1.7.5.4
next prev parent reply other threads:[~2012-03-07 1:42 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-05 12:21 [PATCH v2 0/7] ARM: mmp: support OF on pxa168 Haojian Zhuang
[not found] ` <1330950111-30797-1-git-send-email-haojian.zhuang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
2012-03-05 12:21 ` [PATCH v2 1/7] serial: pxa: add OF support Haojian Zhuang
[not found] ` <1330950111-30797-2-git-send-email-haojian.zhuang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
2012-03-05 12:55 ` Arnd Bergmann
[not found] ` <201203051255.37311.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-05 14:03 ` Haojian Zhuang
2012-03-06 2:42 ` [PATCH v3 " Haojian Zhuang
[not found] ` <1331001730-13429-1-git-send-email-haojian.zhuang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
2012-03-06 15:02 ` Arnd Bergmann
[not found] ` <201203061502.08097.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-06 15:04 ` Haojian Zhuang
2012-03-07 1:42 ` Haojian Zhuang [this message]
[not found] ` <1331084525-4638-1-git-send-email-haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-03-07 7:58 ` [PATCH v3 1/6] " Arnd Bergmann
2012-03-09 15:24 ` [PATCH v2 1/7] " Grant Likely
2012-04-03 15:45 ` Grant Likely
2012-03-05 12:21 ` [PATCH v2 2/7] rtc: sa1100: " Haojian Zhuang
2012-03-05 14:41 ` Arnd Bergmann
2012-03-05 12:21 ` [PATCH v2 3/7] i2c: pxa: " Haojian Zhuang
2012-03-05 14:41 ` Arnd Bergmann
2012-03-05 12:21 ` [PATCH v2 4/7] ARM: mmp: enable rtc clk in pxa168 Haojian Zhuang
[not found] ` <1330950111-30797-5-git-send-email-haojian.zhuang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
2012-03-05 14:38 ` Arnd Bergmann
2012-03-05 12:21 ` [PATCH v2 5/7] ARM: mmp: append OF support on pxa168 Haojian Zhuang
[not found] ` <1330950111-30797-6-git-send-email-haojian.zhuang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
2012-03-05 14:37 ` Arnd Bergmann
2012-04-09 1:36 ` Chris Ball
[not found] ` <87y5q5znx8.fsf-2X9k7bc8m7Mdnm+yROfE0A@public.gmane.org>
2012-04-09 1:46 ` Haojian Zhuang
[not found] ` <CAN1soZyXH_fpwOdDESB600MAm0FL_aanhnVKaLke0O+6B_v9dg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-04-09 1:51 ` Chris Ball
[not found] ` <87hawtzn8z.fsf-2X9k7bc8m7Mdnm+yROfE0A@public.gmane.org>
2012-04-09 2:04 ` Haojian Zhuang
2012-04-09 1:43 ` Chris Ball
[not found] ` <87ty0tznlb.fsf-2X9k7bc8m7Mdnm+yROfE0A@public.gmane.org>
2012-04-09 1:47 ` Haojian Zhuang
2012-03-05 12:21 ` [PATCH v2 6/7] ARM: dts: append DTS file of pxa168 Haojian Zhuang
[not found] ` <1330950111-30797-7-git-send-email-haojian.zhuang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
2012-03-05 14:35 ` Arnd Bergmann
2012-03-05 12:21 ` [PATCH v2 7/7] Document: devicetree: add OF documents for arch-mmp Haojian Zhuang
[not found] ` <1330950111-30797-8-git-send-email-haojian.zhuang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
2012-03-05 14:46 ` Arnd Bergmann
2012-03-05 15:07 ` Rob Herring
2012-03-05 15:08 ` Cousson, Benoit
2012-04-02 23:21 ` Mitch Bradley
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=1331084525-4638-1-git-send-email-haojian.zhuang@gmail.com \
--to=haojian.zhuang-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=arnd-r2nGTMty4D4@public.gmane.org \
--cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
--cc=eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=haojian.zhuang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.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).