tizen 2.4 release
[kernel/u-boot-tm1.git] / board / spreadtrum / pikeayoung2dtv / openphone.c
1 #include <common.h>
2 #include <asm/io.h>
3 #include <asm/arch/ldo.h>
4 #include <asm/arch/sprd_reg_ahb.h>
5 #include <asm/arch/regs_ahb.h>
6 #include <asm/arch/common.h>
7 #include <asm/arch/adi_hal_internal.h>
8 #include <asm/u-boot.h>
9 #include <part.h>
10 #include <sdhci.h>
11 #include <asm/arch/mfp.h>
12 #include <linux/gpio.h>
13 #include <asm/arch/gpio.h>
14 #include <asm/arch/pinmap.h>
15 DECLARE_GLOBAL_DATA_PTR;
16
17 extern void sprd_gpio_init(void);
18 extern void ADI_init (void);
19 extern int LDO_Init(void);
20 extern void ADC_Init(void);
21 extern int sound_init(void);
22
23 #ifdef CONFIG_GENERIC_MMC
24 int mv_sdh_init(u32 regbase, u32 max_clk, u32 min_clk, u32 quirks);
25 int mmc_sdcard_init();
26
27 int board_mmc_init(bd_t *bd)
28 {
29         mmc_sdcard_init();
30
31         mv_sdh_init(CONFIG_SYS_SD_BASE, SDIO_BASE_CLK_192M,
32                         SDIO_CLK_250K, 0);
33
34         return 0;
35 }
36 #endif
37
38 extern struct eic_gpio_resource sprd_gpio_resource[];
39
40 /*enable aon timer2 for udelay functions*/
41 void aon_26M_timer2_enable()
42 {
43         REG32(REG_AON_APB_APB_EB0) |= BIT_AON_TMR_EB;
44 }
45
46 void cp_26m_clk_sel()
47 {
48     int gpio_states = 0;
49
50     //mask
51     REG32(0x40280504) |= (1<<6) | (1<<9) | (1<<10);
52     //data
53     gpio_states = REG32(0x40280500);
54
55     //HW 0.4 board
56     //bit 6:0, bit9:1, bit10:1
57     if ( (gpio_states & 0x40) != 0 ||
58         ((gpio_states & 0x200)!= 0 &&
59         (gpio_states & 0x400)!= 0))
60     {
61         REG32(REG_PMU_APB_26M_SEL_CFG) |= BIT_CP0_26M_SEL;
62     }
63 }
64
65
66 int board_init()
67 {
68         gd->bd->bi_arch_number = MACH_TYPE_OPENPHONE;
69         gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
70         ADI_init();
71         misc_init();
72         LDO_Init();
73         ADC_Init();
74         pin_init();
75         sprd_eic_init();
76         sprd_gpio_init();
77         sound_init();
78         init_ldo_sleep_gr();
79         //TDPllRefConfig(1);
80         aon_26M_timer2_enable();
81         cp_26m_clk_sel();
82
83         return 0;
84 }
85
86 int dram_init(void)
87 {
88         gd->ram_size = get_ram_size((volatile void *)PHYS_SDRAM_1,
89                         PHYS_SDRAM_1_SIZE);
90         return 0;
91 }
92
93
94 void fdt_fixup_chosen_bootargs_board(char *buf, const char *boot_mode, int calibration_mode)
95 {
96         char *p = buf;
97         /**
98         * Because of in u-boot, we can't find FDT chosen remove function
99         * and samsung only uses uart to do calibration,
100         * so in samsung board .dts, we remove the "console=ttyS1,115200n8" in chosen node by defaul
101 t.
102         * so in normal mode, we need to append console
103         */
104         if (!calibration_mode) {
105         p += sprintf(p, "console=ttyS1,115200n8 no_console_suspend");
106         }
107 }