Gabriel Fernandez | afdc1ae | 2025-05-27 15:27:53 +0200 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later OR BSD-3-Clause |
| 2 | /* |
| 3 | * Copyright (C) 2017, STMicroelectronics - All Rights Reserved |
| 4 | * Author(s): Patrice Chotard, <patrice.chotard@foss.st.com> for STMicroelectronics. |
| 5 | */ |
| 6 | |
| 7 | #include <dm.h> |
| 8 | #include <stm32-reset-core.h> |
| 9 | |
| 10 | /* Timeout for deassert */ |
| 11 | #define STM32_DEASSERT_TIMEOUT_US 10000 |
| 12 | |
| 13 | static const struct stm32_reset_cfg *stm32_get_reset_line(struct reset_ctl *reset_ctl) |
| 14 | { |
| 15 | struct stm32_reset_priv *priv = dev_get_priv(reset_ctl->dev); |
| 16 | struct stm32_reset_cfg *ptr_line = &priv->reset_line; |
| 17 | int bank = (reset_ctl->id / (sizeof(u32) * BITS_PER_BYTE)) * 4; |
| 18 | int offset = reset_ctl->id % (sizeof(u32) * BITS_PER_BYTE); |
| 19 | |
| 20 | ptr_line->offset = bank; |
| 21 | ptr_line->bit_idx = offset; |
| 22 | ptr_line->set_clr = true; |
| 23 | |
| 24 | return ptr_line; |
| 25 | } |
| 26 | |
| 27 | static const struct stm32_reset_data stm32_reset_data = { |
| 28 | .get_reset_line = stm32_get_reset_line, |
| 29 | .reset_us = STM32_DEASSERT_TIMEOUT_US, |
| 30 | }; |
| 31 | |
| 32 | static int stm32_reset_probe(struct udevice *dev) |
| 33 | { |
| 34 | return stm32_reset_core_probe(dev, &stm32_reset_data); |
| 35 | } |
| 36 | |
| 37 | U_BOOT_DRIVER(stm32_rcc_reset) = { |
| 38 | .name = "stm32_rcc_reset", |
| 39 | .id = UCLASS_RESET, |
| 40 | .probe = stm32_reset_probe, |
| 41 | .priv_auto = sizeof(struct stm32_reset_priv), |
| 42 | .ops = &stm32_reset_ops, |
| 43 | }; |