blob: d9dd2c2bf67f13472442735023ec3a1934143ff4 [file] [log] [blame]
Andre Przywara4849e2e2022-10-20 23:10:24 +01001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Calxeda Highbank/Midway "system registers" bus driver
4 *
5 * There is a "clocks" subnode inside the top node, which groups all clocks,
6 * both programmable PLLs as well as fixed clocks.
7 * Simple allow the DT enumeration to look inside this node, so that we can
8 * read the fixed clock frequencies using the DM clock framework.
9 *
10 * Copyright (C) 2019 Arm Ltd.
11 */
12
13#include <common.h>
14#include <dm.h>
15#include <dm/lists.h>
16
17static int hb_sregs_scan_fdt_dev(struct udevice *dev)
18{
19 ofnode clock_node, node;
20
21 /* Search for subnode called "clocks". */
22 ofnode_for_each_subnode(clock_node, dev_ofnode(dev)) {
23 if (!ofnode_name_eq(clock_node, "clocks"))
24 continue;
25
26 /* Enumerate all nodes inside this "clocks" subnode. */
27 ofnode_for_each_subnode(node, clock_node)
28 lists_bind_fdt(dev, node, NULL, NULL, false);
29 return 0;
30 }
31
32 return -ENOENT;
33}
34
35static const struct udevice_id highbank_sreg_ids[] = {
36 { .compatible = "calxeda,hb-sregs" },
37 {}
38};
39
40U_BOOT_DRIVER(hb_sregs) = {
41 .name = "hb-sregs",
42 .id = UCLASS_SIMPLE_BUS,
43 .bind = hb_sregs_scan_fdt_dev,
44 .of_match = highbank_sreg_ids,
45};