blob: 6eed3fb122377c2ce03b37cf61c939ef7605e08f [file] [log] [blame]
Bo-Chen Chen49465162022-11-30 14:47:41 +08001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <boardid.h>
Rex-BC Chend7b74602023-01-17 11:04:58 +08004#include <console/console.h>
5#include <delay.h>
Bo-Chen Chen49465162022-11-30 14:47:41 +08006#include <gpio.h>
7#include <soc/gpio_common.h>
Rex-BC Chend7b74602023-01-17 11:04:58 +08008#include <soc/i2c.h>
9#include <soc/regulator.h>
Ruihai Zhou4a604182023-05-29 20:27:06 +080010#include <soc/tps65132s.h>
Rex-BC Chend7b74602023-01-17 11:04:58 +080011#include <soc/pmif.h>
Bo-Chen Chen49465162022-11-30 14:47:41 +080012#include <string.h>
13
14#include "gpio.h"
15#include "panel.h"
16
Ruihai Zhou4a604182023-05-29 20:27:06 +080017#define PMIC_TPS65132_I2C I2C3
Rex-BC Chend7b74602023-01-17 11:04:58 +080018
Bo-Chen Chen817c6a72023-01-10 15:59:05 +080019static void power_on_mipi_boe_tv110c9m_ll0(void)
Bo-Chen Chen49465162022-11-30 14:47:41 +080020{
Ruihai Zhou4a604182023-05-29 20:27:06 +080021 const struct tps65132s_reg_setting reg_settings[] = {
22 { PMIC_TPS65132_VPOS, 0x11, 0x1f },
23 { PMIC_TPS65132_VNEG, 0x11, 0x1f },
24 { PMIC_TPS65132_DLYX, 0x95, 0xff },
25 { PMIC_TPS65132_ASSDD, 0x5b, 0xff },
26 };
27 const struct tps65132s_cfg cfg = {
28 .i2c_bus = PMIC_TPS65132_I2C,
29 .en = GPIO_EN_PPVAR_MIPI_DISP,
30 .sync = GPIO_EN_PPVAR_MIPI_DISP_150MA,
31 .settings = reg_settings,
32 .setting_counts = ARRAY_SIZE(reg_settings),
33 };
yangcong65384642023-03-02 20:59:30 +080034
Rex-BC Chend7b74602023-01-17 11:04:58 +080035 /* Enable VM18V */
36 mainboard_enable_regulator(MTK_REGULATOR_VDD18, true);
Ruihai Zhouffe2ced2023-07-07 16:48:24 +080037 mtk_i2c_bus_init(PMIC_TPS65132_I2C, I2C_SPEED_FAST);
38 mdelay(10);
Ruihai Zhou4a604182023-05-29 20:27:06 +080039 if (tps65132s_setup(&cfg) != CB_SUCCESS)
40 printk(BIOS_ERR, "Failed to set up voltage regulator tps65132s\n");
Rex-BC Chend7b74602023-01-17 11:04:58 +080041 gpio_output(GPIO_DISP_RST_1V8_L, 0);
42 mdelay(1);
Rex-BC Chend7b74602023-01-17 11:04:58 +080043 gpio_output(GPIO_DISP_RST_1V8_L, 1);
44 mdelay(1);
45 gpio_output(GPIO_DISP_RST_1V8_L, 0);
46 mdelay(1);
47 gpio_output(GPIO_DISP_RST_1V8_L, 1);
48 mdelay(6);
Bo-Chen Chen49465162022-11-30 14:47:41 +080049}
50
51static struct panel_description panels[] = {
52 [1] = {
Bo-Chen Chen817c6a72023-01-10 15:59:05 +080053 .name = "BOE_TV110C9M_LL0",
54 .power_on = power_on_mipi_boe_tv110c9m_ll0,
Yidi Linba604b52024-01-03 16:07:24 +080055 .configure_backlight = configure_mipi_pwm_backlight,
56 .orientation = LB_FB_ORIENTATION_BOTTOM_UP,
Bo-Chen Chen49465162022-11-30 14:47:41 +080057 .disp_path = DISP_PATH_MIPI,
Bo-Chen Chenf57155b2022-12-07 19:09:57 +080058 .pwm_ctrl_gpio = true,
Bo-Chen Chen49465162022-11-30 14:47:41 +080059 },
Bo-Chen Chen49465162022-11-30 14:47:41 +080060};
61
62struct panel_description *get_panel_description(uint32_t panel_id)
63{
Yidi Lin0b192d32023-03-20 17:40:31 +080064 /* Only PANEL_ID_LOW_CHANNEL value is valid for the reference board. */
65 uint32_t id = panel_id & 0xF;
66
67 if (id >= ARRAY_SIZE(panels))
Bo-Chen Chen49465162022-11-30 14:47:41 +080068 return NULL;
69
Yidi Lin0b192d32023-03-20 17:40:31 +080070 return &panels[id];
Bo-Chen Chen49465162022-11-30 14:47:41 +080071}