From patchwork Tue Nov 22 13:44:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajendra Nayak X-Patchwork-Id: 5280 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id B7C8324016 for ; Tue, 22 Nov 2011 13:44:53 +0000 (UTC) Received: from mail-qw0-f52.google.com (mail-qw0-f52.google.com [209.85.216.52]) by fiordland.canonical.com (Postfix) with ESMTP id 71E0AA1870E for ; Tue, 22 Nov 2011 13:44:53 +0000 (UTC) Received: by qadz3 with SMTP id z3so282810qad.11 for ; Tue, 22 Nov 2011 05:44:53 -0800 (PST) Received: by 10.152.144.136 with SMTP id sm8mr11921378lab.33.1321969492203; Tue, 22 Nov 2011 05:44:52 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.41.198 with SMTP id h6cs178272lal; Tue, 22 Nov 2011 05:44:51 -0800 (PST) Received: by 10.236.195.36 with SMTP id o24mr26905800yhn.57.1321969488854; Tue, 22 Nov 2011 05:44:48 -0800 (PST) Received: from devils.ext.ti.com (devils.ext.ti.com. [198.47.26.153]) by mx.google.com with ESMTPS id r14si1870057anl.130.2011.11.22.05.44.48 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 22 Nov 2011 05:44:48 -0800 (PST) Received-SPF: pass (google.com: domain of rnayak@ti.com designates 198.47.26.153 as permitted sender) client-ip=198.47.26.153; Authentication-Results: mx.google.com; spf=pass (google.com: domain of rnayak@ti.com designates 198.47.26.153 as permitted sender) smtp.mail=rnayak@ti.com Received: from dbdp20.itg.ti.com ([172.24.170.38]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id pAMDiiE3003766 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 22 Nov 2011 07:44:46 -0600 Received: from DBDE70.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id pAMDievN025281; Tue, 22 Nov 2011 19:14:43 +0530 (IST) Received: from dbdp31.itg.ti.com (172.24.170.98) by dbde70.ent.ti.com (172.24.170.148) with Microsoft SMTP Server id 14.1.323.3; Tue, 22 Nov 2011 19:14:42 +0530 Received: from ula0131687.apr.dhcp.ti.com (ula0131687-172024137230.apr.dhcp.ti.com [172.24.137.230]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id pAMDiZ12000926; Tue, 22 Nov 2011 19:14:42 +0530 (IST) From: Rajendra Nayak To: , , CC: , , , , , , , , Rajendra Nayak Subject: [PATCH v2 3/4] omap-serial: Add minimal device tree support Date: Tue, 22 Nov 2011 19:14:15 +0530 Message-ID: <1321969456-24266-4-git-send-email-rnayak@ti.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1321969456-24266-1-git-send-email-rnayak@ti.com> References: <1321969456-24266-1-git-send-email-rnayak@ti.com> MIME-Version: 1.0 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/smaridle bits and handling remote wakeup and dynamic muxing. Signed-off-by: Rajendra Nayak Acked-by: Rob Herring --- .../devicetree/bindings/serial/omap_serial.txt | 10 ++++ drivers/tty/serial/omap-serial.c | 45 ++++++++++++++++++- 2 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/serial/omap_serial.txt diff --git a/Documentation/devicetree/bindings/serial/omap_serial.txt b/Documentation/devicetree/bindings/serial/omap_serial.txt new file mode 100644 index 0000000..342eedd --- /dev/null +++ b/Documentation/devicetree/bindings/serial/omap_serial.txt @@ -0,0 +1,10 @@ +OMAP UART controller + +Required properties: +- compatible : should be "ti,omap2-uart" for OMAP2 controllers +- compatible : should be "ti,omap3-uart" for OMAP3 controllers +- compatible : should be "ti,omap4-uart" for OMAP4 controllers +- ti,hwmods : Must be "uart", n being the instance number (1-based) + +Optional properties: +- clock-frequency : frequency of the clock input to the UART diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index f14b9c5..5aa524e 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -1324,6 +1325,19 @@ static void uart_tx_dma_callback(int lch, u16 ch_status, void *data) return; } +static struct omap_uart_port_info *of_get_uart_port_info(struct device *dev) +{ + struct omap_uart_port_info *omap_up_info; + + omap_up_info = devm_kzalloc(dev, sizeof(*omap_up_info), GFP_KERNEL); + if (!omap_up_info) + return NULL; /* out of memory */ + + of_property_read_u32(dev->of_node, "clock-frequency", + &omap_up_info->uartclk); + return omap_up_info; +} + static int serial_omap_probe(struct platform_device *pdev) { struct uart_omap_port *up; @@ -1331,6 +1345,9 @@ static int serial_omap_probe(struct platform_device *pdev) struct omap_uart_port_info *omap_up_info = pdev->dev.platform_data; int ret = -ENOSPC; + if (pdev->dev.of_node) + omap_up_info = of_get_uart_port_info(&pdev->dev); + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!mem) { dev_err(&pdev->dev, "no mem resource?\n"); @@ -1375,9 +1392,20 @@ static int serial_omap_probe(struct platform_device *pdev) up->port.regshift = 2; up->port.fifosize = 64; up->port.ops = &serial_omap_pops; - up->port.line = pdev->id; - sprintf(up->name, "OMAP UART%d", up->port.line); + if (pdev->dev.of_node) + up->port.line = of_alias_get_id(pdev->dev.of_node, "serial"); + else + up->port.line = pdev->id; + + if (up->port.line < 0) { + dev_err(&pdev->dev, "failed to get alias/pdev id, errno %d\n", + up->port.line); + ret = -ENODEV; + goto err; + } + + sprintf(up->name, "OMAP UART%d", up->port.line); up->port.mapbase = mem->start; up->port.membase = ioremap(mem->start, resource_size(mem)); if (!up->port.membase) { @@ -1530,7 +1558,7 @@ static int serial_omap_runtime_suspend(struct device *dev) if (!up) return -EINVAL; - if (!pdata->enable_wakeup) + if (!pdata || !pdata->enable_wakeup) return 0; if (pdata->get_context_loss_count) @@ -1591,12 +1619,23 @@ static const struct dev_pm_ops serial_omap_dev_pm_ops = { serial_omap_runtime_resume, NULL) }; +#if defined(CONFIG_OF) +static const struct of_device_id omap_serial_of_match[] = { + { .compatible = "ti,omap2-uart" }, + { .compatible = "ti,omap3-uart" }, + { .compatible = "ti,omap4-uart" }, + {}, +}; +MODULE_DEVICE_TABLE(of, omap_serial_of_match); +#endif + static struct platform_driver serial_omap_driver = { .probe = serial_omap_probe, .remove = serial_omap_remove, .driver = { .name = DRIVER_NAME, .pm = &serial_omap_dev_pm_ops, + .of_match_table = of_match_ptr(omap_serial_of_match), }, };