Ruihai Zhou | d5c1e13 | 2023-03-28 16:49:01 +0800 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
Ruihai Zhou | e811c9a | 2023-05-16 17:30:23 +0800 | [diff] [blame] | 3 | #include <console/console.h> |
Ruihai Zhou | d5c1e13 | 2023-03-28 16:49:01 +0800 | [diff] [blame] | 4 | #include <delay.h> |
| 5 | #include <gpio.h> |
| 6 | #include <soc/regulator.h> |
Ruihai Zhou | e811c9a | 2023-05-16 17:30:23 +0800 | [diff] [blame] | 7 | #include <soc/tps65132s.h> |
Ruihai Zhou | d5c1e13 | 2023-03-28 16:49:01 +0800 | [diff] [blame] | 8 | |
Ruihai Zhou | d5c1e13 | 2023-03-28 16:49:01 +0800 | [diff] [blame] | 9 | #include "gpio.h" |
Yidi Lin | cb7c4fd | 2024-01-02 17:33:00 +0800 | [diff] [blame] | 10 | #include "panel.h" |
Ruihai Zhou | d5c1e13 | 2023-03-28 16:49:01 +0800 | [diff] [blame] | 11 | |
| 12 | static void mipi_panel_power_on(void) |
| 13 | { |
Ruihai Zhou | e811c9a | 2023-05-16 17:30:23 +0800 | [diff] [blame] | 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 = { |
Ruihai Zhou | 266e655 | 2023-07-03 20:10:28 +0800 | [diff] [blame] | 21 | .i2c_bus = PMIC_I2C_BUS, |
Ruihai Zhou | e811c9a | 2023-05-16 17:30:23 +0800 | [diff] [blame] | 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 | |
Ruihai Zhou | d5c1e13 | 2023-03-28 16:49:01 +0800 | [diff] [blame] | 28 | mainboard_set_regulator_voltage(MTK_REGULATOR_VIO18, 1800000); |
Ruihai Zhou | 266e655 | 2023-07-03 20:10:28 +0800 | [diff] [blame] | 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); |
Cong Yang | 20a332a | 2023-09-28 11:40:50 +0800 | [diff] [blame] | 37 | mdelay(3); |
Ruihai Zhou | 266e655 | 2023-07-03 20:10:28 +0800 | [diff] [blame] | 38 | } else if (tps65132s_setup(&cfg) != CB_SUCCESS) { |
Ruihai Zhou | e811c9a | 2023-05-16 17:30:23 +0800 | [diff] [blame] | 39 | printk(BIOS_ERR, "Failed to setup tps65132s\n"); |
Ruihai Zhou | 266e655 | 2023-07-03 20:10:28 +0800 | [diff] [blame] | 40 | } |
Ruihai Zhou | e811c9a | 2023-05-16 17:30:23 +0800 | [diff] [blame] | 41 | |
Ruihai Zhou | d5c1e13 | 2023-03-28 16:49:01 +0800 | [diff] [blame] | 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[] = { |
Ruihai Zhou | 50c201a | 2023-05-26 11:15:59 +0800 | [diff] [blame] | 51 | /* K&D panel vendor and ILI9882T chip, |
| 52 | K&D and STA panel are identical except manufacturer_name. */ |
Ruihai Zhou | 060c7c7 | 2023-09-22 10:21:37 +0800 | [diff] [blame] | 53 | [6] = { |
Yidi Lin | cb7c4fd | 2024-01-02 17:33:00 +0800 | [diff] [blame] | 54 | .configure_backlight = backlight_control, |
Ruihai Zhou | 50c201a | 2023-05-26 11:15:59 +0800 | [diff] [blame] | 55 | .power_on = mipi_panel_power_on, |
| 56 | .name = "STA_ILI9882T", |
Yidi Lin | cb7c4fd | 2024-01-02 17:33:00 +0800 | [diff] [blame] | 57 | .disp_path = DISP_PATH_MIPI, |
Ruihai Zhou | 50c201a | 2023-05-26 11:15:59 +0800 | [diff] [blame] | 58 | .orientation = LB_FB_ORIENTATION_LEFT_UP, |
| 59 | }, |
| 60 | /* STA panel vendor and ILI9882T chip */ |
Ruihai Zhou | 060c7c7 | 2023-09-22 10:21:37 +0800 | [diff] [blame] | 61 | [9] = { |
Yidi Lin | cb7c4fd | 2024-01-02 17:33:00 +0800 | [diff] [blame] | 62 | .configure_backlight = backlight_control, |
Ruihai Zhou | d5c1e13 | 2023-03-28 16:49:01 +0800 | [diff] [blame] | 63 | .power_on = mipi_panel_power_on, |
| 64 | .name = "STA_ILI9882T", |
Yidi Lin | cb7c4fd | 2024-01-02 17:33:00 +0800 | [diff] [blame] | 65 | .disp_path = DISP_PATH_MIPI, |
Ruihai Zhou | d5c1e13 | 2023-03-28 16:49:01 +0800 | [diff] [blame] | 66 | .orientation = LB_FB_ORIENTATION_LEFT_UP, |
| 67 | }, |
Ruihai Zhou | 50c201a | 2023-05-26 11:15:59 +0800 | [diff] [blame] | 68 | /* STA panel vendor and HIMAX83102_J02 chip */ |
Ruihai Zhou | d5c1e13 | 2023-03-28 16:49:01 +0800 | [diff] [blame] | 69 | [10] = { |
Yidi Lin | cb7c4fd | 2024-01-02 17:33:00 +0800 | [diff] [blame] | 70 | .configure_backlight = backlight_control, |
Ruihai Zhou | d5c1e13 | 2023-03-28 16:49:01 +0800 | [diff] [blame] | 71 | .power_on = mipi_panel_power_on, |
| 72 | .name = "STA_HIMAX83102_J02", |
Yidi Lin | cb7c4fd | 2024-01-02 17:33:00 +0800 | [diff] [blame] | 73 | .disp_path = DISP_PATH_MIPI, |
Ruihai Zhou | d5c1e13 | 2023-03-28 16:49:01 +0800 | [diff] [blame] | 74 | .orientation = LB_FB_ORIENTATION_LEFT_UP, |
| 75 | }, |
| 76 | }; |
| 77 | |
| 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 | |
Yidi Lin | cb7c4fd | 2024-01-02 17:33:00 +0800 | [diff] [blame] | 84 | return &starmie_panels[id]; |
Ruihai Zhou | d5c1e13 | 2023-03-28 16:49:01 +0800 | [diff] [blame] | 85 | } |