|
40 | 40 | #define SPI_MOSI_PIN 5 /* SPI_MOSI PB5 */ |
41 | 41 | #endif /* PLATFORM_stm32f4 */ |
42 | 42 |
|
43 | | - |
44 | 43 | #ifdef PLATFORM_stm32u5 |
| 44 | + |
45 | 45 | #ifdef TZEN |
46 | 46 | #define PERIPH_BASE (0x50000000UL) |
47 | 47 | #else |
48 | 48 | #define PERIPH_BASE (0x40000000UL) |
49 | 49 | #endif |
50 | 50 |
|
51 | | -#define APB2PERIPH_BASE (PERIPH_BASE + 0x00010000UL) |
52 | | -#define AHB2PERIPH_BASE (PERIPH_BASE + 0x02020000UL) |
| 51 | +#define OCTOSPI1_BASE (PERIPH_BASE + 0x020D1400UL) |
| 52 | +#define OCTOSPI2_BASE (PERIPH_BASE + 0x020D2400UL) |
53 | 53 |
|
54 | | -#define SPI1_BASE (APB2PERIPH_BASE + 0x3000UL) |
| 54 | +#ifndef OCTOSPI_BASE |
| 55 | +#define OCTOSPI_BASE OCTOSPI2_BASE |
| 56 | +#endif |
55 | 57 |
|
56 | | -#define RCC_BASE (APB2PERIPH_BASE + 0x0C00UL) |
| 58 | +/* Registers mapping */ |
| 59 | +#define APB2PERIPH_BASE (PERIPH_BASE + 0x00012C00UL) |
| 60 | +#define RCC_BASE (PERIPH_BASE + 0x06020C00UL) |
| 61 | +#define GPIO_BASE (PERIPH_BASE + 0x02020000UL) |
| 62 | +#define AHB2PERIPH_BASE (PERIPH_BASE + 0x02020000UL) |
| 63 | +#define SPI1_BASE (APB2PERIPH_BASE + 0x3000UL) |
57 | 64 | #define APB2_CLOCK_ER (*(volatile uint32_t *)(RCC_BASE + 0xA4)) |
58 | 65 | #define APB2_CLOCK_RST (*(volatile uint32_t *)(RCC_BASE + 0x7C)) |
| 66 | +#define AHB2_CLOCK_ER (*(volatile uint32_t *)(RCC_BASE + 0x90)) |
| 67 | +#define AHB2_CLOCK_RST (*(volatile uint32_t *)(RCC_BASE + 0x68)) |
| 68 | + |
59 | 69 | #define RCC_GPIO_CLOCK_ER (*(volatile uint32_t *)(RCC_BASE + 0x8C)) |
60 | 70 |
|
61 | | -#define GPIO_BASE (APB2PERIPH_BASE + 0x02020000UL) |
| 71 | + |
| 72 | +#define RCC_AHB2ENR_QSPIEN (1 << 8) /* OCTOSPI2 = bit 8, OCTOSPI1 = bit 4 */ |
| 73 | + |
62 | 74 | #define GPIOA_BASE (GPIO_BASE + 0x00000UL) |
63 | 75 | #define GPIOB_BASE (GPIO_BASE + 0x00400UL) |
64 | 76 | #define GPIOC_BASE (GPIO_BASE + 0x00800UL) |
|
69 | 81 | #define GPIOH_BASE (GPIO_BASE + 0x01C00UL) |
70 | 82 | #define GPIOI_BASE (GPIO_BASE + 0x02000UL) |
71 | 83 |
|
| 84 | +/** QSPI **/ |
| 85 | +/* Default Base (H) and AF (alternate function=5) for QSPI */ |
| 86 | +#define QSPI_GPIO GPIOH_BASE |
| 87 | +#define QSPI_PIN_AF 5 |
| 88 | + |
| 89 | +#ifndef QSPI_CLOCK_BASE |
| 90 | +#define QSPI_CLOCK_BASE 160000000 |
| 91 | +#endif |
| 92 | + |
| 93 | +#ifndef QSPI_CLOCK_MHZ |
| 94 | +#define QSPI_CLOCK_MHZ 10000000 |
| 95 | +#endif |
| 96 | + |
| 97 | +/* Default to flash bank 1 */ |
| 98 | +#ifndef QSPI_FLASH_BANK |
| 99 | +#define QSPI_FLASH_BANK 1 |
| 100 | +#endif |
| 101 | + |
| 102 | +/* Default flash size to 16MB */ |
| 103 | +#ifndef QSPI_FLASH_SIZE |
| 104 | +#define QSPI_FLASH_SIZE 23 /* 2^24 = 16 MB */ |
| 105 | +#endif |
| 106 | + |
| 107 | +/* QSPI CLK PB2 (alt OCTOSPIM_P1_CLK)*/ |
| 108 | +#define QSPI_CLOCK_PIO_BASE GPIOH_BASE |
| 109 | +#define QSPI_CLOCK_PIN 6 |
| 110 | +#define QSPI_CLOCK_PIN_AF 5 |
| 111 | + |
| 112 | +/* nQSPI_CS PG6 (alt PB6 -> OCTOSPIM_P1_NCS) */ |
| 113 | +#ifndef QSPI_ALT_CONFIGURATION |
| 114 | +#define QSPI_CS_PIO_BASE GPIOH_BASE |
| 115 | +#define QSPI_CS_FLASH_PIN 5 |
| 116 | +#else |
| 117 | +#define QSPI_CS_PIO_BASE GPIOH_BASE |
| 118 | +#define QSPI_CS_FLASH_PIN 6 |
| 119 | +#endif |
| 120 | + |
| 121 | +/* QSPI_IO0 */ |
| 122 | +#define QSPI_IO0_PIO_BASE GPIOH_BASE |
| 123 | +#define QSPI_IO0_PIN 9 |
| 124 | +#define QSPI_IO0_PIN_AF 5 |
| 125 | + |
| 126 | +/* QSPI_IO1 */ |
| 127 | +#define QSPI_IO1_PIO_BASE GPIOH_BASE |
| 128 | +#define QSPI_IO1_PIN 10 |
| 129 | +#define QSPI_IO1_PIN_AF 5 |
| 130 | + |
| 131 | +/* QSPI_IO2 */ |
| 132 | +#define QSPI_IO2_PIO_BASE GPIOH_BASE |
| 133 | +#define QSPI_IO2_PIN 11 |
| 134 | +#define QSPI_IO2_PIN_AF 5 |
| 135 | + |
| 136 | +/* QSPI_IO3 */ |
| 137 | +#define QSPI_IO3_PIO_BASE GPIOH_BASE |
| 138 | +#define QSPI_IO3_PIN 12 |
| 139 | +#define QSPI_IO3_PIN_AF 5 |
| 140 | + |
| 141 | + |
72 | 142 | /* STMOD+ Port */ |
73 | 143 | #define SPI_GPIO GPIOE_BASE |
74 | 144 | #define SPI_CS_GPIO GPIOE_BASE |
|
0 commit comments