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