[PATCH v2 1/4] mfd: mc13xxx: add device tree probe support
From: Shawn Guo <hidden>
Date: 2011-12-06 03:26:43
Also in:
linux-devicetree
On Mon, Dec 05, 2011 at 07:09:47PM +0000, Mark Brown wrote:
On Mon, Dec 05, 2011 at 02:41:24PM +0800, Shawn Guo wrote:quoted
On Fri, Dec 02, 2011 at 03:36:38PM +0000, Mark Brown wrote:quoted
On Thu, Dec 01, 2011 at 05:21:05PM +0800, Shawn Guo wrote:quoted
quoted
quoted
+Sub-nodes: +- regulators : Contain the regulator nodes. The bindings details of individual + regulator node can be found in: + Documentation/devicetree/bindings/regulator/regulator.txtquoted
quoted
How does the driver figure out which regulators map onto which subnodes?quoted
There should only be one sub-node named 'regulators', otherwise, DTC will report ERROR (duplicate_node_names).That doesn't answer the question - I've still no idea how the binding is supposed to map the nodes contained within regulators onto the physical regulators.
Oops, I missed the question. It's in the patch #3.
+struct mc13xxx_regulator_init_data * __devinit mc13xxx_parse_regulators_dt(
+ struct platform_device *pdev, struct mc13xxx_regulator *regulators,
+ int num_regulators)
+{
+ struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev);
+ struct mc13xxx_regulator_init_data *data, *p;
+ struct device_node *parent, *child;
+ int i;
+
+ of_node_get(pdev->dev.parent->of_node);
+ parent = of_find_node_by_name(pdev->dev.parent->of_node, "regulators");
+ if (!parent)
+ return NULL;
+
+ data = devm_kzalloc(&pdev->dev, sizeof(*data) * priv->num_regulators,
+ GFP_KERNEL);
+ if (!data)
+ return NULL;
+ p = data;
+
+ for_each_child_of_node(parent, child) {
+ for (i = 0; i < num_regulators; i++) {
+ if (!of_node_cmp(child->name,
+ regulators[i].desc.name)) {And here it is. It finds the regulator node by looking for the regulator name. Regards, Shawn
+ p->id = i; + p->init_data = of_get_regulator_init_data( + &pdev->dev, child); + p->node = child; + p++; + break; + } + } + } + + return data; +}