Add ADC driver for Atmel G20, G45 and X5 boards
Subsystems (5)
PATCH v5 1/1 Add ADC driver for Atmel G20, G45 and X5 boards
Hi Greg,
Here is a patchset adding an IIO driver for various Atmel SoCs. As it relies on out-of-staging-IIO, which is still in staging-next, it seems that you should be the one merging it.
As you can see, it got an acked-by all the maintainers involved in this patch, so it should be pretty good for inclusion.
Thanks,
Maxime
PATCH 1/9 ARM: AT91: Add platform data for the AT91 ADCs
The AT91 SoCs often embeds an ADC. This patch adds the needed platform data to specify the informations required by the driver to work properly.
For now, we only need the reference voltage and which channels are available on the board.
--- include/linux/platform_data/at91_adc.h | 61 ++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 include/linux/platform_data/at91_adc.h
include/linux/platform_data/at91_adc.h new file +61 -0
@@ -0,0 +1,61 @@ +/* +* Copyright (C) 2011 Free Electrons +* +* Licensed under the GPLv2 or later. +*/ + +#ifndef _AT91_ADC_H_ +#define _AT91_ADC_H_ + +/** +* struct at91_adc_reg_desc - Various informations relative to registers +* @channel_base: Base offset for the channel data registers +* @drdy_mask: Mask of the DRDY field in the relevant registers +(Interruptions registers mostly) +* @status_register: Offset of the Interrupt Status Register +* @trigger_register: Offset of the Trigger setup register +*/ +struct at91_adc_reg_desc { +u8 channel_base; +u32 drdy_mask; +u8 status_register; +u8 trigger_register; +}; + +/** +* struct at91_adc_trigger - description of triggers +* @name: name of the trigger advertised to the user +* @value: value to set in the ADC's trigger setup register +to enable the trigger +* @is_external: Does the trigger rely on an external pin? +*/ +struct at91_adc_trigger { +const char *name; +u8 value; +bool is_external; +}; + +/** +* struct at91_adc_data - platform data for ADC driver +* @channels_used: channels in use on the board as a bitmask +* @num_channels: global number of channels available on the board +* @registers: Registers definition on the board +* @startup_time: startup time of the ADC in microseconds +* @trigger_list: Triggers available in the ADC +* @trigger_number: Number of triggers available in the ADC +* @use_external_triggers: does the board has external triggers availables +* @vref: Reference voltage for the ADC in millivolts +*/ +struct at91_adc_data { +unsigned long channels_used; +u8 num_channels; +struct at91_adc_reg_desc *registers; +u8 startup_time; +struct at91_adc_trigger *trigger_list; +u8 trigger_number; +bool use_external_triggers; +u16 vref; +}; + +extern void __init at91_add_device_adc (struct at91_adc_data *data); +#endif
Signature · 1 line
1.7.9.5
PATCH 2/9 ARM: AT91: IIO: Add AT91 ADC driver.
In reply to Maxime RipardAdd the ADC driver for Atmel's AT91SAM9G20-EK, AT91SAM9M10G45-EK and AT91SAM9X5 family boards.
It has support for both software and hardware triggers.
--- drivers/iio/Kconfig | 2 + drivers/iio/Makefile | 2 + drivers/iio/adc/Kconfig | 16 ++ drivers/iio/adc/Makefile | 5 + drivers/iio/adc/at91_adc.c | 672 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 697 insertions(+) create mode 100644 drivers/iio/adc/Kconfig create mode 100644 drivers/iio/adc/Makefile create mode 100644 drivers/iio/adc/at91_adc.c
drivers/iio/Kconfig +2 -0
@@ -48,4 +48,6 @@ config IIO_CONSUMERS_PER_TRIGGER This value controls the maximum number of consumers that a given trigger may handle. Default is 2. +source "drivers/iio/adc/Kconfig" + endif # IIO
drivers/iio/Makefile +2 -0
@@ -8,3 +8,5 @@ industrialio-$(CONFIG_IIO_BUFFER) += industrialio-buffer.o industrialio-$(CONFIG_IIO_TRIGGER) += industrialio-trigger.o obj-$(CONFIG_IIO_KFIFO_BUF) += kfifo_buf.o + +obj-y += adc/
drivers/iio/adc/Kconfig new file +16 -0
@@ -0,0 +1,16 @@ +# +# ADC drivers +# +menu "Analog to digital converters" + +config AT91_ADC + tristate "Atmel AT91 ADC" + depends on ARCH_AT91 + select IIO_BUFFER + select IIO_KFIFO_BUF + select IIO_TRIGGER + select SYSFS + help + Say yes here to build support for Atmel AT91 ADC. + +endmenu
drivers/iio/adc/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile for IIO ADC drivers +# + +obj-$(CONFIG_AT91_ADC) += at91_adc.o
drivers/iio/adc/at91_adc.c new file +672 -0
672 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 3/9 ARM: AT91: Add the ADC to the sam9g20ek board
In reply to Maxime RipardThis patch adds platform data for the AT91 ADC driver support for the AT91SAM9G20-EK board.
--- arch/arm/mach-at91/at91sam9260.c | 8 +++ arch/arm/mach-at91/at91sam9260_devices.c | 90 ++++++++++++++++++++++++++++++ arch/arm/mach-at91/board-sam9g20ek.c | 14 +++++ 3 files changed, 112 insertions(+)
arch/arm/mach-at91/at91sam9260.c +8 -0
@@ -55,6 +55,13 @@ static struct clk adc_clk = { .pmc_mask = 1 << AT91SAM9260_ID_ADC, .type = CLK_TYPE_PERIPHERAL, }; + +static struct clk adc_op_clk = { + .name ="adc_op_clk" , + .type =CLK_TYPE_PERIPHERAL , + .rate_hz =5000000 , +}; +static struct clk usart0_clk = { .name ="usart0_clk" , .pmc_mask =1 <<AT91SAM9260_ID_US0 ,
@@ -166,6 +173,7 @@ static struct clk *periph_clocks[] __initdata = { &pioB_clk, &pioC_clk, &adc_clk, + &adc_op_clk, &usart0_clk, &usart1_clk, &usart2_clk,
arch/arm/mach-at91/at91sam9260_devices.c +90 -0
108 lines not on this page · raw message
arch/arm/mach-at91/board-sam9g20ek.c +14 -0
@@ -32,6 +32,8 @@#include <linux/regulator/fixed.h> #include <linux/regulator/consumer.h> +#include <linux/platform_data/at91_adc.h> +#include <mach/hardware.h> #include <asm/setup.h> #include <asm/mach-types.h>
@@ -318,6 +320,16 @@ 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 ), + .use_external_triggers = true, + .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"),
@@ -393,6 +405,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.9.5
PATCH 4/9 AT91: ADC: Add support for the AT91SAM9M10G45-EK board
In reply to Maxime RipardThis patch adds platform data for the AT91 ADC driver support for the AT91SAM9M10G45-EK board.
--- arch/arm/mach-at91/at91sam9g45.c | 9 +++ arch/arm/mach-at91/at91sam9g45_devices.c | 101 ++++++++++++++++++++++++++++++ arch/arm/mach-at91/board-sam9m10g45ek.c | 12 ++++ 3 files changed, 122 insertions(+)
arch/arm/mach-at91/at91sam9g45.c +9 -0
@@ -176,6 +176,12 @@ static struct clk vdec_clk = { .type = CLK_TYPE_PERIPHERAL, }; +static struct clk adc_op_clk = { + .name ="adc_op_clk" , + .type =CLK_TYPE_PERIPHERAL , + .rate_hz =13200000 , +}; +static struct clk *periph_clocks[]__initdata = { &pioA_clk, &pioB_clk,
@@ -204,6 +210,7 @@ static struct clk *periph_clocks[] __initdata = { &isi_clk, &udphs_clk, &mmc1_clk, + &adc_op_clk, // irq0 };
@@ -242,6 +249,8 @@ static struct clk_lookup periph_clocks_lookups[] = {CLKDEV_CON_ID ("pioC" , &pioC_clk),CLKDEV_CON_ID ("pioD" , &pioDE_clk),CLKDEV_CON_ID ("pioE" , &pioDE_clk), +/* Fake adc clock */ + CLKDEV_CON_ID("adc_clk", &tsc_clk), }; static struct clk_lookup usart_clocks_lookups[] = {
arch/arm/mach-at91/at91sam9g45_devices.c +101 -0
116 lines not on this page · raw message
arch/arm/mach-at91/board-sam9m10g45ek.c +12 -0
@@ -27,6 +27,8 @@#include <linux/atmel-mci.h> #include <linux/delay.h> +#include <linux/platform_data/at91_adc.h> +#include <mach/hardware.h> #include <video/atmel_lcdc.h> #include <media/soc_camera.h>
@@ -315,6 +317,14 @@ static struct at91_tsadcc_data ek_tsadcc_data = { .ts_sample_hold_time = 0x0a, }; +/* +* ADCs +*/ +static struct at91_adc_data ek_adc_data = { + .channels_used =BIT (0 ) |BIT (1 ) |BIT (2 ) |BIT (3 ) |BIT (4 ) |BIT (5 ) |BIT (6 ) |BIT (7 ), + .use_external_triggers = true, + .vref =3300 , +};/* * GPIO Buttons
@@ -480,6 +490,8 @@ static void __init ek_board_init(void)at91_add_device_lcdc (&ek_lcdc_data);/* Touch Screen */ at91_add_device_tsadcc (&ek_tsadcc_data); +/* ADC */ +at91_add_device_adc (&ek_adc_data);/* Push Buttons */ ek_add_device_buttons ();/* AC97 */
Signature · 1 line
1.7.9.5
PATCH 5/9 ARM: AT91: Add the ADC clock to the sam9x5 SoC file
In reply to Maxime Ripard--- arch/arm/mach-at91/at91sam9x5.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm/mach-at91/at91sam9x5.c +6 -0
@@ -120,6 +120,11 @@ static struct clk adc_clk = { .pmc_mask = 1 << AT91SAM9X5_ID_ADC, .type = CLK_TYPE_PERIPHERAL, }; +static struct clk adc_op_clk = { + .name ="adc_op_clk" , + .type =CLK_TYPE_PERIPHERAL , + .rate_hz =5000000 , +};static struct clk dma0_clk = { .name ="dma0_clk" , .pmc_mask =1 <<AT91SAM9X5_ID_DMA0 ,
@@ -205,6 +210,7 @@ static struct clk *periph_clocks[] __initdata = { &tcb0_clk, &pwm_clk, &adc_clk, + &adc_op_clk, &dma0_clk, &dma1_clk, &uhphs_clk,
Signature · 1 line
1.7.9.5
PATCH 6/9 IIO: AT91: Add DT support to at91_adc driver
In reply to Maxime Ripard--- .../devicetree/bindings/arm/atmel-adc.txt | 65 ++++++++++ drivers/iio/adc/at91_adc.c | 132 +++++++++++++++++++- 2 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/arm/atmel-adc.txt
Documentation/devicetree/bindings/arm/atmel-adc.txt new file +65 -0
@@ -0,0 +1,65 @@ +* AT91's Analog to Digital Converter (ADC) + +Required properties: + - compatible: Should be "atmel,at91sam9260-adc" + - reg: Should contain ADC registers location and length + - interrupts: Should contain the IRQ line for the ADC + - atmel,adc-channel-base: Offset of the first channel data register + - atmel,adc-channels-used: Bitmask of the channels muxed and enable for this + device + - atmel,adc-drdy-mask: Mask of the DRDY interruption in the ADC + - atmel,adc-num-channels: Number of channels available in the ADC + - atmel,adc-startup-time: Startup Time of the ADC in microseconds as + defined in the datasheet + - atmel,adc-status-register: Offset of the Interrupt Status Register + - atmel,adc-trigger-register: Offset of the Trigger Register + - atmel,adc-vref: Reference voltage in millivolts for the conversions + +Optional properties: + - atmel,adc-use-external: Boolean to enable of external triggers + +Optional trigger Nodes: + - Required properties: + * trigger-name: Name of the trigger exposed to the user + * trigger-value: Value to put in the Trigger register + to activate this trigger + - Optional properties: + * trigger-external: Is the trigger an external trigger? + +Examples: +adc0: adc at fffb0000 { + compatible = "atmel,at91sam9260-adc"; + reg = <0xfffb0000 0x100>; + interrupts = <20 4>; + atmel,adc-channel-base = <0x30>; + atmel,adc-channels-used = <0xff>; + atmel,adc-drdy-mask = <0x10000>; + atmel,adc-num-channels = <8>; + atmel,adc-startup-time = <40>; + atmel,adc-status-register = <0x1c>; + atmel,adc-trigger-register = <0x08>; + atmel,adc-use-external; + atmel,adc-vref = <3300>; + + trigger at 0 { + trigger-name = "external-rising"; + trigger-value = <0x1>; + trigger-external; + }; + trigger at 1 { + trigger-name = "external-falling"; + trigger-value = <0x2>; + trigger-external; + }; + + trigger at 2 { + trigger-name = "external-any"; + trigger-value = <0x3>; + trigger-external; + }; + + trigger at 3 { + trigger-name = "continuous"; + trigger-value = <0x6>; + }; +};
drivers/iio/adc/at91_adc.c +131 -1
161 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 7/9 ARM: AT91: Add ADC driver to the at91sam9g45 dtsi
In reply to Maxime Ripard--- arch/arm/boot/dts/at91sam9g45.dtsi | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
arch/arm/boot/dts/at91sam9g45.dtsi +37 -0
@@ -199,6 +199,43 @@ interrupts = <25 4>; status = "disabled"; }; + + adc0: adc at fffb0000 { + compatible = "atmel,at91sam9260-adc"; + reg = <0xfffb0000 0x100>; + interrupts = <20 4>; + atmel,adc-use-external-triggers; + atmel,adc-channels-used = <0xff>; + atmel,adc-vref = <3300>; + atmel,adc-num-channels = <8>; + atmel,adc-startup-time = <40>; + atmel,adc-channel-base = <0x30>; + atmel,adc-drdy-mask = <0x10000>; + atmel,adc-status-register = <0x1c>; + atmel,adc-trigger-register = <0x08>; + + trigger at 0 { + trigger-name = "external-rising"; + trigger-value = <0x1>; + trigger-external; + }; + trigger at 1 { + trigger-name = "external-falling"; + trigger-value = <0x2>; + trigger-external; + }; + + trigger at 2 { + trigger-name = "external-any"; + trigger-value = <0x3>; + trigger-external; + }; + + trigger at 3 { + trigger-name = "continuous"; + trigger-value = <0x6>; + }; + }; }; nand0: nand at 40000000 {
Signature · 1 line
1.7.9.5
PATCH 8/9 ARM: AT91: Add ADC driver to the at91sam9x5 dtsi
In reply to Maxime Ripard--- arch/arm/boot/dts/at91sam9x5.dtsi | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
arch/arm/boot/dts/at91sam9x5.dtsi +38 -0
@@ -190,6 +190,44 @@ interrupts = <27 4>; status = "disabled"; }; + + adc0: adc at f804c000 { + compatible = "atmel,at91sam9260-adc"; + reg = <0xf804c000 0x100>; + interrupts = <19 4>; + atmel,adc-use-external; + atmel,adc-channels-used = <0xffff>; + atmel,adc-vref = <3300>; + atmel,adc-num-channels = <12>; + atmel,adc-startup-time = <40>; + atmel,adc-channel-base = <0x50>; + atmel,adc-drdy-mask = <0x1000000>; + atmel,adc-status-register = <0x30>; + atmel,adc-trigger-register = <0xc0>; + + trigger at 0 { + trigger-name = "external-rising"; + trigger-value = <0x1>; + trigger-external; + }; + + trigger at 1 { + trigger-name = "external-falling"; + trigger-value = <0x2>; + trigger-external; + }; + + trigger at 2 { + trigger-name = "external-any"; + trigger-value = <0x3>; + trigger-external; + }; + + trigger at 3 { + trigger-name = "continuous"; + trigger-value = <0x6>; + }; + }; }; nand0: nand at 40000000 {
Signature · 1 line
1.7.9.5
PATCH 9/9 ARM: AT91: Add ADC driver to the at91sam9g20 dtsi
In reply to Maxime Ripard--- arch/arm/boot/dts/at91sam9g20.dtsi | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
arch/arm/boot/dts/at91sam9g20.dtsi +35 -0
@@ -197,6 +197,41 @@ interrupts = <10 4>; status = "disabled"; }; + + adc0: adc at fffe0000 { + compatible = "atmel,at91sam9260-adc"; + reg = <0xfffe0000 0x100>; + interrupts = <5 4>; + atmel,adc-use-external-triggers; + atmel,adc-channels-used = <0xf>; + atmel,adc-vref = <3300>; + atmel,adc-num-channels = <4>; + atmel,adc-startup-time = <10>; + atmel,adc-channel-base = <0x30>; + atmel,adc-drdy-mask = <0x10000>; + atmel,adc-status-register = <0x1c>; + atmel,adc-trigger-register = <0x04>; + + trigger at 0 { + trigger-name = "timer-counter-0"; + trigger-value = <0x1>; + }; + trigger at 1 { + trigger-name = "timer-counter-1"; + trigger-value = <0x3>; + }; + + trigger at 2 { + trigger-name = "timer-counter-2"; + trigger-value = <0x5>; + }; + + trigger at 3 { + trigger-name = "external"; + trigger-value = <0x13>; + trigger-external; + }; + }; }; nand0: nand at 40000000 {
Signature · 1 line
1.7.9.5
PATCH v5 1/1 Add ADC driver for Atmel G20, G45 and X5 boards
In reply to Maxime RipardQuoted 8 lines · Maxime Ripard
Hi Greg,
Here is a patchset adding an IIO driver for various Atmel SoCs. As it relies on out-of-staging-IIO, which is still in staging-next, it seems that you should be the one merging it.
As you can see, it got an acked-by all the maintainers involved in this patch, so it should be pretty good for inclusion.
All now applied, thanks.
greg k-h