blob: 9f877f7d9068c3c5531b8962d5262ade47808a30 [file] [log] [blame]
Angel Pons210a0082020-04-02 23:48:24 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Dennis Wassenberg020a3ce2015-09-10 12:17:49 +02002
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>
Nico Hubere223c3a2017-01-24 11:18:07 +01008#include <delay.h>
Dennis Wassenberg020a3ce2015-09-10 12:17:49 +02009
10#include "chip.h"
11
12static 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
Dennis Wassenberg020a3ce2015-09-10 12:17:49 +020019 printk(BIOS_DEBUG, "Roda IT8518: Initializing keyboard.\n");
20 pc_keyboard_init(NO_AUX_DEVICE);
Nico Hubere223c3a2017-01-24 11:18:07 +010021
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);
31 send_ec_data(conf->cpuhot_limit);
32 }
Dennis Wassenberg020a3ce2015-09-10 12:17:49 +020033}
34
35static struct device_operations ops = {
36 .init = it8518_init,
Nico Huber2f8ba692020-04-05 14:05:24 +020037 .read_resources = noop_read_resources,
Elyes HAOUAS4d319c32020-04-07 13:51:13 +020038 .set_resources = noop_set_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 = {
Nicholas Sudsgaardbfb11be2024-01-30 09:53:46 +090051 .name = "Roda IT8518 EC",
Dennis Wassenberg020a3ce2015-09-10 12:17:49 +020052 .enable_dev = enable_dev
53};