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 | |
Sean Anderson | b786054 | 2020-06-24 06:41:12 -0400 | [diff] [blame] | 6 | #include <clk.h> |
| 7 | #include <dm.h> |
| 8 | |
| 9 | /* |
| 10 | * Power domains are taken care of by driver_probe, so we just have to enable |
| 11 | * clocks |
| 12 | */ |
| 13 | static int simple_pm_bus_probe(struct udevice *dev) |
| 14 | { |
| 15 | int ret; |
| 16 | struct clk_bulk *bulk = dev_get_priv(dev); |
| 17 | |
| 18 | ret = clk_get_bulk(dev, bulk); |
| 19 | if (ret) |
| 20 | return ret; |
| 21 | |
| 22 | ret = clk_enable_bulk(bulk); |
Simon Glass | 0873822 | 2021-03-25 10:26:10 +1300 | [diff] [blame] | 23 | if (ret && ret != -ENOSYS) { |
Sean Anderson | b786054 | 2020-06-24 06:41:12 -0400 | [diff] [blame] | 24 | clk_release_bulk(bulk); |
| 25 | return ret; |
| 26 | } |
| 27 | return 0; |
| 28 | } |
| 29 | |
| 30 | static int simple_pm_bus_remove(struct udevice *dev) |
| 31 | { |
| 32 | int ret; |
| 33 | struct clk_bulk *bulk = dev_get_priv(dev); |
| 34 | |
| 35 | ret = clk_release_bulk(bulk); |
Simon Glass | 0873822 | 2021-03-25 10:26:10 +1300 | [diff] [blame] | 36 | if (ret && ret != -ENOSYS) |
Sean Anderson | b786054 | 2020-06-24 06:41:12 -0400 | [diff] [blame] | 37 | return ret; |
| 38 | else |
| 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | static const struct udevice_id simple_pm_bus_ids[] = { |
| 43 | { .compatible = "simple-pm-bus" }, |
| 44 | { } |
| 45 | }; |
| 46 | |
| 47 | U_BOOT_DRIVER(simple_pm_bus_drv) = { |
| 48 | .name = "simple_pm_bus", |
| 49 | .id = UCLASS_SIMPLE_BUS, |
| 50 | .of_match = simple_pm_bus_ids, |
| 51 | .probe = simple_pm_bus_probe, |
| 52 | .remove = simple_pm_bus_remove, |
Simon Glass | 8a2b47f | 2020-12-03 16:55:17 -0700 | [diff] [blame] | 53 | .priv_auto = sizeof(struct clk_bulk), |
Sean Anderson | b786054 | 2020-06-24 06:41:12 -0400 | [diff] [blame] | 54 | .flags = DM_FLAG_PRE_RELOC, |
| 55 | }; |