From 45a86172452a168f3157e2b0f16cfb113b43fa79 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 21 Feb 2017 11:29:04 -0300 Subject: [PATCH 1/7] regulator: ltc3589: Add OF device ID table The driver doesn't have a struct of_device_id table but supported devices are registered via Device Trees. This is working on the assumption that a I2C device registered via OF will always match a legacy I2C device ID and that the MODALIAS reported will always be of the form i2c:. But this could change in the future so the correct approach is to have an OF device ID table if the devices are registered via OF. Signed-off-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- drivers/regulator/ltc3589.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/ltc3589.c b/drivers/regulator/ltc3589.c index a7a1a0313bbf..853a06ad86d6 100644 --- a/drivers/regulator/ltc3589.c +++ b/drivers/regulator/ltc3589.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -470,7 +471,11 @@ static int ltc3589_probe(struct i2c_client *client, return -ENOMEM; i2c_set_clientdata(client, ltc3589); - ltc3589->variant = id->driver_data; + if (client->dev.of_node) + ltc3589->variant = (enum ltc3589_variant) + of_device_get_match_data(&client->dev); + else + ltc3589->variant = id->driver_data; ltc3589->dev = dev; descs = ltc3589->regulator_descs; @@ -542,9 +547,27 @@ static struct i2c_device_id ltc3589_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, ltc3589_i2c_id); +static const struct of_device_id ltc3589_of_match[] = { + { + .compatible = "lltc,ltc3589", + .data = (void *)LTC3589, + }, + { + .compatible = "lltc,ltc3589-1", + .data = (void *)LTC3589_1, + }, + { + .compatible = "lltc,ltc3589-2", + .data = (void *)LTC3589_2, + }, + { }, +}; +MODULE_DEVICE_TABLE(of, ltc3589_of_match); + static struct i2c_driver ltc3589_driver = { .driver = { .name = DRIVER_NAME, + .of_match_table = of_match_ptr(ltc3589_of_match), }, .probe = ltc3589_probe, .id_table = ltc3589_i2c_id, From c314341557d3e8369b89eabde0b864997cf7f420 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 21 Feb 2017 11:29:05 -0300 Subject: [PATCH 2/7] regulator: ltc3676: Add OF device ID table The driver doesn't have a struct of_device_id table but supported devices are registered via Device Trees. This is working on the assumption that a I2C device registered via OF will always match a legacy I2C device ID and that the MODALIAS reported will always be of the form i2c:. But this could change in the future so the correct approach is to have an OF device ID table if the devices are registered via OF. Signed-off-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- drivers/regulator/ltc3676.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/regulator/ltc3676.c b/drivers/regulator/ltc3676.c index 503cd90eba39..662ee05ea44d 100644 --- a/drivers/regulator/ltc3676.c +++ b/drivers/regulator/ltc3676.c @@ -406,9 +406,16 @@ static const struct i2c_device_id ltc3676_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, ltc3676_i2c_id); +static const struct of_device_id ltc3676_of_match[] = { + { .compatible = "lltc,ltc3676" }, + { }, +}; +MODULE_DEVICE_TABLE(of, ltc3676_of_match); + static struct i2c_driver ltc3676_driver = { .driver = { .name = DRIVER_NAME, + .of_match_table = of_match_ptr(ltc3676_of_match), }, .probe = ltc3676_regulator_probe, .id_table = ltc3676_i2c_id, From 9503b5085fd0e7cfc6e32b1a473a997303d7e26a Mon Sep 17 00:00:00 2001 From: Milo Kim Date: Tue, 28 Feb 2017 16:50:41 +0900 Subject: [PATCH 3/7] regulator: lm363x: Use generic DT property name for external control pins Vpos and Vneg LDOs can be enabled or disabled by external GPIOs. Use general DT property 'enable-gpios' for this usage. Two enable pins are differentiable by selecting the index number. Signed-off-by: Milo Kim Signed-off-by: Mark Brown --- drivers/regulator/lm363x-regulator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/lm363x-regulator.c b/drivers/regulator/lm363x-regulator.c index f53e63301a20..ce5f7d9ad475 100644 --- a/drivers/regulator/lm363x-regulator.c +++ b/drivers/regulator/lm363x-regulator.c @@ -227,9 +227,9 @@ static int lm363x_regulator_of_get_enable_gpio(struct device_node *np, int id) */ switch (id) { case LM3632_LDO_POS: - return of_get_named_gpio(np, "ti,lcm-en1-gpio", 0); + return of_get_named_gpio(np, "enable-gpios", 0); case LM3632_LDO_NEG: - return of_get_named_gpio(np, "ti,lcm-en2-gpio", 0); + return of_get_named_gpio(np, "enable-gpios", 1); default: return -EINVAL; } From 45493684f5953d83cb2621027ad0792d167bedab Mon Sep 17 00:00:00 2001 From: Milo Kim Date: Tue, 28 Feb 2017 16:50:40 +0900 Subject: [PATCH 4/7] regulator: lm363x: Use generic property for hardware enable pins With index usages, device specific properties can be replaced with generic one. Vpos is index 0 and Vneg is index 1. DT examples are added as well. Signed-off-by: Milo Kim Signed-off-by: Mark Brown --- .../bindings/regulator/lm363x-regulator.txt | 78 ++++++++++++++++++- 1 file changed, 76 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/regulator/lm363x-regulator.txt b/Documentation/devicetree/bindings/regulator/lm363x-regulator.txt index 8f14df9d1205..cc5a6151d85f 100644 --- a/Documentation/devicetree/bindings/regulator/lm363x-regulator.txt +++ b/Documentation/devicetree/bindings/regulator/lm363x-regulator.txt @@ -8,8 +8,8 @@ Required property: Optional properties: LM3632 has external enable pins for two LDOs. - - ti,lcm-en1-gpio: A GPIO specifier for Vpos control pin. - - ti,lcm-en2-gpio: A GPIO specifier for Vneg control pin. + - enable-gpios: Two GPIO specifiers for Vpos and Vneg control pins. + The first entry is Vpos, the second is Vneg enable pin. Child nodes: LM3631 @@ -30,5 +30,79 @@ Child nodes: Examples: Please refer to ti-lmu dt-bindings [2]. +lm3631@29 { + compatible = "ti,lm3631"; + reg = <0x29>; + + regulators { + compatible = "ti,lm363x-regulator"; + + vboost { + regulator-name = "lcd_boost"; + regulator-min-microvolt = <4500000>; + regulator-max-microvolt = <6350000>; + regulator-always-on; + }; + + vcont { + regulator-name = "lcd_vcont"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + }; + + voref { + regulator-name = "lcd_voref"; + regulator-min-microvolt = <4000000>; + regulator-max-microvolt = <6000000>; + }; + + vpos { + regulator-name = "lcd_vpos"; + regulator-min-microvolt = <4000000>; + regulator-max-microvolt = <6000000>; + regulator-boot-on; + }; + + vneg { + regulator-name = "lcd_vneg"; + regulator-min-microvolt = <4000000>; + regulator-max-microvolt = <6000000>; + regulator-boot-on; + }; + }; +}; + +lm3632@11 { + compatible = "ti,lm3632"; + reg = <0x11>; + + regulators { + compatible = "ti,lm363x-regulator"; + + /* GPIO1_16 for Vpos, GPIO1_28 is for Vneg */ + enable-gpios = <&gpio1 16 GPIO_ACTIVE_HIGH>, + <&gpio1 28 GPIO_ACTIVE_HIGH>; + + vboost { + regulator-name = "lcd_boost"; + regulator-min-microvolt = <4500000>; + regulator-max-microvolt = <6400000>; + regulator-always-on; + }; + + vpos { + regulator-name = "lcd_vpos"; + regulator-min-microvolt = <4000000>; + regulator-max-microvolt = <6000000>; + }; + + vneg { + regulator-name = "lcd_vneg"; + regulator-min-microvolt = <4000000>; + regulator-max-microvolt = <6000000>; + }; + }; +}; + [1] ../regulator/regulator.txt [2] ../mfd/ti-lmu.txt From 2f3c578fe2edf1de7ab981d1d7121e2eeee5b466 Mon Sep 17 00:00:00 2001 From: Jeremy Linton Date: Mon, 3 Apr 2017 00:28:42 -0500 Subject: [PATCH 5/7] regulator: hi655x: Describe consumed platform device The hi655x-regulator driver consumes a similarly named platform device. Adding that to the module device table, allows modprobe to locate this driver once the device is created. Signed-off-by: Jeremy Linton Signed-off-by: Mark Brown --- drivers/regulator/hi655x-regulator.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/regulator/hi655x-regulator.c b/drivers/regulator/hi655x-regulator.c index aca18466f522..11a6d27ec82f 100644 --- a/drivers/regulator/hi655x-regulator.c +++ b/drivers/regulator/hi655x-regulator.c @@ -214,7 +214,14 @@ static int hi655x_regulator_probe(struct platform_device *pdev) return 0; } +static const struct platform_device_id hi655x_regulator_table[] = { + { .name = "hi655x-regulator" }, + {}, +}; +MODULE_DEVICE_TABLE(platform, hi655x_regulator_table); + static struct platform_driver hi655x_regulator_driver = { + .id_table = hi655x_regulator_table, .driver = { .name = "hi655x-regulator", }, From a7a453f56a1a116027f84ac53b365eb045a0e279 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Tue, 28 Mar 2017 15:14:40 +0100 Subject: [PATCH 6/7] regulator: helpers: Add regmap set_soft_start helper Add a helper function regulator_set_soft_start_regmap to allow regmap based regulators to easily enable soft start. Signed-off-by: Charles Keepax Signed-off-by: Mark Brown --- drivers/regulator/helpers.c | 18 ++++++++++++++++++ include/linux/regulator/driver.h | 8 ++++++++ 2 files changed, 26 insertions(+) diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c index 379cdacc05d8..a75e7da49af8 100644 --- a/drivers/regulator/helpers.c +++ b/drivers/regulator/helpers.c @@ -445,6 +445,24 @@ int regulator_set_bypass_regmap(struct regulator_dev *rdev, bool enable) } EXPORT_SYMBOL_GPL(regulator_set_bypass_regmap); +/** + * regulator_set_soft_start_regmap - Default set_soft_start() using regmap + * + * @rdev: device to operate on. + */ +int regulator_set_soft_start_regmap(struct regulator_dev *rdev) +{ + unsigned int val; + + val = rdev->desc->soft_start_val_on; + if (!val) + val = rdev->desc->soft_start_mask; + + return regmap_update_bits(rdev->regmap, rdev->desc->soft_start_reg, + rdev->desc->soft_start_mask, val); +} +EXPORT_SYMBOL_GPL(regulator_set_soft_start_regmap); + /** * regulator_get_bypass_regmap - Default get_bypass() using regmap * diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index dac8e7b16bc6..1054c033e783 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -292,6 +292,10 @@ enum regulator_type { * set_active_discharge * @active_discharge_reg: Register for control when using regmap * set_active_discharge + * @soft_start_reg: Register for control when using regmap set_soft_start + * @soft_start_mask: Mask for control when using regmap set_soft_start + * @soft_start_val_on: Enabling value for control when using regmap + * set_soft_start * * @enable_time: Time taken for initial enable of regulator (in uS). * @off_on_delay: guard time (in uS), before re-enabling a regulator @@ -345,6 +349,9 @@ struct regulator_desc { unsigned int active_discharge_off; unsigned int active_discharge_mask; unsigned int active_discharge_reg; + unsigned int soft_start_reg; + unsigned int soft_start_mask; + unsigned int soft_start_val_on; unsigned int enable_time; @@ -476,6 +483,7 @@ int regulator_set_voltage_time_sel(struct regulator_dev *rdev, unsigned int new_selector); int regulator_set_bypass_regmap(struct regulator_dev *rdev, bool enable); int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable); +int regulator_set_soft_start_regmap(struct regulator_dev *rdev); int regulator_set_active_discharge_regmap(struct regulator_dev *rdev, bool enable); From f7d37bc3cb20828ac43b22cbd40222877ee2c46a Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Tue, 28 Mar 2017 15:14:41 +0100 Subject: [PATCH 7/7] regulator: helpers: Add regmap set_pull_down helper Add a helper function regulator_set_pull_down_regmap to allow regmap based regulators to easily enable pull down. Signed-off-by: Charles Keepax Signed-off-by: Mark Brown --- drivers/regulator/helpers.c | 18 ++++++++++++++++++ include/linux/regulator/driver.h | 8 ++++++++ 2 files changed, 26 insertions(+) diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c index a75e7da49af8..2ae7c3ac5940 100644 --- a/drivers/regulator/helpers.c +++ b/drivers/regulator/helpers.c @@ -463,6 +463,24 @@ int regulator_set_soft_start_regmap(struct regulator_dev *rdev) } EXPORT_SYMBOL_GPL(regulator_set_soft_start_regmap); +/** + * regulator_set_pull_down_regmap - Default set_pull_down() using regmap + * + * @rdev: device to operate on. + */ +int regulator_set_pull_down_regmap(struct regulator_dev *rdev) +{ + unsigned int val; + + val = rdev->desc->pull_down_val_on; + if (!val) + val = rdev->desc->pull_down_mask; + + return regmap_update_bits(rdev->regmap, rdev->desc->pull_down_reg, + rdev->desc->pull_down_mask, val); +} +EXPORT_SYMBOL_GPL(regulator_set_pull_down_regmap); + /** * regulator_get_bypass_regmap - Default get_bypass() using regmap * diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index 1054c033e783..8a9078dd2a5f 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -296,6 +296,10 @@ enum regulator_type { * @soft_start_mask: Mask for control when using regmap set_soft_start * @soft_start_val_on: Enabling value for control when using regmap * set_soft_start + * @pull_down_reg: Register for control when using regmap set_pull_down + * @pull_down_mask: Mask for control when using regmap set_pull_down + * @pull_down_val_on: Enabling value for control when using regmap + * set_pull_down * * @enable_time: Time taken for initial enable of regulator (in uS). * @off_on_delay: guard time (in uS), before re-enabling a regulator @@ -352,6 +356,9 @@ struct regulator_desc { unsigned int soft_start_reg; unsigned int soft_start_mask; unsigned int soft_start_val_on; + unsigned int pull_down_reg; + unsigned int pull_down_mask; + unsigned int pull_down_val_on; unsigned int enable_time; @@ -484,6 +491,7 @@ int regulator_set_voltage_time_sel(struct regulator_dev *rdev, int regulator_set_bypass_regmap(struct regulator_dev *rdev, bool enable); int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable); int regulator_set_soft_start_regmap(struct regulator_dev *rdev); +int regulator_set_pull_down_regmap(struct regulator_dev *rdev); int regulator_set_active_discharge_regmap(struct regulator_dev *rdev, bool enable);