forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-02-20 e636c8d336489bf3eed5878299e6cc045bbad077
kernel/drivers/platform/x86/intel_mid_powerbtn.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Power button driver for Intel MID platforms.
34 *
....@@ -5,18 +6,8 @@
56 *
67 * Author: Hong Liu <hong.liu@intel.com>
78 * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as published by
11
- * the Free Software Foundation; version 2 of the License.
12
- *
13
- * This program is distributed in the hope that it will be useful, but
14
- * WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
- * General Public License for more details.
179 */
1810
19
-#include <linux/init.h>
2011 #include <linux/input.h>
2112 #include <linux/interrupt.h>
2213 #include <linux/mfd/intel_msic.h>
....@@ -55,6 +46,7 @@
5546 unsigned short mirqlvl1_addr;
5647 unsigned short pbstat_addr;
5748 u8 pbstat_mask;
49
+ struct intel_scu_ipc_dev *scu;
5850 int (*setup)(struct mid_pb_ddata *ddata);
5951 };
6052
....@@ -64,7 +56,8 @@
6456 int ret;
6557 u8 pbstat;
6658
67
- ret = intel_scu_ipc_ioread8(ddata->pbstat_addr, &pbstat);
59
+ ret = intel_scu_ipc_dev_ioread8(ddata->scu, ddata->pbstat_addr,
60
+ &pbstat);
6861 if (ret)
6962 return ret;
7063
....@@ -76,14 +69,15 @@
7669
7770 static int mid_irq_ack(struct mid_pb_ddata *ddata)
7871 {
79
- return intel_scu_ipc_update_register(ddata->mirqlvl1_addr, 0, MSIC_PWRBTNM);
72
+ return intel_scu_ipc_dev_update(ddata->scu, ddata->mirqlvl1_addr, 0,
73
+ MSIC_PWRBTNM);
8074 }
8175
8276 static int mrfld_setup(struct mid_pb_ddata *ddata)
8377 {
8478 /* Unmask the PBIRQ and MPBIRQ on Tangier */
85
- intel_scu_ipc_update_register(BCOVE_PBIRQ, 0, MSIC_PWRBTNM);
86
- intel_scu_ipc_update_register(BCOVE_PBIRQMASK, 0, MSIC_PWRBTNM);
79
+ intel_scu_ipc_dev_update(ddata->scu, BCOVE_PBIRQ, 0, MSIC_PWRBTNM);
80
+ intel_scu_ipc_dev_update(ddata->scu, BCOVE_PBIRQMASK, 0, MSIC_PWRBTNM);
8781
8882 return 0;
8983 }
....@@ -121,12 +115,9 @@
121115 .setup = mrfld_setup,
122116 };
123117
124
-#define ICPU(model, ddata) \
125
- { X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, (kernel_ulong_t)&ddata }
126
-
127118 static const struct x86_cpu_id mid_pb_cpu_ids[] = {
128
- ICPU(INTEL_FAM6_ATOM_SALTWELL_MID, mfld_ddata),
129
- ICPU(INTEL_FAM6_ATOM_SILVERMONT_MID, mrfld_ddata),
119
+ X86_MATCH_INTEL_FAM6_MODEL(ATOM_SALTWELL_MID, &mfld_ddata),
120
+ X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT_MID, &mrfld_ddata),
130121 {}
131122 };
132123
....@@ -173,6 +164,10 @@
173164 return error;
174165 }
175166
167
+ ddata->scu = devm_intel_scu_ipc_dev_get(&pdev->dev);
168
+ if (!ddata->scu)
169
+ return -EPROBE_DEFER;
170
+
176171 error = devm_request_threaded_irq(&pdev->dev, irq, NULL, mid_pb_isr,
177172 IRQF_ONESHOT, DRIVER_NAME, ddata);
178173 if (error) {