blob: 1941ac60f85d4acad00ab625557d3b5f6b047751 [file] [log] [blame]
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +01001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2011 Sven Schnelle <svens@stackframe.org>
5 * Copyright (C) 2013 Vladimir Serbinenko <phcoder@gmail.com>
6 *
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
10 * the License.
11 *
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.
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010016 */
17
18#define __SIMPLE_DEVICE__
19#include <console/console.h>
20#include <arch/io.h>
21#include <device/device.h>
22#include <device/pci.h>
23#include <delay.h>
24#include "dock.h"
25#include "southbridge/intel/ibexpeak/pch.h"
26#include "ec/lenovo/h8/h8.h"
27#include <ec/acpi/ec.h>
28
29void h8_mainboard_init_dock (void)
30{
31 if (dock_present()) {
32 printk(BIOS_DEBUG, "dock is connected\n");
33 dock_connect();
34 } else
35 printk(BIOS_DEBUG, "dock is not connected\n");
36}
37
38void dock_connect(void)
39{
Vladimir Serbinenkof319ae42014-08-19 00:48:39 +020040 u16 gpiobase = pci_read_config16(PCH_LPC_DEV, GPIO_BASE) & 0xfffc;
41
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010042 ec_set_bit(0x02, 0);
43 ec_set_bit(0x1a, 0);
44 ec_set_bit(0xfe, 4);
Vladimir Serbinenkof319ae42014-08-19 00:48:39 +020045
46 outl(inl(gpiobase + 0x0c) | (1 << 28), gpiobase + 0x0c);
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010047}
48
49void dock_disconnect(void)
50{
Vladimir Serbinenkof319ae42014-08-19 00:48:39 +020051 u16 gpiobase = pci_read_config16(PCH_LPC_DEV, GPIO_BASE) & 0xfffc;
52
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010053 ec_clr_bit(0x02, 0);
54 ec_clr_bit(0x1a, 0);
55 ec_clr_bit(0xfe, 4);
Vladimir Serbinenkof319ae42014-08-19 00:48:39 +020056
57 outl(inl(gpiobase + 0x0c) & ~(1 << 28), gpiobase + 0x0c);
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010058}
59
60int dock_present(void)
61{
62 u16 gpiobase = pci_read_config16(PCH_LPC_DEV, GPIO_BASE) & 0xfffc;
63 u8 st = inb(gpiobase + 0x0c);
64
Vladimir Serbinenkoc5e040b2014-08-18 23:54:54 +020065 return ((st >> 3) & 7) != 7;
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010066}