Angel Pons | 210a008 | 2020-04-02 23:48:24 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Dennis Wassenberg | 020a3ce | 2015-09-10 12:17:49 +0200 | [diff] [blame] | 3 | |
| 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 Huber | e223c3a | 2017-01-24 11:18:07 +0100 | [diff] [blame] | 9 | #include <delay.h> |
Dennis Wassenberg | 020a3ce | 2015-09-10 12:17:49 +0200 | [diff] [blame] | 10 | |
| 11 | #include "chip.h" |
| 12 | |
| 13 | static 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 Wassenberg | 020a3ce | 2015-09-10 12:17:49 +0200 | [diff] [blame] | 20 | printk(BIOS_DEBUG, "Roda IT8518: Initializing keyboard.\n"); |
| 21 | pc_keyboard_init(NO_AUX_DEVICE); |
Nico Huber | e223c3a | 2017-01-24 11:18:07 +0100 | [diff] [blame] | 22 | |
| 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 Wassenberg | 020a3ce | 2015-09-10 12:17:49 +0200 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | static struct device_operations ops = { |
| 37 | .init = it8518_init, |
| 38 | .read_resources = DEVICE_NOOP, |
Dennis Wassenberg | 020a3ce | 2015-09-10 12:17:49 +0200 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | static struct pnp_info pnp_dev_info[] = { |
Felix Held | c864958a | 2018-07-07 00:30:40 +0200 | [diff] [blame] | 42 | { NULL, 0, 0, 0, } |
Dennis Wassenberg | 020a3ce | 2015-09-10 12:17:49 +0200 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | static void enable_dev(struct device *dev) |
| 46 | { |
Felix Held | c864958a | 2018-07-07 00:30:40 +0200 | [diff] [blame] | 47 | pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info); |
Dennis Wassenberg | 020a3ce | 2015-09-10 12:17:49 +0200 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | struct chip_operations ec_roda_it8518_ops = { |
| 51 | CHIP_NAME("Roda IT8518 EC") |
| 52 | .enable_dev = enable_dev |
| 53 | }; |