aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc
diff options
context:
space:
mode:
authorHaojian Zhuang <haojian.zhuang@gmail.com>2012-09-21 06:06:52 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2012-10-02 05:43:13 -0400
commit2e57d56747e601b3e0ff6697e524025d0504d161 (patch)
tree29a7c677878d39f64e90dfbdf7063a11c08d4c15 /drivers/rtc
parent837c8293ba24d08cd7438d82ad9bb8d2fb0f8a5b (diff)
mfd: 88pm860x: Device tree support
Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/rtc-88pm860x.c43
1 files changed, 34 insertions, 9 deletions
diff --git a/drivers/rtc/rtc-88pm860x.c b/drivers/rtc/rtc-88pm860x.c
index feddefc42109..de9e854b326a 100644
--- a/drivers/rtc/rtc-88pm860x.c
+++ b/drivers/rtc/rtc-88pm860x.c
@@ -11,6 +11,7 @@
11 11
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/of.h>
14#include <linux/platform_device.h> 15#include <linux/platform_device.h>
15#include <linux/slab.h> 16#include <linux/slab.h>
16#include <linux/mutex.h> 17#include <linux/mutex.h>
@@ -284,6 +285,28 @@ out:
284} 285}
285#endif 286#endif
286 287
288#ifdef CONFIG_OF
289static int __devinit pm860x_rtc_dt_init(struct platform_device *pdev,
290 struct pm860x_rtc_info *info)
291{
292 struct device_node *np = pdev->dev.parent->of_node;
293 int ret;
294 if (!np)
295 return -ENODEV;
296 np = of_find_node_by_name(np, "rtc");
297 if (!np) {
298 dev_err(&pdev->dev, "failed to find rtc node\n");
299 return -ENODEV;
300 }
301 ret = of_property_read_u32(np, "marvell,88pm860x-vrtc", &info->vrtc);
302 if (ret)
303 info->vrtc = 0;
304 return 0;
305}
306#else
307#define pm860x_rtc_dt_init(x, y) (-1)
308#endif
309
287static int __devinit pm860x_rtc_probe(struct platform_device *pdev) 310static int __devinit pm860x_rtc_probe(struct platform_device *pdev)
288{ 311{
289 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); 312 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
@@ -294,8 +317,6 @@ static int __devinit pm860x_rtc_probe(struct platform_device *pdev)
294 int ret; 317 int ret;
295 318
296 pdata = pdev->dev.platform_data; 319 pdata = pdev->dev.platform_data;
297 if (pdata == NULL)
298 dev_warn(&pdev->dev, "No platform data!\n");
299 320
300 info = kzalloc(sizeof(struct pm860x_rtc_info), GFP_KERNEL); 321 info = kzalloc(sizeof(struct pm860x_rtc_info), GFP_KERNEL);
301 if (!info) 322 if (!info)
@@ -345,9 +366,11 @@ static int __devinit pm860x_rtc_probe(struct platform_device *pdev)
345 } 366 }
346 } 367 }
347 rtc_tm_to_time(&tm, &ticks); 368 rtc_tm_to_time(&tm, &ticks);
348 if (pdata && pdata->sync) { 369 if (pm860x_rtc_dt_init(pdev, info)) {
349 pdata->sync(ticks); 370 if (pdata && pdata->sync) {
350 info->sync = pdata->sync; 371 pdata->sync(ticks);
372 info->sync = pdata->sync;
373 }
351 } 374 }
352 375
353 info->rtc_dev = rtc_device_register("88pm860x-rtc", &pdev->dev, 376 info->rtc_dev = rtc_device_register("88pm860x-rtc", &pdev->dev,
@@ -366,10 +389,12 @@ static int __devinit pm860x_rtc_probe(struct platform_device *pdev)
366 389
367#ifdef VRTC_CALIBRATION 390#ifdef VRTC_CALIBRATION
368 /* <00> -- 2.7V, <01> -- 2.9V, <10> -- 3.1V, <11> -- 3.3V */ 391 /* <00> -- 2.7V, <01> -- 2.9V, <10> -- 3.1V, <11> -- 3.3V */
369 if (pdata && pdata->vrtc) 392 if (pm860x_rtc_dt_init(pdev, info)) {
370 info->vrtc = pdata->vrtc & 0x3; 393 if (pdata && pdata->vrtc)
371 else 394 info->vrtc = pdata->vrtc & 0x3;
372 info->vrtc = 1; 395 else
396 info->vrtc = 1;
397 }
373 pm860x_set_bits(info->i2c, PM8607_MEAS_EN2, MEAS2_VRTC, MEAS2_VRTC); 398 pm860x_set_bits(info->i2c, PM8607_MEAS_EN2, MEAS2_VRTC, MEAS2_VRTC);
374 399
375 /* calibrate VRTC */ 400 /* calibrate VRTC */