summaryrefslogtreecommitdiff
path: root/drivers/platform/x86/intel/speed_select_if/isst_tpmi.c
blob: 17972191538a390acaa6d1650cbed3e826219bd9 (plain)
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
69
70
71
72
// SPDX-License-Identifier: GPL-2.0-only
/*
 * isst_tpmi.c: SST TPMI interface
 *
 * Copyright (c) 2023, Intel Corporation.
 * All Rights Reserved.
 *
 */

#include <linux/auxiliary_bus.h>
#include <linux/module.h>
#include <linux/intel_tpmi.h>

#include "isst_tpmi_core.h"

static int intel_sst_probe(struct auxiliary_device *auxdev, const struct auxiliary_device_id *id)
{
	int ret;

	ret = tpmi_sst_init();
	if (ret)
		return ret;

	ret = tpmi_sst_dev_add(auxdev);
	if (ret)
		tpmi_sst_exit();

	return ret;
}

static void intel_sst_remove(struct auxiliary_device *auxdev)
{
	tpmi_sst_dev_remove(auxdev);
	tpmi_sst_exit();
}

static int intel_sst_suspend(struct device *dev)
{
	tpmi_sst_dev_suspend(to_auxiliary_dev(dev));

	return 0;
}

static int intel_sst_resume(struct device *dev)
{
	tpmi_sst_dev_resume(to_auxiliary_dev(dev));

	return 0;
}

static DEFINE_SIMPLE_DEV_PM_OPS(intel_sst_pm, intel_sst_suspend, intel_sst_resume);

static const struct auxiliary_device_id intel_sst_id_table[] = {
	{ .name = "intel_vsec.tpmi-sst" },
	{}
};
MODULE_DEVICE_TABLE(auxiliary, intel_sst_id_table);

static struct auxiliary_driver intel_sst_aux_driver = {
	.id_table       = intel_sst_id_table,
	.remove         = intel_sst_remove,
	.probe          = intel_sst_probe,
	.driver = {
		.pm = pm_sleep_ptr(&intel_sst_pm),
	},
};

module_auxiliary_driver(intel_sst_aux_driver);

MODULE_IMPORT_NS(INTEL_TPMI_SST);
MODULE_DESCRIPTION("Intel TPMI SST Driver");
MODULE_LICENSE("GPL");