blob: 4dbe651f71f59f1faea1294e301fd3491e702551 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Venki Pallipadi3ad0b022008-10-22 16:34:52 -07002
3#ifndef I7300_IDLE_H
4#define I7300_IDLE_H
5
6#include <linux/pci.h>
7
8/*
9 * I/O AT controls (PCI bus 0 device 8 function 0)
10 * DIMM controls (PCI bus 0 device 16 function 1)
11 */
12#define IOAT_BUS 0
13#define IOAT_DEVFN PCI_DEVFN(8, 0)
14#define MEMCTL_BUS 0
15#define MEMCTL_DEVFN PCI_DEVFN(16, 1)
16
17struct fbd_ioat {
18 unsigned int vendor;
19 unsigned int ioat_dev;
Len Brown2f102602009-05-27 23:59:58 -040020 unsigned int enabled;
Venki Pallipadi3ad0b022008-10-22 16:34:52 -070021};
22
23/*
24 * The i5000 chip-set has the same hooks as the i7300
Len Brown2f102602009-05-27 23:59:58 -040025 * but it is not enabled by default and must be manually
26 * manually enabled with "forceload=1" because it is
27 * only lightly validated.
Venki Pallipadi3ad0b022008-10-22 16:34:52 -070028 */
Venki Pallipadi3ad0b022008-10-22 16:34:52 -070029
30static const struct fbd_ioat fbd_ioat_list[] = {
Len Brown2f102602009-05-27 23:59:58 -040031 {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IOAT_CNB, 1},
32 {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IOAT, 0},
Venki Pallipadi3ad0b022008-10-22 16:34:52 -070033 {0, 0}
34};
35
36/* table of devices that work with this driver */
37static const struct pci_device_id pci_tbl[] = {
38 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_FBD_CNB) },
Venki Pallipadi3ad0b022008-10-22 16:34:52 -070039 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5000_ERR) },
Venki Pallipadi3ad0b022008-10-22 16:34:52 -070040 { } /* Terminating entry */
41};
42
43/* Check for known platforms with I/O-AT */
44static inline int i7300_idle_platform_probe(struct pci_dev **fbd_dev,
Len Brown2f102602009-05-27 23:59:58 -040045 struct pci_dev **ioat_dev,
46 int enable_all)
Venki Pallipadi3ad0b022008-10-22 16:34:52 -070047{
48 int i;
49 struct pci_dev *memdev, *dmadev;
50
51 memdev = pci_get_bus_and_slot(MEMCTL_BUS, MEMCTL_DEVFN);
52 if (!memdev)
53 return -ENODEV;
54
55 for (i = 0; pci_tbl[i].vendor != 0; i++) {
56 if (memdev->vendor == pci_tbl[i].vendor &&
57 memdev->device == pci_tbl[i].device) {
58 break;
59 }
60 }
61 if (pci_tbl[i].vendor == 0)
62 return -ENODEV;
63
64 dmadev = pci_get_bus_and_slot(IOAT_BUS, IOAT_DEVFN);
65 if (!dmadev)
66 return -ENODEV;
67
68 for (i = 0; fbd_ioat_list[i].vendor != 0; i++) {
69 if (dmadev->vendor == fbd_ioat_list[i].vendor &&
70 dmadev->device == fbd_ioat_list[i].ioat_dev) {
Len Brown2f102602009-05-27 23:59:58 -040071 if (!(fbd_ioat_list[i].enabled || enable_all))
72 continue;
Venki Pallipadi3ad0b022008-10-22 16:34:52 -070073 if (fbd_dev)
74 *fbd_dev = memdev;
75 if (ioat_dev)
76 *ioat_dev = dmadev;
77
78 return 0;
79 }
80 }
81 return -ENODEV;
82}
83
84#endif