Skip to content

Commit

Permalink
mfd: palmas: Add SMPS10_BOOST feature
Browse files Browse the repository at this point in the history
The SMPS10 regulator is not presesnt in all the variants
of the PALMAS PMIC family. Hence adding a feature to distingush
between them.

Signed-off-by: J Keerthy <j-keerthy@ti.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
  • Loading branch information
J Keerthy authored and Samuel Ortiz committed Jun 20, 2013
1 parent ad522f4 commit 1ffb0be
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 8 deletions.
29 changes: 21 additions & 8 deletions drivers/mfd/palmas.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <linux/err.h>
#include <linux/mfd/core.h>
#include <linux/mfd/palmas.h>
#include <linux/of_platform.h>
#include <linux/of_device.h>

static const struct regmap_config palmas_regmap_config[PALMAS_NUM_CLIENTS] = {
{
Expand Down Expand Up @@ -231,15 +231,26 @@ static void palmas_dt_to_pdata(struct i2c_client *i2c,
palmas_set_pdata_irq_flag(i2c, pdata);
}

static unsigned int palmas_features = PALMAS_PMIC_FEATURE_SMPS10_BOOST;

static const struct of_device_id of_palmas_match_tbl[] = {
{
.compatible = "ti,palmas",
.data = &palmas_features,
},
{ },
};

static int palmas_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct palmas *palmas;
struct palmas_platform_data *pdata;
struct device_node *node = i2c->dev.of_node;
int ret = 0, i;
unsigned int reg, addr;
unsigned int reg, addr, *features;
int slave;
const struct of_device_id *match;

pdata = dev_get_platdata(&i2c->dev);

Expand All @@ -261,9 +272,16 @@ static int palmas_i2c_probe(struct i2c_client *i2c,

i2c_set_clientdata(i2c, palmas);
palmas->dev = &i2c->dev;
palmas->id = id->driver_data;
palmas->irq = i2c->irq;

match = of_match_device(of_match_ptr(of_palmas_match_tbl), &i2c->dev);

if (!match)
return -ENODATA;

features = (unsigned int *)match->data;
palmas->features = *features;

for (i = 0; i < PALMAS_NUM_CLIENTS; i++) {
if (i == 0)
palmas->i2c_clients[i] = i2c;
Expand Down Expand Up @@ -433,11 +451,6 @@ static const struct i2c_device_id palmas_i2c_id[] = {
};
MODULE_DEVICE_TABLE(i2c, palmas_i2c_id);

static struct of_device_id of_palmas_match_tbl[] = {
{ .compatible = "ti,palmas", },
{ /* end */ }
};

static struct i2c_driver palmas_i2c_driver = {
.driver = {
.name = "palmas",
Expand Down
3 changes: 3 additions & 0 deletions drivers/regulator/palmas-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,9 @@ static int palmas_regulators_probe(struct platform_device *pdev)
continue;
ramp_delay_support = true;
break;
case PALMAS_REG_SMPS10:
if (!PALMAS_PMIC_HAS(palmas, SMPS10_BOOST))
continue;
}

if ((id == PALMAS_REG_SMPS6) || (id == PALMAS_REG_SMPS8))
Expand Down
14 changes: 14 additions & 0 deletions include/linux/mfd/palmas.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@
((a) == PALMAS_CHIP_ID))
#define is_palmas_charger(a) ((a) == PALMAS_CHIP_CHARGER_ID)

/**
* Palmas PMIC feature types
*
* PALMAS_PMIC_FEATURE_SMPS10_BOOST - used when the PMIC provides SMPS10_BOOST
* regulator.
*
* PALMAS_PMIC_HAS(b, f) - macro to check if a bandgap device is capable of a
* specific feature (above) or not. Return non-zero, if yes.
*/
#define PALMAS_PMIC_FEATURE_SMPS10_BOOST BIT(0)
#define PALMAS_PMIC_HAS(b, f) \
((b)->features & PALMAS_PMIC_FEATURE_ ## f)

struct palmas_pmic;
struct palmas_gpadc;
struct palmas_resource;
Expand All @@ -46,6 +59,7 @@ struct palmas {
/* Stored chip id */
int id;

unsigned int features;
/* IRQ Data */
int irq;
u32 irq_mask;
Expand Down

0 comments on commit 1ffb0be

Please sign in to comment.