UDEV trigger for SD card insert and remove in iMX28 Linux 2.6.35

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

UDEV trigger for SD card insert and remove in iMX28 Linux 2.6.35

Jump to solution
2,728 Views
emanuelec
Contributor III

I have my bord based on iMX28 + LTIB + Linux 2.6.35 (design based on iMX28 EVK).

I use internal FLASH and sometimes I need to plug external mass storage like USB pendrive o SD card. I wrote my custom udev rules for manage my external devices. When I insert/remove pendrive all works fine: udev receives trigger on connect (ADD) and on disconnect (REMOVE). When I try to do the same actions with SD card (mmc0) sometimes I don't receive any plug notification: if I see DUART terminal, there are no messages and no udev rules triggered (if all works fine, for example, when I remove sd card I see a message like "mmc0: card removed" in duart console). If I look for mmc0 (all partitions) object in my sysfs, in effect I don't see any entry to sd card.

May be this a problem in sd driver? Is there a patch?

Please note: if I plug sd card and after I turn on my device, the rule "ADD" is always triggered and also REMOVE rule is correctly triggered.


Thanks.


Emanuele

Labels (2)
0 Kudos
1 Solution
1,104 Views
emanuelec
Contributor III

SOLVED!

I found a workaround.

The problem is:

when I plug SD card inside SD card connector, mmc driver detects the card via mxs_mmc_is_plugged function (file: mxs-mmc.c). But tested flag is not correctly set (I think) because it doesn't reflect the status of SSP_DETECT pin. This because the flag is set when sd card is not completely inserted inside sd connector: this flag is set just when gold connectors of sd card connect the pins of the sd slot. SSPx_DETECT pin is moved only when SD card is completely inserted in sd slot because there is a switch inside the sd connector that electrically put SSPx_DETECT to ground (or VCC when released).

Workaround I use is simple (function: mxs_mmc_detect_poll, file: mxs-mmc.c):

[..]

card_status = mxs_mmc_is_plugged(host);

if(card_status != host->present && card_status == 1 && numTry < 5) {

numTry++;

card_status = host->present;

} else {

numTry = 0;

}

if (card_status != host->present)

[..]

I simply wait few seconds after plug detection. In this time I suppose the sd card is correctly inserted inside sd connector...

View solution in original post

0 Kudos
1 Reply
1,105 Views
emanuelec
Contributor III

SOLVED!

I found a workaround.

The problem is:

when I plug SD card inside SD card connector, mmc driver detects the card via mxs_mmc_is_plugged function (file: mxs-mmc.c). But tested flag is not correctly set (I think) because it doesn't reflect the status of SSP_DETECT pin. This because the flag is set when sd card is not completely inserted inside sd connector: this flag is set just when gold connectors of sd card connect the pins of the sd slot. SSPx_DETECT pin is moved only when SD card is completely inserted in sd slot because there is a switch inside the sd connector that electrically put SSPx_DETECT to ground (or VCC when released).

Workaround I use is simple (function: mxs_mmc_detect_poll, file: mxs-mmc.c):

[..]

card_status = mxs_mmc_is_plugged(host);

if(card_status != host->present && card_status == 1 && numTry < 5) {

numTry++;

card_status = host->present;

} else {

numTry = 0;

}

if (card_status != host->present)

[..]

I simply wait few seconds after plug detection. In this time I suppose the sd card is correctly inserted inside sd connector...

0 Kudos