2009年3月23日 星期一

Linux MMC (SD)

linux-2.6.27

drivers/mmc/core/Makefile

obj-$(CONFIG_MMC)  += mmc_core.o
mmc_core-y := core.o bus.o host.o \
mmc.o mmc_ops.o sd.o sd_ops.o \
sdio.o sdio_ops.o sdio_bus.o \
sdio_cis.o sdio_io.o sdio_irq.o


drivers/mmc/core/core.c
static int __init mmc_init(void)
{
int ret;

workqueue = create_singlethread_workqueue("kmmcd");
if (!workqueue)
return -ENOMEM;

ret = mmc_register_bus();
if (ret)
goto destroy_workqueue;

ret = mmc_register_host_class();
if (ret)
goto unregister_bus;

ret = sdio_register_bus();
if (ret)
goto unregister_host_class;

return 0;

unregister_host_class:
mmc_unregister_host_class();
unregister_bus:
mmc_unregister_bus();
destroy_workqueue:
destroy_workqueue(workqueue);

return ret;
}

subsys_initcall(mmc_init);


drivers/mmc/core/bus.c
static struct bus_type mmc_bus_type = {
.name = "mmc",
.dev_attrs = mmc_dev_attrs,
.match = mmc_bus_match,
.uevent = mmc_bus_uevent,
.probe = mmc_bus_probe,
.remove = mmc_bus_remove,
.suspend = mmc_bus_suspend,
.resume = mmc_bus_resume,
};

int mmc_register_bus(void)
{
return bus_register(&mmc_bus_type);
}


drivers/mmc/core/host.c

static struct class mmc_host_class = {
.name = "mmc_host",
.dev_release = mmc_host_classdev_release,
};

int mmc_register_host_class(void)
{
return class_register(&mmc_host_class);
}


drivers/mmc/core/sdio_bus.c
static struct bus_type sdio_bus_type = {
.name = "sdio",
.dev_attrs = sdio_dev_attrs,
.match = sdio_bus_match,
.uevent = sdio_bus_uevent,
.probe = sdio_bus_probe,
.remove = sdio_bus_remove,
};

int sdio_register_bus(void)
{
return bus_register(&sdio_bus_type);
}




















drivers/mmc/card/Kconfig
config MMC_TEST
tristate "MMC host test driver"
default n
help
Development driver that performs a series of reads and writes
to a memory card in order to expose certain well known bugs
in host controllers. The tests are executed by writing to the
"test" file in sysfs under each card. Note that whatever is
on your card will be overwritten by these tests.

This driver is only of interest to those developing or
testing a host driver. Most people should say N here.

to run all test:
echo "" > /sys/class/mmc_host/mmc0/mmc0\:e624/test

to run test case 1 only:
echo 1 > /sys/class/mmc_host/mmc0/mmc0\:e624/test

http://fixunix.com/kernel/489349-mmc_test-some-results.html
http://lkml.org/lkml/2008/5/17/45

Writing Modern Linux SDIO Drivers
http://www.varsanofiev.com/inside/WritingLinuxSDIODrivers.htm

沒有留言: