blob: c3a2555780e4db2063661925eae7d6d2841fc14a [file] [log] [blame]
Patrick Rudolph1194aa82017-05-21 08:49:44 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2017 Patrick Rudolph <siro@das-labor.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <southbridge/intel/common/gpio.h>
17#include <console/console.h>
18#include <device/device.h>
19#include <ec/acpi/ec.h>
20#include <option.h>
21
22#include "h8.h"
23#include "chip.h"
24
25/*
26 * Controls BDC (Bluetooth daughter card) power.
27 */
28void h8_bluetooth_enable(int on)
29{
30 if (on)
31 ec_set_bit(0x3a, 4);
32 else
33 ec_clr_bit(0x3a, 4);
34}
35
36/*
37 * Detect BDC on supported MBs.
38 */
39bool h8_has_bdc(struct device *dev)
40{
41 struct ec_lenovo_h8_config *conf = dev->chip_info;
42
43 if (!conf->has_bdc_detection) {
44 printk(BIOS_INFO, "H8: BDC detection not implemented. "
45 "Assuming BDC installed\n");
46 return true;
47 }
48
49 if (get_gpio(conf->bdc_gpio_num) == conf->bdc_gpio_lvl) {
50 printk(BIOS_INFO, "H8: BDC installed\n");
51 return true;
52 }
53
54 printk(BIOS_INFO, "H8: BDC not installed\n");
55 return false;
56}
57
58/*
59 * Return BDC NVRAM setting.
60 */
61bool h8_bluetooth_nv_enable(void)
62{
63 u8 val;
64
65 if (get_option(&val, "bluetooth") != CB_SUCCESS)
66 return true;
67
68 return val;
69}