Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 166676
b: refs/heads/master
c: e6a0a8b
h: refs/heads/master
v: v3
  • Loading branch information
Uwe Kleine-König authored and Linus Torvalds committed Oct 1, 2009
1 parent e8164f2 commit 8bf34ad
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 34 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d1c627b59c8e69d40b94a4ff28a582a84c6a95a3
refs/heads/master: e6a0a8bfef1094084e53bfaad6d512c23da7a6dd
50 changes: 17 additions & 33 deletions trunk/drivers/spi/spi_imx.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,43 +354,14 @@ static int mx1_rx_available(struct spi_imx_data *spi_imx)
static void spi_imx_chipselect(struct spi_device *spi, int is_active)
{
struct spi_imx_data *spi_imx = spi_master_get_devdata(spi->master);
unsigned int cs = 0;
int gpio = spi_imx->chipselect[spi->chip_select];
struct spi_imx_config config;

if (spi->mode & SPI_CS_HIGH)
cs = 1;
int active = is_active != BITBANG_CS_INACTIVE;
int dev_is_lowactive = !(spi->mode & SPI_CS_HIGH);

if (is_active == BITBANG_CS_INACTIVE) {
if (gpio >= 0)
gpio_set_value(gpio, !cs);
if (gpio < 0)
return;
}

config.bpw = spi->bits_per_word;
config.speed_hz = spi->max_speed_hz;
config.mode = spi->mode;
config.cs = spi_imx->chipselect[spi->chip_select];

spi_imx->config(spi_imx, &config);

/* Initialize the functions for transfer */
if (config.bpw <= 8) {
spi_imx->rx = spi_imx_buf_rx_u8;
spi_imx->tx = spi_imx_buf_tx_u8;
} else if (config.bpw <= 16) {
spi_imx->rx = spi_imx_buf_rx_u16;
spi_imx->tx = spi_imx_buf_tx_u16;
} else if (config.bpw <= 32) {
spi_imx->rx = spi_imx_buf_rx_u32;
spi_imx->tx = spi_imx_buf_tx_u32;
} else
BUG();

if (gpio >= 0)
gpio_set_value(gpio, cs);

return;
gpio_set_value(gpio, dev_is_lowactive ^ active);
}

static void spi_imx_push(struct spi_imx_data *spi_imx)
Expand Down Expand Up @@ -451,6 +422,19 @@ static int spi_imx_setupxfer(struct spi_device *spi,
if (!config.speed_hz)
config.speed_hz = spi->max_speed_hz;

/* Initialize the functions for transfer */
if (config.bpw <= 8) {
spi_imx->rx = spi_imx_buf_rx_u8;
spi_imx->tx = spi_imx_buf_tx_u8;
} else if (config.bpw <= 16) {
spi_imx->rx = spi_imx_buf_rx_u16;
spi_imx->tx = spi_imx_buf_tx_u16;
} else if (config.bpw <= 32) {
spi_imx->rx = spi_imx_buf_rx_u32;
spi_imx->tx = spi_imx_buf_tx_u32;
} else
BUG();

spi_imx->config(spi_imx, &config);

return 0;
Expand Down

0 comments on commit 8bf34ad

Please sign in to comment.