blob: 7a18953cba127910409e5ba1f1ae55f502f4bcbb [file] [log] [blame]
Sean Andersonb7860542020-06-24 06:41:12 -04001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2020 Sean Anderson <seanga2@gmail.com>
4 */
5
6#include <common.h>
7#include <clk.h>
8#include <dm.h>
9
10/*
11 * Power domains are taken care of by driver_probe, so we just have to enable
12 * clocks
13 */
14static int simple_pm_bus_probe(struct udevice *dev)
15{
16 int ret;
17 struct clk_bulk *bulk = dev_get_priv(dev);
18
19 ret = clk_get_bulk(dev, bulk);
20 if (ret)
21 return ret;
22
23 ret = clk_enable_bulk(bulk);
24 if (ret && ret != -ENOSYS && ret != -ENOTSUPP) {
25 clk_release_bulk(bulk);
26 return ret;
27 }
28 return 0;
29}
30
31static int simple_pm_bus_remove(struct udevice *dev)
32{
33 int ret;
34 struct clk_bulk *bulk = dev_get_priv(dev);
35
36 ret = clk_release_bulk(bulk);
37 if (ret && ret != -ENOSYS && ret != -ENOTSUPP)
38 return ret;
39 else
40 return 0;
41}
42
43static const struct udevice_id simple_pm_bus_ids[] = {
44 { .compatible = "simple-pm-bus" },
45 { }
46};
47
48U_BOOT_DRIVER(simple_pm_bus_drv) = {
49 .name = "simple_pm_bus",
50 .id = UCLASS_SIMPLE_BUS,
51 .of_match = simple_pm_bus_ids,
52 .probe = simple_pm_bus_probe,
53 .remove = simple_pm_bus_remove,
Simon Glass8a2b47f2020-12-03 16:55:17 -070054 .priv_auto = sizeof(struct clk_bulk),
Sean Andersonb7860542020-06-24 06:41:12 -040055 .flags = DM_FLAG_PRE_RELOC,
56};