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