# SD card reader in HP ProBook 450s G0

## nilreM

Hello, guys.

I'm configuring Gentoo on my new HP ProBook 450s G0. Among other features, it has internal SD/MMC card reader, which lists in lspci as "Realtek Semiconductor Co., Ltd. RTS5229 PCI Express Card Reader (rev 01)".

If I boot machine with SD card installed, card reader is listed and works as expected. Installing and removing the card causes messages in the dmesg, also udisks shows notifications etc.. The corresponding lspci output is:

```
00:00.0 Host bridge: Intel Corporation 3rd Gen Core processor DRAM Controller (rev 09)

00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)

00:14.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller (rev 04)

00:16.0 Communication controller: Intel Corporation 7 Series/C210 Series Chipset Family MEI Controller #1 (rev 04)

00:1a.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #2 (rev 04)

00:1b.0 Audio device: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)

00:1c.0 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 1 (rev c4)

00:1c.2 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 3 (rev c4)

00:1c.3 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 4 (rev c4)

00:1c.5 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 6 (rev c4)

00:1d.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #1 (rev 04)

00:1f.0 ISA bridge: Intel Corporation HM76 Express Chipset LPC Controller (rev 04)

00:1f.2 SATA controller: Intel Corporation 7 Series Chipset Family 6-port SATA Controller [AHCI mode] (rev 04)

02:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS5229 PCI Express Card Reader (rev 01)

03:00.0 Network controller: Ralink corp. RT3290 Wireless 802.11n 1T/1R PCIe

03:00.1 Bluetooth: Ralink corp. RT3290 Bluetooth

04:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 0c)
```

In dmesg were some related messages::

```
[    1.671078] pci 0000:02:00.0: [10ec:5229] type 00 class 0xff0000

[    1.671103] pci 0000:02:00.0: reg 10: [mem 0xd0700000-0xd0700fff]

[    1.671272] pci 0000:02:00.0: supports D1 D2

[    1.671273] pci 0000:02:00.0: PME# supported from D1 D2 D3hot

...

[    1.854614] pci 0000:02:00.0: Signaling PME through PCIe PME interrupt

...

[    3.101202] rtsx_pci 0000:02:00.0: irq 46 for MSI/MSI-X

[    3.101215] rtsx_pci 0000:02:00.0: rtsx_pci_acquire_irq: pcr->msi_en = 1, pci->irq = 46
```

So far, so good. But, if I boot machine without the card, the card reader is absent. lspci shows no line

```
02:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS5229 PCI Express Card Reader (rev 01)
```

dmesg also doesn't contain anything about device 02:00.0. I can insert and remove cards, nothing happens in the system. No notifications, silence in dmesg.

Now, if I install card and do 

```
echo "1" > /sys/bus/pci/rescan
```

the cardreader will appear immediatly, the card is detected and shows usual notifications. The lspci output looks now like above, dmesg shows these for the moment of rescan:

```
[  532.090303] pci 0000:02:00.0: [10ec:5229] type 00 class 0xff0000

[  532.090337] pci 0000:02:00.0: reg 10: [mem 0x00000000-0x00000fff]

[  532.090531] pci 0000:02:00.0: supports D1 D2

[  532.090533] pci 0000:02:00.0: PME# supported from D1 D2 D3hot

[  532.092283] pci 0000:02:00.0: BAR 0: assigned [mem 0xd0700000-0xd0700fff]

[  532.092349] rtsx_pci 0000:02:00.0: enabling device (0000 -> 0002)

[  532.092464] rtsx_pci 0000:02:00.0: irq 50 for MSI/MSI-X

[  532.092483] rtsx_pci 0000:02:00.0: rtsx_pci_acquire_irq: pcr->msi_en = 1, pci->irq = 50
```

(rtsx_pci is the card reader driver)

Now, the system works just like if I booted it with card in there. Even if I rescan pci bus without card, card reader wouldn't disappear.

I thought it might have something to do with PCI hotplug (which was disabled - the laptop has no expresscard slots, so no way to hotplug anything into PCI bus in runtime). I rebuilt the kernel, adding the support for hotplug (everything I expect to be needed for work):

```
CONFIG_HOTPLUG_PCI_PCIE=y

CONFIG_PCI_IOAPIC=y

CONFIG_HOTPLUG_PCI=y

CONFIG_HOTPLUG_PCI_ACPI=y
```

But this showed no differences.

What is going? I have a workaround, but it isn't convinient to always run some script as root when I first time insert a card. How do I get rid of this issue?

The kernel I use is lastest stable gentoo-sources-3.10.25 built with lastest stable genkernel-3.4.45.1

----------

## sebB

According to this you need

```
CONFIG_MFD_RTSX_PCI=m

CONFIG_MMC_REALTEK_PCI=m

CONFIG_MEMSTICK_REALTEK_PCI=m
```

----------

## nilreM

I have read that thread.

I have first two as "Y", compiled in-kernel. Memstick is N, because it is for Sony MemoryStick cards, and this laptop doesn't support them. Although, I tried to build everything (including memstick) as modules, with no difference.

I also tried to use sys-block/rts5229 instead of in-tree driver. This showed some unimportant differences (devices look like /dev/sdX instead of /dev/mmcblkX), but the general behaviour looked exactly like this: no device in lspci unless booted with card inserted or rescanned PCI bus with card inserted. No uevents or something when card is inserted in this case. But, when the device appeared in lspci (no matter was it booted with card in, or rescanned the bus afterwards), everything works: card insertion generates kernel events and udev reacts as expected.

From this I can deduce that all drivers it needs to work are built and working. I don't need to check device drivers.

It looks like system firmware disables card reader when it is unused to save energy. So, it might be a power management issue. What do I check about this, as if I am completely dumb in this matter?

----------

## sebB

 *Quote:*   

> I have first two as "Y"

 

Try compiling them as module (M)

----------

## v_andal

 *nilreM wrote:*   

> I have read that thread.
> 
> From this I can deduce that all drivers it needs to work are built and working. I don't need to check device drivers.
> 
> It looks like system firmware disables card reader when it is unused to save energy.

 

There's option CONFIG_MMC_RICOH_MMC. I don't know if it would help, but maybe you should try. From my own experience, it's no so simple to get SD cards reader to work under Linux. I had to use driver for Memory Stick to get my SD Card reader working (also Ricoh controller).

----------

