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> |
| 4 | #include <cbfs.h> |
| 5 | #include <console/console.h> |
Ruihai Zhou | d4b6b81 | 2023-11-08 09:11:34 +0800 | [diff] [blame^] | 6 | #include <delay.h> |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 7 | #include <edid.h> |
| 8 | #include <gpio.h> |
Ruihai Zhou | d3089a3 | 2023-11-07 16:29:50 +0800 | [diff] [blame] | 9 | #include <identity.h> |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 10 | #include <soc/gpio_common.h> |
Ruihai Zhou | d4b6b81 | 2023-11-08 09:11:34 +0800 | [diff] [blame^] | 11 | #include <soc/i2c.h> |
| 12 | #include <soc/pmif.h> |
| 13 | #include <soc/regulator.h> |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 14 | #include <string.h> |
| 15 | |
| 16 | #include "gpio.h" |
| 17 | #include "panel.h" |
| 18 | |
Ruihai Zhou | d3089a3 | 2023-11-07 16:29:50 +0800 | [diff] [blame] | 19 | struct panel_description __weak *get_panel_description(uint32_t panel_id) |
| 20 | { |
| 21 | printk(BIOS_WARNING, "%s: %s: the panel configuration is not ready\n", |
| 22 | __func__, mainboard_part_number); |
| 23 | return NULL; |
| 24 | } |
| 25 | |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 26 | struct panel_description *get_active_panel(void) |
| 27 | { |
| 28 | uint32_t active_panel_id = panel_id(); |
Yidi Lin | ba604b5 | 2024-01-03 16:07:24 +0800 | [diff] [blame] | 29 | return get_panel_description(active_panel_id); |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 30 | } |
Ruihai Zhou | d3089a3 | 2023-11-07 16:29:50 +0800 | [diff] [blame] | 31 | |
| 32 | void configure_mipi_pwm_backlight(void) |
| 33 | { |
| 34 | gpio_output(GPIO_AP_DISP_BKLTEN, 0); |
| 35 | gpio_output(GPIO_MIPI_BL_PWM_1V8, 0); |
| 36 | } |
| 37 | |
| 38 | void fill_lp_backlight_gpios(struct lb_gpios *gpios) |
| 39 | { |
| 40 | struct panel_description *panel = get_active_panel(); |
| 41 | if (!panel || panel->disp_path == DISP_PATH_NONE) |
| 42 | return; |
| 43 | |
| 44 | struct lb_gpio mipi_pwm_gpios[] = { |
| 45 | {GPIO_MIPI_BL_PWM_1V8.id, ACTIVE_HIGH, -1, "PWM control"}, |
| 46 | }; |
| 47 | |
| 48 | struct lb_gpio edp_pwm_gpios[] = { |
| 49 | {GPIO_EDP_BL_PWM_1V8.id, ACTIVE_HIGH, -1, "PWM control"}, |
| 50 | }; |
| 51 | |
| 52 | if (panel->pwm_ctrl_gpio) { |
| 53 | /* PWM control for typical eDP and MIPI panels */ |
| 54 | if (panel->disp_path == DISP_PATH_MIPI) |
| 55 | lb_add_gpios(gpios, mipi_pwm_gpios, ARRAY_SIZE(mipi_pwm_gpios)); |
| 56 | else |
| 57 | lb_add_gpios(gpios, edp_pwm_gpios, ARRAY_SIZE(edp_pwm_gpios)); |
| 58 | } |
| 59 | |
| 60 | struct lb_gpio backlight_gpios[] = { |
| 61 | {GPIO_AP_DISP_BKLTEN.id, ACTIVE_HIGH, -1, "backlight enable"}, |
| 62 | }; |
| 63 | |
| 64 | lb_add_gpios(gpios, backlight_gpios, ARRAY_SIZE(backlight_gpios)); |
| 65 | } |
Ruihai Zhou | d4b6b81 | 2023-11-08 09:11:34 +0800 | [diff] [blame^] | 66 | |
| 67 | void power_on_mipi_panel(const struct tps65132s_cfg *cfg) |
| 68 | { |
| 69 | mtk_i2c_bus_init(cfg->i2c_bus, I2C_SPEED_FAST); |
| 70 | |
| 71 | /* Enable VM18V */ |
| 72 | mainboard_enable_regulator(MTK_REGULATOR_VDD18, true); |
| 73 | mdelay(2); |
| 74 | if (tps65132s_setup(cfg) != CB_SUCCESS) |
| 75 | printk(BIOS_ERR, "Failed to set up voltage regulator tps65132s\n"); |
| 76 | gpio_output(GPIO_DISP_RST_1V8_L, 0); |
| 77 | mdelay(1); |
| 78 | gpio_output(GPIO_DISP_RST_1V8_L, 1); |
| 79 | mdelay(1); |
| 80 | gpio_output(GPIO_DISP_RST_1V8_L, 0); |
| 81 | mdelay(1); |
| 82 | gpio_output(GPIO_DISP_RST_1V8_L, 1); |
| 83 | mdelay(6); |
| 84 | } |