Uwe Hermann | 3fa1363 | 2007-07-12 13:13:56 +0000 | [diff] [blame] | 1 | /* |
Stefan Reinauer | 7e61e45 | 2008-01-18 10:35:56 +0000 | [diff] [blame] | 2 | * This file is part of the coreboot project. |
Uwe Hermann | 3fa1363 | 2007-07-12 13:13:56 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2007 Uwe Hermann <uwe@hermann-uwe.de> |
Edward O'Callaghan | fdceb48 | 2014-06-02 07:58:14 +1000 | [diff] [blame] | 5 | * Copyright (C) 2014 Edward O'Callaghan <eocallaghan@alterapraxis.com> |
Uwe Hermann | 3fa1363 | 2007-07-12 13:13:56 +0000 | [diff] [blame] | 6 | * |
| 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 Hermann | 3fa1363 | 2007-07-12 13:13:56 +0000 | [diff] [blame] | 16 | */ |
| 17 | |
Stefan Reinauer | 24d1d4b | 2013-03-21 11:51:41 -0700 | [diff] [blame] | 18 | #include <arch/io.h> |
Patrick Georgi | 3d5bb23 | 2010-05-09 21:15:13 +0000 | [diff] [blame] | 19 | #include <device/pnp_def.h> |
Edward O'Callaghan | fdceb48 | 2014-06-02 07:58:14 +1000 | [diff] [blame] | 20 | #include <stdint.h> |
Uwe Hermann | 3fa1363 | 2007-07-12 13:13:56 +0000 | [diff] [blame] | 21 | |
Edward O'Callaghan | fdceb48 | 2014-06-02 07:58:14 +1000 | [diff] [blame] | 22 | #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'Callaghan | 85836c2 | 2014-07-09 20:26:25 +1000 | [diff] [blame] | 28 | static void pnp_enter_conf_state(pnp_devfn_t dev) |
Edward O'Callaghan | fdceb48 | 2014-06-02 07:58:14 +1000 | [diff] [blame] | 29 | { |
| 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'Callaghan | 85836c2 | 2014-07-09 20:26:25 +1000 | [diff] [blame] | 35 | static void pnp_exit_conf_state(pnp_devfn_t dev) |
Edward O'Callaghan | fdceb48 | 2014-06-02 07:58:14 +1000 | [diff] [blame] | 36 | { |
| 37 | u16 port = dev >> 8; |
| 38 | outb(SMSC_EXIT_KEY, port); |
| 39 | } |
| 40 | |
Uwe Hermann | 3fa1363 | 2007-07-12 13:13:56 +0000 | [diff] [blame] | 41 | |
| 42 | /** |
| 43 | * Enable the specified serial port. |
| 44 | * |
| 45 | * @param dev The device to use. |
Christopher Kilgour | 7bc63fd | 2008-04-19 13:32:19 +0000 | [diff] [blame] | 46 | * @param iobase The I/O base of the serial port (usually 0x3f8/0x2f8). |
Uwe Hermann | 3fa1363 | 2007-07-12 13:13:56 +0000 | [diff] [blame] | 47 | */ |
Edward O'Callaghan | 85836c2 | 2014-07-09 20:26:25 +1000 | [diff] [blame] | 48 | void smscsuperio_enable_serial(pnp_devfn_t dev, u16 iobase) |
Uwe Hermann | 3fa1363 | 2007-07-12 13:13:56 +0000 | [diff] [blame] | 49 | { |
Edward O'Callaghan | fdceb48 | 2014-06-02 07:58:14 +1000 | [diff] [blame] | 50 | pnp_enter_conf_state(dev); |
Uwe Hermann | 3fa1363 | 2007-07-12 13:13:56 +0000 | [diff] [blame] | 51 | 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'Callaghan | fdceb48 | 2014-06-02 07:58:14 +1000 | [diff] [blame] | 55 | pnp_exit_conf_state(dev); |
Uwe Hermann | 3fa1363 | 2007-07-12 13:13:56 +0000 | [diff] [blame] | 56 | } |