Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 1 | /* |
| 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 Menzel | a46a712 | 2013-02-23 18:37:27 +0100 | [diff] [blame] | 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 18 | */ |
| 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> |
Nico Huber | 1c81128 | 2013-06-15 20:33:44 +0200 | [diff] [blame^] | 25 | #include <superio/conf_mode.h> |
Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 26 | #include <console/console.h> |
| 27 | #include <device/smbus.h> |
| 28 | #include <string.h> |
Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 29 | #include <uart8250.h> |
| 30 | #include <pc80/keyboard.h> |
| 31 | #include <stdlib.h> |
| 32 | #include "chip.h" |
| 33 | #include "kbc1100.h" |
| 34 | |
| 35 | /* Forward declarations */ |
| 36 | static void enable_dev(device_t dev); |
Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 37 | static void kbc1100_init(device_t dev); |
| 38 | |
Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 39 | struct chip_operations superio_smsc_kbc1100_ops = { |
| 40 | CHIP_NAME("SMSC KBC1100 Super I/O") |
| 41 | .enable_dev = enable_dev |
| 42 | }; |
| 43 | |
| 44 | static struct device_operations ops = { |
| 45 | .read_resources = pnp_read_resources, |
Nico Huber | 0b2ee93 | 2013-06-15 19:58:35 +0200 | [diff] [blame] | 46 | .set_resources = pnp_set_resources, |
| 47 | .enable_resources = pnp_enable_resources, |
| 48 | .enable = pnp_alt_enable, |
Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 49 | .init = kbc1100_init, |
Nico Huber | 1c81128 | 2013-06-15 20:33:44 +0200 | [diff] [blame^] | 50 | .ops_pnp_mode = &pnp_conf_mode_55_aa, |
Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | static struct pnp_info pnp_dev_info[] = { |
| 54 | { &ops, KBC1100_KBC, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_IRQ1, { 0x7ff, 0 }, { 0x7ff, 0x4}, }, |
| 55 | }; |
| 56 | |
| 57 | static void enable_dev(device_t dev) |
| 58 | { |
| 59 | pnp_enable_devices(dev, &pnp_ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info); |
| 60 | } |
| 61 | |
Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 62 | static void kbc1100_init(device_t dev) |
| 63 | { |
| 64 | struct superio_smsc_kbc1100_config *conf = dev->chip_info; |
| 65 | struct resource *res0, *res1; |
| 66 | |
Stefan Reinauer | 5ff7c13 | 2011-10-31 12:56:45 -0700 | [diff] [blame] | 67 | |
| 68 | |
Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 69 | if (!dev->enabled) { |
| 70 | return; |
| 71 | } |
| 72 | |
| 73 | switch(dev->path.pnp.device) { |
Stefan Reinauer | 5ff7c13 | 2011-10-31 12:56:45 -0700 | [diff] [blame] | 74 | |
Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 75 | case KBC1100_KBC: |
| 76 | res0 = find_resource(dev, PNP_IDX_IO0); |
| 77 | res1 = find_resource(dev, PNP_IDX_IO1); |
| 78 | pc_keyboard_init(&conf->keyboard); |
| 79 | break; |
| 80 | } |
| 81 | } |