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