Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

omap-serial: Add minimal device tree support

Adapt the driver to device tree and pass minimal platform
data from device tree needed for console boot.
No power management features will be suppported for now
since it requires more tweaks around OCP settings
to toggle forceidle/noidle/smartidle bits and handling
remote wakeup and dynamic muxing.

Signed-off-by: Rajendra Nayak <rnayak@ti.com>
Reviewed-by: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>

authored by

Rajendra Nayak and committed by
Tony Lindgren
d92b0dfc 8fe789dc

+52 -3
+10
Documentation/devicetree/bindings/serial/omap_serial.txt
··· 1 + OMAP UART controller 2 + 3 + Required properties: 4 + - compatible : should be "ti,omap2-uart" for OMAP2 controllers 5 + - compatible : should be "ti,omap3-uart" for OMAP3 controllers 6 + - compatible : should be "ti,omap4-uart" for OMAP4 controllers 7 + - ti,hwmods : Must be "uart<n>", n being the instance number (1-based) 8 + 9 + Optional properties: 10 + - clock-frequency : frequency of the clock input to the UART
+42 -3
drivers/tty/serial/omap-serial.c
··· 38 38 #include <linux/serial_core.h> 39 39 #include <linux/irq.h> 40 40 #include <linux/pm_runtime.h> 41 + #include <linux/of.h> 41 42 42 43 #include <plat/dma.h> 43 44 #include <plat/dmtimer.h> ··· 1326 1325 return; 1327 1326 } 1328 1327 1328 + static struct omap_uart_port_info *of_get_uart_port_info(struct device *dev) 1329 + { 1330 + struct omap_uart_port_info *omap_up_info; 1331 + 1332 + omap_up_info = devm_kzalloc(dev, sizeof(*omap_up_info), GFP_KERNEL); 1333 + if (!omap_up_info) 1334 + return NULL; /* out of memory */ 1335 + 1336 + of_property_read_u32(dev->of_node, "clock-frequency", 1337 + &omap_up_info->uartclk); 1338 + return omap_up_info; 1339 + } 1340 + 1329 1341 static int serial_omap_probe(struct platform_device *pdev) 1330 1342 { 1331 1343 struct uart_omap_port *up; 1332 1344 struct resource *mem, *irq, *dma_tx, *dma_rx; 1333 1345 struct omap_uart_port_info *omap_up_info = pdev->dev.platform_data; 1334 1346 int ret = -ENOSPC; 1347 + 1348 + if (pdev->dev.of_node) 1349 + omap_up_info = of_get_uart_port_info(&pdev->dev); 1335 1350 1336 1351 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1337 1352 if (!mem) { ··· 1393 1376 up->port.regshift = 2; 1394 1377 up->port.fifosize = 64; 1395 1378 up->port.ops = &serial_omap_pops; 1396 - up->port.line = pdev->id; 1397 - sprintf(up->name, "OMAP UART%d", up->port.line); 1398 1379 1380 + if (pdev->dev.of_node) 1381 + up->port.line = of_alias_get_id(pdev->dev.of_node, "serial"); 1382 + else 1383 + up->port.line = pdev->id; 1384 + 1385 + if (up->port.line < 0) { 1386 + dev_err(&pdev->dev, "failed to get alias/pdev id, errno %d\n", 1387 + up->port.line); 1388 + ret = -ENODEV; 1389 + goto err; 1390 + } 1391 + 1392 + sprintf(up->name, "OMAP UART%d", up->port.line); 1399 1393 up->port.mapbase = mem->start; 1400 1394 up->port.membase = ioremap(mem->start, resource_size(mem)); 1401 1395 if (!up->port.membase) { ··· 1559 1531 if (!up) 1560 1532 return -EINVAL; 1561 1533 1562 - if (!pdata->enable_wakeup) 1534 + if (!pdata || !pdata->enable_wakeup) 1563 1535 return 0; 1564 1536 1565 1537 if (pdata->get_context_loss_count) ··· 1620 1592 serial_omap_runtime_resume, NULL) 1621 1593 }; 1622 1594 1595 + #if defined(CONFIG_OF) 1596 + static const struct of_device_id omap_serial_of_match[] = { 1597 + { .compatible = "ti,omap2-uart" }, 1598 + { .compatible = "ti,omap3-uart" }, 1599 + { .compatible = "ti,omap4-uart" }, 1600 + {}, 1601 + }; 1602 + MODULE_DEVICE_TABLE(of, omap_serial_of_match); 1603 + #endif 1604 + 1623 1605 static struct platform_driver serial_omap_driver = { 1624 1606 .probe = serial_omap_probe, 1625 1607 .remove = serial_omap_remove, 1626 1608 .driver = { 1627 1609 .name = DRIVER_NAME, 1628 1610 .pm = &serial_omap_dev_pm_ops, 1611 + .of_match_table = of_match_ptr(omap_serial_of_match), 1629 1612 }, 1630 1613 }; 1631 1614