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 | |
| 35 | ret = pmic_init(I2C_5); |
| 36 | if (ret) |
| 37 | return ret; |
Łukasz Majewski | c733681 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 38 | |
Minkyu Kang | 72b81d3 | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | int dram_init(void) |
| 43 | { |
Minkyu Kang | 177feff | 2010-11-22 20:27:44 +0900 | [diff] [blame] | 44 | gd->ram_size = PHYS_SDRAM_1_SIZE + PHYS_SDRAM_2_SIZE + |
| 45 | PHYS_SDRAM_3_SIZE; |
| 46 | |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | void dram_init_banksize(void) |
| 51 | { |
Minkyu Kang | 72b81d3 | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 52 | gd->bd->bi_dram[0].start = PHYS_SDRAM_1; |
| 53 | gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE; |
| 54 | gd->bd->bi_dram[1].start = PHYS_SDRAM_2; |
| 55 | gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE; |
| 56 | gd->bd->bi_dram[2].start = PHYS_SDRAM_3; |
| 57 | gd->bd->bi_dram[2].size = PHYS_SDRAM_3_SIZE; |
Minkyu Kang | 72b81d3 | 2010-05-31 22:02:42 +0900 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | #ifdef CONFIG_DISPLAY_BOARDINFO |
| 61 | int checkboard(void) |
| 62 | { |
| 63 | puts("Board:\tGoni\n"); |
| 64 | return 0; |
| 65 | } |
| 66 | #endif |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 67 | |
| 68 | #ifdef CONFIG_GENERIC_MMC |
| 69 | int board_mmc_init(bd_t *bis) |
| 70 | { |
| 71 | int i; |
| 72 | |
| 73 | /* MASSMEMORY_EN: XMSMDATA7: GPJ2[7] output high */ |
Łukasz Majewski | ef5d9eb | 2011-07-15 00:16:22 +0000 | [diff] [blame] | 74 | s5p_gpio_direction_output(&s5pc110_gpio->j2, 7, 1); |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 75 | |
| 76 | /* |
| 77 | * MMC0 GPIO |
| 78 | * GPG0[0] SD_0_CLK |
| 79 | * GPG0[1] SD_0_CMD |
| 80 | * GPG0[2] SD_0_CDn -> Not used |
| 81 | * GPG0[3:6] SD_0_DATA[0:3] |
| 82 | */ |
| 83 | for (i = 0; i < 7; i++) { |
| 84 | if (i == 2) |
| 85 | continue; |
| 86 | /* GPG0[0:6] special function 2 */ |
Łukasz Majewski | ef5d9eb | 2011-07-15 00:16:22 +0000 | [diff] [blame] | 87 | s5p_gpio_cfg_pin(&s5pc110_gpio->g0, i, 0x2); |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 88 | /* GPG0[0:6] pull disable */ |
Łukasz Majewski | ef5d9eb | 2011-07-15 00:16:22 +0000 | [diff] [blame] | 89 | s5p_gpio_set_pull(&s5pc110_gpio->g0, i, GPIO_PULL_NONE); |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 90 | /* GPG0[0:6] drv 4x */ |
Łukasz Majewski | ef5d9eb | 2011-07-15 00:16:22 +0000 | [diff] [blame] | 91 | s5p_gpio_set_drv(&s5pc110_gpio->g0, i, GPIO_DRV_4X); |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 92 | } |
| 93 | |
Jaehoon Chung | 1727e21 | 2010-09-27 15:43:52 +0900 | [diff] [blame] | 94 | return s5p_mmc_init(0, 4); |
Minkyu Kang | 87f314e | 2010-07-06 20:58:41 +0900 | [diff] [blame] | 95 | } |
| 96 | #endif |
Lukasz Majewski | a954da2 | 2011-10-27 10:36:47 +0200 | [diff] [blame] | 97 | |
| 98 | #ifdef CONFIG_USB_GADGET |
| 99 | static int s5pc1xx_phy_control(int on) |
| 100 | { |
| 101 | int ret; |
| 102 | static int status; |
Łukasz Majewski | c733681 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 103 | struct pmic *p = pmic_get("MAX8998_PMIC"); |
| 104 | if (!p) |
| 105 | return -ENODEV; |
Lukasz Majewski | a954da2 | 2011-10-27 10:36:47 +0200 | [diff] [blame] | 106 | |
| 107 | if (pmic_probe(p)) |
| 108 | return -1; |
| 109 | |
| 110 | if (on && !status) { |
| 111 | ret = pmic_set_output(p, MAX8998_REG_ONOFF1, |
| 112 | MAX8998_LDO3, LDO_ON); |
| 113 | ret = pmic_set_output(p, MAX8998_REG_ONOFF2, |
| 114 | MAX8998_LDO8, LDO_ON); |
| 115 | if (ret) { |
| 116 | puts("MAX8998 LDO setting error!\n"); |
| 117 | return -1; |
| 118 | } |
| 119 | status = 1; |
| 120 | } else if (!on && status) { |
| 121 | ret = pmic_set_output(p, MAX8998_REG_ONOFF1, |
| 122 | MAX8998_LDO3, LDO_OFF); |
| 123 | ret = pmic_set_output(p, MAX8998_REG_ONOFF2, |
| 124 | MAX8998_LDO8, LDO_OFF); |
| 125 | if (ret) { |
| 126 | puts("MAX8998 LDO setting error!\n"); |
| 127 | return -1; |
| 128 | } |
| 129 | status = 0; |
| 130 | } |
| 131 | udelay(10000); |
| 132 | |
| 133 | return 0; |
| 134 | } |
| 135 | |
| 136 | struct s3c_plat_otg_data s5pc110_otg_data = { |
| 137 | .phy_control = s5pc1xx_phy_control, |
| 138 | .regs_phy = S5PC110_PHY_BASE, |
| 139 | .regs_otg = S5PC110_OTG_BASE, |
| 140 | .usb_phy_ctrl = S5PC110_USB_PHY_CONTROL, |
| 141 | }; |
| 142 | #endif |