Skip to contentSkip to conversation

regulator: max8952: Add support for Device Tree

PATCH In review Tomasz Figa 2 participants 4 messages Apr 4, 2013 – Apr 5, 2013

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover regulator: max8952: Add support for Device Tree

This series adds Device Tree support to max8952 voltage regulator driver. First patch prepares platform data structure to be generated at runtime from data parsed from device tree. Second patch implements Device Tree binding and adds necessary documentation.

Tested on Universal C210 board.

Tomasz Figa (2):
regulator: max8952: Separate constraints from platform data struct
regulator: max8952: Add Device Tree support

 .../devicetree/bindings/regulator/max8952.txt      | 52 +++++++++++++++
 arch/arm/mach-exynos/mach-universal_c210.c         | 27 ++++----
 drivers/regulator/max8952.c                        | 74 +++++++++++++++++++++-
 include/linux/regulator/max8952.h                  | 10 +--
 4 files changed, 143 insertions(+), 20 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/regulator/max8952.txt
Signature · 1 line
1.8.1.5
#1 lore raw

PATCH 1/2 regulator: max8952: Separate constraints from platform data struct

This patch modifies platform data structure of max8952 driver to use pointer to regulator_init_data struct instead of embedding it.

This is a prerequisite for adding Device Tree support for the driver.

---
 arch/arm/mach-exynos/mach-universal_c210.c | 27 ++++++++++++++-------------
 drivers/regulator/max8952.c                |  4 ++--
 include/linux/regulator/max8952.h          |  2 +-
 3 files changed, 17 insertions(+), 16 deletions(-)
arch/arm/mach-exynos/mach-universal_c210.c +14 -13
index 366abb3..c876b5b 100644
@@ -97,6 +97,19 @@ static struct s3c2410_uartcfg universal_uartcfgs[] __initdata = {
 static struct regulator_consumer_supply max8952_consumer =
 	REGULATOR_SUPPLY("vdd_arm", NULL);
 
+static struct regulator_init_data universal_max8952_reg_data = {
+	.constraints	= {
+		.name		= "VARM_1.2V",
+		.min_uV		= 770000,
+		.max_uV		= 1400000,
+		.valid_ops_mask	= REGULATOR_CHANGE_VOLTAGE,
+		.always_on	= 1,
+		.boot_on	= 1,
+	},
+	.num_consumer_supplies	= 1,
+	.consumer_supplies	= &max8952_consumer,
+};
+
 static struct max8952_platform_data universal_max8952_pdata __initdata = {
 	.gpio_vid0	= EXYNOS4_GPX0(3),
 	.gpio_vid1	= EXYNOS4_GPX0(4),
@@ -105,19 +118,7 @@ static struct max8952_platform_data universal_max8952_pdata __initdata = {
 	.dvs_mode	= { 48, 32, 28, 18 }, /* 1.25, 1.20, 1.05, 0.95V */
 	.sync_freq	= 0, /* default: fastest */
 	.ramp_speed	= 0, /* default: fastest */
-
-	.reg_data	= {
-		.constraints	= {
-			.name		= "VARM_1.2V",
-			.min_uV		= 770000,
-			.max_uV		= 1400000,
-			.valid_ops_mask	= REGULATOR_CHANGE_VOLTAGE,
-			.always_on	= 1,
-			.boot_on	= 1,
-		},
-		.num_consumer_supplies	= 1,
-		.consumer_supplies	= &max8952_consumer,
-	},
+	.reg_data	= &universal_max8952_reg_data,
 };
 
 static struct regulator_consumer_supply lp3974_buck1_consumer =
drivers/regulator/max8952.c +2 -2
index fc7935a..100b917 100644
@@ -154,11 +154,11 @@ static int max8952_pmic_probe(struct i2c_client *client,
 	max8952->pdata = pdata;
 
 	config.dev = max8952->dev;
-	config.init_data = &pdata->reg_data;
+	config.init_data = pdata->reg_data;
 	config.driver_data = max8952;
 
 	config.ena_gpio = pdata->gpio_en;
-	if (pdata->reg_data.constraints.boot_on)
+	if (pdata->reg_data->constraints.boot_on)
 		config.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH;
 
 	max8952->rdev = regulator_register(&regulator, &config);
include/linux/regulator/max8952.h +1 -1
index 45e4285..c13aa34 100644
@@ -128,7 +128,7 @@ struct max8952_platform_data {
 	u8 sync_freq;
 	u8 ramp_speed;
 
-	struct regulator_init_data reg_data;
+	struct regulator_init_data *reg_data;
 };
 
 
Signature · 1 line
1.8.1.5
#2 lore raw

PATCH 2/2 regulator: max8952: Add Device Tree support

In reply to Tomasz Figa

This patch adds Device Tree support to max8952 regulator driver.

---
 .../devicetree/bindings/regulator/max8952.txt      | 52 ++++++++++++++++
 drivers/regulator/max8952.c                        | 70 ++++++++++++++++++++++
 include/linux/regulator/max8952.h                  |  8 +--
 3 files changed, 126 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/regulator/max8952.txt
Documentation/devicetree/bindings/regulator/max8952.txt new file +52 -0
new file mode 100644
index 0000000..866fcdd
@@ -0,0 +1,52 @@
+Maxim MAX8952 voltage regulator
+
+Required properties:
+- compatible: must be equal to "maxim,max8952"
+- reg: I2C slave address, usually 0x60
+- max8952,dvs-mode-microvolt: array of 4 integer values defining DVS voltages
+  in microvolts. All values must be from range <770000, 1400000>
+- any required generic properties defined in regulator.txt
+
+Optional properties:
+- max8952,vid-gpios: array of two GPIO pins used for DVS voltage selection
+- max8952,en-gpio: GPIO used to control enable status of regulator
+- max8952,default-mode: index of default DVS voltage, from <0, 3> range
+- max8952,sync-freq: sync frequency, must be one of following values:
+    - 0: 26 MHz
+    - 1: 13 MHz
+    - 2: 19.2 MHz
+  Defaults to 26 MHz if not specified.
+- max8952,ramp-speed: voltage ramp speed, must be one of following values:
+    - 0: 32mV/us
+    - 1: 16mV/us
+    - 2: 8mV/us
+    - 3: 4mV/us
+    - 4: 2mV/us
+    - 5: 1mV/us
+    - 6: 0.5mV/us
+    - 7: 0.25mV/us
+  Defaults to 32mV/us if not specified.
+- any available generic properties defined in regulator.txt
+
+Example:
+
+	vdd_arm_reg: pmic@60 {
+		compatible = "maxim,max8952";
+		reg = <0x60>;
+
+		/* max8952-specific properties */
+		max8952,vid-gpios = <&gpx0 3 0>, <&gpx0 4 0>;
+		max8952,en-gpio = <&gpx0 1 0>;
+		max8952,default-mode = <0>;
+		max8952,dvs-mode-microvolt = <1250000>, <1200000>,
+						<1050000>, <950000>;
+		max8952,sync-freq = <0>;
+		max8952,ramp-speed = <0>;
+
+		/* generic regulator properties */
+		regulator-name = "vdd_arm";
+		regulator-min-microvolt = <770000>;
+		regulator-max-microvolt = <1400000>;
+		regulator-always-on;
+		regulator-boot-on;
+	};
drivers/regulator/max8952.c +70 -0

94 lines not on this page · raw message

include/linux/regulator/max8952.h +4 -4
index c13aa34..4dbb63a 100644
@@ -122,11 +122,11 @@ struct max8952_platform_data {
 	int gpio_vid1;
 	int gpio_en;
 
-	u8 default_mode;
-	u8 dvs_mode[MAX8952_NUM_DVS_MODE]; /* MAX8952_DVS_MODEx_XXXXmV */
+	u32 default_mode;
+	u32 dvs_mode[MAX8952_NUM_DVS_MODE]; /* MAX8952_DVS_MODEx_XXXXmV */
 
-	u8 sync_freq;
-	u8 ramp_speed;
+	u32 sync_freq;
+	u32 ramp_speed;
 
 	struct regulator_init_data *reg_data;
 };
Signature · 1 line
1.8.1.5
#3 lore raw

Re: [PATCH 2/2] regulator: max8952: Add Device Tree support

drivers/regulator/max8952.c static const struct regulator_desc regulator = { · line 178

Quoted 2 lines · Tomasz Figa
drivers/regulator/max8952.c +2 -0
+	if (of_property_read_u32(np, "max8952,ramp-speed", &pd->ramp_speed))
+		dev_warn(dev, "max8952,ramp-speed property not specified, defaulting to 32mV/us\n");

Applied both, though the above warning seems a bit harsh - it seems like assuming a worst case ramp rate ought to be totally safe and just a minor performance issue so silently accepted.