blob: 01a3d0cd08edc7271215e0e61c5a1d5497ac33ac [file] [log] [blame]
Geert Uytterhoeven89d463e2015-02-05 11:11:28 +01001/*
2 * Simple Power-Managed Bus Driver
3 *
4 * Copyright (C) 2014-2015 Glider bvba
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#include <linux/module.h>
12#include <linux/of_platform.h>
13#include <linux/platform_device.h>
14#include <linux/pm_runtime.h>
15
16
17static int simple_pm_bus_probe(struct platform_device *pdev)
18{
Tony Lindgreneda080e2021-01-15 10:47:17 +020019 const struct of_dev_auxdata *lookup = dev_get_platdata(&pdev->dev);
Geert Uytterhoeven89d463e2015-02-05 11:11:28 +010020 struct device_node *np = pdev->dev.of_node;
21
22 dev_dbg(&pdev->dev, "%s\n", __func__);
23
24 pm_runtime_enable(&pdev->dev);
25
26 if (np)
Tony Lindgreneda080e2021-01-15 10:47:17 +020027 of_platform_populate(np, NULL, lookup, &pdev->dev);
Geert Uytterhoeven89d463e2015-02-05 11:11:28 +010028
29 return 0;
30}
31
32static int simple_pm_bus_remove(struct platform_device *pdev)
33{
34 dev_dbg(&pdev->dev, "%s\n", __func__);
35
36 pm_runtime_disable(&pdev->dev);
37 return 0;
38}
39
40static const struct of_device_id simple_pm_bus_of_match[] = {
41 { .compatible = "simple-pm-bus", },
42 { /* sentinel */ }
43};
44MODULE_DEVICE_TABLE(of, simple_pm_bus_of_match);
45
46static struct platform_driver simple_pm_bus_driver = {
47 .probe = simple_pm_bus_probe,
48 .remove = simple_pm_bus_remove,
49 .driver = {
50 .name = "simple-pm-bus",
51 .of_match_table = simple_pm_bus_of_match,
52 },
53};
54
55module_platform_driver(simple_pm_bus_driver);
56
57MODULE_DESCRIPTION("Simple Power-Managed Bus Driver");
58MODULE_AUTHOR("Geert Uytterhoeven <geert+renesas@glider.be>");
59MODULE_LICENSE("GPL v2");