aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/tty/serial/amba-pl011.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 3322023e38aa..05c15ec7bd21 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -52,6 +52,8 @@
52#include <linux/scatterlist.h> 52#include <linux/scatterlist.h>
53#include <linux/delay.h> 53#include <linux/delay.h>
54#include <linux/types.h> 54#include <linux/types.h>
55#include <linux/of.h>
56#include <linux/of_device.h>
55#include <linux/pinctrl/consumer.h> 57#include <linux/pinctrl/consumer.h>
56#include <linux/sizes.h> 58#include <linux/sizes.h>
57 59
@@ -1862,6 +1864,38 @@ static struct uart_driver amba_reg = {
1862 .cons = AMBA_CONSOLE, 1864 .cons = AMBA_CONSOLE,
1863}; 1865};
1864 1866
1867static int pl011_probe_dt_alias(int index, struct device *dev)
1868{
1869 struct device_node *np;
1870 static bool seen_dev_with_alias = false;
1871 static bool seen_dev_without_alias = false;
1872 int ret = index;
1873
1874 if (!IS_ENABLED(CONFIG_OF))
1875 return ret;
1876
1877 np = dev->of_node;
1878 if (!np)
1879 return ret;
1880
1881 ret = of_alias_get_id(np, "serial");
1882 if (IS_ERR_VALUE(ret)) {
1883 seen_dev_without_alias = true;
1884 ret = index;
1885 } else {
1886 seen_dev_with_alias = true;
1887 if (ret >= ARRAY_SIZE(amba_ports) || amba_ports[ret] != NULL) {
1888 dev_warn(dev, "requested serial port %d not available.\n", ret);
1889 ret = index;
1890 }
1891 }
1892
1893 if (seen_dev_with_alias && seen_dev_without_alias)
1894 dev_warn(dev, "aliased and non-aliased serial devices found in device tree. Serial port enumeration may be unpredictable.\n");
1895
1896 return ret;
1897}
1898
1865static int pl011_probe(struct amba_device *dev, const struct amba_id *id) 1899static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
1866{ 1900{
1867 struct uart_amba_port *uap; 1901 struct uart_amba_port *uap;
@@ -1884,6 +1918,8 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
1884 goto out; 1918 goto out;
1885 } 1919 }
1886 1920
1921 i = pl011_probe_dt_alias(i, &dev->dev);
1922
1887 base = ioremap(dev->res.start, resource_size(&dev->res)); 1923 base = ioremap(dev->res.start, resource_size(&dev->res));
1888 if (!base) { 1924 if (!base) {
1889 ret = -ENOMEM; 1925 ret = -ENOMEM;