blob: 43a9ee61ccd545094819a89262ed5209c93d422f [file] [log] [blame]
Edward O'Callaghan962b6c02014-01-23 22:12:25 +11001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2014 Edward O'Callaghan <eocallaghan@alterapraxis.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.
Edward O'Callaghan962b6c02014-01-23 22:12:25 +110015 */
16
17#include <arch/io.h>
18#include <device/device.h>
19#include <device/pnp.h>
20#include <superio/conf_mode.h>
21#include <console/console.h>
22#include <stdlib.h>
Edward O'Callaghane1fe6882014-04-30 20:41:41 +100023#include <pc80/keyboard.h>
Edward O'Callaghan962b6c02014-01-23 22:12:25 +110024
Edward O'Callaghandd2e8c32014-04-24 02:58:11 +100025#include "fintek_internal.h"
Edward O'Callaghan962b6c02014-01-23 22:12:25 +110026#include "chip.h"
27#include "f71869ad.h"
28
Edward O'Callaghanf21bdc32014-10-21 07:43:41 +110029static void f71869ad_init(struct device *dev)
Edward O'Callaghan962b6c02014-01-23 22:12:25 +110030{
Edward O'Callaghan962b6c02014-01-23 22:12:25 +110031 if (!dev->enabled)
32 return;
33
34 switch(dev->path.pnp.device) {
35 /* TODO: Might potentially need code for HWM or FDC etc. */
36 case F71869AD_KBC:
Timothy Pearson448e3862015-11-24 14:12:01 -060037 pc_keyboard_init(NO_AUX_DEVICE);
Edward O'Callaghan962b6c02014-01-23 22:12:25 +110038 break;
Edward O'Callaghandd2e8c32014-04-24 02:58:11 +100039 case F71869AD_HWM:
40 f71869ad_multifunc_init(dev);
Edward O'Callaghan63f28c02014-04-26 15:21:45 +100041 f71869ad_hwm_init(dev);
Edward O'Callaghandd2e8c32014-04-24 02:58:11 +100042 break;
Edward O'Callaghan962b6c02014-01-23 22:12:25 +110043 }
44}
45
46static 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 = f71869ad_init,
52 .ops_pnp_mode = &pnp_conf_mode_8787_aa,
53};
54
55/*
Felix Heldb6667932014-07-15 19:36:43 +020056 * io_info contains the mask 0x07f8. Given 8 register, each 8 bits wide of a
Edward O'Callaghan962b6c02014-01-23 22:12:25 +110057 * logical device we need a mask of the following form:
58 *
59 * MSB LSB
60 * v v
61 * 0x[15..11][10..3][2..0]
62 * ------ ^^^^^ ^^^^
63 * null | |
64 * | +------ Register index
65 * |
66 * +------------- Compare against base address and
67 * asserts a chip_select on match.
68 *
69 * i.e., 0x07F8 = [00000][11111111][000]
70 *
Edward O'Callaghanb5fc67a2014-02-10 12:08:36 +110071 * NOTE: Be sure to set these in your devicetree.cb, i.e.
72 *
73 * chip superio/fintek/f71869ad
74 * device pnp 4e.00 off # Floppy
75 * io 0x60 = 0x3f0
76 * irq 0x70 = 6
77 * drq 0x74 = 2
78 * end
79 * device pnp 4e.01 on # COM1
80 * io 0x60 = 0x3f8
81 * irq 0x70 = 4
82 * end
83 * device pnp 4e.02 off # COM2
84 * io 0x60 = 0x2f8
85 * irq 0x70 = 3
86 * end
87 * device pnp 4e.03 off # Parallel Port
88 * io 0x60 = 0x378
89 * irq 0x70 = 7
90 * drq 0x74 = 3
91 * end
92 * device pnp 4e.04 on # Hardware Monitor
93 * io 0x60 = 0x295
94 * irq 0x70 = 0
95 * end
96 * device pnp 4e.05 on # KBC
97 * io 0x60 = 0x060
98 * irq 0x70 = 1 # Keyboard IRQ
99 * irq 0x72 = 12 # Mouse IRQ
100 * end
101 * device pnp 4e.06 off end # GPIO
Edward O'Callaghanc8480982014-05-08 19:50:55 +1000102 * device pnp 4e.07 on end # WDT
103 * device pnp 4e.08 off end # CIR
104 * device pnp 4e.0a on end # PME
Edward O'Callaghanb5fc67a2014-02-10 12:08:36 +1100105 * end # f71869ad
106 *
Edward O'Callaghan962b6c02014-01-23 22:12:25 +1100107 */
108static struct pnp_info pnp_dev_info[] = {
Samuel Holland7daac912017-06-06 22:55:01 -0500109 { &ops, F71869AD_FDC, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, 0x07f8, },
110 { &ops, F71869AD_SP1, PNP_IO0 | PNP_IRQ0, 0x07f8, },
111 { &ops, F71869AD_SP2, PNP_IO0 | PNP_IRQ0, 0x07f8, },
112 { &ops, F71869AD_PP, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, 0x07f8, },
113 { &ops, F71869AD_HWM, PNP_IO0 | PNP_IRQ0, 0x0ff8, },
114 { &ops, F71869AD_KBC, PNP_IO0 | PNP_IRQ0 | PNP_IRQ1, 0x07ff, },
Edward O'Callaghan962b6c02014-01-23 22:12:25 +1100115 { &ops, F71869AD_GPIO, },
Edward O'Callaghanc8480982014-05-08 19:50:55 +1000116 { &ops, F71869AD_WDT, },
Samuel Holland7daac912017-06-06 22:55:01 -0500117 { &ops, F71869AD_CIR, PNP_IO0 | PNP_IRQ0, 0x07f8, },
Edward O'Callaghan962b6c02014-01-23 22:12:25 +1100118 { &ops, F71869AD_PME, },
119};
120
Edward O'Callaghanf21bdc32014-10-21 07:43:41 +1100121static void enable_dev(struct device *dev)
Edward O'Callaghan962b6c02014-01-23 22:12:25 +1100122{
123 pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
124}
125
126struct chip_operations superio_fintek_f71869ad_ops = {
127 CHIP_NAME("Fintek F71869AD Super I/O")
128 .enable_dev = enable_dev
129};