blob: 1de2c61a08387fbffd5a355a6645bcdf0a9bf430 [file] [log] [blame]
Ruihai Zhoud5c1e132023-03-28 16:49:01 +08001/* SPDX-License-Identifier: GPL-2.0-only */
2
Ruihai Zhoue811c9a2023-05-16 17:30:23 +08003#include <console/console.h>
Ruihai Zhoud5c1e132023-03-28 16:49:01 +08004#include <delay.h>
5#include <gpio.h>
6#include <soc/regulator.h>
Ruihai Zhoue811c9a2023-05-16 17:30:23 +08007#include <soc/tps65132s.h>
Ruihai Zhoud5c1e132023-03-28 16:49:01 +08008
Ruihai Zhoud5c1e132023-03-28 16:49:01 +08009#include "gpio.h"
Yidi Lincb7c4fd2024-01-02 17:33:00 +080010#include "panel.h"
Ruihai Zhoud5c1e132023-03-28 16:49:01 +080011
12static void mipi_panel_power_on(void)
13{
Ruihai Zhoue811c9a2023-05-16 17:30:23 +080014 const struct tps65132s_reg_setting reg_settings[] = {
15 { PMIC_TPS65132_VPOS, 0x14, 0x1F },
16 { PMIC_TPS65132_VNEG, 0x14, 0x1F },
17 { PMIC_TPS65132_DLYX, 0x95, 0xFF },
18 { PMIC_TPS65132_ASSDD, 0x5b, 0xFF },
19 };
20 const struct tps65132s_cfg cfg = {
Ruihai Zhou266e6552023-07-03 20:10:28 +080021 .i2c_bus = PMIC_I2C_BUS,
Ruihai Zhoue811c9a2023-05-16 17:30:23 +080022 .en = GPIO_EN_PP3300_DISP_X,
23 .sync = GPIO_EN_PP3300_SDBRDG_X,
24 .settings = reg_settings,
25 .setting_counts = ARRAY_SIZE(reg_settings),
26 };
27
Ruihai Zhoud5c1e132023-03-28 16:49:01 +080028 mainboard_set_regulator_voltage(MTK_REGULATOR_VIO18, 1800000);
Ruihai Zhou266e6552023-07-03 20:10:28 +080029 mtk_i2c_bus_init(PMIC_I2C_BUS, I2C_SPEED_FAST);
30
31 if (is_pmic_aw37503(PMIC_I2C_BUS)) {
32 printk(BIOS_DEBUG, "Initialize and power on PMIC AW37503\n");
33 aw37503_init(PMIC_I2C_BUS);
34 gpio_output(GPIO_EN_PP3300_DISP_X, 1);
35 mdelay(2);
36 gpio_output(GPIO_EN_PP3300_SDBRDG_X, 1);
Cong Yang20a332a2023-09-28 11:40:50 +080037 mdelay(3);
Ruihai Zhou266e6552023-07-03 20:10:28 +080038 } else if (tps65132s_setup(&cfg) != CB_SUCCESS) {
Ruihai Zhoue811c9a2023-05-16 17:30:23 +080039 printk(BIOS_ERR, "Failed to setup tps65132s\n");
Ruihai Zhou266e6552023-07-03 20:10:28 +080040 }
Ruihai Zhoue811c9a2023-05-16 17:30:23 +080041
Ruihai Zhoud5c1e132023-03-28 16:49:01 +080042 /* DISP_RST_1V8_L */
43 gpio_output(GPIO_EDPBRDG_RST_L, 1);
44 mdelay(1);
45 gpio_output(GPIO_EDPBRDG_RST_L, 0);
46 udelay(20);
47 gpio_output(GPIO_EDPBRDG_RST_L, 1);
48}
49
50static struct panel_description starmie_panels[] = {
Ruihai Zhou50c201a2023-05-26 11:15:59 +080051 /* K&D panel vendor and ILI9882T chip,
52 K&D and STA panel are identical except manufacturer_name. */
Ruihai Zhou060c7c72023-09-22 10:21:37 +080053 [6] = {
Yidi Lincb7c4fd2024-01-02 17:33:00 +080054 .configure_backlight = backlight_control,
Ruihai Zhou50c201a2023-05-26 11:15:59 +080055 .power_on = mipi_panel_power_on,
56 .name = "STA_ILI9882T",
Yidi Lincb7c4fd2024-01-02 17:33:00 +080057 .disp_path = DISP_PATH_MIPI,
Ruihai Zhou50c201a2023-05-26 11:15:59 +080058 .orientation = LB_FB_ORIENTATION_LEFT_UP,
59 },
60 /* STA panel vendor and ILI9882T chip */
Ruihai Zhou060c7c72023-09-22 10:21:37 +080061 [9] = {
Yidi Lincb7c4fd2024-01-02 17:33:00 +080062 .configure_backlight = backlight_control,
Ruihai Zhoud5c1e132023-03-28 16:49:01 +080063 .power_on = mipi_panel_power_on,
64 .name = "STA_ILI9882T",
Yidi Lincb7c4fd2024-01-02 17:33:00 +080065 .disp_path = DISP_PATH_MIPI,
Ruihai Zhoud5c1e132023-03-28 16:49:01 +080066 .orientation = LB_FB_ORIENTATION_LEFT_UP,
67 },
Ruihai Zhou50c201a2023-05-26 11:15:59 +080068 /* STA panel vendor and HIMAX83102_J02 chip */
Ruihai Zhoud5c1e132023-03-28 16:49:01 +080069 [10] = {
Yidi Lincb7c4fd2024-01-02 17:33:00 +080070 .configure_backlight = backlight_control,
Ruihai Zhoud5c1e132023-03-28 16:49:01 +080071 .power_on = mipi_panel_power_on,
72 .name = "STA_HIMAX83102_J02",
Yidi Lincb7c4fd2024-01-02 17:33:00 +080073 .disp_path = DISP_PATH_MIPI,
Ruihai Zhoud5c1e132023-03-28 16:49:01 +080074 .orientation = LB_FB_ORIENTATION_LEFT_UP,
75 },
76};
77
78struct panel_description *get_panel_description(void)
79{
80 uint32_t id = panel_id() & 0xF;
81 if (id >= ARRAY_SIZE(starmie_panels))
82 return NULL;
83
Yidi Lincb7c4fd2024-01-02 17:33:00 +080084 return &starmie_panels[id];
Ruihai Zhoud5c1e132023-03-28 16:49:01 +080085}