aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91/at91sam9g45_devices.c
diff options
context:
space:
mode:
authorMaxime Ripard <maxime.ripard@free-electrons.com>2012-05-11 09:35:35 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-05-14 16:25:33 -0400
commit4a5920e848173dafd3907c8789fdb6ec89d0d621 (patch)
tree7189c71bdf39a1303747fd99be9eec7fa94a8ac7 /arch/arm/mach-at91/at91sam9g45_devices.c
parent67b5d7b3e2ce01c091c8adb120b9fffcb2dddc0a (diff)
ARM: AT91: ADC: Add support for the AT91SAM9M10G45-EK board
This patch adds platform data for the AT91 ADC driver support for the AT91SAM9M10G45-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/at91sam9g45_devices.c')
-rw-r--r--arch/arm/mach-at91/at91sam9g45_devices.c101
1 files changed, 101 insertions, 0 deletions
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c
index 6b008aee1dff..0c6d9fe41eec 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -19,9 +19,12 @@
19#include <linux/i2c-gpio.h> 19#include <linux/i2c-gpio.h>
20#include <linux/atmel-mci.h> 20#include <linux/atmel-mci.h>
21 21
22#include <linux/platform_data/at91_adc.h>
23
22#include <linux/fb.h> 24#include <linux/fb.h>
23#include <video/atmel_lcdc.h> 25#include <video/atmel_lcdc.h>
24 26
27#include <mach/at91_adc.h>
25#include <mach/board.h> 28#include <mach/board.h>
26#include <mach/at91sam9g45.h> 29#include <mach/at91sam9g45.h>
27#include <mach/at91sam9g45_matrix.h> 30#include <mach/at91sam9g45_matrix.h>
@@ -1207,6 +1210,104 @@ void __init at91_add_device_tsadcc(struct at91_tsadcc_data *data) {}
1207 1210
1208 1211
1209/* -------------------------------------------------------------------- 1212/* --------------------------------------------------------------------
1213 * ADC
1214 * -------------------------------------------------------------------- */
1215
1216#if IS_ENABLED(CONFIG_AT91_ADC)
1217static struct at91_adc_data adc_data;
1218
1219static struct resource adc_resources[] = {
1220 [0] = {
1221 .start = AT91SAM9G45_BASE_TSC,
1222 .end = AT91SAM9G45_BASE_TSC + SZ_16K - 1,
1223 .flags = IORESOURCE_MEM,
1224 },
1225 [1] = {
1226 .start = AT91SAM9G45_ID_TSC,
1227 .end = AT91SAM9G45_ID_TSC,
1228 .flags = IORESOURCE_IRQ,
1229 }
1230};
1231
1232static struct platform_device at91_adc_device = {
1233 .name = "at91_adc",
1234 .id = -1,
1235 .dev = {
1236 .platform_data = &adc_data,
1237 },
1238 .resource = adc_resources,
1239 .num_resources = ARRAY_SIZE(adc_resources),
1240};
1241
1242static struct at91_adc_trigger at91_adc_triggers[] = {
1243 [0] = {
1244 .name = "external-rising",
1245 .value = 1,
1246 .is_external = true,
1247 },
1248 [1] = {
1249 .name = "external-falling",
1250 .value = 2,
1251 .is_external = true,
1252 },
1253 [2] = {
1254 .name = "external-any",
1255 .value = 3,
1256 .is_external = true,
1257 },
1258 [3] = {
1259 .name = "continuous",
1260 .value = 6,
1261 .is_external = false,
1262 },
1263};
1264
1265static struct at91_adc_reg_desc at91_adc_register_g45 = {
1266 .channel_base = AT91_ADC_CHR(0),
1267 .drdy_mask = AT91_ADC_DRDY,
1268 .status_register = AT91_ADC_SR,
1269 .trigger_register = 0x08,
1270};
1271
1272void __init at91_add_device_adc(struct at91_adc_data *data)
1273{
1274 if (!data)
1275 return;
1276
1277 if (test_bit(0, &data->channels_used))
1278 at91_set_gpio_input(AT91_PIN_PD20, 0);
1279 if (test_bit(1, &data->channels_used))
1280 at91_set_gpio_input(AT91_PIN_PD21, 0);
1281 if (test_bit(2, &data->channels_used))
1282 at91_set_gpio_input(AT91_PIN_PD22, 0);
1283 if (test_bit(3, &data->channels_used))
1284 at91_set_gpio_input(AT91_PIN_PD23, 0);
1285 if (test_bit(4, &data->channels_used))
1286 at91_set_gpio_input(AT91_PIN_PD24, 0);
1287 if (test_bit(5, &data->channels_used))
1288 at91_set_gpio_input(AT91_PIN_PD25, 0);
1289 if (test_bit(6, &data->channels_used))
1290 at91_set_gpio_input(AT91_PIN_PD26, 0);
1291 if (test_bit(7, &data->channels_used))
1292 at91_set_gpio_input(AT91_PIN_PD27, 0);
1293
1294 if (data->use_external_triggers)
1295 at91_set_A_periph(AT91_PIN_PD28, 0);
1296
1297 data->num_channels = 8;
1298 data->startup_time = 40;
1299 data->registers = &at91_adc_register_g45;
1300 data->trigger_number = 4;
1301 data->trigger_list = at91_adc_triggers;
1302
1303 adc_data = *data;
1304 platform_device_register(&at91_adc_device);
1305}
1306#else
1307void __init at91_add_device_adc(struct at91_adc_data *data) {}
1308#endif
1309
1310/* --------------------------------------------------------------------
1210 * RTT 1311 * RTT
1211 * -------------------------------------------------------------------- */ 1312 * -------------------------------------------------------------------- */
1212 1313