From patchwork Fri Oct 24 20:08:59 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfgang Ocker X-Patchwork-Id: 5713 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 0E8FE4767B for ; Sat, 25 Oct 2008 07:09:22 +1100 (EST) X-Original-To: linuxppc-dev@ozlabs.org Delivered-To: linuxppc-dev@ozlabs.org Received: from bes.recconet.de (bes.recconet.de [87.106.167.58]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 59A77DDDE0 for ; Sat, 25 Oct 2008 07:09:07 +1100 (EST) Received: from trinity.recco.de (trinity.intern.recconet.de [192.168.11.241]) by bes.recconet.de (8.13.8/8.13.8/Recconet-2008030801) with ESMTP id m9OK8hoP005269; Fri, 24 Oct 2008 22:08:43 +0200 Received: from [172.16.135.104] (galileo.recco.de [172.16.135.104]) (authenticated bits=0) by trinity.recco.de (8.13.8/8.13.8/Reccoware-2008101201) with ESMTP id m9OK90Db022800; Fri, 24 Oct 2008 22:09:00 +0200 Subject: [PATCH] Added gpios property for SPI slaves From: Wolfgang Ocker To: linuxppc-dev@ozlabs.org Organization: Reccoware Systems Date: Fri, 24 Oct 2008 22:08:59 +0200 Message-Id: <1224878939.4039.22.camel@galileo.recco.de> Mime-Version: 1.0 X-Mailer: Evolution 2.12.3 (2.12.3-5.fc8) Cc: Stefan Roese X-BeenThere: linuxppc-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org SPI slave devices require the specification of a chip select address. This patch allows that specification using the gpios property. The reg property remains supported. Signed-off-by: Wolfgang Ocker --- linux-2.6.27.3/drivers/of/of_spi.c.of_spi_gpio 2008-10-22 23:38:01.000000000 +0200 +++ linux-2.6.27.3/drivers/of/of_spi.c.of_spi_cshigh 2008-10-24 21:36:39.000000000 +0200 @@ -10,6 +10,7 @@ #include #include #include +#include /** * of_register_spi_devices - Register child devices onto the SPI bus @@ -24,6 +25,7 @@ void of_register_spi_devices(struct spi_ struct spi_device *spi; struct device_node *nc; const u32 *prop; + int cs_addr; int rc; int len; @@ -48,13 +50,20 @@ void of_register_spi_devices(struct spi_ /* Device address */ prop = of_get_property(nc, "reg", &len); - if (!prop || len < sizeof(*prop)) { - dev_err(&master->dev, "%s has no 'reg' property\n", - nc->full_name); - spi_dev_put(spi); - continue; + if (prop && len >= sizeof(*prop)) { + cs_addr = *prop; + } + else { + cs_addr = of_get_gpio(nc, 0); + if (cs_addr < 0) { + dev_err(&master->dev, + "%s has no 'reg' nor gpios property\n", + nc->full_name); + spi_dev_put(spi); + continue; + } } - spi->chip_select = *prop; + spi->chip_select = cs_addr; /* Mode (clock phase/polarity/etc.) */ if (of_find_property(nc, "spi-cpha", NULL)) --- linux-2.6.27.3/Documentation/powerpc/booting-without-of.txt.of_spi_gpio 2008-10-22 23:38:01.000000000 +0200 +++ linux-2.6.27.3/Documentation/powerpc/booting-without-of.txt.of_spi_cshigh 2008-10-24 21:57:16.000000000 +0200 @@ -1909,7 +1909,9 @@ platforms are moved over to use the flat SPI slave nodes must be children of the SPI master node and can contain the following properties. - - reg - (required) chip select address of device. + - reg - chip select address of device. + - gpios - chip select address of device (alternatively). + one of reg and gpios is required. - compatible - (required) name of SPI device following generic names recommended practice - spi-max-frequency - (required) Maximum SPI clocking speed of device in Hz @@ -1936,7 +1938,7 @@ platforms are moved over to use the flat codec@1 { compatible = "ti,tlv320aic26"; spi-max-frequency = <100000>; - reg = <1>; + gpios = <&GPIO1 3>; }; };