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 | |
Nicola Corna | 2fca86f | 2017-03-02 08:08:45 +0100 | [diff] [blame] | 18 | #include <device/device.h> |
| 19 | #include <device/pnp.h> |
| 20 | #include <superio/conf_mode.h> |
Nicola Corna | 2fca86f | 2017-03-02 08:08:45 +0100 | [diff] [blame] | 21 | #include <stdlib.h> |
| 22 | #include <pc80/keyboard.h> |
| 23 | |
| 24 | #include "f71808a.h" |
| 25 | #include "fintek_internal.h" |
| 26 | |
| 27 | static void f71808a_init(struct device *dev) |
| 28 | { |
| 29 | if (!dev->enabled) |
| 30 | return; |
| 31 | |
| 32 | switch (dev->path.pnp.device) { |
| 33 | /* TODO: Might potentially need code for UART, GPIO... */ |
| 34 | case F71808A_KBC: |
| 35 | pc_keyboard_init(NO_AUX_DEVICE); |
| 36 | break; |
| 37 | case F71808A_HWM: |
| 38 | f71808a_multifunc_init(dev); |
| 39 | f71808a_hwm_init(dev); |
| 40 | break; |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | static struct device_operations ops = { |
| 45 | .read_resources = pnp_read_resources, |
| 46 | .set_resources = pnp_set_resources, |
| 47 | .enable_resources = pnp_enable_resources, |
| 48 | .enable = pnp_alt_enable, |
| 49 | .init = f71808a_init, |
| 50 | .ops_pnp_mode = &pnp_conf_mode_8787_aa, |
| 51 | }; |
| 52 | |
| 53 | static struct pnp_info pnp_dev_info[] = { |
| 54 | /* TODO: Some of the 0x07f8 etc. values may not be correct. */ |
Felix Held | 8ac8ac6 | 2018-07-06 21:43:34 +0200 | [diff] [blame] | 55 | { NULL, F71808A_SP1, PNP_IO0 | PNP_IRQ0, 0x07f8, }, |
| 56 | { NULL, F71808A_HWM, PNP_IO0 | PNP_IRQ0, 0x07f8, }, |
| 57 | { NULL, F71808A_KBC, PNP_IO0 | PNP_IRQ0 | PNP_IRQ1, 0x07ff, }, |
| 58 | { NULL, F71808A_GPIO, PNP_IRQ0, }, |
| 59 | { NULL, F71808A_WDT, PNP_IO0, 0x07f8,}, |
| 60 | { NULL, F71808A_CIR, PNP_IO0 | PNP_IRQ0, 0x07f8, }, |
| 61 | { NULL, F71808A_PME, }, |
Nicola Corna | 2fca86f | 2017-03-02 08:08:45 +0100 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | static void enable_dev(struct device *dev) |
| 65 | { |
| 66 | pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info); |
| 67 | } |
| 68 | |
| 69 | struct chip_operations superio_fintek_f71808a_ops = { |
| 70 | CHIP_NAME("Fintek F71808A Super I/O") |
| 71 | .enable_dev = enable_dev |
| 72 | }; |