tizen 2.4 release
[profile/mobile/platform/kernel/u-boot-tm1.git] / modem_boot / spi_channel_api.c
1 #include <common.h>
2 #include <linux/types.h>
3
4 #define SPI_PORT        0
5 extern int spi_channel_read (unsigned long dev_id,unsigned char *buffer_ptr,int len);
6 extern int spi_channel_write (unsigned long dev_id,unsigned char *buffer_ptr,int len);
7 extern void spi_channel_open (unsigned long phy_id,unsigned long mode,unsigned long tx_bit_length);
8 extern void dump_spi_registers(unsigned long phy_id);
9 extern int  spi_channel_status(void);
10
11 void SPI_channel_open(void)
12 {
13         spi_channel_open(0,1,32);
14         dump_spi_registers(0);
15         req_clk_init();
16 }
17 /******************************************************************************
18 **  Description:    This function is used to read data from MODEM by SPI BUS.
19 **  Author:         jiayong.yang
20 **  parameter:      buffer is used to save data from MODEM
21 **                  len is length of data to be read. 
22 ******************************************************************************/
23 int SPI_channel_read(unsigned char *buffer,int len)
24 {
25     unsigned long status;
26     int ret;
27     do{status = req_clk_status();}while(status==0);
28     ret = spi_channel_read (SPI_PORT,buffer,len);
29     do{status = req_clk_status();}while(status);
30     return ret;
31 }
32 /******************************************************************************
33 **  Description:    This function is used to send data to MODEM by SPI BUS.
34 **  Author:         jiayong.yang
35 **  parameter:      buffer is used to save data from MODEM
36 **                  len is length of data to be read. 
37 ******************************************************************************/
38 int SPI_channel_write(unsigned char *buffer,int len)
39 {
40     unsigned long status;
41     int ret;
42     do{status = req_clk_status();}while(status==0);
43     ret = spi_channel_write (SPI_PORT,buffer,len);
44     do{status = req_clk_status();}while(status);
45     return ret;
46 }
47 void SPI_channel_close(void)
48 {
49     return;
50 }