xref: /openbmc/qemu/hw/sd/sdmmc-internal.h (revision 0bcea3f7)
1 /*
2  * SD/MMC cards common
3  *
4  * Copyright (c) 2018  Philippe Mathieu-Daudé <f4bug@amsat.org>
5  *
6  * This work is licensed under the terms of the GNU GPL, version 2 or later.
7  * See the COPYING file in the top-level directory.
8  * SPDX-License-Identifier: GPL-2.0-or-later
9  */
10 
11 #ifndef SDMMC_INTERNAL_H
12 #define SDMMC_INTERNAL_H
13 
14 #define TYPE_SDMMC_COMMON "sdmmc-common"
15 DECLARE_OBJ_CHECKERS(SDState, SDCardClass, SDMMC_COMMON, TYPE_SDMMC_COMMON)
16 
17 /*
18  * EXT_CSD Modes segment
19  *
20  * Define the configuration the Device is working in.
21  * These modes can be changed by the host by means of the SWITCH command.
22  */
23 #define EXT_CSD_CMDQ_MODE_EN            15      /* R/W */
24 #define EXT_CSD_FLUSH_CACHE             32      /* W */
25 #define EXT_CSD_CACHE_CTRL              33      /* R/W */
26 #define EXT_CSD_POWER_OFF_NOTIFICATION  34      /* R/W */
27 #define EXT_CSD_PACKED_FAILURE_INDEX    35      /* RO */
28 #define EXT_CSD_PACKED_CMD_STATUS       36      /* RO */
29 #define EXT_CSD_EXP_EVENTS_STATUS       54      /* RO, 2 bytes */
30 #define EXT_CSD_EXP_EVENTS_CTRL         56      /* R/W, 2 bytes */
31 #define EXT_CSD_CLASS_6_CTRL            59
32 #define EXT_CSD_INI_TIMEOUT_EMU         60
33 #define EXT_CSD_DATA_SECTOR_SIZE        61      /* R */
34 #define EXT_CSD_USE_NATIVE_SECTOR       62
35 #define EXT_CSD_NATIVE_SECTOR_SIZE      63
36 #define EXT_CSD_VENDOR_SPECIFIC_FIELD   64      /* 64 bytes */
37 #define EXT_CSD_PROGRAM_CID_CSD_DDR_SUPPORT 130
38 #define EXT_CSD_PERIODIC_WAKEUP         131
39 #define EXT_CSD_TCASE_SUPPORT           132
40 #define EXT_CSD_SEC_BAD_BLK_MGMNT       134
41 #define EXT_CSD_GP_SIZE_MULT            143     /* R/W */
42 #define EXT_CSD_PARTITION_SETTING_COMPLETED 155 /* R/W */
43 #define EXT_CSD_PARTITION_ATTRIBUTE     156     /* R/W */
44 #define EXT_CSD_MAX_ENH_SIZE_MULT       157     /* RO, 3 bytes */
45 #define EXT_CSD_PARTITION_SUPPORT       160     /* RO */
46 #define EXT_CSD_HPI_MGMT                161     /* R/W */
47 #define EXT_CSD_RST_N_FUNCTION          162     /* R/W */
48 #define EXT_CSD_BKOPS_EN                163     /* R/W */
49 #define EXT_CSD_BKOPS_START             164     /* W */
50 #define EXT_CSD_SANITIZE_START          165     /* W */
51 #define EXT_CSD_WR_REL_PARAM            166     /* RO */
52 #define EXT_CSD_WR_REL_SET              167
53 #define EXT_CSD_RPMB_MULT               168     /* RO */
54 #define EXT_CSD_FW_CONFIG               169     /* R/W */
55 #define EXT_CSD_USER_WP                 171
56 #define EXT_CSD_BOOT_WP                 173     /* R/W */
57 #define EXT_CSD_BOOT_WP_STATUS          174
58 #define EXT_CSD_ERASE_GROUP_DEF         175     /* R/W */
59 #define EXT_CSD_BOOT_BUS_CONDITIONS     177
60 #define EXT_CSD_BOOT_CONFIG_PROT        178
61 #define EXT_CSD_PART_CONFIG             179     /* R/W */
62 #define EXT_CSD_ERASED_MEM_CONT         181     /* RO */
63 #define EXT_CSD_BUS_WIDTH               183     /* R/W */
64 #define EXT_CSD_STROBE_SUPPORT          184     /* RO */
65 #define EXT_CSD_HS_TIMING               185     /* R/W */
66 #define EXT_CSD_POWER_CLASS             187     /* R/W */
67 #define EXT_CSD_CMD_SET_REV             189
68 #define EXT_CSD_CMD_SET                 191
69 /*
70  * EXT_CSD Properties segment
71  *
72  * Define the Device capabilities, cannot be modified by the host.
73  */
74 #define EXT_CSD_REV                     192
75 #define EXT_CSD_STRUCTURE               194
76 #define EXT_CSD_CARD_TYPE               196
77 #define EXT_CSD_DRIVER_STRENGTH         197
78 #define EXT_CSD_OUT_OF_INTERRUPT_TIME   198
79 #define EXT_CSD_PART_SWITCH_TIME        199
80 #define EXT_CSD_PWR_CL_52_195           200
81 #define EXT_CSD_PWR_CL_26_195           201
82 #define EXT_CSD_PWR_CL_52_360           202
83 #define EXT_CSD_PWR_CL_26_360           203
84 #define EXT_CSD_SEC_CNT                 212     /* 4 bytes */
85 #define EXT_CSD_S_A_TIMEOUT             217
86 #define EXT_CSD_S_C_VCCQ                219
87 #define EXT_CSD_S_C_VCC                 220
88 #define EXT_CSD_REL_WR_SEC_C            222
89 #define EXT_CSD_HC_WP_GRP_SIZE          221
90 #define EXT_CSD_ERASE_TIMEOUT_MULT      223
91 #define EXT_CSD_HC_ERASE_GRP_SIZE       224
92 #define EXT_CSD_ACC_SIZE                225
93 #define EXT_CSD_BOOT_MULT               226
94 #define EXT_CSD_BOOT_INFO               228
95 #define EXT_CSD_SEC_FEATURE_SUPPORT     231
96 #define EXT_CSD_TRIM_MULT               232
97 #define EXT_CSD_INI_TIMEOUT_PA          241
98 #define EXT_CSD_BKOPS_STATUS            246
99 #define EXT_CSD_POWER_OFF_LONG_TIME     247
100 #define EXT_CSD_GENERIC_CMD6_TIME       248
101 #define EXT_CSD_CACHE_SIZE              249     /* 4 bytes */
102 #define EXT_CSD_EXT_SUPPORT             494
103 #define EXT_CSD_LARGE_UNIT_SIZE_M1      495
104 #define EXT_CSD_CONTEXT_CAPABILITIES    496
105 #define EXT_CSD_TAG_RES_SIZE            497
106 #define EXT_CSD_TAG_UNIT_SIZE           498
107 #define EXT_CSD_DATA_TAG_SUPPORT        499
108 #define EXT_CSD_MAX_PACKED_WRITES       500
109 #define EXT_CSD_MAX_PACKED_READS        501
110 #define EXT_CSD_BKOPS_SUPPORT           502
111 #define EXT_CSD_HPI_FEATURES            503
112 #define EXT_CSD_S_CMD_SET               504
113 
114 #define EXT_CSD_WR_REL_PARAM_EN                 (1 << 2)
115 #define EXT_CSD_WR_REL_PARAM_EN_RPMB_REL_WR     (1 << 4)
116 
117 #define EXT_CSD_PART_CONFIG_ACC_MASK            (0x7)
118 #define EXT_CSD_PART_CONFIG_ACC_DEFAULT         (0x0)
119 #define EXT_CSD_PART_CONFIG_ACC_BOOT0           (0x1)
120 
121 #define EXT_CSD_PART_CONFIG_EN_MASK             (0x7 << 3)
122 #define EXT_CSD_PART_CONFIG_EN_BOOT0            (0x1 << 3)
123 #define EXT_CSD_PART_CONFIG_EN_USER             (0x7 << 3)
124 
125 #endif
126