From patchwork Sun Jan 25 17:36:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= X-Patchwork-Id: 432579 X-Patchwork-Delegate: jogo@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 466BD140077 for ; Mon, 26 Jan 2015 04:37:15 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 8D34328BE4D; Sun, 25 Jan 2015 18:34:42 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 69F6128BE49 for ; Sun, 25 Jan 2015 18:34:35 +0100 (CET) X-policyd-weight: using cached result; rate: -8.5 Received: from mail-wg0-f46.google.com (mail-wg0-f46.google.com [74.125.82.46]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Sun, 25 Jan 2015 18:34:34 +0100 (CET) Received: by mail-wg0-f46.google.com with SMTP id l2so5478258wgh.5 for ; Sun, 25 Jan 2015 09:36:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=bIyjQ28+ZxEI0f5C0HqCyD7AaNpfcTBD/FkUdj4GoxI=; b=E5c4H6hMldzXdF84VFPy5SSCavrrPDX5PYCBacQ7TbT9bK9RJ/9SxQqSYpnOnyTh/Z AElp+LMxw2ubMbdY3wZI1BWK2LX4F60lccqNIibEdqoCHuSRPgGp5iE/mxN1CQl+BwIs qFhzbttbhQQgbjdq6k1dnisnUg0V/lT2km6GMmB93z2cu43GNBIYB/zY5bk039+TvUxm sHO6I5NdUeH2mTnLymY5e5T3JoQt801YWwbQEwjKE1VnvOr0D35qR9ib2IGA2rF1c2Wq MtdXEWBcNzn5qNqjFW/2r4EQk5y2dj2F2UY9bWZvIrJth4x8vVfwAKAM9F2Z4aeNwVm5 7S8Q== X-Received: by 10.194.2.178 with SMTP id 18mr36060949wjv.67.1422207416814; Sun, 25 Jan 2015 09:36:56 -0800 (PST) Received: from [192.168.1.10] (240.Red-83-49-122.dynamicIP.rima-tde.net. [83.49.122.240]) by mx.google.com with ESMTPSA id e18sm10931179wjz.27.2015.01.25.09.36.55 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Jan 2015 09:36:56 -0800 (PST) Message-ID: <54C529B2.3090704@gmail.com> Date: Sun, 25 Jan 2015 18:36:50 +0100 From: =?windows-1252?Q?=C1lvaro_Fern=E1ndez_Rojas?= User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: OpenWrt Development List , Jonas Gorski References: <5488DC9C.3000504@gmail.com> <54C528DE.8030504@gmail.com> In-Reply-To: <54C528DE.8030504@gmail.com> Subject: [OpenWrt-Devel] [PATCH V3 3/5] brcm63xx: backport DT spi-gpio no CS X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Signed-off-by: Álvaro Fernández Rojas diff --git a/target/linux/brcm63xx/patches-3.14/378-DT-SPI-GPIO-no-cs-backport.patch b/target/linux/brcm63xx/patches-3.14/378-DT-SPI-GPIO-no-cs-backport.patch new file mode 100644 index 0000000..57b66eb --- /dev/null +++ b/target/linux/brcm63xx/patches-3.14/378-DT-SPI-GPIO-no-cs-backport.patch @@ -0,0 +1,74 @@ +--- a/Documentation/devicetree/bindings/spi/spi-gpio.txt ++++ b/Documentation/devicetree/bindings/spi/spi-gpio.txt +@@ -8,8 +8,10 @@ Required properties: + - gpio-sck: GPIO spec for the SCK line to use + - gpio-miso: GPIO spec for the MISO line to use + - gpio-mosi: GPIO spec for the MOSI line to use +- - cs-gpios: GPIOs to use for chipselect lines +- - num-chipselects: number of chipselect lines ++ - cs-gpios: GPIOs to use for chipselect lines. ++ Not needed if num-chipselects = <0>. ++ - num-chipselects: Number of chipselect lines. Should be <0> if a single device ++ with no chip select is connected. + + Example: + +--- a/drivers/spi/spi-gpio.c ++++ b/drivers/spi/spi-gpio.c +@@ -425,6 +425,7 @@ static int spi_gpio_probe(struct platfor + struct spi_gpio_platform_data *pdata; + u16 master_flags = 0; + bool use_of = 0; ++ int num_devices; + + status = spi_gpio_probe_dt(pdev); + if (status < 0) +@@ -434,16 +435,21 @@ static int spi_gpio_probe(struct platfor + + pdata = dev_get_platdata(&pdev->dev); + #ifdef GENERIC_BITBANG +- if (!pdata || !pdata->num_chipselect) ++ if (!pdata || (!use_of && !pdata->num_chipselect)) + return -ENODEV; + #endif + ++ if (use_of && !SPI_N_CHIPSEL) ++ num_devices = 1; ++ else ++ num_devices = SPI_N_CHIPSEL; ++ + status = spi_gpio_request(pdata, dev_name(&pdev->dev), &master_flags); + if (status < 0) + return status; + + master = spi_alloc_master(&pdev->dev, sizeof(*spi_gpio) + +- (sizeof(int) * SPI_N_CHIPSEL)); ++ (sizeof(int) * num_devices)); + if (!master) { + status = -ENOMEM; + goto gpio_free; +@@ -458,7 +464,7 @@ static int spi_gpio_probe(struct platfor + master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32); + master->flags = master_flags; + master->bus_num = pdev->id; +- master->num_chipselect = SPI_N_CHIPSEL; ++ master->num_chipselect = num_devices; + master->setup = spi_gpio_setup; + master->cleanup = spi_gpio_cleanup; + #ifdef CONFIG_OF +@@ -473,9 +479,12 @@ static int spi_gpio_probe(struct platfor + * property of the node. + */ + +- for (i = 0; i < SPI_N_CHIPSEL; i++) +- spi_gpio->cs_gpios[i] = +- of_get_named_gpio(np, "cs-gpios", i); ++ if (!SPI_N_CHIPSEL) ++ spi_gpio->cs_gpios[0] = SPI_GPIO_NO_CHIPSELECT; ++ else ++ for (i = 0; i < SPI_N_CHIPSEL; i++) ++ spi_gpio->cs_gpios[i] = ++ of_get_named_gpio(np, "cs-gpios", i); + } + #endif + diff --git a/target/linux/brcm63xx/patches-3.18/376-DT-SPI-GPIO-no-cs-backport.patch b/target/linux/brcm63xx/patches-3.18/376-DT-SPI-GPIO-no-cs-backport.patch new file mode 100644 index 0000000..da75cb5 --- /dev/null +++ b/target/linux/brcm63xx/patches-3.18/376-DT-SPI-GPIO-no-cs-backport.patch @@ -0,0 +1,74 @@ +--- a/Documentation/devicetree/bindings/spi/spi-gpio.txt ++++ b/Documentation/devicetree/bindings/spi/spi-gpio.txt +@@ -8,8 +8,10 @@ Required properties: + - gpio-sck: GPIO spec for the SCK line to use + - gpio-miso: GPIO spec for the MISO line to use + - gpio-mosi: GPIO spec for the MOSI line to use +- - cs-gpios: GPIOs to use for chipselect lines +- - num-chipselects: number of chipselect lines ++ - cs-gpios: GPIOs to use for chipselect lines. ++ Not needed if num-chipselects = <0>. ++ - num-chipselects: Number of chipselect lines. Should be <0> if a single device ++ with no chip select is connected. + + Example: + +--- a/drivers/spi/spi-gpio.c ++++ b/drivers/spi/spi-gpio.c +@@ -424,6 +424,7 @@ static int spi_gpio_probe(struct platfor + struct spi_gpio_platform_data *pdata; + u16 master_flags = 0; + bool use_of = 0; ++ int num_devices; + + status = spi_gpio_probe_dt(pdev); + if (status < 0) +@@ -433,16 +434,21 @@ static int spi_gpio_probe(struct platfor + + pdata = dev_get_platdata(&pdev->dev); + #ifdef GENERIC_BITBANG +- if (!pdata || !pdata->num_chipselect) ++ if (!pdata || (!use_of && !pdata->num_chipselect)) + return -ENODEV; + #endif + ++ if (use_of && !SPI_N_CHIPSEL) ++ num_devices = 1; ++ else ++ num_devices = SPI_N_CHIPSEL; ++ + status = spi_gpio_request(pdata, dev_name(&pdev->dev), &master_flags); + if (status < 0) + return status; + + master = spi_alloc_master(&pdev->dev, sizeof(*spi_gpio) + +- (sizeof(int) * SPI_N_CHIPSEL)); ++ (sizeof(int) * num_devices)); + if (!master) { + status = -ENOMEM; + goto gpio_free; +@@ -457,7 +463,7 @@ static int spi_gpio_probe(struct platfor + master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32); + master->flags = master_flags; + master->bus_num = pdev->id; +- master->num_chipselect = SPI_N_CHIPSEL; ++ master->num_chipselect = num_devices; + master->setup = spi_gpio_setup; + master->cleanup = spi_gpio_cleanup; + #ifdef CONFIG_OF +@@ -472,9 +478,12 @@ static int spi_gpio_probe(struct platfor + * property of the node. + */ + +- for (i = 0; i < SPI_N_CHIPSEL; i++) +- spi_gpio->cs_gpios[i] = +- of_get_named_gpio(np, "cs-gpios", i); ++ if (!SPI_N_CHIPSEL) ++ spi_gpio->cs_gpios[0] = SPI_GPIO_NO_CHIPSELECT; ++ else ++ for (i = 0; i < SPI_N_CHIPSEL; i++) ++ spi_gpio->cs_gpios[i] = ++ of_get_named_gpio(np, "cs-gpios", i); + } + #endif +