Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Minkyu Kang | 72b81d3 | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2008-2009 Samsung Electronics |
| 4 | * Minkyu Kang <mk7.kang@samsung.com> |
| 5 | * Kyungmin Park <kyungmin.park@samsung.com> |
Minkyu Kang | 72b81d3 | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
Simon Glass | 903fd79 | 2014-10-20 19:48:37 -0600 | [diff] [blame] | 9 | #include <asm/gpio.h> |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 10 | #include <asm/arch/mmc.h> |
Jaehoon Chung | cf2a693 | 2017-01-03 09:43:28 +0900 | [diff] [blame] | 11 | #include <dm.h> |
Łukasz Majewski | c733681 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 12 | #include <power/pmic.h> |
Marek Vasut | 5d5716e | 2015-12-04 02:51:20 +0100 | [diff] [blame] | 13 | #include <usb/dwc2_udc.h> |
Lukasz Majewski | a954da2 | 2011-10-27 10:36:47 +0200 | [diff] [blame] | 14 | #include <asm/arch/cpu.h> |
Łukasz Majewski | c733681 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 15 | #include <power/max8998_pmic.h> |
Piotr Wilczek | 2ac9a35 | 2014-01-22 15:54:33 +0100 | [diff] [blame] | 16 | #include <samsung/misc.h> |
Mateusz Zalega | 2d281b3 | 2014-04-28 21:13:30 +0200 | [diff] [blame] | 17 | #include <usb.h> |
| 18 | #include <usb_mass_storage.h> |
Simon Glass | c62db35 | 2017-05-31 19:47:48 -0600 | [diff] [blame] | 19 | #include <asm/mach-types.h> |
Piotr Wilczek | 2ac9a35 | 2014-01-22 15:54:33 +0100 | [diff] [blame] | 20 | |
Minkyu Kang | 72b81d3 | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 21 | DECLARE_GLOBAL_DATA_PTR; |
| 22 | |
Piotr Wilczek | 2ac9a35 | 2014-01-22 15:54:33 +0100 | [diff] [blame] | 23 | u32 get_board_rev(void) |
| 24 | { |
| 25 | return 0; |
| 26 | } |
| 27 | |
Minkyu Kang | 72b81d3 | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 28 | int board_init(void) |
| 29 | { |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 30 | /* Set Initial global variables */ |
Minkyu Kang | 72b81d3 | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 31 | gd->bd->bi_arch_number = MACH_TYPE_GONI; |
| 32 | gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100; |
| 33 | |
Łukasz Majewski | 0ecdab6 | 2012-11-13 03:22:16 +0000 | [diff] [blame] | 34 | return 0; |
| 35 | } |
| 36 | |
Robert Baldyga | 4d38395 | 2014-10-06 14:33:11 +0200 | [diff] [blame] | 37 | #ifdef CONFIG_SYS_I2C_INIT_BOARD |
| 38 | void i2c_init_board(void) |
| 39 | { |
| 40 | gpio_request(S5PC110_GPIO_J43, "i2c_clk"); |
| 41 | gpio_request(S5PC110_GPIO_J40, "i2c_data"); |
| 42 | gpio_direction_output(S5PC110_GPIO_J43, 1); |
| 43 | gpio_direction_output(S5PC110_GPIO_J40, 1); |
| 44 | } |
| 45 | #endif |
| 46 | |
Minkyu Kang | 72b81d3 | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 47 | int dram_init(void) |
| 48 | { |
Minkyu Kang | 177feff | 2010-11-22 20:27:44 +0900 | [diff] [blame] | 49 | gd->ram_size = PHYS_SDRAM_1_SIZE + PHYS_SDRAM_2_SIZE + |
| 50 | PHYS_SDRAM_3_SIZE; |
| 51 | |
| 52 | return 0; |
| 53 | } |
| 54 | |
Simon Glass | 76b00ac | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 55 | int dram_init_banksize(void) |
Minkyu Kang | 177feff | 2010-11-22 20:27:44 +0900 | [diff] [blame] | 56 | { |
Minkyu Kang | 72b81d3 | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 57 | gd->bd->bi_dram[0].start = PHYS_SDRAM_1; |
| 58 | gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE; |
| 59 | gd->bd->bi_dram[1].start = PHYS_SDRAM_2; |
| 60 | gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE; |
| 61 | gd->bd->bi_dram[2].start = PHYS_SDRAM_3; |
| 62 | gd->bd->bi_dram[2].size = PHYS_SDRAM_3_SIZE; |
Simon Glass | 76b00ac | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 63 | |
| 64 | return 0; |
Minkyu Kang | 72b81d3 | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | #ifdef CONFIG_DISPLAY_BOARDINFO |
| 68 | int checkboard(void) |
| 69 | { |
| 70 | puts("Board:\tGoni\n"); |
| 71 | return 0; |
| 72 | } |
| 73 | #endif |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 74 | |
Masahiro Yamada | 4aa2ba3 | 2017-05-09 20:31:39 +0900 | [diff] [blame] | 75 | #ifdef CONFIG_MMC |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 76 | int board_mmc_init(bd_t *bis) |
| 77 | { |
Przemyslaw Marczak | 5c18a1c | 2013-09-10 11:34:49 +0200 | [diff] [blame] | 78 | int i, ret, ret_sd = 0; |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 79 | |
| 80 | /* MASSMEMORY_EN: XMSMDATA7: GPJ2[7] output high */ |
Simon Glass | 7f19610 | 2014-10-20 19:48:39 -0600 | [diff] [blame] | 81 | gpio_request(S5PC110_GPIO_J27, "massmemory_en"); |
Akshay Saraswat | f6ae1ca | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 82 | gpio_direction_output(S5PC110_GPIO_J27, 1); |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 83 | |
| 84 | /* |
| 85 | * MMC0 GPIO |
| 86 | * GPG0[0] SD_0_CLK |
| 87 | * GPG0[1] SD_0_CMD |
| 88 | * GPG0[2] SD_0_CDn -> Not used |
| 89 | * GPG0[3:6] SD_0_DATA[0:3] |
| 90 | */ |
Akshay Saraswat | f6ae1ca | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 91 | for (i = S5PC110_GPIO_G00; i < S5PC110_GPIO_G07; i++) { |
| 92 | if (i == S5PC110_GPIO_G02) |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 93 | continue; |
| 94 | /* GPG0[0:6] special function 2 */ |
Akshay Saraswat | f6ae1ca | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 95 | gpio_cfg_pin(i, 0x2); |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 96 | /* GPG0[0:6] pull disable */ |
Akshay Saraswat | f6ae1ca | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 97 | gpio_set_pull(i, S5P_GPIO_PULL_NONE); |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 98 | /* GPG0[0:6] drv 4x */ |
Akshay Saraswat | f6ae1ca | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 99 | gpio_set_drv(i, S5P_GPIO_DRV_4X); |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 100 | } |
| 101 | |
Przemyslaw Marczak | 5c18a1c | 2013-09-10 11:34:49 +0200 | [diff] [blame] | 102 | ret = s5p_mmc_init(0, 4); |
| 103 | if (ret) |
Masahiro Yamada | 9b643e3 | 2017-09-16 14:10:41 +0900 | [diff] [blame] | 104 | pr_err("MMC: Failed to init MMC:0.\n"); |
Przemyslaw Marczak | 5c18a1c | 2013-09-10 11:34:49 +0200 | [diff] [blame] | 105 | |
| 106 | /* |
| 107 | * SD card (T_FLASH) detect and init |
| 108 | * T_FLASH_DETECT: EINT28: GPH3[4] input mode |
| 109 | */ |
Simon Glass | 7f19610 | 2014-10-20 19:48:39 -0600 | [diff] [blame] | 110 | gpio_request(S5PC110_GPIO_H34, "t_flash_detect"); |
Akshay Saraswat | f6ae1ca | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 111 | gpio_cfg_pin(S5PC110_GPIO_H34, S5P_GPIO_INPUT); |
| 112 | gpio_set_pull(S5PC110_GPIO_H34, S5P_GPIO_PULL_UP); |
Przemyslaw Marczak | 5c18a1c | 2013-09-10 11:34:49 +0200 | [diff] [blame] | 113 | |
Akshay Saraswat | f6ae1ca | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 114 | if (!gpio_get_value(S5PC110_GPIO_H34)) { |
| 115 | for (i = S5PC110_GPIO_G20; i < S5PC110_GPIO_G27; i++) { |
| 116 | if (i == S5PC110_GPIO_G22) |
Przemyslaw Marczak | 5c18a1c | 2013-09-10 11:34:49 +0200 | [diff] [blame] | 117 | continue; |
| 118 | |
| 119 | /* GPG2[0:6] special function 2 */ |
Akshay Saraswat | f6ae1ca | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 120 | gpio_cfg_pin(i, 0x2); |
Przemyslaw Marczak | 5c18a1c | 2013-09-10 11:34:49 +0200 | [diff] [blame] | 121 | /* GPG2[0:6] pull disable */ |
Akshay Saraswat | f6ae1ca | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 122 | gpio_set_pull(i, S5P_GPIO_PULL_NONE); |
Przemyslaw Marczak | 5c18a1c | 2013-09-10 11:34:49 +0200 | [diff] [blame] | 123 | /* GPG2[0:6] drv 4x */ |
Akshay Saraswat | f6ae1ca | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 124 | gpio_set_drv(i, S5P_GPIO_DRV_4X); |
Przemyslaw Marczak | 5c18a1c | 2013-09-10 11:34:49 +0200 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | ret_sd = s5p_mmc_init(2, 4); |
| 128 | if (ret_sd) |
Masahiro Yamada | 9b643e3 | 2017-09-16 14:10:41 +0900 | [diff] [blame] | 129 | pr_err("MMC: Failed to init SD card (MMC:2).\n"); |
Przemyslaw Marczak | 5c18a1c | 2013-09-10 11:34:49 +0200 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | return ret & ret_sd; |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 133 | } |
| 134 | #endif |
Lukasz Majewski | a954da2 | 2011-10-27 10:36:47 +0200 | [diff] [blame] | 135 | |
| 136 | #ifdef CONFIG_USB_GADGET |
| 137 | static int s5pc1xx_phy_control(int on) |
| 138 | { |
Jaehoon Chung | cf2a693 | 2017-01-03 09:43:28 +0900 | [diff] [blame] | 139 | struct udevice *dev; |
Lukasz Majewski | a954da2 | 2011-10-27 10:36:47 +0200 | [diff] [blame] | 140 | static int status; |
Jaehoon Chung | cf2a693 | 2017-01-03 09:43:28 +0900 | [diff] [blame] | 141 | int reg, ret; |
Lukasz Majewski | a954da2 | 2011-10-27 10:36:47 +0200 | [diff] [blame] | 142 | |
Jaehoon Chung | fd3b710 | 2017-01-05 16:55:14 +0900 | [diff] [blame] | 143 | ret = pmic_get("max8998-pmic", &dev); |
Jaehoon Chung | cf2a693 | 2017-01-03 09:43:28 +0900 | [diff] [blame] | 144 | if (ret) |
| 145 | return ret; |
Lukasz Majewski | a954da2 | 2011-10-27 10:36:47 +0200 | [diff] [blame] | 146 | |
| 147 | if (on && !status) { |
Jaehoon Chung | cf2a693 | 2017-01-03 09:43:28 +0900 | [diff] [blame] | 148 | reg = pmic_reg_read(dev, MAX8998_REG_ONOFF1); |
| 149 | reg |= MAX8998_LDO3; |
| 150 | ret = pmic_reg_write(dev, MAX8998_REG_ONOFF1, reg); |
Lukasz Majewski | a954da2 | 2011-10-27 10:36:47 +0200 | [diff] [blame] | 151 | if (ret) { |
| 152 | puts("MAX8998 LDO setting error!\n"); |
Jaehoon Chung | cf2a693 | 2017-01-03 09:43:28 +0900 | [diff] [blame] | 153 | return -EINVAL; |
| 154 | } |
| 155 | |
| 156 | reg = pmic_reg_read(dev, MAX8998_REG_ONOFF2); |
| 157 | reg |= MAX8998_LDO8; |
| 158 | ret = pmic_reg_write(dev, MAX8998_REG_ONOFF2, reg); |
| 159 | if (ret) { |
| 160 | puts("MAX8998 LDO setting error!\n"); |
| 161 | return -EINVAL; |
Lukasz Majewski | a954da2 | 2011-10-27 10:36:47 +0200 | [diff] [blame] | 162 | } |
| 163 | status = 1; |
| 164 | } else if (!on && status) { |
Jaehoon Chung | cf2a693 | 2017-01-03 09:43:28 +0900 | [diff] [blame] | 165 | reg = pmic_reg_read(dev, MAX8998_REG_ONOFF1); |
| 166 | reg &= ~MAX8998_LDO3; |
| 167 | ret = pmic_reg_write(dev, MAX8998_REG_ONOFF1, reg); |
Lukasz Majewski | a954da2 | 2011-10-27 10:36:47 +0200 | [diff] [blame] | 168 | if (ret) { |
| 169 | puts("MAX8998 LDO setting error!\n"); |
Jaehoon Chung | cf2a693 | 2017-01-03 09:43:28 +0900 | [diff] [blame] | 170 | return -EINVAL; |
| 171 | } |
| 172 | |
| 173 | reg = pmic_reg_read(dev, MAX8998_REG_ONOFF2); |
| 174 | reg &= ~MAX8998_LDO8; |
| 175 | ret = pmic_reg_write(dev, MAX8998_REG_ONOFF2, reg); |
| 176 | if (ret) { |
| 177 | puts("MAX8998 LDO setting error!\n"); |
| 178 | return -EINVAL; |
Lukasz Majewski | a954da2 | 2011-10-27 10:36:47 +0200 | [diff] [blame] | 179 | } |
| 180 | status = 0; |
| 181 | } |
| 182 | udelay(10000); |
Lukasz Majewski | a954da2 | 2011-10-27 10:36:47 +0200 | [diff] [blame] | 183 | return 0; |
| 184 | } |
| 185 | |
Marek Vasut | c098287 | 2015-12-04 02:23:29 +0100 | [diff] [blame] | 186 | struct dwc2_plat_otg_data s5pc110_otg_data = { |
Lukasz Majewski | a954da2 | 2011-10-27 10:36:47 +0200 | [diff] [blame] | 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 | }; |
Mateusz Zalega | 2d281b3 | 2014-04-28 21:13:30 +0200 | [diff] [blame] | 192 | |
| 193 | int board_usb_init(int index, enum usb_init_type init) |
| 194 | { |
| 195 | debug("USB_udc_probe\n"); |
Marek Vasut | a4bb9b3 | 2015-12-04 02:26:33 +0100 | [diff] [blame] | 196 | return dwc2_udc_probe(&s5pc110_otg_data); |
Mateusz Zalega | 2d281b3 | 2014-04-28 21:13:30 +0200 | [diff] [blame] | 197 | } |
Lukasz Majewski | a954da2 | 2011-10-27 10:36:47 +0200 | [diff] [blame] | 198 | #endif |
Piotr Wilczek | 2ac9a35 | 2014-01-22 15:54:33 +0100 | [diff] [blame] | 199 | |
| 200 | #ifdef CONFIG_MISC_INIT_R |
| 201 | int 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 |
Lukasz Majewski | 1118ecd | 2015-03-03 17:32:04 +0100 | [diff] [blame] | 209 | |
| 210 | int board_usb_cleanup(int index, enum usb_init_type init) |
| 211 | { |
| 212 | return 0; |
| 213 | } |