2 * Intel(R) Trace Hub pci driver
4 * Copyright (C) 2014-2015 Intel Corporation.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18 #include <linux/types.h>
19 #include <linux/module.h>
20 #include <linux/device.h>
21 #include <linux/sysfs.h>
22 #include <linux/pci.h>
26 #define DRIVER_NAME "intel_th_pci"
28 #define BAR_MASK (BIT(TH_MMIO_CONFIG) | BIT(TH_MMIO_SW))
30 #define PCI_REG_NPKDSC 0x80
31 #define NPKDSC_TSACT BIT(5)
33 static int intel_th_pci_activate(struct intel_th
*th
)
35 struct pci_dev
*pdev
= to_pci_dev(th
->dev
);
39 if (!INTEL_TH_CAP(th
, tscu_enable
))
42 err
= pci_read_config_dword(pdev
, PCI_REG_NPKDSC
, &npkdsc
);
44 npkdsc
|= NPKDSC_TSACT
;
45 err
= pci_write_config_dword(pdev
, PCI_REG_NPKDSC
, npkdsc
);
49 dev_err(&pdev
->dev
, "failed to read NPKDSC register\n");
54 static void intel_th_pci_deactivate(struct intel_th
*th
)
56 struct pci_dev
*pdev
= to_pci_dev(th
->dev
);
60 if (!INTEL_TH_CAP(th
, tscu_enable
))
63 err
= pci_read_config_dword(pdev
, PCI_REG_NPKDSC
, &npkdsc
);
65 npkdsc
|= NPKDSC_TSACT
;
66 err
= pci_write_config_dword(pdev
, PCI_REG_NPKDSC
, npkdsc
);
70 dev_err(&pdev
->dev
, "failed to read NPKDSC register\n");
73 static int intel_th_pci_probe(struct pci_dev
*pdev
,
74 const struct pci_device_id
*id
)
76 struct intel_th_drvdata
*drvdata
= (void *)id
->driver_data
;
80 err
= pcim_enable_device(pdev
);
84 err
= pcim_iomap_regions_request_all(pdev
, BAR_MASK
, DRIVER_NAME
);
88 th
= intel_th_alloc(&pdev
->dev
, drvdata
, pdev
->resource
,
89 DEVICE_COUNT_RESOURCE
, pdev
->irq
);
93 th
->activate
= intel_th_pci_activate
;
94 th
->deactivate
= intel_th_pci_deactivate
;
101 static void intel_th_pci_remove(struct pci_dev
*pdev
)
103 struct intel_th
*th
= pci_get_drvdata(pdev
);
108 static const struct intel_th_drvdata intel_th_2x
= {
112 static const struct pci_device_id intel_th_pci_id_table
[] = {
114 PCI_DEVICE(PCI_VENDOR_ID_INTEL
, 0x9d26),
115 .driver_data
= (kernel_ulong_t
)0,
118 PCI_DEVICE(PCI_VENDOR_ID_INTEL
, 0xa126),
119 .driver_data
= (kernel_ulong_t
)0,
123 PCI_DEVICE(PCI_VENDOR_ID_INTEL
, 0x5a8e),
124 .driver_data
= (kernel_ulong_t
)0,
128 PCI_DEVICE(PCI_VENDOR_ID_INTEL
, 0x0a80),
129 .driver_data
= (kernel_ulong_t
)0,
133 PCI_DEVICE(PCI_VENDOR_ID_INTEL
, 0x1a8e),
134 .driver_data
= (kernel_ulong_t
)0,
137 /* Kaby Lake PCH-H */
138 PCI_DEVICE(PCI_VENDOR_ID_INTEL
, 0xa2a6),
139 .driver_data
= (kernel_ulong_t
)0,
143 PCI_DEVICE(PCI_VENDOR_ID_INTEL
, 0x19e1),
144 .driver_data
= (kernel_ulong_t
)0,
148 PCI_DEVICE(PCI_VENDOR_ID_INTEL
, 0xa1a6),
149 .driver_data
= (kernel_ulong_t
)0,
153 PCI_DEVICE(PCI_VENDOR_ID_INTEL
, 0x318e),
154 .driver_data
= (kernel_ulong_t
)&intel_th_2x
,
158 PCI_DEVICE(PCI_VENDOR_ID_INTEL
, 0xa326),
159 .driver_data
= (kernel_ulong_t
)&intel_th_2x
,
163 PCI_DEVICE(PCI_VENDOR_ID_INTEL
, 0x9da6),
164 .driver_data
= (kernel_ulong_t
)&intel_th_2x
,
168 PCI_DEVICE(PCI_VENDOR_ID_INTEL
, 0x18e1),
169 .driver_data
= (kernel_ulong_t
)&intel_th_2x
,
174 MODULE_DEVICE_TABLE(pci
, intel_th_pci_id_table
);
176 static struct pci_driver intel_th_pci_driver
= {
178 .id_table
= intel_th_pci_id_table
,
179 .probe
= intel_th_pci_probe
,
180 .remove
= intel_th_pci_remove
,
183 module_pci_driver(intel_th_pci_driver
);
185 MODULE_LICENSE("GPL v2");
186 MODULE_DESCRIPTION("Intel(R) Trace Hub PCI controller driver");
187 MODULE_AUTHOR("Alexander Shishkin <alexander.shishkin@intel.com>");