blob: 436b31908427f03889b28aa1e9987e2ab524e000 [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>
Elyes HAOUAS4f66cb92019-12-01 13:21:52 +010021#include <types.h>
Patrick Rudolph1194aa82017-05-21 08:49:44 +020022
23#include "h8.h"
24#include "chip.h"
25
26/*
27 * Controls BDC (Bluetooth daughter card) power.
28 */
29void h8_bluetooth_enable(int on)
30{
31 if (on)
32 ec_set_bit(0x3a, 4);
33 else
34 ec_clr_bit(0x3a, 4);
35}
36
37/*
38 * Detect BDC on supported MBs.
39 */
40bool h8_has_bdc(struct device *dev)
41{
42 struct ec_lenovo_h8_config *conf = dev->chip_info;
43
44 if (!conf->has_bdc_detection) {
45 printk(BIOS_INFO, "H8: BDC detection not implemented. "
46 "Assuming BDC installed\n");
47 return true;
48 }
49
50 if (get_gpio(conf->bdc_gpio_num) == conf->bdc_gpio_lvl) {
51 printk(BIOS_INFO, "H8: BDC installed\n");
52 return true;
53 }
54
55 printk(BIOS_INFO, "H8: BDC not installed\n");
56 return false;
57}
58
59/*
60 * Return BDC NVRAM setting.
61 */
62bool h8_bluetooth_nv_enable(void)
63{
64 u8 val;
65
66 if (get_option(&val, "bluetooth") != CB_SUCCESS)
67 return true;
68
69 return val;
70}