From patchwork Mon Jun 20 11:02:27 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: 2076 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 74D4623F4F for ; Mon, 20 Jun 2011 10:53:09 +0000 (UTC) Received: from mail-vw0-f52.google.com (mail-vw0-f52.google.com [209.85.212.52]) by fiordland.canonical.com (Postfix) with ESMTP id 1E211A18729 for ; Mon, 20 Jun 2011 10:53:09 +0000 (UTC) Received: by vws16 with SMTP id 16so3360445vws.11 for ; Mon, 20 Jun 2011 03:53:08 -0700 (PDT) Received: by 10.52.100.72 with SMTP id ew8mr2101547vdb.247.1308567188392; Mon, 20 Jun 2011 03:53:08 -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.52.183.130 with SMTP id em2cs24127vdc; Mon, 20 Jun 2011 03:53:08 -0700 (PDT) Received: by 10.236.77.135 with SMTP id d7mr318186yhe.326.1308567187911; Mon, 20 Jun 2011 03:53:07 -0700 (PDT) Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by mx.google.com with ESMTP id m3si32440945icx.17.2011.06.20.03.53.07; Mon, 20 Jun 2011 03:53:07 -0700 (PDT) Received-SPF: neutral (google.com: 203.254.224.33 is neither permitted nor denied by best guess record for domain of thomas.abraham@linaro.org) client-ip=203.254.224.33; Authentication-Results: mx.google.com; spf=neutral (google.com: 203.254.224.33 is neither permitted nor denied by best guess record for domain of thomas.abraham@linaro.org) smtp.mail=thomas.abraham@linaro.org Received: from epcpsbgm2.samsung.com (mailout3.samsung.com [203.254.224.33]) by mailout3.samsung.com (Oracle Communications Messaging Exchange Server 7u4-19.01 64bit (built Sep 7 2010)) with ESMTP id <0LN300JC04WB33H0@mailout3.samsung.com> for patches@linaro.org; Mon, 20 Jun 2011 19:53:07 +0900 (KST) X-AuditID: cbfee61b-b7c62ae0000056ed-ce-4dff2693bb62 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (MMPCPMTA) with SMTP id DA.CC.22253.3962FFD4; Mon, 20 Jun 2011 19:53:07 +0900 (KST) Received: from localhost.localdomain ([107.108.73.37]) by mmp2.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0LN300JSM4W4PB@mmp2.samsung.com> for patches@linaro.org; Mon, 20 Jun 2011 19:53:07 +0900 (KST) Date: Mon, 20 Jun 2011 16:32:27 +0530 From: Thomas Abraham Subject: [PATCH 1/6] serial: samsung: Keep a copy of platform data in driver's private data In-reply-to: <1308567752-13451-1-git-send-email-thomas.abraham@linaro.org> To: devicetree-discuss@lists.ozlabs.org Cc: linaro-dev@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, kgene.kim@samsung.com, ben-linux@fluff.org, patches@linaro.org Message-id: <1308567752-13451-2-git-send-email-thomas.abraham@linaro.org> X-Mailer: git-send-email 1.6.6.rc2 Content-transfer-encoding: 7BIT References: <1308567752-13451-1-git-send-email-thomas.abraham@linaro.org> X-Brightmail-Tracker: AAAAAA== The driver depends on pdev->dev.platform_data to retrive information about the platform data even after the initialization. To add device tree support, this has to be changed in way that the platform data is avialable from driver's private data. This patch adds support for keeping a copy of the plaform data in s3c24xx_uart_info and using it when needed after the initialization. Signed-off-by: Thomas Abraham --- drivers/tty/serial/s5pv210.c | 12 ++++++++++-- drivers/tty/serial/samsung.c | 24 ++++++++++++++++++++---- drivers/tty/serial/samsung.h | 4 +++- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/drivers/tty/serial/s5pv210.c b/drivers/tty/serial/s5pv210.c index d6b2423..3b2021a 100644 --- a/drivers/tty/serial/s5pv210.c +++ b/drivers/tty/serial/s5pv210.c @@ -27,9 +27,13 @@ static int s5pv210_serial_setsource(struct uart_port *port, struct s3c24xx_uart_clksrc *clk) { - struct s3c2410_uartcfg *cfg = port->dev->platform_data; + struct s3c24xx_uart_port *ourport; + struct s3c2410_uartcfg *cfg; unsigned long ucon = rd_regl(port, S3C2410_UCON); + ourport = container_of(port, struct s3c24xx_uart_port, port); + cfg = &ourport->info->cfg; + if ((cfg->clocks_size) == 1) return 0; @@ -50,9 +54,13 @@ static int s5pv210_serial_setsource(struct uart_port *port, static int s5pv210_serial_getsource(struct uart_port *port, struct s3c24xx_uart_clksrc *clk) { - struct s3c2410_uartcfg *cfg = port->dev->platform_data; + struct s3c24xx_uart_port *ourport; + struct s3c2410_uartcfg *cfg; u32 ucon = rd_regl(port, S3C2410_UCON); + ourport = container_of(port, struct s3c24xx_uart_port, port); + cfg = &ourport->info->cfg; + clk->divisor = 1; if ((cfg->clocks_size) == 1) diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c index 7ead421..77d900f 100644 --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c @@ -42,6 +42,7 @@ #include #include #include +#include #include @@ -169,10 +170,13 @@ static inline struct s3c24xx_uart_info *s3c24xx_port_to_info(struct uart_port *p static inline struct s3c2410_uartcfg *s3c24xx_port_to_cfg(struct uart_port *port) { + struct s3c24xx_uart_port *ourport; + if (port->dev == NULL) return NULL; - return (struct s3c2410_uartcfg *)port->dev->platform_data; + ourport = container_of(port, struct s3c24xx_uart_port, port); + return &ourport->info->cfg; } static int s3c24xx_serial_rx_fifocnt(struct s3c24xx_uart_port *ourport, @@ -1053,7 +1057,7 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport, struct platform_device *platdev) { struct uart_port *port = &ourport->port; - struct s3c2410_uartcfg *cfg; + struct s3c2410_uartcfg *cfg = platdev->dev.platform_data; struct resource *res; int ret; @@ -1062,14 +1066,24 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport, if (platdev == NULL) return -ENODEV; - cfg = s3c24xx_dev_to_cfg(&platdev->dev); - if (port->mapbase != 0) return 0; + if (cfg) { + memcpy((void *)&info->cfg, cfg, sizeof(struct s3c2410_uartcfg)); + info->cfg.clocks = kzalloc(sizeof(struct s3c24xx_uart_clksrc) * + cfg->clocks_size, GFP_KERNEL); + if (!info->cfg.clocks) + return -ENOMEM; + memcpy(info->cfg.clocks, cfg->clocks, + sizeof(struct s3c24xx_uart_clksrc) * cfg->clocks_size); + } + + cfg = &info->cfg; if (cfg->hwport > CONFIG_SERIAL_SAMSUNG_UARTS) { printk(KERN_ERR "%s: port %d bigger than %d\n", __func__, cfg->hwport, CONFIG_SERIAL_SAMSUNG_UARTS); + kfree(info->cfg.clocks); return -ERANGE; } @@ -1181,11 +1195,13 @@ EXPORT_SYMBOL_GPL(s3c24xx_serial_probe); int __devexit s3c24xx_serial_remove(struct platform_device *dev) { struct uart_port *port = s3c24xx_dev_to_port(&dev->dev); + struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port); if (port) { s3c24xx_serial_cpufreq_deregister(to_ourport(port)); device_remove_file(&dev->dev, &dev_attr_clock_source); uart_remove_one_port(&s3c24xx_uart_drv, port); + kfree(info->cfg.clocks); } return 0; diff --git a/drivers/tty/serial/samsung.h b/drivers/tty/serial/samsung.h index a69d9a5..4f2f6f5 100644 --- a/drivers/tty/serial/samsung.h +++ b/drivers/tty/serial/samsung.h @@ -24,6 +24,9 @@ struct s3c24xx_uart_info { unsigned int has_divslot:1; + /* copy of platform data */ + struct s3c2410_uartcfg cfg; + /* clock source control */ int (*get_clksrc)(struct uart_port *, struct s3c24xx_uart_clksrc *clk); @@ -56,7 +59,6 @@ struct s3c24xx_uart_port { /* conversion functions */ #define s3c24xx_dev_to_port(__dev) (struct uart_port *)dev_get_drvdata(__dev) -#define s3c24xx_dev_to_cfg(__dev) (struct s3c2410_uartcfg *)((__dev)->platform_data) /* register access controls */