blob: 202eda7b7df9c6d278f9da194ce33953d8a1809a [file] [log] [blame]
Bo-Chen Chen49465162022-11-30 14:47:41 +08001/* 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 Zhoud3089a32023-11-07 16:29:50 +08008#include <identity.h>
Bo-Chen Chen49465162022-11-30 14:47:41 +08009#include <soc/gpio_common.h>
10#include <string.h>
11
12#include "gpio.h"
13#include "panel.h"
14
Ruihai Zhoud3089a32023-11-07 16:29:50 +080015struct 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 Chen49465162022-11-30 14:47:41 +080022struct panel_description *get_active_panel(void)
23{
24 uint32_t active_panel_id = panel_id();
Yidi Linba604b52024-01-03 16:07:24 +080025 return get_panel_description(active_panel_id);
Bo-Chen Chen49465162022-11-30 14:47:41 +080026}
Ruihai Zhoud3089a32023-11-07 16:29:50 +080027
28void 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
34void 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}