Wang Qing Pei | 931d6f3 | 2010-08-17 11:22:40 +0000 | [diff] [blame] | 1 | /* |
| 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 Pei | 931d6f3 | 2010-08-17 11:22:40 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <console/console.h> |
| 18 | #include <device/device.h> |
| 19 | #include <device/pci.h> |
| 20 | #include <arch/io.h> |
Wang Qing Pei | 931d6f3 | 2010-08-17 11:22:40 +0000 | [diff] [blame] | 21 | #include <cpu/x86/msr.h> |
| 22 | #include <cpu/amd/mtrr.h> |
| 23 | #include <device/pci_def.h> |
efdesign98 | 00c8c4a | 2011-07-20 12:37:58 -0600 | [diff] [blame] | 24 | #include "southbridge/amd/sb700/sb700.h" |
| 25 | #include "southbridge/amd/sb700/smbus.h" |
Wang Qing Pei | 931d6f3 | 2010-08-17 11:22:40 +0000 | [diff] [blame] | 26 | |
Wang Qing Pei | 931d6f3 | 2010-08-17 11:22:40 +0000 | [diff] [blame] | 27 | void set_pcie_dereset(void); |
| 28 | void set_pcie_reset(void); |
| 29 | u8 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 | ***/ |
| 34 | void 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 | |
| 47 | void 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 | |
| 61 | u8 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 Menzel | 528640d | 2013-02-23 21:31:23 +0100 | [diff] [blame] | 70 | static void mainboard_enable(device_t dev) |
Wang Qing Pei | 931d6f3 | 2010-08-17 11:22:40 +0000 | [diff] [blame] | 71 | { |
Wang Qing Pei | 931d6f3 | 2010-08-17 11:22:40 +0000 | [diff] [blame] | 72 | printk(BIOS_INFO, "Mainboard MA78GM-US2H Enable. dev=0x%p\n", dev); |
| 73 | |
Wang Qing Pei | 931d6f3 | 2010-08-17 11:22:40 +0000 | [diff] [blame] | 74 | set_pcie_dereset(); |
| 75 | /* get_ide_dma66(); */ |
| 76 | } |
| 77 | |
Wang Qing Pei | 931d6f3 | 2010-08-17 11:22:40 +0000 | [diff] [blame] | 78 | struct chip_operations mainboard_ops = { |
Paul Menzel | 528640d | 2013-02-23 21:31:23 +0100 | [diff] [blame] | 79 | .enable_dev = mainboard_enable, |
Wang Qing Pei | 931d6f3 | 2010-08-17 11:22:40 +0000 | [diff] [blame] | 80 | }; |