blob: 233b134702bb8847a4b74e6c2918884a0beee603 [file] [log] [blame]
Vladimir Serbinenko61ffb4c2014-08-12 22:51:53 +02001/*
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 Serbinenko61ffb4c2014-08-12 22:51:53 +020016 */
17
Vladimir Serbinenko61ffb4c2014-08-12 22:51:53 +020018#include <console/console.h>
Vladimir Serbinenko61ffb4c2014-08-12 22:51:53 +020019#include <device/device.h>
Arthur Heymansbf6b6af2019-10-18 14:02:57 +020020#include <southbridge/intel/common/gpio.h>
Peter Lemenkovc8ed32e2018-11-05 19:54:57 +010021#include <ec/lenovo/h8/h8.h>
Vladimir Serbinenko61ffb4c2014-08-12 22:51:53 +020022#include <ec/acpi/ec.h>
23
Elyes HAOUASbf0970e2019-03-21 11:10:03 +010024#include "dock.h"
25
Vladimir Serbinenko61ffb4c2014-08-12 22:51:53 +020026void h8_mainboard_init_dock (void)
27{
28 if (dock_present()) {
29 printk(BIOS_DEBUG, "dock is connected\n");
30 dock_connect();
31 } else
32 printk(BIOS_DEBUG, "dock is not connected\n");
33}
34
35void dock_connect(void)
36{
37 ec_set_bit(0x02, 0);
Arthur Heymansbf6b6af2019-10-18 14:02:57 +020038 set_gpio(28, GPIO_LEVEL_HIGH);
Vladimir Serbinenko61ffb4c2014-08-12 22:51:53 +020039}
40
41void dock_disconnect(void)
42{
43 ec_clr_bit(0x02, 0);
Arthur Heymansbf6b6af2019-10-18 14:02:57 +020044 set_gpio(28, GPIO_LEVEL_LOW);
Vladimir Serbinenko61ffb4c2014-08-12 22:51:53 +020045}
46
47int dock_present(void)
48{
Arthur Heymansbf6b6af2019-10-18 14:02:57 +020049 const int dock_id_gpio[] = { 2, 3, 4, -1};
Vladimir Serbinenko61ffb4c2014-08-12 22:51:53 +020050
Arthur Heymansbf6b6af2019-10-18 14:02:57 +020051 return get_gpios(dock_id_gpio) != 7;
Vladimir Serbinenko61ffb4c2014-08-12 22:51:53 +020052}