Duncan Laurie | b29e2d5 | 2018-10-15 02:40:21 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2018 Google LLC |
| 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 <device/pnp.h> |
| 17 | #include <pc80/keyboard.h> |
| 18 | #include <stdint.h> |
| 19 | #include <stdlib.h> |
| 20 | |
| 21 | #include "commands.h" |
| 22 | #include "ec.h" |
| 23 | #include "chip.h" |
| 24 | |
| 25 | static void wilco_ec_init(struct device *dev) |
| 26 | { |
| 27 | if (!dev->enabled) |
| 28 | return; |
| 29 | |
| 30 | /* Print EC firmware information */ |
| 31 | wilco_ec_print_all_info(); |
| 32 | |
| 33 | /* Initialize keyboard, ignore emulated PS/2 mouse */ |
| 34 | pc_keyboard_init(NO_AUX_DEVICE); |
| 35 | |
| 36 | /* Direct power button to the host for processing */ |
| 37 | wilco_ec_send(KB_POWER_BUTTON_TO_HOST, 1); |
| 38 | } |
| 39 | |
| 40 | static void wilco_ec_resource(struct device *dev, int index, |
| 41 | size_t base, size_t size) |
| 42 | { |
| 43 | struct resource *res = new_resource(dev, index); |
| 44 | res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED; |
| 45 | res->base = base; |
| 46 | res->size = size; |
| 47 | } |
| 48 | |
| 49 | static void wilco_ec_read_resources(struct device *dev) |
| 50 | { |
| 51 | /* ACPI command and data regions */ |
| 52 | wilco_ec_resource(dev, 0, CONFIG_EC_BASE_ACPI_DATA, 8); |
| 53 | |
| 54 | /* Host command and data regions */ |
| 55 | wilco_ec_resource(dev, 1, CONFIG_EC_BASE_HOST_DATA, 8); |
| 56 | |
| 57 | /* Packet region */ |
| 58 | wilco_ec_resource(dev, 2, CONFIG_EC_BASE_PACKET, 16); |
| 59 | } |
| 60 | |
| 61 | static struct device_operations ops = { |
| 62 | .init = wilco_ec_init, |
| 63 | .read_resources = wilco_ec_read_resources, |
| 64 | .enable_resources = DEVICE_NOOP, |
| 65 | .set_resources = DEVICE_NOOP, |
| 66 | }; |
| 67 | |
| 68 | static struct pnp_info info[] = { |
| 69 | { NULL, 0, 0, 0, } |
| 70 | }; |
| 71 | |
| 72 | static void wilco_ec_enable_dev(struct device *dev) |
| 73 | { |
| 74 | pnp_enable_devices(dev, &ops, ARRAY_SIZE(info), info); |
| 75 | } |
| 76 | |
| 77 | struct chip_operations ec_google_wilco_ops = { |
| 78 | CHIP_NAME("Google Wilco EC") |
| 79 | .enable_dev = wilco_ec_enable_dev, |
| 80 | }; |