blob: 47b459b75d1ff7b90cc71253a26a0d606e96fd96 [file] [log] [blame]
Tom Rini8b0c8a12018-05-06 18:27:01 -04001/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
Patrick Delaunay85b53972018-03-12 10:46:10 +01002/*
3 * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
Patrick Delaunay85b53972018-03-12 10:46:10 +01004 */
5
6#ifndef _MACH_STM32_H_
7#define _MACH_STM32_H_
8
Tom Rini34d4a822023-11-13 09:07:23 -05009#include <linux/sizes.h>
Simon Glass4dcacfc2020-05-10 11:40:13 -060010#ifndef __ASSEMBLY__
11#include <linux/bitops.h>
Patrice Chotardd29531c2023-10-27 16:43:04 +020012
13enum boot_device {
14 BOOT_FLASH_SD = 0x10,
15 BOOT_FLASH_SD_1 = 0x11,
16 BOOT_FLASH_SD_2 = 0x12,
17 BOOT_FLASH_SD_3 = 0x13,
18
19 BOOT_FLASH_EMMC = 0x20,
20 BOOT_FLASH_EMMC_1 = 0x21,
21 BOOT_FLASH_EMMC_2 = 0x22,
22 BOOT_FLASH_EMMC_3 = 0x23,
23
24 BOOT_FLASH_NAND = 0x30,
25 BOOT_FLASH_NAND_FMC = 0x31,
26
27 BOOT_FLASH_NOR = 0x40,
28 BOOT_FLASH_NOR_QSPI = 0x41,
29
30 BOOT_SERIAL_UART = 0x50,
31 BOOT_SERIAL_UART_1 = 0x51,
32 BOOT_SERIAL_UART_2 = 0x52,
33 BOOT_SERIAL_UART_3 = 0x53,
34 BOOT_SERIAL_UART_4 = 0x54,
35 BOOT_SERIAL_UART_5 = 0x55,
36 BOOT_SERIAL_UART_6 = 0x56,
37 BOOT_SERIAL_UART_7 = 0x57,
38 BOOT_SERIAL_UART_8 = 0x58,
39
40 BOOT_SERIAL_USB = 0x60,
41 BOOT_SERIAL_USB_OTG = 0x62,
42
43 BOOT_FLASH_SPINAND = 0x70,
44 BOOT_FLASH_SPINAND_1 = 0x71,
Patrick Delaunay7fcceb62022-05-30 19:20:45 +020045
46 BOOT_FLASH_HYPERFLASH = 0x80,
47 BOOT_FLASH_HYPERFLASH_1 = 0x81
Patrice Chotardd29531c2023-10-27 16:43:04 +020048};
49
50#define TAMP_BOOT_MODE_MASK GENMASK(15, 8)
51#define TAMP_BOOT_MODE_SHIFT 8
Tom Riniee20d662023-11-20 09:19:50 -050052#define TAMP_BOOT_AUTH_MASK GENMASK(23, 16)
53#define TAMP_BOOT_AUTH_SHIFT 16
Patrice Chotardd29531c2023-10-27 16:43:04 +020054#define TAMP_BOOT_DEVICE_MASK GENMASK(7, 4)
55#define TAMP_BOOT_INSTANCE_MASK GENMASK(3, 0)
Tom Riniee20d662023-11-20 09:19:50 -050056#define TAMP_BOOT_AUTH_ST_MASK GENMASK(7, 4)
57#define TAMP_BOOT_PARTITION_MASK GENMASK(3, 0)
Patrice Chotardd29531c2023-10-27 16:43:04 +020058#define TAMP_BOOT_FORCED_MASK GENMASK(7, 0)
Patrice Chotardd29531c2023-10-27 16:43:04 +020059
60enum forced_boot_mode {
61 BOOT_NORMAL = 0x00,
62 BOOT_FASTBOOT = 0x01,
63 BOOT_RECOVERY = 0x02,
64 BOOT_STM32PROG = 0x03,
65 BOOT_UMS_MMC0 = 0x10,
66 BOOT_UMS_MMC1 = 0x11,
67 BOOT_UMS_MMC2 = 0x12,
68};
69
Simon Glass4dcacfc2020-05-10 11:40:13 -060070#endif
71
Patrick Delaunay85b53972018-03-12 10:46:10 +010072/*
73 * Peripheral memory map
74 * only address used before device tree parsing
75 */
Patrice Chotardd29531c2023-10-27 16:43:04 +020076
Patrick Delaunay4c6fcbc2024-01-15 15:05:57 +010077#if defined(CONFIG_STM32MP15X) || defined(CONFIG_STM32MP13X)
Patrick Delaunay85b53972018-03-12 10:46:10 +010078#define STM32_RCC_BASE 0x50000000
79#define STM32_PWR_BASE 0x50001000
Marek Vasut83ec9582022-02-25 02:15:59 +010080#define STM32_SYSCFG_BASE 0x50020000
Patrick Delaunay4c6fcbc2024-01-15 15:05:57 +010081#ifdef CONFIG_STM32MP15X
Patrick Delaunay85b53972018-03-12 10:46:10 +010082#define STM32_DBGMCU_BASE 0x50081000
Patrick Delaunay123687c2022-05-20 18:24:46 +020083#endif
Marek Vasut93865c62020-03-26 16:57:26 +010084#define STM32_FMC2_BASE 0x58002000
Marek Vasutc49678e2023-05-11 21:55:45 +020085#define STM32_IWDG2_BASE 0x5A002000
Marek Vasut83ec9582022-02-25 02:15:59 +010086#define STM32_DDRCTRL_BASE 0x5A003000
87#define STM32_DDRPHYC_BASE 0x5A004000
Marek Vasutc49678e2023-05-11 21:55:45 +020088#define STM32_IWDG1_BASE 0x5C003000
Patrick Delaunay85b53972018-03-12 10:46:10 +010089#define STM32_TZC_BASE 0x5C006000
90#define STM32_ETZPC_BASE 0x5C007000
Patrick Delaunay82b88ef2019-07-05 17:20:11 +020091#define STM32_STGEN_BASE 0x5C008000
Patrick Delaunay85b53972018-03-12 10:46:10 +010092#define STM32_TAMP_BASE 0x5C00A000
93
Patrick Delaunay4c6fcbc2024-01-15 15:05:57 +010094#ifdef CONFIG_STM32MP15X
Patrick Delaunay82168e82018-05-17 14:50:46 +020095#define STM32_USART1_BASE 0x5C000000
96#define STM32_USART2_BASE 0x4000E000
Patrick Delaunay123687c2022-05-20 18:24:46 +020097#endif
Patrick Delaunay990e0572024-01-15 15:05:56 +010098#ifdef CONFIG_STM32MP13X
Patrick Delaunay123687c2022-05-20 18:24:46 +020099#define STM32_USART1_BASE 0x4c000000
100#define STM32_USART2_BASE 0x4c001000
101#endif
Patrick Delaunay82168e82018-05-17 14:50:46 +0200102#define STM32_USART3_BASE 0x4000F000
103#define STM32_UART4_BASE 0x40010000
104#define STM32_UART5_BASE 0x40011000
105#define STM32_USART6_BASE 0x44003000
106#define STM32_UART7_BASE 0x40018000
107#define STM32_UART8_BASE 0x40019000
Patrick Delaunay82168e82018-05-17 14:50:46 +0200108
Patrick Delaunay5c2f6d72021-07-06 17:19:45 +0200109#define STM32_SDMMC1_BASE 0x58005000
110#define STM32_SDMMC2_BASE 0x58007000
111#define STM32_SDMMC3_BASE 0x48004000
112
Marek Vasut5053e932025-05-12 18:44:04 +0200113#ifdef CONFIG_STM32MP13X
114#define STM32_SYSRAM_BASE 0x2FFE0000
115#define STM32_SYSRAM_SIZE SZ_128K
116#endif
117
Patrick Delaunay4c6fcbc2024-01-15 15:05:57 +0100118#ifdef CONFIG_STM32MP15X
Patrick Delaunay85b53972018-03-12 10:46:10 +0100119#define STM32_SYSRAM_BASE 0x2FFC0000
120#define STM32_SYSRAM_SIZE SZ_256K
Patrick Delaunay123687c2022-05-20 18:24:46 +0200121#endif
Patrick Delaunay85b53972018-03-12 10:46:10 +0100122
123#define STM32_DDR_BASE 0xC0000000
124#define STM32_DDR_SIZE SZ_1G
125
Patrick Delaunayc5d15652018-03-20 10:54:53 +0100126#ifndef __ASSEMBLY__
Patrick Delaunayc5d15652018-03-20 10:54:53 +0100127/*
128 * enumerated for boot interface from Bootrom, used in TAMP_BOOT_CONTEXT
129 * - boot device = bit 8:4
130 * - boot instance = bit 3:0
131 */
132#define BOOT_TYPE_MASK 0xF0
133#define BOOT_TYPE_SHIFT 4
134#define BOOT_INSTANCE_MASK 0x0F
135#define BOOT_INSTANCE_SHIFT 0
136
Patrick Delaunayc5d15652018-03-20 10:54:53 +0100137/* TAMP registers */
138#define TAMP_BACKUP_REGISTER(x) (STM32_TAMP_BASE + 0x100 + 4 * x)
Patrick Delaunay123687c2022-05-20 18:24:46 +0200139
Patrick Delaunay4c6fcbc2024-01-15 15:05:57 +0100140#ifdef CONFIG_STM32MP15X
Patrick Delaunaye0207372018-04-16 10:13:24 +0200141#define TAMP_BACKUP_MAGIC_NUMBER TAMP_BACKUP_REGISTER(4)
142#define TAMP_BACKUP_BRANCH_ADDRESS TAMP_BACKUP_REGISTER(5)
Sughosh Ganu73abe8e2022-10-21 18:16:00 +0530143#define TAMP_FWU_BOOT_INFO_REG TAMP_BACKUP_REGISTER(10)
Fabien Dessenned7700d12019-10-30 14:38:29 +0100144#define TAMP_COPRO_RSC_TBL_ADDRESS TAMP_BACKUP_REGISTER(17)
145#define TAMP_COPRO_STATE TAMP_BACKUP_REGISTER(18)
Patrick Delaunayc5d15652018-03-20 10:54:53 +0100146#define TAMP_BOOT_CONTEXT TAMP_BACKUP_REGISTER(20)
Patrick Delaunay9c07f4a2019-04-18 17:32:45 +0200147#define TAMP_BOOTCOUNT TAMP_BACKUP_REGISTER(21)
Patrick Delaunayc5d15652018-03-20 10:54:53 +0100148
Sughosh Ganu73abe8e2022-10-21 18:16:00 +0530149#define TAMP_FWU_BOOT_IDX_MASK GENMASK(3, 0)
150
151#define TAMP_FWU_BOOT_IDX_OFFSET 0
Fabien Dessenned7700d12019-10-30 14:38:29 +0100152#define TAMP_COPRO_STATE_OFF 0
153#define TAMP_COPRO_STATE_INIT 1
154#define TAMP_COPRO_STATE_CRUN 2
155#define TAMP_COPRO_STATE_CSTOP 3
156#define TAMP_COPRO_STATE_STANDBY 4
157#define TAMP_COPRO_STATE_CRASH 5
Patrick Delaunay123687c2022-05-20 18:24:46 +0200158#endif
159
Patrick Delaunay990e0572024-01-15 15:05:56 +0100160#ifdef CONFIG_STM32MP13X
Patrick Delaunay123687c2022-05-20 18:24:46 +0200161#define TAMP_BOOTCOUNT TAMP_BACKUP_REGISTER(31)
162#define TAMP_BOOT_CONTEXT TAMP_BACKUP_REGISTER(30)
163#endif
Fabien Dessenned7700d12019-10-30 14:38:29 +0100164
Patrice Chotardd29531c2023-10-27 16:43:04 +0200165#endif /* __ASSEMBLY__ */
166#endif /* CONFIG_STM32MP15X || CONFIG_STM32MP13X */
Patrick Delaunay008d3c32019-02-27 17:01:20 +0100167
Patrice Chotardf952d702024-01-09 15:00:17 +0100168#ifdef CONFIG_STM32MP25X
Patrick Delaunay7fcceb62022-05-30 19:20:45 +0200169#define STM32_USART2_BASE 0x400E0000
170#define STM32_USART3_BASE 0x400F0000
171#define STM32_UART4_BASE 0x40100000
172#define STM32_UART5_BASE 0x40110000
173#define STM32_USART6_BASE 0x40220000
174#define STM32_UART9_BASE 0x402C0000
175#define STM32_USART1_BASE 0x40330000
176#define STM32_UART7_BASE 0x40370000
177#define STM32_UART8_BASE 0x40380000
Patrice Chotardd29531c2023-10-27 16:43:04 +0200178#define STM32_RCC_BASE 0x44200000
179#define STM32_TAMP_BASE 0x46010000
Patrick Delaunay7fcceb62022-05-30 19:20:45 +0200180#define STM32_SDMMC1_BASE 0x48220000
181#define STM32_SDMMC2_BASE 0x48230000
182#define STM32_SDMMC3_BASE 0x48240000
Patrice Chotardd29531c2023-10-27 16:43:04 +0200183
184#define STM32_DDR_BASE 0x80000000
185
186#define STM32_DDR_SIZE SZ_4G
187
188/* TAMP registers x = 0 to 127 : hardcoded description, waiting NVMEM node in DT */
189#define TAMP_BACKUP_REGISTER(x) (STM32_TAMP_BASE + 0x100 + 4 * (x))
190
191/* TAMP registers zone 3 RIF 1 (RW) at 96*/
192#define TAMP_BOOT_CONTEXT TAMP_BACKUP_REGISTER(96)
193#endif /* STM32MP25X */
Patrick Delaunayc5d15652018-03-20 10:54:53 +0100194
Patrick Delaunay14d6a242018-05-17 15:24:05 +0200195/* offset used for BSEC driver: misc_read and misc_write */
196#define STM32_BSEC_SHADOW_OFFSET 0x0
Patrick Delaunay92dc1022019-02-12 11:44:41 +0100197#define STM32_BSEC_SHADOW(id) (STM32_BSEC_SHADOW_OFFSET + (id) * 4)
Patrick Delaunay14d6a242018-05-17 15:24:05 +0200198#define STM32_BSEC_OTP_OFFSET 0x80000000
Patrick Delaunay92dc1022019-02-12 11:44:41 +0100199#define STM32_BSEC_OTP(id) (STM32_BSEC_OTP_OFFSET + (id) * 4)
Patrick Delaunayb10cddf2020-02-12 19:37:38 +0100200#define STM32_BSEC_LOCK_OFFSET 0xC0000000
201#define STM32_BSEC_LOCK(id) (STM32_BSEC_LOCK_OFFSET + (id) * 4)
Patrick Delaunay92dc1022019-02-12 11:44:41 +0100202
Patrick Delaunayb10cddf2020-02-12 19:37:38 +0100203/* BSEC OTP index */
Patrick Delaunay4c6fcbc2024-01-15 15:05:57 +0100204#ifdef CONFIG_STM32MP15X
Patrick Delaunayb10cddf2020-02-12 19:37:38 +0100205#define BSEC_OTP_RPN 1
206#define BSEC_OTP_SERIAL 13
207#define BSEC_OTP_PKG 16
208#define BSEC_OTP_MAC 57
Patrick Delaunay92dc1022019-02-12 11:44:41 +0100209#define BSEC_OTP_BOARD 59
Patrick Delaunay123687c2022-05-20 18:24:46 +0200210#endif
Patrick Delaunay990e0572024-01-15 15:05:56 +0100211#ifdef CONFIG_STM32MP13X
Patrick Delaunay123687c2022-05-20 18:24:46 +0200212#define BSEC_OTP_RPN 1
213#define BSEC_OTP_SERIAL 13
214#define BSEC_OTP_MAC 57
215#define BSEC_OTP_BOARD 60
216#endif
Patrice Chotardd29531c2023-10-27 16:43:04 +0200217#ifdef CONFIG_STM32MP25X
218#define BSEC_OTP_SERIAL 5
219#define BSEC_OTP_RPN 9
Patrick Delaunayf296fd22024-03-19 20:14:27 +0100220#define BSEC_OTP_REVID 102
Patrick Delaunaydb9d93c2024-01-15 15:05:47 +0100221#define BSEC_OTP_PKG 122
Patrick Delaunaya6c078c2024-01-15 15:05:53 +0100222#define BSEC_OTP_BOARD 246
Patrick Delaunaydb9d93c2024-01-15 15:05:47 +0100223#define BSEC_OTP_MAC 247
Patrice Chotardd29531c2023-10-27 16:43:04 +0200224#endif
Patrick Delaunay14d6a242018-05-17 15:24:05 +0200225
Patrice Chotardd29531c2023-10-27 16:43:04 +0200226#ifndef __ASSEMBLY__
227#include <asm/types.h>
228
229/* enumerated used to identify the SYSCON driver instance */
230enum {
231 STM32MP_SYSCON_UNKNOWN,
232 STM32MP_SYSCON_SYSCFG,
233};
234#endif /* __ASSEMBLY__*/
235
Patrick Delaunay85b53972018-03-12 10:46:10 +0100236#endif /* _MACH_STM32_H_ */