blob: 455f7591fedf4bcfcee5de4b91bb96d300b8f980 [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
Bo-Chen Chen817c6a72023-01-10 15:59:05 +080027static void power_on_mipi_boe_tv110c9m_ll0(void)
Bo-Chen Chen49465162022-11-30 14:47:41 +080028{
Ruihai Zhou4a604182023-05-29 20:27:06 +080029 const struct tps65132s_reg_setting reg_settings[] = {
30 { PMIC_TPS65132_VPOS, 0x11, 0x1f },
31 { PMIC_TPS65132_VNEG, 0x11, 0x1f },
32 { PMIC_TPS65132_DLYX, 0x95, 0xff },
33 { PMIC_TPS65132_ASSDD, 0x5b, 0xff },
34 };
35 const struct tps65132s_cfg cfg = {
36 .i2c_bus = PMIC_TPS65132_I2C,
37 .en = GPIO_EN_PPVAR_MIPI_DISP,
38 .sync = GPIO_EN_PPVAR_MIPI_DISP_150MA,
39 .settings = reg_settings,
40 .setting_counts = ARRAY_SIZE(reg_settings),
41 };
yangcong65384642023-03-02 20:59:30 +080042
Rex-BC Chend7b74602023-01-17 11:04:58 +080043 /* Enable VM18V */
44 mainboard_enable_regulator(MTK_REGULATOR_VDD18, true);
Ruihai Zhouffe2ced2023-07-07 16:48:24 +080045 mtk_i2c_bus_init(PMIC_TPS65132_I2C, I2C_SPEED_FAST);
46 mdelay(10);
Ruihai Zhou4a604182023-05-29 20:27:06 +080047 if (tps65132s_setup(&cfg) != CB_SUCCESS)
48 printk(BIOS_ERR, "Failed to set up voltage regulator tps65132s\n");
Rex-BC Chend7b74602023-01-17 11:04:58 +080049 gpio_output(GPIO_DISP_RST_1V8_L, 0);
50 mdelay(1);
Rex-BC Chend7b74602023-01-17 11:04:58 +080051 gpio_output(GPIO_DISP_RST_1V8_L, 1);
52 mdelay(1);
53 gpio_output(GPIO_DISP_RST_1V8_L, 0);
54 mdelay(1);
55 gpio_output(GPIO_DISP_RST_1V8_L, 1);
56 mdelay(6);
Bo-Chen Chen49465162022-11-30 14:47:41 +080057}
58
59static struct panel_description panels[] = {
60 [1] = {
Bo-Chen Chen817c6a72023-01-10 15:59:05 +080061 .name = "BOE_TV110C9M_LL0",
62 .power_on = power_on_mipi_boe_tv110c9m_ll0,
Bo-Chen Chen49465162022-11-30 14:47:41 +080063 .configure_panel_backlight = configure_mipi_pwm_backlight,
64 .disp_path = DISP_PATH_MIPI,
Bo-Chen Chenf57155b2022-12-07 19:09:57 +080065 .pwm_ctrl_gpio = true,
Bo-Chen Chen49465162022-11-30 14:47:41 +080066 },
Bo-Chen Chen49465162022-11-30 14:47:41 +080067};
68
69struct panel_description *get_panel_description(uint32_t panel_id)
70{
Yidi Lin0b192d32023-03-20 17:40:31 +080071 /* Only PANEL_ID_LOW_CHANNEL value is valid for the reference board. */
72 uint32_t id = panel_id & 0xF;
73
74 if (id >= ARRAY_SIZE(panels))
Bo-Chen Chen49465162022-11-30 14:47:41 +080075 return NULL;
76
Yidi Lin0b192d32023-03-20 17:40:31 +080077 return &panels[id];
Bo-Chen Chen49465162022-11-30 14:47:41 +080078}
Bo-Chen Chenf57155b2022-12-07 19:09:57 +080079
80void fill_lp_backlight_gpios(struct lb_gpios *gpios)
81{
82 struct panel_description *panel = get_active_panel();
83 if (!panel || panel->disp_path == DISP_PATH_NONE)
84 return;
85
86 struct lb_gpio mipi_pwm_gpios[] = {
Liju-Clr Chen26a8dea2022-12-15 13:40:41 +080087 {GPIO_MIPI_BL_PWM_1V8.id, ACTIVE_HIGH, -1, "PWM control"},
Bo-Chen Chenf57155b2022-12-07 19:09:57 +080088 };
89
90 struct lb_gpio edp_pwm_gpios[] = {
91 {GPIO_EDP_BL_PWM_1V8.id, ACTIVE_HIGH, -1, "PWM control"},
92 };
93
94 if (panel->pwm_ctrl_gpio) {
95 /* PWM control for typical eDP and MIPI panels */
96 if (panel->disp_path == DISP_PATH_MIPI)
97 lb_add_gpios(gpios, mipi_pwm_gpios, ARRAY_SIZE(mipi_pwm_gpios));
98 else
99 lb_add_gpios(gpios, edp_pwm_gpios, ARRAY_SIZE(edp_pwm_gpios));
100 }
101
102 struct lb_gpio backlight_gpios[] = {
103 {GPIO_AP_DISP_BKLTEN.id, ACTIVE_HIGH, -1, "backlight enable"},
104 };
105
106 lb_add_gpios(gpios, backlight_gpios, ARRAY_SIZE(backlight_gpios));
107}