tree: drop last paragraph of GPL copyright header
[coreboot.git] / src / superio / smsc / sio1036 / sio1036_early_init.c
blobb01151061c84e6e493abbe5c6f1d37b39a770465
1 /*
2 * This file is part of the coreboot project.
4 * Copyright (C) 2012 Advanced Micro Devices, Inc.
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.
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.
16 /* Pre-RAM driver for the SMSC KBC1100 Super I/O chip */
18 #include <arch/io.h>
19 #include <stdint.h>
21 #include "sio1036.h"
23 static inline void sio1036_enter_conf_state(pnp_devfn_t dev)
25 unsigned port = dev >> 8;
26 outb(0x55, port);
29 static inline void sio1036_exit_conf_state(pnp_devfn_t dev)
31 unsigned port = dev >> 8;
32 outb(0xaa, port);
35 /* Detect SMSC SIO1036 LPC Debug Card status */
36 static u8 detect_sio1036_chip(unsigned port)
38 pnp_devfn_t dev = PNP_DEV(port, SIO1036_SP1);
39 unsigned data;
41 sio1036_enter_conf_state (dev);
42 data = pnp_read_config (dev, 0x0D);
43 sio1036_exit_conf_state(dev);
45 /* Detect SMSC SIO1036 chip */
46 if (data == 0x82) {
47 /* Found SMSC SIO1036 chip */
48 return 0;
50 else {
51 return 1;
55 void sio1036_enable_serial(pnp_devfn_t dev, u16 iobase)
57 unsigned port = dev >> 8;
59 if (detect_sio1036_chip(port) != 0)
60 return;
62 sio1036_enter_conf_state (dev);
64 /* Enable SMSC UART 0 */
65 /* Valid configuration cycle */
66 pnp_write_config (dev, 0x00, 0x28);
68 /* PP power/mode/cr lock */
69 pnp_write_config (dev, 0x01, 0x98 | LPT_POWER_DOWN);
70 pnp_write_config (dev, 0x02, 0x08 | UART_POWER_DOWN);
72 /*Auto power management*/
73 pnp_write_config (dev, 0x07, 0x00 );
75 /*ECP FIFO threhod */
76 pnp_write_config (dev, 0x0A, 0x00 | IR_OUPUT_MUX);
78 /*GPIO direction register 2 */
79 pnp_write_config (dev, 0x033, 0x00);
81 /*UART Mode */
82 pnp_write_config (dev, 0x0C, 0x02);
84 /* GPIO polarity regisgter 2 */
85 pnp_write_config (dev, 0x034, 0x00);
87 /* Enable SMSC UART 0 */
88 /*Set base io address */
89 pnp_write_config (dev, 0x25, (u8)(iobase >> 2));
91 /* Set UART IRQ onto 0x04 */
92 pnp_write_config (dev, 0x28, 0x04);
94 sio1036_exit_conf_state(dev);