Yidi Lin | 3d7b606 | 2015-07-31 17:10:40 +0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2015 MediaTek Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Yidi Lin | 3d7b606 | 2015-07-31 17:10:40 +0800 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <arch/cache.h> |
| 17 | #include <arch/io.h> |
| 18 | #include <boardid.h> |
| 19 | #include <boot/coreboot_tables.h> |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 20 | #include <bootmode.h> |
| 21 | #include <console/console.h> |
Koro Chen | 9733ba5 | 2015-07-31 17:11:04 +0800 | [diff] [blame] | 22 | #include <delay.h> |
Yidi Lin | 3d7b606 | 2015-07-31 17:10:40 +0800 | [diff] [blame] | 23 | #include <device/device.h> |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 24 | #include <drivers/parade/ps8640/ps8640.h> |
| 25 | #include <edid.h> |
Yidi Lin | 3d7b606 | 2015-07-31 17:10:40 +0800 | [diff] [blame] | 26 | |
CC Ma | 72980b1 | 2015-09-15 17:33:38 +0800 | [diff] [blame] | 27 | #include <elog.h> |
Koro Chen | 9733ba5 | 2015-07-31 17:11:04 +0800 | [diff] [blame] | 28 | #include <gpio.h> |
henryc.chen | 316ded8 | 2016-03-11 14:55:30 +0800 | [diff] [blame] | 29 | #include <soc/da9212.h> |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 30 | #include <soc/ddp.h> |
| 31 | #include <soc/dsi.h> |
jun.gao | f059e97 | 2015-12-17 16:59:55 +0800 | [diff] [blame] | 32 | #include <soc/i2c.h> |
henryc.chen | 316ded8 | 2016-03-11 14:55:30 +0800 | [diff] [blame] | 33 | #include <soc/mt6311.h> |
Koro Chen | 9733ba5 | 2015-07-31 17:11:04 +0800 | [diff] [blame] | 34 | #include <soc/mt6391.h> |
| 35 | #include <soc/mtcmos.h> |
| 36 | #include <soc/pinmux.h> |
| 37 | #include <soc/pll.h> |
Ben Lok | a737940 | 2015-07-31 17:11:11 +0800 | [diff] [blame] | 38 | #include <soc/usb.h> |
CC Ma | 72980b1 | 2015-09-15 17:33:38 +0800 | [diff] [blame] | 39 | #include <vendorcode/google/chromeos/chromeos.h> |
Koro Chen | 9733ba5 | 2015-07-31 17:11:04 +0800 | [diff] [blame] | 40 | |
henryc.chen | 316ded8 | 2016-03-11 14:55:30 +0800 | [diff] [blame] | 41 | enum { |
| 42 | CODEC_I2C_BUS = 0, |
| 43 | EXT_BUCK_I2C_BUS = 1, |
| 44 | }; |
| 45 | |
| 46 | static void configure_ext_buck(void) |
Jimmy Huang | 27eba67 | 2015-07-31 17:11:00 +0800 | [diff] [blame] | 47 | { |
henryc.chen | 316ded8 | 2016-03-11 14:55:30 +0800 | [diff] [blame] | 48 | mtk_i2c_bus_init(EXT_BUCK_I2C_BUS); |
jun.gao | f059e97 | 2015-12-17 16:59:55 +0800 | [diff] [blame] | 49 | |
Julius Werner | 9a57095 | 2016-03-14 20:12:18 -0700 | [diff] [blame] | 50 | switch (board_id() + CONFIG_BOARD_ID_ADJUSTMENT) { |
henryc.chen | 70b3044 | 2015-12-23 11:45:29 +0800 | [diff] [blame] | 51 | case 3: |
| 52 | case 4: |
Jimmy Huang | 27eba67 | 2015-07-31 17:11:00 +0800 | [diff] [blame] | 53 | /* rev-3 and rev-4 use mt6311 as external buck */ |
henryc.chen | 316ded8 | 2016-03-11 14:55:30 +0800 | [diff] [blame] | 54 | gpio_output(PAD_EINT15, 1); |
| 55 | udelay(500); |
| 56 | mt6311_probe(EXT_BUCK_I2C_BUS); |
Jimmy Huang | 27eba67 | 2015-07-31 17:11:00 +0800 | [diff] [blame] | 57 | break; |
henryc.chen | 70b3044 | 2015-12-23 11:45:29 +0800 | [diff] [blame] | 58 | case 2: |
| 59 | default: |
| 60 | /* rev-2 and rev-5 use da9212 as external buck */ |
henryc.chen | 316ded8 | 2016-03-11 14:55:30 +0800 | [diff] [blame] | 61 | mt6391_gpio_output(MT6391_KP_ROW3, 1); /* DA9212_IC_EN */ |
| 62 | mt6391_gpio_output(MT6391_KP_ROW4, 1); /* DA9212_EN_A */ |
| 63 | udelay(500); /* add 500us delay for powering on da9212 */ |
| 64 | da9212_probe(EXT_BUCK_I2C_BUS); |
henryc.chen | 70b3044 | 2015-12-23 11:45:29 +0800 | [diff] [blame] | 65 | break; |
Jimmy Huang | 27eba67 | 2015-07-31 17:11:00 +0800 | [diff] [blame] | 66 | } |
| 67 | } |
| 68 | |
YH Huang | 5d687ad | 2016-07-14 11:49:01 +0800 | [diff] [blame] | 69 | static void configure_touchscreen(void) |
| 70 | { |
| 71 | /* Pull low reset gpio for 500us and then pull high */ |
| 72 | if (board_id() + CONFIG_BOARD_ID_ADJUSTMENT >= 7) { |
| 73 | gpio_output(PAD_PCM_SYNC, 0); |
| 74 | udelay(500); |
| 75 | gpio_output(PAD_PCM_SYNC, 1); |
| 76 | } |
| 77 | } |
| 78 | |
Koro Chen | 9733ba5 | 2015-07-31 17:11:04 +0800 | [diff] [blame] | 79 | static void configure_audio(void) |
| 80 | { |
| 81 | mtcmos_audio_power_on(); |
| 82 | |
Koro Chen | 603cb85 | 2015-12-30 17:50:56 +0800 | [diff] [blame] | 83 | /* vgp1 set to 1.8V */ |
| 84 | mt6391_configure_ldo(LDO_VCAMD, LDO_1P8); |
| 85 | /* delay 1ms for realtek's power sequence request */ |
| 86 | mdelay(1); |
| 87 | /* vcama set to 1.8V */ |
| 88 | mt6391_configure_ldo(LDO_VCAMA, LDO_1P8); |
Koro Chen | 9733ba5 | 2015-07-31 17:11:04 +0800 | [diff] [blame] | 89 | |
| 90 | /* reset ALC5676 */ |
Julius Werner | 9a57095 | 2016-03-14 20:12:18 -0700 | [diff] [blame] | 91 | if (board_id() + CONFIG_BOARD_ID_ADJUSTMENT < 5) |
Koro Chen | a9f6529 | 2015-12-30 17:31:44 +0800 | [diff] [blame] | 92 | gpio_output(PAD_LCM_RST, 1); |
Koro Chen | 9733ba5 | 2015-07-31 17:11:04 +0800 | [diff] [blame] | 93 | |
| 94 | /* SoC I2S */ |
| 95 | gpio_set_mode(PAD_I2S0_LRCK, PAD_I2S0_LRCK_FUNC_I2S1_WS); |
| 96 | gpio_set_mode(PAD_I2S0_BCK, PAD_I2S0_BCK_FUNC_I2S1_BCK); |
| 97 | gpio_set_mode(PAD_I2S0_MCK, PAD_I2S0_MCK_FUNC_I2S1_MCK); |
| 98 | gpio_set_mode(PAD_I2S0_DATA0, PAD_I2S0_DATA0_FUNC_I2S1_DO_1); |
| 99 | gpio_set_mode(PAD_I2S0_DATA1, PAD_I2S0_DATA1_FUNC_I2S2_DI_2); |
Koro Chen | 9733ba5 | 2015-07-31 17:11:04 +0800 | [diff] [blame] | 100 | /* codec ext MCLK ON */ |
| 101 | mt6391_gpio_output(MT6391_KP_COL4, 1); |
Yidi Lin | 19318dd | 2016-03-16 16:59:17 +0800 | [diff] [blame] | 102 | |
| 103 | switch (board_id() + CONFIG_BOARD_ID_ADJUSTMENT) { |
| 104 | case 2: |
| 105 | case 3: |
| 106 | case 4: |
| 107 | mt6391_gpio_output(MT6391_KP_COL5, 1); |
| 108 | break; |
| 109 | case 5: |
| 110 | case 6: |
| 111 | gpio_set_mode(PAD_UCTS0, PAD_UCTS0_FUNC_I2S2_DI_1); |
| 112 | mt6391_gpio_output(MT6391_KP_COL5, 1); |
| 113 | break; |
| 114 | default: |
| 115 | break; |
| 116 | } |
Koro Chen | 9733ba5 | 2015-07-31 17:11:04 +0800 | [diff] [blame] | 117 | |
jun.gao | f059e97 | 2015-12-17 16:59:55 +0800 | [diff] [blame] | 118 | /* Init i2c bus Timing register for audio codecs */ |
henryc.chen | 316ded8 | 2016-03-11 14:55:30 +0800 | [diff] [blame] | 119 | mtk_i2c_bus_init(CODEC_I2C_BUS); |
jun.gao | f059e97 | 2015-12-17 16:59:55 +0800 | [diff] [blame] | 120 | |
Koro Chen | 9733ba5 | 2015-07-31 17:11:04 +0800 | [diff] [blame] | 121 | /* set I2S clock to 48KHz */ |
| 122 | mt_pll_set_aud_div(48 * KHz); |
| 123 | } |
| 124 | |
Ben Lok | a737940 | 2015-07-31 17:11:11 +0800 | [diff] [blame] | 125 | static void configure_usb(void) |
| 126 | { |
| 127 | setup_usb_host(); |
| 128 | |
Julius Werner | 9a57095 | 2016-03-14 20:12:18 -0700 | [diff] [blame] | 129 | if (board_id() + CONFIG_BOARD_ID_ADJUSTMENT > 3) { |
Yidi Lin | 57debca | 2017-02-17 15:59:17 +0800 | [diff] [blame] | 130 | /* Type C port 0 Over current alert pin */ |
Yidi Lin | 358f66a | 2016-01-11 10:05:46 +0800 | [diff] [blame] | 131 | gpio_input_pullup(PAD_MSDC3_DSL); |
Yidi Lin | 57debca | 2017-02-17 15:59:17 +0800 | [diff] [blame] | 132 | if (!IS_ENABLED(CONFIG_BOARD_GOOGLE_ROWAN)) { |
| 133 | /* Enable USB3 type A port 0 5V load switch */ |
| 134 | gpio_output(PAD_CM2MCLK, 1); |
| 135 | /* USB3 Type A port 0 power over current alert pin */ |
| 136 | gpio_input_pullup(PAD_CMPCLK); |
| 137 | } |
| 138 | /* Type C port 1 over current alert pin */ |
Yidi Lin | 19318dd | 2016-03-16 16:59:17 +0800 | [diff] [blame] | 139 | if (board_id() + CONFIG_BOARD_ID_ADJUSTMENT < 7) |
| 140 | gpio_input_pullup(PAD_PCM_SYNC); |
Yidi Lin | 358f66a | 2016-01-11 10:05:46 +0800 | [diff] [blame] | 141 | } |
| 142 | |
Yidi Lin | 19318dd | 2016-03-16 16:59:17 +0800 | [diff] [blame] | 143 | if (board_id() + CONFIG_BOARD_ID_ADJUSTMENT > 4 && |
| 144 | board_id() + CONFIG_BOARD_ID_ADJUSTMENT < 7) |
| 145 | { |
Yidi Lin | 358f66a | 2016-01-11 10:05:46 +0800 | [diff] [blame] | 146 | /* USB 2.0 type A port over current interrupt pin(low active) */ |
| 147 | gpio_input_pullup(PAD_UCTS2); |
| 148 | /* USB 2.0 type A port BC1.2 STATUS(low active) */ |
| 149 | gpio_input_pullup(PAD_AUD_DAT_MISO); |
| 150 | } |
Ben Lok | a737940 | 2015-07-31 17:11:11 +0800 | [diff] [blame] | 151 | } |
| 152 | |
Ben Lok | 7d7dc20 | 2016-01-08 13:10:34 +0800 | [diff] [blame] | 153 | static void configure_usb_hub(void) |
| 154 | { |
Yidi Lin | 57debca | 2017-02-17 15:59:17 +0800 | [diff] [blame] | 155 | if (IS_ENABLED(CONFIG_BOARD_GOOGLE_ROWAN)) |
| 156 | return; |
| 157 | |
Ben Lok | 7d7dc20 | 2016-01-08 13:10:34 +0800 | [diff] [blame] | 158 | /* set usb hub reset pin (low active) to high */ |
Julius Werner | 9a57095 | 2016-03-14 20:12:18 -0700 | [diff] [blame] | 159 | if (board_id() + CONFIG_BOARD_ID_ADJUSTMENT > 4) |
Ben Lok | 7d7dc20 | 2016-01-08 13:10:34 +0800 | [diff] [blame] | 160 | gpio_output(PAD_UTXD3, 1); |
| 161 | } |
| 162 | |
YH Huang | 1fcee36 | 2015-07-31 17:11:07 +0800 | [diff] [blame] | 163 | /* Setup backlight control pins as output pin and power-off by default */ |
| 164 | static void configure_backlight(void) |
| 165 | { |
Yidi Lin | 0443ecc | 2015-12-28 16:40:54 +0800 | [diff] [blame] | 166 | /* Configure PANEL_LCD_POWER_EN */ |
Julius Werner | 9a57095 | 2016-03-14 20:12:18 -0700 | [diff] [blame] | 167 | switch (board_id() + CONFIG_BOARD_ID_ADJUSTMENT) { |
YH Huang | 1fcee36 | 2015-07-31 17:11:07 +0800 | [diff] [blame] | 168 | case 3: |
Yidi Lin | 0443ecc | 2015-12-28 16:40:54 +0800 | [diff] [blame] | 169 | gpio_output(PAD_UCTS2, 0); |
YH Huang | 1fcee36 | 2015-07-31 17:11:07 +0800 | [diff] [blame] | 170 | break; |
| 171 | case 4: |
Yidi Lin | 0443ecc | 2015-12-28 16:40:54 +0800 | [diff] [blame] | 172 | gpio_output(PAD_SRCLKENAI, 0); |
| 173 | break; |
YH Huang | 1fcee36 | 2015-07-31 17:11:07 +0800 | [diff] [blame] | 174 | default: |
Yidi Lin | 0443ecc | 2015-12-28 16:40:54 +0800 | [diff] [blame] | 175 | gpio_output(PAD_UTXD2, 0); |
YH Huang | 1fcee36 | 2015-07-31 17:11:07 +0800 | [diff] [blame] | 176 | break; |
| 177 | } |
Yidi Lin | 0443ecc | 2015-12-28 16:40:54 +0800 | [diff] [blame] | 178 | |
| 179 | gpio_output(PAD_DISP_PWM0, 0); /* DISP_PWM0 */ |
| 180 | gpio_output(PAD_PCM_TX, 0); /* PANEL_POWER_EN */ |
YH Huang | 1fcee36 | 2015-07-31 17:11:07 +0800 | [diff] [blame] | 181 | } |
| 182 | |
Jitao Shi | 8ea218b | 2016-01-11 19:24:37 +0800 | [diff] [blame] | 183 | static void configure_display(void) |
| 184 | { |
Yidi Lin | 19318dd | 2016-03-16 16:59:17 +0800 | [diff] [blame] | 185 | /* board from Rev2 */ |
| 186 | gpio_output(PAD_CMMCLK, 1); /* PANEL_3V3_ENABLE */ |
| 187 | /* vgp2 set to 3.3V for ps8640 */ |
| 188 | mt6391_configure_ldo(LDO_VGP2, LDO_3P3); |
| 189 | gpio_output(PAD_URTS0, 0); /* PS8640_SYSRSTN */ |
| 190 | /* PS8640_1V2_ENABLE */ |
| 191 | if (board_id() + CONFIG_BOARD_ID_ADJUSTMENT == 4) |
| 192 | gpio_output(PAD_SRCLKENAI2, 1); |
| 193 | else |
| 194 | gpio_output(PAD_URTS2, 1); |
| 195 | /* delay 2ms for vgp2 and PS8640_1V2_ENABLE stable */ |
| 196 | mdelay(2); |
| 197 | /* PS8640_PDN */ |
| 198 | if (board_id() + CONFIG_BOARD_ID_ADJUSTMENT > 4) |
| 199 | gpio_output(PAD_LCM_RST, 1); |
| 200 | else |
| 201 | gpio_output(PAD_UCTS0, 1); |
| 202 | gpio_output(PAD_PCM_CLK, 1); /* PS8640_MODE_CONF */ |
| 203 | gpio_output(PAD_URTS0, 1); /* PS8640_SYSRSTN */ |
| 204 | /* for level shift(1.8V to 3.3V) on */ |
| 205 | udelay(100); |
Jitao Shi | 8ea218b | 2016-01-11 19:24:37 +0800 | [diff] [blame] | 206 | } |
| 207 | |
Daniel Kurtz | 8e055f8 | 2017-04-20 15:31:33 +0800 | [diff] [blame] | 208 | static void configure_backlight_rowan(void) |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 209 | { |
Daniel Kurtz | 8e055f8 | 2017-04-20 15:31:33 +0800 | [diff] [blame] | 210 | gpio_output(PAD_DAIPCMOUT, 0); /* PANEL_LCD_POWER_EN */ |
| 211 | gpio_output(PAD_DISP_PWM0, 0); /* DISP_PWM0 */ |
| 212 | gpio_output(PAD_PCM_TX, 0); /* PANEL_POWER_EN */ |
| 213 | } |
| 214 | |
| 215 | static void configure_display_rowan(void) |
| 216 | { |
| 217 | gpio_output(PAD_UCTS2, 1); /* VDDIO_EN */ |
| 218 | /* delay 15 ms for panel vddio to stabilize */ |
| 219 | mdelay(15); |
| 220 | |
| 221 | gpio_output(PAD_SRCLKENAI2, 1); /* LCD_RESET */ |
| 222 | udelay(20); |
| 223 | gpio_output(PAD_SRCLKENAI2, 0); /* LCD_RESET */ |
| 224 | udelay(20); |
| 225 | gpio_output(PAD_SRCLKENAI2, 1); /* LCD_RESET */ |
| 226 | mdelay(20); |
| 227 | |
| 228 | /* Rowan panel avdd */ |
| 229 | gpio_output(PAD_URTS2, 1); |
| 230 | |
| 231 | /* Rowan panel avee */ |
| 232 | gpio_output(PAD_URTS0, 1); |
| 233 | |
| 234 | /* panel.delay.prepare */ |
| 235 | mdelay(20); |
| 236 | } |
| 237 | |
| 238 | static const struct edid rowan_boe_edid = { |
| 239 | .panel_bits_per_color = 8, |
| 240 | .panel_bits_per_pixel = 24, |
| 241 | .mode = { |
| 242 | .name = "1536x2048@60Hz", |
| 243 | .pixel_clock = 241646, |
| 244 | .lvds_dual_channel = 1, |
| 245 | .refresh = 60, |
| 246 | .ha = 1536, .hbl = 404, .hso = 200, .hspw = 4, .hborder = 0, |
| 247 | .va = 2048, .vbl = 28, .vso = 12, .vspw = 2, .vborder = 0, |
| 248 | .phsync = '-', .pvsync = '-', |
| 249 | .x_mm = 147, .y_mm = 196, |
| 250 | }, |
| 251 | }; |
| 252 | |
| 253 | static int read_edid_from_ps8640(struct edid *edid) |
| 254 | { |
Yidi Lin | 19318dd | 2016-03-16 16:59:17 +0800 | [diff] [blame] | 255 | u8 i2c_bus, i2c_addr; |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 256 | |
Yidi Lin | 19318dd | 2016-03-16 16:59:17 +0800 | [diff] [blame] | 257 | if (board_id() + CONFIG_BOARD_ID_ADJUSTMENT > 6) { |
| 258 | i2c_bus = 0; |
| 259 | i2c_addr = 0x8; |
| 260 | } else { |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 261 | i2c_bus = 4; |
Yidi Lin | 19318dd | 2016-03-16 16:59:17 +0800 | [diff] [blame] | 262 | i2c_addr = 0x18; |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 263 | } |
Yidi Lin | 19318dd | 2016-03-16 16:59:17 +0800 | [diff] [blame] | 264 | |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 265 | mtk_i2c_bus_init(i2c_bus); |
| 266 | |
Yidi Lin | 19318dd | 2016-03-16 16:59:17 +0800 | [diff] [blame] | 267 | ps8640_init(i2c_bus, i2c_addr); |
Daniel Kurtz | 8e055f8 | 2017-04-20 15:31:33 +0800 | [diff] [blame] | 268 | if (ps8640_get_edid(i2c_bus, i2c_addr, edid)) { |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 269 | printk(BIOS_ERR, "Can't get panel's edid\n"); |
Daniel Kurtz | 8e055f8 | 2017-04-20 15:31:33 +0800 | [diff] [blame] | 270 | return -1; |
| 271 | } |
| 272 | |
| 273 | return 0; |
| 274 | } |
| 275 | |
| 276 | static void display_startup(void) |
| 277 | { |
| 278 | struct edid edid; |
| 279 | int ret; |
| 280 | u32 mipi_dsi_flags; |
| 281 | bool dual_dsi_mode; |
| 282 | |
| 283 | if (IS_ENABLED(CONFIG_BOARD_GOOGLE_ROWAN)) { |
| 284 | edid = rowan_boe_edid; |
| 285 | dual_dsi_mode = true; |
| 286 | mipi_dsi_flags = MIPI_DSI_MODE_VIDEO | |
| 287 | MIPI_DSI_MODE_VIDEO_SYNC_PULSE | |
| 288 | MIPI_DSI_MODE_LPM | MIPI_DSI_MODE_EOT_PACKET | |
| 289 | MIPI_DSI_CLOCK_NON_CONTINUOUS; |
| 290 | } else { |
| 291 | if (read_edid_from_ps8640(&edid) < 0) |
| 292 | return; |
| 293 | |
| 294 | dual_dsi_mode = false; |
| 295 | mipi_dsi_flags = MIPI_DSI_MODE_VIDEO | |
| 296 | MIPI_DSI_MODE_VIDEO_SYNC_PULSE; |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 297 | } |
| 298 | |
Daniel Kurtz | 2332ada | 2017-04-20 12:30:00 +0800 | [diff] [blame] | 299 | edid_set_framebuffer_bits_per_pixel(&edid, 32, 0); |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 300 | |
Jitao Shi | b927fe1 | 2017-02-07 08:51:01 +0800 | [diff] [blame] | 301 | mtk_ddp_init(dual_dsi_mode); |
Daniel Kurtz | 8e055f8 | 2017-04-20 15:31:33 +0800 | [diff] [blame] | 302 | ret = mtk_dsi_init(mipi_dsi_flags, MIPI_DSI_FMT_RGB888, 4, |
| 303 | dual_dsi_mode, &edid); |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 304 | if (ret < 0) { |
| 305 | printk(BIOS_ERR, "dsi init fail\n"); |
| 306 | return; |
| 307 | } |
| 308 | |
Jitao Shi | b927fe1 | 2017-02-07 08:51:01 +0800 | [diff] [blame] | 309 | mtk_ddp_mode_set(&edid, dual_dsi_mode); |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 310 | |
| 311 | set_vbe_mode_info_valid(&edid, (uintptr_t)0); |
| 312 | } |
| 313 | |
Elyes HAOUAS | d129d43 | 2018-05-04 20:23:33 +0200 | [diff] [blame^] | 314 | static void mainboard_init(struct device *dev) |
Yidi Lin | 3d7b606 | 2015-07-31 17:10:40 +0800 | [diff] [blame] | 315 | { |
Ben Lok | a737940 | 2015-07-31 17:11:11 +0800 | [diff] [blame] | 316 | /* TP_SHIFT_EN: Enables the level shifter for I2C bus 4 (TPAD), which |
| 317 | * also contains the PS8640 eDP brige and the USB hub. |
| 318 | */ |
Julius Werner | 9a57095 | 2016-03-14 20:12:18 -0700 | [diff] [blame] | 319 | if (board_id() + CONFIG_BOARD_ID_ADJUSTMENT < 5) |
Yidi Lin | cd6aac1 | 2015-12-28 17:22:33 +0800 | [diff] [blame] | 320 | mt6391_gpio_output(MT6391_KP_ROW2, 1); |
Ben Lok | a737940 | 2015-07-31 17:11:11 +0800 | [diff] [blame] | 321 | |
Yidi Lin | b9b2c6f | 2015-11-13 16:21:48 +0800 | [diff] [blame] | 322 | /* Config SD card detection pin */ |
Julius Werner | d1e3b9b | 2017-03-10 14:25:48 -0800 | [diff] [blame] | 323 | gpio_input_pullup(PAD_EINT1); /* SD_DET */ |
Yidi Lin | b9b2c6f | 2015-11-13 16:21:48 +0800 | [diff] [blame] | 324 | |
Koro Chen | 9733ba5 | 2015-07-31 17:11:04 +0800 | [diff] [blame] | 325 | configure_audio(); |
Martin Roth | c7dfbe2 | 2016-07-22 11:15:12 -0600 | [diff] [blame] | 326 | |
| 327 | /* fix dsi lp mode is half voltage attenuation */ |
| 328 | mtk_dsi_pin_drv_ctrl(); |
| 329 | |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 330 | if (display_init_required()) { |
Daniel Kurtz | 8e055f8 | 2017-04-20 15:31:33 +0800 | [diff] [blame] | 331 | mtcmos_display_power_on(); |
Yidi Lin | 57debca | 2017-02-17 15:59:17 +0800 | [diff] [blame] | 332 | if (IS_ENABLED(CONFIG_BOARD_GOOGLE_ROWAN)) { |
Daniel Kurtz | 8e055f8 | 2017-04-20 15:31:33 +0800 | [diff] [blame] | 333 | configure_backlight_rowan(); |
| 334 | configure_display_rowan(); |
Yidi Lin | 57debca | 2017-02-17 15:59:17 +0800 | [diff] [blame] | 335 | } else { |
| 336 | configure_backlight(); |
| 337 | configure_display(); |
Yidi Lin | 57debca | 2017-02-17 15:59:17 +0800 | [diff] [blame] | 338 | } |
Daniel Kurtz | 8e055f8 | 2017-04-20 15:31:33 +0800 | [diff] [blame] | 339 | display_startup(); |
Jitao Shi | 4a04a7b | 2016-01-08 16:02:13 +0800 | [diff] [blame] | 340 | } else { |
| 341 | printk(BIOS_INFO, "Skipping display init.\n"); |
| 342 | } |
Ben Lok | a737940 | 2015-07-31 17:11:11 +0800 | [diff] [blame] | 343 | configure_usb(); |
Ben Lok | 7d7dc20 | 2016-01-08 13:10:34 +0800 | [diff] [blame] | 344 | configure_usb_hub(); |
henryc.chen | 316ded8 | 2016-03-11 14:55:30 +0800 | [diff] [blame] | 345 | configure_ext_buck(); |
YH Huang | 5d687ad | 2016-07-14 11:49:01 +0800 | [diff] [blame] | 346 | configure_touchscreen(); |
Yidi Lin | 3d7b606 | 2015-07-31 17:10:40 +0800 | [diff] [blame] | 347 | } |
| 348 | |
Elyes HAOUAS | d129d43 | 2018-05-04 20:23:33 +0200 | [diff] [blame^] | 349 | static void mainboard_enable(struct device *dev) |
Yidi Lin | 3d7b606 | 2015-07-31 17:10:40 +0800 | [diff] [blame] | 350 | { |
| 351 | dev->ops->init = &mainboard_init; |
| 352 | } |
| 353 | |
| 354 | struct chip_operations mainboard_ops = { |
| 355 | .name = "oak", |
| 356 | .enable_dev = mainboard_enable, |
| 357 | }; |