Minkyu Kang | 72b81d3 | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008-2009 Samsung Electronics |
| 3 | * Minkyu Kang <mk7.kang@samsung.com> |
| 4 | * Kyungmin Park <kyungmin.park@samsung.com> |
| 5 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 6 | * SPDX-License-Identifier: GPL-2.0+ |
Minkyu Kang | 72b81d3 | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 10 | #include <asm/arch/gpio.h> |
| 11 | #include <asm/arch/mmc.h> |
Łukasz Majewski | c733681 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 12 | #include <power/pmic.h> |
Lukasz Majewski | a954da2 | 2011-10-27 10:36:47 +0200 | [diff] [blame] | 13 | #include <usb/s3c_udc.h> |
| 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> |
Piotr Wilczek | 2ac9a35 | 2014-01-22 15:54:33 +0100 | [diff] [blame] | 19 | |
Minkyu Kang | 72b81d3 | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 20 | DECLARE_GLOBAL_DATA_PTR; |
| 21 | |
Piotr Wilczek | 2ac9a35 | 2014-01-22 15:54:33 +0100 | [diff] [blame] | 22 | u32 get_board_rev(void) |
| 23 | { |
| 24 | return 0; |
| 25 | } |
| 26 | |
Minkyu Kang | 72b81d3 | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 27 | int board_init(void) |
| 28 | { |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 29 | /* Set Initial global variables */ |
Minkyu Kang | 72b81d3 | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 30 | gd->bd->bi_arch_number = MACH_TYPE_GONI; |
| 31 | gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100; |
| 32 | |
Łukasz Majewski | 0ecdab6 | 2012-11-13 03:22:16 +0000 | [diff] [blame] | 33 | return 0; |
| 34 | } |
| 35 | |
| 36 | int power_init_board(void) |
| 37 | { |
| 38 | int ret; |
| 39 | |
Łukasz Majewski | 2936df1 | 2013-08-16 15:33:33 +0200 | [diff] [blame] | 40 | /* |
| 41 | * For PMIC the I2C bus is named as I2C5, but it is connected |
| 42 | * to logical I2C adapter 0 |
| 43 | */ |
| 44 | ret = pmic_init(I2C_0); |
Łukasz Majewski | 0ecdab6 | 2012-11-13 03:22:16 +0000 | [diff] [blame] | 45 | if (ret) |
| 46 | return ret; |
Łukasz Majewski | c733681 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 47 | |
Minkyu Kang | 72b81d3 | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 48 | return 0; |
| 49 | } |
| 50 | |
| 51 | int dram_init(void) |
| 52 | { |
Minkyu Kang | 177feff | 2010-11-22 20:27:44 +0900 | [diff] [blame] | 53 | gd->ram_size = PHYS_SDRAM_1_SIZE + PHYS_SDRAM_2_SIZE + |
| 54 | PHYS_SDRAM_3_SIZE; |
| 55 | |
| 56 | return 0; |
| 57 | } |
| 58 | |
| 59 | void dram_init_banksize(void) |
| 60 | { |
Minkyu Kang | 72b81d3 | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 61 | gd->bd->bi_dram[0].start = PHYS_SDRAM_1; |
| 62 | gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE; |
| 63 | gd->bd->bi_dram[1].start = PHYS_SDRAM_2; |
| 64 | gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE; |
| 65 | gd->bd->bi_dram[2].start = PHYS_SDRAM_3; |
| 66 | gd->bd->bi_dram[2].size = PHYS_SDRAM_3_SIZE; |
Minkyu Kang | 72b81d3 | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | #ifdef CONFIG_DISPLAY_BOARDINFO |
| 70 | int checkboard(void) |
| 71 | { |
| 72 | puts("Board:\tGoni\n"); |
| 73 | return 0; |
| 74 | } |
| 75 | #endif |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 76 | |
| 77 | #ifdef CONFIG_GENERIC_MMC |
| 78 | int board_mmc_init(bd_t *bis) |
| 79 | { |
Przemyslaw Marczak | 5c18a1c | 2013-09-10 11:34:49 +0200 | [diff] [blame] | 80 | int i, ret, ret_sd = 0; |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 81 | |
| 82 | /* MASSMEMORY_EN: XMSMDATA7: GPJ2[7] output high */ |
Akshay Saraswat | f6ae1ca | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 83 | gpio_direction_output(S5PC110_GPIO_J27, 1); |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 84 | |
| 85 | /* |
| 86 | * MMC0 GPIO |
| 87 | * GPG0[0] SD_0_CLK |
| 88 | * GPG0[1] SD_0_CMD |
| 89 | * GPG0[2] SD_0_CDn -> Not used |
| 90 | * GPG0[3:6] SD_0_DATA[0:3] |
| 91 | */ |
Akshay Saraswat | f6ae1ca | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 92 | for (i = S5PC110_GPIO_G00; i < S5PC110_GPIO_G07; i++) { |
| 93 | if (i == S5PC110_GPIO_G02) |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 94 | continue; |
| 95 | /* GPG0[0:6] special function 2 */ |
Akshay Saraswat | f6ae1ca | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 96 | gpio_cfg_pin(i, 0x2); |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 97 | /* GPG0[0:6] pull disable */ |
Akshay Saraswat | f6ae1ca | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 98 | gpio_set_pull(i, S5P_GPIO_PULL_NONE); |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 99 | /* GPG0[0:6] drv 4x */ |
Akshay Saraswat | f6ae1ca | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 100 | gpio_set_drv(i, S5P_GPIO_DRV_4X); |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 101 | } |
| 102 | |
Przemyslaw Marczak | 5c18a1c | 2013-09-10 11:34:49 +0200 | [diff] [blame] | 103 | ret = s5p_mmc_init(0, 4); |
| 104 | if (ret) |
| 105 | error("MMC: Failed to init MMC:0.\n"); |
| 106 | |
| 107 | /* |
| 108 | * SD card (T_FLASH) detect and init |
| 109 | * T_FLASH_DETECT: EINT28: GPH3[4] input mode |
| 110 | */ |
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) |
| 129 | error("MMC: Failed to init SD card (MMC:2).\n"); |
| 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 | { |
| 139 | int ret; |
| 140 | static int status; |
Łukasz Majewski | c733681 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 141 | struct pmic *p = pmic_get("MAX8998_PMIC"); |
| 142 | if (!p) |
| 143 | return -ENODEV; |
Lukasz Majewski | a954da2 | 2011-10-27 10:36:47 +0200 | [diff] [blame] | 144 | |
| 145 | if (pmic_probe(p)) |
| 146 | return -1; |
| 147 | |
| 148 | if (on && !status) { |
| 149 | ret = pmic_set_output(p, MAX8998_REG_ONOFF1, |
| 150 | MAX8998_LDO3, LDO_ON); |
| 151 | ret = pmic_set_output(p, MAX8998_REG_ONOFF2, |
| 152 | MAX8998_LDO8, LDO_ON); |
| 153 | if (ret) { |
| 154 | puts("MAX8998 LDO setting error!\n"); |
| 155 | return -1; |
| 156 | } |
| 157 | status = 1; |
| 158 | } else if (!on && status) { |
| 159 | ret = pmic_set_output(p, MAX8998_REG_ONOFF1, |
| 160 | MAX8998_LDO3, LDO_OFF); |
| 161 | ret = pmic_set_output(p, MAX8998_REG_ONOFF2, |
| 162 | MAX8998_LDO8, LDO_OFF); |
| 163 | if (ret) { |
| 164 | puts("MAX8998 LDO setting error!\n"); |
| 165 | return -1; |
| 166 | } |
| 167 | status = 0; |
| 168 | } |
| 169 | udelay(10000); |
| 170 | |
| 171 | return 0; |
| 172 | } |
| 173 | |
| 174 | struct s3c_plat_otg_data s5pc110_otg_data = { |
| 175 | .phy_control = s5pc1xx_phy_control, |
| 176 | .regs_phy = S5PC110_PHY_BASE, |
| 177 | .regs_otg = S5PC110_OTG_BASE, |
| 178 | .usb_phy_ctrl = S5PC110_USB_PHY_CONTROL, |
| 179 | }; |
Mateusz Zalega | 2d281b3 | 2014-04-28 21:13:30 +0200 | [diff] [blame] | 180 | |
| 181 | int board_usb_init(int index, enum usb_init_type init) |
| 182 | { |
| 183 | debug("USB_udc_probe\n"); |
| 184 | return s3c_udc_probe(&s5pc110_otg_data); |
| 185 | } |
Lukasz Majewski | a954da2 | 2011-10-27 10:36:47 +0200 | [diff] [blame] | 186 | #endif |
Piotr Wilczek | 2ac9a35 | 2014-01-22 15:54:33 +0100 | [diff] [blame] | 187 | |
| 188 | #ifdef CONFIG_MISC_INIT_R |
| 189 | int misc_init_r(void) |
| 190 | { |
| 191 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
| 192 | set_board_info(); |
| 193 | #endif |
| 194 | return 0; |
| 195 | } |
| 196 | #endif |