Michael Xie | 7586cef | 2008-09-22 13:11:39 +0000 | [diff] [blame] | 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. |
Michael Xie | 7586cef | 2008-09-22 13:11:39 +0000 | [diff] [blame] | 14 | */ |
| 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 "sb600.h" |
| 22 | |
| 23 | static void ide_init(struct device *dev) |
| 24 | { |
Michael Xie | 7586cef | 2008-09-22 13:11:39 +0000 | [diff] [blame] | 25 | /* Enable ide devices so the linux ide driver will work */ |
| 26 | u32 dword; |
| 27 | u8 byte; |
Michael Xie | 7586cef | 2008-09-22 13:11:39 +0000 | [diff] [blame] | 28 | |
| 29 | /* RPR10.1 disable MSI */ |
| 30 | dword = pci_read_config32(dev, 0x70); |
| 31 | dword &= ~(1 << 16); |
| 32 | pci_write_config32(dev, 0x70, dword); |
| 33 | |
Rudolf Marek | 470e182 | 2010-10-10 20:43:00 +0000 | [diff] [blame] | 34 | /* Enable UDMA on all devices, it will become UDMA0 (default PIO is PIO0) */ |
Michael Xie | 7586cef | 2008-09-22 13:11:39 +0000 | [diff] [blame] | 35 | byte = pci_read_config8(dev, 0x54); |
Rudolf Marek | 470e182 | 2010-10-10 20:43:00 +0000 | [diff] [blame] | 36 | byte |= 0xf; |
Michael Xie | 7586cef | 2008-09-22 13:11:39 +0000 | [diff] [blame] | 37 | pci_write_config8(dev, 0x54, byte); |
Michael Xie | 7586cef | 2008-09-22 13:11:39 +0000 | [diff] [blame] | 38 | |
| 39 | /* Enable I/O Access&& Bus Master */ |
| 40 | dword = pci_read_config16(dev, 0x4); |
| 41 | dword |= 1 << 2; |
| 42 | pci_write_config16(dev, 0x4, dword); |
Michael Xie | 7586cef | 2008-09-22 13:11:39 +0000 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | static struct pci_operations lops_pci = { |
| 46 | .set_subsystem = pci_dev_set_subsystem, |
| 47 | }; |
| 48 | |
| 49 | static struct device_operations ide_ops = { |
| 50 | .read_resources = pci_dev_read_resources, |
| 51 | .set_resources = pci_dev_set_resources, |
| 52 | .enable_resources = pci_dev_enable_resources, |
| 53 | .init = ide_init, |
| 54 | .scan_bus = 0, |
| 55 | /* .enable = sb600_enable, */ |
| 56 | .ops_pci = &lops_pci, |
| 57 | }; |
| 58 | |
Stefan Reinauer | 8e96ba2 | 2010-03-16 23:33:29 +0000 | [diff] [blame] | 59 | static const struct pci_driver ide_driver __pci_driver = { |
Michael Xie | 7586cef | 2008-09-22 13:11:39 +0000 | [diff] [blame] | 60 | .ops = &ide_ops, |
| 61 | .vendor = PCI_VENDOR_ID_ATI, |
| 62 | .device = PCI_DEVICE_ID_ATI_SB600_IDE, |
| 63 | }; |