From patchwork Thu Jun 12 13:13:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Krishna Chatradhi X-Patchwork-Id: 4342001 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 423C8BEEAA for ; Thu, 12 Jun 2014 13:20:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 859C92034C for ; Thu, 12 Jun 2014 13:20:20 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 47B9D2034A for ; Thu, 12 Jun 2014 13:20:19 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wv4tI-000253-O6; Thu, 12 Jun 2014 13:18:04 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wv4tD-0001vr-G4 for linux-arm-kernel@lists.infradead.org; Thu, 12 Jun 2014 13:18:00 +0000 Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N720043U4XBY490@mailout1.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 12 Jun 2014 22:17:35 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.126]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id 13.DF.24374.F68A9935; Thu, 12 Jun 2014 22:17:35 +0900 (KST) X-AuditID: cbfee68d-b7fd46d000005f36-9f-5399a86f21da Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 1D.D0.08203.F68A9935; Thu, 12 Jun 2014 22:17:35 +0900 (KST) Received: from chnaveen-ubuntu.sisodomain.com ([107.108.83.161]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N720043G4V85LA0@mmp2.samsung.com>; Thu, 12 Jun 2014 22:17:35 +0900 (KST) From: Naveen Krishna Chatradhi To: linux-arm-kernel@lists.infradead.org, spi-devel-general@lists.sourceforge.net, linux-samsung-soc@vger.kernel.org Subject: [PATCH 1/3 v4] spi: s3c64xx: fix broken "cs_gpios" usage in the driver Date: Thu, 12 Jun 2014 18:43:39 +0530 Message-id: <1402578821-27338-1-git-send-email-ch.naveen@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnkeLIzCtJLcpLzFFi42JZI2JSp5u/YmawwYPL8hZTHz5hs3h5SNNi /pFzrBZnlx1ks3h1ZiObxeRN9xktjv4usOhdcJXNYtPja6wWM87vY7JYtO0/s8WRKY3sFutn vGZx4PWY3XCRxePv8+ssHjtn3WX32LSqk83jzrU9bB6bl9R77F7wmcmjb8sqRo+fL3U8Pm+S C+CK4rJJSc3JLEst0rdL4MpYPucme8ECo4rlu9qYGxiXaXQxcnBICJhITD2p18XICWSKSVy4 t56ti5GLQ0hgKaPEtvlbmSASJhIzZ/5mgkhMZ5R4eWk9M0hCSKCfSWLWtVgQm03ATOLgotXs IENFBMok5k2oA6lnFtjNJHH57FM2kBphAX+Jv4sOgfWyCKhKfJjVBWbzCrhK7D+5iAniIAWJ OZNsQHolBK6xS2x+9pUVol5A4tvkQywQNbISmw4wQ9wmKXFwxQ2WCYyCCxgZVjGKphYkFxQn pRcZ6hUn5haX5qXrJefnbmIERsbp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9D3C3vbJrg0/968r+okpoXuquKzqbZ3b0azm+91OiEZ+iD 8pjA6k9ZmjHJ88Lu/PFK2rDy9zSb6UsiVBy3tDce7DjvzrFp6+ZrKnniXX4nd06eb1Tw4Gpo mauNa2SGjJZf9uSod1dUFaeEKVfocCmxFGckGmoxFxUnAgAQ+PfuAAMAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140612_061759_713085_0D895CD2 X-CRM114-Status: GOOD ( 19.62 ) X-Spam-Score: -5.7 (-----) Cc: devicetree@vger.kernel.org, kgene.kim@samsung.com, Tomasz Figa , Doug Anderson , grant.likely@secretlab.ca, jaswinder.singh@linaro.org, broonie@kernel.org, cpgs@samsung.com, naveenkrishna.ch@gmail.com, Javier Martinez Canillas X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since, (3146bee spi: s3c64xx: Added provision for dedicated cs pin) spi-s3c64xx.c driver expects 1. chip select gpios from "cs-gpio"(singular) under the "controller-data" node of the client/slave device of the SPI. 2. "cs-gpio"(singular) entry to be present in the SPI device node. Eg of current broken usage: &spi_1 { cs-gpio <>; /* this entry is checked during probe */ ... slave_node { controller-data { cs-gpio <&gpioa2 5 0>; /* This field is parsed during .setup() */ } }; }; The following dts files which were using this driver. But, din't have the "cs-gpio" entry under SPI node. -- arch/arm/boot/dts/exynos4210-smdkv310.dts -- arch/arm/boot/dts/exynos4412-trats2.dts -- arch/arm/boot/dts/exynos5250-smdk5250.dts Also, the SPI core and many drivers moved on to using "cs-gpios" from SPI node and removed the gpio handling code from drivers (including spi-s3c64xx.c). Hence, spi-s3c64xx.c is broken since "Jun 21 11:26:12 2013" and considering the time with no compliants about the breakage. We are assuming it is safe to remove the "cs-gpio"(singular) usage from device tree binding of spi-samsung.txt and makes appropriate changes in the driver to use "cs-gpios"(plural) from SPI device node. Signed-off-by: Naveen Krishna Chatradhi Acked-by: Rob Herring Cc: Javier Martinez Canillas Cc: Doug Anderson Cc: Tomasz Figa Reviewed-by: Javier Martinez Canillas Tested-by: Doug Anderson --- .../devicetree/bindings/spi/spi-samsung.txt | 8 ++-- drivers/spi/spi-s3c64xx.c | 41 ++++++++------------ 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/Documentation/devicetree/bindings/spi/spi-samsung.txt b/Documentation/devicetree/bindings/spi/spi-samsung.txt index 86aa061..2d29dac 100644 --- a/Documentation/devicetree/bindings/spi/spi-samsung.txt +++ b/Documentation/devicetree/bindings/spi/spi-samsung.txt @@ -42,15 +42,13 @@ Optional Board Specific Properties: - num-cs: Specifies the number of chip select lines supported. If not specified, the default number of chip select lines is set to 1. +- cs-gpios: should specify GPIOs used for chipselects (see spi-bus.txt) + SPI Controller specific data in SPI slave nodes: - The spi slave nodes should provide the following information which is required by the spi controller. - - cs-gpio: A gpio specifier that specifies the gpio line used as - the slave select line by the spi controller. The format of the gpio - specifier depends on the gpio controller. - - samsung,spi-feedback-delay: The sampling phase shift to be applied on the miso line (to account for any lag in the miso line). The following are the valid values. @@ -85,6 +83,7 @@ Example: #size-cells = <0>; pinctrl-names = "default"; pinctrl-0 = <&spi0_bus>; + cs-gpios = <&gpa2 5 0>; w25q80bw@0 { #address-cells = <1>; @@ -94,7 +93,6 @@ Example: spi-max-frequency = <10000>; controller-data { - cs-gpio = <&gpa2 5 1 0 3>; samsung,spi-feedback-delay = <0>; }; diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 75a5696..b888c66 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -197,7 +197,6 @@ struct s3c64xx_spi_driver_data { struct s3c64xx_spi_dma_data tx_dma; struct s3c64xx_spi_port_config *port_conf; unsigned int port_id; - bool cs_gpio; }; static void flush_fifo(struct s3c64xx_spi_driver_data *sdd) @@ -776,17 +775,6 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata( return ERR_PTR(-ENOMEM); } - /* The CS line is asserted/deasserted by the gpio pin */ - if (sdd->cs_gpio) - cs->line = of_get_named_gpio(data_np, "cs-gpio", 0); - - if (!gpio_is_valid(cs->line)) { - dev_err(&spi->dev, "chip select gpio is not specified or invalid\n"); - kfree(cs); - of_node_put(data_np); - return ERR_PTR(-EINVAL); - } - of_property_read_u32(data_np, "samsung,spi-feedback-delay", &fb_delay); cs->fb_delay = fb_delay; of_node_put(data_np); @@ -812,6 +800,10 @@ static int s3c64xx_spi_setup(struct spi_device *spi) spi->controller_data = cs; } + /* For the non-DT platforms derive chip selects from controller data */ + if (!spi->dev.of_node) + spi->cs_gpio = cs->line; + if (IS_ERR_OR_NULL(cs)) { dev_err(&spi->dev, "No CS for SPI(%d)\n", spi->chip_select); return -ENODEV; @@ -819,17 +811,19 @@ static int s3c64xx_spi_setup(struct spi_device *spi) if (!spi_get_ctldata(spi)) { /* Request gpio only if cs line is asserted by gpio pins */ - if (sdd->cs_gpio) { - err = gpio_request_one(cs->line, GPIOF_OUT_INIT_HIGH, - dev_name(&spi->dev)); + if (gpio_is_valid(spi->cs_gpio)) { + err = gpio_request_one(spi->cs_gpio, + GPIOF_OUT_INIT_HIGH, + dev_name(&spi->dev)); if (err) { dev_err(&spi->dev, "Failed to get /CS gpio [%d]: %d\n", - cs->line, err); + spi->cs_gpio, err); goto err_gpio_req; } - - spi->cs_gpio = cs->line; + } else { + dev_err(&spi->dev, "chip select gpio is invalid\n"); + return -EINVAL; } spi_set_ctldata(spi, cs); @@ -884,7 +878,8 @@ setup_exit: /* setup() returns with device de-selected */ writel(S3C64XX_SPI_SLAVE_SIG_INACT, sdd->regs + S3C64XX_SPI_SLAVE_SEL); - gpio_free(cs->line); + if (gpio_is_valid(spi->cs_gpio)) + gpio_free(spi->cs_gpio); spi_set_ctldata(spi, NULL); err_gpio_req: @@ -900,10 +895,12 @@ static void s3c64xx_spi_cleanup(struct spi_device *spi) struct s3c64xx_spi_driver_data *sdd; sdd = spi_master_get_devdata(spi->master); - if (spi->cs_gpio) { + if (gpio_is_valid(spi->cs_gpio)) { gpio_free(spi->cs_gpio); if (spi->dev.of_node) kfree(cs); + else + spi->cs_gpio = -ENOENT; } spi_set_ctldata(spi, NULL); } @@ -1075,11 +1072,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) sdd->cntrlr_info = sci; sdd->pdev = pdev; sdd->sfr_start = mem_res->start; - sdd->cs_gpio = true; if (pdev->dev.of_node) { - if (!of_find_property(pdev->dev.of_node, "cs-gpio", NULL)) - sdd->cs_gpio = false; - ret = of_alias_get_id(pdev->dev.of_node, "spi"); if (ret < 0) { dev_err(&pdev->dev, "failed to get alias id, errno %d\n",