diff options
Diffstat (limited to 'drivers/spi/omap2_mcspi.c')
-rw-r--r-- | drivers/spi/omap2_mcspi.c | 112 |
1 files changed, 29 insertions, 83 deletions
diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c index f076cc5c6fb0..f7851325c61e 100644 --- a/drivers/spi/omap2_mcspi.c +++ b/drivers/spi/omap2_mcspi.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Copyright (C) 2005, 2006 Nokia Corporation | 4 | * Copyright (C) 2005, 2006 Nokia Corporation |
5 | * Author: Samuel Ortiz <samuel.ortiz@nokia.com> and | 5 | * Author: Samuel Ortiz <samuel.ortiz@nokia.com> and |
6 | * Juha Yrjölä <juha.yrjola@nokia.com> | 6 | * Juha Yrj�l� <juha.yrjola@nokia.com> |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by | 9 | * it under the terms of the GNU General Public License as published by |
@@ -1087,91 +1087,14 @@ static int __init omap2_mcspi_reset(struct omap2_mcspi *mcspi) | |||
1087 | return 0; | 1087 | return 0; |
1088 | } | 1088 | } |
1089 | 1089 | ||
1090 | static u8 __initdata spi1_rxdma_id [] = { | ||
1091 | OMAP24XX_DMA_SPI1_RX0, | ||
1092 | OMAP24XX_DMA_SPI1_RX1, | ||
1093 | OMAP24XX_DMA_SPI1_RX2, | ||
1094 | OMAP24XX_DMA_SPI1_RX3, | ||
1095 | }; | ||
1096 | |||
1097 | static u8 __initdata spi1_txdma_id [] = { | ||
1098 | OMAP24XX_DMA_SPI1_TX0, | ||
1099 | OMAP24XX_DMA_SPI1_TX1, | ||
1100 | OMAP24XX_DMA_SPI1_TX2, | ||
1101 | OMAP24XX_DMA_SPI1_TX3, | ||
1102 | }; | ||
1103 | |||
1104 | static u8 __initdata spi2_rxdma_id[] = { | ||
1105 | OMAP24XX_DMA_SPI2_RX0, | ||
1106 | OMAP24XX_DMA_SPI2_RX1, | ||
1107 | }; | ||
1108 | |||
1109 | static u8 __initdata spi2_txdma_id[] = { | ||
1110 | OMAP24XX_DMA_SPI2_TX0, | ||
1111 | OMAP24XX_DMA_SPI2_TX1, | ||
1112 | }; | ||
1113 | |||
1114 | #if defined(CONFIG_SOC_OMAP2430) || defined(CONFIG_ARCH_OMAP3) \ | ||
1115 | || defined(CONFIG_ARCH_OMAP4) | ||
1116 | static u8 __initdata spi3_rxdma_id[] = { | ||
1117 | OMAP24XX_DMA_SPI3_RX0, | ||
1118 | OMAP24XX_DMA_SPI3_RX1, | ||
1119 | }; | ||
1120 | |||
1121 | static u8 __initdata spi3_txdma_id[] = { | ||
1122 | OMAP24XX_DMA_SPI3_TX0, | ||
1123 | OMAP24XX_DMA_SPI3_TX1, | ||
1124 | }; | ||
1125 | #endif | ||
1126 | |||
1127 | #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4) | ||
1128 | static u8 __initdata spi4_rxdma_id[] = { | ||
1129 | OMAP34XX_DMA_SPI4_RX0, | ||
1130 | }; | ||
1131 | |||
1132 | static u8 __initdata spi4_txdma_id[] = { | ||
1133 | OMAP34XX_DMA_SPI4_TX0, | ||
1134 | }; | ||
1135 | #endif | ||
1136 | 1090 | ||
1137 | static int __init omap2_mcspi_probe(struct platform_device *pdev) | 1091 | static int __init omap2_mcspi_probe(struct platform_device *pdev) |
1138 | { | 1092 | { |
1139 | struct spi_master *master; | 1093 | struct spi_master *master; |
1094 | struct omap2_mcspi_platform_config *pdata = pdev->dev.platform_data; | ||
1140 | struct omap2_mcspi *mcspi; | 1095 | struct omap2_mcspi *mcspi; |
1141 | struct resource *r; | 1096 | struct resource *r; |
1142 | int status = 0, i; | 1097 | int status = 0, i; |
1143 | const u8 *rxdma_id, *txdma_id; | ||
1144 | unsigned num_chipselect; | ||
1145 | |||
1146 | switch (pdev->id) { | ||
1147 | case 1: | ||
1148 | rxdma_id = spi1_rxdma_id; | ||
1149 | txdma_id = spi1_txdma_id; | ||
1150 | num_chipselect = 4; | ||
1151 | break; | ||
1152 | case 2: | ||
1153 | rxdma_id = spi2_rxdma_id; | ||
1154 | txdma_id = spi2_txdma_id; | ||
1155 | num_chipselect = 2; | ||
1156 | break; | ||
1157 | #if defined(CONFIG_SOC_OMAP2430) || defined(CONFIG_ARCH_OMAP3) \ | ||
1158 | || defined(CONFIG_ARCH_OMAP4) | ||
1159 | case 3: | ||
1160 | rxdma_id = spi3_rxdma_id; | ||
1161 | txdma_id = spi3_txdma_id; | ||
1162 | num_chipselect = 2; | ||
1163 | break; | ||
1164 | #endif | ||
1165 | #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4) | ||
1166 | case 4: | ||
1167 | rxdma_id = spi4_rxdma_id; | ||
1168 | txdma_id = spi4_txdma_id; | ||
1169 | num_chipselect = 1; | ||
1170 | break; | ||
1171 | #endif | ||
1172 | default: | ||
1173 | return -EINVAL; | ||
1174 | } | ||
1175 | 1098 | ||
1176 | master = spi_alloc_master(&pdev->dev, sizeof *mcspi); | 1099 | master = spi_alloc_master(&pdev->dev, sizeof *mcspi); |
1177 | if (master == NULL) { | 1100 | if (master == NULL) { |
@@ -1188,7 +1111,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) | |||
1188 | master->setup = omap2_mcspi_setup; | 1111 | master->setup = omap2_mcspi_setup; |
1189 | master->transfer = omap2_mcspi_transfer; | 1112 | master->transfer = omap2_mcspi_transfer; |
1190 | master->cleanup = omap2_mcspi_cleanup; | 1113 | master->cleanup = omap2_mcspi_cleanup; |
1191 | master->num_chipselect = num_chipselect; | 1114 | master->num_chipselect = pdata->num_cs; |
1192 | 1115 | ||
1193 | dev_set_drvdata(&pdev->dev, master); | 1116 | dev_set_drvdata(&pdev->dev, master); |
1194 | 1117 | ||
@@ -1206,6 +1129,8 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) | |||
1206 | goto err1; | 1129 | goto err1; |
1207 | } | 1130 | } |
1208 | 1131 | ||
1132 | r->start += pdata->regs_offset; | ||
1133 | r->end += pdata->regs_offset; | ||
1209 | mcspi->phys = r->start; | 1134 | mcspi->phys = r->start; |
1210 | mcspi->base = ioremap(r->start, r->end - r->start + 1); | 1135 | mcspi->base = ioremap(r->start, r->end - r->start + 1); |
1211 | if (!mcspi->base) { | 1136 | if (!mcspi->base) { |
@@ -1240,11 +1165,32 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) | |||
1240 | if (mcspi->dma_channels == NULL) | 1165 | if (mcspi->dma_channels == NULL) |
1241 | goto err3; | 1166 | goto err3; |
1242 | 1167 | ||
1243 | for (i = 0; i < num_chipselect; i++) { | 1168 | for (i = 0; i < master->num_chipselect; i++) { |
1169 | char dma_ch_name[14]; | ||
1170 | struct resource *dma_res; | ||
1171 | |||
1172 | sprintf(dma_ch_name, "rx%d", i); | ||
1173 | dma_res = platform_get_resource_byname(pdev, IORESOURCE_DMA, | ||
1174 | dma_ch_name); | ||
1175 | if (!dma_res) { | ||
1176 | dev_dbg(&pdev->dev, "cannot get DMA RX channel\n"); | ||
1177 | status = -ENODEV; | ||
1178 | break; | ||
1179 | } | ||
1180 | |||
1244 | mcspi->dma_channels[i].dma_rx_channel = -1; | 1181 | mcspi->dma_channels[i].dma_rx_channel = -1; |
1245 | mcspi->dma_channels[i].dma_rx_sync_dev = rxdma_id[i]; | 1182 | mcspi->dma_channels[i].dma_rx_sync_dev = dma_res->start; |
1183 | sprintf(dma_ch_name, "tx%d", i); | ||
1184 | dma_res = platform_get_resource_byname(pdev, IORESOURCE_DMA, | ||
1185 | dma_ch_name); | ||
1186 | if (!dma_res) { | ||
1187 | dev_dbg(&pdev->dev, "cannot get DMA TX channel\n"); | ||
1188 | status = -ENODEV; | ||
1189 | break; | ||
1190 | } | ||
1191 | |||
1246 | mcspi->dma_channels[i].dma_tx_channel = -1; | 1192 | mcspi->dma_channels[i].dma_tx_channel = -1; |
1247 | mcspi->dma_channels[i].dma_tx_sync_dev = txdma_id[i]; | 1193 | mcspi->dma_channels[i].dma_tx_sync_dev = dma_res->start; |
1248 | } | 1194 | } |
1249 | 1195 | ||
1250 | if (omap2_mcspi_reset(mcspi) < 0) | 1196 | if (omap2_mcspi_reset(mcspi) < 0) |