On an embedded Linux platform, I have a network adapter attached to an SDIO interface. There is no Card Detect signal on this particular bus. If for instance, I turn the network adapter power on or off, is there any way I can force a re-scan of the SDIO bus from user space?
-
does the code within `/usr/bin/rescan-scsi-bus.sh` do this ? – ron Jul 15 '20 at 18:57
3 Answers
As mentioned by 0andriy, you can use bind/unbind. I am doing something similar but this will be different as it depends on the hardware. To unbind my sdio wifi module I use:
echo -n "2190000.usdhc" > /sys/devices/soc0/soc/2100000.aips-bus/2190000.usdhc/driver/unbind
This will give you something like mmc1: card 0001 removed in dmesg.
I then toggle a gpio pin to reset my wifi module
Then to rebind:
echo -n "2190000.usdhc" > /sys/bus/soc/devices/soc0/soc/2100000.aips-bus/2190000.usdhc/subsystem/drivers/sdhci-esdhc-imx/bind
At which point dmesg will print something like:
mmc1: SDHCI controller on 2190000.usdhc [2190000.usdhc] using ADMA
mmc1: new high speed SDIO card at address 0001
Binding/unbinding process is explained well by this old LWN.net article.
-
Note that based on the related [question](https://unix.stackexchange.com/a/291741/45713), if you are using a TI SDIO device it won't work without the interrupt. – minghua Jun 03 '18 at 06:30
Looks like there was a patch submitted to the linux-mmc mailing list to add this feature, however looking at the current source, it doesn't appear to have been added.
So unfortunately I guess this makes the answer: you can't.
- 70,657
- 19
- 188
- 223
-
1It's not fully true. Easiest way to work around is to unbind / bind cycle of the host controller. Also there is another way to simulate card detection in the driver, but it might be non-upstreamable solution. – 0andriy Sep 06 '16 at 21:34
I was able to follow the steps specified in Marius's answer in beaglebone black to successfully unbind and bind a WiFi chip connected to the mmc2(there are 3 SDIO interfaces in beaglebone mmc0, mmc1, mmc2) interface. But the path to the mmc2 interface in beaglebone black(this is tested on a Beaglebone Rev C board running the IoT Buster image) is a little different.
To unbind the sdio module execute the below command as root:
echo -n "47810000.mmc" > /sys/devices/platform/soc/subsystem/devices/47810000.mmc/driver/unbind
To bind the module:
echo -n "47810000.mmc" > /sys/devices/platform/soc/subsystem/devices/47810000.mmc/subsystem/drivers/omap_hsmmc/bind
- 11
- 2