aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/s5m-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mfd/s5m-core.c')
-rw-r--r--drivers/mfd/s5m-core.c58
1 files changed, 45 insertions, 13 deletions
diff --git a/drivers/mfd/s5m-core.c b/drivers/mfd/s5m-core.c
index caadabeed8e9..48949d998d10 100644
--- a/drivers/mfd/s5m-core.c
+++ b/drivers/mfd/s5m-core.c
@@ -26,7 +26,27 @@
26#include <linux/mfd/s5m87xx/s5m-rtc.h> 26#include <linux/mfd/s5m87xx/s5m-rtc.h>
27#include <linux/regmap.h> 27#include <linux/regmap.h>
28 28
29static struct mfd_cell s5m87xx_devs[] = { 29static struct mfd_cell s5m8751_devs[] = {
30 {
31 .name = "s5m8751-pmic",
32 }, {
33 .name = "s5m-charger",
34 }, {
35 .name = "s5m8751-codec",
36 },
37};
38
39static struct mfd_cell s5m8763_devs[] = {
40 {
41 .name = "s5m8763-pmic",
42 }, {
43 .name = "s5m-rtc",
44 }, {
45 .name = "s5m-charger",
46 },
47};
48
49static struct mfd_cell s5m8767_devs[] = {
30 { 50 {
31 .name = "s5m8767-pmic", 51 .name = "s5m8767-pmic",
32 }, { 52 }, {
@@ -42,7 +62,7 @@ EXPORT_SYMBOL_GPL(s5m_reg_read);
42 62
43int s5m_bulk_read(struct s5m87xx_dev *s5m87xx, u8 reg, int count, u8 *buf) 63int s5m_bulk_read(struct s5m87xx_dev *s5m87xx, u8 reg, int count, u8 *buf)
44{ 64{
45 return regmap_bulk_read(s5m87xx->regmap, reg, buf, count);; 65 return regmap_bulk_read(s5m87xx->regmap, reg, buf, count);
46} 66}
47EXPORT_SYMBOL_GPL(s5m_bulk_read); 67EXPORT_SYMBOL_GPL(s5m_bulk_read);
48 68
@@ -54,7 +74,7 @@ EXPORT_SYMBOL_GPL(s5m_reg_write);
54 74
55int s5m_bulk_write(struct s5m87xx_dev *s5m87xx, u8 reg, int count, u8 *buf) 75int s5m_bulk_write(struct s5m87xx_dev *s5m87xx, u8 reg, int count, u8 *buf)
56{ 76{
57 return regmap_raw_write(s5m87xx->regmap, reg, buf, count * sizeof(u16)); 77 return regmap_raw_write(s5m87xx->regmap, reg, buf, count);
58} 78}
59EXPORT_SYMBOL_GPL(s5m_bulk_write); 79EXPORT_SYMBOL_GPL(s5m_bulk_write);
60 80
@@ -74,10 +94,10 @@ static int s5m87xx_i2c_probe(struct i2c_client *i2c,
74{ 94{
75 struct s5m_platform_data *pdata = i2c->dev.platform_data; 95 struct s5m_platform_data *pdata = i2c->dev.platform_data;
76 struct s5m87xx_dev *s5m87xx; 96 struct s5m87xx_dev *s5m87xx;
77 int ret = 0; 97 int ret;
78 int error;
79 98
80 s5m87xx = kzalloc(sizeof(struct s5m87xx_dev), GFP_KERNEL); 99 s5m87xx = devm_kzalloc(&i2c->dev, sizeof(struct s5m87xx_dev),
100 GFP_KERNEL);
81 if (s5m87xx == NULL) 101 if (s5m87xx == NULL)
82 return -ENOMEM; 102 return -ENOMEM;
83 103
@@ -96,9 +116,9 @@ static int s5m87xx_i2c_probe(struct i2c_client *i2c,
96 116
97 s5m87xx->regmap = regmap_init_i2c(i2c, &s5m_regmap_config); 117 s5m87xx->regmap = regmap_init_i2c(i2c, &s5m_regmap_config);
98 if (IS_ERR(s5m87xx->regmap)) { 118 if (IS_ERR(s5m87xx->regmap)) {
99 error = PTR_ERR(s5m87xx->regmap); 119 ret = PTR_ERR(s5m87xx->regmap);
100 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", 120 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
101 error); 121 ret);
102 goto err; 122 goto err;
103 } 123 }
104 124
@@ -112,9 +132,23 @@ static int s5m87xx_i2c_probe(struct i2c_client *i2c,
112 132
113 pm_runtime_set_active(s5m87xx->dev); 133 pm_runtime_set_active(s5m87xx->dev);
114 134
115 ret = mfd_add_devices(s5m87xx->dev, -1, 135 switch (s5m87xx->device_type) {
116 s5m87xx_devs, ARRAY_SIZE(s5m87xx_devs), 136 case S5M8751X:
117 NULL, 0); 137 ret = mfd_add_devices(s5m87xx->dev, -1, s5m8751_devs,
138 ARRAY_SIZE(s5m8751_devs), NULL, 0);
139 break;
140 case S5M8763X:
141 ret = mfd_add_devices(s5m87xx->dev, -1, s5m8763_devs,
142 ARRAY_SIZE(s5m8763_devs), NULL, 0);
143 break;
144 case S5M8767X:
145 ret = mfd_add_devices(s5m87xx->dev, -1, s5m8767_devs,
146 ARRAY_SIZE(s5m8767_devs), NULL, 0);
147 break;
148 default:
149 /* If this happens the probe function is problem */
150 BUG();
151 }
118 152
119 if (ret < 0) 153 if (ret < 0)
120 goto err; 154 goto err;
@@ -126,7 +160,6 @@ err:
126 s5m_irq_exit(s5m87xx); 160 s5m_irq_exit(s5m87xx);
127 i2c_unregister_device(s5m87xx->rtc); 161 i2c_unregister_device(s5m87xx->rtc);
128 regmap_exit(s5m87xx->regmap); 162 regmap_exit(s5m87xx->regmap);
129 kfree(s5m87xx);
130 return ret; 163 return ret;
131} 164}
132 165
@@ -138,7 +171,6 @@ static int s5m87xx_i2c_remove(struct i2c_client *i2c)
138 s5m_irq_exit(s5m87xx); 171 s5m_irq_exit(s5m87xx);
139 i2c_unregister_device(s5m87xx->rtc); 172 i2c_unregister_device(s5m87xx->rtc);
140 regmap_exit(s5m87xx->regmap); 173 regmap_exit(s5m87xx->regmap);
141 kfree(s5m87xx);
142 return 0; 174 return 0;
143} 175}
144 176