Skip to contentSkip to conversation

mxs-lradc: Split driver into MFD

PATCH Superseded Ksenija Stanojevic 5 participants 16 messages Nov 2, 2016 – Nov 15, 2016

Subsystems (6)

v9 of 15 Superseded Latest is v15 →

lore
Share & tools
lore
#0 lore raw

v9 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                    |  845 ++++++++++
 drivers/iio/adc/mxs-lradc.c                        | 1750 --------------------
 drivers/input/touchscreen/Kconfig                  |   10 +
 drivers/input/touchscreen/Makefile                 |    1 +
 drivers/input/touchscreen/mxs-lradc-ts.c           |  743 +++++++++
 drivers/mfd/Kconfig                                |   17 +
 drivers/mfd/Makefile                               |    1 +
 drivers/mfd/mxs-lradc.c                            |  249 +++
 include/linux/mfd/mxs-lradc.h                      |  203 +++
 12 files changed, 2083 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 v9 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 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       | 249 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/mxs-lradc.h | 203 ++++++++++++++++++++++++++++++++++
 4 files changed, 470 insertions(+)
 create mode 100644 drivers/mfd/mxs-lradc.c
 create mode 100644 include/linux/mfd/mxs-lradc.h
drivers/mfd/Kconfig +17 -0
index c6df644..bdd88cf 100644
@@ -326,6 +326,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 9834e66..057ca15 100644
@@ -211,3 +211,4 @@ obj-$(CONFIG_INTEL_SOC_PMIC)	+= intel-soc-pmic.o
 obj-$(CONFIG_MFD_MT6397)	+= mt6397-core.o
 
 obj-$(CONFIG_MFD_ALTERA_A10SR)	+= altera-a10sr.o
+obj-$(CONFIG_MFD_MXS_LRADC)     += mxs-lradc.o
drivers/mfd/mxs-lradc.c new file +249 -0

249 lines not on this page · raw message

include/linux/mfd/mxs-lradc.h new file +203 -0

203 lines not on this page · raw message

Signature · 1 line
1.9.1
Tested-by on v9 1/5
#2 lore raw

Re: [PATCH v9 1/5] mfd: mxs-lradc: Add support for mxs-lradc MFD

Quoted 8 lines

Ksenija Stanojevic <[email protected]> hat am 2. November 2016 um 08:38 geschrieben:

Add core files for low resolution analog-to-digital converter (mxs-lradc) MFD driver.

for Patch 1 + 2

drivers/mfd/Makefile obj-$(CONFIG_INTEL_SOC_PMIC) += intel-soc-pmic.o · line 214

Quoted 11 lines

---
...

drivers/mfd/Makefile +1 -0
index 9834e66..057ca15 100644
@@ -211,3 +211,4 @@ obj-$(CONFIG_INTEL_SOC_PMIC)	+= intel-soc-pmic.o
 obj-$(CONFIG_MFD_MT6397)	+= mt6397-core.o
 
 obj-$(CONFIG_MFD_ALTERA_A10SR)	+= altera-a10sr.o
+obj-$(CONFIG_MFD_MXS_LRADC)     += mxs-lradc.o

Btw this part won't apply anymore

#3 lore raw

Re: [PATCH v9 1/5] mfd: mxs-lradc: Add support for mxs-lradc MFD

Hi,

Quoted 23 lines · Stefan Wahren
Quoted 9 lines

Ksenija Stanojevic <[email protected]> hat am 2. November 2016 um 08:38 geschrieben:

Add core files for low resolution analog-to-digital converter (mxs-lradc) MFD driver.

for Patch 1 + 2

Quoted 9 lines

---
...

drivers/mfd/Makefile +0 -0
index 9834e66..057ca15 100644
@@ -211,3 +211,4 @@ obj-$(CONFIG_INTEL_SOC_PMIC)      += intel-soc-pmic.o
 obj-$(CONFIG_MFD_MT6397)     += mt6397-core.o
 
Quoted 4 lines

drivers/mfd/Makefile obj-$(CONFIG_INTEL_SOC_PMIC) += intel-soc-pmic.o · line 214

Quoted 2 lines
drivers/mfd/Makefile +1 -0
 obj-$(CONFIG_MFD_ALTERA_A10SR)       += altera-a10sr.o
+obj-$(CONFIG_MFD_MXS_LRADC)     += mxs-lradc.o

Btw this part won't apply anymore

I think now everyone is approving of this patch series. Who will take this patch series, Jonathan or Lee? Should I resend patches?

Thanks,
Ksenija

#4 lore raw

Re: [PATCH v9 1/5] mfd: mxs-lradc: Add support for mxs-lradc MFD

Quoted 26 lines · Ksenija Stanojević

Hi,

Quoted 23 lines · Stefan Wahren
Quoted 9 lines

Ksenija Stanojevic <[email protected]> hat am 2. November 2016 um 08:38 geschrieben:

Add core files for low resolution analog-to-digital converter (mxs-lradc) MFD driver.

for Patch 1 + 2

Quoted 9 lines

---
...

drivers/mfd/Makefile +0 -0
index 9834e66..057ca15 100644
@@ -211,3 +211,4 @@ obj-$(CONFIG_INTEL_SOC_PMIC)      += intel-soc-pmic.o
 obj-$(CONFIG_MFD_MT6397)     += mt6397-core.o
 
Quoted 8 lines
Quoted 4 lines

drivers/mfd/Makefile obj-$(CONFIG_INTEL_SOC_PMIC) += intel-soc-pmic.o · line 214

Quoted 2 lines
drivers/mfd/Makefile +1 -0
 obj-$(CONFIG_MFD_ALTERA_A10SR)       += altera-a10sr.o
+obj-$(CONFIG_MFD_MXS_LRADC)     += mxs-lradc.o

Btw this part won't apply anymore

I think now everyone is approving of this patch series. Who will take this patch series, Jonathan or Lee? Should I resend patches?

Send patch-set again with all the Acks you've collected.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#5 lore raw

Re: [PATCH v9 1/5] mfd: mxs-lradc: Add support for mxs-lradc MFD

In reply to Ksenija Stanojevic
Quoted 134 lines · Ksenija Stanojevic

Add core files for low resolution analog-to-digital converter (mxs-lradc) MFD driver.

---
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       | 249 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/mxs-lradc.h | 203 ++++++++++++++++++++++++++++++++++
 4 files changed, 470 insertions(+)
 create mode 100644 drivers/mfd/mxs-lradc.c
 create mode 100644 include/linux/mfd/mxs-lradc.h
drivers/mfd/Kconfig +17 -0
index c6df644..bdd88cf 100644
@@ -326,6 +326,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 9834e66..057ca15 100644
@@ -211,3 +211,4 @@ obj-$(CONFIG_INTEL_SOC_PMIC)	+= intel-soc-pmic.o
 obj-$(CONFIG_MFD_MT6397)	+= mt6397-core.o
 
 obj-$(CONFIG_MFD_ALTERA_A10SR)	+= altera-a10sr.o
+obj-$(CONFIG_MFD_MXS_LRADC)     += mxs-lradc.o
drivers/mfd/mxs-lradc.c new file +22 -0
new file mode 100644
index 0000000..ffc8f2e
@@ -0,0 +1,249 @@
+/*
+ * Freescale MXS Low Resolution Analog-to-Digital Converter driver
+ *
+ * Copyright (c) 2012 DENX Software Engineering, GmbH.
+ * Copyright (c) 2016 Ksenija Stanojevic <[email protected]>
+ *
+ * Authors:
+ *  Marek Vasut <[email protected]>
+ *  Ksenija Stanojevic <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/clk.h>

drivers/mfd/mxs-lradc.c line 32

Quoted 10 lines
drivers/mfd/mxs-lradc.c new file +10 -0
+#include <linux/device.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/mxs-lradc.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+#define MXS_LRADC_BASE		0x80050000

Just for my understanding, why is this hardware address hard-coded here? Shouldn't that be fetched from DT ?

Quoted 2 lines
drivers/mfd/mxs-lradc.c new file +2 -0
+#define ADC_CELL		0
+#define TSC_CELL		1

[...]

Signature · 2 lines
Best regards,
Marek Vasut
reviewer
#6 lore raw

Re: [PATCH v9 1/5] mfd: mxs-lradc: Add support for mxs-lradc MFD

Quoted 4 lines · Marek Vasut
Quoted 1 line

+#define MXS_LRADC_BASE 0x80050000

Just for my understanding, why is this hardware address hard-coded here? Shouldn't that be fetched from DT ?

Yes, this base address should be retrieved from device tree.

#7 lore raw

Re: [PATCH v9 1/5] mfd: mxs-lradc: Add support for mxs-lradc MFD

In reply to Marek Vasut
Quoted 140 lines · Marek Vasut
Quoted 139 lines · Ksenija Stanojevic

Add core files for low resolution analog-to-digital converter (mxs-lradc) MFD driver.

---
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       | 249 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/mxs-lradc.h | 203 ++++++++++++++++++++++++++++++++++
 4 files changed, 470 insertions(+)
 create mode 100644 drivers/mfd/mxs-lradc.c
 create mode 100644 include/linux/mfd/mxs-lradc.h
drivers/mfd/Kconfig +17 -0
index c6df644..bdd88cf 100644
@@ -326,6 +326,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 9834e66..057ca15 100644
@@ -211,3 +211,4 @@ obj-$(CONFIG_INTEL_SOC_PMIC)      += intel-soc-pmic.o
 obj-$(CONFIG_MFD_MT6397)     += mt6397-core.o
 
 obj-$(CONFIG_MFD_ALTERA_A10SR)       += altera-a10sr.o
+obj-$(CONFIG_MFD_MXS_LRADC)     += mxs-lradc.o
drivers/mfd/mxs-lradc.c new file +27 -0
new file mode 100644
index 0000000..ffc8f2e
@@ -0,0 +1,249 @@
+/*
+ * Freescale MXS Low Resolution Analog-to-Digital Converter driver
+ *
+ * Copyright (c) 2012 DENX Software Engineering, GmbH.
+ * Copyright (c) 2016 Ksenija Stanojevic <[email protected]>
+ *
+ * Authors:
+ *  Marek Vasut <[email protected]>
+ *  Ksenija Stanojevic <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/clk.h>
+#include <linux/device.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/mxs-lradc.h>
+#include <linux/module.h>
+#include <linux/of.h>
Quoted 8 lines

drivers/mfd/mxs-lradc.c line 32

Quoted 5 lines
drivers/mfd/mxs-lradc.c new file +5 -0
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+#define MXS_LRADC_BASE               0x80050000

Just for my understanding, why is this hardware address hard-coded here? Shouldn't that be fetched from DT ?

Do you mean that address should be fetched by using of_address_to_resource() in probe function, or something else?

Thanks,
Ksenija

#8 lore raw

Re: [PATCH v9 1/5] mfd: mxs-lradc: Add support for mxs-lradc MFD

Quoted 150 lines · Ksenija Stanojević
Quoted 140 lines · Marek Vasut
Quoted 139 lines · Ksenija Stanojevic

Add core files for low resolution analog-to-digital converter (mxs-lradc) MFD driver.

---
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       | 249 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/mxs-lradc.h | 203 ++++++++++++++++++++++++++++++++++
 4 files changed, 470 insertions(+)
 create mode 100644 drivers/mfd/mxs-lradc.c
 create mode 100644 include/linux/mfd/mxs-lradc.h
drivers/mfd/Kconfig +17 -0
index c6df644..bdd88cf 100644
@@ -326,6 +326,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 9834e66..057ca15 100644
@@ -211,3 +211,4 @@ obj-$(CONFIG_INTEL_SOC_PMIC)      += intel-soc-pmic.o
 obj-$(CONFIG_MFD_MT6397)     += mt6397-core.o
 
 obj-$(CONFIG_MFD_ALTERA_A10SR)       += altera-a10sr.o
+obj-$(CONFIG_MFD_MXS_LRADC)     += mxs-lradc.o
drivers/mfd/mxs-lradc.c new file +27 -0
new file mode 100644
index 0000000..ffc8f2e
@@ -0,0 +1,249 @@
+/*
+ * Freescale MXS Low Resolution Analog-to-Digital Converter driver
+ *
+ * Copyright (c) 2012 DENX Software Engineering, GmbH.
+ * Copyright (c) 2016 Ksenija Stanojevic <[email protected]>
+ *
+ * Authors:
+ *  Marek Vasut <[email protected]>
+ *  Ksenija Stanojevic <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/clk.h>
+#include <linux/device.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/mxs-lradc.h>
+#include <linux/module.h>
+#include <linux/of.h>
Quoted 8 lines

drivers/mfd/mxs-lradc.c line 32

Quoted 5 lines
drivers/mfd/mxs-lradc.c new file +5 -0
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+#define MXS_LRADC_BASE               0x80050000

Just for my understanding, why is this hardware address hard-coded here? Shouldn't that be fetched from DT ?

Quoted 2 lines

Do you mean that address should be fetched by using of_address_to_resource() in probe function, or something else?

Probably platform_get_resource() .

Signature · 2 lines
Best regards,
Marek Vasut
#9 lore raw

Re: [PATCH v9 1/5] mfd: mxs-lradc: Add support for mxs-lradc MFD

In reply to Ksenija Stanojevic

Hi Ksenija,

Quoted 95 lines

Ksenija Stanojevic <[email protected]> hat am 2. November 2016 um 08:38 geschrieben:

Add core files for low resolution analog-to-digital converter (mxs-lradc) MFD driver.

---
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       | 249
++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/mxs-lradc.h | 203 ++++++++++++++++++++++++++++++++++
 4 files changed, 470 insertions(+)
 create mode 100644 drivers/mfd/mxs-lradc.c
 create mode 100644 include/linux/mfd/mxs-lradc.h

...

drivers/mfd/mxs-lradc.c new file +13 -0
new file mode 100644
index 0000000..ffc8f2e
@@ -0,0 +1,249 @@
...
+
+static const struct of_device_id mxs_lradc_dt_ids[] = {
+	{ .compatible = "fsl,imx23-lradc", .data = (void *)IMX23_LRADC, },
+	{ .compatible = "fsl,imx28-lradc", .data = (void *)IMX28_LRADC, },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, mxs_lradc_dt_ids);
+
+static int mxs_lradc_probe(struct platform_device *pdev)
+{
+	const struct of_device_id *of_id;
+	struct device *dev = &pdev->dev;
+	struct device_node *node = dev->of_node;

drivers/mfd/mxs-lradc.c line 132

Quoted 10 lines
drivers/mfd/mxs-lradc.c new file +10 -0
+	struct mxs_lradc *lradc;
+	struct mfd_cell *cells = mxs_cells;
+	int ret = 0;
+	u32 ts_wires = 0;
+
+	lradc = devm_kzalloc(&pdev->dev, sizeof(*lradc), GFP_KERNEL);
+	if (!lradc)
+		return -ENOMEM;
+
+	of_id = of_match_device(mxs_lradc_dt_ids, &pdev->dev);

since you already plan to make a V10, please add a NULL check here. So we can avoid a possible NULL pointer dereference in the following line.

Thanks
Stefan

Quoted 14 lines
drivers/mfd/mxs-lradc.c new file +14 -0
+	lradc->soc = (enum mxs_lradc_id)of_id->data;
+
+	lradc->clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(lradc->clk)) {
+		dev_err(dev, "Failed to get the delay unit clock\n");
+		return PTR_ERR(lradc->clk);
+	}
+
+	ret = clk_prepare_enable(lradc->clk);
+	if (ret) {
+		dev_err(dev, "Failed to enable the delay unit clock\n");
+		return ret;
+	}
+
#10 lore raw

Re: [PATCH v9 1/5] mfd: mxs-lradc: Add support for mxs-lradc MFD

Quoted 102 lines · Stefan Wahren

Hi Ksenija,

Quoted 100 lines

Ksenija Stanojevic <[email protected]> hat am 2. November 2016 um 08:38 geschrieben:

Add core files for low resolution analog-to-digital converter (mxs-lradc) MFD driver.

---
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       | 249
++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/mxs-lradc.h | 203 ++++++++++++++++++++++++++++++++++
 4 files changed, 470 insertions(+)
 create mode 100644 drivers/mfd/mxs-lradc.c
 create mode 100644 include/linux/mfd/mxs-lradc.h

...

drivers/mfd/mxs-lradc.c new file +18 -0
new file mode 100644
index 0000000..ffc8f2e
@@ -0,0 +1,249 @@
...
+
+static const struct of_device_id mxs_lradc_dt_ids[] = {
+     { .compatible = "fsl,imx23-lradc", .data = (void *)IMX23_LRADC, },
+     { .compatible = "fsl,imx28-lradc", .data = (void *)IMX28_LRADC, },
+     { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, mxs_lradc_dt_ids);
+
+static int mxs_lradc_probe(struct platform_device *pdev)
+{
+     const struct of_device_id *of_id;
+     struct device *dev = &pdev->dev;
+     struct device_node *node = dev->of_node;
+     struct mxs_lradc *lradc;
+     struct mfd_cell *cells = mxs_cells;
+     int ret = 0;
+     u32 ts_wires = 0;
+
Quoted 8 lines

drivers/mfd/mxs-lradc.c line 132

Quoted 5 lines
drivers/mfd/mxs-lradc.c new file +5 -0
+     lradc = devm_kzalloc(&pdev->dev, sizeof(*lradc), GFP_KERNEL);
+     if (!lradc)
+             return -ENOMEM;
+
+     of_id = of_match_device(mxs_lradc_dt_ids, &pdev->dev);

since you already plan to make a V10, please add a NULL check here. So we can avoid a possible NULL pointer dereference in the following line.

Ok. I will.

Thanks,
Ksenija

Quoted 15 lines
Quoted 15 lines
drivers/mfd/mxs-lradc.c new file +14 -0
+     lradc->soc = (enum mxs_lradc_id)of_id->data;
+
+     lradc->clk = devm_clk_get(&pdev->dev, NULL);
+     if (IS_ERR(lradc->clk)) {
+             dev_err(dev, "Failed to get the delay unit clock\n");
+             return PTR_ERR(lradc->clk);
+     }
+
+     ret = clk_prepare_enable(lradc->clk);
+     if (ret) {
+             dev_err(dev, "Failed to enable the delay unit clock\n");
+             return ret;
+     }
+
#11 lore raw

PATCH v9 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 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 | 845 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 859 insertions(+)
 create mode 100644 drivers/iio/adc/mxs-lradc-adc.c
drivers/iio/adc/Kconfig +13 -0
index 7edcf32..6414397 100644
@@ -207,6 +207,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 7a40c04..e62ebeb 100644
@@ -34,6 +34,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 +845 -0

845 lines not on this page · raw message

Signature · 1 line
1.9.1
#12 lore raw

Re: [PATCH v9 2/5] iio: adc: mxs-lradc: Add support for adc driver

Quoted 7 lines · 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.

---

Shouldn't you squash this and 4/5 , in which case this would result in a move ?

Signature · 2 lines
Best regards,
Marek Vasut
#13 lore raw

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

In reply to Ksenija Stanojevic

Add 4-wire/5-wire touchscreen controller.

---
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 | 743 +++++++++++++++++++++++++++++++
 3 files changed, 754 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 +743 -0

743 lines not on this page · raw message

Signature · 1 line
1.9.1
#14 lore raw

PATCH v9 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 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 6414397..02c7592 100644
@@ -362,20 +362,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 e62ebeb..131c466 100644
@@ -35,7 +35,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
#15 lore raw

PATCH v9 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 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