Angel Pons | 210a008 | 2020-04-02 23:48:24 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Patrick Rudolph | b8e325a | 2017-08-13 12:09:54 +0200 | [diff] [blame] | 3 | |
| 4 | #include <southbridge/intel/common/gpio.h> |
| 5 | #include <console/console.h> |
| 6 | #include <device/device.h> |
| 7 | #include <ec/acpi/ec.h> |
| 8 | #include <option.h> |
Elyes HAOUAS | 5fd93e0 | 2019-05-15 21:07:30 +0200 | [diff] [blame] | 9 | #include <types.h> |
Patrick Rudolph | b8e325a | 2017-08-13 12:09:54 +0200 | [diff] [blame] | 10 | |
| 11 | #include "h8.h" |
| 12 | #include "chip.h" |
| 13 | |
| 14 | /* Controls radio-off pin in WWAN MiniPCIe slot. */ |
| 15 | void h8_wwan_enable(int on) |
| 16 | { |
| 17 | if (on) |
| 18 | ec_set_bit(0x3a, 6); |
| 19 | else |
| 20 | ec_clr_bit(0x3a, 6); |
| 21 | } |
| 22 | |
| 23 | /* |
| 24 | * Detect WWAN on supported MBs. |
| 25 | */ |
Furquan Shaikh | 4fc17b4 | 2020-04-24 21:39:08 -0700 | [diff] [blame^] | 26 | bool h8_has_wwan(const struct device *dev) |
Patrick Rudolph | b8e325a | 2017-08-13 12:09:54 +0200 | [diff] [blame] | 27 | { |
| 28 | struct ec_lenovo_h8_config *conf = dev->chip_info; |
| 29 | |
| 30 | if (!conf->has_wwan_detection) { |
| 31 | printk(BIOS_INFO, "H8: WWAN detection not implemented. " |
| 32 | "Assuming WWAN installed\n"); |
| 33 | return true; |
| 34 | } |
| 35 | |
| 36 | if (get_gpio(conf->wwan_gpio_num) == conf->wwan_gpio_lvl) { |
| 37 | printk(BIOS_INFO, "H8: WWAN installed\n"); |
| 38 | return true; |
| 39 | } |
| 40 | |
| 41 | printk(BIOS_INFO, "H8: WWAN not installed\n"); |
| 42 | return false; |
| 43 | } |
| 44 | |
| 45 | /* |
| 46 | * Return WWAN NVRAM setting. |
| 47 | */ |
| 48 | bool h8_wwan_nv_enable(void) |
| 49 | { |
| 50 | u8 val; |
| 51 | |
| 52 | if (get_option(&val, "wwan") != CB_SUCCESS) |
| 53 | return true; |
| 54 | |
| 55 | return val; |
| 56 | } |