tizen 2.4 release
[kernel/u-boot-tm1.git] / modem_boot / sdio_channel_api.c
1 #include <config.h>
2 #include <common.h>
3 #include "../drivers/sdio/sdio_api.h"
4 #define mdelay(x)       udelay(1000*x)
5 //#define __DEBUG__
6 SDIO_HANDLE     sdio_handle=NULL;
7 extern int  req_clk_status(void);
8 extern void req_clk_init(void);
9 void sdio_channel_open(void)
10 {
11         int status;
12         status = req_clk_status();
13         printf("Clock_Req(W) = %d \n",status);
14  //       do{status = req_clk_status();}while(status==0);
15         sdio_handle = sdio_open();
16         
17 }
18 /******************************************************************************
19 **  Description:    This function is used to read data from MODEM by SPI BUS.
20 **  Author:         jiayong.yang
21 **  parameter:      buffer is used to save data from MODEM
22 **                  len is length of data to be read. 
23 ******************************************************************************/
24 int sdio_channel_read(unsigned char *buffer,int len)
25 {
26     unsigned long status;
27     int ret;
28     
29     if(sdio_handle == NULL)
30         return 0;
31     status = req_clk_status();
32     //printf("(R) = %d \n",status);
33     do{status = req_clk_status();}while(status==0);
34     
35     ret = sdio_read (sdio_handle,buffer,len);
36     //do{status = req_clk_status();}while(status);
37     return ret;
38 }
39 /******************************************************************************
40 **  Description:    This function is used to send data to MODEM by SPI BUS.
41 **  Author:         jiayong.yang
42 **  parameter:      buffer is used to save data from MODEM
43 **                  len is length of data to be read. 
44 ******************************************************************************/
45 int sdio_channel_write(unsigned char *buffer,int len)
46 {
47     unsigned long status;
48     int ret;
49     
50     
51     if(sdio_handle == NULL)
52         return 0;
53     status = req_clk_status();
54     //printf("(W) = %d \n",status);
55     do{status = req_clk_status();}while(status==0);
56     ret = sdio_write (sdio_handle,buffer,len);
57
58     return ret;
59 }
60 void sdio_channel_close(void)
61 {
62     if(sdio_handle!=NULL)
63     {
64         sdio_close(sdio_handle);
65         sdio_handle = NULL;
66     }
67 }
68