Iru Cai | 44d399c | 2017-03-26 10:25:00 +0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2011 Iru Cai <mytbk920423@gmail.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; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | */ |
| 15 | |
| 16 | #include <arch/io.h> |
Kyösti Mälkki | 3855c01 | 2019-03-03 08:45:19 +0200 | [diff] [blame] | 17 | #include <device/pnp_ops.h> |
Iru Cai | 44d399c | 2017-03-26 10:25:00 +0800 | [diff] [blame] | 18 | #include <device/pnp.h> |
| 19 | #include "ec.h" |
| 20 | |
| 21 | void kbc1126_enter_conf(void) |
| 22 | { |
| 23 | outb(0x55, 0x2e); |
| 24 | outb(0x22, 0x2e); |
| 25 | outb(0x00, 0x2f); |
| 26 | outb(0x23, 0x2e); |
| 27 | outb(0x00, 0x2f); |
| 28 | outb(0x24, 0x2e); |
| 29 | outb(0x84, 0x2f); |
| 30 | } |
| 31 | |
| 32 | void kbc1126_exit_conf(void) |
| 33 | { |
| 34 | outb(0xaa, 0x2e); |
| 35 | /* one more time in PlatformStage1 of vendor firmware */ |
| 36 | outb(0xaa, 0x2e); |
| 37 | |
| 38 | outb(0x83, 0x200); |
| 39 | outb(0x00, 0x201); |
| 40 | inb(0x201); |
| 41 | } |
| 42 | |
| 43 | void kbc1126_mailbox_init(void) |
| 44 | { |
| 45 | pnp_devfn_t dev = PNP_DEV(0x2e, KBC1100_MAILBOX); |
| 46 | pnp_set_logical_device(dev); |
| 47 | pnp_set_iobase(dev, PNP_IDX_IO0, 0x200); |
| 48 | pnp_set_enable(dev, 1); |
| 49 | } |
| 50 | |
| 51 | void kbc1126_kbc_init(void) |
| 52 | { |
| 53 | pnp_devfn_t dev = PNP_DEV(0x2e, KBC1100_KBC); |
| 54 | pnp_set_logical_device(dev); |
| 55 | pnp_set_irq(dev, PNP_IDX_IRQ0, 0x1); |
| 56 | pnp_set_irq(dev, PNP_IDX_IRQ1, 0xc); |
| 57 | pnp_set_enable(dev, 1); |
| 58 | } |
| 59 | |
| 60 | void kbc1126_ec_init(void) |
| 61 | { |
| 62 | pnp_devfn_t dev = PNP_DEV(0x2e, KBC1100_EC0); |
| 63 | pnp_set_logical_device(dev); |
| 64 | pnp_set_iobase(dev, PNP_IDX_IO0, 0x62); |
| 65 | pnp_set_enable(dev, 1); |
| 66 | } |
| 67 | |
| 68 | void kbc1126_com1_init(void) |
| 69 | { |
| 70 | pnp_devfn_t dev = PNP_DEV(0x2e, SMSCSUPERIO_SP1); |
| 71 | pnp_set_logical_device(dev); |
| 72 | pnp_set_iobase(dev, PNP_IDX_IO0, 0x280); |
| 73 | pnp_set_irq(dev, PNP_IDX_IRQ0, 0x6); |
| 74 | pnp_set_enable(dev, 1); |
| 75 | } |
| 76 | |
| 77 | void kbc1126_pm1_init(void) |
| 78 | { |
| 79 | pnp_devfn_t dev = PNP_DEV(0x2e, KBC1100_PM1); |
| 80 | pnp_set_logical_device(dev); |
| 81 | pnp_set_iobase(dev, PNP_IDX_IO0, 0x220); |
| 82 | pnp_set_enable(dev, 1); |
| 83 | } |
| 84 | |
| 85 | /* |
| 86 | * This code is found in PEI module F65354B9-1FF0-46D7-A5F7-0926CB238048 |
| 87 | * of the OEM firmware. |
| 88 | * |
| 89 | * For mainboards without a Super I/O at 0x4e, without this code, superiotool |
| 90 | * will detect an Infineon Super I/O at 0x4e. |
| 91 | */ |
| 92 | |
| 93 | void kbc1126_disable4e(void) |
| 94 | { |
| 95 | outb(0x55, 0x4e); |
| 96 | |
| 97 | outb(0x26, 0x4e); |
| 98 | outb(0x00, 0x4f); |
| 99 | outb(0x27, 0x4e); |
| 100 | outb(0xfe, 0x4f); |
| 101 | outb(0x60, 0x4e); |
| 102 | outb(0xfe, 0x4f); |
| 103 | outb(0x61, 0x4e); |
| 104 | outb(0x80, 0x4f); |
| 105 | outb(0x30, 0x4e); |
| 106 | outb(0x01, 0x4f); |
| 107 | |
| 108 | outb(0xaa, 0x4e); |
| 109 | } |