mb/google/dedede/var/bugzzy: Initialize display signals on user mode
Bugzzy uses panel-built-in touch screen, it needs to set panel power
and reset signal to high for touch screen to work.
On user mode, coreboot doesn't initialize graphics since there is no
screen display before OS. So we would add a WA to initialize required
signals on user mode. It takes under 30 ms delay on booting time.
BUG=b:205496327
BRANCH=dedede
TEST=Verified touch screen worked with test coreboot
and test touch screen 028D firmware
Signed-off-by: Seunghwan Kim <sh_.kim@samsung.corp-partner.google.com>
Change-Id: Iaa4d16deb932f43ae1ab33ff5b4e74120ab670db
Reviewed-on: https://review.coreboot.org/c/coreboot/+/60190
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Karthik Ramasubramanian <kramasub@google.com>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
diff --git a/src/mainboard/google/dedede/variants/bugzzy/Makefile.inc b/src/mainboard/google/dedede/variants/bugzzy/Makefile.inc
index fd60a18..7412194 100644
--- a/src/mainboard/google/dedede/variants/bugzzy/Makefile.inc
+++ b/src/mainboard/google/dedede/variants/bugzzy/Makefile.inc
@@ -1,5 +1,6 @@
## SPDX-License-Identifier: GPL-2.0-or-later
ramstage-y += gpio.c
+ramstage-y += ramstage.c
smm-y += variant.c
diff --git a/src/mainboard/google/dedede/variants/bugzzy/ramstage.c b/src/mainboard/google/dedede/variants/bugzzy/ramstage.c
new file mode 100644
index 0000000..7844b6e
--- /dev/null
+++ b/src/mainboard/google/dedede/variants/bugzzy/ramstage.c
@@ -0,0 +1,59 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#include <bootstate.h>
+#include <arch/mmio.h>
+#include <delay.h>
+#include <bootmode.h>
+#include <device/device.h>
+#include <device/pci.h>
+#include <soc/pci_devs.h>
+#include <drivers/intel/gma/i915_reg.h>
+
+static void panel_power_on(uintptr_t igd_bar)
+{
+ setbits32((void *)(igd_bar + PCH_PP_CONTROL), PANEL_POWER_ON);
+}
+
+static void panel_reset_assert(uintptr_t igd_bar)
+{
+ clrsetbits32((void *)(igd_bar + PCH_GPIOB),
+ GPIO_CLOCK_VAL_OUT,
+ GPIO_CLOCK_DIR_MASK | GPIO_CLOCK_DIR_OUT | GPIO_CLOCK_VAL_MASK);
+}
+
+static void panel_reset_deassert(uintptr_t igd_bar)
+{
+ const uint32_t data32 = GPIO_CLOCK_VAL_OUT |
+ GPIO_CLOCK_DIR_MASK | GPIO_CLOCK_DIR_OUT | GPIO_CLOCK_VAL_MASK;
+ setbits32((void *)(igd_bar + PCH_GPIOB), data32);
+}
+
+/*
+ * Bugzzy uses panel-built-in touch screen, it needs to set panel power and
+ * reset signal to high for touch screen to work.
+ * On user mode, coreboot doesn't initialize graphics since there is no screen
+ * display before OS. We would add this WA to initialize required signals on
+ * user mode.
+ */
+static void wa_init_display_signal(void *unused)
+{
+ struct device *igd_dev = pcidev_path_on_root(SA_DEVFN_IGD);
+ uintptr_t igd_bar;
+
+ if (display_init_required() || !igd_dev)
+ return;
+
+ igd_bar = find_resource(igd_dev, PCI_BASE_ADDRESS_0)->base;
+ if (!igd_bar)
+ return;
+
+ panel_power_on(igd_bar);
+ mdelay(20);
+ panel_reset_deassert(igd_bar);
+ mdelay(2);
+ panel_reset_assert(igd_bar);
+ mdelay(2);
+ panel_reset_deassert(igd_bar);
+}
+
+BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_ENTRY, wa_init_display_signal, NULL);