@@ -440,6 +448,7 @@
reg = <0x8006a000 0x2000>;
interrupts = <112 70 71>;
status = "disabled";
+ id = "0";
};
auart1: serial@8006c000 {
@@ -447,6 +456,7 @@
reg = <0x8006c000 0x2000>;
interrupts = <113 72 73>;
status = "disabled";
+ id = "1";
};
auart2: serial@8006e000 {
@@ -454,6 +464,7 @@
reg = <0x8006e000 0x2000>;
interrupts = <114 74 75>;
status = "disabled";
+ id = "2";
};
auart3: serial@80070000 {
@@ -461,6 +472,7 @@
reg = <0x80070000 0x2000>;
interrupts = <115 76 77>;
status = "disabled";
+ id = "3";
};
auart4: serial@80072000 {
@@ -468,6 +480,7 @@
reg = <0x80072000 0x2000>;
interrupts = <116 78 79>;
status = "disabled";
+ id = "4";
};
duart: serial@80074000 {
@@ -33,6 +33,9 @@
#include <linux/delay.h>
#include <linux/io.h>
#include <linux/pinctrl/consumer.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/pinctrl/consumer.h>
#include <asm/cacheflush.h>
@@ -675,6 +678,50 @@ static struct uart_driver auart_driver = {
#endif
};
+static struct of_device_id mxs_auart_dt_ids[] = {
+ { .compatible = "fsl,imx28-auart", },
+ { /* sentinel */ }
+};
+
+
+static int mxs_auart_probe_dt(struct mxs_auart_port *s,
+ struct platform_device *pdev)
+{
+ struct device_node *np = pdev->dev.of_node;
+ const struct of_device_id *of_id =
+ of_match_device(mxs_auart_dt_ids, &pdev->dev);
+ int *ret;
+ int copy;
+
+ if (!np)
+ /* no device tree device */
+ return 1;
+
+ ret = of_get_property(np, "id", NULL);
+ if (ret == NULL) {
+ dev_err(&pdev->dev, "failed to get alias id, errno %d\n", ret);
+ return ret;
+ }
+
+ copy = *ret - 48;
+ s->port.line = copy;
+
+ return 0;
+}
+
+static void mxs_auart_probe_pdev(struct mxs_auart_port *s,
+ struct platform_device *pdev)
+{
+ struct imxuart_platform_data *pdata = pdev->dev.platform_data;
+
+ s->port.line = pdev->id < 0 ? 0 : pdev->id;
+
+ if (!pdata)
+ return;
+}
+
static int __devinit mxs_auart_probe(struct platform_device *pdev)
{
struct mxs_auart_port *s;
@@ -688,6 +735,15 @@ static int __devinit mxs_auart_probe(struct platform_device *pdev)
ret = -ENOMEM;
goto out;
}
+
+ ret = mxs_auart_probe_dt(s, pdev);
+ if (ret > 0)
+ mxs_auart_probe_pdev(s, pdev);
+ else if (ret < 0) {
+ ret - EINVAL;
+ goto out;
+ }
+
pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
if (IS_ERR(pinctrl)) {
@@ -711,7 +767,7 @@ static int __devinit mxs_auart_probe(struct platform_device *pdev)
s->port.membase = ioremap(r->start, resource_size(r));
s->port.ops = &mxs_auart_ops;
s->port.iotype = UPIO_MEM;
- s->port.line = pdev->id < 0 ? 0 : pdev->id;
+
s->port.fifosize = 16;
s->port.uartclk = clk_get_rate(s->clk);
s->port.type = PORT_IMX;