aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/ar933x_uart.c
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2013-08-29 02:44:01 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-30 17:11:27 -0400
commitdd910d98a2e240443db0090b0ae8a719a4a460f8 (patch)
tree4f149a3230c42b8bb2bdf462b69589a9448cf1c6 /drivers/tty/serial/ar933x_uart.c
parent284301ef7c4e5aad2bcb81be5525e4bfc0ba3e31 (diff)
tty: ar933x_uart: add device tree support and binding documentation
Modify the probe routine to get the port line number from device tree if the 'of_node' is populated in the platform device. The driver can be built as module, thus add an OF specific module device table as well to support module auto loading. This makes it possible to use the driver for AR9330 UART devices specified in device tree. Cc: devicetree@vger.kernel.org Signed-off-by: Gabor Juhos <juhosg@openwrt.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/ar933x_uart.c')
-rw-r--r--drivers/tty/serial/ar933x_uart.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c
index 0437a9e08d58..acd03af7cd52 100644
--- a/drivers/tty/serial/ar933x_uart.c
+++ b/drivers/tty/serial/ar933x_uart.c
@@ -17,6 +17,8 @@
17#include <linux/sysrq.h> 17#include <linux/sysrq.h>
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/of.h>
21#include <linux/of_platform.h>
20#include <linux/tty.h> 22#include <linux/tty.h>
21#include <linux/tty_flip.h> 23#include <linux/tty_flip.h>
22#include <linux/serial_core.h> 24#include <linux/serial_core.h>
@@ -623,13 +625,24 @@ static int ar933x_uart_probe(struct platform_device *pdev)
623 struct uart_port *port; 625 struct uart_port *port;
624 struct resource *mem_res; 626 struct resource *mem_res;
625 struct resource *irq_res; 627 struct resource *irq_res;
628 struct device_node *np;
626 unsigned int baud; 629 unsigned int baud;
627 int id; 630 int id;
628 int ret; 631 int ret;
629 632
630 id = pdev->id; 633 np = pdev->dev.of_node;
631 if (id == -1) 634 if (config_enabled(CONFIG_OF) && np) {
632 id = 0; 635 id = of_alias_get_id(np, "serial");
636 if (id < 0) {
637 dev_err(&pdev->dev, "unable to get alias id, err=%d\n",
638 id);
639 return id;
640 }
641 } else {
642 id = pdev->id;
643 if (id == -1)
644 id = 0;
645 }
633 646
634 if (id > CONFIG_SERIAL_AR933X_NR_UARTS) 647 if (id > CONFIG_SERIAL_AR933X_NR_UARTS)
635 return -EINVAL; 648 return -EINVAL;
@@ -713,12 +726,21 @@ static int ar933x_uart_remove(struct platform_device *pdev)
713 return 0; 726 return 0;
714} 727}
715 728
729#ifdef CONFIG_OF
730static const struct of_device_id ar933x_uart_of_ids[] = {
731 { .compatible = "qca,ar9330-uart" },
732 {},
733};
734MODULE_DEVICE_TABLE(of, ar933x_uart_of_ids);
735#endif
736
716static struct platform_driver ar933x_uart_platform_driver = { 737static struct platform_driver ar933x_uart_platform_driver = {
717 .probe = ar933x_uart_probe, 738 .probe = ar933x_uart_probe,
718 .remove = ar933x_uart_remove, 739 .remove = ar933x_uart_remove,
719 .driver = { 740 .driver = {
720 .name = DRIVER_NAME, 741 .name = DRIVER_NAME,
721 .owner = THIS_MODULE, 742 .owner = THIS_MODULE,
743 .of_match_table = of_match_ptr(ar933x_uart_of_ids),
722 }, 744 },
723}; 745};
724 746