coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
ec.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <console/console.h>
4 #include <device/device.h>
5 #include <device/pnp.h>
6 #include <pc80/keyboard.h>
7 #include <ec/acpi/ec.h>
8 #include <delay.h>
9 
10 #include "chip.h"
11 
12 static void it8518_init(struct device *dev)
13 {
14  const struct ec_roda_it8518_config *const conf = dev->chip_info;
15 
16  if (!dev->enabled)
17  return;
18 
19  printk(BIOS_DEBUG, "Roda IT8518: Initializing keyboard.\n");
21 
22  if (conf && conf->cpuhot_limit) {
23  /* The EC may take very long for the first command on a
24  cold boot (~180ms witnessed). Since we need an incre-
25  dibly long timeout, we do this EC RAM write manually. */
26  int timeout = 50000; /* 50,000 * 10us = 500ms */
27  send_ec_command(0x81);
28  while (ec_status() & EC_IBF && --timeout)
29  udelay(10);
30  send_ec_data(0xb2);
32  }
33 }
34 
35 static struct device_operations ops = {
36  .init = it8518_init,
37  .read_resources = noop_read_resources,
38  .set_resources = noop_set_resources,
39 };
40 
41 static struct pnp_info pnp_dev_info[] = {
42  { NULL, 0, 0, 0, }
43 };
44 
45 static void enable_dev(struct device *dev)
46 {
48 }
49 
51  CHIP_NAME("Roda IT8518 EC")
52  .enable_dev = enable_dev
53 };
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define printk(level,...)
Definition: stdlib.h:16
int send_ec_command(u8 command)
Definition: ec.c:13
u8 ec_status(void)
Definition: ec.c:122
int send_ec_data(u8 data)
Definition: ec.c:35
#define EC_IBF
Definition: ec.h:17
struct chip_operations ec_roda_it8518_ops
Definition: ec.c:50
static void it8518_init(struct device *dev)
Definition: ec.c:12
static void enable_dev(struct device *dev)
Definition: ec.c:45
static struct device_operations ops
Definition: ec.c:35
static struct pnp_info pnp_dev_info[]
Definition: ec.c:41
#define CHIP_NAME(X)
Definition: device.h:32
static void noop_read_resources(struct device *dev)
Standard device operations function pointers shims.
Definition: device.h:73
static void noop_set_resources(struct device *dev)
Definition: device.h:74
uint8_t pc_keyboard_init(uint8_t probe_aux)
Definition: keyboard.c:229
#define NO_AUX_DEVICE
Definition: keyboard.h:6
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
void pnp_enable_devices(struct device *base_dev, struct device_operations *ops, unsigned int functions, struct pnp_info *info)
Definition: pnp_device.c:371
#define NULL
Definition: stddef.h:19
void(* init)(struct device *dev)
Definition: device.h:42
Definition: device.h:107
DEVTREE_CONST void * chip_info
Definition: device.h:164
unsigned int enabled
Definition: device.h:122
Definition: pnp.h:37
void udelay(uint32_t us)
Definition: udelay.c:15