blob: a6d0ef0b645bb90eb6d7aff7bc6466540f3da420 [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.
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 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
Paul Menzela46a7122013-02-23 18:37:27 +010017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Frank Vibrans7b904d82011-02-14 19:00:13 +000018 */
19
20/* RAM driver for the SMSC KBC1100 Super I/O chip */
21
22#include <arch/io.h>
23#include <device/device.h>
24#include <device/pnp.h>
25#include <console/console.h>
26#include <device/smbus.h>
27#include <string.h>
Frank Vibrans7b904d82011-02-14 19:00:13 +000028#include <uart8250.h>
29#include <pc80/keyboard.h>
30#include <stdlib.h>
31#include "chip.h"
32#include "kbc1100.h"
33
34/* Forward declarations */
35static void enable_dev(device_t dev);
Frank Vibrans7b904d82011-02-14 19:00:13 +000036static void kbc1100_init(device_t dev);
37
38static void pnp_enter_conf_state(device_t dev);
39static void pnp_exit_conf_state(device_t dev);
40
41struct chip_operations superio_smsc_kbc1100_ops = {
42 CHIP_NAME("SMSC KBC1100 Super I/O")
43 .enable_dev = enable_dev
44};
45
Nico Huber13dc9762013-06-15 19:33:15 +020046static const struct pnp_mode_ops pnp_conf_mode_ops = {
47 .enter_conf_mode = pnp_enter_conf_state,
48 .exit_conf_mode = pnp_exit_conf_state,
49};
50
Frank Vibrans7b904d82011-02-14 19:00:13 +000051static struct device_operations ops = {
52 .read_resources = pnp_read_resources,
Nico Huber0b2ee932013-06-15 19:58:35 +020053 .set_resources = pnp_set_resources,
54 .enable_resources = pnp_enable_resources,
55 .enable = pnp_alt_enable,
Frank Vibrans7b904d82011-02-14 19:00:13 +000056 .init = kbc1100_init,
Nico Huber13dc9762013-06-15 19:33:15 +020057 .ops_pnp_mode = &pnp_conf_mode_ops,
Frank Vibrans7b904d82011-02-14 19:00:13 +000058};
59
60static struct pnp_info pnp_dev_info[] = {
61 { &ops, KBC1100_KBC, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_IRQ1, { 0x7ff, 0 }, { 0x7ff, 0x4}, },
62};
63
64static void enable_dev(device_t dev)
65{
66 pnp_enable_devices(dev, &pnp_ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
67}
68
Frank Vibrans7b904d82011-02-14 19:00:13 +000069static void kbc1100_init(device_t dev)
70{
71 struct superio_smsc_kbc1100_config *conf = dev->chip_info;
72 struct resource *res0, *res1;
73
Stefan Reinauer5ff7c132011-10-31 12:56:45 -070074
75
Frank Vibrans7b904d82011-02-14 19:00:13 +000076 if (!dev->enabled) {
77 return;
78 }
79
80 switch(dev->path.pnp.device) {
Stefan Reinauer5ff7c132011-10-31 12:56:45 -070081
Frank Vibrans7b904d82011-02-14 19:00:13 +000082 case KBC1100_KBC:
83 res0 = find_resource(dev, PNP_IDX_IO0);
84 res1 = find_resource(dev, PNP_IDX_IO1);
85 pc_keyboard_init(&conf->keyboard);
86 break;
87 }
88}
89
90static void pnp_enter_conf_state(device_t dev)
91{
92 outb(0x55, dev->path.pnp.port);
93}
94
95static void pnp_exit_conf_state(device_t dev)
96{
97 outb(0xaa, dev->path.pnp.port);
98}