Browse Source

Merge pull request #954 from weety/dev

[BSP][DeviceDrivers] Add MMC/SDIO initializer; Change the MMC initialization in each BSP.
Bernard Xiong 7 years ago
parent
commit
0e3397b92e

+ 0 - 3
bsp/at91sam9260/applications/application.c

@@ -73,9 +73,6 @@ int main(void)
 #endif
 #endif
 
 
 #ifdef RT_USING_SDIO
 #ifdef RT_USING_SDIO
-	rt_mmcsd_core_init();
-	rt_mmcsd_blk_init();
-	at91_mci_init();
 	timeout = 0;
 	timeout = 0;
 	while ((rt_device_find("sd0") == RT_NULL) && (timeout++ < RT_TICK_PER_SECOND*2))
 	while ((rt_device_find("sd0") == RT_NULL) && (timeout++ < RT_TICK_PER_SECOND*2))
 	{
 	{

+ 2 - 1
bsp/at91sam9260/drivers/at91_mci.c

@@ -834,7 +834,7 @@ static void mci_gpio_init()
 #endif
 #endif
 }
 }
 
 
-rt_int32_t at91_mci_init(void)
+int at91_mci_init(void)
 {
 {
 	struct rt_mmcsd_host *host;
 	struct rt_mmcsd_host *host;
 	struct at91_mci *mci;
 	struct at91_mci *mci;
@@ -903,6 +903,7 @@ err:
 	return -RT_ENOMEM;
 	return -RT_ENOMEM;
 }
 }
 
 
+INIT_DEVICE_EXPORT(at91_mci_init);
 
 
 #include "finsh.h"
 #include "finsh.h"
 FINSH_FUNCTION_EXPORT(at91_mci_init, at91sam9260 sd init);
 FINSH_FUNCTION_EXPORT(at91_mci_init, at91sam9260 sd init);

+ 1 - 1
bsp/at91sam9260/drivers/at91_mci.h

@@ -119,6 +119,6 @@
 #define AT91_MCI_IDR		0x48		/* Interrupt Disable Register */
 #define AT91_MCI_IDR		0x48		/* Interrupt Disable Register */
 #define AT91_MCI_IMR		0x4c		/* Interrupt Mask Register */
 #define AT91_MCI_IMR		0x4c		/* Interrupt Mask Register */
 
 
-extern rt_int32_t at91_mci_init(void);
+extern int at91_mci_init(void);
 
 
 #endif
 #endif

+ 0 - 3
bsp/dm365/applications/application.c

@@ -67,9 +67,6 @@ int main(void)
 #endif
 #endif
 
 
 #ifdef RT_USING_SDIO
 #ifdef RT_USING_SDIO
-	rt_mmcsd_core_init();
-	rt_mmcsd_blk_init();
-	rt_hw_mmcsd_init();
 	timeout = 0;
 	timeout = 0;
 	while ((rt_device_find("sd0") == RT_NULL) && (timeout++ < RT_TICK_PER_SECOND*2))
 	while ((rt_device_find("sd0") == RT_NULL) && (timeout++ < RT_TICK_PER_SECOND*2))
 	{
 	{

+ 4 - 1
bsp/dm365/drivers/mmcsd.c

@@ -1388,7 +1388,7 @@ static void rt_hw_edma_init(void)
 ** µ÷ÓÃÄ£¿é: ÎÞ
 ** µ÷ÓÃÄ£¿é: ÎÞ
 **
 **
 ********************************************************************************************************/
 ********************************************************************************************************/
-rt_int32_t rt_hw_mmcsd_init(void)
+int rt_hw_mmcsd_init(void)
 {
 {
 	struct clk  *clk;
 	struct clk  *clk;
 	struct mmc_dm365_host *dm365_host;
 	struct mmc_dm365_host *dm365_host;
@@ -1477,3 +1477,6 @@ err:
 
 
 	return -RT_ENOMEM;
 	return -RT_ENOMEM;
 }
 }
+
+INIT_DEVICE_EXPORT(rt_hw_mmcsd_init);
+

+ 1 - 1
bsp/dm365/drivers/mmcsd.h

@@ -140,6 +140,6 @@ typedef struct {
 	volatile rt_uint32_t MMCFIFOCTL;
 	volatile rt_uint32_t MMCFIFOCTL;
 }mmcsd_regs_t;
 }mmcsd_regs_t;
 
 
-extern rt_int32_t rt_hw_mmcsd_init(void);
+extern int rt_hw_mmcsd_init(void);
 
 
 #endif
 #endif

+ 0 - 4
bsp/fh8620/platform/fh8620/iot_cam/board.c

@@ -584,10 +584,6 @@ void rt_board_driver_init(){
 
 
 #ifdef RT_USING_SDIO
 #ifdef RT_USING_SDIO
 #ifndef RT_USING_WIFI_MARVEL
 #ifndef RT_USING_WIFI_MARVEL
-    rt_mmcsd_core_init();
-	rt_kprintf("MMC CORE initialized!\n");
-    rt_mmcsd_blk_init();
-	rt_kprintf("MMC BLK initialized!\n");
     rt_hw_mmc_init();
     rt_hw_mmc_init();
 	rt_kprintf("MMC initialized!\n");
 	rt_kprintf("MMC initialized!\n");
     rt_thread_delay(RT_TICK_PER_SECOND*2);
     rt_thread_delay(RT_TICK_PER_SECOND*2);

+ 0 - 3
bsp/imxrt1052-evk/drivers/drv_sdio.c

@@ -554,9 +554,6 @@ err:
 
 
 int imxrt_mci_init(void)
 int imxrt_mci_init(void)
 {
 {
-    
-    rt_mmcsd_core_init();
-	rt_mmcsd_blk_init();
     /* initilize sd card */
     /* initilize sd card */
     _imxrt_mci_init();
     _imxrt_mci_init();
     
     

+ 0 - 3
bsp/x1000/applications/mnt.c

@@ -30,9 +30,6 @@
 int mnt_init(void)
 int mnt_init(void)
 {
 {
 #ifdef RT_USING_SDIO
 #ifdef RT_USING_SDIO
-    rt_mmcsd_core_init();
-    rt_mmcsd_blk_init();
-
     jz47xx_sdio_init();
     jz47xx_sdio_init();
     rt_thread_delay(RT_TICK_PER_SECOND * 1);
     rt_thread_delay(RT_TICK_PER_SECOND * 1);
 
 

+ 2 - 2
components/drivers/include/drivers/mmcsd_core.h

@@ -247,9 +247,9 @@ void mmcsd_change(struct rt_mmcsd_host *host);
 void mmcsd_detect(void *param);
 void mmcsd_detect(void *param);
 struct rt_mmcsd_host *mmcsd_alloc_host(void);
 struct rt_mmcsd_host *mmcsd_alloc_host(void);
 void mmcsd_free_host(struct rt_mmcsd_host *host);
 void mmcsd_free_host(struct rt_mmcsd_host *host);
-void rt_mmcsd_core_init(void);
+int rt_mmcsd_core_init(void);
 
 
-void rt_mmcsd_blk_init(void);
+int rt_mmcsd_blk_init(void);
 rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card);
 rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card);
 void rt_mmcsd_blk_remove(struct rt_mmcsd_card *card);
 void rt_mmcsd_blk_remove(struct rt_mmcsd_card *card);
 
 

+ 5 - 2
components/drivers/sdio/block_dev.c

@@ -479,8 +479,11 @@ void rt_mmcsd_blk_remove(struct rt_mmcsd_card *card)
  * @deprecated since 2.1.0, this function does not need to be invoked
  * @deprecated since 2.1.0, this function does not need to be invoked
  * in the system initialization.
  * in the system initialization.
  */
  */
-void rt_mmcsd_blk_init(void)
+int rt_mmcsd_blk_init(void)
 {
 {
-	/* nothing */
+    /* nothing */
+    return 0;
 }
 }
 
 
+INIT_PREV_EXPORT(rt_mmcsd_blk_init);
+

+ 3 - 1
components/drivers/sdio/mmcsd_core.c

@@ -726,7 +726,7 @@ void mmcsd_free_host(struct rt_mmcsd_host *host)
     rt_free(host);
     rt_free(host);
 }
 }
 
 
-void rt_mmcsd_core_init(void)
+int rt_mmcsd_core_init(void)
 {
 {
     rt_err_t ret;
     rt_err_t ret;
 
 
@@ -751,3 +751,5 @@ void rt_mmcsd_core_init(void)
     rt_sdio_init();
     rt_sdio_init();
 }
 }
 
 
+INIT_PREV_EXPORT(rt_mmcsd_core_init);
+

+ 13 - 0
include/rtservice.h

@@ -141,6 +141,19 @@ rt_inline unsigned int rt_list_len(const rt_list_t *l)
          &pos->member != (head);    \
          &pos->member != (head);    \
          pos = rt_list_entry(pos->member.next, typeof(*pos), member))
          pos = rt_list_entry(pos->member.next, typeof(*pos), member))
 
 
+/**
+ * rt_list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
+ * @pos:    the type * to use as a loop cursor.
+ * @n:      another type * to use as temporary storage
+ * @head:   the head for your list.
+ * @member: the name of the list_struct within the struct.
+ */
+#define rt_list_for_each_entry_safe(pos, n, head, member)           \
+    for (pos = rt_list_entry((head)->next, typeof(*pos), member),   \
+         n = rt_list_entry(pos->member.next, typeof(*pos), member);  \
+         &pos->member != (head);    \
+         pos = n, n = rt_list_entry(n->member.next, typeof(*n), member))
+
 /**
 /**
  * rt_list_first_entry - get the first element from a list
  * rt_list_first_entry - get the first element from a list
  * @ptr:    the list head to take the element from.
  * @ptr:    the list head to take the element from.