yongqiang niu has uploaded this change for review.

View Change

WIP: coreboot: Add anx7625 panel driver

Add panel anx7625 to support display

Signed-off-by: Huijuan Xie <huijuan.xie@mediatek.corp-partner.google.com>
Change-Id: I045d2042b5649e36470500f266f108564b7063fa
---
M src/mainboard/google/asurada/Makefile.inc
A src/mainboard/google/asurada/panel.h
A src/mainboard/google/asurada/panel_anx7625.c
3 files changed, 131 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/75/46575/1
diff --git a/src/mainboard/google/asurada/Makefile.inc b/src/mainboard/google/asurada/Makefile.inc
index d3f8ce6..2e5d86f 100644
--- a/src/mainboard/google/asurada/Makefile.inc
+++ b/src/mainboard/google/asurada/Makefile.inc
@@ -20,3 +20,5 @@
ramstage-y += chromeos.c
ramstage-y += mainboard.c
ramstage-y += reset.c
+
+ramstage-$(CONFIG_DRIVER_ANALOGIX_ANX7625) += panel_anx7625.c
\ No newline at end of file
diff --git a/src/mainboard/google/asurada/panel.h b/src/mainboard/google/asurada/panel.h
new file mode 100644
index 0000000..648440b
--- /dev/null
+++ b/src/mainboard/google/asurada/panel.h
@@ -0,0 +1,58 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __MAINBOARD_GOOGLE_KUKUI_PANEL_H__
+#define __MAINBOARD_GOOGLE_KUKUI_PANEL_H__
+
+#include <edid.h>
+#include <soc/dsi.h>
+
+/*
+ * The data that to be serialized and put into CBFS.
+ * Note some fields, for example edid.mode.name, were actually pointers and
+ * cannot be really serialized.
+ */
+struct panel_serializable_data {
+ struct edid edid; /* edid info of this panel */
+ enum lb_fb_orientation orientation; /* Panel orientation */
+ u8 init[]; /* A packed array of lcm_init_command */
+};
+
+struct panel_description {
+ const char *name; /* Panel name for constructing CBFS file name */
+ struct panel_serializable_data *s;
+ void (*power_on)(void); /* Callback to turn on panel */
+};
+
+/* Returns the panel description from given ID. */
+struct panel_description *get_panel_description(int panel_id);
+
+/* Loads panel serializable data from CBFS. */
+struct panel_description *get_panel_from_cbfs(struct panel_description *desc);
+
+#define INIT_DCS_CMD(...) \
+ LCM_DCS_CMD, \
+ sizeof((u8[]){__VA_ARGS__}), \
+ __VA_ARGS__
+
+#define INIT_GENERIC_CMD(...) \
+ LCM_GENERIC_CMD, \
+ sizeof((u8[]){__VA_ARGS__}), \
+ __VA_ARGS__
+
+#define INIT_DELAY_CMD(delay) \
+ LCM_DELAY_CMD, \
+ delay
+
+#define INIT_END_CMD \
+ LCM_END_CMD
+
+/* GPIO names */
+#define GPIO_MIPIBRDG_INT_ODL GPIO(EINT6) /* 6 */
+#define GPIO_MIPIBRDG_PWREN GPIO(DSI_TE) /* 41 */
+#define GPIO_MIPIBRDG_RST_L_1V8 GPIO(LCM_RST) /* 42 */
+#define GPIO_MIPIBRDG_PP3300_EN GPIO(PERIPHERAL_EN1) /* 127 */
+#define GPIO_MIPIBRDG_PP1800_EN GPIO(PERIPHERAL_EN2) /* 128 */
+#define GPIO_MIPIBRDG_PP1000_EN GPIO(PERIPHERAL_EN3) /* 129 */
+#define GPIO_PP3300_PANEL GPIO(CAM_CLK3) /* 136 */
+
+#endif /* __MAINBOARD_GOOGLE_KUKUI_PANEL_H__ */
diff --git a/src/mainboard/google/asurada/panel_anx7625.c b/src/mainboard/google/asurada/panel_anx7625.c
new file mode 100644
index 0000000..0145859
--- /dev/null
+++ b/src/mainboard/google/asurada/panel_anx7625.c
@@ -0,0 +1,71 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <console/console.h>
+#include <delay.h>
+#include <drivers/analogix/anx7625/anx7625.h>
+#include <edid.h>
+#include <gpio.h>
+#include <soc/i2c.h>
+
+#include "panel.h"
+
+
+static void power_on_anx7625(void)
+{
+ /* Disable backlight before turning on bridge */
+ gpio_output(GPIO(KPROW1), 0);
+ gpio_output(GPIO(DISP_PWM), 0);
+ gpio_output(GPIO_PP3300_PANEL, 1);
+
+ /* Turn on bridge */
+ gpio_output(GPIO_MIPIBRDG_RST_L_1V8, 0);
+ gpio_output(GPIO_MIPIBRDG_PP1000_EN, 1);
+ gpio_output(GPIO_MIPIBRDG_PP1800_EN, 1);
+ gpio_output(GPIO_MIPIBRDG_PP3300_EN, 1);
+ mdelay(2);
+ gpio_output(GPIO_MIPIBRDG_PWREN, 1);
+ mdelay(10);
+ gpio_output(GPIO_MIPIBRDG_RST_L_1V8, 1);
+}
+
+static void dummy_power_on(void)
+{
+ /* The panel has been already powered on when getting panel information
+ * so we should do nothing here.
+ */
+}
+
+static struct panel_serializable_data anx7625_data = {
+ .orientation = LB_FB_ORIENTATION_NORMAL,
+ .init = { INIT_END_CMD },
+};
+
+static struct panel_description anx7625_panel = {
+ .s = &anx7625_data,
+ .power_on = dummy_power_on,
+};
+
+struct panel_description *get_panel_description(int panel_id)
+{
+ /* To read panel EDID, we have to first power on anx7625. */
+ power_on_anx7625();
+
+ u8 i2c_bus = 3;
+ mtk_i2c_bus_init(i2c_bus);
+
+ if (anx7625_init(i2c_bus)) {
+ printk(BIOS_ERR, "Can't init ANX7625 bridge.\n");
+ return NULL;
+ }
+ struct edid *edid = &anx7625_data.edid;
+ if (anx7625_dp_get_edid(i2c_bus, edid)) {
+ printk(BIOS_ERR, "Can't get panel's edid.\n");
+ return NULL;
+ }
+ if (anx7625_dp_start(i2c_bus, edid) < 0) {
+ printk(BIOS_ERR, "Can't start display via ANX7625.\n");
+ return NULL;
+ }
+
+ return &anx7625_panel;
+}

To view, visit change 46575. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I045d2042b5649e36470500f266f108564b7063fa
Gerrit-Change-Number: 46575
Gerrit-PatchSet: 1
Gerrit-Owner: yongqiang niu <yongqiang.niu@mediatek.com>
Gerrit-Reviewer: Martin Roth <martinroth@google.com>
Gerrit-Reviewer: Patrick Georgi <pgeorgi@google.com>
Gerrit-MessageType: newchange