Wang Qing Pei | 0ede4c0 | 2010-08-17 15:19:32 +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. |
| 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 Pei | 0ede4c0 | 2010-08-17 15:19:32 +0000 | [diff] [blame] | 25 | #include <cpu/x86/msr.h> |
| 26 | #include <cpu/amd/mtrr.h> |
| 27 | #include <device/pci_def.h> |
efdesign98 | 00c8c4a | 2011-07-20 12:37:58 -0600 | [diff] [blame] | 28 | #include "southbridge/amd/sb700/sb700.h" |
| 29 | #include "southbridge/amd/sb700/smbus.h" |
Wang Qing Pei | 0ede4c0 | 2010-08-17 15:19:32 +0000 | [diff] [blame] | 30 | |
Wang Qing Pei | 0ede4c0 | 2010-08-17 15:19:32 +0000 | [diff] [blame] | 31 | void set_pcie_dereset(void); |
| 32 | void set_pcie_reset(void); |
Wang Qing Pei | d6c4395 | 2010-08-18 01:55:11 +0000 | [diff] [blame] | 33 | u8 is_dev3_present(void); |
Wang Qing Pei | 0ede4c0 | 2010-08-17 15:19:32 +0000 | [diff] [blame] | 34 | |
| 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 | ***/ |
| 39 | void 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 | |
| 52 | void 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 | ********************************************************/ |
| 71 | static 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 Pei | d6c4395 | 2010-08-18 01:55:11 +0000 | [diff] [blame] | 94 | u8 is_dev3_present(void) |
| 95 | { |
| 96 | return 0; |
| 97 | } |
| 98 | |
Wang Qing Pei | 0ede4c0 | 2010-08-17 15:19:32 +0000 | [diff] [blame] | 99 | /************************************************* |
| 100 | * enable the dedicated function in this board. |
| 101 | * This function called early than rs780_enable. |
| 102 | *************************************************/ |
Paul Menzel | 528640d | 2013-02-23 21:31:23 +0100 | [diff] [blame^] | 103 | static void mainboard_enable(device_t dev) |
Wang Qing Pei | 0ede4c0 | 2010-08-17 15:19:32 +0000 | [diff] [blame] | 104 | { |
Wang Qing Pei | 0ede4c0 | 2010-08-17 15:19:32 +0000 | [diff] [blame] | 105 | printk(BIOS_INFO, "Mainboard PA78VM5 Enable. dev=0x%p\n", dev); |
| 106 | |
Wang Qing Pei | 0ede4c0 | 2010-08-17 15:19:32 +0000 | [diff] [blame] | 107 | set_pcie_dereset(); |
| 108 | /* get_ide_dma66(); */ |
| 109 | } |
| 110 | |
Wang Qing Pei | 0ede4c0 | 2010-08-17 15:19:32 +0000 | [diff] [blame] | 111 | struct chip_operations mainboard_ops = { |
Paul Menzel | 528640d | 2013-02-23 21:31:23 +0100 | [diff] [blame^] | 112 | .enable_dev = mainboard_enable, |
Wang Qing Pei | 0ede4c0 | 2010-08-17 15:19:32 +0000 | [diff] [blame] | 113 | }; |