1 // Copyright 2015-2018 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 
15 #pragma once
16 #include <stdint.h>
17 //include soc related (generated) definitions
18 #include "soc/soc_caps.h"
19 #include "soc/soc_pins.h"
20 #include "soc/sdmmc_reg.h"
21 #include "soc/sdmmc_struct.h"
22 #include "soc/gpio_sig_map.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /**
29  * Common SDMMC slot info, doesn't depend on SOC_SDMMC_USE_{IOMUX,GPIO_MATRIX}
30  */
31 typedef struct {
32     uint8_t width;          /*!< Maximum supported slot width (1, 4, 8) */
33     uint8_t card_detect;    /*!< Card detect signal in GPIO Matrix */
34     uint8_t write_protect;  /*!< Write protect signal in GPIO Matrix */
35     uint8_t card_int;       /*!< Card interrupt signal in GPIO Matrix */
36 } sdmmc_slot_info_t;
37 
38 /** Width and GPIO matrix signal numbers for auxillary SD host signals, one structure per slot */
39 extern const sdmmc_slot_info_t sdmmc_slot_info[SOC_SDMMC_NUM_SLOTS];
40 
41 /**
42  * This structure lists pin numbers (if SOC_SDMMC_USE_IOMUX is set)
43  * or GPIO Matrix signal numbers (if SOC_SDMMC_USE_GPIO_MATRIX is set)
44  * for the SD bus signals. Field names match SD bus signal names.
45  */
46 typedef struct {
47     uint8_t clk;
48     uint8_t cmd;
49     uint8_t d0;
50     uint8_t d1;
51     uint8_t d2;
52     uint8_t d3;
53     uint8_t d4;
54     uint8_t d5;
55     uint8_t d6;
56     uint8_t d7;
57 } sdmmc_slot_io_info_t;
58 
59 /* Note: it is in theory possible to have both IOMUX and GPIO Matrix supported
60  * in the same SoC. However this is not used on any SoC at this point, and would
61  * complicate the driver. Hence only one of these options is supported at a time.
62  */
63 #if SOC_SDMMC_USE_IOMUX
64 /** GPIO pin numbers of SD bus signals, one structure per slot */
65 extern const sdmmc_slot_io_info_t sdmmc_slot_gpio_num[SOC_SDMMC_NUM_SLOTS];
66 
67 #elif SOC_SDMMC_USE_GPIO_MATRIX
68 /** GPIO matrix signal numbers of SD bus signals, one structure per slot */
69 extern const sdmmc_slot_io_info_t sdmmc_slot_gpio_sig[SOC_SDMMC_NUM_SLOTS];
70 
71 #endif // SOC_SDMMC_USE_{IOMUX,GPIO_MATRIX}
72 
73 #ifdef __cplusplus
74 }
75 #endif
76