diff options
Diffstat (limited to 'drivers/spi/omap2_mcspi.c')
-rw-r--r-- | drivers/spi/omap2_mcspi.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c index 9d2186fd74aa..454a2712e629 100644 --- a/drivers/spi/omap2_mcspi.c +++ b/drivers/spi/omap2_mcspi.c | |||
@@ -119,12 +119,14 @@ struct omap2_mcspi { | |||
119 | struct clk *fck; | 119 | struct clk *fck; |
120 | /* Virtual base address of the controller */ | 120 | /* Virtual base address of the controller */ |
121 | void __iomem *base; | 121 | void __iomem *base; |
122 | unsigned long phys; | ||
122 | /* SPI1 has 4 channels, while SPI2 has 2 */ | 123 | /* SPI1 has 4 channels, while SPI2 has 2 */ |
123 | struct omap2_mcspi_dma *dma_channels; | 124 | struct omap2_mcspi_dma *dma_channels; |
124 | }; | 125 | }; |
125 | 126 | ||
126 | struct omap2_mcspi_cs { | 127 | struct omap2_mcspi_cs { |
127 | void __iomem *base; | 128 | void __iomem *base; |
129 | unsigned long phys; | ||
128 | int word_len; | 130 | int word_len; |
129 | }; | 131 | }; |
130 | 132 | ||
@@ -233,7 +235,7 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer) | |||
233 | c = count; | 235 | c = count; |
234 | word_len = cs->word_len; | 236 | word_len = cs->word_len; |
235 | 237 | ||
236 | base = (unsigned long) io_v2p(cs->base); | 238 | base = cs->phys; |
237 | tx_reg = base + OMAP2_MCSPI_TX0; | 239 | tx_reg = base + OMAP2_MCSPI_TX0; |
238 | rx_reg = base + OMAP2_MCSPI_RX0; | 240 | rx_reg = base + OMAP2_MCSPI_RX0; |
239 | rx = xfer->rx_buf; | 241 | rx = xfer->rx_buf; |
@@ -633,6 +635,7 @@ static int omap2_mcspi_setup(struct spi_device *spi) | |||
633 | if (!cs) | 635 | if (!cs) |
634 | return -ENOMEM; | 636 | return -ENOMEM; |
635 | cs->base = mcspi->base + spi->chip_select * 0x14; | 637 | cs->base = mcspi->base + spi->chip_select * 0x14; |
638 | cs->phys = mcspi->phys + spi->chip_select * 0x14; | ||
636 | spi->controller_state = cs; | 639 | spi->controller_state = cs; |
637 | } | 640 | } |
638 | 641 | ||
@@ -1005,7 +1008,13 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) | |||
1005 | goto err1; | 1008 | goto err1; |
1006 | } | 1009 | } |
1007 | 1010 | ||
1008 | mcspi->base = (void __iomem *) io_p2v(r->start); | 1011 | mcspi->phys = r->start; |
1012 | mcspi->base = ioremap(r->start, r->end - r->start + 1); | ||
1013 | if (!mcspi->base) { | ||
1014 | dev_dbg(&pdev->dev, "can't ioremap MCSPI\n"); | ||
1015 | status = -ENOMEM; | ||
1016 | goto err1aa; | ||
1017 | } | ||
1009 | 1018 | ||
1010 | INIT_WORK(&mcspi->work, omap2_mcspi_work); | 1019 | INIT_WORK(&mcspi->work, omap2_mcspi_work); |
1011 | 1020 | ||
@@ -1055,6 +1064,8 @@ err3: | |||
1055 | err2: | 1064 | err2: |
1056 | clk_put(mcspi->ick); | 1065 | clk_put(mcspi->ick); |
1057 | err1a: | 1066 | err1a: |
1067 | iounmap(mcspi->base); | ||
1068 | err1aa: | ||
1058 | release_mem_region(r->start, (r->end - r->start) + 1); | 1069 | release_mem_region(r->start, (r->end - r->start) + 1); |
1059 | err1: | 1070 | err1: |
1060 | spi_master_put(master); | 1071 | spi_master_put(master); |
@@ -1067,6 +1078,7 @@ static int __exit omap2_mcspi_remove(struct platform_device *pdev) | |||
1067 | struct omap2_mcspi *mcspi; | 1078 | struct omap2_mcspi *mcspi; |
1068 | struct omap2_mcspi_dma *dma_channels; | 1079 | struct omap2_mcspi_dma *dma_channels; |
1069 | struct resource *r; | 1080 | struct resource *r; |
1081 | void __iomem *base; | ||
1070 | 1082 | ||
1071 | master = dev_get_drvdata(&pdev->dev); | 1083 | master = dev_get_drvdata(&pdev->dev); |
1072 | mcspi = spi_master_get_devdata(master); | 1084 | mcspi = spi_master_get_devdata(master); |
@@ -1078,7 +1090,9 @@ static int __exit omap2_mcspi_remove(struct platform_device *pdev) | |||
1078 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1090 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1079 | release_mem_region(r->start, (r->end - r->start) + 1); | 1091 | release_mem_region(r->start, (r->end - r->start) + 1); |
1080 | 1092 | ||
1093 | base = mcspi->base; | ||
1081 | spi_unregister_master(master); | 1094 | spi_unregister_master(master); |
1095 | iounmap(base); | ||
1082 | kfree(dma_channels); | 1096 | kfree(dma_channels); |
1083 | 1097 | ||
1084 | return 0; | 1098 | return 0; |