aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/atmel_spi.c
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2011-01-13 01:06:28 -0500
committerPaul Mundt <lethal@linux-sh.org>2011-01-13 01:06:28 -0500
commitf43dc23d5ea91fca257be02138a255f02d98e806 (patch)
treeb29722f6e965316e90ac97abf79923ced250dc21 /drivers/spi/atmel_spi.c
parentf8e53553f452dcbf67cb89c8cba63a1cd6eb4cc0 (diff)
parent4162cf64973df51fc885825bc9ca4d055891c49f (diff)
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6 into common/serial-rework
Conflicts: arch/sh/kernel/cpu/sh2/setup-sh7619.c arch/sh/kernel/cpu/sh2a/setup-mxg.c arch/sh/kernel/cpu/sh2a/setup-sh7201.c arch/sh/kernel/cpu/sh2a/setup-sh7203.c arch/sh/kernel/cpu/sh2a/setup-sh7206.c arch/sh/kernel/cpu/sh3/setup-sh7705.c arch/sh/kernel/cpu/sh3/setup-sh770x.c arch/sh/kernel/cpu/sh3/setup-sh7710.c arch/sh/kernel/cpu/sh3/setup-sh7720.c arch/sh/kernel/cpu/sh4/setup-sh4-202.c arch/sh/kernel/cpu/sh4/setup-sh7750.c arch/sh/kernel/cpu/sh4/setup-sh7760.c arch/sh/kernel/cpu/sh4a/setup-sh7343.c arch/sh/kernel/cpu/sh4a/setup-sh7366.c arch/sh/kernel/cpu/sh4a/setup-sh7722.c arch/sh/kernel/cpu/sh4a/setup-sh7723.c arch/sh/kernel/cpu/sh4a/setup-sh7724.c arch/sh/kernel/cpu/sh4a/setup-sh7763.c arch/sh/kernel/cpu/sh4a/setup-sh7770.c arch/sh/kernel/cpu/sh4a/setup-sh7780.c arch/sh/kernel/cpu/sh4a/setup-sh7785.c arch/sh/kernel/cpu/sh4a/setup-sh7786.c arch/sh/kernel/cpu/sh4a/setup-shx3.c arch/sh/kernel/cpu/sh5/setup-sh5.c drivers/serial/sh-sci.c drivers/serial/sh-sci.h include/linux/serial_sci.h
Diffstat (limited to 'drivers/spi/atmel_spi.c')
-rw-r--r--drivers/spi/atmel_spi.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index f5b3fdbb1e27..a067046c9da2 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -18,6 +18,7 @@
18#include <linux/err.h> 18#include <linux/err.h>
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/spi/spi.h> 20#include <linux/spi/spi.h>
21#include <linux/slab.h>
21 22
22#include <asm/io.h> 23#include <asm/io.h>
23#include <mach/board.h> 24#include <mach/board.h>
@@ -189,14 +190,14 @@ static void atmel_spi_next_xfer_data(struct spi_master *master,
189 190
190 /* use scratch buffer only when rx or tx data is unspecified */ 191 /* use scratch buffer only when rx or tx data is unspecified */
191 if (xfer->rx_buf) 192 if (xfer->rx_buf)
192 *rx_dma = xfer->rx_dma + xfer->len - len; 193 *rx_dma = xfer->rx_dma + xfer->len - *plen;
193 else { 194 else {
194 *rx_dma = as->buffer_dma; 195 *rx_dma = as->buffer_dma;
195 if (len > BUFFER_SIZE) 196 if (len > BUFFER_SIZE)
196 len = BUFFER_SIZE; 197 len = BUFFER_SIZE;
197 } 198 }
198 if (xfer->tx_buf) 199 if (xfer->tx_buf)
199 *tx_dma = xfer->tx_dma + xfer->len - len; 200 *tx_dma = xfer->tx_dma + xfer->len - *plen;
200 else { 201 else {
201 *tx_dma = as->buffer_dma; 202 *tx_dma = as->buffer_dma;
202 if (len > BUFFER_SIZE) 203 if (len > BUFFER_SIZE)
@@ -351,8 +352,12 @@ atmel_spi_dma_map_xfer(struct atmel_spi *as, struct spi_transfer *xfer)
351 352
352 xfer->tx_dma = xfer->rx_dma = INVALID_DMA_ADDRESS; 353 xfer->tx_dma = xfer->rx_dma = INVALID_DMA_ADDRESS;
353 if (xfer->tx_buf) { 354 if (xfer->tx_buf) {
355 /* tx_buf is a const void* where we need a void * for the dma
356 * mapping */
357 void *nonconst_tx = (void *)xfer->tx_buf;
358
354 xfer->tx_dma = dma_map_single(dev, 359 xfer->tx_dma = dma_map_single(dev,
355 (void *) xfer->tx_buf, xfer->len, 360 nonconst_tx, xfer->len,
356 DMA_TO_DEVICE); 361 DMA_TO_DEVICE);
357 if (dma_mapping_error(dev, xfer->tx_dma)) 362 if (dma_mapping_error(dev, xfer->tx_dma))
358 return -ENOMEM; 363 return -ENOMEM;
@@ -653,6 +658,8 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *msg)
653 struct spi_transfer *xfer; 658 struct spi_transfer *xfer;
654 unsigned long flags; 659 unsigned long flags;
655 struct device *controller = spi->master->dev.parent; 660 struct device *controller = spi->master->dev.parent;
661 u8 bits;
662 struct atmel_spi_device *asd;
656 663
657 as = spi_master_get_devdata(spi->master); 664 as = spi_master_get_devdata(spi->master);
658 665
@@ -671,8 +678,18 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *msg)
671 return -EINVAL; 678 return -EINVAL;
672 } 679 }
673 680
681 if (xfer->bits_per_word) {
682 asd = spi->controller_state;
683 bits = (asd->csr >> 4) & 0xf;
684 if (bits != xfer->bits_per_word - 8) {
685 dev_dbg(&spi->dev, "you can't yet change "
686 "bits_per_word in transfers\n");
687 return -ENOPROTOOPT;
688 }
689 }
690
674 /* FIXME implement these protocol options!! */ 691 /* FIXME implement these protocol options!! */
675 if (xfer->bits_per_word || xfer->speed_hz) { 692 if (xfer->speed_hz) {
676 dev_dbg(&spi->dev, "no protocol options yet\n"); 693 dev_dbg(&spi->dev, "no protocol options yet\n");
677 return -ENOPROTOOPT; 694 return -ENOPROTOOPT;
678 } 695 }
@@ -788,7 +805,7 @@ static int __init atmel_spi_probe(struct platform_device *pdev)
788 spin_lock_init(&as->lock); 805 spin_lock_init(&as->lock);
789 INIT_LIST_HEAD(&as->queue); 806 INIT_LIST_HEAD(&as->queue);
790 as->pdev = pdev; 807 as->pdev = pdev;
791 as->regs = ioremap(regs->start, (regs->end - regs->start) + 1); 808 as->regs = ioremap(regs->start, resource_size(regs));
792 if (!as->regs) 809 if (!as->regs)
793 goto out_free_buffer; 810 goto out_free_buffer;
794 as->irq = irq; 811 as->irq = irq;