blob: cf3c8f7cf0b963669f9bd5b51ece6f7966547a4f [file] [log] [blame]
Patrick Rudolphb8e325a2017-08-13 12:09:54 +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/* Controls radio-off pin in WWAN MiniPCIe slot. */
26void h8_wwan_enable(int on)
27{
28 if (on)
29 ec_set_bit(0x3a, 6);
30 else
31 ec_clr_bit(0x3a, 6);
32}
33
34/*
35 * Detect WWAN on supported MBs.
36 */
37bool h8_has_wwan(struct device *dev)
38{
39 struct ec_lenovo_h8_config *conf = dev->chip_info;
40
41 if (!conf->has_wwan_detection) {
42 printk(BIOS_INFO, "H8: WWAN detection not implemented. "
43 "Assuming WWAN installed\n");
44 return true;
45 }
46
47 if (get_gpio(conf->wwan_gpio_num) == conf->wwan_gpio_lvl) {
48 printk(BIOS_INFO, "H8: WWAN installed\n");
49 return true;
50 }
51
52 printk(BIOS_INFO, "H8: WWAN not installed\n");
53 return false;
54}
55
56/*
57 * Return WWAN NVRAM setting.
58 */
59bool h8_wwan_nv_enable(void)
60{
61 u8 val;
62
63 if (get_option(&val, "wwan") != CB_SUCCESS)
64 return true;
65
66 return val;
67}