| 1 |
|
| 2 |
|
| 3 |
#include <arch/cache.h> |
| 4 |
#include <boot/coreboot_tables.h> |
| 5 |
#include <console/console.h> |
| 6 |
#include <device/mmio.h> |
| 7 |
#include <delay.h> |
| 8 |
#include <device/device.h> |
| 9 |
#include <device/i2c_simple.h> |
| 10 |
#include <drivers/parade/ps8625/ps8625.h> |
| 11 |
#include <ec/google/chromeec/ec.h> |
| 12 |
#include <soc/tmu.h> |
| 13 |
#include <soc/clk.h> |
| 14 |
#include <soc/cpu.h> |
| 15 |
#include <soc/gpio.h> |
| 16 |
#include <soc/power.h> |
| 17 |
#include <soc/periph.h> |
| 18 |
#include <soc/i2c.h> |
| 19 |
#include <soc/dp.h> |
| 20 |
#include <soc/fimd.h> |
| 21 |
#include <soc/usb.h> |
| 22 |
#include <string.h> |
| 23 |
#include <symbols.h> |
| 24 |
#include <vbe.h> |
| 25 |
#include <framebuffer_info.h> |
| 26 |
|
| 27 |
|
| 28 |
#define DRAM_START ((uintptr_t)_dram/MiB) |
| 29 |
#define DRAM_SIZE CONFIG_DRAM_SIZE_MB |
| 30 |
|
| 31 |
|
| 32 |
static struct vidinfo vidinfo = { |
| 33 |
.vl_freq = 60, |
| 34 |
.vl_col = 1366, |
| 35 |
.vl_row = 768, |
| 36 |
.vl_width = 1366, |
| 37 |
.vl_height = 768, |
| 38 |
.vl_clkp = 1, |
| 39 |
.vl_dp = 1, |
| 40 |
.vl_bpix = 4, |
| 41 |
.vl_hspw = 32, |
| 42 |
.vl_hbpd = 40, |
| 43 |
.vl_hfpd = 40, |
| 44 |
.vl_vspw = 6, |
| 45 |
.vl_vbpd = 10, |
| 46 |
.vl_vfpd = 12, |
| 47 |
.vl_cmd_allow_len = 0xf, |
| 48 |
.win_id = 3, |
| 49 |
.dp_enabled = 1, |
| 50 |
.dual_lcd_enabled = 0, |
| 51 |
.interface_mode = FIMD_RGB_INTERFACE, |
| 52 |
}; |
| 53 |
|
| 54 |
static unsigned char panel_edid[] = { |
| 55 |
0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x00, |
| 56 |
0x06,0xaf,0x5c,0x31,0x00,0x00,0x00,0x00, |
| 57 |
0x00,0x16,0x01,0x03,0x80,0x1a,0x0e,0x78, |
| 58 |
0x0a,0x99,0x85,0x95,0x55,0x56,0x92,0x28, |
| 59 |
0x22,0x50,0x54,0x00,0x00,0x00,0x01,0x01, |
| 60 |
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, |
| 61 |
0x01,0x01,0x01,0x01,0x01,0x01,0xa3,0x1b, |
| 62 |
0x56,0x7e,0x50,0x00,0x16,0x30,0x30,0x20, |
| 63 |
0x36,0x00,0x00,0x90,0x10,0x00,0x00,0x18, |
| 64 |
0x6d,0x12,0x56,0x7e,0x50,0x00,0x16,0x30, |
| 65 |
0x30,0x20,0x36,0x00,0x00,0x90,0x10,0x00, |
| 66 |
0x00,0x18,0x00,0x00,0x00,0xfe,0x00,0x41, |
| 67 |
0x55,0x4f,0x0a,0x20,0x20,0x20,0x20,0x20, |
| 68 |
0x20,0x20,0x20,0x20,0x00,0x00,0x00,0xfe, |
| 69 |
0x00,0x42,0x31,0x31,0x36,0x58,0x57,0x30, |
| 70 |
0x33,0x20,0x56,0x31,0x20,0x0a,0x00,0x3d, |
| 71 |
0x00,0xc0,0x00,0x00,0x27,0xfd,0x00,0x20, |
| 72 |
0x02,0x59,0x07,0x00,0x64,0x3e,0x07,0x02, |
| 73 |
0x00,0x00,0xcd,0x12,0x59,0xff,0x10,0x03, |
| 74 |
0x00,0x00,0x00,0x00,0x64,0x00,0x00,0x00, |
| 75 |
0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00, |
| 76 |
0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00, |
| 77 |
0x9c,0x3f,0x07,0x02,0x31,0xf9,0x00,0x20, |
| 78 |
0x59,0xff,0x10,0x03,0x00,0x00,0x00,0x00, |
| 79 |
0xbc,0x3e,0x07,0x02,0xc0,0x9b,0x01,0x20, |
| 80 |
0x00,0x00,0x00,0x00,0xdb,0xf8,0x00,0x20, |
| 81 |
0x98,0x3e,0x07,0x02,0x8b,0xaf,0x00,0x20, |
| 82 |
0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 83 |
0xe5,0xcd,0x16,0x00,0xe9,0xcd,0x16,0x00, |
| 84 |
0xe8,0x03,0x00,0x00,0x6c,0x55,0x01,0x20, |
| 85 |
0x2c,0x01,0x00,0x00,0x85,0xbb,0x00,0x20, |
| 86 |
0xe8,0x03,0x00,0x00,0xe9,0xcd,0x16,0x00, |
| 87 |
}; |
| 88 |
|
| 89 |
static const struct parade_write parade_writes[] = { |
| 90 |
{ 0x02, 0xa1, 0x01 }, |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
{ 0x04, 0x14, 0x01 }, |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
{ 0x04, 0xe3, 0x20 }, |
| 101 |
{ 0x04, 0xe2, 0x80 }, |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
{ 0x04, 0x8a, 0x0c }, |
| 109 |
{ 0x04, 0x89, 0x08 }, |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
{ 0x04, 0x71, 0x2d }, |
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
{ 0x04, 0x7d, 0x07 }, |
| 121 |
{ 0x04, 0x7b, 0x00 }, |
| 122 |
{ 0x04, 0x7a, 0xfd }, |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
{ 0x04, 0xc0, 0x12 }, |
| 128 |
{ 0x04, 0xc1, 0x92 }, |
| 129 |
{ 0x04, 0xc2, 0x1c }, |
| 130 |
{ 0x04, 0x32, 0x80 }, |
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
{ 0x04, 0x00, 0xb0 }, |
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
{ 0x04, 0x15, 0x40 }, |
| 141 |
|
| 142 |
{ 0x04, 0x54, 0x10 }, |
| 143 |
|
| 144 |
{ 0x01, 0x02, 0x81 }, |
| 145 |
|
| 146 |
{ 0x01, 0x21, 0x81 }, |
| 147 |
{ 0x00, 0x52, 0x20 }, |
| 148 |
{ 0x00, 0xf1, 0x03 }, |
| 149 |
{ 0x00, 0x62, 0x41 }, |
| 150 |
|
| 151 |
{ 0x00, 0xf6, 0x01 }, |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
{ 0x00, 0x77, 0x06 }, |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
{ 0x00, 0x4c, 0x04 }, |
| 163 |
|
| 164 |
{ 0x01, 0xc0, 0x00 }, |
| 165 |
{ 0x01, 0xc1, 0x1c }, |
| 166 |
{ 0x01, 0xc2, 0xf8 }, |
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
{ 0x01, 0xc3, 0x44 }, |
| 172 |
{ 0x01, 0xc4, 0x32 }, |
| 173 |
{ 0x01, 0xc5, 0x53 }, |
| 174 |
{ 0x01, 0xc6, 0x4c }, |
| 175 |
{ 0x01, 0xc7, 0x56 }, |
| 176 |
{ 0x01, 0xc8, 0x35 }, |
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
{ 0x01, 0xca, 0x01 }, |
| 182 |
|
| 183 |
{ 0x01, 0xcb, 0x05 }, |
| 184 |
|
| 185 |
{ 0x01, 0xa5, 0x80 }, |
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
{ 0x01, 0xcc, 0x13 }, |
| 191 |
|
| 192 |
{ 0x02, 0xb1, 0x20 }, |
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
{ 0x04, 0x10, 0x16 }, |
| 198 |
|
| 199 |
{ 0x04, 0x59, 0x60 }, |
| 200 |
{ 0x04, 0x54, 0x14 }, |
| 201 |
{ 0x02, 0xa1, 0x91 } |
| 202 |
}; |
| 203 |
|
| 204 |
|
| 205 |
static enum exynos5_gpio_pin dp_pd_l = GPIO_X35; |
| 206 |
static enum exynos5_gpio_pin dp_rst_l = GPIO_Y77; |
| 207 |
static enum exynos5_gpio_pin dp_hpd = GPIO_X26; |
| 208 |
static enum exynos5_gpio_pin bl_pwm = GPIO_B20; |
| 209 |
static enum exynos5_gpio_pin bl_en = GPIO_X22; |
| 210 |
|
| 211 |
static void parade_dp_bridge_setup(void) |
| 212 |
{ |
| 213 |
int i; |
| 214 |
|
| 215 |
gpio_set_value(dp_pd_l, 1); |
| 216 |
gpio_cfg_pin(dp_pd_l, GPIO_OUTPUT); |
| 217 |
gpio_set_pull(dp_pd_l, GPIO_PULL_NONE); |
| 218 |
|
| 219 |
gpio_set_value(dp_rst_l, 0); |
| 220 |
gpio_cfg_pin(dp_rst_l, GPIO_OUTPUT); |
| 221 |
gpio_set_pull(dp_rst_l, GPIO_PULL_NONE); |
| 222 |
udelay(10); |
| 223 |
gpio_set_value(dp_rst_l, 1); |
| 224 |
|
| 225 |
gpio_set_pull(dp_hpd, GPIO_PULL_NONE); |
| 226 |
gpio_cfg_pin(dp_hpd, GPIO_INPUT); |
| 227 |
|
| 228 |
|
| 229 |
gpio_set_value(dp_pd_l, 1); |
| 230 |
gpio_set_value(dp_rst_l, 1); |
| 231 |
|
| 232 |
|
| 233 |
mdelay(40); |
| 234 |
|
| 235 |
|
| 236 |
exynos_pinmux_i2c7(); |
| 237 |
i2c_init(7, 100000, 0x00); |
| 238 |
|
| 239 |
parade_ps8625_bridge_setup(7, 0x48, parade_writes, |
| 240 |
ARRAY_SIZE(parade_writes)); |
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
for (i = 0; i < 1000; i++){ |
| 248 |
if (gpio_get_value(dp_hpd)) |
| 249 |
break; |
| 250 |
mdelay(1); |
| 251 |
} |
| 252 |
} |
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
#define LCD_T3_DELAY_MS 60 |
| 263 |
|
| 264 |
#define LCD_T5_DELAY_MS 10 |
| 265 |
#define LCD_T6_DELAY_MS 10 |
| 266 |
|
| 267 |
static void backlight_pwm(void) |
| 268 |
{ |
| 269 |
|
| 270 |
gpio_direction_output(bl_pwm, 1); |
| 271 |
udelay(LCD_T6_DELAY_MS * 1000); |
| 272 |
} |
| 273 |
|
| 274 |
static void backlight_en(void) |
| 275 |
{ |
| 276 |
|
| 277 |
gpio_direction_output(bl_en, 1); |
| 278 |
} |
| 279 |
|
| 280 |
static enum exynos5_gpio_pin usb_drd0_vbus = GPIO_H00; |
| 281 |
static enum exynos5_gpio_pin usb_drd1_vbus = GPIO_H01; |
| 282 |
|
| 283 |
|
| 284 |
static void prepare_usb(void) |
| 285 |
{ |
| 286 |
|
| 287 |
reset_usb_drd0_dwc3(); |
| 288 |
reset_usb_drd1_dwc3(); |
| 289 |
} |
| 290 |
|
| 291 |
static void setup_usb(void) |
| 292 |
{ |
| 293 |
|
| 294 |
setup_usb_drd0_phy(); |
| 295 |
setup_usb_drd1_phy(); |
| 296 |
|
| 297 |
setup_usb_drd0_dwc3(); |
| 298 |
setup_usb_drd1_dwc3(); |
| 299 |
|
| 300 |
gpio_direction_output(usb_drd0_vbus, 1); |
| 301 |
gpio_direction_output(usb_drd1_vbus, 1); |
| 302 |
} |
| 303 |
|
| 304 |
static struct edp_video_info dp_video_info = { |
| 305 |
.master_mode = 0, |
| 306 |
.h_sync_polarity = 0, |
| 307 |
.v_sync_polarity = 0, |
| 308 |
.interlaced = 0, |
| 309 |
.color_space = COLOR_RGB, |
| 310 |
.dynamic_range = VESA, |
| 311 |
.ycbcr_coeff = COLOR_YCBCR601, |
| 312 |
.color_depth = COLOR_8, |
| 313 |
}; |
| 314 |
|
| 315 |
|
| 316 |
#define MAX_DP_TRIES 5 |
| 317 |
|
| 318 |
static void setup_storage(void) |
| 319 |
{ |
| 320 |
|
| 321 |
if (clock_set_dwmci(PERIPH_ID_SDMMC0)) |
| 322 |
printk(BIOS_CRIT, "%s: Failed to set MMC0 clock.\n", __func__); |
| 323 |
exynos_pinmux_sdmmc0(); |
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
clock_set_dwmci(PERIPH_ID_SDMMC2); |
| 328 |
exynos_pinmux_sdmmc2(); |
| 329 |
} |
| 330 |
|
| 331 |
static void gpio_init(void) |
| 332 |
{ |
| 333 |
|
| 334 |
exynos_pinmux_i2c2(); |
| 335 |
exynos_pinmux_i2c4(); |
| 336 |
exynos_pinmux_i2c7(); |
| 337 |
exynos_pinmux_i2c8(); |
| 338 |
exynos_pinmux_i2c9(); |
| 339 |
exynos_pinmux_i2c10(); |
| 340 |
} |
| 341 |
|
| 342 |
enum { |
| 343 |
FET_CTRL_WAIT = 3 << 2, |
| 344 |
FET_CTRL_ADENFET = 1 << 1, |
| 345 |
FET_CTRL_ENFET = 1 << 0 |
| 346 |
}; |
| 347 |
|
| 348 |
static void tps65090_thru_ec_fet_set(int index) |
| 349 |
{ |
| 350 |
uint8_t value = FET_CTRL_ADENFET | FET_CTRL_WAIT | FET_CTRL_ENFET; |
| 351 |
|
| 352 |
if (google_chromeec_i2c_xfer(0x48, 0xe + index, 1, &value, 1, 0)) { |
| 353 |
printk(BIOS_ERR, |
| 354 |
"Error sending i2c pass through command to EC.\n"); |
| 355 |
return; |
| 356 |
} |
| 357 |
} |
| 358 |
|
| 359 |
static void lcd_vdd(void) |
| 360 |
{ |
| 361 |
|
| 362 |
tps65090_thru_ec_fet_set(6); |
| 363 |
} |
| 364 |
|
| 365 |
static void backlight_vdd(void) |
| 366 |
{ |
| 367 |
|
| 368 |
tps65090_thru_ec_fet_set(1); |
| 369 |
} |
| 370 |
|
| 371 |
static void sdmmc_vdd(void) |
| 372 |
{ |
| 373 |
|
| 374 |
tps65090_thru_ec_fet_set(4); |
| 375 |
} |
| 376 |
|
| 377 |
|
| 378 |
static void mainboard_init(struct device *dev) |
| 379 |
{ |
| 380 |
|
| 381 |
|
| 382 |
struct edp_device_info device_info; |
| 383 |
|
| 384 |
void *fb_addr = (void *)(get_fb_base_kb() * KiB); |
| 385 |
|
| 386 |
prepare_usb(); |
| 387 |
gpio_init(); |
| 388 |
setup_storage(); |
| 389 |
tmu_init(&exynos5420_tmu_info); |
| 390 |
|
| 391 |
|
| 392 |
clock_gate(); |
| 393 |
|
| 394 |
sdmmc_vdd(); |
| 395 |
|
| 396 |
fb_add_framebuffer_info((uintptr_t)fb_addr, 1366, 768, 2 * 1366, 16); |
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
write32p(0x14640000, 0x0); |
| 405 |
write32p(0x14680000, 0x0); |
| 406 |
|
| 407 |
lcd_vdd(); |
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
vidinfo.screen_base = fb_addr; |
| 415 |
exynos_fimd_lcd_init(&vidinfo); |
| 416 |
|
| 417 |
parade_dp_bridge_setup(); |
| 418 |
|
| 419 |
|
| 420 |
memset(&device_info, 0, sizeof(device_info)); |
| 421 |
device_info.disp_info.name = (char *)"Peach Pit display"; |
| 422 |
device_info.disp_info.h_total = 1366; |
| 423 |
device_info.disp_info.v_total = 768; |
| 424 |
device_info.video_info = dp_video_info; |
| 425 |
device_info.raw_edid = panel_edid; |
| 426 |
exynos_init_dp(&device_info); |
| 427 |
|
| 428 |
backlight_vdd(); |
| 429 |
backlight_pwm(); |
| 430 |
backlight_en(); |
| 431 |
|
| 432 |
setup_usb(); |
| 433 |
} |
| 434 |
|
| 435 |
static void mainboard_enable(struct device *dev) |
| 436 |
{ |
| 437 |
dev->ops->init = &mainboard_init; |
| 438 |
|
| 439 |
|
| 440 |
mmu_config_range(DRAM_START, DRAM_SIZE, DCACHE_WRITEBACK); |
| 441 |
mmu_config_range((uintptr_t)_dma_coherent/MiB, |
| 442 |
REGION_SIZE(dma_coherent)/MiB, DCACHE_OFF); |
| 443 |
|
| 444 |
const unsigned int epll_hz = 192000000; |
| 445 |
const unsigned int sample_rate = 48000; |
| 446 |
const unsigned int lr_frame_size = 256; |
| 447 |
clock_epll_set_rate(epll_hz); |
| 448 |
clock_select_i2s_clk_source(); |
| 449 |
clock_set_i2s_clk_prescaler(epll_hz, sample_rate * lr_frame_size); |
| 450 |
|
| 451 |
power_enable_xclkout(); |
| 452 |
} |
| 453 |
|
| 454 |
struct chip_operations mainboard_ops = { |
| 455 |
.enable_dev = mainboard_enable, |
| 456 |
}; |
| 457 |
|
| 458 |
void lb_board(struct lb_header *header) |
| 459 |
{ |
| 460 |
struct lb_range *dma; |
| 461 |
|
| 462 |
dma = (struct lb_range *)lb_new_record(header); |
| 463 |
dma->tag = LB_TAG_DMA; |
| 464 |
dma->size = sizeof(*dma); |
| 465 |
dma->range_start = (uintptr_t)_dma_coherent; |
| 466 |
dma->range_size = REGION_SIZE(dma_coherent); |
| 467 |
} |