Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <boardid.h> |
Bo-Chen Chen | f57155b | 2022-12-07 19:09:57 +0800 | [diff] [blame] | 4 | #include <boot/coreboot_tables.h> |
Rex-BC Chen | d7b7460 | 2023-01-17 11:04:58 +0800 | [diff] [blame] | 5 | #include <console/console.h> |
| 6 | #include <delay.h> |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 7 | #include <gpio.h> |
| 8 | #include <soc/gpio_common.h> |
Rex-BC Chen | d7b7460 | 2023-01-17 11:04:58 +0800 | [diff] [blame] | 9 | #include <soc/i2c.h> |
| 10 | #include <soc/regulator.h> |
Ruihai Zhou | 4a60418 | 2023-05-29 20:27:06 +0800 | [diff] [blame] | 11 | #include <soc/tps65132s.h> |
Rex-BC Chen | d7b7460 | 2023-01-17 11:04:58 +0800 | [diff] [blame] | 12 | #include <soc/pmif.h> |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 13 | #include <string.h> |
| 14 | |
yangcong | 6538464 | 2023-03-02 20:59:30 +0800 | [diff] [blame] | 15 | #include "display.h" |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 16 | #include "gpio.h" |
| 17 | #include "panel.h" |
| 18 | |
Ruihai Zhou | 4a60418 | 2023-05-29 20:27:06 +0800 | [diff] [blame] | 19 | #define PMIC_TPS65132_I2C I2C3 |
Rex-BC Chen | d7b7460 | 2023-01-17 11:04:58 +0800 | [diff] [blame] | 20 | |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 21 | static void configure_mipi_pwm_backlight(void) |
| 22 | { |
| 23 | gpio_output(GPIO_AP_DISP_BKLTEN, 0); |
Liju-Clr Chen | 26a8dea | 2022-12-15 13:40:41 +0800 | [diff] [blame] | 24 | gpio_output(GPIO_MIPI_BL_PWM_1V8, 0); |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 25 | } |
| 26 | |
Bo-Chen Chen | 817c6a7 | 2023-01-10 15:59:05 +0800 | [diff] [blame] | 27 | static void power_on_mipi_boe_tv110c9m_ll0(void) |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 28 | { |
Ruihai Zhou | 4a60418 | 2023-05-29 20:27:06 +0800 | [diff] [blame] | 29 | 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 | }; |
yangcong | 6538464 | 2023-03-02 20:59:30 +0800 | [diff] [blame] | 42 | |
Rex-BC Chen | d7b7460 | 2023-01-17 11:04:58 +0800 | [diff] [blame] | 43 | /* Enable VM18V */ |
| 44 | mainboard_enable_regulator(MTK_REGULATOR_VDD18, true); |
Ruihai Zhou | ffe2ced | 2023-07-07 16:48:24 +0800 | [diff] [blame] | 45 | mtk_i2c_bus_init(PMIC_TPS65132_I2C, I2C_SPEED_FAST); |
| 46 | mdelay(10); |
Ruihai Zhou | 4a60418 | 2023-05-29 20:27:06 +0800 | [diff] [blame] | 47 | if (tps65132s_setup(&cfg) != CB_SUCCESS) |
| 48 | printk(BIOS_ERR, "Failed to set up voltage regulator tps65132s\n"); |
Rex-BC Chen | d7b7460 | 2023-01-17 11:04:58 +0800 | [diff] [blame] | 49 | gpio_output(GPIO_DISP_RST_1V8_L, 0); |
| 50 | mdelay(1); |
Rex-BC Chen | d7b7460 | 2023-01-17 11:04:58 +0800 | [diff] [blame] | 51 | 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 Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | static struct panel_description panels[] = { |
| 60 | [1] = { |
Bo-Chen Chen | 817c6a7 | 2023-01-10 15:59:05 +0800 | [diff] [blame] | 61 | .name = "BOE_TV110C9M_LL0", |
| 62 | .power_on = power_on_mipi_boe_tv110c9m_ll0, |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 63 | .configure_panel_backlight = configure_mipi_pwm_backlight, |
| 64 | .disp_path = DISP_PATH_MIPI, |
Bo-Chen Chen | f57155b | 2022-12-07 19:09:57 +0800 | [diff] [blame] | 65 | .pwm_ctrl_gpio = true, |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 66 | }, |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | struct panel_description *get_panel_description(uint32_t panel_id) |
| 70 | { |
Yidi Lin | 0b192d3 | 2023-03-20 17:40:31 +0800 | [diff] [blame] | 71 | /* 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 Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 75 | return NULL; |
| 76 | |
Yidi Lin | 0b192d3 | 2023-03-20 17:40:31 +0800 | [diff] [blame] | 77 | return &panels[id]; |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 78 | } |
Bo-Chen Chen | f57155b | 2022-12-07 19:09:57 +0800 | [diff] [blame] | 79 | |
| 80 | void 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 Chen | 26a8dea | 2022-12-15 13:40:41 +0800 | [diff] [blame] | 87 | {GPIO_MIPI_BL_PWM_1V8.id, ACTIVE_HIGH, -1, "PWM control"}, |
Bo-Chen Chen | f57155b | 2022-12-07 19:09:57 +0800 | [diff] [blame] | 88 | }; |
| 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 | } |