Skip to contentSkip to conversation

iio: ADC driver for EP93xx SoC

PATCH Superseded Alexander Sverdlin 3 participants 11 messages May 17, 2017 – Jun 3, 2017

Subsystems (5)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Alexander Sverdlin

author maintainer
#0 lore raw

v4 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
author maintainer
#1 lore raw

PATCH 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
index 39ef3b613912..b9cd9d7da14d 100644
@@ -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
author maintainer
#2 lore raw

PATCH v4 2/5 clk: ep93xx: Add ADC clock

In reply to Alexander Sverdlin

From: 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
index b9cd9d7da14d..425342637e47 100644
@@ -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
author maintainer
#3 lore raw

PATCH v4 3/5 ep93xx: Add ADC platform device support to core

In reply to Alexander Sverdlin

Newly 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
index c393b1b0310d..f53c61813998 100644
@@ -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
index 4c0bbd97f741..db0839691ef5 100644
@@ -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
index 7bf7ff8beae7..d20e631164cf 100644
@@ -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
author maintainer
#4 lore raw

PATCH v4 4/5 edb93xx: Add ADC platform device

In reply to Alexander Sverdlin

This 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
index 0ac176386789..7a7f280b07d7 100644
@@ -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
author maintainer
#5 lore raw

PATCH v4 5/5 iio: adc: New driver for Cirrus Logic EP93xx ADC

In reply to Alexander Sverdlin

New 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
new file mode 100644
index 000000000000..23053e7817bd
@@ -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
index 401f47b51d83..a3eba810292a 100644
@@ -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
index 9339bec4babe..d1a036d38486 100644
@@ -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
maintainer
#6 lore raw

v4 cover iio: ADC driver for EP93xx SoC

In reply to Alexander Sverdlin
Quoted 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:
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

#7 lore raw

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_parent in 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

author maintainer
#8 lore raw

v4 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.

#9 lore raw

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 MAINTAINERS file?
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

maintainer
#10 lore raw

v4 cover iio: ADC driver for EP93xx SoC

In reply to Ryan Mallon
Quoted 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:

Quoted 3 lines

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.

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