blob: 505ba3ecca61af1f5792f9279e182c5a2888d880 [file] [log] [blame]
Wang Qing Pei931d6f32010-08-17 11:22:40 +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.
Wang Qing Pei931d6f32010-08-17 11:22:40 +000015 */
16
17#include <console/console.h>
18#include <device/device.h>
19#include <device/pci.h>
20#include <arch/io.h>
Wang Qing Pei931d6f32010-08-17 11:22:40 +000021#include <cpu/x86/msr.h>
22#include <cpu/amd/mtrr.h>
23#include <device/pci_def.h>
efdesign9800c8c4a2011-07-20 12:37:58 -060024#include "southbridge/amd/sb700/sb700.h"
25#include "southbridge/amd/sb700/smbus.h"
Wang Qing Pei931d6f32010-08-17 11:22:40 +000026
Wang Qing Pei931d6f32010-08-17 11:22:40 +000027void set_pcie_dereset(void);
28void set_pcie_reset(void);
29u8 is_dev3_present(void);
30/*
31 * ma78gm-us2h uses GPIO 6 as PCIe slot reset, GPIO4 as GFX slot reset. We need to
32 * pull it up before training the slot.
33 ***/
34void set_pcie_dereset()
35{
36 u16 word;
37 device_t sm_dev;
38 /* GPIO 6 reset PCIe slot, GPIO 4 reset GFX PCIe */
39 sm_dev = dev_find_slot(0, PCI_DEVFN(0x14, 0));
40
41 word = pci_read_config16(sm_dev, 0xA8);
42 word |= (1 << 0) | (1 << 2); /* Set Gpio6,4 as output */
43 word &= ~((1 << 8) | (1 << 10));
44 pci_write_config16(sm_dev, 0xA8, word);
45}
46
47void set_pcie_reset()
48{
49 u16 word;
50 device_t sm_dev;
51 /* GPIO 6 reset PCIe slot, GPIO 4 reset GFX PCIe */
52 sm_dev = dev_find_slot(0, PCI_DEVFN(0x14, 0));
53
54 word = pci_read_config16(sm_dev, 0xA8);
55 word &= ~((1 << 0) | (1 << 2)); /* Set Gpio6,4 as output */
56 word &= ~((1 << 8) | (1 << 10));
57 pci_write_config16(sm_dev, 0xA8, word);
58}
59
60
61u8 is_dev3_present(void)
62{
63 return 0;
64}
65
66/*************************************************
67* enable the dedicated function in board.
68* This function called early than rs780_enable.
69*************************************************/
Paul Menzel528640d2013-02-23 21:31:23 +010070static void mainboard_enable(device_t dev)
Wang Qing Pei931d6f32010-08-17 11:22:40 +000071{
Wang Qing Pei931d6f32010-08-17 11:22:40 +000072 printk(BIOS_INFO, "Mainboard MA78GM-US2H Enable. dev=0x%p\n", dev);
73
Wang Qing Pei931d6f32010-08-17 11:22:40 +000074 set_pcie_dereset();
75 /* get_ide_dma66(); */
76}
77
Wang Qing Pei931d6f32010-08-17 11:22:40 +000078struct chip_operations mainboard_ops = {
Paul Menzel528640d2013-02-23 21:31:23 +010079 .enable_dev = mainboard_enable,
Wang Qing Pei931d6f32010-08-17 11:22:40 +000080};