Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Samsung Electronics |
| 3 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Rajeshwari Birje | 987b0dd | 2013-12-26 09:44:17 +0530 | [diff] [blame^] | 8 | #include <cros_ec.h> |
Hatim RV | db3040a | 2012-12-11 00:52:47 +0000 | [diff] [blame] | 9 | #include <fdtdec.h> |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 10 | #include <asm/io.h> |
Rajeshwari Shinde | 0bdb3fb | 2013-02-12 20:40:02 +0000 | [diff] [blame] | 11 | #include <errno.h> |
Rajeshwari Shinde | 1d518e6 | 2012-07-23 21:23:55 +0000 | [diff] [blame] | 12 | #include <i2c.h> |
Ajay Kumar | ca67ee2 | 2013-01-08 20:42:26 +0000 | [diff] [blame] | 13 | #include <lcd.h> |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 14 | #include <netdev.h> |
Hatim RV | 000b548 | 2012-11-02 01:15:37 +0000 | [diff] [blame] | 15 | #include <spi.h> |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 16 | #include <asm/arch/cpu.h> |
Amar | bb54b75 | 2013-04-27 11:42:57 +0530 | [diff] [blame] | 17 | #include <asm/arch/dwmmc.h> |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 18 | #include <asm/arch/gpio.h> |
| 19 | #include <asm/arch/mmc.h> |
Rajeshwari Shinde | 5d2a8e2 | 2012-06-06 19:54:30 +0000 | [diff] [blame] | 20 | #include <asm/arch/pinmux.h> |
Ajay Kumar | ca67ee2 | 2013-01-08 20:42:26 +0000 | [diff] [blame] | 21 | #include <asm/arch/power.h> |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 22 | #include <asm/arch/sromc.h> |
Ajay Kumar | ca67ee2 | 2013-01-08 20:42:26 +0000 | [diff] [blame] | 23 | #include <asm/arch/dp_info.h> |
Rajeshwari Shinde | 418eb7e | 2012-12-10 01:55:48 +0000 | [diff] [blame] | 24 | #include <power/pmic.h> |
Rajeshwari Shinde | 0bdb3fb | 2013-02-12 20:40:02 +0000 | [diff] [blame] | 25 | #include <power/max77686_pmic.h> |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 26 | |
| 27 | DECLARE_GLOBAL_DATA_PTR; |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 28 | |
Vivek Gautam | 6872572 | 2013-01-07 23:37:18 +0000 | [diff] [blame] | 29 | #ifdef CONFIG_USB_EHCI_EXYNOS |
Rajeshwari Birje | 987b0dd | 2013-12-26 09:44:17 +0530 | [diff] [blame^] | 30 | static int board_usb_vbus_init(void) |
Vivek Gautam | 6872572 | 2013-01-07 23:37:18 +0000 | [diff] [blame] | 31 | { |
| 32 | struct exynos5_gpio_part1 *gpio1 = (struct exynos5_gpio_part1 *) |
| 33 | samsung_get_base_gpio_part1(); |
| 34 | |
| 35 | /* Enable VBUS power switch */ |
| 36 | s5p_gpio_direction_output(&gpio1->x2, 6, 1); |
| 37 | |
| 38 | /* VBUS turn ON time */ |
| 39 | mdelay(3); |
| 40 | |
| 41 | return 0; |
| 42 | } |
| 43 | #endif |
| 44 | |
Rajeshwari Shinde | 6d7b21d | 2013-02-14 19:46:14 +0000 | [diff] [blame] | 45 | #ifdef CONFIG_SOUND_MAX98095 |
| 46 | static void board_enable_audio_codec(void) |
| 47 | { |
| 48 | struct exynos5_gpio_part1 *gpio1 = (struct exynos5_gpio_part1 *) |
| 49 | samsung_get_base_gpio_part1(); |
| 50 | |
| 51 | /* Enable MAX98095 Codec */ |
| 52 | s5p_gpio_direction_output(&gpio1->x1, 7, 1); |
| 53 | s5p_gpio_set_pull(&gpio1->x1, 7, GPIO_PULL_NONE); |
| 54 | } |
| 55 | #endif |
| 56 | |
Rajeshwari Birje | 987b0dd | 2013-12-26 09:44:17 +0530 | [diff] [blame^] | 57 | int exynos_init(void) |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 58 | { |
Vivek Gautam | 6872572 | 2013-01-07 23:37:18 +0000 | [diff] [blame] | 59 | #ifdef CONFIG_USB_EHCI_EXYNOS |
| 60 | board_usb_vbus_init(); |
| 61 | #endif |
Rajeshwari Shinde | 6d7b21d | 2013-02-14 19:46:14 +0000 | [diff] [blame] | 62 | #ifdef CONFIG_SOUND_MAX98095 |
| 63 | board_enable_audio_codec(); |
| 64 | #endif |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 65 | return 0; |
| 66 | } |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 67 | |
Chander Kashyap | 5ff8061e | 2012-02-09 01:26:19 +0000 | [diff] [blame] | 68 | int board_eth_init(bd_t *bis) |
| 69 | { |
| 70 | #ifdef CONFIG_SMC911X |
Hatim RV | db3040a | 2012-12-11 00:52:47 +0000 | [diff] [blame] | 71 | u32 smc_bw_conf, smc_bc_conf; |
| 72 | struct fdt_sromc config; |
| 73 | fdt_addr_t base_addr; |
Hatim RV | db3040a | 2012-12-11 00:52:47 +0000 | [diff] [blame] | 74 | |
Hatim RV | db3040a | 2012-12-11 00:52:47 +0000 | [diff] [blame] | 75 | /* Non-FDT configuration - bank number and timing parameters*/ |
| 76 | config.bank = CONFIG_ENV_SROM_BANK; |
| 77 | config.width = 2; |
| 78 | |
| 79 | config.timing[FDT_SROM_TACS] = 0x01; |
| 80 | config.timing[FDT_SROM_TCOS] = 0x01; |
| 81 | config.timing[FDT_SROM_TACC] = 0x06; |
| 82 | config.timing[FDT_SROM_TCOH] = 0x01; |
| 83 | config.timing[FDT_SROM_TAH] = 0x0C; |
| 84 | config.timing[FDT_SROM_TACP] = 0x09; |
| 85 | config.timing[FDT_SROM_PMC] = 0x01; |
| 86 | base_addr = CONFIG_SMC911X_BASE; |
Hatim RV | db3040a | 2012-12-11 00:52:47 +0000 | [diff] [blame] | 87 | |
| 88 | /* Ethernet needs data bus width of 16 bits */ |
| 89 | if (config.width != 2) { |
| 90 | debug("%s: Unsupported bus width %d\n", __func__, |
| 91 | config.width); |
| 92 | return -1; |
| 93 | } |
| 94 | smc_bw_conf = SROMC_DATA16_WIDTH(config.bank) |
| 95 | | SROMC_BYTE_ENABLE(config.bank); |
| 96 | |
| 97 | smc_bc_conf = SROMC_BC_TACS(config.timing[FDT_SROM_TACS]) |\ |
| 98 | SROMC_BC_TCOS(config.timing[FDT_SROM_TCOS]) |\ |
| 99 | SROMC_BC_TACC(config.timing[FDT_SROM_TACC]) |\ |
| 100 | SROMC_BC_TCOH(config.timing[FDT_SROM_TCOH]) |\ |
| 101 | SROMC_BC_TAH(config.timing[FDT_SROM_TAH]) |\ |
| 102 | SROMC_BC_TACP(config.timing[FDT_SROM_TACP]) |\ |
| 103 | SROMC_BC_PMC(config.timing[FDT_SROM_PMC]); |
| 104 | |
| 105 | /* Select and configure the SROMC bank */ |
| 106 | exynos_pinmux_config(PERIPH_ID_SROMC, config.bank); |
| 107 | s5p_config_sromc(config.bank, smc_bw_conf, smc_bc_conf); |
| 108 | return smc911x_initialize(0, base_addr); |
Chander Kashyap | 5ff8061e | 2012-02-09 01:26:19 +0000 | [diff] [blame] | 109 | #endif |
| 110 | return 0; |
| 111 | } |
| 112 | |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 113 | #ifdef CONFIG_DISPLAY_BOARDINFO |
| 114 | int checkboard(void) |
| 115 | { |
Rajeshwari Shinde | 15ab89e | 2013-02-18 02:51:49 +0000 | [diff] [blame] | 116 | printf("\nBoard: SMDK5250\n"); |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 117 | return 0; |
| 118 | } |
| 119 | #endif |
| 120 | |
| 121 | #ifdef CONFIG_GENERIC_MMC |
| 122 | int board_mmc_init(bd_t *bis) |
| 123 | { |
Amar | bb54b75 | 2013-04-27 11:42:57 +0530 | [diff] [blame] | 124 | int err, ret = 0, index, bus_width; |
| 125 | u32 base; |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 126 | |
Rajeshwari Shinde | e8bfeda | 2012-07-03 20:03:00 +0000 | [diff] [blame] | 127 | err = exynos_pinmux_config(PERIPH_ID_SDMMC0, PINMUX_FLAG_8BIT_MODE); |
Amar | bb54b75 | 2013-04-27 11:42:57 +0530 | [diff] [blame] | 128 | if (err) |
Rajeshwari Shinde | e8bfeda | 2012-07-03 20:03:00 +0000 | [diff] [blame] | 129 | debug("SDMMC0 not configured\n"); |
Amar | bb54b75 | 2013-04-27 11:42:57 +0530 | [diff] [blame] | 130 | ret |= err; |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 131 | |
Amar | bb54b75 | 2013-04-27 11:42:57 +0530 | [diff] [blame] | 132 | /*EMMC: dwmmc Channel-0 with 8 bit bus width */ |
| 133 | index = 0; |
| 134 | base = samsung_get_base_mmc() + (0x10000 * index); |
| 135 | bus_width = 8; |
| 136 | err = exynos_dwmci_add_port(index, base, bus_width, (u32)NULL); |
| 137 | if (err) |
| 138 | debug("dwmmc Channel-0 init failed\n"); |
| 139 | ret |= err; |
| 140 | |
| 141 | err = exynos_pinmux_config(PERIPH_ID_SDMMC2, PINMUX_FLAG_NONE); |
| 142 | if (err) |
| 143 | debug("SDMMC2 not configured\n"); |
| 144 | ret |= err; |
| 145 | |
| 146 | /*SD: dwmmc Channel-2 with 4 bit bus width */ |
| 147 | index = 2; |
| 148 | base = samsung_get_base_mmc() + (0x10000 * index); |
| 149 | bus_width = 4; |
| 150 | err = exynos_dwmci_add_port(index, base, bus_width, (u32)NULL); |
| 151 | if (err) |
| 152 | debug("dwmmc Channel-2 init failed\n"); |
| 153 | ret |= err; |
| 154 | |
| 155 | return ret; |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 156 | } |
| 157 | #endif |
| 158 | |
Amar | a8b3573 | 2013-07-10 10:42:29 +0530 | [diff] [blame] | 159 | void board_i2c_init(const void *blob) |
| 160 | { |
| 161 | int i; |
| 162 | |
| 163 | for (i = 0; i < CONFIG_MAX_I2C_NUM; i++) { |
| 164 | exynos_pinmux_config((PERIPH_ID_I2C0 + i), |
| 165 | PINMUX_FLAG_NONE); |
| 166 | } |
Chander Kashyap | ed2e25a | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 167 | } |
Ajay Kumar | ca67ee2 | 2013-01-08 20:42:26 +0000 | [diff] [blame] | 168 | |
Ajay Kumar | 11575ae | 2013-01-10 21:06:10 +0000 | [diff] [blame] | 169 | #ifdef CONFIG_LCD |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 170 | void exynos_cfg_lcd_gpio(void) |
Ajay Kumar | ca67ee2 | 2013-01-08 20:42:26 +0000 | [diff] [blame] | 171 | { |
| 172 | struct exynos5_gpio_part1 *gpio1 = |
| 173 | (struct exynos5_gpio_part1 *) samsung_get_base_gpio_part1(); |
| 174 | |
| 175 | /* For Backlight */ |
| 176 | s5p_gpio_cfg_pin(&gpio1->b2, 0, GPIO_OUTPUT); |
| 177 | s5p_gpio_set_value(&gpio1->b2, 0, 1); |
| 178 | |
| 179 | /* LCD power on */ |
| 180 | s5p_gpio_cfg_pin(&gpio1->x1, 5, GPIO_OUTPUT); |
| 181 | s5p_gpio_set_value(&gpio1->x1, 5, 1); |
| 182 | |
| 183 | /* Set Hotplug detect for DP */ |
| 184 | s5p_gpio_cfg_pin(&gpio1->x0, 7, GPIO_FUNC(0x3)); |
| 185 | } |
| 186 | |
Ajay Kumar | 92bf4be | 2013-02-21 23:53:09 +0000 | [diff] [blame] | 187 | void exynos_set_dp_phy(unsigned int onoff) |
| 188 | { |
| 189 | set_dp_phy_ctrl(onoff); |
| 190 | } |
| 191 | |
Ajay Kumar | ca67ee2 | 2013-01-08 20:42:26 +0000 | [diff] [blame] | 192 | vidinfo_t panel_info = { |
| 193 | .vl_freq = 60, |
| 194 | .vl_col = 2560, |
| 195 | .vl_row = 1600, |
| 196 | .vl_width = 2560, |
| 197 | .vl_height = 1600, |
| 198 | .vl_clkp = CONFIG_SYS_LOW, |
| 199 | .vl_hsp = CONFIG_SYS_LOW, |
| 200 | .vl_vsp = CONFIG_SYS_LOW, |
| 201 | .vl_dp = CONFIG_SYS_LOW, |
| 202 | .vl_bpix = 4, /* LCD_BPP = 2^4, for output conosle on LCD */ |
| 203 | |
| 204 | /* wDP panel timing infomation */ |
| 205 | .vl_hspw = 32, |
| 206 | .vl_hbpd = 80, |
| 207 | .vl_hfpd = 48, |
| 208 | |
| 209 | .vl_vspw = 6, |
| 210 | .vl_vbpd = 37, |
| 211 | .vl_vfpd = 3, |
| 212 | .vl_cmd_allow_len = 0xf, |
| 213 | |
| 214 | .win_id = 3, |
Ajay Kumar | ca67ee2 | 2013-01-08 20:42:26 +0000 | [diff] [blame] | 215 | .dual_lcd_enabled = 0, |
| 216 | |
| 217 | .init_delay = 0, |
| 218 | .power_on_delay = 0, |
| 219 | .reset_delay = 0, |
| 220 | .interface_mode = FIMD_RGB_INTERFACE, |
| 221 | .dp_enabled = 1, |
| 222 | }; |
| 223 | |
| 224 | static struct edp_device_info edp_info = { |
| 225 | .disp_info = { |
| 226 | .h_res = 2560, |
| 227 | .h_sync_width = 32, |
| 228 | .h_back_porch = 80, |
| 229 | .h_front_porch = 48, |
| 230 | .v_res = 1600, |
| 231 | .v_sync_width = 6, |
| 232 | .v_back_porch = 37, |
| 233 | .v_front_porch = 3, |
| 234 | .v_sync_rate = 60, |
| 235 | }, |
| 236 | .lt_info = { |
| 237 | .lt_status = DP_LT_NONE, |
| 238 | }, |
| 239 | .video_info = { |
| 240 | .master_mode = 0, |
| 241 | .bist_mode = DP_DISABLE, |
| 242 | .bist_pattern = NO_PATTERN, |
| 243 | .h_sync_polarity = 0, |
| 244 | .v_sync_polarity = 0, |
| 245 | .interlaced = 0, |
| 246 | .color_space = COLOR_RGB, |
| 247 | .dynamic_range = VESA, |
| 248 | .ycbcr_coeff = COLOR_YCBCR601, |
| 249 | .color_depth = COLOR_8, |
| 250 | }, |
| 251 | }; |
| 252 | |
| 253 | static struct exynos_dp_platform_data dp_platform_data = { |
Ajay Kumar | ca67ee2 | 2013-01-08 20:42:26 +0000 | [diff] [blame] | 254 | .edp_dev_info = &edp_info, |
| 255 | }; |
| 256 | |
| 257 | void init_panel_info(vidinfo_t *vid) |
| 258 | { |
Amar | bb54b75 | 2013-04-27 11:42:57 +0530 | [diff] [blame] | 259 | vid->rgb_mode = MODE_RGB_P; |
Ajay Kumar | ca67ee2 | 2013-01-08 20:42:26 +0000 | [diff] [blame] | 260 | exynos_set_dp_platform_data(&dp_platform_data); |
| 261 | } |
Ajay Kumar | 11575ae | 2013-01-10 21:06:10 +0000 | [diff] [blame] | 262 | #endif |