blob: 21f7adf4c11db2f28c95e421a9639d254dea61b7 [file] [log] [blame]
Mondrian nuessle21da0192009-04-22 20:30:42 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2009 University of Heidelberg
Uwe Hermannfff87d32009-06-01 01:38:29 +00005 * Written by Mondrian Nuessle <nuessle@uni-heidelberg.de> for Univ. Heidelberg
Mondrian nuessle21da0192009-04-22 20:30:42 +00006 *
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.
Mondrian nuessle21da0192009-04-22 20:30:42 +000016 */
17
Uwe Hermannfff87d32009-06-01 01:38:29 +000018/* PILOT Super I/O is only based on LPC observation done on factory system. */
Mondrian nuessle21da0192009-04-22 20:30:42 +000019
Stefan Reinauer24d1d4b2013-03-21 11:51:41 -070020#include <arch/io.h>
Edward O'Callaghanf18abab2014-03-31 21:53:32 +110021#include <device/pnp.h>
Mondrian nuessle21da0192009-04-22 20:30:42 +000022#include "pilot.h"
23
Uwe Hermannfff87d32009-06-01 01:38:29 +000024/* Pilot uses 0x5A/0xA5 pattern to actiavte deactivate config access. */
Edward O'Callaghan85836c22014-07-09 20:26:25 +100025void pnp_enter_ext_func_mode(pnp_devfn_t dev)
Mondrian nuessle21da0192009-04-22 20:30:42 +000026{
Uwe Hermann8c023682010-11-06 23:36:49 +000027 u16 port = dev >> 8;
Mondrian nuessle21da0192009-04-22 20:30:42 +000028 outb(0x5A, port);
29}
30
Edward O'Callaghan85836c22014-07-09 20:26:25 +100031void pnp_exit_ext_func_mode(pnp_devfn_t dev)
Mondrian nuessle21da0192009-04-22 20:30:42 +000032{
Uwe Hermann8c023682010-11-06 23:36:49 +000033 u16 port = dev >> 8;
Mondrian nuessle21da0192009-04-22 20:30:42 +000034 outb(0xA5, port);
35}
36
Uwe Hermannfff87d32009-06-01 01:38:29 +000037/* Serial config is a fairly standard procedure. */
Edward O'Callaghan85836c22014-07-09 20:26:25 +100038void pilot_enable_serial(pnp_devfn_t dev, u16 iobase)
Mondrian nuessle21da0192009-04-22 20:30:42 +000039{
40 pnp_enter_ext_func_mode(dev);
41 pnp_set_logical_device(dev);
42 pnp_set_iobase(dev, PNP_IDX_IO0, iobase);
43 pnp_set_enable(dev, 1);
44 pnp_exit_ext_func_mode(dev);
45}
46
Edward O'Callaghan85836c22014-07-09 20:26:25 +100047void pilot_disable_serial(pnp_devfn_t dev)
Mondrian nuessle21da0192009-04-22 20:30:42 +000048{
49 pnp_enter_ext_func_mode(dev);
50 pnp_set_logical_device(dev);
Uwe Hermann8c023682010-11-06 23:36:49 +000051 pnp_set_iobase(dev, PNP_IDX_IO0, 0x0000);
Mondrian nuessle21da0192009-04-22 20:30:42 +000052 pnp_set_enable(dev, 0);
53 pnp_exit_ext_func_mode(dev);
54}