Linux 4.18.10
[linux/fpc-iii.git] / drivers / bus / simple-pm-bus.c
blobc5eb46cbf388b507608f96ed1b55082d42d54981
1 /*
2 * Simple Power-Managed Bus Driver
4 * Copyright (C) 2014-2015 Glider bvba
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 */
11 #include <linux/module.h>
12 #include <linux/of_platform.h>
13 #include <linux/platform_device.h>
14 #include <linux/pm_runtime.h>
17 static int simple_pm_bus_probe(struct platform_device *pdev)
19 struct device_node *np = pdev->dev.of_node;
21 dev_dbg(&pdev->dev, "%s\n", __func__);
23 pm_runtime_enable(&pdev->dev);
25 if (np)
26 of_platform_populate(np, NULL, NULL, &pdev->dev);
28 return 0;
31 static int simple_pm_bus_remove(struct platform_device *pdev)
33 dev_dbg(&pdev->dev, "%s\n", __func__);
35 pm_runtime_disable(&pdev->dev);
36 return 0;
39 static const struct of_device_id simple_pm_bus_of_match[] = {
40 { .compatible = "simple-pm-bus", },
41 { /* sentinel */ }
43 MODULE_DEVICE_TABLE(of, simple_pm_bus_of_match);
45 static struct platform_driver simple_pm_bus_driver = {
46 .probe = simple_pm_bus_probe,
47 .remove = simple_pm_bus_remove,
48 .driver = {
49 .name = "simple-pm-bus",
50 .of_match_table = simple_pm_bus_of_match,
54 module_platform_driver(simple_pm_bus_driver);
56 MODULE_DESCRIPTION("Simple Power-Managed Bus Driver");
57 MODULE_AUTHOR("Geert Uytterhoeven <geert+renesas@glider.be>");
58 MODULE_LICENSE("GPL v2");