blob: 014b7bdf8902dbde6d73fb8ffd505c369038027b [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{
Rajeshwari Shindece073802013-02-14 19:46:14 +000032 /* Enable MAX98095 Codec */
Akshay Saraswatf6ae1ca2014-05-13 10:30:14 +053033 gpio_direction_output(EXYNOS5_GPIO_X17, 1);
34 gpio_set_pull(EXYNOS5_GPIO_X17, S5P_GPIO_PULL_NONE);
Rajeshwari Shindece073802013-02-14 19:46:14 +000035}
36#endif
37
Rajeshwari Birje71ebb332013-12-26 09:44:17 +053038int exynos_init(void)
Chander Kashyap0aee53b2012-02-05 23:01:47 +000039{
Rajeshwari Shindece073802013-02-14 19:46:14 +000040#ifdef CONFIG_SOUND_MAX98095
41 board_enable_audio_codec();
42#endif
Chander Kashyap0aee53b2012-02-05 23:01:47 +000043 return 0;
44}
45
Chander Kashyapbf936212012-02-09 01:26:19 +000046int board_eth_init(bd_t *bis)
47{
48#ifdef CONFIG_SMC911X
Hatim RV3ea93942012-12-11 00:52:47 +000049 u32 smc_bw_conf, smc_bc_conf;
50 struct fdt_sromc config;
51 fdt_addr_t base_addr;
Hatim RV3ea93942012-12-11 00:52:47 +000052
Hatim RV3ea93942012-12-11 00:52:47 +000053 /* Non-FDT configuration - bank number and timing parameters*/
54 config.bank = CONFIG_ENV_SROM_BANK;
55 config.width = 2;
56
57 config.timing[FDT_SROM_TACS] = 0x01;
58 config.timing[FDT_SROM_TCOS] = 0x01;
59 config.timing[FDT_SROM_TACC] = 0x06;
60 config.timing[FDT_SROM_TCOH] = 0x01;
61 config.timing[FDT_SROM_TAH] = 0x0C;
62 config.timing[FDT_SROM_TACP] = 0x09;
63 config.timing[FDT_SROM_PMC] = 0x01;
64 base_addr = CONFIG_SMC911X_BASE;
Hatim RV3ea93942012-12-11 00:52:47 +000065
66 /* Ethernet needs data bus width of 16 bits */
67 if (config.width != 2) {
68 debug("%s: Unsupported bus width %d\n", __func__,
69 config.width);
70 return -1;
71 }
72 smc_bw_conf = SROMC_DATA16_WIDTH(config.bank)
73 | SROMC_BYTE_ENABLE(config.bank);
74
75 smc_bc_conf = SROMC_BC_TACS(config.timing[FDT_SROM_TACS]) |\
76 SROMC_BC_TCOS(config.timing[FDT_SROM_TCOS]) |\
77 SROMC_BC_TACC(config.timing[FDT_SROM_TACC]) |\
78 SROMC_BC_TCOH(config.timing[FDT_SROM_TCOH]) |\
79 SROMC_BC_TAH(config.timing[FDT_SROM_TAH]) |\
80 SROMC_BC_TACP(config.timing[FDT_SROM_TACP]) |\
81 SROMC_BC_PMC(config.timing[FDT_SROM_PMC]);
82
83 /* Select and configure the SROMC bank */
84 exynos_pinmux_config(PERIPH_ID_SROMC, config.bank);
85 s5p_config_sromc(config.bank, smc_bw_conf, smc_bc_conf);
86 return smc911x_initialize(0, base_addr);
Chander Kashyapbf936212012-02-09 01:26:19 +000087#endif
88 return 0;
89}
90
Chander Kashyap0aee53b2012-02-05 23:01:47 +000091#ifdef CONFIG_DISPLAY_BOARDINFO
92int checkboard(void)
93{
Rajeshwari Shinde07f17502013-02-18 02:51:49 +000094 printf("\nBoard: SMDK5250\n");
Chander Kashyap0aee53b2012-02-05 23:01:47 +000095 return 0;
96}
97#endif
98
99#ifdef CONFIG_GENERIC_MMC
100int board_mmc_init(bd_t *bis)
101{
Amar752f4c42013-04-27 11:42:57 +0530102 int err, ret = 0, index, bus_width;
103 u32 base;
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000104
Rajeshwari Shinde41222c22012-07-03 20:03:00 +0000105 err = exynos_pinmux_config(PERIPH_ID_SDMMC0, PINMUX_FLAG_8BIT_MODE);
Amar752f4c42013-04-27 11:42:57 +0530106 if (err)
Rajeshwari Shinde41222c22012-07-03 20:03:00 +0000107 debug("SDMMC0 not configured\n");
Amar752f4c42013-04-27 11:42:57 +0530108 ret |= err;
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000109
Amar752f4c42013-04-27 11:42:57 +0530110 /*EMMC: dwmmc Channel-0 with 8 bit bus width */
111 index = 0;
112 base = samsung_get_base_mmc() + (0x10000 * index);
113 bus_width = 8;
114 err = exynos_dwmci_add_port(index, base, bus_width, (u32)NULL);
115 if (err)
116 debug("dwmmc Channel-0 init failed\n");
117 ret |= err;
118
119 err = exynos_pinmux_config(PERIPH_ID_SDMMC2, PINMUX_FLAG_NONE);
120 if (err)
121 debug("SDMMC2 not configured\n");
122 ret |= err;
123
124 /*SD: dwmmc Channel-2 with 4 bit bus width */
125 index = 2;
126 base = samsung_get_base_mmc() + (0x10000 * index);
127 bus_width = 4;
128 err = exynos_dwmci_add_port(index, base, bus_width, (u32)NULL);
129 if (err)
130 debug("dwmmc Channel-2 init failed\n");
131 ret |= err;
132
133 return ret;
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000134}
135#endif
136
Amar1ae76d42013-07-10 10:42:29 +0530137void board_i2c_init(const void *blob)
138{
139 int i;
140
141 for (i = 0; i < CONFIG_MAX_I2C_NUM; i++) {
142 exynos_pinmux_config((PERIPH_ID_I2C0 + i),
143 PINMUX_FLAG_NONE);
144 }
145}
146
Piotr Wilczekd31b3882014-03-07 14:59:44 +0100147#if defined(CONFIG_POWER)
148#ifdef CONFIG_POWER_MAX77686
149static int pmic_reg_update(struct pmic *p, int reg, uint regval)
150{
151 u32 val;
152 int ret = 0;
153
154 ret = pmic_reg_read(p, reg, &val);
155 if (ret) {
156 debug("%s: PMIC %d register read failed\n", __func__, reg);
157 return -1;
158 }
159 val |= regval;
160 ret = pmic_reg_write(p, reg, val);
161 if (ret) {
162 debug("%s: PMIC %d register write failed\n", __func__, reg);
163 return -1;
164 }
165 return 0;
166}
167
168static int max77686_init(void)
169{
170 struct pmic *p;
171
172 if (pmic_init(I2C_PMIC))
173 return -1;
174
175 p = pmic_get("MAX77686_PMIC");
176 if (!p)
177 return -ENODEV;
178
179 if (pmic_probe(p))
180 return -1;
181
182 if (pmic_reg_update(p, MAX77686_REG_PMIC_32KHZ, MAX77686_32KHCP_EN))
183 return -1;
184
185 if (pmic_reg_update(p, MAX77686_REG_PMIC_BBAT,
186 MAX77686_BBCHOSTEN | MAX77686_BBCVS_3_5V))
187 return -1;
188
189 /* VDD_MIF */
190 if (pmic_reg_write(p, MAX77686_REG_PMIC_BUCK1OUT,
191 MAX77686_BUCK1OUT_1V)) {
192 debug("%s: PMIC %d register write failed\n", __func__,
193 MAX77686_REG_PMIC_BUCK1OUT);
194 return -1;
195 }
196
197 if (pmic_reg_update(p, MAX77686_REG_PMIC_BUCK1CRTL,
198 MAX77686_BUCK1CTRL_EN))
199 return -1;
200
201 /* VDD_ARM */
202 if (pmic_reg_write(p, MAX77686_REG_PMIC_BUCK2DVS1,
203 MAX77686_BUCK2DVS1_1_3V)) {
204 debug("%s: PMIC %d register write failed\n", __func__,
205 MAX77686_REG_PMIC_BUCK2DVS1);
206 return -1;
207 }
208
209 if (pmic_reg_update(p, MAX77686_REG_PMIC_BUCK2CTRL1,
210 MAX77686_BUCK2CTRL_ON))
211 return -1;
212
213 /* VDD_INT */
214 if (pmic_reg_write(p, MAX77686_REG_PMIC_BUCK3DVS1,
215 MAX77686_BUCK3DVS1_1_0125V)) {
216 debug("%s: PMIC %d register write failed\n", __func__,
217 MAX77686_REG_PMIC_BUCK3DVS1);
218 return -1;
219 }
220
221 if (pmic_reg_update(p, MAX77686_REG_PMIC_BUCK3CTRL,
222 MAX77686_BUCK3CTRL_ON))
223 return -1;
224
225 /* VDD_G3D */
226 if (pmic_reg_write(p, MAX77686_REG_PMIC_BUCK4DVS1,
227 MAX77686_BUCK4DVS1_1_2V)) {
228 debug("%s: PMIC %d register write failed\n", __func__,
229 MAX77686_REG_PMIC_BUCK4DVS1);
230 return -1;
231 }
232
233 if (pmic_reg_update(p, MAX77686_REG_PMIC_BUCK4CTRL1,
234 MAX77686_BUCK3CTRL_ON))
235 return -1;
236
237 /* VDD_LDO2 */
238 if (pmic_reg_update(p, MAX77686_REG_PMIC_LDO2CTRL1,
239 MAX77686_LD02CTRL1_1_5V | EN_LDO))
240 return -1;
241
242 /* VDD_LDO3 */
243 if (pmic_reg_update(p, MAX77686_REG_PMIC_LDO3CTRL1,
244 MAX77686_LD03CTRL1_1_8V | EN_LDO))
245 return -1;
246
247 /* VDD_LDO5 */
248 if (pmic_reg_update(p, MAX77686_REG_PMIC_LDO5CTRL1,
249 MAX77686_LD05CTRL1_1_8V | EN_LDO))
250 return -1;
251
252 /* VDD_LDO10 */
253 if (pmic_reg_update(p, MAX77686_REG_PMIC_LDO10CTRL1,
254 MAX77686_LD10CTRL1_1_8V | EN_LDO))
255 return -1;
256
257 return 0;
258}
259#endif /* CONFIG_POWER_MAX77686 */
260
261int exynos_power_init(void)
262{
263 int ret = 0;
264
265#ifdef CONFIG_POWER_MAX77686
266 ret = max77686_init();
267#endif
268 return ret;
269}
270#endif /* CONFIG_POWER */
271
Ajay Kumar99e51622013-01-10 21:06:10 +0000272#ifdef CONFIG_LCD
Ajay Kumar29fd5702013-02-21 23:52:57 +0000273void exynos_cfg_lcd_gpio(void)
Ajay Kumar9b572852013-01-08 20:42:26 +0000274{
Ajay Kumar9b572852013-01-08 20:42:26 +0000275
276 /* For Backlight */
Akshay Saraswatf6ae1ca2014-05-13 10:30:14 +0530277 gpio_cfg_pin(EXYNOS5_GPIO_B20, S5P_GPIO_OUTPUT);
278 gpio_set_value(EXYNOS5_GPIO_B20, 1);
Ajay Kumar9b572852013-01-08 20:42:26 +0000279
280 /* LCD power on */
Akshay Saraswatf6ae1ca2014-05-13 10:30:14 +0530281 gpio_cfg_pin(EXYNOS5_GPIO_X15, S5P_GPIO_OUTPUT);
282 gpio_set_value(EXYNOS5_GPIO_X15, 1);
Ajay Kumar9b572852013-01-08 20:42:26 +0000283
284 /* Set Hotplug detect for DP */
Akshay Saraswatf6ae1ca2014-05-13 10:30:14 +0530285 gpio_cfg_pin(EXYNOS5_GPIO_X07, S5P_GPIO_FUNC(0x3));
Ajay Kumar9b572852013-01-08 20:42:26 +0000286}
287
Ajay Kumar18637812013-02-21 23:53:09 +0000288void exynos_set_dp_phy(unsigned int onoff)
289{
290 set_dp_phy_ctrl(onoff);
291}
292
Ajay Kumar9b572852013-01-08 20:42:26 +0000293vidinfo_t panel_info = {
294 .vl_freq = 60,
295 .vl_col = 2560,
296 .vl_row = 1600,
297 .vl_width = 2560,
298 .vl_height = 1600,
299 .vl_clkp = CONFIG_SYS_LOW,
300 .vl_hsp = CONFIG_SYS_LOW,
301 .vl_vsp = CONFIG_SYS_LOW,
302 .vl_dp = CONFIG_SYS_LOW,
303 .vl_bpix = 4, /* LCD_BPP = 2^4, for output conosle on LCD */
304
305 /* wDP panel timing infomation */
306 .vl_hspw = 32,
307 .vl_hbpd = 80,
308 .vl_hfpd = 48,
309
310 .vl_vspw = 6,
311 .vl_vbpd = 37,
312 .vl_vfpd = 3,
313 .vl_cmd_allow_len = 0xf,
314
315 .win_id = 3,
Ajay Kumar9b572852013-01-08 20:42:26 +0000316 .dual_lcd_enabled = 0,
317
318 .init_delay = 0,
319 .power_on_delay = 0,
320 .reset_delay = 0,
321 .interface_mode = FIMD_RGB_INTERFACE,
322 .dp_enabled = 1,
323};
324
325static struct edp_device_info edp_info = {
326 .disp_info = {
327 .h_res = 2560,
328 .h_sync_width = 32,
329 .h_back_porch = 80,
330 .h_front_porch = 48,
331 .v_res = 1600,
332 .v_sync_width = 6,
333 .v_back_porch = 37,
334 .v_front_porch = 3,
335 .v_sync_rate = 60,
336 },
337 .lt_info = {
338 .lt_status = DP_LT_NONE,
339 },
340 .video_info = {
341 .master_mode = 0,
342 .bist_mode = DP_DISABLE,
343 .bist_pattern = NO_PATTERN,
344 .h_sync_polarity = 0,
345 .v_sync_polarity = 0,
346 .interlaced = 0,
347 .color_space = COLOR_RGB,
348 .dynamic_range = VESA,
349 .ycbcr_coeff = COLOR_YCBCR601,
350 .color_depth = COLOR_8,
351 },
352};
353
354static struct exynos_dp_platform_data dp_platform_data = {
Ajay Kumar9b572852013-01-08 20:42:26 +0000355 .edp_dev_info = &edp_info,
356};
357
358void init_panel_info(vidinfo_t *vid)
359{
Amar752f4c42013-04-27 11:42:57 +0530360 vid->rgb_mode = MODE_RGB_P;
Ajay Kumar9b572852013-01-08 20:42:26 +0000361 exynos_set_dp_platform_data(&dp_platform_data);
362}
Ajay Kumar99e51622013-01-10 21:06:10 +0000363#endif