aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mfd/tps65090.c11
-rw-r--r--drivers/regulator/tps65090-regulator.c64
-rw-r--r--include/linux/mfd/tps65090.h13
3 files changed, 20 insertions, 68 deletions
diff --git a/drivers/mfd/tps65090.c b/drivers/mfd/tps65090.c
index a66d4df51293..47f802bf1848 100644
--- a/drivers/mfd/tps65090.c
+++ b/drivers/mfd/tps65090.c
@@ -78,17 +78,6 @@ static struct mfd_cell tps65090s[] = {
78 }, 78 },
79}; 79};
80 80
81struct tps65090 {
82 struct mutex lock;
83 struct device *dev;
84 struct i2c_client *client;
85 struct regmap *rmap;
86 struct irq_chip irq_chip;
87 struct mutex irq_lock;
88 int irq_base;
89 unsigned int id;
90};
91
92int tps65090_write(struct device *dev, int reg, uint8_t val) 81int tps65090_write(struct device *dev, int reg, uint8_t val)
93{ 82{
94 struct tps65090 *tps = dev_get_drvdata(dev); 83 struct tps65090 *tps = dev_get_drvdata(dev);
diff --git a/drivers/regulator/tps65090-regulator.c b/drivers/regulator/tps65090-regulator.c
index 6bbf760be80a..661fcecd1cec 100644
--- a/drivers/regulator/tps65090-regulator.c
+++ b/drivers/regulator/tps65090-regulator.c
@@ -29,10 +29,6 @@
29 29
30struct tps65090_regulator { 30struct tps65090_regulator {
31 int id; 31 int id;
32 /* Regulator register address.*/
33 u8 reg_en_reg;
34 u8 en_bit;
35
36 /* used by regulator core */ 32 /* used by regulator core */
37 struct regulator_desc desc; 33 struct regulator_desc desc;
38 34
@@ -40,64 +36,14 @@ struct tps65090_regulator {
40 struct device *dev; 36 struct device *dev;
41}; 37};
42 38
43static inline struct device *to_tps65090_dev(struct regulator_dev *rdev)
44{
45 return rdev_get_dev(rdev)->parent->parent;
46}
47
48static int tps65090_reg_is_enabled(struct regulator_dev *rdev)
49{
50 struct tps65090_regulator *ri = rdev_get_drvdata(rdev);
51 struct device *parent = to_tps65090_dev(rdev);
52 uint8_t control;
53 int ret;
54
55 ret = tps65090_read(parent, ri->reg_en_reg, &control);
56 if (ret < 0) {
57 dev_err(&rdev->dev, "Error in reading reg 0x%x\n",
58 ri->reg_en_reg);
59 return ret;
60 }
61 return (((control >> ri->en_bit) & 1) == 1);
62}
63
64static int tps65090_reg_enable(struct regulator_dev *rdev)
65{
66 struct tps65090_regulator *ri = rdev_get_drvdata(rdev);
67 struct device *parent = to_tps65090_dev(rdev);
68 int ret;
69
70 ret = tps65090_set_bits(parent, ri->reg_en_reg, ri->en_bit);
71 if (ret < 0)
72 dev_err(&rdev->dev, "Error in updating reg 0x%x\n",
73 ri->reg_en_reg);
74 return ret;
75}
76
77static int tps65090_reg_disable(struct regulator_dev *rdev)
78{
79 struct tps65090_regulator *ri = rdev_get_drvdata(rdev);
80 struct device *parent = to_tps65090_dev(rdev);
81 int ret;
82
83 ret = tps65090_clr_bits(parent, ri->reg_en_reg, ri->en_bit);
84 if (ret < 0)
85 dev_err(&rdev->dev, "Error in updating reg 0x%x\n",
86 ri->reg_en_reg);
87
88 return ret;
89}
90
91static struct regulator_ops tps65090_ops = { 39static struct regulator_ops tps65090_ops = {
92 .enable = tps65090_reg_enable, 40 .enable = regulator_enable_regmap,
93 .disable = tps65090_reg_disable, 41 .disable = regulator_disable_regmap,
94 .is_enabled = tps65090_reg_is_enabled, 42 .is_enabled = regulator_is_enabled_regmap,
95}; 43};
96 44
97#define tps65090_REG(_id) \ 45#define tps65090_REG(_id) \
98{ \ 46{ \
99 .reg_en_reg = (TPS65090_ID_##_id) + 12, \
100 .en_bit = 0, \
101 .id = TPS65090_ID_##_id, \ 47 .id = TPS65090_ID_##_id, \
102 .desc = { \ 48 .desc = { \
103 .name = tps65090_rails(_id), \ 49 .name = tps65090_rails(_id), \
@@ -105,6 +51,8 @@ static struct regulator_ops tps65090_ops = {
105 .ops = &tps65090_ops, \ 51 .ops = &tps65090_ops, \
106 .type = REGULATOR_VOLTAGE, \ 52 .type = REGULATOR_VOLTAGE, \
107 .owner = THIS_MODULE, \ 53 .owner = THIS_MODULE, \
54 .enable_reg = (TPS65090_ID_##_id) + 12, \
55 .enable_mask = BIT(0), \
108 }, \ 56 }, \
109} 57}
110 58
@@ -136,6 +84,7 @@ static inline struct tps65090_regulator *find_regulator_info(int id)
136 84
137static int __devinit tps65090_regulator_probe(struct platform_device *pdev) 85static int __devinit tps65090_regulator_probe(struct platform_device *pdev)
138{ 86{
87 struct tps65090 *tps65090_mfd = dev_get_drvdata(pdev->dev.parent);
139 struct tps65090_regulator *ri = NULL; 88 struct tps65090_regulator *ri = NULL;
140 struct regulator_config config = { }; 89 struct regulator_config config = { };
141 struct regulator_dev *rdev; 90 struct regulator_dev *rdev;
@@ -155,6 +104,7 @@ static int __devinit tps65090_regulator_probe(struct platform_device *pdev)
155 config.dev = &pdev->dev; 104 config.dev = &pdev->dev;
156 config.init_data = &tps_pdata->regulator; 105 config.init_data = &tps_pdata->regulator;
157 config.driver_data = ri; 106 config.driver_data = ri;
107 config.regmap = tps65090_mfd->rmap;
158 108
159 rdev = regulator_register(&ri->desc, &config); 109 rdev = regulator_register(&ri->desc, &config);
160 if (IS_ERR(rdev)) { 110 if (IS_ERR(rdev)) {
diff --git a/include/linux/mfd/tps65090.h b/include/linux/mfd/tps65090.h
index 38e31c55adbb..6bc31d854626 100644
--- a/include/linux/mfd/tps65090.h
+++ b/include/linux/mfd/tps65090.h
@@ -22,6 +22,19 @@
22#ifndef __LINUX_MFD_TPS65090_H 22#ifndef __LINUX_MFD_TPS65090_H
23#define __LINUX_MFD_TPS65090_H 23#define __LINUX_MFD_TPS65090_H
24 24
25#include <linux/irq.h>
26
27struct tps65090 {
28 struct mutex lock;
29 struct device *dev;
30 struct i2c_client *client;
31 struct regmap *rmap;
32 struct irq_chip irq_chip;
33 struct mutex irq_lock;
34 int irq_base;
35 unsigned int id;
36};
37
25struct tps65090_subdev_info { 38struct tps65090_subdev_info {
26 int id; 39 int id;
27 const char *name; 40 const char *name;