-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In future we may want to be able to do fixups for specific PCI devices in skiboot, so add a small framework for doing this. This is not intended for the same purposes as quirks in the Linux kernel, as the PCI devices that quirks can match for in skiboot are not properly configured. This is intended to enable having a custom path to make changes that don't directly interact with the PCI device, for example adding device tree entries. Signed-off-by: Russell Currey <ruscur@russell.cc> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com> [stewart@linux.vnet.ibm.com: fix 0 vs NULL sparse warning, (C) date] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
- Loading branch information
1 parent
ca2d917
commit dca7b55
Showing
4 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* Copyright 2017 IBM Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
* implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <skiboot.h> | ||
#include <pci.h> | ||
#include <pci-quirk.h> | ||
#include <ast.h> | ||
|
||
/* Quirks are: {fixup function, vendor ID, (device ID or PCI_ANY_ID)} */ | ||
static const struct pci_quirk quirk_table[] = { | ||
{NULL} | ||
}; | ||
|
||
void pci_handle_quirk(struct phb *phb, | ||
struct pci_device *pd, | ||
uint16_t vendor_id, | ||
uint16_t device_id) | ||
{ | ||
const struct pci_quirk *quirks = quirk_table; | ||
|
||
while (quirks->vendor_id) { | ||
if (vendor_id == quirks->vendor_id && | ||
(quirks->device_id == PCI_ANY_ID || | ||
device_id == quirks->device_id)) | ||
quirks->fixup(phb, pd); | ||
quirks++; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* Copyright 2016 IBM Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
* implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef __PCI_QUIRK_H | ||
#define __PCI_QUIRK_H | ||
|
||
#include <pci.h> | ||
|
||
#define PCI_ANY_ID 0xFFFF | ||
|
||
struct pci_quirk { | ||
void (*fixup)(struct phb *, struct pci_device *); | ||
uint16_t vendor_id; | ||
uint16_t device_id; | ||
}; | ||
|
||
void pci_handle_quirk(struct phb *phb, | ||
struct pci_device *pd, | ||
uint16_t vendor_id, | ||
uint16_t device_id); | ||
|
||
#endif /* __PCI_QUIRK_H */ |