coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
wwan.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
4 #include <console/console.h>
5 #include <device/device.h>
6 #include <ec/acpi/ec.h>
7 #include <option.h>
8 #include <types.h>
9 
10 #include "h8.h"
11 #include "chip.h"
12 
13 /* Controls radio-off pin in WWAN MiniPCIe slot. */
14 void h8_wwan_enable(int on)
15 {
16  if (on)
17  ec_set_bit(0x3a, 6);
18  else
19  ec_clr_bit(0x3a, 6);
20 }
21 
22 /*
23  * Detect WWAN on supported MBs.
24  */
25 bool h8_has_wwan(const struct device *dev)
26 {
27  struct ec_lenovo_h8_config *conf = dev->chip_info;
28 
29  if (!conf->has_wwan_detection) {
30  printk(BIOS_INFO, "H8: WWAN detection not implemented. "
31  "Assuming WWAN installed\n");
32  return true;
33  }
34 
35  if (get_gpio(conf->wwan_gpio_num) == conf->wwan_gpio_lvl) {
36  printk(BIOS_INFO, "H8: WWAN installed\n");
37  return true;
38  }
39 
40  printk(BIOS_INFO, "H8: WWAN not installed\n");
41  return false;
42 }
43 
44 /*
45  * Return WWAN NVRAM setting.
46  */
48 {
49  return get_uint_option("wwan", true);
50 }
#define printk(level,...)
Definition: stdlib.h:16
void ec_set_bit(u8 addr, u8 bit)
Definition: ec.c:133
void ec_clr_bit(u8 addr, u8 bit)
Definition: ec.c:138
int get_gpio(int community_base, int pad0_offset)
Definition: gpio_support.c:148
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
unsigned int get_uint_option(const char *name, const unsigned int fallback)
Definition: option.c:116
Definition: device.h:107
DEVTREE_CONST void * chip_info
Definition: device.h:164
u8 has_wwan_detection
Definition: chip.h:36
void h8_wwan_enable(int on)
Definition: wwan.c:14
bool h8_has_wwan(const struct device *dev)
Definition: wwan.c:25
bool h8_wwan_nv_enable(void)
Definition: wwan.c:47