O2 SD-Card Reader fix Linux

Posted by JeremyL on Fri 08 November 2013

If you are like me and have a device with the O2 Micro, Inc. Integrated MMC/SD Controller you may have ran into problems getting your SD-Card to be work. You may have hit one of the following errors when you do:

Disable ADMA to workaround a sequence of errors which looks like:
mmc0: error -110 whilst initializing SD card
mmc0: ADMA error
mmc0: Got data interrupt 0x02000000 even though no data operation was in progress.

[  +7.696725] mmc0: ADMA error
[  +0.000126] mmc0: error -5 whilst initializing SD card

The laptop I have has had this problem since I got at the end of 2010. This is on a Toshiba Qosmio x505-887. What you need to do work around the issue is add in a quirk. I have done this on Arch Linux and Ubuntu, but should work for all other Linux variants. Since I have started seeing this error pop up more again I decided I should make a post for it.

How to fix

You need to create a new file in

/etc/modprobe.d

sudo vim /etc/modprobe.d/sd-card-fix.conf

Put the following inside the new file.

options sdhci debug_quirks=0x40

From here you will need to rebuild your initramfs so this will stay in effect through reboots.
Arch Linux

sudo mkinitcpio -p NameOfYourKernel
example:
sudo mkinitcpio -p linux

Ubuntu or Debian variants

sudo update-initramfs -u

Fedora or Red Hat variants such as CentOS

mkinitrd /boot/initrd-$(uname -r).new.img $(uname -r)

Just do a quick reboot and all will be well.
Once you're back logged in you can insert your card and it will be read properly, you should see a similar output to this.

[  +5.532544] mmc0: new high speed SDHC card at address e624
[  +0.045797] mmcblk0: mmc0:e624 SU08G 7.40 GiB 
[  +0.011842]  mmcblk0: p1 p2 < p5 p6 >