File tree Expand file tree Collapse file tree 4 files changed +41
-20
lines changed Expand file tree Collapse file tree 4 files changed +41
-20
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,22 @@ __STATIC_INLINE kstatus_t rcc_enable_hse(void)
111111 return iopoll32_until_set(RCC_BASE_ADDR + RCC_CR_REG, RCC_CR_HSERDY, HSE_STARTUP_TIMEOUT);
112112}
113113
114+ #if defined(HAS_HSI48_CLOCK)
115+ __STATIC_INLINE kstatus_t rcc_enable_hsi48(void)
116+ {
117+ kstatus_t status = K_STATUS_OKAY;
118+ uint32_t reg;
119+
120+ reg = ioread32(RCC_BASE_ADDR + RCC_HSI48_REG);
121+ reg |= RCC_HSI48ON;
122+ iowrite32(RCC_BASE_ADDR + RCC_HSI48_REG, reg);
123+
124+ return iopoll32_until_set(RCC_BASE_ADDR + RCC_HSI48_REG, RCC_HSI48RDY, 500);
125+ }
126+ #endif /* RCC_CR_HSI48ON */
127+
128+
129+
114130/**
115131 * @brief Convert AHB divisor (power of 2) to register value
116132 *
@@ -222,6 +238,13 @@ __STATIC_INLINE kstatus_t rcc_init_system_clk(void)
222238 }
223239 {%- endif %}
224240
241+ {%- if dts.clocks.clk_hsi48 is defined and dts.clocks.clk_hsi48.status == "okay" %}
242+ status = rcc_enable_hsi48();
243+ if (unlikely(status != K_STATUS_OKAY)) {
244+ goto err;
245+ }
246+ {%- endif %}
247+
225248 {%- if dts.clocks.clk_hse.status == "okay" %}
226249 status = rcc_enable_hse();
227250 if (unlikely(status != K_STATUS_OKAY)) {
Original file line number Diff line number Diff line change 7171 */
7272#define RCC_CIR_REG RCC_CICR_REG
7373
74+ /*
75+ * For stm32l496/4a6 subfamily, HSI48 control is held by CRRCR register
76+ */
77+ #if defined(CONFIG_SOC_SUBFAMILY_STM32L49_Ax )
78+ #define HAS_HSI48_CLOCK
79+ #define RCC_HSI48_REG RCC_CRRCR_REG
80+ #define RCC_HSI48ON RCC_CRRCR_HSI48ON
81+ #define RCC_HSI48RDY RCC_CRRCR_HSI48RDY
82+ #endif
83+
7484{#- There is only one main PLL for stm32f4xx families #}
7585{%- set pll = dts .get_compatible ("st,stm32l4xx-pll" )[0 ] %}
7686{%- if pll is not none and pll .status == "okay "%}
Original file line number Diff line number Diff line change @@ -161,14 +161,6 @@ kstatus_t rcc_enable_pll(void)
161161 stm32u5_enable_pll_p_output (PLL_ID_3 );
162162 stm32u5_enable_pll_r_output (PLL_ID_3 );
163163
164- /*
165- * Fixme:
166- * Ugly hack, force HSI48 ON, this is used by RNG as clock source.
167- * Remove this while outpost/sentry-kernel/issues/253 outpost/sentry-kernel/issues/254
168- * are fixed/closed.
169- */
170- rcc_enable_hsi48 ();
171-
172164 return K_STATUS_OKAY ;
173165}
174166
Original file line number Diff line number Diff line change 4949#define RCC_APB2_BUS_FREQUENCY_MAX RCC_SYSCLOCK_FREQUENCY_MAX
5050#define RCC_APB3_BUS_FREQUENCY_MAX RCC_SYSCLOCK_FREQUENCY_MAX
5151
52+ /*
53+ * For stm32u5 family, HSI48 control is held by CR register
54+ */
55+ #define HAS_HSI48_CLOCK
56+ #define RCC_HSI48_REG RCC_CR_REG
57+ #define RCC_HSI48ON RCC_CR_HSI48ON
58+ #define RCC_HSI48RDY RCC_CR_HSI48RDY
59+
5260typedef enum stm32u5_pll_id {
5361 PLL_ID_1 = 0 ,
5462 PLL_ID_2 = 1 ,
@@ -104,18 +112,6 @@ static inline void __stm32_rcc_set_peripheral_bus_div(
104112 iowrite32 (RCC_BASE_ADDR + RCC_CFGR3_REG , cfgr3 .raw );
105113}
106114
107- static inline kstatus_t rcc_enable_hsi48 (void )
108- {
109- kstatus_t status = K_STATUS_OKAY ;
110- uint32_t rcc_cr ;
111-
112- rcc_cr = ioread32 (RCC_BASE_ADDR + RCC_CR_REG );
113- rcc_cr |= RCC_CR_HSI48ON ;
114- iowrite32 (RCC_BASE_ADDR + RCC_CR_REG , rcc_cr );
115-
116- return iopoll32_until_set (RCC_BASE_ADDR + RCC_CR_REG , RCC_CR_HSI48RDY , 500 );
117- }
118-
119115kstatus_t rcc_select_system_clock (void );
120116
121117kstatus_t rcc_enable_pll (void );
You can’t perform that action at this time.
0 commit comments