blob: 84f049a40f76467c3033602ada50a50601f729a9 [file] [log] [blame]
Wang Qing Pei0ede4c02010-08-17 15:19:32 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2010 Wang Qing Pei <wangqingpei@gmail.com>
5 * Copyright (C) 2010 Advanced Micro Devices, Inc.
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; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include <console/console.h>
22#include <device/device.h>
23#include <device/pci.h>
24#include <arch/io.h>
Wang Qing Pei0ede4c02010-08-17 15:19:32 +000025#include <cpu/x86/msr.h>
26#include <cpu/amd/mtrr.h>
27#include <device/pci_def.h>
efdesign9800c8c4a2011-07-20 12:37:58 -060028#include "southbridge/amd/sb700/sb700.h"
29#include "southbridge/amd/sb700/smbus.h"
Wang Qing Pei0ede4c02010-08-17 15:19:32 +000030
Wang Qing Pei0ede4c02010-08-17 15:19:32 +000031void set_pcie_dereset(void);
32void set_pcie_reset(void);
Wang Qing Peid6c43952010-08-18 01:55:11 +000033u8 is_dev3_present(void);
Wang Qing Pei0ede4c02010-08-17 15:19:32 +000034
35/*
36 * the board uses GPIO 6 as PCIe slot reset, GPIO4 as GFX slot reset. We need to
37 * pull it up before training the slot.
38 ***/
39void set_pcie_dereset()
40{
41 u16 word;
42 device_t sm_dev;
43 /* GPIO 6 reset PCIe slot, GPIO 4 reset GFX PCIe */
44 sm_dev = dev_find_slot(0, PCI_DEVFN(0x14, 0));
45
46 word = pci_read_config16(sm_dev, 0xA8);
47 word |= (1 << 0) | (1 << 2); /* Set Gpio6,4 as output */
48 word &= ~((1 << 8) | (1 << 10));
49 pci_write_config16(sm_dev, 0xA8, word);
50}
51
52void set_pcie_reset()
53{
54 u16 word;
55 device_t sm_dev;
56 /* GPIO 6 reset PCIe slot, GPIO 4 reset GFX PCIe */
57 sm_dev = dev_find_slot(0, PCI_DEVFN(0x14, 0));
58
59 word = pci_read_config16(sm_dev, 0xA8);
60 word &= ~((1 << 0) | (1 << 2)); /* Set Gpio6,4 as output */
61 word &= ~((1 << 8) | (1 << 10));
62 pci_write_config16(sm_dev, 0xA8, word);
63}
64
65#if 0 /* not tested yet. */
66/********************************************************
67* board uses SB700 GPIO9 to detect IDE_DMA66.
68* IDE_DMA66 is routed to GPIO 9. So we read Gpio 9 to
69* get the cable type, 40 pin or 80 pin?
70********************************************************/
71static void get_ide_dma66(void)
72{
73 u8 byte;
74 /*u32 sm_dev, ide_dev; */
75 device_t sm_dev, ide_dev;
76
77 sm_dev = dev_find_slot(0, PCI_DEVFN(0x14, 0));
78
79 byte = pci_read_config8(sm_dev, 0xA9);
80 byte |= (1 << 5); /* Set Gpio9 as input */
81 pci_write_config8(sm_dev, 0xA9, byte);
82
83 ide_dev = dev_find_slot(0, PCI_DEVFN(0x14, 1));
84 byte = pci_read_config8(ide_dev, 0x56);
85 byte &= ~(7 << 0);
86 if ((1 << 5) & pci_read_config8(sm_dev, 0xAA))
87 byte |= 2 << 0; /* mode 2 */
88 else
89 byte |= 5 << 0; /* mode 5 */
90 pci_write_config8(ide_dev, 0x56, byte);
91}
92#endif /* get_ide_dma66() */
93
Wang Qing Peid6c43952010-08-18 01:55:11 +000094u8 is_dev3_present(void)
95{
96 return 0;
97}
98
Wang Qing Pei0ede4c02010-08-17 15:19:32 +000099/*************************************************
100* enable the dedicated function in this board.
101* This function called early than rs780_enable.
102*************************************************/
Paul Menzel528640d2013-02-23 21:31:23 +0100103static void mainboard_enable(device_t dev)
Wang Qing Pei0ede4c02010-08-17 15:19:32 +0000104{
Wang Qing Pei0ede4c02010-08-17 15:19:32 +0000105 printk(BIOS_INFO, "Mainboard PA78VM5 Enable. dev=0x%p\n", dev);
106
Wang Qing Pei0ede4c02010-08-17 15:19:32 +0000107 set_pcie_dereset();
108 /* get_ide_dma66(); */
109}
110
Wang Qing Pei0ede4c02010-08-17 15:19:32 +0000111struct chip_operations mainboard_ops = {
Paul Menzel528640d2013-02-23 21:31:23 +0100112 .enable_dev = mainboard_enable,
Wang Qing Pei0ede4c02010-08-17 15:19:32 +0000113};