1 /* 2 * Copyright (C) 2017, STMicroelectronics - All Rights Reserved 3 * Author(s): Patrice Chotard, <patrice.chotard@st.com> for STMicroelectronics. 4 * 5 * SPDX-License-Identifier: GPL-2.0+ 6 */ 7 8 #include <common.h> 9 #include <dm.h> 10 #include <misc.h> 11 #include <stm32_rcc.h> 12 #include <dm/device-internal.h> 13 #include <dm/lists.h> 14 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 29 static int stm32_rcc_bind(struct udevice *dev) 30 { 31 struct udevice *child; 32 struct driver *drv; 33 struct stm32_rcc_clk *rcc_clk = 34 (struct stm32_rcc_clk *)dev_get_driver_data(dev); 35 int ret; 36 37 debug("%s(dev=%p)\n", __func__, dev); 38 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 49 if (ret) 50 return ret; 51 52 #ifdef CONFIG_SPL_BUILD 53 return 0; 54 #else 55 return device_bind_driver_to_node(dev, "stm32_rcc_reset", 56 "stm32_rcc_reset", 57 dev_ofnode(dev), &child); 58 #endif 59 } 60 61 static const struct misc_ops stm32_rcc_ops = { 62 }; 63 64 static const struct udevice_id stm32_rcc_ids[] = { 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 }, 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 }; 78