From patchwork Thu Jul 7 09:49:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102036 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1310112qgy; Thu, 7 Jul 2016 02:47:10 -0700 (PDT) X-Received: by 10.98.93.216 with SMTP id n85mr3655070pfj.36.1467884830717; Thu, 07 Jul 2016 02:47:10 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wa12si3373545pac.138.2016.07.07.02.47.10; Thu, 07 Jul 2016 02:47:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751680AbcGGJrK (ORCPT + 1 other); Thu, 7 Jul 2016 05:47:10 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:57731 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751418AbcGGJrI (ORCPT ); Thu, 7 Jul 2016 05:47:08 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0M1GfI-1bahtc28FM-00tClr; Thu, 07 Jul 2016 11:46:36 +0200 From: Arnd Bergmann To: Mark Brown Cc: Alexander Shiyan , linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Arnd Bergmann , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] spi: clps711x: Driver refactor Date: Thu, 7 Jul 2016 11:49:45 +0200 Message-Id: <20160707094952.4111577-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:Uwp7LbyNFMEhMUD3VyakqFcU38zcx4GVBoNY0KDc5A7WLCkLJrS /oQxSQDVgvRPiJEXNJwPtPOXnV+QM8oOD0HzwUeWT2UpURRFGV7eZjVoU6TfhZJgX/ygcm4 cUCoXWFevFP8T0xP+8LB+MD/6CJZGFGHeKubNnH/G3lrDOA6qlTi932BUj25YvA6LmLUiZE 8ptpVDU7KzK/AlJj/zh+g== X-UI-Out-Filterresults: notjunk:1; V01:K0:gV2PysTYNxo=:DDk2mjRhu1ct7WDEmF77GI +memlytiyvIYXzwKmsEtfu/FxsnLOjOktRXML3JCsPXwpTk6mDM8zPD4rqWPCo21FJNVfj3mX meiMWHsyGIujShhR34ZmegpPBSAx7k9rwOBcWjhyANiLGnjQS1Ltk6VBoy1lz+3z84odqmxia TJjucXz4R7ZKBo+TSNLrAue6fMHUcZQ5FwBu/vvUowexmi7qCzWkuM4/3DOxuInMJ+nqJMNlN K5o8CrZLQfkT+yDltOFKrJ8jQsxrIDNakbuAioH7GsoAUmkGTJxjdN2uo5dXWm8od8IsytXrE E18ix3pRnYletwFH0a+wFn52S1el+nOaNodWJDIcLIgJgaAqxf+ms/GRh21DrUUd1OYNzaFyM pPhdYo65od4e9K13oZhRSqBNtV0Z0aQhAYRSCg9H+BwOclF4091EEqHb7zvZqiIuuGsizQcV9 07RwPV25SRqYZnsEpixOo17stutSUE7LE5pjdoakac6xbCPRbpn0Gp48km0p4Gx7y/6z5XdXO uVy82oJQmwuOw7VHBoUjNpdRQUwetr2veo1YYp9L3SSHttHYoKt+CTbTE4VQ4TbduZiPqwhLu l1/L2qlrG4FYeqhE4ECifc4+q8EX9k5l1VAUEqnp+Q68BF41HUgXHPQnS2C1GbmQMHBt9c/Ln alRNJzfviyo14J7J4mdFO57zPbKd6nHqj6ZGXdKLQfpcl0B7dtq7jVQL7ChgSEzcWnpk= Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org From: Alexander Shiyan This is a complex patch for refactoring CLPS711X SPI driver. This change adds devicetree support and removes board support. Signed-off-by: Alexander Shiyan Signed-off-by: Arnd Bergmann --- drivers/spi/spi-clps711x.c | 69 +++++++++++++++++----------------------------- 1 file changed, 26 insertions(+), 43 deletions(-) -- 2.9.0 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/spi/spi-clps711x.c b/drivers/spi/spi-clps711x.c index 8c30de0315e7..18193df2eba8 100644 --- a/drivers/spi/spi-clps711x.c +++ b/drivers/spi/spi-clps711x.c @@ -1,7 +1,7 @@ /* * CLPS711X SPI bus driver * - * Copyright (C) 2012-2014 Alexander Shiyan + * Copyright (C) 2012-2016 Alexander Shiyan * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -20,9 +19,8 @@ #include #include #include -#include -#define DRIVER_NAME "spi-clps711x" +#define DRIVER_NAME "clps711x-spi" #define SYNCIO_FRMLEN(x) ((x) << 8) #define SYNCIO_TXFRMEN (1 << 14) @@ -40,6 +38,17 @@ struct spi_clps711x_data { static int spi_clps711x_setup(struct spi_device *spi) { + if (!spi->controller_state) { + int ret; + + ret = devm_gpio_request(&spi->master->dev, spi->cs_gpio, + dev_name(&spi->master->dev)); + if (ret) + return ret; + + spi->controller_state = spi; + } + /* We are expect that SPI-device is not selected */ gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH)); @@ -104,20 +113,9 @@ static irqreturn_t spi_clps711x_isr(int irq, void *dev_id) static int spi_clps711x_probe(struct platform_device *pdev) { struct spi_clps711x_data *hw; - struct spi_clps711x_pdata *pdata = dev_get_platdata(&pdev->dev); struct spi_master *master; struct resource *res; - int i, irq, ret; - - if (!pdata) { - dev_err(&pdev->dev, "No platform data supplied\n"); - return -EINVAL; - } - - if (pdata->num_chipselect < 1) { - dev_err(&pdev->dev, "At least one CS must be defined\n"); - return -EINVAL; - } + int irq, ret; irq = platform_get_irq(pdev, 0); if (irq < 0) @@ -127,40 +125,24 @@ static int spi_clps711x_probe(struct platform_device *pdev) if (!master) return -ENOMEM; - master->cs_gpios = devm_kzalloc(&pdev->dev, sizeof(int) * - pdata->num_chipselect, GFP_KERNEL); - if (!master->cs_gpios) { - ret = -ENOMEM; - goto err_out; - } - - master->bus_num = pdev->id; + master->bus_num = -1; master->mode_bits = SPI_CPHA | SPI_CS_HIGH; master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 8); - master->num_chipselect = pdata->num_chipselect; + master->dev.of_node = pdev->dev.of_node; master->setup = spi_clps711x_setup; master->prepare_message = spi_clps711x_prepare_message; master->transfer_one = spi_clps711x_transfer_one; hw = spi_master_get_devdata(master); - for (i = 0; i < master->num_chipselect; i++) { - master->cs_gpios[i] = pdata->chipselect[i]; - ret = devm_gpio_request(&pdev->dev, master->cs_gpios[i], - DRIVER_NAME); - if (ret) { - dev_err(&pdev->dev, "Can't get CS GPIO %i\n", i); - goto err_out; - } - } - hw->spi_clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(hw->spi_clk)) { ret = PTR_ERR(hw->spi_clk); goto err_out; } - hw->syscon = syscon_regmap_lookup_by_pdevname("syscon.3"); + hw->syscon = + syscon_regmap_lookup_by_compatible("cirrus,ep7209-syscon3"); if (IS_ERR(hw->syscon)) { ret = PTR_ERR(hw->syscon); goto err_out; @@ -185,14 +167,8 @@ static int spi_clps711x_probe(struct platform_device *pdev) goto err_out; ret = devm_spi_register_master(&pdev->dev, master); - if (!ret) { - dev_info(&pdev->dev, - "SPI bus driver initialized. Master clock %u Hz\n", - master->max_speed_hz); + if (!ret) return 0; - } - - dev_err(&pdev->dev, "Failed to register master\n"); err_out: spi_master_put(master); @@ -200,9 +176,16 @@ err_out: return ret; } +static const struct of_device_id clps711x_spi_dt_ids[] = { + { .compatible = "cirrus,ep7209-spi", }, + { } +}; +MODULE_DEVICE_TABLE(of, clps711x_spi_dt_ids); + static struct platform_driver clps711x_spi_driver = { .driver = { .name = DRIVER_NAME, + .of_match_table = clps711x_spi_dt_ids, }, .probe = spi_clps711x_probe, }; From patchwork Thu Jul 7 09:49:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102035 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1310201qgy; Thu, 7 Jul 2016 02:47:26 -0700 (PDT) X-Received: by 10.67.4.137 with SMTP id ce9mr50516662pad.120.1467884846720; Thu, 07 Jul 2016 02:47:26 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g18si1923115pfb.298.2016.07.07.02.47.26; Thu, 07 Jul 2016 02:47:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751426AbcGGJrZ (ORCPT + 1 other); Thu, 7 Jul 2016 05:47:25 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:54403 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751418AbcGGJrY (ORCPT ); Thu, 7 Jul 2016 05:47:24 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0MbgsX-1b2jYu1Yqj-00J3bO; Thu, 07 Jul 2016 11:46:53 +0200 From: Arnd Bergmann To: Mark Brown , Rob Herring , Mark Rutland Cc: Alexander Shiyan , linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Arnd Bergmann , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] spi: add DT binding for clps711x SPI Date: Thu, 7 Jul 2016 11:49:46 +0200 Message-Id: <20160707094952.4111577-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160707094952.4111577-1-arnd@arndb.de> References: <20160707094952.4111577-1-arnd@arndb.de> X-Provags-ID: V03:K0:kafMD+HS74NgCkJSYumhG/G7pNUT3DRE9ROfprkxhHCmlgGiBfO fzBAni1PjNstpQMRfLWa62aAiK6Ho5viFiM3asx4fMFjQ1E1iNGS077cj5QdrWFtKjRJNU4 gfWZT88bgv/YyNAu8OaGTVT8ZrBNIgvwoxPw2ZZw9MXFKJm5gZNvJCN/2Tw+rPjIkoK/taP 6Y0F95n36Xmoekppb4j7A== X-UI-Out-Filterresults: notjunk:1; V01:K0:cTjg6CbmwNQ=:CL1SkLhuuNS27Je+kqsdlC 9EOrkv6PzMqQWwKqpd/r+S2DlwqciJFS9GQsH5rvIv47TEMHKu9TXt6AZlqjp59/BaZm/j/AY lD4JOfx/hm7BtbYWtqP6nsqQ+iwrRfQAx9x38bBSXeBKDV4P8MYiYGce0e0uEpiZVX6Zm+V1X AAJ0iClCnLRKlWZBaE9UwcLR1Yh4x2EyBs8eCcPMzgYA8rBlds4NKX5TWYNMegpQ+b0L7DZMl nQCgxhsjElYoZEBeCy7n6+wRqFPBHUzionBGu1DzyLPfcBocuod8WoDAtpkFvMdgvRqFLtdcF yeoZEK3C9+7ft6hsY1nehweh306/Dp1lut14aHzHnImO6bMQJxaZtDb4XPS/OaTDGOrrcXZij wKWm1fK43b4JgSvvw1YeDL8zV7YCz3teOwdzEuzERYL8/L5LkcDUt+sBFMbQ/GS6DC8V51FSF OHn/+zb33K+yIGJxCB8K+gVjnpaUE5msPrTANMh41zOIkhWrTaQLKJZVG8BH8mBYLi+vVJCA0 96FjyyyVTDHNscFgkvsXj7DcMopP5X8wvBvdrU3E7CO3pd1hPa7IoBd4YZhOBjxzZJmyc2RL2 MsXC/4ehfka/BlnTMnaJXx1pw16axYyTgn4McgV3sD/J6ny9gEwUJz2ju52hnu/x/eGqCgfCX ecwaMK9QDKitCL5JVztE2gfWBiUMZKy1hEXSw9ERs1XLTstlvk2UfGbCeR9TmSTAiWfQ= Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org This documents the binding used by Alexander Shiyan's DT support for the clps711x SPI controller. I've left the file name to match the ARM platform port name "clps711x" for consistency with the other bindings, even though the compatible string refers to the later ep7309 chip. Linux no longer supports the old clps711x and ep72xx product lines, but we still use the name. The entire family is now discontinued by the manufacturer. Signed-off-by: Arnd Bergmann Cc: Alexander Shiyan --- .../devicetree/bindings/spi/spi-clps711x.txt | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Documentation/devicetree/bindings/spi/spi-clps711x.txt -- 2.9.0 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/Documentation/devicetree/bindings/spi/spi-clps711x.txt b/Documentation/devicetree/bindings/spi/spi-clps711x.txt new file mode 100644 index 000000000000..4c3ec13f423f --- /dev/null +++ b/Documentation/devicetree/bindings/spi/spi-clps711x.txt @@ -0,0 +1,33 @@ +Serial Peripheral Interface on Cirrus Logic CL-PS71xx, EP72xx, EP73xx + +Required properties +- #address-cells: must be <1> +- #size-cells: must be <0> +- compatible: should include "cirrus,ep7209-spi" +- reg: Address and length of one register range +- interrupts: one interrupt line +- clocks: One entry, refers to the SPI bus clock +- cs-gpios: Specifies the gpio pins to be used for chipselects. + See: Documentation/devicetree/bindings/spi/spi-bus.txt + +An additional register is present in the system controller, +which is assumed to be in the same device tree, with and marked +as compatible with "cirrus,ep7209-syscon3". + +Example: + +spi@80000500 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "cirrus,ep7209-spi"; + reg = <0x80000500 0x4>; + interrupts = <15>; + clocks = <&clks CLPS711X_CLK_SPI>; + status = "disabled"; +}; + +syscon3: syscon@80002200 { + compatible = "cirrus,ep7209-syscon3", "syscon"; + reg = <0x80002200 0x40>; +}; +