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,at91rm9200-pmc" },
20 { .compatible
= "atmel,at91sam9260-pmc" },
21 { .compatible
= "atmel,at91sam9g45-pmc" },
22 { .compatible
= "atmel,at91sam9n12-pmc" },
23 { .compatible
= "atmel,at91sam9x5-pmc" },
24 { .compatible
= "atmel,sama5d3-pmc" },
25 { .compatible
= "atmel,sama5d2-pmc" },
29 U_BOOT_DRIVER(at91_pmc
) = {
31 .id
= UCLASS_SIMPLE_BUS
,
32 .of_match
= at91_pmc_match
,
35 /*---------------------------------------------------------*/
37 int at91_pmc_core_probe(struct udevice
*dev
)
39 struct pmc_platdata
*plat
= dev_get_platdata(dev
);
41 dev
= dev_get_parent(dev
);
43 plat
->reg_base
= (struct at91_pmc
*)dev_get_addr_ptr(dev
);
49 * at91_clk_sub_device_bind() - for the at91 clock driver
50 * Recursively bind its children as clk devices.
52 * @return: 0 on success, or negative error code on failure
54 int at91_clk_sub_device_bind(struct udevice
*dev
, const char *drv_name
)
56 const void *fdt
= gd
->fdt_blob
;
57 int offset
= dev_of_offset(dev
);
58 bool pre_reloc_only
= !(gd
->flags
& GD_FLG_RELOC
);
62 for (offset
= fdt_first_subnode(fdt
, offset
);
64 offset
= fdt_next_subnode(fdt
, offset
)) {
66 !dm_fdt_pre_reloc(fdt
, offset
))
69 * If this node has "compatible" property, this is not
70 * a clock sub-node, but a normal device. skip.
72 fdt_get_property(fdt
, offset
, "compatible", &ret
);
76 if (ret
!= -FDT_ERR_NOTFOUND
)
79 name
= fdt_get_name(fdt
, offset
, NULL
);
82 ret
= device_bind_driver_to_node(dev
, drv_name
, name
,
91 int at91_clk_of_xlate(struct clk
*clk
, struct fdtdec_phandle_args
*args
)
95 if (args
->args_count
) {
96 debug("Invalid args_count: %d\n", args
->args_count
);
100 periph
= fdtdec_get_uint(gd
->fdt_blob
, dev_of_offset(clk
->dev
), "reg",
110 int at91_clk_probe(struct udevice
*dev
)
112 struct udevice
*dev_periph_container
, *dev_pmc
;
113 struct pmc_platdata
*plat
= dev_get_platdata(dev
);
115 dev_periph_container
= dev_get_parent(dev
);
116 dev_pmc
= dev_get_parent(dev_periph_container
);
118 plat
->reg_base
= (struct at91_pmc
*)dev_get_addr_ptr(dev_pmc
);