blob: acb2c830f73a9e83bcf5491cbf12bf1a568840dc [file] [log] [blame]
Zheng Baod0985752011-01-20 04:45:48 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2010 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.
Zheng Baod0985752011-01-20 04:45:48 +000014 */
15
16#include <console/console.h>
17#include <device/device.h>
18#include <device/pci.h>
19#include <device/pci_ids.h>
20#include <device/pci_ops.h>
21#include "sb800.h"
22
23static void ide_init(struct device *dev)
24{
25 struct southbridge_amd_sb800_config *conf;
26 /* Enable ide devices so the linux ide driver will work */
27 u32 dword;
28 u8 byte;
29
30 conf = dev->chip_info;
31
32 /* RPR9.1 disable MSI */
33 /* TODO: For A14, it should set as 1. I doubt it. */
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 /* set ide as primary, if you want to boot from IDE, you'd better set it
50 * in mainboard/Config.lb */
51 if (conf->boot_switch_sata_ide == 1) {
52 byte = pci_read_config8(dev, 0xAD);
53 byte |= 1 << 4;
54 pci_write_config8(dev, 0xAD, byte);
55 }
Zheng Baod0985752011-01-20 04:45:48 +000056}
57
58static struct pci_operations lops_pci = {
59 .set_subsystem = pci_dev_set_subsystem,
60};
61
62static struct device_operations ide_ops = {
63 .read_resources = pci_dev_read_resources,
64 .set_resources = pci_dev_set_resources,
65 .enable_resources = pci_dev_enable_resources,
66 .init = ide_init,
67 .scan_bus = 0,
68 .ops_pci = &lops_pci,
69};
70
71static const struct pci_driver ide_driver __pci_driver = {
72 .ops = &ide_ops,
73 .vendor = PCI_VENDOR_ID_ATI,
74 .device = PCI_DEVICE_ID_ATI_SB800_IDE,
75};