]>
Commit | Line | Data |
---|---|---|
4e280b91 | 1 | /* |
3bc599c9 PC |
2 | * Copyright (C) 2017, STMicroelectronics - All Rights Reserved |
3 | * Author(s): Patrice Chotard, <patrice.chotard@st.com> for STMicroelectronics. | |
4e280b91 CK |
4 | * |
5 | * SPDX-License-Identifier: GPL-2.0+ | |
6 | */ | |
7 | ||
8 | #include <common.h> | |
9 | #include <dm.h> | |
10 | #include <misc.h> | |
928954fe PC |
11 | #include <stm32_rcc.h> |
12 | #include <dm/device-internal.h> | |
4e280b91 CK |
13 | #include <dm/lists.h> |
14 | ||
928954fe PC |
15 | struct stm32_rcc_clk stm32_rcc_clk_f4 = { |
16 | .drv_name = "stm32fx_rcc_clock", | |
17 | .soc = STM32F4, | |
18 | }; | |
19 | ||
20 | struct stm32_rcc_clk stm32_rcc_clk_f7 = { | |
21 | .drv_name = "stm32fx_rcc_clock", | |
22 | .soc = STM32F7, | |
23 | }; | |
24 | ||
25 | struct stm32_rcc_clk stm32_rcc_clk_h7 = { | |
26 | .drv_name = "stm32h7_rcc_clock", | |
27 | }; | |
28 | ||
4e280b91 CK |
29 | static int stm32_rcc_bind(struct udevice *dev) |
30 | { | |
4e280b91 | 31 | struct udevice *child; |
928954fe PC |
32 | struct driver *drv; |
33 | struct stm32_rcc_clk *rcc_clk = | |
34 | (struct stm32_rcc_clk *)dev_get_driver_data(dev); | |
35 | int ret; | |
4e280b91 CK |
36 | |
37 | debug("%s(dev=%p)\n", __func__, dev); | |
38 | ||
928954fe PC |
39 | drv = lists_driver_lookup_name(rcc_clk->drv_name); |
40 | if (!drv) { | |
41 | debug("Cannot find driver '%s'\n", rcc_clk->drv_name); | |
42 | return -ENOENT; | |
43 | } | |
44 | ||
45 | ret = device_bind_with_driver_data(dev, drv, rcc_clk->drv_name, | |
46 | rcc_clk->soc, | |
47 | dev_ofnode(dev), &child); | |
48 | ||
4e280b91 CK |
49 | if (ret) |
50 | return ret; | |
51 | ||
928954fe PC |
52 | #ifdef CONFIG_SPL_BUILD |
53 | return 0; | |
54 | #else | |
4e280b91 CK |
55 | return device_bind_driver_to_node(dev, "stm32_rcc_reset", |
56 | "stm32_rcc_reset", | |
57 | dev_ofnode(dev), &child); | |
928954fe | 58 | #endif |
4e280b91 CK |
59 | } |
60 | ||
61 | static const struct misc_ops stm32_rcc_ops = { | |
62 | }; | |
63 | ||
64 | static const struct udevice_id stm32_rcc_ids[] = { | |
928954fe PC |
65 | {.compatible = "st,stm32f42xx-rcc", .data = (ulong)&stm32_rcc_clk_f4 }, |
66 | {.compatible = "st,stm32f746-rcc", .data = (ulong)&stm32_rcc_clk_f7 }, | |
67 | {.compatible = "st,stm32h743-rcc", .data = (ulong)&stm32_rcc_clk_h7 }, | |
4e280b91 CK |
68 | { } |
69 | }; | |
70 | ||
71 | U_BOOT_DRIVER(stm32_rcc) = { | |
72 | .name = "stm32-rcc", | |
73 | .id = UCLASS_MISC, | |
74 | .of_match = stm32_rcc_ids, | |
75 | .bind = stm32_rcc_bind, | |
76 | .ops = &stm32_rcc_ops, | |
77 | }; |