diff options
Diffstat (limited to 'drivers/spi/spi_s3c64xx.c')
-rw-r--r-- | drivers/spi/spi_s3c64xx.c | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/drivers/spi/spi_s3c64xx.c b/drivers/spi/spi_s3c64xx.c index 97365815a729..c3038da2648a 100644 --- a/drivers/spi/spi_s3c64xx.c +++ b/drivers/spi/spi_s3c64xx.c | |||
@@ -200,6 +200,9 @@ static void flush_fifo(struct s3c64xx_spi_driver_data *sdd) | |||
200 | val = readl(regs + S3C64XX_SPI_STATUS); | 200 | val = readl(regs + S3C64XX_SPI_STATUS); |
201 | } while (TX_FIFO_LVL(val, sci) && loops--); | 201 | } while (TX_FIFO_LVL(val, sci) && loops--); |
202 | 202 | ||
203 | if (loops == 0) | ||
204 | dev_warn(&sdd->pdev->dev, "Timed out flushing TX FIFO\n"); | ||
205 | |||
203 | /* Flush RxFIFO*/ | 206 | /* Flush RxFIFO*/ |
204 | loops = msecs_to_loops(1); | 207 | loops = msecs_to_loops(1); |
205 | do { | 208 | do { |
@@ -210,6 +213,9 @@ static void flush_fifo(struct s3c64xx_spi_driver_data *sdd) | |||
210 | break; | 213 | break; |
211 | } while (loops--); | 214 | } while (loops--); |
212 | 215 | ||
216 | if (loops == 0) | ||
217 | dev_warn(&sdd->pdev->dev, "Timed out flushing RX FIFO\n"); | ||
218 | |||
213 | val = readl(regs + S3C64XX_SPI_CH_CFG); | 219 | val = readl(regs + S3C64XX_SPI_CH_CFG); |
214 | val &= ~S3C64XX_SPI_CH_SW_RST; | 220 | val &= ~S3C64XX_SPI_CH_SW_RST; |
215 | writel(val, regs + S3C64XX_SPI_CH_CFG); | 221 | writel(val, regs + S3C64XX_SPI_CH_CFG); |
@@ -320,16 +326,17 @@ static int wait_for_xfer(struct s3c64xx_spi_driver_data *sdd, | |||
320 | 326 | ||
321 | /* millisecs to xfer 'len' bytes @ 'cur_speed' */ | 327 | /* millisecs to xfer 'len' bytes @ 'cur_speed' */ |
322 | ms = xfer->len * 8 * 1000 / sdd->cur_speed; | 328 | ms = xfer->len * 8 * 1000 / sdd->cur_speed; |
323 | ms += 5; /* some tolerance */ | 329 | ms += 10; /* some tolerance */ |
324 | 330 | ||
325 | if (dma_mode) { | 331 | if (dma_mode) { |
326 | val = msecs_to_jiffies(ms) + 10; | 332 | val = msecs_to_jiffies(ms) + 10; |
327 | val = wait_for_completion_timeout(&sdd->xfer_completion, val); | 333 | val = wait_for_completion_timeout(&sdd->xfer_completion, val); |
328 | } else { | 334 | } else { |
335 | u32 status; | ||
329 | val = msecs_to_loops(ms); | 336 | val = msecs_to_loops(ms); |
330 | do { | 337 | do { |
331 | val = readl(regs + S3C64XX_SPI_STATUS); | 338 | status = readl(regs + S3C64XX_SPI_STATUS); |
332 | } while (RX_FIFO_LVL(val, sci) < xfer->len && --val); | 339 | } while (RX_FIFO_LVL(status, sci) < xfer->len && --val); |
333 | } | 340 | } |
334 | 341 | ||
335 | if (!val) | 342 | if (!val) |
@@ -447,8 +454,8 @@ static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd) | |||
447 | writel(val, regs + S3C64XX_SPI_CLK_CFG); | 454 | writel(val, regs + S3C64XX_SPI_CLK_CFG); |
448 | } | 455 | } |
449 | 456 | ||
450 | void s3c64xx_spi_dma_rxcb(struct s3c2410_dma_chan *chan, void *buf_id, | 457 | static void s3c64xx_spi_dma_rxcb(struct s3c2410_dma_chan *chan, void *buf_id, |
451 | int size, enum s3c2410_dma_buffresult res) | 458 | int size, enum s3c2410_dma_buffresult res) |
452 | { | 459 | { |
453 | struct s3c64xx_spi_driver_data *sdd = buf_id; | 460 | struct s3c64xx_spi_driver_data *sdd = buf_id; |
454 | unsigned long flags; | 461 | unsigned long flags; |
@@ -467,8 +474,8 @@ void s3c64xx_spi_dma_rxcb(struct s3c2410_dma_chan *chan, void *buf_id, | |||
467 | spin_unlock_irqrestore(&sdd->lock, flags); | 474 | spin_unlock_irqrestore(&sdd->lock, flags); |
468 | } | 475 | } |
469 | 476 | ||
470 | void s3c64xx_spi_dma_txcb(struct s3c2410_dma_chan *chan, void *buf_id, | 477 | static void s3c64xx_spi_dma_txcb(struct s3c2410_dma_chan *chan, void *buf_id, |
471 | int size, enum s3c2410_dma_buffresult res) | 478 | int size, enum s3c2410_dma_buffresult res) |
472 | { | 479 | { |
473 | struct s3c64xx_spi_driver_data *sdd = buf_id; | 480 | struct s3c64xx_spi_driver_data *sdd = buf_id; |
474 | unsigned long flags; | 481 | unsigned long flags; |
@@ -508,8 +515,9 @@ static int s3c64xx_spi_map_mssg(struct s3c64xx_spi_driver_data *sdd, | |||
508 | list_for_each_entry(xfer, &msg->transfers, transfer_list) { | 515 | list_for_each_entry(xfer, &msg->transfers, transfer_list) { |
509 | 516 | ||
510 | if (xfer->tx_buf != NULL) { | 517 | if (xfer->tx_buf != NULL) { |
511 | xfer->tx_dma = dma_map_single(dev, xfer->tx_buf, | 518 | xfer->tx_dma = dma_map_single(dev, |
512 | xfer->len, DMA_TO_DEVICE); | 519 | (void *)xfer->tx_buf, xfer->len, |
520 | DMA_TO_DEVICE); | ||
513 | if (dma_mapping_error(dev, xfer->tx_dma)) { | 521 | if (dma_mapping_error(dev, xfer->tx_dma)) { |
514 | dev_err(dev, "dma_map_single Tx failed\n"); | 522 | dev_err(dev, "dma_map_single Tx failed\n"); |
515 | xfer->tx_dma = XFER_DMAADDR_INVALID; | 523 | xfer->tx_dma = XFER_DMAADDR_INVALID; |
@@ -919,6 +927,13 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev) | |||
919 | return -ENODEV; | 927 | return -ENODEV; |
920 | } | 928 | } |
921 | 929 | ||
930 | sci = pdev->dev.platform_data; | ||
931 | if (!sci->src_clk_name) { | ||
932 | dev_err(&pdev->dev, | ||
933 | "Board init must call s3c64xx_spi_set_info()\n"); | ||
934 | return -EINVAL; | ||
935 | } | ||
936 | |||
922 | /* Check for availability of necessary resource */ | 937 | /* Check for availability of necessary resource */ |
923 | 938 | ||
924 | dmatx_res = platform_get_resource(pdev, IORESOURCE_DMA, 0); | 939 | dmatx_res = platform_get_resource(pdev, IORESOURCE_DMA, 0); |
@@ -946,8 +961,6 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev) | |||
946 | return -ENOMEM; | 961 | return -ENOMEM; |
947 | } | 962 | } |
948 | 963 | ||
949 | sci = pdev->dev.platform_data; | ||
950 | |||
951 | platform_set_drvdata(pdev, master); | 964 | platform_set_drvdata(pdev, master); |
952 | 965 | ||
953 | sdd = spi_master_get_devdata(master); | 966 | sdd = spi_master_get_devdata(master); |
@@ -1170,7 +1183,7 @@ static int __init s3c64xx_spi_init(void) | |||
1170 | { | 1183 | { |
1171 | return platform_driver_probe(&s3c64xx_spi_driver, s3c64xx_spi_probe); | 1184 | return platform_driver_probe(&s3c64xx_spi_driver, s3c64xx_spi_probe); |
1172 | } | 1185 | } |
1173 | module_init(s3c64xx_spi_init); | 1186 | subsys_initcall(s3c64xx_spi_init); |
1174 | 1187 | ||
1175 | static void __exit s3c64xx_spi_exit(void) | 1188 | static void __exit s3c64xx_spi_exit(void) |
1176 | { | 1189 | { |