Commit f9de7342 authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branches 'spi/topic/atmel', 'spi/topic/bcm2385',...

Merge remote-tracking branches 'spi/topic/atmel', 'spi/topic/bcm2385', 'spi/topic/bcm2835', 'spi/topic/bcm53xx' and 'spi/topic/bitbang' into spi-next
...@@ -180,11 +180,17 @@ ...@@ -180,11 +180,17 @@
| SPI_BF(name, value)) | SPI_BF(name, value))
/* Register access macros */ /* Register access macros */
#ifdef CONFIG_AVR32
#define spi_readl(port, reg) \ #define spi_readl(port, reg) \
__raw_readl((port)->regs + SPI_##reg) __raw_readl((port)->regs + SPI_##reg)
#define spi_writel(port, reg, value) \ #define spi_writel(port, reg, value) \
__raw_writel((value), (port)->regs + SPI_##reg) __raw_writel((value), (port)->regs + SPI_##reg)
#else
#define spi_readl(port, reg) \
readl_relaxed((port)->regs + SPI_##reg)
#define spi_writel(port, reg, value) \
writel_relaxed((value), (port)->regs + SPI_##reg)
#endif
/* use PIO for small transfers, avoiding DMA setup/teardown overhead and /* use PIO for small transfers, avoiding DMA setup/teardown overhead and
* cache operations; better heuristics consider wordsize and bitrate. * cache operations; better heuristics consider wordsize and bitrate.
*/ */
......
This diff is collapsed.
...@@ -44,7 +44,7 @@ static int bcm53xxspi_wait(struct bcm53xxspi *b53spi, unsigned int timeout_ms) ...@@ -44,7 +44,7 @@ static int bcm53xxspi_wait(struct bcm53xxspi *b53spi, unsigned int timeout_ms)
u32 tmp; u32 tmp;
/* SPE bit has to be 0 before we read MSPI STATUS */ /* SPE bit has to be 0 before we read MSPI STATUS */
deadline = jiffies + BCM53XXSPI_SPE_TIMEOUT_MS * HZ / 1000; deadline = jiffies + msecs_to_jiffies(BCM53XXSPI_SPE_TIMEOUT_MS);
do { do {
tmp = bcm53xxspi_read(b53spi, B53SPI_MSPI_SPCR2); tmp = bcm53xxspi_read(b53spi, B53SPI_MSPI_SPCR2);
if (!(tmp & B53SPI_MSPI_SPCR2_SPE)) if (!(tmp & B53SPI_MSPI_SPCR2_SPE))
...@@ -56,7 +56,7 @@ static int bcm53xxspi_wait(struct bcm53xxspi *b53spi, unsigned int timeout_ms) ...@@ -56,7 +56,7 @@ static int bcm53xxspi_wait(struct bcm53xxspi *b53spi, unsigned int timeout_ms)
goto spi_timeout; goto spi_timeout;
/* Check status */ /* Check status */
deadline = jiffies + timeout_ms * HZ / 1000; deadline = jiffies + msecs_to_jiffies(timeout_ms);
do { do {
tmp = bcm53xxspi_read(b53spi, B53SPI_MSPI_MSPI_STATUS); tmp = bcm53xxspi_read(b53spi, B53SPI_MSPI_MSPI_STATUS);
if (tmp & B53SPI_MSPI_MSPI_STATUS_SPIF) { if (tmp & B53SPI_MSPI_MSPI_STATUS_SPIF) {
......
...@@ -49,12 +49,17 @@ bitbang_txrx_be_cpha0(struct spi_device *spi, ...@@ -49,12 +49,17 @@ bitbang_txrx_be_cpha0(struct spi_device *spi,
{ {
/* if (cpol == 0) this is SPI_MODE_0; else this is SPI_MODE_2 */ /* if (cpol == 0) this is SPI_MODE_0; else this is SPI_MODE_2 */
bool oldbit = !(word & 1);
/* clock starts at inactive polarity */ /* clock starts at inactive polarity */
for (word <<= (32 - bits); likely(bits); bits--) { for (word <<= (32 - bits); likely(bits); bits--) {
/* setup MSB (to slave) on trailing edge */ /* setup MSB (to slave) on trailing edge */
if ((flags & SPI_MASTER_NO_TX) == 0) if ((flags & SPI_MASTER_NO_TX) == 0) {
if ((word & (1 << 31)) != oldbit) {
setmosi(spi, word & (1 << 31)); setmosi(spi, word & (1 << 31));
oldbit = word & (1 << 31);
}
}
spidelay(nsecs); /* T(setup) */ spidelay(nsecs); /* T(setup) */
setsck(spi, !cpol); setsck(spi, !cpol);
...@@ -76,13 +81,18 @@ bitbang_txrx_be_cpha1(struct spi_device *spi, ...@@ -76,13 +81,18 @@ bitbang_txrx_be_cpha1(struct spi_device *spi,
{ {
/* if (cpol == 0) this is SPI_MODE_1; else this is SPI_MODE_3 */ /* if (cpol == 0) this is SPI_MODE_1; else this is SPI_MODE_3 */
bool oldbit = !(word & (1 << 31));
/* clock starts at inactive polarity */ /* clock starts at inactive polarity */
for (word <<= (32 - bits); likely(bits); bits--) { for (word <<= (32 - bits); likely(bits); bits--) {
/* setup MSB (to slave) on leading edge */ /* setup MSB (to slave) on leading edge */
setsck(spi, !cpol); setsck(spi, !cpol);
if ((flags & SPI_MASTER_NO_TX) == 0) if ((flags & SPI_MASTER_NO_TX) == 0) {
if ((word & (1 << 31)) != oldbit) {
setmosi(spi, word & (1 << 31)); setmosi(spi, word & (1 << 31));
oldbit = word & (1 << 31);
}
}
spidelay(nsecs); /* T(setup) */ spidelay(nsecs); /* T(setup) */
setsck(spi, cpol); setsck(spi, cpol);
......
...@@ -850,6 +850,9 @@ static int spi_transfer_one_message(struct spi_master *master, ...@@ -850,6 +850,9 @@ static int spi_transfer_one_message(struct spi_master *master,
if (msg->status == -EINPROGRESS) if (msg->status == -EINPROGRESS)
msg->status = ret; msg->status = ret;
if (msg->status)
master->handle_err(master, msg);
spi_finalize_current_message(master); spi_finalize_current_message(master);
return ret; return ret;
......
...@@ -294,6 +294,8 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv) ...@@ -294,6 +294,8 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
* transfer_one_message are mutually exclusive; when both * transfer_one_message are mutually exclusive; when both
* are set, the generic subsystem does not call your * are set, the generic subsystem does not call your
* transfer_one callback. * transfer_one callback.
* @handle_err: the subsystem calls the driver to handle and error that occurs
* in the generic implementation of transfer_one_message().
* @unprepare_message: undo any work done by prepare_message(). * @unprepare_message: undo any work done by prepare_message().
* @cs_gpios: Array of GPIOs to use as chip select lines; one per CS * @cs_gpios: Array of GPIOs to use as chip select lines; one per CS
* number. Any individual value may be -ENOENT for CS lines that * number. Any individual value may be -ENOENT for CS lines that
...@@ -448,6 +450,8 @@ struct spi_master { ...@@ -448,6 +450,8 @@ struct spi_master {
void (*set_cs)(struct spi_device *spi, bool enable); void (*set_cs)(struct spi_device *spi, bool enable);
int (*transfer_one)(struct spi_master *master, struct spi_device *spi, int (*transfer_one)(struct spi_master *master, struct spi_device *spi,
struct spi_transfer *transfer); struct spi_transfer *transfer);
void (*handle_err)(struct spi_master *master,
struct spi_message *message);
/* gpio chip select */ /* gpio chip select */
int *cs_gpios; int *cs_gpios;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment