1eaaa4f7eSrev13@wp.pl /* 2eaaa4f7eSrev13@wp.pl * (C) Copyright 2011 3eaaa4f7eSrev13@wp.pl * Yuri Tikhonov, Emcraft Systems, yur@emcraft.com 4eaaa4f7eSrev13@wp.pl * 5eaaa4f7eSrev13@wp.pl * (C) Copyright 2015 666562414SKamil Lulko * Kamil Lulko, <kamil.lulko@gmail.com> 7eaaa4f7eSrev13@wp.pl * 8eaaa4f7eSrev13@wp.pl * SPDX-License-Identifier: GPL-2.0+ 9eaaa4f7eSrev13@wp.pl */ 10eaaa4f7eSrev13@wp.pl 11eaaa4f7eSrev13@wp.pl #ifndef _MACH_STM32_H_ 12eaaa4f7eSrev13@wp.pl #define _MACH_STM32_H_ 13eaaa4f7eSrev13@wp.pl 14eaaa4f7eSrev13@wp.pl /* 15eaaa4f7eSrev13@wp.pl * Peripheral memory map 16eaaa4f7eSrev13@wp.pl */ 17089fddfdSAntonio Borneo #define STM32_SYSMEM_BASE 0x1FFF0000 18eaaa4f7eSrev13@wp.pl #define STM32_PERIPH_BASE 0x40000000 19eaaa4f7eSrev13@wp.pl #define STM32_APB1PERIPH_BASE (STM32_PERIPH_BASE + 0x00000000) 20eaaa4f7eSrev13@wp.pl #define STM32_APB2PERIPH_BASE (STM32_PERIPH_BASE + 0x00010000) 21eaaa4f7eSrev13@wp.pl #define STM32_AHB1PERIPH_BASE (STM32_PERIPH_BASE + 0x00020000) 22eaaa4f7eSrev13@wp.pl #define STM32_AHB2PERIPH_BASE (STM32_PERIPH_BASE + 0x10000000) 23eaaa4f7eSrev13@wp.pl 24eaaa4f7eSrev13@wp.pl #define STM32_BUS_MASK 0xFFFF0000 25eaaa4f7eSrev13@wp.pl 2609959ba3SVikas Manocha #define STM32_GPIOA_BASE (STM32_AHB1PERIPH_BASE + 0x0000) 2709959ba3SVikas Manocha #define STM32_GPIOB_BASE (STM32_AHB1PERIPH_BASE + 0x0400) 2809959ba3SVikas Manocha #define STM32_GPIOC_BASE (STM32_AHB1PERIPH_BASE + 0x0800) 2909959ba3SVikas Manocha #define STM32_GPIOD_BASE (STM32_AHB1PERIPH_BASE + 0x0C00) 3009959ba3SVikas Manocha #define STM32_GPIOE_BASE (STM32_AHB1PERIPH_BASE + 0x1000) 3109959ba3SVikas Manocha #define STM32_GPIOF_BASE (STM32_AHB1PERIPH_BASE + 0x1400) 3209959ba3SVikas Manocha #define STM32_GPIOG_BASE (STM32_AHB1PERIPH_BASE + 0x1800) 3309959ba3SVikas Manocha #define STM32_GPIOH_BASE (STM32_AHB1PERIPH_BASE + 0x1C00) 3409959ba3SVikas Manocha #define STM32_GPIOI_BASE (STM32_AHB1PERIPH_BASE + 0x2000) 3509959ba3SVikas Manocha 36eaaa4f7eSrev13@wp.pl /* 37eaaa4f7eSrev13@wp.pl * Register maps 38eaaa4f7eSrev13@wp.pl */ 39089fddfdSAntonio Borneo struct stm32_u_id_regs { 40089fddfdSAntonio Borneo u32 u_id_low; 41089fddfdSAntonio Borneo u32 u_id_mid; 42089fddfdSAntonio Borneo u32 u_id_high; 43089fddfdSAntonio Borneo }; 44089fddfdSAntonio Borneo 45eaaa4f7eSrev13@wp.pl struct stm32_rcc_regs { 46eaaa4f7eSrev13@wp.pl u32 cr; /* RCC clock control */ 47eaaa4f7eSrev13@wp.pl u32 pllcfgr; /* RCC PLL configuration */ 48eaaa4f7eSrev13@wp.pl u32 cfgr; /* RCC clock configuration */ 49eaaa4f7eSrev13@wp.pl u32 cir; /* RCC clock interrupt */ 50eaaa4f7eSrev13@wp.pl u32 ahb1rstr; /* RCC AHB1 peripheral reset */ 51eaaa4f7eSrev13@wp.pl u32 ahb2rstr; /* RCC AHB2 peripheral reset */ 52eaaa4f7eSrev13@wp.pl u32 ahb3rstr; /* RCC AHB3 peripheral reset */ 53eaaa4f7eSrev13@wp.pl u32 rsv0; 54eaaa4f7eSrev13@wp.pl u32 apb1rstr; /* RCC APB1 peripheral reset */ 55eaaa4f7eSrev13@wp.pl u32 apb2rstr; /* RCC APB2 peripheral reset */ 56eaaa4f7eSrev13@wp.pl u32 rsv1[2]; 57eaaa4f7eSrev13@wp.pl u32 ahb1enr; /* RCC AHB1 peripheral clock enable */ 58eaaa4f7eSrev13@wp.pl u32 ahb2enr; /* RCC AHB2 peripheral clock enable */ 59eaaa4f7eSrev13@wp.pl u32 ahb3enr; /* RCC AHB3 peripheral clock enable */ 60eaaa4f7eSrev13@wp.pl u32 rsv2; 61eaaa4f7eSrev13@wp.pl u32 apb1enr; /* RCC APB1 peripheral clock enable */ 62eaaa4f7eSrev13@wp.pl u32 apb2enr; /* RCC APB2 peripheral clock enable */ 63eaaa4f7eSrev13@wp.pl u32 rsv3[2]; 64eaaa4f7eSrev13@wp.pl u32 ahb1lpenr; /* RCC AHB1 periph clk enable in low pwr mode */ 65eaaa4f7eSrev13@wp.pl u32 ahb2lpenr; /* RCC AHB2 periph clk enable in low pwr mode */ 66eaaa4f7eSrev13@wp.pl u32 ahb3lpenr; /* RCC AHB3 periph clk enable in low pwr mode */ 67eaaa4f7eSrev13@wp.pl u32 rsv4; 68eaaa4f7eSrev13@wp.pl u32 apb1lpenr; /* RCC APB1 periph clk enable in low pwr mode */ 69eaaa4f7eSrev13@wp.pl u32 apb2lpenr; /* RCC APB2 periph clk enable in low pwr mode */ 70eaaa4f7eSrev13@wp.pl u32 rsv5[2]; 71eaaa4f7eSrev13@wp.pl u32 bdcr; /* RCC Backup domain control */ 72eaaa4f7eSrev13@wp.pl u32 csr; /* RCC clock control & status */ 73eaaa4f7eSrev13@wp.pl u32 rsv6[2]; 74eaaa4f7eSrev13@wp.pl u32 sscgr; /* RCC spread spectrum clock generation */ 75eaaa4f7eSrev13@wp.pl u32 plli2scfgr; /* RCC PLLI2S configuration */ 76eaaa4f7eSrev13@wp.pl u32 pllsaicfgr; 77eaaa4f7eSrev13@wp.pl u32 dckcfgr; 78eaaa4f7eSrev13@wp.pl }; 79eaaa4f7eSrev13@wp.pl 80eaaa4f7eSrev13@wp.pl struct stm32_pwr_regs { 81eaaa4f7eSrev13@wp.pl u32 cr; 82eaaa4f7eSrev13@wp.pl u32 csr; 83eaaa4f7eSrev13@wp.pl }; 84eaaa4f7eSrev13@wp.pl 85eaaa4f7eSrev13@wp.pl /* 86eaaa4f7eSrev13@wp.pl * Registers access macros 87eaaa4f7eSrev13@wp.pl */ 88089fddfdSAntonio Borneo #define STM32_U_ID_BASE (STM32_SYSMEM_BASE + 0x7A10) 89089fddfdSAntonio Borneo #define STM32_U_ID ((struct stm32_u_id_regs *)STM32_U_ID_BASE) 90089fddfdSAntonio Borneo 91eaaa4f7eSrev13@wp.pl #define STM32_RCC_BASE (STM32_AHB1PERIPH_BASE + 0x3800) 92eaaa4f7eSrev13@wp.pl #define STM32_RCC ((struct stm32_rcc_regs *)STM32_RCC_BASE) 93eaaa4f7eSrev13@wp.pl 94eaaa4f7eSrev13@wp.pl #define STM32_PWR_BASE (STM32_APB1PERIPH_BASE + 0x7000) 95eaaa4f7eSrev13@wp.pl #define STM32_PWR ((struct stm32_pwr_regs *)STM32_PWR_BASE) 96eaaa4f7eSrev13@wp.pl 9766562414SKamil Lulko /* 9866562414SKamil Lulko * Peripheral base addresses 9966562414SKamil Lulko */ 10066562414SKamil Lulko #define STM32_USART1_BASE (STM32_APB2PERIPH_BASE + 0x1000) 10166562414SKamil Lulko #define STM32_USART2_BASE (STM32_APB1PERIPH_BASE + 0x4400) 10266562414SKamil Lulko #define STM32_USART3_BASE (STM32_APB1PERIPH_BASE + 0x4800) 10366562414SKamil Lulko #define STM32_USART6_BASE (STM32_APB2PERIPH_BASE + 0x1400) 10466562414SKamil Lulko 105*9ecb0c41SVikas Manocha #define FLASH_CNTL_BASE (STM32_AHB1PERIPH_BASE + 0x3C00) 106*9ecb0c41SVikas Manocha 107*9ecb0c41SVikas Manocha static const u32 sect_sz_kb[CONFIG_SYS_MAX_FLASH_SECT] = { 108*9ecb0c41SVikas Manocha [0 ... 3] = 16 * 1024, 109*9ecb0c41SVikas Manocha [4] = 64 * 1024, 110*9ecb0c41SVikas Manocha [5 ... 11] = 128 * 1024 111*9ecb0c41SVikas Manocha }; 112*9ecb0c41SVikas Manocha 113eaaa4f7eSrev13@wp.pl enum clock { 114eaaa4f7eSrev13@wp.pl CLOCK_CORE, 115eaaa4f7eSrev13@wp.pl CLOCK_AHB, 116eaaa4f7eSrev13@wp.pl CLOCK_APB1, 117eaaa4f7eSrev13@wp.pl CLOCK_APB2 118eaaa4f7eSrev13@wp.pl }; 119eaaa4f7eSrev13@wp.pl 120eaaa4f7eSrev13@wp.pl int configure_clocks(void); 121eaaa4f7eSrev13@wp.pl unsigned long clock_get(enum clock clck); 122*9ecb0c41SVikas Manocha void stm32_flash_latency_cfg(int latency); 123eaaa4f7eSrev13@wp.pl 124eaaa4f7eSrev13@wp.pl #endif /* _MACH_STM32_H_ */ 125