hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/mfd/intel_soc_pmic_bxtwc.c
....@@ -1,28 +1,21 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * MFD core driver for Intel Broxton Whiskey Cove PMIC
34 *
45 * Copyright (C) 2015 Intel Corporation. All rights reserved.
5
- *
6
- * This program is free software; you can redistribute it and/or modify it
7
- * under the terms and conditions of the GNU General Public License,
8
- * version 2, as published by the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope it will be useful, but WITHOUT
11
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13
- * more details.
146 */
157
16
-#include <linux/module.h>
178 #include <linux/acpi.h>
18
-#include <linux/err.h>
199 #include <linux/delay.h>
10
+#include <linux/err.h>
2011 #include <linux/interrupt.h>
2112 #include <linux/kernel.h>
2213 #include <linux/mfd/core.h>
2314 #include <linux/mfd/intel_soc_pmic.h>
2415 #include <linux/mfd/intel_soc_pmic_bxtwc.h>
25
-#include <asm/intel_pmc_ipc.h>
16
+#include <linux/module.h>
17
+
18
+#include <asm/intel_scu_ipc.h>
2619
2720 /* PMIC device registers */
2821 #define REG_ADDR_MASK 0xFF00
....@@ -64,6 +57,10 @@
6457
6558 /* Whiskey Cove PMIC share same ACPI ID between different platforms */
6659 #define BROXTON_PMIC_WC_HRV 4
60
+
61
+#define PMC_PMIC_ACCESS 0xFF
62
+#define PMC_PMIC_READ 0x0
63
+#define PMC_PMIC_WRITE 0x1
6764
6865 enum bxtwc_irqs {
6966 BXTWC_PWRBTN_LVL1_IRQ = 0,
....@@ -295,13 +292,12 @@
295292
296293 ipc_in[0] = reg;
297294 ipc_in[1] = i2c_addr;
298
- ret = intel_pmc_ipc_command(PMC_IPC_PMIC_ACCESS,
299
- PMC_IPC_PMIC_ACCESS_READ,
300
- ipc_in, sizeof(ipc_in), (u32 *)ipc_out, 1);
301
- if (ret) {
302
- dev_err(pmic->dev, "Failed to read from PMIC\n");
295
+ ret = intel_scu_ipc_dev_command(pmic->scu, PMC_PMIC_ACCESS,
296
+ PMC_PMIC_READ, ipc_in, sizeof(ipc_in),
297
+ ipc_out, sizeof(ipc_out));
298
+ if (ret)
303299 return ret;
304
- }
300
+
305301 *val = ipc_out[0];
306302
307303 return 0;
....@@ -310,7 +306,6 @@
310306 static int regmap_ipc_byte_reg_write(void *context, unsigned int reg,
311307 unsigned int val)
312308 {
313
- int ret;
314309 int i2c_addr;
315310 u8 ipc_in[3];
316311 struct intel_soc_pmic *pmic = context;
....@@ -328,15 +323,9 @@
328323 ipc_in[0] = reg;
329324 ipc_in[1] = i2c_addr;
330325 ipc_in[2] = val;
331
- ret = intel_pmc_ipc_command(PMC_IPC_PMIC_ACCESS,
332
- PMC_IPC_PMIC_ACCESS_WRITE,
333
- ipc_in, sizeof(ipc_in), NULL, 0);
334
- if (ret) {
335
- dev_err(pmic->dev, "Failed to write to PMIC\n");
336
- return ret;
337
- }
338
-
339
- return 0;
326
+ return intel_scu_ipc_dev_command(pmic->scu, PMC_PMIC_ACCESS,
327
+ PMC_PMIC_WRITE, ipc_in, sizeof(ipc_in),
328
+ NULL, 0);
340329 }
341330
342331 /* sysfs interfaces to r/w PMIC registers, required by initial script */
....@@ -457,15 +446,17 @@
457446 return -ENOMEM;
458447
459448 ret = platform_get_irq(pdev, 0);
460
- if (ret < 0) {
461
- dev_err(&pdev->dev, "Invalid IRQ\n");
449
+ if (ret < 0)
462450 return ret;
463
- }
464451 pmic->irq = ret;
465452
466453 dev_set_drvdata(&pdev->dev, pmic);
467454 pmic->dev = &pdev->dev;
468455
456
+ pmic->scu = devm_intel_scu_ipc_dev_get(&pdev->dev);
457
+ if (!pmic->scu)
458
+ return -EPROBE_DEFER;
459
+
469460 pmic->regmap = devm_regmap_init(&pdev->dev, NULL, pmic,
470461 &bxtwc_regmap_config);
471462 if (IS_ERR(pmic->regmap)) {