RE: [PATCH v4 5/8] MFD: ti_am335x_tscadc: Add DT support
Hi Koen, SNIP Since AM335x is DT only, why is there a platform data codepath and why is it the first branch it tries? And I guess the next question is related to the first: why doesn't it work when used with DT? When I copy over the nodes from the evm.dts to my board I get tsc tsc: Missing platform data in dmesg. This IP came up 1st on AM335x, but it is not platform dependent. The driver can be used on other platforms where-in DT is not supported. According to the maintainers platform data takes precedence over DT. Hence the order. Rachana, I see no point adding support for platform_data when you know that none of older platforms are going to use this driver and all future platforms _must_ follow device-tree model. So I agree that you should remove board file dependency from the driver. Ok. I will remove support for platform data in the next version of patches. I do not see Missing platform data error msg in the latest driver. I am not able to trace from where this got populated. Can you share the branch which you have tested? https://github.com/patilrachna/linux/tree/v3.8_rc3_MFD_TSCADC_DT-v2 Did you get a chance to test this branch? And can you also share your branch, on which you observed the issue. Regards, Rachna ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
RE: [PATCH v4 5/8] MFD: ti_am335x_tscadc: Add DT support
On Wed, Jan 30, 2013 at 16:10:09, Koen Kooi wrote: Op 24 jan. 2013, om 04:45 heeft Patil, Rachna rac...@ti.com het volgende geschreven: From: Patil, Rachna rac...@ti.com Make changes to add DT support in the MFD core driver. Signed-off-by: Patil, Rachna rac...@ti.com --- Changes in v4: Non-standard properties prefixed with vendor name. drivers/mfd/ti_am335x_tscadc.c | 28 +++- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c index e9f3fb5..87b446b 100644 --- a/drivers/mfd/ti_am335x_tscadc.c +++ b/drivers/mfd/ti_am335x_tscadc.c @@ -22,6 +22,8 @@ #include linux/regmap.h #include linux/mfd/core.h #include linux/pm_runtime.h +#include linux/of.h +#include linux/of_device.h #include linux/mfd/ti_am335x_tscadc.h #include linux/input/ti_am335x_tsc.h @@ -64,20 +66,31 @@ static int ti_tscadc_probe(struct platform_device *pdev) struct resource *res; struct clk *clk; struct mfd_tscadc_board *pdata = pdev-dev.platform_data; + struct device_node *node = pdev-dev.of_node; struct mfd_cell *cell; int err, ctrl; int clk_value, clock_rate; - int tsc_wires, adc_channels = 0, total_channels; + int tsc_wires = 0, adc_channels = 0, total_channels; - if (!pdata) { + if (!pdata !pdev-dev.of_node) { dev_err(pdev-dev, Could not find platform data\n); return -EINVAL; } - if (pdata-adc_init) - adc_channels = pdata-adc_init-adc_channels; + if (pdev-dev.platform_data) { + if (pdata-tsc_init) + tsc_wires = pdata-tsc_init-wires; + + if (pdata-adc_init) + adc_channels = pdata-adc_init-adc_channels; + } else { + node = of_find_node_by_name(pdev-dev.of_node, tsc); + of_property_read_u32(node, ti,wires, tsc_wires); + + node = of_find_node_by_name(pdev-dev.of_node, adc); + of_property_read_u32(node, ti,adc-channels, adc_channels); + } Since AM335x is DT only, why is there a platform data codepath and why is it the first branch it tries? And I guess the next question is related to the first: why doesn't it work when used with DT? When I copy over the nodes from the evm.dts to my board I get tsc tsc: Missing platform data in dmesg. This IP came up 1st on AM335x, but it is not platform dependent. The driver can be used on other platforms where-in DT is not supported. According to the maintainers platform data takes precedence over DT. Hence the order. I do not see Missing platform data error msg in the latest driver. I am not able to trace from where this got populated. What are the chances this driver will work when applied on top of 3.8-rcX? Has it even been tested with that? Has it been tested at all? This driver has been tested on top of v3.8-rc3 on a AM335x EVM. Regards, Rachna ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v4 0/8] MFD: ti_am335x_tscadc: DT support and TSC features addition
From: Patil, Rachna rac...@ti.com This patch set is a cumulative set of [1] and [2] sent earlier. Note that there are no code changes in either of the patch set, only rebased on top of Linus's v3.8-rc3 tag to make sure that all the patches apply without any conflicts. This patch set has been tested on AM335x EVM. [1] http://www.spinics.net/lists/linux-input/msg23060.html [2] http://www.spinics.net/lists/linux-input/msg23090.html Changes in v4: Subnodes and their properties documentation added. Non-standard properties prefixed with vendor name. Changes in v3: No code change. Changes in v2: Patch input: ti_am335x_tsc: Add variance filter from v1 has been dropped. Add MFD device DT node in AM335x EVM. Patil, Rachna (8): input: ti_am335x_tsc: Step enable bits made configurable input: ti_am335x_tsc: Order of TSC wires, made configurable input: touchscreen: ti_tsc: remove unwanted fifo flush MFD: ti_am335x_tscadc: add device tree binding information MFD: ti_am335x_tscadc: Add DT support input: ti_am335x_tsc: Add DT support IIO: ti_am335x_adc: Add DT support arm/dts: AM335x-evm: Add TSC/ADC MFD device support .../devicetree/bindings/mfd/ti_am335x_tscadc.txt | 52 arch/arm/boot/dts/am335x-evm.dts | 13 + arch/arm/boot/dts/am33xx.dtsi |8 + drivers/iio/adc/ti_am335x_adc.c| 26 +- drivers/input/touchscreen/ti_am335x_tsc.c | 266 +--- drivers/mfd/ti_am335x_tscadc.c | 28 ++- include/linux/input/ti_am335x_tsc.h| 12 + include/linux/mfd/ti_am335x_tscadc.h | 11 +- 8 files changed, 364 insertions(+), 52 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/ti_am335x_tscadc.txt -- 1.7.9.5 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v4 1/8] input: ti_am335x_tsc: Step enable bits made configurable
From: Patil, Rachna rac...@ti.com Current code has hard coded value written to step enable bits. Now the bits are updated based on how many steps are needed to be configured got from platform data. The user needs to take care not to exceed the count more than 16. While using ADC and TSC one should take care to set this parameter correctly. Signed-off-by: Patil, Rachna rac...@ti.com --- drivers/input/touchscreen/ti_am335x_tsc.c | 10 -- include/linux/mfd/ti_am335x_tscadc.h |1 - 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c index 51e7b87..da652e0 100644 --- a/drivers/input/touchscreen/ti_am335x_tsc.c +++ b/drivers/input/touchscreen/ti_am335x_tsc.c @@ -39,6 +39,7 @@ struct titsc { unsigned intirq; unsigned intwires; unsigned intx_plate_resistance; + unsigned intenable_bits; boolpen_down; int steps_to_configure; }; @@ -57,6 +58,7 @@ static void titsc_writel(struct titsc *tsc, unsigned int reg, static void titsc_step_config(struct titsc *ts_dev) { unsigned intconfig; + unsigned intstepenable = 0; int i, total_steps; /* Configure the Step registers */ @@ -128,7 +130,11 @@ static void titsc_step_config(struct titsc *ts_dev) titsc_writel(ts_dev, REG_STEPDELAY(total_steps + 2), STEPCONFIG_OPENDLY); - titsc_writel(ts_dev, REG_SE, STPENB_STEPENB_TC); + for (i = 0; i = (total_steps + 2); i++) + stepenable |= 1 i; + ts_dev-enable_bits = stepenable; + + titsc_writel(ts_dev, REG_SE, ts_dev-enable_bits); } static void titsc_read_coordinates(struct titsc *ts_dev, @@ -250,7 +256,7 @@ static irqreturn_t titsc_irq(int irq, void *dev) titsc_writel(ts_dev, REG_IRQSTATUS, irqclr); - titsc_writel(ts_dev, REG_SE, STPENB_STEPENB_TC); + titsc_writel(ts_dev, REG_SE, ts_dev-enable_bits); return IRQ_HANDLED; } diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h index c79ad5d..23e4f33 100644 --- a/include/linux/mfd/ti_am335x_tscadc.h +++ b/include/linux/mfd/ti_am335x_tscadc.h @@ -47,7 +47,6 @@ #define STEPENB_MASK (0x1 0) #define STEPENB(val) ((val) 0) #define STPENB_STEPENB STEPENB(0x1) -#define STPENB_STEPENB_TC STEPENB(0x1FFF) /* IRQ enable */ #define IRQENB_HW_PEN BIT(0) -- 1.7.9.5 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v4 2/8] input: ti_am335x_tsc: Order of TSC wires, made configurable
From: Patil, Rachna rac...@ti.com The current driver expected touchscreen input wires(XP,XN,YP,YN) to be connected in a particular order. Making changes to accept this as platform data. Signed-off-by: Patil, Rachna rac...@ti.com --- drivers/input/touchscreen/ti_am335x_tsc.c | 156 ++--- include/linux/input/ti_am335x_tsc.h | 12 +++ include/linux/mfd/ti_am335x_tscadc.h | 10 +- 3 files changed, 159 insertions(+), 19 deletions(-) diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c index da652e0..0c460f9 100644 --- a/drivers/input/touchscreen/ti_am335x_tsc.c +++ b/drivers/input/touchscreen/ti_am335x_tsc.c @@ -33,6 +33,17 @@ #define SEQ_SETTLE 275 #define MAX_12BIT ((1 12) - 1) +/* + * Refer to function regbit_map() to + * map the values in the matrix. + */ +static int config[4][4] = { + {1, 0, 1, 0}, + {2, 3, 2, 3}, + {4, 5, 4, 5}, + {0, 6, 0, 6} +}; + struct titsc { struct input_dev*input; struct ti_tscadc_dev*mfd_tscadc; @@ -42,6 +53,9 @@ struct titsc { unsigned intenable_bits; boolpen_down; int steps_to_configure; + int config_inp[20]; + int bit_xp, bit_xn, bit_yp, bit_yn; + int inp_xp, inp_xn, inp_yp, inp_yn; }; static unsigned int titsc_readl(struct titsc *ts, unsigned int reg) @@ -55,6 +69,107 @@ static void titsc_writel(struct titsc *tsc, unsigned int reg, writel(val, tsc-mfd_tscadc-tscadc_base + reg); } +/* + * Each of the analog lines are mapped + * with one or two register bits, + * which can be either pulled high/low + * depending on the value to be read. + */ +static int regbit_map(int val) +{ + int map_bits = 0; + + switch (val) { + case 1: + map_bits = XPP; + break; + case 2: + map_bits = XNP; + break; + case 3: + map_bits = XNN; + break; + case 4: + map_bits = YPP; + break; + case 5: + map_bits = YPN; + break; + case 6: + map_bits = YNN; + break; + } + + return map_bits; +} + +static int titsc_config_wires(struct titsc *ts_dev) +{ + int analog_line[10], wire_order[10]; + int i, temp_bits, err; + + for (i = 0; i 4; i++) { + /* +* Get the order in which TSC wires are attached +* w.r.t. each of the analog input lines on the EVM. +*/ + analog_line[i] = ts_dev-config_inp[i] 0xF0; + analog_line[i] = analog_line[i] 4; + + wire_order[i] = ts_dev-config_inp[i] 0x0F; + } + + for (i = 0; i 4; i++) { + switch (wire_order[i]) { + case 0: + temp_bits = config[analog_line[i]][0]; + if (temp_bits == 0) { + err = -EINVAL; + goto ret; + } else { + ts_dev-bit_xp = regbit_map(temp_bits); + ts_dev-inp_xp = analog_line[i]; + break; + } + case 1: + temp_bits = config[analog_line[i]][1]; + if (temp_bits == 0) { + err = -EINVAL; + goto ret; + } else { + ts_dev-bit_xn = regbit_map(temp_bits); + ts_dev-inp_xn = analog_line[i]; + break; + } + case 2: + temp_bits = config[analog_line[i]][2]; + if (temp_bits == 0) { + err = -EINVAL; + goto ret; + } else { + ts_dev-bit_yp = regbit_map(temp_bits); + ts_dev-inp_yp = analog_line[i]; + break; + } + case 3: + temp_bits = config[analog_line[i]][3]; + if (temp_bits == 0) { + err = -EINVAL; + goto ret; + } else { + ts_dev-bit_yn = regbit_map(temp_bits); + ts_dev-inp_yn = analog_line[i]; + break; + } + } + } + + return 0; + +ret: + return
[PATCH v4 4/8] MFD: ti_am335x_tscadc: add device tree binding information
From: Patil, Rachna rac...@ti.com Signed-off-by: Patil, Rachna rac...@ti.com --- Changes in v4: Subnodes and their properties documentation added. Non-standard properties prefixed with vendor name. .../devicetree/bindings/mfd/ti_am335x_tscadc.txt | 52 1 file changed, 52 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/ti_am335x_tscadc.txt diff --git a/Documentation/devicetree/bindings/mfd/ti_am335x_tscadc.txt b/Documentation/devicetree/bindings/mfd/ti_am335x_tscadc.txt new file mode 100644 index 000..0100771 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/ti_am335x_tscadc.txt @@ -0,0 +1,52 @@ +Texas Instruments - TSC / ADC multi-functional device + +ti_tscadc is a multi-function device with touchscreen and ADC on chip. +This document describes the binding for mfd device. + +Required properties: +- compatible: ti,ti-tscadc +- reg: Specifies the address of MFD block +- interrupts: IRQ line connected to the main SoC +- interrupt-parent: The parent interrupt controller + +Optional properties: +- ti,hwmods: Hardware information related to TSC/ADC MFD device + +Sub-nodes: +Device Description +-- --- +tscTouchscreen +adcAnalog to digital converter + +Sub-node device required properties: +tsc: +- ti,wires: 4/5/8 wire touchscreen support on the platform. +- ti,x-plate-resistance: X plate resistance. +- ti,steps-to-configure: A step is configured to read a single co-ordinate value, + can be applied more number of times for better results. +- ti,wire-config: Order for connecting wires on touchscreen. + +adc: +- ti,adc-channels: Number of ADC channels used. + +Example: + + tscadc: tscadc@44e0d000 { + compatible = ti,ti-tscadc; + reg = 0x44e0d000 0x1000; + + interrupt-parent = intc; + interrupts = 16; + ti,hwmods = adc_tsc; + + tsc { + ti,wires = 4; + ti,x-plate-resistance = 200; + ti,steps-to-configure = 5; + ti,wire-config = 0x00 0x11 0x22 0x33; + }; + + adc { + ti,adc-channels = 4; + }; + }; -- 1.7.9.5 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v4 3/8] input: touchscreen: ti_tsc: remove unwanted fifo flush
From: Patil, Rachna rac...@ti.com When touchscreen and ADC are used together, this unwanted fifo flush leads to loss of ADC data. Signed-off-by: Patil, Rachna rac...@ti.com --- drivers/input/touchscreen/ti_am335x_tsc.c | 10 -- 1 file changed, 10 deletions(-) diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c index 0c460f9..064d2b2 100644 --- a/drivers/input/touchscreen/ti_am335x_tsc.c +++ b/drivers/input/touchscreen/ti_am335x_tsc.c @@ -308,8 +308,6 @@ static irqreturn_t titsc_irq(int irq, void *dev) unsigned int x = 0, y = 0; unsigned int z1, z2, z; unsigned int fsm; - unsigned int fifo1count, fifo0count; - int i; status = titsc_readl(ts_dev, REG_IRQSTATUS); if (status IRQENB_FIFO0THRES) { @@ -318,14 +316,6 @@ static irqreturn_t titsc_irq(int irq, void *dev) z1 = titsc_readl(ts_dev, REG_FIFO0) 0xfff; z2 = titsc_readl(ts_dev, REG_FIFO1) 0xfff; - fifo1count = titsc_readl(ts_dev, REG_FIFO1CNT); - for (i = 0; i fifo1count; i++) - titsc_readl(ts_dev, REG_FIFO1); - - fifo0count = titsc_readl(ts_dev, REG_FIFO0CNT); - for (i = 0; i fifo0count; i++) - titsc_readl(ts_dev, REG_FIFO0); - if (ts_dev-pen_down z1 != 0 z2 != 0) { /* * Calculate pressure using formula -- 1.7.9.5 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v4 6/8] input: ti_am335x_tsc: Add DT support
From: Patil, Rachna rac...@ti.com Add DT support for client touchscreen driver Signed-off-by: Patil, Rachna rac...@ti.com --- Changes in v4: Non-standard properties prefixed with vendor name. drivers/input/touchscreen/ti_am335x_tsc.c | 94 + 1 file changed, 81 insertions(+), 13 deletions(-) diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c index 064d2b2..6ff5a76 100644 --- a/drivers/input/touchscreen/ti_am335x_tsc.c +++ b/drivers/input/touchscreen/ti_am335x_tsc.c @@ -26,6 +26,8 @@ #include linux/io.h #include linux/input/ti_am335x_tsc.h #include linux/delay.h +#include linux/of.h +#include linux/of_device.h #include linux/mfd/ti_am335x_tscadc.h @@ -366,6 +368,74 @@ static irqreturn_t titsc_irq(int irq, void *dev) return IRQ_HANDLED; } +static int titsc_parse_dt(struct ti_tscadc_dev *tscadc_dev, + struct titsc *ts_dev) +{ + struct device_node *node = tscadc_dev-dev-of_node; + int err, i; + u32 val32, wires_conf[4]; + + if (!node) + return -EINVAL; + else { + node = of_find_node_by_name(node, tsc); + if (!node) + return -EINVAL; + else { + err = of_property_read_u32(node, ti,wires, val32); + if (err 0) + goto error_ret; + else + ts_dev-wires = val32; + + err = of_property_read_u32(node, + ti,x-plate-resistance, val32); + if (err 0) + goto error_ret; + else + ts_dev-x_plate_resistance = val32; + + err = of_property_read_u32(node, + ti,steps-to-configure, val32); + if (err 0) + goto error_ret; + else + ts_dev-steps_to_configure = val32; + + err = of_property_read_u32_array(node, ti,wire-config, + wires_conf, ARRAY_SIZE(wires_conf)); + if (err 0) + goto error_ret; + else { + for (i = 0; i ARRAY_SIZE(wires_conf); i++) + ts_dev-config_inp[i] = wires_conf[i]; + } + } + } + return 0; + +error_ret: + return err; +} + +static int titsc_parse_pdata(struct ti_tscadc_dev *tscadc_dev, + struct titsc *ts_dev) +{ + struct mfd_tscadc_board *pdata = tscadc_dev-dev-platform_data; + + if (!pdata) + return -EINVAL; + + ts_dev-wires = pdata-tsc_init-wires; + ts_dev-x_plate_resistance = + pdata-tsc_init-x_plate_resistance; + ts_dev-steps_to_configure = + pdata-tsc_init-steps_to_configure; + memcpy(ts_dev-config_inp, pdata-tsc_init-wire_config, + sizeof(pdata-tsc_init-wire_config)); + return 0; +} + /* * The functions for inserting/removing driver as a module. */ @@ -375,16 +445,8 @@ static int titsc_probe(struct platform_device *pdev) struct titsc *ts_dev; struct input_dev *input_dev; struct ti_tscadc_dev *tscadc_dev = pdev-dev.platform_data; - struct mfd_tscadc_board *pdata; int err; - pdata = tscadc_dev-dev-platform_data; - - if (!pdata) { - dev_err(pdev-dev, Could not find platform data\n); - return -EINVAL; - } - /* Allocate memory for device */ ts_dev = kzalloc(sizeof(struct titsc), GFP_KERNEL); input_dev = input_allocate_device(); @@ -398,11 +460,17 @@ static int titsc_probe(struct platform_device *pdev) ts_dev-mfd_tscadc = tscadc_dev; ts_dev-input = input_dev; ts_dev-irq = tscadc_dev-irq; - ts_dev-wires = pdata-tsc_init-wires; - ts_dev-x_plate_resistance = pdata-tsc_init-x_plate_resistance; - ts_dev-steps_to_configure = pdata-tsc_init-steps_to_configure; - memcpy(ts_dev-config_inp, pdata-tsc_init-wire_config, - sizeof(pdata-tsc_init-wire_config)); + + if (tscadc_dev-dev-platform_data) + err = titsc_parse_pdata(tscadc_dev, ts_dev); + else + err = titsc_parse_dt(tscadc_dev, ts_dev); + + if (err) { + dev_err(pdev-dev, Could not find platform data\n); + err = -EINVAL; + goto err_free_mem; + } err = request_irq(ts_dev-irq, titsc_irq, 0, pdev-dev.driver-name, ts_dev); -- 1.7.9.5
[PATCH v4 5/8] MFD: ti_am335x_tscadc: Add DT support
From: Patil, Rachna rac...@ti.com Make changes to add DT support in the MFD core driver. Signed-off-by: Patil, Rachna rac...@ti.com --- Changes in v4: Non-standard properties prefixed with vendor name. drivers/mfd/ti_am335x_tscadc.c | 28 +++- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c index e9f3fb5..87b446b 100644 --- a/drivers/mfd/ti_am335x_tscadc.c +++ b/drivers/mfd/ti_am335x_tscadc.c @@ -22,6 +22,8 @@ #include linux/regmap.h #include linux/mfd/core.h #include linux/pm_runtime.h +#include linux/of.h +#include linux/of_device.h #include linux/mfd/ti_am335x_tscadc.h #include linux/input/ti_am335x_tsc.h @@ -64,20 +66,31 @@ static int ti_tscadc_probe(struct platform_device *pdev) struct resource *res; struct clk *clk; struct mfd_tscadc_board *pdata = pdev-dev.platform_data; + struct device_node *node = pdev-dev.of_node; struct mfd_cell *cell; int err, ctrl; int clk_value, clock_rate; - int tsc_wires, adc_channels = 0, total_channels; + int tsc_wires = 0, adc_channels = 0, total_channels; - if (!pdata) { + if (!pdata !pdev-dev.of_node) { dev_err(pdev-dev, Could not find platform data\n); return -EINVAL; } - if (pdata-adc_init) - adc_channels = pdata-adc_init-adc_channels; + if (pdev-dev.platform_data) { + if (pdata-tsc_init) + tsc_wires = pdata-tsc_init-wires; + + if (pdata-adc_init) + adc_channels = pdata-adc_init-adc_channels; + } else { + node = of_find_node_by_name(pdev-dev.of_node, tsc); + of_property_read_u32(node, ti,wires, tsc_wires); + + node = of_find_node_by_name(pdev-dev.of_node, adc); + of_property_read_u32(node, ti,adc-channels, adc_channels); + } - tsc_wires = pdata-tsc_init-wires; total_channels = tsc_wires + adc_channels; if (total_channels 8) { @@ -256,11 +269,16 @@ static const struct dev_pm_ops tscadc_pm_ops = { #define TSCADC_PM_OPS NULL #endif +static const struct of_device_id ti_tscadc_dt_ids[] = { + { .compatible = ti,ti-tscadc, }, +}; + static struct platform_driver ti_tscadc_driver = { .driver = { .name = ti_tscadc, .owner = THIS_MODULE, .pm = TSCADC_PM_OPS, + .of_match_table = of_match_ptr(ti_tscadc_dt_ids), }, .probe = ti_tscadc_probe, .remove = ti_tscadc_remove, -- 1.7.9.5 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v4 7/8] IIO: ti_am335x_adc: Add DT support
From: Patil, Rachna rac...@ti.com Add DT support for client ADC driver. Signed-off-by: Patil, Rachna rac...@ti.com --- Changes in v4: Non-standard properties prefixed with vendor name. drivers/iio/adc/ti_am335x_adc.c | 26 ++ 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c index cd030e1..8e7b089 100644 --- a/drivers/iio/adc/ti_am335x_adc.c +++ b/drivers/iio/adc/ti_am335x_adc.c @@ -22,6 +22,8 @@ #include linux/platform_device.h #include linux/io.h #include linux/iio/iio.h +#include linux/of.h +#include linux/of_device.h #include linux/mfd/ti_am335x_tscadc.h #include linux/platform_data/ti_am335x_adc.h @@ -141,11 +143,12 @@ static int tiadc_probe(struct platform_device *pdev) struct iio_dev *indio_dev; struct tiadc_device *adc_dev; struct ti_tscadc_dev*tscadc_dev = pdev-dev.platform_data; - struct mfd_tscadc_board *pdata; + struct mfd_tscadc_board *pdata = tscadc_dev-dev-platform_data; + struct device_node *node = tscadc_dev-dev-of_node; int err; + u32 val32; - pdata = tscadc_dev-dev-platform_data; - if (!pdata || !pdata-adc_init) { + if (!pdata !node) { dev_err(pdev-dev, Could not find platform data\n); return -EINVAL; } @@ -159,7 +162,22 @@ static int tiadc_probe(struct platform_device *pdev) adc_dev = iio_priv(indio_dev); adc_dev-mfd_tscadc = tscadc_dev; - adc_dev-channels = pdata-adc_init-adc_channels; + + if (pdata) + adc_dev-channels = pdata-adc_init-adc_channels; + else { + node = of_find_node_by_name(node, adc); + if (!node) + return -EINVAL; + else { + err = of_property_read_u32(node, + ti,adc-channels, val32); + if (err 0) + goto err_free_device; + else + adc_dev-channels = val32; + } + } indio_dev-dev.parent = pdev-dev; indio_dev-name = dev_name(pdev-dev); -- 1.7.9.5 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v4 8/8] arm/dts: AM335x-evm: Add TSC/ADC MFD device support
From: Patil, Rachna rac...@ti.com Add support for core multifunctional device along with its clients touchscreen and ADC. Signed-off-by: Patil, Rachna rac...@ti.com --- Changes in v4: Non-standard properties prefixed with vendor name. arch/arm/boot/dts/am335x-evm.dts | 13 + arch/arm/boot/dts/am33xx.dtsi|8 2 files changed, 21 insertions(+) diff --git a/arch/arm/boot/dts/am335x-evm.dts b/arch/arm/boot/dts/am335x-evm.dts index d649644..bfd7928 100644 --- a/arch/arm/boot/dts/am335x-evm.dts +++ b/arch/arm/boot/dts/am335x-evm.dts @@ -244,3 +244,16 @@ cpsw_emac1 { phy_id = davinci_mdio, 1; }; + +tscadc { + tsc { + ti,wires = 4; + ti,x-plate-resistance = 200; + ti,steps-to-configure = 5; + ti,wire-config = 0x00 0x11 0x22 0x33; + }; + + adc { + ti,adc-channels = 4; + }; +}; diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi index c2f14e8..211ec42 100644 --- a/arch/arm/boot/dts/am33xx.dtsi +++ b/arch/arm/boot/dts/am33xx.dtsi @@ -385,5 +385,13 @@ mac-address = [ 00 00 00 00 00 00 ]; }; }; + + tscadc: tscadc@44e0d000 { + compatible = ti,ti-tscadc; + reg = 0x44e0d000 0x1000; + interrupt-parent = intc; + interrupts = 16; + ti,hwmods = adc_tsc; + }; }; }; -- 1.7.9.5 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v3 0/8] MFD: ti_am335x_tscadc: DT support and TSC features addition
From: Patil, Rachna rac...@ti.com This patch set is a cumulative set of [1] and [2] sent earlier. Note that there are no code changes in either of the patch set, only rebased on top of Linus's v3.8-rc3 tag to make sure that all the patches apply without any conflicts. This patch set has been tested on AM335x EVM. [1] http://www.spinics.net/lists/linux-input/msg23060.html [2] http://www.spinics.net/lists/linux-input/msg23090.html Changes in v3: No code change. Changes in v2: Patch input: ti_am335x_tsc: Add variance filter from v1 has been dropped. Add MFD device DT node in AM335x EVM. Patil, Rachna (8): input: ti_am335x_tsc: Step enable bits made configurable input: ti_am335x_tsc: Order of TSC wires, made configurable input: touchscreen: ti_tsc: remove unwanted fifo flush MFD: ti_am335x_tscadc: add device tree binding information MFD: ti_am335x_tscadc: Add DT support input: ti_am335x_tsc: Add DT support IIO: ti_am335x_adc: Add DT support arm/dts: AM335x-evm: Add TSC/ADC MFD device support .../devicetree/bindings/mfd/ti_am335x_tscadc.txt | 35 +++ arch/arm/boot/dts/am335x-evm.dts | 13 + arch/arm/boot/dts/am33xx.dtsi |8 + drivers/iio/adc/ti_am335x_adc.c| 26 +- drivers/input/touchscreen/ti_am335x_tsc.c | 266 +--- drivers/mfd/ti_am335x_tscadc.c | 28 ++- include/linux/input/ti_am335x_tsc.h| 12 + include/linux/mfd/ti_am335x_tscadc.h | 11 +- 8 files changed, 347 insertions(+), 52 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/ti_am335x_tscadc.txt -- 1.7.9.5 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v3 1/8] input: ti_am335x_tsc: Step enable bits made configurable
From: Patil, Rachna rac...@ti.com Current code has hard coded value written to step enable bits. Now the bits are updated based on how many steps are needed to be configured got from platform data. The user needs to take care not to exceed the count more than 16. While using ADC and TSC one should take care to set this parameter correctly. Signed-off-by: Patil, Rachna rac...@ti.com --- drivers/input/touchscreen/ti_am335x_tsc.c | 10 -- include/linux/mfd/ti_am335x_tscadc.h |1 - 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c index 51e7b87..da652e0 100644 --- a/drivers/input/touchscreen/ti_am335x_tsc.c +++ b/drivers/input/touchscreen/ti_am335x_tsc.c @@ -39,6 +39,7 @@ struct titsc { unsigned intirq; unsigned intwires; unsigned intx_plate_resistance; + unsigned intenable_bits; boolpen_down; int steps_to_configure; }; @@ -57,6 +58,7 @@ static void titsc_writel(struct titsc *tsc, unsigned int reg, static void titsc_step_config(struct titsc *ts_dev) { unsigned intconfig; + unsigned intstepenable = 0; int i, total_steps; /* Configure the Step registers */ @@ -128,7 +130,11 @@ static void titsc_step_config(struct titsc *ts_dev) titsc_writel(ts_dev, REG_STEPDELAY(total_steps + 2), STEPCONFIG_OPENDLY); - titsc_writel(ts_dev, REG_SE, STPENB_STEPENB_TC); + for (i = 0; i = (total_steps + 2); i++) + stepenable |= 1 i; + ts_dev-enable_bits = stepenable; + + titsc_writel(ts_dev, REG_SE, ts_dev-enable_bits); } static void titsc_read_coordinates(struct titsc *ts_dev, @@ -250,7 +256,7 @@ static irqreturn_t titsc_irq(int irq, void *dev) titsc_writel(ts_dev, REG_IRQSTATUS, irqclr); - titsc_writel(ts_dev, REG_SE, STPENB_STEPENB_TC); + titsc_writel(ts_dev, REG_SE, ts_dev-enable_bits); return IRQ_HANDLED; } diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h index c79ad5d..23e4f33 100644 --- a/include/linux/mfd/ti_am335x_tscadc.h +++ b/include/linux/mfd/ti_am335x_tscadc.h @@ -47,7 +47,6 @@ #define STEPENB_MASK (0x1 0) #define STEPENB(val) ((val) 0) #define STPENB_STEPENB STEPENB(0x1) -#define STPENB_STEPENB_TC STEPENB(0x1FFF) /* IRQ enable */ #define IRQENB_HW_PEN BIT(0) -- 1.7.9.5 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v3 2/8] input: ti_am335x_tsc: Order of TSC wires, made configurable
From: Patil, Rachna rac...@ti.com The current driver expected touchscreen input wires(XP,XN,YP,YN) to be connected in a particular order. Making changes to accept this as platform data. Signed-off-by: Patil, Rachna rac...@ti.com --- drivers/input/touchscreen/ti_am335x_tsc.c | 156 ++--- include/linux/input/ti_am335x_tsc.h | 12 +++ include/linux/mfd/ti_am335x_tscadc.h | 10 +- 3 files changed, 159 insertions(+), 19 deletions(-) diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c index da652e0..0c460f9 100644 --- a/drivers/input/touchscreen/ti_am335x_tsc.c +++ b/drivers/input/touchscreen/ti_am335x_tsc.c @@ -33,6 +33,17 @@ #define SEQ_SETTLE 275 #define MAX_12BIT ((1 12) - 1) +/* + * Refer to function regbit_map() to + * map the values in the matrix. + */ +static int config[4][4] = { + {1, 0, 1, 0}, + {2, 3, 2, 3}, + {4, 5, 4, 5}, + {0, 6, 0, 6} +}; + struct titsc { struct input_dev*input; struct ti_tscadc_dev*mfd_tscadc; @@ -42,6 +53,9 @@ struct titsc { unsigned intenable_bits; boolpen_down; int steps_to_configure; + int config_inp[20]; + int bit_xp, bit_xn, bit_yp, bit_yn; + int inp_xp, inp_xn, inp_yp, inp_yn; }; static unsigned int titsc_readl(struct titsc *ts, unsigned int reg) @@ -55,6 +69,107 @@ static void titsc_writel(struct titsc *tsc, unsigned int reg, writel(val, tsc-mfd_tscadc-tscadc_base + reg); } +/* + * Each of the analog lines are mapped + * with one or two register bits, + * which can be either pulled high/low + * depending on the value to be read. + */ +static int regbit_map(int val) +{ + int map_bits = 0; + + switch (val) { + case 1: + map_bits = XPP; + break; + case 2: + map_bits = XNP; + break; + case 3: + map_bits = XNN; + break; + case 4: + map_bits = YPP; + break; + case 5: + map_bits = YPN; + break; + case 6: + map_bits = YNN; + break; + } + + return map_bits; +} + +static int titsc_config_wires(struct titsc *ts_dev) +{ + int analog_line[10], wire_order[10]; + int i, temp_bits, err; + + for (i = 0; i 4; i++) { + /* +* Get the order in which TSC wires are attached +* w.r.t. each of the analog input lines on the EVM. +*/ + analog_line[i] = ts_dev-config_inp[i] 0xF0; + analog_line[i] = analog_line[i] 4; + + wire_order[i] = ts_dev-config_inp[i] 0x0F; + } + + for (i = 0; i 4; i++) { + switch (wire_order[i]) { + case 0: + temp_bits = config[analog_line[i]][0]; + if (temp_bits == 0) { + err = -EINVAL; + goto ret; + } else { + ts_dev-bit_xp = regbit_map(temp_bits); + ts_dev-inp_xp = analog_line[i]; + break; + } + case 1: + temp_bits = config[analog_line[i]][1]; + if (temp_bits == 0) { + err = -EINVAL; + goto ret; + } else { + ts_dev-bit_xn = regbit_map(temp_bits); + ts_dev-inp_xn = analog_line[i]; + break; + } + case 2: + temp_bits = config[analog_line[i]][2]; + if (temp_bits == 0) { + err = -EINVAL; + goto ret; + } else { + ts_dev-bit_yp = regbit_map(temp_bits); + ts_dev-inp_yp = analog_line[i]; + break; + } + case 3: + temp_bits = config[analog_line[i]][3]; + if (temp_bits == 0) { + err = -EINVAL; + goto ret; + } else { + ts_dev-bit_yn = regbit_map(temp_bits); + ts_dev-inp_yn = analog_line[i]; + break; + } + } + } + + return 0; + +ret: + return
[PATCH v3 3/8] input: touchscreen: ti_tsc: remove unwanted fifo flush
From: Patil, Rachna rac...@ti.com When touchscreen and ADC are used together, this unwanted fifo flush leads to loss of ADC data. Signed-off-by: Patil, Rachna rac...@ti.com --- drivers/input/touchscreen/ti_am335x_tsc.c | 10 -- 1 file changed, 10 deletions(-) diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c index 0c460f9..064d2b2 100644 --- a/drivers/input/touchscreen/ti_am335x_tsc.c +++ b/drivers/input/touchscreen/ti_am335x_tsc.c @@ -308,8 +308,6 @@ static irqreturn_t titsc_irq(int irq, void *dev) unsigned int x = 0, y = 0; unsigned int z1, z2, z; unsigned int fsm; - unsigned int fifo1count, fifo0count; - int i; status = titsc_readl(ts_dev, REG_IRQSTATUS); if (status IRQENB_FIFO0THRES) { @@ -318,14 +316,6 @@ static irqreturn_t titsc_irq(int irq, void *dev) z1 = titsc_readl(ts_dev, REG_FIFO0) 0xfff; z2 = titsc_readl(ts_dev, REG_FIFO1) 0xfff; - fifo1count = titsc_readl(ts_dev, REG_FIFO1CNT); - for (i = 0; i fifo1count; i++) - titsc_readl(ts_dev, REG_FIFO1); - - fifo0count = titsc_readl(ts_dev, REG_FIFO0CNT); - for (i = 0; i fifo0count; i++) - titsc_readl(ts_dev, REG_FIFO0); - if (ts_dev-pen_down z1 != 0 z2 != 0) { /* * Calculate pressure using formula -- 1.7.9.5 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v3 4/8] MFD: ti_am335x_tscadc: add device tree binding information
From: Patil, Rachna rac...@ti.com Signed-off-by: Patil, Rachna rac...@ti.com --- .../devicetree/bindings/mfd/ti_am335x_tscadc.txt | 35 1 file changed, 35 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/ti_am335x_tscadc.txt diff --git a/Documentation/devicetree/bindings/mfd/ti_am335x_tscadc.txt b/Documentation/devicetree/bindings/mfd/ti_am335x_tscadc.txt new file mode 100644 index 000..c13c492 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/ti_am335x_tscadc.txt @@ -0,0 +1,35 @@ +Texas Instruments - TSC / ADC multi-functional device + +ti_tscadc is a multi-function device with touchscreen and ADC on chip. +This document describes the binding for mfd device. + +Required properties: +- compatible: ti,ti-tscadc +- reg: Specifies the address of MFD block +- interrupts: IRQ line connected to the main SoC +- interrupt-parent: The parent interrupt controller + +Optional properties: +- ti,hwmods: Hardware information related to TSC/ADC MFD device + +Example: + + tscadc: tscadc@44e0d000 { + compatible = ti,ti-tscadc; + reg = 0x44e0d000 0x1000; + + interrupt-parent = intc; + interrupts = 16; + ti,hwmods = adc_tsc; + + tsc { + wires = 4; + x-plate-resistance = 200; + steps-to-configure = 5; + wire-config = 0x00 0x11 0x22 0x33; + }; + + adc { + adc-channels = 4; + }; + }; -- 1.7.9.5 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v3 5/8] MFD: ti_am335x_tscadc: Add DT support
From: Patil, Rachna rac...@ti.com Make changes to add DT support in the MFD core driver. Signed-off-by: Patil, Rachna rac...@ti.com --- drivers/mfd/ti_am335x_tscadc.c | 28 +++- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c index e9f3fb5..4c01056 100644 --- a/drivers/mfd/ti_am335x_tscadc.c +++ b/drivers/mfd/ti_am335x_tscadc.c @@ -22,6 +22,8 @@ #include linux/regmap.h #include linux/mfd/core.h #include linux/pm_runtime.h +#include linux/of.h +#include linux/of_device.h #include linux/mfd/ti_am335x_tscadc.h #include linux/input/ti_am335x_tsc.h @@ -64,20 +66,31 @@ static int ti_tscadc_probe(struct platform_device *pdev) struct resource *res; struct clk *clk; struct mfd_tscadc_board *pdata = pdev-dev.platform_data; + struct device_node *node = pdev-dev.of_node; struct mfd_cell *cell; int err, ctrl; int clk_value, clock_rate; - int tsc_wires, adc_channels = 0, total_channels; + int tsc_wires = 0, adc_channels = 0, total_channels; - if (!pdata) { + if (!pdata !pdev-dev.of_node) { dev_err(pdev-dev, Could not find platform data\n); return -EINVAL; } - if (pdata-adc_init) - adc_channels = pdata-adc_init-adc_channels; + if (pdev-dev.platform_data) { + if (pdata-tsc_init) + tsc_wires = pdata-tsc_init-wires; + + if (pdata-adc_init) + adc_channels = pdata-adc_init-adc_channels; + } else { + node = of_find_node_by_name(pdev-dev.of_node, tsc); + of_property_read_u32(node, wires, tsc_wires); + + node = of_find_node_by_name(pdev-dev.of_node, adc); + of_property_read_u32(node, adc-channels, adc_channels); + } - tsc_wires = pdata-tsc_init-wires; total_channels = tsc_wires + adc_channels; if (total_channels 8) { @@ -256,11 +269,16 @@ static const struct dev_pm_ops tscadc_pm_ops = { #define TSCADC_PM_OPS NULL #endif +static const struct of_device_id ti_tscadc_dt_ids[] = { + { .compatible = ti,ti-tscadc, }, +}; + static struct platform_driver ti_tscadc_driver = { .driver = { .name = ti_tscadc, .owner = THIS_MODULE, .pm = TSCADC_PM_OPS, + .of_match_table = of_match_ptr(ti_tscadc_dt_ids), }, .probe = ti_tscadc_probe, .remove = ti_tscadc_remove, -- 1.7.9.5 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v3 6/8] input: ti_am335x_tsc: Add DT support
From: Patil, Rachna rac...@ti.com Add DT support for client touchscreen driver Signed-off-by: Patil, Rachna rac...@ti.com --- drivers/input/touchscreen/ti_am335x_tsc.c | 94 + 1 file changed, 81 insertions(+), 13 deletions(-) diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c index 064d2b2..249dac5 100644 --- a/drivers/input/touchscreen/ti_am335x_tsc.c +++ b/drivers/input/touchscreen/ti_am335x_tsc.c @@ -26,6 +26,8 @@ #include linux/io.h #include linux/input/ti_am335x_tsc.h #include linux/delay.h +#include linux/of.h +#include linux/of_device.h #include linux/mfd/ti_am335x_tscadc.h @@ -366,6 +368,74 @@ static irqreturn_t titsc_irq(int irq, void *dev) return IRQ_HANDLED; } +static int titsc_parse_dt(struct ti_tscadc_dev *tscadc_dev, + struct titsc *ts_dev) +{ + struct device_node *node = tscadc_dev-dev-of_node; + int err, i; + u32 val32, wires_conf[4]; + + if (!node) + return -EINVAL; + else { + node = of_find_node_by_name(node, tsc); + if (!node) + return -EINVAL; + else { + err = of_property_read_u32(node, wires, val32); + if (err 0) + goto error_ret; + else + ts_dev-wires = val32; + + err = of_property_read_u32(node, + x-plate-resistance, val32); + if (err 0) + goto error_ret; + else + ts_dev-x_plate_resistance = val32; + + err = of_property_read_u32(node, + steps-to-configure, val32); + if (err 0) + goto error_ret; + else + ts_dev-steps_to_configure = val32; + + err = of_property_read_u32_array(node, wire-config, + wires_conf, ARRAY_SIZE(wires_conf)); + if (err 0) + goto error_ret; + else { + for (i = 0; i ARRAY_SIZE(wires_conf); i++) + ts_dev-config_inp[i] = wires_conf[i]; + } + } + } + return 0; + +error_ret: + return err; +} + +static int titsc_parse_pdata(struct ti_tscadc_dev *tscadc_dev, + struct titsc *ts_dev) +{ + struct mfd_tscadc_board *pdata = tscadc_dev-dev-platform_data; + + if (!pdata) + return -EINVAL; + + ts_dev-wires = pdata-tsc_init-wires; + ts_dev-x_plate_resistance = + pdata-tsc_init-x_plate_resistance; + ts_dev-steps_to_configure = + pdata-tsc_init-steps_to_configure; + memcpy(ts_dev-config_inp, pdata-tsc_init-wire_config, + sizeof(pdata-tsc_init-wire_config)); + return 0; +} + /* * The functions for inserting/removing driver as a module. */ @@ -375,16 +445,8 @@ static int titsc_probe(struct platform_device *pdev) struct titsc *ts_dev; struct input_dev *input_dev; struct ti_tscadc_dev *tscadc_dev = pdev-dev.platform_data; - struct mfd_tscadc_board *pdata; int err; - pdata = tscadc_dev-dev-platform_data; - - if (!pdata) { - dev_err(pdev-dev, Could not find platform data\n); - return -EINVAL; - } - /* Allocate memory for device */ ts_dev = kzalloc(sizeof(struct titsc), GFP_KERNEL); input_dev = input_allocate_device(); @@ -398,11 +460,17 @@ static int titsc_probe(struct platform_device *pdev) ts_dev-mfd_tscadc = tscadc_dev; ts_dev-input = input_dev; ts_dev-irq = tscadc_dev-irq; - ts_dev-wires = pdata-tsc_init-wires; - ts_dev-x_plate_resistance = pdata-tsc_init-x_plate_resistance; - ts_dev-steps_to_configure = pdata-tsc_init-steps_to_configure; - memcpy(ts_dev-config_inp, pdata-tsc_init-wire_config, - sizeof(pdata-tsc_init-wire_config)); + + if (tscadc_dev-dev-platform_data) + err = titsc_parse_pdata(tscadc_dev, ts_dev); + else + err = titsc_parse_dt(tscadc_dev, ts_dev); + + if (err) { + dev_err(pdev-dev, Could not find platform data\n); + err = -EINVAL; + goto err_free_mem; + } err = request_irq(ts_dev-irq, titsc_irq, 0, pdev-dev.driver-name, ts_dev); -- 1.7.9.5 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https
[PATCH v3 7/8] IIO: ti_am335x_adc: Add DT support
From: Patil, Rachna rac...@ti.com Add DT support for client ADC driver. Signed-off-by: Patil, Rachna rac...@ti.com --- drivers/iio/adc/ti_am335x_adc.c | 26 ++ 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c index cd030e1..81ca8e5 100644 --- a/drivers/iio/adc/ti_am335x_adc.c +++ b/drivers/iio/adc/ti_am335x_adc.c @@ -22,6 +22,8 @@ #include linux/platform_device.h #include linux/io.h #include linux/iio/iio.h +#include linux/of.h +#include linux/of_device.h #include linux/mfd/ti_am335x_tscadc.h #include linux/platform_data/ti_am335x_adc.h @@ -141,11 +143,12 @@ static int tiadc_probe(struct platform_device *pdev) struct iio_dev *indio_dev; struct tiadc_device *adc_dev; struct ti_tscadc_dev*tscadc_dev = pdev-dev.platform_data; - struct mfd_tscadc_board *pdata; + struct mfd_tscadc_board *pdata = tscadc_dev-dev-platform_data; + struct device_node *node = tscadc_dev-dev-of_node; int err; + u32 val32; - pdata = tscadc_dev-dev-platform_data; - if (!pdata || !pdata-adc_init) { + if (!pdata !node) { dev_err(pdev-dev, Could not find platform data\n); return -EINVAL; } @@ -159,7 +162,22 @@ static int tiadc_probe(struct platform_device *pdev) adc_dev = iio_priv(indio_dev); adc_dev-mfd_tscadc = tscadc_dev; - adc_dev-channels = pdata-adc_init-adc_channels; + + if (pdata) + adc_dev-channels = pdata-adc_init-adc_channels; + else { + node = of_find_node_by_name(node, adc); + if (!node) + return -EINVAL; + else { + err = of_property_read_u32(node, + adc-channels, val32); + if (err 0) + goto err_free_device; + else + adc_dev-channels = val32; + } + } indio_dev-dev.parent = pdev-dev; indio_dev-name = dev_name(pdev-dev); -- 1.7.9.5 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH v3 8/8] arm/dts: AM335x-evm: Add TSC/ADC MFD device support
From: Patil, Rachna rac...@ti.com Add support for core multifunctional device along with its clients touchscreen and ADC. Signed-off-by: Patil, Rachna rac...@ti.com --- arch/arm/boot/dts/am335x-evm.dts | 13 + arch/arm/boot/dts/am33xx.dtsi|8 2 files changed, 21 insertions(+) diff --git a/arch/arm/boot/dts/am335x-evm.dts b/arch/arm/boot/dts/am335x-evm.dts index d649644..ea28476 100644 --- a/arch/arm/boot/dts/am335x-evm.dts +++ b/arch/arm/boot/dts/am335x-evm.dts @@ -244,3 +244,16 @@ cpsw_emac1 { phy_id = davinci_mdio, 1; }; + +tscadc { + tsc { + wires = 4; + x-plate-resistance = 200; + steps-to-configure = 5; + wire-config = 0x00 0x11 0x22 0x33; + }; + + adc { + adc-channels = 4; + }; +}; diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi index c2f14e8..211ec42 100644 --- a/arch/arm/boot/dts/am33xx.dtsi +++ b/arch/arm/boot/dts/am33xx.dtsi @@ -385,5 +385,13 @@ mac-address = [ 00 00 00 00 00 00 ]; }; }; + + tscadc: tscadc@44e0d000 { + compatible = ti,ti-tscadc; + reg = 0x44e0d000 0x1000; + interrupt-parent = intc; + interrupts = 16; + ti,hwmods = adc_tsc; + }; }; }; -- 1.7.9.5 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
RE: [PATCH RESEND 3/7] input: ti_am335x_tsc: Add variance filter
On Thu, Nov 22, 2012 at 00:03:50, Dmitry Torokhov wrote: Hi Rachna, Hi Dmitry, On Wed, Nov 07, 2012 at 12:22:00PM +0530, Patil, Rachna wrote: Only fine tuning variance parameter present in tslib utility does not help in removing all the ADC noise. This logic of filtering is necessary to get this touchscreen to work finely. No, if filtering in tslib is not adequate please fix tslib so that your work is usable for other devices as well. For now I will drop this patch from the patch set and send across the next version of the set with review comments on remaining patches addressed. I will take up tslib separately. Regards, Rachna Thanks. -- Dmitry ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
RE: [PATCH RESEND 6/7] input: ti_am335x_tsc: Add DT support
Hi Dmitry, On Thu, Nov 22, 2012 at 00:02:23, Dmitry Torokhov wrote: Hi Rachna, On Wed, Nov 07, 2012 at 12:22:03PM +0530, Patil, Rachna wrote: Add DT support for client touchscreen driver Signed-off-by: Patil, Rachna rac...@ti.com --- drivers/input/touchscreen/ti_am335x_tsc.c | 60 - 1 files changed, 50 insertions(+), 10 deletions(-) diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c index 7a26810..c063cf6 100644 --- a/drivers/input/touchscreen/ti_am335x_tsc.c +++ b/drivers/input/touchscreen/ti_am335x_tsc.c @@ -26,6 +26,8 @@ #include linux/io.h #include linux/input/ti_am335x_tsc.h #include linux/delay.h +#include linux/of.h +#include linux/of_device.h #include linux/mfd/ti_am335x_tscadc.h @@ -398,12 +400,18 @@ static int __devinit titsc_probe(struct platform_device *pdev) struct titsc *ts_dev; struct input_dev *input_dev; struct ti_tscadc_dev *tscadc_dev = pdev-dev.platform_data; - struct mfd_tscadc_board *pdata; - int err; - - pdata = tscadc_dev-dev-platform_data; - - if (!pdata) { + int err, i; + struct mfd_tscadc_board *pdata = NULL; + struct device_node *node = NULL; + u32 val32, wires_conf[4]; + + if (tscadc_dev-dev-of_node) { + node = tscadc_dev-dev-of_node; + node = of_find_node_by_name(node, tsc); + } else + pdata = tscadc_dev-dev-platform_data; + + if (!pdata !node) { dev_err(pdev-dev, Could not find platform data\n); return -EINVAL; } @@ -421,11 +429,43 @@ static int __devinit titsc_probe(struct platform_device *pdev) ts_dev-mfd_tscadc = tscadc_dev; ts_dev-input = input_dev; ts_dev-irq = tscadc_dev-irq; - ts_dev-wires = pdata-tsc_init-wires; - ts_dev-x_plate_resistance = pdata-tsc_init-x_plate_resistance; - ts_dev-steps_to_configure = pdata-tsc_init-steps_to_configure; - memcpy(ts_dev-config_inp, pdata-tsc_init-wire_config, + + if (node) { + err = of_property_read_u32(node, wires, val32); + if (err 0) + goto err_free_mem; + else + ts_dev-wires = val32; + + err = of_property_read_u32(node, x-plate-resistance, val32); + if (err 0) + goto err_free_mem; + else + ts_dev-x_plate_resistance = val32; + + err = of_property_read_u32(node, steps-to-configure, val32); + if (err 0) + goto err_free_mem; + else + ts_dev-steps_to_configure = val32; + + err = of_property_read_u32_array(node, wire-config, + wires_conf, ARRAY_SIZE(wires_conf)); + if (err 0) + goto err_free_mem; + else { + for (i = 0; i ARRAY_SIZE(wires_conf); i++) + ts_dev-config_inp[i] = wires_conf[i]; + } + } else { + ts_dev-wires = pdata-tsc_init-wires; + ts_dev-x_plate_resistance = + pdata-tsc_init-x_plate_resistance; + ts_dev-steps_to_configure = + pdata-tsc_init-steps_to_configure; + memcpy(ts_dev-config_inp, pdata-tsc_init-wire_config, sizeof(pdata-tsc_init-wire_config)); I believe if platform data is supplied it should take precedence over DT data so that parameters can be adjusted if really needed. Ok. I will fix this is in v2. Regards, Rachna ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
RE: [PATCH RESEND 0/7] MFD: ti_am335x_tscadc: DT support and TSC features addition
Hi, This is just a gentle reminder of the patch set I had posted earlier viz. [PATCH RESEND 0/7] MFD: ti_am335x_tscadc: DT support and TSC features addition Can this patch set be pulled in if there are no review comments. This patch set does not break anything existing, it just adds new features and DT support for the MFD core and its clients. Regards, Rachna On Wed, Nov 07, 2012 at 12:21:57, Patil, Rachna wrote: This patch set is a cumulative set of [1] and [2] sent earlier. Note that there are no code changes in either of the patch set, only rebased on top of MFD-next to make sure that all the patches apply without any conflicts. This patch set has been tested on AM335x EVM and is based on top of [3]. [1] http://www.spinics.net/lists/linux-input/msg23060.html [2] http://www.spinics.net/lists/linux-input/msg23090.html [3] https://lkml.org/lkml/2012/11/6/67 Patil, Rachna (7): input: ti_am335x_tsc: Step enable bits made configurable input: ti_am335x_tsc: Order of TSC wires, made configurable input: ti_am335x_tsc: Add variance filter MFD: ti_am335x_tscadc: add device tree binding information MFD: ti_am335x_tscadc: Add DT support input: ti_am335x_tsc: Add DT support IIO: ti_am335x_adc: Add DT support .../devicetree/bindings/mfd/ti_am335x_tscadc.txt | 35 +++ drivers/iio/adc/ti_am335x_adc.c| 24 ++- drivers/input/touchscreen/ti_am335x_tsc.c | 239 +--- drivers/mfd/ti_am335x_tscadc.c | 28 ++- include/linux/input/ti_am335x_tsc.h| 12 + include/linux/mfd/ti_am335x_tscadc.h | 11 +- 6 files changed, 308 insertions(+), 41 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/ti_am335x_tscadc.txt ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH RESEND 1/7] input: ti_am335x_tsc: Step enable bits made configurable
Current code has hard coded value written to step enable bits. Now the bits are updated based on how many steps are needed to be configured got from platform data. The user needs to take care not to exceed the count more than 16. While using ADC and TSC one should take care to set this parameter correctly. Signed-off-by: Patil, Rachna rac...@ti.com --- drivers/input/touchscreen/ti_am335x_tsc.c | 10 -- include/linux/mfd/ti_am335x_tscadc.h |1 - 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c index 7a18a8a..4369224 100644 --- a/drivers/input/touchscreen/ti_am335x_tsc.c +++ b/drivers/input/touchscreen/ti_am335x_tsc.c @@ -39,6 +39,7 @@ struct titsc { unsigned intirq; unsigned intwires; unsigned intx_plate_resistance; + unsigned intenable_bits; boolpen_down; int steps_to_configure; }; @@ -57,6 +58,7 @@ static void titsc_writel(struct titsc *tsc, unsigned int reg, static void titsc_step_config(struct titsc *ts_dev) { unsigned intconfig; + unsigned intstepenable = 0; int i, total_steps; /* Configure the Step registers */ @@ -128,7 +130,11 @@ static void titsc_step_config(struct titsc *ts_dev) titsc_writel(ts_dev, REG_STEPDELAY(total_steps + 2), STEPCONFIG_OPENDLY); - titsc_writel(ts_dev, REG_SE, STPENB_STEPENB_TC); + for (i = 0; i = (total_steps + 2); i++) + stepenable |= 1 i; + ts_dev-enable_bits = stepenable; + + titsc_writel(ts_dev, REG_SE, ts_dev-enable_bits); } static void titsc_read_coordinates(struct titsc *ts_dev, @@ -250,7 +256,7 @@ static irqreturn_t titsc_irq(int irq, void *dev) titsc_writel(ts_dev, REG_IRQSTATUS, irqclr); - titsc_writel(ts_dev, REG_SE, STPENB_STEPENB_TC); + titsc_writel(ts_dev, REG_SE, ts_dev-enable_bits); return IRQ_HANDLED; } diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h index c79ad5d..23e4f33 100644 --- a/include/linux/mfd/ti_am335x_tscadc.h +++ b/include/linux/mfd/ti_am335x_tscadc.h @@ -47,7 +47,6 @@ #define STEPENB_MASK (0x1 0) #define STEPENB(val) ((val) 0) #define STPENB_STEPENB STEPENB(0x1) -#define STPENB_STEPENB_TC STEPENB(0x1FFF) /* IRQ enable */ #define IRQENB_HW_PEN BIT(0) -- 1.7.0.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH RESEND 4/7] MFD: ti_am335x_tscadc: add device tree binding information
Signed-off-by: Patil, Rachna rac...@ti.com --- .../devicetree/bindings/mfd/ti_am335x_tscadc.txt | 35 1 files changed, 35 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/ti_am335x_tscadc.txt diff --git a/Documentation/devicetree/bindings/mfd/ti_am335x_tscadc.txt b/Documentation/devicetree/bindings/mfd/ti_am335x_tscadc.txt new file mode 100644 index 000..c13c492 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/ti_am335x_tscadc.txt @@ -0,0 +1,35 @@ +Texas Instruments - TSC / ADC multi-functional device + +ti_tscadc is a multi-function device with touchscreen and ADC on chip. +This document describes the binding for mfd device. + +Required properties: +- compatible: ti,ti-tscadc +- reg: Specifies the address of MFD block +- interrupts: IRQ line connected to the main SoC +- interrupt-parent: The parent interrupt controller + +Optional properties: +- ti,hwmods: Hardware information related to TSC/ADC MFD device + +Example: + + tscadc: tscadc@44e0d000 { + compatible = ti,ti-tscadc; + reg = 0x44e0d000 0x1000; + + interrupt-parent = intc; + interrupts = 16; + ti,hwmods = adc_tsc; + + tsc { + wires = 4; + x-plate-resistance = 200; + steps-to-configure = 5; + wire-config = 0x00 0x11 0x22 0x33; + }; + + adc { + adc-channels = 4; + }; + }; -- 1.7.0.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH RESEND 0/7] MFD: ti_am335x_tscadc: DT support and TSC features addition
This patch set is a cumulative set of [1] and [2] sent earlier. Note that there are no code changes in either of the patch set, only rebased on top of MFD-next to make sure that all the patches apply without any conflicts. This patch set has been tested on AM335x EVM and is based on top of [3]. [1] http://www.spinics.net/lists/linux-input/msg23060.html [2] http://www.spinics.net/lists/linux-input/msg23090.html [3] https://lkml.org/lkml/2012/11/6/67 Patil, Rachna (7): input: ti_am335x_tsc: Step enable bits made configurable input: ti_am335x_tsc: Order of TSC wires, made configurable input: ti_am335x_tsc: Add variance filter MFD: ti_am335x_tscadc: add device tree binding information MFD: ti_am335x_tscadc: Add DT support input: ti_am335x_tsc: Add DT support IIO: ti_am335x_adc: Add DT support .../devicetree/bindings/mfd/ti_am335x_tscadc.txt | 35 +++ drivers/iio/adc/ti_am335x_adc.c| 24 ++- drivers/input/touchscreen/ti_am335x_tsc.c | 239 +--- drivers/mfd/ti_am335x_tscadc.c | 28 ++- include/linux/input/ti_am335x_tsc.h| 12 + include/linux/mfd/ti_am335x_tscadc.h | 11 +- 6 files changed, 308 insertions(+), 41 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/ti_am335x_tscadc.txt ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH RESEND 3/7] input: ti_am335x_tsc: Add variance filter
Only fine tuning variance parameter present in tslib utility does not help in removing all the ADC noise. This logic of filtering is necessary to get this touchscreen to work finely. Signed-off-by: Patil, Rachna rac...@ti.com --- drivers/input/touchscreen/ti_am335x_tsc.c | 15 ++- 1 files changed, 14 insertions(+), 1 deletions(-) diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c index 6a817a8..7a26810 100644 --- a/drivers/input/touchscreen/ti_am335x_tsc.c +++ b/drivers/input/touchscreen/ti_am335x_tsc.c @@ -32,6 +32,8 @@ #define ADCFSM_STEPID 0x10 #define SEQ_SETTLE 275 #define MAX_12BIT ((1 12) - 1) +#define TSCADC_DELTA_X 15 +#define TSCADC_DELTA_Y 15 /* * Refer to function regbit_map() to @@ -51,6 +53,8 @@ struct titsc { unsigned intwires; unsigned intx_plate_resistance; unsigned intenable_bits; + unsigned intbckup_x; + unsigned intbckup_y; boolpen_down; int steps_to_configure; int config_inp[20]; @@ -309,12 +313,18 @@ static irqreturn_t titsc_irq(int irq, void *dev) unsigned int z1, z2, z; unsigned int fsm; unsigned int fifo1count, fifo0count; + unsigned int diffx = 0, diffy = 0; int i; status = titsc_readl(ts_dev, REG_IRQSTATUS); if (status IRQENB_FIFO0THRES) { titsc_read_coordinates(ts_dev, x, y); + diffx = abs(x - (ts_dev-bckup_x)); + diffy = abs(y - (ts_dev-bckup_y)); + ts_dev-bckup_x = x; + ts_dev-bckup_y = y; + z1 = titsc_readl(ts_dev, REG_FIFO0) 0xfff; z2 = titsc_readl(ts_dev, REG_FIFO1) 0xfff; @@ -338,7 +348,8 @@ static irqreturn_t titsc_irq(int irq, void *dev) z /= z1; z = (z + 2047) 12; - if (z = MAX_12BIT) { + if ((diffx TSCADC_DELTA_X) + (diffy TSCADC_DELTA_Y) (z = MAX_12BIT)) { input_report_abs(input_dev, ABS_X, x); input_report_abs(input_dev, ABS_Y, y); input_report_abs(input_dev, ABS_PRESSURE, z); @@ -361,6 +372,8 @@ static irqreturn_t titsc_irq(int irq, void *dev) fsm = titsc_readl(ts_dev, REG_ADCFSM); if (fsm == ADCFSM_STEPID) { ts_dev-pen_down = false; + ts_dev-bckup_x = 0; + ts_dev-bckup_y = 0; input_report_key(input_dev, BTN_TOUCH, 0); input_report_abs(input_dev, ABS_PRESSURE, 0); input_sync(input_dev); -- 1.7.0.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH RESEND 2/7] input: ti_am335x_tsc: Order of TSC wires, made configurable
The current driver expected touchscreen input wires(XP,XN,YP,YN) to be connected in a particular order. Making changes to accept this as platform data. Signed-off-by: Patil, Rachna rac...@ti.com --- drivers/input/touchscreen/ti_am335x_tsc.c | 156 ++--- include/linux/input/ti_am335x_tsc.h | 12 ++ include/linux/mfd/ti_am335x_tscadc.h | 10 ++- 3 files changed, 159 insertions(+), 19 deletions(-) diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c index 4369224..6a817a8 100644 --- a/drivers/input/touchscreen/ti_am335x_tsc.c +++ b/drivers/input/touchscreen/ti_am335x_tsc.c @@ -33,6 +33,17 @@ #define SEQ_SETTLE 275 #define MAX_12BIT ((1 12) - 1) +/* + * Refer to function regbit_map() to + * map the values in the matrix. + */ +static int config[4][4] = { + {1, 0, 1, 0}, + {2, 3, 2, 3}, + {4, 5, 4, 5}, + {0, 6, 0, 6} +}; + struct titsc { struct input_dev*input; struct ti_tscadc_dev*mfd_tscadc; @@ -42,6 +53,9 @@ struct titsc { unsigned intenable_bits; boolpen_down; int steps_to_configure; + int config_inp[20]; + int bit_xp, bit_xn, bit_yp, bit_yn; + int inp_xp, inp_xn, inp_yp, inp_yn; }; static unsigned int titsc_readl(struct titsc *ts, unsigned int reg) @@ -55,6 +69,107 @@ static void titsc_writel(struct titsc *tsc, unsigned int reg, writel(val, tsc-mfd_tscadc-tscadc_base + reg); } +/* + * Each of the analog lines are mapped + * with one or two register bits, + * which can be either pulled high/low + * depending on the value to be read. + */ +static int regbit_map(int val) +{ + int map_bits = 0; + + switch (val) { + case 1: + map_bits = XPP; + break; + case 2: + map_bits = XNP; + break; + case 3: + map_bits = XNN; + break; + case 4: + map_bits = YPP; + break; + case 5: + map_bits = YPN; + break; + case 6: + map_bits = YNN; + break; + } + + return map_bits; +} + +static int titsc_config_wires(struct titsc *ts_dev) +{ + int analog_line[10], wire_order[10]; + int i, temp_bits, err; + + for (i = 0; i 4; i++) { + /* +* Get the order in which TSC wires are attached +* w.r.t. each of the analog input lines on the EVM. +*/ + analog_line[i] = ts_dev-config_inp[i] 0xF0; + analog_line[i] = analog_line[i] 4; + + wire_order[i] = ts_dev-config_inp[i] 0x0F; + } + + for (i = 0; i 4; i++) { + switch (wire_order[i]) { + case 0: + temp_bits = config[analog_line[i]][0]; + if (temp_bits == 0) { + err = -EINVAL; + goto ret; + } else { + ts_dev-bit_xp = regbit_map(temp_bits); + ts_dev-inp_xp = analog_line[i]; + break; + } + case 1: + temp_bits = config[analog_line[i]][1]; + if (temp_bits == 0) { + err = -EINVAL; + goto ret; + } else { + ts_dev-bit_xn = regbit_map(temp_bits); + ts_dev-inp_xn = analog_line[i]; + break; + } + case 2: + temp_bits = config[analog_line[i]][2]; + if (temp_bits == 0) { + err = -EINVAL; + goto ret; + } else { + ts_dev-bit_yp = regbit_map(temp_bits); + ts_dev-inp_yp = analog_line[i]; + break; + } + case 3: + temp_bits = config[analog_line[i]][3]; + if (temp_bits == 0) { + err = -EINVAL; + goto ret; + } else { + ts_dev-bit_yn = regbit_map(temp_bits); + ts_dev-inp_yn = analog_line[i]; + break; + } + } + } + + return 0; + +ret: + return err; +} + static void
[PATCH RESEND 6/7] input: ti_am335x_tsc: Add DT support
Add DT support for client touchscreen driver Signed-off-by: Patil, Rachna rac...@ti.com --- drivers/input/touchscreen/ti_am335x_tsc.c | 60 - 1 files changed, 50 insertions(+), 10 deletions(-) diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c index 7a26810..c063cf6 100644 --- a/drivers/input/touchscreen/ti_am335x_tsc.c +++ b/drivers/input/touchscreen/ti_am335x_tsc.c @@ -26,6 +26,8 @@ #include linux/io.h #include linux/input/ti_am335x_tsc.h #include linux/delay.h +#include linux/of.h +#include linux/of_device.h #include linux/mfd/ti_am335x_tscadc.h @@ -398,12 +400,18 @@ static int __devinit titsc_probe(struct platform_device *pdev) struct titsc *ts_dev; struct input_dev *input_dev; struct ti_tscadc_dev *tscadc_dev = pdev-dev.platform_data; - struct mfd_tscadc_board *pdata; - int err; - - pdata = tscadc_dev-dev-platform_data; - - if (!pdata) { + int err, i; + struct mfd_tscadc_board *pdata = NULL; + struct device_node *node = NULL; + u32 val32, wires_conf[4]; + + if (tscadc_dev-dev-of_node) { + node = tscadc_dev-dev-of_node; + node = of_find_node_by_name(node, tsc); + } else + pdata = tscadc_dev-dev-platform_data; + + if (!pdata !node) { dev_err(pdev-dev, Could not find platform data\n); return -EINVAL; } @@ -421,11 +429,43 @@ static int __devinit titsc_probe(struct platform_device *pdev) ts_dev-mfd_tscadc = tscadc_dev; ts_dev-input = input_dev; ts_dev-irq = tscadc_dev-irq; - ts_dev-wires = pdata-tsc_init-wires; - ts_dev-x_plate_resistance = pdata-tsc_init-x_plate_resistance; - ts_dev-steps_to_configure = pdata-tsc_init-steps_to_configure; - memcpy(ts_dev-config_inp, pdata-tsc_init-wire_config, + + if (node) { + err = of_property_read_u32(node, wires, val32); + if (err 0) + goto err_free_mem; + else + ts_dev-wires = val32; + + err = of_property_read_u32(node, x-plate-resistance, val32); + if (err 0) + goto err_free_mem; + else + ts_dev-x_plate_resistance = val32; + + err = of_property_read_u32(node, steps-to-configure, val32); + if (err 0) + goto err_free_mem; + else + ts_dev-steps_to_configure = val32; + + err = of_property_read_u32_array(node, wire-config, + wires_conf, ARRAY_SIZE(wires_conf)); + if (err 0) + goto err_free_mem; + else { + for (i = 0; i ARRAY_SIZE(wires_conf); i++) + ts_dev-config_inp[i] = wires_conf[i]; + } + } else { + ts_dev-wires = pdata-tsc_init-wires; + ts_dev-x_plate_resistance = + pdata-tsc_init-x_plate_resistance; + ts_dev-steps_to_configure = + pdata-tsc_init-steps_to_configure; + memcpy(ts_dev-config_inp, pdata-tsc_init-wire_config, sizeof(pdata-tsc_init-wire_config)); + } err = request_irq(ts_dev-irq, titsc_irq, 0, pdev-dev.driver-name, ts_dev); -- 1.7.0.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH RESEND 5/7] MFD: ti_am335x_tscadc: Add DT support
Make changes to add DT support in the MFD core driver. Signed-off-by: Patil, Rachna rac...@ti.com --- drivers/mfd/ti_am335x_tscadc.c | 28 +++- 1 files changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c index 8ca3bf0..07b7788 100644 --- a/drivers/mfd/ti_am335x_tscadc.c +++ b/drivers/mfd/ti_am335x_tscadc.c @@ -22,6 +22,8 @@ #include linux/regmap.h #include linux/mfd/core.h #include linux/pm_runtime.h +#include linux/of.h +#include linux/of_device.h #include linux/mfd/ti_am335x_tscadc.h #include linux/input/ti_am335x_tsc.h @@ -64,20 +66,31 @@ static int __devinit ti_tscadc_probe(struct platform_device *pdev) struct resource *res; struct clk *clk; struct mfd_tscadc_board *pdata = pdev-dev.platform_data; + struct device_node *node = pdev-dev.of_node; struct mfd_cell *cell; int err, ctrl; int clk_value, clock_rate; - int tsc_wires, adc_channels = 0, total_channels; + int tsc_wires = 0, adc_channels = 0, total_channels; - if (!pdata) { + if (!pdata !pdev-dev.of_node) { dev_err(pdev-dev, Could not find platform data\n); return -EINVAL; } - if (pdata-adc_init) - adc_channels = pdata-adc_init-adc_channels; + if (pdev-dev.of_node) { + node = of_find_node_by_name(pdev-dev.of_node, tsc); + of_property_read_u32(node, wires, tsc_wires); + + node = of_find_node_by_name(pdev-dev.of_node, adc); + of_property_read_u32(node, adc-channels, adc_channels); + } else { + if (pdata-tsc_init) + tsc_wires = pdata-tsc_init-wires; + + if (pdata-adc_init) + adc_channels = pdata-adc_init-adc_channels; + } - tsc_wires = pdata-tsc_init-wires; total_channels = tsc_wires + adc_channels; if (total_channels 8) { @@ -256,11 +269,16 @@ static const struct dev_pm_ops tscadc_pm_ops = { #define TSCADC_PM_OPS NULL #endif +static const struct of_device_id ti_tscadc_dt_ids[] = { + { .compatible = ti,ti-tscadc, }, +}; + static struct platform_driver ti_tscadc_driver = { .driver = { .name = ti_tscadc, .owner = THIS_MODULE, .pm = TSCADC_PM_OPS, + .of_match_table = of_match_ptr(ti_tscadc_dt_ids), }, .probe = ti_tscadc_probe, .remove = __devexit_p(ti_tscadc_remove), -- 1.7.0.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
[PATCH RESEND 7/7] IIO: ti_am335x_adc: Add DT support
Add DT support for client ADC driver. Signed-off-by: Patil, Rachna rac...@ti.com --- drivers/iio/adc/ti_am335x_adc.c | 24 1 files changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c index 02a43c8..1f1ec0c 100644 --- a/drivers/iio/adc/ti_am335x_adc.c +++ b/drivers/iio/adc/ti_am335x_adc.c @@ -22,6 +22,8 @@ #include linux/platform_device.h #include linux/io.h #include linux/iio/iio.h +#include linux/of.h +#include linux/of_device.h #include linux/mfd/ti_am335x_tscadc.h #include linux/platform_data/ti_am335x_adc.h @@ -141,11 +143,18 @@ static int __devinit tiadc_probe(struct platform_device *pdev) struct iio_dev *indio_dev; struct tiadc_device *adc_dev; struct ti_tscadc_dev*tscadc_dev = pdev-dev.platform_data; - struct mfd_tscadc_board *pdata; + struct mfd_tscadc_board *pdata = NULL; + struct device_node *node = NULL; int err; + u32 val32; - pdata = tscadc_dev-dev-platform_data; - if (!pdata || !pdata-adc_init) { + if (tscadc_dev-dev-of_node) { + node = tscadc_dev-dev-of_node; + node = of_find_node_by_name(node, adc); + } else + pdata = tscadc_dev-dev-platform_data; + + if (!pdata !node) { dev_err(pdev-dev, Could not find platform data\n); return -EINVAL; } @@ -159,7 +168,14 @@ static int __devinit tiadc_probe(struct platform_device *pdev) adc_dev = iio_priv(indio_dev); adc_dev-mfd_tscadc = tscadc_dev; - adc_dev-channels = pdata-adc_init-adc_channels; + if (node) { + err = of_property_read_u32(node, adc-channels, val32); + if (err 0) + goto err_free_device; + else + adc_dev-channels = val32; + } else + adc_dev-channels = pdata-adc_init-adc_channels; indio_dev-dev.parent = pdev-dev; indio_dev-name = dev_name(pdev-dev); -- 1.7.0.4 ___ devicetree-discuss mailing list devicetree-discuss@lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss