2013-07-08 12:59:49

by Yadwinder Singh Brar

[permalink] [raw]
Subject: [v2 PATCH 0/6] Add DT support for s2mps11

Mainly this series adds dt support for s2mps11 in mfd and regulator driver.

changes since v1:
- As suggested by Mark, used regulator-ramp-delay = <0> as ramp_disable and
Moved the ramp_disable into regulator constraints as it is quite generic.
- Implemented set_ramp_delay callback, to make driver simple and in more
compliance with framework.
- Modified Documentation accordingly.
- Fixed some NITs pointed by Sachin.

It also includes a patch to remove some redundant checks in _regulator_do_set_voltage().

Yadwinder Singh Brar (6):
regulator: core: Add support for disabling ramp delay
regulator: s2mps11: Implement set_ramp_rate callback for bucks
regulator: s2mps11: Add DT support
regulator: s2mps11: Convert driver completely to use set_ramp_delay
callback
regulator: core: Remove redundant checks
mfd: s2mps11: Add device tree support

Documentation/devicetree/bindings/mfd/s2mps11.txt | 89 +++++++++
.../devicetree/bindings/regulator/regulator.txt | 2 +
drivers/mfd/sec-core.c | 3 +
drivers/regulator/core.c | 7 +-
drivers/regulator/of_regulator.c | 12 +-
drivers/regulator/s2mps11.c | 203 +++++++++++++++-----
include/linux/mfd/samsung/s2mps11.h | 11 +
include/linux/regulator/machine.h | 1 +
8 files changed, 270 insertions(+), 58 deletions(-)
create mode 100644 Documentation/devicetree/bindings/mfd/s2mps11.txt


2013-07-08 12:59:56

by Yadwinder Singh Brar

[permalink] [raw]
Subject: [v2 PATCH 1/6] regulator: core: Add support for disabling ramp delay

Some hardwares support disabling ramp delay, so adding ramp_disable flag to
constraints. It will be used to figure out whether ramp_delay in constraints
is explicitly set to zero or its unintialized (zero by default).
And we don't need to call set_voltage_time_sel() for regulators for whom ramp
delay is disabled in constraints.

Signed-off-by: Yadwinder Singh Brar <[email protected]>
---
.../devicetree/bindings/regulator/regulator.txt | 2 ++
drivers/regulator/core.c | 6 ++++--
drivers/regulator/of_regulator.c | 12 +++++++++---
include/linux/regulator/machine.h | 1 +
4 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/regulator/regulator.txt b/Documentation/devicetree/bindings/regulator/regulator.txt
index 48a3b8e..2bd8f09 100644
--- a/Documentation/devicetree/bindings/regulator/regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/regulator.txt
@@ -12,6 +12,8 @@ Optional properties:
- regulator-allow-bypass: allow the regulator to go into bypass mode
- <name>-supply: phandle to the parent supply/regulator node
- regulator-ramp-delay: ramp delay for regulator(in uV/uS)
+ For hardwares which support disabling ramp rate, it should be explicitly
+ intialised to zero (regulator-ramp-delay = <0>) for disabling ramp delay.

Deprecated properties:
- regulator-compatible: If a regulator chip contains multiple
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 288c75a..6e6371c 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -984,7 +984,8 @@ static int set_machine_constraints(struct regulator_dev *rdev,
}
}

- if (rdev->constraints->ramp_delay && ops->set_ramp_delay) {
+ if ((rdev->constraints->ramp_delay || rdev->constraints->ramp_disable)
+ && ops->set_ramp_delay) {
ret = ops->set_ramp_delay(rdev, rdev->constraints->ramp_delay);
if (ret < 0) {
rdev_err(rdev, "failed to set ramp_delay\n");
@@ -2438,7 +2439,8 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
}

/* Call set_voltage_time_sel if successfully obtained old_selector */
- if (ret == 0 && _regulator_is_enabled(rdev) && old_selector >= 0 &&
+ if (ret == 0 && !rdev->constraints->ramp_disable &&
+ _regulator_is_enabled(rdev) && old_selector >= 0 &&
old_selector != selector && rdev->desc->ops->set_voltage_time_sel) {

delay = rdev->desc->ops->set_voltage_time_sel(rdev,
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index f3c8f8f..7827384 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -21,6 +21,7 @@ static void of_get_regulation_constraints(struct device_node *np,
{
const __be32 *min_uV, *max_uV, *uV_offset;
const __be32 *min_uA, *max_uA, *ramp_delay;
+ struct property *prop;
struct regulation_constraints *constraints = &(*init_data)->constraints;

constraints->name = of_get_property(np, "regulator-name", NULL);
@@ -64,9 +65,14 @@ static void of_get_regulation_constraints(struct device_node *np,
if (of_property_read_bool(np, "regulator-allow-bypass"))
constraints->valid_ops_mask |= REGULATOR_CHANGE_BYPASS;

- ramp_delay = of_get_property(np, "regulator-ramp-delay", NULL);
- if (ramp_delay)
- constraints->ramp_delay = be32_to_cpu(*ramp_delay);
+ prop = of_find_property(np, "regulator-ramp-delay", NULL);
+ if (prop && prop->value) {
+ ramp_delay = prop->value;
+ if (*ramp_delay)
+ constraints->ramp_delay = be32_to_cpu(*ramp_delay);
+ else
+ constraints->ramp_disable = true;
+ }
}

/**
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h
index 36adbc8..999b20c 100644
--- a/include/linux/regulator/machine.h
+++ b/include/linux/regulator/machine.h
@@ -134,6 +134,7 @@ struct regulation_constraints {
unsigned always_on:1; /* regulator never off when system is on */
unsigned boot_on:1; /* bootloader/firmware enabled regulator */
unsigned apply_uV:1; /* apply uV constraint if min == max */
+ unsigned ramp_disable:1; /* disable ramp delay */
};

/**
--
1.7.0.4

2013-07-08 13:00:00

by Yadwinder Singh Brar

[permalink] [raw]
Subject: [v2 PATCH 4/6] regulator: s2mps11: Convert driver completely to use set_ramp_delay callback

Since now we have ramp_delay and ramp_disable as standard regulator
constraints and DT part using it so this patch removes legacy part i.e. getting
ramp_delayxx and ramp_enable from pdata since it can be passed as
standard regulator constraints.

Signed-off-by: Yadwinder Singh Brar <[email protected]>
---
drivers/regulator/s2mps11.c | 62 ++++++------------------------------------
1 files changed, 9 insertions(+), 53 deletions(-)

diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
index 4157759..e1aadbd 100644
--- a/drivers/regulator/s2mps11.c
+++ b/drivers/regulator/s2mps11.c
@@ -35,11 +35,6 @@ struct s2mps11_info {
int ramp_delay16;
int ramp_delay7810;
int ramp_delay9;
-
- bool buck6_ramp;
- bool buck2_ramp;
- bool buck3_ramp;
- bool buck4_ramp;
};

static int get_ramp_delay(int ramp_delay)
@@ -67,26 +62,18 @@ static int s2mps11_regulator_set_voltage_time_sel(struct regulator_dev *rdev,

switch (rdev->desc->id) {
case S2MPS11_BUCK2:
- if (!s2mps11->buck2_ramp)
- return 0;
ramp_delay = s2mps11->ramp_delay2;
break;
case S2MPS11_BUCK3:
- if (!s2mps11->buck3_ramp)
- return 0;
ramp_delay = s2mps11->ramp_delay34;
break;
case S2MPS11_BUCK4:
- if (!s2mps11->buck4_ramp)
- return 0;
ramp_delay = s2mps11->ramp_delay34;
break;
case S2MPS11_BUCK5:
ramp_delay = s2mps11->ramp_delay5;
break;
case S2MPS11_BUCK6:
- if (!s2mps11->buck6_ramp)
- return 0;
case S2MPS11_BUCK1:
ramp_delay = s2mps11->ramp_delay16;
break;
@@ -415,15 +402,21 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
struct regulator_config config = { };
struct s2mps11_info *s2mps11;
int i, ret;
- unsigned char ramp_enable, ramp_reg = 0;

s2mps11 = devm_kzalloc(&pdev->dev, sizeof(struct s2mps11_info),
GFP_KERNEL);
if (!s2mps11)
return -ENOMEM;

- if (!iodev->dev->of_node)
- goto p_data;
+ if (!iodev->dev->of_node) {
+ if (pdata) {
+ goto common_reg;
+ } else {
+ dev_err(pdev->dev.parent,
+ "Platform data or DT node not supplied\n");
+ return -ENODEV;
+ }
+ }

for (i = 0; i < S2MPS11_REGULATOR_CNT; i++)
rdata[i].name = regulators[i].name;
@@ -436,43 +429,6 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)

of_regulator_match(&pdev->dev, reg_np, rdata, S2MPS11_REGULATOR_MAX);

- goto common_reg;
-p_data:
- if (!pdata) {
- dev_err(pdev->dev.parent, "Platform data not supplied\n");
- return -ENODEV;
- }
-
- s2mps11->ramp_delay2 = pdata->buck2_ramp_delay;
- s2mps11->ramp_delay34 = pdata->buck34_ramp_delay;
- s2mps11->ramp_delay5 = pdata->buck5_ramp_delay;
- s2mps11->ramp_delay16 = pdata->buck16_ramp_delay;
- s2mps11->ramp_delay7810 = pdata->buck7810_ramp_delay;
- s2mps11->ramp_delay9 = pdata->buck9_ramp_delay;
-
- s2mps11->buck6_ramp = pdata->buck6_ramp_enable;
- s2mps11->buck2_ramp = pdata->buck2_ramp_enable;
- s2mps11->buck3_ramp = pdata->buck3_ramp_enable;
- s2mps11->buck4_ramp = pdata->buck4_ramp_enable;
-
- ramp_enable = (s2mps11->buck2_ramp << 3) | (s2mps11->buck3_ramp << 2) |
- (s2mps11->buck4_ramp << 1) | s2mps11->buck6_ramp ;
-
- if (ramp_enable) {
- if (s2mps11->buck2_ramp)
- ramp_reg |= get_ramp_delay(s2mps11->ramp_delay2) << 6;
- if (s2mps11->buck3_ramp || s2mps11->buck4_ramp)
- ramp_reg |= get_ramp_delay(s2mps11->ramp_delay34) << 4;
- sec_reg_write(iodev, S2MPS11_REG_RAMP, ramp_reg | ramp_enable);
- }
-
- ramp_reg &= 0x00;
- ramp_reg |= get_ramp_delay(s2mps11->ramp_delay5) << 6;
- ramp_reg |= get_ramp_delay(s2mps11->ramp_delay16) << 4;
- ramp_reg |= get_ramp_delay(s2mps11->ramp_delay7810) << 2;
- ramp_reg |= get_ramp_delay(s2mps11->ramp_delay9);
- sec_reg_write(iodev, S2MPS11_REG_RAMP_BUCK, ramp_reg);
-
common_reg:
platform_set_drvdata(pdev, s2mps11);

--
1.7.0.4

2013-07-08 13:00:04

by Yadwinder Singh Brar

[permalink] [raw]
Subject: [v2 PATCH 5/6] regulator: core: Remove redundant checks

In function _regulator_do_set_voltage(), old_selector gets intialised only
if (_regulator_is_enabled(rdev) && rdev->desc->ops->set_voltage_time_sel &&
rdev->desc->ops->get_voltage_sel)) is true.

Before calling set_voltage_time_sel() we checks if (old_selector >= 0) and it
will true if it got intialised properly. so we don't need to check again
_regulator_is_enabled(rdev) && rdev->desc->ops->set_voltage_time_sel before
calling set_voltage_time_sel().

Signed-off-by: Yadwinder Singh Brar <[email protected]>
---
drivers/regulator/core.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 6e6371c..15368f3 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2439,9 +2439,8 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
}

/* Call set_voltage_time_sel if successfully obtained old_selector */
- if (ret == 0 && !rdev->constraints->ramp_disable &&
- _regulator_is_enabled(rdev) && old_selector >= 0 &&
- old_selector != selector && rdev->desc->ops->set_voltage_time_sel) {
+ if (ret == 0 && !rdev->constraints->ramp_disable && old_selector >= 0
+ && old_selector != selector) {

delay = rdev->desc->ops->set_voltage_time_sel(rdev,
old_selector, selector);
--
1.7.0.4

2013-07-08 13:00:30

by Yadwinder Singh Brar

[permalink] [raw]
Subject: [v2 PATCH 6/6] mfd: s2mps11: Add device tree support

This patch adds DT compatible string for s2mps11 and binding documentation.

Signed-off-by: Yadwinder Singh Brar <[email protected]>
---
Documentation/devicetree/bindings/mfd/s2mps11.txt | 89 +++++++++++++++++++++
drivers/mfd/sec-core.c | 3 +
2 files changed, 92 insertions(+), 0 deletions(-)
create mode 100644 Documentation/devicetree/bindings/mfd/s2mps11.txt

diff --git a/Documentation/devicetree/bindings/mfd/s2mps11.txt b/Documentation/devicetree/bindings/mfd/s2mps11.txt
new file mode 100644
index 0000000..36269c4
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/s2mps11.txt
@@ -0,0 +1,89 @@
+
+* Samsung S2MPS11 Voltage and Current Regulator
+
+The Samsung S2MP211 is a multi-function device which includes voltage and
+current regulators, RTC, charger controller and other sub-blocks. It is
+interfaced to the host controller using a I2C interface. Each sub-block is
+addressed by the host system using different I2C slave address.
+
+Required properties:
+- compatible: Should be "samsung,s2mps11-pmic".
+- reg: Specifies the I2C slave address of the pmic block. It should be 0x66.
+
+Optional properties:
+- interrupt-parent: Specifies the phandle of the interrupt controller to which
+ the interrupts from s2mps11 are delivered to.
+- interrupts: Interrupt specifiers for interrupt sources.
+
+Optional nodes:
+- regulators: The regulators of s2mps11 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 listed below.
+
+ regulator_name {
+ [standard regulator constraints....];
+ };
+
+ regulator-ramp-delay for BUCKs = [6250/12500/25000(default)/50000] uV/us
+
+ BUCK[2/3/4/6] supports disabling ramp delay on hardware, so explictly
+ regulator-ramp-delay = <0> can be used for them to disable ramp delay.
+ In absence of regulator-ramp-delay property, default ramp delay will be used.
+
+NOTE: Some BUCKs share the ramp rate setting i.e. same ramp value will be set
+for a particular group of BUCKs. So provide same regulator-ramp-delay<value>.
+Grouping of BUCKs sharing ramp rate setting is as follow : BUCK[1, 6],
+BUCK[3, 4], and BUCK[7, 8, 10]
+
+The regulator constraints inside the regulator nodes use the standard regulator
+bindings which are documented elsewhere.
+
+The following are the names of the regulators that the s2mps11 pmic block
+supports. Note: The 'n' in LDOn and BUCKn represents the LDO or BUCK number
+as per the datasheet of s2mps11.
+
+ - LDOn
+ - valid values for n are 1 to 28
+ - Example: LDO0, LD01, LDO28
+ - BUCKn
+ - valid values for n are 1 to 9.
+ - Example: BUCK1, BUCK2, BUCK9
+
+Example:
+
+ s2mps11_pmic@66 {
+ compatible = "samsung,s2mps11-pmic";
+ reg = <0x66>;
+
+ regulators {
+ ldo1_reg: LDO1 {
+ regulator-name = "VDD_ABB_3.3V";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ };
+
+ ldo2_reg: LDO2 {
+ regulator-name = "VDD_ALIVE_1.1V";
+ regulator-min-microvolt = <1100000>;
+ regulator-max-microvolt = <1100000>;
+ regulator-always-on;
+ };
+
+ buck1_reg: BUCK1 {
+ regulator-name = "vdd_mif";
+ regulator-min-microvolt = <950000>;
+ regulator-max-microvolt = <1350000>;
+ regulator-always-on;
+ regulator-boot-on;
+ };
+
+ buck2_reg: BUCK2 {
+ regulator-name = "vdd_arm";
+ regulator-min-microvolt = <950000>;
+ regulator-max-microvolt = <1350000>;
+ regulator-always-on;
+ regulator-boot-on;
+ regulator-ramp-delay = <50000>;
+ };
+ };
+ };
diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c
index 77ee26e..760da8a 100644
--- a/drivers/mfd/sec-core.c
+++ b/drivers/mfd/sec-core.c
@@ -66,6 +66,9 @@ static struct of_device_id sec_dt_match[] = {
{ .compatible = "samsung,s5m8767-pmic",
.data = (void *)S5M8767X,
},
+ { .compatible = "samsung,s2mps11-pmic",
+ .data = (void *)S2MPS11X,
+ },
{},
};
#endif
--
1.7.0.4

2013-07-08 12:59:54

by Yadwinder Singh Brar

[permalink] [raw]
Subject: [v2 PATCH 2/6] regulator: s2mps11: Implement set_ramp_rate callback for bucks

Implementing set_ramp_rate() and using standard constraints for getting
ramp_delay and ramp_disable, instead of getting it as s2mps11 specific data
through platform data, makes driver more compliant with framework and reduces
the complexity for adding DT support.

Signed-off-by: Yadwinder Singh Brar <[email protected]>
---
drivers/regulator/s2mps11.c | 117 +++++++++++++++++++++++++++++++++++
include/linux/mfd/samsung/s2mps11.h | 11 +++
2 files changed, 128 insertions(+), 0 deletions(-)

diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
index a671eb6..4bebcb6 100644
--- a/drivers/regulator/s2mps11.c
+++ b/drivers/regulator/s2mps11.c
@@ -16,6 +16,7 @@
#include <linux/gpio.h>
#include <linux/slab.h>
#include <linux/module.h>
+#include <linux/regmap.h>
#include <linux/platform_device.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
@@ -104,6 +105,121 @@ static int s2mps11_regulator_set_voltage_time_sel(struct regulator_dev *rdev,
return DIV_ROUND_UP(abs(new_volt - old_volt), ramp_delay);
}

+static int s2mps11_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
+{
+ struct s2mps11_info *s2mps11 = rdev_get_drvdata(rdev);
+ unsigned int ramp_val, ramp_shift, ramp_reg = S2MPS11_REG_RAMP_BUCK;
+ unsigned int ramp_enable = 1, enable_shift = 0;
+ int ret;
+
+ switch (rdev->desc->id) {
+ case S2MPS11_BUCK1:
+ if (ramp_delay > s2mps11->ramp_delay16)
+ s2mps11->ramp_delay16 = ramp_delay;
+ else
+ ramp_delay = s2mps11->ramp_delay16;
+
+ ramp_shift = S2MPS11_BUCK16_RAMP_SHIFT;
+ break;
+ case S2MPS11_BUCK2:
+ enable_shift = S2MPS11_BUCK2_RAMP_EN_SHIFT;
+ if (!ramp_delay) {
+ ramp_enable = 0;
+ break;
+ }
+
+ s2mps11->ramp_delay2 = ramp_delay;
+ ramp_shift = S2MPS11_BUCK2_RAMP_SHIFT;
+ ramp_reg = S2MPS11_REG_RAMP;
+ break;
+ case S2MPS11_BUCK3:
+ enable_shift = S2MPS11_BUCK3_RAMP_EN_SHIFT;
+ if (!ramp_delay) {
+ ramp_enable = 0;
+ break;
+ }
+
+ if (ramp_delay > s2mps11->ramp_delay34)
+ s2mps11->ramp_delay34 = ramp_delay;
+ else
+ ramp_delay = s2mps11->ramp_delay34;
+
+ ramp_shift = S2MPS11_BUCK34_RAMP_SHIFT;
+ ramp_reg = S2MPS11_REG_RAMP;
+ break;
+ case S2MPS11_BUCK4:
+ enable_shift = S2MPS11_BUCK4_RAMP_EN_SHIFT;
+ if (!ramp_delay) {
+ ramp_enable = 0;
+ break;
+ }
+
+ if (ramp_delay > s2mps11->ramp_delay34)
+ s2mps11->ramp_delay34 = ramp_delay;
+ else
+ ramp_delay = s2mps11->ramp_delay34;
+
+ ramp_shift = S2MPS11_BUCK34_RAMP_SHIFT;
+ ramp_reg = S2MPS11_REG_RAMP;
+ break;
+ case S2MPS11_BUCK5:
+ s2mps11->ramp_delay5 = ramp_delay;
+ ramp_shift = S2MPS11_BUCK5_RAMP_SHIFT;
+ break;
+ case S2MPS11_BUCK6:
+ enable_shift = S2MPS11_BUCK6_RAMP_EN_SHIFT;
+ if (!ramp_delay) {
+ ramp_enable = 0;
+ break;
+ }
+
+ if (ramp_delay > s2mps11->ramp_delay16)
+ s2mps11->ramp_delay16 = ramp_delay;
+ else
+ ramp_delay = s2mps11->ramp_delay16;
+
+ ramp_shift = S2MPS11_BUCK16_RAMP_SHIFT;
+ break;
+ case S2MPS11_BUCK7:
+ case S2MPS11_BUCK8:
+ case S2MPS11_BUCK10:
+ if (ramp_delay > s2mps11->ramp_delay7810)
+ s2mps11->ramp_delay7810 = ramp_delay;
+ else
+ ramp_delay = s2mps11->ramp_delay7810;
+
+ ramp_shift = S2MPS11_BUCK7810_RAMP_SHIFT;
+ break;
+ case S2MPS11_BUCK9:
+ s2mps11->ramp_delay9 = ramp_delay;
+ ramp_shift = S2MPS11_BUCK9_RAMP_SHIFT;
+ break;
+ default:
+ return 0;
+ }
+
+ if (!ramp_enable)
+ goto ramp_disable;
+
+ if (enable_shift) {
+ ret = regmap_update_bits(rdev->regmap, S2MPS11_REG_RAMP,
+ 1 << enable_shift, 1 << enable_shift);
+ if (ret) {
+ dev_err(&rdev->dev, "failed to enable ramp rate\n");
+ return ret;
+ }
+ }
+
+ ramp_val = get_ramp_delay(ramp_delay);
+
+ return regmap_update_bits(rdev->regmap, ramp_reg,
+ ramp_val << ramp_shift, 1 << ramp_shift);
+
+ramp_disable:
+ return regmap_update_bits(rdev->regmap, S2MPS11_REG_RAMP, 0,
+ 1 << enable_shift);
+}
+
static struct regulator_ops s2mps11_ldo_ops = {
.list_voltage = regulator_list_voltage_linear,
.map_voltage = regulator_map_voltage_linear,
@@ -124,6 +240,7 @@ static struct regulator_ops s2mps11_buck_ops = {
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.set_voltage_time_sel = s2mps11_regulator_set_voltage_time_sel,
+ .set_ramp_delay = s2mps11_set_ramp_delay,
};

#define regulator_desc_ldo1(num) { \
diff --git a/include/linux/mfd/samsung/s2mps11.h b/include/linux/mfd/samsung/s2mps11.h
index 4e94dc6..d0d52ea 100644
--- a/include/linux/mfd/samsung/s2mps11.h
+++ b/include/linux/mfd/samsung/s2mps11.h
@@ -191,6 +191,17 @@ enum s2mps11_regulators {
#define S2MPS11_BUCK_N_VOLTAGES (S2MPS11_BUCK_VSEL_MASK + 1)
#define S2MPS11_RAMP_DELAY 25000 /* uV/us */

+
+#define S2MPS11_BUCK2_RAMP_SHIFT 6
+#define S2MPS11_BUCK34_RAMP_SHIFT 4
+#define S2MPS11_BUCK5_RAMP_SHIFT 6
+#define S2MPS11_BUCK16_RAMP_SHIFT 4
+#define S2MPS11_BUCK7810_RAMP_SHIFT 2
+#define S2MPS11_BUCK9_RAMP_SHIFT 0
+#define S2MPS11_BUCK2_RAMP_EN_SHIFT 3
+#define S2MPS11_BUCK3_RAMP_EN_SHIFT 2
+#define S2MPS11_BUCK4_RAMP_EN_SHIFT 1
+#define S2MPS11_BUCK6_RAMP_EN_SHIFT 0
#define S2MPS11_PMIC_EN_SHIFT 6
#define S2MPS11_REGULATOR_MAX (S2MPS11_REG_MAX - 3)

--
1.7.0.4

2013-07-08 13:01:50

by Yadwinder Singh Brar

[permalink] [raw]
Subject: [v2 PATCH 3/6] regulator: s2mps11: Add DT support

This patch adds DT support for parsing regulators constraints for parent(mfd)
node and moves some common intialising code out of loop while registering.

Signed-off-by: Yadwinder Singh Brar <[email protected]>
---
drivers/regulator/s2mps11.c | 48 +++++++++++++++++++++++++++++++++---------
1 files changed, 37 insertions(+), 11 deletions(-)

diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
index 4bebcb6..4157759 100644
--- a/drivers/regulator/s2mps11.c
+++ b/drivers/regulator/s2mps11.c
@@ -20,9 +20,12 @@
#include <linux/platform_device.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
+#include <linux/regulator/of_regulator.h>
#include <linux/mfd/samsung/core.h>
#include <linux/mfd/samsung/s2mps11.h>

+#define S2MPS11_REGULATOR_CNT ARRAY_SIZE(regulators)
+
struct s2mps11_info {
struct regulator_dev *rdev[S2MPS11_REGULATOR_MAX];

@@ -407,22 +410,38 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
{
struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
struct sec_platform_data *pdata = dev_get_platdata(iodev->dev);
+ struct of_regulator_match rdata[S2MPS11_REGULATOR_MAX];
+ struct device_node *reg_np = NULL;
struct regulator_config config = { };
struct s2mps11_info *s2mps11;
int i, ret;
unsigned char ramp_enable, ramp_reg = 0;

- if (!pdata) {
- dev_err(pdev->dev.parent, "Platform data not supplied\n");
- return -ENODEV;
- }
-
s2mps11 = devm_kzalloc(&pdev->dev, sizeof(struct s2mps11_info),
GFP_KERNEL);
if (!s2mps11)
return -ENOMEM;

- platform_set_drvdata(pdev, s2mps11);
+ if (!iodev->dev->of_node)
+ goto p_data;
+
+ for (i = 0; i < S2MPS11_REGULATOR_CNT; i++)
+ rdata[i].name = regulators[i].name;
+
+ reg_np = of_find_node_by_name(iodev->dev->of_node, "regulators");
+ if (!reg_np) {
+ dev_err(&pdev->dev, "could not find regulators sub-node\n");
+ return -EINVAL;
+ }
+
+ of_regulator_match(&pdev->dev, reg_np, rdata, S2MPS11_REGULATOR_MAX);
+
+ goto common_reg;
+p_data:
+ if (!pdata) {
+ dev_err(pdev->dev.parent, "Platform data not supplied\n");
+ return -ENODEV;
+ }

s2mps11->ramp_delay2 = pdata->buck2_ramp_delay;
s2mps11->ramp_delay34 = pdata->buck34_ramp_delay;
@@ -454,12 +473,19 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
ramp_reg |= get_ramp_delay(s2mps11->ramp_delay9);
sec_reg_write(iodev, S2MPS11_REG_RAMP_BUCK, ramp_reg);

- for (i = 0; i < S2MPS11_REGULATOR_MAX; i++) {
+common_reg:
+ platform_set_drvdata(pdev, s2mps11);

- config.dev = &pdev->dev;
- config.regmap = iodev->regmap;
- config.init_data = pdata->regulators[i].initdata;
- config.driver_data = s2mps11;
+ config.dev = &pdev->dev;
+ config.regmap = iodev->regmap;
+ config.driver_data = s2mps11;
+ for (i = 0; i < S2MPS11_REGULATOR_MAX; i++) {
+ if (!reg_np) {
+ config.init_data = pdata->regulators[i].initdata;
+ } else {
+ config.init_data = rdata[i].init_data;
+ config.of_node = rdata[i].of_node;
+ }

s2mps11->rdev[i] = regulator_register(&regulators[i], &config);
if (IS_ERR(s2mps11->rdev[i])) {
--
1.7.0.4

2013-07-08 13:19:13

by Mark Brown

[permalink] [raw]
Subject: Re: [v2 PATCH 1/6] regulator: core: Add support for disabling ramp delay

On Sat, Jun 29, 2013 at 06:21:15PM +0530, Yadwinder Singh Brar wrote:
> Some hardwares support disabling ramp delay, so adding ramp_disable flag to
> constraints. It will be used to figure out whether ramp_delay in constraints
> is explicitly set to zero or its unintialized (zero by default).
> And we don't need to call set_voltage_time_sel() for regulators for whom ramp
> delay is disabled in constraints.

Applied, thanks. I've applied this on a branch topic/ramp but please
ask for a tag if it needs to be merged elsewhere - I'll definitely be
rebasing after -rc1 if nothing else.


Attachments:
(No filename) (588.00 B)
signature.asc (836.00 B)
Digital signature
Download all attachments

2013-07-08 13:22:01

by Mark Brown

[permalink] [raw]
Subject: Re: [v2 PATCH 5/6] regulator: core: Remove redundant checks

On Sat, Jun 29, 2013 at 06:21:19PM +0530, Yadwinder Singh Brar wrote:
> In function _regulator_do_set_voltage(), old_selector gets intialised only
> if (_regulator_is_enabled(rdev) && rdev->desc->ops->set_voltage_time_sel &&
> rdev->desc->ops->get_voltage_sel)) is true.

Applied, thanks.


Attachments:
(No filename) (289.00 B)
signature.asc (836.00 B)
Digital signature
Download all attachments

2013-07-08 13:27:18

by Mark Brown

[permalink] [raw]
Subject: Re: [v2 PATCH 2/6] regulator: s2mps11: Implement set_ramp_rate callback for bucks

On Sat, Jun 29, 2013 at 06:21:16PM +0530, Yadwinder Singh Brar wrote:

> Implementing set_ramp_rate() and using standard constraints for getting
> ramp_delay and ramp_disable, instead of getting it as s2mps11 specific data
> through platform data, makes driver more compliant with framework and reduces
> the complexity for adding DT support.

These driver specific changes all look good, I'll apply them after the
merge window due to branching issues.


Attachments:
(No filename) (453.00 B)
signature.asc (836.00 B)
Digital signature
Download all attachments

2013-07-08 13:29:04

by Mark Brown

[permalink] [raw]
Subject: Re: [v2 PATCH 6/6] mfd: s2mps11: Add device tree support

On Sat, Jun 29, 2013 at 06:21:20PM +0530, Yadwinder Singh Brar wrote:
> This patch adds DT compatible string for s2mps11 and binding documentation.
>
> Signed-off-by: Yadwinder Singh Brar <[email protected]>

Reviewed-by: Mark Brown <[email protected]>

It looks like this should be OK to merge via the MFD tree separately to
the regulator changes, or I can apply it to the regualtor tree if that's
easier for people.


Attachments:
(No filename) (424.00 B)
signature.asc (836.00 B)
Digital signature
Download all attachments

2013-07-08 13:41:04

by Yadwinder Singh Brar

[permalink] [raw]
Subject: Re: [v2 PATCH 6/6] mfd: s2mps11: Add device tree support

On Mon, Jul 8, 2013 at 6:58 PM, Mark Brown <[email protected]> wrote:
> On Sat, Jun 29, 2013 at 06:21:20PM +0530, Yadwinder Singh Brar wrote:
>> This patch adds DT compatible string for s2mps11 and binding documentation.
>>
>> Signed-off-by: Yadwinder Singh Brar <[email protected]>
>
> Reviewed-by: Mark Brown <[email protected]>
>
> It looks like this should be OK to merge via the MFD tree separately to
> the regulator changes, or I can apply it to the regualtor tree if that's
> easier for people.

Yes, it can be merged via MFD, thats why I put it at last.
Either way it will fine.

Thanks,
Yadwinder

2013-07-11 11:06:51

by Lee Jones

[permalink] [raw]
Subject: Re: [v2 PATCH 6/6] mfd: s2mps11: Add device tree support

On Sat, 29 Jun 2013, Yadwinder Singh Brar wrote:

> This patch adds DT compatible string for s2mps11 and binding documentation.
>
> Signed-off-by: Yadwinder Singh Brar <[email protected]>
> ---
> Documentation/devicetree/bindings/mfd/s2mps11.txt | 89 +++++++++++++++++++++
> drivers/mfd/sec-core.c | 3 +
> 2 files changed, 92 insertions(+), 0 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/mfd/s2mps11.txt

Applied with Mark's RB.

--
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog