Ubuntu 14.04 Realtek Semiconductor Co., Ltd. RTS5227 PCI Express Card Reader isn't working

I've read some other posts issuing this problem. But without an solution for exactly this problem. I've installed Ubuntu 14.04 on my Lenovo T440s.

Realtek Semiconductor Co., Ltd. RTS5227 PCI Express Card Reader isn't working on it.

After I pushed a SD Card into the slot, nothing happened.

# lspci

02:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS5227 PCI Express Card Reader (rev 01)
    Subsystem: Lenovo Device 220c
    Flags: fast devsel, IRQ 16
    Memory at f0500000 (32-bit, non-prefetchable) [size=4K]
    Capabilities: [40] Power Management version 3
    Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
    Capabilities: [70] Express Endpoint, MSI 00
    Capabilities: [100] Advanced Error Reporting
    Capabilities: [140] Device Serial Number 00-00-00-01-00-4c-e0-00
    Capabilities: [150] Latency Tolerance Reporting
    Capabilities: [158] L1 PM Substates

# lshw
    *-pci:0
         Beschreibung: PCI bridge
         Produkt: Lynx Point-LP PCI Express Root Port 6
         Hersteller: Intel Corporation
         Physische ID: 1c
         Bus-Informationen: pci@0000:00:1c.0
         Version: e4
         Breite: 32 bits
         Takt: 33MHz
         Fähigkeiten: pci pciexpress msi pm normal_decode bus_master cap_list
         Konfiguration: driver=pcieport
         Ressourcen: irq:17 memory:f0500000-f05fffff
       *-generic UNGEFORDERT
            Beschreibung: Unassigned class
            Produkt: RTS5227 PCI Express Card Reader
            Hersteller: Realtek Semiconductor Co., Ltd.
            Physische ID: 0
            Bus-Informationen: pci@0000:02:00.0
            Version: 01
            Breite: 32 bits
            Takt: 33MHz
            Fähigkeiten: pm msi pciexpress cap_list
            Konfiguration: latency=0
            Ressourcen: memory:f0500000-f0500fff

greetz


Solution 1:

working on MSI GE60 I've got a Realtek Semiconductor Co., Ltd. RTS5227 working on windows but not in linux mint (based on ubuntu).

ATTENTION / IMPORTANT :

use this method can possibly induce the device to not recognize the card reader after a reboot. I've not understood yet what's going on but the device seems not able to enumerate on pci bus. I fixed that by cold boot on windows (with official driver).

I found some tutorials for rts5209 and tried to adapt them :

https://vidyut.net/realtek-sd-card-reader-working-ubuntu/

http://dainaccio.wordpress.com/2013/07/14/realtek-sd-reader-mounting-problems-under-linux-mintubuntu/#more-836

I took the sources for RTS5229 from realtek website (PCIE RTS5229 card reader driver for Linux) : no more than 2 links in my message, tutorials seems more important --> google

then I had do do a little more code modification than in the linked tutorials in rtcx.c in order to build without error : comment the declaration of proc_info in the rtsx_host_template initialization line 206.

(before)
.proc_info = proc_info, 

(after)
//.proc_info = proc_info,

once I get through this I built the driver and try to go with it, but obviously the link between driver and hardware was not there.

So I took the name of my device and try to modify the code in order to have the right device name. Go in the first lines (55) of rtsx.h and adapt the definition of the device name to your need :

(before)
#define CR_DRIVER_NAME "rts5229"

(after)
#define CR_DRIVER_NAME "rts5227"

After what I modified the target of the Makefile :

(before)
TARGET_MODULE := rts5229

(after)
TARGET_MODULE := rts5227

after what

make clean
make
sudo make install
sudo depmod
sudo modprobe rts5227

verify that your device is not using rtsx_pci module (lspci -v) if its the case you need to use the Dainaccio way to fix that (near the end of second tutorial).

when your module is correctly loaded a ls /dev should show you a new interface (for me /dev/sdb) :D

In fact that's not really clean.The thing is there should be a lot more understanding of the difference between the 2 card reader version and a lot more understanding of the driver to make that work fine.

The driver is basically functional, you can mount / unmount partition, write and read on the card, insertion and removal is detected. I have not tested the automount. But anyway a lspci -v with the driver working will show you that this solution is not clean : the peripheral class is not recognized so others values I think. By a brief look in the code I also saw many reference hard-coded to rts5229. they could be some work to be done...

anyway, have a nice day !

~~~~~

Solution 2:

Upstream rtsx_pci manages the card reader.

Still Something is wrong as I had to unload then reload the driver for it to work:

# modprobe -r rtsx_pci
# modprobe rtsx_pci

PS: I have not yet reported (or even checked the issue was already reported) to upstream. I hope to do it soon though feel free to beat me at that (the onyl requirement is to have hardware that reproduce the bug).

Here on Thinkpad Yoga S1 which also ship this device:

# lspci

05:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS5227 PCI Express Card Reader (rev 01)
Subsystem: Lenovo Device 2217
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 75
Region 0: Memory at f0400000 (32-bit, non-prefetchable) [size=4K]
Capabilities: [40] Power Management version 3
    Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=375mA PME(D0-,D1+,D2+,D3hot+,D3cold+)
    Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [50] MSI: Enable+ Count=1/1 Maskable- 64bit+
    Address: 00000000fee0f00c  Data: 41e2
Capabilities: [70] Express (v2) Endpoint, MSI 00
    DevCap: MaxPayload 128 bytes, PhantFunc 0, Latency L0s unlimited, L1 unlimited
        ExtTag- AttnBtn- AttnInd- PwrInd- RBE+ FLReset-
    DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
        RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop-
        MaxPayload 128 bytes, MaxReadReq 512 bytes
    DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr+ TransPend-
    LnkCap: Port #0, Speed 2.5GT/s, Width x1, ASPM L0s L1, Exit Latency L0s unlimited, L1 <64us
        ClockPM+ Surprise- LLActRep- BwNot-
    LnkCtl: ASPM L1 Enabled; RCB 64 bytes Disabled- CommClk-
        ExtSynch- ClockPM+ AutWidDis- BWInt- AutBWInt-
    LnkSta: Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
    DevCap2: Completion Timeout: Not Supported, TimeoutDis+, LTR+, OBFF Via message/WAKE#
    DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR+, OBFF Disabled
    LnkCtl2: Target Link Speed: 2.5GT/s, EnterCompliance- SpeedDis-
         Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
         Compliance De-emphasis: -6dB
    LnkSta2: Current De-emphasis Level: -3.5dB, EqualizationComplete-, EqualizationPhase1-
         EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
Capabilities: [100 v2] Advanced Error Reporting
    UESta:  DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
    UEMsk:  DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
    UESvrt: DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
    CESta:  RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr-
    CEMsk:  RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
    AERCap: First Error Pointer: 00, GenCap+ CGenEn- ChkCap+ ChkEn-
Capabilities: [140 v1] Device Serial Number 00-00-00-01-00-4c-e0-00
Capabilities: [150 v1] Latency Tolerance Reporting
    Max snoop latency: 71680ns
    Max no snoop latency: 71680ns
Capabilities: [158 v1] L1 PM Substates
    L1SubCap: PCI-PM_L1.2+ PCI-PM_L1.1+ ASPM_L1.2+ ASPM_L1.1+ L1_PM_Substates+
          PortCommonModeRestoreTime=60us PortTPowerOnTime=60us
Kernel driver in use: rtsx_pci

Solution 3:

it was the rts_pstor driver on my Debian system. took two rmmod/modprobe cycles to get it to work.