mxs-lradc: Split driver into MFD
Subsystems (5)
v3 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 (4):
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
drivers/iio/adc/Kconfig | 27 +- drivers/iio/adc/Makefile | 2 +- drivers/iio/adc/mxs-lradc-adc.c | 811 ++++++++++++++ drivers/iio/adc/mxs-lradc.c | 1775 ------------------------------ drivers/input/touchscreen/Kconfig | 10 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/mxs-lradc-ts.c | 729 ++++++++++++ drivers/mfd/Kconfig | 17 + drivers/mfd/Makefile | 1 + drivers/mfd/mxs-lradc.c | 217 ++++ include/linux/mfd/mxs-lradc.h | 204 ++++ 11 files changed, 2004 insertions(+), 1790 deletions(-) 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
PATCH v3 1/4 mfd: mxs-lradc: Add support for mxs-lradc MFD
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")
---
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 | 217 ++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/mxs-lradc.h | 204 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 439 insertions(+) create mode 100644 drivers/mfd/mxs-lradc.c create mode 100644 include/linux/mfd/mxs-lradc.h
drivers/mfd/Kconfig +17 -0
@@ -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
drivers/mfd/Makefile +1 -0
@@ -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
drivers/mfd/mxs-lradc.c new file +217 -0
217 lines not on this page · raw message
include/linux/mfd/mxs-lradc.h new file +204 -0
204 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH v3 1/4] mfd: mxs-lradc: Add support for mxs-lradc MFD
Hi,
Quoted 11 lines
Ksenija Stanojevic <[email protected]> hat am 24. Juni 2016 um 14:09 geschrieben:
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 formfd_add_devices")Signed-off-by Ksenija Stanojevic <[email protected]>Acked-by Jonathan Cameron <[email protected]>
i tested it successfully with a i.MX23 board (without touchscreen).
Re: [PATCH v3 1/4] mfd: mxs-lradc: Add support for mxs-lradc MFD
In reply to Ksenija StanojevicQuoted 37 lines · 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 formfd_add_devices")Signed-off-by Ksenija Stanojevic <[email protected]>Acked-by Jonathan Cameron <[email protected]>---
Changes in v3:
- add note to commit message
- move switch statement intoif(touch_ret == 0)branch
- addMODULE_AUTHORChanges in v2:
- do not change spacing inKconfig
- make structmfd_cellpart of structmxs_lradc
- use switch instead of if inmxs_lradc_irq_mask
- use only necessary header files inmxs_lradc.h
- usedevm_mfd_add_device
- use separate function to register mfd device
- change licence to GPL
- add copyrightdrivers/mfd/Kconfig | 17 ++++ drivers/mfd/Makefile | 1 + drivers/mfd/mxs-lradc.c | 217 ++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/mxs-lradc.h | 204 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 439 insertions(+) create mode 100644 drivers/mfd/mxs-lradc.c create mode 100644 include/linux/mfd/mxs-lradc.hdrivers/mfd/Kconfig +0
-0@@ -271,6 +271,23 @@ config MFD_MC13XXX_I2C help
drivers/mfd/Kconfig config MFD_MC13XXX_I2C · line 281
Quoted 10 lines
drivers/mfd/Kconfig +8
-0Select 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
Low Resolution Analogue-to-Digital Converter
Quoted 27 lines
drivers/mfd/Kconfig +9
-0+ 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 OFdrivers/mfd/Makefile +1
-0@@ -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.odrivers/mfd/mxs-lradc.c new file +0
-0
drivers/mfd/mxs-lradc.c line 4
Quoted 4 lines
drivers/mfd/mxs-lradc.c new file +4
-0@@ -0,0 +1,217 @@ +/* +* Freescale MXS LRADC driver +* +* Copyright (c) 2012 DENX Software Engineering, GmbH.
You need to update the copyright.
Authors:
Quoted 57 lines
drivers/mfd/mxs-lradc.c new file +57
-0+* 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> +#include <linux/of_device.h> +#include <linux/platform_device.h> +#include <linux/slab.h> + +static const char *const mx23_lradc_irq_names[] = { +"mxs-lradc-touchscreen" , +"mxs-lradc-channel0" , +"mxs-lradc-channel1" , +"mxs-lradc-channel2" , +"mxs-lradc-channel3" , +"mxs-lradc-channel4" , +"mxs-lradc-channel5" , +"mxs-lradc-channel6" , +"mxs-lradc-channel7" , +}; + +static const char *const mx28_lradc_irq_names[] = { +"mxs-lradc-touchscreen" , +"mxs-lradc-thresh0" , +"mxs-lradc-thresh1" , +"mxs-lradc-channel0" , +"mxs-lradc-channel1" , +"mxs-lradc-channel2" , +"mxs-lradc-channel3" , +"mxs-lradc-channel4" , +"mxs-lradc-channel5" , +"mxs-lradc-channel6" , +"mxs-lradc-channel7" , +"mxs-lradc-button0" , +"mxs-lradc-button1" , +}; + +struct mxs_lradc_of_config { +const int irq_count; +const char *const *irq_name; +}; +
drivers/mfd/mxs-lradc.c line 71
Quoted 10 lines
drivers/mfd/mxs-lradc.c new file +10
-0+static const struct mxs_lradc_of_config mxs_lradc_of_config[] = { + [IMX23_LRADC ] = { + .irq_count =ARRAY_SIZE (mx23_lradc_irq_names), + .irq_name = mx23_lradc_irq_names, + }, + [IMX28_LRADC ] = { + .irq_count =ARRAY_SIZE (mx28_lradc_irq_names), + .irq_name = mx28_lradc_irq_names, + }, +};
Please use DEFINE_RES_IRQ_NAMED() instead.
Quoted 9 lines
drivers/mfd/mxs-lradc.c new file +9
-0+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_add_device (struct platform_device *pdev, +struct mxs_lradc *lradc,char *name,int i)
drivers/mfd/mxs-lradc.c line 91
Quoted 10 lines
drivers/mfd/mxs-lradc.c new file +10
-0+{ +struct mfd_cell *cell; + + cell = &lradc->cells[i]; + cell->name = name; + cell->platform_data = lradc; + cell->pdata_size =sizeof (*lradc); + +return devm_mfd_add_devices (&pdev->dev,-1 , cell,1 ,NULL ,0 ,NULL ); +}
Please don't roll your own API.
Use 'struct mfd_cell' like everyone else does.
drivers/mfd/mxs-lradc.c line 98
Quoted 6 lines
drivers/mfd/mxs-lradc.c new file +6
-0+static int mxs_lradc_probe (struct platform_device *pdev) +{ +const struct of_device_id *of_id = +of_match_device (mxs_lradc_dt_ids, &pdev->dev); +const struct mxs_lradc_of_config *of_cfg = + &mxs_lradc_of_config[(enum mxs_lradc_id )of_id->data];
This implementation is wayyyy more complicated than it needs to be.
You've entangled DT probing with the MFD API.
Please use the MFD API properly.
drivers/mfd/mxs-lradc.c line 109
Quoted 11 lines
drivers/mfd/mxs-lradc.c new file +11
-0+struct device *dev = &pdev->dev; +struct device_node *node = dev->of_node; +struct mxs_lradc *lradc; +struct resource *iores; +int ret =0 , touch_ret, i; +u32 ts_wires =0 ; + + lradc =devm_kzalloc (&pdev->dev,sizeof (*lradc),GFP_KERNEL ); +if (!lradc) +return -ENOMEM ; + lradc->soc = (enum mxs_lradc_id )of_id->data;
If you're going to pull the platform ID out like this, please pull the *_match_* function down, just above this line. And separate them both from allocating memory.
drivers/mfd/mxs-lradc.c line 111
Quoted 1 line
drivers/mfd/mxs-lradc.c new file +1
-0+/* Grab the memory area */
This comment doesn't add anything.
We know what these calls do, and they don't "grab" anything.
drivers/mfd/mxs-lradc.c line 121
Quoted 10 lines
drivers/mfd/mxs-lradc.c new file +10
-0+ iores =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + lradc->base =devm_ioremap_resource (dev, iores); +if (IS_ERR (lradc->base)) +return PTR_ERR (lradc->base); + + 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); + }
'\n' here. Nice spacing makes code easier to follow.
drivers/mfd/mxs-lradc.c line 129
Quoted 8 lines
drivers/mfd/mxs-lradc.c new file +8
-0+ ret =clk_prepare_enable (lradc->clk); +if (ret !=0 ) { +dev_err (dev,"Failed to enable the delay unit clock\n" ); +return ret; + } + + touch_ret =of_property_read_u32 (node,"fsl,lradc-touchscreen-wires" , + &ts_wires);
Why do you need more than one 'ret' variable?
drivers/mfd/mxs-lradc.c line 132
Quoted 2 lines
drivers/mfd/mxs-lradc.c new file +2
-0+if (touch_ret ==0 ) { + lradc->buffer_vchans =BUFFER_VCHANS_LIMITED ;
'\n' here or else we think it's related to the switch().
drivers/mfd/mxs-lradc.c line 135
Quoted 3 lines
drivers/mfd/mxs-lradc.c new file +3
-0+switch (ts_wires) { +case 4 : + lradc->use_touchscreen =MXS_LRADC_TOUCHSCREEN_4WIRE ;
This is not a good name for a variable. It looks like a bool here, but you're initialising with a configuration option.
drivers/mfd/mxs-lradc.c line 143
Quoted 8 lines
drivers/mfd/mxs-lradc.c new file +8
-0+break ; +case 5 : +if (lradc->soc ==IMX28_LRADC ) { + lradc->use_touchscreen = +MXS_LRADC_TOUCHSCREEN_5WIRE ; +break ; + } +/* fall through an error message for i.MX23 */
"to an error"
drivers/mfd/mxs-lradc.c line 148
Quoted 5 lines
drivers/mfd/mxs-lradc.c new file +5
-0+default : +dev_err (&pdev->dev, +"Unsupported number of touchscreen wires (%d)\n" , + ts_wires); +return -EINVAL ;
The clock is still enabled.
Quoted 4 lines
drivers/mfd/mxs-lradc.c new file +4
-0+ } + }else { + lradc->buffer_vchans =BUFFER_VCHANS_ALL ; + }
drivers/mfd/mxs-lradc.c line 162
Quoted 10 lines
drivers/mfd/mxs-lradc.c new file +10
-0+ + lradc->irq_count = of_cfg->irq_count; + lradc->irq_name = of_cfg->irq_name; +for (i =0 ; i < lradc->irq_count; i++) { + lradc->irq[i] =platform_get_irq (pdev, i); +if (lradc->irq[i] <0 ) { + ret = lradc->irq[i]; + goto err_clk; + } + }
You shouldn't be 'get'ing the IRQ here.
Where are you consuming these IRQs?
drivers/mfd/mxs-lradc.c line 168
Quoted 5 lines
drivers/mfd/mxs-lradc.c new file +5
-0+platform_set_drvdata (pdev, lradc); + + ret =stmp_reset_block (lradc->base); +if (ret) +return ret;
The clock is still enabled.
drivers/mfd/mxs-lradc.c line 174
Quoted 5 lines
drivers/mfd/mxs-lradc.c new file +5
-0+ ret =mxs_lradc_add_device (pdev, lradc,DRIVER_NAME_ADC ,0 ); +if (ret) { +dev_err (&pdev->dev,"Failed to add the ADC subdevice\n" ); + goto err_clk; + }
Do this using statically defined mfd_cells.
Quoted 26 lines
drivers/mfd/mxs-lradc.c new file +26
-0+if (!lradc->use_touchscreen) +return 0 ; + + ret =mxs_lradc_add_device (pdev, lradc,DRIVER_NAME_TS ,1 ); +if (ret) { +dev_err (&pdev->dev, +"Failed to add the touchscreen subdevice\n" ); + goto err_clk; + } + +return 0 ; + +err_clk: +clk_disable_unprepare (lradc->clk); + +return ret; +} + +static int mxs_lradc_remove (struct platform_device *pdev) +{ +struct mxs_lradc *lradc =platform_get_drvdata (pdev); + +clk_disable_unprepare (lradc->clk); + +return 0 ; +}
drivers/mfd/mxs-lradc.c line 211
Quoted 10 lines
drivers/mfd/mxs-lradc.c new file +10
-0+ +static struct platform_driver mxs_lradc_driver = { + .driver = { + .name ="mxs-lradc" , + .of_match_table = mxs_lradc_dt_ids, + }, + .probe = mxs_lradc_probe, + .remove = mxs_lradc_remove, +}; +
This line is superfluous.
Quoted 12 lines
drivers/mfd/mxs-lradc.c new file +6
-0+module_platform_driver (mxs_lradc_driver); + +MODULE_AUTHOR ("Ksenija Stanojevic <[email protected]>" ); +MODULE_DESCRIPTION ("Freescale i.MX23/i.MX28 LRADC driver" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform:mxs-lradc" );include/linux/mfd/mxs-lradc.h new file +0
-0
include/linux/mfd/mxs-lradc.h line 4
Quoted 4 lines
include/linux/mfd/mxs-lradc.h new file +4
-0@@ -0,0 +1,204 @@ +/* +* Freescale MXS LRADC driver +* +* Copyright (c) 2012 DENX Software Engineering, GmbH.
You need to update the copyright.
Author:
Quoted 5 lines
include/linux/mfd/mxs-lradc.h new file +5
-0+* Marek Vasut <[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
include/linux/mfd/mxs-lradc.h line 19
Quoted 10 lines
include/linux/mfd/mxs-lradc.h new file +10
-0+* (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. +*/ + +#ifndef __MXS_LRADC_H +#define __MXS_LRADC_H
__MFD_MXS_*
include/linux/mfd/mxs-lradc.h line 26
Quoted 6 lines
include/linux/mfd/mxs-lradc.h new file +6
-0+#include <linux/bitops.h> +#include <linux/io.h> +#include <linux/stmp_device.h> + +#define DRIVER_NAME_ADC "mxs-lradc-adc" +#define DRIVER_NAME_TS "mxs-lradc-ts"
Don't define these. Just use the proper names.
Quoted 104 lines
include/linux/mfd/mxs-lradc.h new file +104
-0+#define LRADC_MAX_DELAY_CHANS 4 +#define LRADC_MAX_MAPPED_CHANS 8 +#define LRADC_MAX_TOTAL_CHANS 16 + +#define LRADC_DELAY_TIMER_HZ 2000 + +#define LRADC_CTRL0 0x00 +# define LRADC_CTRL0_MX28_TOUCH_DETECT_ENABLE BIT(23) +# define LRADC_CTRL0_MX28_TOUCH_SCREEN_TYPE BIT(22) +# define LRADC_CTRL0_MX28_YNNSW /* YM */ BIT(21) +# define LRADC_CTRL0_MX28_YPNSW /* YP */ BIT(20) +# define LRADC_CTRL0_MX28_YPPSW /* YP */ BIT(19) +# define LRADC_CTRL0_MX28_XNNSW /* XM */ BIT(18) +# define LRADC_CTRL0_MX28_XNPSW /* XM */ BIT(17) +# define LRADC_CTRL0_MX28_XPPSW /* XP */ BIT(16) + +# define LRADC_CTRL0_MX23_TOUCH_DETECT_ENABLE BIT(20) +# define LRADC_CTRL0_MX23_YM BIT(19) +# define LRADC_CTRL0_MX23_XM BIT(18) +# define LRADC_CTRL0_MX23_YP BIT(17) +# define LRADC_CTRL0_MX23_XP BIT(16) + +# define LRADC_CTRL0_MX28_PLATE_MASK \ + (LRADC_CTRL0_MX28_TOUCH_DETECT_ENABLE | \ + LRADC_CTRL0_MX28_YNNSW | LRADC_CTRL0_MX28_YPNSW | \ + LRADC_CTRL0_MX28_YPPSW | LRADC_CTRL0_MX28_XNNSW | \ + LRADC_CTRL0_MX28_XNPSW | LRADC_CTRL0_MX28_XPPSW) + +# define LRADC_CTRL0_MX23_PLATE_MASK \ + (LRADC_CTRL0_MX23_TOUCH_DETECT_ENABLE | \ + LRADC_CTRL0_MX23_YM | LRADC_CTRL0_MX23_XM | \ + LRADC_CTRL0_MX23_YP | LRADC_CTRL0_MX23_XP) + +#define LRADC_CTRL1 0x10 +#define LRADC_CTRL1_TOUCH_DETECT_IRQ_EN BIT(24) +#define LRADC_CTRL1_LRADC_IRQ_EN (n) (1 << ((n) + 16)) +#define LRADC_CTRL1_MX28_LRADC_IRQ_EN_MASK (0x1fff << 16) +#define LRADC_CTRL1_MX23_LRADC_IRQ_EN_MASK (0x01ff << 16) +#define LRADC_CTRL1_LRADC_IRQ_EN_OFFSET 16 +#define LRADC_CTRL1_TOUCH_DETECT_IRQ BIT(8) +#define LRADC_CTRL1_LRADC_IRQ (n) (1 << (n)) +#define LRADC_CTRL1_MX28_LRADC_IRQ_MASK 0x1fff +#define LRADC_CTRL1_MX23_LRADC_IRQ_MASK 0x01ff +#define LRADC_CTRL1_LRADC_IRQ_OFFSET 0 + +#define LRADC_CTRL2 0x20 +#define LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET 24 +#define LRADC_CTRL2_TEMPSENSE_PWD BIT(15) + +#define LRADC_STATUS 0x40 +#define LRADC_STATUS_TOUCH_DETECT_RAW BIT(0) + +#define LRADC_CH (n) (0x50 + (0x10 * (n))) +#define LRADC_CH_ACCUMULATE BIT(29) +#define LRADC_CH_NUM_SAMPLES_MASK (0x1f << 24) +#define LRADC_CH_NUM_SAMPLES_OFFSET 24 +#define LRADC_CH_NUM_SAMPLES (x) \ + ((x) << LRADC_CH_NUM_SAMPLES_OFFSET) +#define LRADC_CH_VALUE_MASK 0x3ffff +#define LRADC_CH_VALUE_OFFSET 0 + +#define LRADC_DELAY (n) (0xd0 + (0x10 * (n))) +#define LRADC_DELAY_TRIGGER_LRADCS_MASK (0xffUL << 24) +#define LRADC_DELAY_TRIGGER_LRADCS_OFFSET 24 +#define LRADC_DELAY_TRIGGER (x) \ + (((x) << LRADC_DELAY_TRIGGER_LRADCS_OFFSET) & \ + LRADC_DELAY_TRIGGER_LRADCS_MASK) +#define LRADC_DELAY_KICK BIT(20) +#define LRADC_DELAY_TRIGGER_DELAYS_MASK (0xf << 16) +#define LRADC_DELAY_TRIGGER_DELAYS_OFFSET 16 +#define LRADC_DELAY_TRIGGER_DELAYS (x) \ + (((x) << LRADC_DELAY_TRIGGER_DELAYS_OFFSET) & \ + LRADC_DELAY_TRIGGER_DELAYS_MASK) +#define LRADC_DELAY_LOOP_COUNT_MASK (0x1f << 11) +#define LRADC_DELAY_LOOP_COUNT_OFFSET 11 +#define LRADC_DELAY_LOOP (x) \ + (((x) << LRADC_DELAY_LOOP_COUNT_OFFSET) & \ + LRADC_DELAY_LOOP_COUNT_MASK) +#define LRADC_DELAY_DELAY_MASK 0x7ff +#define LRADC_DELAY_DELAY_OFFSET 0 +#define LRADC_DELAY_DELAY (x) \ + (((x) << LRADC_DELAY_DELAY_OFFSET) & \ + LRADC_DELAY_DELAY_MASK) + +#define LRADC_CTRL4 0x140 +#define LRADC_CTRL4_LRADCSELECT_MASK (n) (0xf << ((n) * 4)) +#define LRADC_CTRL4_LRADCSELECT_OFFSET (n) ((n) * 4) +#define LRADC_CTRL4_LRADCSELECT (n, x) \ + (((x) << LRADC_CTRL4_LRADCSELECT_OFFSET(n)) & \ + LRADC_CTRL4_LRADCSELECT_MASK(n)) + +#define LRADC_RESOLUTION 12 +#define LRADC_SINGLE_SAMPLE_MASK ((1 << LRADC_RESOLUTION) - 1) + +enum mxs_lradc_id { +IMX23_LRADC , +IMX28_LRADC , +}; + +enum mxs_lradc_ts_wires { +MXS_LRADC_TOUCHSCREEN_NONE =0 , +MXS_LRADC_TOUCHSCREEN_4WIRE , +MXS_LRADC_TOUCHSCREEN_5WIRE , +};
include/linux/mfd/mxs-lradc.h line 141
Quoted 10 lines
include/linux/mfd/mxs-lradc.h new file +10
-0+ +struct mxs_lradc { +enum mxs_lradc_id soc; + +void __iomem *base; +struct clk *clk; + +int irq[13 ]; +const char *const *irq_name; +int irq_count;
I guess you won't be needing these.
include/linux/mfd/mxs-lradc.h line 144
Quoted 2 lines
include/linux/mfd/mxs-lradc.h new file +2
-0+#define BUFFER_VCHANS_LIMITED 0x3f +#define BUFFER_VCHANS_ALL 0xff
Can you remove all these defines from inside the struct definition please?
Quoted 36 lines
include/linux/mfd/mxs-lradc.h new file +36
-0+u8 buffer_vchans; + +/* +* Certain LRADC channels are shared between touchscreen +* and/or touch-buttons and generic LRADC block. Therefore when using +* either of these, these channels are not available for the regular +* sampling. The shared channels are as follows: +* +* CH0 -- Touch button #0 +* CH1 -- Touch button #1 +* CH2 -- Touch screen XPUL +* CH3 -- Touch screen YPLL +* CH4 -- Touch screen XNUL +* CH5 -- Touch screen YNLR +* CH6 -- Touch screen WIPER (5-wire only) +* +* The bit fields below represents which parts of the LRADC block are +* switched into special mode of operation. These channels can not +* be sampled as regular LRADC channels. The driver will refuse any +* attempt to sample these channels. +*/ +#define CHAN_MASK_TOUCHBUTTON (BIT(1) | BIT(0)) +#define CHAN_MASK_TOUCHSCREEN_4WIRE (0xf << 2) +#define CHAN_MASK_TOUCHSCREEN_5WIRE (0x1f << 2) +enum mxs_lradc_ts_wires use_touchscreen; +bool use_touchbutton; + +#define MXS_LRADC_CELLS 2 +struct mfd_cell cells[MXS_LRADC_CELLS ]; +}; + +static inline void mxs_lradc_reg_set (struct mxs_lradc *lradc,u32 val,u32 reg) +{ +writel (val, lradc->base + reg +STMP_OFFSET_REG_SET ); +} +
include/linux/mfd/mxs-lradc.h line 190
Quoted 10 lines
include/linux/mfd/mxs-lradc.h new file +10
-0+static inline void mxs_lradc_reg_clear (struct mxs_lradc *lradc,u32 val, +u32 reg) +{ +writel (val, lradc->base + reg +STMP_OFFSET_REG_CLR ); +} + +static inline void mxs_lradc_reg_wrt (struct mxs_lradc *lradc,u32 val,u32 reg) +{ +writel (val, lradc->base + reg); +}
Why do you need to abstract the well know, accepted writel calls?
Quoted 13 lines
include/linux/mfd/mxs-lradc.h new file +13
-0+static inline u32 mxs_lradc_irq_mask (struct mxs_lradc *lradc) +{ +switch (lradc->soc) { +case IMX23_LRADC : +return LRADC_CTRL1_MX23_LRADC_IRQ_MASK ; +case IMX28_LRADC : +return LRADC_CTRL1_MX28_LRADC_IRQ_MASK ; +default : +return 0 ; + } +} + +#endif /* __MXS_LRADC_H */
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v3 1/4] mfd: mxs-lradc: Add support for mxs-lradc MFD
Hi Lee,
Thank you for the review.
Quoted 181 lines · Lee Jones
Quoted 37 lines · 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 formfd_add_devices")Signed-off-by Ksenija Stanojevic <[email protected]>Acked-by Jonathan Cameron <[email protected]>---
Changes in v3:
- add note to commit message
- move switch statement intoif(touch_ret == 0)branch
- addMODULE_AUTHORChanges in v2:
- do not change spacing inKconfig
- make structmfd_cellpart of structmxs_lradc
- use switch instead of if inmxs_lradc_irq_mask
- use only necessary header files inmxs_lradc.h
- usedevm_mfd_add_device
- use separate function to register mfd device
- change licence to GPL
- add copyrightdrivers/mfd/Kconfig | 17 ++++ drivers/mfd/Makefile | 1 + drivers/mfd/mxs-lradc.c | 217 ++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/mxs-lradc.h | 204 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 439 insertions(+) create mode 100644 drivers/mfd/mxs-lradc.c create mode 100644 include/linux/mfd/mxs-lradc.hdrivers/mfd/Kconfig +0
-0@@ -271,6 +271,23 @@ config MFD_MC13XXX_I2C helpdrivers/mfd/Kconfig config MFD_MC13XXX_I2C · line 281
Quoted 10 lines
drivers/mfd/Kconfig +8
-0Select 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.MX28Low Resolution Analogue-to-Digital Converter
Quoted 27 lines
drivers/mfd/Kconfig +9
-0+ 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 OFdrivers/mfd/Makefile +1
-0@@ -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.odrivers/mfd/mxs-lradc.c new file +0
-0drivers/mfd/mxs-lradc.c line 4
Quoted 4 lines
drivers/mfd/mxs-lradc.c new file +4
-0@@ -0,0 +1,217 @@ +/* +* Freescale MXS LRADC driver +* +* Copyright (c) 2012 DENX Software Engineering, GmbH. You need to update the copyright.
Authors:
Quoted 57 lines
drivers/mfd/mxs-lradc.c new file +57
-0+* 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> +#include <linux/of_device.h> +#include <linux/platform_device.h> +#include <linux/slab.h> + +static const char *const mx23_lradc_irq_names[] = { +"mxs-lradc-touchscreen" , +"mxs-lradc-channel0" , +"mxs-lradc-channel1" , +"mxs-lradc-channel2" , +"mxs-lradc-channel3" , +"mxs-lradc-channel4" , +"mxs-lradc-channel5" , +"mxs-lradc-channel6" , +"mxs-lradc-channel7" , +}; + +static const char *const mx28_lradc_irq_names[] = { +"mxs-lradc-touchscreen" , +"mxs-lradc-thresh0" , +"mxs-lradc-thresh1" , +"mxs-lradc-channel0" , +"mxs-lradc-channel1" , +"mxs-lradc-channel2" , +"mxs-lradc-channel3" , +"mxs-lradc-channel4" , +"mxs-lradc-channel5" , +"mxs-lradc-channel6" , +"mxs-lradc-channel7" , +"mxs-lradc-button0" , +"mxs-lradc-button1" , +}; + +struct mxs_lradc_of_config { +const int irq_count; +const char *const *irq_name; +}; +drivers/mfd/mxs-lradc.c line 71
Quoted 10 lines
drivers/mfd/mxs-lradc.c new file +10
-0+static const struct mxs_lradc_of_config mxs_lradc_of_config[] = { + [IMX23_LRADC ] = { + .irq_count =ARRAY_SIZE (mx23_lradc_irq_names), + .irq_name = mx23_lradc_irq_names, + }, + [IMX28_LRADC ] = { + .irq_count =ARRAY_SIZE (mx28_lradc_irq_names), + .irq_name = mx28_lradc_irq_names, + }, +};Please use
DEFINE_RES_IRQ_NAMED()instead.Quoted 9 lines
drivers/mfd/mxs-lradc.c new file +9
-0+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_add_device (struct platform_device *pdev, +struct mxs_lradc *lradc,char *name,int i)drivers/mfd/mxs-lradc.c line 91
Quoted 10 lines
drivers/mfd/mxs-lradc.c new file +10
-0+{ +struct mfd_cell *cell; + + cell = &lradc->cells[i]; + cell->name = name; + cell->platform_data = lradc; + cell->pdata_size =sizeof (*lradc); + +return devm_mfd_add_devices (&pdev->dev,-1 , cell,1 ,NULL ,0 ,NULL ); +}Please don't roll your own API.
Quoted 1 line
Use 'struct
mfd_cell' like everyone else does.
It has been suggested in previous reviews to use separate function to register mfd device, and to make mfd_cell allocate dynamically because struc mxs-lradc is allocated dynamically.
But I can revrse changes and make mfd_cells allocate staticaly wthout separate function.
Quoted 25 lines
drivers/mfd/mxs-lradc.c line 98
Quoted 6 lines
drivers/mfd/mxs-lradc.c new file +6
-0+static int mxs_lradc_probe (struct platform_device *pdev) +{ +const struct of_device_id *of_id = +of_match_device (mxs_lradc_dt_ids, &pdev->dev); +const struct mxs_lradc_of_config *of_cfg = + &mxs_lradc_of_config[(enum mxs_lradc_id )of_id->data];This implementation is wayyyy more complicated than it needs to be.
You've entangled DT probing with the MFD API.
Please use the MFD API properly.
drivers/mfd/mxs-lradc.c line 109
Quoted 11 lines
drivers/mfd/mxs-lradc.c new file +11
-0+struct device *dev = &pdev->dev; +struct device_node *node = dev->of_node; +struct mxs_lradc *lradc; +struct resource *iores; +int ret =0 , touch_ret, i; +u32 ts_wires =0 ; + + lradc =devm_kzalloc (&pdev->dev,sizeof (*lradc),GFP_KERNEL ); +if (!lradc) +return -ENOMEM ; + lradc->soc = (enum mxs_lradc_id )of_id->data;
Quoted 3 lines
If you're going to pull the platform ID out like this, please pull the *_match_* function down, just above this line. And separate them both from allocating memory.
Ok, but then I will also need to pull this line also:
const struct mxs_lradc_of_config *of_cfg =
&mxs_lradc_of_config[(enum mxs_lradc_id)of_id->data];
Quoted 3 lines
drivers/mfd/mxs-lradc.c line 111
Quoted 1 line
drivers/mfd/mxs-lradc.c new file +1
-0+/* Grab the memory area */ This comment doesn't add anything.
Ok, I will remove it.
Quoted 24 lines
We know what these calls do, and they don't "grab" anything.
drivers/mfd/mxs-lradc.c line 121
Quoted 10 lines
drivers/mfd/mxs-lradc.c new file +10
-0+ iores =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + lradc->base =devm_ioremap_resource (dev, iores); +if (IS_ERR (lradc->base)) +return PTR_ERR (lradc->base); + + 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); + }'\n' here. Nice spacing makes code easier to follow.
drivers/mfd/mxs-lradc.c line 129
Quoted 8 lines
drivers/mfd/mxs-lradc.c new file +8
-0+ ret =clk_prepare_enable (lradc->clk); +if (ret !=0 ) { +dev_err (dev,"Failed to enable the delay unit clock\n" ); +return ret; + } + + touch_ret =of_property_read_u32 (node,"fsl,lradc-touchscreen-wires" , + &ts_wires);
Quoted 1 line
Why do you need more than one 'ret' variable?
Yeah, it's not really needed.
Quoted 11 lines
drivers/mfd/mxs-lradc.c line 132
Quoted 2 lines
drivers/mfd/mxs-lradc.c new file +2
-0+if (touch_ret ==0 ) { + lradc->buffer_vchans =BUFFER_VCHANS_LIMITED ;'\n' here or else we think it's related to the
switch().drivers/mfd/mxs-lradc.c line 135
Quoted 3 lines
drivers/mfd/mxs-lradc.c new file +3
-0+switch (ts_wires) { +case 4 : + lradc->use_touchscreen =MXS_LRADC_TOUCHSCREEN_4WIRE ;This is not a good name for a variable. It looks like a bool here, but you're initialising with a configuration option.
Ok, will touchscreen_wire be ok?
Quoted 11 lines
drivers/mfd/mxs-lradc.c line 143
Quoted 8 lines
drivers/mfd/mxs-lradc.c new file +8
-0+break ; +case 5 : +if (lradc->soc ==IMX28_LRADC ) { + lradc->use_touchscreen = +MXS_LRADC_TOUCHSCREEN_5WIRE ; +break ; + } +/* fall through an error message for i.MX23 */ "to an error"
Quoted 7 lines
drivers/mfd/mxs-lradc.c line 148
Quoted 5 lines
drivers/mfd/mxs-lradc.c new file +5
-0+default : +dev_err (&pdev->dev, +"Unsupported number of touchscreen wires (%d)\n" , + ts_wires); +return -EINVAL ;The clock is still enabled.
Ok, I will use goto err_clk
Quoted 15 lines
Quoted 4 lines
drivers/mfd/mxs-lradc.c new file +4
-0+ } + }else { + lradc->buffer_vchans =BUFFER_VCHANS_ALL ; + }drivers/mfd/mxs-lradc.c line 162
Quoted 10 lines
drivers/mfd/mxs-lradc.c new file +10
-0+ + lradc->irq_count = of_cfg->irq_count; + lradc->irq_name = of_cfg->irq_name; +for (i =0 ; i < lradc->irq_count; i++) { + lradc->irq[i] =platform_get_irq (pdev, i); +if (lradc->irq[i] <0 ) { + ret = lradc->irq[i]; + goto err_clk; + } + }
Quoted 3 lines
You shouldn't be 'get'ing the IRQ here.
Where are you consuming these IRQs?
There are used in adc (mxs-lradc-adc) and touchscreen (mxs-lradc-ts) part.
Quoted 9 lines
drivers/mfd/mxs-lradc.c line 168
Quoted 5 lines
drivers/mfd/mxs-lradc.c new file +5
-0+platform_set_drvdata (pdev, lradc); + + ret =stmp_reset_block (lradc->base); +if (ret) +return ret;The clock is still enabled.
Ok, I will use goto err_clk
Quoted 86 lines
drivers/mfd/mxs-lradc.c line 174
Quoted 5 lines
drivers/mfd/mxs-lradc.c new file +5
-0+ ret =mxs_lradc_add_device (pdev, lradc,DRIVER_NAME_ADC ,0 ); +if (ret) { +dev_err (&pdev->dev,"Failed to add the ADC subdevice\n" ); + goto err_clk; + }Do this using statically defined
mfd_cells.Quoted 26 lines
drivers/mfd/mxs-lradc.c new file +26
-0+if (!lradc->use_touchscreen) +return 0 ; + + ret =mxs_lradc_add_device (pdev, lradc,DRIVER_NAME_TS ,1 ); +if (ret) { +dev_err (&pdev->dev, +"Failed to add the touchscreen subdevice\n" ); + goto err_clk; + } + +return 0 ; + +err_clk: +clk_disable_unprepare (lradc->clk); + +return ret; +} + +static int mxs_lradc_remove (struct platform_device *pdev) +{ +struct mxs_lradc *lradc =platform_get_drvdata (pdev); + +clk_disable_unprepare (lradc->clk); + +return 0 ; +}drivers/mfd/mxs-lradc.c line 211
Quoted 10 lines
drivers/mfd/mxs-lradc.c new file +10
-0+ +static struct platform_driver mxs_lradc_driver = { + .driver = { + .name ="mxs-lradc" , + .of_match_table = mxs_lradc_dt_ids, + }, + .probe = mxs_lradc_probe, + .remove = mxs_lradc_remove, +}; +This line is superfluous.
Quoted 12 lines
drivers/mfd/mxs-lradc.c new file +6
-0+module_platform_driver (mxs_lradc_driver); + +MODULE_AUTHOR ("Ksenija Stanojevic <[email protected]>" ); +MODULE_DESCRIPTION ("Freescale i.MX23/i.MX28 LRADC driver" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform:mxs-lradc" );include/linux/mfd/mxs-lradc.h new file +0
-0include/linux/mfd/mxs-lradc.h line 4
Quoted 4 lines
include/linux/mfd/mxs-lradc.h new file +4
-0@@ -0,0 +1,204 @@ +/* +* Freescale MXS LRADC driver +* +* Copyright (c) 2012 DENX Software Engineering, GmbH. You need to update the copyright.
Author:
Quoted 5 lines
include/linux/mfd/mxs-lradc.h new file +5
-0+* Marek Vasut <[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 include/linux/mfd/mxs-lradc.h line 19
Quoted 10 lines
include/linux/mfd/mxs-lradc.h new file +10
-0+* (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. +*/ + +#ifndef __MXS_LRADC_H +#define __MXS_LRADC_H__MFD_MXS_*
Quoted 8 lines
include/linux/mfd/mxs-lradc.h line 26
Quoted 6 lines
include/linux/mfd/mxs-lradc.h new file +6
-0+#include <linux/bitops.h> +#include <linux/io.h> +#include <linux/stmp_device.h> + +#define DRIVER_NAME_ADC "mxs-lradc-adc" +#define DRIVER_NAME_TS "mxs-lradc-ts"Don't define these. Just use the proper names.
Ok.
Quoted 117 lines
Quoted 104 lines
include/linux/mfd/mxs-lradc.h new file +104
-0+#define LRADC_MAX_DELAY_CHANS 4 +#define LRADC_MAX_MAPPED_CHANS 8 +#define LRADC_MAX_TOTAL_CHANS 16 + +#define LRADC_DELAY_TIMER_HZ 2000 + +#define LRADC_CTRL0 0x00 +# define LRADC_CTRL0_MX28_TOUCH_DETECT_ENABLE BIT(23) +# define LRADC_CTRL0_MX28_TOUCH_SCREEN_TYPE BIT(22) +# define LRADC_CTRL0_MX28_YNNSW /* YM */ BIT(21) +# define LRADC_CTRL0_MX28_YPNSW /* YP */ BIT(20) +# define LRADC_CTRL0_MX28_YPPSW /* YP */ BIT(19) +# define LRADC_CTRL0_MX28_XNNSW /* XM */ BIT(18) +# define LRADC_CTRL0_MX28_XNPSW /* XM */ BIT(17) +# define LRADC_CTRL0_MX28_XPPSW /* XP */ BIT(16) + +# define LRADC_CTRL0_MX23_TOUCH_DETECT_ENABLE BIT(20) +# define LRADC_CTRL0_MX23_YM BIT(19) +# define LRADC_CTRL0_MX23_XM BIT(18) +# define LRADC_CTRL0_MX23_YP BIT(17) +# define LRADC_CTRL0_MX23_XP BIT(16) + +# define LRADC_CTRL0_MX28_PLATE_MASK \ + (LRADC_CTRL0_MX28_TOUCH_DETECT_ENABLE | \ + LRADC_CTRL0_MX28_YNNSW | LRADC_CTRL0_MX28_YPNSW | \ + LRADC_CTRL0_MX28_YPPSW | LRADC_CTRL0_MX28_XNNSW | \ + LRADC_CTRL0_MX28_XNPSW | LRADC_CTRL0_MX28_XPPSW) + +# define LRADC_CTRL0_MX23_PLATE_MASK \ + (LRADC_CTRL0_MX23_TOUCH_DETECT_ENABLE | \ + LRADC_CTRL0_MX23_YM | LRADC_CTRL0_MX23_XM | \ + LRADC_CTRL0_MX23_YP | LRADC_CTRL0_MX23_XP) + +#define LRADC_CTRL1 0x10 +#define LRADC_CTRL1_TOUCH_DETECT_IRQ_EN BIT(24) +#define LRADC_CTRL1_LRADC_IRQ_EN (n) (1 << ((n) + 16)) +#define LRADC_CTRL1_MX28_LRADC_IRQ_EN_MASK (0x1fff << 16) +#define LRADC_CTRL1_MX23_LRADC_IRQ_EN_MASK (0x01ff << 16) +#define LRADC_CTRL1_LRADC_IRQ_EN_OFFSET 16 +#define LRADC_CTRL1_TOUCH_DETECT_IRQ BIT(8) +#define LRADC_CTRL1_LRADC_IRQ (n) (1 << (n)) +#define LRADC_CTRL1_MX28_LRADC_IRQ_MASK 0x1fff +#define LRADC_CTRL1_MX23_LRADC_IRQ_MASK 0x01ff +#define LRADC_CTRL1_LRADC_IRQ_OFFSET 0 + +#define LRADC_CTRL2 0x20 +#define LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET 24 +#define LRADC_CTRL2_TEMPSENSE_PWD BIT(15) + +#define LRADC_STATUS 0x40 +#define LRADC_STATUS_TOUCH_DETECT_RAW BIT(0) + +#define LRADC_CH (n) (0x50 + (0x10 * (n))) +#define LRADC_CH_ACCUMULATE BIT(29) +#define LRADC_CH_NUM_SAMPLES_MASK (0x1f << 24) +#define LRADC_CH_NUM_SAMPLES_OFFSET 24 +#define LRADC_CH_NUM_SAMPLES (x) \ + ((x) << LRADC_CH_NUM_SAMPLES_OFFSET) +#define LRADC_CH_VALUE_MASK 0x3ffff +#define LRADC_CH_VALUE_OFFSET 0 + +#define LRADC_DELAY (n) (0xd0 + (0x10 * (n))) +#define LRADC_DELAY_TRIGGER_LRADCS_MASK (0xffUL << 24) +#define LRADC_DELAY_TRIGGER_LRADCS_OFFSET 24 +#define LRADC_DELAY_TRIGGER (x) \ + (((x) << LRADC_DELAY_TRIGGER_LRADCS_OFFSET) & \ + LRADC_DELAY_TRIGGER_LRADCS_MASK) +#define LRADC_DELAY_KICK BIT(20) +#define LRADC_DELAY_TRIGGER_DELAYS_MASK (0xf << 16) +#define LRADC_DELAY_TRIGGER_DELAYS_OFFSET 16 +#define LRADC_DELAY_TRIGGER_DELAYS (x) \ + (((x) << LRADC_DELAY_TRIGGER_DELAYS_OFFSET) & \ + LRADC_DELAY_TRIGGER_DELAYS_MASK) +#define LRADC_DELAY_LOOP_COUNT_MASK (0x1f << 11) +#define LRADC_DELAY_LOOP_COUNT_OFFSET 11 +#define LRADC_DELAY_LOOP (x) \ + (((x) << LRADC_DELAY_LOOP_COUNT_OFFSET) & \ + LRADC_DELAY_LOOP_COUNT_MASK) +#define LRADC_DELAY_DELAY_MASK 0x7ff +#define LRADC_DELAY_DELAY_OFFSET 0 +#define LRADC_DELAY_DELAY (x) \ + (((x) << LRADC_DELAY_DELAY_OFFSET) & \ + LRADC_DELAY_DELAY_MASK) + +#define LRADC_CTRL4 0x140 +#define LRADC_CTRL4_LRADCSELECT_MASK (n) (0xf << ((n) * 4)) +#define LRADC_CTRL4_LRADCSELECT_OFFSET (n) ((n) * 4) +#define LRADC_CTRL4_LRADCSELECT (n, x) \ + (((x) << LRADC_CTRL4_LRADCSELECT_OFFSET(n)) & \ + LRADC_CTRL4_LRADCSELECT_MASK(n)) + +#define LRADC_RESOLUTION 12 +#define LRADC_SINGLE_SAMPLE_MASK ((1 << LRADC_RESOLUTION) - 1) + +enum mxs_lradc_id { +IMX23_LRADC , +IMX28_LRADC , +}; + +enum mxs_lradc_ts_wires { +MXS_LRADC_TOUCHSCREEN_NONE =0 , +MXS_LRADC_TOUCHSCREEN_4WIRE , +MXS_LRADC_TOUCHSCREEN_5WIRE , +};include/linux/mfd/mxs-lradc.h line 141
Quoted 10 lines
include/linux/mfd/mxs-lradc.h new file +10
-0+ +struct mxs_lradc { +enum mxs_lradc_id soc; + +void __iomem *base; +struct clk *clk; + +int irq[13 ]; +const char *const *irq_name; +int irq_count;I guess you won't be needing these.
Quoted 5 lines
include/linux/mfd/mxs-lradc.h line 144
Quoted 2 lines
include/linux/mfd/mxs-lradc.h new file +2
-0+#define BUFFER_VCHANS_LIMITED 0x3f +#define BUFFER_VCHANS_ALL 0xffCan you remove all these defines from inside the struct definition please?
Ok.
Quoted 40 lines
Quoted 40 lines
include/linux/mfd/mxs-lradc.h new file +40
-0+u8 buffer_vchans; + +/* +* Certain LRADC channels are shared between touchscreen +* and/or touch-buttons and generic LRADC block. Therefore when using +* either of these, these channels are not available for the regular +* sampling. The shared channels are as follows: +* +* CH0 -- Touch button #0 +* CH1 -- Touch button #1 +* CH2 -- Touch screen XPUL +* CH3 -- Touch screen YPLL +* CH4 -- Touch screen XNUL +* CH5 -- Touch screen YNLR +* CH6 -- Touch screen WIPER (5-wire only) +* +* The bit fields below represents which parts of the LRADC block are +* switched into special mode of operation. These channels can not +* be sampled as regular LRADC channels. The driver will refuse any +* attempt to sample these channels. +*/ +#define CHAN_MASK_TOUCHBUTTON (BIT(1) | BIT(0)) +#define CHAN_MASK_TOUCHSCREEN_4WIRE (0xf << 2) +#define CHAN_MASK_TOUCHSCREEN_5WIRE (0x1f << 2) +enum mxs_lradc_ts_wires use_touchscreen; +bool use_touchbutton; + +#define MXS_LRADC_CELLS 2 +struct mfd_cell cells[MXS_LRADC_CELLS ]; +}; + +static inline void mxs_lradc_reg_set (struct mxs_lradc *lradc,u32 val,u32 reg) +{ +writel (val, lradc->base + reg +STMP_OFFSET_REG_SET ); +} + +static inline void mxs_lradc_reg_clear (struct mxs_lradc *lradc,u32 val, +u32 reg) +{ +writel (val, lradc->base + reg +STMP_OFFSET_REG_CLR );
Quoted 8 lines
include/linux/mfd/mxs-lradc.h line 190
Quoted 6 lines
include/linux/mfd/mxs-lradc.h new file +6
-0+} + +static inline void mxs_lradc_reg_wrt (struct mxs_lradc *lradc,u32 val,u32 reg) +{ +writel (val, lradc->base + reg); +}Why do you need to abstract the well know, accepted writel calls?
It makes code more readable.
Quoted 5 lines
Quoted 5 lines
include/linux/mfd/mxs-lradc.h new file +5
-0+static inline u32 mxs_lradc_irq_mask (struct mxs_lradc *lradc) +{ +switch (lradc->soc) { +case IMX23_LRADC : +return LRADC_CTRL1_MX23_LRADC_IRQ_MASK ;
Quoted 8 lines
include/linux/mfd/mxs-lradc.h line 204
Quoted 8 lines
include/linux/mfd/mxs-lradc.h new file +8
-0+case IMX28_LRADC : +return LRADC_CTRL1_MX28_LRADC_IRQ_MASK ; +default : + return 0; + } +} + +#endif /* __MXS_LRADC_H */
Regards,
Ksenija
Re: [PATCH v3 1/4] mfd: mxs-lradc: Add support for mxs-lradc MFD
Hi Ksenija!
Quoted 3 lines · Ksenija Stanojevi=C4=87 writes:
Quoted 2 lines · Lee Jones
Review
Quoted 2 lines
(quoted diff) +2
-0+static int mxs_lradc_add_device(struct platform_device *pdev, + struct mxs_lradc *lradc, char *name, in=
t i)
Quoted 9 lines
Quoted 9 lines
Review
Quoted 9 lines
(quoted diff) +9
-0+{ + struct mfd_cell *cell; + + cell =3D &lradc->cells[i]; + cell->name =3D name; + cell->platform_data =3D lradc; + cell->pdata_size =3D sizeof(*lradc); + + return devm_mfd_add_devices(&pdev->dev, -1, cell, 1, NULL, 0, N=
ULL);
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
+}
Please don't roll your own API.
Quoted 8 lines
Quoted 1 line
Use 'struct
mfd_cell' like everyone else does.=
It has been suggested in previous reviews to use separate function to register mfd device, and to make
mfd_cellallocate dynamically because struc mxs-lradc is allocated dynamically.
But I can revrse changes and makemfd_cellsallocate staticaly wthout separate function.
I think making mfd_cells members of struct mxs-lradc will address all review comments.
HTH,
Harald
Re: [PATCH v3 1/4] mfd: mxs-lradc: Add support for mxs-lradc MFD
Quoted 21 lines · Harald Geyer
Hi Ksenija!
Quoted 18 lines · Ksenija Stanojević
Quoted 16 lines · Lee Jones
drivers/mfd/mxs-lradc.c line 91
Quoted 12 lines
drivers/mfd/mxs-lradc.c new file +12
-0+static int mxs_lradc_add_device (struct platform_device *pdev, +struct mxs_lradc *lradc,char *name,int i) +{ +struct mfd_cell *cell; + + cell = &lradc->cells[i]; + cell->name = name; + cell->platform_data = lradc; + cell->pdata_size =sizeof (*lradc); + +return devm_mfd_add_devices (&pdev->dev,-1 , cell,1 ,NULL ,0 ,NULL ); +}Please don't roll your own API.
Use 'struct
mfd_cell' like everyone else does.
Quoted 8 lines
Quoted 5 lines
It has been suggested in previous reviews to use separate function to register mfd device, and to make
mfd_cellallocate dynamically because struc mxs-lradc is allocated dynamically.
But I can revrse changes and makemfd_cellsallocate staticaly wthout separate function.I think making
mfd_cellsmembers of struct mxs-lradc will address all review comments.
No, please don't do that either.
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v3 1/4] mfd: mxs-lradc: Add support for mxs-lradc MFD
Quoted 29 lines · Lee Jones
Quoted 27 lines · Harald Geyer
Hi Ksenija!
Quoted 23 lines · Ksenija Stanojević
Quoted 15 lines · Lee Jones
drivers/mfd/mxs-lradc.c line 91
Quoted 12 lines
drivers/mfd/mxs-lradc.c new file +12
-0+static int mxs_lradc_add_device (struct platform_device *pdev, +struct mxs_lradc *lradc,char *name,int i) +{ +struct mfd_cell *cell; + + cell = &lradc->cells[i]; + cell->name = name; + cell->platform_data = lradc; + cell->pdata_size =sizeof (*lradc); + +return devm_mfd_add_devices (&pdev->dev,-1 , cell,1 ,NULL ,0 ,NULL ); +}Please don't roll your own API.
Quoted 1 line
Use 'struct
mfd_cell' like everyone else does.It has been suggested in previous reviews to use separate function to register mfd device, and to make
mfd_cellallocate dynamically because struc mxs-lradc is allocated dynamically.
But I can revrse changes and makemfd_cellsallocate staticaly wthout separate function.
Quoted 5 lines
Quoted 2 lines
I think making
mfd_cellsmembers of struct mxs-lradc will address all review comments.No, please don't do that either.
It'd be nice if you explained in detail why not. Otherwise this is just empty splat.
Signature · 2 lines
Best regards, Marek Vasut
Re: [PATCH v3 1/4] mfd: mxs-lradc: Add support for mxs-lradc MFD
Hi,
Quoted 35 lines
Marek Vasut <[email protected]> hat am 14. Juli 2016 um 17:38 geschrieben:
Quoted 31 lines · Lee Jones
Quoted 29 lines · Harald Geyer
Hi Ksenija!
Quoted 25 lines · Ksenija Stanojević
Quoted 17 lines · Lee Jones
Quoted 12 lines
(quoted diff) +2
-0+static int mxs_lradc_add_device(struct platform_device *pdev, + struct mxs_lradc *lradc, char *name, inti)
drivers/mfd/mxs-lradc.c new file +9
-0+{ +struct mfd_cell *cell; + + cell = &lradc->cells[i]; + cell->name = name; + cell->platform_data = lradc; + cell->pdata_size =sizeof (*lradc); + + return devm_mfd_add_devices(&pdev->dev, -1, cell, 1, NULL, 0,Quoted 2 lines
NULL);
+}Please don't roll your own API.
Quoted 1 line
Use 'struct
mfd_cell' like everyone else does.It has been suggested in previous reviews to use separate function to register mfd device, and to make
mfd_cellallocate dynamically because struc mxs-lradc is allocated dynamically.
But I can revrse changes and makemfd_cellsallocate staticaly wthout separate function.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I think making
mfd_cellsmembers of struct mxs-lradc will address all review comments.No, please don't do that either.
It'd be nice if you explained in detail why not. Otherwise this is just empty splat.
since there is no reply, here is my guess:
static const struct mfd_cell mxs_lradc_devs[] = {
{
.name = DRIVER_NAME_ADC,
},
{
.name = DRIVER_NAME_TS,
},
};But i'm not sure if we need of_compatible defined here. The intension of this patch series is to keep the DT binding.
@Lee: Could you please give us a feedback?
@Ksenija: Still motivated for next round?
Regards
Stefan
Quoted 4 lines
Signature · 3 lines
-- Best regards, Marek Vasut
Re: [PATCH v3 1/4] mfd: mxs-lradc: Add support for mxs-lradc MFD
Hi,
Quoted 40 lines · Stefan Wahren
Hi,
Quoted 38 lines
Marek Vasut <[email protected]> hat am 14. Juli 2016 um 17:38 geschrieben:
Quoted 34 lines · Lee Jones
Quoted 31 lines · Harald Geyer
Hi Ksenija!
Quoted 18 lines · Ksenija Stanojević
Quoted 17 lines · Lee Jones
Quoted 12 lines
(quoted diff) +2
-0+static int mxs_lradc_add_device(struct platform_device *pdev, + struct mxs_lradc *lradc, char *name, inti)
(quoted diff) +9
-0+{ + struct mfd_cell *cell; + + cell = &lradc->cells[i]; + cell->name = name; + cell->platform_data = lradc; + cell->pdata_size = sizeof(*lradc); + + return devm_mfd_add_devices(&pdev->dev, -1, cell, 1, NULL, 0,Quoted 2 lines
NULL);
+}Please don't roll your own API.
Quoted 7 lines
Quoted 1 line
Use 'struct
mfd_cell' like everyone else does.It has been suggested in previous reviews to use separate function to register mfd device, and to make
mfd_cellallocate dynamically because struc mxs-lradc is allocated dynamically.
But I can revrse changes and makemfd_cellsallocate staticaly wthout separate function.I think making
mfd_cellsmembers of struct mxs-lradc will address all review comments.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
No, please don't do that either.
It'd be nice if you explained in detail why not. Otherwise this is just empty splat.
since there is no reply, here is my guess:
Sorry for the delay, I'm currently working on it. I will post another version soon.
Quoted 11 lines
static const struct mfd_cell mxs_lradc_devs[] = { { .name = DRIVER_NAME_ADC, }, { .name = DRIVER_NAME_TS, }, };But i'm not sure if we need
of_compatibledefined here. The intension of this patch series is to keep the DT binding.
I think it needs .resources because in next version DEFINE_RES_IRQ_NAMED will be used.
Quoted 11 lines
@Lee: Could you please give us a feedback?
@Ksenija: Still motivated for next round?
Regards
StefanQuoted 4 lines
--
Best regards,
Marek Vasut
Regards,
Ksenija
Re: [PATCH v3 1/4] mfd: mxs-lradc: Add support for mxs-lradc MFD
Hi All,
Quoted 62 lines · Ksenija Stanojević
Hi,
Quoted 40 lines · Stefan Wahren
Hi,
Quoted 38 lines
Marek Vasut <[email protected]> hat am 14. Juli 2016 um 17:38 geschrieben:
Quoted 34 lines · Lee Jones
Quoted 31 lines · Harald Geyer
Hi Ksenija!
Quoted 18 lines · Ksenija Stanojević
Quoted 17 lines · Lee Jones
Quoted 12 lines
(quoted diff) +2
-0+static int mxs_lradc_add_device(struct platform_device *pdev, + struct mxs_lradc *lradc, char *name, inti)
(quoted diff) +9
-0+{ + struct mfd_cell *cell; + + cell = &lradc->cells[i]; + cell->name = name; + cell->platform_data = lradc; + cell->pdata_size = sizeof(*lradc); + + return devm_mfd_add_devices(&pdev->dev, -1, cell, 1, NULL, 0,Quoted 2 lines
NULL);
+}Please don't roll your own API.
Quoted 7 lines
Quoted 1 line
Use 'struct
mfd_cell' like everyone else does.It has been suggested in previous reviews to use separate function to register mfd device, and to make
mfd_cellallocate dynamically because struc mxs-lradc is allocated dynamically.
But I can revrse changes and makemfd_cellsallocate staticaly wthout separate function.I think making
mfd_cellsmembers of struct mxs-lradc will address all review comments.Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
No, please don't do that either.
It'd be nice if you explained in detail why not. Otherwise this is just empty splat.
since there is no reply, here is my guess:
Sorry for the delay, I'm currently working on it. I will post another version soon.
Quoted 9 lines
static const struct mfd_cell mxs_lradc_devs[] = { { .name = DRIVER_NAME_ADC, }, { .name = DRIVER_NAME_TS, }, };
Quoted 9 lines
Quoted 2 lines
But i'm not sure if we need
of_compatibledefined here. The intension of this patch series is to keep the DT binding.I think it needs .resources because in next version
DEFINE_RES_IRQ_NAMEDwill be used.Quoted 3 lines
@Lee: Could you please give us a feedback?
@Ksenija: Still motivated for next round?
Can someone with imx23 board send me /proc/interrupts log, I need irq numbers...
Thanks,
Ksenija
Fabio Estevam
reviewerRe: [PATCH v3 1/4] mfd: mxs-lradc: Add support for mxs-lradc MFD
Hi Ksenija,
Quoted 2 lines · Ksenija Stanojević
Can someone with imx23 board send me
/proc/interruptslog, I need irq numbers...
Can't you get them from the MX23 Reference Manual (Table 5-1. i.MX23 Interrupt Sources)?
Re: [PATCH v3 1/4] mfd: mxs-lradc: Add support for mxs-lradc MFD
Hi Fabio,
Quoted 10 lines · Fabio Estevam
Hi Ksenija,
Quoted 2 lines · Ksenija Stanojević
Can someone with imx23 board send me
/proc/interruptslog, I need irq numbers...Can't you get them from the MX23 Reference Manual (Table 5-1. i.MX23 Interrupt Sources)?
I thought it will be more reliable if I asked someone, since numbers from MX28 manual don't match with /proc/interrupts log.
Re: [PATCH v3 1/4] mfd: mxs-lradc: Add support for mxs-lradc MFD
Quoted 1 line · Ksenija Stanojević
Hi Fabio,
Hi,
Quoted 6 lines · Fabio Estevam
Quoted 5 lines
Hi Ksenija,
On Wed, Aug 3, 2016 at 1:32 PM, Ksenija Stanojević <[email protected]> wrote:
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Can someone with imx23 board send me
/proc/interruptslog, I need irq numbers...Can't you get them from the MX23 Reference Manual (Table 5-1. i.MX23 Interrupt Sources)?
I thought it will be more reliable if I asked someone, since numbers from MX28 manual don't match with
/proc/interruptslog.
What do you mean they don't match ? Please elaborate.
Signature · 2 lines
Best regards, Marek Vasut
Re: [PATCH v3 1/4] mfd: mxs-lradc: Add support for mxs-lradc MFD
Quoted 14 lines · Marek Vasut
Quoted 1 line · Ksenija Stanojević
Hi Fabio,
Hi,
Quoted 9 lines · Fabio Estevam
Quoted 8 lines
Hi Ksenija,
Quoted 2 lines · Ksenija Stanojević
Can someone with imx23 board send me
/proc/interruptslog, I need irq numbers...
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Can't you get them from the MX23 Reference Manual (Table 5-1. i.MX23 Interrupt Sources)?
I thought it will be more reliable if I asked someone, since numbers from MX28 manual don't match with
/proc/interruptslog.What do you mean they don't match ? Please elaborate.
irqs don't have the same values in Table 5.1 in MX28 manual and in /proc/interrupts
output.
For example:
touchscreen irq in MX28 manual have these values:
10 (source number) and 0x0028 (vector number)
in /proc/interrupts:
210: 0 - 10 Edge mxs-lradc-touchscreen
Re: [PATCH v3 1/4] mfd: mxs-lradc: Add support for mxs-lradc MFD
Quoted 27 lines · Ksenija Stanojević
Quoted 14 lines · Marek Vasut
Quoted 1 line · Ksenija Stanojević
Hi Fabio,
Hi,
Quoted 9 lines · Fabio Estevam
Quoted 8 lines
Hi Ksenija,
Quoted 2 lines · Ksenija Stanojević
Can someone with imx23 board send me
/proc/interruptslog, I need irq numbers...Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Can't you get them from the MX23 Reference Manual (Table 5-1. i.MX23 Interrupt Sources)?
I thought it will be more reliable if I asked someone, since numbers from MX28 manual don't match with
/proc/interruptslog.What do you mean they don't match ? Please elaborate.
irqs don't have the same values in Table 5.1 in MX28 manual and in
/proc/interrupts
output.
Quoted 6 lines
For example:
touchscreen irq in MX28 manual have these values:
10 (source number) and0x0028(vector number)in
/proc/interrupts:
210: 0 - 10 Edge mxs-lradc-touchscreen
I see lradc_touch_irq in the MX28RM is IRQ 10 and it is also 10 in your /proc/interrupts output . What am I missing ?
Signature · 2 lines
Best regards, Marek Vasut
Re: [PATCH v3 1/4] mfd: mxs-lradc: Add support for mxs-lradc MFD
Quoted 32 lines · Marek Vasut
Quoted 31 lines · Ksenija Stanojević
Quoted 14 lines · Marek Vasut
Quoted 1 line · Ksenija Stanojević
Hi Fabio,
Hi,
Quoted 9 lines · Fabio Estevam
Quoted 8 lines
Hi Ksenija,
Quoted 2 lines · Ksenija Stanojević
Can someone with imx23 board send me
/proc/interruptslog, I need irq numbers...Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Can't you get them from the MX23 Reference Manual (Table 5-1. i.MX23 Interrupt Sources)?
I thought it will be more reliable if I asked someone, since numbers from MX28 manual don't match with
/proc/interruptslog.What do you mean they don't match ? Please elaborate.
irqs don't have the same values in Table 5.1 in MX28 manual and in
/proc/interrupts
output.For example:
touchscreen irq in MX28 manual have these values:
10 (source number) and0x0028(vector number)
Quoted 5 lines
Quoted 2 lines
in
/proc/interrupts:
210: 0 - 10 Edge mxs-lradc-touchscreenI see
lradc_touch_irqin the MX28RM is IRQ 10 and it is also 10 in your/proc/interruptsoutput . What am I missing ?
I was referring to the number of the first column 210, that's the number that I need and cannot find in the Table of the manual.
Re: [PATCH v3 1/4] mfd: mxs-lradc: Add support for mxs-lradc MFD
Quoted 33 lines · Ksenija Stanojević
Quoted 32 lines · Marek Vasut
Quoted 31 lines · Ksenija Stanojević
Quoted 14 lines · Marek Vasut
Quoted 1 line · Ksenija Stanojević
Hi Fabio,
Hi,
Quoted 9 lines · Fabio Estevam
Quoted 8 lines
Hi Ksenija,
Quoted 2 lines · Ksenija Stanojević
Can someone with imx23 board send me
/proc/interruptslog, I need irq numbers...Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Can't you get them from the MX23 Reference Manual (Table 5-1. i.MX23 Interrupt Sources)?
I thought it will be more reliable if I asked someone, since numbers from MX28 manual don't match with
/proc/interruptslog.What do you mean they don't match ? Please elaborate.
irqs don't have the same values in Table 5.1 in MX28 manual and in
/proc/interrupts
output.For example:
touchscreen irq in MX28 manual have these values:
10 (source number) and0x0028(vector number)
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
in
/proc/interrupts:
210: 0 - 10 Edge mxs-lradc-touchscreenI see
lradc_touch_irqin the MX28RM is IRQ 10 and it is also 10 in your/proc/interruptsoutput . What am I missing ?I was referring to the number of the first column 210, that's the number that I need and cannot find in the Table of the manual.
The first number in /proc/interrupts is the number which Linux maps to that particular IRQ line, but that number can be anything, it does not (need to) match the hardware in any way. What do you need it for ?
Signature · 2 lines
Best regards, Marek Vasut
Re: [PATCH v3 1/4] mfd: mxs-lradc: Add support for mxs-lradc MFD
Quoted 40 lines · Marek Vasut
Quoted 39 lines · Ksenija Stanojević
Quoted 37 lines · Marek Vasut
Quoted 27 lines · Ksenija Stanojević
Quoted 14 lines · Marek Vasut
Quoted 1 line · Ksenija Stanojević
Hi Fabio,
Hi,
Quoted 9 lines · Fabio Estevam
Quoted 8 lines
Hi Ksenija,
Quoted 2 lines · Ksenija Stanojević
Can someone with imx23 board send me
/proc/interruptslog, I need irq numbers...Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Can't you get them from the MX23 Reference Manual (Table 5-1. i.MX23 Interrupt Sources)?
I thought it will be more reliable if I asked someone, since numbers from MX28 manual don't match with
/proc/interruptslog.What do you mean they don't match ? Please elaborate.
irqs don't have the same values in Table 5.1 in MX28 manual and in
/proc/interrupts
output.Quoted 6 lines
For example:
touchscreen irq in MX28 manual have these values:
10 (source number) and0x0028(vector number)in
/proc/interrupts:
210: 0 - 10 Edge mxs-lradc-touchscreenI see
lradc_touch_irqin the MX28RM is IRQ 10 and it is also 10 in your/proc/interruptsoutput . What am I missing ?
Quoted 6 lines
Quoted 2 lines
I was referring to the number of the first column 210, that's the number that I need and cannot find in the Table of the manual.
The first number in
/proc/interruptsis the number which Linux maps to that particular IRQ line, but that number can be anything, it does not (need to) match the hardware in any way. What do you need it for ?
Thanks, I didn't know that. Well I was using the first number to map irq names to irq number in DEFINE_RES_IRQ_NAMED. Otherwise I get probe failure:
probe of mxs-lradc-ts failed with error -22
It's because platform_get_irq_byname cannot find irq for the given irq name.
Re: [PATCH v3 1/4] mfd: mxs-lradc: Add support for mxs-lradc MFD
In reply to Marek VasutQuoted 30 lines · Marek Vasut
Quoted 29 lines · Lee Jones
Quoted 27 lines · Harald Geyer
Hi Ksenija!
Quoted 23 lines · Ksenija Stanojević
Quoted 15 lines · Lee Jones
drivers/mfd/mxs-lradc.c line 91
Quoted 12 lines
drivers/mfd/mxs-lradc.c new file +12
-0+static int mxs_lradc_add_device (struct platform_device *pdev, +struct mxs_lradc *lradc,char *name,int i) +{ +struct mfd_cell *cell; + + cell = &lradc->cells[i]; + cell->name = name; + cell->platform_data = lradc; + cell->pdata_size =sizeof (*lradc); + +return devm_mfd_add_devices (&pdev->dev,-1 , cell,1 ,NULL ,0 ,NULL ); +}Please don't roll your own API.
Quoted 1 line
Use 'struct
mfd_cell' like everyone else does.It has been suggested in previous reviews to use separate function to register mfd device, and to make
mfd_cellallocate dynamically because struc mxs-lradc is allocated dynamically.
But I can revrse changes and makemfd_cellsallocate staticaly wthout separate function.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I think making
mfd_cellsmembers of struct mxs-lradc will address all review comments.No, please don't do that either.
It'd be nice if you explained in detail why not. Otherwise this is just empty splat.
I already said what needs to be done.
"Use struct mfd_cell", in it's pure/static form. Don't include it in any device data struct.
"like everyone else does", look at other driver to see how they do it.
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH v3 2/4 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 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 | 811 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 825 insertions(+) create mode 100644 drivers/iio/adc/mxs-lradc-adc.c
drivers/iio/adc/Kconfig +13 -0
@@ -194,6 +194,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 HI8435 tristate "Holt Integrated Circuits HI-8435 threshold detector" select IIO_TRIGGERED_EVENT
drivers/iio/adc/Makefile +1 -0
@@ -29,6 +29,7 @@ obj-$(CONFIG_MAX1363) += max1363.o obj-$(CONFIG_MCP320X) += mcp320x.o obj-$(CONFIG_MCP3422) += mcp3422.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 +811 -0
811 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH v3 2/4] iio: adc: mxs-lradc: Add support for adc driver
Quoted 11 lines
Ksenija Stanojevic <[email protected]> hat am 24. Juni 2016 um 14:10 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]>Acked-by Jonathan Cameron <[email protected]>
Thanks a lot
PATCH v3 3/4 input: touchscreen: mxs-lradc: Add support for touchscreen
In reply to Ksenija StanojevicAdd 4-wire/5-wire touchscreen controller.
---
Changes in v3:
- add MODULE_*(ALIAS, AUTHOR, DESCRIPTION)
Changes in v2:
- do not change spacing in Kconfig
- remove dev.parent
- rename err_ts_register to error
- combine functions hw_stop and disable_ts so that mxs_lradc_ts_remove could be deleted.
- add spinlock in struct mxs_lradc_ts to enable locking in interrupt handler.
- only grab irqs that are relevant to touchscreen
- use direct return instead assigning error to touch_ret in probe function.
- change licence to GPL
- add copyright
drivers/input/touchscreen/Kconfig | 10 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/mxs-lradc-ts.c | 729 +++++++++++++++++++++++++++++++ 3 files changed, 740 insertions(+) create mode 100644 drivers/input/touchscreen/mxs-lradc-ts.c
drivers/input/touchscreen/Kconfig +10 -0
@@ -305,6 +305,16 @@ config TOUCHSCREEN_EGALAX_SERIAL To compile this driver as a module, choose M here: the module will be called egalax_ts_serial. +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_FT6236 tristate "FT6236 I2C touchscreen" depends on I2C
drivers/input/touchscreen/Makefile +1 -0
@@ -52,6 +52,7 @@ obj-$(CONFIG_TOUCHSCREEN_MIGOR) += migor_ts.o obj-$(CONFIG_TOUCHSCREEN_MMS114) += mms114.o obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o obj-$(CONFIG_TOUCHSCREEN_MK712) += mk712.o +obj-$(CONFIG_TOUCHSCREEN_MXS_LRADC) += mxs-lradc-ts.o obj-$(CONFIG_TOUCHSCREEN_HP600) += hp680_ts_input.o obj-$(CONFIG_TOUCHSCREEN_HP7XX) += jornada720_ts.o obj-$(CONFIG_TOUCHSCREEN_IPAQ_MICRO) += ipaq-micro-ts.o
drivers/input/touchscreen/mxs-lradc-ts.c new file +729 -0
729 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v3 4/4 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 v3:
- none
Changes in v2:
- none
drivers/iio/adc/Kconfig | 14 - drivers/iio/adc/Makefile | 1 - drivers/iio/adc/mxs-lradc.c | 1775 ------------------------------------------- 3 files changed, 1790 deletions(-) delete mode 100644 drivers/iio/adc/mxs-lradc.c
drivers/iio/adc/Kconfig +0 -14
@@ -310,20 +310,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
@@ -30,7 +30,6 @@ obj-$(CONFIG_MCP320X) += mcp320x.o obj-$(CONFIG_MCP3422) += mcp3422.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 -1775
1,775 lines not on this page · raw message
Signature · 1 line
1.9.1