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