change source file mode to 0644 instead of 0755
[profile/mobile/platform/kernel/u-boot-tm1.git] / board / spreadtrum / sp6820gb / openphone.c
1 #include <common.h>
2 #include <asm/io.h>
3 #include <asm/arch/ldo.h>
4 #include <asm/arch/sc8810_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 DECLARE_GLOBAL_DATA_PTR;
13
14 extern void sprd_gpio_init(void);
15 extern void ADI_init (void);
16 extern int LDO_Init(void);
17
18
19
20 #define PIN_CTL_REG 0x8C000000
21 static void chip_init(void)
22 {
23     //ANA_REG_SET(ANA_ADIE_CHIP_ID,0);
24     /* setup pins configration when LDO shutdown*/
25     //__raw_writel(0x1fff00, PIN_CTL_REG);
26      *(volatile unsigned int *)PIN_CTL_REG = 0x1fff00;
27 }
28 #ifdef CONFIG_GENERIC_MMC
29 static unsigned long sdio_func_cfg[] = {
30         MFP_CFG_X(SD0_CLK, AF0, DS3, F_PULL_NONE, S_PULL_NONE, IO_Z),
31         MFP_CFG_X(SD_CMD, AF0, DS0, F_PULL_UP,  S_PULL_NONE, IO_Z),
32         MFP_CFG_X(SD_D0, AF0, DS0, F_PULL_UP, S_PULL_NONE, IO_Z),
33         MFP_CFG_X(SD_D1, AF0, DS0, F_PULL_DOWN, S_PULL_NONE, IO_Z),
34         MFP_CFG_X(SD_D2, AF0, DS0, F_PULL_DOWN, S_PULL_NONE, IO_Z),
35         MFP_CFG_X(SD_D3, AF0, DS0, F_PULL_DOWN, S_PULL_NONE, IO_Z),
36 };
37
38 static unsigned long sdcard_detect_gpio_cfg =
39 MFP_CFG_X(RFCTL11, AF3, DS1, F_PULL_UP,S_PULL_NONE, IO_Z);
40
41 void sprd_config_sdio_pins(void)
42 {
43         sprd_mfp_config(sdio_func_cfg, ARRAY_SIZE(sdio_func_cfg));
44         sprd_mfp_config(&sdcard_detect_gpio_cfg, 1);
45 }
46 int mv_sdh_init(u32 regbase, u32 max_clk, u32 min_clk, u32 quirks);
47 int board_mmc_init(bd_t *bd)
48 {
49         ulong mmc_base_address[CONFIG_SYS_MMC_NUM] = CONFIG_SYS_MMC_BASE;
50         u8 i, data;
51
52         REG32(AHB_CTL0)     |= BIT_4;
53         REG32(AHB_SOFT_RST) |= BIT_12;
54         REG32(AHB_SOFT_RST) &= ~BIT_12;
55         LDO_SetVoltLevel(LDO_LDO_SDIO0, LDO_VOLT_LEVEL1);
56         LDO_TurnOnLDO(LDO_LDO_SDIO0);
57         sprd_config_sdio_pins();
58
59         for (i = 0; i < CONFIG_SYS_MMC_NUM; i++) {
60                 if (mv_sdh_init(mmc_base_address[i], SDIO_BASE_CLK_96M, 
61                         SDIO_CLK_250K, 0))
62                         return 1;
63         }
64
65         return 0;
66 }
67 #endif
68
69 int board_init()
70 {
71         gd->bd->bi_arch_number = MACH_TYPE_OPENPHONE;
72         gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
73
74     ADI_init();
75     chip_init();
76     LDO_Init();
77     sprd_gpio_init();
78     //board_gpio_init();
79         return 0;
80 }
81
82 int dram_init(void)
83 {
84         gd->ram_size = get_ram_size((volatile void *)PHYS_SDRAM_1,
85                         PHYS_SDRAM_1_SIZE);
86         return 0;
87 }