blob: 507db476654a32b32bb93cf638ea279c3796f4e7 [file] [log] [blame]
Alexander Shishkin2b0b16d2015-09-22 15:47:15 +03001/*
2 * Intel(R) Trace Hub pci driver
3 *
4 * Copyright (C) 2014-2015 Intel Corporation.
5 *
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.
9 *
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
13 * more details.
14 */
15
16#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
17
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>
23
24#include "intel_th.h"
25
26#define DRIVER_NAME "intel_th_pci"
27
28#define BAR_MASK (BIT(TH_MMIO_CONFIG) | BIT(TH_MMIO_SW))
29
30static int intel_th_pci_probe(struct pci_dev *pdev,
31 const struct pci_device_id *id)
32{
33 struct intel_th *th;
34 int err;
35
36 err = pcim_enable_device(pdev);
37 if (err)
38 return err;
39
40 err = pcim_iomap_regions_request_all(pdev, BAR_MASK, DRIVER_NAME);
41 if (err)
42 return err;
43
44 th = intel_th_alloc(&pdev->dev, pdev->resource,
45 DEVICE_COUNT_RESOURCE, pdev->irq);
46 if (IS_ERR(th))
47 return PTR_ERR(th);
48
Alexander Shishkine9b2b3e2017-08-10 11:10:58 +030049 pci_set_master(pdev);
50
Alexander Shishkin2b0b16d2015-09-22 15:47:15 +030051 return 0;
52}
53
54static void intel_th_pci_remove(struct pci_dev *pdev)
55{
56 struct intel_th *th = pci_get_drvdata(pdev);
57
58 intel_th_free(th);
59}
60
61static const struct pci_device_id intel_th_pci_id_table[] = {
62 {
63 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x9d26),
64 .driver_data = (kernel_ulong_t)0,
65 },
66 {
67 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa126),
68 .driver_data = (kernel_ulong_t)0,
69 },
Alexander Shishkin6396b912015-12-22 17:25:22 +020070 {
71 /* Apollo Lake */
72 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x5a8e),
73 .driver_data = (kernel_ulong_t)0,
74 },
Alexander Shishkin3f040882015-12-22 17:25:23 +020075 {
76 /* Broxton */
77 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0a80),
78 .driver_data = (kernel_ulong_t)0,
79 },
Alexander Shishkinaaa3ca82016-04-08 18:26:52 +030080 {
81 /* Broxton B-step */
82 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x1a8e),
83 .driver_data = (kernel_ulong_t)0,
84 },
Alexander Shishkin7a1a47c2016-06-28 18:55:23 +030085 {
86 /* Kaby Lake PCH-H */
87 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa2a6),
88 .driver_data = (kernel_ulong_t)0,
89 },
Alexander Shishkin5118ccd2015-09-08 14:03:55 +030090 {
91 /* Denverton */
92 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x19e1),
93 .driver_data = (kernel_ulong_t)0,
94 },
Alexander Shishkin340837f2016-06-30 16:10:51 +030095 {
96 /* Gemini Lake */
97 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x318e),
98 .driver_data = (kernel_ulong_t)0,
99 },
Alexander Shishkin84331e12016-06-30 16:11:13 +0300100 {
101 /* Cannon Lake H */
102 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa326),
103 .driver_data = (kernel_ulong_t)0,
104 },
Alexander Shishkin2b0b16d2015-09-22 15:47:15 +0300105 { 0 },
106};
107
108MODULE_DEVICE_TABLE(pci, intel_th_pci_id_table);
109
110static struct pci_driver intel_th_pci_driver = {
111 .name = DRIVER_NAME,
112 .id_table = intel_th_pci_id_table,
113 .probe = intel_th_pci_probe,
114 .remove = intel_th_pci_remove,
115};
116
117module_pci_driver(intel_th_pci_driver);
118
119MODULE_LICENSE("GPL v2");
120MODULE_DESCRIPTION("Intel(R) Trace Hub PCI controller driver");
121MODULE_AUTHOR("Alexander Shishkin <alexander.shishkin@intel.com>");