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