2 * Copyright (C) 2016 Atmel Corporation
3 * Wenyou.Yang <wenyou.yang@atmel.com>
5 * SPDX-License-Identifier: GPL-2.0+
9 #include <clk-uclass.h>
10 #include <dm/device.h>
16 DECLARE_GLOBAL_DATA_PTR;
18 static const struct udevice_id at91_pmc_match[] = {
19 { .compatible = "atmel,sama5d2-pmc" },
23 U_BOOT_DRIVER(at91_pmc) = {
25 .id = UCLASS_SIMPLE_BUS,
26 .of_match = at91_pmc_match,
29 /*---------------------------------------------------------*/
31 int at91_pmc_core_probe(struct udevice *dev)
33 struct pmc_platdata *plat = dev_get_platdata(dev);
35 dev = dev_get_parent(dev);
37 plat->reg_base = (struct at91_pmc *)dev_get_addr_ptr(dev);
43 * at91_clk_sub_device_bind() - for the at91 clock driver
44 * Recursively bind its children as clk devices.
46 * @return: 0 on success, or negative error code on failure
48 int at91_clk_sub_device_bind(struct udevice *dev, const char *drv_name)
50 const void *fdt = gd->fdt_blob;
51 int offset = dev_of_offset(dev);
52 bool pre_reloc_only = !(gd->flags & GD_FLG_RELOC);
56 for (offset = fdt_first_subnode(fdt, offset);
58 offset = fdt_next_subnode(fdt, offset)) {
60 !dm_fdt_pre_reloc(fdt, offset))
63 * If this node has "compatible" property, this is not
64 * a clock sub-node, but a normal device. skip.
66 fdt_get_property(fdt, offset, "compatible", &ret);
70 if (ret != -FDT_ERR_NOTFOUND)
73 name = fdt_get_name(fdt, offset, NULL);
76 ret = device_bind_driver_to_node(dev, drv_name, name,
85 int at91_clk_of_xlate(struct clk *clk, struct fdtdec_phandle_args *args)
89 if (args->args_count) {
90 debug("Invalid args_count: %d\n", args->args_count);
94 periph = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(clk->dev), "reg",
104 int at91_clk_probe(struct udevice *dev)
106 struct udevice *dev_periph_container, *dev_pmc;
107 struct pmc_platdata *plat = dev_get_platdata(dev);
109 dev_periph_container = dev_get_parent(dev);
110 dev_pmc = dev_get_parent(dev_periph_container);
112 plat->reg_base = (struct at91_pmc *)dev_get_addr_ptr(dev_pmc);