aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/sec-core.c
diff options
context:
space:
mode:
authorKrzysztof Kozlowski <k.kozlowski@samsung.com>2014-04-14 03:40:45 -0400
committerLee Jones <lee.jones@linaro.org>2014-06-03 03:11:16 -0400
commite349c910e2398cbff59d7c58851503191a8e9157 (patch)
tree0d54685f5ea382b6b99e6a7d9e2d536e2b6d06db /drivers/mfd/sec-core.c
parenta865a589144da6dbf26750b7193a9748da159305 (diff)
mfd/rtc: s5m: Do not allocate RTC I2C dummy and regmap for unsupported chipsets
The rtc-s5m driver does not support all of S2M and S5M chipsets supported by main MFD sec-core driver. For such chipsets unsupported by rtc-s5m, the MFD sec-core driver initialized regmap with default config. This config in such cases wouldn't work at all. The main MFD sec-core driver shouldn't initialize regmap for child drivers which is not used by them and even not valid. Move the allocation of RTC I2C dummy device and initialization of RTC regmap from main MFD sec-core driver to the rtc-s5m driver. The rtc-s5m driver will use proper regmap config for supported devices. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Acked-by: Alessandro Zummo <a.zummo@towertech.it> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/mfd/sec-core.c')
-rw-r--r--drivers/mfd/sec-core.c53
1 files changed, 1 insertions, 52 deletions
diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c
index 1cf27521fff4..d4682c6cbff5 100644
--- a/drivers/mfd/sec-core.c
+++ b/drivers/mfd/sec-core.c
@@ -25,7 +25,6 @@
25#include <linux/mfd/core.h> 25#include <linux/mfd/core.h>
26#include <linux/mfd/samsung/core.h> 26#include <linux/mfd/samsung/core.h>
27#include <linux/mfd/samsung/irq.h> 27#include <linux/mfd/samsung/irq.h>
28#include <linux/mfd/samsung/rtc.h>
29#include <linux/mfd/samsung/s2mpa01.h> 28#include <linux/mfd/samsung/s2mpa01.h>
30#include <linux/mfd/samsung/s2mps11.h> 29#include <linux/mfd/samsung/s2mps11.h>
31#include <linux/mfd/samsung/s2mps14.h> 30#include <linux/mfd/samsung/s2mps14.h>
@@ -196,20 +195,6 @@ static const struct regmap_config s5m8767_regmap_config = {
196 .cache_type = REGCACHE_FLAT, 195 .cache_type = REGCACHE_FLAT,
197}; 196};
198 197
199static const struct regmap_config s5m_rtc_regmap_config = {
200 .reg_bits = 8,
201 .val_bits = 8,
202
203 .max_register = SEC_RTC_REG_MAX,
204};
205
206static const struct regmap_config s2mps14_rtc_regmap_config = {
207 .reg_bits = 8,
208 .val_bits = 8,
209
210 .max_register = S2MPS_RTC_REG_MAX,
211};
212
213#ifdef CONFIG_OF 198#ifdef CONFIG_OF
214/* 199/*
215 * Only the common platform data elements for s5m8767 are parsed here from the 200 * Only the common platform data elements for s5m8767 are parsed here from the
@@ -264,7 +249,7 @@ static int sec_pmic_probe(struct i2c_client *i2c,
264 const struct i2c_device_id *id) 249 const struct i2c_device_id *id)
265{ 250{
266 struct sec_platform_data *pdata = dev_get_platdata(&i2c->dev); 251 struct sec_platform_data *pdata = dev_get_platdata(&i2c->dev);
267 const struct regmap_config *regmap, *regmap_rtc; 252 const struct regmap_config *regmap;
268 struct sec_pmic_dev *sec_pmic; 253 struct sec_pmic_dev *sec_pmic;
269 int ret; 254 int ret;
270 255
@@ -298,39 +283,21 @@ static int sec_pmic_probe(struct i2c_client *i2c,
298 switch (sec_pmic->device_type) { 283 switch (sec_pmic->device_type) {
299 case S2MPA01: 284 case S2MPA01:
300 regmap = &s2mpa01_regmap_config; 285 regmap = &s2mpa01_regmap_config;
301 /*
302 * The rtc-s5m driver does not support S2MPA01 and there
303 * is no mfd_cell for S2MPA01 RTC device.
304 * However we must pass something to devm_regmap_init_i2c()
305 * so use S5M-like regmap config even though it wouldn't work.
306 */
307 regmap_rtc = &s5m_rtc_regmap_config;
308 break; 286 break;
309 case S2MPS11X: 287 case S2MPS11X:
310 regmap = &s2mps11_regmap_config; 288 regmap = &s2mps11_regmap_config;
311 /*
312 * The rtc-s5m driver does not support S2MPS11 and there
313 * is no mfd_cell for S2MPS11 RTC device.
314 * However we must pass something to devm_regmap_init_i2c()
315 * so use S5M-like regmap config even though it wouldn't work.
316 */
317 regmap_rtc = &s5m_rtc_regmap_config;
318 break; 289 break;
319 case S2MPS14X: 290 case S2MPS14X:
320 regmap = &s2mps14_regmap_config; 291 regmap = &s2mps14_regmap_config;
321 regmap_rtc = &s2mps14_rtc_regmap_config;
322 break; 292 break;
323 case S5M8763X: 293 case S5M8763X:
324 regmap = &s5m8763_regmap_config; 294 regmap = &s5m8763_regmap_config;
325 regmap_rtc = &s5m_rtc_regmap_config;
326 break; 295 break;
327 case S5M8767X: 296 case S5M8767X:
328 regmap = &s5m8767_regmap_config; 297 regmap = &s5m8767_regmap_config;
329 regmap_rtc = &s5m_rtc_regmap_config;
330 break; 298 break;
331 default: 299 default:
332 regmap = &sec_regmap_config; 300 regmap = &sec_regmap_config;
333 regmap_rtc = &s5m_rtc_regmap_config;
334 break; 301 break;
335 } 302 }
336 303
@@ -342,21 +309,6 @@ static int sec_pmic_probe(struct i2c_client *i2c,
342 return ret; 309 return ret;
343 } 310 }
344 311
345 sec_pmic->rtc = i2c_new_dummy(i2c->adapter, RTC_I2C_ADDR);
346 if (!sec_pmic->rtc) {
347 dev_err(&i2c->dev, "Failed to allocate I2C for RTC\n");
348 return -ENODEV;
349 }
350 i2c_set_clientdata(sec_pmic->rtc, sec_pmic);
351
352 sec_pmic->regmap_rtc = devm_regmap_init_i2c(sec_pmic->rtc, regmap_rtc);
353 if (IS_ERR(sec_pmic->regmap_rtc)) {
354 ret = PTR_ERR(sec_pmic->regmap_rtc);
355 dev_err(&i2c->dev, "Failed to allocate RTC register map: %d\n",
356 ret);
357 goto err_regmap_rtc;
358 }
359
360 if (pdata && pdata->cfg_pmic_irq) 312 if (pdata && pdata->cfg_pmic_irq)
361 pdata->cfg_pmic_irq(); 313 pdata->cfg_pmic_irq();
362 314
@@ -403,8 +355,6 @@ static int sec_pmic_probe(struct i2c_client *i2c,
403 355
404err_mfd: 356err_mfd:
405 sec_irq_exit(sec_pmic); 357 sec_irq_exit(sec_pmic);
406err_regmap_rtc:
407 i2c_unregister_device(sec_pmic->rtc);
408 return ret; 358 return ret;
409} 359}
410 360
@@ -414,7 +364,6 @@ static int sec_pmic_remove(struct i2c_client *i2c)
414 364
415 mfd_remove_devices(sec_pmic->dev); 365 mfd_remove_devices(sec_pmic->dev);
416 sec_irq_exit(sec_pmic); 366 sec_irq_exit(sec_pmic);
417 i2c_unregister_device(sec_pmic->rtc);
418 return 0; 367 return 0;
419} 368}
420 369