Dennis Wassenberg | 020a3ce | 2015-09-10 12:17:49 +0200 | [diff] [blame] | 1 | /* |
| 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 Huber | e223c3a | 2017-01-24 11:18:07 +0100 | [diff] [blame] | 21 | #include <delay.h> |
Dennis Wassenberg | 020a3ce | 2015-09-10 12:17:49 +0200 | [diff] [blame] | 22 | |
| 23 | #include "chip.h" |
| 24 | |
| 25 | static 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 Wassenberg | 020a3ce | 2015-09-10 12:17:49 +0200 | [diff] [blame] | 32 | printk(BIOS_DEBUG, "Roda IT8518: Initializing keyboard.\n"); |
| 33 | pc_keyboard_init(NO_AUX_DEVICE); |
Nico Huber | e223c3a | 2017-01-24 11:18:07 +0100 | [diff] [blame] | 34 | |
| 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 Wassenberg | 020a3ce | 2015-09-10 12:17:49 +0200 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | static struct device_operations ops = { |
| 49 | .init = it8518_init, |
| 50 | .read_resources = DEVICE_NOOP, |
| 51 | .enable_resources = DEVICE_NOOP, |
| 52 | }; |
| 53 | |
| 54 | static struct pnp_info pnp_dev_info[] = { |
Felix Held | c864958a | 2018-07-07 00:30:40 +0200 | [diff] [blame] | 55 | { NULL, 0, 0, 0, } |
Dennis Wassenberg | 020a3ce | 2015-09-10 12:17:49 +0200 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | static void enable_dev(struct device *dev) |
| 59 | { |
Felix Held | c864958a | 2018-07-07 00:30:40 +0200 | [diff] [blame] | 60 | 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] | 61 | } |
| 62 | |
| 63 | struct chip_operations ec_roda_it8518_ops = { |
| 64 | CHIP_NAME("Roda IT8518 EC") |
| 65 | .enable_dev = enable_dev |
| 66 | }; |