From: Karol Lewandowski <k.lewandowsk@samsung.com>
To: Thomas Abraham <thomas.abraham@linaro.org>
Cc: linux-kernel@vger.kernel.org,
devicetree-discuss@lists.ozlabs.org, rob.herring@calxeda.com,
grant.likely@secretlab.ca, kgene.kim@samsung.com,
broonie@opensource.wolfsonmicro.com, myungjoo.ham@samsung.com,
kyungmin.park@samsung.com, linux-arm-kernel@lists.infradead.org,
linux-samsung-soc@vger.kernel.org, patches@linaro.org,
Rajendra Nayak <rnayak@ti.com>
Subject: Re: [PATCH v4 2/2] regulator: add device tree support for max8997
Date: Wed, 28 Mar 2012 19:03:28 +0200 [thread overview]
Message-ID: <4F734460.4060605@samsung.com> (raw)
In-Reply-To: <1332582590-16382-3-git-send-email-thomas.abraham@linaro.org>
On 24.03.2012 10:49, Thomas Abraham wrote:
Hi Thomas!
> Add device tree based discovery support for max8997.
...
> +Regulators: The regulators of max8997 that have to be instantiated should be
> +included in a sub-node named 'regulators'. Regulator nodes included in this
> +sub-node should be of the format as below. Note: The 'n' in LDOn and BUCKn
> +represents the LDO or BUCK number as per the datasheet of max8997.
> +
> + For LDO's:
> + LDOn {
> + standard regulator bindings here
> + };
> +
> + For BUCK's:
> + BUCKn {
> + standard regulator bindings here
> + };
> +
Small note - driver supports[1] configuring following regulators by
using respective DT node names:
- EN32KHz_AP
- EN32KHz_CP
- ENVICHG
- ESAFEOUT1
- ESAFEOUT2
- CHARGER
- CHARGER_CV
- CHARGER_TOPOFF
I wonder if these should be mentioned in documentation too.
[1] These are used in e.g. mach-nuri.c
> diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c> index 9657929..dce8aaf 100644
> --- a/drivers/regulator/max8997.c
> +++ b/drivers/regulator/max8997.c
..
> +static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev,
> + struct max8997_platform_data *pdata)
> +{
> + struct device_node *pmic_np, *regulators_np, *reg_np;
> + struct max8997_regulator_data *rdata;
> + unsigned int i, dvs_voltage_nr = 1, ret;
> +
> + pmic_np = iodev->dev->of_node;
> + if (!pmic_np) {
> + dev_err(iodev->dev, "could not find pmic sub-node\n");
> + return -ENODEV;
> + }
> +
> + regulators_np = of_find_node_by_name(pmic_np, "regulators");
> + if (!regulators_np) {
> + dev_err(iodev->dev, "could not find regulators sub-node\n");
> + return -EINVAL;
> + }
> +
> + /* count the number of regulators to be supported in pmic */
> + pdata->num_regulators = 0;
> + for_each_child_of_node(regulators_np, reg_np)
> + pdata->num_regulators++;
> +
> + rdata = devm_kzalloc(iodev->dev, sizeof(*rdata) *
> + pdata->num_regulators, GFP_KERNEL);
> + if (!rdata) {
> + dev_err(iodev->dev, "could not allocate memory for "
> + "regulator data\n");
> + return -ENOMEM;
> + }
> + pdata->regulators = rdata;
> + for_each_child_of_node(regulators_np, reg_np) {
> + for (i = 0; i < ARRAY_SIZE(regulators); i++)
> + if (!of_node_cmp(reg_np->name, regulators[i].name))
> + break;
> + rdata->id = i;
rdata->id will be equal to ARRAY_SIZE(regulators) when one adds DT node
name (below "regulators") which is different from what can be found in
regulators[] table.
On my test machine this results in hard lockup - possibly because
something tries to access regulators[ARRAY_SIZE(regulators)]
later on.
Following patch fixes this on my machine (using DTS with misspelled LDO1 for LDx1):
diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c
index dce8aaf..c20fd72 100644
--- a/drivers/regulator/max8997.c
+++ b/drivers/regulator/max8997.c
@@ -1011,6 +1011,13 @@ static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev,
for (i = 0; i < ARRAY_SIZE(regulators); i++)
if (!of_node_cmp(reg_np->name, regulators[i].name))
break;
+
+ if (i == ARRAY_SIZE(regulators)) {
+ dev_warn(iodev->dev, "don't know how to configure regulator %s\n",
+ reg_np->name);
+ continue;
+ }
+
rdata->id = i;
rdata->initdata = of_get_regulator_init_data(
iodev->dev, reg_np);
Regards,
--
Karol Lewandowski | Samsung Poland R&D Center | Linux/Platform
WARNING: multiple messages have this Message-ID (diff)
From: k.lewandowsk@samsung.com (Karol Lewandowski)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 2/2] regulator: add device tree support for max8997
Date: Wed, 28 Mar 2012 19:03:28 +0200 [thread overview]
Message-ID: <4F734460.4060605@samsung.com> (raw)
In-Reply-To: <1332582590-16382-3-git-send-email-thomas.abraham@linaro.org>
On 24.03.2012 10:49, Thomas Abraham wrote:
Hi Thomas!
> Add device tree based discovery support for max8997.
...
> +Regulators: The regulators of max8997 that have to be instantiated should be
> +included in a sub-node named 'regulators'. Regulator nodes included in this
> +sub-node should be of the format as below. Note: The 'n' in LDOn and BUCKn
> +represents the LDO or BUCK number as per the datasheet of max8997.
> +
> + For LDO's:
> + LDOn {
> + standard regulator bindings here
> + };
> +
> + For BUCK's:
> + BUCKn {
> + standard regulator bindings here
> + };
> +
Small note - driver supports[1] configuring following regulators by
using respective DT node names:
- EN32KHz_AP
- EN32KHz_CP
- ENVICHG
- ESAFEOUT1
- ESAFEOUT2
- CHARGER
- CHARGER_CV
- CHARGER_TOPOFF
I wonder if these should be mentioned in documentation too.
[1] These are used in e.g. mach-nuri.c
> diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c> index 9657929..dce8aaf 100644
> --- a/drivers/regulator/max8997.c
> +++ b/drivers/regulator/max8997.c
..
> +static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev,
> + struct max8997_platform_data *pdata)
> +{
> + struct device_node *pmic_np, *regulators_np, *reg_np;
> + struct max8997_regulator_data *rdata;
> + unsigned int i, dvs_voltage_nr = 1, ret;
> +
> + pmic_np = iodev->dev->of_node;
> + if (!pmic_np) {
> + dev_err(iodev->dev, "could not find pmic sub-node\n");
> + return -ENODEV;
> + }
> +
> + regulators_np = of_find_node_by_name(pmic_np, "regulators");
> + if (!regulators_np) {
> + dev_err(iodev->dev, "could not find regulators sub-node\n");
> + return -EINVAL;
> + }
> +
> + /* count the number of regulators to be supported in pmic */
> + pdata->num_regulators = 0;
> + for_each_child_of_node(regulators_np, reg_np)
> + pdata->num_regulators++;
> +
> + rdata = devm_kzalloc(iodev->dev, sizeof(*rdata) *
> + pdata->num_regulators, GFP_KERNEL);
> + if (!rdata) {
> + dev_err(iodev->dev, "could not allocate memory for "
> + "regulator data\n");
> + return -ENOMEM;
> + }
> + pdata->regulators = rdata;
> + for_each_child_of_node(regulators_np, reg_np) {
> + for (i = 0; i < ARRAY_SIZE(regulators); i++)
> + if (!of_node_cmp(reg_np->name, regulators[i].name))
> + break;
> + rdata->id = i;
rdata->id will be equal to ARRAY_SIZE(regulators) when one adds DT node
name (below "regulators") which is different from what can be found in
regulators[] table.
On my test machine this results in hard lockup - possibly because
something tries to access regulators[ARRAY_SIZE(regulators)]
later on.
Following patch fixes this on my machine (using DTS with misspelled LDO1 for LDx1):
diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c
index dce8aaf..c20fd72 100644
--- a/drivers/regulator/max8997.c
+++ b/drivers/regulator/max8997.c
@@ -1011,6 +1011,13 @@ static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev,
for (i = 0; i < ARRAY_SIZE(regulators); i++)
if (!of_node_cmp(reg_np->name, regulators[i].name))
break;
+
+ if (i == ARRAY_SIZE(regulators)) {
+ dev_warn(iodev->dev, "don't know how to configure regulator %s\n",
+ reg_np->name);
+ continue;
+ }
+
rdata->id = i;
rdata->initdata = of_get_regulator_init_data(
iodev->dev, reg_np);
Regards,
--
Karol Lewandowski | Samsung Poland R&D Center | Linux/Platform
next prev parent reply other threads:[~2012-03-28 17:03 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-24 9:49 [PATCH v4 0/2] regulator: add irq domain and device tree support for MAX8997 Thomas Abraham
2012-03-24 9:49 ` Thomas Abraham
2012-03-24 9:49 ` Thomas Abraham
2012-03-24 9:49 ` [PATCH v4 1/2] mfd: add irq domain support for max8997 interrupts Thomas Abraham
2012-03-24 9:49 ` Thomas Abraham
2012-03-24 9:49 ` Thomas Abraham
2012-03-26 12:20 ` MyungJoo Ham
2012-03-26 12:20 ` MyungJoo Ham
2012-03-30 22:06 ` Grant Likely
2012-03-30 22:06 ` Grant Likely
2012-04-17 18:11 ` Thomas Abraham
2012-04-17 18:11 ` Thomas Abraham
2012-04-04 21:22 ` Mark Brown
2012-04-04 21:22 ` Mark Brown
2012-04-16 15:32 ` Samuel Ortiz
2012-04-16 15:32 ` Samuel Ortiz
2012-04-16 18:47 ` Mark Brown
2012-04-16 18:47 ` Mark Brown
2012-03-24 9:49 ` [PATCH v4 2/2] regulator: add device tree support for max8997 Thomas Abraham
2012-03-24 9:49 ` Thomas Abraham
2012-03-27 6:40 ` MyungJoo Ham
2012-03-27 6:40 ` MyungJoo Ham
2012-03-28 17:03 ` Karol Lewandowski [this message]
2012-03-28 17:03 ` Karol Lewandowski
2012-04-17 18:35 ` Thomas Abraham
2012-04-17 18:35 ` Thomas Abraham
2012-04-17 18:38 ` Mark Brown
2012-04-17 18:38 ` Mark Brown
2012-04-18 8:16 ` Thomas Abraham
2012-04-18 8:16 ` Thomas Abraham
2012-03-30 22:09 ` Grant Likely
2012-03-30 22:09 ` Grant Likely
2012-04-16 18:51 ` Mark Brown
2012-04-16 18:51 ` Mark Brown
2012-04-16 18:56 ` Thomas Abraham
2012-04-16 18:56 ` Thomas Abraham
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F734460.4060605@samsung.com \
--to=k.lewandowsk@samsung.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=grant.likely@secretlab.ca \
--cc=kgene.kim@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
--cc=patches@linaro.org \
--cc=rnayak@ti.com \
--cc=rob.herring@calxeda.com \
--cc=thomas.abraham@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.