blob: 4cea63b813ed3f5ba16c6b0a971aab6adba8c344 [file] [log] [blame]
Minkyu Kang194cbce2010-05-31 22:02:42 +09001/*
2 * Copyright (C) 2008-2009 Samsung Electronics
3 * Minkyu Kang <mk7.kang@samsung.com>
4 * Kyungmin Park <kyungmin.park@samsung.com>
5 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02006 * SPDX-License-Identifier: GPL-2.0+
Minkyu Kang194cbce2010-05-31 22:02:42 +09007 */
8
9#include <common.h>
Minkyu Kang2111b2d2010-07-06 20:58:41 +090010#include <asm/arch/gpio.h>
11#include <asm/arch/mmc.h>
Łukasz Majewski1c6dba12012-11-13 03:21:55 +000012#include <power/pmic.h>
Lukasz Majewski35be8502011-10-27 10:36:47 +020013#include <usb/s3c_udc.h>
14#include <asm/arch/cpu.h>
Łukasz Majewski1c6dba12012-11-13 03:21:55 +000015#include <power/max8998_pmic.h>
Piotr Wilczekc88b89e2014-01-22 15:54:33 +010016#include <samsung/misc.h>
17
Minkyu Kang194cbce2010-05-31 22:02:42 +090018DECLARE_GLOBAL_DATA_PTR;
19
Piotr Wilczekc88b89e2014-01-22 15:54:33 +010020u32 get_board_rev(void)
21{
22 return 0;
23}
24
Minkyu Kang194cbce2010-05-31 22:02:42 +090025int board_init(void)
26{
Minkyu Kang2111b2d2010-07-06 20:58:41 +090027 /* Set Initial global variables */
Minkyu Kang194cbce2010-05-31 22:02:42 +090028 gd->bd->bi_arch_number = MACH_TYPE_GONI;
29 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
30
Łukasz Majewski0fcc9a52012-11-13 03:22:16 +000031 return 0;
32}
33
34int power_init_board(void)
35{
36 int ret;
37
Łukasz Majewskide55e752013-08-16 15:33:33 +020038 /*
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);
Łukasz Majewski0fcc9a52012-11-13 03:22:16 +000043 if (ret)
44 return ret;
Łukasz Majewski1c6dba12012-11-13 03:21:55 +000045
Minkyu Kang194cbce2010-05-31 22:02:42 +090046 return 0;
47}
48
49int dram_init(void)
50{
Minkyu Kang00ab1762010-11-22 20:27:44 +090051 gd->ram_size = PHYS_SDRAM_1_SIZE + PHYS_SDRAM_2_SIZE +
52 PHYS_SDRAM_3_SIZE;
53
54 return 0;
55}
56
57void dram_init_banksize(void)
58{
Minkyu Kang194cbce2010-05-31 22:02:42 +090059 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;
Minkyu Kang194cbce2010-05-31 22:02:42 +090065}
66
67#ifdef CONFIG_DISPLAY_BOARDINFO
68int checkboard(void)
69{
70 puts("Board:\tGoni\n");
71 return 0;
72}
73#endif
Minkyu Kang2111b2d2010-07-06 20:58:41 +090074
75#ifdef CONFIG_GENERIC_MMC
76int board_mmc_init(bd_t *bis)
77{
Przemyslaw Marczak151d23f2013-09-10 11:34:49 +020078 int i, ret, ret_sd = 0;
Minkyu Kang2111b2d2010-07-06 20:58:41 +090079
80 /* MASSMEMORY_EN: XMSMDATA7: GPJ2[7] output high */
Akshay Saraswat1376cdd2014-05-13 10:30:14 +053081 gpio_direction_output(S5PC110_GPIO_J27, 1);
Minkyu Kang2111b2d2010-07-06 20:58:41 +090082
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 */
Akshay Saraswat1376cdd2014-05-13 10:30:14 +053090 for (i = S5PC110_GPIO_G00; i < S5PC110_GPIO_G07; i++) {
91 if (i == S5PC110_GPIO_G02)
Minkyu Kang2111b2d2010-07-06 20:58:41 +090092 continue;
93 /* GPG0[0:6] special function 2 */
Akshay Saraswat1376cdd2014-05-13 10:30:14 +053094 gpio_cfg_pin(i, 0x2);
Minkyu Kang2111b2d2010-07-06 20:58:41 +090095 /* GPG0[0:6] pull disable */
Akshay Saraswat1376cdd2014-05-13 10:30:14 +053096 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
Minkyu Kang2111b2d2010-07-06 20:58:41 +090097 /* GPG0[0:6] drv 4x */
Akshay Saraswat1376cdd2014-05-13 10:30:14 +053098 gpio_set_drv(i, S5P_GPIO_DRV_4X);
Minkyu Kang2111b2d2010-07-06 20:58:41 +090099 }
100
Przemyslaw Marczak151d23f2013-09-10 11:34:49 +0200101 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 */
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530109 gpio_cfg_pin(S5PC110_GPIO_H34, S5P_GPIO_INPUT);
110 gpio_set_pull(S5PC110_GPIO_H34, S5P_GPIO_PULL_UP);
Przemyslaw Marczak151d23f2013-09-10 11:34:49 +0200111
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530112 if (!gpio_get_value(S5PC110_GPIO_H34)) {
113 for (i = S5PC110_GPIO_G20; i < S5PC110_GPIO_G27; i++) {
114 if (i == S5PC110_GPIO_G22)
Przemyslaw Marczak151d23f2013-09-10 11:34:49 +0200115 continue;
116
117 /* GPG2[0:6] special function 2 */
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530118 gpio_cfg_pin(i, 0x2);
Przemyslaw Marczak151d23f2013-09-10 11:34:49 +0200119 /* GPG2[0:6] pull disable */
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530120 gpio_set_pull(i, S5P_GPIO_PULL_NONE);
Przemyslaw Marczak151d23f2013-09-10 11:34:49 +0200121 /* GPG2[0:6] drv 4x */
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530122 gpio_set_drv(i, S5P_GPIO_DRV_4X);
Przemyslaw Marczak151d23f2013-09-10 11:34:49 +0200123 }
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;
Minkyu Kang2111b2d2010-07-06 20:58:41 +0900131}
132#endif
Lukasz Majewski35be8502011-10-27 10:36:47 +0200133
134#ifdef CONFIG_USB_GADGET
135static int s5pc1xx_phy_control(int on)
136{
137 int ret;
138 static int status;
Łukasz Majewski1c6dba12012-11-13 03:21:55 +0000139 struct pmic *p = pmic_get("MAX8998_PMIC");
140 if (!p)
141 return -ENODEV;
Lukasz Majewski35be8502011-10-27 10:36:47 +0200142
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
172struct 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
Piotr Wilczekc88b89e2014-01-22 15:54:33 +0100179
180#ifdef CONFIG_MISC_INIT_R
181int 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