blob: f4a27588dcd8f0e8285a9177abeab90134ec2c29 [file] [log] [blame]
Angel Pons210a0082020-04-02 23:48:24 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Dennis Wassenberg020a3ce2015-09-10 12:17:49 +02003
4#include <console/console.h>
5#include <device/device.h>
6#include <device/pnp.h>
7#include <pc80/keyboard.h>
8#include <ec/acpi/ec.h>
Nico Hubere223c3a2017-01-24 11:18:07 +01009#include <delay.h>
Dennis Wassenberg020a3ce2015-09-10 12:17:49 +020010
11#include "chip.h"
12
13static void it8518_init(struct device *dev)
14{
15 const struct ec_roda_it8518_config *const conf = dev->chip_info;
16
17 if (!dev->enabled)
18 return;
19
Dennis Wassenberg020a3ce2015-09-10 12:17:49 +020020 printk(BIOS_DEBUG, "Roda IT8518: Initializing keyboard.\n");
21 pc_keyboard_init(NO_AUX_DEVICE);
Nico Hubere223c3a2017-01-24 11:18:07 +010022
23 if (conf && conf->cpuhot_limit) {
24 /* The EC may take very long for the first command on a
25 cold boot (~180ms witnessed). Since we need an incre-
26 dibly long timeout, we do this EC RAM write manually. */
27 int timeout = 50000; /* 50,000 * 10us = 500ms */
28 send_ec_command(0x81);
29 while (ec_status() & EC_IBF && --timeout)
30 udelay(10);
31 send_ec_data(0xb2);
32 send_ec_data(conf->cpuhot_limit);
33 }
Dennis Wassenberg020a3ce2015-09-10 12:17:49 +020034}
35
36static struct device_operations ops = {
37 .init = it8518_init,
Nico Huber2f8ba692020-04-05 14:05:24 +020038 .read_resources = noop_read_resources,
Dennis Wassenberg020a3ce2015-09-10 12:17:49 +020039};
40
41static struct pnp_info pnp_dev_info[] = {
Felix Heldc864958a2018-07-07 00:30:40 +020042 { NULL, 0, 0, 0, }
Dennis Wassenberg020a3ce2015-09-10 12:17:49 +020043};
44
45static void enable_dev(struct device *dev)
46{
Felix Heldc864958a2018-07-07 00:30:40 +020047 pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
Dennis Wassenberg020a3ce2015-09-10 12:17:49 +020048}
49
50struct chip_operations ec_roda_it8518_ops = {
51 CHIP_NAME("Roda IT8518 EC")
52 .enable_dev = enable_dev
53};