2 #define SUBPARTITION_PER_PARTITION 4 /* 4 sub partitions per partition */
3 #define PARTITONS_PER_DISK 4 /* 4 partitions per disk */
4 #define MINOR_PER_DISK 1 /* one additional minor to point to */
7 * We can have multiple MMC host controller present on the hardware. The MINIX
8 * approach to handle this is to run a driver for each instance. Every driver
9 * will therefore be stated with an "instance" id and the rest of the code here
10 * will assume a single host controller to be present.
12 * The SD specification allows multiple cards to be attached to a single host
13 * controller using the same lines. I recommend reading SD Specifications Part 1
14 * Physical layer Simplified Specification chapter 3 about SD Memory Card system
15 * concepts if you want to get a better understanding of this.
17 * In practice an MMC host will usually have a single slot attached to it and that
18 * Slot may or may not contain a card. On sudden card removal we might want to
19 * keep track of the last inserted card and we might therefore at later stage
20 * add an additional "last_card" attribute to the card.
22 * The following diagram shows the structure that will be used to modulate the
23 * hardware written in umlwiki syntax.
26 * +instance:int] 1 --- 0..4 [ /slot/
27 * +card_detect:func ] 1 --- 0..1 [ /card/ ]
31 #define MAX_SD_SLOTS 4
35 //TODO Add more modes like INACTIVE STATE and such
36 #define SD_MODE_UNINITIALIZED 0
37 #define SD_MODE_CARD_IDENTIFICATION 1
38 #define SD_MODE_DATA_TRANSFER_MODE 2
42 uint32_t cid
[4]; /* Card Identification */
43 uint32_t rca
; /* Relative card address */
44 uint32_t dsr
; /* Driver stage register */
45 uint32_t csd
[4]; /* Card specific data */
46 uint32_t scr
[2]; /* SD configuration */
47 uint32_t ocr
; /* Operation conditions */
48 uint32_t ssr
[5]; /* SD Status */
49 uint32_t csr
; /* Card status */
52 /* struct representing an mmc command */
59 #define RESP_LEN_48_CHK_BUSY (3<<0)
60 #define RESP_LEN_48 (2<<0)
61 #define RESP_LEN_136 (1<<0)
62 #define NO_RESPONSE (0<<0)
69 /* structure representing an SD card */
72 /* pointer back to the SD slot for convenience */
75 struct sd_card_regs regs
;
77 /* some helpers (data comming from the csd) */
81 /* drive state: deaf, initialized, dead */
84 /* MINIX/block driver related things */
85 int open_ct
; /* in-use count */
87 /* 1 disks + 4 partitions and 16 possible sub partitions */
88 struct device part
[MINOR_PER_DISK
+ PARTITONS_PER_DISK
];
89 struct device subpart
[PARTITONS_PER_DISK
* SUBPARTITION_PER_PARTITION
];
92 /* structure representing an SD slot */
95 /* pointer back to the host for convenience */
96 struct mmc_host
*host
;
102 /* structure for the host controller */
105 /* MMC host configuration */
106 int (*host_set_instance
) (struct mmc_host
* host
, int instance
);
107 /* MMC host configuration */
108 int (*host_init
) (struct mmc_host
* host
);
110 void (*set_log_level
) (int level
);
111 /* Host controller reset */
112 int (*host_reset
) (struct mmc_host
* host
);
113 /* Card detection (binary yes/no) */
114 int (*card_detect
) (struct sd_slot
* slot
);
115 /* Perform card detection e.g. card type */
116 struct sd_card
*(*card_initialize
) (struct sd_slot
* slot
);
117 /* Release the card */
118 int (*card_release
) (struct sd_card
* card
);
120 /* read count blocks into existing buf */
121 int (*read
) (struct sd_card
* card
,
122 uint32_t blknr
, uint32_t count
, unsigned char *buf
);
124 /* write count blocks */
125 int (*write
) (struct sd_card
* card
,
126 uint32_t blknr
, uint32_t count
, unsigned char *buf
);
128 /* up to 4 slots with 4 SD cards */
129 struct sd_slot slot
[MAX_SD_SLOTS
];
133 /* Command execution */
134 int (*send_cmd
) (struct sd_card
* card
, struct mmc_command
*);
136 /* struct representing an mmc command */
147 /* Hack done for driver registration */
148 void host_initialize_host_structure_mmchs(struct mmc_host
*host
);
149 void host_initialize_host_structure_dummy(struct mmc_host
*host
);