]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/pci/hotplug/pciehprm_nonacpi.c
2 * PCIEHPRM NONACPI: PHP Resource Manager for Non-ACPI/Legacy platform
4 * Copyright (C) 1995,2001 Compaq Computer Corporation
5 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
6 * Copyright (C) 2001 IBM Corp.
7 * Copyright (C) 2003-2004 Intel Corporation
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or (at
14 * your option) any later version.
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
19 * NON INFRINGEMENT. See the GNU General Public License for more
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com>
30 #include <linux/config.h>
31 #include <linux/module.h>
32 #include <linux/kernel.h>
33 #include <linux/types.h>
34 #include <linux/sched.h>
35 #include <linux/pci.h>
36 #include <linux/init.h>
37 #include <linux/slab.h>
38 #include <asm/uaccess.h>
41 #include "pciehprm_nonacpi.h"
44 void pciehprm_cleanup(void)
49 int pciehprm_get_physical_slot_number(struct controller
*ctrl
, u32
*sun
, u8 busnum
, u8 devnum
)
52 *sun
= (u8
) (ctrl
->first_slot
);
57 struct controller
*ctrl
,
58 struct pci_func
*func
,
63 struct pci_bus lpci_bus
, *pci_bus
;
65 memcpy(&lpci_bus
, ctrl
->pci_bus
, sizeof(lpci_bus
));
67 pci_bus
->number
= func
->bus
;
68 devfn
= PCI_DEVFN(func
->device
, func
->function
);
70 temp_byte
= 0x40; /* hard coded value for LT */
71 if (card_type
== PCI_HEADER_TYPE_BRIDGE
) {
72 /* set subordinate Latency Timer */
73 rc
= pci_bus_write_config_byte(pci_bus
, devfn
, PCI_SEC_LATENCY_TIMER
, temp_byte
);
76 dbg("%s: set secondary LT error. b:d:f(%02x:%02x:%02x)\n", __FUNCTION__
,
77 func
->bus
, func
->device
, func
->function
);
82 /* set base Latency Timer */
83 rc
= pci_bus_write_config_byte(pci_bus
, devfn
, PCI_LATENCY_TIMER
, temp_byte
);
86 dbg("%s: set LT error. b:d:f(%02x:%02x:%02x)\n", __FUNCTION__
, func
->bus
, func
->device
, func
->function
);
90 /* set Cache Line size */
91 temp_byte
= 0x08; /* hard coded value for CLS */
93 rc
= pci_bus_write_config_byte(pci_bus
, devfn
, PCI_CACHE_LINE_SIZE
, temp_byte
);
96 dbg("%s: set CLS error. b:d:f(%02x:%02x:%02x)\n", __FUNCTION__
, func
->bus
, func
->device
, func
->function
);
100 /* set enable_serr */
105 void pciehprm_enable_card(
106 struct controller
*ctrl
,
107 struct pci_func
*func
,
110 u16 command
, bcommand
;
111 struct pci_bus lpci_bus
, *pci_bus
;
115 memcpy(&lpci_bus
, ctrl
->pci_bus
, sizeof(lpci_bus
));
117 pci_bus
->number
= func
->bus
;
118 devfn
= PCI_DEVFN(func
->device
, func
->function
);
120 rc
= pci_bus_read_config_word(pci_bus
, devfn
, PCI_COMMAND
, &command
);
122 command
|= PCI_COMMAND_PARITY
| PCI_COMMAND_SERR
123 | PCI_COMMAND_MASTER
| PCI_COMMAND_INVALIDATE
124 | PCI_COMMAND_IO
| PCI_COMMAND_MEMORY
;
126 rc
= pci_bus_write_config_word(pci_bus
, devfn
, PCI_COMMAND
, command
);
128 if (card_type
== PCI_HEADER_TYPE_BRIDGE
) {
130 rc
= pci_bus_read_config_word(pci_bus
, devfn
, PCI_BRIDGE_CONTROL
, &bcommand
);
132 bcommand
|= PCI_BRIDGE_CTL_PARITY
| PCI_BRIDGE_CTL_SERR
133 | PCI_BRIDGE_CTL_NO_ISA
;
135 rc
= pci_bus_write_config_word(pci_bus
, devfn
, PCI_BRIDGE_CONTROL
, bcommand
);
139 static int legacy_pciehprm_init_pci(void)
144 int pciehprm_init(enum php_ctlr_type ctrl_type
)
150 retval
= legacy_pciehprm_init_pci();