blob: 76ff3871d0b490316a6f54f369897f782e939715 [file] [log] [blame]
Wenyou Yang9e5935c2016-07-20 17:55:12 +08001/*
2 * Copyright (C) 2016 Atmel Corporation
3 * Wenyou.Yang <wenyou.yang@atmel.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#include <common.h>
9#include <clk-uclass.h>
10#include <dm/device.h>
11#include <dm/lists.h>
12#include <dm/root.h>
13#include "pmc.h"
14
15DECLARE_GLOBAL_DATA_PTR;
16
Wenyou Yang9e5935c2016-07-20 17:55:12 +080017static const struct udevice_id at91_pmc_match[] = {
18 { .compatible = "atmel,sama5d2-pmc" },
19 {}
20};
21
22U_BOOT_DRIVER(at91_pmc) = {
Wenyou Yangb892b052016-09-13 10:25:55 +080023 .name = "at91-pmc",
24 .id = UCLASS_SIMPLE_BUS,
Wenyou Yang9e5935c2016-07-20 17:55:12 +080025 .of_match = at91_pmc_match,
Wenyou Yang9e5935c2016-07-20 17:55:12 +080026};
27
28int at91_pmc_core_probe(struct udevice *dev)
29{
30 struct pmc_platdata *plat = dev_get_platdata(dev);
31
32 dev = dev_get_parent(dev);
33
34 plat->reg_base = (struct at91_pmc *)dev_get_addr_ptr(dev);
35
36 return 0;
37}
38
39int at91_pmc_clk_node_bind(struct udevice *dev)
40{
41 const void *fdt = gd->fdt_blob;
42 int offset = dev->of_offset;
43 const char *name;
44 int ret;
45
46 for (offset = fdt_first_subnode(fdt, offset);
47 offset > 0;
48 offset = fdt_next_subnode(fdt, offset)) {
49 name = fdt_get_name(fdt, offset, NULL);
50 if (!name)
51 return -EINVAL;
52
53 ret = device_bind_driver_to_node(dev, "clk", name,
54 offset, NULL);
55 if (ret)
56 return ret;
57 }
58
59 return 0;
60}
61
62U_BOOT_DRIVER(clk_generic) = {
63 .id = UCLASS_CLK,
64 .name = "clk",
65};