hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/drivers/platform/x86/intel_punit_ipc.c
....@@ -1,25 +1,22 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Driver for the Intel P-Unit Mailbox IPC mechanism
34 *
45 * (C) Copyright 2015 Intel Corporation
56 *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2 as
8
- * published by the Free Software Foundation.
9
- *
107 * The heart of the P-Unit is the Foxton microcontroller and its firmware,
118 * which provide mailbox interface for power management usage.
129 */
1310
14
-#include <linux/module.h>
15
-#include <linux/mod_devicetable.h>
16
-#include <linux/acpi.h>
17
-#include <linux/delay.h>
1811 #include <linux/bitops.h>
12
+#include <linux/delay.h>
1913 #include <linux/device.h>
2014 #include <linux/interrupt.h>
2115 #include <linux/io.h>
16
+#include <linux/mod_devicetable.h>
17
+#include <linux/module.h>
2218 #include <linux/platform_device.h>
19
+
2320 #include <asm/intel_punit_ipc.h>
2421
2522 /* IPC Mailbox registers */
....@@ -226,7 +223,6 @@
226223
227224 static int intel_punit_get_bars(struct platform_device *pdev)
228225 {
229
- struct resource *res;
230226 void __iomem *addr;
231227
232228 /*
....@@ -234,14 +230,12 @@
234230 * - BIOS_IPC BASE_DATA
235231 * - BIOS_IPC BASE_IFACE
236232 */
237
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
238
- addr = devm_ioremap_resource(&pdev->dev, res);
233
+ addr = devm_platform_ioremap_resource(pdev, 0);
239234 if (IS_ERR(addr))
240235 return PTR_ERR(addr);
241236 punit_ipcdev->base[BIOS_IPC][BASE_DATA] = addr;
242237
243
- res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
244
- addr = devm_ioremap_resource(&pdev->dev, res);
238
+ addr = devm_platform_ioremap_resource(pdev, 1);
245239 if (IS_ERR(addr))
246240 return PTR_ERR(addr);
247241 punit_ipcdev->base[BIOS_IPC][BASE_IFACE] = addr;
....@@ -253,33 +247,21 @@
253247 * - GTDRIVER_IPC BASE_DATA
254248 * - GTDRIVER_IPC BASE_IFACE
255249 */
256
- res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
257
- if (res && resource_size(res) > 1) {
258
- addr = devm_ioremap_resource(&pdev->dev, res);
259
- if (!IS_ERR(addr))
260
- punit_ipcdev->base[ISPDRIVER_IPC][BASE_DATA] = addr;
261
- }
250
+ addr = devm_platform_ioremap_resource(pdev, 2);
251
+ if (!IS_ERR(addr))
252
+ punit_ipcdev->base[ISPDRIVER_IPC][BASE_DATA] = addr;
262253
263
- res = platform_get_resource(pdev, IORESOURCE_MEM, 3);
264
- if (res && resource_size(res) > 1) {
265
- addr = devm_ioremap_resource(&pdev->dev, res);
266
- if (!IS_ERR(addr))
267
- punit_ipcdev->base[ISPDRIVER_IPC][BASE_IFACE] = addr;
268
- }
254
+ addr = devm_platform_ioremap_resource(pdev, 3);
255
+ if (!IS_ERR(addr))
256
+ punit_ipcdev->base[ISPDRIVER_IPC][BASE_IFACE] = addr;
269257
270
- res = platform_get_resource(pdev, IORESOURCE_MEM, 4);
271
- if (res && resource_size(res) > 1) {
272
- addr = devm_ioremap_resource(&pdev->dev, res);
273
- if (!IS_ERR(addr))
274
- punit_ipcdev->base[GTDRIVER_IPC][BASE_DATA] = addr;
275
- }
258
+ addr = devm_platform_ioremap_resource(pdev, 4);
259
+ if (!IS_ERR(addr))
260
+ punit_ipcdev->base[GTDRIVER_IPC][BASE_DATA] = addr;
276261
277
- res = platform_get_resource(pdev, IORESOURCE_MEM, 5);
278
- if (res && resource_size(res) > 1) {
279
- addr = devm_ioremap_resource(&pdev->dev, res);
280
- if (!IS_ERR(addr))
281
- punit_ipcdev->base[GTDRIVER_IPC][BASE_IFACE] = addr;
282
- }
262
+ addr = devm_platform_ioremap_resource(pdev, 5);
263
+ if (!IS_ERR(addr))
264
+ punit_ipcdev->base[GTDRIVER_IPC][BASE_IFACE] = addr;
283265
284266 return 0;
285267 }
....@@ -295,9 +277,8 @@
295277
296278 platform_set_drvdata(pdev, punit_ipcdev);
297279
298
- irq = platform_get_irq(pdev, 0);
280
+ irq = platform_get_irq_optional(pdev, 0);
299281 if (irq < 0) {
300
- punit_ipcdev->irq = 0;
301282 dev_warn(&pdev->dev, "Invalid IRQ, using polling mode\n");
302283 } else {
303284 ret = devm_request_irq(&pdev->dev, irq, intel_punit_ioc,
....@@ -312,14 +293,13 @@
312293
313294 ret = intel_punit_get_bars(pdev);
314295 if (ret)
315
- goto out;
296
+ return ret;
316297
317298 punit_ipcdev->dev = &pdev->dev;
318299 mutex_init(&punit_ipcdev->lock);
319300 init_completion(&punit_ipcdev->cmd_complete);
320301
321
-out:
322
- return ret;
302
+ return 0;
323303 }
324304
325305 static int intel_punit_ipc_remove(struct platform_device *pdev)
....@@ -338,7 +318,7 @@
338318 .remove = intel_punit_ipc_remove,
339319 .driver = {
340320 .name = "intel_punit_ipc",
341
- .acpi_match_table = ACPI_PTR(punit_ipc_acpi_ids),
321
+ .acpi_match_table = punit_ipc_acpi_ids,
342322 },
343323 };
344324