SD/MMC/SDIO Registers: Difference between revisions
| Line 214: | Line 214: | ||
SCMDE is probably in bit1 (though, official specs say bit0, which would be same as RCMDE). | SCMDE is probably in bit1 (though, official specs say bit0, which would be same as RCMDE). | ||
== DSi SD/MMC I/O Ports: Control == | == DSi SD/MMC I/O Ports: Control Registers == | ||
===4004802h/4004A02h - SD_CARD_PORT_SELECT=== | |||
15-11 Unknown/unused (appears to be always zero) | 15-11 Unknown/unused (appears to be always zero) | ||
10 Unknown (write: should be 1, read: usually/always 0) | 10 Unknown (write: should be 1, read: usually/always 0) (W?) | ||
9 Unknown (write: should be 0, read: usually 1 for SD) | 9 Unknown (write: should be 0, read: usually 1 for SD) (R?) | ||
8 Unknown (write: should be 0, read: usually 1 for SDIO) | 8 Unknown (write: should be 0, read: usually 1 for SDIO) (R?) | ||
7-4 Unknown/unused (appears to be always zero) | 7-4 Unknown/unused (appears to be always zero) | ||
3-1 Unknown (R/W) | 3-1 Unknown (R/W) | ||
0 Port Select (0=SD Card Slot, 1=Onboard eMMC) | 0 Port Select (0=SD Card Slot, 1=Onboard eMMC) (for SDIO: Unknown)(R/W) | ||
===4004828h/4004A28h - SD_CARD_OPTION - Card Option Setup=== | |||
15 Bus Width (0=4bit, 1=1bit) (R/W) | |||
14 Unknown (usually set) (R?) | |||
13-9 Unknown/unused (appears to be always zero) | |||
8 Unknown (firmware toggles this after CLK change?) (W?) | |||
7-4 Unknown, maybe some 4bit timing/timeout value (R/W) | |||
0-3 Unknown, maybe another 4bit timing/timeout value (R/W) | |||
Among others, this register should contain a 4bit timeout setting, "RTO[3:0] for SD (aka TO[3:0] for SDIO) timeout period for data start/busy bits, in the form of a multiple number of the SDCLK period."<br> | |||
Unknown which "multiple numbers" that's referring to (probably some exponential/table values).<br> | |||
Settings spotted on DSi are 40E0h,40EEh. | |||
===4004824h/4004A24h - SD_CARD_CLK_CTL Card Clock Control=== | |||
15-11 Unknown (always 0) ;unlike Toshiba: no HCLK divider-disable in bit15) | |||
10 Unknown (0=Normal, 1=Unknown, doesn't affect SDCLK output?) (R/W) | |||
9 Unknown (0=Normal, 1=Unknown, freezes SDCLK output?) (R/W) | |||
8 SDCLK Enable (0=Force SDCLK=LOW, 1=Output SDCLK=HCLK/n) (R/W) | |||
7-4 | 7-0 HCLK Div (0,1,2,4,8,16,32,64,128 = Div2,4,8,16,32,64,128,256,512) (R/W) | ||
The DSi uses HCLK=33.513982 MHz, the SDCLK pin can range from HCLK/512=65kHz to HCLK/2=16.757MHz, max transfer rate would be thus 8MByte/s in 4bit mode.<br> | |||
Card detection should be done at a low clock rate. For SD/MMC, the DSi starts with HCLK/128, and uses the clock specified in CSD register after detection (when extracting bits from CSD: mind the different 120bit-without-CRC vs 128bit-with-CRC notations). For SDIO, the DSi starts with HCLK/256, and switches to HCLK/2 after reading SDIO Bus Speed register (Function0:00013h).<br> | |||
The SDCLK pins are permanently pulsed, even for devices deselected via SD_CARD_PORT_SELECT.0, and even if no CMD or DATA is being transferred. However, the DSi firmware is usually stopping SDCLK via Bit8=0 when not accessing SD/MMC (doing so may reduce noise and power consumption).<br> | |||
Trying to set bit9, or to set more than one bit in bit7-0 will freeze the SDCLK output (in this case SDCLK may get stuck HIGH or LOW, unlike Bit8=0 which forces LOW). | |||
===4004808h/4004A08h - SD_STOP_INTERNAL_ACTION=== | |||
15-9 Unknown/unused (appears to be always zero) | 15-9 Unknown/unused (appears to be always zero) | ||
8 | 8 Auto-Stop (1=Automatically send CMD12 after BLK_COUNT blocks) (R/W) | ||
7-1 Unknown/unused (appears to be always zero) | 7-1 Unknown/unused (appears to be always zero) | ||
0 Unknown | 0 Unknown (R/W) | ||
Stop whatever internal action for whatever purpose in whatever situation?<br> | Stop whatever internal action for whatever purpose in whatever situation?<br> | ||
Existing code does set bit8 (prior to changing SD_DATA16_BLK_COUNT).<br> | Existing code does set bit8 (prior to changing SD_DATA16_BLK_COUNT).<br> | ||
Existing code does clear bit0 (alongsides with IRQ enable/acknowlege or so). | Existing code does clear bit0 (alongsides with IRQ enable/acknowlege or so).<br> | ||
===40048E0h/4004AE0h - SD_SOFT_RESET - Software Reset=== | |||
15-3 Unknown/unused (appears to be always zero) | |||
2 Unknown (always 1) (R?) | |||
1 Unknown (always 1) (though firmware tries to toggle this bit) (R?) | |||
0 SRST Soft Reset (0=Reset, 1=Release) (R/W) | |||
Software should apply reset after sensing card insertion/removal, and (thereafter) release reset in case of card insertion. Software reset does acknowledge all IRQs (except that from SDIO /IRQ pin?), and does probably also reinitialize some other registers.<br> | |||
Clearing bit0 does force following settings (while and as long as Bit0=0): | |||
SD_STOP_INTERNAL_ACTION = 0000h | |||
SD_RESPONSE0-7 = zerofilled | |||
SD_IRQ_STATUS0-1 = all IRQs flags acknowledged | |||
SD_CARD_CLK_CTL = bit 8 and 10 cleared | |||
SD_CARD_OPTION = 40EEh | |||
SD_CARD_INTERRUPT_CONTROL = 0000h | |||
All other registers seem to be left unaffected (including the the extra IRQ flags in 4004900h); though there may be some further hidden effects (like aborting transfers or resetting internal registers).<br> | |||
Note: The DSi firmware does issue reset by toggling both bit0 and bit1, although bit1 does seem to be read-only (always 1), and trying to clear that bit doesn't seem to have any effect at all. | |||