Fabian Kunkel | f75c3b4 | 2015-05-25 17:04:28 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2014 Edward O'Callaghan <eocallaghan@alterapraxis.com> |
| 5 | * Copyright (C) 2015 BAP - Bruhnspace Advanced Projects |
| 6 | * (Written by Fabian Kunkel <fabi@adv.bruhnspace.com> for BAP) |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
Fabian Kunkel | f75c3b4 | 2015-05-25 17:04:28 +0200 | [diff] [blame] | 17 | */ |
| 18 | |
| 19 | #include <arch/io.h> |
| 20 | #include <device/device.h> |
| 21 | #include <device/pnp.h> |
| 22 | #include <superio/conf_mode.h> |
| 23 | #include <console/console.h> |
| 24 | #include <stdlib.h> |
| 25 | #include <pc80/keyboard.h> |
| 26 | #include "f81866d.h" |
| 27 | #include "fintek_internal.h" |
| 28 | |
| 29 | static void f81866d_init(struct device *dev) |
| 30 | { |
| 31 | if (!dev->enabled) |
| 32 | return; |
| 33 | |
| 34 | switch (dev->path.pnp.device) { |
| 35 | /* TODO: Might potentially need extra code for serial, wdt etc. */ |
| 36 | case F81866D_KBC: |
Timothy Pearson | 448e386 | 2015-11-24 14:12:01 -0600 | [diff] [blame] | 37 | pc_keyboard_init(NO_AUX_DEVICE); |
Fabian Kunkel | f75c3b4 | 2015-05-25 17:04:28 +0200 | [diff] [blame] | 38 | break; |
| 39 | case F81866D_HWM: |
| 40 | // Fixing temp sensor read out and init Fan control |
| 41 | f81866d_hwm_init(dev); |
| 42 | break; |
Fabian Kunkel | 145796e | 2016-07-07 15:15:18 +0200 | [diff] [blame] | 43 | case F81866D_SP1: |
| 44 | // Enable Uart1 and IRQ share register |
| 45 | f81866d_uart_init(dev); |
| 46 | break; |
| 47 | case F81866D_SP2: |
| 48 | // Enable Uart2 and IRQ share register |
| 49 | f81866d_uart_init(dev); |
| 50 | break; |
| 51 | case F81866D_SP3: |
| 52 | // Enable Uart3 and IRQ share register |
| 53 | f81866d_uart_init(dev); |
| 54 | break; |
| 55 | case F81866D_SP4: |
| 56 | // Enable Uart4 and IRQ share register |
| 57 | f81866d_uart_init(dev); |
| 58 | break; |
Fabian Kunkel | f75c3b4 | 2015-05-25 17:04:28 +0200 | [diff] [blame] | 59 | } |
| 60 | } |
| 61 | |
| 62 | static struct device_operations ops = { |
| 63 | .read_resources = pnp_read_resources, |
| 64 | .set_resources = pnp_set_resources, |
| 65 | .enable_resources = pnp_enable_resources, |
| 66 | .enable = pnp_alt_enable, |
| 67 | .init = f81866d_init, |
| 68 | .ops_pnp_mode = &pnp_conf_mode_8787_aa, |
| 69 | }; |
| 70 | |
| 71 | static struct pnp_info pnp_dev_info[] = { |
| 72 | /* TODO: Some of the 0x7f8 etc. values may not be correct. */ |
Samuel Holland | 7daac91 | 2017-06-06 22:55:01 -0500 | [diff] [blame] | 73 | { &ops, F81866D_FDC, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, 0x07f8, }, |
| 74 | { &ops, F81866D_SP1, PNP_IO0 | PNP_IRQ0, 0x7f8, }, |
| 75 | { &ops, F81866D_SP2, PNP_IO0 | PNP_IRQ0, 0x7f8, }, |
| 76 | { &ops, F81866D_SP3, PNP_IO0 | PNP_IRQ0, 0x7f8, }, |
| 77 | { &ops, F81866D_SP4, PNP_IO0 | PNP_IRQ0, 0x7f8, }, |
| 78 | { &ops, F81866D_SP5, PNP_IO0 | PNP_IRQ0, 0x7f8, }, |
| 79 | { &ops, F81866D_SP6, PNP_IO0 | PNP_IRQ0, 0x7f8, }, |
| 80 | { &ops, F81866D_KBC, PNP_IO0 | PNP_IRQ0 | PNP_IRQ1, 0x07ff, }, |
| 81 | { &ops, F81866D_PP, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, 0x07f8, }, |
| 82 | { &ops, F81866D_HWM, PNP_IO0 | PNP_IRQ0, 0xff8, }, |
Fabian Kunkel | f75c3b4 | 2015-05-25 17:04:28 +0200 | [diff] [blame] | 83 | { &ops, F81866D_GPIO, PNP_IRQ0, }, |
| 84 | { &ops, F81866D_PME, }, |
| 85 | { &ops, F81866D_WDT, }, |
| 86 | }; |
| 87 | |
| 88 | static void enable_dev(struct device *dev) |
| 89 | { |
| 90 | pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info); |
| 91 | } |
| 92 | |
| 93 | struct chip_operations superio_fintek_f81866d_ops = { |
| 94 | CHIP_NAME("Fintek F81866AD-I Super I/O") |
| 95 | .enable_dev = enable_dev |
| 96 | }; |