Ruihai Zhou | d5c1e13 | 2023-03-28 16:49:01 +0800 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <console/console.h> |
| 4 | #include <delay.h> |
| 5 | #include <drivers/analogix/anx7625/anx7625.h> |
| 6 | #include <edid.h> |
| 7 | #include <gpio.h> |
| 8 | #include <soc/i2c.h> |
| 9 | |
| 10 | #include "display.h" |
| 11 | #include "gpio.h" |
| 12 | |
| 13 | static void bridge_anx7625_power_on(void) |
| 14 | { |
| 15 | /* Turn on bridge */ |
| 16 | gpio_output(GPIO_EDPBRDG_RST_L, 0); |
| 17 | gpio_output(GPIO_EN_PP1000_EDPBRDG, 1); |
| 18 | gpio_output(GPIO_EN_PP1800_EDPBRDG, 1); |
| 19 | gpio_output(GPIO_EN_PP3300_EDPBRDG, 1); |
| 20 | mdelay(14); |
| 21 | gpio_output(GPIO_EDPBRDG_PWREN, 1); |
| 22 | mdelay(80); |
| 23 | gpio_output(GPIO_EDPBRDG_RST_L, 1); |
| 24 | } |
| 25 | |
| 26 | static int bridge_anx7625_get_edid(u8 i2c_bus, struct edid *edid) |
| 27 | { |
| 28 | if (anx7625_init(i2c_bus) < 0) { |
| 29 | printk(BIOS_ERR, "%s: Can't init ANX7625 bridge\n", __func__); |
| 30 | return -1; |
| 31 | } |
| 32 | if (anx7625_dp_get_edid(i2c_bus, edid) < 0) { |
| 33 | printk(BIOS_ERR, "%s: Can't get panel's edid\n", __func__); |
| 34 | return -1; |
| 35 | } |
| 36 | return 0; |
| 37 | } |
| 38 | |
| 39 | static int bridge_anx7625_post_power_on(u8 i2c_bus, struct edid *edid) |
| 40 | { |
| 41 | return anx7625_dp_start(i2c_bus, edid); |
| 42 | } |
| 43 | |
| 44 | static struct panel_serializable_data anx7625_data; |
| 45 | |
| 46 | static struct panel_description anx7625_bridge = { |
| 47 | .s = &anx7625_data, |
| 48 | .post_power_on = bridge_anx7625_post_power_on, |
| 49 | .orientation = LB_FB_ORIENTATION_NORMAL, |
| 50 | }; |
| 51 | |
| 52 | struct panel_description *get_anx7625_description(void) |
| 53 | { |
| 54 | mtk_i2c_bus_init(BRIDGE_I2C, I2C_SPEED_FAST); |
| 55 | bridge_anx7625_power_on(); |
| 56 | if (bridge_anx7625_get_edid(BRIDGE_I2C, &anx7625_bridge.s->edid) < 0) { |
| 57 | printk(BIOS_ERR, "Can't get panel's edid\n"); |
| 58 | return NULL; |
| 59 | } |
| 60 | return &anx7625_bridge; |
| 61 | } |