tizen 2.4 release
[profile/mobile/platform/kernel/u-boot-tm1.git] / board / spreadtrum / sp9630ea_3592m_3mod / 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 void init_ldo_sleep_gr(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(SDIO0_BASE_ADDR, SDIO_BASE_CLK_384M,
32                         SDIO_CLK_390K, 0);
33
34         return 0;
35 }
36 #endif
37
38 extern struct eic_gpio_resource sprd_gpio_resource[];
39
40 int board_init()
41 {
42         gd->bd->bi_arch_number = MACH_TYPE_OPENPHONE;
43         gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
44         ADI_init();
45         misc_init();
46         LDO_Init();
47         ADC_Init();
48         pin_init();
49         sprd_eic_init();
50         sprd_gpio_init();
51         init_ldo_sleep_gr();
52         TDPllRefConfig(1);
53
54         return 0;
55 }
56
57 PUBLIC phys_size_t get_dram_size_from_gd(void)
58 {
59         return gd->ram_size;
60 }
61
62 int dram_init(void)
63 {
64 #ifdef CONFIG_DDR_AUTO_DETECT
65         ulong sdram_base = CONFIG_SYS_SDRAM_BASE;
66         ulong sdram_size = 0;
67         int i;
68
69         gd->ram_size = 0;
70         ulong bank_cnt = CONFIG_NR_DRAM_BANKS_ADDR_IN_IRAM;
71
72         for (i = 1; i <= *(volatile uint32 *)CONFIG_NR_DRAM_BANKS_ADDR_IN_IRAM; i++) {
73                 gd->ram_size += *(volatile ulong *)((volatile ulong *)CONFIG_NR_DRAM_BANKS_ADDR_IN_IRAM + i);
74         }
75
76         gd->ram_size = get_ram_size((volatile void *)sdram_base, gd->ram_size);
77 #else
78         gd->ram_size = get_ram_size((volatile void *)PHYS_SDRAM_1,
79                         PHYS_SDRAM_1_SIZE);
80 #endif
81         return 0;
82 }