linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: spi-devel-general@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org,
	Sascha Hauer <s.hauer@pengutronix.de>,
	David Brownell <dbrownell@users.sourceforge.net>,
	Andrew Morton <akpm@linux-foundation.org>,
	Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Subject: [PATCH 3/7] spi-imx: Fix initial chipselect settings
Date: Wed, 30 Sep 2009 21:43:30 +0200	[thread overview]
Message-ID: <1254339814-21506-3-git-send-email-u.kleine-koenig@pengutronix.de> (raw)
In-Reply-To: <1254339814-21506-2-git-send-email-u.kleine-koenig@pengutronix.de>

From: Sascha Hauer <s.hauer@pengutronix.de>

We can only setup the gpio pins in spi_setup time when we
know the SPI_CS_HIGH setting.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 drivers/spi/spi_imx.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c
index a8f9bff..b91a5a8 100644
--- a/drivers/spi/spi_imx.c
+++ b/drivers/spi/spi_imx.c
@@ -478,12 +478,18 @@ static int spi_imx_transfer(struct spi_device *spi,
 
 static int spi_imx_setup(struct spi_device *spi)
 {
+	struct spi_imx_data *spi_imx = spi_master_get_devdata(spi->master);
+	int gpio = spi_imx->chipselect[spi->chip_select];
+
 	if (!spi->bits_per_word)
 		spi->bits_per_word = 8;
 
 	pr_debug("%s: mode %d, %u bpw, %d hz\n", __func__,
 		 spi->mode, spi->bits_per_word, spi->max_speed_hz);
 
+	if (gpio >= 0)
+		gpio_direction_output(gpio, spi->mode & SPI_CS_HIGH ? 0 : 1);
+
 	spi_imx_chipselect(spi, BITBANG_CS_INACTIVE);
 
 	return 0;
@@ -532,7 +538,6 @@ static int __init spi_imx_probe(struct platform_device *pdev)
 			dev_err(&pdev->dev, "can't get cs gpios");
 			goto out_master_put;
 		}
-		gpio_direction_output(spi_imx->chipselect[i], 1);
 	}
 
 	spi_imx->bitbang.chipselect = spi_imx_chipselect;
-- 
1.6.4.3

  reply	other threads:[~2009-09-30 19:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-30 19:42 [PATCH 0/7] Updates for spi-imx Uwe Kleine-König
     [not found] ` <20090930194211.GB1881-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2009-09-30 19:43   ` [PATCH 1/7] spi-imx: rename source file to spi_imx.c Uwe Kleine-König
     [not found]     ` <1254339814-21506-1-git-send-email-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2009-09-30 19:43       ` [PATCH 2/7] spi-imx: update state correctly Uwe Kleine-König
2009-09-30 19:43         ` Uwe Kleine-König [this message]
     [not found]           ` <1254339814-21506-3-git-send-email-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2009-09-30 19:43             ` [PATCH 4/7] spi-imx: setup mode_bits we can handle Uwe Kleine-König
2009-09-30 19:43               ` [PATCH 5/7] spi-imx: no need to assert bits_per_word being initialized Uwe Kleine-König
     [not found]                 ` <1254339814-21506-5-git-send-email-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2009-09-30 19:43                   ` [PATCH 6/7] spi-imx: initialize complete config struct Uwe Kleine-König
2009-09-30 19:43                     ` [PATCH 7/7 RFC] spi-imx: strip down chipselect function to only drive the chipselect Uwe Kleine-König
2009-09-30 23:52 ` [PATCH 0/7] Updates for spi-imx Andrew Morton
2009-10-01  4:59   ` Uwe Kleine-König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1254339814-21506-3-git-send-email-u.kleine-koenig@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=akpm@linux-foundation.org \
    --cc=dbrownell@users.sourceforge.net \
    --cc=g.liakhovetski@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=spi-devel-general@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).