2 * Copyright (C) 2012 Samsung Electronics
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
31 #include <asm/arch/cpu.h>
32 #include <asm/arch/dwmmc.h>
33 #include <asm/arch/gpio.h>
34 #include <asm/arch/mmc.h>
35 #include <asm/arch/pinmux.h>
36 #include <asm/arch/power.h>
37 #include <asm/arch/sromc.h>
38 #include <asm/arch/dp_info.h>
39 #include <power/pmic.h>
40 #include <power/max77686_pmic.h>
42 DECLARE_GLOBAL_DATA_PTR;
44 #ifdef CONFIG_USB_EHCI_EXYNOS
45 int board_usb_vbus_init(void)
47 struct exynos5_gpio_part1 *gpio1 = (struct exynos5_gpio_part1 *)
48 samsung_get_base_gpio_part1();
50 /* Enable VBUS power switch */
51 s5p_gpio_direction_output(&gpio1->x2, 6, 1);
53 /* VBUS turn ON time */
60 #ifdef CONFIG_SOUND_MAX98095
61 static void board_enable_audio_codec(void)
63 struct exynos5_gpio_part1 *gpio1 = (struct exynos5_gpio_part1 *)
64 samsung_get_base_gpio_part1();
66 /* Enable MAX98095 Codec */
67 s5p_gpio_direction_output(&gpio1->x1, 7, 1);
68 s5p_gpio_set_pull(&gpio1->x1, 7, GPIO_PULL_NONE);
74 gd->bd->bi_boot_params = (PHYS_SDRAM_1 + 0x100UL);
76 #ifdef CONFIG_EXYNOS_SPI
79 #ifdef CONFIG_USB_EHCI_EXYNOS
80 board_usb_vbus_init();
82 #ifdef CONFIG_SOUND_MAX98095
83 board_enable_audio_codec();
93 for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
94 addr = CONFIG_SYS_SDRAM_BASE + (i * SDRAM_BANK_SIZE);
95 gd->ram_size += get_ram_size((long *)addr, SDRAM_BANK_SIZE);
100 #if defined(CONFIG_POWER)
101 static int pmic_reg_update(struct pmic *p, int reg, uint regval)
106 ret = pmic_reg_read(p, reg, &val);
108 debug("%s: PMIC %d register read failed\n", __func__, reg);
112 ret = pmic_reg_write(p, reg, val);
114 debug("%s: PMIC %d register write failed\n", __func__, reg);
120 int power_init_board(void)
126 i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
128 if (pmic_init(I2C_PMIC))
131 p = pmic_get("MAX77686_PMIC");
138 if (pmic_reg_update(p, MAX77686_REG_PMIC_32KHZ, MAX77686_32KHCP_EN))
141 if (pmic_reg_update(p, MAX77686_REG_PMIC_BBAT,
142 MAX77686_BBCHOSTEN | MAX77686_BBCVS_3_5V))
146 if (pmic_reg_write(p, MAX77686_REG_PMIC_BUCK1OUT,
147 MAX77686_BUCK1OUT_1V)) {
148 debug("%s: PMIC %d register write failed\n", __func__,
149 MAX77686_REG_PMIC_BUCK1OUT);
153 if (pmic_reg_update(p, MAX77686_REG_PMIC_BUCK1CRTL,
154 MAX77686_BUCK1CTRL_EN))
158 if (pmic_reg_write(p, MAX77686_REG_PMIC_BUCK2DVS1,
159 MAX77686_BUCK2DVS1_1_3V)) {
160 debug("%s: PMIC %d register write failed\n", __func__,
161 MAX77686_REG_PMIC_BUCK2DVS1);
165 if (pmic_reg_update(p, MAX77686_REG_PMIC_BUCK2CTRL1,
166 MAX77686_BUCK2CTRL_ON))
170 if (pmic_reg_write(p, MAX77686_REG_PMIC_BUCK3DVS1,
171 MAX77686_BUCK3DVS1_1_0125V)) {
172 debug("%s: PMIC %d register write failed\n", __func__,
173 MAX77686_REG_PMIC_BUCK3DVS1);
177 if (pmic_reg_update(p, MAX77686_REG_PMIC_BUCK3CTRL,
178 MAX77686_BUCK3CTRL_ON))
182 if (pmic_reg_write(p, MAX77686_REG_PMIC_BUCK4DVS1,
183 MAX77686_BUCK4DVS1_1_2V)) {
184 debug("%s: PMIC %d register write failed\n", __func__,
185 MAX77686_REG_PMIC_BUCK4DVS1);
189 if (pmic_reg_update(p, MAX77686_REG_PMIC_BUCK4CTRL1,
190 MAX77686_BUCK3CTRL_ON))
194 if (pmic_reg_update(p, MAX77686_REG_PMIC_LDO2CTRL1,
195 MAX77686_LD02CTRL1_1_5V | EN_LDO))
199 if (pmic_reg_update(p, MAX77686_REG_PMIC_LDO3CTRL1,
200 MAX77686_LD03CTRL1_1_8V | EN_LDO))
204 if (pmic_reg_update(p, MAX77686_REG_PMIC_LDO5CTRL1,
205 MAX77686_LD05CTRL1_1_8V | EN_LDO))
209 if (pmic_reg_update(p, MAX77686_REG_PMIC_LDO10CTRL1,
210 MAX77686_LD10CTRL1_1_8V | EN_LDO))
217 void dram_init_banksize(void)
221 for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
222 addr = CONFIG_SYS_SDRAM_BASE + (i * SDRAM_BANK_SIZE);
223 size = get_ram_size((long *)addr, SDRAM_BANK_SIZE);
224 gd->bd->bi_dram[i].start = addr;
225 gd->bd->bi_dram[i].size = size;
229 int board_eth_init(bd_t *bis)
231 #ifdef CONFIG_SMC911X
232 u32 smc_bw_conf, smc_bc_conf;
233 struct fdt_sromc config;
234 fdt_addr_t base_addr;
236 /* Non-FDT configuration - bank number and timing parameters*/
237 config.bank = CONFIG_ENV_SROM_BANK;
240 config.timing[FDT_SROM_TACS] = 0x01;
241 config.timing[FDT_SROM_TCOS] = 0x01;
242 config.timing[FDT_SROM_TACC] = 0x06;
243 config.timing[FDT_SROM_TCOH] = 0x01;
244 config.timing[FDT_SROM_TAH] = 0x0C;
245 config.timing[FDT_SROM_TACP] = 0x09;
246 config.timing[FDT_SROM_PMC] = 0x01;
247 base_addr = CONFIG_SMC911X_BASE;
249 /* Ethernet needs data bus width of 16 bits */
250 if (config.width != 2) {
251 debug("%s: Unsupported bus width %d\n", __func__,
255 smc_bw_conf = SROMC_DATA16_WIDTH(config.bank)
256 | SROMC_BYTE_ENABLE(config.bank);
258 smc_bc_conf = SROMC_BC_TACS(config.timing[FDT_SROM_TACS]) |\
259 SROMC_BC_TCOS(config.timing[FDT_SROM_TCOS]) |\
260 SROMC_BC_TACC(config.timing[FDT_SROM_TACC]) |\
261 SROMC_BC_TCOH(config.timing[FDT_SROM_TCOH]) |\
262 SROMC_BC_TAH(config.timing[FDT_SROM_TAH]) |\
263 SROMC_BC_TACP(config.timing[FDT_SROM_TACP]) |\
264 SROMC_BC_PMC(config.timing[FDT_SROM_PMC]);
266 /* Select and configure the SROMC bank */
267 exynos_pinmux_config(PERIPH_ID_SROMC, config.bank);
268 s5p_config_sromc(config.bank, smc_bw_conf, smc_bc_conf);
269 return smc911x_initialize(0, base_addr);
274 #ifdef CONFIG_DISPLAY_BOARDINFO
277 printf("\nBoard: SMDK5250\n");
282 #ifdef CONFIG_GENERIC_MMC
283 int board_mmc_init(bd_t *bis)
285 int err, ret = 0, index, bus_width;
288 err = exynos_pinmux_config(PERIPH_ID_SDMMC0, PINMUX_FLAG_8BIT_MODE);
290 debug("SDMMC0 not configured\n");
293 /*EMMC: dwmmc Channel-0 with 8 bit bus width */
295 base = samsung_get_base_mmc() + (0x10000 * index);
297 err = exynos_dwmci_add_port(index, base, bus_width, (u32)NULL);
299 debug("dwmmc Channel-0 init failed\n");
302 err = exynos_pinmux_config(PERIPH_ID_SDMMC2, PINMUX_FLAG_NONE);
304 debug("SDMMC2 not configured\n");
307 /*SD: dwmmc Channel-2 with 4 bit bus width */
309 base = samsung_get_base_mmc() + (0x10000 * index);
311 err = exynos_dwmci_add_port(index, base, bus_width, (u32)NULL);
313 debug("dwmmc Channel-2 init failed\n");
320 static int board_uart_init(void)
322 int err, uart_id, ret = 0;
324 for (uart_id = PERIPH_ID_UART0; uart_id <= PERIPH_ID_UART3; uart_id++) {
325 err = exynos_pinmux_config(uart_id, PINMUX_FLAG_NONE);
327 debug("UART%d not configured\n",
328 (uart_id - PERIPH_ID_UART0));
335 #ifdef CONFIG_BOARD_EARLY_INIT_F
336 int board_early_init_f(void)
339 err = board_uart_init();
341 debug("UART init failed\n");
344 #ifdef CONFIG_SYS_I2C_INIT_BOARD
345 board_i2c_init(NULL);
352 void exynos_cfg_lcd_gpio(void)
354 struct exynos5_gpio_part1 *gpio1 =
355 (struct exynos5_gpio_part1 *) samsung_get_base_gpio_part1();
358 s5p_gpio_cfg_pin(&gpio1->b2, 0, GPIO_OUTPUT);
359 s5p_gpio_set_value(&gpio1->b2, 0, 1);
362 s5p_gpio_cfg_pin(&gpio1->x1, 5, GPIO_OUTPUT);
363 s5p_gpio_set_value(&gpio1->x1, 5, 1);
365 /* Set Hotplug detect for DP */
366 s5p_gpio_cfg_pin(&gpio1->x0, 7, GPIO_FUNC(0x3));
369 void exynos_set_dp_phy(unsigned int onoff)
371 set_dp_phy_ctrl(onoff);
374 vidinfo_t panel_info = {
380 .vl_clkp = CONFIG_SYS_LOW,
381 .vl_hsp = CONFIG_SYS_LOW,
382 .vl_vsp = CONFIG_SYS_LOW,
383 .vl_dp = CONFIG_SYS_LOW,
384 .vl_bpix = 4, /* LCD_BPP = 2^4, for output conosle on LCD */
386 /* wDP panel timing infomation */
394 .vl_cmd_allow_len = 0xf,
397 .dual_lcd_enabled = 0,
402 .interface_mode = FIMD_RGB_INTERFACE,
406 static struct edp_device_info edp_info = {
419 .lt_status = DP_LT_NONE,
423 .bist_mode = DP_DISABLE,
424 .bist_pattern = NO_PATTERN,
425 .h_sync_polarity = 0,
426 .v_sync_polarity = 0,
428 .color_space = COLOR_RGB,
429 .dynamic_range = VESA,
430 .ycbcr_coeff = COLOR_YCBCR601,
431 .color_depth = COLOR_8,
435 static struct exynos_dp_platform_data dp_platform_data = {
436 .edp_dev_info = &edp_info,
439 void init_panel_info(vidinfo_t *vid)
441 vid->rgb_mode = MODE_RGB_P;
442 exynos_set_dp_platform_data(&dp_platform_data);