From patchwork Tue Jun 10 10:08:00 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: 4327491 Return-Path: X-Original-To: patchwork-linux-samsung-soc@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 542C9BEEAA for ; Tue, 10 Jun 2014 10:10:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 68C81202B4 for ; Tue, 10 Jun 2014 10:10:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5558F20295 for ; Tue, 10 Jun 2014 10:10:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752179AbaFJKKt (ORCPT ); Tue, 10 Jun 2014 06:10:49 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:32832 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751611AbaFJKKs (ORCPT ); Tue, 10 Jun 2014 06:10:48 -0400 Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N6Y000YZ6XYRY30@mailout1.samsung.com>; Tue, 10 Jun 2014 19:10:46 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.122]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id E8.81.13369.6A9D6935; Tue, 10 Jun 2014 19:10:46 +0900 (KST) X-AuditID: cbfee690-b7fb56d000003439-6c-5396d9a6e906 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id F7.9F.07139.6A9D6935; Tue, 10 Jun 2014 19:10:46 +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 <0N6Y00CJL6XQ9T80@mmp2.samsung.com>; Tue, 10 Jun 2014 19:10:46 +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 Subject: [PATCH 1/2 v2] spi: s3c64xx: use "cs-gpios" from spi node instead of "cs-gpio" Date: Tue, 10 Jun 2014 15:38:00 +0530 Message-id: <1402394881-31564-2-git-send-email-ch.naveen@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1402394881-31564-1-git-send-email-ch.naveen@samsung.com> References: <1402394881-31564-1-git-send-email-ch.naveen@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRmVeSWpSXmKPExsWyRsSkSnfZzWnBBr/viVhMffiEzeLlIU2L +UfOsVqcXXaQzeLVmY1sFpM33We0OPq7wKJ3wVU2i02Pr7FazDi/j8li0bb/zBZHpjSyO/B4 zG64yOLx9/l1Fo+ds+6ye2xa1cnmcefaHjaPzUvqPXYv+Mzk0bdlFaPHz5c6Hp83yQVwRXHZ pKTmZJalFunbJXBl3FnayVSwWLdixYPzzA2MF1W6GDk5JARMJN5d2sYGYYtJXLi3Hsjm4hAS WMoosfXfV1aYonWXnjBBJKYzShx6+5YZwulnkvi79AsLSBWbgJnEwUWr2bsYOThEBMok5k2o A6lhFpjJJPHx3B2wFcICkRKX3j5iBLFZBFQl7h69wwRi8wq4SqzoOMYI0ishoCAxZ5INSJhT wE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8v Ks1JLT7EmAx01ERmKdHkfGDyyCuJNzQ2MTc1NrU0sTAxsyRNWEmc92CrdaCQQHpiSWp2ampB ahHMFiYOTqkGRua1XYs+r+39b/gtUGpB+1KVzIY21uJfkqGu03w+He/88UxI8213PMt2sWfy d9fcWjdbWZVX9E3Yoqp167TleZd+Sr+m9H3hLseI5ws4CvImJb+9byRze43Kv/39KquNoyYc l/zZ++G5tf+cf30KDV7Rc0Tauz495v9i/97k5I7+fOdiv6lF35RYijMSDbWYi4oTAdEBwJUU AwAA 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 Cc: Javier Martinez Canillas Cc: Doug Anderson Acked-by: Rob Herring --- Changes since v1: 1. fixed a compilation warning thus squashing the other patch into this. 2. Updated device tree description in spi-samsung.txt .../devicetree/bindings/spi/spi-samsung.txt | 8 ++- drivers/spi/spi-s3c64xx.c | 56 ++++++++++++-------- 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/Documentation/devicetree/bindings/spi/spi-samsung.txt b/Documentation/devicetree/bindings/spi/spi-samsung.txt index 86aa061..13bfcb5 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 1 0 3>; 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..4594dde 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -750,47 +750,56 @@ static int s3c64xx_spi_transfer_one(struct spi_master *master, } static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata( - struct spi_device *spi) + struct spi_device *spi, + struct s3c64xx_spi_csinfo *cs) { - struct s3c64xx_spi_csinfo *cs; - struct device_node *slave_np, *data_np = NULL; - struct s3c64xx_spi_driver_data *sdd; + struct device_node *data_np = NULL; u32 fb_delay = 0; - sdd = spi_master_get_devdata(spi->master); - slave_np = spi->dev.of_node; - if (!slave_np) { - dev_err(&spi->dev, "device node not found\n"); + data_np = of_get_child_by_name(spi->dev.of_node, "controller-data"); + if (!data_np) { + dev_err(&spi->dev, "child node 'controller-data' not found\n"); return ERR_PTR(-EINVAL); } - data_np = of_get_child_by_name(slave_np, "controller-data"); - if (!data_np) { - dev_err(&spi->dev, "child node 'controller-data' not found\n"); + of_property_read_u32(data_np, "samsung,spi-feedback-delay", &fb_delay); + cs->fb_delay = fb_delay; + of_node_put(data_np); + + return cs; +} + +static struct s3c64xx_spi_csinfo *s3c64xx_get_cs_gpios(struct spi_device *spi) +{ + struct device_node *parent_np = NULL; + struct s3c64xx_spi_driver_data *sdd; + struct s3c64xx_spi_csinfo *cs; + + parent_np = of_get_parent(spi->dev.of_node); + if (!parent_np) { + dev_err(&spi->dev, "Parent node not found\n"); return ERR_PTR(-EINVAL); } + sdd = spi_master_get_devdata(spi->master); + cs = kzalloc(sizeof(*cs), GFP_KERNEL); if (!cs) { - of_node_put(data_np); + of_node_put(parent_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); + cs->line = of_get_named_gpio(parent_np, "cs-gpios", 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); + of_node_put(parent_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); - return cs; + return s3c64xx_get_slave_ctrldata(spi, cs); } /* @@ -806,9 +815,14 @@ static int s3c64xx_spi_setup(struct spi_device *spi) struct s3c64xx_spi_info *sci; int err; + if (!spi->dev.of_node) { + dev_err(&spi->dev, "device node not found\n"); + return -EINVAL; + } + sdd = spi_master_get_devdata(spi->master); if (!cs && spi->dev.of_node) { - cs = s3c64xx_get_slave_ctrldata(spi); + cs = s3c64xx_get_cs_gpios(spi); spi->controller_data = cs; } @@ -1077,7 +1091,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");