From patchwork Wed Jun 11 06:31:57 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: 4333651 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9B3C39F333 for ; Wed, 11 Jun 2014 06:34:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AF329202EB for ; Wed, 11 Jun 2014 06:34:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AD9C6202EC for ; Wed, 11 Jun 2014 06:34:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752544AbaFKGer (ORCPT ); Wed, 11 Jun 2014 02:34:47 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:20645 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752183AbaFKGeo (ORCPT ); Wed, 11 Jun 2014 02:34:44 -0400 Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N6Z00ET1RLUKU00@mailout4.samsung.com>; Wed, 11 Jun 2014 15:34:42 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.123]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id E6.16.24374.288F7935; Wed, 11 Jun 2014 15:34:42 +0900 (KST) X-AuditID: cbfee68d-b7fd46d000005f36-50-5397f882f307 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id EC.98.07139.288F7935; Wed, 11 Jun 2014 15:34:42 +0900 (KST) Received: from chnaveen-ubuntu.sisodomain.com ([107.108.83.161]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N6Z00IC1RLOF9A0@mmp1.samsung.com>; Wed, 11 Jun 2014 15:34:42 +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 Cc: naveenkrishna.ch@gmail.com, broonie@kernel.org, grant.likely@secretlab.ca, jaswinder.singh@linaro.org, kgene.kim@samsung.com, cpgs@samsung.com, devicetree@vger.kernel.org, Javier Martinez Canillas , Doug Anderson , Tomasz Figa Subject: [PATCH 1/2 v3] spi: s3c64xx: use "cs-gpios" from spi node instead of "cs-gpio" Date: Wed, 11 Jun 2014 12:01:57 +0530 Message-id: <1402468318-7342-1-git-send-email-ch.naveen@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIIsWRmVeSWpSXmKPExsWyRsSkWrfpx/RggzXLlC2mPnzCZvHykKbF /CPnWC3OLjvIZvHqzEY2i8mb7jNaHP1dYNG74CqbxabH11gtZpzfx2SxaNt/ZosjUxrZLdbP eM3iwOsxu+Eii8ff59dZPHbOusvusWlVJ5vHnWt72Dw2L6n32L3gM5NH35ZVjB4/X+p4fN4k F8AVxWWTkpqTWZZapG+XwJWx9ssu1oL3ShU9uy+wNTB+lO5i5OSQEDCRmN6+iRXCFpO4cG89 WxcjF4eQwFJGiSMLJ7PDFE08uoYZIrGIUeLjmqdQTj+TxMbHX9lAqtgEzCQOLloN1MHBISJQ JjFvQh1IDbPAbiaJy2efgtUIC0RKXPj1GMxmEVCVeLT9EtgGXgEXiUePfzOB9EoIKEjMmWQD 0ishcIld4s3084wQ9QIS3yYfYoGokZXYdIAZ4jhJiYMrbrBMYBRcwMiwilE0tSC5oD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4uwuK lyV0Tp/jtcG/d9KE7Rl7p7/IU/+evNLqS6LsS937bBPcwk5rblQsDtz7qGNRzn+t7S11PqUB 3AnyXmkfHpT3hh87PXt5xSkLl4u7eIICqsJuyGbuPL/ES2O3g6DUbePmlbrpxcb/orU4Zv6r 8Hko9zRg5k6P60YLav3X3/+/Y3OcEktxRqKhFnNRcSIAKGh9zQEDAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Currently, spi-s3c64xx.c needs "cs-gpio" chip select GPIO to be defined under "controller-data" node under each slave node. &spi_x { cs-gpios <>; ... slave_node { controller-data { cs-gpio = <>; ... }; ... }; ... }; Where as, SPI core and many other drivers uses "cs-gpios" for from device tree node. Hence, make changes in spi-s3c64xx.c driver to make use of "cs-gpios" from SPI node(parent) instead of "cs-gpio" defined in slaves "controller-data"(child) node. Also updates the Device tree Documentation. Signed-off-by: Naveen Krishna Chatradhi Acked-by: Rob Herring Cc: Javier Martinez Canillas Cc: Doug Anderson Cc: Tomasz Figa --- Changes since v2: 1. updated the gpios usage in Documentation 2. use the spi->cs_gpio in the driver, instead of parsing the node again. 3. Corrected error check of the of.node and during gpio_free .../devicetree/bindings/spi/spi-samsung.txt | 8 +++----- drivers/spi/spi-s3c64xx.c | 18 ++++++------------ 2 files changed, 9 insertions(+), 17 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..842b148 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -772,24 +772,19 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata( cs = kzalloc(sizeof(*cs), GFP_KERNEL); if (!cs) { - of_node_put(data_np); 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)) { + if (!gpio_is_valid(spi->cs_gpio)) { dev_err(&spi->dev, "chip select gpio is not specified or invalid\n"); - kfree(cs); - of_node_put(data_np); return ERR_PTR(-EINVAL); } + cs->line = spi->cs_gpio; of_property_read_u32(data_np, "samsung,spi-feedback-delay", &fb_delay); cs->fb_delay = fb_delay; of_node_put(data_np); + return cs; } @@ -828,8 +823,6 @@ static int s3c64xx_spi_setup(struct spi_device *spi) cs->line, err); goto err_gpio_req; } - - spi->cs_gpio = cs->line; } spi_set_ctldata(spi, cs); @@ -884,7 +877,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 (cs->line) + gpio_free(cs->line); spi_set_ctldata(spi, NULL); err_gpio_req: @@ -1077,7 +1071,7 @@ static int s3c64xx_spi_probe(struct platform_device *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)) + if (!of_find_property(pdev->dev.of_node, "cs-gpios", NULL)) sdd->cs_gpio = false; ret = of_alias_get_id(pdev->dev.of_node, "spi");