coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
mainboard.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <device/pci_def.h>
4 #include <device/pci_ids.h>
5 #include <device/device.h>
6 #include <device/pci_ops.h>
7 #include <arch/io.h>
8 #include <ec/acpi/ec.h>
11 #include "dock.h"
13 #include <drivers/lenovo/lenovo.h>
14 #include <acpi/acpigen.h>
15 
16 #define PANEL INT15_5F35_CL_DISPLAY_DEFAULT
17 
18 static void mainboard_init(struct device *dev)
19 {
20  struct device *idedev, *sdhci_dev;
21 
22  ec_clr_bit(0x03, 2);
23 
24  if (inb(0x164c) & 0x08) {
25  ec_set_bit(0x03, 2);
26  ec_write(0x0c, 0x88);
27  }
28 
31  PANEL, 3);
32 
33  /* If we're resuming from suspend, blink suspend LED */
34  if (acpi_is_wakeup_s3())
35  ec_write(0x0c, 0xc7);
36 
37  idedev = pcidev_on_root(0x1f, 1);
38  if (idedev && idedev->chip_info && dock_ultrabay_device_present()) {
40  config->ide_enable_primary = 1;
41  /* enable Ultrabay power */
42  outb(inb(0x1628) | 0x01, 0x1628);
43  ec_write(0x0c, 0x84);
44  } else {
45  /* disable Ultrabay power */
46  outb(inb(0x1628) & ~0x01, 0x1628);
47  ec_write(0x0c, 0x04);
48  }
49 
50  /* Set SDHCI write protect polarity "SDWPPol" */
52  if (sdhci_dev) {
53  if (pci_read_config8(sdhci_dev, 0xfa) != 0x20) {
54  /* unlock */
55  pci_write_config8(sdhci_dev, 0xf9, 0xfc);
56  /* set SDWPPol, keep CLKRUNDis, SDPWRPol clear */
57  pci_write_config8(sdhci_dev, 0xfa, 0x20);
58  /* restore lock */
59  pci_write_config8(sdhci_dev, 0xf9, 0x00);
60  }
61  }
62 }
63 
64 static void fill_ssdt(const struct device *device)
65 {
66  drivers_lenovo_serial_ports_ssdt_generate("\\_SB.PCI0.LPCB", 1);
67 }
68 
69 static void mainboard_enable(struct device *dev)
70 {
71  dev->ops->init = mainboard_init;
72  dev->ops->acpi_fill_ssdt = fill_ssdt;
73 }
74 
77 };
struct chip_operations mainboard_ops
Definition: mainboard.c:19
static int acpi_is_wakeup_s3(void)
Definition: acpi.h:9
u8 inb(u16 port)
void outb(u8 val, u16 port)
DEVTREE_CONST struct device * pcidev_on_root(uint8_t dev, uint8_t fn)
Definition: device_const.c:260
struct device * dev_find_device(u16 vendor, u16 device, struct device *from)
Find a device of a given vendor and type.
Definition: device_util.c:42
void install_intel_vga_int15_handler(int active_lfp_, int pfit_, int display_, int panel_type_)
Definition: int15.c:101
@ GMA_INT15_ACTIVE_LFP_INT_LVDS
Definition: int15.h:25
@ GMA_INT15_PANEL_FIT_DEFAULT
Definition: int15.h:17
void ec_set_bit(u8 addr, u8 bit)
Definition: ec.c:133
void ec_clr_bit(u8 addr, u8 bit)
Definition: ec.c:138
int ec_write(u8 addr, u8 data)
Definition: ec.c:115
static __always_inline u8 pci_read_config8(const struct device *dev, u16 reg)
Definition: pci_ops.h:46
static __always_inline void pci_write_config8(const struct device *dev, u16 reg, u8 val)
Definition: pci_ops.h:64
void drivers_lenovo_serial_ports_ssdt_generate(const char *scope, int have_dock_serial)
Definition: wacom.c:74
static void mainboard_init(struct device *dev)
Definition: mainboard.c:18
static void fill_ssdt(const struct device *device)
Definition: mainboard.c:64
#define PANEL
Definition: mainboard.c:16
static void mainboard_enable(struct device *dev)
Definition: mainboard.c:69
enum board_config config
Definition: memory.c:448
#define PCI_VID_RICOH
Definition: pci_ids.h:1656
#define PCI_DID_RICOH_R5C822
Definition: pci_ids.h:1662
void(* enable_dev)(struct device *dev)
Definition: device.h:24
void(* init)(struct device *dev)
Definition: device.h:42
Definition: device.h:107
struct device_operations * ops
Definition: device.h:143
DEVTREE_CONST void * chip_info
Definition: device.h:164
int dock_ultrabay_device_present(void)
Definition: dock.c:246