Jorge Ramirez-Ortiz | 766263c | 2018-09-23 09:39:56 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2018, Renesas Electronics Corporation. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | /** |
| 8 | * @file emmc_registers.h |
| 9 | * @brief emmc boot driver is expecting this header file. HS-MMC module header file. |
| 10 | * |
| 11 | */ |
| 12 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 13 | #ifndef EMMC_REGISTERS_H |
| 14 | #define EMMC_REGISTERS_H |
Jorge Ramirez-Ortiz | 766263c | 2018-09-23 09:39:56 +0200 | [diff] [blame] | 15 | |
| 16 | /* ************************ HEADER (INCLUDE) SECTION *********************** */ |
| 17 | |
| 18 | /* ***************** MACROS, CONSTANTS, COMPILATION FLAGS ****************** */ |
| 19 | |
| 20 | /* MMC channel select */ |
| 21 | #define MMC_CH0 (0U) /* SDHI2/MMC0 */ |
| 22 | #define MMC_CH1 (1U) /* SDHI3/MMC1 */ |
| 23 | |
| 24 | #if RCAR_LSI == RCAR_E3 |
| 25 | #define USE_MMC_CH (MMC_CH1) /* R-Car E3 */ |
| 26 | #else /* RCAR_LSI == RCAR_E3 */ |
| 27 | #define USE_MMC_CH (MMC_CH0) /* R-Car H3/M3/M3N */ |
| 28 | #endif /* RCAR_LSI == RCAR_E3 */ |
| 29 | |
| 30 | #define BIT0 (0x00000001U) |
| 31 | #define BIT1 (0x00000002U) |
| 32 | #define BIT2 (0x00000004U) |
| 33 | #define BIT3 (0x00000008U) |
| 34 | #define BIT4 (0x00000010U) |
| 35 | #define BIT5 (0x00000020U) |
| 36 | #define BIT6 (0x00000040U) |
| 37 | #define BIT7 (0x00000080U) |
| 38 | #define BIT8 (0x00000100U) |
| 39 | #define BIT9 (0x00000200U) |
| 40 | #define BIT10 (0x00000400U) |
| 41 | #define BIT11 (0x00000800U) |
| 42 | #define BIT12 (0x00001000U) |
| 43 | #define BIT13 (0x00002000U) |
| 44 | #define BIT14 (0x00004000U) |
| 45 | #define BIT15 (0x00008000U) |
| 46 | #define BIT16 (0x00010000U) |
| 47 | #define BIT17 (0x00020000U) |
| 48 | #define BIT18 (0x00040000U) |
| 49 | #define BIT19 (0x00080000U) |
| 50 | #define BIT20 (0x00100000U) |
| 51 | #define BIT21 (0x00200000U) |
| 52 | #define BIT22 (0x00400000U) |
| 53 | #define BIT23 (0x00800000U) |
| 54 | #define BIT24 (0x01000000U) |
| 55 | #define BIT25 (0x02000000U) |
| 56 | #define BIT26 (0x04000000U) |
| 57 | #define BIT27 (0x08000000U) |
| 58 | #define BIT28 (0x10000000U) |
| 59 | #define BIT29 (0x20000000U) |
| 60 | #define BIT30 (0x40000000U) |
| 61 | #define BIT31 (0x80000000U) |
| 62 | |
| 63 | /** @brief Clock Pulse Generator (CPG) registers |
| 64 | */ |
| 65 | #define CPG_BASE (0xE6150000U) |
| 66 | |
| 67 | #define CPG_MSTPSR3 (CPG_BASE+0x0048U) /* Module stop status register 3 */ |
| 68 | |
| 69 | #define CPG_SMSTPCR3 (CPG_BASE+0x013CU) /* System module stop control register 3 */ |
| 70 | |
| 71 | #define CPG_SD2CKCR (CPG_BASE+0x0268U) /* SDHI2 clock frequency control register */ |
| 72 | #define CPG_SD3CKCR (CPG_BASE+0x026CU) /* SDHI3 clock frequency control register */ |
| 73 | |
| 74 | #define CPG_CPGWPR (CPG_BASE+0x0900U) /* CPG Write Protect Register */ |
| 75 | |
| 76 | #if USE_MMC_CH == MMC_CH0 |
| 77 | #define CPG_SDxCKCR (CPG_SD2CKCR) /* SDHI2/MMC0 */ |
| 78 | #else /* USE_MMC_CH == MMC_CH0 */ |
| 79 | #define CPG_SDxCKCR (CPG_SD3CKCR) /* SDHI3/MMC1 */ |
| 80 | #endif /* USE_MMC_CH == MMC_CH0 */ |
| 81 | |
| 82 | /** Boot Status register |
| 83 | */ |
| 84 | #define MFISBTSTSR (0xE6260604U) |
| 85 | |
| 86 | #define MFISBTSTSR_BOOT_PARTITION (0x00000010U) |
| 87 | |
| 88 | /** brief eMMC registers |
| 89 | */ |
| 90 | #define MMC0_SD_BASE (0xEE140000U) |
| 91 | #define MMC1_SD_BASE (0xEE160000U) |
| 92 | |
| 93 | #if USE_MMC_CH == MMC_CH0 |
| 94 | #define MMC_SD_BASE (MMC0_SD_BASE) |
| 95 | #else /* USE_MMC_CH == MMC_CH0 */ |
| 96 | #define MMC_SD_BASE (MMC1_SD_BASE) |
| 97 | #endif /* USE_MMC_CH == MMC_CH0 */ |
| 98 | |
| 99 | #define SD_CMD (MMC_SD_BASE + 0x0000U) |
| 100 | #define SD_PORTSEL (MMC_SD_BASE + 0x0008U) |
| 101 | #define SD_ARG (MMC_SD_BASE + 0x0010U) |
| 102 | #define SD_ARG1 (MMC_SD_BASE + 0x0018U) |
| 103 | #define SD_STOP (MMC_SD_BASE + 0x0020U) |
| 104 | #define SD_SECCNT (MMC_SD_BASE + 0x0028U) |
| 105 | #define SD_RSP10 (MMC_SD_BASE + 0x0030U) |
| 106 | #define SD_RSP1 (MMC_SD_BASE + 0x0038U) |
| 107 | #define SD_RSP32 (MMC_SD_BASE + 0x0040U) |
| 108 | #define SD_RSP3 (MMC_SD_BASE + 0x0048U) |
| 109 | #define SD_RSP54 (MMC_SD_BASE + 0x0050U) |
| 110 | #define SD_RSP5 (MMC_SD_BASE + 0x0058U) |
| 111 | #define SD_RSP76 (MMC_SD_BASE + 0x0060U) |
| 112 | #define SD_RSP7 (MMC_SD_BASE + 0x0068U) |
| 113 | #define SD_INFO1 (MMC_SD_BASE + 0x0070U) |
| 114 | #define SD_INFO2 (MMC_SD_BASE + 0x0078U) |
| 115 | #define SD_INFO1_MASK (MMC_SD_BASE + 0x0080U) |
| 116 | #define SD_INFO2_MASK (MMC_SD_BASE + 0x0088U) |
| 117 | #define SD_CLK_CTRL (MMC_SD_BASE + 0x0090U) |
| 118 | #define SD_SIZE (MMC_SD_BASE + 0x0098U) |
| 119 | #define SD_OPTION (MMC_SD_BASE + 0x00A0U) |
| 120 | #define SD_ERR_STS1 (MMC_SD_BASE + 0x00B0U) |
| 121 | #define SD_ERR_STS2 (MMC_SD_BASE + 0x00B8U) |
| 122 | #define SD_BUF0 (MMC_SD_BASE + 0x00C0U) |
| 123 | #define SDIO_MODE (MMC_SD_BASE + 0x00D0U) |
| 124 | #define SDIO_INFO1 (MMC_SD_BASE + 0x00D8U) |
| 125 | #define SDIO_INFO1_MASK (MMC_SD_BASE + 0x00E0U) |
| 126 | #define CC_EXT_MODE (MMC_SD_BASE + 0x0360U) |
| 127 | #define SOFT_RST (MMC_SD_BASE + 0x0380U) |
| 128 | #define VERSION (MMC_SD_BASE + 0x0388U) |
| 129 | #define HOST_MODE (MMC_SD_BASE + 0x0390U) |
| 130 | #define DM_CM_DTRAN_MODE (MMC_SD_BASE + 0x0820U) |
| 131 | #define DM_CM_DTRAN_CTRL (MMC_SD_BASE + 0x0828U) |
| 132 | #define DM_CM_RST (MMC_SD_BASE + 0x0830U) |
| 133 | #define DM_CM_INFO1 (MMC_SD_BASE + 0x0840U) |
| 134 | #define DM_CM_INFO1_MASK (MMC_SD_BASE + 0x0848U) |
| 135 | #define DM_CM_INFO2 (MMC_SD_BASE + 0x0850U) |
| 136 | #define DM_CM_INFO2_MASK (MMC_SD_BASE + 0x0858U) |
| 137 | #define DM_DTRAN_ADDR (MMC_SD_BASE + 0x0880U) |
| 138 | |
| 139 | /** @brief SD_INFO1 Registers |
| 140 | */ |
| 141 | #define SD_INFO1_HPIRES 0x00010000UL /* Response Reception Completion */ |
| 142 | #define SD_INFO1_INFO10 0x00000400UL /* Indicates the SDDAT3 state */ |
| 143 | #define SD_INFO1_INFO9 0x00000200UL /* SDDAT3 Card Insertion */ |
| 144 | #define SD_INFO1_INFO8 0x00000100UL /* SDDAT3 Card Removal */ |
| 145 | #define SD_INFO1_INFO7 0x00000080UL /* Write Protect */ |
| 146 | #define SD_INFO1_INFO5 0x00000020UL /* Indicates the ISDCD state */ |
| 147 | #define SD_INFO1_INFO4 0x00000010UL /* ISDCD Card Insertion */ |
| 148 | #define SD_INFO1_INFO3 0x00000008UL /* ISDCD Card Removal */ |
| 149 | #define SD_INFO1_INFO2 0x00000004UL /* Access end */ |
| 150 | #define SD_INFO1_INFO0 0x00000001UL /* Response end */ |
| 151 | |
| 152 | /** @brief SD_INFO2 Registers |
| 153 | */ |
| 154 | #define SD_INFO2_ILA 0x00008000UL /* Illegal Access Error */ |
| 155 | #define SD_INFO2_CBSY 0x00004000UL /* Command Type Register Busy */ |
| 156 | #define SD_INFO2_SCLKDIVEN 0x00002000UL |
| 157 | #define SD_INFO2_BWE 0x00000200UL /* SD_BUF Write Enable */ |
| 158 | #define SD_INFO2_BRE 0x00000100UL /* SD_BUF Read Enable */ |
| 159 | #define SD_INFO2_DAT0 0x00000080UL /* SDDAT0 */ |
| 160 | #define SD_INFO2_ERR6 0x00000040UL /* Response Timeout */ |
| 161 | #define SD_INFO2_ERR5 0x00000020UL /* SD_BUF Illegal Read Access */ |
| 162 | #define SD_INFO2_ERR4 0x00000010UL /* SD_BUF Illegal Write Access */ |
| 163 | #define SD_INFO2_ERR3 0x00000008UL /* Data Timeout */ |
| 164 | #define SD_INFO2_ERR2 0x00000004UL /* END Error */ |
| 165 | #define SD_INFO2_ERR1 0x00000002UL /* CRC Error */ |
| 166 | #define SD_INFO2_ERR0 0x00000001UL /* CMD Error */ |
| 167 | #define SD_INFO2_ALL_ERR 0x0000807FUL |
| 168 | #define SD_INFO2_CLEAR 0x00000800UL /* BIT11 The write value should always be 1. HWM_0003 */ |
| 169 | |
| 170 | /** @brief SOFT_RST |
| 171 | */ |
| 172 | #define SOFT_RST_SDRST 0x00000001UL |
| 173 | |
| 174 | /** @brief SD_CLK_CTRL |
| 175 | */ |
| 176 | #define SD_CLK_CTRL_SDCLKOFFEN 0x00000200UL |
| 177 | #define SD_CLK_CTRL_SCLKEN 0x00000100UL |
| 178 | #define SD_CLK_CTRL_CLKDIV_MASK 0x000000FFUL |
| 179 | #define SD_CLOCK_ENABLE 0x00000100UL |
| 180 | #define SD_CLOCK_DISABLE 0x00000000UL |
| 181 | #define SD_CLK_WRITE_MASK 0x000003FFUL |
| 182 | #define SD_CLK_CLKDIV_CLEAR_MASK 0xFFFFFF0FUL |
| 183 | |
| 184 | /** @brief SD_OPTION |
| 185 | */ |
| 186 | #define SD_OPTION_TIMEOUT_CNT_MASK 0x000000F0UL |
| 187 | |
| 188 | /** @brief MMC Clock Frequency |
| 189 | * 200MHz * 1/x = output clock |
| 190 | */ |
| 191 | #define MMC_CLK_OFF 0UL /* Clock output is disabled */ |
| 192 | #define MMC_400KHZ 512UL /* 200MHz * 1/512 = 390 KHz */ |
| 193 | #define MMC_20MHZ 16UL /* 200MHz * 1/16 = 12.5 MHz Normal speed mode */ |
| 194 | #define MMC_26MHZ 8UL /* 200MHz * 1/8 = 25 MHz High speed mode 26Mhz */ |
| 195 | #define MMC_52MHZ 4UL /* 200MHz * 1/4 = 50 MHz High speed mode 52Mhz */ |
| 196 | #define MMC_100MHZ 2UL /* 200MHz * 1/2 = 100 MHz */ |
| 197 | #define MMC_200MHZ 1UL /* 200MHz * 1/1 = 200 MHz */ |
| 198 | |
| 199 | #define MMC_FREQ_52MHZ 52000000UL |
| 200 | #define MMC_FREQ_26MHZ 26000000UL |
| 201 | #define MMC_FREQ_20MHZ 20000000UL |
| 202 | |
| 203 | /** @brief MMC Clock DIV |
| 204 | */ |
| 205 | #define MMC_SD_CLK_START 0x00000100UL /* CLOCK On */ |
| 206 | #define MMC_SD_CLK_STOP (~0x00000100UL) /* CLOCK stop */ |
| 207 | #define MMC_SD_CLK_DIV1 0x000000FFUL /* 1/1 */ |
| 208 | #define MMC_SD_CLK_DIV2 0x00000000UL /* 1/2 */ |
| 209 | #define MMC_SD_CLK_DIV4 0x00000001UL /* 1/4 */ |
| 210 | #define MMC_SD_CLK_DIV8 0x00000002UL /* 1/8 */ |
| 211 | #define MMC_SD_CLK_DIV16 0x00000004UL /* 1/16 */ |
| 212 | #define MMC_SD_CLK_DIV32 0x00000008UL /* 1/32 */ |
| 213 | #define MMC_SD_CLK_DIV64 0x00000010UL /* 1/64 */ |
| 214 | #define MMC_SD_CLK_DIV128 0x00000020UL /* 1/128 */ |
| 215 | #define MMC_SD_CLK_DIV256 0x00000040UL /* 1/256 */ |
| 216 | #define MMC_SD_CLK_DIV512 0x00000080UL /* 1/512 */ |
| 217 | |
| 218 | /** @brief DM_CM_DTRAN_MODE |
| 219 | */ |
| 220 | #define DM_CM_DTRAN_MODE_CH0 0x00000000UL /* CH0(downstream) */ |
| 221 | #define DM_CM_DTRAN_MODE_CH1 0x00010000UL /* CH1(upstream) */ |
| 222 | #define DM_CM_DTRAN_MODE_BIT_WIDTH 0x00000030UL |
| 223 | |
| 224 | /** @brief CC_EXT_MODE |
| 225 | */ |
| 226 | #define CC_EXT_MODE_DMASDRW_ENABLE 0x00000002UL /* SD_BUF Read/Write DMA Transfer */ |
| 227 | #define CC_EXT_MODE_CLEAR 0x00001010UL /* BIT 12 & 4 always 1. */ |
| 228 | |
| 229 | /** @brief DM_CM_INFO_MASK |
| 230 | */ |
| 231 | #define DM_CM_INFO_MASK_CLEAR 0xFFFCFFFEUL |
| 232 | #define DM_CM_INFO_CH0_ENABLE 0x00010001UL |
| 233 | #define DM_CM_INFO_CH1_ENABLE 0x00020001UL |
| 234 | |
| 235 | /** @brief DM_DTRAN_ADDR |
| 236 | */ |
| 237 | #define DM_DTRAN_ADDR_WRITE_MASK 0xFFFFFFF8UL |
| 238 | |
| 239 | /** @brief DM_CM_DTRAN_CTRL |
| 240 | */ |
| 241 | #define DM_CM_DTRAN_CTRL_START 0x00000001UL |
| 242 | |
| 243 | /** @brief SYSC Registers |
| 244 | */ |
| 245 | #if USE_MMC_CH == MMC_CH0 |
| 246 | #define CPG_MSTP_MMC (BIT12) /* SDHI2/MMC0 */ |
| 247 | #else /* USE_MMC_CH == MMC_CH0 */ |
| 248 | #define CPG_MSTP_MMC (BIT11) /* SDHI3/MMC1 */ |
| 249 | #endif /* USE_MMC_CH == MMC_CH0 */ |
| 250 | |
| 251 | /* ********************** STRUCTURES, TYPE DEFINITIONS ********************* */ |
| 252 | |
| 253 | /* ********************** DECLARATION OF EXTERNAL DATA ********************* */ |
| 254 | |
| 255 | /* ************************** FUNCTION PROTOTYPES ************************** */ |
| 256 | |
| 257 | /* ********************************* CODE ********************************** */ |
| 258 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 259 | #endif /* EMMC_REGISTERS_H */ |
Jorge Ramirez-Ortiz | 766263c | 2018-09-23 09:39:56 +0200 | [diff] [blame] | 260 | /* ******************************** END ************************************ */ |