blob: 443703d6f6bc2c60969dbdf521392f592dc56375 [file] [log] [blame]
Bo-Chen Chen49465162022-11-30 14:47:41 +08001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <boardid.h>
Bo-Chen Chenf57155b2022-12-07 19:09:57 +08004#include <boot/coreboot_tables.h>
Rex-BC Chend7b74602023-01-17 11:04:58 +08005#include <console/console.h>
6#include <delay.h>
Bo-Chen Chen49465162022-11-30 14:47:41 +08007#include <gpio.h>
8#include <soc/gpio_common.h>
Rex-BC Chend7b74602023-01-17 11:04:58 +08009#include <soc/i2c.h>
10#include <soc/regulator.h>
Ruihai Zhou4a604182023-05-29 20:27:06 +080011#include <soc/tps65132s.h>
Rex-BC Chend7b74602023-01-17 11:04:58 +080012#include <soc/pmif.h>
Bo-Chen Chen49465162022-11-30 14:47:41 +080013#include <string.h>
14
yangcong65384642023-03-02 20:59:30 +080015#include "display.h"
Bo-Chen Chen49465162022-11-30 14:47:41 +080016#include "gpio.h"
17#include "panel.h"
18
Ruihai Zhou4a604182023-05-29 20:27:06 +080019#define PMIC_TPS65132_I2C I2C3
Rex-BC Chend7b74602023-01-17 11:04:58 +080020
Bo-Chen Chen49465162022-11-30 14:47:41 +080021static void configure_mipi_pwm_backlight(void)
22{
23 gpio_output(GPIO_AP_DISP_BKLTEN, 0);
Liju-Clr Chen26a8dea2022-12-15 13:40:41 +080024 gpio_output(GPIO_MIPI_BL_PWM_1V8, 0);
Bo-Chen Chen49465162022-11-30 14:47:41 +080025}
26
Jianeng Ceng47a97972023-03-30 16:50:22 +080027static void configure_edp_backlight(void)
Bo-Chen Chenc07ccd92022-11-30 18:34:54 +080028{
Jianeng Ceng47a97972023-03-30 16:50:22 +080029 gpio_output(GPIO_AP_DISP_BKLTEN, 0);
Bo-Chen Chenc07ccd92022-11-30 18:34:54 +080030}
31
Bo-Chen Chen817c6a72023-01-10 15:59:05 +080032static void power_on_mipi_boe_tv110c9m_ll0(void)
Bo-Chen Chen49465162022-11-30 14:47:41 +080033{
Ruihai Zhou4a604182023-05-29 20:27:06 +080034 const struct tps65132s_reg_setting reg_settings[] = {
35 { PMIC_TPS65132_VPOS, 0x11, 0x1f },
36 { PMIC_TPS65132_VNEG, 0x11, 0x1f },
37 { PMIC_TPS65132_DLYX, 0x95, 0xff },
38 { PMIC_TPS65132_ASSDD, 0x5b, 0xff },
39 };
40 const struct tps65132s_cfg cfg = {
41 .i2c_bus = PMIC_TPS65132_I2C,
42 .en = GPIO_EN_PPVAR_MIPI_DISP,
43 .sync = GPIO_EN_PPVAR_MIPI_DISP_150MA,
44 .settings = reg_settings,
45 .setting_counts = ARRAY_SIZE(reg_settings),
46 };
yangcong65384642023-03-02 20:59:30 +080047
Rex-BC Chend7b74602023-01-17 11:04:58 +080048 /* Enable VM18V */
49 mainboard_enable_regulator(MTK_REGULATOR_VDD18, true);
Ruihai Zhouffe2ced2023-07-07 16:48:24 +080050 mtk_i2c_bus_init(PMIC_TPS65132_I2C, I2C_SPEED_FAST);
51 mdelay(10);
Ruihai Zhou4a604182023-05-29 20:27:06 +080052 if (tps65132s_setup(&cfg) != CB_SUCCESS)
53 printk(BIOS_ERR, "Failed to set up voltage regulator tps65132s\n");
Rex-BC Chend7b74602023-01-17 11:04:58 +080054 gpio_output(GPIO_DISP_RST_1V8_L, 0);
55 mdelay(1);
Rex-BC Chend7b74602023-01-17 11:04:58 +080056 gpio_output(GPIO_DISP_RST_1V8_L, 1);
57 mdelay(1);
58 gpio_output(GPIO_DISP_RST_1V8_L, 0);
59 mdelay(1);
60 gpio_output(GPIO_DISP_RST_1V8_L, 1);
61 mdelay(6);
Bo-Chen Chen49465162022-11-30 14:47:41 +080062}
63
Jianeng Ceng47a97972023-03-30 16:50:22 +080064static void power_on_edp_samsung_atana33xc20(void)
Bo-Chen Chenc07ccd92022-11-30 18:34:54 +080065{
Jianeng Ceng47a97972023-03-30 16:50:22 +080066 gpio_output(GPIO_EN_PP3300_EDP_DISP_X, 1);
67 gpio_set_pull(GPIO_EDP_HPD_1V8, GPIO_PULL_ENABLE, GPIO_PULL_UP);
68 gpio_set_mode(GPIO_EDP_HPD_1V8, 4);
Bo-Chen Chenc07ccd92022-11-30 18:34:54 +080069}
70
Bo-Chen Chen49465162022-11-30 14:47:41 +080071static struct panel_description panels[] = {
72 [1] = {
Bo-Chen Chen817c6a72023-01-10 15:59:05 +080073 .name = "BOE_TV110C9M_LL0",
74 .power_on = power_on_mipi_boe_tv110c9m_ll0,
Bo-Chen Chen49465162022-11-30 14:47:41 +080075 .configure_panel_backlight = configure_mipi_pwm_backlight,
76 .disp_path = DISP_PATH_MIPI,
Bo-Chen Chenf57155b2022-12-07 19:09:57 +080077 .pwm_ctrl_gpio = true,
Bo-Chen Chen49465162022-11-30 14:47:41 +080078 },
Bo-Chen Chenc07ccd92022-11-30 18:34:54 +080079 [11] = {
Jianeng Ceng47a97972023-03-30 16:50:22 +080080 .name = "SAMSUNG_ATANA33XC20",
81 .power_on = power_on_edp_samsung_atana33xc20,
82 .configure_panel_backlight = configure_edp_backlight,
Bo-Chen Chenc07ccd92022-11-30 18:34:54 +080083 .disp_path = DISP_PATH_EDP,
Bo-Chen Chenf57155b2022-12-07 19:09:57 +080084 .pwm_ctrl_gpio = false,
Bo-Chen Chenc07ccd92022-11-30 18:34:54 +080085 },
Bo-Chen Chen49465162022-11-30 14:47:41 +080086};
87
88struct panel_description *get_panel_description(uint32_t panel_id)
89{
Yidi Lin0b192d32023-03-20 17:40:31 +080090 /* Only PANEL_ID_LOW_CHANNEL value is valid for the reference board. */
91 uint32_t id = panel_id & 0xF;
92
93 if (id >= ARRAY_SIZE(panels))
Bo-Chen Chen49465162022-11-30 14:47:41 +080094 return NULL;
95
Yidi Lin0b192d32023-03-20 17:40:31 +080096 return &panels[id];
Bo-Chen Chen49465162022-11-30 14:47:41 +080097}
Bo-Chen Chenf57155b2022-12-07 19:09:57 +080098
99void fill_lp_backlight_gpios(struct lb_gpios *gpios)
100{
101 struct panel_description *panel = get_active_panel();
102 if (!panel || panel->disp_path == DISP_PATH_NONE)
103 return;
104
105 struct lb_gpio mipi_pwm_gpios[] = {
Liju-Clr Chen26a8dea2022-12-15 13:40:41 +0800106 {GPIO_MIPI_BL_PWM_1V8.id, ACTIVE_HIGH, -1, "PWM control"},
Bo-Chen Chenf57155b2022-12-07 19:09:57 +0800107 };
108
109 struct lb_gpio edp_pwm_gpios[] = {
110 {GPIO_EDP_BL_PWM_1V8.id, ACTIVE_HIGH, -1, "PWM control"},
111 };
112
113 if (panel->pwm_ctrl_gpio) {
114 /* PWM control for typical eDP and MIPI panels */
115 if (panel->disp_path == DISP_PATH_MIPI)
116 lb_add_gpios(gpios, mipi_pwm_gpios, ARRAY_SIZE(mipi_pwm_gpios));
117 else
118 lb_add_gpios(gpios, edp_pwm_gpios, ARRAY_SIZE(edp_pwm_gpios));
119 }
120
121 struct lb_gpio backlight_gpios[] = {
122 {GPIO_AP_DISP_BKLTEN.id, ACTIVE_HIGH, -1, "backlight enable"},
123 };
124
125 lb_add_gpios(gpios, backlight_gpios, ARRAY_SIZE(backlight_gpios));
126}