blob: 91a3c777f5a59a57176a12c945173800a0f3b31e [file] [log] [blame]
Zheng Bao9db833b2009-12-28 09:59:44 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2000 AG Electronics Ltd.
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.
Zheng Bao9db833b2009-12-28 09:59:44 +000015 */
arch import user (historical)577f1852005-07-06 17:11:02 +000016
17#include <arch/io.h>
18#include <console/console.h>
19#include <device/device.h>
20#include <device/pnp.h>
Carl-Daniel Hailfinger2ee67792008-10-01 12:52:52 +000021#include <stdlib.h>
Edward O'Callaghandef00be2014-04-30 05:01:52 +100022#include <pc80/keyboard.h>
arch import user (historical)577f1852005-07-06 17:11:02 +000023#include "pc97317.h"
24
Edward O'Callaghanf21bdc32014-10-21 07:43:41 +110025static void init(struct device *dev)
arch import user (historical)577f1852005-07-06 17:11:02 +000026{
Uwe Hermanna69d9782010-11-15 19:35:14 +000027 if (!dev->enabled)
arch import user (historical)577f1852005-07-06 17:11:02 +000028 return;
Uwe Hermanna69d9782010-11-15 19:35:14 +000029
Stefan Reinauer2b34db82009-02-28 20:10:20 +000030 switch(dev->path.pnp.device) {
arch import user (historical)577f1852005-07-06 17:11:02 +000031 case PC97317_KBCK:
arch import user (historical)577f1852005-07-06 17:11:02 +000032 pnp_set_logical_device(dev);
Uwe Hermanna69d9782010-11-15 19:35:14 +000033 pnp_set_enable(dev, 0); /* Disable keyboard */
34 pnp_write_config(dev, 0xf0, 0x40); /* Set KBC clock to 8 MHz. */
35 pnp_set_enable(dev, 1); /* Enable keyboard */
Timothy Pearson448e3862015-11-24 14:12:01 -060036 pc_keyboard_init(NO_AUX_DEVICE);
arch import user (historical)577f1852005-07-06 17:11:02 +000037 break;
arch import user (historical)577f1852005-07-06 17:11:02 +000038 default:
39 break;
40 }
41}
42
43static struct device_operations ops = {
44 .read_resources = pnp_read_resources,
45 .set_resources = pnp_set_resources,
46 .enable_resources = pnp_enable_resources,
47 .enable = pnp_enable,
48 .init = init,
49};
50
51static struct pnp_info pnp_dev_info[] = {
Uwe Hermanna69d9782010-11-15 19:35:14 +000052 { &ops, PC97317_KBCK, PNP_IO0 | PNP_IO1 | PNP_IRQ0, {0x0ffb, 0}, {0x0ffb, 4}, },
53 { &ops, PC97317_KBCM, PNP_IRQ0, },
54 { &ops, PC97317_RTC, PNP_IO0 | PNP_IRQ0, {0xfffe, 0}, },
55 { &ops, PC97317_FDC, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, {0xfffa, 0}, },
56 { &ops, PC97317_PP, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, {0x03fc, 0}, },
57 { &ops, PC97317_SP2, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0 | PNP_DRQ1, {0xfff8, 0}, },
58 { &ops, PC97317_SP1, PNP_IO0 | PNP_IRQ0, {0xfff8, 0}, },
59 { &ops, PC97317_GPIO, PNP_IO0, {0xfff8, 0}, },
60 { &ops, PC97317_PM, PNP_IO0, {0xfffe, 0}, },
arch import user (historical)577f1852005-07-06 17:11:02 +000061};
62
63static void enable_dev(struct device *dev)
64{
Uwe Hermanna69d9782010-11-15 19:35:14 +000065 pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
arch import user (historical)577f1852005-07-06 17:11:02 +000066}
67
Uwe Hermannd86417b2006-10-24 23:00:42 +000068struct chip_operations superio_nsc_pc97317_ops = {
Uwe Hermanna7aa29b2006-11-05 18:50:49 +000069 CHIP_NAME("NSC PC97317 Super I/O")
arch import user (historical)577f1852005-07-06 17:11:02 +000070 .enable_dev = enable_dev,
71};