Felix Held | 3f3eca9 | 2020-01-23 17:12:32 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Gergely Kiss | c9c2926 | 2017-12-27 15:19:16 +0100 | [diff] [blame] | 2 | |
| 3 | #include <device/device.h> |
| 4 | #include <device/pnp.h> |
| 5 | #include <pc80/keyboard.h> |
Gergely Kiss | c9c2926 | 2017-12-27 15:19:16 +0100 | [diff] [blame] | 6 | #include <superio/conf_mode.h> |
Kevin Cody-Little | f5f552a | 2018-05-10 21:33:03 -0400 | [diff] [blame] | 7 | #include <superio/ite/common/env_ctrl.h> |
Gergely Kiss | c9c2926 | 2017-12-27 15:19:16 +0100 | [diff] [blame] | 8 | |
Kevin Cody-Little | f5f552a | 2018-05-10 21:33:03 -0400 | [diff] [blame] | 9 | #include "chip.h" |
Gergely Kiss | c9c2926 | 2017-12-27 15:19:16 +0100 | [diff] [blame] | 10 | #include "it8623e.h" |
| 11 | |
| 12 | static void it8623e_init(struct device *dev) |
| 13 | { |
Kevin Cody-Little | f5f552a | 2018-05-10 21:33:03 -0400 | [diff] [blame] | 14 | const struct superio_ite_it8623e_config *conf = dev->chip_info; |
| 15 | const struct resource *res; |
Gergely Kiss | c9c2926 | 2017-12-27 15:19:16 +0100 | [diff] [blame] | 16 | |
| 17 | if (!dev->enabled) |
| 18 | return; |
| 19 | |
| 20 | switch (dev->path.pnp.device) { |
| 21 | case IT8623E_EC: |
Angel Pons | c167b74 | 2021-11-03 13:25:02 +0100 | [diff] [blame^] | 22 | res = probe_resource(dev, PNP_IDX_IO0); |
Kevin Cody-Little | f5f552a | 2018-05-10 21:33:03 -0400 | [diff] [blame] | 23 | if (!conf || !res) |
| 24 | break; |
| 25 | ite_ec_init(res->base, &conf->ec); |
Gergely Kiss | c9c2926 | 2017-12-27 15:19:16 +0100 | [diff] [blame] | 26 | break; |
| 27 | case IT8623E_KBCK: |
| 28 | pc_keyboard_init(NO_AUX_DEVICE); |
| 29 | break; |
| 30 | case IT8623E_KBCM: |
| 31 | break; |
| 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 = it8623e_init, |
| 41 | .ops_pnp_mode = &pnp_conf_mode_870155_aa, |
| 42 | }; |
| 43 | |
| 44 | static struct pnp_info pnp_dev_info[] = { |
Felix Held | c40275b | 2017-12-27 22:11:30 +0100 | [diff] [blame] | 45 | { NULL, IT8623E_FDC, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, 0x0ff8, }, |
| 46 | { NULL, IT8623E_SP1, PNP_IO0 | PNP_IRQ0, 0x0ff8, }, |
| 47 | { NULL, IT8623E_SP2, PNP_IO0 | PNP_IRQ0, 0x0ff8, }, |
| 48 | { NULL, IT8623E_PP, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_DRQ0, |
| 49 | 0x0ff8, 0x0ff8, }, |
| 50 | { NULL, IT8623E_EC, PNP_IO0 | PNP_IO1 | PNP_IRQ0, 0x0ff0, 0x0ff0, }, |
| 51 | { NULL, IT8623E_KBCK, PNP_IO0 | PNP_IO1 | PNP_IRQ0, 0x0fff, 0x0fff, }, |
| 52 | { NULL, IT8623E_KBCM, PNP_IRQ0, }, |
| 53 | { NULL, IT8623E_GPIO, PNP_IO0 | PNP_IO1 | PNP_IO2 | PNP_IRQ0, |
| 54 | 0x0fff, 0x0fe0, 0x0fff, }, |
Gergely Kiss | c9c2926 | 2017-12-27 15:19:16 +0100 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | static void enable_dev(struct device *dev) |
| 58 | { |
Felix Held | c40275b | 2017-12-27 22:11:30 +0100 | [diff] [blame] | 59 | 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] | 60 | } |
| 61 | |
| 62 | struct chip_operations superio_ite_it8623e_ops = { |
| 63 | CHIP_NAME("ITE IT8623E Super I/O") |
| 64 | .enable_dev = enable_dev, |
| 65 | }; |