Seunghwan Kim | 1106bcc | 2021-12-17 15:57:52 +0900 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | |
| 3 | #include <bootstate.h> |
| 4 | #include <arch/mmio.h> |
| 5 | #include <delay.h> |
| 6 | #include <bootmode.h> |
| 7 | #include <device/device.h> |
| 8 | #include <device/pci.h> |
| 9 | #include <soc/pci_devs.h> |
| 10 | #include <drivers/intel/gma/i915_reg.h> |
| 11 | |
| 12 | static void panel_power_on(uintptr_t igd_bar) |
| 13 | { |
| 14 | setbits32((void *)(igd_bar + PCH_PP_CONTROL), PANEL_POWER_ON); |
| 15 | } |
| 16 | |
| 17 | static void panel_reset_assert(uintptr_t igd_bar) |
| 18 | { |
| 19 | clrsetbits32((void *)(igd_bar + PCH_GPIOB), |
| 20 | GPIO_CLOCK_VAL_OUT, |
| 21 | GPIO_CLOCK_DIR_MASK | GPIO_CLOCK_DIR_OUT | GPIO_CLOCK_VAL_MASK); |
| 22 | } |
| 23 | |
| 24 | static void panel_reset_deassert(uintptr_t igd_bar) |
| 25 | { |
| 26 | const uint32_t data32 = GPIO_CLOCK_VAL_OUT | |
| 27 | GPIO_CLOCK_DIR_MASK | GPIO_CLOCK_DIR_OUT | GPIO_CLOCK_VAL_MASK; |
| 28 | setbits32((void *)(igd_bar + PCH_GPIOB), data32); |
| 29 | } |
| 30 | |
| 31 | /* |
| 32 | * Bugzzy uses panel-built-in touch screen, it needs to set panel power and |
| 33 | * reset signal to high for touch screen to work. |
| 34 | * On user mode, coreboot doesn't initialize graphics since there is no screen |
| 35 | * display before OS. We would add this WA to initialize required signals on |
| 36 | * user mode. |
| 37 | */ |
| 38 | static void wa_init_display_signal(void *unused) |
| 39 | { |
| 40 | struct device *igd_dev = pcidev_path_on_root(SA_DEVFN_IGD); |
| 41 | uintptr_t igd_bar; |
| 42 | |
| 43 | if (display_init_required() || !igd_dev) |
| 44 | return; |
| 45 | |
| 46 | igd_bar = find_resource(igd_dev, PCI_BASE_ADDRESS_0)->base; |
| 47 | if (!igd_bar) |
| 48 | return; |
| 49 | |
| 50 | panel_power_on(igd_bar); |
| 51 | mdelay(20); |
| 52 | panel_reset_deassert(igd_bar); |
| 53 | mdelay(2); |
| 54 | panel_reset_assert(igd_bar); |
| 55 | mdelay(2); |
| 56 | panel_reset_deassert(igd_bar); |
| 57 | } |
| 58 | |
| 59 | BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_ENTRY, wa_init_display_signal, NULL); |