aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi_imx.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi/spi_imx.c')
-rw-r--r--drivers/spi/spi_imx.c70
1 files changed, 35 insertions, 35 deletions
diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c
index 61ba147e384d..269a55ec52ef 100644
--- a/drivers/spi/spi_imx.c
+++ b/drivers/spi/spi_imx.c
@@ -506,20 +506,6 @@ static int map_dma_buffers(struct driver_data *drv_data)
506 if (!IS_DMA_ALIGNED(drv_data->rx) || !IS_DMA_ALIGNED(drv_data->tx)) 506 if (!IS_DMA_ALIGNED(drv_data->rx) || !IS_DMA_ALIGNED(drv_data->tx))
507 return -1; 507 return -1;
508 508
509 /* NULL rx means write-only transfer and no map needed
510 since rx DMA will not be used */
511 if (drv_data->rx) {
512 buf = drv_data->rx;
513 drv_data->rx_dma = dma_map_single(
514 dev,
515 buf,
516 drv_data->len,
517 DMA_FROM_DEVICE);
518 if (dma_mapping_error(dev, drv_data->rx_dma))
519 return -1;
520 drv_data->rx_dma_needs_unmap = 1;
521 }
522
523 if (drv_data->tx == NULL) { 509 if (drv_data->tx == NULL) {
524 /* Read only message --> use drv_data->dummy_dma_buf for dummy 510 /* Read only message --> use drv_data->dummy_dma_buf for dummy
525 writes to achive reads */ 511 writes to achive reads */
@@ -533,18 +519,31 @@ static int map_dma_buffers(struct driver_data *drv_data)
533 buf, 519 buf,
534 drv_data->tx_map_len, 520 drv_data->tx_map_len,
535 DMA_TO_DEVICE); 521 DMA_TO_DEVICE);
536 if (dma_mapping_error(dev, drv_data->tx_dma)) { 522 if (dma_mapping_error(dev, drv_data->tx_dma))
537 if (drv_data->rx_dma) {
538 dma_unmap_single(dev,
539 drv_data->rx_dma,
540 drv_data->len,
541 DMA_FROM_DEVICE);
542 drv_data->rx_dma_needs_unmap = 0;
543 }
544 return -1; 523 return -1;
545 }
546 drv_data->tx_dma_needs_unmap = 1; 524 drv_data->tx_dma_needs_unmap = 1;
547 525
526 /* NULL rx means write-only transfer and no map needed
527 * since rx DMA will not be used */
528 if (drv_data->rx) {
529 buf = drv_data->rx;
530 drv_data->rx_dma = dma_map_single(dev,
531 buf,
532 drv_data->len,
533 DMA_FROM_DEVICE);
534 if (dma_mapping_error(dev, drv_data->rx_dma)) {
535 if (drv_data->tx_dma) {
536 dma_unmap_single(dev,
537 drv_data->tx_dma,
538 drv_data->tx_map_len,
539 DMA_TO_DEVICE);
540 drv_data->tx_dma_needs_unmap = 0;
541 }
542 return -1;
543 }
544 drv_data->rx_dma_needs_unmap = 1;
545 }
546
548 return 0; 547 return 0;
549} 548}
550 549
@@ -1457,7 +1456,7 @@ static int __init spi_imx_probe(struct platform_device *pdev)
1457 struct device *dev = &pdev->dev; 1456 struct device *dev = &pdev->dev;
1458 struct spi_imx_master *platform_info; 1457 struct spi_imx_master *platform_info;
1459 struct spi_master *master; 1458 struct spi_master *master;
1460 struct driver_data *drv_data = NULL; 1459 struct driver_data *drv_data;
1461 struct resource *res; 1460 struct resource *res;
1462 int irq, status = 0; 1461 int irq, status = 0;
1463 1462
@@ -1468,14 +1467,6 @@ static int __init spi_imx_probe(struct platform_device *pdev)
1468 goto err_no_pdata; 1467 goto err_no_pdata;
1469 } 1468 }
1470 1469
1471 drv_data->clk = clk_get(&pdev->dev, "perclk2");
1472 if (IS_ERR(drv_data->clk)) {
1473 dev_err(&pdev->dev, "probe - cannot get get\n");
1474 status = PTR_ERR(drv_data->clk);
1475 goto err_no_clk;
1476 }
1477 clk_enable(drv_data->clk);
1478
1479 /* Allocate master with space for drv_data */ 1470 /* Allocate master with space for drv_data */
1480 master = spi_alloc_master(dev, sizeof(struct driver_data)); 1471 master = spi_alloc_master(dev, sizeof(struct driver_data));
1481 if (!master) { 1472 if (!master) {
@@ -1496,6 +1487,14 @@ static int __init spi_imx_probe(struct platform_device *pdev)
1496 1487
1497 drv_data->dummy_dma_buf = SPI_DUMMY_u32; 1488 drv_data->dummy_dma_buf = SPI_DUMMY_u32;
1498 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
1499 /* Find and map resources */ 1498 /* Find and map resources */
1500 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1499 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1501 if (!res) { 1500 if (!res) {
@@ -1631,12 +1630,13 @@ err_no_iomap:
1631 kfree(drv_data->ioarea); 1630 kfree(drv_data->ioarea);
1632 1631
1633err_no_iores: 1632err_no_iores:
1634 spi_master_put(master);
1635
1636err_no_pdata:
1637 clk_disable(drv_data->clk); 1633 clk_disable(drv_data->clk);
1638 clk_put(drv_data->clk); 1634 clk_put(drv_data->clk);
1635
1639err_no_clk: 1636err_no_clk:
1637 spi_master_put(master);
1638
1639err_no_pdata:
1640err_no_mem: 1640err_no_mem:
1641 return status; 1641 return status;
1642} 1642}