blob: a69f73d5e85319ef60c9d2ea7908ab9facfd7484 [file] [log] [blame]
Chander Kashyap0aee53b2012-02-05 23:01:47 +00001/*
2 * Copyright (C) 2012 Samsung Electronics
3 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Chander Kashyap0aee53b2012-02-05 23:01:47 +00005 */
6
7#include <common.h>
Rajeshwari Birje71ebb332013-12-26 09:44:17 +05308#include <cros_ec.h>
Hatim RV3ea93942012-12-11 00:52:47 +00009#include <fdtdec.h>
Chander Kashyap0aee53b2012-02-05 23:01:47 +000010#include <asm/io.h>
Rajeshwari Shindeb278c402013-02-12 20:40:02 +000011#include <errno.h>
Rajeshwari Shindec82b0502012-07-23 21:23:55 +000012#include <i2c.h>
Ajay Kumar9b572852013-01-08 20:42:26 +000013#include <lcd.h>
Chander Kashyap0aee53b2012-02-05 23:01:47 +000014#include <netdev.h>
Hatim RV3a8a7002012-11-02 01:15:37 +000015#include <spi.h>
Chander Kashyap0aee53b2012-02-05 23:01:47 +000016#include <asm/arch/cpu.h>
Amar752f4c42013-04-27 11:42:57 +053017#include <asm/arch/dwmmc.h>
Chander Kashyap0aee53b2012-02-05 23:01:47 +000018#include <asm/arch/gpio.h>
19#include <asm/arch/mmc.h>
Rajeshwari Shindec6baaa62012-06-06 19:54:30 +000020#include <asm/arch/pinmux.h>
Ajay Kumar9b572852013-01-08 20:42:26 +000021#include <asm/arch/power.h>
Chander Kashyap0aee53b2012-02-05 23:01:47 +000022#include <asm/arch/sromc.h>
Ajay Kumar9b572852013-01-08 20:42:26 +000023#include <asm/arch/dp_info.h>
Rajeshwari Shinde211e8432012-12-10 01:55:48 +000024#include <power/pmic.h>
Rajeshwari Shindeb278c402013-02-12 20:40:02 +000025#include <power/max77686_pmic.h>
Chander Kashyap0aee53b2012-02-05 23:01:47 +000026
27DECLARE_GLOBAL_DATA_PTR;
Chander Kashyap0aee53b2012-02-05 23:01:47 +000028
Rajeshwari Shindece073802013-02-14 19:46:14 +000029#ifdef CONFIG_SOUND_MAX98095
30static void board_enable_audio_codec(void)
31{
32 struct exynos5_gpio_part1 *gpio1 = (struct exynos5_gpio_part1 *)
33 samsung_get_base_gpio_part1();
34
35 /* Enable MAX98095 Codec */
36 s5p_gpio_direction_output(&gpio1->x1, 7, 1);
37 s5p_gpio_set_pull(&gpio1->x1, 7, GPIO_PULL_NONE);
38}
39#endif
40
Rajeshwari Birje71ebb332013-12-26 09:44:17 +053041int exynos_init(void)
Chander Kashyap0aee53b2012-02-05 23:01:47 +000042{
Rajeshwari Shindece073802013-02-14 19:46:14 +000043#ifdef CONFIG_SOUND_MAX98095
44 board_enable_audio_codec();
45#endif
Chander Kashyap0aee53b2012-02-05 23:01:47 +000046 return 0;
47}
48
Chander Kashyapbf936212012-02-09 01:26:19 +000049int board_eth_init(bd_t *bis)
50{
51#ifdef CONFIG_SMC911X
Hatim RV3ea93942012-12-11 00:52:47 +000052 u32 smc_bw_conf, smc_bc_conf;
53 struct fdt_sromc config;
54 fdt_addr_t base_addr;
Hatim RV3ea93942012-12-11 00:52:47 +000055
Hatim RV3ea93942012-12-11 00:52:47 +000056 /* Non-FDT configuration - bank number and timing parameters*/
57 config.bank = CONFIG_ENV_SROM_BANK;
58 config.width = 2;
59
60 config.timing[FDT_SROM_TACS] = 0x01;
61 config.timing[FDT_SROM_TCOS] = 0x01;
62 config.timing[FDT_SROM_TACC] = 0x06;
63 config.timing[FDT_SROM_TCOH] = 0x01;
64 config.timing[FDT_SROM_TAH] = 0x0C;
65 config.timing[FDT_SROM_TACP] = 0x09;
66 config.timing[FDT_SROM_PMC] = 0x01;
67 base_addr = CONFIG_SMC911X_BASE;
Hatim RV3ea93942012-12-11 00:52:47 +000068
69 /* Ethernet needs data bus width of 16 bits */
70 if (config.width != 2) {
71 debug("%s: Unsupported bus width %d\n", __func__,
72 config.width);
73 return -1;
74 }
75 smc_bw_conf = SROMC_DATA16_WIDTH(config.bank)
76 | SROMC_BYTE_ENABLE(config.bank);
77
78 smc_bc_conf = SROMC_BC_TACS(config.timing[FDT_SROM_TACS]) |\
79 SROMC_BC_TCOS(config.timing[FDT_SROM_TCOS]) |\
80 SROMC_BC_TACC(config.timing[FDT_SROM_TACC]) |\
81 SROMC_BC_TCOH(config.timing[FDT_SROM_TCOH]) |\
82 SROMC_BC_TAH(config.timing[FDT_SROM_TAH]) |\
83 SROMC_BC_TACP(config.timing[FDT_SROM_TACP]) |\
84 SROMC_BC_PMC(config.timing[FDT_SROM_PMC]);
85
86 /* Select and configure the SROMC bank */
87 exynos_pinmux_config(PERIPH_ID_SROMC, config.bank);
88 s5p_config_sromc(config.bank, smc_bw_conf, smc_bc_conf);
89 return smc911x_initialize(0, base_addr);
Chander Kashyapbf936212012-02-09 01:26:19 +000090#endif
91 return 0;
92}
93
Chander Kashyap0aee53b2012-02-05 23:01:47 +000094#ifdef CONFIG_DISPLAY_BOARDINFO
95int checkboard(void)
96{
Rajeshwari Shinde07f17502013-02-18 02:51:49 +000097 printf("\nBoard: SMDK5250\n");
Chander Kashyap0aee53b2012-02-05 23:01:47 +000098 return 0;
99}
100#endif
101
102#ifdef CONFIG_GENERIC_MMC
103int board_mmc_init(bd_t *bis)
104{
Amar752f4c42013-04-27 11:42:57 +0530105 int err, ret = 0, index, bus_width;
106 u32 base;
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000107
Rajeshwari Shinde41222c22012-07-03 20:03:00 +0000108 err = exynos_pinmux_config(PERIPH_ID_SDMMC0, PINMUX_FLAG_8BIT_MODE);
Amar752f4c42013-04-27 11:42:57 +0530109 if (err)
Rajeshwari Shinde41222c22012-07-03 20:03:00 +0000110 debug("SDMMC0 not configured\n");
Amar752f4c42013-04-27 11:42:57 +0530111 ret |= err;
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000112
Amar752f4c42013-04-27 11:42:57 +0530113 /*EMMC: dwmmc Channel-0 with 8 bit bus width */
114 index = 0;
115 base = samsung_get_base_mmc() + (0x10000 * index);
116 bus_width = 8;
117 err = exynos_dwmci_add_port(index, base, bus_width, (u32)NULL);
118 if (err)
119 debug("dwmmc Channel-0 init failed\n");
120 ret |= err;
121
122 err = exynos_pinmux_config(PERIPH_ID_SDMMC2, PINMUX_FLAG_NONE);
123 if (err)
124 debug("SDMMC2 not configured\n");
125 ret |= err;
126
127 /*SD: dwmmc Channel-2 with 4 bit bus width */
128 index = 2;
129 base = samsung_get_base_mmc() + (0x10000 * index);
130 bus_width = 4;
131 err = exynos_dwmci_add_port(index, base, bus_width, (u32)NULL);
132 if (err)
133 debug("dwmmc Channel-2 init failed\n");
134 ret |= err;
135
136 return ret;
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000137}
138#endif
139
Amar1ae76d42013-07-10 10:42:29 +0530140void board_i2c_init(const void *blob)
141{
142 int i;
143
144 for (i = 0; i < CONFIG_MAX_I2C_NUM; i++) {
145 exynos_pinmux_config((PERIPH_ID_I2C0 + i),
146 PINMUX_FLAG_NONE);
147 }
148}
149
Ajay Kumar99e51622013-01-10 21:06:10 +0000150#ifdef CONFIG_LCD
Ajay Kumar29fd5702013-02-21 23:52:57 +0000151void exynos_cfg_lcd_gpio(void)
Ajay Kumar9b572852013-01-08 20:42:26 +0000152{
153 struct exynos5_gpio_part1 *gpio1 =
154 (struct exynos5_gpio_part1 *) samsung_get_base_gpio_part1();
155
156 /* For Backlight */
157 s5p_gpio_cfg_pin(&gpio1->b2, 0, GPIO_OUTPUT);
158 s5p_gpio_set_value(&gpio1->b2, 0, 1);
159
160 /* LCD power on */
161 s5p_gpio_cfg_pin(&gpio1->x1, 5, GPIO_OUTPUT);
162 s5p_gpio_set_value(&gpio1->x1, 5, 1);
163
164 /* Set Hotplug detect for DP */
165 s5p_gpio_cfg_pin(&gpio1->x0, 7, GPIO_FUNC(0x3));
166}
167
Ajay Kumar18637812013-02-21 23:53:09 +0000168void exynos_set_dp_phy(unsigned int onoff)
169{
170 set_dp_phy_ctrl(onoff);
171}
172
Ajay Kumar9b572852013-01-08 20:42:26 +0000173vidinfo_t panel_info = {
174 .vl_freq = 60,
175 .vl_col = 2560,
176 .vl_row = 1600,
177 .vl_width = 2560,
178 .vl_height = 1600,
179 .vl_clkp = CONFIG_SYS_LOW,
180 .vl_hsp = CONFIG_SYS_LOW,
181 .vl_vsp = CONFIG_SYS_LOW,
182 .vl_dp = CONFIG_SYS_LOW,
183 .vl_bpix = 4, /* LCD_BPP = 2^4, for output conosle on LCD */
184
185 /* wDP panel timing infomation */
186 .vl_hspw = 32,
187 .vl_hbpd = 80,
188 .vl_hfpd = 48,
189
190 .vl_vspw = 6,
191 .vl_vbpd = 37,
192 .vl_vfpd = 3,
193 .vl_cmd_allow_len = 0xf,
194
195 .win_id = 3,
Ajay Kumar9b572852013-01-08 20:42:26 +0000196 .dual_lcd_enabled = 0,
197
198 .init_delay = 0,
199 .power_on_delay = 0,
200 .reset_delay = 0,
201 .interface_mode = FIMD_RGB_INTERFACE,
202 .dp_enabled = 1,
203};
204
205static struct edp_device_info edp_info = {
206 .disp_info = {
207 .h_res = 2560,
208 .h_sync_width = 32,
209 .h_back_porch = 80,
210 .h_front_porch = 48,
211 .v_res = 1600,
212 .v_sync_width = 6,
213 .v_back_porch = 37,
214 .v_front_porch = 3,
215 .v_sync_rate = 60,
216 },
217 .lt_info = {
218 .lt_status = DP_LT_NONE,
219 },
220 .video_info = {
221 .master_mode = 0,
222 .bist_mode = DP_DISABLE,
223 .bist_pattern = NO_PATTERN,
224 .h_sync_polarity = 0,
225 .v_sync_polarity = 0,
226 .interlaced = 0,
227 .color_space = COLOR_RGB,
228 .dynamic_range = VESA,
229 .ycbcr_coeff = COLOR_YCBCR601,
230 .color_depth = COLOR_8,
231 },
232};
233
234static struct exynos_dp_platform_data dp_platform_data = {
Ajay Kumar9b572852013-01-08 20:42:26 +0000235 .edp_dev_info = &edp_info,
236};
237
238void init_panel_info(vidinfo_t *vid)
239{
Amar752f4c42013-04-27 11:42:57 +0530240 vid->rgb_mode = MODE_RGB_P;
Ajay Kumar9b572852013-01-08 20:42:26 +0000241 exynos_set_dp_platform_data(&dp_platform_data);
242}
Ajay Kumar99e51622013-01-10 21:06:10 +0000243#endif