blob: 09ff480a990f8d03ea9640a39aadab0a18c8ef3e [file] [log] [blame]
Dennis Wassenberg020a3ce2015-09-10 12:17:49 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2015 secunet Security Networks AG
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <console/console.h>
17#include <device/device.h>
18#include <device/pnp.h>
19#include <pc80/keyboard.h>
20#include <ec/acpi/ec.h>
Nico Hubere223c3a2017-01-24 11:18:07 +010021#include <delay.h>
Dennis Wassenberg020a3ce2015-09-10 12:17:49 +020022
23#include "chip.h"
24
25static void it8518_init(struct device *dev)
26{
27 const struct ec_roda_it8518_config *const conf = dev->chip_info;
28
29 if (!dev->enabled)
30 return;
31
Dennis Wassenberg020a3ce2015-09-10 12:17:49 +020032 printk(BIOS_DEBUG, "Roda IT8518: Initializing keyboard.\n");
33 pc_keyboard_init(NO_AUX_DEVICE);
Nico Hubere223c3a2017-01-24 11:18:07 +010034
35 if (conf && conf->cpuhot_limit) {
36 /* The EC may take very long for the first command on a
37 cold boot (~180ms witnessed). Since we need an incre-
38 dibly long timeout, we do this EC RAM write manually. */
39 int timeout = 50000; /* 50,000 * 10us = 500ms */
40 send_ec_command(0x81);
41 while (ec_status() & EC_IBF && --timeout)
42 udelay(10);
43 send_ec_data(0xb2);
44 send_ec_data(conf->cpuhot_limit);
45 }
Dennis Wassenberg020a3ce2015-09-10 12:17:49 +020046}
47
48static struct device_operations ops = {
49 .init = it8518_init,
50 .read_resources = DEVICE_NOOP,
51 .enable_resources = DEVICE_NOOP,
52};
53
54static struct pnp_info pnp_dev_info[] = {
Felix Heldc864958a2018-07-07 00:30:40 +020055 { NULL, 0, 0, 0, }
Dennis Wassenberg020a3ce2015-09-10 12:17:49 +020056};
57
58static void enable_dev(struct device *dev)
59{
Felix Heldc864958a2018-07-07 00:30:40 +020060 pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
Dennis Wassenberg020a3ce2015-09-10 12:17:49 +020061}
62
63struct chip_operations ec_roda_it8518_ops = {
64 CHIP_NAME("Roda IT8518 EC")
65 .enable_dev = enable_dev
66};