1 /* 2 * Copyright (C) 2008-2009 Samsung Electronics 3 * Minkyu Kang <mk7.kang@samsung.com> 4 * Kyungmin Park <kyungmin.park@samsung.com> 5 * 6 * SPDX-License-Identifier: GPL-2.0+ 7 */ 8 9 #include <common.h> 10 #include <asm/arch/gpio.h> 11 #include <asm/arch/mmc.h> 12 #include <power/pmic.h> 13 #include <usb/s3c_udc.h> 14 #include <asm/arch/cpu.h> 15 #include <power/max8998_pmic.h> 16 #include <samsung/misc.h> 17 18 DECLARE_GLOBAL_DATA_PTR; 19 20 u32 get_board_rev(void) 21 { 22 return 0; 23 } 24 25 int board_init(void) 26 { 27 /* Set Initial global variables */ 28 gd->bd->bi_arch_number = MACH_TYPE_GONI; 29 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100; 30 31 return 0; 32 } 33 34 int power_init_board(void) 35 { 36 int ret; 37 38 /* 39 * For PMIC the I2C bus is named as I2C5, but it is connected 40 * to logical I2C adapter 0 41 */ 42 ret = pmic_init(I2C_0); 43 if (ret) 44 return ret; 45 46 return 0; 47 } 48 49 int dram_init(void) 50 { 51 gd->ram_size = PHYS_SDRAM_1_SIZE + PHYS_SDRAM_2_SIZE + 52 PHYS_SDRAM_3_SIZE; 53 54 return 0; 55 } 56 57 void dram_init_banksize(void) 58 { 59 gd->bd->bi_dram[0].start = PHYS_SDRAM_1; 60 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE; 61 gd->bd->bi_dram[1].start = PHYS_SDRAM_2; 62 gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE; 63 gd->bd->bi_dram[2].start = PHYS_SDRAM_3; 64 gd->bd->bi_dram[2].size = PHYS_SDRAM_3_SIZE; 65 } 66 67 #ifdef CONFIG_DISPLAY_BOARDINFO 68 int checkboard(void) 69 { 70 puts("Board:\tGoni\n"); 71 return 0; 72 } 73 #endif 74 75 #ifdef CONFIG_GENERIC_MMC 76 int board_mmc_init(bd_t *bis) 77 { 78 int i, ret, ret_sd = 0; 79 80 /* MASSMEMORY_EN: XMSMDATA7: GPJ2[7] output high */ 81 gpio_direction_output(S5PC110_GPIO_J27, 1); 82 83 /* 84 * MMC0 GPIO 85 * GPG0[0] SD_0_CLK 86 * GPG0[1] SD_0_CMD 87 * GPG0[2] SD_0_CDn -> Not used 88 * GPG0[3:6] SD_0_DATA[0:3] 89 */ 90 for (i = S5PC110_GPIO_G00; i < S5PC110_GPIO_G07; i++) { 91 if (i == S5PC110_GPIO_G02) 92 continue; 93 /* GPG0[0:6] special function 2 */ 94 gpio_cfg_pin(i, 0x2); 95 /* GPG0[0:6] pull disable */ 96 gpio_set_pull(i, S5P_GPIO_PULL_NONE); 97 /* GPG0[0:6] drv 4x */ 98 gpio_set_drv(i, S5P_GPIO_DRV_4X); 99 } 100 101 ret = s5p_mmc_init(0, 4); 102 if (ret) 103 error("MMC: Failed to init MMC:0.\n"); 104 105 /* 106 * SD card (T_FLASH) detect and init 107 * T_FLASH_DETECT: EINT28: GPH3[4] input mode 108 */ 109 gpio_cfg_pin(S5PC110_GPIO_H34, S5P_GPIO_INPUT); 110 gpio_set_pull(S5PC110_GPIO_H34, S5P_GPIO_PULL_UP); 111 112 if (!gpio_get_value(S5PC110_GPIO_H34)) { 113 for (i = S5PC110_GPIO_G20; i < S5PC110_GPIO_G27; i++) { 114 if (i == S5PC110_GPIO_G22) 115 continue; 116 117 /* GPG2[0:6] special function 2 */ 118 gpio_cfg_pin(i, 0x2); 119 /* GPG2[0:6] pull disable */ 120 gpio_set_pull(i, S5P_GPIO_PULL_NONE); 121 /* GPG2[0:6] drv 4x */ 122 gpio_set_drv(i, S5P_GPIO_DRV_4X); 123 } 124 125 ret_sd = s5p_mmc_init(2, 4); 126 if (ret_sd) 127 error("MMC: Failed to init SD card (MMC:2).\n"); 128 } 129 130 return ret & ret_sd; 131 } 132 #endif 133 134 #ifdef CONFIG_USB_GADGET 135 static int s5pc1xx_phy_control(int on) 136 { 137 int ret; 138 static int status; 139 struct pmic *p = pmic_get("MAX8998_PMIC"); 140 if (!p) 141 return -ENODEV; 142 143 if (pmic_probe(p)) 144 return -1; 145 146 if (on && !status) { 147 ret = pmic_set_output(p, MAX8998_REG_ONOFF1, 148 MAX8998_LDO3, LDO_ON); 149 ret = pmic_set_output(p, MAX8998_REG_ONOFF2, 150 MAX8998_LDO8, LDO_ON); 151 if (ret) { 152 puts("MAX8998 LDO setting error!\n"); 153 return -1; 154 } 155 status = 1; 156 } else if (!on && status) { 157 ret = pmic_set_output(p, MAX8998_REG_ONOFF1, 158 MAX8998_LDO3, LDO_OFF); 159 ret = pmic_set_output(p, MAX8998_REG_ONOFF2, 160 MAX8998_LDO8, LDO_OFF); 161 if (ret) { 162 puts("MAX8998 LDO setting error!\n"); 163 return -1; 164 } 165 status = 0; 166 } 167 udelay(10000); 168 169 return 0; 170 } 171 172 struct s3c_plat_otg_data s5pc110_otg_data = { 173 .phy_control = s5pc1xx_phy_control, 174 .regs_phy = S5PC110_PHY_BASE, 175 .regs_otg = S5PC110_OTG_BASE, 176 .usb_phy_ctrl = S5PC110_USB_PHY_CONTROL, 177 }; 178 #endif 179 180 #ifdef CONFIG_MISC_INIT_R 181 int misc_init_r(void) 182 { 183 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG 184 set_board_info(); 185 #endif 186 return 0; 187 } 188 #endif 189