Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1539245 > unrolled thread

[PATCH v8 0/3] add support for Allwinner SoCs ADC

Started byQuentin Schulz <quentin.schulz@free-electrons.com>
First post2016-12-09 11:30 +0100
Last post2016-12-09 11:30 +0100
Articles 2 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH v8 0/3] add support for Allwinner SoCs ADC Quentin Schulz <quentin.schulz@free-electrons.com> - 2016-12-09 11:30 +0100
    [PATCH v8 2/3] mfd: Kconfig: MFD_SUN4I_GPADC depends on !TOUCHSCREN_SUN4I_GPADC Quentin Schulz <quentin.schulz@free-electrons.com> - 2016-12-09 11:30 +0100

#1539245 — [PATCH v8 0/3] add support for Allwinner SoCs ADC

FromQuentin Schulz <quentin.schulz@free-electrons.com>
Date2016-12-09 11:30 +0100
Subject[PATCH v8 0/3] add support for Allwinner SoCs ADC
Message-ID<sMqBb-24F-5@gated-at.bofh.it>
The Allwinner SoCs all have an ADC that can also act as a touchscreen
controller and a thermal sensor. The first four channels can be used
either for the ADC or the touchscreen and the fifth channel is used for
the thermal sensor. We currently have a driver for the two latter
functions in drivers/input/touchscreen/sun4i-ts.c but we don't have
access to the ADC feature at all. It is meant to replace the current
driver by using MFD and subdrivers.

This adds initial support for Allwinner SoCs ADC with all features. Yet,
the touchscreen is not implemented but will be added later. To switch
between touchscreen and ADC modes, you need to poke a few bits in
registers and (de)activate an interrupt (pen-up).

When changing modes or channels, the IP is in inconsistent mode and has
no register or interrupt to notify the kernel when it's stable and ready
to return correct values. Therefore, we add a delay of 100ms when
changing modes and 10ms when changing channels. These values have been
found empirically.

An MFD is provided to let the input driver activate the pen-up interrupt
through a virtual interrupt, poke a few bits via regmap and read data
from the ADC driver while both (and iio_hwmon) are probed by the MFD.

The thermal sensor requires the IP to be in touchscreen mode to return
correct values. Therefore, if the user is continuously reading the ADC
channel(s), the thermal framework in which the thermal sensor is
registered will switch the IP in touchscreen mode to get a temperature
value and requires a delay of 100ms (because of the mode switching),
then the ADC will switch back to ADC mode and requires also a delay of
100ms. If the ADC readings are critical to user and the SoC temperature
is not, this driver is capable of not registering the thermal sensor in
the thermal framework and thus, "quicken" the ADC readings. In most use
cases, the SoC temperature is more critical (for cpu throttling for
example or activating cooling devices) than ADC readings, thus it is
enabled by default in multi_v7_defconfig and in sunxi_defconfig (default
being added in this patch series).

There are slight variations between the different SoCs ADC like the
address of some registers and the scale and offset to apply to raw
thermal sensor values. These variations are handled by using different
platform_device_id, passed to the sub-drivers when they are probed by
the MFD.



Removal of proposed patch for iio_hwmon's iio channel's label in v3. The
patch induces irreversible ABI changes and will be handled as a separate
patch since I think it is not absolutely necessary to have labels yet in
iio_hwmon.

Removal of proposed patch for reattaching of_node of the MFD to the MFD
cell device structure in v3. As Lee Jones said, this patch might cause
"unintended side-effects for existing drivers.". Moreover, this patch
introduced a bug of multiple probe of this MFD driver I haven't
identified yet. This patch aimed at allowing the ADC driver (which is a
child of the MFD and not present in the DT) to register in the thermal
framework. The thermal driver has a phandle to the MFD node which is
used to match against the MFD of_node but since the ADC driver has no
node in the DT, could not register in the thermal framework. The other
solution is to "impersonate" the MFD when registering in the thermal
framework since the device is only used to match the phandle and the
of_node, an other structure passed by parameter being used to compute
temperatures.

(in the ADC driver, probed by the MFD driver) instead of:
tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, info,
					   &sun4i_ts_tz_ops);
we now have:
tzd = devm_thermal_zone_of_sensor_register(pdev->dev.parent, 0, info,
					   &sun4i_ts_tz_ops);

Removal of proposed patch to use late_initcall for iio_hwmon probe
deferring.

Removal of patch for iio_hwmon probe deferring due to being applied to
 -next by Guenter Roeck.

This patch series requires this[1] patch which has already been merged
by Lee Jones.

[1] https://patchwork.kernel.org/patch/9333547/

Quentin Schulz (3):
  ARM: sunxi_defconfig: Add CONFIG_THERMAL_OF
  mfd: Kconfig: MFD_SUN4I_GPADC depends on !TOUCHSCREN_SUN4I_GPADC
  iio: adc: add support for Allwinner SoCs ADC

 arch/arm/configs/sunxi_defconfig  |   1 +
 drivers/iio/adc/Kconfig           |  16 +
 drivers/iio/adc/Makefile          |   1 +
 drivers/iio/adc/sun4i-gpadc-iio.c | 612 ++++++++++++++++++++++++++++++++++++++
 drivers/mfd/Kconfig               |   1 +
 include/linux/mfd/sun4i-gpadc.h   |   2 +
 6 files changed, 633 insertions(+)
 create mode 100644 drivers/iio/adc/sun4i-gpadc-iio.c

-- 
2.9.3

[toc] | [next] | [standalone]


#1539246 — [PATCH v8 2/3] mfd: Kconfig: MFD_SUN4I_GPADC depends on !TOUCHSCREN_SUN4I_GPADC

FromQuentin Schulz <quentin.schulz@free-electrons.com>
Date2016-12-09 11:30 +0100
Subject[PATCH v8 2/3] mfd: Kconfig: MFD_SUN4I_GPADC depends on !TOUCHSCREN_SUN4I_GPADC
Message-ID<sMqBc-24F-35@gated-at.bofh.it>
In reply to#1539245
MFD_SUN4I_GPADC and TOUCHSCREEN_SUN4I are incompatible (both are drivers
for Allwinner SoCs' ADC). This makes sure TOUCHSCREEN_SUN4I isn't
enabled while MFD_SUN4I_GPADC is enabled.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---

added in v8. I wrongly put the XOR dependance for SUN4I_GPADC and
TOUCHSCREEN_SUN4I instead of for MFD_SUN4I_GPADC and TOUCHSCREEN_SUN4I.

 drivers/mfd/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 443ee50..e803884 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -45,6 +45,7 @@ config MFD_SUN4I_GPADC
 	select MFD_CORE
 	select REGMAP_MMIO
 	depends on ARCH_SUNXI || COMPILE_TEST
+	depends on !TOUCHSCREEN_SUN4I
 	help
 	  Select this to get support for Allwinner SoCs (A10, A13 and A31) ADC.
 	  This driver will only map the hardware interrupt and registers, you
-- 
2.9.3

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web