* [PATCH 1/6] regulator: max77686: Consistently index opmode array by rdev id
2014-11-04 8:49 [PATCH 0/6] regulator: max77686/802: Cleanup Krzysztof Kozlowski
@ 2014-11-04 8:49 ` Krzysztof Kozlowski
2014-11-04 20:41 ` Mark Brown
2014-11-04 8:49 ` [PATCH 2/6] regulator: max77686: Initialize opmode explicitly to normal mode Krzysztof Kozlowski
` (6 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Krzysztof Kozlowski @ 2014-11-04 8:49 UTC (permalink / raw)
To: Samuel Ortiz, Lee Jones, Liam Girdwood, Mark Brown, linux-kernel
Cc: Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas, Krzysztof Kozlowski
Mixed indexes were used for array of opmodes in max77686_data structure:
id of regulator and index of regulator_desc array.
These indexes are exactly the same but the mixture may confuse. Use
consistently the id of regulator.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
drivers/regulator/max77686.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c
index 09b0d8c20a9d..27c5f4556044 100644
--- a/drivers/regulator/max77686.c
+++ b/drivers/regulator/max77686.c
@@ -82,6 +82,7 @@ enum max77686_ramp_rate {
};
struct max77686_data {
+ /* Array indexed by regulator id */
unsigned int opmode[MAX77686_REGULATORS];
};
@@ -513,12 +514,13 @@ static int max77686_pmic_probe(struct platform_device *pdev)
for (i = 0; i < MAX77686_REGULATORS; i++) {
struct regulator_dev *rdev;
+ int id = regulators[i].id;
config.init_data = pdata->regulators[i].initdata;
config.of_node = pdata->regulators[i].of_node;
- max77686->opmode[i] = regulators[i].enable_mask >>
- max77686_get_opmode_shift(i);
+ max77686->opmode[id] = regulators[i].enable_mask >>
+ max77686_get_opmode_shift(id);
rdev = devm_regulator_register(&pdev->dev,
®ulators[i], &config);
if (IS_ERR(rdev)) {
--
1.9.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 1/6] regulator: max77686: Consistently index opmode array by rdev id
2014-11-04 8:49 ` [PATCH 1/6] regulator: max77686: Consistently index opmode array by rdev id Krzysztof Kozlowski
@ 2014-11-04 20:41 ` Mark Brown
0 siblings, 0 replies; 16+ messages in thread
From: Mark Brown @ 2014-11-04 20:41 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Samuel Ortiz, Lee Jones, Liam Girdwood, linux-kernel,
Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas
[-- Attachment #1: Type: text/plain, Size: 215 bytes --]
On Tue, Nov 04, 2014 at 09:49:41AM +0100, Krzysztof Kozlowski wrote:
> Mixed indexes were used for array of opmodes in max77686_data structure:
> id of regulator and index of regulator_desc array.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 2/6] regulator: max77686: Initialize opmode explicitly to normal mode
2014-11-04 8:49 [PATCH 0/6] regulator: max77686/802: Cleanup Krzysztof Kozlowski
2014-11-04 8:49 ` [PATCH 1/6] regulator: max77686: Consistently index opmode array by rdev id Krzysztof Kozlowski
@ 2014-11-04 8:49 ` Krzysztof Kozlowski
2014-11-04 20:42 ` Mark Brown
2014-11-04 8:49 ` [RFT 3/6] regulator: max77802: Don't ignore return value of current opmode Krzysztof Kozlowski
` (5 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Krzysztof Kozlowski @ 2014-11-04 8:49 UTC (permalink / raw)
To: Samuel Ortiz, Lee Jones, Liam Girdwood, Mark Brown, linux-kernel
Cc: Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas, Krzysztof Kozlowski
Minor nit: Initialize the opmode for each regulator to normal mode in a
readable explicit way.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Suggested-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Reviewed-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
---
drivers/regulator/max77686.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c
index 27c5f4556044..28f4eab82a09 100644
--- a/drivers/regulator/max77686.c
+++ b/drivers/regulator/max77686.c
@@ -519,8 +519,7 @@ static int max77686_pmic_probe(struct platform_device *pdev)
config.init_data = pdata->regulators[i].initdata;
config.of_node = pdata->regulators[i].of_node;
- max77686->opmode[id] = regulators[i].enable_mask >>
- max77686_get_opmode_shift(id);
+ max77686->opmode[id] = MAX77686_NORMAL;
rdev = devm_regulator_register(&pdev->dev,
®ulators[i], &config);
if (IS_ERR(rdev)) {
--
1.9.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 2/6] regulator: max77686: Initialize opmode explicitly to normal mode
2014-11-04 8:49 ` [PATCH 2/6] regulator: max77686: Initialize opmode explicitly to normal mode Krzysztof Kozlowski
@ 2014-11-04 20:42 ` Mark Brown
0 siblings, 0 replies; 16+ messages in thread
From: Mark Brown @ 2014-11-04 20:42 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Samuel Ortiz, Lee Jones, Liam Girdwood, linux-kernel,
Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas
[-- Attachment #1: Type: text/plain, Size: 186 bytes --]
On Tue, Nov 04, 2014 at 09:49:42AM +0100, Krzysztof Kozlowski wrote:
> Minor nit: Initialize the opmode for each regulator to normal mode in a
> readable explicit way.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* [RFT 3/6] regulator: max77802: Don't ignore return value of current opmode
2014-11-04 8:49 [PATCH 0/6] regulator: max77686/802: Cleanup Krzysztof Kozlowski
2014-11-04 8:49 ` [PATCH 1/6] regulator: max77686: Consistently index opmode array by rdev id Krzysztof Kozlowski
2014-11-04 8:49 ` [PATCH 2/6] regulator: max77686: Initialize opmode explicitly to normal mode Krzysztof Kozlowski
@ 2014-11-04 8:49 ` Krzysztof Kozlowski
2014-11-04 20:47 ` Mark Brown
2014-11-04 8:49 ` [RFT 4/6] regulator: max77802: Remove support for board files Krzysztof Kozlowski
` (4 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Krzysztof Kozlowski @ 2014-11-04 8:49 UTC (permalink / raw)
To: Samuel Ortiz, Lee Jones, Liam Girdwood, Mark Brown, linux-kernel
Cc: Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas, Krzysztof Kozlowski
The return value of regmap_read() of current opmode for regulator was
silently ignored and whatever happened to be in 'val' variable was used
as new opmode. This could lead to using bogus opmode.
Don't ignore what regmap_read() returns. If it fails just fall back to
normal opmode.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
---
drivers/regulator/max77802.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c
index a0d146278b76..7cbff7038b43 100644
--- a/drivers/regulator/max77802.c
+++ b/drivers/regulator/max77802.c
@@ -606,7 +606,13 @@ static int max77802_pmic_probe(struct platform_device *pdev)
config.of_node = pdata->regulators[i].of_node;
ret = regmap_read(iodev->regmap, regulators[i].enable_reg, &val);
- val = val >> shift & MAX77802_OPMODE_MASK;
+ if (ret < 0) {
+ dev_warn(&pdev->dev,
+ "cannot read current mode for %d\n", i);
+ val = MAX77802_OPMODE_NORMAL;
+ } else {
+ val = val >> shift & MAX77802_OPMODE_MASK;
+ }
/*
* If the regulator is disabled and the system warm rebooted,
--
1.9.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [RFT 3/6] regulator: max77802: Don't ignore return value of current opmode
2014-11-04 8:49 ` [RFT 3/6] regulator: max77802: Don't ignore return value of current opmode Krzysztof Kozlowski
@ 2014-11-04 20:47 ` Mark Brown
0 siblings, 0 replies; 16+ messages in thread
From: Mark Brown @ 2014-11-04 20:47 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Samuel Ortiz, Lee Jones, Liam Girdwood, linux-kernel,
Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas
[-- Attachment #1: Type: text/plain, Size: 289 bytes --]
On Tue, Nov 04, 2014 at 09:49:43AM +0100, Krzysztof Kozlowski wrote:
> The return value of regmap_read() of current opmode for regulator was
> silently ignored and whatever happened to be in 'val' variable was used
> as new opmode. This could lead to using bogus opmode.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* [RFT 4/6] regulator: max77802: Remove support for board files
2014-11-04 8:49 [PATCH 0/6] regulator: max77686/802: Cleanup Krzysztof Kozlowski
` (2 preceding siblings ...)
2014-11-04 8:49 ` [RFT 3/6] regulator: max77802: Don't ignore return value of current opmode Krzysztof Kozlowski
@ 2014-11-04 8:49 ` Krzysztof Kozlowski
2014-11-04 8:49 ` [PATCH 5/6] regulator: max77686: " Krzysztof Kozlowski
` (3 subsequent siblings)
7 siblings, 0 replies; 16+ messages in thread
From: Krzysztof Kozlowski @ 2014-11-04 8:49 UTC (permalink / raw)
To: Samuel Ortiz, Lee Jones, Liam Girdwood, Mark Brown, linux-kernel
Cc: Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas, Krzysztof Kozlowski
The driver is used only on Exynos based boards with DTS support.
Simplify the driver and remove dead (unused) entries in platform_data
structure.
Convert the driver to DTS-only version. Parse all regulators at once,
not one-by-one. Remove dependency on data provided by max77686 MFD
driver. Use new DT style parsing method for regulators init data.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
drivers/regulator/max77802.c | 92 +++++++++-----------------------------------
1 file changed, 19 insertions(+), 73 deletions(-)
diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c
index 7cbff7038b43..f91bc43a6808 100644
--- a/drivers/regulator/max77802.c
+++ b/drivers/regulator/max77802.c
@@ -70,6 +70,7 @@ static unsigned int ramp_table_77802_4bit[] = {
};
struct max77802_regulator_prv {
+ /* Array indexed by regulator id */
unsigned int opmode[MAX77802_REG_MAX];
};
@@ -362,6 +363,8 @@ static struct regulator_ops max77802_buck_dvs_ops = {
/* LDOs 3-7, 9-14, 18-26, 28, 29, 32-34 */
#define regulator_77802_desc_p_ldo(num, supply, log) { \
.name = "LDO"#num, \
+ .of_match = of_match_ptr("LDO"#num), \
+ .regulators_node = of_match_ptr("regulators"), \
.id = MAX77802_LDO##num, \
.supply_name = "inl"#supply, \
.ops = &max77802_ldo_ops_logic##log, \
@@ -380,6 +383,8 @@ static struct regulator_ops max77802_buck_dvs_ops = {
/* LDOs 1, 2, 8, 15, 17, 27, 30, 35 */
#define regulator_77802_desc_n_ldo(num, supply, log) { \
.name = "LDO"#num, \
+ .of_match = of_match_ptr("LDO"#num), \
+ .regulators_node = of_match_ptr("regulators"), \
.id = MAX77802_LDO##num, \
.supply_name = "inl"#supply, \
.ops = &max77802_ldo_ops_logic##log, \
@@ -398,6 +403,8 @@ static struct regulator_ops max77802_buck_dvs_ops = {
/* BUCKs 1, 6 */
#define regulator_77802_desc_16_buck(num) { \
.name = "BUCK"#num, \
+ .of_match = of_match_ptr("BUCK"#num), \
+ .regulators_node = of_match_ptr("regulators"), \
.id = MAX77802_BUCK##num, \
.supply_name = "inb"#num, \
.ops = &max77802_buck_16_dvs_ops, \
@@ -416,6 +423,8 @@ static struct regulator_ops max77802_buck_dvs_ops = {
/* BUCKS 2-4 */
#define regulator_77802_desc_234_buck(num) { \
.name = "BUCK"#num, \
+ .of_match = of_match_ptr("BUCK"#num), \
+ .regulators_node = of_match_ptr("regulators"), \
.id = MAX77802_BUCK##num, \
.supply_name = "inb"#num, \
.ops = &max77802_buck_234_ops, \
@@ -435,6 +444,8 @@ static struct regulator_ops max77802_buck_dvs_ops = {
/* BUCK 5 */
#define regulator_77802_desc_buck5(num) { \
.name = "BUCK"#num, \
+ .of_match = of_match_ptr("BUCK"#num), \
+ .regulators_node = of_match_ptr("regulators"), \
.id = MAX77802_BUCK##num, \
.supply_name = "inb"#num, \
.ops = &max77802_buck_dvs_ops, \
@@ -453,6 +464,8 @@ static struct regulator_ops max77802_buck_dvs_ops = {
/* BUCKs 7-10 */
#define regulator_77802_desc_buck7_10(num) { \
.name = "BUCK"#num, \
+ .of_match = of_match_ptr("BUCK"#num), \
+ .regulators_node = of_match_ptr("regulators"), \
.id = MAX77802_BUCK##num, \
.supply_name = "inb"#num, \
.ops = &max77802_buck_dvs_ops, \
@@ -513,85 +526,19 @@ static const struct regulator_desc regulators[] = {
regulator_77802_desc_n_ldo(35, 2, 1),
};
-#ifdef CONFIG_OF
-static int max77802_pmic_dt_parse_pdata(struct platform_device *pdev,
- struct max77686_platform_data *pdata)
-{
- struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
- struct device_node *pmic_np, *regulators_np;
- struct max77686_regulator_data *rdata;
- struct of_regulator_match rmatch;
- unsigned int i;
-
- pmic_np = iodev->dev->of_node;
- regulators_np = of_get_child_by_name(pmic_np, "regulators");
- if (!regulators_np) {
- dev_err(&pdev->dev, "could not find regulators sub-node\n");
- return -EINVAL;
- }
-
- pdata->num_regulators = ARRAY_SIZE(regulators);
- rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) *
- pdata->num_regulators, GFP_KERNEL);
- if (!rdata) {
- of_node_put(regulators_np);
- return -ENOMEM;
- }
-
- for (i = 0; i < pdata->num_regulators; i++) {
- rmatch.name = regulators[i].name;
- rmatch.init_data = NULL;
- rmatch.of_node = NULL;
- if (of_regulator_match(&pdev->dev, regulators_np, &rmatch,
- 1) != 1) {
- dev_warn(&pdev->dev, "No matching regulator for '%s'\n",
- rmatch.name);
- continue;
- }
- rdata[i].initdata = rmatch.init_data;
- rdata[i].of_node = rmatch.of_node;
- rdata[i].id = regulators[i].id;
- }
-
- pdata->regulators = rdata;
- of_node_put(regulators_np);
-
- return 0;
-}
-#else
-static int max77802_pmic_dt_parse_pdata(struct platform_device *pdev,
- struct max77686_platform_data *pdata)
-{
- return 0;
-}
-#endif /* CONFIG_OF */
-
static int max77802_pmic_probe(struct platform_device *pdev)
{
struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
- struct max77686_platform_data *pdata = dev_get_platdata(iodev->dev);
struct max77802_regulator_prv *max77802;
- int i, ret = 0, val;
+ int i, val;
struct regulator_config config = { };
- /* This is allocated by the MFD driver */
- if (!pdata) {
- dev_err(&pdev->dev, "no platform data found for regulator\n");
- return -ENODEV;
- }
-
max77802 = devm_kzalloc(&pdev->dev,
sizeof(struct max77802_regulator_prv),
GFP_KERNEL);
if (!max77802)
return -ENOMEM;
- if (iodev->dev->of_node) {
- ret = max77802_pmic_dt_parse_pdata(pdev, pdata);
- if (ret)
- return ret;
- }
-
config.dev = iodev->dev;
config.regmap = iodev->regmap;
config.driver_data = max77802;
@@ -599,11 +546,9 @@ static int max77802_pmic_probe(struct platform_device *pdev)
for (i = 0; i < MAX77802_REG_MAX; i++) {
struct regulator_dev *rdev;
- int id = pdata->regulators[i].id;
+ int id = regulators[i].id;
int shift = max77802_get_opmode_shift(id);
-
- config.init_data = pdata->regulators[i].initdata;
- config.of_node = pdata->regulators[i].of_node;
+ int ret;
ret = regmap_read(iodev->regmap, regulators[i].enable_reg, &val);
if (ret < 0) {
@@ -627,9 +572,10 @@ static int max77802_pmic_probe(struct platform_device *pdev)
rdev = devm_regulator_register(&pdev->dev,
®ulators[i], &config);
if (IS_ERR(rdev)) {
+ ret = PTR_ERR(rdev);
dev_err(&pdev->dev,
- "regulator init failed for %d\n", i);
- return PTR_ERR(rdev);
+ "regulator init failed for %d: %d\n", i, ret);
+ return ret;
}
}
--
1.9.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 5/6] regulator: max77686: Remove support for board files
2014-11-04 8:49 [PATCH 0/6] regulator: max77686/802: Cleanup Krzysztof Kozlowski
` (3 preceding siblings ...)
2014-11-04 8:49 ` [RFT 4/6] regulator: max77802: Remove support for board files Krzysztof Kozlowski
@ 2014-11-04 8:49 ` Krzysztof Kozlowski
2014-11-04 20:46 ` Mark Brown
2014-11-04 8:49 ` [PATCH 6/6] mfd: max77686/802: " Krzysztof Kozlowski
` (2 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Krzysztof Kozlowski @ 2014-11-04 8:49 UTC (permalink / raw)
To: Samuel Ortiz, Lee Jones, Liam Girdwood, Mark Brown, linux-kernel
Cc: Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas, Krzysztof Kozlowski
The driver is used only on Exynos based boards with DTS support.
Simplify the driver and remove dead (unused) entries in platform_data
structure.
Convert the driver to DTS-only version. Parse all regulators at once,
not one-by-one. Remove dependency on data provided by max77686 MFD
driver. Use new DT style parsing method for regulators init data.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
drivers/regulator/max77686.c | 91 +++++++++-----------------------------------
1 file changed, 19 insertions(+), 72 deletions(-)
diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c
index 28f4eab82a09..871b96bcd2d0 100644
--- a/drivers/regulator/max77686.c
+++ b/drivers/regulator/max77686.c
@@ -281,6 +281,8 @@ static struct regulator_ops max77686_buck_dvs_ops = {
#define regulator_desc_ldo(num) { \
.name = "LDO"#num, \
+ .of_match = of_match_ptr("LDO"#num), \
+ .regulators_node = of_match_ptr("voltage-regulators"), \
.id = MAX77686_LDO##num, \
.ops = &max77686_ops, \
.type = REGULATOR_VOLTAGE, \
@@ -297,6 +299,8 @@ static struct regulator_ops max77686_buck_dvs_ops = {
}
#define regulator_desc_lpm_ldo(num) { \
.name = "LDO"#num, \
+ .of_match = of_match_ptr("LDO"#num), \
+ .regulators_node = of_match_ptr("voltage-regulators"), \
.id = MAX77686_LDO##num, \
.ops = &max77686_ldo_ops, \
.type = REGULATOR_VOLTAGE, \
@@ -313,6 +317,8 @@ static struct regulator_ops max77686_buck_dvs_ops = {
}
#define regulator_desc_ldo_low(num) { \
.name = "LDO"#num, \
+ .of_match = of_match_ptr("LDO"#num), \
+ .regulators_node = of_match_ptr("voltage-regulators"), \
.id = MAX77686_LDO##num, \
.ops = &max77686_ldo_ops, \
.type = REGULATOR_VOLTAGE, \
@@ -329,6 +335,8 @@ static struct regulator_ops max77686_buck_dvs_ops = {
}
#define regulator_desc_ldo1_low(num) { \
.name = "LDO"#num, \
+ .of_match = of_match_ptr("LDO"#num), \
+ .regulators_node = of_match_ptr("voltage-regulators"), \
.id = MAX77686_LDO##num, \
.ops = &max77686_ops, \
.type = REGULATOR_VOLTAGE, \
@@ -345,6 +353,8 @@ static struct regulator_ops max77686_buck_dvs_ops = {
}
#define regulator_desc_buck(num) { \
.name = "BUCK"#num, \
+ .of_match = of_match_ptr("BUCK"#num), \
+ .regulators_node = of_match_ptr("voltage-regulators"), \
.id = MAX77686_BUCK##num, \
.ops = &max77686_ops, \
.type = REGULATOR_VOLTAGE, \
@@ -360,6 +370,8 @@ static struct regulator_ops max77686_buck_dvs_ops = {
}
#define regulator_desc_buck1(num) { \
.name = "BUCK"#num, \
+ .of_match = of_match_ptr("BUCK"#num), \
+ .regulators_node = of_match_ptr("voltage-regulators"), \
.id = MAX77686_BUCK##num, \
.ops = &max77686_buck1_ops, \
.type = REGULATOR_VOLTAGE, \
@@ -375,6 +387,8 @@ static struct regulator_ops max77686_buck_dvs_ops = {
}
#define regulator_desc_buck_dvs(num) { \
.name = "BUCK"#num, \
+ .of_match = of_match_ptr("BUCK"#num), \
+ .regulators_node = of_match_ptr("voltage-regulators"), \
.id = MAX77686_BUCK##num, \
.ops = &max77686_buck_dvs_ops, \
.type = REGULATOR_VOLTAGE, \
@@ -428,86 +442,21 @@ static const struct regulator_desc regulators[] = {
regulator_desc_buck(9),
};
-#ifdef CONFIG_OF
-static int max77686_pmic_dt_parse_pdata(struct platform_device *pdev,
- struct max77686_platform_data *pdata)
-{
- struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
- struct device_node *pmic_np, *regulators_np;
- struct max77686_regulator_data *rdata;
- struct of_regulator_match rmatch;
- unsigned int i;
-
- pmic_np = iodev->dev->of_node;
- regulators_np = of_get_child_by_name(pmic_np, "voltage-regulators");
- if (!regulators_np) {
- dev_err(&pdev->dev, "could not find regulators sub-node\n");
- return -EINVAL;
- }
-
- pdata->num_regulators = ARRAY_SIZE(regulators);
- rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) *
- pdata->num_regulators, GFP_KERNEL);
- if (!rdata) {
- of_node_put(regulators_np);
- return -ENOMEM;
- }
-
- for (i = 0; i < pdata->num_regulators; i++) {
- rmatch.name = regulators[i].name;
- rmatch.init_data = NULL;
- rmatch.of_node = NULL;
- of_regulator_match(&pdev->dev, regulators_np, &rmatch, 1);
- rdata[i].initdata = rmatch.init_data;
- rdata[i].of_node = rmatch.of_node;
- }
-
- pdata->regulators = rdata;
- of_node_put(regulators_np);
-
- return 0;
-}
-#else
-static int max77686_pmic_dt_parse_pdata(struct platform_device *pdev,
- struct max77686_platform_data *pdata)
-{
- return 0;
-}
-#endif /* CONFIG_OF */
-
static int max77686_pmic_probe(struct platform_device *pdev)
{
struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
- struct max77686_platform_data *pdata = dev_get_platdata(iodev->dev);
struct max77686_data *max77686;
- int i, ret = 0;
+ int i;
struct regulator_config config = { };
dev_dbg(&pdev->dev, "%s\n", __func__);
- if (!pdata) {
- dev_err(&pdev->dev, "no platform data found for regulator\n");
- return -ENODEV;
- }
-
- if (iodev->dev->of_node) {
- ret = max77686_pmic_dt_parse_pdata(pdev, pdata);
- if (ret)
- return ret;
- }
-
- if (pdata->num_regulators != MAX77686_REGULATORS) {
- dev_err(&pdev->dev,
- "Invalid initial data for regulator's initialiation\n");
- return -EINVAL;
- }
-
max77686 = devm_kzalloc(&pdev->dev, sizeof(struct max77686_data),
GFP_KERNEL);
if (!max77686)
return -ENOMEM;
- config.dev = &pdev->dev;
+ config.dev = iodev->dev;
config.regmap = iodev->regmap;
config.driver_data = max77686;
platform_set_drvdata(pdev, max77686);
@@ -516,16 +465,14 @@ static int max77686_pmic_probe(struct platform_device *pdev)
struct regulator_dev *rdev;
int id = regulators[i].id;
- config.init_data = pdata->regulators[i].initdata;
- config.of_node = pdata->regulators[i].of_node;
-
max77686->opmode[id] = MAX77686_NORMAL;
rdev = devm_regulator_register(&pdev->dev,
®ulators[i], &config);
if (IS_ERR(rdev)) {
+ int ret = PTR_ERR(rdev);
dev_err(&pdev->dev,
- "regulator init failed for %d\n", i);
- return PTR_ERR(rdev);
+ "regulator init failed for %d: %d\n", i, ret);
+ return ret;
}
}
--
1.9.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 5/6] regulator: max77686: Remove support for board files
2014-11-04 8:49 ` [PATCH 5/6] regulator: max77686: " Krzysztof Kozlowski
@ 2014-11-04 20:46 ` Mark Brown
2014-11-05 8:33 ` Krzysztof Kozlowski
0 siblings, 1 reply; 16+ messages in thread
From: Mark Brown @ 2014-11-04 20:46 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Samuel Ortiz, Lee Jones, Liam Girdwood, linux-kernel,
Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas
[-- Attachment #1: Type: text/plain, Size: 718 bytes --]
On Tue, Nov 04, 2014 at 09:49:45AM +0100, Krzysztof Kozlowski wrote:
> The driver is used only on Exynos based boards with DTS support.
> Simplify the driver and remove dead (unused) entries in platform_data
> structure.
This mostly isn't actually removing platform data support as far as I
can see? It's removing some spurious error checks for missing platform
data (which is good) and converting to use the core DT parsing (which is
also good) but just leaving this:
> - struct max77686_platform_data *pdata = dev_get_platdata(iodev->dev);
> - config.init_data = pdata->regulators[i].initdata;
would keep platform data support there. What problem is removing
platform data support solving?
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 5/6] regulator: max77686: Remove support for board files
2014-11-04 20:46 ` Mark Brown
@ 2014-11-05 8:33 ` Krzysztof Kozlowski
0 siblings, 0 replies; 16+ messages in thread
From: Krzysztof Kozlowski @ 2014-11-05 8:33 UTC (permalink / raw)
To: Mark Brown
Cc: Samuel Ortiz, Lee Jones, Liam Girdwood, linux-kernel,
Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas
On wto, 2014-11-04 at 20:46 +0000, Mark Brown wrote:
> On Tue, Nov 04, 2014 at 09:49:45AM +0100, Krzysztof Kozlowski wrote:
> > The driver is used only on Exynos based boards with DTS support.
> > Simplify the driver and remove dead (unused) entries in platform_data
> > structure.
>
> This mostly isn't actually removing platform data support as far as I
> can see? It's removing some spurious error checks for missing platform
> data (which is good) and converting to use the core DT parsing (which is
> also good) but just leaving this:
>
> > - struct max77686_platform_data *pdata = dev_get_platdata(iodev->dev);
>
> > - config.init_data = pdata->regulators[i].initdata;
>
> would keep platform data support there. What problem is removing
> platform data support solving?
There isn't specific problem to solve. The purpose here is to remove
legacy and old code which really is not used. On Samsung boards with
mainline kernel the platform data is not used for a long, long time.
On our vendor kernels (for example these published on
opensource.samsung.com for Android and Tizen devices) this driver is not
used... because whole kernel is different and all drivers for Samsung
specific stuff (SoC, PMIC, sensors, LCD etc.) are developed by vendor.
In my humble opinion there aren't any users of this code. Removing it
helps in maintaining the driver.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 6/6] mfd: max77686/802: Remove support for board files
2014-11-04 8:49 [PATCH 0/6] regulator: max77686/802: Cleanup Krzysztof Kozlowski
` (4 preceding siblings ...)
2014-11-04 8:49 ` [PATCH 5/6] regulator: max77686: " Krzysztof Kozlowski
@ 2014-11-04 8:49 ` Krzysztof Kozlowski
2014-11-04 9:24 ` [PATCH 0/6] regulator: max77686/802: Cleanup Javier Martinez Canillas
2014-11-04 9:25 ` Krzysztof Kozlowski
7 siblings, 0 replies; 16+ messages in thread
From: Krzysztof Kozlowski @ 2014-11-04 8:49 UTC (permalink / raw)
To: Samuel Ortiz, Lee Jones, Liam Girdwood, Mark Brown, linux-kernel
Cc: Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas, Krzysztof Kozlowski
The driver is used only on Exynos based boards with DTS support.
After removal of board file support from max77686 and max77802 regulator
drivers, the MFD driver can be converted to DTS-only version. This
simplifies a little the code:
1. No dead (unused) entries in platform_data structure.
2. More code removed.
3. Regulator driver does not depend on allocated memory
from MFD driver.
4. It makes also easier extending the regulator driver.
Add to the max77686 MFD driver dependency on CONFIG_OF because without
DTS the regulator drivers (max77686 and max77802) won't bind.
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Acked-by: Lee Jones <lee.jones@linaro.org>
---
drivers/mfd/Kconfig | 1 +
drivers/mfd/max77686.c | 23 -----------------------
include/linux/mfd/max77686-private.h | 1 -
include/linux/mfd/max77686.h | 28 ----------------------------
4 files changed, 1 insertion(+), 52 deletions(-)
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index cbdb10918af1..fd9d19ccf8c0 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -401,6 +401,7 @@ config MFD_MAX14577
config MFD_MAX77686
bool "Maxim Semiconductor MAX77686/802 PMIC Support"
depends on I2C=y
+ depends on OF
select MFD_CORE
select REGMAP_I2C
select REGMAP_IRQ
diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c
index 929795eae9fc..3da237afacde 100644
--- a/drivers/mfd/max77686.c
+++ b/drivers/mfd/max77686.c
@@ -205,24 +205,10 @@ static const struct of_device_id max77686_pmic_dt_match[] = {
{ },
};
-static struct max77686_platform_data *max77686_i2c_parse_dt_pdata(struct device
- *dev)
-{
- struct max77686_platform_data *pd;
-
- pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
- if (!pd)
- return NULL;
-
- dev->platform_data = pd;
- return pd;
-}
-
static int max77686_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct max77686_dev *max77686 = NULL;
- struct max77686_platform_data *pdata = dev_get_platdata(&i2c->dev);
const struct of_device_id *match;
unsigned int data;
int ret = 0;
@@ -233,14 +219,6 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
const struct mfd_cell *cells;
int n_devs;
- if (IS_ENABLED(CONFIG_OF) && i2c->dev.of_node && !pdata)
- pdata = max77686_i2c_parse_dt_pdata(&i2c->dev);
-
- if (!pdata) {
- dev_err(&i2c->dev, "No platform data found.\n");
- return -EINVAL;
- }
-
max77686 = devm_kzalloc(&i2c->dev,
sizeof(struct max77686_dev), GFP_KERNEL);
if (!max77686)
@@ -259,7 +237,6 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
max77686->dev = &i2c->dev;
max77686->i2c = i2c;
- max77686->wakeup = pdata->wakeup;
max77686->irq = i2c->irq;
if (max77686->type == TYPE_MAX77686) {
diff --git a/include/linux/mfd/max77686-private.h b/include/linux/mfd/max77686-private.h
index 960b92ad450d..f5043490d67c 100644
--- a/include/linux/mfd/max77686-private.h
+++ b/include/linux/mfd/max77686-private.h
@@ -447,7 +447,6 @@ struct max77686_dev {
struct regmap_irq_chip_data *rtc_irq_data;
int irq;
- bool wakeup;
struct mutex irqlock;
int irq_masks_cur[MAX77686_IRQ_GROUP_NR];
int irq_masks_cache[MAX77686_IRQ_GROUP_NR];
diff --git a/include/linux/mfd/max77686.h b/include/linux/mfd/max77686.h
index 553f7d09258a..bb995ab9a575 100644
--- a/include/linux/mfd/max77686.h
+++ b/include/linux/mfd/max77686.h
@@ -119,12 +119,6 @@ enum max77802_regulators {
MAX77802_REG_MAX,
};
-struct max77686_regulator_data {
- int id;
- struct regulator_init_data *initdata;
- struct device_node *of_node;
-};
-
enum max77686_opmode {
MAX77686_OPMODE_NORMAL,
MAX77686_OPMODE_LP,
@@ -136,26 +130,4 @@ struct max77686_opmode_data {
int mode;
};
-struct max77686_platform_data {
- int ono;
- int wakeup;
-
- /* ---- PMIC ---- */
- struct max77686_regulator_data *regulators;
- int num_regulators;
-
- struct max77686_opmode_data *opmode_data;
-
- /*
- * GPIO-DVS feature is not enabled with the current version of
- * MAX77686 driver. Buck2/3/4_voltages[0] is used as the default
- * voltage at probe. DVS/SELB gpios are set as OUTPUT-LOW.
- */
- int buck234_gpio_dvs[3]; /* GPIO of [0]DVS1, [1]DVS2, [2]DVS3 */
- int buck234_gpio_selb[3]; /* [0]SELB2, [1]SELB3, [2]SELB4 */
- unsigned int buck2_voltage[8]; /* buckx_voltage in uV */
- unsigned int buck3_voltage[8];
- unsigned int buck4_voltage[8];
-};
-
#endif /* __LINUX_MFD_MAX77686_H */
--
1.9.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 0/6] regulator: max77686/802: Cleanup
2014-11-04 8:49 [PATCH 0/6] regulator: max77686/802: Cleanup Krzysztof Kozlowski
` (5 preceding siblings ...)
2014-11-04 8:49 ` [PATCH 6/6] mfd: max77686/802: " Krzysztof Kozlowski
@ 2014-11-04 9:24 ` Javier Martinez Canillas
2014-11-04 9:25 ` Krzysztof Kozlowski
7 siblings, 0 replies; 16+ messages in thread
From: Javier Martinez Canillas @ 2014-11-04 9:24 UTC (permalink / raw)
To: Krzysztof Kozlowski, Samuel Ortiz, Lee Jones, Liam Girdwood,
Mark Brown, linux-kernel
Cc: Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz
Hello Krzysztof,
On 11/04/2014 09:49 AM, Krzysztof Kozlowski wrote:
> Previously this patchset was part of adding GPIO to max77686
> regulator driver [1]. I split it but the goal is the same:
> cleanup and simplify the regulator drivers by removing obsolete
> board file support so adding new features would be easier.
>
This series will conflict with fixes that Mark applied yesterday:
ecea748 ("regulator: max77802: zero-initialize regulator match table")
050cf85 ("regulator: max77686: zero-initialize regulator match table")
You should base on top of the regulator for-next branch.
Best regards,
Javier
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 0/6] regulator: max77686/802: Cleanup
2014-11-04 8:49 [PATCH 0/6] regulator: max77686/802: Cleanup Krzysztof Kozlowski
` (6 preceding siblings ...)
2014-11-04 9:24 ` [PATCH 0/6] regulator: max77686/802: Cleanup Javier Martinez Canillas
@ 2014-11-04 9:25 ` Krzysztof Kozlowski
2014-11-04 20:42 ` Mark Brown
7 siblings, 1 reply; 16+ messages in thread
From: Krzysztof Kozlowski @ 2014-11-04 9:25 UTC (permalink / raw)
To: Samuel Ortiz
Cc: Lee Jones, Liam Girdwood, Mark Brown, linux-kernel,
Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas
On wto, 2014-11-04 at 09:49 +0100, Krzysztof Kozlowski wrote:
> Hi,
>
>
> Previously this patchset was part of adding GPIO to max77686
> regulator driver [1]. I split it but the goal is the same:
> cleanup and simplify the regulator drivers by removing obsolete
> board file support so adding new features would be easier.
>
> The patchset removes board file support from regulator drivers
> incrementally and in a bisect-friendly way. Thus MFD driver is
> updated at the end.
>
> Everything should be pulled at once (preferrably regulator tree).
> Rebased on next-20141031.
Probably I should rebase it on newer next or regulator tree because
yesterdays Javier's changes were applied. The merge conflict is trivial
to solve (only removal of lines).
Mark, let me know if you want me to resubmit because of the conflict.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 0/6] regulator: max77686/802: Cleanup
2014-11-04 9:25 ` Krzysztof Kozlowski
@ 2014-11-04 20:42 ` Mark Brown
2014-11-05 8:34 ` Krzysztof Kozlowski
0 siblings, 1 reply; 16+ messages in thread
From: Mark Brown @ 2014-11-04 20:42 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Samuel Ortiz, Lee Jones, Liam Girdwood, linux-kernel,
Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas
[-- Attachment #1: Type: text/plain, Size: 363 bytes --]
On Tue, Nov 04, 2014 at 10:25:22AM +0100, Krzysztof Kozlowski wrote:
> Probably I should rebase it on newer next or regulator tree because
> yesterdays Javier's changes were applied. The merge conflict is trivial
> to solve (only removal of lines).
> Mark, let me know if you want me to resubmit because of the conflict.
Send me something I can apply, please.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 0/6] regulator: max77686/802: Cleanup
2014-11-04 20:42 ` Mark Brown
@ 2014-11-05 8:34 ` Krzysztof Kozlowski
0 siblings, 0 replies; 16+ messages in thread
From: Krzysztof Kozlowski @ 2014-11-05 8:34 UTC (permalink / raw)
To: Mark Brown
Cc: Samuel Ortiz, Lee Jones, Liam Girdwood, linux-kernel,
Kyungmin Park, Marek Szyprowski, Bartlomiej Zolnierkiewicz,
Javier Martinez Canillas
On wto, 2014-11-04 at 20:42 +0000, Mark Brown wrote:
> On Tue, Nov 04, 2014 at 10:25:22AM +0100, Krzysztof Kozlowski wrote:
>
> > Probably I should rebase it on newer next or regulator tree because
> > yesterdays Javier's changes were applied. The merge conflict is trivial
> > to solve (only removal of lines).
>
> > Mark, let me know if you want me to resubmit because of the conflict.
>
> Send me something I can apply, please.
Thanks for applying first three patches. I'll send rebased version.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 16+ messages in thread