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. |
Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | /* RAM driver for the SMSC KBC1100 Super I/O chip */ |
| 17 | |
| 18 | #include <arch/io.h> |
| 19 | #include <device/device.h> |
| 20 | #include <device/pnp.h> |
Nico Huber | 1c81128 | 2013-06-15 20:33:44 +0200 | [diff] [blame] | 21 | #include <superio/conf_mode.h> |
Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 22 | #include <console/console.h> |
| 23 | #include <device/smbus.h> |
| 24 | #include <string.h> |
Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 25 | #include <pc80/keyboard.h> |
| 26 | #include <stdlib.h> |
Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 27 | #include "kbc1100.h" |
| 28 | |
| 29 | /* Forward declarations */ |
Edward O'Callaghan | f21bdc3 | 2014-10-21 07:43:41 +1100 | [diff] [blame] | 30 | static void enable_dev(struct device *dev); |
| 31 | static void kbc1100_init(struct device *dev); |
Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 32 | |
Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 33 | struct chip_operations superio_smsc_kbc1100_ops = { |
Arthur Heymans | 12d0103 | 2017-08-01 21:51:10 +0200 | [diff] [blame] | 34 | CHIP_NAME("SMSC KBC1100 Super I/O") |
| 35 | .enable_dev = enable_dev |
Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | static struct device_operations ops = { |
Arthur Heymans | 12d0103 | 2017-08-01 21:51:10 +0200 | [diff] [blame] | 39 | .read_resources = pnp_read_resources, |
| 40 | .set_resources = pnp_set_resources, |
| 41 | .enable_resources = pnp_enable_resources, |
| 42 | .enable = pnp_alt_enable, |
| 43 | .init = kbc1100_init, |
| 44 | .ops_pnp_mode = &pnp_conf_mode_55_aa, |
Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | static struct pnp_info pnp_dev_info[] = { |
Arthur Heymans | 12d0103 | 2017-08-01 21:51:10 +0200 | [diff] [blame] | 48 | { &ops, KBC1100_KBC, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_IRQ1, 0x7ff, |
| 49 | 0x7ff, }, |
Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 50 | }; |
| 51 | |
Edward O'Callaghan | f21bdc3 | 2014-10-21 07:43:41 +1100 | [diff] [blame] | 52 | static void enable_dev(struct device *dev) |
Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 53 | { |
Arthur Heymans | 12d0103 | 2017-08-01 21:51:10 +0200 | [diff] [blame] | 54 | pnp_enable_devices(dev, &pnp_ops, ARRAY_SIZE(pnp_dev_info), |
| 55 | pnp_dev_info); |
Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 56 | } |
| 57 | |
Edward O'Callaghan | f21bdc3 | 2014-10-21 07:43:41 +1100 | [diff] [blame] | 58 | static void kbc1100_init(struct device *dev) |
Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 59 | { |
Arthur Heymans | 12d0103 | 2017-08-01 21:51:10 +0200 | [diff] [blame] | 60 | struct resource *res0, *res1; |
Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 61 | |
Arthur Heymans | 12d0103 | 2017-08-01 21:51:10 +0200 | [diff] [blame] | 62 | if (!dev->enabled) |
| 63 | return; |
Stefan Reinauer | 5ff7c13 | 2011-10-31 12:56:45 -0700 | [diff] [blame] | 64 | |
Arthur Heymans | 12d0103 | 2017-08-01 21:51:10 +0200 | [diff] [blame] | 65 | switch (dev->path.pnp.device) { |
| 66 | case KBC1100_KBC: |
| 67 | res0 = find_resource(dev, PNP_IDX_IO0); |
| 68 | res1 = find_resource(dev, PNP_IDX_IO1); |
| 69 | pc_keyboard_init(NO_AUX_DEVICE); |
| 70 | break; |
| 71 | } |
Frank Vibrans | 7b904d8 | 2011-02-14 19:00:13 +0000 | [diff] [blame] | 72 | } |