Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 350463
b: refs/heads/master
c: c51ce40
h: refs/heads/master
i:
  350461: eb06579
  350459: 793c3fe
  350455: 0f7f6ae
  350447: 6a47bf4
  350431: 18a5348
  350399: ba08e93
  350335: 1f00c46
  350207: 6c71417
v: v3
  • Loading branch information
Laxman Dewangan authored and Mark Brown committed Dec 27, 2012
1 parent 9c1e7a5 commit 4986de2
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: faa3b2d57964e3c3e974e1d0bea8e047bd8e5edd
refs/heads/master: c51ce403d3d9e3d54339c4563f17e958f3bc64df
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
TPS51632 Voltage regulators

Required properties:
- compatible: Must be "ti,tps51632"
- reg: I2C slave address

Optional properties:
- ti,enable-pwm-dvfs: Enable the DVFS voltage control through the PWM interface.
- ti,dvfs-step-20mV: The 20mV step voltage when PWM DVFS enabled. Missing this
will set 10mV step voltage in PWM DVFS mode. In normal mode, the voltage
step is 10mV as per datasheet.

Any property defined as part of the core regulator binding, defined in
regulator.txt, can also be used.

Example:

tps51632 {
compatible = "ti,tps51632";
reg = <0x43>;
regulator-name = "tps51632-vout";
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <1500000>;
regulator-boot-on;
ti,enable-pwm-dvfs;
ti,dvfs-step-20mV;
};
59 changes: 59 additions & 0 deletions trunk/drivers/regulator/tps51632-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/of_regulator.h>
#include <linux/regulator/tps51632-regulator.h>
#include <linux/slab.h>

Expand Down Expand Up @@ -252,6 +255,49 @@ static const struct regmap_config tps51632_regmap_config = {
.cache_type = REGCACHE_RBTREE,
};

#if defined(CONFIG_OF)
static const struct of_device_id tps51632_of_match[] = {
{ .compatible = "ti,tps51632",},
{},
};
MODULE_DEVICE_TABLE(of, tps51632_of_match);

static struct tps51632_regulator_platform_data *
of_get_tps51632_platform_data(struct device *dev)
{
struct tps51632_regulator_platform_data *pdata;
struct device_node *np = dev->of_node;

pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata) {
dev_err(dev, "Memory alloc failed for platform data\n");
return NULL;
}

pdata->reg_init_data = of_get_regulator_init_data(dev, dev->of_node);
if (!pdata->reg_init_data) {
dev_err(dev, "Not able to get OF regulator init data\n");
return NULL;
}

pdata->enable_pwm_dvfs =
of_property_read_bool(np, "ti,enable-pwm-dvfs");
pdata->dvfs_step_20mV = of_property_read_bool(np, "ti,dvfs-step-20mV");

pdata->base_voltage_uV = pdata->reg_init_data->constraints.min_uV ? :
TPS51632_MIN_VOLATGE;
pdata->max_voltage_uV = pdata->reg_init_data->constraints.max_uV ? :
TPS51632_MAX_VOLATGE;
return pdata;
}
#else
static struct tps51632_regulator_platform_data *
of_get_tps51632_platform_data(struct device *dev)
{
return NULL;
}
#endif

static int tps51632_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
Expand All @@ -261,7 +307,19 @@ static int tps51632_probe(struct i2c_client *client,
int ret;
struct regulator_config config = { };

if (client->dev.of_node) {
const struct of_device_id *match;
match = of_match_device(of_match_ptr(tps51632_of_match),
&client->dev);
if (!match) {
dev_err(&client->dev, "Error: No device match found\n");
return -ENODEV;
}
}

pdata = client->dev.platform_data;
if (!pdata && client->dev.of_node)
pdata = of_get_tps51632_platform_data(&client->dev);
if (!pdata) {
dev_err(&client->dev, "No Platform data\n");
return -EINVAL;
Expand Down Expand Up @@ -350,6 +408,7 @@ static struct i2c_driver tps51632_i2c_driver = {
.driver = {
.name = "tps51632",
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(tps51632_of_match),
},
.probe = tps51632_probe,
.remove = tps51632_remove,
Expand Down

0 comments on commit 4986de2

Please sign in to comment.