Wenyou Yang | 9e5935c | 2016-07-20 17:55:12 +0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 15 | DECLARE_GLOBAL_DATA_PTR; |
| 16 | |
Wenyou Yang | 9e5935c | 2016-07-20 17:55:12 +0800 | [diff] [blame] | 17 | static const struct udevice_id at91_pmc_match[] = { |
| 18 | { .compatible = "atmel,sama5d2-pmc" }, |
| 19 | {} |
| 20 | }; |
| 21 | |
| 22 | U_BOOT_DRIVER(at91_pmc) = { |
Wenyou Yang | b892b05 | 2016-09-13 10:25:55 +0800 | [diff] [blame^] | 23 | .name = "at91-pmc", |
| 24 | .id = UCLASS_SIMPLE_BUS, |
Wenyou Yang | 9e5935c | 2016-07-20 17:55:12 +0800 | [diff] [blame] | 25 | .of_match = at91_pmc_match, |
Wenyou Yang | 9e5935c | 2016-07-20 17:55:12 +0800 | [diff] [blame] | 26 | }; |
| 27 | |
| 28 | int 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 | |
| 39 | int 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 | |
| 62 | U_BOOT_DRIVER(clk_generic) = { |
| 63 | .id = UCLASS_CLK, |
| 64 | .name = "clk", |
| 65 | }; |