Touch panel DTS analysis (MSM8994 platform, Atmel chip), msm8994atmel
Touch panel DTS analysis (MSM8994 platform, Atmel chip)
On MSM8994, the DTS node of Touch panel is written in/kernel/arch/arm/boot/dts/qcom/msm8994-mtp.dtsi file. The Code is as follows:
& Soc {i2c @ f9924000 {atmel_mxt_ts @ 4a {compatible = "atmel, atmel_mxt_ts"; reg = <0x4a>; interrupt-parent = <& msm_gpio>; interrupts = <61 0x2008>; avdd-supply = <& pm8994_l22>; vdd_io-supply = <& pm8994_l14> ;.........};};
In DTS nodes, we mainly look at avdd-supply and vdd_io-supply two attributes. The usage of these two attributes in C code is as follows:
/Kernel/drivers/input/touchscreen/atmel_mxt_ts.cmxt_probe_regulators (struct mxt_data * data ){........ data-> reg_vdd_io = regulator_get (dev, "vdd_io ");........ data-> reg_avdd = regulator_get (dev, "avdd ");........}
/Kernel/drivers/regulator/core. cstruct regulator * regulator_get (struct device * dev, const char * id) {return _ regulator_get (dev, id, 0 );}
Static struct regulator * _ regulator_get (struct device * dev, const char * id, int exclusive ){....... rdev = regulator_dev_lookup (dev, id, & ret); if (rdev) goto found ;......}
Static struct regulator_dev * regulator_dev_lookup (struct devic * dev, const char * supply, int * ret) {struct regulator_dev * r; struct device_node * node ;........ /* first do a dt based lookup */if (dev & dev-> of_node) {node = of_get_regulator (dev, supply) if (node) {list_for_each_entry (r, & regulator_list, list) if (r-> dev. parent & node = r-> dev. of_node) return r ;........}}}
Static struct device_node * of_get_regulator (struct device * dev, const char * supply) {struct device_node * regnode = NULL; char prop_name [32]; ...... snprintf (prop_name, 32, "% s-supply", supply); regnode = of_parse_phandle (dev-> of_node, prop_name, 0 );........}
From the above code, we can see how the vdd_io-supply and avdd-supply attribute in DTS is parsed and used. In the mxt_probe () function, transmit the "avdd" and "vdd_io" strings to the regulator_get () function. After calling them step by step () the function combines the string into the required string attribute in DTS, and then finds the corresponding regulator_dev struct through the attribute value!