spi-topcliff-pch: add recovery processing in case wait-event timeout
[zen-stable.git] / arch / arm / plat-samsung / pd.c
blob312b510d86b76bf0b96feba92de8aae8163380c3
1 /* linux/arch/arm/plat-samsung/pd.c
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
6 * Samsung Power domain support
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/init.h>
14 #include <linux/export.h>
15 #include <linux/platform_device.h>
16 #include <linux/err.h>
17 #include <linux/pm_runtime.h>
19 #include <plat/pd.h>
21 static int samsung_pd_probe(struct platform_device *pdev)
23 struct samsung_pd_info *pdata = pdev->dev.platform_data;
24 struct device *dev = &pdev->dev;
26 if (!pdata) {
27 dev_err(dev, "no device data specified\n");
28 return -ENOENT;
31 pm_runtime_set_active(dev);
32 pm_runtime_enable(dev);
34 dev_info(dev, "power domain registered\n");
35 return 0;
38 static int __devexit samsung_pd_remove(struct platform_device *pdev)
40 struct device *dev = &pdev->dev;
42 pm_runtime_disable(dev);
43 return 0;
46 static int samsung_pd_runtime_suspend(struct device *dev)
48 struct samsung_pd_info *pdata = dev->platform_data;
49 int ret = 0;
51 if (pdata->disable)
52 ret = pdata->disable(dev);
54 dev_dbg(dev, "suspended\n");
55 return ret;
58 static int samsung_pd_runtime_resume(struct device *dev)
60 struct samsung_pd_info *pdata = dev->platform_data;
61 int ret = 0;
63 if (pdata->enable)
64 ret = pdata->enable(dev);
66 dev_dbg(dev, "resumed\n");
67 return ret;
70 static const struct dev_pm_ops samsung_pd_pm_ops = {
71 .runtime_suspend = samsung_pd_runtime_suspend,
72 .runtime_resume = samsung_pd_runtime_resume,
75 static struct platform_driver samsung_pd_driver = {
76 .driver = {
77 .name = "samsung-pd",
78 .owner = THIS_MODULE,
79 .pm = &samsung_pd_pm_ops,
81 .probe = samsung_pd_probe,
82 .remove = __devexit_p(samsung_pd_remove),
85 static int __init samsung_pd_init(void)
87 int ret;
89 ret = platform_driver_register(&samsung_pd_driver);
90 if (ret)
91 printk(KERN_ERR "%s: failed to add PD driver\n", __func__);
93 return ret;
95 arch_initcall(samsung_pd_init);