blob: cbe1a9efb7a82d99cee3c6be3abec635a40f0a2d [file] [log] [blame]
Nico Huber1c811282013-06-15 20:33:44 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 Nico Huber <nico.h@gmx.de>
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; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Nico Huber1c811282013-06-15 20:33:44 +020014 */
15
16#include <arch/io.h>
17#include <device/device.h>
18#include <superio/conf_mode.h>
19
20/* Common enter/exit implementations */
21
Edward O'Callaghan377fd752014-10-21 07:51:24 +110022void pnp_enter_conf_mode_55(struct device *dev)
Nico Huber1c811282013-06-15 20:33:44 +020023{
24 outb(0x55, dev->path.pnp.port);
25}
26
Edward O'Callaghanb14bf882014-11-01 09:14:58 +110027void pnp_enter_conf_mode_6767(struct device *dev)
28{
29 outb(0x67, dev->path.pnp.port);
30 outb(0x67, dev->path.pnp.port);
31}
32
33void pnp_enter_conf_mode_7777(struct device *dev)
34{
35 outb(0x77, dev->path.pnp.port);
36 outb(0x77, dev->path.pnp.port);
37}
38
Edward O'Callaghan377fd752014-10-21 07:51:24 +110039void pnp_enter_conf_mode_8787(struct device *dev)
Nico Huber1c811282013-06-15 20:33:44 +020040{
41 outb(0x87, dev->path.pnp.port);
42 outb(0x87, dev->path.pnp.port);
43}
44
Edward O'Callaghanb14bf882014-11-01 09:14:58 +110045void pnp_enter_conf_mode_a0a0(struct device *dev)
46{
47 outb(0xa0, dev->path.pnp.port);
48 outb(0xa0, dev->path.pnp.port);
49}
50
Edward O'Callaghan377fd752014-10-21 07:51:24 +110051void pnp_exit_conf_mode_aa(struct device *dev)
Nico Huber1c811282013-06-15 20:33:44 +020052{
53 outb(0xaa, dev->path.pnp.port);
54}
55
Edward O'Callaghan377fd752014-10-21 07:51:24 +110056void pnp_enter_conf_mode_870155aa(struct device *dev)
Edward O'Callaghanbf9f2432014-05-06 17:24:59 +100057{
58 outb(0x87, dev->path.pnp.port);
59 outb(0x01, dev->path.pnp.port);
60 outb(0x55, dev->path.pnp.port);
61
62 if (dev->path.pnp.port == 0x4e)
63 outb(0xaa, dev->path.pnp.port);
64 else
65 outb(0x55, dev->path.pnp.port);
66}
67
Edward O'Callaghan377fd752014-10-21 07:51:24 +110068void pnp_exit_conf_mode_0202(struct device *dev)
Edward O'Callaghanbf9f2432014-05-06 17:24:59 +100069{
70 outb(0x02, dev->path.pnp.port);
71 outb(0x02, dev->path.pnp.port + 1);
72}
73
74
Nico Huber1c811282013-06-15 20:33:44 +020075const struct pnp_mode_ops pnp_conf_mode_55_aa = {
76 .enter_conf_mode = pnp_enter_conf_mode_55,
77 .exit_conf_mode = pnp_exit_conf_mode_aa,
78};
79
Edward O'Callaghanb14bf882014-11-01 09:14:58 +110080const struct pnp_mode_ops pnp_conf_mode_6767_aa = {
81 .enter_conf_mode = pnp_enter_conf_mode_6767,
82 .exit_conf_mode = pnp_exit_conf_mode_aa,
83};
84
85const struct pnp_mode_ops pnp_conf_mode_7777_aa = {
86 .enter_conf_mode = pnp_enter_conf_mode_7777,
87 .exit_conf_mode = pnp_exit_conf_mode_aa,
88};
89
Nico Huber1c811282013-06-15 20:33:44 +020090const struct pnp_mode_ops pnp_conf_mode_8787_aa = {
91 .enter_conf_mode = pnp_enter_conf_mode_8787,
92 .exit_conf_mode = pnp_exit_conf_mode_aa,
93};
Edward O'Callaghanbf9f2432014-05-06 17:24:59 +100094
Edward O'Callaghanb14bf882014-11-01 09:14:58 +110095const struct pnp_mode_ops pnp_conf_mode_a0a0_aa = {
96 .enter_conf_mode = pnp_enter_conf_mode_a0a0,
97 .exit_conf_mode = pnp_exit_conf_mode_aa,
98};
99
Edward O'Callaghanbf9f2432014-05-06 17:24:59 +1000100const struct pnp_mode_ops pnp_conf_mode_870155_aa = {
101 .enter_conf_mode = pnp_enter_conf_mode_870155aa,
102 .exit_conf_mode = pnp_exit_conf_mode_0202,
103};