1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * isst_tpmi.c: SST TPMI interface
4  *
5  * Copyright (c) 2023, Intel Corporation.
6  * All Rights Reserved.
7  *
8  */
9 
10 #include <linux/auxiliary_bus.h>
11 #include <linux/module.h>
12 #include <linux/intel_tpmi.h>
13 
14 #include "isst_tpmi_core.h"
15 
intel_sst_probe(struct auxiliary_device * auxdev,const struct auxiliary_device_id * id)16 static int intel_sst_probe(struct auxiliary_device *auxdev, const struct auxiliary_device_id *id)
17 {
18 	int ret;
19 
20 	ret = tpmi_sst_init();
21 	if (ret)
22 		return ret;
23 
24 	ret = tpmi_sst_dev_add(auxdev);
25 	if (ret)
26 		tpmi_sst_exit();
27 
28 	return ret;
29 }
30 
intel_sst_remove(struct auxiliary_device * auxdev)31 static void intel_sst_remove(struct auxiliary_device *auxdev)
32 {
33 	tpmi_sst_dev_remove(auxdev);
34 	tpmi_sst_exit();
35 }
36 
intel_sst_suspend(struct device * dev)37 static int intel_sst_suspend(struct device *dev)
38 {
39 	tpmi_sst_dev_suspend(to_auxiliary_dev(dev));
40 
41 	return 0;
42 }
43 
intel_sst_resume(struct device * dev)44 static int intel_sst_resume(struct device *dev)
45 {
46 	tpmi_sst_dev_resume(to_auxiliary_dev(dev));
47 
48 	return 0;
49 }
50 
51 static DEFINE_SIMPLE_DEV_PM_OPS(intel_sst_pm, intel_sst_suspend, intel_sst_resume);
52 
53 static const struct auxiliary_device_id intel_sst_id_table[] = {
54 	{ .name = "intel_vsec.tpmi-sst" },
55 	{}
56 };
57 MODULE_DEVICE_TABLE(auxiliary, intel_sst_id_table);
58 
59 static struct auxiliary_driver intel_sst_aux_driver = {
60 	.id_table       = intel_sst_id_table,
61 	.remove         = intel_sst_remove,
62 	.probe          = intel_sst_probe,
63 	.driver = {
64 		.pm = pm_sleep_ptr(&intel_sst_pm),
65 	},
66 };
67 
68 module_auxiliary_driver(intel_sst_aux_driver);
69 
70 MODULE_IMPORT_NS(INTEL_TPMI_SST);
71 MODULE_DESCRIPTION("Intel TPMI SST Driver");
72 MODULE_LICENSE("GPL");
73