Edward O'Callaghan | 946bee1 | 2014-05-06 18:00:07 +1000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2014 Edward O'Callaghan <eocallaghan@alterapraxis.com> |
| 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. |
Edward O'Callaghan | 946bee1 | 2014-05-06 18:00:07 +1000 | [diff] [blame] | 15 | */ |
| 16 | |
Edward O'Callaghan | 946bee1 | 2014-05-06 18:00:07 +1000 | [diff] [blame] | 17 | #include <device/device.h> |
| 18 | #include <device/pnp.h> |
| 19 | #include <superio/conf_mode.h> |
Rudolf Marek | 290bed7 | 2014-05-13 16:07:00 +0200 | [diff] [blame] | 20 | #include <pc80/keyboard.h> |
Tobias Diedrich | 1f064d7 | 2017-04-14 19:45:51 +0200 | [diff] [blame] | 21 | #include <superio/ite/common/env_ctrl.h> |
Edward O'Callaghan | 946bee1 | 2014-05-06 18:00:07 +1000 | [diff] [blame] | 22 | |
| 23 | #include "chip.h" |
| 24 | #include "it8728f.h" |
Edward O'Callaghan | 946bee1 | 2014-05-06 18:00:07 +1000 | [diff] [blame] | 25 | |
Edward O'Callaghan | f21bdc3 | 2014-10-21 07:43:41 +1100 | [diff] [blame] | 26 | static void it8728f_init(struct device *dev) |
Edward O'Callaghan | 946bee1 | 2014-05-06 18:00:07 +1000 | [diff] [blame] | 27 | { |
Tobias Diedrich | 1f064d7 | 2017-04-14 19:45:51 +0200 | [diff] [blame] | 28 | const struct superio_ite_it8728f_config *conf = dev->chip_info; |
| 29 | const struct resource *res; |
| 30 | |
Edward O'Callaghan | 946bee1 | 2014-05-06 18:00:07 +1000 | [diff] [blame] | 31 | if (!dev->enabled) |
| 32 | return; |
| 33 | |
Elyes HAOUAS | 0ce41f1 | 2018-11-13 10:03:31 +0100 | [diff] [blame] | 34 | switch (dev->path.pnp.device) { |
Tobias Diedrich | 1f064d7 | 2017-04-14 19:45:51 +0200 | [diff] [blame] | 35 | /* TODO: Might potentially need code for FDC etc. */ |
Rudolf Marek | 290bed7 | 2014-05-13 16:07:00 +0200 | [diff] [blame] | 36 | case IT8728F_EC: |
Tobias Diedrich | 1f064d7 | 2017-04-14 19:45:51 +0200 | [diff] [blame] | 37 | res = find_resource(dev, PNP_IDX_IO0); |
| 38 | if (!conf || !res) |
| 39 | break; |
| 40 | ite_ec_init(res->base, &conf->ec); |
Edward O'Callaghan | 946bee1 | 2014-05-06 18:00:07 +1000 | [diff] [blame] | 41 | break; |
Rudolf Marek | 290bed7 | 2014-05-13 16:07:00 +0200 | [diff] [blame] | 42 | case IT8728F_KBCK: |
| 43 | set_kbc_ps2_mode(); |
Timothy Pearson | 448e386 | 2015-11-24 14:12:01 -0600 | [diff] [blame] | 44 | pc_keyboard_init(NO_AUX_DEVICE); |
Rudolf Marek | 290bed7 | 2014-05-13 16:07:00 +0200 | [diff] [blame] | 45 | break; |
Edward O'Callaghan | 946bee1 | 2014-05-06 18:00:07 +1000 | [diff] [blame] | 46 | } |
| 47 | } |
| 48 | |
| 49 | static struct device_operations ops = { |
| 50 | .read_resources = pnp_read_resources, |
| 51 | .set_resources = pnp_set_resources, |
| 52 | .enable_resources = pnp_enable_resources, |
| 53 | .enable = pnp_alt_enable, |
| 54 | .init = it8728f_init, |
| 55 | .ops_pnp_mode = &pnp_conf_mode_870155_aa, |
| 56 | }; |
| 57 | |
Edward O'Callaghan | 946bee1 | 2014-05-06 18:00:07 +1000 | [diff] [blame] | 58 | static struct pnp_info pnp_dev_info[] = { |
Felix Held | c40275b | 2017-12-27 22:11:30 +0100 | [diff] [blame] | 59 | { NULL, IT8728F_FDC, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, 0x0ff8, }, |
| 60 | { NULL, IT8728F_SP1, PNP_IO0 | PNP_IRQ0, 0x0ff8, }, |
| 61 | { NULL, IT8728F_SP2, PNP_IO0 | PNP_IRQ0, 0x0ff8, }, |
| 62 | { NULL, IT8728F_PP, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, 0x0ffc, }, |
| 63 | { NULL, IT8728F_EC, PNP_IO0 | PNP_IO1 | PNP_IRQ0, 0x0ff8, 0x0ff8, }, |
| 64 | { NULL, IT8728F_KBCK, PNP_IO0 | PNP_IO1 | PNP_IRQ0, 0x0fff, 0x0fff, }, |
| 65 | { NULL, IT8728F_KBCM, PNP_IRQ0, }, |
| 66 | { NULL, IT8728F_GPIO, PNP_IO0 | PNP_IO1 | PNP_IO2 | PNP_IRQ0, |
| 67 | 0x0fff, 0x0ff8, 0x0ff8, }, |
| 68 | { NULL, IT8728F_IR, PNP_IO0 | PNP_IRQ0, 0x0ff8, }, |
Edward O'Callaghan | 946bee1 | 2014-05-06 18:00:07 +1000 | [diff] [blame] | 69 | }; |
| 70 | |
Edward O'Callaghan | f21bdc3 | 2014-10-21 07:43:41 +1100 | [diff] [blame] | 71 | static void enable_dev(struct device *dev) |
Edward O'Callaghan | 946bee1 | 2014-05-06 18:00:07 +1000 | [diff] [blame] | 72 | { |
| 73 | pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info); |
| 74 | } |
| 75 | |
| 76 | struct chip_operations superio_ite_it8728f_ops = { |
| 77 | CHIP_NAME("ITE IT8728F Super I/O") |
| 78 | .enable_dev = enable_dev |
| 79 | }; |