2 * Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>.
4 * Based in part on pci.c from Etherboot 5.4, by Ken Yap and David
5 * Munro, in turn based on the Linux kernel's PCI implementation.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or any later version.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 FILE_LICENCE ( GPL2_OR_LATER
);
29 #include <gpxe/tables.h>
30 #include <gpxe/device.h>
38 * Set device to be a busmaster in case BIOS neglected to do so. Also
39 * adjust PCI latency timer to a reasonable value, 32.
41 void adjust_pci_device ( struct pci_device
*pci
) {
42 unsigned short new_command
, pci_command
;
43 unsigned char pci_latency
;
45 pci_read_config_word ( pci
, PCI_COMMAND
, &pci_command
);
46 new_command
= ( pci_command
| PCI_COMMAND_MASTER
|
47 PCI_COMMAND_MEM
| PCI_COMMAND_IO
);
48 if ( pci_command
!= new_command
) {
49 pci_write_config_word ( pci
, PCI_COMMAND
, new_command
);
52 pci_read_config_byte ( pci
, PCI_LATENCY_TIMER
, &pci_latency
);
53 if ( pci_latency
< 32 ) {
54 pci_write_config_byte ( pci
, PCI_LATENCY_TIMER
, 32);