blob: 58a837ea8fe7bf950c941d5396c43c786cceaace [file] [log] [blame]
Edward O'Callaghan946bee12014-05-06 18:00:07 +10001/*
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'Callaghan946bee12014-05-06 18:00:07 +100015 */
16
Edward O'Callaghan946bee12014-05-06 18:00:07 +100017#include <device/device.h>
18#include <device/pnp.h>
19#include <superio/conf_mode.h>
Rudolf Marek290bed72014-05-13 16:07:00 +020020#include <pc80/keyboard.h>
Tobias Diedrich1f064d72017-04-14 19:45:51 +020021#include <superio/ite/common/env_ctrl.h>
Edward O'Callaghan946bee12014-05-06 18:00:07 +100022
23#include "chip.h"
24#include "it8728f.h"
Edward O'Callaghan946bee12014-05-06 18:00:07 +100025
Edward O'Callaghanf21bdc32014-10-21 07:43:41 +110026static void it8728f_init(struct device *dev)
Edward O'Callaghan946bee12014-05-06 18:00:07 +100027{
Tobias Diedrich1f064d72017-04-14 19:45:51 +020028 const struct superio_ite_it8728f_config *conf = dev->chip_info;
29 const struct resource *res;
30
Edward O'Callaghan946bee12014-05-06 18:00:07 +100031 if (!dev->enabled)
32 return;
33
Elyes HAOUAS0ce41f12018-11-13 10:03:31 +010034 switch (dev->path.pnp.device) {
Tobias Diedrich1f064d72017-04-14 19:45:51 +020035 /* TODO: Might potentially need code for FDC etc. */
Rudolf Marek290bed72014-05-13 16:07:00 +020036 case IT8728F_EC:
Tobias Diedrich1f064d72017-04-14 19:45:51 +020037 res = find_resource(dev, PNP_IDX_IO0);
38 if (!conf || !res)
39 break;
40 ite_ec_init(res->base, &conf->ec);
Edward O'Callaghan946bee12014-05-06 18:00:07 +100041 break;
Rudolf Marek290bed72014-05-13 16:07:00 +020042 case IT8728F_KBCK:
43 set_kbc_ps2_mode();
Timothy Pearson448e3862015-11-24 14:12:01 -060044 pc_keyboard_init(NO_AUX_DEVICE);
Rudolf Marek290bed72014-05-13 16:07:00 +020045 break;
Edward O'Callaghan946bee12014-05-06 18:00:07 +100046 }
47}
48
49static 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'Callaghan946bee12014-05-06 18:00:07 +100058static struct pnp_info pnp_dev_info[] = {
Felix Heldc40275b2017-12-27 22:11:30 +010059 { 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'Callaghan946bee12014-05-06 18:00:07 +100069};
70
Edward O'Callaghanf21bdc32014-10-21 07:43:41 +110071static void enable_dev(struct device *dev)
Edward O'Callaghan946bee12014-05-06 18:00:07 +100072{
73 pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
74}
75
76struct chip_operations superio_ite_it8728f_ops = {
77 CHIP_NAME("ITE IT8728F Super I/O")
78 .enable_dev = enable_dev
79};