Touch panel DTS 分析(MSM8994平台,Atmel 晶片),msm8994atmel
Touch panel DTS 分析(MSM8994平台,Atmel 晶片)
在MSM8994平台下,Touch panel的DTS節點寫在/kernel/arch/arm/boot/dts/qcom/msm8994-mtp.dtsi檔案中。具體代碼如下:
&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>; ......... }; };
在DTS節點中,我們主要看一下avdd-supply and vdd_io-supply兩個屬性。這兩個屬性在C代碼裡的使用方式如下:
/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, ®ulator_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); ........}
從上述代碼大致上可以看到DTS裡的vdd_io-supply and avdd-supply屬性是如何解析和使用的。在mxt_probe()函數中將字串“avdd”和“vdd_io”傳給regulator_get()函數,一步步調用下來後,在of_get_regulator()函數中將字串合并成DTS中符合要求的字串屬性,之後通過屬性的值來找到相應的regulator_dev 結構體!