aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;