Skip to content

Commit 2b0b16d

Browse files
virtuosogregkh
authored andcommitted
intel_th: Add pci glue layer for Intel(R) Trace Hub
This patch adds basic support for PCI-based Intel TH devices. It requests 2 bars (configuration registers for the subdevices and STH channel MMIO region) and calls into Intel TH core code to create the bus with subdevices etc. Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 39f4034 commit 2b0b16d

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed

drivers/hwtracing/intel_th/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ config INTEL_TH
1515

1616
if INTEL_TH
1717

18+
config INTEL_TH_PCI
19+
tristate "Intel(R) Trace Hub PCI controller"
20+
depends on PCI
21+
help
22+
Intel(R) Trace Hub may exist as a PCI device. This option enables
23+
support glue layer for PCI-based Intel TH.
24+
25+
Say Y here to enable PCI Intel TH support.
26+
1827
config INTEL_TH_DEBUG
1928
bool "Intel(R) Trace Hub debugging"
2029
depends on DEBUG_FS

drivers/hwtracing/intel_th/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
obj-$(CONFIG_INTEL_TH) += intel_th.o
22
intel_th-y := core.o
33
intel_th-$(CONFIG_INTEL_TH_DEBUG) += debug.o
4+
5+
obj-$(CONFIG_INTEL_TH_PCI) += intel_th_pci.o
6+
intel_th_pci-y := pci.o

drivers/hwtracing/intel_th/pci.c

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
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+
30+
static 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+
49+
pci_set_drvdata(pdev, th);
50+
51+
return 0;
52+
}
53+
54+
static 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+
61+
static 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+
},
70+
{ 0 },
71+
};
72+
73+
MODULE_DEVICE_TABLE(pci, intel_th_pci_id_table);
74+
75+
static struct pci_driver intel_th_pci_driver = {
76+
.name = DRIVER_NAME,
77+
.id_table = intel_th_pci_id_table,
78+
.probe = intel_th_pci_probe,
79+
.remove = intel_th_pci_remove,
80+
};
81+
82+
module_pci_driver(intel_th_pci_driver);
83+
84+
MODULE_LICENSE("GPL v2");
85+
MODULE_DESCRIPTION("Intel(R) Trace Hub PCI controller driver");
86+
MODULE_AUTHOR("Alexander Shishkin <[email protected]>");

0 commit comments

Comments
 (0)