summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1883a96)
raw | patch | inline | side by side (parent: 1883a96)
author | J Keerthy <j-keerthy@ti.com> | |
Wed, 24 Apr 2013 06:20:49 +0000 (11:50 +0530) | ||
committer | J Keerthy <j-keerthy@ti.com> | |
Tue, 28 May 2013 05:38:59 +0000 (11:08 +0530) |
Introduce palmas_pmic_data structure so that Palmas variants
like TWL6035, TWL6037, TPS65913 can populate data specific
to them. This enables driver to support variants.
Signed-off-by: J Keerthy <j-keerthy@ti.com>
like TWL6035, TWL6037, TPS65913 can populate data specific
to them. This enables driver to support variants.
Signed-off-by: J Keerthy <j-keerthy@ti.com>
drivers/mfd/palmas.c | patch | blob | history | |
include/linux/mfd/palmas.h | patch | blob | history |
diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
index b077bedda03ef18d211c6d30446ac6fc1679d61d..e7947cbbd55ae885a88d3073644874941e58e6bd 100644 (file)
--- a/drivers/mfd/palmas.c
+++ b/drivers/mfd/palmas.c
return ret;
}
+static struct palmas_pmic_data palmas_data = {
+ .irq_chip = &palmas_irq_chip,
+ .regmap_config = palmas_regmap_config,
+ .mfd_cell = palmas_children,
+ .id = TWL6035,
+ .has_usb = 1,
+};
+
+static const struct of_device_id of_palmas_match_tbl[] = {
+ {
+ .compatible = "ti,palmas",
+ .data = &palmas_data,
+ },
+ { },
+};
+
static int palmas_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
unsigned int reg, addr;
int slave;
struct mfd_cell *children;
+ const struct of_device_id *match;
+ const struct palmas_pmic_data *pmic_data;
pdata = dev_get_platdata(&i2c->dev);
i2c_set_clientdata(i2c, palmas);
palmas->dev = &i2c->dev;
- palmas->id = id->driver_data;
+ palmas->palmas_id = id->driver_data;
palmas->irq = i2c->irq;
+ match = of_match_device(of_match_ptr(of_palmas_match_tbl), &i2c->dev);
+
+ if (match) {
+ pmic_data = match->data;
+ palmas->palmas_id = pmic_data->id;
+ } else {
+ return -ENODATA;
+ }
+
for (i = 0; i < PALMAS_NUM_CLIENTS; i++) {
if (i == 0)
palmas->i2c_clients[i] = i2c;
}
}
palmas->regmap[i] = devm_regmap_init_i2c(palmas->i2c_clients[i],
- &palmas_regmap_config[i]);
+ pmic_data->regmap_config + i);
if (IS_ERR(palmas->regmap[i])) {
ret = PTR_ERR(palmas->regmap[i]);
dev_err(palmas->dev,
regmap_write(palmas->regmap[slave], addr, reg);
ret = regmap_add_irq_chip(palmas->regmap[slave], palmas->irq,
- IRQF_ONESHOT, 0, &palmas_irq_chip,
+ IRQF_ONESHOT, 0, pmic_data->irq_chip,
&palmas->irq_data);
if (ret < 0)
goto err;
return ret;
}
+ /*
+ * For now all PMICs belonging to palmas family are assumed to get the
+ * same childern as PALMAS
+ */
children = kmemdup(palmas_children, sizeof(palmas_children),
GFP_KERNEL);
if (!children) {
}
static const struct i2c_device_id palmas_i2c_id[] = {
- { "palmas", },
- { "twl6035", },
- { "twl6037", },
- { "tps65913", },
+ { "palmas", TWL6035},
+ { "twl6035", TWL6035},
+ { "twl6037", TWL6037},
+ { "tps65913", TPS65913},
{ /* end */ }
};
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",
index 82932db7fdb4c533673b343641e8b7da96410cf9..7838df7f4d3cea2572b47a0d4322ac730c76880d 100644 (file)
int designrev;
int sw_revision;
+ int palmas_id;
/* IRQ Data */
int irq;
u32 irq_mask;
};
+enum pmic_ids {
+ TWL6035,
+ TWL6037,
+ TPS65913,
+};
+
enum palmas_regulators {
/* SMPS regulators */
PALMAS_REG_SMPS12,
u8 linkstat;
};
+/**
+ * struct palmas_pmic_data - Maintains the specific data for PMICs of PALMAS
+ * family
+ * @irq_chip: regmap_irq_chip specific to individual members
+ * of PALMAS family.
+ * @regmap_config: regmap_config specific to the individual members
+ * of PALMAS family.
+ * @mfd_cell: mfd cell specific to the individual members of
+ * PALMAS family.
+ * @id: Id of the member of the PALMAS family.
+ * @has_usb: Flag indicating whether PMIC supports USB
+ */
+struct palmas_pmic_data {
+ struct regmap_irq_chip *irq_chip;
+ const struct regmap_config *regmap_config;
+ const struct mfd_cell *mfd_cell;
+ int id;
+ int has_usb;
+};
+
#define comparator_to_palmas(x) container_of((x), struct palmas_usb, comparator)
enum usb_irq_events {