mxs-lradc: Split driver into MFD
Subsystems (6)
v13 cover mxs-lradc: Split driver into MFD
Split existing driver mxs-lradc into MFD with touchscreen and IIO part.
Tested on I.MX28
Ksenija Stanojevic (5):
mfd: mxs-lradc: Add support for mxs-lradc MFD
iio: adc: mxs-lradc: Add support for adc driver
input: touchscreen: mxs-lradc: Add support for touchscreen
iio: adc: mxs-lradc: Remove driver
mfd: Move binding document
.../bindings/{iio/adc => mfd}/mxs-lradc.txt | 0
drivers/iio/adc/Kconfig | 27 +-
drivers/iio/adc/Makefile | 2 +-
drivers/iio/adc/mxs-lradc-adc.c | 843 ++++++++++
drivers/iio/adc/mxs-lradc.c | 1750 --------------------
drivers/input/touchscreen/Kconfig | 10 +
drivers/input/touchscreen/Makefile | 1 +
drivers/input/touchscreen/mxs-lradc-ts.c | 718 ++++++++
drivers/mfd/Kconfig | 17 +
drivers/mfd/Makefile | 1 +
drivers/mfd/mxs-lradc.c | 264 +++
include/linux/mfd/mxs-lradc.h | 187 +++
12 files changed, 2055 insertions(+), 1765 deletions(-)
rename Documentation/devicetree/bindings/{iio/adc => mfd}/mxs-lradc.txt (100%)
create mode 100644 drivers/iio/adc/mxs-lradc-adc.c
delete mode 100644 drivers/iio/adc/mxs-lradc.c
create mode 100644 drivers/input/touchscreen/mxs-lradc-ts.c
create mode 100644 drivers/mfd/mxs-lradc.c
create mode 100644 include/linux/mfd/mxs-lradc.hSignature · 1 line
1.9.1
PATCH v13 1/5 mfd: mxs-lradc: Add support for mxs-lradc MFD
Add core files for low resolution analog-to-digital converter (mxs-lradc) MFD driver.
---
Changes in v13:
- none
Changes in v12:
- use BIT macro
Changes in v11:
- create static struct mfd_cells
- don't set platform data in mfd cells, set driver data instead
- remove mxs_lradc_reg_* functions, use writel function instead
Changes in v10:
- fetch base address from DT
- add a NULL check for of_match_device
Changes in v9:
- improve commit message.
Changes in v8:
- rebase onto 4.9-rc1
Changes in v7:
- define macros ADC_CELL and TSC_CELL
- remove one cell and dynamically set them in the switch()
- fail in the touchscreen driver instead of mfd driver if hardware doesn't contain a touchscreen
Changes in v6:
- update copyright
- add kernel-doc header for struct mxs-lradc
- add error message
- change EINVAL to ENODEV
- use PLATFORM_DEVID_NONE instead -1
- cosmetic fixes
Changes in v5:
- use DEFINE_RES_MEM
- don't pass ioreammaped adress to platform cells
- move comment outside of struct mxs_lradc
- change type of argument in mxs_lradc_reg_set, mxs_lradc_reg_clear, mxs_lradc_reg_wrt (struct mxs_lradc * -> void __iomem *)
Changes in v4:
- update copyright
- use DEFINE_RES_IRQ_NAMED
- remove mxs_lradc_add_device function
- use struct mfd_cell in static form
- improve spacing
- remove unnecessary comment
- remove platform_get_irq
- remove touch_ret and use ret instead
- rename use_touchscreen to touchscreen_wire
- use goto statements
- remove irq[13], irq_count and irq_name from struct mxs_lradc
- remove all defines from inside the struct definition
Changes in v3:
- add note to commit message
- move switch statement into if(touch_ret == 0) branch
- add MODULE_AUTHOR
Changes in v2:
- do not change spacing in Kconfig
- make struct mfd_cell part of struct mxs_lradc
- use switch instead of if in mxs_lradc_irq_mask
- use only necessary header files in mxs_lradc.h
- use devm_mfd_add_device
- use separate function to register mfd device
- change licence to GPL
- add copyright
drivers/mfd/Kconfig | 17 +++ drivers/mfd/Makefile | 1 + drivers/mfd/mxs-lradc.c | 264 ++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/mxs-lradc.h | 187 ++++++++++++++++++++++++++++++ 4 files changed, 469 insertions(+) create mode 100644 drivers/mfd/mxs-lradc.c create mode 100644 include/linux/mfd/mxs-lradc.h
drivers/mfd/Kconfig +17 -0
@@ -343,6 +343,23 @@ config MFD_MC13XXX_I2C help Select this if your MC13xxx is connected via an I2C bus. +config MFD_MXS_LRADC + tristate "Freescale i.MX23/i.MX28 LRADC" + depends on ARCH_MXS || COMPILE_TEST + select MFD_CORE + select STMP_DEVICE + help + Say yes here to build support for the Low Resolution + Analog-to-Digital Converter (LRADC) found on the i.MX23 and i.MX28 + processors. This driver provides common support for accessing the + device, additional drivers must be enabled in order to use the + functionality of the device: + mxs-lradc-adc for ADC readings + mxs-lradc-ts for touchscreen support + + This driver can also be built as a module. If so, the module will be + called mxs-lradc. + config MFD_MX25_TSADC tristate "Freescale i.MX25 integrated Touchscreen and ADC unit" select REGMAP_MMIO
drivers/mfd/Makefile +1 -0
@@ -212,3 +212,4 @@ obj-$(CONFIG_MFD_MT6397) += mt6397-core.o obj-$(CONFIG_MFD_ALTERA_A10SR) += altera-a10sr.o obj-$(CONFIG_MFD_SUN4I_GPADC) += sun4i-gpadc.o +obj-$(CONFIG_MFD_MXS_LRADC) += mxs-lradc.o
drivers/mfd/mxs-lradc.c new file +264 -0
264 lines not on this page · raw message
include/linux/mfd/mxs-lradc.h new file +187 -0
187 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH v13 1/5] mfd: mxs-lradc: Add support for mxs-lradc MFD
Hi Ksenija,
Quoted 8 lines
Ksenija Stanojevic <[email protected]> hat am 29. Januar 2017 um 19:04 geschrieben:
Add core files for low resolution analog-to-digital converter (mxs-lradc) MFD driver.
Signed-off-by Ksenija Stanojevic <[email protected]>Acked-by Lee Jones <[email protected]>
unfortunately this patch (only MAKEFILE part) doesn't cleanly applies to for-mfd-next.
Stefan
PATCH v13 2/5 iio: adc: mxs-lradc: Add support for adc driver
In reply to Ksenija StanojevicAdd support for sixteen-channel 12-bit resolution ADC and its functions, which include general-purpose ADC readings, battery voltage measurement, and die temperature measurement.
---
Changes in v13:
- none
Changes in v12:
- none
Changes in v11:
- use dev_get_drvdata instead dev_get_platdata
- use writel instead mxs_lradc_reg_* functions
Changes in v10:
- none
Changes in v9:
- none
Changes in v8:
- rebase onto 4.9-rc1
Changes in v7:
- none
Changes in v6:
- update copyright
Changes in v5:
- add field void __iomem *base to struct mxs_lradc_adc
- change arguments in all functions for accessing I/O memory to follow the previous change.
- use devm_ioremap for mapping I/O memory
Changes in v4:
- update copyright
- use platform_get_irq_byname
- use irq_of_parse_and_map
Changes in v3:
- make buffer large enough for timestamps
- remove unnecessary blank lines
Changes in v2:
- improve commit message
- do not change spacing in Kconfig
- impove formating
- remove wrapper show_scale_avail
- use correct syntax for comments
- use devm_iio_trigger_alloc
- do not allocate buffer dynamically
- use iio_device_claim_*_mode helpers
- add spinlock in struct mxs_lradc_ts to enable locking in interrupt handler
- only grab irqs that are relevant to adc
- remove blank line at the end of the file
- change licence to GPL
- add copyright
drivers/iio/adc/Kconfig | 13 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/mxs-lradc-adc.c | 843 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 857 insertions(+) create mode 100644 drivers/iio/adc/mxs-lradc-adc.c
drivers/iio/adc/Kconfig +13 -0
@@ -229,6 +229,19 @@ config EXYNOS_ADC To compile this driver as a module, choose M here: the module will be called exynos_adc. +config MXS_LRADC_ADC + tristate "Freescale i.MX23/i.MX28 LRADC ADC" + depends on MFD_MXS_LRADC + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + help + Say yes here to build support for the ADC functions of the + i.MX23/i.MX28 LRADC. This includes general-purpose ADC readings, + battery voltage measurement, and die temperature measurement. + + This driver can also be built as a module. If so, the module will be + called mxs-lradc-adc. + config FSL_MX25_ADC tristate "Freescale MX25 ADC driver" depends on MFD_MX25_TSADC
drivers/iio/adc/Makefile +1 -0
@@ -38,6 +38,7 @@ obj-$(CONFIG_MCP320X) += mcp320x.o obj-$(CONFIG_MCP3422) += mcp3422.o obj-$(CONFIG_MEDIATEK_MT6577_AUXADC) += mt6577_auxadc.o obj-$(CONFIG_MEN_Z188_ADC) += men_z188_adc.o +obj-$(CONFIG_MXS_LRADC_ADC) += mxs-lradc-adc.o obj-$(CONFIG_MXS_LRADC) += mxs-lradc.o obj-$(CONFIG_NAU7802) += nau7802.o obj-$(CONFIG_PALMAS_GPADC) += palmas_gpadc.o
drivers/iio/adc/mxs-lradc-adc.c new file +843 -0
843 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH v13 2/5] iio: adc: mxs-lradc: Add support for adc driver
Hi Ksenija,
Quoted 18 lines
Ksenija Stanojevic <[email protected]> hat am 29. Januar 2017 um 19:04 geschrieben:
Add support for sixteen-channel 12-bit resolution ADC and its functions, which include general-purpose ADC readings, battery voltage measurement, and die temperature measurement.
Signed-off-by Ksenija Stanojevic <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>Reviewed-by Marek Vasut <[email protected]>---
...drivers/iio/adc/mxs-lradc-adc.c new file +0
-0
drivers/iio/adc/mxs-lradc-adc.c line 346
Quoted 6 lines
drivers/iio/adc/mxs-lradc-adc.c new file +5
-0@@ -0,0 +1,843 @@ + +#define SHOW_SCALE_AVAILABLE_ATTR (ch) \ +static IIO_DEVICE_ATTR(in_voltage##ch##_scale_available, S_IRUGO, \ + mxs_lradc_adc_show_scale_avail, NULL, ch) +
checkpatch complains here:
ERROR: Macros with complex values should be enclosed in parentheses #498: FILE: drivers/iio/adc/mxs-lradc-adc.c:343:
+#define SHOW_SCALE_AVAILABLE_ATTR(ch) \
+static IIO_DEVICE_ATTR(in_voltage##ch##_scale_available, S_IRUGO, \
+ mxs_lradc_adc_show_scale_avail, NULL, ch)
WARNING: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'. #499: FILE: drivers/iio/adc/mxs-lradc-adc.c:344:
+static IIO_DEVICE_ATTR(in_voltage##ch##_scale_available, S_IRUGO, \
total: 1 errors, 2 warnings, 869 lines checked
But the iio values on Olinuxino Maxi looks good.
PATCH v13 3/5 input: touchscreen: mxs-lradc: Add support for touchscreen
In reply to Ksenija StanojevicAdd 4-wire/5-wire touchscreen controller.
---
Changes in v13:
- use struct state_info instead of using functions for doing conditionals on every operation.
- call mxs_lradc_ts_stop() before requesting interrupts.
Changes in v12:
- none
Changes in v11:
- use dev_get_drvdata instead dev_get_platdata
- use writel instead mxs_lradc_reg_* functions
Changes in v10:
- none
Changes in v9:
- none
Changes in v8:
- rebase onto 4.9-rc1
Changes in v7:
- remove touch_ret variable in probe and use ret instead
- make error check on of_property_read_u32 in probe
Changes in v6:
- update copyright
Changes in v5:
- add field void __iomem *base to struct mxs_lradc_adc
- change arguments in all functions for accessing I/O memory to follow the previous change.
- use devm_ioremap for mapping I/O memory
Changes in v4:
- update copyright
- use platform_get_irq_byname
- use irq_of_parse_and_map
Changes in v3:
- make buffer large enough for timestamps
- remove unnecessary blank lines
Changes in v2:
- improve commit message
- do not change spacing in Kconfig
- impove formating
- remove wrapper show_scale_avail
- use correct syntax for comments
- use devm_iio_trigger_alloc
- do not allocate buffer dynamically
- use iio_device_claim_*_mode helpers
- add spinlock in struct mxs_lradc_ts to enable locking in interrupt handler
- only grab irqs that are relevant to adc
- remove blank line at the end of the file
- change licence to GPL
- add copyright
drivers/input/touchscreen/Kconfig | 10 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/mxs-lradc-ts.c | 718 +++++++++++++++++++++++++++++++ 3 files changed, 729 insertions(+) create mode 100644 drivers/input/touchscreen/mxs-lradc-ts.c
drivers/input/touchscreen/Kconfig +10 -0
@@ -841,6 +841,16 @@ config TOUCHSCREEN_USB_COMPOSITE To compile this driver as a module, choose M here: the module will be called usbtouchscreen. +config TOUCHSCREEN_MXS_LRADC + tristate "Freescale i.MX23/i.MX28 LRADC touchscreen" + depends on MFD_MXS_LRADC + help + Say Y here if you have a touchscreen connected to the low-resolution + analog-to-digital converter (LRADC) on an i.MX23 or i.MX28 processor. + + To compile this driver as a module, choose M here: the module will be + called mxs-lradc-ts. + config TOUCHSCREEN_MX25 tristate "Freescale i.MX25 touchscreen input driver" depends on MFD_MX25_TSADC
drivers/input/touchscreen/Makefile +1 -0
@@ -46,6 +46,7 @@ obj-$(CONFIG_TOUCHSCREEN_INTEL_MID) += intel-mid-touch.o obj-$(CONFIG_TOUCHSCREEN_IPROC) += bcm_iproc_tsc.o obj-$(CONFIG_TOUCHSCREEN_LPC32XX) += lpc32xx_ts.o obj-$(CONFIG_TOUCHSCREEN_MAX11801) += max11801_ts.o +obj-$(CONFIG_TOUCHSCREEN_MXS_LRADC) += mxs-lradc-ts.o obj-$(CONFIG_TOUCHSCREEN_MX25) += fsl-imx25-tcq.o obj-$(CONFIG_TOUCHSCREEN_MC13783) += mc13783_ts.o obj-$(CONFIG_TOUCHSCREEN_MCS5000) += mcs5000_ts.o
drivers/input/touchscreen/mxs-lradc-ts.c new file +718 -0
718 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH v13 3/5] input: touchscreen: mxs-lradc: Add support for touchscreen
Hi Ksenija,
Quoted 4 lines
Ksenija Stanojevic <[email protected]> hat am 29. Januar 2017 um 19:04 geschrieben:
Add 4-wire/5-wire touchscreen controller.
i compiled all 3 driver as a module and kept the devicetree for the Olinuxino iMX233 [1] as it is (no touchscreen). After booting all 3 driver are loaded:
Module Size Used bymxs_lradc_adc 11000 0industrialio_triggered_buffer 2628 1 mxs_lradc_adc
kfifo_buf 3337 1 industrialio_triggered_buffer mxs_lradc_ts 4192 0 mxs_lradc 4402 0 mfd_core 4612 1 mxs_lradc
But the touchscreen driver threw this error:
[ 427.230000] mxs-lradc-ts: probe of mxs-lradc-ts failed with error -22
I didn't expect this behavior. I expect that the touchscreen driver notice that there isn't a touchscreen property and abort probing silently. Also i didn't expected that the driver is still loaded in case of a probe error.
Btw shouldn't be the mxs_lradc_adc "Used by" mxs_lradc?
Because "modprobe -r mxs_lradc" doesn't unload mxs_lradc_adc.
[1] - http://lxr.free-electrons.com/source/arch/arm/boot/dts/imx23-olinuxino.dts
Re: [PATCH v13 3/5] input: touchscreen: mxs-lradc: Add support for touchscreen
Hi,
Quoted 3 lines · Stefan Wahren
Hi Ksenija,
Quoted 1 line
Ksenija Stanojevic <[email protected]> hat am 29. Januar 2017
um 19:04 geschrieben:
Quoted 5 lines
Quoted 3 lines
Add 4-wire/5-wire touchscreen controller.
i compiled all 3 driver as a module and kept the devicetree for the
Olinuxino iMX233 [1] as it is (no touchscreen). After booting all 3 driver are loaded:
Quoted 4 lines
where
Module Size Used bymxs_lradc_adc11000 0industrialio_triggered_buffer2628 1mxs_lradc_adc
Quoted 8 lines
kfifo_buf 3337 1 industrialio_triggered_buffer mxs_lradc_ts 4192 0 mxs_lradc 4402 0 mfd_core 4612 1 mxs_lradcBut the touchscreen driver threw this error:
[ 427.230000] mxs-lradc-ts: probe of mxs-lradc-ts failed with error -22
I think it should be like that. In earlier versions module wouldn't load if there was no touchscreen device (it was done in the mfd part). But Lee suggested that it there is no device it should fail in the touchscreen driver.
Quoted 1 line
I didn't expect this behavior. I expect that the touchscreen driver
notice that there isn't a touchscreen property and abort probing silently. Also i didn't expected that the driver is still loaded in case of a probe error.
Well module can be loaded if probe fails see __driver_attach [1] . But in order that driver won't load in case of probe error I think init function should be changed somehow, unregistered driver in case of error but I'm not sure how...
Quoted 3 lines
Btw shouldn't be the
mxs_lradc_adc"Used by"mxs_lradc?Because "modprobe -r
mxs_lradc" doesn't unloadmxs_lradc_adc.
both adc and touchscreen driver can't load if mfd part is not loaded but in order to be listed in Used by column and unload if mfd part is unloaded I think that they need to use symbols from the mfd part.
[1] http://lxr.free-electrons.com/source/drivers/base/dd.c#L731
PATCH v13 4/5 iio: adc: mxs-lradc: Remove driver
In reply to Ksenija StanojevicSince the driver has been split into mfd there is no reason for it to stay, so remove it.
---
Changes in v13:
- none
Changes in v12:
- none
Changes in v11:
- none
Changes in v10:
- none
Changes in v9:
- none
Changes in v8:
- rebase onto 4.9-rc1
Changes in v7:
- none
Changes in v6:
- none
Changes in v5:
- none
Changes in v4:
- none
Changes in v3:
- none
Changes in v2:
- add to the patchset
drivers/iio/adc/Kconfig | 14 - drivers/iio/adc/Makefile | 1 - drivers/iio/adc/mxs-lradc.c | 1750 ------------------------------------------- 3 files changed, 1765 deletions(-) delete mode 100644 drivers/iio/adc/mxs-lradc.c
drivers/iio/adc/Kconfig +0 -14
@@ -412,20 +412,6 @@ config MEN_Z188_ADC This driver can also be built as a module. If so, the module will be called men_z188_adc. -config MXS_LRADC - tristate "Freescale i.MX23/i.MX28 LRADC" - depends on (ARCH_MXS || COMPILE_TEST) && HAS_IOMEM - depends on INPUT - select STMP_DEVICE - select IIO_BUFFER - select IIO_TRIGGERED_BUFFER - help - Say yes here to build support for i.MX23/i.MX28 LRADC convertor - built into these chips. - - To compile this driver as a module, choose M here: the - module will be called mxs-lradc. - config NAU7802 tristate "Nuvoton NAU7802 ADC driver" depends on I2C
drivers/iio/adc/Makefile +0 -1
@@ -39,7 +39,6 @@ obj-$(CONFIG_MCP3422) += mcp3422.o obj-$(CONFIG_MEDIATEK_MT6577_AUXADC) += mt6577_auxadc.o obj-$(CONFIG_MEN_Z188_ADC) += men_z188_adc.o obj-$(CONFIG_MXS_LRADC_ADC) += mxs-lradc-adc.o -obj-$(CONFIG_MXS_LRADC) += mxs-lradc.o obj-$(CONFIG_NAU7802) += nau7802.o obj-$(CONFIG_PALMAS_GPADC) += palmas_gpadc.o obj-$(CONFIG_QCOM_SPMI_IADC) += qcom-spmi-iadc.o
drivers/iio/adc/mxs-lradc.c deleted +0 -1750
1,750 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v13 5/5 mfd: Move binding document
In reply to Ksenija StanojevicThe bindings, which are now used in MFD, need also to be documented in the MFD binding document.
---
Changes in v13:
- none
Changes in v12:
- none
Changes in v11:
- none
Changes in v10:
- none
Changes in v9:
- format patch using -M option
Changes in v8:
- rebase onto 4.9-rc1
Changes in v7:
- add to the patchset
Documentation/devicetree/bindings/{iio/adc => mfd}/mxs-lradc.txt | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename Documentation/devicetree/bindings/{iio/adc => mfd}/mxs-lradc.txt (100%)Documentation/devicetree/bindings/mfd/mxs-lradc.txt renamed from Documentation/devicetree/bindings/iio/adc/mxs-lradc.txt +0 -0
Signature · 1 line
1.9.1