Update sdio.c

This commit is contained in:
ruiqian 2017-07-04 00:50:48 +08:00 committed by GitHub
parent 0a798b33a5
commit 465fdfc2ff
1 changed files with 26 additions and 8 deletions

View File

@ -29,8 +29,8 @@
#ifndef RT_SDIO_STACK_SIZE #ifndef RT_SDIO_STACK_SIZE
#define RT_SDIO_STACK_SIZE 512 #define RT_SDIO_STACK_SIZE 512
#endif #endif
#ifndef RT_SDIO_THREAD_PREORITY #ifndef RT_SDIO_THREAD_PRIORITY
#define RT_SDIO_THREAD_PREORITY 0x40 #define RT_SDIO_THREAD_PRIORITY 0x40
#endif #endif
static rt_list_t sdio_cards; 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); RT_ASSERT(host->sdio_irq_sem != RT_NULL);
host->sdio_irq_thread = rt_thread_create("sdio_irq", sdio_irq_thread, host, 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) if (host->sdio_irq_thread != RT_NULL)
{ {
rt_thread_startup(host->sdio_irq_thread); rt_thread_startup(host->sdio_irq_thread);
@ -1253,6 +1253,16 @@ err:
return -RT_EIO; 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_int32_t sdio_set_block_size(struct rt_sdio_function *func,
rt_uint32_t blksize) 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, rt_inline rt_int32_t sdio_match_card(struct rt_mmcsd_card *card,
const struct rt_sdio_device_id *id) const struct rt_sdio_device_id *id)
{ {
rt_uint8_t num = 1;
if ((id->manufacturer != SDIO_ANY_MAN_ID) && if ((id->manufacturer != SDIO_ANY_MAN_ID) &&
(id->manufacturer != card->cis.manufacturer)) (id->manufacturer != card->cis.manufacturer))
return 0; 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; return 1;
num++;
}
return 0;
} }
static struct rt_mmcsd_card *sdio_match_driver(struct rt_sdio_device_id *id) static struct rt_mmcsd_card *sdio_match_driver(struct rt_sdio_device_id *id)
{ {
rt_list_t *l; rt_list_t *l;