1 /*
2  * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
3  *
4  * SPDX-License-Identifier: Apache-2.0.
5  *
6  * @Date: 2021-03-31 14:59:20
7  * @LastEditTime: 2021-05-25 16:46:46
8  * @Description:  This files is for sd ctrl register-related implementations
9  *
10  * @Modify History: * * Ver   Who        Date         Changes
11  * ----- ------     --------    --------------------------------------
12  */
13 
14 #include "ft_sdctrl_hw.h"
15 #include "ft_sdctrl.h"
16 
17 #include "ft_io.h"
18 #include "ft_types.h"
19 #include "ft_assert.h"
20 #include "ft_generic_timer.h"
21 
FSdCtrl_Reset(FT_INOUT FtsdCtrl_t * pFtsdCtrl,pFtsdCtrl_delayTimer_t fDelayTimer)22 void FSdCtrl_Reset(FT_INOUT FtsdCtrl_t *pFtsdCtrl, pFtsdCtrl_delayTimer_t fDelayTimer)
23 {
24     FSdCtrl_Config_t *pConfig;
25     Ft_assertVoid(FT_NULL != pFtsdCtrl);
26 
27     pConfig = &pFtsdCtrl->config;
28     /* trigger software reset for 1us */
29     Ft_setBit32(pConfig->baseAddress + SOFTWARE_RESET_REG_OFFSET, SOFTWARE_RESET_SRST);
30     /* Wait for reset is ok */
31     Ft_GenericTimer_UsDelay(1);
32     Ft_clearBit32(pConfig->baseAddress + SOFTWARE_RESET_REG_OFFSET, SOFTWARE_RESET_SRST);
33 
34     /* wait dat[0] to be high-lev */
35     while ((!(Ft_in32(pConfig->baseAddress + STATUS_REG) & STATUS_REG_DLSL(1))))
36     {
37         fDelayTimer(1);
38     }
39 
40     return;
41 }
42