coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
dock.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <console/console.h>
4 #include <device/device.h>
6 #include <ec/lenovo/h8/h8.h>
7 #include <ec/acpi/ec.h>
8 
9 #include "../../dock.h"
10 
11 void h8_mb_init(void)
12 {
13  if (dock_present()) {
14  printk(BIOS_DEBUG, "dock is connected\n");
15  dock_connect();
16  } else {
17  printk(BIOS_DEBUG, "dock is not connected\n");
18  }
19 }
20 
21 void dock_connect(void)
22 {
23  ec_set_bit(0x02, 0);
25 }
26 
27 void dock_disconnect(void)
28 {
29  ec_clr_bit(0x02, 0);
31 }
32 
33 int dock_present(void)
34 {
35  const int dock_id_gpio[] = { 2, 3, 4, -1};
36 
37  return get_gpios(dock_id_gpio) != 7;
38 }
#define printk(level,...)
Definition: stdlib.h:16
void ec_set_bit(u8 addr, u8 bit)
Definition: ec.c:133
void ec_clr_bit(u8 addr, u8 bit)
Definition: ec.c:138
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
#define GPIO_LEVEL_HIGH
Definition: gpio.h:54
#define GPIO_LEVEL_LOW
Definition: gpio.h:53
unsigned int get_gpios(const int *gpio_num_array)
Definition: gpio.c:107
void set_gpio(int gpio_num, int value)
Definition: gpio.c:125
void dock_connect(void)
Definition: dock.c:215
void dock_disconnect(void)
Definition: dock.c:234
void h8_mb_init(void)
Definition: dock.c:10
int dock_present(void)
Definition: dock.c:36