Move MMCONF resource into the domain for fam10 for the resource allocator.
[coreboot.git] / src / southbridge / sis / sis966 / sis966_early_setup_car.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2006 AMD
5  * Written by Yinghai Lu <yinghai.lu@amd.com> for AMD.
6  * Copyright (C) 2007 Silicon Integrated Systems Corp. (SiS)
7  * Written by Morgan Tsai <my_tsai@sis.com> for SiS.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
22  */
23
24 void sis966_early_pcie_setup(unsigned busnx, unsigned devnx, unsigned anactrl_io_base, unsigned pci_e_x)
25 {
26         uint32_t tgio_ctrl;
27         uint32_t pll_ctrl;
28         uint32_t dword;
29         int i;
30         device_t dev;
31         dev = PCI_DEV(busnx, devnx+1, 1);
32         dword = pci_read_config32(dev, 0xe4);
33         dword |= 0x3f0; // disable it at first
34         pci_write_config32(dev, 0xe4, dword);
35
36         for(i=0; i<3; i++) {
37                 tgio_ctrl = inl(anactrl_io_base + 0xcc);
38                 tgio_ctrl &= ~(3<<9);
39                 tgio_ctrl |= (i<<9);
40                 outl(tgio_ctrl, anactrl_io_base + 0xcc);
41                 pll_ctrl = inl(anactrl_io_base + 0x30);
42                 pll_ctrl |= (1<<31);
43                 outl(pll_ctrl, anactrl_io_base + 0x30);
44                 do {
45                         pll_ctrl = inl(anactrl_io_base + 0x30);
46                 } while (!(pll_ctrl & 1));
47         }
48         tgio_ctrl = inl(anactrl_io_base + 0xcc);
49         tgio_ctrl &= ~((7<<4)|(1<<8));
50         tgio_ctrl |= (pci_e_x<<4)|(1<<8);
51         outl(tgio_ctrl, anactrl_io_base + 0xcc);
52
53 //      wait 100us
54         udelay(100);
55
56         dword = pci_read_config32(dev, 0xe4);
57         dword &= ~(0x3f0); // enable
58         pci_write_config32(dev, 0xe4, dword);
59
60 //      need to wait 100ms
61         mdelay(100);
62 }
63