aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2008-12-13 04:12:51 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-12-13 04:12:51 -0500
commit72aaf09fda49f5919d98d65d35e5179f3acb0497 (patch)
tree5fd25748f7f5640f8ee8efb86ddca88d12840791 /drivers/spi
parent67fbc2312312095acc2f19a0b601bac10f84cf9d (diff)
parent58c2467355ed3154a12ee49d8f8236547145c9d3 (diff)
Merge git://git.marvell.com/orion into devel
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/au1550_spi.c26
-rw-r--r--drivers/spi/mpc52xx_psc_spi.c5
-rw-r--r--drivers/spi/spi_imx.c25
-rw-r--r--drivers/spi/spi_s3c24xx_gpio.c3
-rw-r--r--drivers/spi/spidev.c4
5 files changed, 38 insertions, 25 deletions
diff --git a/drivers/spi/au1550_spi.c b/drivers/spi/au1550_spi.c
index 87b73e0169c5..b02f25c702fd 100644
--- a/drivers/spi/au1550_spi.c
+++ b/drivers/spi/au1550_spi.c
@@ -369,10 +369,23 @@ static int au1550_spi_dma_txrxb(struct spi_device *spi, struct spi_transfer *t)
369 dma_rx_addr = t->rx_dma; 369 dma_rx_addr = t->rx_dma;
370 370
371 /* 371 /*
372 * check if buffers are already dma mapped, map them otherwise 372 * check if buffers are already dma mapped, map them otherwise:
373 * - first map the TX buffer, so cache data gets written to memory
374 * - then map the RX buffer, so that cache entries (with
375 * soon-to-be-stale data) get removed
373 * use rx buffer in place of tx if tx buffer was not provided 376 * use rx buffer in place of tx if tx buffer was not provided
374 * use temp rx buffer (preallocated or realloc to fit) for rx dma 377 * use temp rx buffer (preallocated or realloc to fit) for rx dma
375 */ 378 */
379 if (t->tx_buf) {
380 if (t->tx_dma == 0) { /* if DMA_ADDR_INVALID, map it */
381 dma_tx_addr = dma_map_single(hw->dev,
382 (void *)t->tx_buf,
383 t->len, DMA_TO_DEVICE);
384 if (dma_mapping_error(hw->dev, dma_tx_addr))
385 dev_err(hw->dev, "tx dma map error\n");
386 }
387 }
388
376 if (t->rx_buf) { 389 if (t->rx_buf) {
377 if (t->rx_dma == 0) { /* if DMA_ADDR_INVALID, map it */ 390 if (t->rx_dma == 0) { /* if DMA_ADDR_INVALID, map it */
378 dma_rx_addr = dma_map_single(hw->dev, 391 dma_rx_addr = dma_map_single(hw->dev,
@@ -396,15 +409,8 @@ static int au1550_spi_dma_txrxb(struct spi_device *spi, struct spi_transfer *t)
396 dma_sync_single_for_device(hw->dev, dma_rx_addr, 409 dma_sync_single_for_device(hw->dev, dma_rx_addr,
397 t->len, DMA_FROM_DEVICE); 410 t->len, DMA_FROM_DEVICE);
398 } 411 }
399 if (t->tx_buf) { 412
400 if (t->tx_dma == 0) { /* if DMA_ADDR_INVALID, map it */ 413 if (!t->tx_buf) {
401 dma_tx_addr = dma_map_single(hw->dev,
402 (void *)t->tx_buf,
403 t->len, DMA_TO_DEVICE);
404 if (dma_mapping_error(hw->dev, dma_tx_addr))
405 dev_err(hw->dev, "tx dma map error\n");
406 }
407 } else {
408 dma_sync_single_for_device(hw->dev, dma_rx_addr, 414 dma_sync_single_for_device(hw->dev, dma_rx_addr,
409 t->len, DMA_BIDIRECTIONAL); 415 t->len, DMA_BIDIRECTIONAL);
410 hw->tx = hw->rx; 416 hw->tx = hw->rx;
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c
index 0debe11b67b4..3b97803e1d11 100644
--- a/drivers/spi/mpc52xx_psc_spi.c
+++ b/drivers/spi/mpc52xx_psc_spi.c
@@ -142,6 +142,7 @@ static int mpc52xx_psc_spi_transfer_rxtx(struct spi_device *spi,
142 unsigned rfalarm; 142 unsigned rfalarm;
143 unsigned send_at_once = MPC52xx_PSC_BUFSIZE; 143 unsigned send_at_once = MPC52xx_PSC_BUFSIZE;
144 unsigned recv_at_once; 144 unsigned recv_at_once;
145 int last_block = 0;
145 146
146 if (!t->tx_buf && !t->rx_buf && t->len) 147 if (!t->tx_buf && !t->rx_buf && t->len)
147 return -EINVAL; 148 return -EINVAL;
@@ -151,15 +152,17 @@ static int mpc52xx_psc_spi_transfer_rxtx(struct spi_device *spi,
151 while (rb < t->len) { 152 while (rb < t->len) {
152 if (t->len - rb > MPC52xx_PSC_BUFSIZE) { 153 if (t->len - rb > MPC52xx_PSC_BUFSIZE) {
153 rfalarm = MPC52xx_PSC_RFALARM; 154 rfalarm = MPC52xx_PSC_RFALARM;
155 last_block = 0;
154 } else { 156 } else {
155 send_at_once = t->len - sb; 157 send_at_once = t->len - sb;
156 rfalarm = MPC52xx_PSC_BUFSIZE - (t->len - rb); 158 rfalarm = MPC52xx_PSC_BUFSIZE - (t->len - rb);
159 last_block = 1;
157 } 160 }
158 161
159 dev_dbg(&spi->dev, "send %d bytes...\n", send_at_once); 162 dev_dbg(&spi->dev, "send %d bytes...\n", send_at_once);
160 for (; send_at_once; sb++, send_at_once--) { 163 for (; send_at_once; sb++, send_at_once--) {
161 /* set EOF flag before the last word is sent */ 164 /* set EOF flag before the last word is sent */
162 if (send_at_once == 1) 165 if (send_at_once == 1 && last_block)
163 out_8(&psc->ircr2, 0x01); 166 out_8(&psc->ircr2, 0x01);
164 167
165 if (tx_buf) 168 if (tx_buf)
diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c
index 0b4db0ce78d6..269a55ec52ef 100644
--- a/drivers/spi/spi_imx.c
+++ b/drivers/spi/spi_imx.c
@@ -1456,7 +1456,7 @@ static int __init spi_imx_probe(struct platform_device *pdev)
1456 struct device *dev = &pdev->dev; 1456 struct device *dev = &pdev->dev;
1457 struct spi_imx_master *platform_info; 1457 struct spi_imx_master *platform_info;
1458 struct spi_master *master; 1458 struct spi_master *master;
1459 struct driver_data *drv_data = NULL; 1459 struct driver_data *drv_data;
1460 struct resource *res; 1460 struct resource *res;
1461 int irq, status = 0; 1461 int irq, status = 0;
1462 1462
@@ -1467,14 +1467,6 @@ static int __init spi_imx_probe(struct platform_device *pdev)
1467 goto err_no_pdata; 1467 goto err_no_pdata;
1468 } 1468 }
1469 1469
1470 drv_data->clk = clk_get(&pdev->dev, "perclk2");
1471 if (IS_ERR(drv_data->clk)) {
1472 dev_err(&pdev->dev, "probe - cannot get get\n");
1473 status = PTR_ERR(drv_data->clk);
1474 goto err_no_clk;
1475 }
1476 clk_enable(drv_data->clk);
1477
1478 /* Allocate master with space for drv_data */ 1470 /* Allocate master with space for drv_data */
1479 master = spi_alloc_master(dev, sizeof(struct driver_data)); 1471 master = spi_alloc_master(dev, sizeof(struct driver_data));
1480 if (!master) { 1472 if (!master) {
@@ -1495,6 +1487,14 @@ static int __init spi_imx_probe(struct platform_device *pdev)
1495 1487
1496 drv_data->dummy_dma_buf = SPI_DUMMY_u32; 1488 drv_data->dummy_dma_buf = SPI_DUMMY_u32;
1497 1489
1490 drv_data->clk = clk_get(&pdev->dev, "perclk2");
1491 if (IS_ERR(drv_data->clk)) {
1492 dev_err(&pdev->dev, "probe - cannot get clock\n");
1493 status = PTR_ERR(drv_data->clk);
1494 goto err_no_clk;
1495 }
1496 clk_enable(drv_data->clk);
1497
1498 /* Find and map resources */ 1498 /* Find and map resources */
1499 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1499 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1500 if (!res) { 1500 if (!res) {
@@ -1630,12 +1630,13 @@ err_no_iomap:
1630 kfree(drv_data->ioarea); 1630 kfree(drv_data->ioarea);
1631 1631
1632err_no_iores: 1632err_no_iores:
1633 spi_master_put(master);
1634
1635err_no_pdata:
1636 clk_disable(drv_data->clk); 1633 clk_disable(drv_data->clk);
1637 clk_put(drv_data->clk); 1634 clk_put(drv_data->clk);
1635
1638err_no_clk: 1636err_no_clk:
1637 spi_master_put(master);
1638
1639err_no_pdata:
1639err_no_mem: 1640err_no_mem:
1640 return status; 1641 return status;
1641} 1642}
diff --git a/drivers/spi/spi_s3c24xx_gpio.c b/drivers/spi/spi_s3c24xx_gpio.c
index cc1f647f579b..f2447a5476bb 100644
--- a/drivers/spi/spi_s3c24xx_gpio.c
+++ b/drivers/spi/spi_s3c24xx_gpio.c
@@ -34,7 +34,7 @@ struct s3c2410_spigpio {
34 34
35static inline struct s3c2410_spigpio *spidev_to_sg(struct spi_device *spi) 35static inline struct s3c2410_spigpio *spidev_to_sg(struct spi_device *spi)
36{ 36{
37 return spi->controller_data; 37 return spi_master_get_devdata(spi->master);
38} 38}
39 39
40static inline void setsck(struct spi_device *dev, int on) 40static inline void setsck(struct spi_device *dev, int on)
@@ -118,6 +118,7 @@ static int s3c2410_spigpio_probe(struct platform_device *dev)
118 /* setup spi bitbang adaptor */ 118 /* setup spi bitbang adaptor */
119 sp->bitbang.master = spi_master_get(master); 119 sp->bitbang.master = spi_master_get(master);
120 sp->bitbang.master->bus_num = info->bus_num; 120 sp->bitbang.master->bus_num = info->bus_num;
121 sp->bitbang.master->num_chipselect = info->num_chipselect;
121 sp->bitbang.chipselect = s3c2410_spigpio_chipselect; 122 sp->bitbang.chipselect = s3c2410_spigpio_chipselect;
122 123
123 sp->bitbang.txrx_word[SPI_MODE_0] = s3c2410_spigpio_txrx_mode0; 124 sp->bitbang.txrx_word[SPI_MODE_0] = s3c2410_spigpio_txrx_mode0;
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index 89a43755a453..5d869c4d3eb2 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -597,7 +597,9 @@ static int spidev_probe(struct spi_device *spi)
597 } 597 }
598 mutex_unlock(&device_list_lock); 598 mutex_unlock(&device_list_lock);
599 599
600 if (status != 0) 600 if (status == 0)
601 spi_set_drvdata(spi, spidev);
602 else
601 kfree(spidev); 603 kfree(spidev);
602 604
603 return status; 605 return status;