blob: fc3604372ec8cf14dacfd09df1e29a25246ab312 [file] [log] [blame]
Frank Vibrans7b904d82011-02-14 19:00:13 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2011 Advanced Micro Devices, Inc.
Edward O'Callaghanf5bde442014-06-02 12:20:11 +10005 * Copyright (C) 2014 Edward O'Callaghan <eocallaghan@alterapraxis.com>
Frank Vibrans7b904d82011-02-14 19:00:13 +00006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
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.
Frank Vibrans7b904d82011-02-14 19:00:13 +000015 */
16
17/* Pre-RAM driver for the SMSC KBC1100 Super I/O chip */
18
Stefan Reinauer24d1d4b2013-03-21 11:51:41 -070019#include <arch/io.h>
Kyösti Mälkki3855c012019-03-03 08:45:19 +020020#include <device/pnp_ops.h>
Edward O'Callaghanf5bde442014-06-02 12:20:11 +100021#include <device/pnp.h>
22#include <stdint.h>
23
Frank Vibrans7b904d82011-02-14 19:00:13 +000024#include "kbc1100.h"
25
Edward O'Callaghan85836c22014-07-09 20:26:25 +100026static void pnp_enter_conf_state(pnp_devfn_t dev)
Frank Vibrans7b904d82011-02-14 19:00:13 +000027{
Edward O'Callaghanf5bde442014-06-02 12:20:11 +100028 u16 port = dev >> 8;
29 outb(0x55, port);
Frank Vibrans7b904d82011-02-14 19:00:13 +000030}
31
Edward O'Callaghan85836c22014-07-09 20:26:25 +100032static void pnp_exit_conf_state(pnp_devfn_t dev)
Frank Vibrans7b904d82011-02-14 19:00:13 +000033{
Edward O'Callaghanf5bde442014-06-02 12:20:11 +100034 u16 port = dev >> 8;
35 outb(0xaa, port);
Frank Vibrans7b904d82011-02-14 19:00:13 +000036}
37
Edward O'Callaghan85836c22014-07-09 20:26:25 +100038void kbc1100_early_serial(pnp_devfn_t dev, u16 iobase)
Edward O'Callaghanf5bde442014-06-02 12:20:11 +100039{
40 pnp_enter_conf_state(dev);
41 pnp_set_logical_device(dev);
42 pnp_set_enable(dev, 0);
43 pnp_set_iobase(dev, PNP_IDX_IO0, iobase);
44 pnp_set_enable(dev, 1);
45 pnp_exit_conf_state(dev);
46}
47
48void kbc1100_early_init(u16 port)
Frank Vibrans7b904d82011-02-14 19:00:13 +000049{
Arthur Heymans12d01032017-08-01 21:51:10 +020050 pnp_devfn_t dev;
51 dev = PNP_DEV(port, KBC1100_KBC);
52 pnp_enter_conf_state(dev);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -070053
Arthur Heymans12d01032017-08-01 21:51:10 +020054 /* Serial IRQ enabled */
55 outb(0x25, port);
56 outb(0x04, port + 1);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -070057
Arthur Heymans12d01032017-08-01 21:51:10 +020058 /* Enable keyboard */
59 pnp_set_logical_device(dev);
60 pnp_set_enable(dev, 0);
61 pnp_set_iobase(dev, PNP_IDX_IO0, 0x60);
62 pnp_set_iobase(dev, PNP_IDX_IO1, 0x64);
63 pnp_set_irq(dev, 0x70, 1); /* IRQ 1 */
64 pnp_set_irq(dev, 0x72, 12); /* IRQ 12 */
65 pnp_set_enable(dev, 1);
Frank Vibrans7b904d82011-02-14 19:00:13 +000066
Arthur Heymans12d01032017-08-01 21:51:10 +020067 /* Enable EC Channel 0 */
68 dev = PNP_DEV(port, KBC1100_EC0);
69 pnp_set_logical_device(dev);
70 pnp_set_enable(dev, 1);
Frank Vibrans7b904d82011-02-14 19:00:13 +000071
Arthur Heymans12d01032017-08-01 21:51:10 +020072 pnp_exit_conf_state(dev);
Frank Vibrans7b904d82011-02-14 19:00:13 +000073
Arthur Heymans12d01032017-08-01 21:51:10 +020074 /* disable the 1s timer */
75 outb(0xE7, 0x64);
Frank Vibrans7b904d82011-02-14 19:00:13 +000076}