f873c8828bbd88354f783d0634dd4eb94f60f2a3
[profile/mobile/platform/kernel/u-boot-tm1.git] / board / spreadtrum / kylew / openphone.c
1 #include <common.h>
2 #include <asm/io.h>
3 DECLARE_GLOBAL_DATA_PTR;
4
5 #define         PIN_REG_SIMDA3          (0x8C000470)
6 #define         PIN_REG_SIMRST3         (0x8C000478)
7 #define         PIN_CTRL_REG            (0x8b000028)
8
9 extern void sprd_gpio_init(void);
10 extern void ADI_init (void);
11 extern int LDO_Init(void);
12
13 #include <asm/arch/regs_ana.h>
14 #include <asm/arch/adi_hal_internal.h>
15
16 #define mdelay(n)       udelay((n) * 1000)
17
18 void modem_poweron(void)
19 {
20         /*Modem Power On*/
21
22         __raw_writel(0x31,0x8C0003b8);
23         gpio_direction_output(106,1);
24         gpio_set_value(106,1);
25 }
26 void modem_poweroff(void)
27 {
28         /*Modem Power Off*/
29         __raw_writel(0x31,0x8C0003b8);
30         gpio_direction_output(106,1);
31         gpio_set_value(106,0);
32         mdelay(100);
33         /*Modem download pin,set to high,Modem can not enter downnload mode*/
34         __raw_writel(0x31,0x8C000114);
35         gpio_direction_output(34,1);
36         gpio_set_value(34,1);
37 }
38
39 void Init_7702_modem(void)
40 {
41         /*Modem Power Off*/
42         __raw_writel(0x31,0x8C0003b8);
43         gpio_direction_output(106,1);
44         gpio_set_value(106,0);
45         /*Modem AP_CP Rst pin set to low (default)*/
46         __raw_writel(0x31,0x8C000124);
47         gpio_direction_output(38,1);
48         gpio_set_value(38,0);
49
50         mdelay(100);
51         /*Modem download pin,set to high,Modem can not enter downnload mode*/
52         __raw_writel(0x31,0x8C000114);
53         gpio_direction_output(34,1);
54         gpio_set_value(34,1);
55         /*Modem Power On*/
56         __raw_writel(0x31,0x8C0003b8);
57         gpio_direction_output(106,1);
58         gpio_set_value(106,1);
59
60         __raw_writel(0x174, 0x8C000398);
61         gpio_direction_output(CP_AP_LIV, 0);
62         //gpio_set_value(CP_AP_LIV, 0);
63
64 }
65
66 void init_calibration_gpio(void)
67 {
68         __raw_writel(0x134, 0x8C000430);
69         gpio_direction_output(AP_CP_RTS, 1);
70         gpio_set_value(AP_CP_RTS, 0);
71
72         __raw_writel(0x1B4, 0x8C000424);
73         gpio_direction_output(CP_AP_RDY, 0);
74         //gpio_set_value(CP_AP_RDY, 0);
75
76         __raw_writel(0x1B0, 0x8C00039c);
77         gpio_direction_output(CP_AP_RTS, 0);
78         //gpio_set_value(CP_AP_RTS, 0);
79
80         __raw_writel(0x134, 0x8C000304);
81         gpio_direction_output(AP_CP_RDY, 1);
82         gpio_set_value(AP_CP_RDY, 1);
83
84         __raw_writel(0x174, 0x8C000398);
85         gpio_direction_output(CP_AP_LIV, 0);
86         //gpio_set_value(CP_AP_LIV, 0);
87 }
88
89 void init_calibration_mode(void)
90 {
91     *(volatile unsigned long *)PIN_REG_SIMDA3  |= 0x000003a0;
92         *(volatile unsigned long *)PIN_REG_SIMRST3 |= 0x000003a0;
93         *(volatile unsigned long *)PIN_CTRL_REG |= 0x00000040;
94         
95         init_calibration_gpio();
96 }
97
98 #define PIN_CTL_REG 0x8C000000
99 static void chip_init(void)
100 {
101     //ANA_REG_SET(ANA_ADIE_CHIP_ID,0);
102     /* setup pins configration when LDO shutdown*/
103     //__raw_writel(0x1fff00, PIN_CTL_REG);
104      *(volatile unsigned int *)PIN_CTL_REG = 0x1fff00;
105 }
106 int board_init()
107 {
108         gd->bd->bi_arch_number = MACH_TYPE_OPENPHONE;
109         gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
110
111     ADI_init();
112     chip_init();
113     LDO_Init();
114     sprd_gpio_init();
115
116          Init_7702_modem();
117
118     //board_gpio_init();
119         return 0;
120 }
121
122 int dram_init(void)
123 {
124         gd->ram_size = get_ram_size((volatile void *)PHYS_SDRAM_1,
125                         PHYS_SDRAM_1_SIZE);
126         return 0;
127 }