1 // Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 #ifndef _SOC_IO_MUX_REG_H_ 15 #define _SOC_IO_MUX_REG_H_ 16 17 #include "soc.h" 18 19 /* The following are the bit fields for PERIPHS_IO_MUX_x_U registers */ 20 /* Output enable in sleep mode */ 21 #define SLP_OE (BIT(0)) 22 #define SLP_OE_M (BIT(0)) 23 #define SLP_OE_V 1 24 #define SLP_OE_S 0 25 /* Pin used for wakeup from sleep */ 26 #define SLP_SEL (BIT(1)) 27 #define SLP_SEL_M (BIT(1)) 28 #define SLP_SEL_V 1 29 #define SLP_SEL_S 1 30 /* Pulldown enable in sleep mode */ 31 #define SLP_PD (BIT(2)) 32 #define SLP_PD_M (BIT(2)) 33 #define SLP_PD_V 1 34 #define SLP_PD_S 2 35 /* Pullup enable in sleep mode */ 36 #define SLP_PU (BIT(3)) 37 #define SLP_PU_M (BIT(3)) 38 #define SLP_PU_V 1 39 #define SLP_PU_S 3 40 /* Input enable in sleep mode */ 41 #define SLP_IE (BIT(4)) 42 #define SLP_IE_M (BIT(4)) 43 #define SLP_IE_V 1 44 #define SLP_IE_S 4 45 /* Drive strength in sleep mode */ 46 #define SLP_DRV 0x3 47 #define SLP_DRV_M (SLP_DRV_V << SLP_DRV_S) 48 #define SLP_DRV_V 0x3 49 #define SLP_DRV_S 5 50 /* Pulldown enable */ 51 #define FUN_PD (BIT(7)) 52 #define FUN_PD_M (BIT(7)) 53 #define FUN_PD_V 1 54 #define FUN_PD_S 7 55 /* Pullup enable */ 56 #define FUN_PU (BIT(8)) 57 #define FUN_PU_M (BIT(8)) 58 #define FUN_PU_V 1 59 #define FUN_PU_S 8 60 /* Input enable */ 61 #define FUN_IE (BIT(9)) 62 #define FUN_IE_M (FUN_IE_V << FUN_IE_S) 63 #define FUN_IE_V 1 64 #define FUN_IE_S 9 65 /* Drive strength */ 66 #define FUN_DRV 0x3 67 #define FUN_DRV_M (FUN_DRV_V << FUN_DRV_S) 68 #define FUN_DRV_V 0x3 69 #define FUN_DRV_S 10 70 /* Function select (possible values are defined for each pin as FUNC_pinname_function below) */ 71 #define MCU_SEL 0x7 72 #define MCU_SEL_M (MCU_SEL_V << MCU_SEL_S) 73 #define MCU_SEL_V 0x7 74 #define MCU_SEL_S 12 75 76 #define PIN_SLP_INPUT_ENABLE(PIN_NAME) SET_PERI_REG_MASK(PIN_NAME,SLP_IE) 77 #define PIN_SLP_INPUT_DISABLE(PIN_NAME) CLEAR_PERI_REG_MASK(PIN_NAME,SLP_IE) 78 #define PIN_SLP_OUTPUT_ENABLE(PIN_NAME) SET_PERI_REG_MASK(PIN_NAME,SLP_OE) 79 #define PIN_SLP_OUTPUT_DISABLE(PIN_NAME) CLEAR_PERI_REG_MASK(PIN_NAME,SLP_OE) 80 #define PIN_SLP_PULLUP_ENABLE(PIN_NAME) SET_PERI_REG_MASK(PIN_NAME,SLP_PU) 81 #define PIN_SLP_PULLUP_DISABLE(PIN_NAME) CLEAR_PERI_REG_MASK(PIN_NAME,SLP_PU) 82 #define PIN_SLP_PULLDOWN_ENABLE(PIN_NAME) SET_PERI_REG_MASK(PIN_NAME,SLP_PD) 83 #define PIN_SLP_PULLDOWN_DISABLE(PIN_NAME) CLEAR_PERI_REG_MASK(PIN_NAME,SLP_PD) 84 #define PIN_SLP_SEL_ENABLE(PIN_NAME) SET_PERI_REG_MASK(PIN_NAME,SLP_SEL) 85 #define PIN_SLP_SEL_DISABLE(PIN_NAME) CLEAR_PERI_REG_MASK(PIN_NAME,SLP_SEL) 86 87 #define PIN_INPUT_ENABLE(PIN_NAME) SET_PERI_REG_MASK(PIN_NAME,FUN_IE) 88 #define PIN_INPUT_DISABLE(PIN_NAME) CLEAR_PERI_REG_MASK(PIN_NAME,FUN_IE) 89 #define PIN_SET_DRV(PIN_NAME, drv) REG_SET_FIELD(PIN_NAME, FUN_DRV, (drv)); 90 91 #define PIN_FUNC_SELECT(PIN_NAME, FUNC) REG_SET_FIELD(PIN_NAME, MCU_SEL, FUNC) 92 93 #define PIN_FUNC_GPIO 2 94 95 #define SPI_CLK_GPIO_NUM 6 96 #define SPI_CS0_GPIO_NUM 11 97 #define SPI_Q_GPIO_NUM 7 98 #define SPI_D_GPIO_NUM 8 99 #define SPI_WP_GPIO_NUM 10 100 #define SPI_HD_GPIO_NUM 9 101 102 #define PIN_CTRL (DR_REG_IO_MUX_BASE +0x00) 103 #define CLK_OUT3 0xf 104 #define CLK_OUT3_V CLK_OUT3 105 #define CLK_OUT3_S 8 106 #define CLK_OUT3_M (CLK_OUT3_V << CLK_OUT3_S) 107 #define CLK_OUT2 0xf 108 #define CLK_OUT2_V CLK_OUT2 109 #define CLK_OUT2_S 4 110 #define CLK_OUT2_M (CLK_OUT2_V << CLK_OUT2_S) 111 #define CLK_OUT1 0xf 112 #define CLK_OUT1_V CLK_OUT1 113 #define CLK_OUT1_S 0 114 #define CLK_OUT1_M (CLK_OUT1_V << CLK_OUT1_S) 115 116 #define PERIPHS_IO_MUX_GPIO0_U (DR_REG_IO_MUX_BASE +0x44) 117 #define IO_MUX_GPIO0_REG PERIPHS_IO_MUX_GPIO0_U 118 #define FUNC_GPIO0_EMAC_TX_CLK 5 119 #define FUNC_GPIO0_GPIO0 2 120 #define FUNC_GPIO0_CLK_OUT1 1 121 #define FUNC_GPIO0_GPIO0_0 0 122 123 #define PERIPHS_IO_MUX_U0TXD_U (DR_REG_IO_MUX_BASE +0x88) 124 #define IO_MUX_GPIO1_REG PERIPHS_IO_MUX_U0TXD_U 125 #define FUNC_U0TXD_EMAC_RXD2 5 126 #define FUNC_U0TXD_GPIO1 2 127 #define FUNC_U0TXD_CLK_OUT3 1 128 #define FUNC_U0TXD_U0TXD 0 129 130 #define PERIPHS_IO_MUX_GPIO2_U (DR_REG_IO_MUX_BASE +0x40) 131 #define IO_MUX_GPIO2_REG PERIPHS_IO_MUX_GPIO2_U 132 #define FUNC_GPIO2_SD_DATA0 4 133 #define FUNC_GPIO2_HS2_DATA0 3 134 #define FUNC_GPIO2_GPIO2 2 135 #define FUNC_GPIO2_HSPIWP 1 136 #define FUNC_GPIO2_GPIO2_0 0 137 138 #define PERIPHS_IO_MUX_U0RXD_U (DR_REG_IO_MUX_BASE +0x84) 139 #define IO_MUX_GPIO3_REG PERIPHS_IO_MUX_U0RXD_U 140 #define FUNC_U0RXD_GPIO3 2 141 #define FUNC_U0RXD_CLK_OUT2 1 142 #define FUNC_U0RXD_U0RXD 0 143 144 #define PERIPHS_IO_MUX_GPIO4_U (DR_REG_IO_MUX_BASE +0x48) 145 #define IO_MUX_GPIO4_REG PERIPHS_IO_MUX_GPIO4_U 146 #define FUNC_GPIO4_EMAC_TX_ER 5 147 #define FUNC_GPIO4_SD_DATA1 4 148 #define FUNC_GPIO4_HS2_DATA1 3 149 #define FUNC_GPIO4_GPIO4 2 150 #define FUNC_GPIO4_HSPIHD 1 151 #define FUNC_GPIO4_GPIO4_0 0 152 153 #define PERIPHS_IO_MUX_GPIO5_U (DR_REG_IO_MUX_BASE +0x6c) 154 #define IO_MUX_GPIO5_REG PERIPHS_IO_MUX_GPIO5_U 155 #define FUNC_GPIO5_EMAC_RX_CLK 5 156 #define FUNC_GPIO5_HS1_DATA6 3 157 #define FUNC_GPIO5_GPIO5 2 158 #define FUNC_GPIO5_VSPICS0 1 159 #define FUNC_GPIO5_GPIO5_0 0 160 161 #define PERIPHS_IO_MUX_SD_CLK_U (DR_REG_IO_MUX_BASE +0x60) 162 #define IO_MUX_GPIO6_REG PERIPHS_IO_MUX_SD_CLK_U 163 #define FUNC_SD_CLK_U1CTS 4 164 #define FUNC_SD_CLK_HS1_CLK 3 165 #define FUNC_SD_CLK_GPIO6 2 166 #define FUNC_SD_CLK_SPICLK 1 167 #define FUNC_SD_CLK_SD_CLK 0 168 169 #define PERIPHS_IO_MUX_SD_DATA0_U (DR_REG_IO_MUX_BASE +0x64) 170 #define IO_MUX_GPIO7_REG PERIPHS_IO_MUX_SD_DATA0_U 171 #define FUNC_SD_DATA0_U2RTS 4 172 #define FUNC_SD_DATA0_HS1_DATA0 3 173 #define FUNC_SD_DATA0_GPIO7 2 174 #define FUNC_SD_DATA0_SPIQ 1 175 #define FUNC_SD_DATA0_SD_DATA0 0 176 177 #define PERIPHS_IO_MUX_SD_DATA1_U (DR_REG_IO_MUX_BASE +0x68) 178 #define IO_MUX_GPIO8_REG PERIPHS_IO_MUX_SD_DATA1_U 179 #define FUNC_SD_DATA1_U2CTS 4 180 #define FUNC_SD_DATA1_HS1_DATA1 3 181 #define FUNC_SD_DATA1_GPIO8 2 182 #define FUNC_SD_DATA1_SPID 1 183 #define FUNC_SD_DATA1_SD_DATA1 0 184 185 #define PERIPHS_IO_MUX_SD_DATA2_U (DR_REG_IO_MUX_BASE +0x54) 186 #define IO_MUX_GPIO9_REG PERIPHS_IO_MUX_SD_DATA2_U 187 #define FUNC_SD_DATA2_U1RXD 4 188 #define FUNC_SD_DATA2_HS1_DATA2 3 189 #define FUNC_SD_DATA2_GPIO9 2 190 #define FUNC_SD_DATA2_SPIHD 1 191 #define FUNC_SD_DATA2_SD_DATA2 0 192 193 #define PERIPHS_IO_MUX_SD_DATA3_U (DR_REG_IO_MUX_BASE +0x58) 194 #define IO_MUX_GPIO10_REG PERIPHS_IO_MUX_SD_DATA3_U 195 #define FUNC_SD_DATA3_U1TXD 4 196 #define FUNC_SD_DATA3_HS1_DATA3 3 197 #define FUNC_SD_DATA3_GPIO10 2 198 #define FUNC_SD_DATA3_SPIWP 1 199 #define FUNC_SD_DATA3_SD_DATA3 0 200 201 #define PERIPHS_IO_MUX_SD_CMD_U (DR_REG_IO_MUX_BASE +0x5c) 202 #define IO_MUX_GPIO11_REG PERIPHS_IO_MUX_SD_CMD_U 203 #define FUNC_SD_CMD_U1RTS 4 204 #define FUNC_SD_CMD_HS1_CMD 3 205 #define FUNC_SD_CMD_GPIO11 2 206 #define FUNC_SD_CMD_SPICS0 1 207 #define FUNC_SD_CMD_SD_CMD 0 208 209 #define PERIPHS_IO_MUX_MTDI_U (DR_REG_IO_MUX_BASE +0x34) 210 #define IO_MUX_GPIO12_REG PERIPHS_IO_MUX_MTDI_U 211 #define FUNC_MTDI_EMAC_TXD3 5 212 #define FUNC_MTDI_SD_DATA2 4 213 #define FUNC_MTDI_HS2_DATA2 3 214 #define FUNC_MTDI_GPIO12 2 215 #define FUNC_MTDI_HSPIQ 1 216 #define FUNC_MTDI_MTDI 0 217 218 #define PERIPHS_IO_MUX_MTCK_U (DR_REG_IO_MUX_BASE +0x38) 219 #define IO_MUX_GPIO13_REG PERIPHS_IO_MUX_MTCK_U 220 #define FUNC_MTCK_EMAC_RX_ER 5 221 #define FUNC_MTCK_SD_DATA3 4 222 #define FUNC_MTCK_HS2_DATA3 3 223 #define FUNC_MTCK_GPIO13 2 224 #define FUNC_MTCK_HSPID 1 225 #define FUNC_MTCK_MTCK 0 226 227 #define PERIPHS_IO_MUX_MTMS_U (DR_REG_IO_MUX_BASE +0x30) 228 #define IO_MUX_GPIO14_REG PERIPHS_IO_MUX_MTMS_U 229 #define FUNC_MTMS_EMAC_TXD2 5 230 #define FUNC_MTMS_SD_CLK 4 231 #define FUNC_MTMS_HS2_CLK 3 232 #define FUNC_MTMS_GPIO14 2 233 #define FUNC_MTMS_HSPICLK 1 234 #define FUNC_MTMS_MTMS 0 235 236 #define PERIPHS_IO_MUX_MTDO_U (DR_REG_IO_MUX_BASE +0x3c) 237 #define IO_MUX_GPIO15_REG PERIPHS_IO_MUX_MTDO_U 238 #define FUNC_MTDO_EMAC_RXD3 5 239 #define FUNC_MTDO_SD_CMD 4 240 #define FUNC_MTDO_HS2_CMD 3 241 #define FUNC_MTDO_GPIO15 2 242 #define FUNC_MTDO_HSPICS0 1 243 #define FUNC_MTDO_MTDO 0 244 245 #define PERIPHS_IO_MUX_GPIO16_U (DR_REG_IO_MUX_BASE +0x4c) 246 #define IO_MUX_GPIO16_REG PERIPHS_IO_MUX_GPIO16_U 247 #define FUNC_GPIO16_EMAC_CLK_OUT 5 248 #define FUNC_GPIO16_U2RXD 4 249 #define FUNC_GPIO16_HS1_DATA4 3 250 #define FUNC_GPIO16_GPIO16 2 251 #define FUNC_GPIO16_GPIO16_0 0 252 253 #define PERIPHS_IO_MUX_GPIO17_U (DR_REG_IO_MUX_BASE +0x50) 254 #define IO_MUX_GPIO17_REG PERIPHS_IO_MUX_GPIO17_U 255 #define FUNC_GPIO17_EMAC_CLK_OUT_180 5 256 #define FUNC_GPIO17_U2TXD 4 257 #define FUNC_GPIO17_HS1_DATA5 3 258 #define FUNC_GPIO17_GPIO17 2 259 #define FUNC_GPIO17_GPIO17_0 0 260 261 #define PERIPHS_IO_MUX_GPIO18_U (DR_REG_IO_MUX_BASE +0x70) 262 #define IO_MUX_GPIO18_REG PERIPHS_IO_MUX_GPIO18_U 263 #define FUNC_GPIO18_HS1_DATA7 3 264 #define FUNC_GPIO18_GPIO18 2 265 #define FUNC_GPIO18_VSPICLK 1 266 #define FUNC_GPIO18_GPIO18_0 0 267 268 #define PERIPHS_IO_MUX_GPIO19_U (DR_REG_IO_MUX_BASE +0x74) 269 #define IO_MUX_GPIO19_REG PERIPHS_IO_MUX_GPIO19_U 270 #define FUNC_GPIO19_EMAC_TXD0 5 271 #define FUNC_GPIO19_U0CTS 3 272 #define FUNC_GPIO19_GPIO19 2 273 #define FUNC_GPIO19_VSPIQ 1 274 #define FUNC_GPIO19_GPIO19_0 0 275 276 #define PERIPHS_IO_MUX_GPIO20_U (DR_REG_IO_MUX_BASE +0x78) 277 #define IO_MUX_GPIO20_REG PERIPHS_IO_MUX_GPIO20_U 278 #define FUNC_GPIO20_GPIO20 2 279 #define FUNC_GPIO20_GPIO20_0 0 280 281 #define PERIPHS_IO_MUX_GPIO21_U (DR_REG_IO_MUX_BASE +0x7c) 282 #define IO_MUX_GPIO21_REG PERIPHS_IO_MUX_GPIO21_U 283 #define FUNC_GPIO21_EMAC_TX_EN 5 284 #define FUNC_GPIO21_GPIO21 2 285 #define FUNC_GPIO21_VSPIHD 1 286 #define FUNC_GPIO21_GPIO21_0 0 287 288 #define PERIPHS_IO_MUX_GPIO22_U (DR_REG_IO_MUX_BASE +0x80) 289 #define IO_MUX_GPIO22_REG PERIPHS_IO_MUX_GPIO22_U 290 #define FUNC_GPIO22_EMAC_TXD1 5 291 #define FUNC_GPIO22_U0RTS 3 292 #define FUNC_GPIO22_GPIO22 2 293 #define FUNC_GPIO22_VSPIWP 1 294 #define FUNC_GPIO22_GPIO22_0 0 295 296 #define PERIPHS_IO_MUX_GPIO23_U (DR_REG_IO_MUX_BASE +0x8c) 297 #define IO_MUX_GPIO23_REG PERIPHS_IO_MUX_GPIO23_U 298 #define FUNC_GPIO23_HS1_STROBE 3 299 #define FUNC_GPIO23_GPIO23 2 300 #define FUNC_GPIO23_VSPID 1 301 #define FUNC_GPIO23_GPIO23_0 0 302 303 #define PERIPHS_IO_MUX_GPIO24_U (DR_REG_IO_MUX_BASE +0x90) 304 #define IO_MUX_GPIO24_REG PERIPHS_IO_MUX_GPIO24_U 305 #define FUNC_GPIO24_GPIO24 2 306 #define FUNC_GPIO24_GPIO24_0 0 307 308 #define PERIPHS_IO_MUX_GPIO25_U (DR_REG_IO_MUX_BASE +0x24) 309 #define IO_MUX_GPIO25_REG PERIPHS_IO_MUX_GPIO25_U 310 #define FUNC_GPIO25_EMAC_RXD0 5 311 #define FUNC_GPIO25_GPIO25 2 312 #define FUNC_GPIO25_GPIO25_0 0 313 314 #define PERIPHS_IO_MUX_GPIO26_U (DR_REG_IO_MUX_BASE +0x28) 315 #define IO_MUX_GPIO26_REG PERIPHS_IO_MUX_GPIO26_U 316 #define FUNC_GPIO26_EMAC_RXD1 5 317 #define FUNC_GPIO26_GPIO26 2 318 #define FUNC_GPIO26_GPIO26_0 0 319 320 #define PERIPHS_IO_MUX_GPIO27_U (DR_REG_IO_MUX_BASE +0x2c) 321 #define IO_MUX_GPIO27_REG PERIPHS_IO_MUX_GPIO27_U 322 #define FUNC_GPIO27_EMAC_RX_DV 5 323 #define FUNC_GPIO27_GPIO27 2 324 #define FUNC_GPIO27_GPIO27_0 0 325 326 #define PERIPHS_IO_MUX_GPIO32_U (DR_REG_IO_MUX_BASE +0x1c) 327 #define IO_MUX_GPIO32_REG PERIPHS_IO_MUX_GPIO32_U 328 #define FUNC_GPIO32_GPIO32 2 329 #define FUNC_GPIO32_GPIO32_0 0 330 331 #define PERIPHS_IO_MUX_GPIO33_U (DR_REG_IO_MUX_BASE +0x20) 332 #define IO_MUX_GPIO33_REG PERIPHS_IO_MUX_GPIO33_U 333 #define FUNC_GPIO33_GPIO33 2 334 #define FUNC_GPIO33_GPIO33_0 0 335 336 #define PERIPHS_IO_MUX_GPIO34_U (DR_REG_IO_MUX_BASE +0x14) 337 #define IO_MUX_GPIO34_REG PERIPHS_IO_MUX_GPIO34_U 338 #define FUNC_GPIO34_GPIO34 2 339 #define FUNC_GPIO34_GPIO34_0 0 340 341 #define PERIPHS_IO_MUX_GPIO35_U (DR_REG_IO_MUX_BASE +0x18) 342 #define IO_MUX_GPIO35_REG PERIPHS_IO_MUX_GPIO35_U 343 #define FUNC_GPIO35_GPIO35 2 344 #define FUNC_GPIO35_GPIO35_0 0 345 346 #define PERIPHS_IO_MUX_GPIO36_U (DR_REG_IO_MUX_BASE +0x04) 347 #define IO_MUX_GPIO36_REG PERIPHS_IO_MUX_GPIO36_U 348 #define FUNC_GPIO36_GPIO36 2 349 #define FUNC_GPIO36_GPIO36_0 0 350 351 #define PERIPHS_IO_MUX_GPIO37_U (DR_REG_IO_MUX_BASE +0x08) 352 #define IO_MUX_GPIO37_REG PERIPHS_IO_MUX_GPIO37_U 353 #define FUNC_GPIO37_GPIO37 2 354 #define FUNC_GPIO37_GPIO37_0 0 355 356 #define PERIPHS_IO_MUX_GPIO38_U (DR_REG_IO_MUX_BASE +0x0c) 357 #define IO_MUX_GPIO38_REG PERIPHS_IO_MUX_GPIO38_U 358 #define FUNC_GPIO38_GPIO38 2 359 #define FUNC_GPIO38_GPIO38_0 0 360 361 #define PERIPHS_IO_MUX_GPIO39_U (DR_REG_IO_MUX_BASE +0x10) 362 #define IO_MUX_GPIO39_REG PERIPHS_IO_MUX_GPIO39_U 363 #define FUNC_GPIO39_GPIO39 2 364 #define FUNC_GPIO39_GPIO39_0 0 365 366 #endif /* _SOC_IO_MUX_REG_H_ */ 367