blob: 46ce2d257690ed38d4dad6f64a9a8f141aad23d4 [file] [log] [blame]
Zheng Baodec279f2010-03-16 01:42:50 +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.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#include <console/console.h>
21#include <device/device.h>
22#include <device/pci.h>
23#include <arch/io.h>
Stefan Reinauer23836e22010-04-15 12:39:29 +000024#include <boot/tables.h>
Zheng Baodec279f2010-03-16 01:42:50 +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"
Zheng Baodec279f2010-03-16 01:42:50 +000030#include "chip.h"
31
Zheng Bao07351422010-03-26 01:43:30 +000032void set_pcie_dereset(void);
33void set_pcie_reset(void);
Wang Qing Pei543f7672010-08-17 11:11:09 +000034u8 is_dev3_present(void);
Zheng Baodec279f2010-03-16 01:42:50 +000035/*
36 * Mahogany 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
Zheng Bao07351422010-03-26 01:43:30 +000065#if 0 /* not tested yet */
Zheng Baodec279f2010-03-16 01:42:50 +000066/********************************************************
Zheng Bao07351422010-03-26 01:43:30 +000067* mahogany uses SB700 GPIO9 to detect IDE_DMA66.
68* IDE_DMA66 is routed to GPIO 9. So we read Gpio 9 to
Zheng Baodec279f2010-03-16 01:42:50 +000069* get the cable type, 40 pin or 80 pin?
70********************************************************/
Zheng Bao07351422010-03-26 01:43:30 +000071static void get_ide_dma66(void)
Zheng Baodec279f2010-03-16 01:42:50 +000072{
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);
Zheng Bao07351422010-03-26 01:43:30 +000080 byte |= (1 << 5); /* Set Gpio9 as input */
Zheng Baodec279f2010-03-16 01:42:50 +000081 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);
Zheng Bao07351422010-03-26 01:43:30 +000086 if ((1 << 5) & pci_read_config8(sm_dev, 0xAA))
Zheng Baodec279f2010-03-16 01:42:50 +000087 byte |= 2 << 0; /* mode 2 */
88 else
89 byte |= 5 << 0; /* mode 5 */
90 pci_write_config8(ide_dev, 0x56, byte);
91}
Zheng Bao07351422010-03-26 01:43:30 +000092#endif /* get_ide_dma66 */
Zheng Baodec279f2010-03-16 01:42:50 +000093
Wang Qing Pei543f7672010-08-17 11:11:09 +000094u8 is_dev3_present(void)
95{
96 return 0;
97}
Zheng Baodec279f2010-03-16 01:42:50 +000098/*************************************************
99* enable the dedicated function in mahogany board.
100* This function called early than rs780_enable.
101*************************************************/
Zheng Bao07351422010-03-26 01:43:30 +0000102static void mahogany_enable(device_t dev)
Zheng Baodec279f2010-03-16 01:42:50 +0000103{
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +0000104 printk(BIOS_INFO, "Mainboard MAHOGANY Enable. dev=0x%p\n", dev);
Kyösti Mälkkiba589e32012-07-11 08:03:13 +0300105 setup_uma_memory();
Zheng Baodec279f2010-03-16 01:42:50 +0000106
107 set_pcie_dereset();
108 /* get_ide_dma66(); */
109}
110
111int add_mainboard_resources(struct lb_memory *mem)
112{
Zheng Bao07351422010-03-26 01:43:30 +0000113 return 0;
Zheng Baodec279f2010-03-16 01:42:50 +0000114}
115
116struct chip_operations mainboard_ops = {
117 CHIP_NAME("AMD MAHOGANY Mainboard")
118 .enable_dev = mahogany_enable,
119};