From patchwork Fri Jun 19 14:18:32 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rini van Zetten X-Patchwork-Id: 28913 X-Patchwork-Delegate: galak@kernel.crashing.org Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 7F0A2B7271 for ; Sat, 20 Jun 2009 00:19:20 +1000 (EST) Received: by ozlabs.org (Postfix) id 6B614DDDA0; Sat, 20 Jun 2009 00:19:20 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (bilbo.ozlabs.org [203.10.76.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "bilbo.ozlabs.org", Issuer "CAcert Class 3 Root" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 67B61DDD1C for ; Sat, 20 Jun 2009 00:19:20 +1000 (EST) Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by bilbo.ozlabs.org (Postfix) with ESMTP id 00472B760E for ; Sat, 20 Jun 2009 00:18:49 +1000 (EST) Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id C92BDB7227 for ; Sat, 20 Jun 2009 00:18:40 +1000 (EST) Received: by ozlabs.org (Postfix) id B8615DDD1C; Sat, 20 Jun 2009 00:18:40 +1000 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from smtp3.euronet.nl (smtp3.euronet.nl [194.134.35.173]) by ozlabs.org (Postfix) with ESMTP id F079BDDD1B for ; Sat, 20 Jun 2009 00:18:39 +1000 (EST) Received: from arv-010 (mf-22dc1.mxs.adsl.euronet.nl [81.70.75.193]) by smtp3.euronet.nl (Postfix) with ESMTP id 4EEE43A2BF; Fri, 19 Jun 2009 16:18:37 +0200 (MEST) Received: from arv-010 (localhost [127.0.0.1]) by arv-010 (Postfix) with ESMTP id EA61E714FA; Fri, 19 Jun 2009 16:18:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=arvoo.nl; h=message-id :date:from:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; s=arv-010; bh=ca1ukzACm KIjBHYKamcxEhGHUyU=; b=srpyiCOl3MlBDU0PG1nQ4A7xUJzuLYzRk+hhzywYb HFmnKHMHUWH0zUTodP1zyLf8ACV5j932IVuD+4cCfCPXEXGqmiOYWkaSQiSPR2wl 82nXPjnKRglAFrz8nMYGGEWXOMqsIdUyY9D75ClVUe5ofLoD5xSvaLOVZSXRC9xO 7g= Received: from arv-002.arvoo.nl (unknown [192.168.0.2]) by arv-010 (Postfix) with ESMTP id 68AAB714FA; Fri, 19 Jun 2009 16:18:32 +0200 (CEST) Received: from [192.168.0.72] (unknown [192.168.0.72]) by arv-002.arvoo.nl (Postfix) with ESMTP id 4A4AE18027DA2; Fri, 19 Jun 2009 16:18:32 +0200 (CEST) Message-ID: <4A3B9E38.9060004@arvoo.nl> Date: Fri, 19 Jun 2009 16:18:32 +0200 From: Rini van Zetten User-Agent: Thunderbird 2.0.0.21 (X11/20090409) MIME-Version: 1.0 To: avorontsov@ru.mvista.com Subject: Re: [PATCH -mm v4][POWERPC] mpc8xxx : allow SPI without cs. References: <4A39DC80.7030906@arvoo.nl> <20090618130955.GA1369@oksana.dev.rtsoft.ru> <4A3B3D90.5030100@arvoo.nl> <20090619134558.GA18872@oksana.dev.rtsoft.ru> In-Reply-To: <20090619134558.GA18872@oksana.dev.rtsoft.ru> X-ARVOO-MailScanner-Information: Please contact the ISP for more information X-MailScanner-ID: 68AAB714FA.66E0D X-ARVOO-MailScanner: Found to be clean X-ARVOO-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-5.8, required 5, autolearn=not spam, ALL_TRUSTED -1.80, BAYES_00 -4.00) X-ARVOO-MailScanner-From: rini@arvoo.nl X-Spam-Status: No Cc: spi-devel-general@lists.sourceforge.net, linuxppc-dev list X-BeenThere: linuxppc-dev@lists.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@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org This patch adds the possibility to have a spi device without a cs. For example, the dts file should look something like this: spi-controller { gpios = <&pio1 1 0 /* cs0 */ 0 /* cs1, no GPIO */ &pio2 2 0>; /* cs2 */ This feature is needed on our home made board to program an onboard fpga. The fpga needs some special pin toggling to put it in programming mode. That's why we want to skip the usual gpio cs and do the pin toggling in our driver Signed-off-by: Rini van Zetten Acked-by: Anton Vorontsov --- Changes : patch against 2.6.30-rc8-mm1 style updates compiler warning fix v4 : missing space in error text added splitted lines combined diff --git a/drivers/spi/spi_mpc8xxx.c b/drivers/spi/spi_mpc8xxx.c index 0fd0ec4..de95790 100644 --- a/drivers/spi/spi_mpc8xxx.c +++ b/drivers/spi/spi_mpc8xxx.c @@ -666,9 +666,12 @@ static void mpc8xxx_spi_cs_control(struct spi_device *spi, bool on) struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(dev->platform_data); u16 cs = spi->chip_select; int gpio = pinfo->gpios[cs]; - bool alow = pinfo->alow_flags[cs]; - gpio_set_value(gpio, on ^ alow); + if (gpio != -EEXIST) { + bool alow = pinfo->alow_flags[cs]; + + gpio_set_value(gpio, on ^ alow); + } } static int of_mpc8xxx_spi_get_chipselects(struct device *dev) @@ -678,7 +681,7 @@ static int of_mpc8xxx_spi_get_chipselects(struct device *dev) struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(pdata); unsigned int ngpios; int i = 0; - int ret; + int ret = 0; ngpios = of_gpio_count(np); if (!ngpios) { @@ -707,27 +710,30 @@ static int of_mpc8xxx_spi_get_chipselects(struct device *dev) enum of_gpio_flags flags; gpio = of_get_gpio_flags(np, i, &flags); - if (!gpio_is_valid(gpio)) { + if (gpio_is_valid(gpio)) { + ret = gpio_request(gpio, dev_name(dev)); + if (ret) { + dev_err(dev, "can't request gpio #%d: %d\n", + i, ret); + goto err_loop; + } + + pinfo->gpios[i] = gpio; + pinfo->alow_flags[i] = flags & OF_GPIO_ACTIVE_LOW; + + ret = gpio_direction_output(pinfo->gpios[i], + pinfo->alow_flags[i]); + if (ret) { + dev_err(dev, "can't set output direction for " + "gpio #%d: %d\n", i, ret); + goto err_loop; + } + } else if (gpio == -EEXIST) { + pinfo->gpios[i] = -EEXIST; + } else { dev_err(dev, "invalid gpio #%d: %d\n", i, gpio); goto err_loop; } - - ret = gpio_request(gpio, dev_name(dev)); - if (ret) { - dev_err(dev, "can't request gpio #%d: %d\n", i, ret); - goto err_loop; - } - - pinfo->gpios[i] = gpio; - pinfo->alow_flags[i] = flags & OF_GPIO_ACTIVE_LOW; - - ret = gpio_direction_output(pinfo->gpios[i], - pinfo->alow_flags[i]); - if (ret) { - dev_err(dev, "can't set output direction for gpio " - "#%d: %d\n", i, ret); - goto err_loop; - } } pdata->max_chipselect = ngpios;