Nico Huber | 5eef7b3 | 2016-09-30 11:44:13 +0200 | [diff] [blame^] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2016 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; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | */ |
| 16 | |
| 17 | #include <device/device.h> |
| 18 | #include <device/pnp.h> |
| 19 | #include <pc80/keyboard.h> |
| 20 | #include <superio/conf_mode.h> |
| 21 | #include <superio/ite/common/env_ctrl.h> |
| 22 | |
| 23 | #include "it8783ef.h" |
| 24 | #include "chip.h" |
| 25 | |
| 26 | static void it8783ef_init(struct device *const dev) |
| 27 | { |
| 28 | const struct superio_ite_it8783ef_config *conf; |
| 29 | const struct resource *res; |
| 30 | |
| 31 | if (!dev->enabled) |
| 32 | return; |
| 33 | |
| 34 | switch (dev->path.pnp.device) { |
| 35 | case IT8783EF_EC: |
| 36 | conf = dev->chip_info; |
| 37 | res = find_resource(dev, PNP_IDX_IO0); |
| 38 | if (!conf || !res) |
| 39 | break; |
| 40 | ite_ec_init(res->base, &conf->ec); |
| 41 | break; |
| 42 | case IT8783EF_KBCK: |
| 43 | pc_keyboard_init(NO_AUX_DEVICE); |
| 44 | break; |
| 45 | default: |
| 46 | break; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | static struct device_operations ops = { |
| 51 | .read_resources = pnp_read_resources, |
| 52 | .set_resources = pnp_set_resources, |
| 53 | .enable_resources = pnp_enable_resources, |
| 54 | .enable = pnp_alt_enable, |
| 55 | .init = it8783ef_init, |
| 56 | .ops_pnp_mode = &pnp_conf_mode_870155_aa, |
| 57 | }; |
| 58 | |
| 59 | static struct pnp_info pnp_dev_info[] = { |
| 60 | /* Floppy Disk Controller */ |
| 61 | { &ops, IT8783EF_FDC, PNP_IO0 | PNP_IRQ0 | PNP_MSC0 | PNP_MSC1, |
| 62 | {0x0ff8, 0}, }, |
| 63 | /* Serial Port 1 */ |
| 64 | { &ops, IT8783EF_SP1, PNP_IO0 | PNP_IRQ0 | PNP_MSC0, {0x0ff8, 0}, }, |
| 65 | /* Serial Port 2 */ |
| 66 | { &ops, IT8783EF_SP2, PNP_IO0 | PNP_IRQ0 | PNP_MSC0, {0x0ff8, 0}, }, |
| 67 | /* Printer Port */ |
| 68 | { &ops, IT8783EF_PP, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_DRQ0 | |
| 69 | PNP_MSC0, |
| 70 | {0x0ffc, 0}, {0x0ffc, 0}, }, |
| 71 | /* Environmental Controller */ |
| 72 | { &ops, IT8783EF_EC, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_MSC0 | |
| 73 | PNP_MSC1 | PNP_MSC2 | PNP_MSC3 | PNP_MSC4 | |
| 74 | PNP_MSC5 | PNP_MSC6 | PNP_MSC7, |
| 75 | {0x0ff8, 0}, {0x0ff8, 0}, }, |
| 76 | /* KBC Keyboard */ |
| 77 | { &ops, IT8783EF_KBCK, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_MSC0, |
| 78 | {0x0fff, 0}, {0x0fff, 0}, }, |
| 79 | /* KBC Mouse */ |
| 80 | { &ops, IT8783EF_KBCM, PNP_IRQ0 | PNP_MSC0, }, |
| 81 | /* GPIO */ |
| 82 | { &ops, IT8783EF_GPIO, PNP_IO0 | PNP_IO1 | PNP_IO2 | PNP_IRQ0 | |
| 83 | PNP_MSC0 | PNP_MSC1 | PNP_MSC2 | PNP_MSC3 | |
| 84 | PNP_MSC4 | PNP_MSC5 | PNP_MSC6 | PNP_MSC7 | |
| 85 | PNP_MSC8 | PNP_MSC9 | PNP_MSCA | PNP_MSCB, |
| 86 | {0x0ffc, 0}, {0x0fff, 0}, {0x0ff8, 0}, }, |
| 87 | /* Serial Port 3 */ |
| 88 | { &ops, IT8783EF_SP3, PNP_IO0 | PNP_IRQ0 | PNP_MSC0, {0x0ff8, 0}, }, |
| 89 | /* Serial Port 4 */ |
| 90 | { &ops, IT8783EF_SP4, PNP_IO0 | PNP_IRQ0 | PNP_MSC0, {0x0ff8, 0}, }, |
| 91 | /* Serial Port 5 */ |
| 92 | { &ops, IT8783EF_SP5, PNP_IO0 | PNP_IRQ0 | PNP_MSC0, {0x0ff8, 0}, }, |
| 93 | /* Serial Port 6 */ |
| 94 | { &ops, IT8783EF_SP6, PNP_IO0 | PNP_IRQ0 | PNP_MSC0, {0x0ff8, 0}, }, |
| 95 | /* Consumer Infrared */ |
| 96 | { &ops, IT8783EF_CIR, PNP_IO0 | PNP_IRQ0 | PNP_MSC0, {0x0ff8, 0}, }, |
| 97 | }; |
| 98 | |
| 99 | static void enable_dev(struct device *dev) |
| 100 | { |
| 101 | pnp_enable_devices(dev, &pnp_ops, |
| 102 | ARRAY_SIZE(pnp_dev_info), pnp_dev_info); |
| 103 | } |
| 104 | |
| 105 | struct chip_operations superio_ite_it8783ef_ops = { |
| 106 | CHIP_NAME("ITE IT8783E/F Super I/O") |
| 107 | .enable_dev = enable_dev, |
| 108 | }; |