diff options
-rw-r--r-- | arch/arm/mach-at91/at91sam9260.c | 8 | ||||
-rw-r--r-- | arch/arm/mach-at91/at91sam9260_devices.c | 90 | ||||
-rw-r--r-- | arch/arm/mach-at91/board-sam9g20ek.c | 14 |
3 files changed, 112 insertions, 0 deletions
diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c index 46f774233298..63d4432960a9 100644 --- a/arch/arm/mach-at91/at91sam9260.c +++ b/arch/arm/mach-at91/at91sam9260.c | |||
@@ -55,6 +55,13 @@ static struct clk adc_clk = { | |||
55 | .pmc_mask = 1 << AT91SAM9260_ID_ADC, | 55 | .pmc_mask = 1 << AT91SAM9260_ID_ADC, |
56 | .type = CLK_TYPE_PERIPHERAL, | 56 | .type = CLK_TYPE_PERIPHERAL, |
57 | }; | 57 | }; |
58 | |||
59 | static struct clk adc_op_clk = { | ||
60 | .name = "adc_op_clk", | ||
61 | .type = CLK_TYPE_PERIPHERAL, | ||
62 | .rate_hz = 5000000, | ||
63 | }; | ||
64 | |||
58 | static struct clk usart0_clk = { | 65 | static struct clk usart0_clk = { |
59 | .name = "usart0_clk", | 66 | .name = "usart0_clk", |
60 | .pmc_mask = 1 << AT91SAM9260_ID_US0, | 67 | .pmc_mask = 1 << AT91SAM9260_ID_US0, |
@@ -166,6 +173,7 @@ static struct clk *periph_clocks[] __initdata = { | |||
166 | &pioB_clk, | 173 | &pioB_clk, |
167 | &pioC_clk, | 174 | &pioC_clk, |
168 | &adc_clk, | 175 | &adc_clk, |
176 | &adc_op_clk, | ||
169 | &usart0_clk, | 177 | &usart0_clk, |
170 | &usart1_clk, | 178 | &usart1_clk, |
171 | &usart2_clk, | 179 | &usart2_clk, |
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 |
diff --git a/arch/arm/mach-at91/board-sam9g20ek.c b/arch/arm/mach-at91/board-sam9g20ek.c index 8923ec9f5831..291b0fe9172f 100644 --- a/arch/arm/mach-at91/board-sam9g20ek.c +++ b/arch/arm/mach-at91/board-sam9g20ek.c | |||
@@ -32,6 +32,8 @@ | |||
32 | #include <linux/regulator/fixed.h> | 32 | #include <linux/regulator/fixed.h> |
33 | #include <linux/regulator/consumer.h> | 33 | #include <linux/regulator/consumer.h> |
34 | 34 | ||
35 | #include <linux/platform_data/at91_adc.h> | ||
36 | |||
35 | #include <mach/hardware.h> | 37 | #include <mach/hardware.h> |
36 | #include <asm/setup.h> | 38 | #include <asm/setup.h> |
37 | #include <asm/mach-types.h> | 39 | #include <asm/mach-types.h> |
@@ -318,6 +320,16 @@ static void __init ek_add_device_buttons(void) | |||
318 | static void __init ek_add_device_buttons(void) {} | 320 | static void __init ek_add_device_buttons(void) {} |
319 | #endif | 321 | #endif |
320 | 322 | ||
323 | /* | ||
324 | * ADCs | ||
325 | */ | ||
326 | |||
327 | static struct at91_adc_data ek_adc_data = { | ||
328 | .channels_used = BIT(0) | BIT(1) | BIT(2) | BIT(3), | ||
329 | .use_external_triggers = true, | ||
330 | .vref = 3300, | ||
331 | }; | ||
332 | |||
321 | #if defined(CONFIG_REGULATOR_FIXED_VOLTAGE) || defined(CONFIG_REGULATOR_FIXED_VOLTAGE_MODULE) | 333 | #if defined(CONFIG_REGULATOR_FIXED_VOLTAGE) || defined(CONFIG_REGULATOR_FIXED_VOLTAGE_MODULE) |
322 | static struct regulator_consumer_supply ek_audio_consumer_supplies[] = { | 334 | static struct regulator_consumer_supply ek_audio_consumer_supplies[] = { |
323 | REGULATOR_SUPPLY("AVDD", "0-001b"), | 335 | REGULATOR_SUPPLY("AVDD", "0-001b"), |
@@ -393,6 +405,8 @@ static void __init ek_board_init(void) | |||
393 | ek_add_device_gpio_leds(); | 405 | ek_add_device_gpio_leds(); |
394 | /* Push Buttons */ | 406 | /* Push Buttons */ |
395 | ek_add_device_buttons(); | 407 | ek_add_device_buttons(); |
408 | /* ADCs */ | ||
409 | at91_add_device_adc(&ek_adc_data); | ||
396 | /* PCK0 provides MCLK to the WM8731 */ | 410 | /* PCK0 provides MCLK to the WM8731 */ |
397 | at91_set_B_periph(AT91_PIN_PC1, 0); | 411 | at91_set_B_periph(AT91_PIN_PC1, 0); |
398 | /* SSC (for WM8731) */ | 412 | /* SSC (for WM8731) */ |