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> |
| 11 | #include <soc/pmif.h> |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 12 | #include <string.h> |
| 13 | |
yangcong | 6538464 | 2023-03-02 20:59:30 +0800 | [diff] [blame^] | 14 | #include "display.h" |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 15 | #include "gpio.h" |
| 16 | #include "panel.h" |
| 17 | |
Rex-BC Chen | d7b7460 | 2023-01-17 11:04:58 +0800 | [diff] [blame] | 18 | |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 19 | static void configure_mipi_pwm_backlight(void) |
| 20 | { |
| 21 | gpio_output(GPIO_AP_DISP_BKLTEN, 0); |
Liju-Clr Chen | 26a8dea | 2022-12-15 13:40:41 +0800 | [diff] [blame] | 22 | gpio_output(GPIO_MIPI_BL_PWM_1V8, 0); |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 23 | } |
| 24 | |
Bo-Chen Chen | c07ccd9 | 2022-11-30 18:34:54 +0800 | [diff] [blame] | 25 | static void configure_edp_aux_backlight(void) |
| 26 | { |
| 27 | /* TODO: Add edp aux backlight for MUTTO_B152731E1 when we get MUTTO_B152731E1 */ |
| 28 | } |
| 29 | |
Bo-Chen Chen | 817c6a7 | 2023-01-10 15:59:05 +0800 | [diff] [blame] | 30 | static void power_on_mipi_boe_tv110c9m_ll0(void) |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 31 | { |
yangcong | 6538464 | 2023-03-02 20:59:30 +0800 | [diff] [blame^] | 32 | tps65132s_program_eeprom(); |
| 33 | |
Rex-BC Chen | d7b7460 | 2023-01-17 11:04:58 +0800 | [diff] [blame] | 34 | /* Enable VM18V */ |
| 35 | mainboard_enable_regulator(MTK_REGULATOR_VDD18, true); |
| 36 | |
Rex-BC Chen | d7b7460 | 2023-01-17 11:04:58 +0800 | [diff] [blame] | 37 | gpio_output(GPIO_DISP_RST_1V8_L, 0); |
| 38 | mdelay(1); |
| 39 | |
| 40 | gpio_output(GPIO_EN_PPVAR_MIPI_DISP, 1); |
| 41 | gpio_output(GPIO_EN_PPVAR_MIPI_DISP_150MA, 1); |
| 42 | mdelay(10); |
Rex-BC Chen | d7b7460 | 2023-01-17 11:04:58 +0800 | [diff] [blame] | 43 | gpio_output(GPIO_DISP_RST_1V8_L, 1); |
| 44 | mdelay(1); |
| 45 | gpio_output(GPIO_DISP_RST_1V8_L, 0); |
| 46 | mdelay(1); |
| 47 | gpio_output(GPIO_DISP_RST_1V8_L, 1); |
| 48 | mdelay(6); |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 49 | } |
| 50 | |
Bo-Chen Chen | c07ccd9 | 2022-11-30 18:34:54 +0800 | [diff] [blame] | 51 | static void power_on_edp_mutto_b152731e1(void) |
| 52 | { |
| 53 | /* TODO: Add the poweron for MUTTO_B152731E1 when we get MUTTO_B152731E1 */ |
| 54 | } |
| 55 | |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 56 | static struct panel_description panels[] = { |
| 57 | [1] = { |
Bo-Chen Chen | 817c6a7 | 2023-01-10 15:59:05 +0800 | [diff] [blame] | 58 | .name = "BOE_TV110C9M_LL0", |
| 59 | .power_on = power_on_mipi_boe_tv110c9m_ll0, |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 60 | .configure_panel_backlight = configure_mipi_pwm_backlight, |
| 61 | .disp_path = DISP_PATH_MIPI, |
Bo-Chen Chen | f57155b | 2022-12-07 19:09:57 +0800 | [diff] [blame] | 62 | .pwm_ctrl_gpio = true, |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 63 | }, |
Bo-Chen Chen | c07ccd9 | 2022-11-30 18:34:54 +0800 | [diff] [blame] | 64 | [11] = { |
| 65 | .name = "MUTTO_B152731E1", |
| 66 | .power_on = power_on_edp_mutto_b152731e1, |
| 67 | .configure_panel_backlight = configure_edp_aux_backlight, |
| 68 | .disp_path = DISP_PATH_EDP, |
Bo-Chen Chen | f57155b | 2022-12-07 19:09:57 +0800 | [diff] [blame] | 69 | .pwm_ctrl_gpio = false, |
Bo-Chen Chen | c07ccd9 | 2022-11-30 18:34:54 +0800 | [diff] [blame] | 70 | }, |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | struct panel_description *get_panel_description(uint32_t panel_id) |
| 74 | { |
| 75 | if (panel_id >= ARRAY_SIZE(panels)) |
| 76 | return NULL; |
| 77 | |
| 78 | return &panels[panel_id]; |
| 79 | } |
Bo-Chen Chen | f57155b | 2022-12-07 19:09:57 +0800 | [diff] [blame] | 80 | |
| 81 | void fill_lp_backlight_gpios(struct lb_gpios *gpios) |
| 82 | { |
| 83 | struct panel_description *panel = get_active_panel(); |
| 84 | if (!panel || panel->disp_path == DISP_PATH_NONE) |
| 85 | return; |
| 86 | |
| 87 | struct lb_gpio mipi_pwm_gpios[] = { |
Liju-Clr Chen | 26a8dea | 2022-12-15 13:40:41 +0800 | [diff] [blame] | 88 | {GPIO_MIPI_BL_PWM_1V8.id, ACTIVE_HIGH, -1, "PWM control"}, |
Bo-Chen Chen | f57155b | 2022-12-07 19:09:57 +0800 | [diff] [blame] | 89 | }; |
| 90 | |
| 91 | struct lb_gpio edp_pwm_gpios[] = { |
| 92 | {GPIO_EDP_BL_PWM_1V8.id, ACTIVE_HIGH, -1, "PWM control"}, |
| 93 | }; |
| 94 | |
| 95 | if (panel->pwm_ctrl_gpio) { |
| 96 | /* PWM control for typical eDP and MIPI panels */ |
| 97 | if (panel->disp_path == DISP_PATH_MIPI) |
| 98 | lb_add_gpios(gpios, mipi_pwm_gpios, ARRAY_SIZE(mipi_pwm_gpios)); |
| 99 | else |
| 100 | lb_add_gpios(gpios, edp_pwm_gpios, ARRAY_SIZE(edp_pwm_gpios)); |
| 101 | } |
| 102 | |
| 103 | struct lb_gpio backlight_gpios[] = { |
| 104 | {GPIO_AP_DISP_BKLTEN.id, ACTIVE_HIGH, -1, "backlight enable"}, |
| 105 | }; |
| 106 | |
| 107 | lb_add_gpios(gpios, backlight_gpios, ARRAY_SIZE(backlight_gpios)); |
| 108 | } |