summaryrefslogtreecommitdiffstats
path: root/drivers/mfd
diff options
context:
space:
mode:
authorGraeme Gregory <gg@slimlogic.co.uk>2012-08-28 13:47:38 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2012-09-23 20:41:59 +0200
commit9c14ac33450eaa3347d0d202c2a4116578976a63 (patch)
treebcb14167bb53eeee067bb78311b73787c79c242c /drivers/mfd
parent190ef1a6e1e493340281d10a9dbda2eac205884c (diff)
downloadop-kernel-dev-9c14ac33450eaa3347d0d202c2a4116578976a63.zip
op-kernel-dev-9c14ac33450eaa3347d0d202c2a4116578976a63.tar.gz
mfd: palmas: Add device tree handling to mfd
Add device tree handling to the palmas MFD. This takes the values that can be set from platform data from the device tree nodes instead. Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/palmas.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
index 7c1a194..4f8d6e6 100644
--- a/drivers/mfd/palmas.c
+++ b/drivers/mfd/palmas.c
@@ -23,6 +23,7 @@
#include <linux/err.h>
#include <linux/mfd/core.h>
#include <linux/mfd/palmas.h>
+#include <linux/of_platform.h>
enum palmas_ids {
PALMAS_PMIC_ID,
@@ -246,17 +247,56 @@ static struct regmap_irq_chip palmas_irq_chip = {
PALMAS_INT1_MASK),
};
+static void __devinit palmas_dt_to_pdata(struct device_node *node,
+ struct palmas_platform_data *pdata)
+{
+ int ret;
+ u32 prop;
+
+ ret = of_property_read_u32(node, "ti,mux_pad1", &prop);
+ if (!ret) {
+ pdata->mux_from_pdata = 1;
+ pdata->pad1 = prop;
+ }
+
+ ret = of_property_read_u32(node, "ti,mux_pad2", &prop);
+ if (!ret) {
+ pdata->mux_from_pdata = 1;
+ pdata->pad2 = prop;
+ }
+
+ /* The default for this register is all masked */
+ ret = of_property_read_u32(node, "ti,power_ctrl", &prop);
+ if (!ret)
+ pdata->power_ctrl = prop;
+ else
+ pdata->power_ctrl = PALMAS_POWER_CTRL_NSLEEP_MASK |
+ PALMAS_POWER_CTRL_ENABLE1_MASK |
+ PALMAS_POWER_CTRL_ENABLE2_MASK;
+}
+
static int __devinit 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;
int slave;
struct mfd_cell *children;
pdata = dev_get_platdata(&i2c->dev);
+
+ if (node && !pdata) {
+ pdata = devm_kzalloc(&i2c->dev, sizeof(*pdata), GFP_KERNEL);
+
+ if (!pdata)
+ return -ENOMEM;
+
+ palmas_dt_to_pdata(node, pdata);
+ }
+
if (!pdata)
return -EINVAL;
@@ -379,6 +419,18 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c,
if (ret)
goto err_irq;
+ /*
+ * If we are probing with DT do this the DT way and return here
+ * otherwise continue and add devices using mfd helpers.
+ */
+ if (node) {
+ ret = of_platform_populate(node, NULL, NULL, &i2c->dev);
+ if (ret < 0)
+ goto err_irq;
+ else
+ return ret;
+ }
+
children = kmemdup(palmas_children, sizeof(palmas_children),
GFP_KERNEL);
if (!children) {
OpenPOWER on IntegriCloud