<sys/ioccom.h>, <sys/ioctl.h>
[minix3.git] / drivers / mmc / mmchost.h
blob30144ff9ee645043bebd53aba3f8fc4084f068b3
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 */
6 /**
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.
25 * [/host/
26 * +instance:int] 1 --- 0..4 [ /slot/
27 * +card_detect:func ] 1 --- 0..1 [ /card/ ]
28 * `
31 #define MAX_SD_SLOTS 4
33 struct mmc_host;
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
40 struct sd_card_regs
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 #define RESP_LEN_48_CHK_BUSY (3<<0)
53 #define RESP_LEN_48 (2<<0)
54 #define RESP_LEN_136 (1<<0)
55 #define RESP_NO_RESPONSE (0<<0)
57 #define DATA_NONE (0)
58 #define DATA_READ (1)
59 #define DATA_WRITE (2)
61 /* struct representing an mmc command */
62 struct mmc_command
64 uint32_t cmd;
65 uint32_t args;
66 uint32_t resp_type;
67 uint32_t data_type;
68 uint32_t resp[4];
69 unsigned char *data;
70 uint32_t data_len;
73 /* structure representing an SD card */
74 struct sd_card
76 /* pointer back to the SD slot for convenience */
77 struct sd_slot *slot;
79 struct sd_card_regs regs;
81 /* some helpers (data comming from the csd) */
82 uint32_t blk_size;
83 uint32_t blk_count;
85 /* drive state: deaf, initialized, dead */
86 unsigned state;
88 /* MINIX/block driver related things */
89 int open_ct; /* in-use count */
91 /* 1 disks + 4 partitions and 16 possible sub partitions */
92 struct device part[MINOR_PER_DISK + PARTITONS_PER_DISK];
93 struct device subpart[PARTITONS_PER_DISK * SUBPARTITION_PER_PARTITION];
96 /* structure representing an SD slot */
97 struct sd_slot
99 /* pointer back to the host for convenience */
100 struct mmc_host *host;
102 unsigned state;
103 struct sd_card card;
106 /* structure for the host controller */
107 struct mmc_host
109 /* MMC host configuration */
110 int (*host_set_instance) (struct mmc_host * host, int instance);
111 /* MMC host configuration */
112 int (*host_init) (struct mmc_host * host);
113 /* Set log level */
114 void (*set_log_level) (int level);
115 /* Host controller reset */
116 int (*host_reset) (struct mmc_host * host);
117 /* Card detection (binary yes/no) */
118 int (*card_detect) (struct sd_slot * slot);
119 /* Perform card detection e.g. card type */
120 struct sd_card *(*card_initialize) (struct sd_slot * slot);
121 /* Release the card */
122 int (*card_release) (struct sd_card * card);
124 /* Additional hardware interrupts */
125 void (*hw_intr) (unsigned int irqs);
127 /* read count blocks into existing buf */
128 int (*read) (struct sd_card * card,
129 uint32_t blknr, uint32_t count, unsigned char *buf);
131 /* write count blocks */
132 int (*write) (struct sd_card * card,
133 uint32_t blknr, uint32_t count, unsigned char *buf);
135 /* up to 4 slots with 4 SD cards */
136 struct sd_slot slot[MAX_SD_SLOTS];
139 #if 0
140 /* Command execution */
141 int (*send_cmd) (struct sd_card * card, struct mmc_command *);
143 /* struct representing an mmc command */
144 struct mmc_command
146 uint32_t cmd;
147 uint32_t args;
148 uint32_t resp[4];
149 unsigned char *data;
150 uint32_t data_len;
152 #endif
154 /* Hack done for driver registration */
155 void host_initialize_host_structure_mmchs(struct mmc_host *host);
156 void host_initialize_host_structure_dummy(struct mmc_host *host);