2012-08-28 11:47:56

by Graeme Gregory

[permalink] [raw]
Subject: [PATCH 0/6] some small cleanups for palmas and DT support

This series does a couple of small improvements to the palmas mfd and
regulator drivers. It does a little re-organisation of the header file
to better implement DT in regulator driver and then add DT handling.

Graeme


2012-08-28 11:48:09

by Graeme Gregory

[permalink] [raw]
Subject: [PATCH 1/6] mfd: palmas improve the error exit path

Improve the error exit path so that we correctly de-allocate resources
that have been allocated upto the point where error occurs.

Signed-off-by: Graeme Gregory <[email protected]>
---
drivers/mfd/palmas.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
index c4a69f1..5ffd330 100644
--- a/drivers/mfd/palmas.c
+++ b/drivers/mfd/palmas.c
@@ -377,11 +377,11 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c,
reg = pdata->pad1;
ret = regmap_write(palmas->regmap[slave], addr, reg);
if (ret)
- goto err;
+ goto err_irq;
} else {
ret = regmap_read(palmas->regmap[slave], addr, &reg);
if (ret)
- goto err;
+ goto err_irq;
}

if (!(reg & PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_0))
@@ -412,11 +412,11 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c,
reg = pdata->pad2;
ret = regmap_write(palmas->regmap[slave], addr, reg);
if (ret)
- goto err;
+ goto err_irq;
} else {
ret = regmap_read(palmas->regmap[slave], addr, &reg);
if (ret)
- goto err;
+ goto err_irq;
}

if (!(reg & PALMAS_PRIMARY_SECONDARY_PAD2_GPIO_4))
@@ -439,13 +439,13 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c,

ret = regmap_write(palmas->regmap[slave], addr, reg);
if (ret)
- goto err;
+ goto err_irq;

children = kmemdup(palmas_children, sizeof(palmas_children),
GFP_KERNEL);
if (!children) {
ret = -ENOMEM;
- goto err;
+ goto err_irq;
}

children[PALMAS_PMIC_ID].platform_data = pdata->pmic_pdata;
@@ -457,13 +457,15 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c,
kfree(children);

if (ret < 0)
- goto err;
+ goto err_devices;

return ret;

-err:
+err_devices:
mfd_remove_devices(palmas->dev);
- kfree(palmas);
+err_irq:
+ regmap_del_irq_chip(palmas->irq, palmas->irq_data);
+err:
return ret;
}

--
1.7.9.5

2012-08-28 11:48:12

by Graeme Gregory

[permalink] [raw]
Subject: [PATCH 2/6] mfd: palmas switch to linear domain in all cases

Swith the palmas to linear domain in all cases so in future DT and non
DT cases will work the same.

With this change we can not use regmap_get_virq internally so no need
to supply IRQ resources to children so remove those definitions.

Signed-off-by: Graeme Gregory <[email protected]>
---
drivers/mfd/palmas.c | 64 +-------------------------------------------------
1 file changed, 1 insertion(+), 63 deletions(-)

diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
index 5ffd330..3d33623 100644
--- a/drivers/mfd/palmas.c
+++ b/drivers/mfd/palmas.c
@@ -24,60 +24,6 @@
#include <linux/mfd/core.h>
#include <linux/mfd/palmas.h>

-static const struct resource gpadc_resource[] = {
- {
- .name = "EOC_SW",
- .start = PALMAS_GPADC_EOC_SW_IRQ,
- .end = PALMAS_GPADC_EOC_SW_IRQ,
- .flags = IORESOURCE_IRQ,
- }
-};
-
-static const struct resource usb_resource[] = {
- {
- .name = "ID",
- .start = PALMAS_ID_OTG_IRQ,
- .end = PALMAS_ID_OTG_IRQ,
- .flags = IORESOURCE_IRQ,
- },
- {
- .name = "ID_WAKEUP",
- .start = PALMAS_ID_IRQ,
- .end = PALMAS_ID_IRQ,
- .flags = IORESOURCE_IRQ,
- },
- {
- .name = "VBUS",
- .start = PALMAS_VBUS_OTG_IRQ,
- .end = PALMAS_VBUS_OTG_IRQ,
- .flags = IORESOURCE_IRQ,
- },
- {
- .name = "VBUS_WAKEUP",
- .start = PALMAS_VBUS_IRQ,
- .end = PALMAS_VBUS_IRQ,
- .flags = IORESOURCE_IRQ,
- },
-};
-
-static const struct resource rtc_resource[] = {
- {
- .name = "RTC_ALARM",
- .start = PALMAS_RTC_ALARM_IRQ,
- .end = PALMAS_RTC_ALARM_IRQ,
- .flags = IORESOURCE_IRQ,
- },
-};
-
-static const struct resource pwron_resource[] = {
- {
- .name = "PWRON_BUTTON",
- .start = PALMAS_PWRON_IRQ,
- .end = PALMAS_PWRON_IRQ,
- .flags = IORESOURCE_IRQ,
- },
-};
-
enum palmas_ids {
PALMAS_PMIC_ID,
PALMAS_GPIO_ID,
@@ -111,20 +57,14 @@ static const struct mfd_cell palmas_children[] = {
},
{
.name = "palmas-rtc",
- .num_resources = ARRAY_SIZE(rtc_resource),
- .resources = rtc_resource,
.id = PALMAS_RTC_ID,
},
{
.name = "palmas-pwrbutton",
- .num_resources = ARRAY_SIZE(pwron_resource),
- .resources = pwron_resource,
.id = PALMAS_PWRBUTTON_ID,
},
{
.name = "palmas-gpadc",
- .num_resources = ARRAY_SIZE(gpadc_resource),
- .resources = gpadc_resource,
.id = PALMAS_GPADC_ID,
},
{
@@ -141,8 +81,6 @@ static const struct mfd_cell palmas_children[] = {
},
{
.name = "palmas-usb",
- .num_resources = ARRAY_SIZE(usb_resource),
- .resources = usb_resource,
.id = PALMAS_USB_ID,
}
};
@@ -364,7 +302,7 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c,
regmap_write(palmas->regmap[slave], addr, reg);

ret = regmap_add_irq_chip(palmas->regmap[slave], palmas->irq,
- IRQF_ONESHOT | IRQF_TRIGGER_LOW, -1, &palmas_irq_chip,
+ IRQF_ONESHOT | IRQF_TRIGGER_LOW, 0, &palmas_irq_chip,
&palmas->irq_data);
if (ret < 0)
goto err;
--
1.7.9.5

2012-08-28 11:48:17

by Graeme Gregory

[permalink] [raw]
Subject: [PATCH 4/6] 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 <[email protected]>
---
drivers/mfd/palmas.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)

diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
index c4b99f4..b5905f0 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) {
--
1.7.9.5

2012-08-28 11:48:22

by Graeme Gregory

[permalink] [raw]
Subject: [PATCH 6/6] regulator: palmas add DT support

Add DT support to palmas regulator. This involved a little change to
the platform data structure. Regulator information can now come from
platform data or DT.

Signed-off-by: Graeme Gregory <[email protected]>
Signed-off-by: Kishon Vijay Abraham I <[email protected]>
---
drivers/regulator/palmas-regulator.c | 130 +++++++++++++++++++++++++++++++---
1 file changed, 119 insertions(+), 11 deletions(-)

diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
index 2ba7502..48c318b 100644
--- a/drivers/regulator/palmas-regulator.c
+++ b/drivers/regulator/palmas-regulator.c
@@ -22,6 +22,8 @@
#include <linux/slab.h>
#include <linux/regmap.h>
#include <linux/mfd/palmas.h>
+#include <linux/of_platform.h>
+#include <linux/regulator/of_regulator.h>

struct regs_info {
char *name;
@@ -568,10 +570,103 @@ static int palmas_ldo_init(struct palmas *palmas, int id,
return 0;
}

+static struct of_regulator_match palmas_matches[] = {
+ { .name = "smps12", },
+ { .name = "smps123", },
+ { .name = "smps3", },
+ { .name = "smps45", },
+ { .name = "smps457", },
+ { .name = "smps6", },
+ { .name = "smps7", },
+ { .name = "smps8", },
+ { .name = "smps9", },
+ { .name = "smps10", },
+ { .name = "ldo1", },
+ { .name = "ldo2", },
+ { .name = "ldo3", },
+ { .name = "ldo4", },
+ { .name = "ldo5", },
+ { .name = "ldo6", },
+ { .name = "ldo7", },
+ { .name = "ldo8", },
+ { .name = "ldo9", },
+ { .name = "ldoln", },
+ { .name = "ldousb", },
+};
+
+static void __devinit palmas_dt_to_pdata(struct device *dev,
+ struct device_node *node,
+ struct palmas_pmic_platform_data *pdata)
+{
+ struct device_node *regulators;
+ u32 prop;
+ int idx, ret;
+
+ regulators = of_find_node_by_name(node, "regulators");
+ if (!regulators) {
+ dev_info(dev, "regulator node not found\n");
+ return;
+ }
+
+ ret = of_regulator_match(dev, regulators, palmas_matches,
+ PALMAS_NUM_REGS);
+ if (ret < 0) {
+ dev_err(dev, "Error parsing regulator init data: %d\n", ret);
+ return;
+ }
+
+ for (idx = 0; idx < PALMAS_NUM_REGS; idx++) {
+ if (!palmas_matches[idx].init_data ||
+ !palmas_matches[idx].of_node)
+ continue;
+
+ pdata->reg_data[idx] = palmas_matches[idx].init_data;
+
+ pdata->reg_init[idx] = devm_kzalloc(dev,
+ sizeof(struct palmas_reg_init), GFP_KERNEL);
+
+ ret = of_property_read_u32(palmas_matches[idx].of_node,
+ "ti,warm_reset", &prop);
+ if (!ret)
+ pdata->reg_init[idx]->warm_reset = prop;
+
+ ret = of_property_read_u32(palmas_matches[idx].of_node,
+ "ti,roof_floor", &prop);
+ if (!ret)
+ pdata->reg_init[idx]->roof_floor = prop;
+
+ ret = of_property_read_u32(palmas_matches[idx].of_node,
+ "ti,mode_sleep", &prop);
+ if (!ret)
+ pdata->reg_init[idx]->mode_sleep = prop;
+
+ ret = of_property_read_u32(palmas_matches[idx].of_node,
+ "ti,warm_reset", &prop);
+ if (!ret)
+ pdata->reg_init[idx]->warm_reset = prop;
+
+ ret = of_property_read_u32(palmas_matches[idx].of_node,
+ "ti,tstep", &prop);
+ if (!ret)
+ pdata->reg_init[idx]->tstep = prop;
+
+ ret = of_property_read_u32(palmas_matches[idx].of_node,
+ "ti,vsel", &prop);
+ if (!ret)
+ pdata->reg_init[idx]->vsel = prop;
+ }
+
+ ret = of_property_read_u32(node, "ti,ldo6_vibrator", &prop);
+ if (!ret)
+ pdata->ldo6_vibrator = prop;
+}
+
+
static __devinit int palmas_probe(struct platform_device *pdev)
{
struct palmas *palmas = dev_get_drvdata(pdev->dev.parent);
struct palmas_pmic_platform_data *pdata = pdev->dev.platform_data;
+ struct device_node *node = pdev->dev.of_node;
struct regulator_dev *rdev;
struct regulator_config config = { };
struct palmas_pmic *pmic;
@@ -579,10 +674,14 @@ static __devinit int palmas_probe(struct platform_device *pdev)
int id = 0, ret;
unsigned int addr, reg;

- if (!pdata)
- return -EINVAL;
- if (!pdata->reg_data)
- return -EINVAL;
+ if (node && !pdata) {
+ pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+
+ if (!pdata)
+ return -ENOMEM;
+
+ palmas_dt_to_pdata(&pdev->dev, node, pdata);
+ }

pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL);
if (!pmic)
@@ -661,7 +760,7 @@ static __devinit int palmas_probe(struct platform_device *pdev)
pmic->desc[id].owner = THIS_MODULE;

/* Initialise sleep/init values from platform data */
- if (pdata && pdata->reg_init) {
+ if (pdata) {
reg_init = pdata->reg_init[id];
if (reg_init) {
ret = palmas_smps_init(palmas, id, reg_init);
@@ -685,11 +784,13 @@ static __devinit int palmas_probe(struct platform_device *pdev)
pmic->range[id] = 1;
}

- if (pdata && pdata->reg_data)
+ if (pdata)
config.init_data = pdata->reg_data[id];
else
config.init_data = NULL;

+ config.of_node = palmas_matches[id].of_node;
+
rdev = regulator_register(&pmic->desc[id], &config);
if (IS_ERR(rdev)) {
dev_err(&pdev->dev,
@@ -726,11 +827,13 @@ static __devinit int palmas_probe(struct platform_device *pdev)
palmas_regs_info[id].ctrl_addr);
pmic->desc[id].enable_mask = PALMAS_LDO1_CTRL_MODE_ACTIVE;

- if (pdata && pdata->reg_data)
+ if (pdata)
config.init_data = pdata->reg_data[id];
else
config.init_data = NULL;

+ config.of_node = palmas_matches[id].of_node;
+
rdev = regulator_register(&pmic->desc[id], &config);
if (IS_ERR(rdev)) {
dev_err(&pdev->dev,
@@ -744,14 +847,12 @@ static __devinit int palmas_probe(struct platform_device *pdev)
pmic->rdev[id] = rdev;

/* Initialise sleep/init values from platform data */
- if (pdata->reg_init) {
+ if (pdata) {
reg_init = pdata->reg_init[id];
if (reg_init) {
ret = palmas_ldo_init(palmas, id, reg_init);
- if (ret) {
- regulator_unregister(pmic->rdev[id]);
+ if (ret)
goto err_unregister_regulator;
- }
}
}
}
@@ -774,9 +875,15 @@ static int __devexit palmas_remove(struct platform_device *pdev)
return 0;
}

+static struct of_device_id __devinitdata of_palmas_match_tbl[] = {
+ { .compatible = "ti,palmas-pmic", },
+ { /* end */ }
+};
+
static struct platform_driver palmas_driver = {
.driver = {
.name = "palmas-pmic",
+ .of_match_table = of_palmas_match_tbl,
.owner = THIS_MODULE,
},
.probe = palmas_probe,
@@ -799,3 +906,4 @@ MODULE_AUTHOR("Graeme Gregory <[email protected]>");
MODULE_DESCRIPTION("Palmas voltage regulator driver");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:palmas-pmic");
+MODULE_DEVICE_TABLE(of, of_palmas_match_tbl);
--
1.7.9.5

2012-08-28 11:51:09

by Graeme Gregory

[permalink] [raw]
Subject: [PATCH 5/6] mfd: change regulator defns to better suite DT

In order to better fit DT parsing in of regulator definitions re-arrange
the platform data struct slightly which requires the definitions of
the regulator IDs earlier in the include file.

Signed-off-by: Graeme Gregory <[email protected]>
---
include/linux/mfd/palmas.h | 60 ++++++++++++++++++++++----------------------
1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index cfbf794..29f6616 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -130,16 +130,44 @@ struct palmas_reg_init {

};

+enum palmas_regulators {
+ /* SMPS regulators */
+ PALMAS_REG_SMPS12,
+ PALMAS_REG_SMPS123,
+ PALMAS_REG_SMPS3,
+ PALMAS_REG_SMPS45,
+ PALMAS_REG_SMPS457,
+ PALMAS_REG_SMPS6,
+ PALMAS_REG_SMPS7,
+ PALMAS_REG_SMPS8,
+ PALMAS_REG_SMPS9,
+ PALMAS_REG_SMPS10,
+ /* LDO regulators */
+ PALMAS_REG_LDO1,
+ PALMAS_REG_LDO2,
+ PALMAS_REG_LDO3,
+ PALMAS_REG_LDO4,
+ PALMAS_REG_LDO5,
+ PALMAS_REG_LDO6,
+ PALMAS_REG_LDO7,
+ PALMAS_REG_LDO8,
+ PALMAS_REG_LDO9,
+ PALMAS_REG_LDOLN,
+ PALMAS_REG_LDOUSB,
+ /* Total number of regulators */
+ PALMAS_NUM_REGS,
+};
+
struct palmas_pmic_platform_data {
/* An array of pointers to regulator init data indexed by regulator
* ID
*/
- struct regulator_init_data **reg_data;
+ struct regulator_init_data *reg_data[PALMAS_NUM_REGS];

/* An array of pointers to structures containing sleep mode and DVS
* configuration for regulators indexed by ID
*/
- struct palmas_reg_init **reg_init;
+ struct palmas_reg_init *reg_init[PALMAS_NUM_REGS];

/* use LDO6 for vibrator control */
int ldo6_vibrator;
@@ -291,34 +319,6 @@ enum palmas_irqs {
PALMAS_NUM_IRQ,
};

-enum palmas_regulators {
- /* SMPS regulators */
- PALMAS_REG_SMPS12,
- PALMAS_REG_SMPS123,
- PALMAS_REG_SMPS3,
- PALMAS_REG_SMPS45,
- PALMAS_REG_SMPS457,
- PALMAS_REG_SMPS6,
- PALMAS_REG_SMPS7,
- PALMAS_REG_SMPS8,
- PALMAS_REG_SMPS9,
- PALMAS_REG_SMPS10,
- /* LDO regulators */
- PALMAS_REG_LDO1,
- PALMAS_REG_LDO2,
- PALMAS_REG_LDO3,
- PALMAS_REG_LDO4,
- PALMAS_REG_LDO5,
- PALMAS_REG_LDO6,
- PALMAS_REG_LDO7,
- PALMAS_REG_LDO8,
- PALMAS_REG_LDO9,
- PALMAS_REG_LDOLN,
- PALMAS_REG_LDOUSB,
- /* Total number of regulators */
- PALMAS_NUM_REGS,
-};
-
struct palmas_pmic {
struct palmas *palmas;
struct device *dev;
--
1.7.9.5

2012-08-28 11:51:36

by Graeme Gregory

[permalink] [raw]
Subject: [PATCH 3/6] mfd: palmas add pdata/data for rest of children

Add the platform data and data structures for children that shall be
added by a future set of commits.

Signed-off-by: Graeme Gregory <[email protected]>
---
drivers/mfd/palmas.c | 13 ++++
include/linux/mfd/palmas.h | 172 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 185 insertions(+)

diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
index 3d33623..c4b99f4 100644
--- a/drivers/mfd/palmas.c
+++ b/drivers/mfd/palmas.c
@@ -389,6 +389,19 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c,
children[PALMAS_PMIC_ID].platform_data = pdata->pmic_pdata;
children[PALMAS_PMIC_ID].pdata_size = sizeof(*pdata->pmic_pdata);

+ children[PALMAS_GPADC_ID].platform_data = pdata->gpadc_pdata;
+ children[PALMAS_GPADC_ID].pdata_size = sizeof(*pdata->gpadc_pdata);
+
+ children[PALMAS_RESOURCE_ID].platform_data = pdata->resource_pdata;
+ children[PALMAS_RESOURCE_ID].pdata_size =
+ sizeof(*pdata->resource_pdata);
+
+ children[PALMAS_USB_ID].platform_data = pdata->usb_pdata;
+ children[PALMAS_USB_ID].pdata_size = sizeof(*pdata->usb_pdata);
+
+ children[PALMAS_CLK_ID].platform_data = pdata->clk_pdata;
+ children[PALMAS_CLK_ID].pdata_size = sizeof(*pdata->clk_pdata);
+
ret = mfd_add_devices(palmas->dev, -1,
children, ARRAY_SIZE(palmas_children),
NULL, regmap_irq_chip_get_base(palmas->irq_data));
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index 9cbc642..cfbf794 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -23,6 +23,9 @@
#define PALMAS_NUM_CLIENTS 3

struct palmas_pmic;
+struct palmas_gpadc;
+struct palmas_resource;
+struct palmas_usb;

struct palmas {
struct device *dev;
@@ -41,6 +44,9 @@ struct palmas {

/* Child Devices */
struct palmas_pmic *pmic;
+ struct palmas_gpadc *gpadc;
+ struct palmas_resource *resource;
+ struct palmas_usb *usb;

/* GPIO MUXing */
u8 gpio_muxed;
@@ -48,6 +54,23 @@ struct palmas {
u8 pwm_muxed;
};

+struct palmas_gpadc_platform_data {
+ /* Channel 3 current source is only enabled during conversion */
+ int ch3_current;
+
+ /* Channel 0 current source can be used for battery detection.
+ * If used for battery detection this will cause a permanent current
+ * consumption depending on current level set here.
+ */
+ int ch0_current;
+
+ /* default BAT_REMOVAL_DAT setting on device probe */
+ int bat_removal;
+
+ /* Sets the START_POLARITY bit in the RT_CTRL register */
+ int start_polarity;
+};
+
struct palmas_reg_init {
/* warm_rest controls the voltage levels after a warm reset
*
@@ -120,8 +143,53 @@ struct palmas_pmic_platform_data {

/* use LDO6 for vibrator control */
int ldo6_vibrator;
+};
+
+struct palmas_usb_platform_data {
+ /* Set this if platform wishes its own vbus control */
+ int no_control_vbus;

+ /* Do we enable the wakeup comparator on probe */
+ int wakeup;
+};
+
+struct palmas_resource_platform_data {
+ int regen1_mode_sleep;
+ int regen2_mode_sleep;
+ int sysen1_mode_sleep;
+ int sysen2_mode_sleep;
+
+ /* bitfield to be loaded to NSLEEP_RES_ASSIGN */
+ u8 nsleep_res;
+ /* bitfield to be loaded to NSLEEP_SMPS_ASSIGN */
+ u8 nsleep_smps;
+ /* bitfield to be loaded to NSLEEP_LDO_ASSIGN1 */
+ u8 nsleep_ldo1;
+ /* bitfield to be loaded to NSLEEP_LDO_ASSIGN2 */
+ u8 nsleep_ldo2;
+
+ /* bitfield to be loaded to ENABLE1_RES_ASSIGN */
+ u8 enable1_res;
+ /* bitfield to be loaded to ENABLE1_SMPS_ASSIGN */
+ u8 enable1_smps;
+ /* bitfield to be loaded to ENABLE1_LDO_ASSIGN1 */
+ u8 enable1_ldo1;
+ /* bitfield to be loaded to ENABLE1_LDO_ASSIGN2 */
+ u8 enable1_ldo2;
+
+ /* bitfield to be loaded to ENABLE2_RES_ASSIGN */
+ u8 enable2_res;
+ /* bitfield to be loaded to ENABLE2_SMPS_ASSIGN */
+ u8 enable2_smps;
+ /* bitfield to be loaded to ENABLE2_LDO_ASSIGN1 */
+ u8 enable2_ldo1;
+ /* bitfield to be loaded to ENABLE2_LDO_ASSIGN2 */
+ u8 enable2_ldo2;
+};

+struct palmas_clk_platform_data {
+ int clk32kg_mode_sleep;
+ int clk32kgaudio_mode_sleep;
};

struct palmas_platform_data {
@@ -138,8 +206,49 @@ struct palmas_platform_data {
u8 pad1, pad2;

struct palmas_pmic_platform_data *pmic_pdata;
+ struct palmas_gpadc_platform_data *gpadc_pdata;
+ struct palmas_usb_platform_data *usb_pdata;
+ struct palmas_resource_platform_data *resource_pdata;
+ struct palmas_clk_platform_data *clk_pdata;
};

+struct palmas_gpadc_calibration {
+ s32 gain;
+ s32 gain_error;
+ s32 offset_error;
+};
+
+struct palmas_gpadc {
+ struct device *dev;
+ struct palmas *palmas;
+
+ int ch3_current;
+ int ch0_current;
+
+ int gpadc_force;
+
+ int bat_removal;
+
+ struct mutex reading_lock;
+ struct completion irq_complete;
+
+ int eoc_sw_irq;
+
+ struct palmas_gpadc_calibration *palmas_cal_tbl;
+
+ int conv0_channel;
+ int conv1_channel;
+ int rt_channel;
+};
+
+struct palmas_gpadc_result {
+ s32 raw_code;
+ s32 corrected_code;
+ s32 result;
+};
+
+#define PALMAS_MAX_CHANNELS 16
+
/* Define the palmas IRQ numbers */
enum palmas_irqs {
/* INT1 registers */
@@ -223,6 +332,69 @@ struct palmas_pmic {
int range[PALMAS_REG_SMPS10];
};

+struct palmas_resource {
+ struct palmas *palmas;
+ struct device *dev;
+};
+
+struct palmas_usb {
+ struct palmas *palmas;
+ struct device *dev;
+
+ /* for vbus reporting with irqs disabled */
+ spinlock_t lock;
+
+ struct regulator *vbus_reg;
+
+ /* used to set vbus, in atomic path */
+ struct work_struct set_vbus_work;
+
+ int irq1;
+ int irq2;
+ int irq3;
+ int irq4;
+
+ int vbus_enable;
+
+ u8 linkstat;
+};
+
+#define comparator_to_palmas(x) container_of((x), struct palmas_usb, comparator)
+
+enum usb_irq_events {
+ /* Wakeup events from INT3 */
+ PALMAS_USB_ID_WAKEPUP,
+ PALMAS_USB_VBUS_WAKEUP,
+
+ /* ID_OTG_EVENTS */
+ PALMAS_USB_ID_GND,
+ N_PALMAS_USB_ID_GND,
+ PALMAS_USB_ID_C,
+ N_PALMAS_USB_ID_C,
+ PALMAS_USB_ID_B,
+ N_PALMAS_USB_ID_B,
+ PALMAS_USB_ID_A,
+ N_PALMAS_USB_ID_A,
+ PALMAS_USB_ID_FLOAT,
+ N_PALMAS_USB_ID_FLOAT,
+
+ /* VBUS_OTG_EVENTS */
+ PALMAS_USB_VB_SESS_END,
+ N_PALMAS_USB_VB_SESS_END,
+ PALMAS_USB_VB_SESS_VLD,
+ N_PALMAS_USB_VB_SESS_VLD,
+ PALMAS_USB_VA_SESS_VLD,
+ N_PALMAS_USB_VA_SESS_VLD,
+ PALMAS_USB_VA_VBUS_VLD,
+ N_PALMAS_USB_VA_VBUS_VLD,
+ PALMAS_USB_VADP_SNS,
+ N_PALMAS_USB_VADP_SNS,
+ PALMAS_USB_VADP_PRB,
+ N_PALMAS_USB_VADP_PRB,
+ PALMAS_USB_VOTG_SESS_VLD,
+ N_PALMAS_USB_VOTG_SESS_VLD,
+};
+
/* defines so we can store the mux settings */
#define PALMAS_GPIO_0_MUXED (1 << 0)
#define PALMAS_GPIO_1_MUXED (1 << 1)
--
1.7.9.5

2012-08-28 16:49:25

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 4/6] mfd: palmas add device tree handling to mfd

On Tue, Aug 28, 2012 at 01:47:38PM +0200, Graeme Gregory wrote:
> 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 <[email protected]>
> ---
> drivers/mfd/palmas.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 52 insertions(+)

Any new device tree bindings should be documented.

2012-08-28 18:11:05

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 2/6] mfd: palmas switch to linear domain in all cases

On Tue, Aug 28, 2012 at 01:47:36PM +0200, Graeme Gregory wrote:
> Swith the palmas to linear domain in all cases so in future DT and non
> DT cases will work the same.

> With this change we can not use regmap_get_virq internally so no need
> to supply IRQ resources to children so remove those definitions.

This second bit of the comment doesn't follow - regmap_get_virq() works
with any kind of irqdomain.

2012-08-28 20:10:07

by Graeme Gregory

[permalink] [raw]
Subject: Re: [PATCH 2/6] mfd: palmas switch to linear domain in all cases

On 28/08/12 20:11, Mark Brown wrote:
> On Tue, Aug 28, 2012 at 01:47:36PM +0200, Graeme Gregory wrote:
>> Swith the palmas to linear domain in all cases so in future DT and non
>> DT cases will work the same.
>> With this change we can not use regmap_get_virq internally so no need
>> to supply IRQ resources to children so remove those definitions.
> This second bit of the comment doesn't follow - regmap_get_virq() works
> with any kind of irqdomain.
Ill re-word it then, I basically meant that the resources are not needed
as internally its easier to use regmap_get_virq().

Graeme

2012-08-28 20:10:42

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 2/6] mfd: palmas switch to linear domain in all cases

On Tue, Aug 28, 2012 at 10:10:01PM +0200, Graeme Gregory wrote:
> On 28/08/12 20:11, Mark Brown wrote:

> > This second bit of the comment doesn't follow - regmap_get_virq() works
> > with any kind of irqdomain.

> Ill re-word it then, I basically meant that the resources are not needed
> as internally its easier to use regmap_get_virq().

Ah, I see! That makes sense.