2014-07-08 12:28:15

by amit daniel kachhap

[permalink] [raw]
Subject: [PATCH 1/3] regulator: s2mpxxx: Move regulator min/step voltages in common place

This is a cleanup patch and moves min/step voltages in a common samsung
header file so that they can be used by other s2mpxxx PMIC drivers. Only
few required macros are added currently and others can be added if needed.

Signed-off-by: Amit Daniel Kachhap <[email protected]>
---
drivers/regulator/s2mpa01.c | 32 ++++++++++++------------
drivers/regulator/s2mps11.c | 50 ++++++++++++++++++-------------------
include/linux/mfd/samsung/core.h | 21 ++++++++++++++++
include/linux/mfd/samsung/s2mpa01.h | 12 ---------
include/linux/mfd/samsung/s2mps11.h | 9 -------
include/linux/mfd/samsung/s2mps14.h | 10 --------
6 files changed, 62 insertions(+), 72 deletions(-)

diff --git a/drivers/regulator/s2mpa01.c b/drivers/regulator/s2mpa01.c
index ee83b48..962c5f1 100644
--- a/drivers/regulator/s2mpa01.c
+++ b/drivers/regulator/s2mpa01.c
@@ -241,8 +241,8 @@ static struct regulator_ops s2mpa01_buck_ops = {
.ops = &s2mpa01_ldo_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = S2MPA01_LDO_MIN, \
- .uV_step = S2MPA01_LDO_STEP1, \
+ .min_uV = MIN_800_MV, \
+ .uV_step = STEP_50_MV, \
.n_voltages = S2MPA01_LDO_N_VOLTAGES, \
.vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \
.vsel_mask = S2MPA01_LDO_VSEL_MASK, \
@@ -255,8 +255,8 @@ static struct regulator_ops s2mpa01_buck_ops = {
.ops = &s2mpa01_ldo_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = S2MPA01_LDO_MIN, \
- .uV_step = S2MPA01_LDO_STEP2, \
+ .min_uV = MIN_800_MV, \
+ .uV_step = STEP_25_MV, \
.n_voltages = S2MPA01_LDO_N_VOLTAGES, \
.vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \
.vsel_mask = S2MPA01_LDO_VSEL_MASK, \
@@ -270,8 +270,8 @@ static struct regulator_ops s2mpa01_buck_ops = {
.ops = &s2mpa01_buck_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = S2MPA01_BUCK_MIN1, \
- .uV_step = S2MPA01_BUCK_STEP1, \
+ .min_uV = MIN_600_MV, \
+ .uV_step = STEP_6_25_MV, \
.n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
.ramp_delay = S2MPA01_RAMP_DELAY, \
.vsel_reg = S2MPA01_REG_B1CTRL2 + (num - 1) * 2, \
@@ -286,8 +286,8 @@ static struct regulator_ops s2mpa01_buck_ops = {
.ops = &s2mpa01_buck_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = S2MPA01_BUCK_MIN2, \
- .uV_step = S2MPA01_BUCK_STEP1, \
+ .min_uV = MIN_800_MV, \
+ .uV_step = STEP_6_25_MV, \
.n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
.ramp_delay = S2MPA01_RAMP_DELAY, \
.vsel_reg = S2MPA01_REG_B5CTRL2, \
@@ -302,8 +302,8 @@ static struct regulator_ops s2mpa01_buck_ops = {
.ops = &s2mpa01_buck_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = S2MPA01_BUCK_MIN1, \
- .uV_step = S2MPA01_BUCK_STEP1, \
+ .min_uV = MIN_600_MV, \
+ .uV_step = STEP_6_25_MV, \
.n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
.ramp_delay = S2MPA01_RAMP_DELAY, \
.vsel_reg = S2MPA01_REG_B6CTRL2 + (num - 6) * 2, \
@@ -318,8 +318,8 @@ static struct regulator_ops s2mpa01_buck_ops = {
.ops = &s2mpa01_buck_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = S2MPA01_BUCK_MIN2, \
- .uV_step = S2MPA01_BUCK_STEP2, \
+ .min_uV = MIN_800_MV, \
+ .uV_step = STEP_12_5_MV, \
.n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
.ramp_delay = S2MPA01_RAMP_DELAY, \
.vsel_reg = S2MPA01_REG_B8CTRL2, \
@@ -334,8 +334,8 @@ static struct regulator_ops s2mpa01_buck_ops = {
.ops = &s2mpa01_buck_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = S2MPA01_BUCK_MIN4, \
- .uV_step = S2MPA01_BUCK_STEP2, \
+ .min_uV = MIN_1500_MV, \
+ .uV_step = STEP_12_5_MV, \
.n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
.ramp_delay = S2MPA01_RAMP_DELAY, \
.vsel_reg = S2MPA01_REG_B9CTRL2, \
@@ -350,8 +350,8 @@ static struct regulator_ops s2mpa01_buck_ops = {
.ops = &s2mpa01_buck_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = S2MPA01_BUCK_MIN3, \
- .uV_step = S2MPA01_BUCK_STEP2, \
+ .min_uV = MIN_1000_MV, \
+ .uV_step = STEP_12_5_MV, \
.n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
.ramp_delay = S2MPA01_RAMP_DELAY, \
.vsel_reg = S2MPA01_REG_B10CTRL2, \
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
index 02e2fb2..2098c3e 100644
--- a/drivers/regulator/s2mps11.c
+++ b/drivers/regulator/s2mps11.c
@@ -250,14 +250,14 @@ static struct regulator_ops s2mps11_buck_ops = {
.set_ramp_delay = s2mps11_set_ramp_delay,
};

-#define regulator_desc_s2mps11_ldo1(num) { \
+#define regulator_desc_s2mps11_ldo1(num) { \
.name = "LDO"#num, \
.id = S2MPS11_LDO##num, \
.ops = &s2mps11_ldo_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = S2MPS11_LDO_MIN, \
- .uV_step = S2MPS11_LDO_STEP1, \
+ .min_uV = MIN_800_MV, \
+ .uV_step = STEP_50_MV, \
.n_voltages = S2MPS11_LDO_N_VOLTAGES, \
.vsel_reg = S2MPS11_REG_L1CTRL + num - 1, \
.vsel_mask = S2MPS11_LDO_VSEL_MASK, \
@@ -270,8 +270,8 @@ static struct regulator_ops s2mps11_buck_ops = {
.ops = &s2mps11_ldo_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = S2MPS11_LDO_MIN, \
- .uV_step = S2MPS11_LDO_STEP2, \
+ .min_uV = MIN_800_MV, \
+ .uV_step = STEP_25_MV, \
.n_voltages = S2MPS11_LDO_N_VOLTAGES, \
.vsel_reg = S2MPS11_REG_L1CTRL + num - 1, \
.vsel_mask = S2MPS11_LDO_VSEL_MASK, \
@@ -285,8 +285,8 @@ static struct regulator_ops s2mps11_buck_ops = {
.ops = &s2mps11_buck_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = S2MPS11_BUCK_MIN1, \
- .uV_step = S2MPS11_BUCK_STEP1, \
+ .min_uV = MIN_600_MV, \
+ .uV_step = STEP_6_25_MV, \
.n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
.ramp_delay = S2MPS11_RAMP_DELAY, \
.vsel_reg = S2MPS11_REG_B1CTRL2 + (num - 1) * 2, \
@@ -301,8 +301,8 @@ static struct regulator_ops s2mps11_buck_ops = {
.ops = &s2mps11_buck_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = S2MPS11_BUCK_MIN1, \
- .uV_step = S2MPS11_BUCK_STEP1, \
+ .min_uV = MIN_600_MV, \
+ .uV_step = STEP_6_25_MV, \
.n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
.ramp_delay = S2MPS11_RAMP_DELAY, \
.vsel_reg = S2MPS11_REG_B5CTRL2, \
@@ -317,8 +317,8 @@ static struct regulator_ops s2mps11_buck_ops = {
.ops = &s2mps11_buck_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = S2MPS11_BUCK_MIN1, \
- .uV_step = S2MPS11_BUCK_STEP1, \
+ .min_uV = MIN_600_MV, \
+ .uV_step = STEP_6_25_MV, \
.n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
.ramp_delay = S2MPS11_RAMP_DELAY, \
.vsel_reg = S2MPS11_REG_B6CTRL2 + (num - 6) * 2, \
@@ -333,8 +333,8 @@ static struct regulator_ops s2mps11_buck_ops = {
.ops = &s2mps11_buck_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = S2MPS11_BUCK_MIN3, \
- .uV_step = S2MPS11_BUCK_STEP3, \
+ .min_uV = MIN_3000_MV, \
+ .uV_step = STEP_25_MV, \
.n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
.ramp_delay = S2MPS11_RAMP_DELAY, \
.vsel_reg = S2MPS11_REG_B9CTRL2, \
@@ -349,8 +349,8 @@ static struct regulator_ops s2mps11_buck_ops = {
.ops = &s2mps11_buck_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = S2MPS11_BUCK_MIN2, \
- .uV_step = S2MPS11_BUCK_STEP2, \
+ .min_uV = MIN_750_MV, \
+ .uV_step = STEP_12_5_MV, \
.n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
.ramp_delay = S2MPS11_RAMP_DELAY, \
.vsel_reg = S2MPS11_REG_B10CTRL2, \
@@ -473,8 +473,8 @@ static struct regulator_ops s2mps14_reg_ops = {
.ops = &s2mps14_reg_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = S2MPS14_LDO_MIN_800MV, \
- .uV_step = S2MPS14_LDO_STEP_25MV, \
+ .min_uV = MIN_800_MV, \
+ .uV_step = STEP_25_MV, \
.n_voltages = S2MPS14_LDO_N_VOLTAGES, \
.vsel_reg = S2MPS14_REG_L1CTRL + num - 1, \
.vsel_mask = S2MPS14_LDO_VSEL_MASK, \
@@ -487,8 +487,8 @@ static struct regulator_ops s2mps14_reg_ops = {
.ops = &s2mps14_reg_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = S2MPS14_LDO_MIN_1800MV, \
- .uV_step = S2MPS14_LDO_STEP_25MV, \
+ .min_uV = MIN_1800_MV, \
+ .uV_step = STEP_25_MV, \
.n_voltages = S2MPS14_LDO_N_VOLTAGES, \
.vsel_reg = S2MPS14_REG_L1CTRL + num - 1, \
.vsel_mask = S2MPS14_LDO_VSEL_MASK, \
@@ -501,8 +501,8 @@ static struct regulator_ops s2mps14_reg_ops = {
.ops = &s2mps14_reg_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = S2MPS14_LDO_MIN_800MV, \
- .uV_step = S2MPS14_LDO_STEP_12_5MV, \
+ .min_uV = MIN_800_MV, \
+ .uV_step = STEP_12_5_MV, \
.n_voltages = S2MPS14_LDO_N_VOLTAGES, \
.vsel_reg = S2MPS14_REG_L1CTRL + num - 1, \
.vsel_mask = S2MPS14_LDO_VSEL_MASK, \
@@ -515,8 +515,8 @@ static struct regulator_ops s2mps14_reg_ops = {
.ops = &s2mps14_reg_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = S2MPS14_BUCK1235_MIN_600MV, \
- .uV_step = S2MPS14_BUCK1235_STEP_6_25MV, \
+ .min_uV = MIN_600_MV, \
+ .uV_step = STEP_6_25_MV, \
.n_voltages = S2MPS14_BUCK_N_VOLTAGES, \
.linear_min_sel = S2MPS14_BUCK1235_START_SEL, \
.ramp_delay = S2MPS14_BUCK_RAMP_DELAY, \
@@ -531,8 +531,8 @@ static struct regulator_ops s2mps14_reg_ops = {
.ops = &s2mps14_reg_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = S2MPS14_BUCK4_MIN_1400MV, \
- .uV_step = S2MPS14_BUCK4_STEP_12_5MV, \
+ .min_uV = MIN_1400_MV, \
+ .uV_step = STEP_12_5_MV, \
.n_voltages = S2MPS14_BUCK_N_VOLTAGES, \
.linear_min_sel = S2MPS14_BUCK4_START_SEL, \
.ramp_delay = S2MPS14_BUCK_RAMP_DELAY, \
diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h
index 47d8424..a4118aa 100644
--- a/include/linux/mfd/samsung/core.h
+++ b/include/linux/mfd/samsung/core.h
@@ -14,6 +14,27 @@
#ifndef __LINUX_MFD_SEC_CORE_H
#define __LINUX_MFD_SEC_CORE_H

+/* Macros to represent minimum voltages for LDO/BUCK */
+#define MIN_3000_MV 3000000
+#define MIN_2500_MV 2500000
+#define MIN_2000_MV 2000000
+#define MIN_1800_MV 1800000
+#define MIN_1500_MV 1500000
+#define MIN_1400_MV 1400000
+#define MIN_1000_MV 1000000
+
+#define MIN_900_MV 900000
+#define MIN_850_MV 850000
+#define MIN_800_MV 800000
+#define MIN_750_MV 750000
+#define MIN_600_MV 600000
+
+/* Macros to represent steps for LDO/BUCK */
+#define STEP_50_MV 50000
+#define STEP_25_MV 25000
+#define STEP_12_5_MV 12500
+#define STEP_6_25_MV 6250
+
enum sec_device_type {
S5M8751X,
S5M8763X,
diff --git a/include/linux/mfd/samsung/s2mpa01.h b/include/linux/mfd/samsung/s2mpa01.h
index fbc63bc..2766108 100644
--- a/include/linux/mfd/samsung/s2mpa01.h
+++ b/include/linux/mfd/samsung/s2mpa01.h
@@ -155,18 +155,6 @@ enum s2mpa01_regulators {
S2MPA01_REGULATOR_MAX,
};

-#define S2MPA01_BUCK_MIN1 600000
-#define S2MPA01_BUCK_MIN2 800000
-#define S2MPA01_BUCK_MIN3 1000000
-#define S2MPA01_BUCK_MIN4 1500000
-#define S2MPA01_LDO_MIN 800000
-
-#define S2MPA01_BUCK_STEP1 6250
-#define S2MPA01_BUCK_STEP2 12500
-
-#define S2MPA01_LDO_STEP1 50000
-#define S2MPA01_LDO_STEP2 25000
-
#define S2MPA01_LDO_VSEL_MASK 0x3F
#define S2MPA01_BUCK_VSEL_MASK 0xFF
#define S2MPA01_ENABLE_MASK (0x03 << S2MPA01_ENABLE_SHIFT)
diff --git a/include/linux/mfd/samsung/s2mps11.h b/include/linux/mfd/samsung/s2mps11.h
index b3ddf98..7981a9d 100644
--- a/include/linux/mfd/samsung/s2mps11.h
+++ b/include/linux/mfd/samsung/s2mps11.h
@@ -171,15 +171,6 @@ enum s2mps11_regulators {
S2MPS11_REGULATOR_MAX,
};

-#define S2MPS11_BUCK_MIN1 600000
-#define S2MPS11_BUCK_MIN2 750000
-#define S2MPS11_BUCK_MIN3 3000000
-#define S2MPS11_LDO_MIN 800000
-#define S2MPS11_BUCK_STEP1 6250
-#define S2MPS11_BUCK_STEP2 12500
-#define S2MPS11_BUCK_STEP3 25000
-#define S2MPS11_LDO_STEP1 50000
-#define S2MPS11_LDO_STEP2 25000
#define S2MPS11_LDO_VSEL_MASK 0x3F
#define S2MPS11_BUCK_VSEL_MASK 0xFF
#define S2MPS11_ENABLE_MASK (0x03 << S2MPS11_ENABLE_SHIFT)
diff --git a/include/linux/mfd/samsung/s2mps14.h b/include/linux/mfd/samsung/s2mps14.h
index 900cd7a..c92f478 100644
--- a/include/linux/mfd/samsung/s2mps14.h
+++ b/include/linux/mfd/samsung/s2mps14.h
@@ -123,10 +123,6 @@ enum s2mps14_regulators {
};

/* Regulator constraints for BUCKx */
-#define S2MPS14_BUCK1235_MIN_600MV 600000
-#define S2MPS14_BUCK4_MIN_1400MV 1400000
-#define S2MPS14_BUCK1235_STEP_6_25MV 6250
-#define S2MPS14_BUCK4_STEP_12_5MV 12500
#define S2MPS14_BUCK1235_START_SEL 0x20
#define S2MPS14_BUCK4_START_SEL 0x40
/*
@@ -136,12 +132,6 @@ enum s2mps14_regulators {
*/
#define S2MPS14_BUCK_RAMP_DELAY 12500

-/* Regulator constraints for different types of LDOx */
-#define S2MPS14_LDO_MIN_800MV 800000
-#define S2MPS14_LDO_MIN_1800MV 1800000
-#define S2MPS14_LDO_STEP_12_5MV 12500
-#define S2MPS14_LDO_STEP_25MV 25000
-
#define S2MPS14_LDO_VSEL_MASK 0x3F
#define S2MPS14_BUCK_VSEL_MASK 0xFF
#define S2MPS14_ENABLE_MASK (0x03 << S2MPS14_ENABLE_SHIFT)
--
1.9.1


2014-07-08 12:28:18

by amit daniel kachhap

[permalink] [raw]
Subject: [PATCH 2/3] regulator: s2mpa01: Optimize the regulator description macro

This patch makes the regulator description macro take minimum and
steps voltage as parameter. In this way many repeated macros can be
removed. Now these macros are repeated only if the the LDO/BUCK ctrl
registers have non-linear positions. The good thing is these ctrl registers
are mostly linear so they are not passed as parameters.

This patch reduces the code size and also allow easy addition of more
s2mpxxx PMIC drivers which differs a lot in minimum/step voltages.

Signed-off-by: Amit Daniel Kachhap <[email protected]>
---
drivers/regulator/s2mpa01.c | 136 ++++++++++++--------------------------------
1 file changed, 37 insertions(+), 99 deletions(-)

diff --git a/drivers/regulator/s2mpa01.c b/drivers/regulator/s2mpa01.c
index 962c5f1..8073466 100644
--- a/drivers/regulator/s2mpa01.c
+++ b/drivers/regulator/s2mpa01.c
@@ -235,28 +235,14 @@ static struct regulator_ops s2mpa01_buck_ops = {
.set_ramp_delay = s2mpa01_set_ramp_delay,
};

-#define regulator_desc_ldo1(num) { \
+#define regulator_desc_ldo(num, min, step) { \
.name = "LDO"#num, \
.id = S2MPA01_LDO##num, \
.ops = &s2mpa01_ldo_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = MIN_800_MV, \
- .uV_step = STEP_50_MV, \
- .n_voltages = S2MPA01_LDO_N_VOLTAGES, \
- .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \
- .vsel_mask = S2MPA01_LDO_VSEL_MASK, \
- .enable_reg = S2MPA01_REG_L1CTRL + num - 1, \
- .enable_mask = S2MPA01_ENABLE_MASK \
-}
-#define regulator_desc_ldo2(num) { \
- .name = "LDO"#num, \
- .id = S2MPA01_LDO##num, \
- .ops = &s2mpa01_ldo_ops, \
- .type = REGULATOR_VOLTAGE, \
- .owner = THIS_MODULE, \
- .min_uV = MIN_800_MV, \
- .uV_step = STEP_25_MV, \
+ .min_uV = min, \
+ .uV_step = step, \
.n_voltages = S2MPA01_LDO_N_VOLTAGES, \
.vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \
.vsel_mask = S2MPA01_LDO_VSEL_MASK, \
@@ -296,14 +282,14 @@ static struct regulator_ops s2mpa01_buck_ops = {
.enable_mask = S2MPA01_ENABLE_MASK \
}

-#define regulator_desc_buck6_7(num) { \
+#define regulator_desc_buck6_10(num, min, step) { \
.name = "BUCK"#num, \
.id = S2MPA01_BUCK##num, \
.ops = &s2mpa01_buck_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = MIN_600_MV, \
- .uV_step = STEP_6_25_MV, \
+ .min_uV = min, \
+ .uV_step = step, \
.n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
.ramp_delay = S2MPA01_RAMP_DELAY, \
.vsel_reg = S2MPA01_REG_B6CTRL2 + (num - 6) * 2, \
@@ -312,91 +298,43 @@ static struct regulator_ops s2mpa01_buck_ops = {
.enable_mask = S2MPA01_ENABLE_MASK \
}

-#define regulator_desc_buck8 { \
- .name = "BUCK8", \
- .id = S2MPA01_BUCK8, \
- .ops = &s2mpa01_buck_ops, \
- .type = REGULATOR_VOLTAGE, \
- .owner = THIS_MODULE, \
- .min_uV = MIN_800_MV, \
- .uV_step = STEP_12_5_MV, \
- .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
- .ramp_delay = S2MPA01_RAMP_DELAY, \
- .vsel_reg = S2MPA01_REG_B8CTRL2, \
- .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \
- .enable_reg = S2MPA01_REG_B8CTRL1, \
- .enable_mask = S2MPA01_ENABLE_MASK \
-}
-
-#define regulator_desc_buck9 { \
- .name = "BUCK9", \
- .id = S2MPA01_BUCK9, \
- .ops = &s2mpa01_buck_ops, \
- .type = REGULATOR_VOLTAGE, \
- .owner = THIS_MODULE, \
- .min_uV = MIN_1500_MV, \
- .uV_step = STEP_12_5_MV, \
- .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
- .ramp_delay = S2MPA01_RAMP_DELAY, \
- .vsel_reg = S2MPA01_REG_B9CTRL2, \
- .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \
- .enable_reg = S2MPA01_REG_B9CTRL1, \
- .enable_mask = S2MPA01_ENABLE_MASK \
-}
-
-#define regulator_desc_buck10 { \
- .name = "BUCK10", \
- .id = S2MPA01_BUCK10, \
- .ops = &s2mpa01_buck_ops, \
- .type = REGULATOR_VOLTAGE, \
- .owner = THIS_MODULE, \
- .min_uV = MIN_1000_MV, \
- .uV_step = STEP_12_5_MV, \
- .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
- .ramp_delay = S2MPA01_RAMP_DELAY, \
- .vsel_reg = S2MPA01_REG_B10CTRL2, \
- .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \
- .enable_reg = S2MPA01_REG_B10CTRL1, \
- .enable_mask = S2MPA01_ENABLE_MASK \
-}
-
static struct regulator_desc regulators[] = {
- regulator_desc_ldo2(1),
- regulator_desc_ldo1(2),
- regulator_desc_ldo1(3),
- regulator_desc_ldo1(4),
- regulator_desc_ldo1(5),
- regulator_desc_ldo2(6),
- regulator_desc_ldo1(7),
- regulator_desc_ldo1(8),
- regulator_desc_ldo1(9),
- regulator_desc_ldo1(10),
- regulator_desc_ldo2(11),
- regulator_desc_ldo1(12),
- regulator_desc_ldo1(13),
- regulator_desc_ldo1(14),
- regulator_desc_ldo1(15),
- regulator_desc_ldo1(16),
- regulator_desc_ldo1(17),
- regulator_desc_ldo1(18),
- regulator_desc_ldo1(19),
- regulator_desc_ldo1(20),
- regulator_desc_ldo1(21),
- regulator_desc_ldo2(22),
- regulator_desc_ldo2(23),
- regulator_desc_ldo1(24),
- regulator_desc_ldo1(25),
- regulator_desc_ldo1(26),
+ regulator_desc_ldo(1, MIN_800_MV, STEP_25_MV),
+ regulator_desc_ldo(2, MIN_800_MV, STEP_50_MV),
+ regulator_desc_ldo(3, MIN_800_MV, STEP_50_MV),
+ regulator_desc_ldo(4, MIN_800_MV, STEP_50_MV),
+ regulator_desc_ldo(5, MIN_800_MV, STEP_50_MV),
+ regulator_desc_ldo(6, MIN_800_MV, STEP_25_MV),
+ regulator_desc_ldo(7, MIN_800_MV, STEP_50_MV),
+ regulator_desc_ldo(8, MIN_800_MV, STEP_50_MV),
+ regulator_desc_ldo(9, MIN_800_MV, STEP_50_MV),
+ regulator_desc_ldo(10, MIN_800_MV, STEP_50_MV),
+ regulator_desc_ldo(11, MIN_800_MV, STEP_25_MV),
+ regulator_desc_ldo(12, MIN_800_MV, STEP_50_MV),
+ regulator_desc_ldo(13, MIN_800_MV, STEP_50_MV),
+ regulator_desc_ldo(14, MIN_800_MV, STEP_50_MV),
+ regulator_desc_ldo(15, MIN_800_MV, STEP_50_MV),
+ regulator_desc_ldo(16, MIN_800_MV, STEP_50_MV),
+ regulator_desc_ldo(17, MIN_800_MV, STEP_50_MV),
+ regulator_desc_ldo(18, MIN_800_MV, STEP_50_MV),
+ regulator_desc_ldo(19, MIN_800_MV, STEP_50_MV),
+ regulator_desc_ldo(20, MIN_800_MV, STEP_50_MV),
+ regulator_desc_ldo(21, MIN_800_MV, STEP_50_MV),
+ regulator_desc_ldo(22, MIN_800_MV, STEP_25_MV),
+ regulator_desc_ldo(23, MIN_800_MV, STEP_25_MV),
+ regulator_desc_ldo(24, MIN_800_MV, STEP_50_MV),
+ regulator_desc_ldo(25, MIN_800_MV, STEP_50_MV),
+ regulator_desc_ldo(26, MIN_800_MV, STEP_50_MV),
regulator_desc_buck1_4(1),
regulator_desc_buck1_4(2),
regulator_desc_buck1_4(3),
regulator_desc_buck1_4(4),
regulator_desc_buck5,
- regulator_desc_buck6_7(6),
- regulator_desc_buck6_7(7),
- regulator_desc_buck8,
- regulator_desc_buck9,
- regulator_desc_buck10,
+ regulator_desc_buck6_10(6, MIN_600_MV, STEP_6_25_MV),
+ regulator_desc_buck6_10(7, MIN_600_MV, STEP_6_25_MV),
+ regulator_desc_buck6_10(8, MIN_800_MV, STEP_12_5_MV),
+ regulator_desc_buck6_10(9, MIN_1500_MV, STEP_12_5_MV),
+ regulator_desc_buck6_10(10, MIN_1000_MV, STEP_12_5_MV),
};

static int s2mpa01_pmic_probe(struct platform_device *pdev)
--
1.9.1

2014-07-08 12:28:21

by amit daniel kachhap

[permalink] [raw]
Subject: [PATCH 3/3] regulator: s2mps11: Optimize the regulator description macro

This patch makes the regulator description macro take minimum and
steps voltage as parameter. In this way many repeated macros can be
removed. Now these macros are repeated only if the the LDO/BUCK ctrl
registers have non-linear positions. The good thing is these ctrl registers
are mostly linear so they are not passed as parameters.

This patch reduces the code size and also allow easy addition of more
s2mpxxx PMIC drivers which differs a lot in minimum/step voltages.

Signed-off-by: Amit Daniel Kachhap <[email protected]>
---
drivers/regulator/s2mps11.c | 261 +++++++++++++++-----------------------------
1 file changed, 86 insertions(+), 175 deletions(-)

diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
index 2098c3e..ea94f47 100644
--- a/drivers/regulator/s2mps11.c
+++ b/drivers/regulator/s2mps11.c
@@ -250,28 +250,14 @@ static struct regulator_ops s2mps11_buck_ops = {
.set_ramp_delay = s2mps11_set_ramp_delay,
};

-#define regulator_desc_s2mps11_ldo1(num) { \
+#define regulator_desc_s2mps11_ldo(num, min, step) { \
.name = "LDO"#num, \
.id = S2MPS11_LDO##num, \
.ops = &s2mps11_ldo_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = MIN_800_MV, \
- .uV_step = STEP_50_MV, \
- .n_voltages = S2MPS11_LDO_N_VOLTAGES, \
- .vsel_reg = S2MPS11_REG_L1CTRL + num - 1, \
- .vsel_mask = S2MPS11_LDO_VSEL_MASK, \
- .enable_reg = S2MPS11_REG_L1CTRL + num - 1, \
- .enable_mask = S2MPS11_ENABLE_MASK \
-}
-#define regulator_desc_s2mps11_ldo2(num) { \
- .name = "LDO"#num, \
- .id = S2MPS11_LDO##num, \
- .ops = &s2mps11_ldo_ops, \
- .type = REGULATOR_VOLTAGE, \
- .owner = THIS_MODULE, \
- .min_uV = MIN_800_MV, \
- .uV_step = STEP_25_MV, \
+ .min_uV = min, \
+ .uV_step = step, \
.n_voltages = S2MPS11_LDO_N_VOLTAGES, \
.vsel_reg = S2MPS11_REG_L1CTRL + num - 1, \
.vsel_mask = S2MPS11_LDO_VSEL_MASK, \
@@ -311,14 +297,14 @@ static struct regulator_ops s2mps11_buck_ops = {
.enable_mask = S2MPS11_ENABLE_MASK \
}

-#define regulator_desc_s2mps11_buck6_8(num) { \
+#define regulator_desc_s2mps11_buck6_10(num, min, step) { \
.name = "BUCK"#num, \
.id = S2MPS11_BUCK##num, \
.ops = &s2mps11_buck_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = MIN_600_MV, \
- .uV_step = STEP_6_25_MV, \
+ .min_uV = min, \
+ .uV_step = step, \
.n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
.ramp_delay = S2MPS11_RAMP_DELAY, \
.vsel_reg = S2MPS11_REG_B6CTRL2 + (num - 6) * 2, \
@@ -327,87 +313,55 @@ static struct regulator_ops s2mps11_buck_ops = {
.enable_mask = S2MPS11_ENABLE_MASK \
}

-#define regulator_desc_s2mps11_buck9 { \
- .name = "BUCK9", \
- .id = S2MPS11_BUCK9, \
- .ops = &s2mps11_buck_ops, \
- .type = REGULATOR_VOLTAGE, \
- .owner = THIS_MODULE, \
- .min_uV = MIN_3000_MV, \
- .uV_step = STEP_25_MV, \
- .n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
- .ramp_delay = S2MPS11_RAMP_DELAY, \
- .vsel_reg = S2MPS11_REG_B9CTRL2, \
- .vsel_mask = S2MPS11_BUCK_VSEL_MASK, \
- .enable_reg = S2MPS11_REG_B9CTRL1, \
- .enable_mask = S2MPS11_ENABLE_MASK \
-}
-
-#define regulator_desc_s2mps11_buck10 { \
- .name = "BUCK10", \
- .id = S2MPS11_BUCK10, \
- .ops = &s2mps11_buck_ops, \
- .type = REGULATOR_VOLTAGE, \
- .owner = THIS_MODULE, \
- .min_uV = MIN_750_MV, \
- .uV_step = STEP_12_5_MV, \
- .n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
- .ramp_delay = S2MPS11_RAMP_DELAY, \
- .vsel_reg = S2MPS11_REG_B10CTRL2, \
- .vsel_mask = S2MPS11_BUCK_VSEL_MASK, \
- .enable_reg = S2MPS11_REG_B10CTRL1, \
- .enable_mask = S2MPS11_ENABLE_MASK \
-}
-
static const struct regulator_desc s2mps11_regulators[] = {
- regulator_desc_s2mps11_ldo2(1),
- regulator_desc_s2mps11_ldo1(2),
- regulator_desc_s2mps11_ldo1(3),
- regulator_desc_s2mps11_ldo1(4),
- regulator_desc_s2mps11_ldo1(5),
- regulator_desc_s2mps11_ldo2(6),
- regulator_desc_s2mps11_ldo1(7),
- regulator_desc_s2mps11_ldo1(8),
- regulator_desc_s2mps11_ldo1(9),
- regulator_desc_s2mps11_ldo1(10),
- regulator_desc_s2mps11_ldo2(11),
- regulator_desc_s2mps11_ldo1(12),
- regulator_desc_s2mps11_ldo1(13),
- regulator_desc_s2mps11_ldo1(14),
- regulator_desc_s2mps11_ldo1(15),
- regulator_desc_s2mps11_ldo1(16),
- regulator_desc_s2mps11_ldo1(17),
- regulator_desc_s2mps11_ldo1(18),
- regulator_desc_s2mps11_ldo1(19),
- regulator_desc_s2mps11_ldo1(20),
- regulator_desc_s2mps11_ldo1(21),
- regulator_desc_s2mps11_ldo2(22),
- regulator_desc_s2mps11_ldo2(23),
- regulator_desc_s2mps11_ldo1(24),
- regulator_desc_s2mps11_ldo1(25),
- regulator_desc_s2mps11_ldo1(26),
- regulator_desc_s2mps11_ldo2(27),
- regulator_desc_s2mps11_ldo1(28),
- regulator_desc_s2mps11_ldo1(29),
- regulator_desc_s2mps11_ldo1(30),
- regulator_desc_s2mps11_ldo1(31),
- regulator_desc_s2mps11_ldo1(32),
- regulator_desc_s2mps11_ldo1(33),
- regulator_desc_s2mps11_ldo1(34),
- regulator_desc_s2mps11_ldo1(35),
- regulator_desc_s2mps11_ldo1(36),
- regulator_desc_s2mps11_ldo1(37),
- regulator_desc_s2mps11_ldo1(38),
+ regulator_desc_s2mps11_ldo(1, MIN_800_MV, STEP_25_MV),
+ regulator_desc_s2mps11_ldo(2, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(3, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(4, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(5, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(6, MIN_800_MV, STEP_25_MV),
+ regulator_desc_s2mps11_ldo(7, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(8, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(9, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(10, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(11, MIN_800_MV, STEP_25_MV),
+ regulator_desc_s2mps11_ldo(12, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(13, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(14, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(15, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(16, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(17, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(18, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(19, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(20, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(21, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(22, MIN_800_MV, STEP_25_MV),
+ regulator_desc_s2mps11_ldo(23, MIN_800_MV, STEP_25_MV),
+ regulator_desc_s2mps11_ldo(24, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(25, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(26, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(27, MIN_800_MV, STEP_25_MV),
+ regulator_desc_s2mps11_ldo(28, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(29, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(30, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(31, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(32, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(33, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(34, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(35, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(36, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(37, MIN_800_MV, STEP_50_MV),
+ regulator_desc_s2mps11_ldo(38, MIN_800_MV, STEP_50_MV),
regulator_desc_s2mps11_buck1_4(1),
regulator_desc_s2mps11_buck1_4(2),
regulator_desc_s2mps11_buck1_4(3),
regulator_desc_s2mps11_buck1_4(4),
regulator_desc_s2mps11_buck5,
- regulator_desc_s2mps11_buck6_8(6),
- regulator_desc_s2mps11_buck6_8(7),
- regulator_desc_s2mps11_buck6_8(8),
- regulator_desc_s2mps11_buck9,
- regulator_desc_s2mps11_buck10,
+ regulator_desc_s2mps11_buck6_10(6, MIN_600_MV, STEP_6_25_MV),
+ regulator_desc_s2mps11_buck6_10(7, MIN_600_MV, STEP_6_25_MV),
+ regulator_desc_s2mps11_buck6_10(8, MIN_600_MV, STEP_6_25_MV),
+ regulator_desc_s2mps11_buck6_10(9, MIN_3000_MV, STEP_25_MV),
+ regulator_desc_s2mps11_buck6_10(10, MIN_750_MV, STEP_12_5_MV),
};

static int s2mps14_regulator_enable(struct regulator_dev *rdev)
@@ -467,56 +421,29 @@ static struct regulator_ops s2mps14_reg_ops = {
.set_suspend_disable = s2mps14_regulator_set_suspend_disable,
};

-#define regulator_desc_s2mps14_ldo1(num) { \
- .name = "LDO"#num, \
- .id = S2MPS14_LDO##num, \
- .ops = &s2mps14_reg_ops, \
- .type = REGULATOR_VOLTAGE, \
- .owner = THIS_MODULE, \
- .min_uV = MIN_800_MV, \
- .uV_step = STEP_25_MV, \
- .n_voltages = S2MPS14_LDO_N_VOLTAGES, \
- .vsel_reg = S2MPS14_REG_L1CTRL + num - 1, \
- .vsel_mask = S2MPS14_LDO_VSEL_MASK, \
- .enable_reg = S2MPS14_REG_L1CTRL + num - 1, \
- .enable_mask = S2MPS14_ENABLE_MASK \
-}
-#define regulator_desc_s2mps14_ldo2(num) { \
- .name = "LDO"#num, \
- .id = S2MPS14_LDO##num, \
- .ops = &s2mps14_reg_ops, \
- .type = REGULATOR_VOLTAGE, \
- .owner = THIS_MODULE, \
- .min_uV = MIN_1800_MV, \
- .uV_step = STEP_25_MV, \
- .n_voltages = S2MPS14_LDO_N_VOLTAGES, \
- .vsel_reg = S2MPS14_REG_L1CTRL + num - 1, \
- .vsel_mask = S2MPS14_LDO_VSEL_MASK, \
- .enable_reg = S2MPS14_REG_L1CTRL + num - 1, \
- .enable_mask = S2MPS14_ENABLE_MASK \
-}
-#define regulator_desc_s2mps14_ldo3(num) { \
+#define regulator_desc_s2mps14_ldo(num, min, step) { \
.name = "LDO"#num, \
.id = S2MPS14_LDO##num, \
.ops = &s2mps14_reg_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = MIN_800_MV, \
- .uV_step = STEP_12_5_MV, \
+ .min_uV = min, \
+ .uV_step = step, \
.n_voltages = S2MPS14_LDO_N_VOLTAGES, \
.vsel_reg = S2MPS14_REG_L1CTRL + num - 1, \
.vsel_mask = S2MPS14_LDO_VSEL_MASK, \
.enable_reg = S2MPS14_REG_L1CTRL + num - 1, \
.enable_mask = S2MPS14_ENABLE_MASK \
}
-#define regulator_desc_s2mps14_buck1235(num) { \
+
+#define regulator_desc_s2mps14_buck(num, min, step) { \
.name = "BUCK"#num, \
.id = S2MPS14_BUCK##num, \
.ops = &s2mps14_reg_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
- .min_uV = MIN_600_MV, \
- .uV_step = STEP_6_25_MV, \
+ .min_uV = min, \
+ .uV_step = step, \
.n_voltages = S2MPS14_BUCK_N_VOLTAGES, \
.linear_min_sel = S2MPS14_BUCK1235_START_SEL, \
.ramp_delay = S2MPS14_BUCK_RAMP_DELAY, \
@@ -525,54 +452,38 @@ static struct regulator_ops s2mps14_reg_ops = {
.enable_reg = S2MPS14_REG_B1CTRL1 + (num - 1) * 2, \
.enable_mask = S2MPS14_ENABLE_MASK \
}
-#define regulator_desc_s2mps14_buck4(num) { \
- .name = "BUCK"#num, \
- .id = S2MPS14_BUCK##num, \
- .ops = &s2mps14_reg_ops, \
- .type = REGULATOR_VOLTAGE, \
- .owner = THIS_MODULE, \
- .min_uV = MIN_1400_MV, \
- .uV_step = STEP_12_5_MV, \
- .n_voltages = S2MPS14_BUCK_N_VOLTAGES, \
- .linear_min_sel = S2MPS14_BUCK4_START_SEL, \
- .ramp_delay = S2MPS14_BUCK_RAMP_DELAY, \
- .vsel_reg = S2MPS14_REG_B1CTRL2 + (num - 1) * 2, \
- .vsel_mask = S2MPS14_BUCK_VSEL_MASK, \
- .enable_reg = S2MPS14_REG_B1CTRL1 + (num - 1) * 2, \
- .enable_mask = S2MPS14_ENABLE_MASK \
-}

static const struct regulator_desc s2mps14_regulators[] = {
- regulator_desc_s2mps14_ldo3(1),
- regulator_desc_s2mps14_ldo3(2),
- regulator_desc_s2mps14_ldo1(3),
- regulator_desc_s2mps14_ldo1(4),
- regulator_desc_s2mps14_ldo3(5),
- regulator_desc_s2mps14_ldo3(6),
- regulator_desc_s2mps14_ldo1(7),
- regulator_desc_s2mps14_ldo2(8),
- regulator_desc_s2mps14_ldo3(9),
- regulator_desc_s2mps14_ldo3(10),
- regulator_desc_s2mps14_ldo1(11),
- regulator_desc_s2mps14_ldo2(12),
- regulator_desc_s2mps14_ldo2(13),
- regulator_desc_s2mps14_ldo2(14),
- regulator_desc_s2mps14_ldo2(15),
- regulator_desc_s2mps14_ldo2(16),
- regulator_desc_s2mps14_ldo2(17),
- regulator_desc_s2mps14_ldo2(18),
- regulator_desc_s2mps14_ldo1(19),
- regulator_desc_s2mps14_ldo1(20),
- regulator_desc_s2mps14_ldo1(21),
- regulator_desc_s2mps14_ldo3(22),
- regulator_desc_s2mps14_ldo1(23),
- regulator_desc_s2mps14_ldo2(24),
- regulator_desc_s2mps14_ldo2(25),
- regulator_desc_s2mps14_buck1235(1),
- regulator_desc_s2mps14_buck1235(2),
- regulator_desc_s2mps14_buck1235(3),
- regulator_desc_s2mps14_buck4(4),
- regulator_desc_s2mps14_buck1235(5),
+ regulator_desc_s2mps14_ldo(1, MIN_800_MV, STEP_12_5_MV),
+ regulator_desc_s2mps14_ldo(2, MIN_800_MV, STEP_12_5_MV),
+ regulator_desc_s2mps14_ldo(3, MIN_800_MV, STEP_25_MV),
+ regulator_desc_s2mps14_ldo(4, MIN_800_MV, STEP_25_MV),
+ regulator_desc_s2mps14_ldo(5, MIN_800_MV, STEP_12_5_MV),
+ regulator_desc_s2mps14_ldo(6, MIN_800_MV, STEP_12_5_MV),
+ regulator_desc_s2mps14_ldo(7, MIN_800_MV, STEP_25_MV),
+ regulator_desc_s2mps14_ldo(8, MIN_1800_MV, STEP_25_MV),
+ regulator_desc_s2mps14_ldo(9, MIN_800_MV, STEP_12_5_MV),
+ regulator_desc_s2mps14_ldo(10, MIN_800_MV, STEP_12_5_MV),
+ regulator_desc_s2mps14_ldo(11, MIN_800_MV, STEP_25_MV),
+ regulator_desc_s2mps14_ldo(12, MIN_1800_MV, STEP_25_MV),
+ regulator_desc_s2mps14_ldo(13, MIN_1800_MV, STEP_25_MV),
+ regulator_desc_s2mps14_ldo(14, MIN_1800_MV, STEP_25_MV),
+ regulator_desc_s2mps14_ldo(15, MIN_1800_MV, STEP_25_MV),
+ regulator_desc_s2mps14_ldo(16, MIN_1800_MV, STEP_25_MV),
+ regulator_desc_s2mps14_ldo(17, MIN_1800_MV, STEP_25_MV),
+ regulator_desc_s2mps14_ldo(18, MIN_1800_MV, STEP_25_MV),
+ regulator_desc_s2mps14_ldo(19, MIN_800_MV, STEP_25_MV),
+ regulator_desc_s2mps14_ldo(20, MIN_800_MV, STEP_25_MV),
+ regulator_desc_s2mps14_ldo(21, MIN_800_MV, STEP_25_MV),
+ regulator_desc_s2mps14_ldo(22, MIN_800_MV, STEP_12_5_MV),
+ regulator_desc_s2mps14_ldo(23, MIN_800_MV, STEP_25_MV),
+ regulator_desc_s2mps14_ldo(24, MIN_1800_MV, STEP_25_MV),
+ regulator_desc_s2mps14_ldo(25, MIN_1800_MV, STEP_25_MV),
+ regulator_desc_s2mps14_buck(1, MIN_600_MV, STEP_6_25_MV),
+ regulator_desc_s2mps14_buck(2, MIN_600_MV, STEP_6_25_MV),
+ regulator_desc_s2mps14_buck(3, MIN_600_MV, STEP_6_25_MV),
+ regulator_desc_s2mps14_buck(4, MIN_1400_MV, STEP_12_5_MV),
+ regulator_desc_s2mps14_buck(5, MIN_600_MV, STEP_6_25_MV),
};

static int s2mps14_pmic_enable_ext_control(struct s2mps11_info *s2mps11,
--
1.9.1

2014-07-09 09:27:09

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 1/3] regulator: s2mpxxx: Move regulator min/step voltages in common place

On Tue, Jul 08, 2014 at 05:57:58PM +0530, Amit Daniel Kachhap wrote:

> include/linux/mfd/samsung/core.h | 21 ++++++++++++++++
> include/linux/mfd/samsung/s2mpa01.h | 12 ---------
> include/linux/mfd/samsung/s2mps11.h | 9 -------
> include/linux/mfd/samsung/s2mps14.h | 10 --------

You need to send patches to the MFD subsystem to the MFD maintainers as
well.


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

2014-07-10 03:22:25

by amit daniel kachhap

[permalink] [raw]
Subject: Re: [PATCH 1/3] regulator: s2mpxxx: Move regulator min/step voltages in common place

On Wed, Jul 9, 2014 at 2:55 PM, Mark Brown <[email protected]> wrote:
> On Tue, Jul 08, 2014 at 05:57:58PM +0530, Amit Daniel Kachhap wrote:
>
>> include/linux/mfd/samsung/core.h | 21 ++++++++++++++++
>> include/linux/mfd/samsung/s2mpa01.h | 12 ---------
>> include/linux/mfd/samsung/s2mps11.h | 9 -------
>> include/linux/mfd/samsung/s2mps14.h | 10 --------
>
> You need to send patches to the MFD subsystem to the MFD maintainers as
> well.

Thanks for the pointer. Will submit to MFD maintainers.

2014-07-10 03:24:14

by amit daniel kachhap

[permalink] [raw]
Subject: Re: [PATCH 2/3] regulator: s2mpa01: Optimize the regulator description macro

Adding MFD maintainers.

On Tue, Jul 8, 2014 at 5:57 PM, Amit Daniel Kachhap
<[email protected]> wrote:
> This patch makes the regulator description macro take minimum and
> steps voltage as parameter. In this way many repeated macros can be
> removed. Now these macros are repeated only if the the LDO/BUCK ctrl
> registers have non-linear positions. The good thing is these ctrl registers
> are mostly linear so they are not passed as parameters.
>
> This patch reduces the code size and also allow easy addition of more
> s2mpxxx PMIC drivers which differs a lot in minimum/step voltages.
>
> Signed-off-by: Amit Daniel Kachhap <[email protected]>
> ---
> drivers/regulator/s2mpa01.c | 136 ++++++++++++--------------------------------
> 1 file changed, 37 insertions(+), 99 deletions(-)
>
> diff --git a/drivers/regulator/s2mpa01.c b/drivers/regulator/s2mpa01.c
> index 962c5f1..8073466 100644
> --- a/drivers/regulator/s2mpa01.c
> +++ b/drivers/regulator/s2mpa01.c
> @@ -235,28 +235,14 @@ static struct regulator_ops s2mpa01_buck_ops = {
> .set_ramp_delay = s2mpa01_set_ramp_delay,
> };
>
> -#define regulator_desc_ldo1(num) { \
> +#define regulator_desc_ldo(num, min, step) { \
> .name = "LDO"#num, \
> .id = S2MPA01_LDO##num, \
> .ops = &s2mpa01_ldo_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = MIN_800_MV, \
> - .uV_step = STEP_50_MV, \
> - .n_voltages = S2MPA01_LDO_N_VOLTAGES, \
> - .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \
> - .vsel_mask = S2MPA01_LDO_VSEL_MASK, \
> - .enable_reg = S2MPA01_REG_L1CTRL + num - 1, \
> - .enable_mask = S2MPA01_ENABLE_MASK \
> -}
> -#define regulator_desc_ldo2(num) { \
> - .name = "LDO"#num, \
> - .id = S2MPA01_LDO##num, \
> - .ops = &s2mpa01_ldo_ops, \
> - .type = REGULATOR_VOLTAGE, \
> - .owner = THIS_MODULE, \
> - .min_uV = MIN_800_MV, \
> - .uV_step = STEP_25_MV, \
> + .min_uV = min, \
> + .uV_step = step, \
> .n_voltages = S2MPA01_LDO_N_VOLTAGES, \
> .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \
> .vsel_mask = S2MPA01_LDO_VSEL_MASK, \
> @@ -296,14 +282,14 @@ static struct regulator_ops s2mpa01_buck_ops = {
> .enable_mask = S2MPA01_ENABLE_MASK \
> }
>
> -#define regulator_desc_buck6_7(num) { \
> +#define regulator_desc_buck6_10(num, min, step) { \
> .name = "BUCK"#num, \
> .id = S2MPA01_BUCK##num, \
> .ops = &s2mpa01_buck_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = MIN_600_MV, \
> - .uV_step = STEP_6_25_MV, \
> + .min_uV = min, \
> + .uV_step = step, \
> .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
> .ramp_delay = S2MPA01_RAMP_DELAY, \
> .vsel_reg = S2MPA01_REG_B6CTRL2 + (num - 6) * 2, \
> @@ -312,91 +298,43 @@ static struct regulator_ops s2mpa01_buck_ops = {
> .enable_mask = S2MPA01_ENABLE_MASK \
> }
>
> -#define regulator_desc_buck8 { \
> - .name = "BUCK8", \
> - .id = S2MPA01_BUCK8, \
> - .ops = &s2mpa01_buck_ops, \
> - .type = REGULATOR_VOLTAGE, \
> - .owner = THIS_MODULE, \
> - .min_uV = MIN_800_MV, \
> - .uV_step = STEP_12_5_MV, \
> - .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
> - .ramp_delay = S2MPA01_RAMP_DELAY, \
> - .vsel_reg = S2MPA01_REG_B8CTRL2, \
> - .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \
> - .enable_reg = S2MPA01_REG_B8CTRL1, \
> - .enable_mask = S2MPA01_ENABLE_MASK \
> -}
> -
> -#define regulator_desc_buck9 { \
> - .name = "BUCK9", \
> - .id = S2MPA01_BUCK9, \
> - .ops = &s2mpa01_buck_ops, \
> - .type = REGULATOR_VOLTAGE, \
> - .owner = THIS_MODULE, \
> - .min_uV = MIN_1500_MV, \
> - .uV_step = STEP_12_5_MV, \
> - .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
> - .ramp_delay = S2MPA01_RAMP_DELAY, \
> - .vsel_reg = S2MPA01_REG_B9CTRL2, \
> - .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \
> - .enable_reg = S2MPA01_REG_B9CTRL1, \
> - .enable_mask = S2MPA01_ENABLE_MASK \
> -}
> -
> -#define regulator_desc_buck10 { \
> - .name = "BUCK10", \
> - .id = S2MPA01_BUCK10, \
> - .ops = &s2mpa01_buck_ops, \
> - .type = REGULATOR_VOLTAGE, \
> - .owner = THIS_MODULE, \
> - .min_uV = MIN_1000_MV, \
> - .uV_step = STEP_12_5_MV, \
> - .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
> - .ramp_delay = S2MPA01_RAMP_DELAY, \
> - .vsel_reg = S2MPA01_REG_B10CTRL2, \
> - .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \
> - .enable_reg = S2MPA01_REG_B10CTRL1, \
> - .enable_mask = S2MPA01_ENABLE_MASK \
> -}
> -
> static struct regulator_desc regulators[] = {
> - regulator_desc_ldo2(1),
> - regulator_desc_ldo1(2),
> - regulator_desc_ldo1(3),
> - regulator_desc_ldo1(4),
> - regulator_desc_ldo1(5),
> - regulator_desc_ldo2(6),
> - regulator_desc_ldo1(7),
> - regulator_desc_ldo1(8),
> - regulator_desc_ldo1(9),
> - regulator_desc_ldo1(10),
> - regulator_desc_ldo2(11),
> - regulator_desc_ldo1(12),
> - regulator_desc_ldo1(13),
> - regulator_desc_ldo1(14),
> - regulator_desc_ldo1(15),
> - regulator_desc_ldo1(16),
> - regulator_desc_ldo1(17),
> - regulator_desc_ldo1(18),
> - regulator_desc_ldo1(19),
> - regulator_desc_ldo1(20),
> - regulator_desc_ldo1(21),
> - regulator_desc_ldo2(22),
> - regulator_desc_ldo2(23),
> - regulator_desc_ldo1(24),
> - regulator_desc_ldo1(25),
> - regulator_desc_ldo1(26),
> + regulator_desc_ldo(1, MIN_800_MV, STEP_25_MV),
> + regulator_desc_ldo(2, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(3, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(4, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(5, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(6, MIN_800_MV, STEP_25_MV),
> + regulator_desc_ldo(7, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(8, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(9, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(10, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(11, MIN_800_MV, STEP_25_MV),
> + regulator_desc_ldo(12, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(13, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(14, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(15, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(16, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(17, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(18, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(19, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(20, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(21, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(22, MIN_800_MV, STEP_25_MV),
> + regulator_desc_ldo(23, MIN_800_MV, STEP_25_MV),
> + regulator_desc_ldo(24, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(25, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(26, MIN_800_MV, STEP_50_MV),
> regulator_desc_buck1_4(1),
> regulator_desc_buck1_4(2),
> regulator_desc_buck1_4(3),
> regulator_desc_buck1_4(4),
> regulator_desc_buck5,
> - regulator_desc_buck6_7(6),
> - regulator_desc_buck6_7(7),
> - regulator_desc_buck8,
> - regulator_desc_buck9,
> - regulator_desc_buck10,
> + regulator_desc_buck6_10(6, MIN_600_MV, STEP_6_25_MV),
> + regulator_desc_buck6_10(7, MIN_600_MV, STEP_6_25_MV),
> + regulator_desc_buck6_10(8, MIN_800_MV, STEP_12_5_MV),
> + regulator_desc_buck6_10(9, MIN_1500_MV, STEP_12_5_MV),
> + regulator_desc_buck6_10(10, MIN_1000_MV, STEP_12_5_MV),
> };
>
> static int s2mpa01_pmic_probe(struct platform_device *pdev)
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2014-07-10 03:25:04

by amit daniel kachhap

[permalink] [raw]
Subject: Re: [PATCH 3/3] regulator: s2mps11: Optimize the regulator description macro

Adding MFD maintainers

On Tue, Jul 8, 2014 at 5:58 PM, Amit Daniel Kachhap
<[email protected]> wrote:
> This patch makes the regulator description macro take minimum and
> steps voltage as parameter. In this way many repeated macros can be
> removed. Now these macros are repeated only if the the LDO/BUCK ctrl
> registers have non-linear positions. The good thing is these ctrl registers
> are mostly linear so they are not passed as parameters.
>
> This patch reduces the code size and also allow easy addition of more
> s2mpxxx PMIC drivers which differs a lot in minimum/step voltages.
>
> Signed-off-by: Amit Daniel Kachhap <[email protected]>
> ---
> drivers/regulator/s2mps11.c | 261 +++++++++++++++-----------------------------
> 1 file changed, 86 insertions(+), 175 deletions(-)
>
> diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
> index 2098c3e..ea94f47 100644
> --- a/drivers/regulator/s2mps11.c
> +++ b/drivers/regulator/s2mps11.c
> @@ -250,28 +250,14 @@ static struct regulator_ops s2mps11_buck_ops = {
> .set_ramp_delay = s2mps11_set_ramp_delay,
> };
>
> -#define regulator_desc_s2mps11_ldo1(num) { \
> +#define regulator_desc_s2mps11_ldo(num, min, step) { \
> .name = "LDO"#num, \
> .id = S2MPS11_LDO##num, \
> .ops = &s2mps11_ldo_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = MIN_800_MV, \
> - .uV_step = STEP_50_MV, \
> - .n_voltages = S2MPS11_LDO_N_VOLTAGES, \
> - .vsel_reg = S2MPS11_REG_L1CTRL + num - 1, \
> - .vsel_mask = S2MPS11_LDO_VSEL_MASK, \
> - .enable_reg = S2MPS11_REG_L1CTRL + num - 1, \
> - .enable_mask = S2MPS11_ENABLE_MASK \
> -}
> -#define regulator_desc_s2mps11_ldo2(num) { \
> - .name = "LDO"#num, \
> - .id = S2MPS11_LDO##num, \
> - .ops = &s2mps11_ldo_ops, \
> - .type = REGULATOR_VOLTAGE, \
> - .owner = THIS_MODULE, \
> - .min_uV = MIN_800_MV, \
> - .uV_step = STEP_25_MV, \
> + .min_uV = min, \
> + .uV_step = step, \
> .n_voltages = S2MPS11_LDO_N_VOLTAGES, \
> .vsel_reg = S2MPS11_REG_L1CTRL + num - 1, \
> .vsel_mask = S2MPS11_LDO_VSEL_MASK, \
> @@ -311,14 +297,14 @@ static struct regulator_ops s2mps11_buck_ops = {
> .enable_mask = S2MPS11_ENABLE_MASK \
> }
>
> -#define regulator_desc_s2mps11_buck6_8(num) { \
> +#define regulator_desc_s2mps11_buck6_10(num, min, step) { \
> .name = "BUCK"#num, \
> .id = S2MPS11_BUCK##num, \
> .ops = &s2mps11_buck_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = MIN_600_MV, \
> - .uV_step = STEP_6_25_MV, \
> + .min_uV = min, \
> + .uV_step = step, \
> .n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
> .ramp_delay = S2MPS11_RAMP_DELAY, \
> .vsel_reg = S2MPS11_REG_B6CTRL2 + (num - 6) * 2, \
> @@ -327,87 +313,55 @@ static struct regulator_ops s2mps11_buck_ops = {
> .enable_mask = S2MPS11_ENABLE_MASK \
> }
>
> -#define regulator_desc_s2mps11_buck9 { \
> - .name = "BUCK9", \
> - .id = S2MPS11_BUCK9, \
> - .ops = &s2mps11_buck_ops, \
> - .type = REGULATOR_VOLTAGE, \
> - .owner = THIS_MODULE, \
> - .min_uV = MIN_3000_MV, \
> - .uV_step = STEP_25_MV, \
> - .n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
> - .ramp_delay = S2MPS11_RAMP_DELAY, \
> - .vsel_reg = S2MPS11_REG_B9CTRL2, \
> - .vsel_mask = S2MPS11_BUCK_VSEL_MASK, \
> - .enable_reg = S2MPS11_REG_B9CTRL1, \
> - .enable_mask = S2MPS11_ENABLE_MASK \
> -}
> -
> -#define regulator_desc_s2mps11_buck10 { \
> - .name = "BUCK10", \
> - .id = S2MPS11_BUCK10, \
> - .ops = &s2mps11_buck_ops, \
> - .type = REGULATOR_VOLTAGE, \
> - .owner = THIS_MODULE, \
> - .min_uV = MIN_750_MV, \
> - .uV_step = STEP_12_5_MV, \
> - .n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
> - .ramp_delay = S2MPS11_RAMP_DELAY, \
> - .vsel_reg = S2MPS11_REG_B10CTRL2, \
> - .vsel_mask = S2MPS11_BUCK_VSEL_MASK, \
> - .enable_reg = S2MPS11_REG_B10CTRL1, \
> - .enable_mask = S2MPS11_ENABLE_MASK \
> -}
> -
> static const struct regulator_desc s2mps11_regulators[] = {
> - regulator_desc_s2mps11_ldo2(1),
> - regulator_desc_s2mps11_ldo1(2),
> - regulator_desc_s2mps11_ldo1(3),
> - regulator_desc_s2mps11_ldo1(4),
> - regulator_desc_s2mps11_ldo1(5),
> - regulator_desc_s2mps11_ldo2(6),
> - regulator_desc_s2mps11_ldo1(7),
> - regulator_desc_s2mps11_ldo1(8),
> - regulator_desc_s2mps11_ldo1(9),
> - regulator_desc_s2mps11_ldo1(10),
> - regulator_desc_s2mps11_ldo2(11),
> - regulator_desc_s2mps11_ldo1(12),
> - regulator_desc_s2mps11_ldo1(13),
> - regulator_desc_s2mps11_ldo1(14),
> - regulator_desc_s2mps11_ldo1(15),
> - regulator_desc_s2mps11_ldo1(16),
> - regulator_desc_s2mps11_ldo1(17),
> - regulator_desc_s2mps11_ldo1(18),
> - regulator_desc_s2mps11_ldo1(19),
> - regulator_desc_s2mps11_ldo1(20),
> - regulator_desc_s2mps11_ldo1(21),
> - regulator_desc_s2mps11_ldo2(22),
> - regulator_desc_s2mps11_ldo2(23),
> - regulator_desc_s2mps11_ldo1(24),
> - regulator_desc_s2mps11_ldo1(25),
> - regulator_desc_s2mps11_ldo1(26),
> - regulator_desc_s2mps11_ldo2(27),
> - regulator_desc_s2mps11_ldo1(28),
> - regulator_desc_s2mps11_ldo1(29),
> - regulator_desc_s2mps11_ldo1(30),
> - regulator_desc_s2mps11_ldo1(31),
> - regulator_desc_s2mps11_ldo1(32),
> - regulator_desc_s2mps11_ldo1(33),
> - regulator_desc_s2mps11_ldo1(34),
> - regulator_desc_s2mps11_ldo1(35),
> - regulator_desc_s2mps11_ldo1(36),
> - regulator_desc_s2mps11_ldo1(37),
> - regulator_desc_s2mps11_ldo1(38),
> + regulator_desc_s2mps11_ldo(1, MIN_800_MV, STEP_25_MV),
> + regulator_desc_s2mps11_ldo(2, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(3, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(4, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(5, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(6, MIN_800_MV, STEP_25_MV),
> + regulator_desc_s2mps11_ldo(7, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(8, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(9, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(10, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(11, MIN_800_MV, STEP_25_MV),
> + regulator_desc_s2mps11_ldo(12, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(13, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(14, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(15, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(16, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(17, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(18, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(19, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(20, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(21, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(22, MIN_800_MV, STEP_25_MV),
> + regulator_desc_s2mps11_ldo(23, MIN_800_MV, STEP_25_MV),
> + regulator_desc_s2mps11_ldo(24, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(25, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(26, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(27, MIN_800_MV, STEP_25_MV),
> + regulator_desc_s2mps11_ldo(28, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(29, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(30, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(31, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(32, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(33, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(34, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(35, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(36, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(37, MIN_800_MV, STEP_50_MV),
> + regulator_desc_s2mps11_ldo(38, MIN_800_MV, STEP_50_MV),
> regulator_desc_s2mps11_buck1_4(1),
> regulator_desc_s2mps11_buck1_4(2),
> regulator_desc_s2mps11_buck1_4(3),
> regulator_desc_s2mps11_buck1_4(4),
> regulator_desc_s2mps11_buck5,
> - regulator_desc_s2mps11_buck6_8(6),
> - regulator_desc_s2mps11_buck6_8(7),
> - regulator_desc_s2mps11_buck6_8(8),
> - regulator_desc_s2mps11_buck9,
> - regulator_desc_s2mps11_buck10,
> + regulator_desc_s2mps11_buck6_10(6, MIN_600_MV, STEP_6_25_MV),
> + regulator_desc_s2mps11_buck6_10(7, MIN_600_MV, STEP_6_25_MV),
> + regulator_desc_s2mps11_buck6_10(8, MIN_600_MV, STEP_6_25_MV),
> + regulator_desc_s2mps11_buck6_10(9, MIN_3000_MV, STEP_25_MV),
> + regulator_desc_s2mps11_buck6_10(10, MIN_750_MV, STEP_12_5_MV),
> };
>
> static int s2mps14_regulator_enable(struct regulator_dev *rdev)
> @@ -467,56 +421,29 @@ static struct regulator_ops s2mps14_reg_ops = {
> .set_suspend_disable = s2mps14_regulator_set_suspend_disable,
> };
>
> -#define regulator_desc_s2mps14_ldo1(num) { \
> - .name = "LDO"#num, \
> - .id = S2MPS14_LDO##num, \
> - .ops = &s2mps14_reg_ops, \
> - .type = REGULATOR_VOLTAGE, \
> - .owner = THIS_MODULE, \
> - .min_uV = MIN_800_MV, \
> - .uV_step = STEP_25_MV, \
> - .n_voltages = S2MPS14_LDO_N_VOLTAGES, \
> - .vsel_reg = S2MPS14_REG_L1CTRL + num - 1, \
> - .vsel_mask = S2MPS14_LDO_VSEL_MASK, \
> - .enable_reg = S2MPS14_REG_L1CTRL + num - 1, \
> - .enable_mask = S2MPS14_ENABLE_MASK \
> -}
> -#define regulator_desc_s2mps14_ldo2(num) { \
> - .name = "LDO"#num, \
> - .id = S2MPS14_LDO##num, \
> - .ops = &s2mps14_reg_ops, \
> - .type = REGULATOR_VOLTAGE, \
> - .owner = THIS_MODULE, \
> - .min_uV = MIN_1800_MV, \
> - .uV_step = STEP_25_MV, \
> - .n_voltages = S2MPS14_LDO_N_VOLTAGES, \
> - .vsel_reg = S2MPS14_REG_L1CTRL + num - 1, \
> - .vsel_mask = S2MPS14_LDO_VSEL_MASK, \
> - .enable_reg = S2MPS14_REG_L1CTRL + num - 1, \
> - .enable_mask = S2MPS14_ENABLE_MASK \
> -}
> -#define regulator_desc_s2mps14_ldo3(num) { \
> +#define regulator_desc_s2mps14_ldo(num, min, step) { \
> .name = "LDO"#num, \
> .id = S2MPS14_LDO##num, \
> .ops = &s2mps14_reg_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = MIN_800_MV, \
> - .uV_step = STEP_12_5_MV, \
> + .min_uV = min, \
> + .uV_step = step, \
> .n_voltages = S2MPS14_LDO_N_VOLTAGES, \
> .vsel_reg = S2MPS14_REG_L1CTRL + num - 1, \
> .vsel_mask = S2MPS14_LDO_VSEL_MASK, \
> .enable_reg = S2MPS14_REG_L1CTRL + num - 1, \
> .enable_mask = S2MPS14_ENABLE_MASK \
> }
> -#define regulator_desc_s2mps14_buck1235(num) { \
> +
> +#define regulator_desc_s2mps14_buck(num, min, step) { \
> .name = "BUCK"#num, \
> .id = S2MPS14_BUCK##num, \
> .ops = &s2mps14_reg_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = MIN_600_MV, \
> - .uV_step = STEP_6_25_MV, \
> + .min_uV = min, \
> + .uV_step = step, \
> .n_voltages = S2MPS14_BUCK_N_VOLTAGES, \
> .linear_min_sel = S2MPS14_BUCK1235_START_SEL, \
> .ramp_delay = S2MPS14_BUCK_RAMP_DELAY, \
> @@ -525,54 +452,38 @@ static struct regulator_ops s2mps14_reg_ops = {
> .enable_reg = S2MPS14_REG_B1CTRL1 + (num - 1) * 2, \
> .enable_mask = S2MPS14_ENABLE_MASK \
> }
> -#define regulator_desc_s2mps14_buck4(num) { \
> - .name = "BUCK"#num, \
> - .id = S2MPS14_BUCK##num, \
> - .ops = &s2mps14_reg_ops, \
> - .type = REGULATOR_VOLTAGE, \
> - .owner = THIS_MODULE, \
> - .min_uV = MIN_1400_MV, \
> - .uV_step = STEP_12_5_MV, \
> - .n_voltages = S2MPS14_BUCK_N_VOLTAGES, \
> - .linear_min_sel = S2MPS14_BUCK4_START_SEL, \
> - .ramp_delay = S2MPS14_BUCK_RAMP_DELAY, \
> - .vsel_reg = S2MPS14_REG_B1CTRL2 + (num - 1) * 2, \
> - .vsel_mask = S2MPS14_BUCK_VSEL_MASK, \
> - .enable_reg = S2MPS14_REG_B1CTRL1 + (num - 1) * 2, \
> - .enable_mask = S2MPS14_ENABLE_MASK \
> -}
>
> static const struct regulator_desc s2mps14_regulators[] = {
> - regulator_desc_s2mps14_ldo3(1),
> - regulator_desc_s2mps14_ldo3(2),
> - regulator_desc_s2mps14_ldo1(3),
> - regulator_desc_s2mps14_ldo1(4),
> - regulator_desc_s2mps14_ldo3(5),
> - regulator_desc_s2mps14_ldo3(6),
> - regulator_desc_s2mps14_ldo1(7),
> - regulator_desc_s2mps14_ldo2(8),
> - regulator_desc_s2mps14_ldo3(9),
> - regulator_desc_s2mps14_ldo3(10),
> - regulator_desc_s2mps14_ldo1(11),
> - regulator_desc_s2mps14_ldo2(12),
> - regulator_desc_s2mps14_ldo2(13),
> - regulator_desc_s2mps14_ldo2(14),
> - regulator_desc_s2mps14_ldo2(15),
> - regulator_desc_s2mps14_ldo2(16),
> - regulator_desc_s2mps14_ldo2(17),
> - regulator_desc_s2mps14_ldo2(18),
> - regulator_desc_s2mps14_ldo1(19),
> - regulator_desc_s2mps14_ldo1(20),
> - regulator_desc_s2mps14_ldo1(21),
> - regulator_desc_s2mps14_ldo3(22),
> - regulator_desc_s2mps14_ldo1(23),
> - regulator_desc_s2mps14_ldo2(24),
> - regulator_desc_s2mps14_ldo2(25),
> - regulator_desc_s2mps14_buck1235(1),
> - regulator_desc_s2mps14_buck1235(2),
> - regulator_desc_s2mps14_buck1235(3),
> - regulator_desc_s2mps14_buck4(4),
> - regulator_desc_s2mps14_buck1235(5),
> + regulator_desc_s2mps14_ldo(1, MIN_800_MV, STEP_12_5_MV),
> + regulator_desc_s2mps14_ldo(2, MIN_800_MV, STEP_12_5_MV),
> + regulator_desc_s2mps14_ldo(3, MIN_800_MV, STEP_25_MV),
> + regulator_desc_s2mps14_ldo(4, MIN_800_MV, STEP_25_MV),
> + regulator_desc_s2mps14_ldo(5, MIN_800_MV, STEP_12_5_MV),
> + regulator_desc_s2mps14_ldo(6, MIN_800_MV, STEP_12_5_MV),
> + regulator_desc_s2mps14_ldo(7, MIN_800_MV, STEP_25_MV),
> + regulator_desc_s2mps14_ldo(8, MIN_1800_MV, STEP_25_MV),
> + regulator_desc_s2mps14_ldo(9, MIN_800_MV, STEP_12_5_MV),
> + regulator_desc_s2mps14_ldo(10, MIN_800_MV, STEP_12_5_MV),
> + regulator_desc_s2mps14_ldo(11, MIN_800_MV, STEP_25_MV),
> + regulator_desc_s2mps14_ldo(12, MIN_1800_MV, STEP_25_MV),
> + regulator_desc_s2mps14_ldo(13, MIN_1800_MV, STEP_25_MV),
> + regulator_desc_s2mps14_ldo(14, MIN_1800_MV, STEP_25_MV),
> + regulator_desc_s2mps14_ldo(15, MIN_1800_MV, STEP_25_MV),
> + regulator_desc_s2mps14_ldo(16, MIN_1800_MV, STEP_25_MV),
> + regulator_desc_s2mps14_ldo(17, MIN_1800_MV, STEP_25_MV),
> + regulator_desc_s2mps14_ldo(18, MIN_1800_MV, STEP_25_MV),
> + regulator_desc_s2mps14_ldo(19, MIN_800_MV, STEP_25_MV),
> + regulator_desc_s2mps14_ldo(20, MIN_800_MV, STEP_25_MV),
> + regulator_desc_s2mps14_ldo(21, MIN_800_MV, STEP_25_MV),
> + regulator_desc_s2mps14_ldo(22, MIN_800_MV, STEP_12_5_MV),
> + regulator_desc_s2mps14_ldo(23, MIN_800_MV, STEP_25_MV),
> + regulator_desc_s2mps14_ldo(24, MIN_1800_MV, STEP_25_MV),
> + regulator_desc_s2mps14_ldo(25, MIN_1800_MV, STEP_25_MV),
> + regulator_desc_s2mps14_buck(1, MIN_600_MV, STEP_6_25_MV),
> + regulator_desc_s2mps14_buck(2, MIN_600_MV, STEP_6_25_MV),
> + regulator_desc_s2mps14_buck(3, MIN_600_MV, STEP_6_25_MV),
> + regulator_desc_s2mps14_buck(4, MIN_1400_MV, STEP_12_5_MV),
> + regulator_desc_s2mps14_buck(5, MIN_600_MV, STEP_6_25_MV),
> };
>
> static int s2mps14_pmic_enable_ext_control(struct s2mps11_info *s2mps11,
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2014-07-10 07:35:21

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH 2/3] regulator: s2mpa01: Optimize the regulator description macro

On Thu, 10 Jul 2014, amit daniel kachhap wrote:
> Adding MFD maintainers.

Why, what for?

> On Tue, Jul 8, 2014 at 5:57 PM, Amit Daniel Kachhap
> <[email protected]> wrote:
> > This patch makes the regulator description macro take minimum and
> > steps voltage as parameter. In this way many repeated macros can be
> > removed. Now these macros are repeated only if the the LDO/BUCK ctrl
> > registers have non-linear positions. The good thing is these ctrl registers
> > are mostly linear so they are not passed as parameters.
> >
> > This patch reduces the code size and also allow easy addition of more
> > s2mpxxx PMIC drivers which differs a lot in minimum/step voltages.
> >
> > Signed-off-by: Amit Daniel Kachhap <[email protected]>
> > ---
> > drivers/regulator/s2mpa01.c | 136 ++++++++++++--------------------------------
> > 1 file changed, 37 insertions(+), 99 deletions(-)
> >
> > diff --git a/drivers/regulator/s2mpa01.c b/drivers/regulator/s2mpa01.c
> > index 962c5f1..8073466 100644
> > --- a/drivers/regulator/s2mpa01.c
> > +++ b/drivers/regulator/s2mpa01.c
> > @@ -235,28 +235,14 @@ static struct regulator_ops s2mpa01_buck_ops = {
> > .set_ramp_delay = s2mpa01_set_ramp_delay,
> > };
> >
> > -#define regulator_desc_ldo1(num) { \
> > +#define regulator_desc_ldo(num, min, step) { \
> > .name = "LDO"#num, \
> > .id = S2MPA01_LDO##num, \
> > .ops = &s2mpa01_ldo_ops, \
> > .type = REGULATOR_VOLTAGE, \
> > .owner = THIS_MODULE, \
> > - .min_uV = MIN_800_MV, \
> > - .uV_step = STEP_50_MV, \
> > - .n_voltages = S2MPA01_LDO_N_VOLTAGES, \
> > - .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \
> > - .vsel_mask = S2MPA01_LDO_VSEL_MASK, \
> > - .enable_reg = S2MPA01_REG_L1CTRL + num - 1, \
> > - .enable_mask = S2MPA01_ENABLE_MASK \
> > -}
> > -#define regulator_desc_ldo2(num) { \
> > - .name = "LDO"#num, \
> > - .id = S2MPA01_LDO##num, \
> > - .ops = &s2mpa01_ldo_ops, \
> > - .type = REGULATOR_VOLTAGE, \
> > - .owner = THIS_MODULE, \
> > - .min_uV = MIN_800_MV, \
> > - .uV_step = STEP_25_MV, \
> > + .min_uV = min, \
> > + .uV_step = step, \
> > .n_voltages = S2MPA01_LDO_N_VOLTAGES, \
> > .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \
> > .vsel_mask = S2MPA01_LDO_VSEL_MASK, \
> > @@ -296,14 +282,14 @@ static struct regulator_ops s2mpa01_buck_ops = {
> > .enable_mask = S2MPA01_ENABLE_MASK \
> > }
> >
> > -#define regulator_desc_buck6_7(num) { \
> > +#define regulator_desc_buck6_10(num, min, step) { \
> > .name = "BUCK"#num, \
> > .id = S2MPA01_BUCK##num, \
> > .ops = &s2mpa01_buck_ops, \
> > .type = REGULATOR_VOLTAGE, \
> > .owner = THIS_MODULE, \
> > - .min_uV = MIN_600_MV, \
> > - .uV_step = STEP_6_25_MV, \
> > + .min_uV = min, \
> > + .uV_step = step, \
> > .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
> > .ramp_delay = S2MPA01_RAMP_DELAY, \
> > .vsel_reg = S2MPA01_REG_B6CTRL2 + (num - 6) * 2, \
> > @@ -312,91 +298,43 @@ static struct regulator_ops s2mpa01_buck_ops = {
> > .enable_mask = S2MPA01_ENABLE_MASK \
> > }
> >
> > -#define regulator_desc_buck8 { \
> > - .name = "BUCK8", \
> > - .id = S2MPA01_BUCK8, \
> > - .ops = &s2mpa01_buck_ops, \
> > - .type = REGULATOR_VOLTAGE, \
> > - .owner = THIS_MODULE, \
> > - .min_uV = MIN_800_MV, \
> > - .uV_step = STEP_12_5_MV, \
> > - .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
> > - .ramp_delay = S2MPA01_RAMP_DELAY, \
> > - .vsel_reg = S2MPA01_REG_B8CTRL2, \
> > - .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \
> > - .enable_reg = S2MPA01_REG_B8CTRL1, \
> > - .enable_mask = S2MPA01_ENABLE_MASK \
> > -}
> > -
> > -#define regulator_desc_buck9 { \
> > - .name = "BUCK9", \
> > - .id = S2MPA01_BUCK9, \
> > - .ops = &s2mpa01_buck_ops, \
> > - .type = REGULATOR_VOLTAGE, \
> > - .owner = THIS_MODULE, \
> > - .min_uV = MIN_1500_MV, \
> > - .uV_step = STEP_12_5_MV, \
> > - .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
> > - .ramp_delay = S2MPA01_RAMP_DELAY, \
> > - .vsel_reg = S2MPA01_REG_B9CTRL2, \
> > - .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \
> > - .enable_reg = S2MPA01_REG_B9CTRL1, \
> > - .enable_mask = S2MPA01_ENABLE_MASK \
> > -}
> > -
> > -#define regulator_desc_buck10 { \
> > - .name = "BUCK10", \
> > - .id = S2MPA01_BUCK10, \
> > - .ops = &s2mpa01_buck_ops, \
> > - .type = REGULATOR_VOLTAGE, \
> > - .owner = THIS_MODULE, \
> > - .min_uV = MIN_1000_MV, \
> > - .uV_step = STEP_12_5_MV, \
> > - .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
> > - .ramp_delay = S2MPA01_RAMP_DELAY, \
> > - .vsel_reg = S2MPA01_REG_B10CTRL2, \
> > - .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \
> > - .enable_reg = S2MPA01_REG_B10CTRL1, \
> > - .enable_mask = S2MPA01_ENABLE_MASK \
> > -}
> > -
> > static struct regulator_desc regulators[] = {
> > - regulator_desc_ldo2(1),
> > - regulator_desc_ldo1(2),
> > - regulator_desc_ldo1(3),
> > - regulator_desc_ldo1(4),
> > - regulator_desc_ldo1(5),
> > - regulator_desc_ldo2(6),
> > - regulator_desc_ldo1(7),
> > - regulator_desc_ldo1(8),
> > - regulator_desc_ldo1(9),
> > - regulator_desc_ldo1(10),
> > - regulator_desc_ldo2(11),
> > - regulator_desc_ldo1(12),
> > - regulator_desc_ldo1(13),
> > - regulator_desc_ldo1(14),
> > - regulator_desc_ldo1(15),
> > - regulator_desc_ldo1(16),
> > - regulator_desc_ldo1(17),
> > - regulator_desc_ldo1(18),
> > - regulator_desc_ldo1(19),
> > - regulator_desc_ldo1(20),
> > - regulator_desc_ldo1(21),
> > - regulator_desc_ldo2(22),
> > - regulator_desc_ldo2(23),
> > - regulator_desc_ldo1(24),
> > - regulator_desc_ldo1(25),
> > - regulator_desc_ldo1(26),
> > + regulator_desc_ldo(1, MIN_800_MV, STEP_25_MV),
> > + regulator_desc_ldo(2, MIN_800_MV, STEP_50_MV),
> > + regulator_desc_ldo(3, MIN_800_MV, STEP_50_MV),
> > + regulator_desc_ldo(4, MIN_800_MV, STEP_50_MV),
> > + regulator_desc_ldo(5, MIN_800_MV, STEP_50_MV),
> > + regulator_desc_ldo(6, MIN_800_MV, STEP_25_MV),
> > + regulator_desc_ldo(7, MIN_800_MV, STEP_50_MV),
> > + regulator_desc_ldo(8, MIN_800_MV, STEP_50_MV),
> > + regulator_desc_ldo(9, MIN_800_MV, STEP_50_MV),
> > + regulator_desc_ldo(10, MIN_800_MV, STEP_50_MV),
> > + regulator_desc_ldo(11, MIN_800_MV, STEP_25_MV),
> > + regulator_desc_ldo(12, MIN_800_MV, STEP_50_MV),
> > + regulator_desc_ldo(13, MIN_800_MV, STEP_50_MV),
> > + regulator_desc_ldo(14, MIN_800_MV, STEP_50_MV),
> > + regulator_desc_ldo(15, MIN_800_MV, STEP_50_MV),
> > + regulator_desc_ldo(16, MIN_800_MV, STEP_50_MV),
> > + regulator_desc_ldo(17, MIN_800_MV, STEP_50_MV),
> > + regulator_desc_ldo(18, MIN_800_MV, STEP_50_MV),
> > + regulator_desc_ldo(19, MIN_800_MV, STEP_50_MV),
> > + regulator_desc_ldo(20, MIN_800_MV, STEP_50_MV),
> > + regulator_desc_ldo(21, MIN_800_MV, STEP_50_MV),
> > + regulator_desc_ldo(22, MIN_800_MV, STEP_25_MV),
> > + regulator_desc_ldo(23, MIN_800_MV, STEP_25_MV),
> > + regulator_desc_ldo(24, MIN_800_MV, STEP_50_MV),
> > + regulator_desc_ldo(25, MIN_800_MV, STEP_50_MV),
> > + regulator_desc_ldo(26, MIN_800_MV, STEP_50_MV),
> > regulator_desc_buck1_4(1),
> > regulator_desc_buck1_4(2),
> > regulator_desc_buck1_4(3),
> > regulator_desc_buck1_4(4),
> > regulator_desc_buck5,
> > - regulator_desc_buck6_7(6),
> > - regulator_desc_buck6_7(7),
> > - regulator_desc_buck8,
> > - regulator_desc_buck9,
> > - regulator_desc_buck10,
> > + regulator_desc_buck6_10(6, MIN_600_MV, STEP_6_25_MV),
> > + regulator_desc_buck6_10(7, MIN_600_MV, STEP_6_25_MV),
> > + regulator_desc_buck6_10(8, MIN_800_MV, STEP_12_5_MV),
> > + regulator_desc_buck6_10(9, MIN_1500_MV, STEP_12_5_MV),
> > + regulator_desc_buck6_10(10, MIN_1000_MV, STEP_12_5_MV),
> > };
> >
> > static int s2mpa01_pmic_probe(struct platform_device *pdev)
> >

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

2014-07-10 10:10:21

by amit daniel kachhap

[permalink] [raw]
Subject: Re: [PATCH 2/3] regulator: s2mpa01: Optimize the regulator description macro

On Thu, Jul 10, 2014 at 1:05 PM, Lee Jones <[email protected]> wrote:
> On Thu, 10 Jul 2014, amit daniel kachhap wrote:
>> Adding MFD maintainers.
>
> Why, what for?
Sorry not needed for this patch.
>
>> On Tue, Jul 8, 2014 at 5:57 PM, Amit Daniel Kachhap
>> <[email protected]> wrote:
>> > This patch makes the regulator description macro take minimum and
>> > steps voltage as parameter. In this way many repeated macros can be
>> > removed. Now these macros are repeated only if the the LDO/BUCK ctrl
>> > registers have non-linear positions. The good thing is these ctrl registers
>> > are mostly linear so they are not passed as parameters.
>> >
>> > This patch reduces the code size and also allow easy addition of more
>> > s2mpxxx PMIC drivers which differs a lot in minimum/step voltages.
>> >
>> > Signed-off-by: Amit Daniel Kachhap <[email protected]>
>> > ---
>> > drivers/regulator/s2mpa01.c | 136 ++++++++++++--------------------------------
>> > 1 file changed, 37 insertions(+), 99 deletions(-)
>> >
>> > diff --git a/drivers/regulator/s2mpa01.c b/drivers/regulator/s2mpa01.c
>> > index 962c5f1..8073466 100644
>> > --- a/drivers/regulator/s2mpa01.c
>> > +++ b/drivers/regulator/s2mpa01.c
>> > @@ -235,28 +235,14 @@ static struct regulator_ops s2mpa01_buck_ops = {
>> > .set_ramp_delay = s2mpa01_set_ramp_delay,
>> > };
>> >
>> > -#define regulator_desc_ldo1(num) { \
>> > +#define regulator_desc_ldo(num, min, step) { \
>> > .name = "LDO"#num, \
>> > .id = S2MPA01_LDO##num, \
>> > .ops = &s2mpa01_ldo_ops, \
>> > .type = REGULATOR_VOLTAGE, \
>> > .owner = THIS_MODULE, \
>> > - .min_uV = MIN_800_MV, \
>> > - .uV_step = STEP_50_MV, \
>> > - .n_voltages = S2MPA01_LDO_N_VOLTAGES, \
>> > - .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \
>> > - .vsel_mask = S2MPA01_LDO_VSEL_MASK, \
>> > - .enable_reg = S2MPA01_REG_L1CTRL + num - 1, \
>> > - .enable_mask = S2MPA01_ENABLE_MASK \
>> > -}
>> > -#define regulator_desc_ldo2(num) { \
>> > - .name = "LDO"#num, \
>> > - .id = S2MPA01_LDO##num, \
>> > - .ops = &s2mpa01_ldo_ops, \
>> > - .type = REGULATOR_VOLTAGE, \
>> > - .owner = THIS_MODULE, \
>> > - .min_uV = MIN_800_MV, \
>> > - .uV_step = STEP_25_MV, \
>> > + .min_uV = min, \
>> > + .uV_step = step, \
>> > .n_voltages = S2MPA01_LDO_N_VOLTAGES, \
>> > .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \
>> > .vsel_mask = S2MPA01_LDO_VSEL_MASK, \
>> > @@ -296,14 +282,14 @@ static struct regulator_ops s2mpa01_buck_ops = {
>> > .enable_mask = S2MPA01_ENABLE_MASK \
>> > }
>> >
>> > -#define regulator_desc_buck6_7(num) { \
>> > +#define regulator_desc_buck6_10(num, min, step) { \
>> > .name = "BUCK"#num, \
>> > .id = S2MPA01_BUCK##num, \
>> > .ops = &s2mpa01_buck_ops, \
>> > .type = REGULATOR_VOLTAGE, \
>> > .owner = THIS_MODULE, \
>> > - .min_uV = MIN_600_MV, \
>> > - .uV_step = STEP_6_25_MV, \
>> > + .min_uV = min, \
>> > + .uV_step = step, \
>> > .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
>> > .ramp_delay = S2MPA01_RAMP_DELAY, \
>> > .vsel_reg = S2MPA01_REG_B6CTRL2 + (num - 6) * 2, \
>> > @@ -312,91 +298,43 @@ static struct regulator_ops s2mpa01_buck_ops = {
>> > .enable_mask = S2MPA01_ENABLE_MASK \
>> > }
>> >
>> > -#define regulator_desc_buck8 { \
>> > - .name = "BUCK8", \
>> > - .id = S2MPA01_BUCK8, \
>> > - .ops = &s2mpa01_buck_ops, \
>> > - .type = REGULATOR_VOLTAGE, \
>> > - .owner = THIS_MODULE, \
>> > - .min_uV = MIN_800_MV, \
>> > - .uV_step = STEP_12_5_MV, \
>> > - .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
>> > - .ramp_delay = S2MPA01_RAMP_DELAY, \
>> > - .vsel_reg = S2MPA01_REG_B8CTRL2, \
>> > - .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \
>> > - .enable_reg = S2MPA01_REG_B8CTRL1, \
>> > - .enable_mask = S2MPA01_ENABLE_MASK \
>> > -}
>> > -
>> > -#define regulator_desc_buck9 { \
>> > - .name = "BUCK9", \
>> > - .id = S2MPA01_BUCK9, \
>> > - .ops = &s2mpa01_buck_ops, \
>> > - .type = REGULATOR_VOLTAGE, \
>> > - .owner = THIS_MODULE, \
>> > - .min_uV = MIN_1500_MV, \
>> > - .uV_step = STEP_12_5_MV, \
>> > - .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
>> > - .ramp_delay = S2MPA01_RAMP_DELAY, \
>> > - .vsel_reg = S2MPA01_REG_B9CTRL2, \
>> > - .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \
>> > - .enable_reg = S2MPA01_REG_B9CTRL1, \
>> > - .enable_mask = S2MPA01_ENABLE_MASK \
>> > -}
>> > -
>> > -#define regulator_desc_buck10 { \
>> > - .name = "BUCK10", \
>> > - .id = S2MPA01_BUCK10, \
>> > - .ops = &s2mpa01_buck_ops, \
>> > - .type = REGULATOR_VOLTAGE, \
>> > - .owner = THIS_MODULE, \
>> > - .min_uV = MIN_1000_MV, \
>> > - .uV_step = STEP_12_5_MV, \
>> > - .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
>> > - .ramp_delay = S2MPA01_RAMP_DELAY, \
>> > - .vsel_reg = S2MPA01_REG_B10CTRL2, \
>> > - .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \
>> > - .enable_reg = S2MPA01_REG_B10CTRL1, \
>> > - .enable_mask = S2MPA01_ENABLE_MASK \
>> > -}
>> > -
>> > static struct regulator_desc regulators[] = {
>> > - regulator_desc_ldo2(1),
>> > - regulator_desc_ldo1(2),
>> > - regulator_desc_ldo1(3),
>> > - regulator_desc_ldo1(4),
>> > - regulator_desc_ldo1(5),
>> > - regulator_desc_ldo2(6),
>> > - regulator_desc_ldo1(7),
>> > - regulator_desc_ldo1(8),
>> > - regulator_desc_ldo1(9),
>> > - regulator_desc_ldo1(10),
>> > - regulator_desc_ldo2(11),
>> > - regulator_desc_ldo1(12),
>> > - regulator_desc_ldo1(13),
>> > - regulator_desc_ldo1(14),
>> > - regulator_desc_ldo1(15),
>> > - regulator_desc_ldo1(16),
>> > - regulator_desc_ldo1(17),
>> > - regulator_desc_ldo1(18),
>> > - regulator_desc_ldo1(19),
>> > - regulator_desc_ldo1(20),
>> > - regulator_desc_ldo1(21),
>> > - regulator_desc_ldo2(22),
>> > - regulator_desc_ldo2(23),
>> > - regulator_desc_ldo1(24),
>> > - regulator_desc_ldo1(25),
>> > - regulator_desc_ldo1(26),
>> > + regulator_desc_ldo(1, MIN_800_MV, STEP_25_MV),
>> > + regulator_desc_ldo(2, MIN_800_MV, STEP_50_MV),
>> > + regulator_desc_ldo(3, MIN_800_MV, STEP_50_MV),
>> > + regulator_desc_ldo(4, MIN_800_MV, STEP_50_MV),
>> > + regulator_desc_ldo(5, MIN_800_MV, STEP_50_MV),
>> > + regulator_desc_ldo(6, MIN_800_MV, STEP_25_MV),
>> > + regulator_desc_ldo(7, MIN_800_MV, STEP_50_MV),
>> > + regulator_desc_ldo(8, MIN_800_MV, STEP_50_MV),
>> > + regulator_desc_ldo(9, MIN_800_MV, STEP_50_MV),
>> > + regulator_desc_ldo(10, MIN_800_MV, STEP_50_MV),
>> > + regulator_desc_ldo(11, MIN_800_MV, STEP_25_MV),
>> > + regulator_desc_ldo(12, MIN_800_MV, STEP_50_MV),
>> > + regulator_desc_ldo(13, MIN_800_MV, STEP_50_MV),
>> > + regulator_desc_ldo(14, MIN_800_MV, STEP_50_MV),
>> > + regulator_desc_ldo(15, MIN_800_MV, STEP_50_MV),
>> > + regulator_desc_ldo(16, MIN_800_MV, STEP_50_MV),
>> > + regulator_desc_ldo(17, MIN_800_MV, STEP_50_MV),
>> > + regulator_desc_ldo(18, MIN_800_MV, STEP_50_MV),
>> > + regulator_desc_ldo(19, MIN_800_MV, STEP_50_MV),
>> > + regulator_desc_ldo(20, MIN_800_MV, STEP_50_MV),
>> > + regulator_desc_ldo(21, MIN_800_MV, STEP_50_MV),
>> > + regulator_desc_ldo(22, MIN_800_MV, STEP_25_MV),
>> > + regulator_desc_ldo(23, MIN_800_MV, STEP_25_MV),
>> > + regulator_desc_ldo(24, MIN_800_MV, STEP_50_MV),
>> > + regulator_desc_ldo(25, MIN_800_MV, STEP_50_MV),
>> > + regulator_desc_ldo(26, MIN_800_MV, STEP_50_MV),
>> > regulator_desc_buck1_4(1),
>> > regulator_desc_buck1_4(2),
>> > regulator_desc_buck1_4(3),
>> > regulator_desc_buck1_4(4),
>> > regulator_desc_buck5,
>> > - regulator_desc_buck6_7(6),
>> > - regulator_desc_buck6_7(7),
>> > - regulator_desc_buck8,
>> > - regulator_desc_buck9,
>> > - regulator_desc_buck10,
>> > + regulator_desc_buck6_10(6, MIN_600_MV, STEP_6_25_MV),
>> > + regulator_desc_buck6_10(7, MIN_600_MV, STEP_6_25_MV),
>> > + regulator_desc_buck6_10(8, MIN_800_MV, STEP_12_5_MV),
>> > + regulator_desc_buck6_10(9, MIN_1500_MV, STEP_12_5_MV),
>> > + regulator_desc_buck6_10(10, MIN_1000_MV, STEP_12_5_MV),
>> > };
>> >
>> > static int s2mpa01_pmic_probe(struct platform_device *pdev)
>> >
>
> --
> Lee Jones
> Linaro STMicroelectronics Landing Team Lead
> Linaro.org │ Open source software for ARM SoCs
> Follow Linaro: Facebook | Twitter | Blog
> --
> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2014-07-14 08:50:08

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH 2/3] regulator: s2mpa01: Optimize the regulator description macro

On 08.07.2014 14:27, Amit Daniel Kachhap wrote:
> This patch makes the regulator description macro take minimum and
> steps voltage as parameter. In this way many repeated macros can be
> removed. Now these macros are repeated only if the the LDO/BUCK ctrl
> registers have non-linear positions. The good thing is these ctrl registers
> are mostly linear so they are not passed as parameters.
>
> This patch reduces the code size and also allow easy addition of more
> s2mpxxx PMIC drivers which differs a lot in minimum/step voltages.
>
> Signed-off-by: Amit Daniel Kachhap <[email protected]>
> ---
> drivers/regulator/s2mpa01.c | 136 ++++++++++++--------------------------------
> 1 file changed, 37 insertions(+), 99 deletions(-)
>
> diff --git a/drivers/regulator/s2mpa01.c b/drivers/regulator/s2mpa01.c
> index 962c5f1..8073466 100644
> --- a/drivers/regulator/s2mpa01.c
> +++ b/drivers/regulator/s2mpa01.c
> @@ -235,28 +235,14 @@ static struct regulator_ops s2mpa01_buck_ops = {
> .set_ramp_delay = s2mpa01_set_ramp_delay,
> };
>
> -#define regulator_desc_ldo1(num) { \
> +#define regulator_desc_ldo(num, min, step) { \

Why adding parameter for the 'min' value? It is always the same for LDOs
- 800 mV.

The same applies for the s2mps11 regulator driver.

Best regards,
Krzysztof

> .name = "LDO"#num, \
> .id = S2MPA01_LDO##num, \
> .ops = &s2mpa01_ldo_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = MIN_800_MV, \
> - .uV_step = STEP_50_MV, \
> - .n_voltages = S2MPA01_LDO_N_VOLTAGES, \
> - .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \
> - .vsel_mask = S2MPA01_LDO_VSEL_MASK, \
> - .enable_reg = S2MPA01_REG_L1CTRL + num - 1, \
> - .enable_mask = S2MPA01_ENABLE_MASK \
> -}
> -#define regulator_desc_ldo2(num) { \
> - .name = "LDO"#num, \
> - .id = S2MPA01_LDO##num, \
> - .ops = &s2mpa01_ldo_ops, \
> - .type = REGULATOR_VOLTAGE, \
> - .owner = THIS_MODULE, \
> - .min_uV = MIN_800_MV, \
> - .uV_step = STEP_25_MV, \
> + .min_uV = min, \
> + .uV_step = step, \
> .n_voltages = S2MPA01_LDO_N_VOLTAGES, \
> .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \
> .vsel_mask = S2MPA01_LDO_VSEL_MASK, \
> @@ -296,14 +282,14 @@ static struct regulator_ops s2mpa01_buck_ops = {
> .enable_mask = S2MPA01_ENABLE_MASK \
> }
>
> -#define regulator_desc_buck6_7(num) { \
> +#define regulator_desc_buck6_10(num, min, step) { \
> .name = "BUCK"#num, \
> .id = S2MPA01_BUCK##num, \
> .ops = &s2mpa01_buck_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = MIN_600_MV, \
> - .uV_step = STEP_6_25_MV, \
> + .min_uV = min, \
> + .uV_step = step, \
> .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
> .ramp_delay = S2MPA01_RAMP_DELAY, \
> .vsel_reg = S2MPA01_REG_B6CTRL2 + (num - 6) * 2, \
> @@ -312,91 +298,43 @@ static struct regulator_ops s2mpa01_buck_ops = {
> .enable_mask = S2MPA01_ENABLE_MASK \
> }
>
> -#define regulator_desc_buck8 { \
> - .name = "BUCK8", \
> - .id = S2MPA01_BUCK8, \
> - .ops = &s2mpa01_buck_ops, \
> - .type = REGULATOR_VOLTAGE, \
> - .owner = THIS_MODULE, \
> - .min_uV = MIN_800_MV, \
> - .uV_step = STEP_12_5_MV, \
> - .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
> - .ramp_delay = S2MPA01_RAMP_DELAY, \
> - .vsel_reg = S2MPA01_REG_B8CTRL2, \
> - .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \
> - .enable_reg = S2MPA01_REG_B8CTRL1, \
> - .enable_mask = S2MPA01_ENABLE_MASK \
> -}
> -
> -#define regulator_desc_buck9 { \
> - .name = "BUCK9", \
> - .id = S2MPA01_BUCK9, \
> - .ops = &s2mpa01_buck_ops, \
> - .type = REGULATOR_VOLTAGE, \
> - .owner = THIS_MODULE, \
> - .min_uV = MIN_1500_MV, \
> - .uV_step = STEP_12_5_MV, \
> - .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
> - .ramp_delay = S2MPA01_RAMP_DELAY, \
> - .vsel_reg = S2MPA01_REG_B9CTRL2, \
> - .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \
> - .enable_reg = S2MPA01_REG_B9CTRL1, \
> - .enable_mask = S2MPA01_ENABLE_MASK \
> -}
> -
> -#define regulator_desc_buck10 { \
> - .name = "BUCK10", \
> - .id = S2MPA01_BUCK10, \
> - .ops = &s2mpa01_buck_ops, \
> - .type = REGULATOR_VOLTAGE, \
> - .owner = THIS_MODULE, \
> - .min_uV = MIN_1000_MV, \
> - .uV_step = STEP_12_5_MV, \
> - .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
> - .ramp_delay = S2MPA01_RAMP_DELAY, \
> - .vsel_reg = S2MPA01_REG_B10CTRL2, \
> - .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \
> - .enable_reg = S2MPA01_REG_B10CTRL1, \
> - .enable_mask = S2MPA01_ENABLE_MASK \
> -}
> -
> static struct regulator_desc regulators[] = {
> - regulator_desc_ldo2(1),
> - regulator_desc_ldo1(2),
> - regulator_desc_ldo1(3),
> - regulator_desc_ldo1(4),
> - regulator_desc_ldo1(5),
> - regulator_desc_ldo2(6),
> - regulator_desc_ldo1(7),
> - regulator_desc_ldo1(8),
> - regulator_desc_ldo1(9),
> - regulator_desc_ldo1(10),
> - regulator_desc_ldo2(11),
> - regulator_desc_ldo1(12),
> - regulator_desc_ldo1(13),
> - regulator_desc_ldo1(14),
> - regulator_desc_ldo1(15),
> - regulator_desc_ldo1(16),
> - regulator_desc_ldo1(17),
> - regulator_desc_ldo1(18),
> - regulator_desc_ldo1(19),
> - regulator_desc_ldo1(20),
> - regulator_desc_ldo1(21),
> - regulator_desc_ldo2(22),
> - regulator_desc_ldo2(23),
> - regulator_desc_ldo1(24),
> - regulator_desc_ldo1(25),
> - regulator_desc_ldo1(26),
> + regulator_desc_ldo(1, MIN_800_MV, STEP_25_MV),
> + regulator_desc_ldo(2, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(3, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(4, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(5, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(6, MIN_800_MV, STEP_25_MV),
> + regulator_desc_ldo(7, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(8, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(9, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(10, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(11, MIN_800_MV, STEP_25_MV),
> + regulator_desc_ldo(12, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(13, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(14, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(15, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(16, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(17, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(18, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(19, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(20, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(21, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(22, MIN_800_MV, STEP_25_MV),
> + regulator_desc_ldo(23, MIN_800_MV, STEP_25_MV),
> + regulator_desc_ldo(24, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(25, MIN_800_MV, STEP_50_MV),
> + regulator_desc_ldo(26, MIN_800_MV, STEP_50_MV),
> regulator_desc_buck1_4(1),
> regulator_desc_buck1_4(2),
> regulator_desc_buck1_4(3),
> regulator_desc_buck1_4(4),
> regulator_desc_buck5,
> - regulator_desc_buck6_7(6),
> - regulator_desc_buck6_7(7),
> - regulator_desc_buck8,
> - regulator_desc_buck9,
> - regulator_desc_buck10,
> + regulator_desc_buck6_10(6, MIN_600_MV, STEP_6_25_MV),
> + regulator_desc_buck6_10(7, MIN_600_MV, STEP_6_25_MV),
> + regulator_desc_buck6_10(8, MIN_800_MV, STEP_12_5_MV),
> + regulator_desc_buck6_10(9, MIN_1500_MV, STEP_12_5_MV),
> + regulator_desc_buck6_10(10, MIN_1000_MV, STEP_12_5_MV),
> };
>
> static int s2mpa01_pmic_probe(struct platform_device *pdev)
>

2014-07-14 08:53:20

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH 1/3] regulator: s2mpxxx: Move regulator min/step voltages in common place

On 08.07.2014 14:27, Amit Daniel Kachhap wrote:
> This is a cleanup patch and moves min/step voltages in a common samsung
> header file so that they can be used by other s2mpxxx PMIC drivers. Only
> few required macros are added currently and others can be added if needed.
>
> Signed-off-by: Amit Daniel Kachhap <[email protected]>
> ---
> drivers/regulator/s2mpa01.c | 32 ++++++++++++------------
> drivers/regulator/s2mps11.c | 50 ++++++++++++++++++-------------------
> include/linux/mfd/samsung/core.h | 21 ++++++++++++++++
> include/linux/mfd/samsung/s2mpa01.h | 12 ---------
> include/linux/mfd/samsung/s2mps11.h | 9 -------
> include/linux/mfd/samsung/s2mps14.h | 10 --------
> 6 files changed, 62 insertions(+), 72 deletions(-)
>

Hi,

Looks good.

Reviewed-by: Krzysztof Kozlowski <[email protected]>

Best regards,
Krzysztof

> diff --git a/drivers/regulator/s2mpa01.c b/drivers/regulator/s2mpa01.c
> index ee83b48..962c5f1 100644
> --- a/drivers/regulator/s2mpa01.c
> +++ b/drivers/regulator/s2mpa01.c
> @@ -241,8 +241,8 @@ static struct regulator_ops s2mpa01_buck_ops = {
> .ops = &s2mpa01_ldo_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = S2MPA01_LDO_MIN, \
> - .uV_step = S2MPA01_LDO_STEP1, \
> + .min_uV = MIN_800_MV, \
> + .uV_step = STEP_50_MV, \
> .n_voltages = S2MPA01_LDO_N_VOLTAGES, \
> .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \
> .vsel_mask = S2MPA01_LDO_VSEL_MASK, \
> @@ -255,8 +255,8 @@ static struct regulator_ops s2mpa01_buck_ops = {
> .ops = &s2mpa01_ldo_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = S2MPA01_LDO_MIN, \
> - .uV_step = S2MPA01_LDO_STEP2, \
> + .min_uV = MIN_800_MV, \
> + .uV_step = STEP_25_MV, \
> .n_voltages = S2MPA01_LDO_N_VOLTAGES, \
> .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \
> .vsel_mask = S2MPA01_LDO_VSEL_MASK, \
> @@ -270,8 +270,8 @@ static struct regulator_ops s2mpa01_buck_ops = {
> .ops = &s2mpa01_buck_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = S2MPA01_BUCK_MIN1, \
> - .uV_step = S2MPA01_BUCK_STEP1, \
> + .min_uV = MIN_600_MV, \
> + .uV_step = STEP_6_25_MV, \
> .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
> .ramp_delay = S2MPA01_RAMP_DELAY, \
> .vsel_reg = S2MPA01_REG_B1CTRL2 + (num - 1) * 2, \
> @@ -286,8 +286,8 @@ static struct regulator_ops s2mpa01_buck_ops = {
> .ops = &s2mpa01_buck_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = S2MPA01_BUCK_MIN2, \
> - .uV_step = S2MPA01_BUCK_STEP1, \
> + .min_uV = MIN_800_MV, \
> + .uV_step = STEP_6_25_MV, \
> .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
> .ramp_delay = S2MPA01_RAMP_DELAY, \
> .vsel_reg = S2MPA01_REG_B5CTRL2, \
> @@ -302,8 +302,8 @@ static struct regulator_ops s2mpa01_buck_ops = {
> .ops = &s2mpa01_buck_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = S2MPA01_BUCK_MIN1, \
> - .uV_step = S2MPA01_BUCK_STEP1, \
> + .min_uV = MIN_600_MV, \
> + .uV_step = STEP_6_25_MV, \
> .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
> .ramp_delay = S2MPA01_RAMP_DELAY, \
> .vsel_reg = S2MPA01_REG_B6CTRL2 + (num - 6) * 2, \
> @@ -318,8 +318,8 @@ static struct regulator_ops s2mpa01_buck_ops = {
> .ops = &s2mpa01_buck_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = S2MPA01_BUCK_MIN2, \
> - .uV_step = S2MPA01_BUCK_STEP2, \
> + .min_uV = MIN_800_MV, \
> + .uV_step = STEP_12_5_MV, \
> .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
> .ramp_delay = S2MPA01_RAMP_DELAY, \
> .vsel_reg = S2MPA01_REG_B8CTRL2, \
> @@ -334,8 +334,8 @@ static struct regulator_ops s2mpa01_buck_ops = {
> .ops = &s2mpa01_buck_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = S2MPA01_BUCK_MIN4, \
> - .uV_step = S2MPA01_BUCK_STEP2, \
> + .min_uV = MIN_1500_MV, \
> + .uV_step = STEP_12_5_MV, \
> .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
> .ramp_delay = S2MPA01_RAMP_DELAY, \
> .vsel_reg = S2MPA01_REG_B9CTRL2, \
> @@ -350,8 +350,8 @@ static struct regulator_ops s2mpa01_buck_ops = {
> .ops = &s2mpa01_buck_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = S2MPA01_BUCK_MIN3, \
> - .uV_step = S2MPA01_BUCK_STEP2, \
> + .min_uV = MIN_1000_MV, \
> + .uV_step = STEP_12_5_MV, \
> .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
> .ramp_delay = S2MPA01_RAMP_DELAY, \
> .vsel_reg = S2MPA01_REG_B10CTRL2, \
> diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
> index 02e2fb2..2098c3e 100644
> --- a/drivers/regulator/s2mps11.c
> +++ b/drivers/regulator/s2mps11.c
> @@ -250,14 +250,14 @@ static struct regulator_ops s2mps11_buck_ops = {
> .set_ramp_delay = s2mps11_set_ramp_delay,
> };
>
> -#define regulator_desc_s2mps11_ldo1(num) { \
> +#define regulator_desc_s2mps11_ldo1(num) { \
> .name = "LDO"#num, \
> .id = S2MPS11_LDO##num, \
> .ops = &s2mps11_ldo_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = S2MPS11_LDO_MIN, \
> - .uV_step = S2MPS11_LDO_STEP1, \
> + .min_uV = MIN_800_MV, \
> + .uV_step = STEP_50_MV, \
> .n_voltages = S2MPS11_LDO_N_VOLTAGES, \
> .vsel_reg = S2MPS11_REG_L1CTRL + num - 1, \
> .vsel_mask = S2MPS11_LDO_VSEL_MASK, \
> @@ -270,8 +270,8 @@ static struct regulator_ops s2mps11_buck_ops = {
> .ops = &s2mps11_ldo_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = S2MPS11_LDO_MIN, \
> - .uV_step = S2MPS11_LDO_STEP2, \
> + .min_uV = MIN_800_MV, \
> + .uV_step = STEP_25_MV, \
> .n_voltages = S2MPS11_LDO_N_VOLTAGES, \
> .vsel_reg = S2MPS11_REG_L1CTRL + num - 1, \
> .vsel_mask = S2MPS11_LDO_VSEL_MASK, \
> @@ -285,8 +285,8 @@ static struct regulator_ops s2mps11_buck_ops = {
> .ops = &s2mps11_buck_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = S2MPS11_BUCK_MIN1, \
> - .uV_step = S2MPS11_BUCK_STEP1, \
> + .min_uV = MIN_600_MV, \
> + .uV_step = STEP_6_25_MV, \
> .n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
> .ramp_delay = S2MPS11_RAMP_DELAY, \
> .vsel_reg = S2MPS11_REG_B1CTRL2 + (num - 1) * 2, \
> @@ -301,8 +301,8 @@ static struct regulator_ops s2mps11_buck_ops = {
> .ops = &s2mps11_buck_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = S2MPS11_BUCK_MIN1, \
> - .uV_step = S2MPS11_BUCK_STEP1, \
> + .min_uV = MIN_600_MV, \
> + .uV_step = STEP_6_25_MV, \
> .n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
> .ramp_delay = S2MPS11_RAMP_DELAY, \
> .vsel_reg = S2MPS11_REG_B5CTRL2, \
> @@ -317,8 +317,8 @@ static struct regulator_ops s2mps11_buck_ops = {
> .ops = &s2mps11_buck_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = S2MPS11_BUCK_MIN1, \
> - .uV_step = S2MPS11_BUCK_STEP1, \
> + .min_uV = MIN_600_MV, \
> + .uV_step = STEP_6_25_MV, \
> .n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
> .ramp_delay = S2MPS11_RAMP_DELAY, \
> .vsel_reg = S2MPS11_REG_B6CTRL2 + (num - 6) * 2, \
> @@ -333,8 +333,8 @@ static struct regulator_ops s2mps11_buck_ops = {
> .ops = &s2mps11_buck_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = S2MPS11_BUCK_MIN3, \
> - .uV_step = S2MPS11_BUCK_STEP3, \
> + .min_uV = MIN_3000_MV, \
> + .uV_step = STEP_25_MV, \
> .n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
> .ramp_delay = S2MPS11_RAMP_DELAY, \
> .vsel_reg = S2MPS11_REG_B9CTRL2, \
> @@ -349,8 +349,8 @@ static struct regulator_ops s2mps11_buck_ops = {
> .ops = &s2mps11_buck_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = S2MPS11_BUCK_MIN2, \
> - .uV_step = S2MPS11_BUCK_STEP2, \
> + .min_uV = MIN_750_MV, \
> + .uV_step = STEP_12_5_MV, \
> .n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
> .ramp_delay = S2MPS11_RAMP_DELAY, \
> .vsel_reg = S2MPS11_REG_B10CTRL2, \
> @@ -473,8 +473,8 @@ static struct regulator_ops s2mps14_reg_ops = {
> .ops = &s2mps14_reg_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = S2MPS14_LDO_MIN_800MV, \
> - .uV_step = S2MPS14_LDO_STEP_25MV, \
> + .min_uV = MIN_800_MV, \
> + .uV_step = STEP_25_MV, \
> .n_voltages = S2MPS14_LDO_N_VOLTAGES, \
> .vsel_reg = S2MPS14_REG_L1CTRL + num - 1, \
> .vsel_mask = S2MPS14_LDO_VSEL_MASK, \
> @@ -487,8 +487,8 @@ static struct regulator_ops s2mps14_reg_ops = {
> .ops = &s2mps14_reg_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = S2MPS14_LDO_MIN_1800MV, \
> - .uV_step = S2MPS14_LDO_STEP_25MV, \
> + .min_uV = MIN_1800_MV, \
> + .uV_step = STEP_25_MV, \
> .n_voltages = S2MPS14_LDO_N_VOLTAGES, \
> .vsel_reg = S2MPS14_REG_L1CTRL + num - 1, \
> .vsel_mask = S2MPS14_LDO_VSEL_MASK, \
> @@ -501,8 +501,8 @@ static struct regulator_ops s2mps14_reg_ops = {
> .ops = &s2mps14_reg_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = S2MPS14_LDO_MIN_800MV, \
> - .uV_step = S2MPS14_LDO_STEP_12_5MV, \
> + .min_uV = MIN_800_MV, \
> + .uV_step = STEP_12_5_MV, \
> .n_voltages = S2MPS14_LDO_N_VOLTAGES, \
> .vsel_reg = S2MPS14_REG_L1CTRL + num - 1, \
> .vsel_mask = S2MPS14_LDO_VSEL_MASK, \
> @@ -515,8 +515,8 @@ static struct regulator_ops s2mps14_reg_ops = {
> .ops = &s2mps14_reg_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = S2MPS14_BUCK1235_MIN_600MV, \
> - .uV_step = S2MPS14_BUCK1235_STEP_6_25MV, \
> + .min_uV = MIN_600_MV, \
> + .uV_step = STEP_6_25_MV, \
> .n_voltages = S2MPS14_BUCK_N_VOLTAGES, \
> .linear_min_sel = S2MPS14_BUCK1235_START_SEL, \
> .ramp_delay = S2MPS14_BUCK_RAMP_DELAY, \
> @@ -531,8 +531,8 @@ static struct regulator_ops s2mps14_reg_ops = {
> .ops = &s2mps14_reg_ops, \
> .type = REGULATOR_VOLTAGE, \
> .owner = THIS_MODULE, \
> - .min_uV = S2MPS14_BUCK4_MIN_1400MV, \
> - .uV_step = S2MPS14_BUCK4_STEP_12_5MV, \
> + .min_uV = MIN_1400_MV, \
> + .uV_step = STEP_12_5_MV, \
> .n_voltages = S2MPS14_BUCK_N_VOLTAGES, \
> .linear_min_sel = S2MPS14_BUCK4_START_SEL, \
> .ramp_delay = S2MPS14_BUCK_RAMP_DELAY, \
> diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h
> index 47d8424..a4118aa 100644
> --- a/include/linux/mfd/samsung/core.h
> +++ b/include/linux/mfd/samsung/core.h
> @@ -14,6 +14,27 @@
> #ifndef __LINUX_MFD_SEC_CORE_H
> #define __LINUX_MFD_SEC_CORE_H
>
> +/* Macros to represent minimum voltages for LDO/BUCK */
> +#define MIN_3000_MV 3000000
> +#define MIN_2500_MV 2500000
> +#define MIN_2000_MV 2000000
> +#define MIN_1800_MV 1800000
> +#define MIN_1500_MV 1500000
> +#define MIN_1400_MV 1400000
> +#define MIN_1000_MV 1000000
> +
> +#define MIN_900_MV 900000
> +#define MIN_850_MV 850000
> +#define MIN_800_MV 800000
> +#define MIN_750_MV 750000
> +#define MIN_600_MV 600000
> +
> +/* Macros to represent steps for LDO/BUCK */
> +#define STEP_50_MV 50000
> +#define STEP_25_MV 25000
> +#define STEP_12_5_MV 12500
> +#define STEP_6_25_MV 6250
> +
> enum sec_device_type {
> S5M8751X,
> S5M8763X,
> diff --git a/include/linux/mfd/samsung/s2mpa01.h b/include/linux/mfd/samsung/s2mpa01.h
> index fbc63bc..2766108 100644
> --- a/include/linux/mfd/samsung/s2mpa01.h
> +++ b/include/linux/mfd/samsung/s2mpa01.h
> @@ -155,18 +155,6 @@ enum s2mpa01_regulators {
> S2MPA01_REGULATOR_MAX,
> };
>
> -#define S2MPA01_BUCK_MIN1 600000
> -#define S2MPA01_BUCK_MIN2 800000
> -#define S2MPA01_BUCK_MIN3 1000000
> -#define S2MPA01_BUCK_MIN4 1500000
> -#define S2MPA01_LDO_MIN 800000
> -
> -#define S2MPA01_BUCK_STEP1 6250
> -#define S2MPA01_BUCK_STEP2 12500
> -
> -#define S2MPA01_LDO_STEP1 50000
> -#define S2MPA01_LDO_STEP2 25000
> -
> #define S2MPA01_LDO_VSEL_MASK 0x3F
> #define S2MPA01_BUCK_VSEL_MASK 0xFF
> #define S2MPA01_ENABLE_MASK (0x03 << S2MPA01_ENABLE_SHIFT)
> diff --git a/include/linux/mfd/samsung/s2mps11.h b/include/linux/mfd/samsung/s2mps11.h
> index b3ddf98..7981a9d 100644
> --- a/include/linux/mfd/samsung/s2mps11.h
> +++ b/include/linux/mfd/samsung/s2mps11.h
> @@ -171,15 +171,6 @@ enum s2mps11_regulators {
> S2MPS11_REGULATOR_MAX,
> };
>
> -#define S2MPS11_BUCK_MIN1 600000
> -#define S2MPS11_BUCK_MIN2 750000
> -#define S2MPS11_BUCK_MIN3 3000000
> -#define S2MPS11_LDO_MIN 800000
> -#define S2MPS11_BUCK_STEP1 6250
> -#define S2MPS11_BUCK_STEP2 12500
> -#define S2MPS11_BUCK_STEP3 25000
> -#define S2MPS11_LDO_STEP1 50000
> -#define S2MPS11_LDO_STEP2 25000
> #define S2MPS11_LDO_VSEL_MASK 0x3F
> #define S2MPS11_BUCK_VSEL_MASK 0xFF
> #define S2MPS11_ENABLE_MASK (0x03 << S2MPS11_ENABLE_SHIFT)
> diff --git a/include/linux/mfd/samsung/s2mps14.h b/include/linux/mfd/samsung/s2mps14.h
> index 900cd7a..c92f478 100644
> --- a/include/linux/mfd/samsung/s2mps14.h
> +++ b/include/linux/mfd/samsung/s2mps14.h
> @@ -123,10 +123,6 @@ enum s2mps14_regulators {
> };
>
> /* Regulator constraints for BUCKx */
> -#define S2MPS14_BUCK1235_MIN_600MV 600000
> -#define S2MPS14_BUCK4_MIN_1400MV 1400000
> -#define S2MPS14_BUCK1235_STEP_6_25MV 6250
> -#define S2MPS14_BUCK4_STEP_12_5MV 12500
> #define S2MPS14_BUCK1235_START_SEL 0x20
> #define S2MPS14_BUCK4_START_SEL 0x40
> /*
> @@ -136,12 +132,6 @@ enum s2mps14_regulators {
> */
> #define S2MPS14_BUCK_RAMP_DELAY 12500
>
> -/* Regulator constraints for different types of LDOx */
> -#define S2MPS14_LDO_MIN_800MV 800000
> -#define S2MPS14_LDO_MIN_1800MV 1800000
> -#define S2MPS14_LDO_STEP_12_5MV 12500
> -#define S2MPS14_LDO_STEP_25MV 25000
> -
> #define S2MPS14_LDO_VSEL_MASK 0x3F
> #define S2MPS14_BUCK_VSEL_MASK 0xFF
> #define S2MPS14_ENABLE_MASK (0x03 << S2MPS14_ENABLE_SHIFT)
>

2014-07-15 09:51:56

by amit daniel kachhap

[permalink] [raw]
Subject: Re: [PATCH 2/3] regulator: s2mpa01: Optimize the regulator description macro

On Mon, Jul 14, 2014 at 2:19 PM, Krzysztof Kozlowski
<[email protected]> wrote:
> On 08.07.2014 14:27, Amit Daniel Kachhap wrote:
>>
>> This patch makes the regulator description macro take minimum and
>> steps voltage as parameter. In this way many repeated macros can be
>> removed. Now these macros are repeated only if the the LDO/BUCK ctrl
>> registers have non-linear positions. The good thing is these ctrl
>> registers
>> are mostly linear so they are not passed as parameters.
>>
>> This patch reduces the code size and also allow easy addition of more
>> s2mpxxx PMIC drivers which differs a lot in minimum/step voltages.
>>
>> Signed-off-by: Amit Daniel Kachhap <[email protected]>
>> ---
>> drivers/regulator/s2mpa01.c | 136
>> ++++++++++++--------------------------------
>> 1 file changed, 37 insertions(+), 99 deletions(-)
>>
>> diff --git a/drivers/regulator/s2mpa01.c b/drivers/regulator/s2mpa01.c
>> index 962c5f1..8073466 100644
>> --- a/drivers/regulator/s2mpa01.c
>> +++ b/drivers/regulator/s2mpa01.c
>> @@ -235,28 +235,14 @@ static struct regulator_ops s2mpa01_buck_ops = {
>> .set_ramp_delay = s2mpa01_set_ramp_delay,
>> };
>>
>> -#define regulator_desc_ldo1(num) { \
>> +#define regulator_desc_ldo(num, min, step) { \
>
>
> Why adding parameter for the 'min' value? It is always the same for LDOs -
> 800 mV.
>
> The same applies for the s2mps11 regulator driver.
Correct. min parameter can be removed.
Thanks for the review.
>
> Best regards,
> Krzysztof
>
>
>> .name = "LDO"#num, \
>> .id = S2MPA01_LDO##num, \
>> .ops = &s2mpa01_ldo_ops, \
>> .type = REGULATOR_VOLTAGE, \
>> .owner = THIS_MODULE, \
>> - .min_uV = MIN_800_MV, \
>> - .uV_step = STEP_50_MV, \
>> - .n_voltages = S2MPA01_LDO_N_VOLTAGES, \
>> - .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \
>> - .vsel_mask = S2MPA01_LDO_VSEL_MASK, \
>> - .enable_reg = S2MPA01_REG_L1CTRL + num - 1, \
>> - .enable_mask = S2MPA01_ENABLE_MASK \
>> -}
>> -#define regulator_desc_ldo2(num) { \
>> - .name = "LDO"#num, \
>> - .id = S2MPA01_LDO##num, \
>> - .ops = &s2mpa01_ldo_ops, \
>> - .type = REGULATOR_VOLTAGE, \
>> - .owner = THIS_MODULE, \
>> - .min_uV = MIN_800_MV, \
>> - .uV_step = STEP_25_MV, \
>> + .min_uV = min, \
>> + .uV_step = step, \
>> .n_voltages = S2MPA01_LDO_N_VOLTAGES, \
>> .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \
>> .vsel_mask = S2MPA01_LDO_VSEL_MASK, \
>> @@ -296,14 +282,14 @@ static struct regulator_ops s2mpa01_buck_ops = {
>> .enable_mask = S2MPA01_ENABLE_MASK \
>> }
>>
>> -#define regulator_desc_buck6_7(num) { \
>> +#define regulator_desc_buck6_10(num, min, step) { \
>> .name = "BUCK"#num, \
>> .id = S2MPA01_BUCK##num, \
>> .ops = &s2mpa01_buck_ops, \
>> .type = REGULATOR_VOLTAGE, \
>> .owner = THIS_MODULE, \
>> - .min_uV = MIN_600_MV, \
>> - .uV_step = STEP_6_25_MV, \
>> + .min_uV = min, \
>> + .uV_step = step, \
>> .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
>> .ramp_delay = S2MPA01_RAMP_DELAY, \
>> .vsel_reg = S2MPA01_REG_B6CTRL2 + (num - 6) * 2, \
>> @@ -312,91 +298,43 @@ static struct regulator_ops s2mpa01_buck_ops = {
>> .enable_mask = S2MPA01_ENABLE_MASK \
>> }
>>
>> -#define regulator_desc_buck8 { \
>> - .name = "BUCK8", \
>> - .id = S2MPA01_BUCK8, \
>> - .ops = &s2mpa01_buck_ops, \
>> - .type = REGULATOR_VOLTAGE, \
>> - .owner = THIS_MODULE, \
>> - .min_uV = MIN_800_MV, \
>> - .uV_step = STEP_12_5_MV, \
>> - .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
>> - .ramp_delay = S2MPA01_RAMP_DELAY, \
>> - .vsel_reg = S2MPA01_REG_B8CTRL2, \
>> - .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \
>> - .enable_reg = S2MPA01_REG_B8CTRL1, \
>> - .enable_mask = S2MPA01_ENABLE_MASK \
>> -}
>> -
>> -#define regulator_desc_buck9 { \
>> - .name = "BUCK9", \
>> - .id = S2MPA01_BUCK9, \
>> - .ops = &s2mpa01_buck_ops, \
>> - .type = REGULATOR_VOLTAGE, \
>> - .owner = THIS_MODULE, \
>> - .min_uV = MIN_1500_MV, \
>> - .uV_step = STEP_12_5_MV, \
>> - .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
>> - .ramp_delay = S2MPA01_RAMP_DELAY, \
>> - .vsel_reg = S2MPA01_REG_B9CTRL2, \
>> - .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \
>> - .enable_reg = S2MPA01_REG_B9CTRL1, \
>> - .enable_mask = S2MPA01_ENABLE_MASK \
>> -}
>> -
>> -#define regulator_desc_buck10 { \
>> - .name = "BUCK10", \
>> - .id = S2MPA01_BUCK10, \
>> - .ops = &s2mpa01_buck_ops, \
>> - .type = REGULATOR_VOLTAGE, \
>> - .owner = THIS_MODULE, \
>> - .min_uV = MIN_1000_MV, \
>> - .uV_step = STEP_12_5_MV, \
>> - .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
>> - .ramp_delay = S2MPA01_RAMP_DELAY, \
>> - .vsel_reg = S2MPA01_REG_B10CTRL2, \
>> - .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \
>> - .enable_reg = S2MPA01_REG_B10CTRL1, \
>> - .enable_mask = S2MPA01_ENABLE_MASK \
>> -}
>> -
>> static struct regulator_desc regulators[] = {
>> - regulator_desc_ldo2(1),
>> - regulator_desc_ldo1(2),
>> - regulator_desc_ldo1(3),
>> - regulator_desc_ldo1(4),
>> - regulator_desc_ldo1(5),
>> - regulator_desc_ldo2(6),
>> - regulator_desc_ldo1(7),
>> - regulator_desc_ldo1(8),
>> - regulator_desc_ldo1(9),
>> - regulator_desc_ldo1(10),
>> - regulator_desc_ldo2(11),
>> - regulator_desc_ldo1(12),
>> - regulator_desc_ldo1(13),
>> - regulator_desc_ldo1(14),
>> - regulator_desc_ldo1(15),
>> - regulator_desc_ldo1(16),
>> - regulator_desc_ldo1(17),
>> - regulator_desc_ldo1(18),
>> - regulator_desc_ldo1(19),
>> - regulator_desc_ldo1(20),
>> - regulator_desc_ldo1(21),
>> - regulator_desc_ldo2(22),
>> - regulator_desc_ldo2(23),
>> - regulator_desc_ldo1(24),
>> - regulator_desc_ldo1(25),
>> - regulator_desc_ldo1(26),
>> + regulator_desc_ldo(1, MIN_800_MV, STEP_25_MV),
>> + regulator_desc_ldo(2, MIN_800_MV, STEP_50_MV),
>> + regulator_desc_ldo(3, MIN_800_MV, STEP_50_MV),
>> + regulator_desc_ldo(4, MIN_800_MV, STEP_50_MV),
>> + regulator_desc_ldo(5, MIN_800_MV, STEP_50_MV),
>> + regulator_desc_ldo(6, MIN_800_MV, STEP_25_MV),
>> + regulator_desc_ldo(7, MIN_800_MV, STEP_50_MV),
>> + regulator_desc_ldo(8, MIN_800_MV, STEP_50_MV),
>> + regulator_desc_ldo(9, MIN_800_MV, STEP_50_MV),
>> + regulator_desc_ldo(10, MIN_800_MV, STEP_50_MV),
>> + regulator_desc_ldo(11, MIN_800_MV, STEP_25_MV),
>> + regulator_desc_ldo(12, MIN_800_MV, STEP_50_MV),
>> + regulator_desc_ldo(13, MIN_800_MV, STEP_50_MV),
>> + regulator_desc_ldo(14, MIN_800_MV, STEP_50_MV),
>> + regulator_desc_ldo(15, MIN_800_MV, STEP_50_MV),
>> + regulator_desc_ldo(16, MIN_800_MV, STEP_50_MV),
>> + regulator_desc_ldo(17, MIN_800_MV, STEP_50_MV),
>> + regulator_desc_ldo(18, MIN_800_MV, STEP_50_MV),
>> + regulator_desc_ldo(19, MIN_800_MV, STEP_50_MV),
>> + regulator_desc_ldo(20, MIN_800_MV, STEP_50_MV),
>> + regulator_desc_ldo(21, MIN_800_MV, STEP_50_MV),
>> + regulator_desc_ldo(22, MIN_800_MV, STEP_25_MV),
>> + regulator_desc_ldo(23, MIN_800_MV, STEP_25_MV),
>> + regulator_desc_ldo(24, MIN_800_MV, STEP_50_MV),
>> + regulator_desc_ldo(25, MIN_800_MV, STEP_50_MV),
>> + regulator_desc_ldo(26, MIN_800_MV, STEP_50_MV),
>> regulator_desc_buck1_4(1),
>> regulator_desc_buck1_4(2),
>> regulator_desc_buck1_4(3),
>> regulator_desc_buck1_4(4),
>> regulator_desc_buck5,
>> - regulator_desc_buck6_7(6),
>> - regulator_desc_buck6_7(7),
>> - regulator_desc_buck8,
>> - regulator_desc_buck9,
>> - regulator_desc_buck10,
>> + regulator_desc_buck6_10(6, MIN_600_MV, STEP_6_25_MV),
>> + regulator_desc_buck6_10(7, MIN_600_MV, STEP_6_25_MV),
>> + regulator_desc_buck6_10(8, MIN_800_MV, STEP_12_5_MV),
>> + regulator_desc_buck6_10(9, MIN_1500_MV, STEP_12_5_MV),
>> + regulator_desc_buck6_10(10, MIN_1000_MV, STEP_12_5_MV),
>> };
>>
>> static int s2mpa01_pmic_probe(struct platform_device *pdev)
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/