Zheng Bao | 9db833b | 2009-12-28 09:59:44 +0000 | [diff] [blame] | 1 | /* |
| 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 Bao | 9db833b | 2009-12-28 09:59:44 +0000 | [diff] [blame] | 15 | */ |
arch import user (historical) | 577f185 | 2005-07-06 17:11:02 +0000 | [diff] [blame] | 16 | |
| 17 | #include <arch/io.h> |
| 18 | #include <console/console.h> |
| 19 | #include <device/device.h> |
| 20 | #include <device/pnp.h> |
Carl-Daniel Hailfinger | 2ee6779 | 2008-10-01 12:52:52 +0000 | [diff] [blame] | 21 | #include <stdlib.h> |
Edward O'Callaghan | def00be | 2014-04-30 05:01:52 +1000 | [diff] [blame] | 22 | #include <pc80/keyboard.h> |
arch import user (historical) | 577f185 | 2005-07-06 17:11:02 +0000 | [diff] [blame] | 23 | #include "pc97317.h" |
| 24 | |
Edward O'Callaghan | f21bdc3 | 2014-10-21 07:43:41 +1100 | [diff] [blame] | 25 | static void init(struct device *dev) |
arch import user (historical) | 577f185 | 2005-07-06 17:11:02 +0000 | [diff] [blame] | 26 | { |
Uwe Hermann | a69d978 | 2010-11-15 19:35:14 +0000 | [diff] [blame] | 27 | if (!dev->enabled) |
arch import user (historical) | 577f185 | 2005-07-06 17:11:02 +0000 | [diff] [blame] | 28 | return; |
Uwe Hermann | a69d978 | 2010-11-15 19:35:14 +0000 | [diff] [blame] | 29 | |
Stefan Reinauer | 2b34db8 | 2009-02-28 20:10:20 +0000 | [diff] [blame] | 30 | switch(dev->path.pnp.device) { |
arch import user (historical) | 577f185 | 2005-07-06 17:11:02 +0000 | [diff] [blame] | 31 | case PC97317_KBCK: |
arch import user (historical) | 577f185 | 2005-07-06 17:11:02 +0000 | [diff] [blame] | 32 | pnp_set_logical_device(dev); |
Uwe Hermann | a69d978 | 2010-11-15 19:35:14 +0000 | [diff] [blame] | 33 | 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 Pearson | 448e386 | 2015-11-24 14:12:01 -0600 | [diff] [blame] | 36 | pc_keyboard_init(NO_AUX_DEVICE); |
arch import user (historical) | 577f185 | 2005-07-06 17:11:02 +0000 | [diff] [blame] | 37 | break; |
arch import user (historical) | 577f185 | 2005-07-06 17:11:02 +0000 | [diff] [blame] | 38 | default: |
| 39 | break; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | static 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 | |
| 51 | static struct pnp_info pnp_dev_info[] = { |
Uwe Hermann | a69d978 | 2010-11-15 19:35:14 +0000 | [diff] [blame] | 52 | { &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) | 577f185 | 2005-07-06 17:11:02 +0000 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | static void enable_dev(struct device *dev) |
| 64 | { |
Uwe Hermann | a69d978 | 2010-11-15 19:35:14 +0000 | [diff] [blame] | 65 | pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info); |
arch import user (historical) | 577f185 | 2005-07-06 17:11:02 +0000 | [diff] [blame] | 66 | } |
| 67 | |
Uwe Hermann | d86417b | 2006-10-24 23:00:42 +0000 | [diff] [blame] | 68 | struct chip_operations superio_nsc_pc97317_ops = { |
Uwe Hermann | a7aa29b | 2006-11-05 18:50:49 +0000 | [diff] [blame] | 69 | CHIP_NAME("NSC PC97317 Super I/O") |
arch import user (historical) | 577f185 | 2005-07-06 17:11:02 +0000 | [diff] [blame] | 70 | .enable_dev = enable_dev, |
| 71 | }; |