最近在driver里发现一个有点值得注意的地方:
在dtsi里定义了power
vdd-supply = <&pm8937_l10>;
vcc_i2c-supply = <&pm8937_l5>;
但是在i2c device的driver里看到的却是
pdata->vcc = devm_regulator_get(dev, "vcc_i2c");
也就是说这边的vcc_i2c和dtis里的vcc_i2c-supply的差距是多了个-supply
这个supply在哪里加的呢,追踪 devm_regulator_get
struct regulator *devm_regulator_get(struct device *dev, const char *id)
{
regulator = regulator_get(dev, id);//只要追踪id就好
}
static struct regulator *_regulator_get(struct device *dev, const char *id,
int exclusive)
{
rdev = regulator_dev_lookup(dev, id, &ret);
}
static struct regulator_dev *regulator_dev_lookup(struct device *dev,
const char *supply,
int *ret)
{
node = of_get_regulator(dev, supply);
}
static struct device_node *of_get_regulator(struct device *dev, const char *supply){
struct device_node *regnode = NULL;
char prop_name[32]; /* 32 is max size of property name */
dev_dbg(dev, "Looking up %s-supply from device tree ", supply);
snprintf(prop_name, 32, "%s-supply", supply); //最终看到了这个加-supply的地方了
regnode = of_parse_phandle(dev->of_node, prop_name, 0);
if (!regnode) {
dev_dbg(dev, "Looking up %s property in node %s failed",
prop_name, dev->of_node->full_name);
return NULL;
}
return regnode;
}