Re: [PATCH v6 1/4] mfd: mxs-lradc: Add support for mxs-lradc MFD

2016-09-29 Thread Lee Jones
On Thu, 29 Sep 2016, Stefan Wahren wrote:

> Hi Lee,
> 
> [add Rob and Mark]
> 
> > Lee Jones  hat am 29. September 2016 um 19:15
> > geschrieben:
> > 
> > 
> > On Thu, 29 Sep 2016, Stefan Wahren wrote:
> > > > Lee Jones  hat am 28. September 2016 um 03:05
> > > > geschrieben:
> > > > 
> > > > 
> > > > On Sat, 17 Sep 2016, Ksenija Stanojevic wrote:
> > > > 
> > > > > +
> > > > > +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 = NULL;
> > > > > + 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);
> > > > > + 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;
> > > > > + }
> > > > > +
> > > > > + ret = of_property_read_u32(node, "fsl,lradc-touchscreen-wires",
> > > > 
> > > > Have you moved the documentation into devicetree/bindings/mfd?
> > > > 
> > > 
> > > i hope it's okay if i answer. The binding has moved to
> > > devicetree/binding/iio/adc/ [1]
> > > 
> > > Should it move completely to mfd or split too?
> > > 
> > > I'm asking myself how we keep DT ABI in the latter case.
> > > 
> > > [1] -
> > > http://lxr.free-electrons.com/source/Documentation/devicetree/bindings/iio/adc/mxs-lradc.txt
> > 
> > I haven't read into the documentation too to deeply, but it stands to
> > reason that the bindings which are now being used in MFD should be
> > documented in the MFD binding document, and the ones which are no longer
> > used in the IIO driver should be removed.
> 
> sure, that isn't a problem.
> 
> The more interesting question would be: do we need a new compatible string for
> the mfd driver?

No, I don't think that is necessary.

> In that case the ADC won't probe for the combination of old devicetree blobs 
> and
> new kernel.


-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


Re: [PATCH v6 1/4] mfd: mxs-lradc: Add support for mxs-lradc MFD

2016-09-29 Thread Stefan Wahren
Hi Lee,

[add Rob and Mark]

> Lee Jones  hat am 29. September 2016 um 19:15
> geschrieben:
> 
> 
> On Thu, 29 Sep 2016, Stefan Wahren wrote:
> > > Lee Jones  hat am 28. September 2016 um 03:05
> > > geschrieben:
> > > 
> > > 
> > > On Sat, 17 Sep 2016, Ksenija Stanojevic wrote:
> > > 
> > > > +
> > > > +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 = NULL;
> > > > +   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);
> > > > +   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;
> > > > +   }
> > > > +
> > > > +   ret = of_property_read_u32(node, "fsl,lradc-touchscreen-wires",
> > > 
> > > Have you moved the documentation into devicetree/bindings/mfd?
> > > 
> > 
> > i hope it's okay if i answer. The binding has moved to
> > devicetree/binding/iio/adc/ [1]
> > 
> > Should it move completely to mfd or split too?
> > 
> > I'm asking myself how we keep DT ABI in the latter case.
> > 
> > [1] -
> > http://lxr.free-electrons.com/source/Documentation/devicetree/bindings/iio/adc/mxs-lradc.txt
> 
> I haven't read into the documentation too to deeply, but it stands to
> reason that the bindings which are now being used in MFD should be
> documented in the MFD binding document, and the ones which are no longer
> used in the IIO driver should be removed.

sure, that isn't a problem.

The more interesting question would be: do we need a new compatible string for
the mfd driver?

In that case the ADC won't probe for the combination of old devicetree blobs and
new kernel.

Regards
Stefan

> 
> -- 
> Lee Jones
> Linaro STMicroelectronics Landing Team Lead
> Linaro.org │ Open source software for ARM SoCs
> Follow Linaro: Facebook | Twitter | Blog


Re: [PATCH v6 1/4] mfd: mxs-lradc: Add support for mxs-lradc MFD

2016-09-29 Thread Lee Jones
On Thu, 29 Sep 2016, Stefan Wahren wrote:
> > Lee Jones  hat am 28. September 2016 um 03:05
> > geschrieben:
> > 
> > 
> > On Sat, 17 Sep 2016, Ksenija Stanojevic wrote:
> > 
> > > +
> > > +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 = NULL;
> > > + 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);
> > > + 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;
> > > + }
> > > +
> > > + ret = of_property_read_u32(node, "fsl,lradc-touchscreen-wires",
> > 
> > Have you moved the documentation into devicetree/bindings/mfd?
> > 
> 
> i hope it's okay if i answer. The binding has moved to
> devicetree/binding/iio/adc/ [1]
> 
> Should it move completely to mfd or split too?
> 
> I'm asking myself how we keep DT ABI in the latter case.
> 
> [1] -
> http://lxr.free-electrons.com/source/Documentation/devicetree/bindings/iio/adc/mxs-lradc.txt

I haven't read into the documentation too to deeply, but it stands to
reason that the bindings which are now being used in MFD should be
documented in the MFD binding document, and the ones which are no longer
used in the IIO driver should be removed.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


Re: [PATCH v6 1/4] mfd: mxs-lradc: Add support for mxs-lradc MFD

2016-09-28 Thread Stefan Wahren
Hi Lee,

> Lee Jones  hat am 28. September 2016 um 03:05
> geschrieben:
> 
> 
> On Sat, 17 Sep 2016, Ksenija Stanojevic wrote:
> 
> > +
> > +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 = NULL;
> > +   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);
> > +   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;
> > +   }
> > +
> > +   ret = of_property_read_u32(node, "fsl,lradc-touchscreen-wires",
> 
> Have you moved the documentation into devicetree/bindings/mfd?
> 

i hope it's okay if i answer. The binding has moved to
devicetree/binding/iio/adc/ [1]

Should it move completely to mfd or split too?

I'm asking myself how we keep DT ABI in the latter case.

[1] -
http://lxr.free-electrons.com/source/Documentation/devicetree/bindings/iio/adc/mxs-lradc.txt

> 
> -- 
> Lee Jones
> Linaro STMicroelectronics Landing Team Lead
> Linaro.org │ Open source software for ARM SoCs
> Follow Linaro: Facebook | Twitter | Blog


Re: [PATCH v6 1/4] mfd: mxs-lradc: Add support for mxs-lradc MFD

2016-09-27 Thread Lee Jones
On Sat, 17 Sep 2016, Ksenija Stanojevic wrote:

> Add core files for mxs-lradc MFD driver.
> 
> Note:  this patch won't compile in iio/testing without this patch:
> a8f447be8056 ("mfd: Add resource managed APIs for mfd_add_devices")
> 
> Signed-off-by: Ksenija Stanojevic 
> ---
> 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   | 259 
> ++
>  include/linux/mfd/mxs-lradc.h | 203 +
>  4 files changed, 480 insertions(+)
>  create mode 100644 drivers/mfd/mxs-lradc.c
>  create mode 100644 include/linux/mfd/mxs-lradc.h
> 
> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index 9ca66de..ffe14ef 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -271,6 +271,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_HI6421_PMIC
>   tristate "HiSilicon Hi6421 PMU/Codec IC"
>   depends on OF
> diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> index 0f230a6..ecf6399 100644
> --- a/drivers/mfd/Makefile
> +++ b/drivers/mfd/Makefile
> @@ -198,3 +198,4 @@ intel-soc-pmic-objs   := 
> intel_soc_pmic_core.o intel_soc_pmic_crc.o
>  intel-soc-pmic-$(CONFIG_INTEL_PMC_IPC)   += intel_soc_pmic_bxtwc.o
>  obj-$(CONFIG_INTEL_SOC_PMIC) += intel-soc-pmic.o
>  obj-$(CONFIG_MFD_MT6397) += mt6397-core.o
> +obj-$(CONFIG_MFD_MXS_LRADC)  += mxs-lradc.o
> diff --git a/drivers/mfd/mxs-lradc.c b/drivers/mfd/mxs-lradc.c
> new file mode 100644
> index 000..05ae894
> --- /dev/null
> +++ b/drivers/mfd/mxs-lradc.c
> @@ -0,0 +1,259 @@
> +/*
> + * Freescale MXS LRADC driver

Please use the full name here.  It's helpful if people are trying to
figure out what LRADC actually means.

> + * Copyright (c) 2012 DENX Software Engineering, GmbH.
> + * Copyright (c) 2016 Ksenija Stanojevic 
> + *
> + * Authors:
> + *  Marek Vasut 
> + *  Ksenija Stanojevic 
> + *
> + * 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 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define MXS_LRADC_BASE   0x8005
> +
> +enum mx23_lradc_irqs {
> + MX23_LRADC_TS_IRQ = 0,
> + MX23_LRADC_CH0_IRQ,
> + MX23_LRADC_CH1_IRQ,
> + 

[PATCH v6 1/4] mfd: mxs-lradc: Add support for mxs-lradc MFD

2016-09-17 Thread Ksenija Stanojevic
Add core files for mxs-lradc MFD driver.

Note:  this patch won't compile in iio/testing without this patch:
a8f447be8056 ("mfd: Add resource managed APIs for mfd_add_devices")

Signed-off-by: Ksenija Stanojevic 
---
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   | 259 ++
 include/linux/mfd/mxs-lradc.h | 203 +
 4 files changed, 480 insertions(+)
 create mode 100644 drivers/mfd/mxs-lradc.c
 create mode 100644 include/linux/mfd/mxs-lradc.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 9ca66de..ffe14ef 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -271,6 +271,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_HI6421_PMIC
tristate "HiSilicon Hi6421 PMU/Codec IC"
depends on OF
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 0f230a6..ecf6399 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -198,3 +198,4 @@ intel-soc-pmic-objs := intel_soc_pmic_core.o 
intel_soc_pmic_crc.o
 intel-soc-pmic-$(CONFIG_INTEL_PMC_IPC) += intel_soc_pmic_bxtwc.o
 obj-$(CONFIG_INTEL_SOC_PMIC)   += intel-soc-pmic.o
 obj-$(CONFIG_MFD_MT6397)   += mt6397-core.o
+obj-$(CONFIG_MFD_MXS_LRADC)+= mxs-lradc.o
diff --git a/drivers/mfd/mxs-lradc.c b/drivers/mfd/mxs-lradc.c
new file mode 100644
index 000..05ae894
--- /dev/null
+++ b/drivers/mfd/mxs-lradc.c
@@ -0,0 +1,259 @@
+/*
+ * Freescale MXS LRADC driver
+ *
+ * Copyright (c) 2012 DENX Software Engineering, GmbH.
+ * Copyright (c) 2016 Ksenija Stanojevic 
+ *
+ * Authors:
+ *  Marek Vasut 
+ *  Ksenija Stanojevic 
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define MXS_LRADC_BASE 0x8005
+
+enum mx23_lradc_irqs {
+   MX23_LRADC_TS_IRQ = 0,
+   MX23_LRADC_CH0_IRQ,
+   MX23_LRADC_CH1_IRQ,
+   MX23_LRADC_CH2_IRQ,
+   MX23_LRADC_CH3_IRQ,
+   MX23_LRADC_CH4_IRQ,
+   MX23_LRADC_CH5_IRQ,
+   MX23_LRADC_CH6_IRQ,
+   MX23_LRADC_CH7_IRQ,
+};
+
+enum mx28_lradc_irqs {
+   MX28_LRADC_TS_IRQ = 0,
+   MX28_LRADC_TRESH0_IRQ,
+   MX28_LRADC_TRESH1_IRQ,
+   MX28_LRADC_CH0_IRQ,
+   MX28_LRADC_CH1_IRQ,
+   MX28_LRADC_CH2_IRQ,
+   MX28_LRADC_CH3_IRQ,
+   M