Other Parts Discussed in Thread: OMAP-L138
Hi
I'm experiencing a problem with using SD cards in Linux on Logic's OMAP-L138 eXperimenter Kit. When I compile the kernel to support SD cards (http://tiexpressdsp.com/index.php/GSG:_Building_Software_Components_for_OMAP-L138#Driver_configuration_in_the_Linux_kernel) system detects them, but always as read-only:
mmc0: new SDHC card at address 0007
mmcblk1: mmc0:0007 SD16G 15.3 GiB (ro)
mmcblk1:
I checked this on several cards. I also checked the setting of the "lock" switch on them. I looked into the kernel source and prink'd some of values returned by functions that seem to check if the card is read only or not (marked with ***):
***config->get_ro(pdev->id): 2
***config->get_ro(pdev->id): 2
mmc0: new SDHC card at address 0007
***mmc_card_readonly: 2, card->csd.cmdclass & CCC_BLOCK_WRITE: 16
mmcblk1: mmc0:0007 SD16G 15.3 GiB (ro)
The mmc_card_readonly function and card->csd.cmdclass & CCC_BLOCK_WRITE values are used in a function mmc_blk_readonly(struct mmc_card *card) in /drivers/mmc/card/block.c:
static inline int mmc_blk_readonly(struct mmc_card *card)
{
return mmc_card_readonly(card) ||
!(card->csd.cmdclass & CCC_BLOCK_WRITE);
}
When I set this return manually to 0, the card is detected as writalbe, and I can save data on it.
config->get_ro(pdev->id) is returned by mmc_davinci_get_ro(struct mmc_host *mmc) in /drivers/mmc/host/davinci.c:
static int mmc_davinci_get_ro(struct mmc_host *mmc)
{
struct platform_device *pdev = to_platform_device(mmc->parent);
struct davinci_mmc_config *config = pdev->dev.platform_data;
if (!config || !config->get_ro)
return -ENOSYS;
return config->get_ro(pdev->id);
}
This seems to be small driver bug. I will correct it, unless you already have a solution.
The kernel version is 2.6.31-rc7-davinci1 from OMAP-L138_C6748 1_00_00_06 package.
----------EDIT----------
The problem seems to lie in function da850_evm_mmc_get_ro from /arch/arm/mach-davinci/board-da-850-evm.c
static int da850_evm_mmc_get_ro(int index)
{
return gpio_get_value(DA850_MMCSD_WP_PIN);
}
This function returns 2, no matter if the SD card is in locked state or not.