AT91: Add a driver for the ADC
Subsystems (4)
PATCH v8 1/1 AT91: Add a driver for the ADC
Hi all,
This patchset adds the driver for the ADC in the AT91 SoC. It has been tested on the at91sam9g20ek and should work on sam9g45 as well.
For now, it only reads values when asked for by sysfs, but eventually will support hardware triggers and more boards.
This patchset is based on the "[PATCH 0/6 V2] IIO: Out of staging step 1: The core" patchset from Jonathan Cameron, applied on top of 3.1
Improvements from v7:
- Fix the channels mask bug
PATCH 1/3 ARM: AT91: Add platform data for the ADCs
--- arch/arm/mach-at91/include/mach/board.h | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-)
arch/arm/mach-at91/include/mach/board.h +18 -0
@@ -207,4 +207,22 @@ extern void __init at91_pwm_leds(struct gpio_led *leds, int nr);/* FIXME: this needs a better location, but gets stuff building again */ extern int at91_suspend_entering_slow_clock (void ); +/* ADC */ +struct at91_adc_data { +/* ADC Clock as specified by the datasheet, in Hz. */ +unsigned int adc_clock; +/* +* Global number of channels available (to specify which channels are +* indeed used on the board, see the channels_used bitmask). +*/ +u8 num_channels; +/* Channels in use on the board as a bitmask */ +unsigned long channels_used; +/* Startup time of the ADC, in microseconds. */ +u8 startup_time; +/* Reference voltage for the ADC in millivolts */ +unsigned short vref; +}; +extern void __init at91_add_device_adc (struct at91_adc_data *data); +#endif
Signature · 1 line
1.7.4.1
PATCH 2/3 ARM: AT91: IIO: Add AT91 ADC driver.
In reply to Maxime Ripard--- drivers/iio/adc/Kconfig | 6 + drivers/iio/adc/Makefile | 4 +- drivers/iio/adc/at91adc.c | 326 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 335 insertions(+), 1 deletions(-) create mode 100644 drivers/iio/adc/at91adc.c
drivers/iio/adc/Kconfig +6 -0
@@ -14,6 +14,12 @@ config IIO_AD799X i2c analog to digital convertors (ADC). Provides direct access via sysfs. +config IIO_AT91ADC + tristate "Atmel AT91 ADC" + depends on SYSFS && ARCH_AT91 + help + Say yes here to build support for Atmel AT91 ADC. + config IIO_MAX1363 tristate "Maxim max1363 ADC driver" depends on I2C
drivers/iio/adc/Makefile +3 -1
@@ -6,4 +6,6 @@ iio_ad799x-y := ad799x_core.o obj-$(CONFIG_IIO_AD799X) += iio_ad799x.o iio_max1363-y := max1363_core.o -obj-$(CONFIG_IIO_MAX1363) += iio_max1363.o +obj-$(CONFIG_IIO_MAX1363) += iio_max1363.o + +obj-$(CONFIG_IIO_AT91ADC) += at91adc.o
drivers/iio/adc/at91adc.c new file +326 -0
326 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH 3/3 ARM: AT91: Add the ADC to the sam9g20ek board
In reply to Maxime Ripard--- arch/arm/mach-at91/at91sam9260_devices.c | 55 ++++++++++++++++++++++++++++++ arch/arm/mach-at91/board-sam9g20ek.c | 11 ++++++ 2 files changed, 66 insertions(+), 0 deletions(-)
arch/arm/mach-at91/at91sam9260_devices.c +55 -0
@@ -1312,6 +1312,61 @@ void __init at91_add_device_cf(struct at91_cf_data *data)void __init at91_add_device_cf (struct at91_cf_data * data) {}#endif +/* -------------------------------------------------------------------- +* ADCs +* -------------------------------------------------------------------- */ + +#if defined(CONFIG_IIO_AT91ADC ) || defined(CONFIG_IIO_AT91ADC_MODULE ) +static struct at91_adc_data adc_data; + +static struct resource adc_resources[] = { + [0 ] = { + .start =AT91SAM9260_BASE_ADC , + .end =AT91SAM9260_BASE_ADC +SZ_16K -1 , + .flags =IORESOURCE_MEM , + }, + [1 ] = { + .start =AT91SAM9260_ID_ADC , + .end =AT91SAM9260_ID_ADC , + .flags =IORESOURCE_IRQ , + }, +}; + +static struct platform_device at91_adc_device = { + .name ="at91adc" , + .id =-1 , + .dev = { + .platform_data = &adc_data, + }, + .resource = adc_resources, + .num_resources =ARRAY_SIZE (adc_resources), +}; + +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_PC0 ,0 ); +if (test_bit (1 , &data->channels_used)) +at91_set_A_periph (AT91_PIN_PC1 ,0 ); +if (test_bit (2 , &data->channels_used)) +at91_set_A_periph (AT91_PIN_PC2 ,0 ); +if (test_bit (3 , &data->channels_used)) +at91_set_A_periph (AT91_PIN_PC3 ,0 ); + + data->adc_clock =5000000 ; + data->num_channels =4 ; + data->startup_time =10 ; + + adc_data = *data; +platform_device_register (&at91_adc_device); +} +#else +void __init at91_add_device_adc (struct at91_adc_data *data) {} +#endif +/* -------------------------------------------------------------------- */ /* * These devices are always present and don't need any board-specific
arch/arm/mach-at91/board-sam9g20ek.c +11 -0
@@ -314,6 +314,15 @@ static void __init ek_add_device_buttons(void)static void __init ek_add_device_buttons (void ) {}#endif +/* +* ADCs +*/ + +static struct at91_adc_data ek_adc_data = { + .channels_used =BIT (0 ) |BIT (1 ) |BIT (2 ) |BIT (3 ), + .vref =3300 , +}; +#if defined(CONFIG_REGULATOR_FIXED_VOLTAGE ) || defined(CONFIG_REGULATOR_FIXED_VOLTAGE_MODULE )static struct regulator_consumer_supply ek_audio_consumer_supplies[] = { REGULATOR_SUPPLY("AVDD", "0-001b"),
@@ -389,6 +398,8 @@ static void __init ek_board_init(void)ek_add_device_gpio_leds ();/* Push Buttons */ ek_add_device_buttons (); +/* ADCs */ +at91_add_device_adc (&ek_adc_data);/* PCK0 provides MCLK to the WM8731 */ at91_set_B_periph (AT91_PIN_PC1 ,0 );/* SSC (for WM8731) */
Signature · 1 line
1.7.4.1
PATCH v8 1/1 AT91: Add a driver for the ADC
In reply to Maxime RipardHi,
So, I guess that we have a pretty good driver with that version. What can we do for the inclusion in the kernel now ?
Maxime
Quoted 23 lines · Maxime Ripard
Hi all,
This patchset adds the driver for the ADC in the AT91 SoC. It has been tested on the at91sam9g20ek and should work on sam9g45 as well.
For now, it only reads values when asked for by sysfs, but eventually will support hardware triggers and more boards.
This patchset is based on the "[PATCH 0/6 V2] IIO: Out of staging step 1: The core" patchset from Jonathan Cameron, applied on top of 3.1
Improvements from v7:
- Fix the channels mask bugCc Nicolas Ferre <[email protected]>Cc Patrice Vilchez <[email protected]>Cc Thomas Petazzoni <[email protected]>_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 4 lines
Maxime Ripard, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH v8 1/1 AT91: Add a driver for the ADC
On 11/22/2011 03:31 PM, Maxime Ripard :
Quoted 4 lines
Hi,
So, I guess that we have a pretty good driver with that version. What can we do for the inclusion in the kernel now ?
I propose that:
1/ We take the patch #1/3 for inclusion through arm-soc during 3.2 2/ Jonathan takes the #2/3 in his IIO subsystem
3/ We take board related patch #3/3 for inclusion during 3.3 (next) 4/ And we may add other boards support if we are quick for 3.3...
Does is sound good to all of you?
Bye,
Quoted 29 lines
Maxime
Quoted 23 lines · Maxime Ripard
Hi all,
This patchset adds the driver for the ADC in the AT91 SoC. It has been tested on the at91sam9g20ek and should work on sam9g45 as well.
For now, it only reads values when asked for by sysfs, but eventually will support hardware triggers and more boards.
This patchset is based on the "[PATCH 0/6 V2] IIO: Out of staging step 1: The core" patchset from Jonathan Cameron, applied on top of 3.1
Improvements from v7:
- Fix the channels mask bugCc Nicolas Ferre <[email protected]>Cc Patrice Vilchez <[email protected]>Cc Thomas Petazzoni <[email protected]>_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 1 line
Nicolas Ferre
Jonathan Cameron
maintainerPATCH v8 1/1 AT91: Add a driver for the ADC
Quoted 10 lines · Nicolas Ferre
On 11/22/2011 03:31 PM, Maxime Ripard :
Quoted 4 lines
Hi,
So, I guess that we have a pretty good driver with that version. What can we do for the inclusion in the kernel now ?
I propose that:
1/ We take the patch #1/3 for inclusion through arm-soc during 3.2 2/ Jonathan takes the #2/3 in his IIO subsystem
Works for me. Poke me when 1 is in place.
Quoted 38 lines
3/ We take board related patch #3/3 for inclusion during 3.3 (next) 4/ And we may add other boards support if we are quick for 3.3...
Does is sound good to all of you?
Bye,
Quoted 29 lines
Maxime
Quoted 23 lines · Maxime Ripard
Hi all,
This patchset adds the driver for the ADC in the AT91 SoC. It has been tested on the at91sam9g20ek and should work on sam9g45 as well.
For now, it only reads values when asked for by sysfs, but eventually will support hardware triggers and more boards.
This patchset is based on the "[PATCH 0/6 V2] IIO: Out of staging step 1: The core" patchset from Jonathan Cameron, applied on top of 3.1
Improvements from v7:
- Fix the channels mask bugCc Nicolas Ferre <[email protected]>Cc Patrice Vilchez <[email protected]>Cc Thomas Petazzoni <[email protected]>_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel