]>
Commit | Line | Data |
---|---|---|
1 | // SPDX-License-Identifier: GPL-2.0+ | |
2 | /* | |
3 | * Copyright (C) 2017, STMicroelectronics - All Rights Reserved | |
4 | * Author(s): Patrice Chotard, <patrice.chotard@foss.st.com> for STMicroelectronics. | |
5 | */ | |
6 | ||
7 | #define LOG_CATEGORY UCLASS_NOP | |
8 | ||
9 | #include <dm.h> | |
10 | #include <log.h> | |
11 | #include <misc.h> | |
12 | #include <stm32_rcc.h> | |
13 | #include <dm/device-internal.h> | |
14 | #include <dm/device_compat.h> | |
15 | #include <dm/lists.h> | |
16 | ||
17 | struct stm32_rcc_clk stm32_rcc_clk_f42x = { | |
18 | .drv_name = "stm32fx_rcc_clock", | |
19 | .soc = STM32F42X, | |
20 | }; | |
21 | ||
22 | struct stm32_rcc_clk stm32_rcc_clk_f469 = { | |
23 | .drv_name = "stm32fx_rcc_clock", | |
24 | .soc = STM32F469, | |
25 | }; | |
26 | ||
27 | struct stm32_rcc_clk stm32_rcc_clk_f7 = { | |
28 | .drv_name = "stm32fx_rcc_clock", | |
29 | .soc = STM32F7, | |
30 | }; | |
31 | ||
32 | struct stm32_rcc_clk stm32_rcc_clk_h7 = { | |
33 | .drv_name = "stm32h7_rcc_clock", | |
34 | }; | |
35 | ||
36 | struct stm32_rcc_clk stm32_rcc_clk_mp1 = { | |
37 | .drv_name = "stm32mp1_clk", | |
38 | .soc = STM32MP1, | |
39 | }; | |
40 | ||
41 | struct stm32_rcc_clk stm32_rcc_clk_mp13 = { | |
42 | .drv_name = "stm32mp13_clk", | |
43 | .soc = STM32MP1, | |
44 | }; | |
45 | ||
46 | static int stm32_rcc_bind(struct udevice *dev) | |
47 | { | |
48 | struct udevice *child; | |
49 | struct driver *drv; | |
50 | struct stm32_rcc_clk *rcc_clk = | |
51 | (struct stm32_rcc_clk *)dev_get_driver_data(dev); | |
52 | int ret; | |
53 | ||
54 | dev_dbg(dev, "RCC bind\n"); | |
55 | drv = lists_driver_lookup_name(rcc_clk->drv_name); | |
56 | if (!drv) { | |
57 | dev_err(dev, "Cannot find driver '%s'\n", rcc_clk->drv_name); | |
58 | return -ENOENT; | |
59 | } | |
60 | ||
61 | ret = device_bind_with_driver_data(dev, drv, dev->name, | |
62 | rcc_clk->soc, | |
63 | dev_ofnode(dev), &child); | |
64 | ||
65 | if (ret) | |
66 | return ret; | |
67 | ||
68 | drv = lists_driver_lookup_name("stm32_rcc_reset"); | |
69 | if (!drv) { | |
70 | dev_err(dev, "Cannot find driver stm32_rcc_reset'\n"); | |
71 | return -ENOENT; | |
72 | } | |
73 | ||
74 | return device_bind_with_driver_data(dev, drv, dev->name, | |
75 | rcc_clk->soc, | |
76 | dev_ofnode(dev), &child); | |
77 | } | |
78 | ||
79 | static const struct udevice_id stm32_rcc_ids[] = { | |
80 | {.compatible = "st,stm32f42xx-rcc", .data = (ulong)&stm32_rcc_clk_f42x }, | |
81 | {.compatible = "st,stm32f469-rcc", .data = (ulong)&stm32_rcc_clk_f469 }, | |
82 | {.compatible = "st,stm32f746-rcc", .data = (ulong)&stm32_rcc_clk_f7 }, | |
83 | {.compatible = "st,stm32h743-rcc", .data = (ulong)&stm32_rcc_clk_h7 }, | |
84 | {.compatible = "st,stm32mp1-rcc", .data = (ulong)&stm32_rcc_clk_mp1 }, | |
85 | {.compatible = "st,stm32mp1-rcc-secure", .data = (ulong)&stm32_rcc_clk_mp1 }, | |
86 | {.compatible = "st,stm32mp13-rcc", .data = (ulong)&stm32_rcc_clk_mp13 }, | |
87 | { } | |
88 | }; | |
89 | ||
90 | U_BOOT_DRIVER(stm32_rcc) = { | |
91 | .name = "stm32-rcc", | |
92 | .id = UCLASS_NOP, | |
93 | .of_match = stm32_rcc_ids, | |
94 | .bind = stm32_rcc_bind, | |
95 | }; |