Minkyu Kang | 194cbce | 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 | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 6 | * SPDX-License-Identifier: GPL-2.0+ |
Minkyu Kang | 194cbce | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
Minkyu Kang | 2111b2d | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 10 | #include <asm/arch/gpio.h> |
| 11 | #include <asm/arch/mmc.h> |
Łukasz Majewski | 1c6dba1 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 12 | #include <power/pmic.h> |
Lukasz Majewski | 35be850 | 2011-10-27 10:36:47 +0200 | [diff] [blame] | 13 | #include <usb/s3c_udc.h> |
| 14 | #include <asm/arch/cpu.h> |
Łukasz Majewski | 1c6dba1 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 15 | #include <power/max8998_pmic.h> |
Piotr Wilczek | c88b89e | 2014-01-22 15:54:33 +0100 | [diff] [blame] | 16 | #include <samsung/misc.h> |
| 17 | |
Minkyu Kang | 194cbce | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 18 | DECLARE_GLOBAL_DATA_PTR; |
| 19 | |
Minkyu Kang | 2111b2d | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 20 | static struct s5pc110_gpio *s5pc110_gpio; |
| 21 | |
Piotr Wilczek | c88b89e | 2014-01-22 15:54:33 +0100 | [diff] [blame] | 22 | u32 get_board_rev(void) |
| 23 | { |
| 24 | return 0; |
| 25 | } |
| 26 | |
Minkyu Kang | 194cbce | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 27 | int board_init(void) |
| 28 | { |
Minkyu Kang | 2111b2d | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 29 | /* Set Initial global variables */ |
| 30 | s5pc110_gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE; |
| 31 | |
Minkyu Kang | 194cbce | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 32 | gd->bd->bi_arch_number = MACH_TYPE_GONI; |
| 33 | gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100; |
| 34 | |
Łukasz Majewski | 0fcc9a5 | 2012-11-13 03:22:16 +0000 | [diff] [blame] | 35 | return 0; |
| 36 | } |
| 37 | |
| 38 | int power_init_board(void) |
| 39 | { |
| 40 | int ret; |
| 41 | |
Łukasz Majewski | de55e75 | 2013-08-16 15:33:33 +0200 | [diff] [blame] | 42 | /* |
| 43 | * For PMIC the I2C bus is named as I2C5, but it is connected |
| 44 | * to logical I2C adapter 0 |
| 45 | */ |
| 46 | ret = pmic_init(I2C_0); |
Łukasz Majewski | 0fcc9a5 | 2012-11-13 03:22:16 +0000 | [diff] [blame] | 47 | if (ret) |
| 48 | return ret; |
Łukasz Majewski | 1c6dba1 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 49 | |
Minkyu Kang | 194cbce | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 50 | return 0; |
| 51 | } |
| 52 | |
| 53 | int dram_init(void) |
| 54 | { |
Minkyu Kang | 00ab176 | 2010-11-22 20:27:44 +0900 | [diff] [blame] | 55 | gd->ram_size = PHYS_SDRAM_1_SIZE + PHYS_SDRAM_2_SIZE + |
| 56 | PHYS_SDRAM_3_SIZE; |
| 57 | |
| 58 | return 0; |
| 59 | } |
| 60 | |
| 61 | void dram_init_banksize(void) |
| 62 | { |
Minkyu Kang | 194cbce | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 63 | gd->bd->bi_dram[0].start = PHYS_SDRAM_1; |
| 64 | gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE; |
| 65 | gd->bd->bi_dram[1].start = PHYS_SDRAM_2; |
| 66 | gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE; |
| 67 | gd->bd->bi_dram[2].start = PHYS_SDRAM_3; |
| 68 | gd->bd->bi_dram[2].size = PHYS_SDRAM_3_SIZE; |
Minkyu Kang | 194cbce | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | #ifdef CONFIG_DISPLAY_BOARDINFO |
| 72 | int checkboard(void) |
| 73 | { |
| 74 | puts("Board:\tGoni\n"); |
| 75 | return 0; |
| 76 | } |
| 77 | #endif |
Minkyu Kang | 2111b2d | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 78 | |
| 79 | #ifdef CONFIG_GENERIC_MMC |
| 80 | int board_mmc_init(bd_t *bis) |
| 81 | { |
Przemyslaw Marczak | 151d23f | 2013-09-10 11:34:49 +0200 | [diff] [blame] | 82 | int i, ret, ret_sd = 0; |
Minkyu Kang | 2111b2d | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 83 | |
| 84 | /* MASSMEMORY_EN: XMSMDATA7: GPJ2[7] output high */ |
Łukasz Majewski | 4d954cc | 2011-07-15 00:16:22 +0000 | [diff] [blame] | 85 | s5p_gpio_direction_output(&s5pc110_gpio->j2, 7, 1); |
Minkyu Kang | 2111b2d | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 86 | |
| 87 | /* |
| 88 | * MMC0 GPIO |
| 89 | * GPG0[0] SD_0_CLK |
| 90 | * GPG0[1] SD_0_CMD |
| 91 | * GPG0[2] SD_0_CDn -> Not used |
| 92 | * GPG0[3:6] SD_0_DATA[0:3] |
| 93 | */ |
| 94 | for (i = 0; i < 7; i++) { |
| 95 | if (i == 2) |
| 96 | continue; |
| 97 | /* GPG0[0:6] special function 2 */ |
Łukasz Majewski | 4d954cc | 2011-07-15 00:16:22 +0000 | [diff] [blame] | 98 | s5p_gpio_cfg_pin(&s5pc110_gpio->g0, i, 0x2); |
Minkyu Kang | 2111b2d | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 99 | /* GPG0[0:6] pull disable */ |
Łukasz Majewski | 4d954cc | 2011-07-15 00:16:22 +0000 | [diff] [blame] | 100 | s5p_gpio_set_pull(&s5pc110_gpio->g0, i, GPIO_PULL_NONE); |
Minkyu Kang | 2111b2d | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 101 | /* GPG0[0:6] drv 4x */ |
Łukasz Majewski | 4d954cc | 2011-07-15 00:16:22 +0000 | [diff] [blame] | 102 | s5p_gpio_set_drv(&s5pc110_gpio->g0, i, GPIO_DRV_4X); |
Minkyu Kang | 2111b2d | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 103 | } |
| 104 | |
Przemyslaw Marczak | 151d23f | 2013-09-10 11:34:49 +0200 | [diff] [blame] | 105 | ret = s5p_mmc_init(0, 4); |
| 106 | if (ret) |
| 107 | error("MMC: Failed to init MMC:0.\n"); |
| 108 | |
| 109 | /* |
| 110 | * SD card (T_FLASH) detect and init |
| 111 | * T_FLASH_DETECT: EINT28: GPH3[4] input mode |
| 112 | */ |
| 113 | s5p_gpio_cfg_pin(&s5pc110_gpio->h3, 4, GPIO_INPUT); |
| 114 | s5p_gpio_set_pull(&s5pc110_gpio->h3, 4, GPIO_PULL_UP); |
| 115 | |
| 116 | if (!s5p_gpio_get_value(&s5pc110_gpio->h3, 4)) { |
| 117 | for (i = 0; i < 7; i++) { |
| 118 | if (i == 2) |
| 119 | continue; |
| 120 | |
| 121 | /* GPG2[0:6] special function 2 */ |
| 122 | s5p_gpio_cfg_pin(&s5pc110_gpio->g2, i, 0x2); |
| 123 | /* GPG2[0:6] pull disable */ |
| 124 | s5p_gpio_set_pull(&s5pc110_gpio->g2, i, GPIO_PULL_NONE); |
| 125 | /* GPG2[0:6] drv 4x */ |
| 126 | s5p_gpio_set_drv(&s5pc110_gpio->g2, i, GPIO_DRV_4X); |
| 127 | } |
| 128 | |
| 129 | ret_sd = s5p_mmc_init(2, 4); |
| 130 | if (ret_sd) |
| 131 | error("MMC: Failed to init SD card (MMC:2).\n"); |
| 132 | } |
| 133 | |
| 134 | return ret & ret_sd; |
Minkyu Kang | 2111b2d | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 135 | } |
| 136 | #endif |
Lukasz Majewski | 35be850 | 2011-10-27 10:36:47 +0200 | [diff] [blame] | 137 | |
| 138 | #ifdef CONFIG_USB_GADGET |
| 139 | static int s5pc1xx_phy_control(int on) |
| 140 | { |
| 141 | int ret; |
| 142 | static int status; |
Łukasz Majewski | 1c6dba1 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 143 | struct pmic *p = pmic_get("MAX8998_PMIC"); |
| 144 | if (!p) |
| 145 | return -ENODEV; |
Lukasz Majewski | 35be850 | 2011-10-27 10:36:47 +0200 | [diff] [blame] | 146 | |
| 147 | if (pmic_probe(p)) |
| 148 | return -1; |
| 149 | |
| 150 | if (on && !status) { |
| 151 | ret = pmic_set_output(p, MAX8998_REG_ONOFF1, |
| 152 | MAX8998_LDO3, LDO_ON); |
| 153 | ret = pmic_set_output(p, MAX8998_REG_ONOFF2, |
| 154 | MAX8998_LDO8, LDO_ON); |
| 155 | if (ret) { |
| 156 | puts("MAX8998 LDO setting error!\n"); |
| 157 | return -1; |
| 158 | } |
| 159 | status = 1; |
| 160 | } else if (!on && status) { |
| 161 | ret = pmic_set_output(p, MAX8998_REG_ONOFF1, |
| 162 | MAX8998_LDO3, LDO_OFF); |
| 163 | ret = pmic_set_output(p, MAX8998_REG_ONOFF2, |
| 164 | MAX8998_LDO8, LDO_OFF); |
| 165 | if (ret) { |
| 166 | puts("MAX8998 LDO setting error!\n"); |
| 167 | return -1; |
| 168 | } |
| 169 | status = 0; |
| 170 | } |
| 171 | udelay(10000); |
| 172 | |
| 173 | return 0; |
| 174 | } |
| 175 | |
| 176 | struct s3c_plat_otg_data s5pc110_otg_data = { |
| 177 | .phy_control = s5pc1xx_phy_control, |
| 178 | .regs_phy = S5PC110_PHY_BASE, |
| 179 | .regs_otg = S5PC110_OTG_BASE, |
| 180 | .usb_phy_ctrl = S5PC110_USB_PHY_CONTROL, |
| 181 | }; |
| 182 | #endif |
Piotr Wilczek | c88b89e | 2014-01-22 15:54:33 +0100 | [diff] [blame] | 183 | |
| 184 | #ifdef CONFIG_MISC_INIT_R |
| 185 | int misc_init_r(void) |
| 186 | { |
| 187 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
| 188 | set_board_info(); |
| 189 | #endif |
| 190 | return 0; |
| 191 | } |
| 192 | #endif |