ARM: Developed device driver for Atmel TSADC controller
Subsystems (4)
PATCH 1/1 ARM: Developed device driver for Atmel TSADC controller
Some Atmel AT91 devices contains a touchscreen analog to digital converter. This device driver use the ADC as a multi-channel raw data input device.
Tested on AT91SAM9G45 boards.
--- CREDITS | 4 + arch/arm/configs/at91sam9g45_defconfig | 1 + arch/arm/mach-at91/include/mach/at91_adc.h | 16 ++ drivers/misc/Kconfig | 7 + drivers/misc/Makefile | 1 + drivers/misc/atmel_tsadc.c | 361 ++++++++++++++++++++++++++++ 6 files changed, 390 insertions(+), 0 deletions(-) create mode 100644 drivers/misc/atmel_tsadc.c
CREDITS +4 -0
@@ -2652,6 +2652,10 @@ S: 2364 Old Trail Drive S: Reston, Virginia 20191 S: USA +N: Petter Nordby +E: pettno at gmail.com +D: Atmel ADC device driver + N: Fredrik Noring E: noring at nocrew.org W: http://www.lysator.liu.se/~noring/
arch/arm/configs/at91sam9g45_defconfig +1 -0
@@ -15,6 +15,7 @@ CONFIG_MODULE_UNLOAD=y # CONFIG_BLK_DEV_BSG is not set # CONFIG_IOSCHED_DEADLINE is not set # CONFIG_IOSCHED_CFQ is not set +CONFIG_CROSS_COMPILE="arm-linux-" CONFIG_ARCH_AT91=y CONFIG_ARCH_AT91SAM9G45=y CONFIG_MACH_AT91SAM9M10G45EK=y
arch/arm/mach-at91/include/mach/at91_adc.h +16 -0
@@ -29,12 +29,28 @@#define AT91_ADC_LOWRES (1 << 4)/* Low Resolution */ #define AT91_ADC_SLEEP (1 << 5)/* Sleep Mode */ #define AT91_ADC_PRESCAL (0x3f << 8)/* Prescalar Rate Selection */ +#define AT91_ADC_EPRESCAL (0xff << 8)/* Prescalar Rate Selection (Extended) */ #define AT91_ADC_PRESCAL_ (x) ((x) << 8)#define AT91_ADC_STARTUP (0x1f << 16)/* Startup Up Time */ #define AT91_ADC_STARTUP_ (x) ((x) << 16)#define AT91_ADC_SHTIM (0xf << 24)/* Sample & Hold Time */ #define AT91_ADC_SHTIM_ (x) ((x) << 24) +#define AT91_ADC_TRGR 0x08/* Trigger register */ +#define AT91_ADC_TRGMOD (7 << 0)/* Trigger mode */ +#define AT91_ADC_TRGMOD_NONE (0 << 0) +#define AT91_ADC_TRGMOD_EXT_RISING (1 << 0) +#define AT91_ADC_TRGMOD_EXT_FALLING (2 << 0) +#define AT91_ADC_TRGMOD_EXT_ANY (3 << 0) +#define AT91_ADC_TRGMOD_PENDET (4 << 0) +#define AT91_ADC_TRGMOD_PERIOD (5 << 0) +#define AT91_ADC_TRGMOD_CONTINUOUS (6 << 0) +#define AT91_ADC_TRGPER (0xffff << 16)/* Trigger period */ + +#define AT91_ADC_TSR 0x0C/* Touch Screen register */ +#define AT91_ADC_TSFREQ (0xf << 0)/* TS Frequency in Interleaved mode */ +#define AT91_ADC_TSSHTIM (0xf << 24)/* Sample & Hold time */ +#define AT91_ADC_CHER 0x10/* Channel Enable Register */ #define AT91_ADC_CHDR 0x14/* Channel Disable Register */ #define AT91_ADC_CHSR 0x18/* Channel Status Register */
drivers/misc/Kconfig +7 -0
@@ -112,6 +112,13 @@ config ATMEL_TCB_CLKSRC_BLOCK TC can be used for other purposes, such as PWM generation and interval timing. +config ATMEL_TSADC + tristate "Atmel touchscreen ADC char device driver" + depends on ARCH_AT91SAM9RL || ARCH_AT91SAM9G45 + help + Say Y here if you want to use the touchscreen ADC controller + as a simple ADC input device. + config IBM_ASM tristate "Device driver for IBM RSA service processor" depends on X86 && PCI && INPUT && EXPERIMENTAL
drivers/misc/Makefile +1 -0
@@ -10,6 +10,7 @@ obj-$(CONFIG_INTEL_MID_PTI) += pti.o obj-$(CONFIG_ATMEL_PWM) += atmel_pwm.o obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o obj-$(CONFIG_ATMEL_TCLIB) += atmel_tclib.o +obj-$(CONFIG_ATMEL_TSADC) += atmel_tsadc.o obj-$(CONFIG_BMP085) += bmp085.o obj-$(CONFIG_ICS932S401) += ics932s401.o obj-$(CONFIG_LKDTM) += lkdtm.o
drivers/misc/atmel_tsadc.c new file +361 -0
361 lines not on this page · raw message
Signature · 1 line
1.7.7
PATCH 1/1 ARM: Developed device driver for Atmel TSADC controller
Quoted 9 lines · Petter Nordby
Some Atmel AT91 devices contains a touchscreen analog to digital converter. This device driver use the ADC as a multi-channel raw data input device.
Tested on AT91SAM9G45 boards.
Signed-off-by Petter Nordby <[email protected]>--- CREDITS | 4 +
Shouldn't this be in MAINTAINERS?
Quoted 5 lines
arch/arm/configs/at91sam9g45_defconfig | 1 + arch/arm/mach-at91/include/mach/at91_adc.h | 16 ++ drivers/misc/Kconfig | 7 + drivers/misc/Makefile | 1 + drivers/misc/atmel_tsadc.c | 361 ++++++++++++++++++++++++++++
We have a proper abstraction of input devices under drivers/input which includes touchscreens. I suggest using that rather than developing your own private kernel API.
It will avoid all sorts of bugs, like using put_user() with IRQs disabled.
Thanks.
PATCH 1/1 ARM: Developed device driver for Atmel TSADC controller
On 01/23/2012 12:36 PM, Russell King - ARM Linux :
Quoted 19 lines · Petter Nordby
Quoted 9 lines
Some Atmel AT91 devices contains a touchscreen analog to digital converter. This device driver use the ADC as a multi-channel raw data input device.
Tested on AT91SAM9G45 boards.
Signed-off-by Petter Nordby <[email protected]>--- CREDITS | 4 +Shouldn't this be in
MAINTAINERS?Quoted 5 lines
arch/arm/configs/at91sam9g45_defconfig | 1 + arch/arm/mach-at91/include/mach/at91_adc.h | 16 ++ drivers/misc/Kconfig | 7 + drivers/misc/Makefile | 1 + drivers/misc/atmel_tsadc.c | 361 ++++++++++++++++++++++++++++
Quoted 3 lines
We have a proper abstraction of input devices under
drivers/inputwhich includes touchscreens. I suggest using that rather than developing your own private kernel API.
Petter,
Be sure that I appreciate the submission of your work. Examples of code and new drivers are always a big strength of the Open Source community.
But as Russell suggested, this use of ADC for AT91SAM9G45 family (TSADC) will be better suited for the IIO subsystem.
A new AT91 ADC driver designed for this IIO subsystem has been developed a little time ago:
"[PATCH RESEND v13] AT91: Add a driver for the ADC"
It will likely be included shortly in mainline kernel. I advice to follow this development and add the support of SAM9G45 ADC to this existing infrastructure.
I guess that the input/touchsreen part of the TSADC is not the purpose of your driver:drivers/input/touchscreen/atmel_tsadcc.c
will take care of this feature.
Best regards,
Signature · 1 line
Nicolas Ferre
PATCH 1/1 ARM: Developed device driver for Atmel TSADC controller
Quoted 9 lines · Nicolas Ferre
But as Russell suggested, this use of ADC for AT91SAM9G45 family (TSADC) will be better suited for the IIO subsystem.
A new AT91 ADC driver designed for this IIO subsystem has been developed a little time ago:
"[PATCH RESEND v13] AT91: Add a driver for the ADC"It will likely be included shortly in mainline kernel. I advice to follow this development and add the support of SAM9G45 ADC to this existing infrastructure.
Thanks for pointing me in this direction. Exactly what I need. I'm really looking forward to getting it in mainline kernel.
Best regards,
Petter Nordby