diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/spi/spi_mpc8xxx.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/drivers/spi/spi_mpc8xxx.c b/drivers/spi/spi_mpc8xxx.c index 4b119eaf4e6b..80374dfa9708 100644 --- a/drivers/spi/spi_mpc8xxx.c +++ b/drivers/spi/spi_mpc8xxx.c | |||
@@ -96,7 +96,8 @@ struct mpc8xxx_spi { | |||
96 | u32 rx_shift; /* RX data reg shift when in qe mode */ | 96 | u32 rx_shift; /* RX data reg shift when in qe mode */ |
97 | u32 tx_shift; /* TX data reg shift when in qe mode */ | 97 | u32 tx_shift; /* TX data reg shift when in qe mode */ |
98 | 98 | ||
99 | bool qe_mode; | 99 | unsigned int flags; |
100 | #define SPI_QE_CPU_MODE (1 << 0) /* QE CPU ("PIO") mode */ | ||
100 | 101 | ||
101 | struct workqueue_struct *workqueue; | 102 | struct workqueue_struct *workqueue; |
102 | struct work_struct work; | 103 | struct work_struct work; |
@@ -235,14 +236,14 @@ int mpc8xxx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t) | |||
235 | if (bits_per_word <= 8) { | 236 | if (bits_per_word <= 8) { |
236 | cs->get_rx = mpc8xxx_spi_rx_buf_u8; | 237 | cs->get_rx = mpc8xxx_spi_rx_buf_u8; |
237 | cs->get_tx = mpc8xxx_spi_tx_buf_u8; | 238 | cs->get_tx = mpc8xxx_spi_tx_buf_u8; |
238 | if (mpc8xxx_spi->qe_mode) { | 239 | if (mpc8xxx_spi->flags & SPI_QE_CPU_MODE) { |
239 | cs->rx_shift = 16; | 240 | cs->rx_shift = 16; |
240 | cs->tx_shift = 24; | 241 | cs->tx_shift = 24; |
241 | } | 242 | } |
242 | } else if (bits_per_word <= 16) { | 243 | } else if (bits_per_word <= 16) { |
243 | cs->get_rx = mpc8xxx_spi_rx_buf_u16; | 244 | cs->get_rx = mpc8xxx_spi_rx_buf_u16; |
244 | cs->get_tx = mpc8xxx_spi_tx_buf_u16; | 245 | cs->get_tx = mpc8xxx_spi_tx_buf_u16; |
245 | if (mpc8xxx_spi->qe_mode) { | 246 | if (mpc8xxx_spi->flags & SPI_QE_CPU_MODE) { |
246 | cs->rx_shift = 16; | 247 | cs->rx_shift = 16; |
247 | cs->tx_shift = 16; | 248 | cs->tx_shift = 16; |
248 | } | 249 | } |
@@ -252,7 +253,8 @@ int mpc8xxx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t) | |||
252 | } else | 253 | } else |
253 | return -EINVAL; | 254 | return -EINVAL; |
254 | 255 | ||
255 | if (mpc8xxx_spi->qe_mode && spi->mode & SPI_LSB_FIRST) { | 256 | if (mpc8xxx_spi->flags & SPI_QE_CPU_MODE && |
257 | spi->mode & SPI_LSB_FIRST) { | ||
256 | cs->tx_shift = 0; | 258 | cs->tx_shift = 0; |
257 | if (bits_per_word <= 8) | 259 | if (bits_per_word <= 8) |
258 | cs->rx_shift = 8; | 260 | cs->rx_shift = 8; |
@@ -518,6 +520,13 @@ static void mpc8xxx_spi_cleanup(struct spi_device *spi) | |||
518 | kfree(spi->controller_state); | 520 | kfree(spi->controller_state); |
519 | } | 521 | } |
520 | 522 | ||
523 | static const char *mpc8xxx_spi_strmode(unsigned int flags) | ||
524 | { | ||
525 | if (flags & SPI_QE_CPU_MODE) | ||
526 | return "QE CPU"; | ||
527 | return "CPU"; | ||
528 | } | ||
529 | |||
521 | static struct spi_master * __devinit | 530 | static struct spi_master * __devinit |
522 | mpc8xxx_spi_probe(struct device *dev, struct resource *mem, unsigned int irq) | 531 | mpc8xxx_spi_probe(struct device *dev, struct resource *mem, unsigned int irq) |
523 | { | 532 | { |
@@ -544,14 +553,14 @@ mpc8xxx_spi_probe(struct device *dev, struct resource *mem, unsigned int irq) | |||
544 | master->cleanup = mpc8xxx_spi_cleanup; | 553 | master->cleanup = mpc8xxx_spi_cleanup; |
545 | 554 | ||
546 | mpc8xxx_spi = spi_master_get_devdata(master); | 555 | mpc8xxx_spi = spi_master_get_devdata(master); |
547 | mpc8xxx_spi->qe_mode = pdata->qe_mode; | ||
548 | mpc8xxx_spi->get_rx = mpc8xxx_spi_rx_buf_u8; | 556 | mpc8xxx_spi->get_rx = mpc8xxx_spi_rx_buf_u8; |
549 | mpc8xxx_spi->get_tx = mpc8xxx_spi_tx_buf_u8; | 557 | mpc8xxx_spi->get_tx = mpc8xxx_spi_tx_buf_u8; |
558 | mpc8xxx_spi->flags = pdata->flags; | ||
550 | mpc8xxx_spi->spibrg = pdata->sysclk; | 559 | mpc8xxx_spi->spibrg = pdata->sysclk; |
551 | 560 | ||
552 | mpc8xxx_spi->rx_shift = 0; | 561 | mpc8xxx_spi->rx_shift = 0; |
553 | mpc8xxx_spi->tx_shift = 0; | 562 | mpc8xxx_spi->tx_shift = 0; |
554 | if (mpc8xxx_spi->qe_mode) { | 563 | if (mpc8xxx_spi->flags & SPI_QE_CPU_MODE) { |
555 | mpc8xxx_spi->rx_shift = 16; | 564 | mpc8xxx_spi->rx_shift = 16; |
556 | mpc8xxx_spi->tx_shift = 24; | 565 | mpc8xxx_spi->tx_shift = 24; |
557 | } | 566 | } |
@@ -584,7 +593,7 @@ mpc8xxx_spi_probe(struct device *dev, struct resource *mem, unsigned int irq) | |||
584 | 593 | ||
585 | /* Enable SPI interface */ | 594 | /* Enable SPI interface */ |
586 | regval = pdata->initial_spmode | SPMODE_INIT_VAL | SPMODE_ENABLE; | 595 | regval = pdata->initial_spmode | SPMODE_INIT_VAL | SPMODE_ENABLE; |
587 | if (pdata->qe_mode) | 596 | if (mpc8xxx_spi->flags & SPI_QE_CPU_MODE) |
588 | regval |= SPMODE_OP; | 597 | regval |= SPMODE_OP; |
589 | 598 | ||
590 | mpc8xxx_spi_write_reg(&mpc8xxx_spi->base->mode, regval); | 599 | mpc8xxx_spi_write_reg(&mpc8xxx_spi->base->mode, regval); |
@@ -604,9 +613,8 @@ mpc8xxx_spi_probe(struct device *dev, struct resource *mem, unsigned int irq) | |||
604 | if (ret < 0) | 613 | if (ret < 0) |
605 | goto unreg_master; | 614 | goto unreg_master; |
606 | 615 | ||
607 | printk(KERN_INFO | 616 | dev_info(dev, "at 0x%p (irq = %d), %s mode\n", mpc8xxx_spi->base, |
608 | "%s: MPC8xxx SPI Controller driver at 0x%p (irq = %d)\n", | 617 | mpc8xxx_spi->irq, mpc8xxx_spi_strmode(mpc8xxx_spi->flags)); |
609 | dev_name(dev), mpc8xxx_spi->base, mpc8xxx_spi->irq); | ||
610 | 618 | ||
611 | return master; | 619 | return master; |
612 | 620 | ||
@@ -797,7 +805,7 @@ static int __devinit of_mpc8xxx_spi_probe(struct of_device *ofdev, | |||
797 | 805 | ||
798 | prop = of_get_property(np, "mode", NULL); | 806 | prop = of_get_property(np, "mode", NULL); |
799 | if (prop && !strcmp(prop, "cpu-qe")) | 807 | if (prop && !strcmp(prop, "cpu-qe")) |
800 | pdata->qe_mode = 1; | 808 | pdata->flags = SPI_QE_CPU_MODE; |
801 | 809 | ||
802 | ret = of_mpc8xxx_spi_get_chipselects(dev); | 810 | ret = of_mpc8xxx_spi_get_chipselects(dev); |
803 | if (ret) | 811 | if (ret) |