diff options
Diffstat (limited to 'drivers/tty/serial/omap-serial.c')
-rw-r--r-- | drivers/tty/serial/omap-serial.c | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index c5b545f19a16..ca24ab37d11c 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/serial_core.h> | 38 | #include <linux/serial_core.h> |
39 | #include <linux/irq.h> | 39 | #include <linux/irq.h> |
40 | #include <linux/pm_runtime.h> | 40 | #include <linux/pm_runtime.h> |
41 | #include <linux/of.h> | ||
41 | 42 | ||
42 | #include <plat/dma.h> | 43 | #include <plat/dma.h> |
43 | #include <plat/dmtimer.h> | 44 | #include <plat/dmtimer.h> |
@@ -1325,6 +1326,19 @@ static void uart_tx_dma_callback(int lch, u16 ch_status, void *data) | |||
1325 | return; | 1326 | return; |
1326 | } | 1327 | } |
1327 | 1328 | ||
1329 | static struct omap_uart_port_info *of_get_uart_port_info(struct device *dev) | ||
1330 | { | ||
1331 | struct omap_uart_port_info *omap_up_info; | ||
1332 | |||
1333 | omap_up_info = devm_kzalloc(dev, sizeof(*omap_up_info), GFP_KERNEL); | ||
1334 | if (!omap_up_info) | ||
1335 | return NULL; /* out of memory */ | ||
1336 | |||
1337 | of_property_read_u32(dev->of_node, "clock-frequency", | ||
1338 | &omap_up_info->uartclk); | ||
1339 | return omap_up_info; | ||
1340 | } | ||
1341 | |||
1328 | static int serial_omap_probe(struct platform_device *pdev) | 1342 | static int serial_omap_probe(struct platform_device *pdev) |
1329 | { | 1343 | { |
1330 | struct uart_omap_port *up; | 1344 | struct uart_omap_port *up; |
@@ -1332,6 +1346,9 @@ static int serial_omap_probe(struct platform_device *pdev) | |||
1332 | struct omap_uart_port_info *omap_up_info = pdev->dev.platform_data; | 1346 | struct omap_uart_port_info *omap_up_info = pdev->dev.platform_data; |
1333 | int ret = -ENOSPC; | 1347 | int ret = -ENOSPC; |
1334 | 1348 | ||
1349 | if (pdev->dev.of_node) | ||
1350 | omap_up_info = of_get_uart_port_info(&pdev->dev); | ||
1351 | |||
1335 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1352 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1336 | if (!mem) { | 1353 | if (!mem) { |
1337 | dev_err(&pdev->dev, "no mem resource?\n"); | 1354 | dev_err(&pdev->dev, "no mem resource?\n"); |
@@ -1376,9 +1393,20 @@ static int serial_omap_probe(struct platform_device *pdev) | |||
1376 | up->port.regshift = 2; | 1393 | up->port.regshift = 2; |
1377 | up->port.fifosize = 64; | 1394 | up->port.fifosize = 64; |
1378 | up->port.ops = &serial_omap_pops; | 1395 | up->port.ops = &serial_omap_pops; |
1379 | up->port.line = pdev->id; | ||
1380 | sprintf(up->name, "OMAP UART%d", up->port.line); | ||
1381 | 1396 | ||
1397 | if (pdev->dev.of_node) | ||
1398 | up->port.line = of_alias_get_id(pdev->dev.of_node, "serial"); | ||
1399 | else | ||
1400 | up->port.line = pdev->id; | ||
1401 | |||
1402 | if (up->port.line < 0) { | ||
1403 | dev_err(&pdev->dev, "failed to get alias/pdev id, errno %d\n", | ||
1404 | up->port.line); | ||
1405 | ret = -ENODEV; | ||
1406 | goto err; | ||
1407 | } | ||
1408 | |||
1409 | sprintf(up->name, "OMAP UART%d", up->port.line); | ||
1382 | up->port.mapbase = mem->start; | 1410 | up->port.mapbase = mem->start; |
1383 | up->port.membase = ioremap(mem->start, resource_size(mem)); | 1411 | up->port.membase = ioremap(mem->start, resource_size(mem)); |
1384 | if (!up->port.membase) { | 1412 | if (!up->port.membase) { |
@@ -1531,7 +1559,7 @@ static int serial_omap_runtime_suspend(struct device *dev) | |||
1531 | if (!up) | 1559 | if (!up) |
1532 | return -EINVAL; | 1560 | return -EINVAL; |
1533 | 1561 | ||
1534 | if (!pdata->enable_wakeup) | 1562 | if (!pdata || !pdata->enable_wakeup) |
1535 | return 0; | 1563 | return 0; |
1536 | 1564 | ||
1537 | if (pdata->get_context_loss_count) | 1565 | if (pdata->get_context_loss_count) |
@@ -1592,12 +1620,23 @@ static const struct dev_pm_ops serial_omap_dev_pm_ops = { | |||
1592 | serial_omap_runtime_resume, NULL) | 1620 | serial_omap_runtime_resume, NULL) |
1593 | }; | 1621 | }; |
1594 | 1622 | ||
1623 | #if defined(CONFIG_OF) | ||
1624 | static const struct of_device_id omap_serial_of_match[] = { | ||
1625 | { .compatible = "ti,omap2-uart" }, | ||
1626 | { .compatible = "ti,omap3-uart" }, | ||
1627 | { .compatible = "ti,omap4-uart" }, | ||
1628 | {}, | ||
1629 | }; | ||
1630 | MODULE_DEVICE_TABLE(of, omap_serial_of_match); | ||
1631 | #endif | ||
1632 | |||
1595 | static struct platform_driver serial_omap_driver = { | 1633 | static struct platform_driver serial_omap_driver = { |
1596 | .probe = serial_omap_probe, | 1634 | .probe = serial_omap_probe, |
1597 | .remove = serial_omap_remove, | 1635 | .remove = serial_omap_remove, |
1598 | .driver = { | 1636 | .driver = { |
1599 | .name = DRIVER_NAME, | 1637 | .name = DRIVER_NAME, |
1600 | .pm = &serial_omap_dev_pm_ops, | 1638 | .pm = &serial_omap_dev_pm_ops, |
1639 | .of_match_table = of_match_ptr(omap_serial_of_match), | ||
1601 | }, | 1640 | }, |
1602 | }; | 1641 | }; |
1603 | 1642 | ||