Kerry Sheh | c94940c | 2012-02-07 20:31:40 +0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2012 Advanced Micro Devices, Inc. |
| 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. |
Kerry Sheh | c94940c | 2012-02-07 20:31:40 +0800 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | |
Stefan Reinauer | 24d1d4b | 2013-03-21 11:51:41 -0700 | [diff] [blame] | 17 | #include <arch/io.h> |
Kyösti Mälkki | 3855c01 | 2019-03-03 08:45:19 +0200 | [diff] [blame] | 18 | #include <device/pnp_ops.h> |
Edward O'Callaghan | d2da65e | 2014-08-06 21:32:50 +1000 | [diff] [blame] | 19 | #include <device/pnp.h> |
| 20 | #include <stdint.h> |
| 21 | |
Kerry Sheh | c94940c | 2012-02-07 20:31:40 +0800 | [diff] [blame] | 22 | #include "sch4037.h" |
| 23 | |
Edward O'Callaghan | 85836c2 | 2014-07-09 20:26:25 +1000 | [diff] [blame] | 24 | static void pnp_enter_conf_state(pnp_devfn_t dev) |
Kerry Sheh | c94940c | 2012-02-07 20:31:40 +0800 | [diff] [blame] | 25 | { |
Edward O'Callaghan | d2da65e | 2014-08-06 21:32:50 +1000 | [diff] [blame] | 26 | unsigned port = dev >> 8; |
Kerry Sheh | c94940c | 2012-02-07 20:31:40 +0800 | [diff] [blame] | 27 | outb(0x55, port); |
| 28 | } |
| 29 | |
Edward O'Callaghan | 85836c2 | 2014-07-09 20:26:25 +1000 | [diff] [blame] | 30 | static void pnp_exit_conf_state(pnp_devfn_t dev) |
Kerry Sheh | c94940c | 2012-02-07 20:31:40 +0800 | [diff] [blame] | 31 | { |
Edward O'Callaghan | d2da65e | 2014-08-06 21:32:50 +1000 | [diff] [blame] | 32 | unsigned port = dev >> 8; |
Kerry Sheh | c94940c | 2012-02-07 20:31:40 +0800 | [diff] [blame] | 33 | outb(0xaa, port); |
| 34 | } |
| 35 | |
Edward O'Callaghan | d2da65e | 2014-08-06 21:32:50 +1000 | [diff] [blame] | 36 | void sch4037_early_init(unsigned port) |
Kerry Sheh | c94940c | 2012-02-07 20:31:40 +0800 | [diff] [blame] | 37 | { |
Edward O'Callaghan | 85836c2 | 2014-07-09 20:26:25 +1000 | [diff] [blame] | 38 | pnp_devfn_t dev; |
Kerry Sheh | c94940c | 2012-02-07 20:31:40 +0800 | [diff] [blame] | 39 | |
| 40 | dev = PNP_DEV(port, SMSCSUPERIO_SP1); |
| 41 | pnp_enter_conf_state(dev); |
| 42 | |
| 43 | /* Auto power management */ |
| 44 | pnp_write_config(dev, 0x22, 0x38); /* BIT3+BIT4+BIT5 */ |
Elyes HAOUAS | a342f39 | 2018-10-17 10:56:26 +0200 | [diff] [blame] | 45 | pnp_write_config(dev, 0x23, 0); |
Kerry Sheh | c94940c | 2012-02-07 20:31:40 +0800 | [diff] [blame] | 46 | |
| 47 | /* Enable SMSC UART 0 */ |
| 48 | dev = PNP_DEV(port, SMSCSUPERIO_SP1); |
| 49 | pnp_set_logical_device(dev); |
| 50 | pnp_set_enable(dev, 0); |
| 51 | |
| 52 | pnp_set_iobase(dev, PNP_IDX_IO0, CONFIG_TTYS0_BASE); |
| 53 | pnp_set_irq(dev, PNP_IDX_IRQ0, 0x4); |
| 54 | |
| 55 | /* Enabled High speed, disabled MIDI support. */ |
| 56 | pnp_write_config(dev, 0xF0, 0x02); |
| 57 | pnp_set_enable(dev, 1); |
| 58 | |
| 59 | /* Enable keyboard */ |
| 60 | dev = PNP_DEV(port, SCH4037_KBC); |
| 61 | pnp_set_logical_device(dev); |
| 62 | pnp_set_enable(dev, 0); |
| 63 | pnp_set_irq(dev, 0x70, 1); /* IRQ 1 */ |
| 64 | pnp_set_irq(dev, 0x72, 12); /* IRQ 12 */ |
| 65 | pnp_set_enable(dev, 1); |
| 66 | |
| 67 | pnp_exit_conf_state(dev); |
| 68 | } |