Jonathan Kollasch | ab940df | 2010-11-11 22:25:55 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2008 Corey Osgood <corey.osgood@gmail.com> |
| 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. |
Jonathan Kollasch | ab940df | 2010-11-11 22:25:55 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <arch/io.h> |
| 18 | #include <device/device.h> |
| 19 | #include <device/pnp.h> |
Nico Huber | 1c81128 | 2013-06-15 20:33:44 +0200 | [diff] [blame] | 20 | #include <superio/conf_mode.h> |
Jonathan Kollasch | ab940df | 2010-11-11 22:25:55 +0000 | [diff] [blame] | 21 | #include <console/console.h> |
| 22 | #include <stdlib.h> |
Edward O'Callaghan | def00be | 2014-04-30 05:01:52 +1000 | [diff] [blame] | 23 | #include <pc80/keyboard.h> |
Jonathan Kollasch | ab940df | 2010-11-11 22:25:55 +0000 | [diff] [blame] | 24 | #include "f71872.h" |
| 25 | |
Edward O'Callaghan | f21bdc3 | 2014-10-21 07:43:41 +1100 | [diff] [blame] | 26 | static void f71872_init(struct device *dev) |
Jonathan Kollasch | ab940df | 2010-11-11 22:25:55 +0000 | [diff] [blame] | 27 | { |
Jonathan Kollasch | ab940df | 2010-11-11 22:25:55 +0000 | [diff] [blame] | 28 | |
| 29 | if (!dev->enabled) |
| 30 | return; |
| 31 | |
| 32 | switch(dev->path.pnp.device) { |
| 33 | /* TODO: Might potentially need code for HWM or FDC etc. */ |
Jonathan Kollasch | ab940df | 2010-11-11 22:25:55 +0000 | [diff] [blame] | 34 | case F71872_KBC: |
Timothy Pearson | 448e386 | 2015-11-24 14:12:01 -0600 | [diff] [blame] | 35 | pc_keyboard_init(NO_AUX_DEVICE); |
Jonathan Kollasch | ab940df | 2010-11-11 22:25:55 +0000 | [diff] [blame] | 36 | break; |
| 37 | } |
| 38 | } |
| 39 | |
Jonathan Kollasch | ab940df | 2010-11-11 22:25:55 +0000 | [diff] [blame] | 40 | static struct device_operations ops = { |
| 41 | .read_resources = pnp_read_resources, |
Nico Huber | 0b2ee93 | 2013-06-15 19:58:35 +0200 | [diff] [blame] | 42 | .set_resources = pnp_set_resources, |
| 43 | .enable_resources = pnp_enable_resources, |
| 44 | .enable = pnp_alt_enable, |
Jonathan Kollasch | ab940df | 2010-11-11 22:25:55 +0000 | [diff] [blame] | 45 | .init = f71872_init, |
Nico Huber | 1c81128 | 2013-06-15 20:33:44 +0200 | [diff] [blame] | 46 | .ops_pnp_mode = &pnp_conf_mode_8787_aa, |
Jonathan Kollasch | ab940df | 2010-11-11 22:25:55 +0000 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | static struct pnp_info pnp_dev_info[] = { |
Uwe Hermann | a69d978 | 2010-11-15 19:35:14 +0000 | [diff] [blame] | 50 | /* TODO: Some of the 0x07f8 etc. values may not be correct. */ |
Samuel Holland | 7daac91 | 2017-06-06 22:55:01 -0500 | [diff] [blame] | 51 | { &ops, F71872_FDC, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, 0x07f8, }, |
| 52 | { &ops, F71872_SP1, PNP_IO0 | PNP_IRQ0, 0x07f8, }, |
| 53 | { &ops, F71872_SP2, PNP_IO0 | PNP_IRQ0, 0x07f8, }, |
| 54 | { &ops, F71872_PP, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, 0x07f8, }, |
| 55 | { &ops, F71872_HWM, PNP_IO0 | PNP_IRQ0, 0x0ff8, }, |
| 56 | { &ops, F71872_KBC, PNP_IO0 | PNP_IRQ0 | PNP_IRQ1, 0x07ff, }, |
Jonathan Kollasch | ab940df | 2010-11-11 22:25:55 +0000 | [diff] [blame] | 57 | { &ops, F71872_GPIO, PNP_IRQ0, }, |
Samuel Holland | 7daac91 | 2017-06-06 22:55:01 -0500 | [diff] [blame] | 58 | { &ops, F71872_VID, PNP_IO0, 0x0ff8, }, |
Jonathan Kollasch | ab940df | 2010-11-11 22:25:55 +0000 | [diff] [blame] | 59 | { &ops, F71872_PM, }, |
| 60 | }; |
| 61 | |
Edward O'Callaghan | f21bdc3 | 2014-10-21 07:43:41 +1100 | [diff] [blame] | 62 | static void enable_dev(struct device *dev) |
Jonathan Kollasch | ab940df | 2010-11-11 22:25:55 +0000 | [diff] [blame] | 63 | { |
| 64 | pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info); |
| 65 | } |
| 66 | |
| 67 | struct chip_operations superio_fintek_f71872_ops = { |
| 68 | CHIP_NAME("Fintek F71872 Super I/O") |
| 69 | .enable_dev = enable_dev |
| 70 | }; |