diff options
author | Maxime Ripard <maxime.ripard@free-electrons.com> | 2012-05-11 09:35:35 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-05-14 16:25:33 -0400 |
commit | 4a5920e848173dafd3907c8789fdb6ec89d0d621 (patch) | |
tree | 7189c71bdf39a1303747fd99be9eec7fa94a8ac7 /arch/arm/mach-at91 | |
parent | 67b5d7b3e2ce01c091c8adb120b9fffcb2dddc0a (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')
-rw-r--r-- | arch/arm/mach-at91/at91sam9g45.c | 9 | ||||
-rw-r--r-- | arch/arm/mach-at91/at91sam9g45_devices.c | 101 | ||||
-rw-r--r-- | arch/arm/mach-at91/board-sam9m10g45ek.c | 12 |
3 files changed, 122 insertions, 0 deletions
diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c index d222f8333dab..30865c6b9936 100644 --- a/arch/arm/mach-at91/at91sam9g45.c +++ b/arch/arm/mach-at91/at91sam9g45.c | |||
@@ -176,6 +176,12 @@ static struct clk vdec_clk = { | |||
176 | .type = CLK_TYPE_PERIPHERAL, | 176 | .type = CLK_TYPE_PERIPHERAL, |
177 | }; | 177 | }; |
178 | 178 | ||
179 | static struct clk adc_op_clk = { | ||
180 | .name = "adc_op_clk", | ||
181 | .type = CLK_TYPE_PERIPHERAL, | ||
182 | .rate_hz = 13200000, | ||
183 | }; | ||
184 | |||
179 | static struct clk *periph_clocks[] __initdata = { | 185 | static struct clk *periph_clocks[] __initdata = { |
180 | &pioA_clk, | 186 | &pioA_clk, |
181 | &pioB_clk, | 187 | &pioB_clk, |
@@ -204,6 +210,7 @@ static struct clk *periph_clocks[] __initdata = { | |||
204 | &isi_clk, | 210 | &isi_clk, |
205 | &udphs_clk, | 211 | &udphs_clk, |
206 | &mmc1_clk, | 212 | &mmc1_clk, |
213 | &adc_op_clk, | ||
207 | // irq0 | 214 | // irq0 |
208 | }; | 215 | }; |
209 | 216 | ||
@@ -242,6 +249,8 @@ static struct clk_lookup periph_clocks_lookups[] = { | |||
242 | CLKDEV_CON_ID("pioC", &pioC_clk), | 249 | CLKDEV_CON_ID("pioC", &pioC_clk), |
243 | CLKDEV_CON_ID("pioD", &pioDE_clk), | 250 | CLKDEV_CON_ID("pioD", &pioDE_clk), |
244 | CLKDEV_CON_ID("pioE", &pioDE_clk), | 251 | CLKDEV_CON_ID("pioE", &pioDE_clk), |
252 | /* Fake adc clock */ | ||
253 | CLKDEV_CON_ID("adc_clk", &tsc_clk), | ||
245 | }; | 254 | }; |
246 | 255 | ||
247 | static struct clk_lookup usart_clocks_lookups[] = { | 256 | static struct clk_lookup usart_clocks_lookups[] = { |
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) | ||
1217 | static struct at91_adc_data adc_data; | ||
1218 | |||
1219 | static 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 | |||
1232 | static 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 | |||
1242 | static 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 | |||
1265 | static 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 | |||
1272 | void __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 | ||
1307 | void __init at91_add_device_adc(struct at91_adc_data *data) {} | ||
1308 | #endif | ||
1309 | |||
1310 | /* -------------------------------------------------------------------- | ||
1210 | * RTT | 1311 | * RTT |
1211 | * -------------------------------------------------------------------- */ | 1312 | * -------------------------------------------------------------------- */ |
1212 | 1313 | ||
diff --git a/arch/arm/mach-at91/board-sam9m10g45ek.c b/arch/arm/mach-at91/board-sam9m10g45ek.c index c88e908ddd82..337abd2f0c1a 100644 --- a/arch/arm/mach-at91/board-sam9m10g45ek.c +++ b/arch/arm/mach-at91/board-sam9m10g45ek.c | |||
@@ -27,6 +27,8 @@ | |||
27 | #include <linux/atmel-mci.h> | 27 | #include <linux/atmel-mci.h> |
28 | #include <linux/delay.h> | 28 | #include <linux/delay.h> |
29 | 29 | ||
30 | #include <linux/platform_data/at91_adc.h> | ||
31 | |||
30 | #include <mach/hardware.h> | 32 | #include <mach/hardware.h> |
31 | #include <video/atmel_lcdc.h> | 33 | #include <video/atmel_lcdc.h> |
32 | #include <media/soc_camera.h> | 34 | #include <media/soc_camera.h> |
@@ -315,6 +317,14 @@ static struct at91_tsadcc_data ek_tsadcc_data = { | |||
315 | .ts_sample_hold_time = 0x0a, | 317 | .ts_sample_hold_time = 0x0a, |
316 | }; | 318 | }; |
317 | 319 | ||
320 | /* | ||
321 | * ADCs | ||
322 | */ | ||
323 | static struct at91_adc_data ek_adc_data = { | ||
324 | .channels_used = BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5) | BIT(6) | BIT(7), | ||
325 | .use_external_triggers = true, | ||
326 | .vref = 3300, | ||
327 | }; | ||
318 | 328 | ||
319 | /* | 329 | /* |
320 | * GPIO Buttons | 330 | * GPIO Buttons |
@@ -480,6 +490,8 @@ static void __init ek_board_init(void) | |||
480 | at91_add_device_lcdc(&ek_lcdc_data); | 490 | at91_add_device_lcdc(&ek_lcdc_data); |
481 | /* Touch Screen */ | 491 | /* Touch Screen */ |
482 | at91_add_device_tsadcc(&ek_tsadcc_data); | 492 | at91_add_device_tsadcc(&ek_tsadcc_data); |
493 | /* ADC */ | ||
494 | at91_add_device_adc(&ek_adc_data); | ||
483 | /* Push Buttons */ | 495 | /* Push Buttons */ |
484 | ek_add_device_buttons(); | 496 | ek_add_device_buttons(); |
485 | /* AC97 */ | 497 | /* AC97 */ |