2020
2121
2222#define  DBG_TAG   "MMC"
23- // #define DBG_LVL DBG_LOG      
24- // #define DBG_LVL DBG_INFO     
23+ // #define DBG_LVL DBG_LOG 
24+ // #define DBG_LVL DBG_INFO 
2525#define  DBG_LVL  DBG_WARNING
26- // #define DBG_LVL DBG_ERROR    
26+ // #define DBG_LVL DBG_ERROR 
2727#include  <rtdbg.h> 
2828
2929#ifdef  RT_USING_SDIO 
3333struct  mmc_xfe_des 
3434{
3535    rt_uint32_t  size ;    /* block size  */ 
36- 	 rt_uint32_t  num ;     /* block num   */ 
37- 	 rt_uint8_t  * buff ;    /* buff addr   */ 
38- 	 rt_uint32_t  flag ;    /* write or read or stream */ 
39- #define  MMC_DATA_WRITE 	 (1 << 0)
40- #define  MMC_DATA_READ 	 (1 << 1)
41- #define  MMC_DATA_STREAM 	 (1 << 2)
36+      rt_uint32_t  num ;     /* block num   */ 
37+      rt_uint8_t  * buff ;    /* buff addr   */ 
38+      rt_uint32_t  flag ;    /* write or read or stream */ 
39+ #define  MMC_DATA_WRITE    (1 << 0)
40+ #define  MMC_DATA_READ     (1 << 1)
41+ #define  MMC_DATA_STREAM   (1 << 2)
4242};
4343
4444struct  mmc_flag 
@@ -57,7 +57,7 @@ struct sdio_drv
5757    tina_mmc_t  mmc_des ;
5858    rt_uint8_t  * mmc_buf ;
5959    rt_uint8_t  usedma ;
60-      
60+ 
6161};
6262
6363#ifdef  CONFIG_MMC_USE_DMA 
@@ -122,7 +122,7 @@ static int mmc_update_clk(tina_mmc_t mmc)
122122    mmc -> risr_reg  =  mmc -> risr_reg ;
123123    return  RT_EOK ;
124124}
125-      
125+ 
126126static  rt_err_t  mmc_trans_data_by_dma (tina_mmc_t  mmc , struct  mmc_xfe_des  * xfe )
127127{
128128    ALIGN (32 ) static  struct  mmc_des_v4p1  pdes [128 ];  // mast ALIGN(32) 
@@ -131,7 +131,7 @@ static rt_err_t mmc_trans_data_by_dma(tina_mmc_t mmc, struct mmc_xfe_des *xfe)
131131    unsigned  length  =  xfe -> size  *  xfe -> num ;
132132    unsigned  buff_frag_num  =  length  >> SDXC_DES_NUM_SHIFT ;
133133    unsigned  remain  =  length  &  (SDXC_DES_BUFFER_MAX_LEN  -  1 );
134-      
134+ 
135135    if  (remain )
136136    {
137137        buff_frag_num  ++ ;
@@ -142,7 +142,7 @@ static rt_err_t mmc_trans_data_by_dma(tina_mmc_t mmc, struct mmc_xfe_des *xfe)
142142    }
143143    memset (pdes , 0 , sizeof (pdes ));
144144    mmu_clean_dcache ((rt_uint32_t )(xfe -> buff ), length );
145-     for  (i  =  0 , des_idx  =  0 ; i  <  buff_frag_num ; i ++ , des_idx ++ )  
145+     for  (i  =  0 , des_idx  =  0 ; i  <  buff_frag_num ; i ++ , des_idx ++ )
146146    {
147147        // memset((void*)&pdes[des_idx], 0, sizeof(struct mmc_v4p1)); 
148148        pdes [des_idx ].des_chain  =  1 ;
@@ -168,8 +168,8 @@ static rt_err_t mmc_trans_data_by_dma(tina_mmc_t mmc, struct mmc_xfe_des *xfe)
168168            pdes [des_idx ].last_des  =  1 ;
169169            pdes [des_idx ].end_of_ring  =  1 ;
170170            pdes [des_idx ].buf_addr_ptr2  =  0 ;
171-         }  
172-         else   
171+         }
172+         else 
173173        {
174174            pdes [des_idx ].buf_addr_ptr2  =  (unsigned long )& pdes [des_idx + 1 ];
175175        }
@@ -203,7 +203,7 @@ static rt_err_t mmc_trans_data_by_dma(tina_mmc_t mmc, struct mmc_xfe_des *xfe)
203203    mmc -> dmac_reg  =  (1  << 1 ) | (1  << 7 );        /* idma on              */ 
204204    rval  =  mmc -> idie_reg  &  (~3 );
205205    if  (xfe -> flag  ==  MMC_DATA_WRITE )
206-         rval  |= (1  << 0 );         
206+         rval  |= (1  << 0 );
207207    else 
208208        rval  |= (1  << 1 );
209209    mmc -> idie_reg  =  rval ;
@@ -222,7 +222,7 @@ static rt_err_t mmc_trans_data_by_cpu(tina_mmc_t mmc, struct mmc_xfe_des *xfe)
222222
223223    if  (xfe -> flag  ==  MMC_DATA_WRITE )
224224    {
225-         for  (i  =  0 ; i  <  (byte_cnt  >> 2 ); i ++ )  
225+         for  (i  =  0 ; i  <  (byte_cnt  >> 2 ); i ++ )
226226        {
227227            while (-- timeout  &&  (mmc -> star_reg  &  (1  << 3 )));
228228
@@ -237,7 +237,7 @@ static rt_err_t mmc_trans_data_by_cpu(tina_mmc_t mmc, struct mmc_xfe_des *xfe)
237237    }
238238    else 
239239    {
240-         for  (i  =  0 ; i  <  (byte_cnt  >> 2 ); i ++ )  
240+         for  (i  =  0 ; i  <  (byte_cnt  >> 2 ); i ++ )
241241        {
242242            while (-- timeout  &&  (mmc -> star_reg  &  (1  << 2 )));
243243
@@ -276,7 +276,7 @@ static rt_err_t mmc_config_clock(tina_mmc_t mmc, int clk)
276276    {
277277        mmc_set_clk (SDMMC1 , clk );
278278    }
279-      
279+ 
280280    /* Re-enable card clock */ 
281281    rval  =  mmc -> ckcr_reg ;
282282    rval  |=  (0x1  << 16 ); //(3 << 16); 
@@ -369,7 +369,7 @@ static int mmc_send_cmd(struct rt_mmcsd_host *host, struct rt_mmcsd_cmd *cmd)
369369        cmdval  |= (1  << 7 );
370370    if  ((resp_type (cmd ) !=  RESP_R3 ) &&  (resp_type (cmd ) !=  RESP_R4 ))
371371        cmdval  |= (1  << 8 );
372-      
372+ 
373373    if  (data )
374374    {
375375        cmdval  |= (1  << 9 ) | (1  << 13 );
@@ -592,7 +592,7 @@ static void sdio_request_send(struct rt_mmcsd_host *host, struct rt_mmcsd_req *r
592592
593593    memset (& sdio -> flag , 0 , sizeof (struct  mmc_flag ));
594594    mmc_send_cmd (host , req -> cmd );
595-      
595+ 
596596    return ;
597597}
598598
0 commit comments