Nicola Corna | 2fca86f | 2017-03-02 08:08:45 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2008 Corey Osgood <corey.osgood@gmail.com> |
| 5 | * Copyright (C) 2017 Nicola Corna <nicola@corna.info> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | */ |
| 17 | |
| 18 | #include <arch/io.h> |
| 19 | #include <device/device.h> |
| 20 | #include <device/pnp.h> |
| 21 | #include <superio/conf_mode.h> |
| 22 | #include <console/console.h> |
| 23 | #include <stdlib.h> |
| 24 | #include <pc80/keyboard.h> |
| 25 | |
| 26 | #include "f71808a.h" |
| 27 | #include "fintek_internal.h" |
| 28 | |
| 29 | static void f71808a_init(struct device *dev) |
| 30 | { |
| 31 | if (!dev->enabled) |
| 32 | return; |
| 33 | |
| 34 | switch (dev->path.pnp.device) { |
| 35 | /* TODO: Might potentially need code for UART, GPIO... */ |
| 36 | case F71808A_KBC: |
| 37 | pc_keyboard_init(NO_AUX_DEVICE); |
| 38 | break; |
| 39 | case F71808A_HWM: |
| 40 | f71808a_multifunc_init(dev); |
| 41 | f71808a_hwm_init(dev); |
| 42 | break; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | static struct device_operations ops = { |
| 47 | .read_resources = pnp_read_resources, |
| 48 | .set_resources = pnp_set_resources, |
| 49 | .enable_resources = pnp_enable_resources, |
| 50 | .enable = pnp_alt_enable, |
| 51 | .init = f71808a_init, |
| 52 | .ops_pnp_mode = &pnp_conf_mode_8787_aa, |
| 53 | }; |
| 54 | |
| 55 | static struct pnp_info pnp_dev_info[] = { |
| 56 | /* TODO: Some of the 0x07f8 etc. values may not be correct. */ |
Samuel Holland | 7daac91 | 2017-06-06 22:55:01 -0500 | [diff] [blame] | 57 | { &ops, F71808A_SP1, PNP_IO0 | PNP_IRQ0, 0x07f8, }, |
| 58 | { &ops, F71808A_HWM, PNP_IO0 | PNP_IRQ0, 0x07f8, }, |
| 59 | { &ops, F71808A_KBC, PNP_IO0 | PNP_IRQ0 | PNP_IRQ1, 0x07ff, }, |
Nicola Corna | 2fca86f | 2017-03-02 08:08:45 +0100 | [diff] [blame] | 60 | { &ops, F71808A_GPIO, PNP_IRQ0, }, |
Samuel Holland | 7daac91 | 2017-06-06 22:55:01 -0500 | [diff] [blame] | 61 | { &ops, F71808A_WDT, PNP_IO0, 0x07f8,}, |
| 62 | { &ops, F71808A_CIR, PNP_IO0 | PNP_IRQ0, 0x07f8, }, |
Nicola Corna | 2fca86f | 2017-03-02 08:08:45 +0100 | [diff] [blame] | 63 | { &ops, F71808A_PME, }, |
| 64 | }; |
| 65 | |
| 66 | static void enable_dev(struct device *dev) |
| 67 | { |
| 68 | pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info); |
| 69 | } |
| 70 | |
| 71 | struct chip_operations superio_fintek_f71808a_ops = { |
| 72 | CHIP_NAME("Fintek F71808A Super I/O") |
| 73 | .enable_dev = enable_dev |
| 74 | }; |