diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2011-07-13 09:33:17 -0400 |
---|---|---|
committer | Shawn Guo <shawn.guo@linaro.org> | 2011-07-26 21:31:45 -0400 |
commit | 62550cd7c08f1a38d0ade1de18baec10f83412bb (patch) | |
tree | e7e826885d6a1bf98acee27d35dd01fcb4cf8308 /drivers/dma/imx-sdma.c | |
parent | abfafc2d10ee2ad217be9ef06181819ca5dd6960 (diff) |
dmaengine: imx-sdma: use platform_device_id to identify sdma version
It might be not good to use software defined version to identify sdma
device type, when hardware does not define such version. Instead,
soc name is stable enough to define the device type.
The patch uses platform_device_id rather than version number passed
by platform data to identify sdma device type/version.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Vinod Koul <vinod.koul@intel.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'drivers/dma/imx-sdma.c')
-rw-r--r-- | drivers/dma/imx-sdma.c | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 1ea47db2ff06..a7708b481eab 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c | |||
@@ -65,8 +65,8 @@ | |||
65 | #define SDMA_ONCE_RTB 0x060 | 65 | #define SDMA_ONCE_RTB 0x060 |
66 | #define SDMA_XTRIG_CONF1 0x070 | 66 | #define SDMA_XTRIG_CONF1 0x070 |
67 | #define SDMA_XTRIG_CONF2 0x074 | 67 | #define SDMA_XTRIG_CONF2 0x074 |
68 | #define SDMA_CHNENBL0_V2 0x200 | 68 | #define SDMA_CHNENBL0_IMX35 0x200 |
69 | #define SDMA_CHNENBL0_V1 0x080 | 69 | #define SDMA_CHNENBL0_IMX31 0x080 |
70 | #define SDMA_CHNPRI_0 0x100 | 70 | #define SDMA_CHNPRI_0 0x100 |
71 | 71 | ||
72 | /* | 72 | /* |
@@ -299,13 +299,18 @@ struct sdma_firmware_header { | |||
299 | u32 ram_code_size; | 299 | u32 ram_code_size; |
300 | }; | 300 | }; |
301 | 301 | ||
302 | enum sdma_devtype { | ||
303 | IMX31_SDMA, /* runs on i.mx31 */ | ||
304 | IMX35_SDMA, /* runs on i.mx35 and later */ | ||
305 | }; | ||
306 | |||
302 | struct sdma_engine { | 307 | struct sdma_engine { |
303 | struct device *dev; | 308 | struct device *dev; |
304 | struct device_dma_parameters dma_parms; | 309 | struct device_dma_parameters dma_parms; |
305 | struct sdma_channel channel[MAX_DMA_CHANNELS]; | 310 | struct sdma_channel channel[MAX_DMA_CHANNELS]; |
306 | struct sdma_channel_control *channel_control; | 311 | struct sdma_channel_control *channel_control; |
307 | void __iomem *regs; | 312 | void __iomem *regs; |
308 | unsigned int version; | 313 | enum sdma_devtype devtype; |
309 | unsigned int num_events; | 314 | unsigned int num_events; |
310 | struct sdma_context_data *context; | 315 | struct sdma_context_data *context; |
311 | dma_addr_t context_phys; | 316 | dma_addr_t context_phys; |
@@ -314,6 +319,19 @@ struct sdma_engine { | |||
314 | struct sdma_script_start_addrs *script_addrs; | 319 | struct sdma_script_start_addrs *script_addrs; |
315 | }; | 320 | }; |
316 | 321 | ||
322 | static struct platform_device_id sdma_devtypes[] = { | ||
323 | { | ||
324 | .name = "imx31-sdma", | ||
325 | .driver_data = IMX31_SDMA, | ||
326 | }, { | ||
327 | .name = "imx35-sdma", | ||
328 | .driver_data = IMX35_SDMA, | ||
329 | }, { | ||
330 | /* sentinel */ | ||
331 | } | ||
332 | }; | ||
333 | MODULE_DEVICE_TABLE(platform, sdma_devtypes); | ||
334 | |||
317 | #define SDMA_H_CONFIG_DSPDMA (1 << 12) /* indicates if the DSPDMA is used */ | 335 | #define SDMA_H_CONFIG_DSPDMA (1 << 12) /* indicates if the DSPDMA is used */ |
318 | #define SDMA_H_CONFIG_RTD_PINS (1 << 11) /* indicates if Real-Time Debug pins are enabled */ | 336 | #define SDMA_H_CONFIG_RTD_PINS (1 << 11) /* indicates if Real-Time Debug pins are enabled */ |
319 | #define SDMA_H_CONFIG_ACR (1 << 4) /* indicates if AHB freq /core freq = 2 or 1 */ | 337 | #define SDMA_H_CONFIG_ACR (1 << 4) /* indicates if AHB freq /core freq = 2 or 1 */ |
@@ -321,8 +339,8 @@ struct sdma_engine { | |||
321 | 339 | ||
322 | static inline u32 chnenbl_ofs(struct sdma_engine *sdma, unsigned int event) | 340 | static inline u32 chnenbl_ofs(struct sdma_engine *sdma, unsigned int event) |
323 | { | 341 | { |
324 | u32 chnenbl0 = (sdma->version == 2 ? SDMA_CHNENBL0_V2 : SDMA_CHNENBL0_V1); | 342 | u32 chnenbl0 = (sdma->devtype == IMX31_SDMA ? SDMA_CHNENBL0_IMX31 : |
325 | 343 | SDMA_CHNENBL0_IMX35); | |
326 | return chnenbl0 + event * 4; | 344 | return chnenbl0 + event * 4; |
327 | } | 345 | } |
328 | 346 | ||
@@ -1162,15 +1180,16 @@ static int __init sdma_init(struct sdma_engine *sdma) | |||
1162 | int i, ret; | 1180 | int i, ret; |
1163 | dma_addr_t ccb_phys; | 1181 | dma_addr_t ccb_phys; |
1164 | 1182 | ||
1165 | switch (sdma->version) { | 1183 | switch (sdma->devtype) { |
1166 | case 1: | 1184 | case IMX31_SDMA: |
1167 | sdma->num_events = 32; | 1185 | sdma->num_events = 32; |
1168 | break; | 1186 | break; |
1169 | case 2: | 1187 | case IMX35_SDMA: |
1170 | sdma->num_events = 48; | 1188 | sdma->num_events = 48; |
1171 | break; | 1189 | break; |
1172 | default: | 1190 | default: |
1173 | dev_err(sdma->dev, "Unknown version %d. aborting\n", sdma->version); | 1191 | dev_err(sdma->dev, "Unknown sdma type %d. aborting\n", |
1192 | sdma->devtype); | ||
1174 | return -ENODEV; | 1193 | return -ENODEV; |
1175 | } | 1194 | } |
1176 | 1195 | ||
@@ -1284,7 +1303,7 @@ static int __init sdma_probe(struct platform_device *pdev) | |||
1284 | if (!sdma->script_addrs) | 1303 | if (!sdma->script_addrs) |
1285 | goto err_alloc; | 1304 | goto err_alloc; |
1286 | 1305 | ||
1287 | sdma->version = pdata->sdma_version; | 1306 | sdma->devtype = pdev->id_entry->driver_data; |
1288 | 1307 | ||
1289 | dma_cap_set(DMA_SLAVE, sdma->dma_device.cap_mask); | 1308 | dma_cap_set(DMA_SLAVE, sdma->dma_device.cap_mask); |
1290 | dma_cap_set(DMA_CYCLIC, sdma->dma_device.cap_mask); | 1309 | dma_cap_set(DMA_CYCLIC, sdma->dma_device.cap_mask); |
@@ -1366,6 +1385,7 @@ static struct platform_driver sdma_driver = { | |||
1366 | .driver = { | 1385 | .driver = { |
1367 | .name = "imx-sdma", | 1386 | .name = "imx-sdma", |
1368 | }, | 1387 | }, |
1388 | .id_table = sdma_devtypes, | ||
1369 | .remove = __exit_p(sdma_remove), | 1389 | .remove = __exit_p(sdma_remove), |
1370 | }; | 1390 | }; |
1371 | 1391 | ||