|
@@ -23,6 +23,7 @@
|
|
|
#include <mach/at91sam9_smc.h>
|
|
|
#include <mach/hardware.h>
|
|
|
#include <linux/platform_data/dma-atmel.h>
|
|
|
+#include <linux/platform_data/at91_adc.h>
|
|
|
|
|
|
#include "board.h"
|
|
|
#include "generic.h"
|
|
@@ -658,6 +659,90 @@ void __init at91_add_device_tsadcc(struct at91_tsadcc_data *data)
|
|
|
void __init at91_add_device_tsadcc(struct at91_tsadcc_data *data) {}
|
|
|
#endif
|
|
|
|
|
|
+/* --------------------------------------------------------------------
|
|
|
+ * ADC and Touchscreen
|
|
|
+ * -------------------------------------------------------------------- */
|
|
|
+
|
|
|
+#if IS_ENABLED(CONFIG_AT91_ADC)
|
|
|
+static struct at91_adc_data adc_data;
|
|
|
+
|
|
|
+static struct resource adc_resources[] = {
|
|
|
+ [0] = {
|
|
|
+ .start = AT91SAM9RL_BASE_TSC,
|
|
|
+ .end = AT91SAM9RL_BASE_TSC + SZ_16K - 1,
|
|
|
+ .flags = IORESOURCE_MEM,
|
|
|
+ },
|
|
|
+ [1] = {
|
|
|
+ .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_TSC,
|
|
|
+ .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_TSC,
|
|
|
+ .flags = IORESOURCE_IRQ,
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+static struct platform_device at91_adc_device = {
|
|
|
+ .name = "at91sam9rl-adc",
|
|
|
+ .id = -1,
|
|
|
+ .dev = {
|
|
|
+ .platform_data = &adc_data,
|
|
|
+ },
|
|
|
+ .resource = adc_resources,
|
|
|
+ .num_resources = ARRAY_SIZE(adc_resources),
|
|
|
+};
|
|
|
+
|
|
|
+static struct at91_adc_trigger at91_adc_triggers[] = {
|
|
|
+ [0] = {
|
|
|
+ .name = "external-rising",
|
|
|
+ .value = 1,
|
|
|
+ .is_external = true,
|
|
|
+ },
|
|
|
+ [1] = {
|
|
|
+ .name = "external-falling",
|
|
|
+ .value = 2,
|
|
|
+ .is_external = true,
|
|
|
+ },
|
|
|
+ [2] = {
|
|
|
+ .name = "external-any",
|
|
|
+ .value = 3,
|
|
|
+ .is_external = true,
|
|
|
+ },
|
|
|
+ [3] = {
|
|
|
+ .name = "continuous",
|
|
|
+ .value = 6,
|
|
|
+ .is_external = false,
|
|
|
+ },
|
|
|
+};
|
|
|
+
|
|
|
+void __init at91_add_device_adc(struct at91_adc_data *data)
|
|
|
+{
|
|
|
+ if (!data)
|
|
|
+ return;
|
|
|
+
|
|
|
+ if (test_bit(0, &data->channels_used))
|
|
|
+ at91_set_A_periph(AT91_PIN_PA17, 0);
|
|
|
+ if (test_bit(1, &data->channels_used))
|
|
|
+ at91_set_A_periph(AT91_PIN_PA18, 0);
|
|
|
+ if (test_bit(2, &data->channels_used))
|
|
|
+ at91_set_A_periph(AT91_PIN_PA19, 0);
|
|
|
+ if (test_bit(3, &data->channels_used))
|
|
|
+ at91_set_A_periph(AT91_PIN_PA20, 0);
|
|
|
+ if (test_bit(4, &data->channels_used))
|
|
|
+ at91_set_A_periph(AT91_PIN_PD6, 0);
|
|
|
+ if (test_bit(5, &data->channels_used))
|
|
|
+ at91_set_A_periph(AT91_PIN_PD7, 0);
|
|
|
+
|
|
|
+ if (data->use_external_triggers)
|
|
|
+ at91_set_A_periph(AT91_PIN_PB15, 0);
|
|
|
+
|
|
|
+ data->startup_time = 40;
|
|
|
+ data->trigger_number = 4;
|
|
|
+ data->trigger_list = at91_adc_triggers;
|
|
|
+
|
|
|
+ adc_data = *data;
|
|
|
+ platform_device_register(&at91_adc_device);
|
|
|
+}
|
|
|
+#else
|
|
|
+void __init at91_add_device_adc(struct at91_adc_data *data) {}
|
|
|
+#endif
|
|
|
|
|
|
/* --------------------------------------------------------------------
|
|
|
* RTC
|