3 * Yuri Tikhonov, Emcraft Systems, yur@emcraft.com
6 * Kamil Lulko, <rev13@wp.pl>
8 * Copyright 2015 ATS Advanced Telematics Systems GmbH
9 * Copyright 2015 Konsulko Group, Matt Porter <mporter@konsulko.com>
11 * SPDX-License-Identifier: GPL-2.0+
14 #ifndef _MACH_STM32_H_
15 #define _MACH_STM32_H_
18 * Peripheral memory map
20 #define STM32_PERIPH_BASE 0x40000000
21 #define STM32_APB1PERIPH_BASE (STM32_PERIPH_BASE + 0x00000000)
22 #define STM32_APB2PERIPH_BASE (STM32_PERIPH_BASE + 0x00010000)
23 #define STM32_AHB1PERIPH_BASE (STM32_PERIPH_BASE + 0x00018000)
25 #define STM32_BUS_MASK 0xFFFF0000
30 struct stm32_des_regs {
39 struct stm32_rcc_regs {
40 u32 cr; /* RCC clock control */
41 u32 cfgr; /* RCC clock configuration */
42 u32 cir; /* RCC clock interrupt */
43 u32 apb2rstr; /* RCC APB2 peripheral reset */
44 u32 apb1rstr; /* RCC APB1 peripheral reset */
45 u32 ahbenr; /* RCC AHB peripheral clock enable */
46 u32 apb2enr; /* RCC APB2 peripheral clock enable */
47 u32 apb1enr; /* RCC APB1 peripheral clock enable */
48 u32 bdcr; /* RCC Backup domain control */
49 u32 csr; /* RCC clock control & status */
52 struct stm32_pwr_regs {
57 struct stm32_flash_regs {
64 u32 rsvd1; /* Reserved */
67 u32 rsvd2[8]; /* Reserved */
75 /* Per bank register set for XL devices */
76 struct stm32_flash_bank_regs {
78 u32 rsvd; /* Reserved */
85 * Registers access macros
87 #define STM32_DES_BASE (0x1ffff7e0)
88 #define STM32_DES ((struct stm32_des_regs *)STM32_DES_BASE)
90 #define STM32_RCC_BASE (STM32_AHB1PERIPH_BASE + 0x9000)
91 #define STM32_RCC ((struct stm32_rcc_regs *)STM32_RCC_BASE)
93 #define STM32_PWR_BASE (STM32_APB1PERIPH_BASE + 0x7000)
94 #define STM32_PWR ((struct stm32_pwr_regs *)STM32_PWR_BASE)
96 #define STM32_FLASH_BASE (STM32_AHB1PERIPH_BASE + 0xa000)
97 #define STM32_FLASH ((struct stm32_flash_regs *)STM32_FLASH_BASE)
99 #define STM32_FLASH_SR_BSY (1 << 0)
101 #define STM32_FLASH_CR_PG (1 << 0)
102 #define STM32_FLASH_CR_PER (1 << 1)
103 #define STM32_FLASH_CR_STRT (1 << 6)
104 #define STM32_FLASH_CR_LOCK (1 << 7)
113 int configure_clocks(void);
114 unsigned long clock_get(enum clock clck);
116 #endif /* _MACH_STM32_H_ */