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  ec_set_bit(0x02, 0);
23  ec_set_bit(0x1a, 0);
24  ec_set_bit(0xfe, 4);
25 
27 }
28 
29 void dock_disconnect(void)
30 {
31  ec_clr_bit(0x02, 0);
32  ec_clr_bit(0x1a, 0);
33  ec_clr_bit(0xfe, 4);
34 
36 }
37 
38 int dock_present(void)
39 {
40  const int dock_id_gpio[] = { 3, 4, 5, -1};
41 
42  return get_gpios(dock_id_gpio) != 7;
43 }
#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