blob: 0081c2f871631f935ae2e46957ce1afe08b8094e [file] [log] [blame]
WANG Siyuanf77f7342013-08-13 17:09:51 +08001/*
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.
WANG Siyuanf77f7342013-08-13 17:09:51 +080014 */
15
16#include <stdint.h>
17#include <string.h>
18#include <device/pci_def.h>
Kyösti Mälkki207880c2013-12-10 09:03:17 +020019#include <arch/acpi.h>
WANG Siyuanf77f7342013-08-13 17:09:51 +080020#include <arch/io.h>
Aaron Durbindc9f5cd2015-09-08 13:34:43 -050021#include <commonlib/loglevel.h>
Kyösti Mälkki1dea4b12016-12-20 06:43:45 +020022
23#include <northbridge/amd/agesa/state_machine.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110024#include <southbridge/amd/agesa/hudson/hudson.h>
Kyösti Mälkki1dea4b12016-12-20 06:43:45 +020025
Edward O'Callaghan92da2062014-05-13 23:52:30 +100026#include <superio/winbond/common/winbond.h>
27#include <superio/winbond/w83627uhg/w83627uhg.h>
WANG Siyuanf77f7342013-08-13 17:09:51 +080028
29#define SERIAL_DEV PNP_DEV(0x2e, W83627UHG_SP1)
30
Kyösti Mälkki1dea4b12016-12-20 06:43:45 +020031void board_BeforeAgesa(struct sysinfo *cb)
WANG Siyuanf77f7342013-08-13 17:09:51 +080032{
Kyösti Mälkki1dea4b12016-12-20 06:43:45 +020033 volatile u32 *addr32;
34 u32 t32;
WANG Siyuanf77f7342013-08-13 17:09:51 +080035
Kyösti Mälkki88ff8b52014-11-21 17:40:37 +020036 /* Set LPC decode enables. */
37 pci_devfn_t dev = PCI_DEV(0, 0x14, 3);
38 pci_write_config32(dev, 0x44, 0xff03ffd5);
39
WANG Siyuanf77f7342013-08-13 17:09:51 +080040 hudson_lpc_port80();
41
42 /* Enable the AcpiMmio space */
43 outb(0x24, 0xcd6);
44 outb(0x1, 0xcd7);
45
Kyösti Mälkki1dea4b12016-12-20 06:43:45 +020046 /* Disable PCI-PCI bridge and release GPIO32/33 for other uses. */
47 outb(0xea, 0xcd6);
48 outb(0x1, 0xcd7);
49
WANG Siyuanf77f7342013-08-13 17:09:51 +080050 /* Set auxiliary output clock frequency on OSCOUT1 pin to be 48MHz */
51 addr32 = (u32 *)0xfed80e28;
52 t32 = *addr32;
53 t32 &= 0xfff8ffff;
54 *addr32 = t32;
55
56 /* Enable Auxiliary Clock1, disable FCH 14 MHz OscClk */
57 addr32 = (u32 *)0xfed80e40;
58 t32 = *addr32;
59 t32 &= 0xffffbffb;
60 *addr32 = t32;
61
Kyösti Mälkki1dea4b12016-12-20 06:43:45 +020062 /* w83627uhg has a default clk of 48MHz, p.9 of data-sheet */
63 winbond_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
WANG Siyuanf77f7342013-08-13 17:09:51 +080064}