blob: 652a1441045bb17fec2b7c95c0512903398306cb [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
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010018#include <console/console.h>
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010019#include <device/device.h>
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010020#include "dock.h"
Arthur Heymans40377c72019-10-18 14:13:36 +020021#include <southbridge/intel/common/gpio.h>
Peter Lemenkovc8ed32e2018-11-05 19:54:57 +010022#include <ec/lenovo/h8/h8.h>
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010023#include <ec/acpi/ec.h>
24
Arthur Heymans40377c72019-10-18 14:13:36 +020025void h8_mainboard_init_dock(void)
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010026{
27 if (dock_present()) {
28 printk(BIOS_DEBUG, "dock is connected\n");
29 dock_connect();
30 } else
31 printk(BIOS_DEBUG, "dock is not connected\n");
32}
33
34void dock_connect(void)
35{
36 ec_set_bit(0x02, 0);
37 ec_set_bit(0x1a, 0);
38 ec_set_bit(0xfe, 4);
Vladimir Serbinenkof319ae42014-08-19 00:48:39 +020039
Arthur Heymans40377c72019-10-18 14:13:36 +020040 set_gpio(28, GPIO_LEVEL_HIGH);
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010041}
42
43void dock_disconnect(void)
44{
45 ec_clr_bit(0x02, 0);
46 ec_clr_bit(0x1a, 0);
47 ec_clr_bit(0xfe, 4);
Vladimir Serbinenkof319ae42014-08-19 00:48:39 +020048
Arthur Heymans40377c72019-10-18 14:13:36 +020049 set_gpio(28, GPIO_LEVEL_LOW);
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010050}
51
52int dock_present(void)
53{
Arthur Heymans40377c72019-10-18 14:13:36 +020054 const int dock_id_gpio[] = { 3, 4, 5, -1};
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010055
Arthur Heymans40377c72019-10-18 14:13:36 +020056 return get_gpios(dock_id_gpio) != 7;
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010057}