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