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 | |
Jianeng Ceng | 47a9797 | 2023-03-30 16:50:22 +0800 | [diff] [blame] | 27 | static void configure_edp_backlight(void) |
Bo-Chen Chen | c07ccd9 | 2022-11-30 18:34:54 +0800 | [diff] [blame] | 28 | { |
Jianeng Ceng | 47a9797 | 2023-03-30 16:50:22 +0800 | [diff] [blame] | 29 | gpio_output(GPIO_AP_DISP_BKLTEN, 0); |
Bo-Chen Chen | c07ccd9 | 2022-11-30 18:34:54 +0800 | [diff] [blame] | 30 | } |
| 31 | |
Bo-Chen Chen | 817c6a7 | 2023-01-10 15:59:05 +0800 | [diff] [blame] | 32 | static void power_on_mipi_boe_tv110c9m_ll0(void) |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 33 | { |
Ruihai Zhou | 4a60418 | 2023-05-29 20:27:06 +0800 | [diff] [blame] | 34 | const struct tps65132s_reg_setting reg_settings[] = { |
| 35 | { PMIC_TPS65132_VPOS, 0x11, 0x1f }, |
| 36 | { PMIC_TPS65132_VNEG, 0x11, 0x1f }, |
| 37 | { PMIC_TPS65132_DLYX, 0x95, 0xff }, |
| 38 | { PMIC_TPS65132_ASSDD, 0x5b, 0xff }, |
| 39 | }; |
| 40 | const struct tps65132s_cfg cfg = { |
| 41 | .i2c_bus = PMIC_TPS65132_I2C, |
| 42 | .en = GPIO_EN_PPVAR_MIPI_DISP, |
| 43 | .sync = GPIO_EN_PPVAR_MIPI_DISP_150MA, |
| 44 | .settings = reg_settings, |
| 45 | .setting_counts = ARRAY_SIZE(reg_settings), |
| 46 | }; |
yangcong | 6538464 | 2023-03-02 20:59:30 +0800 | [diff] [blame] | 47 | |
Rex-BC Chen | d7b7460 | 2023-01-17 11:04:58 +0800 | [diff] [blame] | 48 | /* Enable VM18V */ |
| 49 | mainboard_enable_regulator(MTK_REGULATOR_VDD18, true); |
Ruihai Zhou | ffe2ced | 2023-07-07 16:48:24 +0800 | [diff] [blame^] | 50 | mtk_i2c_bus_init(PMIC_TPS65132_I2C, I2C_SPEED_FAST); |
| 51 | mdelay(10); |
Ruihai Zhou | 4a60418 | 2023-05-29 20:27:06 +0800 | [diff] [blame] | 52 | if (tps65132s_setup(&cfg) != CB_SUCCESS) |
| 53 | printk(BIOS_ERR, "Failed to set up voltage regulator tps65132s\n"); |
Rex-BC Chen | d7b7460 | 2023-01-17 11:04:58 +0800 | [diff] [blame] | 54 | gpio_output(GPIO_DISP_RST_1V8_L, 0); |
| 55 | mdelay(1); |
Rex-BC Chen | d7b7460 | 2023-01-17 11:04:58 +0800 | [diff] [blame] | 56 | gpio_output(GPIO_DISP_RST_1V8_L, 1); |
| 57 | mdelay(1); |
| 58 | gpio_output(GPIO_DISP_RST_1V8_L, 0); |
| 59 | mdelay(1); |
| 60 | gpio_output(GPIO_DISP_RST_1V8_L, 1); |
| 61 | mdelay(6); |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 62 | } |
| 63 | |
Jianeng Ceng | 47a9797 | 2023-03-30 16:50:22 +0800 | [diff] [blame] | 64 | static void power_on_edp_samsung_atana33xc20(void) |
Bo-Chen Chen | c07ccd9 | 2022-11-30 18:34:54 +0800 | [diff] [blame] | 65 | { |
Jianeng Ceng | 47a9797 | 2023-03-30 16:50:22 +0800 | [diff] [blame] | 66 | gpio_output(GPIO_EN_PP3300_EDP_DISP_X, 1); |
| 67 | gpio_set_pull(GPIO_EDP_HPD_1V8, GPIO_PULL_ENABLE, GPIO_PULL_UP); |
| 68 | gpio_set_mode(GPIO_EDP_HPD_1V8, 4); |
Bo-Chen Chen | c07ccd9 | 2022-11-30 18:34:54 +0800 | [diff] [blame] | 69 | } |
| 70 | |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 71 | static struct panel_description panels[] = { |
| 72 | [1] = { |
Bo-Chen Chen | 817c6a7 | 2023-01-10 15:59:05 +0800 | [diff] [blame] | 73 | .name = "BOE_TV110C9M_LL0", |
| 74 | .power_on = power_on_mipi_boe_tv110c9m_ll0, |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 75 | .configure_panel_backlight = configure_mipi_pwm_backlight, |
| 76 | .disp_path = DISP_PATH_MIPI, |
Bo-Chen Chen | f57155b | 2022-12-07 19:09:57 +0800 | [diff] [blame] | 77 | .pwm_ctrl_gpio = true, |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 78 | }, |
Bo-Chen Chen | c07ccd9 | 2022-11-30 18:34:54 +0800 | [diff] [blame] | 79 | [11] = { |
Jianeng Ceng | 47a9797 | 2023-03-30 16:50:22 +0800 | [diff] [blame] | 80 | .name = "SAMSUNG_ATANA33XC20", |
| 81 | .power_on = power_on_edp_samsung_atana33xc20, |
| 82 | .configure_panel_backlight = configure_edp_backlight, |
Bo-Chen Chen | c07ccd9 | 2022-11-30 18:34:54 +0800 | [diff] [blame] | 83 | .disp_path = DISP_PATH_EDP, |
Bo-Chen Chen | f57155b | 2022-12-07 19:09:57 +0800 | [diff] [blame] | 84 | .pwm_ctrl_gpio = false, |
Bo-Chen Chen | c07ccd9 | 2022-11-30 18:34:54 +0800 | [diff] [blame] | 85 | }, |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | struct panel_description *get_panel_description(uint32_t panel_id) |
| 89 | { |
Yidi Lin | 0b192d3 | 2023-03-20 17:40:31 +0800 | [diff] [blame] | 90 | /* Only PANEL_ID_LOW_CHANNEL value is valid for the reference board. */ |
| 91 | uint32_t id = panel_id & 0xF; |
| 92 | |
| 93 | if (id >= ARRAY_SIZE(panels)) |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 94 | return NULL; |
| 95 | |
Yidi Lin | 0b192d3 | 2023-03-20 17:40:31 +0800 | [diff] [blame] | 96 | return &panels[id]; |
Bo-Chen Chen | 4946516 | 2022-11-30 14:47:41 +0800 | [diff] [blame] | 97 | } |
Bo-Chen Chen | f57155b | 2022-12-07 19:09:57 +0800 | [diff] [blame] | 98 | |
| 99 | void fill_lp_backlight_gpios(struct lb_gpios *gpios) |
| 100 | { |
| 101 | struct panel_description *panel = get_active_panel(); |
| 102 | if (!panel || panel->disp_path == DISP_PATH_NONE) |
| 103 | return; |
| 104 | |
| 105 | struct lb_gpio mipi_pwm_gpios[] = { |
Liju-Clr Chen | 26a8dea | 2022-12-15 13:40:41 +0800 | [diff] [blame] | 106 | {GPIO_MIPI_BL_PWM_1V8.id, ACTIVE_HIGH, -1, "PWM control"}, |
Bo-Chen Chen | f57155b | 2022-12-07 19:09:57 +0800 | [diff] [blame] | 107 | }; |
| 108 | |
| 109 | struct lb_gpio edp_pwm_gpios[] = { |
| 110 | {GPIO_EDP_BL_PWM_1V8.id, ACTIVE_HIGH, -1, "PWM control"}, |
| 111 | }; |
| 112 | |
| 113 | if (panel->pwm_ctrl_gpio) { |
| 114 | /* PWM control for typical eDP and MIPI panels */ |
| 115 | if (panel->disp_path == DISP_PATH_MIPI) |
| 116 | lb_add_gpios(gpios, mipi_pwm_gpios, ARRAY_SIZE(mipi_pwm_gpios)); |
| 117 | else |
| 118 | lb_add_gpios(gpios, edp_pwm_gpios, ARRAY_SIZE(edp_pwm_gpios)); |
| 119 | } |
| 120 | |
| 121 | struct lb_gpio backlight_gpios[] = { |
| 122 | {GPIO_AP_DISP_BKLTEN.id, ACTIVE_HIGH, -1, "backlight enable"}, |
| 123 | }; |
| 124 | |
| 125 | lb_add_gpios(gpios, backlight_gpios, ARRAY_SIZE(backlight_gpios)); |
| 126 | } |