coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
mainboard.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <assert.h>
4 #include <bl31.h>
5 #include <boardid.h>
6 #include <bootmode.h>
7 #include <console/console.h>
8 #include <device/mmio.h>
9 #include <delay.h>
10 #include <device/device.h>
11 #include <device/i2c_simple.h>
12 #include <ec/google/chromeec/ec.h>
13 #include <gpio.h>
14 #include <soc/clock.h>
15 #include <soc/display.h>
16 #include <soc/grf.h>
17 #include <soc/mipi.h>
18 #include <soc/i2c.h>
19 #include <soc/usb.h>
20 #include <string.h>
21 
22 #include "board.h"
23 
24 #include <arm-trusted-firmware/include/export/plat/rockchip/common/plat_params_exp.h>
25 
26 /*
27  * We have to drive the stronger pull-up within 1 second of powering up the
28  * touchpad to prevent its firmware from falling into recovery. Not on
29  * Scarlet-based boards.
30  */
31 static void configure_touchpad(void)
32 {
33  gpio_output(GPIO_TP_RST_L, 1); /* TP's I2C pull-up rail */
34 }
35 
36 /*
37  * Wifi's PDN/RST line is pulled down by its (unpowered) voltage rails, but
38  * this reset pin is pulled up by default. Let's drive it low as early as we
39  * can. This only applies to boards with Marvell 8997 WiFi.
40  */
41 static void assert_wifi_reset(void)
42 {
43  gpio_output(GPIO_WLAN_RST_L, 0); /* Assert WLAN_MODULE_RST# */
44 }
45 
46 static void configure_emmc(void)
47 {
48  /* Host controller does not support programmable clock generator.
49  * If we don't do this setting, when we use phy to control the
50  * emmc clock(when clock exceed 50MHz), it will get wrong clock.
51  *
52  * Refer to TRM V0.3 Part 1 Chapter 15 PAGE 782 for this register.
53  * Please search "_CON11[7:0]" to locate register description.
54  */
56 
58 }
59 
60 static void register_apio_suspend(void)
61 {
62  static struct bl_aux_param_rk_apio param_apio = {
63  .h = {
64  .type = BL_AUX_PARAM_RK_SUSPEND_APIO,
65  },
66  .apio = {
67  .apio1 = 1,
68  .apio2 = 1,
69  .apio3 = 1,
70  .apio4 = 1,
71  .apio5 = 1,
72  },
73  };
74  register_bl31_aux_param(&param_apio.h);
75 }
76 
77 static void register_gpio_suspend(void)
78 {
79  /*
80  * These three GPIO params are used to shut down the 1.5V, 1.8V and
81  * 3.3V power rails, which need to be shut down ordered by voltage,
82  * with highest voltage first.
83  * Since register_bl31() appends to the front of the list, we need to
84  * register them backwards, with 1.5V coming first.
85  * 1.5V and 1.8V are EC-controlled on Scarlet derivatives,
86  * so we skip them.
87  */
88  if (!CONFIG(GRU_BASEBOARD_SCARLET)) {
89  static struct bl_aux_param_gpio param_p15_en = {
90  .h = { .type = BL_AUX_PARAM_RK_SUSPEND_GPIO },
91  .gpio = { .polarity = ARM_TF_GPIO_LEVEL_LOW },
92  };
93  param_p15_en.gpio.index = GPIO_P15V_EN.raw;
94  register_bl31_aux_param(&param_p15_en.h);
95 
96  static struct bl_aux_param_gpio param_p18_audio_en = {
97  .h = { .type = BL_AUX_PARAM_RK_SUSPEND_GPIO },
98  .gpio = { .polarity = ARM_TF_GPIO_LEVEL_LOW },
99  };
100  param_p18_audio_en.gpio.index = GPIO_P18V_AUDIO_PWREN.raw;
101  register_bl31_aux_param(&param_p18_audio_en.h);
102  }
103 
104  static struct bl_aux_param_gpio param_p30_en = {
105  .h = { .type = BL_AUX_PARAM_RK_SUSPEND_GPIO },
106  .gpio = { .polarity = ARM_TF_GPIO_LEVEL_LOW },
107  };
108  param_p30_en.gpio.index = GPIO_P30V_EN.raw;
109  register_bl31_aux_param(&param_p30_en.h);
110 }
111 
112 static void register_reset_to_bl31(void)
113 {
114  static struct bl_aux_param_gpio param_reset = {
115  .h = {
116  .type = BL_AUX_PARAM_RK_RESET_GPIO,
117  },
118  .gpio = {
119  .polarity = 1,
120  },
121  };
122 
123  /* gru/kevin reset pin: gpio0b3 */
124  param_reset.gpio.index = GPIO_RESET.raw,
125 
126  register_bl31_aux_param(&param_reset.h);
127 }
128 
129 static void register_poweroff_to_bl31(void)
130 {
131  static struct bl_aux_param_gpio param_poweroff = {
132  .h = {
133  .type = BL_AUX_PARAM_RK_POWEROFF_GPIO,
134  },
135  .gpio = {
136  .polarity = 1,
137  },
138  };
139 
140  /*
141  * gru/kevin power off pin: gpio1a6,
142  * reuse with tsadc int pin, so iomux need set back to
143  * gpio in BL31 and depthcharge before you setting this gpio
144  */
145  param_poweroff.gpio.index = GPIO_POWEROFF.raw,
146 
147  register_bl31_aux_param(&param_poweroff.h);
148 }
149 
150 static void configure_sdmmc(void)
151 {
152  gpio_output(GPIO(2, A, 2), 1); /* SDMMC_SDIO_PWR_EN */
153 
154  /* set SDMMC_DET_L pin */
155  if (CONFIG(GRU_BASEBOARD_SCARLET))
156  /*
157  * do not have external pull up, so need to
158  * set this pin internal pull up
159  */
160  gpio_input_pullup(GPIO(1, B, 3));
161  else
162  gpio_input(GPIO(4, D, 0));
163 
164  /*
165  * Keep sd card io domain 3v
166  * In Scarlet derivatives, this GPIO set to high will get 3v,
167  * With other board variants setting this GPIO low results in 3V.
168  */
169  if (CONFIG(GRU_BASEBOARD_SCARLET))
170  gpio_output(GPIO(2, D, 4), 1);
171  else
172  gpio_output(GPIO(2, D, 4), 0);
173 
174  gpio_input(GPIO(4, B, 0)); /* SDMMC0_D0 remove pull-up */
175  gpio_input(GPIO(4, B, 1)); /* SDMMC0_D1 remove pull-up */
176  gpio_input(GPIO(4, B, 2)); /* SDMMC0_D2 remove pull-up */
177  gpio_input(GPIO(4, B, 3)); /* SDMMC0_D3 remove pull-up */
178  gpio_input(GPIO(4, B, 4)); /* SDMMC0_CLK remove pull-down */
179  gpio_input(GPIO(4, B, 5)); /* SDMMC0_CMD remove pull-up */
180 
181  write32(&rk3399_grf->gpio2_p[2][1], RK_CLRSETBITS(0xfff, 0));
182 
183  /*
184  * Set all outputs' drive strength to 8 mA. Group 4 bank B driver
185  * strength requires three bits per pin. Value of 2 written in that
186  * three bit field means '8 mA', as deduced from the kernel code.
187  *
188  * Thus the six pins involved in SDMMC interface require 18 bits to
189  * configure drive strength, but each 32 bit register provides only 16
190  * bits for this setting, this covers 5 pins fully and one bit from
191  * the 6th pin. Two more bits spill over to the next register. This is
192  * described on page 378 of rk3399 TRM Version 0.3 Part 1.
193  */
195  RK_CLRSETBITS(0xffff,
196  (2 << 0) | (2 << 3) |
197  (2 << 6) | (2 << 9) | (2 << 12)));
199 
200  /* And now set the multiplexor to enable SDMMC0. */
202 }
203 
204 static void configure_codec(void)
205 {
206  gpio_input(GPIO(3, D, 0)); /* I2S0_SCLK remove pull-up */
207  gpio_input(GPIO(3, D, 1)); /* I2S0_RX remove pull-up */
208  gpio_input(GPIO(3, D, 2)); /* I2S0_TX remove pull-up */
209  gpio_input(GPIO(3, D, 3)); /* I2S0_SDI0 remove pull-up */
210  /* GPIOs 3_D4 - 3_D6 not used for I2S and are SKU ID pins on Scarlet. */
211  gpio_input(GPIO(3, D, 7)); /* I2S0_SDO0 remove pull-up */
212  gpio_input(GPIO(4, A, 0)); /* I2S0_MCLK remove pull-up */
213 
216 
217  if (!CONFIG(GRU_BASEBOARD_SCARLET))
220 
221  rkclk_configure_i2s(12288000);
222 }
223 
224 static void configure_display(void)
225 {
226  /*
227  * Rainier is Scarlet-derived, but uses EDP so use board-specific
228  * config rather than baseboard.
229  */
230  if (CONFIG(BOARD_GOOGLE_SCARLET)) {
231  gpio_output(GPIO(4, D, 1), 0); /* DISPLAY_RST_L */
232  gpio_output(GPIO(4, D, 3), 1); /* PPVARP_LCD */
233  mdelay(10);
234  gpio_output(GPIO(4, D, 4), 1); /* PPVARN_LCD */
235  mdelay(20 + 2); /* add 2ms for bias rise time */
236  gpio_output(GPIO(4, D, 1), 1); /* DISPLAY_RST_L */
237  mdelay(30);
238  } else {
239  /* set pinmux for edp HPD */
240  gpio_input_pulldown(GPIO(4, C, 7));
242 
243  gpio_output(GPIO(4, D, 3), 1); /* P3.3V_DISP */
244  }
245 }
246 
247 static void usb_power_cycle(int port)
248 {
250  printk(BIOS_ERR, "Cannot force USB%d PD sink\n", port);
251 
252  mdelay(10); /* Make sure USB stick is fully depowered. */
253 
255  printk(BIOS_ERR, "Cannot restore USB%d PD mode\n", port);
256 }
257 
258 static void setup_usb(int port)
259 {
260  /* Must be PHY0 or PHY1. */
261  assert(port == 0 || port == 1);
262 
263  /*
264  * A few magic PHY tuning values that improve eye diagram amplitude
265  * and make it extra sure we get reliable communication in firmware
266  * Set max ODT compensation voltage and current tuning reference.
267  */
268  write32(&rk3399_grf->usbphy_ctrl[port][3], RK_CLRSETBITS(0xfff, 0x2e3));
269 
270  /* Set max pre-emphasis level on PHY0 and PHY1. */
272  RK_CLRSETBITS(0xffff, 0xa7));
273 
274  /*
275  * 1. Disable the pre-emphasize in eop state and chirp
276  * state to avoid mis-trigger the disconnect detection
277  * and also avoid high-speed handshake fail for PHY0
278  * and PHY1 consist of otg-port and host-port.
279  *
280  * 2. Configure PHY0 and PHY1 otg-ports squelch detection
281  * threshold to 125mV (default is 150mV).
282  */
284  RK_CLRSETBITS(7 << 13 | 3 << 0, 6 << 13));
285  write32(&rk3399_grf->usbphy_ctrl[port][13], RK_CLRBITS(3 << 0));
286 
287  /*
288  * ODT auto compensation bypass, and set max driver
289  * strength only for PHY0 and PHY1 otg-port.
290  */
292  RK_CLRSETBITS(0x7e << 4, 0x60 << 4));
293 
294  /*
295  * ODT auto refresh bypass, and set the max bias current
296  * tuning reference only for PHY0 and PHY1 otg-port.
297  */
299  RK_CLRSETBITS(0x21c, 1 << 4));
300 
301  /*
302  * ODT auto compensation bypass, and set default driver
303  * strength only for PHY0 and PHY1 host-port.
304  */
305  write32(&rk3399_grf->usbphy_ctrl[port][15], RK_SETBITS(1 << 10));
306 
307  /* ODT auto refresh bypass only for PHY0 and PHY1 host-port. */
308  write32(&rk3399_grf->usbphy_ctrl[port][16], RK_CLRBITS(1 << 9));
309 
310  if (port == 0)
311  setup_usb_otg0();
312  else
313  setup_usb_otg1();
314 
315  /*
316  * Need to power-cycle USB ports for use in firmware, since some devices
317  * can't fall back to USB 2.0 after they saw SuperSpeed terminations.
318  * This takes about a dozen milliseconds, so only do it in boot modes
319  * that have firmware UI (which one could select USB boot from).
320  */
321  if (display_init_required())
323 }
324 
325 static void mainboard_init(struct device *dev)
326 {
327  configure_sdmmc();
328  configure_emmc();
329  configure_codec();
330  if (display_init_required())
332  setup_usb(0);
333  if (CONFIG(GRU_HAS_WLAN_RESET))
335  if (!CONFIG(GRU_BASEBOARD_SCARLET)) {
336  configure_touchpad(); /* Scarlet: works differently */
337  setup_usb(1); /* Scarlet: only one USB port */
338  }
343 }
344 
345 static void prepare_backlight_i2c(void)
346 {
347  gpio_input(GPIO(1, B, 7)); /* I2C0_SDA remove pull_up */
348  gpio_input(GPIO(1, C, 0)); /* I2C0_SCL remove pull_up */
349 
350  i2c_init(0, 100*KHz);
351 
354 }
355 
357 {
358  gpio_output(GPIO_BL_EN, 1); /* BL_EN */
359 
360  /* Configure as output GPIO, to be toggled by payload. */
361  if (CONFIG(GRU_BASEBOARD_SCARLET))
363 
364  if (CONFIG(BOARD_GOOGLE_GRU))
366 }
367 
369  /* page 0 */
370  MIPI_INIT_CMD(0xF0, 0x55, 0xAA, 0x52, 0x08, 0x00),
371  MIPI_INIT_CMD(0xB1, 0xE8, 0x11),
372  MIPI_INIT_CMD(0xB2, 0x25, 0x02),
373  MIPI_INIT_CMD(0xB5, 0x08, 0x00),
374  MIPI_INIT_CMD(0xBC, 0x0F, 0x00),
375  MIPI_INIT_CMD(0xB8, 0x03, 0x06, 0x00, 0x00),
376  MIPI_INIT_CMD(0xBD, 0x01, 0x90, 0x14, 0x14),
377  MIPI_INIT_CMD(0x6F, 0x01),
378  MIPI_INIT_CMD(0xC0, 0x03),
379  MIPI_INIT_CMD(0x6F, 0x02),
380  MIPI_INIT_CMD(0xC1, 0x0D),
381  MIPI_INIT_CMD(0xD9, 0x01, 0x09, 0x70),
382  MIPI_INIT_CMD(0xC5, 0x12, 0x21, 0x00),
383  MIPI_INIT_CMD(0xBB, 0x93, 0x93),
384 
385  /* page 1 */
386  MIPI_INIT_CMD(0xF0, 0x55, 0xAA, 0x52, 0x08, 0x01),
387  MIPI_INIT_CMD(0xB3, 0x3C, 0x3C),
388  MIPI_INIT_CMD(0xB4, 0x0F, 0x0F),
389  MIPI_INIT_CMD(0xB9, 0x45, 0x45),
390  MIPI_INIT_CMD(0xBA, 0x14, 0x14),
391  MIPI_INIT_CMD(0xCA, 0x02),
392  MIPI_INIT_CMD(0xCE, 0x04),
393  MIPI_INIT_CMD(0xC3, 0x9B, 0x9B),
394  MIPI_INIT_CMD(0xD8, 0xC0, 0x03),
395  MIPI_INIT_CMD(0xBC, 0x82, 0x01),
396  MIPI_INIT_CMD(0xBD, 0x9E, 0x01),
397 
398  /* page 2 */
399  MIPI_INIT_CMD(0xF0, 0x55, 0xAA, 0x52, 0x08, 0x02),
400  MIPI_INIT_CMD(0xB0, 0x82),
401  MIPI_INIT_CMD(0xD1, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x82, 0x00, 0xA5,
402  0x00, 0xC1, 0x00, 0xEA, 0x01, 0x0D, 0x01, 0x40),
403  MIPI_INIT_CMD(0xD2, 0x01, 0x6A, 0x01, 0xA8, 0x01, 0xDC, 0x02, 0x29,
404  0x02, 0x67, 0x02, 0x68, 0x02, 0xA8, 0x02, 0xF0),
405  MIPI_INIT_CMD(0xD3, 0x03, 0x19, 0x03, 0x49, 0x03, 0x67, 0x03, 0x8C,
406  0x03, 0xA6, 0x03, 0xC7, 0x03, 0xDE, 0x03, 0xEC),
407  MIPI_INIT_CMD(0xD4, 0x03, 0xFF, 0x03, 0xFF),
408  MIPI_INIT_CMD(0xE0, 0x00, 0x00, 0x00, 0x86, 0x00, 0xC5, 0x00, 0xE5,
409  0x00, 0xFF, 0x01, 0x26, 0x01, 0x45, 0x01, 0x75),
410  MIPI_INIT_CMD(0xE1, 0x01, 0x9C, 0x01, 0xD5, 0x02, 0x05, 0x02, 0x4D,
411  0x02, 0x86, 0x02, 0x87, 0x02, 0xC3, 0x03, 0x03),
412  MIPI_INIT_CMD(0xE2, 0x03, 0x2A, 0x03, 0x56, 0x03, 0x72, 0x03, 0x94,
413  0x03, 0xAC, 0x03, 0xCB, 0x03, 0xE0, 0x03, 0xED),
414  MIPI_INIT_CMD(0xE3, 0x03, 0xFF, 0x03, 0xFF),
415 
416  /* page 3 */
417  MIPI_INIT_CMD(0xF0, 0x55, 0xAA, 0x52, 0x08, 0x03),
418  MIPI_INIT_CMD(0xB0, 0x00, 0x00, 0x00, 0x00),
419  MIPI_INIT_CMD(0xB1, 0x00, 0x00, 0x00, 0x00),
420  MIPI_INIT_CMD(0xB2, 0x00, 0x00, 0x06, 0x04, 0x01, 0x40, 0x85),
421  MIPI_INIT_CMD(0xB3, 0x10, 0x07, 0xFC, 0x04, 0x01, 0x40, 0x80),
422  MIPI_INIT_CMD(0xB6, 0xF0, 0x08, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01,
423  0x40, 0x80),
424  MIPI_INIT_CMD(0xBA, 0xC5, 0x07, 0x00, 0x04, 0x11, 0x25, 0x8C),
425  MIPI_INIT_CMD(0xBB, 0xC5, 0x07, 0x00, 0x03, 0x11, 0x25, 0x8C),
426  MIPI_INIT_CMD(0xC0, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x80, 0x80),
427  MIPI_INIT_CMD(0xC1, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x80, 0x80),
428  MIPI_INIT_CMD(0xC4, 0x00, 0x00),
429  MIPI_INIT_CMD(0xEF, 0x41),
430 
431  /* page 4 */
432  MIPI_INIT_CMD(0xF0, 0x55, 0xAA, 0x52, 0x08, 0x04),
433  MIPI_INIT_CMD(0xEC, 0x4C),
434 
435  /* page 5 */
436  MIPI_INIT_CMD(0xF0, 0x55, 0xAA, 0x52, 0x08, 0x05),
437  MIPI_INIT_CMD(0xB0, 0x13, 0x03, 0x03, 0x01),
438  MIPI_INIT_CMD(0xB1, 0x30, 0x00),
439  MIPI_INIT_CMD(0xB2, 0x02, 0x02, 0x00),
440  MIPI_INIT_CMD(0xB3, 0x82, 0x23, 0x82, 0x9D),
441  MIPI_INIT_CMD(0xB4, 0xC5, 0x75, 0x24, 0x57),
442  MIPI_INIT_CMD(0xB5, 0x00, 0xD4, 0x72, 0x11, 0x11, 0xAB, 0x0A),
443  MIPI_INIT_CMD(0xB6, 0x00, 0x00, 0xD5, 0x72, 0x24, 0x56),
444  MIPI_INIT_CMD(0xB7, 0x5C, 0xDC, 0x5C, 0x5C),
445  MIPI_INIT_CMD(0xB9, 0x0C, 0x00, 0x00, 0x01, 0x00),
446  MIPI_INIT_CMD(0xC0, 0x75, 0x11, 0x11, 0x54, 0x05),
447  MIPI_INIT_CMD(0xC6, 0x00, 0x00, 0x00, 0x00),
448  MIPI_INIT_CMD(0xD0, 0x00, 0x48, 0x08, 0x00, 0x00),
449  MIPI_INIT_CMD(0xD1, 0x00, 0x48, 0x09, 0x00, 0x00),
450 
451  /* page 6 */
452  MIPI_INIT_CMD(0xF0, 0x55, 0xAA, 0x52, 0x08, 0x06),
453  MIPI_INIT_CMD(0xB0, 0x02, 0x32, 0x32, 0x08, 0x2F),
454  MIPI_INIT_CMD(0xB1, 0x2E, 0x15, 0x14, 0x13, 0x12),
455  MIPI_INIT_CMD(0xB2, 0x11, 0x10, 0x00, 0x3D, 0x3D),
456  MIPI_INIT_CMD(0xB3, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D),
457  MIPI_INIT_CMD(0xB4, 0x3D, 0x32),
458  MIPI_INIT_CMD(0xB5, 0x03, 0x32, 0x32, 0x09, 0x2F),
459  MIPI_INIT_CMD(0xB6, 0x2E, 0x1B, 0x1A, 0x19, 0x18),
460  MIPI_INIT_CMD(0xB7, 0x17, 0x16, 0x01, 0x3D, 0x3D),
461  MIPI_INIT_CMD(0xB8, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D),
462  MIPI_INIT_CMD(0xB9, 0x3D, 0x32),
463  MIPI_INIT_CMD(0xC0, 0x01, 0x32, 0x32, 0x09, 0x2F),
464  MIPI_INIT_CMD(0xC1, 0x2E, 0x1A, 0x1B, 0x16, 0x17),
465  MIPI_INIT_CMD(0xC2, 0x18, 0x19, 0x03, 0x3D, 0x3D),
466  MIPI_INIT_CMD(0xC3, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D),
467  MIPI_INIT_CMD(0xC4, 0x3D, 0x32),
468  MIPI_INIT_CMD(0xC5, 0x00, 0x32, 0x32, 0x08, 0x2F),
469  MIPI_INIT_CMD(0xC6, 0x2E, 0x14, 0x15, 0x10, 0x11),
470  MIPI_INIT_CMD(0xC7, 0x12, 0x13, 0x02, 0x3D, 0x3D),
471  MIPI_INIT_CMD(0xC8, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D),
472  MIPI_INIT_CMD(0xC9, 0x3D, 0x32),
473 
474  {},
475 };
476 
477 static struct panel_init_command kd097d04_init_commands[] = {
478  /* voltage setting */
479  MIPI_INIT_CMD(0xB0, 0x00),
480  MIPI_INIT_CMD(0xB2, 0x02),
481  MIPI_INIT_CMD(0xB3, 0x11),
482  MIPI_INIT_CMD(0xB4, 0x00),
483  MIPI_INIT_CMD(0xB6, 0x80),
484  /* VCOM disable */
485  MIPI_INIT_CMD(0xB7, 0x02),
486  MIPI_INIT_CMD(0xB8, 0x80),
487  MIPI_INIT_CMD(0xBA, 0x43),
488  /* VCOM setting */
489  MIPI_INIT_CMD(0xBB, 0x53),
490  /* VSP setting */
491  MIPI_INIT_CMD(0xBC, 0x0A),
492  /* VSN setting */
493  MIPI_INIT_CMD(0xBD, 0x4A),
494  /* VGH setting */
495  MIPI_INIT_CMD(0xBE, 0x2F),
496  /* VGL setting */
497  MIPI_INIT_CMD(0xBF, 0x1A),
498  MIPI_INIT_CMD(0xF0, 0x39),
499  MIPI_INIT_CMD(0xF1, 0x22),
500  /* Gamma setting */
501  MIPI_INIT_CMD(0xB0, 0x02),
502  MIPI_INIT_CMD(0xC0, 0x00),
503  MIPI_INIT_CMD(0xC1, 0x01),
504  MIPI_INIT_CMD(0xC2, 0x0B),
505  MIPI_INIT_CMD(0xC3, 0x15),
506  MIPI_INIT_CMD(0xC4, 0x22),
507  MIPI_INIT_CMD(0xC5, 0x11),
508  MIPI_INIT_CMD(0xC6, 0x15),
509  MIPI_INIT_CMD(0xC7, 0x19),
510  MIPI_INIT_CMD(0xC8, 0x1A),
511  MIPI_INIT_CMD(0xC9, 0x16),
512  MIPI_INIT_CMD(0xCA, 0x18),
513  MIPI_INIT_CMD(0xCB, 0x13),
514  MIPI_INIT_CMD(0xCC, 0x18),
515  MIPI_INIT_CMD(0xCD, 0x13),
516  MIPI_INIT_CMD(0xCE, 0x1C),
517  MIPI_INIT_CMD(0xCF, 0x19),
518  MIPI_INIT_CMD(0xD0, 0x21),
519  MIPI_INIT_CMD(0xD1, 0x2C),
520  MIPI_INIT_CMD(0xD2, 0x2F),
521  MIPI_INIT_CMD(0xD3, 0x30),
522  MIPI_INIT_CMD(0xD4, 0x19),
523  MIPI_INIT_CMD(0xD5, 0x1F),
524  MIPI_INIT_CMD(0xD6, 0x00),
525  MIPI_INIT_CMD(0xD7, 0x01),
526  MIPI_INIT_CMD(0xD8, 0x0B),
527  MIPI_INIT_CMD(0xD9, 0x15),
528  MIPI_INIT_CMD(0xDA, 0x22),
529  MIPI_INIT_CMD(0xDB, 0x11),
530  MIPI_INIT_CMD(0xDC, 0x15),
531  MIPI_INIT_CMD(0xDD, 0x19),
532  MIPI_INIT_CMD(0xDE, 0x1A),
533  MIPI_INIT_CMD(0xDF, 0x16),
534  MIPI_INIT_CMD(0xE0, 0x18),
535  MIPI_INIT_CMD(0xE1, 0x13),
536  MIPI_INIT_CMD(0xE2, 0x18),
537  MIPI_INIT_CMD(0xE3, 0x13),
538  MIPI_INIT_CMD(0xE4, 0x1C),
539  MIPI_INIT_CMD(0xE5, 0x19),
540  MIPI_INIT_CMD(0xE6, 0x21),
541  MIPI_INIT_CMD(0xE7, 0x2C),
542  MIPI_INIT_CMD(0xE8, 0x2F),
543  MIPI_INIT_CMD(0xE9, 0x30),
544  MIPI_INIT_CMD(0xEA, 0x19),
545  MIPI_INIT_CMD(0xEB, 0x1F),
546  /* GOA MUX setting */
547  MIPI_INIT_CMD(0xB0, 0x01),
548  MIPI_INIT_CMD(0xC0, 0x10),
549  MIPI_INIT_CMD(0xC1, 0x0F),
550  MIPI_INIT_CMD(0xC2, 0x0E),
551  MIPI_INIT_CMD(0xC3, 0x0D),
552  MIPI_INIT_CMD(0xC4, 0x0C),
553  MIPI_INIT_CMD(0xC5, 0x0B),
554  MIPI_INIT_CMD(0xC6, 0x0A),
555  MIPI_INIT_CMD(0xC7, 0x09),
556  MIPI_INIT_CMD(0xC8, 0x08),
557  MIPI_INIT_CMD(0xC9, 0x07),
558  MIPI_INIT_CMD(0xCA, 0x06),
559  MIPI_INIT_CMD(0xCB, 0x05),
560  MIPI_INIT_CMD(0xCC, 0x00),
561  MIPI_INIT_CMD(0xCD, 0x01),
562  MIPI_INIT_CMD(0xCE, 0x02),
563  MIPI_INIT_CMD(0xCF, 0x03),
564  MIPI_INIT_CMD(0xD0, 0x04),
565  MIPI_INIT_CMD(0xD6, 0x10),
566  MIPI_INIT_CMD(0xD7, 0x0F),
567  MIPI_INIT_CMD(0xD8, 0x0E),
568  MIPI_INIT_CMD(0xD9, 0x0D),
569  MIPI_INIT_CMD(0xDA, 0x0C),
570  MIPI_INIT_CMD(0xDB, 0x0B),
571  MIPI_INIT_CMD(0xDC, 0x0A),
572  MIPI_INIT_CMD(0xDD, 0x09),
573  MIPI_INIT_CMD(0xDE, 0x08),
574  MIPI_INIT_CMD(0xDF, 0x07),
575  MIPI_INIT_CMD(0xE0, 0x06),
576  MIPI_INIT_CMD(0xE1, 0x05),
577  MIPI_INIT_CMD(0xE2, 0x00),
578  MIPI_INIT_CMD(0xE3, 0x01),
579  MIPI_INIT_CMD(0xE4, 0x02),
580  MIPI_INIT_CMD(0xE5, 0x03),
581  MIPI_INIT_CMD(0xE6, 0x04),
582  MIPI_INIT_CMD(0xE7, 0x00),
583  MIPI_INIT_CMD(0xEC, 0xC0),
584  /* GOA timing setting */
585  MIPI_INIT_CMD(0xB0, 0x03),
586  MIPI_INIT_CMD(0xC0, 0x01),
587  MIPI_INIT_CMD(0xC2, 0x6F),
588  MIPI_INIT_CMD(0xC3, 0x6F),
589  MIPI_INIT_CMD(0xC5, 0x36),
590  MIPI_INIT_CMD(0xC8, 0x08),
591  MIPI_INIT_CMD(0xC9, 0x04),
592  MIPI_INIT_CMD(0xCA, 0x41),
593  MIPI_INIT_CMD(0xCC, 0x43),
594  MIPI_INIT_CMD(0xCF, 0x60),
595  MIPI_INIT_CMD(0xD2, 0x04),
596  MIPI_INIT_CMD(0xD3, 0x04),
597  MIPI_INIT_CMD(0xD4, 0x03),
598  MIPI_INIT_CMD(0xD5, 0x02),
599  MIPI_INIT_CMD(0xD6, 0x01),
600  MIPI_INIT_CMD(0xD7, 0x00),
601  MIPI_INIT_CMD(0xDB, 0x01),
602  MIPI_INIT_CMD(0xDE, 0x36),
603  MIPI_INIT_CMD(0xE6, 0x6F),
604  MIPI_INIT_CMD(0xE7, 0x6F),
605  /* GOE setting */
606  MIPI_INIT_CMD(0xB0, 0x06),
607  MIPI_INIT_CMD(0xB8, 0xA5),
608  MIPI_INIT_CMD(0xC0, 0xA5),
609  MIPI_INIT_CMD(0xD5, 0x3F),
610  {},
611 };
612 
613 const struct mipi_panel_data kd097d04_panel = {
614  .mipi_num = 2,
615  .format = MIPI_DSI_FMT_RGB888,
616  .lanes = 8,
617  .display_on_udelay = 120000,
618  .video_mode_udelay = 5000,
619  .init_cmd = kd097d04_init_commands,
620 };
621 
622 static const struct edid_mode kd097d04_edid_mode = {
623  .name = "1536x2048@60Hz",
624  .pixel_clock = 216000,
625  .refresh = 60,
626  .ha = 1536,
627  .hbl = 186,
628  .hso = 81,
629  .hspw = 24,
630  .va = 2048,
631  .vbl = 42,
632  .vso = 17,
633  .vspw = 2,
634 };
635 
636 const struct mipi_panel_data inx097pfg_panel = {
637  .mipi_num = 2,
638  .format = MIPI_DSI_FMT_RGB888,
639  .lanes = 8,
640  .display_on_udelay = 120000,
641  .video_mode_udelay = 5000,
642  .init_cmd = innolux_p097pfg_init_cmds,
643 };
644 
645 static const struct edid_mode inx097pfg_edid_mode = {
646  .name = "1536x2048@60Hz",
647  .pixel_clock = 220000,
648  .refresh = 60,
649  .ha = 1536,
650  .hbl = 224,
651  .hso = 100,
652  .hspw = 24,
653  .va = 2048,
654  .vbl = 38,
655  .vso = 18,
656  .vspw = 2,
657 };
658 
660  (struct edid_mode *edid_mode)
661 {
662  switch (sku_id()) {
663  case 0:
664  case 2:
665  case 4:
666  case 6:
668  sizeof(struct edid_mode));
669  return &inx097pfg_panel;
670  case 1:
671  case 3:
672  case 5:
673  case 7:
674  default:
676  sizeof(struct edid_mode));
677  return &kd097d04_panel;
678  }
679 }
680 
681 static void mainboard_enable(struct device *dev)
682 {
683  dev->ops->init = &mainboard_init;
684 }
685 
688 };
struct chip_operations mainboard_ops
Definition: mainboard.c:19
static void write32(void *addr, uint32_t val)
Definition: mmio.h:40
void * memcpy(void *dest, const void *src, size_t n)
Definition: memcpy.c:7
#define assert(statement)
Definition: assert.h:74
void register_bl31_aux_param(struct bl_aux_param_header *param)
Definition: bl31.c:54
int display_init_required(void)
Definition: bootmode.c:22
#define KHz
Definition: helpers.h:79
#define printk(level,...)
Definition: stdlib.h:16
void mdelay(unsigned int msecs)
Definition: delay.c:2
@ GPIO
Definition: chip.h:84
@ CONFIG
Definition: dsi_common.h:201
@ MIPI_DSI_FMT_RGB888
Definition: dsi_common.h:13
int google_chromeec_set_usb_pd_role(uint8_t port, enum usb_pd_control_role role)
Definition: ec.c:1214
@ USB_PD_CTRL_ROLE_FORCE_SINK
Definition: ec_commands.h:5508
@ USB_PD_CTRL_ROLE_TOGGLE_ON
Definition: ec_commands.h:5506
#define GPIO_P15V_EN
Definition: board.h:30
#define GPIO_BL_EN
Definition: board.h:26
#define GPIO_P18V_AUDIO_PWREN
Definition: board.h:31
#define GPIO_SPK_PA_EN
Definition: board.h:33
#define GPIO_BACKLIGHT
Definition: board.h:27
#define GPIO_TP_RST_L
Definition: board.h:34
#define GPIO_POWEROFF
Definition: board.h:9
#define GPIO_P30V_EN
Definition: board.h:32
#define GPIO_WLAN_RST_L
Definition: board.h:42
static void usb_power_cycle(int port)
Definition: mainboard.c:247
static void mainboard_init(struct device *dev)
Definition: mainboard.c:325
static struct panel_init_command kd097d04_init_commands[]
Definition: mainboard.c:477
static void register_poweroff_to_bl31(void)
Definition: mainboard.c:129
const struct mipi_panel_data inx097pfg_panel
Definition: mainboard.c:636
static const struct edid_mode inx097pfg_edid_mode
Definition: mainboard.c:645
static void configure_codec(void)
Definition: mainboard.c:204
static void configure_sdmmc(void)
Definition: mainboard.c:150
static void configure_display(void)
Definition: mainboard.c:224
static void configure_touchpad(void)
Definition: mainboard.c:31
static void assert_wifi_reset(void)
Definition: mainboard.c:41
static struct panel_init_command innolux_p097pfg_init_cmds[]
Definition: mainboard.c:368
static void register_gpio_suspend(void)
Definition: mainboard.c:77
static void register_apio_suspend(void)
Definition: mainboard.c:60
static void setup_usb(int port)
Definition: mainboard.c:258
static void configure_emmc(void)
Definition: mainboard.c:46
const struct mipi_panel_data kd097d04_panel
Definition: mainboard.c:613
static void prepare_backlight_i2c(void)
Definition: mainboard.c:345
void mainboard_power_on_backlight(void)
Definition: mainboard.c:356
static void mainboard_enable(struct device *dev)
Definition: mainboard.c:681
static void register_reset_to_bl31(void)
Definition: mainboard.c:112
static const struct edid_mode kd097d04_edid_mode
Definition: mainboard.c:622
const struct mipi_panel_data * mainboard_get_mipi_mode(struct edid_mode *edid_mode)
Definition: mainboard.c:660
uint32_t sku_id(void)
Definition: mainboard.c:11
port
Definition: i915.h:29
void gpio_input(gpio_t gpio)
Definition: gpio.c:189
void gpio_output(gpio_t gpio, int value)
Definition: gpio.c:194
void gpio_input_pulldown(gpio_t gpio)
Definition: gpio.c:179
void gpio_input_pullup(gpio_t gpio)
Definition: gpio.c:184
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
#define GPIO_RESET
Definition: gpio.h:16
#define IOMUX_EDP_HOTPLUG
Definition: grf.h:206
#define IOMUX_I2SCLK
Definition: grf.h:195
#define IOMUX_I2C0_SDA
Definition: grf.h:344
#define IOMUX_I2C0_SCL
Definition: grf.h:343
#define IOMUX_SDMMC
Definition: grf.h:341
static struct rk3399_pmugrf_regs *const rk3399_pmugrf
Definition: grf.h:320
#define IOMUX_I2S0_SD0
Definition: grf.h:346
static struct rk3399_grf_regs *const rk3399_grf
Definition: grf.h:319
#define RK_CLRBITS(clr)
Definition: soc.h:10
#define RK_SETBITS(set)
Definition: soc.h:9
#define RK_CLRSETBITS(clr, set)
Definition: soc.h:8
#define MIPI_INIT_CMD(...)
Definition: mipi.h:254
void i2c_init(unsigned int bus)
Definition: i2c.c:198
void rkclk_configure_i2s(unsigned int hz)
Definition: clock.c:451
void rkclk_configure_emmc(void)
Definition: clock.c:892
void setup_usb_otg0(void)
Definition: usb.c:148
void setup_usb_otg1(void)
Definition: usb.c:157
void(* enable_dev)(struct device *dev)
Definition: device.h:24
void(* init)(struct device *dev)
Definition: device.h:42
Definition: device.h:107
struct device_operations * ops
Definition: device.h:143
Definition: edid.h:20
const char * name
Definition: edid.h:21
u32 usbphy_ctrl[2][26+6]
Definition: grf.h:61
u32 iomux_sdmmc
Definition: grf.h:131
u32 iomux_i2s0
Definition: grf.h:123
u32 gpio2_p[3][4]
Definition: grf.h:145
u32 iomux_i2sclk
Definition: grf.h:127
u32 iomux_edp_hotplug
Definition: grf.h:140
u32 gpio4b_e01
Definition: grf.h:151
u32 gpio4b_e2
Definition: grf.h:152
u32 emmccore_con[12]
Definition: grf.h:181
u32 iomux_i2c0_scl
Definition: grf.h:211
u32 iomux_i2c0_sda
Definition: grf.h:206