Sean Anderson | b786054 | 2020-06-24 06:41:12 -0400 | [diff] [blame] | 1 | // 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 | */ |
| 14 | static 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 | |
| 31 | static 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 | |
| 43 | static const struct udevice_id simple_pm_bus_ids[] = { |
| 44 | { .compatible = "simple-pm-bus" }, |
| 45 | { } |
| 46 | }; |
| 47 | |
| 48 | U_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 Glass | 8a2b47f | 2020-12-03 16:55:17 -0700 | [diff] [blame] | 54 | .priv_auto = sizeof(struct clk_bulk), |
Sean Anderson | b786054 | 2020-06-24 06:41:12 -0400 | [diff] [blame] | 55 | .flags = DM_FLAG_PRE_RELOC, |
| 56 | }; |