2 * This file is part of the coreboot project.
4 * Copyright (C) 2008 Advanced Micro Devices, Inc.
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.
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.
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
20 #include <console/console.h>
24 #include <device/device.h>
25 #include <device/pci.h>
26 #include <device/pci_ids.h>
27 #include <device/pci_ops.h>
28 #include <cpu/x86/msr.h>
29 #include <cpu/amd/mtrr.h>
33 /*****************************************
34 * Compliant with CIM_33's ATINB_MiscClockCtrl
35 *****************************************/
36 void static rs690_config_misc_clk(device_t nb_dev)
41 struct bus pbus; /* fake bus for dev0 fun1 */
43 reg = pci_read_config32(nb_dev, 0x4c);
45 pci_write_config32(nb_dev, 0x4c, reg);
47 word = pci_cf8_conf1.read16(&pbus, 0, 1, 0xf8);
49 pci_cf8_conf1.write16(&pbus, 0, 1, 0xf8, word);
51 word = pci_cf8_conf1.read16(&pbus, 0, 1, 0xe8);
52 word &= ~((1 << 12) | (1 << 13) | (1 << 14));
54 pci_cf8_conf1.write16(&pbus, 0, 1, 0xe8, word);
56 reg = pci_cf8_conf1.read32(&pbus, 0, 1, 0x94);
57 reg &= ~((1 << 16) | (1 << 24) | (1 << 28));
58 pci_cf8_conf1.write32(&pbus, 0, 1, 0x94, reg);
60 reg = pci_cf8_conf1.read32(&pbus, 0, 1, 0x8c);
61 reg &= ~((1 << 13) | (1 << 14) | (1 << 24) | (1 << 25));
63 pci_cf8_conf1.write32(&pbus, 0, 1, 0x8c, reg);
65 reg = pci_cf8_conf1.read32(&pbus, 0, 1, 0xcc);
67 pci_cf8_conf1.write32(&pbus, 0, 1, 0xcc, reg);
69 reg = nbmc_read_index(nb_dev, 0x7a);
73 set_htiu_enable_bits(nb_dev, 0x05, 1 << 11, 1 << 11);
74 nbmc_write_index(nb_dev, 0x7a, reg);
75 /* Powering Down efuse and strap block clocks after boot-up. GFX Mode. */
76 reg = pci_cf8_conf1.read32(&pbus, 0, 1, 0xcc);
79 pci_cf8_conf1.write32(&pbus, 0, 1, 0xcc, reg);
81 /* Powerdown reference clock to graphics core PLL in northbridge only mode */
82 reg = pci_cf8_conf1.read32(&pbus, 0, 1, 0x8c);
84 pci_cf8_conf1.write32(&pbus, 0, 1, 0x8c, reg);
86 /* Powering Down efuse and strap block clocks after boot-up. NB Only Mode. */
87 reg = pci_cf8_conf1.read32(&pbus, 0, 1, 0xcc);
88 reg |= (1 << 23) | (1 << 24);
89 pci_cf8_conf1.write32(&pbus, 0, 1, 0xcc, reg);
91 /* Powerdown clock to memory controller in northbridge only mode */
92 byte = pci_cf8_conf1.read8(&pbus, 0, 1, 0xe4);
94 pci_cf8_conf1.write8(&pbus, 0, 1, 0xe4, reg);
96 /* CLKCFG:0xE8 Bit[17] = 0x1 Powerdown clock to IOC GFX block in no external graphics mode */
100 reg = pci_read_config32(nb_dev, 0x4c);
102 pci_write_config32(nb_dev, 0x4c, reg);
104 set_htiu_enable_bits(nb_dev, 0x05, 7 << 8, 7 << 8);
108 u32 get_vid_did(device_t dev)
110 return pci_read_config32(dev, 0);
113 /***********************************************
115 * 0:00.1 CLK : bit 0 of nb_cfg 0x4c : 0 - disable, default
116 * 0:01.0 P2P Internal:
117 * 0:02.0 P2P : bit 2 of nbmiscind 0x0c : 0 - enable, default + 32 * 2
118 * 0:03.0 P2P : bit 3 of nbmiscind 0x0c : 0 - enable, default + 32 * 2
119 * 0:04.0 P2P : bit 4 of nbmiscind 0x0c : 0 - enable, default + 32 * 2
120 * 0:05.0 P2P : bit 5 of nbmiscind 0x0c : 0 - enable, default + 32 * 2
121 * 0:06.0 P2P : bit 6 of nbmiscind 0x0c : 0 - enable, default + 32 * 2
122 * 0:07.0 P2P : bit 7 of nbmiscind 0x0c : 0 - enable, default + 32 * 2
123 * 0:08.0 NB2SB : bit 6 of nbmiscind 0x00 : 0 - disable, default + 32 * 1
124 * case 0 will be called twice, one is by cpu in hypertransport.c line458,
125 * the other is by rs690.
126 ***********************************************/
127 void rs690_enable(device_t dev)
129 device_t nb_dev = 0, sb_dev = 0;
132 printk(BIOS_INFO, "rs690_enable: dev=%p, VID_DID=0x%x\n", dev, get_vid_did(dev));
134 nb_dev = dev_find_slot(0, PCI_DEVFN(0, 0));
136 die("rs690_enable: CAN NOT FIND RS690 DEVICE, HALT!\n");
140 /* sb_dev (dev 8) is a bridge that links to southbridge. */
141 sb_dev = dev_find_slot(0, PCI_DEVFN(8, 0));
143 die("rs690_enable: CAN NOT FIND SB bridge, HALT!\n");
147 dev_ind = dev->path.pci.devfn >> 3;
149 case 0: /* bus0, dev0, fun0; */
150 printk(BIOS_INFO, "Bus-0, Dev-0, Fun-0.\n");
151 enable_pcie_bar3(nb_dev); /* PCIEMiscInit */
152 config_gpp_core(nb_dev, sb_dev);
153 rs690_gpp_sb_init(nb_dev, sb_dev, 8);
154 /* set SB payload size: 64byte */
155 set_pcie_enable_bits(nb_dev, 0x10 | PCIE_CORE_INDEX_GPPSB, 3 << 11, 2 << 11);
157 /* Bus0Dev0Fun1Clock control init, we have to do it here, for dev0 Fun1 doesn't have a vendor or device ID */
158 rs690_config_misc_clk(nb_dev);
161 case 1: /* bus0, dev1 */
162 printk(BIOS_INFO, "Bus-0, Dev-1, Fun-0.\n");
164 case 2: /* bus0, dev2,3, two GFX */
166 printk(BIOS_INFO, "Bus-0, Dev-2,3, Fun-0. enable=%d\n", dev->enabled);
167 set_nbmisc_enable_bits(nb_dev, 0x0c, 1 << dev_ind,
168 (dev->enabled ? 0 : 1) << dev_ind);
170 rs690_gfx_init(nb_dev, dev, dev_ind);
172 case 4: /* bus0, dev4-7, four GPP */
176 printk(BIOS_INFO, "Bus-0, Dev-4,5,6,7, Fun-0. enable=%d\n",
178 set_nbmisc_enable_bits(nb_dev, 0x0c, 1 << dev_ind,
179 (dev->enabled ? 0 : 1) << dev_ind);
181 rs690_gpp_sb_init(nb_dev, dev, dev_ind);
183 case 8: /* bus0, dev8, SB */
184 printk(BIOS_INFO, "Bus-0, Dev-8, Fun-0. enable=%d\n", dev->enabled);
185 set_nbmisc_enable_bits(nb_dev, 0x00, 1 << 6,
186 (dev->enabled ? 1 : 0) << 6);
188 rs690_gpp_sb_init(nb_dev, dev, dev_ind);
189 disable_pcie_bar3(nb_dev);
192 printk(BIOS_DEBUG, "unknown dev: %s\n", dev_path(dev));
196 struct chip_operations southbridge_amd_rs690_ops = {
197 CHIP_NAME("ATI RS690")
198 .enable_dev = rs690_enable,