Andre Przywara | a32910b | 2022-10-20 23:10:24 +0100 | [diff] [blame] | 1 | // 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 | |
Andre Przywara | a32910b | 2022-10-20 23:10:24 +0100 | [diff] [blame] | 13 | #include <dm.h> |
| 14 | #include <dm/lists.h> |
| 15 | |
| 16 | static int hb_sregs_scan_fdt_dev(struct udevice *dev) |
| 17 | { |
| 18 | ofnode clock_node, node; |
| 19 | |
| 20 | /* Search for subnode called "clocks". */ |
| 21 | ofnode_for_each_subnode(clock_node, dev_ofnode(dev)) { |
| 22 | if (!ofnode_name_eq(clock_node, "clocks")) |
| 23 | continue; |
| 24 | |
| 25 | /* Enumerate all nodes inside this "clocks" subnode. */ |
| 26 | ofnode_for_each_subnode(node, clock_node) |
| 27 | lists_bind_fdt(dev, node, NULL, NULL, false); |
| 28 | return 0; |
| 29 | } |
| 30 | |
| 31 | return -ENOENT; |
| 32 | } |
| 33 | |
| 34 | static const struct udevice_id highbank_sreg_ids[] = { |
| 35 | { .compatible = "calxeda,hb-sregs" }, |
| 36 | {} |
| 37 | }; |
| 38 | |
| 39 | U_BOOT_DRIVER(hb_sregs) = { |
| 40 | .name = "hb-sregs", |
| 41 | .id = UCLASS_SIMPLE_BUS, |
| 42 | .bind = hb_sregs_scan_fdt_dev, |
| 43 | .of_match = highbank_sreg_ids, |
| 44 | }; |