1 /* 2 * MSC (MMC/SD controller) structures. 3 * 4 * Copyright (C) 2024 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA 20 */ 21 22 #pragma once 23 24 #include <stdint.h> 25 26 27 28 /* MMC/SD structures. */ 29 30 struct CID 31 { 32 uint16_t month:4, year:8, reserved:4; 33 uint32_t serial; 34 uint8_t revision; 35 char name[5]; 36 uint16_t oem; 37 uint8_t manufacturer; 38 } __attribute__((packed)); 39 40 struct CSD 41 { 42 uint8_t reserved0:2, 43 format:2, 44 temp_write_prot:1, 45 perm_write_prot:1, 46 copy:1, 47 format_group:1; 48 uint16_t reserved1:5, 49 write_block_partial:1, 50 write_blocklen:4, 51 write_time_factor:3, 52 reserved2:2, 53 write_prot_group_enable:1; 54 uint64_t write_prot_group_size:7, 55 erase_sector_size:7, 56 erase_single_block_enable:1, 57 device_size_multiplier:3, 58 max_write_current_max:3, 59 max_write_current_min:3, 60 max_read_current_max:3, 61 max_read_current_min:3, 62 device_size:12, 63 reserved3:2, 64 dsr_implemented:1, 65 read_block_misalign:1, 66 write_block_misalign:1, 67 read_block_partial:1, 68 read_blocklen:4, 69 card_command_classes:12; 70 uint8_t tran_speed, 71 data_read_access_time_2, 72 data_read_access_time_1, 73 reserved4:6, 74 csd:2; 75 } __attribute__((packed)); 76 77 78 79 /* Generic card structure. */ 80 81 struct msc_card 82 { 83 uint16_t rca; 84 uint32_t ocr; 85 uint8_t bus_width; 86 struct CID cid; 87 struct CSD csd; 88 };