blob: 64bd058c0cc0fbd4edec4fb3775a4360ebf91e81 [file] [log] [blame]
Juhana Helovuoa8c84902010-12-06 01:11:12 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2010 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.
Juhana Helovuoa8c84902010-12-06 01:11:12 +000014 */
15
16#include <console/console.h>
17#include <device/device.h>
18#include <device/pci.h>
19#include <arch/io.h>
20#include <cpu/x86/msr.h>
21#include <cpu/amd/mtrr.h>
22#include <device/pci_def.h>
efdesign9800c8c4a2011-07-20 12:37:58 -060023#include "southbridge/amd/sb700/sb700.h"
24#include "southbridge/amd/sb700/smbus.h"
Juhana Helovuoa8c84902010-12-06 01:11:12 +000025
26
Juhana Helovuoa8c84902010-12-06 01:11:12 +000027void set_pcie_dereset(void);
28void set_pcie_reset(void);
29u8 is_dev3_present(void);
30
31void set_pcie_dereset()
32{
33 u8 byte;
34 u16 word;
35 device_t sm_dev;
36 /* set 0 to bit1 :disable GPM9 as SLP_S2 output */
37 /* set 0 to bit2 :disable GPM8 as AZ_RST output */
38 byte = pm_ioread(0x8d);
39 byte &= ~((1 << 1) | (1 << 2));
40 pm_iowrite(0x8d, byte);
41
42 /* set the GPM8 and GPM9 output enable and the value to 1 */
43 byte = pm_ioread(0x94);
44 byte &= ~((1 << 2) | (1 << 3));
45 byte |= ((1 << 0) | (1 << 1));
46 pm_iowrite(0x94, byte);
47
48 /* set the GPIO65 output enable and the value is 1 */
49 sm_dev = dev_find_slot(0, PCI_DEVFN(0x14, 0));
50 word = pci_read_config16(sm_dev, 0x7e);
51 word |= (1 << 0);
52 word &= ~(1 << 4);
53 pci_write_config16(sm_dev, 0x7e, word);
54}
55
56void set_pcie_reset()
57{
58 u8 byte;
59 u16 word;
60 device_t sm_dev;
61
62 /* set 0 to bit1 :disable GPM9 as SLP_S2 output */
63 /* set 0 to bit2 :disable GPM8 as AZ_RST output */
64 byte = pm_ioread(0x8d);
65 byte &= ~((1 << 1) | (1 << 2));
66 pm_iowrite(0x8d, byte);
67
68 /* set the GPM8 and GPM9 output enable and the value to 0 */
69 byte = pm_ioread(0x94);
70 byte &= ~((1 << 2) | (1 << 3));
71 byte &= ~((1 << 0) | (1 << 1));
72 pm_iowrite(0x94, byte);
73
74 /* set the GPIO65 output enable and the value is 0 */
75 sm_dev = dev_find_slot(0, PCI_DEVFN(0x14, 0));
76 word = pci_read_config16(sm_dev, 0x7e);
77 word &= ~(1 << 0);
78 word &= ~(1 << 4);
79 pci_write_config16(sm_dev, 0x7e, word);
80}
81
Juhana Helovuoa8c84902010-12-06 01:11:12 +000082/*
83 * justify the dev3 is exist or not
84 * NOTE: This just copied from AMD Tilapia code.
85 * It is completly unknown if it will work at all for this board.
86 */
87u8 is_dev3_present(void)
88{
89 u16 word;
90 device_t sm_dev;
91
92 /* access the smbus extended register */
93 sm_dev = dev_find_slot(0, PCI_DEVFN(0x14, 0));
94
95 /* put the GPIO68 output to tristate */
96 word = pci_read_config16(sm_dev, 0x7e);
97 word |= 1 << 6;
98 pci_write_config16(sm_dev, 0x7e,word);
99
100 /* read the GPIO68 input status */
101 word = pci_read_config16(sm_dev, 0x7e);
102
103 if(word & (1 << 10)){
104 /*not exist*/
105 return 0;
106 }else{
107 /*exist*/
108 return 1;
109 }
110}
111
112
113/*************************************************
114* enable the dedicated function in this board.
115* This function called early than rs780_enable.
116*************************************************/
Paul Menzel528640d2013-02-23 21:31:23 +0100117static void mainboard_enable(device_t dev)
Juhana Helovuoa8c84902010-12-06 01:11:12 +0000118{
119 printk(BIOS_INFO, "Mainboard enable. dev=0x%p\n", dev);
120
Juhana Helovuoa8c84902010-12-06 01:11:12 +0000121 set_pcie_dereset();
122 /* get_ide_dma66(); */
123 /* set_thermal_config(); */
124}
125
126struct chip_operations mainboard_ops = {
Paul Menzel528640d2013-02-23 21:31:23 +0100127 .enable_dev = mainboard_enable,
Juhana Helovuoa8c84902010-12-06 01:11:12 +0000128};