NVIDIA DriveOS Linux NSR SDK API Reference

7.0.3.0 Release
nvmnand_mmc_util.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2018 NVIDIA Corporation. All rights reserved.
3  *
4  * NVIDIA Corporation and its licensors retain all intellectual property
5  * and proprietary rights in and to this software, related documentation
6  * and any modifications thereto. Any use, reproduction, disclosure or
7  * distribution of this software and related documentation without an express
8  * license agreement from NVIDIA Corporation is strictly prohibited.
9  */
10 
11 #ifndef __NV_MNAND_UTIL_H__
12 #define __NV_MNAND_UTIL_H__
13 
14 #include <stdio.h>
15 #include <stdint.h>
16 #include "nvmnand.h"
17 #include "nvmnand_part_ops.h"
18 
19 #ifdef QNX /* QNX */
20 #include <sys/dcmd_cam.h>
21 #else /* Linux */
22 #include "nvcommon.h"
23 #endif
24 
25 
26 #define max(a,b) NV_MAX(a, b)
27 #define min(a,b) NV_MIN(a, b)
28 #define ARRAY_SIZE(array) (sizeof((array))/sizeof((array)[0]))
29 
34 /* MMCSD passtrough commands used */
35 #define MMC_SEND_CID 2
36 #define MMC_SWITCH 6
37 #define MMC_SEND_EXT_CSD 8
38 #define MMC_IF_COND 8
39 #define MMC_SEND_CSD 9
40 #define MMC_SEND_STATUS 13
41 #define MMC_READ_SINGLE_BLOCK 17 /* read single block */
42 #define MMC_READ_MULTIPLE_BLOCK 18 /* read multiple blocks */
43 #define MMC_WRITE_BLOCK 24 /* write single block */
44 #define MMC_WRITE_MULTIPLE_BLOCK 25 /* write multiple blocks */
45 #define MMC_GEN_CMD 56 /* Hynix F26/Toshiba specific */
46 #define MMC_MANF0_CMD 60 /* Hynix F20 specific */
47 #define MMC_STOP_TRANSMISSION 12
48 #define MMC_SECTOR_START 32 /* S */
49 #define MMC_SECTOR_END 33 /* S */
50 #define MMC_ERASE_GROUP_START 35 /* S */
51 #define MMC_ERASE_GROUP_END 36 /* S */
52 #define MMC_ERASE 38 /* S */
53 /* Erase flags */
54 #define MMC_ERASE_NORM 0x00000000
55 #define MMC_ERASE_TRIM 0x00000001
56 #define MMC_ERASE_GARBAGE_COLLECT 0x80008001
57 #define MMC_ERASE_SECURE_TRIM 0x80000001
58 #define MMC_ERASE_SECURE 0x80000000
59 #ifdef QNX
60 #define MMC_COMBO_CMD 128 /* pseudo command for combos */
61 #define MMC_GET_CXD_CMD 129 /* pseudo command for CSD/CID */
62 #define MMC_TRIM_ALL_CMD 130 /* pseudo command for trimming the chip */
63 #endif
64 
65 /* Parameters for setting EXT CSD */
66 #define MMC_SWITCH_CMDSET_DFLT 0x01
67 #define MMC_SWITCH_MODE_WRITE 0x3
68 
69 /* CID content */
70 #define CID_MID 15
71 #define CID_PRV 6
72 #define CID_PNM 7
73 
74 /* sector size */
75 #ifndef SECTOR_SZ
76 #define SECTOR_SZ 512
77 #endif
78 
79 #define ARRAY_SIZE(array) (sizeof((array))/sizeof((array)[0]))
80 
81 /* EXT CSD FFU related macros */
82 #define EXT_CSD_SUPPORTED_MODES 493
83 #define EXT_CSD_FFU_FEATURES 492
84 #define EXT_CSD_FFU_ARG3 490
85 #define EXT_CSD_FFU_ARG2 489
86 #define EXT_CSD_FFU_ARG1 488
87 #define EXT_CSD_FFU_ARG0 487
88 #define EXT_CSD_FW_CONFIG 169
89 #define EXT_CSD_MODE_CONFIG 30
90 #define EXT_CSD_MODE_CONFIG_NORMAL 0
91 #define EXT_CSD_MODE_CONFIG_FFU 1
92 #define EXT_CSD_MODE_CONFIG_VENDOR 0x10U
93 #define EXT_CSD_MODE_OPERATION_CODES 29
94 #define EXT_CSD_MODE_OPERATION_CODES_FFU_INSTALL 1
95 #define EXT_CSD_MODE_OPERATION_CODES_FFU_ABORT 2
96 #define EXT_CSD_MODE_FFU_STATUS 26
97 #define EXT_CSD_MODE_FFU_STATUS_SUCCESS 0
98 #define EXT_CSD_MODE_FFU_STATUS_GENERAL_ERR 0x10
99 #define EXT_CSD_MODE_FFU_STATUS_FW_INSTALL_ERR 0x11
100 #define EXT_CSD_MODE_FFU_STATUS_DOWNLOAD_ERR 0x12
101 
102 /* Some general EXT CSD content */
103 #define EXT_CSD_FLUSH_CACHE 32
104 #define EXT_CSD_CACHE_CTRL 33
105 #define EXT_CSD_PWR_OFF_NOTIFICATION 34
106 #define EXT_CSD_PWR_OFF_NOTIFICATION_NO_PWR_NOTIFY 0
107 #define EXT_CSD_PWR_OFF_NOTIFICATION_PWR_ON 1
108 #define EXT_CSD_PWR_OFF_NOTIFICATION_PWR_OFF_SHORT 2
109 #define EXT_CSD_PWR_OFF_NOTIFICATION_PWR_OFF_LONG 3
110 #define EXT_CSD_ENH_START_ADDR0 136
111 #define EXT_CSD_ENH_START_ADDR1 137
112 #define EXT_CSD_ENH_START_ADDR2 138
113 #define EXT_CSD_ENH_START_ADDR3 139
114 #define EXT_CSD_ENH_SIZE_MULT0 140
115 #define EXT_CSD_ENH_SIZE_MULT1 141
116 #define EXT_CSD_ENH_SIZE_MULT2 142
117 #define EXT_CSD_MAX_ENH_SIZE_MULT0 157
118 #define EXT_CSD_MAX_ENH_SIZE_MULT1 158
119 #define EXT_CSD_MAX_ENH_SIZE_MULT2 159
120 #define EXT_CSD_BKOPS_EN 163
121 #define EXT_CSD_BKOPS_ENABLED 1
122 #define EXT_CSD_BKOPS_START 164
123 #define EXT_CSD_BKOPS_INITIATE 1
124 #define EXT_CSD_REV 192
125 #define EXT_CSD_REV_4_4 5
126 #define EXT_CSD_REV_4_5 6
127 #define EXT_CSD_REV_5_0 7
128 #define EXT_CSD_REV_5_1 8
129 #define EXT_CSD_BKOPS_SUPPORT 502
130 #define EXT_CSD_SEC_COUNT0 212
131 #define EXT_CSD_SEC_COUNT1 213
132 #define EXT_CSD_SEC_COUNT2 214
133 #define EXT_CSD_SEC_COUNT3 215
134 #define EXT_CSD_BKOPS_STATUS 246
135 #define EXT_CSD_PWR_OFF_LONG_TIME 247
136 #define EXT_CSD_GENERIC_CMD6_TIME 248
137 #define EXT_CSD_FIRMWARE_VER0 254
138 #define EXT_CSD_FIRMWARE_VER1 255
139 #define EXT_CSD_FIRMWARE_VER2 256
140 #define EXT_CSD_FIRMWARE_VER3 257
141 #define EXT_CSD_FIRMWARE_VER4 258
142 #define EXT_CSD_FIRMWARE_VER5 259
143 #define EXT_CSD_FIRMWARE_VER6 260
144 #define EXT_CSD_FIRMWARE_VER7 261
145 
146 #define HOURS_PER_DAY 24
147 #define SECS_PER_HOUR 3600
148 #define SECS_PER_DAY ((HOURS_PER_DAY) * (SECS_PER_HOUR))
149 
151 #define MAX_FW_DEVICE_LEN (8U)
152 
154 #define MAX_PRN_DEVICE_LEN (6U)
155 
157 #define EMMC_VERSION_WITH_FFU_SUPPORT 7U
158 
162 typedef struct __mmc_combo_cmd_t {
163  uint32_t cmd;
164  uint32_t arg;
165 #ifndef QNX
166  uint8_t *data_ptr;
167  uint32_t data_len;
168 #endif
170 
171 #ifdef QNX
172 
189 int scsi_passthru_complex(int fd, uint8_t cmd, uint32_t argument,
190  uint32_t flags, uint8_t *senseptr, int senselen,
191  uint8_t *dataptr, int datalen, char *errmsg_prepend, int check_error);
192 
207 int scsi_passthru_simple(int fd, uint8_t cmd, uint32_t argument,
208  uint8_t *dataptr, int datalen, char *errmsg_prepend, int check_error);
209 #endif
210 
220 MNAND_STATUS mnand_mmc_common_update_card_status(int fd, uint32_t *card_status);
221 
232 
243 
254 
265 MNAND_STATUS mnand_mmc_common_set_xcsd(int fd, uint8_t index, uint8_t value);
266 
276 
277 #ifdef QNX
278 
289 int mnand_mmc_common_read_sectors_virt(int fd, unsigned int start_sector,
290  unsigned int sector_cnt, void *virtaddr);
291 
303 int mnand_mmc_common_read_sectors_phys(int fd, unsigned int start_sector,
304  unsigned int sector_cnt, off_t physaddr);
305 
306 #else /* Linux */
307 
317 int mnand_send_combo_cmd(int fd, mmc_combo_cmd_t *ccs, int num_cmd);
318 
329 int mnand_send_cmd_one(int fd, mmc_combo_cmd_t *ccs);
330 
339 
351 MNAND_STATUS mnand_mmc_common_set_update_xcsd(int fd, uint8_t index,
352  uint8_t enabled, mnand_ext_csd_info *xcsd);
353 #endif
354 #endif /* __NV_MNAND_UTIL_H__ */
__mnand_csd_info
CSD - eMMC only.
Definition: nvmnand.h:245
mnand_mmc_common_set_update_xcsd
MNAND_STATUS mnand_mmc_common_set_update_xcsd(int fd, uint8_t index, uint8_t enabled, mnand_ext_csd_info *xcsd)
Setting the EXT CSD register and update the xcsd.
__mmc_combo_cmd_t::cmd
uint32_t cmd
Definition: nvmnand_mmc_util.h:163
mnand_mmc_common_get_aligned_sector_count
uint32_t mnand_mmc_common_get_aligned_sector_count(mnand_chip *chip)
Get the power-of-2 aligned user sector count.
mnand_send_combo_cmd
int mnand_send_combo_cmd(int fd, mmc_combo_cmd_t *ccs, int num_cmd)
send a list of eMMC command to mnand device
__mmc_combo_cmd_t
combo command
Definition: nvmnand_mmc_util.h:162
nvcommon.h
__mmc_combo_cmd_t::data_ptr
uint8_t * data_ptr
Definition: nvmnand_mmc_util.h:166
__mmc_combo_cmd_t::data_len
uint32_t data_len
Definition: nvmnand_mmc_util.h:167
mnand_send_cmd_one
int mnand_send_cmd_one(int fd, mmc_combo_cmd_t *ccs)
send a list of eMMC command to mnand device
mnand_mmc_common_trim_all
MNAND_STATUS mnand_mmc_common_trim_all(mnand_chip *chip)
Trimming the whole device.
mmc_combo_cmd_t
struct __mmc_combo_cmd_t mmc_combo_cmd_t
combo command
mnand_mmc_common_update_xcsd
MNAND_STATUS mnand_mmc_common_update_xcsd(int fd, mnand_ext_csd_info *xcsd)
Updating the EXT CSD.
nvmnand.h
NVIDIA mNAND library
__mmc_combo_cmd_t::arg
uint32_t arg
Definition: nvmnand_mmc_util.h:164
mnand_mmc_common_set_xcsd
MNAND_STATUS mnand_mmc_common_set_xcsd(int fd, uint8_t index, uint8_t value)
Setting the EXT CSD register.
nvmnand_part_ops.h
NVIDIA mNAND library part specific operations header file
__mnand_chip
mNAND chip information
Definition: nvmnand.h:430
mnand_mmc_common_update_card_status
MNAND_STATUS mnand_mmc_common_update_card_status(int fd, uint32_t *card_status)
Updating the card status.
MNAND_STATUS
enum __mnand_status MNAND_STATUS
mNAND operation status used in the API
mnand_mmc_common_update_cid
MNAND_STATUS mnand_mmc_common_update_cid(int fd, mnand_cid_info *cid)
Updating the CID.
mnand_mmc_common_update_csd
MNAND_STATUS mnand_mmc_common_update_csd(int fd, mnand_csd_info *csd)
Updating the CSD.
__mnand_ext_csd_info
EXT CSD - eMMC only.
Definition: nvmnand.h:252
__mnand_cid_info
CID - eMMC only.
Definition: nvmnand.h:238