Gergely Kiss | c9c2926 | 2017-12-27 15:19:16 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2006 Uwe Hermann <uwe@hermann-uwe.de> |
| 5 | * Copyright (C) 2007 Philipp Degler <pdegler@rumms.uni-mannheim.de> |
| 6 | * Copyright (C) 2017 Gergely Kiss <mail.gery@gmail.com> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | */ |
| 18 | |
| 19 | #include <device/device.h> |
| 20 | #include <device/pnp.h> |
| 21 | #include <pc80/keyboard.h> |
| 22 | #include <arch/io.h> |
| 23 | #include <stdlib.h> |
| 24 | #include <superio/conf_mode.h> |
Kevin Cody-Little | f5f552a | 2018-05-10 21:33:03 -0400 | [diff] [blame] | 25 | #include <superio/ite/common/env_ctrl.h> |
Gergely Kiss | c9c2926 | 2017-12-27 15:19:16 +0100 | [diff] [blame] | 26 | |
Kevin Cody-Little | f5f552a | 2018-05-10 21:33:03 -0400 | [diff] [blame] | 27 | #include "chip.h" |
Gergely Kiss | c9c2926 | 2017-12-27 15:19:16 +0100 | [diff] [blame] | 28 | #include "it8623e.h" |
| 29 | |
| 30 | static void it8623e_init(struct device *dev) |
| 31 | { |
Kevin Cody-Little | f5f552a | 2018-05-10 21:33:03 -0400 | [diff] [blame] | 32 | const struct superio_ite_it8623e_config *conf = dev->chip_info; |
| 33 | const struct resource *res; |
Gergely Kiss | c9c2926 | 2017-12-27 15:19:16 +0100 | [diff] [blame] | 34 | |
| 35 | if (!dev->enabled) |
| 36 | return; |
| 37 | |
| 38 | switch (dev->path.pnp.device) { |
| 39 | case IT8623E_EC: |
Kevin Cody-Little | f5f552a | 2018-05-10 21:33:03 -0400 | [diff] [blame] | 40 | res = find_resource(dev, PNP_IDX_IO0); |
| 41 | if (!conf || !res) |
| 42 | break; |
| 43 | ite_ec_init(res->base, &conf->ec); |
Gergely Kiss | c9c2926 | 2017-12-27 15:19:16 +0100 | [diff] [blame] | 44 | break; |
| 45 | case IT8623E_KBCK: |
| 46 | pc_keyboard_init(NO_AUX_DEVICE); |
| 47 | break; |
| 48 | case IT8623E_KBCM: |
| 49 | break; |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | static struct device_operations ops = { |
| 54 | .read_resources = pnp_read_resources, |
| 55 | .set_resources = pnp_set_resources, |
| 56 | .enable_resources = pnp_enable_resources, |
| 57 | .enable = pnp_alt_enable, |
| 58 | .init = it8623e_init, |
| 59 | .ops_pnp_mode = &pnp_conf_mode_870155_aa, |
| 60 | }; |
| 61 | |
| 62 | static struct pnp_info pnp_dev_info[] = { |
Felix Held | c40275b | 2017-12-27 22:11:30 +0100 | [diff] [blame^] | 63 | { NULL, IT8623E_FDC, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, 0x0ff8, }, |
| 64 | { NULL, IT8623E_SP1, PNP_IO0 | PNP_IRQ0, 0x0ff8, }, |
| 65 | { NULL, IT8623E_SP2, PNP_IO0 | PNP_IRQ0, 0x0ff8, }, |
| 66 | { NULL, IT8623E_PP, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_DRQ0, |
| 67 | 0x0ff8, 0x0ff8, }, |
| 68 | { NULL, IT8623E_EC, PNP_IO0 | PNP_IO1 | PNP_IRQ0, 0x0ff0, 0x0ff0, }, |
| 69 | { NULL, IT8623E_KBCK, PNP_IO0 | PNP_IO1 | PNP_IRQ0, 0x0fff, 0x0fff, }, |
| 70 | { NULL, IT8623E_KBCM, PNP_IRQ0, }, |
| 71 | { NULL, IT8623E_GPIO, PNP_IO0 | PNP_IO1 | PNP_IO2 | PNP_IRQ0, |
| 72 | 0x0fff, 0x0fe0, 0x0fff, }, |
Gergely Kiss | c9c2926 | 2017-12-27 15:19:16 +0100 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | static void enable_dev(struct device *dev) |
| 76 | { |
Felix Held | c40275b | 2017-12-27 22:11:30 +0100 | [diff] [blame^] | 77 | pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info); |
Gergely Kiss | c9c2926 | 2017-12-27 15:19:16 +0100 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | struct chip_operations superio_ite_it8623e_ops = { |
| 81 | CHIP_NAME("ITE IT8623E Super I/O") |
| 82 | .enable_dev = enable_dev, |
| 83 | }; |