From ae8ca610515ab0461eff44a8c9eb08654ba88279 Mon Sep 17 00:00:00 2001 From: ruiqian Date: Tue, 4 Jul 2017 00:48:53 +0800 Subject: [PATCH 1/5] Update mmcsd_card.h --- components/drivers/include/drivers/mmcsd_card.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/drivers/include/drivers/mmcsd_card.h b/components/drivers/include/drivers/mmcsd_card.h index 4a82bc58f..18470a5ea 100644 --- a/components/drivers/include/drivers/mmcsd_card.h +++ b/components/drivers/include/drivers/mmcsd_card.h @@ -135,6 +135,8 @@ struct rt_sdio_function { rt_uint32_t enable_timeout_val; /* max enable timeout in msec */ struct rt_sdio_function_tuple *tuples; + + void *priv; }; #define SDIO_MAX_FUNCTIONS 7 From 1590e38f46473420e1958f72873795d05c372bd2 Mon Sep 17 00:00:00 2001 From: ruiqian Date: Tue, 4 Jul 2017 00:49:23 +0800 Subject: [PATCH 2/5] Update mmcsd_host.h --- components/drivers/include/drivers/mmcsd_host.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/drivers/include/drivers/mmcsd_host.h b/components/drivers/include/drivers/mmcsd_host.h index 3b68058ba..877a04d8e 100644 --- a/components/drivers/include/drivers/mmcsd_host.h +++ b/components/drivers/include/drivers/mmcsd_host.h @@ -111,7 +111,7 @@ struct rt_mmcsd_host { rt_uint32_t max_blk_count; /* maximum block count */ rt_uint32_t spi_use_crc; - struct rt_semaphore bus_lock; + struct rt_mutex bus_lock; struct rt_semaphore sem_ack; rt_uint32_t sdio_irq_num; From bf48d2b7454b17c0470892238c4d8fb1ea7524f1 Mon Sep 17 00:00:00 2001 From: ruiqian Date: Tue, 4 Jul 2017 00:49:50 +0800 Subject: [PATCH 3/5] Update sdio.h --- components/drivers/include/drivers/sdio.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/drivers/include/drivers/sdio.h b/components/drivers/include/drivers/sdio.h index 5f6588295..2cd1c7dfd 100644 --- a/components/drivers/include/drivers/sdio.h +++ b/components/drivers/include/drivers/sdio.h @@ -229,6 +229,8 @@ rt_int32_t sdio_detach_irq(struct rt_sdio_function *func); void sdio_irq_wakeup(struct rt_mmcsd_host *host); rt_int32_t sdio_enable_func(struct rt_sdio_function *func); rt_int32_t sdio_disable_func(struct rt_sdio_function *func); +void sdio_set_drvdata(struct rt_sdio_function *func, void *data); +void* sdio_get_drvdata(struct rt_sdio_function *func); rt_int32_t sdio_set_block_size(struct rt_sdio_function *func, rt_uint32_t blksize); rt_int32_t sdio_register_driver(struct rt_sdio_driver *driver); From 0a798b33a513e754538bb59328c0f3bde611cb20 Mon Sep 17 00:00:00 2001 From: ruiqian Date: Tue, 4 Jul 2017 00:50:25 +0800 Subject: [PATCH 4/5] Update mmcsd_core.c --- components/drivers/sdio/mmcsd_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/drivers/sdio/mmcsd_core.c b/components/drivers/sdio/mmcsd_core.c index adda6a491..02063efdd 100644 --- a/components/drivers/sdio/mmcsd_core.c +++ b/components/drivers/sdio/mmcsd_core.c @@ -49,12 +49,12 @@ static rt_uint32_t mmcsd_hotpluge_mb_pool[4]; void mmcsd_host_lock(struct rt_mmcsd_host *host) { - rt_sem_take(&host->bus_lock, RT_WAITING_FOREVER); + rt_mutex_take(&host->bus_lock, RT_WAITING_FOREVER); } void mmcsd_host_unlock(struct rt_mmcsd_host *host) { - rt_sem_release(&host->bus_lock); + rt_mutex_release(&host->bus_lock); } void mmcsd_req_complete(struct rt_mmcsd_host *host) @@ -713,7 +713,7 @@ struct rt_mmcsd_host *mmcsd_alloc_host(void) host->max_blk_size = 512; host->max_blk_count = 4096; - rt_sem_init(&host->bus_lock, "sd_bus_lock", 1, RT_IPC_FLAG_FIFO); + rt_mutex_init(&host->bus_lock, "sd_bus_lock", RT_IPC_FLAG_FIFO); rt_sem_init(&host->sem_ack, "sd_ack", 0, RT_IPC_FLAG_FIFO); return host; @@ -721,7 +721,7 @@ struct rt_mmcsd_host *mmcsd_alloc_host(void) void mmcsd_free_host(struct rt_mmcsd_host *host) { - rt_sem_detach(&host->bus_lock); + rt_mutex_detach(&host->bus_lock); rt_sem_detach(&host->sem_ack); rt_free(host); } From 465fdfc2fff22abc6444b6d700e10621bc622d77 Mon Sep 17 00:00:00 2001 From: ruiqian Date: Tue, 4 Jul 2017 00:50:48 +0800 Subject: [PATCH 5/5] Update sdio.c --- components/drivers/sdio/sdio.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/components/drivers/sdio/sdio.c b/components/drivers/sdio/sdio.c index 59f1456e6..496765854 100644 --- a/components/drivers/sdio/sdio.c +++ b/components/drivers/sdio/sdio.c @@ -29,8 +29,8 @@ #ifndef RT_SDIO_STACK_SIZE #define RT_SDIO_STACK_SIZE 512 #endif -#ifndef RT_SDIO_THREAD_PREORITY -#define RT_SDIO_THREAD_PREORITY 0x40 +#ifndef RT_SDIO_THREAD_PRIORITY +#define RT_SDIO_THREAD_PRIORITY 0x40 #endif static rt_list_t sdio_cards; @@ -1059,7 +1059,7 @@ static rt_int32_t sdio_irq_thread_create(struct rt_mmcsd_card *card) RT_ASSERT(host->sdio_irq_sem != RT_NULL); host->sdio_irq_thread = rt_thread_create("sdio_irq", sdio_irq_thread, host, - RT_SDIO_STACK_SIZE, RT_SDIO_THREAD_PREORITY, 20); + RT_SDIO_STACK_SIZE, RT_SDIO_THREAD_PRIORITY, 20); if (host->sdio_irq_thread != RT_NULL) { rt_thread_startup(host->sdio_irq_thread); @@ -1079,7 +1079,7 @@ static rt_int32_t sdio_irq_thread_delete(struct rt_mmcsd_card *card) if (!host->sdio_irq_num) { if (host->flags & MMCSD_SUP_SDIO_IRQ) - host->ops->enable_sdio_irq(host, 0); + host->ops->enable_sdio_irq(host, 0); rt_sem_delete(host->sdio_irq_sem); host->sdio_irq_sem = RT_NULL; rt_thread_delete(host->sdio_irq_thread); @@ -1253,6 +1253,16 @@ err: return -RT_EIO; } +void sdio_set_drvdata(struct rt_sdio_function *func, void *data) +{ + func->priv = data; +} + +void* sdio_get_drvdata(struct rt_sdio_function *func) +{ + return func->priv; +} + rt_int32_t sdio_set_block_size(struct rt_sdio_function *func, rt_uint32_t blksize) { @@ -1284,16 +1294,24 @@ rt_int32_t sdio_set_block_size(struct rt_sdio_function *func, rt_inline rt_int32_t sdio_match_card(struct rt_mmcsd_card *card, const struct rt_sdio_device_id *id) { + rt_uint8_t num = 1; + if ((id->manufacturer != SDIO_ANY_MAN_ID) && (id->manufacturer != card->cis.manufacturer)) return 0; - if ((id->product != SDIO_ANY_PROD_ID) && - (id->product != (card->cis.product | 1))) - return 0; + + while (num <= card->sdio_function_num) + { + if ((id->product != SDIO_ANY_PROD_ID) && + (id->product == card->sdio_function[num]->product)) + return 1; + num++; + } - return 1; + return 0; } + static struct rt_mmcsd_card *sdio_match_driver(struct rt_sdio_device_id *id) { rt_list_t *l;