1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2008-2009 Samsung Electronics
4 * Minkyu Kang <mk7.kang@samsung.com>
5 * Kyungmin Park <kyungmin.park@samsung.com>
11 #include <asm/global_data.h>
13 #include <asm/arch/mmc.h>
15 #include <linux/delay.h>
16 #include <power/pmic.h>
17 #include <usb/dwc2_udc.h>
18 #include <asm/arch/cpu.h>
19 #include <power/max8998_pmic.h>
20 #include <samsung/misc.h>
22 #include <usb_mass_storage.h>
23 #include <asm/mach-types.h>
25 DECLARE_GLOBAL_DATA_PTR;
29 /* Set Initial global variables */
30 gd->bd->bi_arch_number = MACH_TYPE_GONI;
31 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
38 gd->ram_size = PHYS_SDRAM_1_SIZE + PHYS_SDRAM_2_SIZE +
44 int dram_init_banksize(void)
46 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
47 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
48 gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
49 gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
50 gd->bd->bi_dram[2].start = PHYS_SDRAM_3;
51 gd->bd->bi_dram[2].size = PHYS_SDRAM_3_SIZE;
56 #ifdef CONFIG_DISPLAY_BOARDINFO
59 puts("Board:\tGoni\n");
65 int board_mmc_init(struct bd_info *bis)
67 int i, ret, ret_sd = 0;
69 /* MASSMEMORY_EN: XMSMDATA7: GPJ2[7] output high */
70 gpio_request(S5PC110_GPIO_J27, "massmemory_en");
71 gpio_direction_output(S5PC110_GPIO_J27, 1);
77 * GPG0[2] SD_0_CDn -> Not used
78 * GPG0[3:6] SD_0_DATA[0:3]
80 for (i = S5PC110_GPIO_G00; i < S5PC110_GPIO_G07; i++) {
81 if (i == S5PC110_GPIO_G02)
83 /* GPG0[0:6] special function 2 */
85 /* GPG0[0:6] pull disable */
86 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
87 /* GPG0[0:6] drv 4x */
88 gpio_set_drv(i, S5P_GPIO_DRV_4X);
91 ret = s5p_mmc_init(0, 4);
93 pr_err("MMC: Failed to init MMC:0.\n");
96 * SD card (T_FLASH) detect and init
97 * T_FLASH_DETECT: EINT28: GPH3[4] input mode
99 gpio_request(S5PC110_GPIO_H34, "t_flash_detect");
100 gpio_cfg_pin(S5PC110_GPIO_H34, S5P_GPIO_INPUT);
101 gpio_set_pull(S5PC110_GPIO_H34, S5P_GPIO_PULL_UP);
103 if (!gpio_get_value(S5PC110_GPIO_H34)) {
104 for (i = S5PC110_GPIO_G20; i < S5PC110_GPIO_G27; i++) {
105 if (i == S5PC110_GPIO_G22)
108 /* GPG2[0:6] special function 2 */
109 gpio_cfg_pin(i, 0x2);
110 /* GPG2[0:6] pull disable */
111 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
112 /* GPG2[0:6] drv 4x */
113 gpio_set_drv(i, S5P_GPIO_DRV_4X);
116 ret_sd = s5p_mmc_init(2, 4);
118 pr_err("MMC: Failed to init SD card (MMC:2).\n");
125 #ifdef CONFIG_USB_GADGET
126 static int s5pc1xx_phy_control(int on)
132 ret = pmic_get("max8998-pmic", &dev);
137 reg = pmic_reg_read(dev, MAX8998_REG_ONOFF1);
139 ret = pmic_reg_write(dev, MAX8998_REG_ONOFF1, reg);
141 puts("MAX8998 LDO setting error!\n");
145 reg = pmic_reg_read(dev, MAX8998_REG_ONOFF2);
147 ret = pmic_reg_write(dev, MAX8998_REG_ONOFF2, reg);
149 puts("MAX8998 LDO setting error!\n");
153 } else if (!on && status) {
154 reg = pmic_reg_read(dev, MAX8998_REG_ONOFF1);
155 reg &= ~MAX8998_LDO3;
156 ret = pmic_reg_write(dev, MAX8998_REG_ONOFF1, reg);
158 puts("MAX8998 LDO setting error!\n");
162 reg = pmic_reg_read(dev, MAX8998_REG_ONOFF2);
163 reg &= ~MAX8998_LDO8;
164 ret = pmic_reg_write(dev, MAX8998_REG_ONOFF2, reg);
166 puts("MAX8998 LDO setting error!\n");
175 struct dwc2_plat_otg_data s5pc110_otg_data = {
176 .phy_control = s5pc1xx_phy_control,
177 .regs_phy = S5PC110_PHY_BASE,
178 .regs_otg = S5PC110_OTG_BASE,
179 .usb_phy_ctrl = S5PC110_USB_PHY_CONTROL,
182 int board_usb_init(int index, enum usb_init_type init)
184 debug("USB_udc_probe\n");
185 return dwc2_udc_probe(&s5pc110_otg_data);
189 #ifdef CONFIG_MISC_INIT_R
190 int misc_init_r(void)
192 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
199 int board_usb_cleanup(int index, enum usb_init_type init)