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>
5 #include "dock.h"
7 #include <ec/lenovo/h8/h8.h>
8 #include <ec/acpi/ec.h>
9 
10 void h8_mb_init(void)
11 {
12  if (dock_present()) {
13  printk(BIOS_DEBUG, "dock is connected\n");
14  dock_connect();
15  } else {
16  printk(BIOS_DEBUG, "dock is not connected\n");
17  }
18 }
19 
20 void dock_connect(void)
21 {
22  /* UNTESTED */
23  ec_set_bit(0x02, 0);
24  ec_set_bit(0x1a, 0);
25  ec_set_bit(0xfe, 4);
26 }
27 
28 void dock_disconnect(void)
29 {
30  /* UNTESTED */
31  ec_clr_bit(0x02, 0);
32  ec_clr_bit(0x1a, 0);
33  ec_clr_bit(0xfe, 4);
34 }
35 
36 int dock_present(void)
37 {
38  const int gpio_num_array[] = {3, 4, 5, -1};
39 
40  return get_gpios(gpio_num_array) != 7;
41 }
#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
unsigned int get_gpios(const int *gpio_num_array)
Definition: gpio.c:107
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