aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-07-23 19:20:43 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-23 19:20:43 -0400
commit2fa379474fe2227d4d691d2d24eab4e3bdb3b26b (patch)
tree6d91e77cf398f992dc67bdd3be74b985640b1a42
parent4f2d658b2f09c41677871a4285a09cf35f954dad (diff)
parent85644d2a8893d72d1869c6347e791902dd414288 (diff)
Merge tag 'spi' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
Pull arm-soc spi updates from Arnd Bergmann: "These changes conceptually belong into the spi tree, but we decided to put them into arm-soc to better deal with interdependencies with other platform specific patches that are already there." * tag 'spi' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: spi/s3c64xx: Expand S3C64XX_SPI_{DE,}ACT macros at call sites spi/s3c64xx: Convert to devm_request_and_ioremap() spi/s3c64xx: Put the /CS GPIO into output mode spi/s3c64xx: Fix handling of errors in gpio_request()
-rw-r--r--drivers/spi/spi-s3c64xx.c42
1 files changed, 12 insertions, 30 deletions
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 0dedbbdb153a..646a7657fe62 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -79,11 +79,6 @@
79#define S3C64XX_SPI_SLAVE_AUTO (1<<1) 79#define S3C64XX_SPI_SLAVE_AUTO (1<<1)
80#define S3C64XX_SPI_SLAVE_SIG_INACT (1<<0) 80#define S3C64XX_SPI_SLAVE_SIG_INACT (1<<0)
81 81
82#define S3C64XX_SPI_ACT(c) writel(0, (c)->regs + S3C64XX_SPI_SLAVE_SEL)
83
84#define S3C64XX_SPI_DEACT(c) writel(S3C64XX_SPI_SLAVE_SIG_INACT, \
85 (c)->regs + S3C64XX_SPI_SLAVE_SEL)
86
87#define S3C64XX_SPI_INT_TRAILING_EN (1<<6) 82#define S3C64XX_SPI_INT_TRAILING_EN (1<<6)
88#define S3C64XX_SPI_INT_RX_OVERRUN_EN (1<<5) 83#define S3C64XX_SPI_INT_RX_OVERRUN_EN (1<<5)
89#define S3C64XX_SPI_INT_RX_UNDERRUN_EN (1<<4) 84#define S3C64XX_SPI_INT_RX_UNDERRUN_EN (1<<4)
@@ -737,14 +732,15 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master,
737 enable_cs(sdd, spi); 732 enable_cs(sdd, spi);
738 733
739 /* Start the signals */ 734 /* Start the signals */
740 S3C64XX_SPI_ACT(sdd); 735 writel(0, sdd->regs + S3C64XX_SPI_SLAVE_SEL);
741 736
742 spin_unlock_irqrestore(&sdd->lock, flags); 737 spin_unlock_irqrestore(&sdd->lock, flags);
743 738
744 status = wait_for_xfer(sdd, xfer, use_dma); 739 status = wait_for_xfer(sdd, xfer, use_dma);
745 740
746 /* Quiese the signals */ 741 /* Quiese the signals */
747 S3C64XX_SPI_DEACT(sdd); 742 writel(S3C64XX_SPI_SLAVE_SIG_INACT,
743 sdd->regs + S3C64XX_SPI_SLAVE_SEL);
748 744
749 if (status) { 745 if (status) {
750 dev_err(&spi->dev, "I/O Error: " 746 dev_err(&spi->dev, "I/O Error: "
@@ -894,11 +890,12 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
894 } 890 }
895 891
896 if (!spi_get_ctldata(spi)) { 892 if (!spi_get_ctldata(spi)) {
897 err = gpio_request(cs->line, dev_name(&spi->dev)); 893 err = gpio_request_one(cs->line, GPIOF_OUT_INIT_HIGH,
894 dev_name(&spi->dev));
898 if (err) { 895 if (err) {
899 dev_err(&spi->dev, "request for slave select gpio " 896 dev_err(&spi->dev,
900 "line [%d] failed\n", cs->line); 897 "Failed to get /CS gpio [%d]: %d\n",
901 err = -EBUSY; 898 cs->line, err);
902 goto err_gpio_req; 899 goto err_gpio_req;
903 } 900 }
904 spi_set_ctldata(spi, cs); 901 spi_set_ctldata(spi, cs);
@@ -1031,7 +1028,7 @@ static void s3c64xx_spi_hwinit(struct s3c64xx_spi_driver_data *sdd, int channel)
1031 1028
1032 sdd->cur_speed = 0; 1029 sdd->cur_speed = 0;
1033 1030
1034 S3C64XX_SPI_DEACT(sdd); 1031 writel(S3C64XX_SPI_SLAVE_SIG_INACT, sdd->regs + S3C64XX_SPI_SLAVE_SEL);
1035 1032
1036 /* Disable Interrupts - we use Polling if not DMA mode */ 1033 /* Disable Interrupts - we use Polling if not DMA mode */
1037 writel(0, regs + S3C64XX_SPI_INT_EN); 1034 writel(0, regs + S3C64XX_SPI_INT_EN);
@@ -1116,7 +1113,8 @@ static int s3c64xx_spi_parse_dt_gpio(struct s3c64xx_spi_driver_data *sdd)
1116 1113
1117 ret = gpio_request(gpio, "spi-bus"); 1114 ret = gpio_request(gpio, "spi-bus");
1118 if (ret) { 1115 if (ret) {
1119 dev_err(dev, "gpio [%d] request failed\n", gpio); 1116 dev_err(dev, "gpio [%d] request failed: %d\n",
1117 gpio, ret);
1120 goto free_gpio; 1118 goto free_gpio;
1121 } 1119 }
1122 } 1120 }
@@ -1278,14 +1276,7 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
1278 /* the spi->mode bits understood by this driver: */ 1276 /* the spi->mode bits understood by this driver: */
1279 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; 1277 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
1280 1278
1281 if (request_mem_region(mem_res->start, 1279 sdd->regs = devm_request_and_ioremap(&pdev->dev, mem_res);
1282 resource_size(mem_res), pdev->name) == NULL) {
1283 dev_err(&pdev->dev, "Req mem region failed\n");
1284 ret = -ENXIO;
1285 goto err0;
1286 }
1287
1288 sdd->regs = ioremap(mem_res->start, resource_size(mem_res));
1289 if (sdd->regs == NULL) { 1280 if (sdd->regs == NULL) {
1290 dev_err(&pdev->dev, "Unable to remap IO\n"); 1281 dev_err(&pdev->dev, "Unable to remap IO\n");
1291 ret = -ENXIO; 1282 ret = -ENXIO;
@@ -1379,9 +1370,7 @@ err3:
1379 if (!sdd->cntrlr_info->cfg_gpio && pdev->dev.of_node) 1370 if (!sdd->cntrlr_info->cfg_gpio && pdev->dev.of_node)
1380 s3c64xx_spi_dt_gpio_free(sdd); 1371 s3c64xx_spi_dt_gpio_free(sdd);
1381err2: 1372err2:
1382 iounmap((void *) sdd->regs);
1383err1: 1373err1:
1384 release_mem_region(mem_res->start, resource_size(mem_res));
1385err0: 1374err0:
1386 platform_set_drvdata(pdev, NULL); 1375 platform_set_drvdata(pdev, NULL);
1387 spi_master_put(master); 1376 spi_master_put(master);
@@ -1393,7 +1382,6 @@ static int s3c64xx_spi_remove(struct platform_device *pdev)
1393{ 1382{
1394 struct spi_master *master = spi_master_get(platform_get_drvdata(pdev)); 1383 struct spi_master *master = spi_master_get(platform_get_drvdata(pdev));
1395 struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); 1384 struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master);
1396 struct resource *mem_res;
1397 1385
1398 pm_runtime_disable(&pdev->dev); 1386 pm_runtime_disable(&pdev->dev);
1399 1387
@@ -1412,12 +1400,6 @@ static int s3c64xx_spi_remove(struct platform_device *pdev)
1412 if (!sdd->cntrlr_info->cfg_gpio && pdev->dev.of_node) 1400 if (!sdd->cntrlr_info->cfg_gpio && pdev->dev.of_node)
1413 s3c64xx_spi_dt_gpio_free(sdd); 1401 s3c64xx_spi_dt_gpio_free(sdd);
1414 1402
1415 iounmap((void *) sdd->regs);
1416
1417 mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1418 if (mem_res != NULL)
1419 release_mem_region(mem_res->start, resource_size(mem_res));
1420
1421 platform_set_drvdata(pdev, NULL); 1403 platform_set_drvdata(pdev, NULL);
1422 spi_master_put(master); 1404 spi_master_put(master);
1423 1405