From patchwork Mon Sep 26 19:07:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: thomas.abraham@linaro.org X-Patchwork-Id: 4347 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 E8A7923F57 for ; Mon, 26 Sep 2011 19:07:49 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id CB4ADA18626 for ; Mon, 26 Sep 2011 19:07:49 +0000 (UTC) Received: by mail-fx0-f52.google.com with SMTP id 23so8789249fxe.11 for ; Mon, 26 Sep 2011 12:07:49 -0700 (PDT) Received: by 10.223.63.8 with SMTP id z8mr10958153fah.84.1317064069703; Mon, 26 Sep 2011 12:07:49 -0700 (PDT) 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.3.234 with SMTP id f10cs48430laf; Mon, 26 Sep 2011 12:07:49 -0700 (PDT) Received: by 10.236.181.170 with SMTP id l30mr41730570yhm.126.1317064068421; Mon, 26 Sep 2011 12:07:48 -0700 (PDT) Received: from mailout4.samsung.com (mailout4.samsung.com. [203.254.224.34]) by mx.google.com with ESMTP id o25si16226526yhk.22.2011.09.26.12.07.47; Mon, 26 Sep 2011 12:07:48 -0700 (PDT) Received-SPF: neutral (google.com: 203.254.224.34 is neither permitted nor denied by best guess record for domain of thomas.abraham@linaro.org) client-ip=203.254.224.34; Authentication-Results: mx.google.com; spf=neutral (google.com: 203.254.224.34 is neither permitted nor denied by best guess record for domain of thomas.abraham@linaro.org) smtp.mail=thomas.abraham@linaro.org Received: from epcpsbgm1.samsung.com (mailout4.samsung.com [203.254.224.34]) by mailout4.samsung.com (Oracle Communications Messaging Exchange Server 7u4-19.01 64bit (built Sep 7 2010)) with ESMTP id <0LS500HZL94F7IJ0@mailout4.samsung.com> for patches@linaro.org; Tue, 27 Sep 2011 04:07:46 +0900 (KST) X-AuditID: cbfee61a-b7cf1ae00000208e-92-4e80cd82cd88 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (MMPCPMTA) with SMTP id 34.47.08334.28DC08E4; Tue, 27 Sep 2011 04:07:46 +0900 (KST) Received: from localhost.localdomain ([107.108.73.37]) by mmp2.samsung.com (Oracle Communications Messaging Exchange Server 7u4-19.01 64bit (built Sep 7 2010)) with ESMTPA id <0LS5008Q69489390@mmp2.samsung.com> for patches@linaro.org; Tue, 27 Sep 2011 04:07:46 +0900 (KST) From: Thomas Abraham To: linux-serial@vger.kernel.org, devicetree-discuss@lists.ozlabs.org Cc: linux-arm-kernel@lists.infradead.org, alan@linux.intel.com, grant.likely@secretlab.ca, linux-samsung-soc@vger.kernel.org, kgene.kim@samsung.com, ben-linux@fluff.org, patches@linaro.org Subject: [PATCH 9/9] serial: samsung: add device tree support Date: Tue, 27 Sep 2011 00:37:18 +0530 Message-id: <1317064038-32428-10-git-send-email-thomas.abraham@linaro.org> X-Mailer: git-send-email 1.6.6.rc2 In-reply-to: <1317064038-32428-1-git-send-email-thomas.abraham@linaro.org> References: <1317064038-32428-1-git-send-email-thomas.abraham@linaro.org> X-Brightmail-Tracker: AAAAAA== Add device tree based discovery support for Samsung's uart controller. Cc: Ben Dooks Cc: Grant Likely Signed-off-by: Thomas Abraham --- drivers/tty/serial/samsung.c | 36 ++++++++++++++++++++++++++++++++++-- 1 files changed, 34 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c index 047b3bd..5e07da3 100644 --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c @@ -42,6 +42,7 @@ #include #include #include +#include #include @@ -1163,10 +1164,26 @@ static ssize_t s3c24xx_serial_show_clksrc(struct device *dev, static DEVICE_ATTR(clock_source, S_IRUGO, s3c24xx_serial_show_clksrc, NULL); + /* Device driver serial port probe */ +static const struct of_device_id s3c24xx_uart_dt_match[]; static int probe_index; +static inline struct s3c24xx_serial_drv_data *s3c24xx_get_driver_data( + struct platform_device *pdev) +{ +#ifdef CONFIG_OF + if (pdev->dev.of_node) { + const struct of_device_id *match; + match = of_match_node(s3c24xx_uart_dt_match, pdev->dev.of_node); + return (struct s3c24xx_serial_drv_data *)match->data; + } +#endif + return (struct s3c24xx_serial_drv_data *) + platform_get_device_id(pdev)->driver_data; +} + static int s3c24xx_serial_probe(struct platform_device *pdev) { struct s3c24xx_uart_port *ourport; @@ -1176,8 +1193,11 @@ static int s3c24xx_serial_probe(struct platform_device *pdev) ourport = &s3c24xx_serial_ports[probe_index]; - ourport->drv_data = (struct s3c24xx_serial_drv_data *) - platform_get_device_id(pdev)->driver_data; + ourport->drv_data = s3c24xx_get_driver_data(pdev); + if (!ourport->drv_data) { + dev_err(&pdev->dev, "could not find driver data\n"); + return -ENODEV; + } ourport->info = ourport->drv_data->info; ourport->cfg = (pdev->dev.platform_data) ? @@ -1626,6 +1646,17 @@ static struct platform_device_id s3c24xx_serial_driver_ids[] = { }; MODULE_DEVICE_TABLE(platform, s3c24xx_serial_driver_ids); +#ifdef CONFIG_OF +static const struct of_device_id s3c24xx_uart_dt_match[] = { + { .compatible = "samsung,s5pv310-uart", + .data = &exynos4210_serial_drv_data }, + {}, +}; +MODULE_DEVICE_TABLE(of, s3c24xx_uart_dt_match); +#else +#define s3c24xx_uart_dt_match NULL +#endif + static struct platform_driver samsung_serial_driver = { .probe = s3c24xx_serial_probe, .remove = __devexit_p(s3c24xx_serial_remove), @@ -1634,6 +1665,7 @@ static struct platform_driver samsung_serial_driver = { .name = "samsung-uart", .owner = THIS_MODULE, .pm = SERIAL_SAMSUNG_PM_OPS, + .of_match_table = s3c24xx_uart_dt_match, }, };