Commit 2a4e333a authored by Miquel Raynal's avatar Miquel Raynal Committed by Lee Jones

mfd: ti_am335x_tscadc: Add a boolean to clarify the presence of a touchscreen

Just checking the number of wires will soon not be enough, add a boolean
to indicate the actual use or not of the touchscreen.

Certain checks only make sense when there is a touchscreen wired. Make
these checks explicitly depend on the presence of the touchscreen.
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20211015081506.933180-35-miquel.raynal@bootlin.com
parent e40b5971
...@@ -120,6 +120,7 @@ static int ti_tscadc_probe(struct platform_device *pdev) ...@@ -120,6 +120,7 @@ static int ti_tscadc_probe(struct platform_device *pdev)
struct mfd_cell *cell; struct mfd_cell *cell;
struct property *prop; struct property *prop;
const __be32 *cur; const __be32 *cur;
bool use_tsc = false;
u32 val; u32 val;
int err; int err;
int tscmag_wires = 0, adc_channels = 0, cell_idx = 0, total_channels; int tscmag_wires = 0, adc_channels = 0, cell_idx = 0, total_channels;
...@@ -143,6 +144,8 @@ static int ti_tscadc_probe(struct platform_device *pdev) ...@@ -143,6 +144,8 @@ static int ti_tscadc_probe(struct platform_device *pdev)
of_property_read_u32(node, "ti,wires", &tscmag_wires); of_property_read_u32(node, "ti,wires", &tscmag_wires);
of_property_read_u32(node, "ti,coordiante-readouts", &readouts); of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
of_node_put(node); of_node_put(node);
if (tscmag_wires)
use_tsc = true;
node = of_get_child_by_name(pdev->dev.of_node, "adc"); node = of_get_child_by_name(pdev->dev.of_node, "adc");
of_property_for_each_u32(node, "ti,adc-channels", prop, cur, val) { of_property_for_each_u32(node, "ti,adc-channels", prop, cur, val) {
...@@ -168,7 +171,7 @@ static int ti_tscadc_probe(struct platform_device *pdev) ...@@ -168,7 +171,7 @@ static int ti_tscadc_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
if (readouts * 2 + 2 + adc_channels > 16) { if (use_tsc && (readouts * 2 + 2 + adc_channels > 16)) {
dev_err(&pdev->dev, "Too many step configurations requested\n"); dev_err(&pdev->dev, "Too many step configurations requested\n");
return -EINVAL; return -EINVAL;
} }
...@@ -223,7 +226,7 @@ static int ti_tscadc_probe(struct platform_device *pdev) ...@@ -223,7 +226,7 @@ static int ti_tscadc_probe(struct platform_device *pdev)
* added manually when timely. * added manually when timely.
*/ */
tscadc->ctrl = CNTRLREG_TSC_STEPCONFIGWRT | CNTRLREG_STEPID; tscadc->ctrl = CNTRLREG_TSC_STEPCONFIGWRT | CNTRLREG_STEPID;
if (tscmag_wires > 0) { if (use_tsc) {
tscadc->ctrl |= CNTRLREG_TSC_ENB; tscadc->ctrl |= CNTRLREG_TSC_ENB;
if (tscmag_wires == 5) if (tscmag_wires == 5)
tscadc->ctrl |= CNTRLREG_TSC_5WIRE; tscadc->ctrl |= CNTRLREG_TSC_5WIRE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment