iio: ADC driver for EP93xx SoC
Subsystems (5)
Alexander Sverdlin
maintainerv4 cover iio: ADC driver for EP93xx SoC
This series prepares the necessary infrastructure for ADC platform device on Cirrus Logic EP93xx family of SoCs and adds the driver for ADC device using IIO subsystem.
Changelog
v4:
Spelling improvements
sign_extend32() usage
v3:
Rebased to the current master
sizeof(struct foo) -> sizeof(*bar)
v2:
Added Documentation/iio/ep93xx_adc.txt
Removed extend_name
Added timeout to the status polling loop
Used iio_device_register() instead of devm_iio_device_register()
Alexander Sverdlin (5):
clk: ep93xx: Implement clk_get_parent()
clk: ep93xx: Add ADC clock
ep93xx: Add ADC platform device support to core
edb93xx: Add ADC platform device
iio: adc: New driver for Cirrus Logic EP93xx ADC
Documentation/iio/ep93xx_adc.txt | 29 +++ arch/arm/mach-ep93xx/clock.c | 14 ++ arch/arm/mach-ep93xx/core.c | 24 +++ arch/arm/mach-ep93xx/edb93xx.c | 1 + arch/arm/mach-ep93xx/include/mach/platform.h | 1 + arch/arm/mach-ep93xx/soc.h | 1 + drivers/iio/adc/Kconfig | 11 ++ drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ep93xx_adc.c | 255 +++++++++++++++++++++++++++ 9 files changed, 337 insertions(+) create mode 100644 Documentation/iio/ep93xx_adc.txt create mode 100644 drivers/iio/adc/ep93xx_adc.c
Signature · 1 line
2.12.2
Alexander Sverdlin
maintainerPATCH v4 1/5 clk: ep93xx: Implement clk_get_parent()
Trivial implementation of clk_get_parent(), but necessary for some drivers, such as ADC.
--- arch/arm/mach-ep93xx/clock.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm/mach-ep93xx/clock.c +6 -0
@@ -475,6 +475,12 @@ int clk_set_rate(struct clk *clk, unsigned long rate) }EXPORT_SYMBOL (clk_set_rate); +struct clk *clk_get_parent (struct clk *clk) +{ +return clk->parent; +} +EXPORT_SYMBOL (clk_get_parent); +static char fclk_divisors[] = {1 ,2 ,4 ,8 ,16 ,1 ,1 ,1 };static char hclk_divisors[] = {1 ,2 ,4 ,5 ,6 ,8 ,16 ,32 };
Signature · 1 line
2.12.2
Alexander Sverdlin
maintainerPATCH v4 2/5 clk: ep93xx: Add ADC clock
In reply to Alexander SverdlinFrom: Alexander Sverdlin <[email protected]>
ADC and keypad controller clocks share the same control register, so use the existing infrastructure to add ADC clock support for Cirrus Logic EP93xx SoCs.
--- arch/arm/mach-ep93xx/clock.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm/mach-ep93xx/clock.c +8 -0
@@ -98,6 +98,13 @@ static struct clk clk_keypad = { .enable_mask = EP93XX_SYSCON_KEYTCHCLKDIV_KEN, .set_rate = set_keytchclk_rate, }; +static struct clk clk_adc = { + .parent = &clk_xtali, + .sw_locked =1 , + .enable_reg =EP93XX_SYSCON_KEYTCHCLKDIV , + .enable_mask =EP93XX_SYSCON_KEYTCHCLKDIV_TSEN , + .set_rate = set_keytchclk_rate, +};static struct clk clk_spi = { .parent = &clk_xtali, .rate =EP93XX_EXT_CLK_RATE ,
@@ -214,6 +221,7 @@ static struct clk_lookup clocks[] = {INIT_CK (NULL ,"pll2" , &clk_pll2),INIT_CK ("ohci-platform" ,NULL , &clk_usb_host),INIT_CK ("ep93xx-keypad" ,NULL , &clk_keypad), +INIT_CK ("ep93xx-adc" ,NULL , &clk_adc),INIT_CK ("ep93xx-fb" ,NULL , &clk_video),INIT_CK ("ep93xx-spi.0" ,NULL , &clk_spi), INIT_CK("ep93xx-i2s", "mclk", &clk_i2s_mclk),
Signature · 1 line
2.12.2
Alexander Sverdlin
maintainerPATCH v4 3/5 ep93xx: Add ADC platform device support to core
In reply to Alexander SverdlinNewly provided ep93xx_register_adc() could be used by machine-specific code to create ADC platform device on Cirrus Logic EP93xx SoC-based machines.
--- arch/arm/mach-ep93xx/core.c | 24 ++++++++++++++++++++++++ arch/arm/mach-ep93xx/include/mach/platform.h | 1 + arch/arm/mach-ep93xx/soc.h | 1 + 3 files changed, 26 insertions(+)
arch/arm/mach-ep93xx/core.c +24 -0
@@ -821,6 +821,30 @@ void ep93xx_ide_release_gpio(struct platform_device *pdev)EXPORT_SYMBOL (ep93xx_ide_release_gpio);/************************************************************************* +* EP93xx ADC +*************************************************************************/ +static struct resource ep93xx_adc_resources[] = { +DEFINE_RES_MEM (EP93XX_ADC_PHYS_BASE ,0x28 ), +DEFINE_RES_IRQ (IRQ_EP93XX_TOUCH ), +}; + +static struct platform_device ep93xx_adc_device = { + .name ="ep93xx-adc" , + .id =-1 , + .num_resources =ARRAY_SIZE (ep93xx_adc_resources), + .resource = ep93xx_adc_resources, +}; + +void __init ep93xx_register_adc (void ) +{ +/* Power up ADC, deactivate Touch Screen Controller */ +ep93xx_devcfg_set_clear (EP93XX_SYSCON_DEVCFG_TIN , +EP93XX_SYSCON_DEVCFG_ADCPD ); + +platform_device_register (&ep93xx_adc_device); +} + +/************************************************************************* * EP93xx Security peripheral *************************************************************************/
arch/arm/mach-ep93xx/include/mach/platform.h +1 -0
@@ -52,6 +52,7 @@ int ep93xx_i2s_acquire(void);void ep93xx_i2s_release (void );void ep93xx_register_ac97 (void );void ep93xx_register_ide (void ); +void ep93xx_register_adc (void );int ep93xx_ide_acquire_gpio (struct platform_device *pdev);void ep93xx_ide_release_gpio (struct platform_device *pdev);
arch/arm/mach-ep93xx/soc.h +1 -0
@@ -95,6 +95,7 @@#define EP93XX_KEY_MATRIX_PHYS_BASE EP93XX_APB_PHYS(0x000f0000)#define EP93XX_KEY_MATRIX_BASE EP93XX_APB_IOMEM(0x000f0000) +#define EP93XX_ADC_PHYS_BASE EP93XX_APB_PHYS(0x00100000)#define EP93XX_ADC_BASE EP93XX_APB_IOMEM(0x00100000)#define EP93XX_TOUCHSCREEN_BASE EP93XX_APB_IOMEM(0x00100000)
Signature · 1 line
2.12.2
Alexander Sverdlin
maintainerPATCH v4 4/5 edb93xx: Add ADC platform device
In reply to Alexander SverdlinThis enables the creation of ADC platform device on EDB93xx series of Cirrus Logic evaluation boards. The driver for this device must be enabled separately, either as built-in, or a module.
--- arch/arm/mach-ep93xx/edb93xx.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-ep93xx/edb93xx.c +1 -0
@@ -245,6 +245,7 @@ static void __init edb93xx_init_machine(void)edb93xx_register_pwm ();edb93xx_register_fb ();edb93xx_register_ide (); +ep93xx_register_adc (); }
Signature · 1 line
2.12.2
Alexander Sverdlin
maintainerPATCH v4 5/5 iio: adc: New driver for Cirrus Logic EP93xx ADC
In reply to Alexander SverdlinNew driver adding support for ADC found on Cirrus Logic EP93xx series of SoCs. Board specific code must take care to create plaform device with all necessary resources.
--- Documentation/iio/ep93xx_adc.txt | 29 +++++ drivers/iio/adc/Kconfig | 11 ++ drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ep93xx_adc.c | 255 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 296 insertions(+) create mode 100644 Documentation/iio/ep93xx_adc.txt create mode 100644 drivers/iio/adc/ep93xx_adc.c
Documentation/iio/ep93xx_adc.txt new file +29 -0
@@ -0,0 +1,29 @@ +Cirrus Logic EP93xx ADC driver. + +1. Overview + +The driver is intended to work on both low-end (EP9301, EP9302) devices with +5-channel ADC and high-end (EP9307, EP9312, EP9315) devices with 10-channel +touchscreen/ADC module. + +2. Channel numbering + +Numbering scheme for channels 0..4 is defined in EP9301 and EP9302 datasheets. +EP9307, EP9312 and EP9312 have 3 channels more (total 8), but the numbering is +not defined. So the last three are numbered randomly, let's say. + +Assuming ep93xx_adc is IIO device0, you'd find the following entries under +/sys/bus/iio/devices/iio:device0/: + + +-----------------+---------------+ + | sysfs entry | ball/pin name | + +-----------------+---------------+ + | in_voltage0_raw | YM | + | in_voltage1_raw | SXP | + | in_voltage2_raw | SXM | + | in_voltage3_raw | SYP | + | in_voltage4_raw | SYM | + | in_voltage5_raw | XP | + | in_voltage6_raw | XM | + | in_voltage7_raw | YP | + +-----------------+---------------+
drivers/iio/adc/Kconfig +11 -0
@@ -249,6 +249,17 @@ config ENVELOPE_DETECTOR To compile this driver as a module, choose M here: the module will be called envelope-detector. +config EP93XX_ADC + tristate "Cirrus Logic EP93XX ADC driver" + depends on ARCH_EP93XX + help + Driver for the ADC module on the EP93XX series of SoC from Cirrus Logic. + It's recommended to switch on CONFIG_HIGH_RES_TIMERS option, in this + case driver will reduce its CPU usage by 90% in some use cases. + + To compile this driver as a module, choose M here: the module will be + called ep93xx_adc. + config EXYNOS_ADC tristate "Exynos ADC driver support" depends on ARCH_EXYNOS || ARCH_S3C24XX || ARCH_S3C64XX || (OF && COMPILE_TEST)
drivers/iio/adc/Makefile +1 -0
@@ -25,6 +25,7 @@ obj-$(CONFIG_CC10001_ADC) += cc10001_adc.o obj-$(CONFIG_CPCAP_ADC) += cpcap-adc.o obj-$(CONFIG_DA9150_GPADC) += da9150-gpadc.o obj-$(CONFIG_ENVELOPE_DETECTOR) += envelope-detector.o +obj-$(CONFIG_EP93XX_ADC) += ep93xx_adc.o obj-$(CONFIG_EXYNOS_ADC) += exynos_adc.o obj-$(CONFIG_FSL_MX25_ADC) += fsl-imx25-gcq.o obj-$(CONFIG_HI8435) += hi8435.o
drivers/iio/adc/ep93xx_adc.c new file +255 -0
255 lines not on this page · raw message
Signature · 1 line
2.12.2
Jonathan Cameron
maintainerv4 cover iio: ADC driver for EP93xx SoC
In reply to Alexander SverdlinQuoted 3 lines · Alexander Sverdlin
This series prepares the necessary infrastructure for ADC platform device on Cirrus Logic EP93xx family of SoCs and adds the driver for ADC device using IIO subsystem.
Hartley, Ryan,
How do you want to handle taking this series forward. Clearly we have a few arch specific bits and then the driver which is dependent on some of them.
I'm happy to take the lot through the IIO tree, but will be wanting a few acks.
I'm interested to note how few implementations there are of clk_get_parent in tree. Any comments on that little bit of the code would be particularly welcome.
Thanks,
Jonathan
Quoted 34 lines
Changelog
v4:
Spelling improvements
sign_extend32()usage
v3:
Rebased to the current master
sizeof(struct foo) ->sizeof(*bar)
v2:
AddedDocumentation/iio/ep93xx_adc.txt
Removedextend_name
Added timeout to the status polling loop
Usediio_device_register()instead ofdevm_iio_device_register()Alexander Sverdlin (5):
clk: ep93xx: Implementclk_get_parent()
clk: ep93xx: Add ADC clock
ep93xx: Add ADC platform device support to core
edb93xx: Add ADC platform device
iio: adc: New driver for Cirrus Logic EP93xx ADCDocumentation/iio/ep93xx_adc.txt | 29 +++ arch/arm/mach-ep93xx/clock.c | 14 ++ arch/arm/mach-ep93xx/core.c | 24 +++ arch/arm/mach-ep93xx/edb93xx.c | 1 + arch/arm/mach-ep93xx/include/mach/platform.h | 1 + arch/arm/mach-ep93xx/soc.h | 1 + drivers/iio/adc/Kconfig | 11 ++ drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ep93xx_adc.c | 255 +++++++++++++++++++++++++++ 9 files changed, 337 insertions(+)create mode 100644
Documentation/iio/ep93xx_adc.txtcreate mode 100644drivers/iio/adc/ep93xx_adc.c
v4 cover iio: ADC driver for EP93xx SoC
Quoted 11 lines · Jonathan Cameron
Quoted 5 lines · Alexander Sverdlin
This series prepares the necessary infrastructure for ADC platform device on
Cirrus Logic EP93xx family of SoCs and adds the driver for ADC device using
IIO subsystem.Hartley, Ryan,
How do you want to handle taking this series forward. Clearly we have a few arch specific bits and then the driver which is dependent on some of them.
I no longer maintain an ep93xx tree because the architecture gets very few patches now. Patches should go via the arm-soc tree, which is maintained by (I believe) Arnd and Olaf.
Quoted 3 lines
I'm happy to take the lot through the IIO tree, but will be wanting a few acks.
Sure, the series looks fine to me. For the ep93xx specific bits:
Quoted 3 lines
I'm interested to note how few implementations there are of
clk_get_parentin tree. Any comments on that little bit of the code would be particularly welcome.
The ep93xx architecture is old and obsolete. Because of this, and the relatively few number of people developing for it and with hardware to test, it hasn't gotten upgraded to some of the more modern kernel apis like the common clock framework.
It probably isn't too difficult to move ep93xx to the common clock framework, but it is a separate change and I don't think Alexander should have to do it as a prerequisite to getting this adc support merged.
~Ryan
Alexander Sverdlin
maintainerv4 cover iio: ADC driver for EP93xx SoC
Hello Ryan!
Quoted 6 lines · Ryan Mallon
Quoted 3 lines
How do you want to handle taking this series forward. Clearly we have a few arch specific bits and then the driver which is dependent on some of them.
I no longer maintain an ep93xx tree because the architecture gets very few patches now. Patches should go via the arm-soc tree, which is maintained by (I believe) Arnd and Olaf.
This probably should be reflected in MAINTAINERS file?
Do you want to drop EP93xx maintenance?
In this case I can volunteer myself as a maintainer for the platform.
--
Best regards,
Alexander.
v4 cover iio: ADC driver for EP93xx SoC
Quoted 10 lines · Alexander Sverdlin
Hello Ryan!
Quoted 3 lines · Ryan Mallon
Quoted 3 lines
How do you want to handle taking this series forward. Clearly we have a few arch specific bits and then the driver which is dependent on some of them.
Quoted 7 lines
Quoted 3 lines
I no longer maintain an ep93xx tree because the architecture gets very few patches now. Patches should go via the arm-soc tree, which is maintained by (I believe) Arnd and Olaf.
This probably should be reflected in
MAINTAINERSfile?
Do you want to drop EP93xx maintenance?
In this case I can volunteer myself as a maintainer for the platform.
Sure. Sounds good. Send a patch changing the maintainer and I can ack it.
~Ryan
Jonathan Cameron
maintainerv4 cover iio: ADC driver for EP93xx SoC
In reply to Ryan MallonQuoted 29 lines · On Mon, 22 May 2017 06:29:08 +1000 Ryan Mallon <[email protected]> wrote:
Quoted 11 lines · Jonathan Cameron
Quoted 5 lines · Alexander Sverdlin
This series prepares the necessary infrastructure for ADC platform device on
Cirrus Logic EP93xx family of SoCs and adds the driver for ADC device using
IIO subsystem.Hartley, Ryan,
How do you want to handle taking this series forward. Clearly we have a few arch specific bits and then the driver which is dependent on some of them.
I no longer maintain an ep93xx tree because the architecture gets very few patches now. Patches should go via the arm-soc tree, which is maintained by (I believe) Arnd and Olaf.
Quoted 3 lines
I'm happy to take the lot through the IIO tree, but will be wanting a few acks.
Sure, the series looks fine to me. For the ep93xx specific bits:
Acked-by Ryan Mallon <[email protected]>Quoted 3 lines
I'm interested to note how few implementations there are of
clk_get_parentin tree. Any comments on that little bit of the code would be particularly welcome.
Quoted 8 lines
The ep93xx architecture is old and obsolete. Because of this, and the relatively few number of people developing for it and with hardware to test, it hasn't gotten upgraded to some of the more modern kernel apis like the common clock framework.
It probably isn't too difficult to move ep93xx to the common clock framework, but it is a separate change and I don't think Alexander should have to do it as a prerequisite to getting this adc support merged.
Agreed entirely!
Alexander, would you mind reposting the whole series, with the linux-arm-kernel at lists.infrared.org cc'd.
I've cc'd it to this email to provide a bit of background to the maintainers, but please add a note to the cover letter highlighting what Ryan has covered here.
Thanks,
Jonathan
Quoted 2 lines
~Ryan