diff options
Diffstat (limited to 'arch/arm/mach-at91/at91sam9263_devices.c')
-rw-r--r-- | arch/arm/mach-at91/at91sam9263_devices.c | 161 |
1 files changed, 93 insertions, 68 deletions
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c index 9b6ca734f1a9..7c0898fe20fa 100644 --- a/arch/arm/mach-at91/at91sam9263_devices.c +++ b/arch/arm/mach-at91/at91sam9263_devices.c | |||
@@ -218,9 +218,9 @@ void __init at91_add_device_eth(struct macb_platform_data *data) {} | |||
218 | * MMC / SD | 218 | * MMC / SD |
219 | * -------------------------------------------------------------------- */ | 219 | * -------------------------------------------------------------------- */ |
220 | 220 | ||
221 | #if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE) | 221 | #if IS_ENABLED(CONFIG_MMC_ATMELMCI) |
222 | static u64 mmc_dmamask = DMA_BIT_MASK(32); | 222 | static u64 mmc_dmamask = DMA_BIT_MASK(32); |
223 | static struct at91_mmc_data mmc0_data, mmc1_data; | 223 | static struct mci_platform_data mmc0_data, mmc1_data; |
224 | 224 | ||
225 | static struct resource mmc0_resources[] = { | 225 | static struct resource mmc0_resources[] = { |
226 | [0] = { | 226 | [0] = { |
@@ -236,7 +236,7 @@ static struct resource mmc0_resources[] = { | |||
236 | }; | 236 | }; |
237 | 237 | ||
238 | static struct platform_device at91sam9263_mmc0_device = { | 238 | static struct platform_device at91sam9263_mmc0_device = { |
239 | .name = "at91_mci", | 239 | .name = "atmel_mci", |
240 | .id = 0, | 240 | .id = 0, |
241 | .dev = { | 241 | .dev = { |
242 | .dma_mask = &mmc_dmamask, | 242 | .dma_mask = &mmc_dmamask, |
@@ -261,7 +261,7 @@ static struct resource mmc1_resources[] = { | |||
261 | }; | 261 | }; |
262 | 262 | ||
263 | static struct platform_device at91sam9263_mmc1_device = { | 263 | static struct platform_device at91sam9263_mmc1_device = { |
264 | .name = "at91_mci", | 264 | .name = "atmel_mci", |
265 | .id = 1, | 265 | .id = 1, |
266 | .dev = { | 266 | .dev = { |
267 | .dma_mask = &mmc_dmamask, | 267 | .dma_mask = &mmc_dmamask, |
@@ -272,85 +272,110 @@ static struct platform_device at91sam9263_mmc1_device = { | |||
272 | .num_resources = ARRAY_SIZE(mmc1_resources), | 272 | .num_resources = ARRAY_SIZE(mmc1_resources), |
273 | }; | 273 | }; |
274 | 274 | ||
275 | void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) | 275 | void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) |
276 | { | 276 | { |
277 | unsigned int i; | ||
278 | unsigned int slot_count = 0; | ||
279 | |||
277 | if (!data) | 280 | if (!data) |
278 | return; | 281 | return; |
279 | 282 | ||
280 | /* input/irq */ | 283 | for (i = 0; i < ATMCI_MAX_NR_SLOTS; i++) { |
281 | if (gpio_is_valid(data->det_pin)) { | ||
282 | at91_set_gpio_input(data->det_pin, 1); | ||
283 | at91_set_deglitch(data->det_pin, 1); | ||
284 | } | ||
285 | if (gpio_is_valid(data->wp_pin)) | ||
286 | at91_set_gpio_input(data->wp_pin, 1); | ||
287 | if (gpio_is_valid(data->vcc_pin)) | ||
288 | at91_set_gpio_output(data->vcc_pin, 0); | ||
289 | 284 | ||
290 | if (mmc_id == 0) { /* MCI0 */ | 285 | if (!data->slot[i].bus_width) |
291 | /* CLK */ | 286 | continue; |
292 | at91_set_A_periph(AT91_PIN_PA12, 0); | ||
293 | 287 | ||
294 | if (data->slot_b) { | 288 | /* input/irq */ |
295 | /* CMD */ | 289 | if (gpio_is_valid(data->slot[i].detect_pin)) { |
296 | at91_set_A_periph(AT91_PIN_PA16, 1); | 290 | at91_set_gpio_input(data->slot[i].detect_pin, |
291 | 1); | ||
292 | at91_set_deglitch(data->slot[i].detect_pin, | ||
293 | 1); | ||
294 | } | ||
295 | if (gpio_is_valid(data->slot[i].wp_pin)) | ||
296 | at91_set_gpio_input(data->slot[i].wp_pin, 1); | ||
297 | |||
298 | if (mmc_id == 0) { /* MCI0 */ | ||
299 | switch (i) { | ||
300 | case 0: /* slot A */ | ||
301 | /* CMD */ | ||
302 | at91_set_A_periph(AT91_PIN_PA1, 1); | ||
303 | /* DAT0, maybe DAT1..DAT3 */ | ||
304 | at91_set_A_periph(AT91_PIN_PA0, 1); | ||
305 | if (data->slot[i].bus_width == 4) { | ||
306 | at91_set_A_periph(AT91_PIN_PA3, 1); | ||
307 | at91_set_A_periph(AT91_PIN_PA4, 1); | ||
308 | at91_set_A_periph(AT91_PIN_PA5, 1); | ||
309 | } | ||
310 | slot_count++; | ||
311 | break; | ||
312 | case 1: /* slot B */ | ||
313 | /* CMD */ | ||
314 | at91_set_A_periph(AT91_PIN_PA16, 1); | ||
315 | /* DAT0, maybe DAT1..DAT3 */ | ||
316 | at91_set_A_periph(AT91_PIN_PA17, 1); | ||
317 | if (data->slot[i].bus_width == 4) { | ||
318 | at91_set_A_periph(AT91_PIN_PA18, 1); | ||
319 | at91_set_A_periph(AT91_PIN_PA19, 1); | ||
320 | at91_set_A_periph(AT91_PIN_PA20, 1); | ||
321 | } | ||
322 | slot_count++; | ||
323 | break; | ||
324 | default: | ||
325 | printk(KERN_ERR | ||
326 | "AT91: SD/MMC slot %d not available\n", i); | ||
327 | break; | ||
328 | } | ||
329 | if (slot_count) { | ||
330 | /* CLK */ | ||
331 | at91_set_A_periph(AT91_PIN_PA12, 0); | ||
297 | 332 | ||
298 | /* DAT0, maybe DAT1..DAT3 */ | 333 | mmc0_data = *data; |
299 | at91_set_A_periph(AT91_PIN_PA17, 1); | 334 | platform_device_register(&at91sam9263_mmc0_device); |
300 | if (data->wire4) { | ||
301 | at91_set_A_periph(AT91_PIN_PA18, 1); | ||
302 | at91_set_A_periph(AT91_PIN_PA19, 1); | ||
303 | at91_set_A_periph(AT91_PIN_PA20, 1); | ||
304 | } | 335 | } |
305 | } else { | 336 | } else if (mmc_id == 1) { /* MCI1 */ |
306 | /* CMD */ | 337 | switch (i) { |
307 | at91_set_A_periph(AT91_PIN_PA1, 1); | 338 | case 0: /* slot A */ |
308 | 339 | /* CMD */ | |
309 | /* DAT0, maybe DAT1..DAT3 */ | 340 | at91_set_A_periph(AT91_PIN_PA7, 1); |
310 | at91_set_A_periph(AT91_PIN_PA0, 1); | 341 | /* DAT0, maybe DAT1..DAT3 */ |
311 | if (data->wire4) { | 342 | at91_set_A_periph(AT91_PIN_PA8, 1); |
312 | at91_set_A_periph(AT91_PIN_PA3, 1); | 343 | if (data->slot[i].bus_width == 4) { |
313 | at91_set_A_periph(AT91_PIN_PA4, 1); | 344 | at91_set_A_periph(AT91_PIN_PA9, 1); |
314 | at91_set_A_periph(AT91_PIN_PA5, 1); | 345 | at91_set_A_periph(AT91_PIN_PA10, 1); |
346 | at91_set_A_periph(AT91_PIN_PA11, 1); | ||
347 | } | ||
348 | slot_count++; | ||
349 | break; | ||
350 | case 1: /* slot B */ | ||
351 | /* CMD */ | ||
352 | at91_set_A_periph(AT91_PIN_PA21, 1); | ||
353 | /* DAT0, maybe DAT1..DAT3 */ | ||
354 | at91_set_A_periph(AT91_PIN_PA22, 1); | ||
355 | if (data->slot[i].bus_width == 4) { | ||
356 | at91_set_A_periph(AT91_PIN_PA23, 1); | ||
357 | at91_set_A_periph(AT91_PIN_PA24, 1); | ||
358 | at91_set_A_periph(AT91_PIN_PA25, 1); | ||
359 | } | ||
360 | slot_count++; | ||
361 | break; | ||
362 | default: | ||
363 | printk(KERN_ERR | ||
364 | "AT91: SD/MMC slot %d not available\n", i); | ||
365 | break; | ||
315 | } | 366 | } |
316 | } | 367 | if (slot_count) { |
368 | /* CLK */ | ||
369 | at91_set_A_periph(AT91_PIN_PA6, 0); | ||
317 | 370 | ||
318 | mmc0_data = *data; | 371 | mmc1_data = *data; |
319 | platform_device_register(&at91sam9263_mmc0_device); | 372 | platform_device_register(&at91sam9263_mmc1_device); |
320 | } else { /* MCI1 */ | ||
321 | /* CLK */ | ||
322 | at91_set_A_periph(AT91_PIN_PA6, 0); | ||
323 | |||
324 | if (data->slot_b) { | ||
325 | /* CMD */ | ||
326 | at91_set_A_periph(AT91_PIN_PA21, 1); | ||
327 | |||
328 | /* DAT0, maybe DAT1..DAT3 */ | ||
329 | at91_set_A_periph(AT91_PIN_PA22, 1); | ||
330 | if (data->wire4) { | ||
331 | at91_set_A_periph(AT91_PIN_PA23, 1); | ||
332 | at91_set_A_periph(AT91_PIN_PA24, 1); | ||
333 | at91_set_A_periph(AT91_PIN_PA25, 1); | ||
334 | } | ||
335 | } else { | ||
336 | /* CMD */ | ||
337 | at91_set_A_periph(AT91_PIN_PA7, 1); | ||
338 | |||
339 | /* DAT0, maybe DAT1..DAT3 */ | ||
340 | at91_set_A_periph(AT91_PIN_PA8, 1); | ||
341 | if (data->wire4) { | ||
342 | at91_set_A_periph(AT91_PIN_PA9, 1); | ||
343 | at91_set_A_periph(AT91_PIN_PA10, 1); | ||
344 | at91_set_A_periph(AT91_PIN_PA11, 1); | ||
345 | } | 373 | } |
346 | } | 374 | } |
347 | |||
348 | mmc1_data = *data; | ||
349 | platform_device_register(&at91sam9263_mmc1_device); | ||
350 | } | 375 | } |
351 | } | 376 | } |
352 | #else | 377 | #else |
353 | void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {} | 378 | void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) {} |
354 | #endif | 379 | #endif |
355 | 380 | ||
356 | /* -------------------------------------------------------------------- | 381 | /* -------------------------------------------------------------------- |