blob: 7845ab83be28105dbab2fbaff0ccbc6619887c2b [file] [log] [blame]
Uwe Hermann3fa13632007-07-12 13:13:56 +00001/*
Stefan Reinauer7e61e452008-01-18 10:35:56 +00002 * This file is part of the coreboot project.
Uwe Hermann3fa13632007-07-12 13:13:56 +00003 *
4 * Copyright (C) 2007 Uwe Hermann <uwe@hermann-uwe.de>
Edward O'Callaghanfdceb482014-06-02 07:58:14 +10005 * Copyright (C) 2014 Edward O'Callaghan <eocallaghan@alterapraxis.com>
Uwe Hermann3fa13632007-07-12 13:13:56 +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.
Uwe Hermann3fa13632007-07-12 13:13:56 +000016 */
17
Stefan Reinauer24d1d4b2013-03-21 11:51:41 -070018#include <arch/io.h>
Patrick Georgi3d5bb232010-05-09 21:15:13 +000019#include <device/pnp_def.h>
Edward O'Callaghanfdceb482014-06-02 07:58:14 +100020#include <stdint.h>
Uwe Hermann3fa13632007-07-12 13:13:56 +000021
Edward O'Callaghanfdceb482014-06-02 07:58:14 +100022#include "smscsuperio.h"
23
24#define SMSC_ENTRY_KEY 0x55
25#define SMSC_EXIT_KEY 0xAA
26
27/* Enable configuration: pass entry key '0x87' into index port dev. */
Edward O'Callaghan85836c22014-07-09 20:26:25 +100028static void pnp_enter_conf_state(pnp_devfn_t dev)
Edward O'Callaghanfdceb482014-06-02 07:58:14 +100029{
30 u16 port = dev >> 8;
31 outb(SMSC_ENTRY_KEY, port);
32}
33
34/* Disable configuration: pass exit key '0xAA' into index port dev. */
Edward O'Callaghan85836c22014-07-09 20:26:25 +100035static void pnp_exit_conf_state(pnp_devfn_t dev)
Edward O'Callaghanfdceb482014-06-02 07:58:14 +100036{
37 u16 port = dev >> 8;
38 outb(SMSC_EXIT_KEY, port);
39}
40
Uwe Hermann3fa13632007-07-12 13:13:56 +000041
42/**
43 * Enable the specified serial port.
44 *
45 * @param dev The device to use.
Christopher Kilgour7bc63fd2008-04-19 13:32:19 +000046 * @param iobase The I/O base of the serial port (usually 0x3f8/0x2f8).
Uwe Hermann3fa13632007-07-12 13:13:56 +000047 */
Edward O'Callaghan85836c22014-07-09 20:26:25 +100048void smscsuperio_enable_serial(pnp_devfn_t dev, u16 iobase)
Uwe Hermann3fa13632007-07-12 13:13:56 +000049{
Edward O'Callaghanfdceb482014-06-02 07:58:14 +100050 pnp_enter_conf_state(dev);
Uwe Hermann3fa13632007-07-12 13:13:56 +000051 pnp_set_logical_device(dev);
52 pnp_set_enable(dev, 0);
53 pnp_set_iobase(dev, PNP_IDX_IO0, iobase);
54 pnp_set_enable(dev, 1);
Edward O'Callaghanfdceb482014-06-02 07:58:14 +100055 pnp_exit_conf_state(dev);
Uwe Hermann3fa13632007-07-12 13:13:56 +000056}