From patchwork Tue Aug 2 23:08:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Abraham X-Patchwork-Id: 1030232 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p72N9eVN015207 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 2 Aug 2011 23:10:01 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QoO5Z-0003kg-6s; Tue, 02 Aug 2011 23:09:30 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QoO5Y-0002MV-P3; Tue, 02 Aug 2011 23:09:28 +0000 Received: from mail-ww0-f49.google.com ([74.125.82.49]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QoO4x-0002FW-3A for linux-arm-kernel@lists.infradead.org; Tue, 02 Aug 2011 23:08:52 +0000 Received: by wwf22 with SMTP id 22so185603wwf.18 for ; Tue, 02 Aug 2011 16:08:50 -0700 (PDT) Received: by 10.227.37.17 with SMTP id v17mr1130318wbd.2.1312326529847; Tue, 02 Aug 2011 16:08:49 -0700 (PDT) Received: from localhost.localdomain ([109.234.204.184]) by mx.google.com with ESMTPS id b13sm192251wbh.24.2011.08.02.16.08.48 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 02 Aug 2011 16:08:49 -0700 (PDT) From: Thomas Abraham To: devicetree-discuss@lists.ozlabs.org Subject: [PATCH 2/4] serial: s5pv210: Add device tree support Date: Wed, 3 Aug 2011 00:08:27 +0100 Message-Id: <1312326509-2723-3-git-send-email-thomas.abraham@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1312326509-2723-1-git-send-email-thomas.abraham@linaro.org> References: <1312326509-2723-1-git-send-email-thomas.abraham@linaro.org> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110802_190851_377246_5378C60E X-CRM114-Status: GOOD ( 22.56 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.49 listed in list.dnswl.org] Cc: kgene.kim@samsung.com, Ben Dooks , patches@linaro.org, grant.likely@secretlab.ca, linux-samsung-soc@vger.kernel.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Tue, 02 Aug 2011 23:10:01 +0000 (UTC) For device tree based probe, the dependecy on pdev->id to attach a corresponding default port info to the driver's private data is removed. The fifosize parameter is obtained from the device tree node and the next available instance of port info is updated with the fifosize value and attached to the driver's private data. The default platform data is selected based on the compatible property. CC: Ben Dooks Signed-off-by: Thomas Abraham --- .../devicetree/bindings/serial/samsung_uart.txt | 16 +++++++ drivers/tty/serial/s5pv210.c | 43 +++++++++++++++++++- drivers/tty/serial/samsung.c | 5 ++- 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/serial/samsung_uart.txt diff --git a/Documentation/devicetree/bindings/serial/samsung_uart.txt b/Documentation/devicetree/bindings/serial/samsung_uart.txt new file mode 100644 index 0000000..9174499 --- /dev/null +++ b/Documentation/devicetree/bindings/serial/samsung_uart.txt @@ -0,0 +1,16 @@ +* Samsung's UART Controller + +The Samsung's UART controller is used for serial communications on all of +Samsung's s3c24xx, s3c64xx and s5p series application processors. + +Required properties: +- compatible: should be specific to the application processor + - "samsung,s5pv310-uart" , for Exynos4 processors. + +- reg: base physical address of the controller and length of memory mapped + region. + +- interrupts : Three interrupt numbers should be specified in the following + order - Rx interrupt, Tx interrupt, Error Interrupt. + +- samsung,uart-fifosize: Size of the tx/rx fifo used in the controller. diff --git a/drivers/tty/serial/s5pv210.c b/drivers/tty/serial/s5pv210.c index fb0806c..a44b599 100644 --- a/drivers/tty/serial/s5pv210.c +++ b/drivers/tty/serial/s5pv210.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -132,10 +133,49 @@ static struct s3c24xx_uart_info *s5p_uart_inf[] = { [3] = &s5p_port_fifo16, }; +#ifdef CONFIG_OF +static struct s3c2410_uartcfg s5pv310_uart_defcfg = { + .ucon = 0x3c5, + .ufcon = 0x111, + .flags = NO_NEED_CHECK_CLKSRC, + .has_fracval = 1, +}; + +static const struct of_device_id s5pv210_uart_dt_match[] = { + { .compatible = "samsung,s5pv310-uart", .data = &s5pv310_uart_defcfg }, + {}, +}; +MODULE_DEVICE_TABLE(of, s5pv210_uart_match); +#else +#define s5pv210_uart_match NULL +#endif + /* device management */ static int s5p_serial_probe(struct platform_device *pdev) { - return s3c24xx_serial_probe(pdev, s5p_uart_inf[pdev->id]); + static unsigned int probe_index; + unsigned int port = pdev->id; + const struct of_device_id *match; + struct s3c2410_uartcfg *cfg; + + if (pdev->dev.of_node) { + if (of_property_read_u32(pdev->dev.of_node, + "samsung,uart-fifosize", + &s5p_uart_inf[probe_index]->fifosize)) + return -EINVAL; + + cfg = devm_kzalloc(&pdev->dev, sizeof(*cfg), GFP_KERNEL); + if (!cfg) + return -ENOMEM; + + match = of_match_node(s5pv210_uart_dt_match, pdev->dev.of_node); + *cfg = *((struct s3c2410_uartcfg *)match->data); + s5p_uart_inf[probe_index]->cfg = cfg; + cfg->hwport = probe_index; + port = probe_index++; + } + + return s3c24xx_serial_probe(pdev, s5p_uart_inf[port]); } static struct platform_driver s5p_serial_driver = { @@ -144,6 +184,7 @@ static struct platform_driver s5p_serial_driver = { .driver = { .name = "s5pv210-uart", .owner = THIS_MODULE, + .of_match_table = s5pv210_uart_dt_match, }, }; diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c index 47fee73..49ba4a5a 100644 --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c @@ -1070,10 +1070,13 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport, /* * If platform data is supplied, keep a copy of the location of - * platform data in the driver's private data. + * platform data in the driver's private data. In case of device tree + * based probe, the location of platform data is already set. */ if (cfg) info->cfg = cfg; + else + cfg = info->cfg; if (cfg->hwport > CONFIG_SERIAL_SAMSUNG_UARTS) { printk(KERN_ERR "%s: port %d bigger than %d\n", __func__,