Skip to contentSkip to conversation

mxs-lradc: Split driver into MFD

PATCH Superseded Ksenija Stanojevic 2 participants 7 messages Dec 9, 2016 – Dec 10, 2016

Subsystems (6)

v12 of 15 Superseded Latest is v15 →

lore
Share & tools
lore
#0 lore raw

v12 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           |  739 +++++++++
 drivers/mfd/Kconfig                                |   17 +
 drivers/mfd/Makefile                               |    1 +
 drivers/mfd/mxs-lradc.c                            |  264 +++
 include/linux/mfd/mxs-lradc.h                      |  187 +++
 12 files changed, 2076 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.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH v12 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 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
index 819dc0a..e5c1289 100644
@@ -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
index db39377..90e9f36 100644
@@ -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
#2 lore raw

PATCH v12 2/5 iio: adc: mxs-lradc: Add support for adc driver

In reply to Ksenija Stanojevic

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.

---
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
index 57ebb99..ad6046a 100644
@@ -219,6 +219,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
index 96894b3..4b2cf9b 100644
@@ -35,6 +35,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
#3 lore raw

PATCH v12 3/5 input: touchscreen: mxs-lradc: Add support for touchscreen

In reply to Ksenija Stanojevic

Add 4-wire/5-wire touchscreen controller.

---
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 | 739 +++++++++++++++++++++++++++++++
 3 files changed, 750 insertions(+)
 create mode 100644 drivers/input/touchscreen/mxs-lradc-ts.c
drivers/input/touchscreen/Kconfig +10 -0
index efca013..8ff915e 100644
@@ -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
index 81b8645..97e1bb7 100644
@@ -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 +739 -0

739 lines not on this page · raw message

Signature · 1 line
1.9.1
#4 lore raw

PATCH v12 4/5 iio: adc: mxs-lradc: Remove driver

In reply to Ksenija Stanojevic

Since the driver has been split into mfd there is no reason for it to stay, so remove it.

---
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
index ad6046a..30cdacf 100644
@@ -374,20 +374,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
index 4b2cf9b..b691f8a 100644
@@ -36,7 +36,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
#5 lore raw

PATCH v12 5/5 mfd: Move binding document

In reply to Ksenija Stanojevic

The bindings, which are now used in MFD, need also to be documented in the MFD binding document.

---
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
similarity index 100%
rename from Documentation/devicetree/bindings/iio/adc/mxs-lradc.txt
rename to Documentation/devicetree/bindings/mfd/mxs-lradc.txt
Signature · 1 line
1.9.1
maintainer
#6 lore raw
In reply to Ksenija Stanojevic
Quoted 4 lines · Ksenija Stanojevic

Split existing driver mxs-lradc into MFD with touchscreen and IIO part.

Tested on I.MX28

Hi All,

At first glance it looks like this is over to Dmitry and Lee. If they are both happy...

Lee, I'm assuming this whole lot will go through MFD. Please work your magic with an immutable branch as I guess my Dmitry and I may well want to pull this in at some point over the coming cycle as well.

If for whatever reason you would prefer I pick it up in the first instance and do a branch for you and Dmitry, give me a shout.

Coming together very nicely and will be good to finally get this sorted!

Thanks,

Jonathan

Quoted 28 lines

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           |  739 +++++++++
 drivers/mfd/Kconfig                                |   17 +
 drivers/mfd/Makefile                               |    1 +
 drivers/mfd/mxs-lradc.c                            |  264 +++
 include/linux/mfd/mxs-lradc.h                      |  187 +++
 12 files changed, 2076 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.h