Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Staging/iio/adc/touchscreen/MXS: provide devicetree adaption

This is an RFC for the new touchscreen properties.

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
Tested-by: Marek Vasut <marex@denx.de>
Acked-by: Marek Vasut <marex@denx.de>
Tested-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
CC: linux-arm-kernel@lists.infradead.org
CC: linux-input@vger.kernel.org
CC: devel@driverdev.osuosl.org
CC: Marek Vasut <marex@denx.de>
CC: Fabio Estevam <fabio.estevam@freescale.com>
CC: devicetree@vger.kernel.org

authored by

Juergen Beisert and committed by
Jonathan Cameron
e9c88fb5 cd6c5586

+71 -26
+31 -5
Documentation/devicetree/bindings/staging/iio/adc/mxs-lradc.txt
··· 1 1 * Freescale i.MX28 LRADC device driver 2 2 3 3 Required properties: 4 - - compatible: Should be "fsl,imx28-lradc" 4 + - compatible: Should be "fsl,imx23-lradc" for i.MX23 SoC and "fsl,imx28-lradc" 5 + for i.MX28 SoC 5 6 - reg: Address and length of the register set for the device 6 7 - interrupts: Should contain the LRADC interrupts 7 8 ··· 10 9 - fsl,lradc-touchscreen-wires: Number of wires used to connect the touchscreen 11 10 to LRADC. Valid value is either 4 or 5. If this 12 11 property is not present, then the touchscreen is 13 - disabled. 12 + disabled. 5 wires is valid for i.MX28 SoC only. 13 + - fsl,ave-ctrl: number of samples per direction to calculate an average value. 14 + Allowed value is 1 ... 31, default is 4 15 + - fsl,ave-delay: delay between consecutive samples. Allowed value is 16 + 1 ... 2047. It is used if 'fsl,ave-ctrl' > 1, counts at 17 + 2 kHz and its default is 2 (= 1 ms) 18 + - fsl,settling: delay between plate switch to next sample. Allowed value is 19 + 1 ... 2047. It counts at 2 kHz and its default is 20 + 10 (= 5 ms) 14 21 15 - Examples: 22 + Example for i.MX23 SoC: 23 + 24 + lradc@80050000 { 25 + compatible = "fsl,imx23-lradc"; 26 + reg = <0x80050000 0x2000>; 27 + interrupts = <36 37 38 39 40 41 42 43 44>; 28 + status = "okay"; 29 + fsl,lradc-touchscreen-wires = <4>; 30 + fsl,ave-ctrl = <4>; 31 + fsl,ave-delay = <2>; 32 + fsl,settling = <10>; 33 + }; 34 + 35 + Example for i.MX28 SoC: 16 36 17 37 lradc@80050000 { 18 38 compatible = "fsl,imx28-lradc"; 19 39 reg = <0x80050000 0x2000>; 20 - interrupts = <10 14 15 16 17 18 19 21 - 20 21 22 23 24 25>; 40 + interrupts = <10 14 15 16 17 18 19 20 21 22 23 24 25>; 41 + status = "okay"; 42 + fsl,lradc-touchscreen-wires = <5>; 43 + fsl,ave-ctrl = <4>; 44 + fsl,ave-delay = <2>; 45 + fsl,settling = <10>; 22 46 };
+4
arch/arm/boot/dts/imx28-evk.dts
··· 183 183 184 184 lradc@80050000 { 185 185 status = "okay"; 186 + fsl,lradc-touchscreen-wires = <4>; 187 + fsl,ave-ctrl = <4>; 188 + fsl,ave-delay = <2>; 189 + fsl,settling = <10>; 186 190 }; 187 191 188 192 i2c0: i2c@80058000 {
+36 -21
drivers/staging/iio/adc/mxs-lradc.c
··· 1224 1224 static int mxs_lradc_probe_touchscreen(struct mxs_lradc *lradc, 1225 1225 struct device_node *lradc_node) 1226 1226 { 1227 - /* TODO retrieve from device tree */ 1227 + int ret; 1228 + u32 ts_wires = 0, adapt; 1229 + 1230 + ret = of_property_read_u32(lradc_node, "fsl,lradc-touchscreen-wires", 1231 + &ts_wires); 1232 + if (ret) 1233 + return -ENODEV; /* touchscreen feature disabled */ 1234 + 1235 + switch (ts_wires) { 1236 + case 4: 1237 + lradc->use_touchscreen = MXS_LRADC_TOUCHSCREEN_4WIRE; 1238 + break; 1239 + case 5: 1240 + if (lradc->soc == IMX28_LRADC) { 1241 + lradc->use_touchscreen = MXS_LRADC_TOUCHSCREEN_5WIRE; 1242 + break; 1243 + } 1244 + /* fall through an error message for i.MX23 */ 1245 + default: 1246 + dev_err(lradc->dev, 1247 + "Unsupported number of touchscreen wires (%d)\n", 1248 + ts_wires); 1249 + return -EINVAL; 1250 + } 1251 + 1228 1252 lradc->over_sample_cnt = 4; 1253 + ret = of_property_read_u32(lradc_node, "fsl,ave-ctrl", &adapt); 1254 + if (ret == 0) 1255 + lradc->over_sample_cnt = adapt; 1256 + 1229 1257 lradc->over_sample_delay = 2; 1258 + ret = of_property_read_u32(lradc_node, "fsl,ave-delay", &adapt); 1259 + if (ret == 0) 1260 + lradc->over_sample_delay = adapt; 1261 + 1230 1262 lradc->settling_delay = 10; 1263 + ret = of_property_read_u32(lradc_node, "fsl,settling", &adapt); 1264 + if (ret == 0) 1265 + lradc->settling_delay = adapt; 1231 1266 1232 1267 return 0; 1233 1268 } ··· 1278 1243 struct mxs_lradc *lradc; 1279 1244 struct iio_dev *iio; 1280 1245 struct resource *iores; 1281 - uint32_t ts_wires = 0; 1282 1246 int ret = 0, touch_ret; 1283 1247 int i; 1284 1248 ··· 1310 1276 } 1311 1277 1312 1278 touch_ret = mxs_lradc_probe_touchscreen(lradc, node); 1313 - 1314 - /* Check if touchscreen is enabled in DT. */ 1315 - ret = of_property_read_u32(node, "fsl,lradc-touchscreen-wires", 1316 - &ts_wires); 1317 - if (ret) 1318 - dev_info(dev, "Touchscreen not enabled.\n"); 1319 - else if (ts_wires == 4) 1320 - lradc->use_touchscreen = MXS_LRADC_TOUCHSCREEN_4WIRE; 1321 - else if (ts_wires == 5) 1322 - lradc->use_touchscreen = MXS_LRADC_TOUCHSCREEN_5WIRE; 1323 - else 1324 - dev_warn(dev, "Unsupported number of touchscreen wires (%d)\n", 1325 - ts_wires); 1326 - 1327 - if ((lradc->soc == IMX23_LRADC) && (ts_wires == 5)) { 1328 - dev_warn(dev, "No support for 5 wire touches on i.MX23\n"); 1329 - dev_warn(dev, "Falling back to 4 wire\n"); 1330 - ts_wires = 4; 1331 - } 1332 1279 1333 1280 /* Grab all IRQ sources */ 1334 1281 for (i = 0; i < of_cfg->irq_count; i++) {