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> |
| 6 | #include <edid.h> |
| 7 | #include <gpio.h> |
Ruihai Zhou | d3089a3 | 2023-11-07 16:29:50 +0800 | [diff] [blame] | 8 | #include <identity.h> |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 9 | #include <soc/gpio_common.h> |
| 10 | #include <string.h> |
| 11 | |
| 12 | #include "gpio.h" |
| 13 | #include "panel.h" |
| 14 | |
Ruihai Zhou | d3089a3 | 2023-11-07 16:29:50 +0800 | [diff] [blame] | 15 | struct panel_description __weak *get_panel_description(uint32_t panel_id) |
| 16 | { |
| 17 | printk(BIOS_WARNING, "%s: %s: the panel configuration is not ready\n", |
| 18 | __func__, mainboard_part_number); |
| 19 | return NULL; |
| 20 | } |
| 21 | |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 22 | struct panel_description *get_active_panel(void) |
| 23 | { |
| 24 | uint32_t active_panel_id = panel_id(); |
Yidi Lin | ba604b5 | 2024-01-03 16:07:24 +0800 | [diff] [blame^] | 25 | return get_panel_description(active_panel_id); |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 26 | } |
Ruihai Zhou | d3089a3 | 2023-11-07 16:29:50 +0800 | [diff] [blame] | 27 | |
| 28 | void configure_mipi_pwm_backlight(void) |
| 29 | { |
| 30 | gpio_output(GPIO_AP_DISP_BKLTEN, 0); |
| 31 | gpio_output(GPIO_MIPI_BL_PWM_1V8, 0); |
| 32 | } |
| 33 | |
| 34 | void fill_lp_backlight_gpios(struct lb_gpios *gpios) |
| 35 | { |
| 36 | struct panel_description *panel = get_active_panel(); |
| 37 | if (!panel || panel->disp_path == DISP_PATH_NONE) |
| 38 | return; |
| 39 | |
| 40 | struct lb_gpio mipi_pwm_gpios[] = { |
| 41 | {GPIO_MIPI_BL_PWM_1V8.id, ACTIVE_HIGH, -1, "PWM control"}, |
| 42 | }; |
| 43 | |
| 44 | struct lb_gpio edp_pwm_gpios[] = { |
| 45 | {GPIO_EDP_BL_PWM_1V8.id, ACTIVE_HIGH, -1, "PWM control"}, |
| 46 | }; |
| 47 | |
| 48 | if (panel->pwm_ctrl_gpio) { |
| 49 | /* PWM control for typical eDP and MIPI panels */ |
| 50 | if (panel->disp_path == DISP_PATH_MIPI) |
| 51 | lb_add_gpios(gpios, mipi_pwm_gpios, ARRAY_SIZE(mipi_pwm_gpios)); |
| 52 | else |
| 53 | lb_add_gpios(gpios, edp_pwm_gpios, ARRAY_SIZE(edp_pwm_gpios)); |
| 54 | } |
| 55 | |
| 56 | struct lb_gpio backlight_gpios[] = { |
| 57 | {GPIO_AP_DISP_BKLTEN.id, ACTIVE_HIGH, -1, "backlight enable"}, |
| 58 | }; |
| 59 | |
| 60 | lb_add_gpios(gpios, backlight_gpios, ARRAY_SIZE(backlight_gpios)); |
| 61 | } |