This is so that people can see it. This is the sb600 for v3. It almost
[coreboot.git] / src / southbridge / amd / sb600 / ide.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2008 Advanced Micro Devices, Inc.
5  *
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.
9  *
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.
14  *
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
18  */
19
20 #include <types.h>
21 #include <lib.h>
22 #include <console.h>
23 #include <device/pci.h>
24 #include <msr.h>
25 #include <legacy.h>
26 #include <device/pci_ids.h>
27 #include <statictree.h>
28 #include <config.h>
29 #include "sb600.h"
30
31 static void ide_init(struct device *dev)
32 {
33         struct southbridge_amd_sb600_ide_dts_config *conf;
34         /* Enable ide devices so the linux ide driver will work */
35         u32 dword;
36         u8 byte;
37         conf = dev->device_configuration;
38
39         /* RPR10.1 disable MSI */
40         dword = pci_read_config32(dev, 0x70);
41         dword &= ~(1 << 16);
42         pci_write_config32(dev, 0x70, dword);
43
44         /* Ultra DMA mode */
45         byte = pci_read_config8(dev, 0x54);
46         byte |= 1 << 0;
47         pci_write_config8(dev, 0x54, byte);
48         byte = pci_read_config8(dev, 0x56);
49         byte &= ~(7 << 0);
50         byte |= 5 << 0;         /* mode 5 */
51         pci_write_config8(dev, 0x56, byte);
52
53         /* Enable I/O Access&& Bus Master */
54         dword = pci_read_config16(dev, 0x4);
55         dword |= 1 << 2;
56         pci_write_config16(dev, 0x4, dword);
57
58 #if CONFIG_PCI_ROM_RUN == 1
59         pci_dev_init(dev);
60 #endif
61
62 }
63
64 static struct pci_operations lops_pci = {
65         .set_subsystem = pci_dev_set_subsystem,
66 };
67
68 struct device_operations sb600_ide = {
69         .id = {.type = DEVICE_ID_PCI,
70                 {.pci = {.vendor = PCI_VENDOR_ID_ATI,
71                               .device = PCI_DEVICE_ID_ATI_SB600_IDE}}},
72         .constructor             = default_device_constructor,
73         .phase4_read_resources   = pci_dev_read_resources,
74         .phase4_set_resources    = pci_dev_set_resources,
75         .phase5_enable_resources = pci_dev_enable_resources,
76         .phase6_init             = ide_init,
77         .ops_pci          = &lops_pci
78 };