diff options
author | Maxime Ripard <maxime.ripard@free-electrons.com> | 2012-05-11 09:35:34 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-05-14 16:25:33 -0400 |
commit | 67b5d7b3e2ce01c091c8adb120b9fffcb2dddc0a (patch) | |
tree | e2c6026fc0bb6f74454373849725978a38d9f829 /arch/arm/mach-at91/at91sam9260_devices.c | |
parent | 0e589d5fb3172b0dde7fdad3a4829ce5352dd30d (diff) |
ARM: AT91: Add the ADC to the sam9g20ek board
This patch adds platform data for the AT91 ADC driver support for
the AT91SAM9G20-EK board.
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch/arm/mach-at91/at91sam9260_devices.c')
-rw-r--r-- | arch/arm/mach-at91/at91sam9260_devices.c | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c index 5652dde4bbe2..be0eb2642439 100644 --- a/arch/arm/mach-at91/at91sam9260_devices.c +++ b/arch/arm/mach-at91/at91sam9260_devices.c | |||
@@ -17,12 +17,15 @@ | |||
17 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/i2c-gpio.h> | 18 | #include <linux/i2c-gpio.h> |
19 | 19 | ||
20 | #include <linux/platform_data/at91_adc.h> | ||
21 | |||
20 | #include <mach/board.h> | 22 | #include <mach/board.h> |
21 | #include <mach/cpu.h> | 23 | #include <mach/cpu.h> |
22 | #include <mach/at91sam9260.h> | 24 | #include <mach/at91sam9260.h> |
23 | #include <mach/at91sam9260_matrix.h> | 25 | #include <mach/at91sam9260_matrix.h> |
24 | #include <mach/at91_matrix.h> | 26 | #include <mach/at91_matrix.h> |
25 | #include <mach/at91sam9_smc.h> | 27 | #include <mach/at91sam9_smc.h> |
28 | #include <mach/at91_adc.h> | ||
26 | 29 | ||
27 | #include "generic.h" | 30 | #include "generic.h" |
28 | 31 | ||
@@ -1369,6 +1372,93 @@ void __init at91_add_device_cf(struct at91_cf_data *data) | |||
1369 | void __init at91_add_device_cf(struct at91_cf_data * data) {} | 1372 | void __init at91_add_device_cf(struct at91_cf_data * data) {} |
1370 | #endif | 1373 | #endif |
1371 | 1374 | ||
1375 | /* -------------------------------------------------------------------- | ||
1376 | * ADCs | ||
1377 | * -------------------------------------------------------------------- */ | ||
1378 | |||
1379 | #if IS_ENABLED(CONFIG_AT91_ADC) | ||
1380 | static struct at91_adc_data adc_data; | ||
1381 | |||
1382 | static struct resource adc_resources[] = { | ||
1383 | [0] = { | ||
1384 | .start = AT91SAM9260_BASE_ADC, | ||
1385 | .end = AT91SAM9260_BASE_ADC + SZ_16K - 1, | ||
1386 | .flags = IORESOURCE_MEM, | ||
1387 | }, | ||
1388 | [1] = { | ||
1389 | .start = AT91SAM9260_ID_ADC, | ||
1390 | .end = AT91SAM9260_ID_ADC, | ||
1391 | .flags = IORESOURCE_IRQ, | ||
1392 | }, | ||
1393 | }; | ||
1394 | |||
1395 | static struct platform_device at91_adc_device = { | ||
1396 | .name = "at91_adc", | ||
1397 | .id = -1, | ||
1398 | .dev = { | ||
1399 | .platform_data = &adc_data, | ||
1400 | }, | ||
1401 | .resource = adc_resources, | ||
1402 | .num_resources = ARRAY_SIZE(adc_resources), | ||
1403 | }; | ||
1404 | |||
1405 | static struct at91_adc_trigger at91_adc_triggers[] = { | ||
1406 | [0] = { | ||
1407 | .name = "timer-counter-0", | ||
1408 | .value = AT91_ADC_TRGSEL_TC0 | AT91_ADC_TRGEN, | ||
1409 | }, | ||
1410 | [1] = { | ||
1411 | .name = "timer-counter-1", | ||
1412 | .value = AT91_ADC_TRGSEL_TC1 | AT91_ADC_TRGEN, | ||
1413 | }, | ||
1414 | [2] = { | ||
1415 | .name = "timer-counter-2", | ||
1416 | .value = AT91_ADC_TRGSEL_TC2 | AT91_ADC_TRGEN, | ||
1417 | }, | ||
1418 | [3] = { | ||
1419 | .name = "external", | ||
1420 | .value = AT91_ADC_TRGSEL_EXTERNAL | AT91_ADC_TRGEN, | ||
1421 | .is_external = true, | ||
1422 | }, | ||
1423 | }; | ||
1424 | |||
1425 | static struct at91_adc_reg_desc at91_adc_register_g20 = { | ||
1426 | .channel_base = AT91_ADC_CHR(0), | ||
1427 | .drdy_mask = AT91_ADC_DRDY, | ||
1428 | .status_register = AT91_ADC_SR, | ||
1429 | .trigger_register = AT91_ADC_MR, | ||
1430 | }; | ||
1431 | |||
1432 | void __init at91_add_device_adc(struct at91_adc_data *data) | ||
1433 | { | ||
1434 | if (!data) | ||
1435 | return; | ||
1436 | |||
1437 | if (test_bit(0, &data->channels_used)) | ||
1438 | at91_set_A_periph(AT91_PIN_PC0, 0); | ||
1439 | if (test_bit(1, &data->channels_used)) | ||
1440 | at91_set_A_periph(AT91_PIN_PC1, 0); | ||
1441 | if (test_bit(2, &data->channels_used)) | ||
1442 | at91_set_A_periph(AT91_PIN_PC2, 0); | ||
1443 | if (test_bit(3, &data->channels_used)) | ||
1444 | at91_set_A_periph(AT91_PIN_PC3, 0); | ||
1445 | |||
1446 | if (data->use_external_triggers) | ||
1447 | at91_set_A_periph(AT91_PIN_PA22, 0); | ||
1448 | |||
1449 | data->num_channels = 4; | ||
1450 | data->startup_time = 10; | ||
1451 | data->registers = &at91_adc_register_g20; | ||
1452 | data->trigger_number = 4; | ||
1453 | data->trigger_list = at91_adc_triggers; | ||
1454 | |||
1455 | adc_data = *data; | ||
1456 | platform_device_register(&at91_adc_device); | ||
1457 | } | ||
1458 | #else | ||
1459 | void __init at91_add_device_adc(struct at91_adc_data *data) {} | ||
1460 | #endif | ||
1461 | |||
1372 | /* -------------------------------------------------------------------- */ | 1462 | /* -------------------------------------------------------------------- */ |
1373 | /* | 1463 | /* |
1374 | * These devices are always present and don't need any board-specific | 1464 | * These devices are always present and don't need any board-specific |