2 * This file is part of the coreboot project.
4 * Copyright (C) 2011 Sven Schnelle <svens@stackframe.org>
5 * Copyright (C) 2013 Vladimir Serbinenko <phcoder@gmail.com>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; version 2 of
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
18 #define __SIMPLE_DEVICE__
19 #include <console/console.h>
21 #include <device/device.h>
22 #include <device/pci.h>
25 #include <southbridge/intel/i82801ix/i82801ix.h>
26 #include <ec/lenovo/h8/h8.h>
27 #include <ec/acpi/ec.h>
29 #define LPC_DEV PCI_DEV(0, 0x1f, 0)
31 void h8_mainboard_init_dock (void)
34 printk(BIOS_DEBUG
, "dock is connected\n");
37 printk(BIOS_DEBUG
, "dock is not connected\n");
40 void dock_connect(void)
42 u16 gpiobase
= pci_read_config16(LPC_DEV
, D31F0_GPIO_BASE
) & 0xfffc;
44 outl(inl(gpiobase
+ 0x0c) | (1 << 28), gpiobase
+ 0x0c);
47 void dock_disconnect(void)
49 u16 gpiobase
= pci_read_config16(LPC_DEV
, D31F0_GPIO_BASE
) & 0xfffc;
51 outl(inl(gpiobase
+ 0x0c) & ~(1 << 28), gpiobase
+ 0x0c);
54 int dock_present(void)
56 u16 gpiobase
= pci_read_config16(LPC_DEV
, D31F0_GPIO_BASE
) & 0xfffc;
57 u8 st
= inb(gpiobase
+ 0x0c);
59 return ((st
>> 2) & 7) != 7;