I started trying to wade through the u-boot driver (sdhci.c), however it's set up to handle multiple different processors, using a lot of conditionals that can be hard to track down. The manufacturer of the board we're using suggested I use the SDK instead. I originally started with that, so my code isn't much different. The code they pointed me to couldn't even do a cmd_config/send cmd - it failed sending a CMD0. The card I'm using is just a 16GB SDHC card.
My command sequenence is:
CMD0
CMD8
CMD55/ACMD41
at this point I know I have a 3.3V HC card
CMD2 (read CID)
CMD3 (get RCA)
CMD9 (get CSD - gets card capacity)
CMD7 - go to transfer mode
CMD16 - set block size to 512 bytes
CMD6 to set bus width to 4 bits
Then I set the clock speed to 25 MHz
This concludes the initialization sequence. I have verified that the card is in TRAN mode using CMD13
I don't know how familiar you are with the iMX6Q uSDHC controller but I start the read by setting the card block length (again) to 512 bytes (CMD16)
Clear the controller read FIFO
set the watermark/burst count register
If you're familiar with ADMA2 - I set up the ADMA2 descriptor (only one is needed) and set the address to it in the ADSADDR reg
call cmd_config which sets up the values needed to send a command
call send_cmd which writes the BLK_ATTR reg (block count = 1 and block size = 512; write the MIX reg, and then the XFERTYP reg
The INTSTAT reg tells me the command was accepted (CC bit)
Wait for TC bit to set (or some error)
Transfer shows complete - no errors; no ADMA errors (DMA_ERR_STATUS = 0)
Before I do the read, I preset the user buffer with 0x5A so I'll know if anything happened. When the read finishes, the buffer is mostly filled with 0x00 so I know something happened. One odd thing is that the last two bytes are correct. Somewhere I have an SDHC card extender. I'll have to find it and check the voltage levels. The pins on the SD card socket are buried under the socket.
I'm not sure if what you mean by going to a higher freq (50 MHz??). The board I'm using doesn't support 1.8V operation so can't use CMD11.
The GPIO pins are set to:
// CD3_CMD on SD3_CMD - ALT 0
IOMUXC_SW_MUX_CTL_PAD_SD3_CMD = PAD_ALT_FUNC_0;
IOMUXC_SW_PAD_CTL_PAD_SD3_CMD = PAD_CTL_PUS_100K_PU |
PAD_CTL_ODE_DISABLED |
PAD_CTL_SPEED_MED |
PAD_CTL_DSE_38ohm |
PAD_CTL_HYS_ENABLED |
PAD_CTL_SRE_FAST;
which is what the SDK uses. What do you think?