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>
15 DECLARE_GLOBAL_DATA_PTR
;
17 static const struct udevice_id at91_pmc_match
[] = {
18 { .compatible
= "atmel,sama5d2-pmc" },
22 U_BOOT_DRIVER(at91_pmc
) = {
24 .id
= UCLASS_SIMPLE_BUS
,
25 .of_match
= at91_pmc_match
,
28 /*---------------------------------------------------------*/
30 int at91_pmc_core_probe(struct udevice
*dev
)
32 struct pmc_platdata
*plat
= dev_get_platdata(dev
);
34 dev
= dev_get_parent(dev
);
36 plat
->reg_base
= (struct at91_pmc
*)dev_get_addr_ptr(dev
);
42 * at91_clk_sub_device_bind() - for the at91 clock driver
43 * Recursively bind its children as clk devices.
45 * @return: 0 on success, or negative error code on failure
47 int at91_clk_sub_device_bind(struct udevice
*dev
, const char *drv_name
)
49 const void *fdt
= gd
->fdt_blob
;
50 int offset
= dev
->of_offset
;
51 bool pre_reloc_only
= !(gd
->flags
& GD_FLG_RELOC
);
55 for (offset
= fdt_first_subnode(fdt
, offset
);
57 offset
= fdt_next_subnode(fdt
, offset
)) {
59 !fdt_getprop(fdt
, offset
, "u-boot,dm-pre-reloc", NULL
))
62 * If this node has "compatible" property, this is not
63 * a clock sub-node, but a normal device. skip.
65 fdt_get_property(fdt
, offset
, "compatible", &ret
);
69 if (ret
!= -FDT_ERR_NOTFOUND
)
72 name
= fdt_get_name(fdt
, offset
, NULL
);
75 ret
= device_bind_driver_to_node(dev
, drv_name
, name
,
84 int at91_clk_of_xlate(struct clk
*clk
, struct fdtdec_phandle_args
*args
)
88 if (args
->args_count
) {
89 debug("Invalid args_count: %d\n", args
->args_count
);
93 periph
= fdtdec_get_uint(gd
->fdt_blob
, clk
->dev
->of_offset
, "reg", -1);
102 int at91_clk_probe(struct udevice
*dev
)
104 struct udevice
*dev_periph_container
, *dev_pmc
;
105 struct pmc_platdata
*plat
= dev_get_platdata(dev
);
107 dev_periph_container
= dev_get_parent(dev
);
108 dev_pmc
= dev_get_parent(dev_periph_container
);
110 plat
->reg_base
= (struct at91_pmc
*)dev_get_addr_ptr(dev_pmc
);