1 /* SPDX-License-Identifier: BSD-3-Clause */ 2 /* 3 * Copyright (c) 2018-2019, STMicroelectronics 4 */ 5 6 #ifndef __STM32_UTIL_H__ 7 #define __STM32_UTIL_H__ 8 9 #include <stdint.h> 10 11 /* Backup registers and RAM utils */ 12 uintptr_t stm32mp_bkpreg(unsigned int idx); 13 14 /* Platform util for the GIC */ 15 uintptr_t get_gicc_base(void); 16 uintptr_t get_gicd_base(void); 17 18 /* 19 * Platform util functions for the GPIO driver 20 * @bank: Target GPIO bank ID as per DT bindings 21 * 22 * Platform shall implement these functions to provide to stm32_gpio 23 * driver the resource reference for a target GPIO bank. That are 24 * memory mapped interface base address, interface offset (see below) 25 * and clock identifier. 26 * 27 * stm32_get_gpio_bank_offset() returns a bank offset that is used to 28 * check DT configuration matches platform implementation of the banks 29 * description. 30 */ 31 vaddr_t stm32_get_gpio_bank_base(unsigned int bank); 32 unsigned int stm32_get_gpio_bank_offset(unsigned int bank); 33 unsigned int stm32_get_gpio_bank_clock(unsigned int bank); 34 35 /* Power management service */ 36 #ifdef CFG_PSCI_ARM32 37 void stm32mp_register_online_cpu(void); 38 #else 39 static inline void stm32mp_register_online_cpu(void) 40 { 41 } 42 #endif 43 44 /* 45 * Generic spinlock function that bypass spinlock if MMU is disabled or 46 * lock is NULL. 47 */ 48 uint32_t may_spin_lock(unsigned int *lock); 49 void may_spin_unlock(unsigned int *lock, uint32_t exceptions); 50 51 /* 52 * Util for clock gating and to get clock rate for stm32 and platform drivers 53 * @id: Target clock ID, ID used in clock DT bindings 54 */ 55 void stm32_clock_enable(unsigned long id); 56 void stm32_clock_disable(unsigned long id); 57 unsigned long stm32_clock_get_rate(unsigned long id); 58 bool stm32_clock_is_enabled(unsigned long id); 59 60 /* 61 * Util for reset signal assertion/desassertion for stm32 and platform drivers 62 * @id: Target peripheral ID, ID used in reset DT bindings 63 */ 64 void stm32_reset_assert(unsigned int id); 65 void stm32_reset_deassert(unsigned int id); 66 67 #endif /*__STM32_UTIL_H__*/ 68