1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2016 Atmel Corporation
4 * Wenyou.Yang <wenyou.yang@atmel.com>
8 #include <clk-uclass.h>
14 DECLARE_GLOBAL_DATA_PTR;
16 static const struct udevice_id at91_pmc_match[] = {
17 { .compatible = "atmel,at91rm9200-pmc" },
18 { .compatible = "atmel,at91sam9260-pmc" },
19 { .compatible = "atmel,at91sam9g45-pmc" },
20 { .compatible = "atmel,at91sam9n12-pmc" },
21 { .compatible = "atmel,at91sam9x5-pmc" },
22 { .compatible = "atmel,sama5d3-pmc" },
23 { .compatible = "atmel,sama5d2-pmc" },
27 U_BOOT_DRIVER(at91_pmc) = {
29 .id = UCLASS_SIMPLE_BUS,
30 .of_match = at91_pmc_match,
33 /*---------------------------------------------------------*/
35 int at91_pmc_core_probe(struct udevice *dev)
37 struct pmc_platdata *plat = dev_get_platdata(dev);
39 dev = dev_get_parent(dev);
41 plat->reg_base = (struct at91_pmc *)devfdt_get_addr_ptr(dev);
47 * at91_clk_sub_device_bind() - for the at91 clock driver
48 * Recursively bind its children as clk devices.
50 * @return: 0 on success, or negative error code on failure
52 int at91_clk_sub_device_bind(struct udevice *dev, const char *drv_name)
54 const void *fdt = gd->fdt_blob;
55 int offset = dev_of_offset(dev);
56 bool pre_reloc_only = !(gd->flags & GD_FLG_RELOC);
60 for (offset = fdt_first_subnode(fdt, offset);
62 offset = fdt_next_subnode(fdt, offset)) {
64 !dm_fdt_pre_reloc(fdt, offset))
67 * If this node has "compatible" property, this is not
68 * a clock sub-node, but a normal device. skip.
70 fdt_get_property(fdt, offset, "compatible", &ret);
74 if (ret != -FDT_ERR_NOTFOUND)
77 name = fdt_get_name(fdt, offset, NULL);
80 ret = device_bind_driver_to_node(dev, drv_name, name,
81 offset_to_ofnode(offset), NULL);
89 int at91_clk_of_xlate(struct clk *clk, struct ofnode_phandle_args *args)
93 if (args->args_count) {
94 debug("Invalid args_count: %d\n", args->args_count);
98 periph = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(clk->dev), "reg",
108 int at91_clk_probe(struct udevice *dev)
110 struct udevice *dev_periph_container, *dev_pmc;
111 struct pmc_platdata *plat = dev_get_platdata(dev);
113 dev_periph_container = dev_get_parent(dev);
114 dev_pmc = dev_get_parent(dev_periph_container);
116 plat->reg_base = (struct at91_pmc *)devfdt_get_addr_ptr(dev_pmc);