aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi_imx.c
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2009-10-01 18:44:33 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-10-01 19:11:17 -0400
commite6a0a8bfef1094084e53bfaad6d512c23da7a6dd (patch)
tree5c543b2628fb840fc7013c57ea22c812f2bea63e /drivers/spi/spi_imx.c
parentd1c627b59c8e69d40b94a4ff28a582a84c6a95a3 (diff)
spi-imx: strip down chipselect function to only drive the chipselect
spi_imx_chipselect() made things that should be (and mostly are) done by spi_imx_setupxfer. Only setting the tx and rx functions was missing. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Sascha Hauer <s.hauer@pengutronix.de> Cc: David Brownell <dbrownell@users.sourceforge.net> Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/spi/spi_imx.c')
-rw-r--r--drivers/spi/spi_imx.c50
1 files changed, 17 insertions, 33 deletions
diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c
index 2fec1170b6c0..89c22efedfb0 100644
--- a/drivers/spi/spi_imx.c
+++ b/drivers/spi/spi_imx.c
@@ -354,43 +354,14 @@ static int mx1_rx_available(struct spi_imx_data *spi_imx)
354static void spi_imx_chipselect(struct spi_device *spi, int is_active) 354static void spi_imx_chipselect(struct spi_device *spi, int is_active)
355{ 355{
356 struct spi_imx_data *spi_imx = spi_master_get_devdata(spi->master); 356 struct spi_imx_data *spi_imx = spi_master_get_devdata(spi->master);
357 unsigned int cs = 0;
358 int gpio = spi_imx->chipselect[spi->chip_select]; 357 int gpio = spi_imx->chipselect[spi->chip_select];
359 struct spi_imx_config config; 358 int active = is_active != BITBANG_CS_INACTIVE;
360 359 int dev_is_lowactive = !(spi->mode & SPI_CS_HIGH);
361 if (spi->mode & SPI_CS_HIGH)
362 cs = 1;
363 360
364 if (is_active == BITBANG_CS_INACTIVE) { 361 if (gpio < 0)
365 if (gpio >= 0)
366 gpio_set_value(gpio, !cs);
367 return; 362 return;
368 }
369
370 config.bpw = spi->bits_per_word;
371 config.speed_hz = spi->max_speed_hz;
372 config.mode = spi->mode;
373 config.cs = spi_imx->chipselect[spi->chip_select];
374
375 spi_imx->config(spi_imx, &config);
376
377 /* Initialize the functions for transfer */
378 if (config.bpw <= 8) {
379 spi_imx->rx = spi_imx_buf_rx_u8;
380 spi_imx->tx = spi_imx_buf_tx_u8;
381 } else if (config.bpw <= 16) {
382 spi_imx->rx = spi_imx_buf_rx_u16;
383 spi_imx->tx = spi_imx_buf_tx_u16;
384 } else if (config.bpw <= 32) {
385 spi_imx->rx = spi_imx_buf_rx_u32;
386 spi_imx->tx = spi_imx_buf_tx_u32;
387 } else
388 BUG();
389
390 if (gpio >= 0)
391 gpio_set_value(gpio, cs);
392 363
393 return; 364 gpio_set_value(gpio, dev_is_lowactive ^ active);
394} 365}
395 366
396static void spi_imx_push(struct spi_imx_data *spi_imx) 367static void spi_imx_push(struct spi_imx_data *spi_imx)
@@ -451,6 +422,19 @@ static int spi_imx_setupxfer(struct spi_device *spi,
451 if (!config.speed_hz) 422 if (!config.speed_hz)
452 config.speed_hz = spi->max_speed_hz; 423 config.speed_hz = spi->max_speed_hz;
453 424
425 /* Initialize the functions for transfer */
426 if (config.bpw <= 8) {
427 spi_imx->rx = spi_imx_buf_rx_u8;
428 spi_imx->tx = spi_imx_buf_tx_u8;
429 } else if (config.bpw <= 16) {
430 spi_imx->rx = spi_imx_buf_rx_u16;
431 spi_imx->tx = spi_imx_buf_tx_u16;
432 } else if (config.bpw <= 32) {
433 spi_imx->rx = spi_imx_buf_rx_u32;
434 spi_imx->tx = spi_imx_buf_tx_u32;
435 } else
436 BUG();
437
454 spi_imx->config(spi_imx, &config); 438 spi_imx->config(spi_imx, &config);
455 439
456 return 0; 440 return 0;