aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/platform/x86/intel_scu_pcidrv.c
blob: 8c5fd8240da958395299fbf1783f16a5c332f30e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// SPDX-License-Identifier: GPL-2.0
/*
 * PCI driver for the Intel SCU.
 *
 * Copyright (C) 2008-2010, 2015, 2020 Intel Corporation
 * Authors: Sreedhara DS (sreedhara.ds@intel.com)
 *	    Mika Westerberg <mika.westerberg@linux.intel.com>
 */

#include <linux/errno.h>
#include <linux/init.h>
#include <linux/pci.h>

#include <asm/intel-mid.h>
#include <asm/intel_scu_ipc.h>

static int intel_scu_pci_probe(struct pci_dev *pdev,
			       const struct pci_device_id *id)
{
	void (*setup_fn)(void) = (void (*)(void))id->driver_data;
	struct intel_scu_ipc_data scu_data = {};
	struct intel_scu_ipc_dev *scu;
	int ret;

	ret = pcim_enable_device(pdev);
	if (ret)
		return ret;

	scu_data.mem = pdev->resource[0];
	scu_data.irq = pdev->irq;

	scu = intel_scu_ipc_register(&pdev->dev, &scu_data);
	if (IS_ERR(scu))
		return PTR_ERR(scu);

	if (setup_fn)
		setup_fn();
	return 0;
}

static void intel_mid_scu_setup(void)
{
	intel_scu_devices_create();
}

static const struct pci_device_id pci_ids[] = {
	{ PCI_VDEVICE(INTEL, 0x080e),
	  .driver_data = (kernel_ulong_t)intel_mid_scu_setup },
	{ PCI_VDEVICE(INTEL, 0x08ea),
	  .driver_data = (kernel_ulong_t)intel_mid_scu_setup },
	{ PCI_VDEVICE(INTEL, 0x0a94) },
	{ PCI_VDEVICE(INTEL, 0x11a0),
	  .driver_data = (kernel_ulong_t)intel_mid_scu_setup },
	{ PCI_VDEVICE(INTEL, 0x1a94) },
	{ PCI_VDEVICE(INTEL, 0x5a94) },
	{}
};

static struct pci_driver intel_scu_pci_driver = {
	.driver = {
		.suppress_bind_attrs = true,
	},
	.name = "intel_scu",
	.id_table = pci_ids,
	.probe = intel_scu_pci_probe,
};

builtin_pci_driver(intel_scu_pci_driver);