mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-08-30 22:08:52 +09:00
![Simon Glass](/assets/img/avatar_default.png)
This construct is quite long-winded. In earlier days it made some sense since auto-allocation was a strange concept. But with driver model now used pretty universally, we can shorten this to 'auto'. This reduces verbosity and makes it easier to read. Coincidentally it also ensures that every declaration is on one line, thus making dtoc's job easier. Signed-off-by: Simon Glass <sjg@chromium.org>
57 lines
1.1 KiB
C
57 lines
1.1 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright (C) 2020 Sean Anderson <seanga2@gmail.com>
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <clk.h>
|
|
#include <dm.h>
|
|
|
|
/*
|
|
* Power domains are taken care of by driver_probe, so we just have to enable
|
|
* clocks
|
|
*/
|
|
static int simple_pm_bus_probe(struct udevice *dev)
|
|
{
|
|
int ret;
|
|
struct clk_bulk *bulk = dev_get_priv(dev);
|
|
|
|
ret = clk_get_bulk(dev, bulk);
|
|
if (ret)
|
|
return ret;
|
|
|
|
ret = clk_enable_bulk(bulk);
|
|
if (ret && ret != -ENOSYS && ret != -ENOTSUPP) {
|
|
clk_release_bulk(bulk);
|
|
return ret;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int simple_pm_bus_remove(struct udevice *dev)
|
|
{
|
|
int ret;
|
|
struct clk_bulk *bulk = dev_get_priv(dev);
|
|
|
|
ret = clk_release_bulk(bulk);
|
|
if (ret && ret != -ENOSYS && ret != -ENOTSUPP)
|
|
return ret;
|
|
else
|
|
return 0;
|
|
}
|
|
|
|
static const struct udevice_id simple_pm_bus_ids[] = {
|
|
{ .compatible = "simple-pm-bus" },
|
|
{ }
|
|
};
|
|
|
|
U_BOOT_DRIVER(simple_pm_bus_drv) = {
|
|
.name = "simple_pm_bus",
|
|
.id = UCLASS_SIMPLE_BUS,
|
|
.of_match = simple_pm_bus_ids,
|
|
.probe = simple_pm_bus_probe,
|
|
.remove = simple_pm_bus_remove,
|
|
.priv_auto = sizeof(struct clk_bulk),
|
|
.flags = DM_FLAG_PRE_RELOC,
|
|
};
|