2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2017-09-13 16:00:08 +00:00
|
|
|
/*
|
2017-10-23 07:53:58 +00:00
|
|
|
* Copyright (C) 2017, STMicroelectronics - All Rights Reserved
|
2020-12-02 17:47:30 +00:00
|
|
|
* Author(s): Patrice Chotard, <patrice.chotard@foss.st.com> for STMicroelectronics.
|
2017-09-13 16:00:08 +00:00
|
|
|
*/
|
|
|
|
|
2020-11-06 18:01:43 +00:00
|
|
|
#define LOG_CATEGORY UCLASS_NOP
|
|
|
|
|
2017-09-13 16:00:08 +00:00
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2017-09-13 16:00:08 +00:00
|
|
|
#include <misc.h>
|
2017-11-15 12:14:51 +00:00
|
|
|
#include <stm32_rcc.h>
|
|
|
|
#include <dm/device-internal.h>
|
2020-02-03 14:36:16 +00:00
|
|
|
#include <dm/device_compat.h>
|
2017-09-13 16:00:08 +00:00
|
|
|
#include <dm/lists.h>
|
|
|
|
|
2018-04-11 15:07:45 +00:00
|
|
|
struct stm32_rcc_clk stm32_rcc_clk_f42x = {
|
2017-11-15 12:14:51 +00:00
|
|
|
.drv_name = "stm32fx_rcc_clock",
|
2018-04-11 15:07:45 +00:00
|
|
|
.soc = STM32F42X,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct stm32_rcc_clk stm32_rcc_clk_f469 = {
|
|
|
|
.drv_name = "stm32fx_rcc_clock",
|
|
|
|
.soc = STM32F469,
|
2017-11-15 12:14:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct stm32_rcc_clk stm32_rcc_clk_f7 = {
|
|
|
|
.drv_name = "stm32fx_rcc_clock",
|
|
|
|
.soc = STM32F7,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct stm32_rcc_clk stm32_rcc_clk_h7 = {
|
|
|
|
.drv_name = "stm32h7_rcc_clock",
|
|
|
|
};
|
|
|
|
|
2018-07-09 13:17:20 +00:00
|
|
|
struct stm32_rcc_clk stm32_rcc_clk_mp1 = {
|
|
|
|
.drv_name = "stm32mp1_clk",
|
|
|
|
.soc = STM32MP1,
|
|
|
|
};
|
|
|
|
|
2017-09-13 16:00:08 +00:00
|
|
|
static int stm32_rcc_bind(struct udevice *dev)
|
|
|
|
{
|
|
|
|
struct udevice *child;
|
2017-11-15 12:14:51 +00:00
|
|
|
struct driver *drv;
|
|
|
|
struct stm32_rcc_clk *rcc_clk =
|
|
|
|
(struct stm32_rcc_clk *)dev_get_driver_data(dev);
|
|
|
|
int ret;
|
2017-09-13 16:00:08 +00:00
|
|
|
|
2020-11-06 18:01:43 +00:00
|
|
|
dev_dbg(dev, "RCC bind\n");
|
2017-11-15 12:14:51 +00:00
|
|
|
drv = lists_driver_lookup_name(rcc_clk->drv_name);
|
|
|
|
if (!drv) {
|
2020-11-06 18:01:43 +00:00
|
|
|
dev_err(dev, "Cannot find driver '%s'\n", rcc_clk->drv_name);
|
2017-11-15 12:14:51 +00:00
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
2020-11-06 18:01:44 +00:00
|
|
|
ret = device_bind_with_driver_data(dev, drv, dev->name,
|
2017-11-15 12:14:51 +00:00
|
|
|
rcc_clk->soc,
|
|
|
|
dev_ofnode(dev), &child);
|
|
|
|
|
2017-09-13 16:00:08 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2018-07-09 13:17:20 +00:00
|
|
|
drv = lists_driver_lookup_name("stm32_rcc_reset");
|
|
|
|
if (!drv) {
|
|
|
|
dev_err(dev, "Cannot find driver stm32_rcc_reset'\n");
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
2020-11-06 18:01:44 +00:00
|
|
|
return device_bind_with_driver_data(dev, drv, dev->name,
|
2018-07-09 13:17:20 +00:00
|
|
|
rcc_clk->soc,
|
|
|
|
dev_ofnode(dev), &child);
|
2017-09-13 16:00:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const struct udevice_id stm32_rcc_ids[] = {
|
2018-04-11 15:07:45 +00:00
|
|
|
{.compatible = "st,stm32f42xx-rcc", .data = (ulong)&stm32_rcc_clk_f42x },
|
|
|
|
{.compatible = "st,stm32f469-rcc", .data = (ulong)&stm32_rcc_clk_f469 },
|
2017-11-15 12:14:51 +00:00
|
|
|
{.compatible = "st,stm32f746-rcc", .data = (ulong)&stm32_rcc_clk_f7 },
|
|
|
|
{.compatible = "st,stm32h743-rcc", .data = (ulong)&stm32_rcc_clk_h7 },
|
2018-07-09 13:17:20 +00:00
|
|
|
{.compatible = "st,stm32mp1-rcc", .data = (ulong)&stm32_rcc_clk_mp1 },
|
2017-09-13 16:00:08 +00:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
U_BOOT_DRIVER(stm32_rcc) = {
|
|
|
|
.name = "stm32-rcc",
|
2019-08-02 11:08:08 +00:00
|
|
|
.id = UCLASS_NOP,
|
2017-09-13 16:00:08 +00:00
|
|
|
.of_match = stm32_rcc_ids,
|
|
|
|
.bind = stm32_rcc_bind,
|
|
|
|
};
|