xref: /aosp_15_r20/external/coreboot/src/mainboard/google/corsola/panel_starmie.c (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <console/console.h>
4 #include <delay.h>
5 #include <gpio.h>
6 #include <soc/regulator.h>
7 #include <soc/tps65132s.h>
8 
9 #include "gpio.h"
10 #include "panel.h"
11 
mipi_panel_power_on(void)12 static void mipi_panel_power_on(void)
13 {
14 	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 = {
21 		.i2c_bus = PMIC_I2C_BUS,
22 		.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 
28 	mainboard_set_regulator_voltage(MTK_REGULATOR_VIO18, 1800000);
29 	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);
37 		mdelay(3);
38 	} else if (tps65132s_setup(&cfg) != CB_SUCCESS) {
39 		printk(BIOS_ERR, "Failed to setup tps65132s\n");
40 	}
41 
42 	/* 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 
50 static struct panel_description starmie_panels[] = {
51 	/* K&D panel vendor and ILI9882T chip,
52 	   K&D and STA panel are identical except manufacturer_name. */
53 	[6] = {
54 		.configure_backlight = backlight_control,
55 		.power_on = mipi_panel_power_on,
56 		.name = "STA_ILI9882T",
57 		.disp_path = DISP_PATH_MIPI,
58 		.orientation = LB_FB_ORIENTATION_LEFT_UP,
59 	},
60 	/* STA panel vendor and ILI9882T chip */
61 	[9] = {
62 		.configure_backlight = backlight_control,
63 		.power_on = mipi_panel_power_on,
64 		.name = "STA_ILI9882T",
65 		.disp_path = DISP_PATH_MIPI,
66 		.orientation = LB_FB_ORIENTATION_LEFT_UP,
67 	},
68 	/* STA panel vendor and HIMAX83102_J02 chip */
69 	[10] = {
70 		.configure_backlight = backlight_control,
71 		.power_on = mipi_panel_power_on,
72 		.name = "STA_HIMAX83102_J02",
73 		.disp_path = DISP_PATH_MIPI,
74 		.orientation = LB_FB_ORIENTATION_LEFT_UP,
75 	},
76 };
77 
get_panel_description(void)78 struct 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 
84 	return &starmie_panels[id];
85 }
86