From patchwork Tue Jul 26 11:00:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Padmavathi Venna X-Patchwork-Id: 1007042 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6Q59Hnq004573 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 26 Jul 2011 05:09:38 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QlZtC-0003eX-VB; Tue, 26 Jul 2011 05:09:07 +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 1QlZtC-0000Di-J5; Tue, 26 Jul 2011 05:09:06 +0000 Received: from mailout2.samsung.com ([203.254.224.25]) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QlZt7-0000DO-FN for linux-arm-kernel@lists.infradead.org; Tue, 26 Jul 2011 05:09:03 +0000 Received: from epcpsbgm2.samsung.com (mailout2.samsung.com [203.254.224.25]) by mailout2.samsung.com (Oracle Communications Messaging Exchange Server 7u4-19.01 64bit (built Sep 7 2010)) with ESMTP id <0LOX00BIMCXJMKF0@mailout2.samsung.com> for linux-arm-kernel@lists.infradead.org; Tue, 26 Jul 2011 14:08:40 +0900 (KST) X-AuditID: cbfee61b-b7c3dae000002cb8-18-4e2e4bd8d923 Received: from epmmp1 ( [203.254.227.16]) by epcpsbgm2.samsung.com (MMPCPMTA) with SMTP id 85.DD.11448.8DB4E2E4; Tue, 26 Jul 2011 14:08:40 +0900 (KST) Received: from localhost.localdomain ([107.108.73.106]) by mmp1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0LOX006V9CY3ME@mmp1.samsung.com> for linux-arm-kernel@lists.infradead.org; Tue, 26 Jul 2011 14:08:40 +0900 (KST) Date: Tue, 26 Jul 2011 07:00:12 -0400 From: Padmavathi Venna Subject: [RFC][PATCH] spi: s3c64xx: Use clkdev for bus clock lookup To: padma.v@samsung.com, spi-devel-general@lists.sourceforge.net, kgene.kim@samsung.com, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, grant.likely@secretlab.ca, linux@arm.linux.org.uk, jassisinghbrar@gmail.com Message-id: <1311678012-21473-1-git-send-email-padma.v@samsung.com> X-Mailer: git-send-email 1.7.0.4 X-Brightmail-Tracker: AAAAAA== X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110726_010901_808258_26387939 X-CRM114-Status: GOOD ( 18.75 ) X-Spam-Score: -1.1 (-) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-1.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.2 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain 2.4 DATE_IN_FUTURE_03_06 Date: is 3 to 6 hours after Received: date -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [203.254.224.25 listed in list.dnswl.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 (demeter1.kernel.org [140.211.167.41]); Tue, 26 Jul 2011 05:09:38 +0000 (UTC) Create a clkdev alias for spi bus clock and modify the spi driver to lookup the clock using the alias name instead of passing clock name from platform data. Signed-off-by: Padmavathi Venna --- This patch is tested for S5PV210 platform and similar changes can be adopted for rest of the Samsung's s3c and s5p platforms, if this approach is accepted. arch/arm/mach-s5pv210/dev-spi.c | 16 ++++++++++++++-- arch/arm/plat-samsung/include/plat/s3c64xx-spi.h | 2 -- drivers/spi/spi_s3c64xx.c | 13 +++---------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/arch/arm/mach-s5pv210/dev-spi.c b/arch/arm/mach-s5pv210/dev-spi.c index eaf9a7b..44480d1 100644 --- a/arch/arm/mach-s5pv210/dev-spi.c +++ b/arch/arm/mach-s5pv210/dev-spi.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -148,6 +149,9 @@ struct platform_device s5pv210_device_spi1 = { void __init s5pv210_spi_set_info(int cntrlr, int src_clk_nr, int num_cs) { struct s3c64xx_spi_info *pd; + struct device *dev; + char devname[16]; + int ret; /* Reject invalid configuration */ if (!num_cs || src_clk_nr < 0 @@ -159,17 +163,25 @@ void __init s5pv210_spi_set_info(int cntrlr, int src_clk_nr, int num_cs) switch (cntrlr) { case 0: pd = &s5pv210_spi0_pdata; + dev = (src_clk_nr) ? &s5pv210_device_spi0.dev : NULL; break; case 1: pd = &s5pv210_spi1_pdata; + dev = (src_clk_nr) ? &s5pv210_device_spi1.dev : NULL; break; default: printk(KERN_ERR "%s: Invalid SPI controller(%d)\n", __func__, cntrlr); return; } - + sprintf(devname, "s3c64xx-spi.%d", cntrlr); + ret = clk_add_alias("clk_spi_bus", devname, + spi_src_clks[src_clk_nr], dev); + if (0 != ret) { + printk(KERN_ERR "failed to create alias for SPI%d clock", + cntrlr); + return; + } pd->num_cs = num_cs; pd->src_clk_nr = src_clk_nr; - pd->src_clk_name = spi_src_clks[src_clk_nr]; } diff --git a/arch/arm/plat-samsung/include/plat/s3c64xx-spi.h b/arch/arm/plat-samsung/include/plat/s3c64xx-spi.h index 4c16fa3..c3d82a5 100644 --- a/arch/arm/plat-samsung/include/plat/s3c64xx-spi.h +++ b/arch/arm/plat-samsung/include/plat/s3c64xx-spi.h @@ -31,7 +31,6 @@ struct s3c64xx_spi_csinfo { /** * struct s3c64xx_spi_info - SPI Controller defining structure * @src_clk_nr: Clock source index for the CLK_CFG[SPI_CLKSEL] field. - * @src_clk_name: Platform name of the corresponding clock. * @clk_from_cmu: If the SPI clock/prescalar control block is present * by the platform's clock-management-unit and not in SPI controller. * @num_cs: Number of CS this controller emulates. @@ -43,7 +42,6 @@ struct s3c64xx_spi_csinfo { */ struct s3c64xx_spi_info { int src_clk_nr; - char *src_clk_name; bool clk_from_cmu; int num_cs; diff --git a/drivers/spi/spi_s3c64xx.c b/drivers/spi/spi_s3c64xx.c index 8945e20..e5431bd 100644 --- a/drivers/spi/spi_s3c64xx.c +++ b/drivers/spi/spi_s3c64xx.c @@ -978,11 +978,6 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev) } sci = pdev->dev.platform_data; - if (!sci->src_clk_name) { - dev_err(&pdev->dev, - "Board init must call s3c64xx_spi_set_info()\n"); - return -EINVAL; - } /* Check for availability of necessary resource */ @@ -1065,17 +1060,15 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev) goto err4; } - sdd->src_clk = clk_get(&pdev->dev, sci->src_clk_name); + sdd->src_clk = clk_get(&pdev->dev, "clk_spi_bus"); if (IS_ERR(sdd->src_clk)) { - dev_err(&pdev->dev, - "Unable to acquire clock '%s'\n", sci->src_clk_name); + dev_err(&pdev->dev, "Unable to acquire clock 'clk_spi_bus'\n"); ret = PTR_ERR(sdd->src_clk); goto err5; } if (clk_enable(sdd->src_clk)) { - dev_err(&pdev->dev, "Couldn't enable clock '%s'\n", - sci->src_clk_name); + dev_err(&pdev->dev, "Couldn't enable clock 'clk_spi_bus'\n"); ret = -EBUSY; goto err6; }