363cd3f28c818008ff73ca780992e8b0ebd1dd05
[coreboot.git] / src / southbridge / amd / sb600 / 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 <console/console.h>
21 #include <device/device.h>
22 #include <device/pci.h>
23 #include <device/pci_ids.h>
24 #include <device/pci_ops.h>
25 #include "sb600.h"
26
27 static void ide_init(struct device *dev)
28 {
29         /* Enable ide devices so the linux ide driver will work */
30         u32 dword;
31         u8 byte;
32
33         /* RPR10.1 disable MSI */
34         dword = pci_read_config32(dev, 0x70);
35         dword &= ~(1 << 16);
36         pci_write_config32(dev, 0x70, dword);
37
38         /* Ultra DMA mode */
39         /* enable UDMA */
40         byte = pci_read_config8(dev, 0x54);
41         byte |= 1 << 0;
42         pci_write_config8(dev, 0x54, byte);
43
44         /* Enable I/O Access&& Bus Master */
45         dword = pci_read_config16(dev, 0x4);
46         dword |= 1 << 2;
47         pci_write_config16(dev, 0x4, dword);
48
49 #if CONFIG_PCI_ROM_RUN == 1
50         pci_dev_init(dev);
51 #endif
52
53 }
54
55 static struct pci_operations lops_pci = {
56         .set_subsystem = pci_dev_set_subsystem,
57 };
58
59 static struct device_operations ide_ops = {
60         .read_resources = pci_dev_read_resources,
61         .set_resources = pci_dev_set_resources,
62         .enable_resources = pci_dev_enable_resources,
63         .init = ide_init,
64         .scan_bus = 0,
65         /* .enable           = sb600_enable, */
66         .ops_pci = &lops_pci,
67 };
68
69 static const struct pci_driver ide_driver __pci_driver = {
70         .ops = &ide_ops,
71         .vendor = PCI_VENDOR_ID_ATI,
72         .device = PCI_DEVICE_ID_ATI_SB600_IDE,
73 };