.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
---|
1 | 2 | /* |
---|
2 | 3 | * MFD core driver for Intel Broxton Whiskey Cove PMIC |
---|
3 | 4 | * |
---|
4 | 5 | * 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. |
---|
14 | 6 | */ |
---|
15 | 7 | |
---|
16 | | -#include <linux/module.h> |
---|
17 | 8 | #include <linux/acpi.h> |
---|
18 | | -#include <linux/err.h> |
---|
19 | 9 | #include <linux/delay.h> |
---|
| 10 | +#include <linux/err.h> |
---|
20 | 11 | #include <linux/interrupt.h> |
---|
21 | 12 | #include <linux/kernel.h> |
---|
22 | 13 | #include <linux/mfd/core.h> |
---|
23 | 14 | #include <linux/mfd/intel_soc_pmic.h> |
---|
24 | 15 | #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> |
---|
26 | 19 | |
---|
27 | 20 | /* PMIC device registers */ |
---|
28 | 21 | #define REG_ADDR_MASK 0xFF00 |
---|
.. | .. |
---|
64 | 57 | |
---|
65 | 58 | /* Whiskey Cove PMIC share same ACPI ID between different platforms */ |
---|
66 | 59 | #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 |
---|
67 | 64 | |
---|
68 | 65 | enum bxtwc_irqs { |
---|
69 | 66 | BXTWC_PWRBTN_LVL1_IRQ = 0, |
---|
.. | .. |
---|
295 | 292 | |
---|
296 | 293 | ipc_in[0] = reg; |
---|
297 | 294 | 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) |
---|
303 | 299 | return ret; |
---|
304 | | - } |
---|
| 300 | + |
---|
305 | 301 | *val = ipc_out[0]; |
---|
306 | 302 | |
---|
307 | 303 | return 0; |
---|
.. | .. |
---|
310 | 306 | static int regmap_ipc_byte_reg_write(void *context, unsigned int reg, |
---|
311 | 307 | unsigned int val) |
---|
312 | 308 | { |
---|
313 | | - int ret; |
---|
314 | 309 | int i2c_addr; |
---|
315 | 310 | u8 ipc_in[3]; |
---|
316 | 311 | struct intel_soc_pmic *pmic = context; |
---|
.. | .. |
---|
328 | 323 | ipc_in[0] = reg; |
---|
329 | 324 | ipc_in[1] = i2c_addr; |
---|
330 | 325 | 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); |
---|
340 | 329 | } |
---|
341 | 330 | |
---|
342 | 331 | /* sysfs interfaces to r/w PMIC registers, required by initial script */ |
---|
.. | .. |
---|
457 | 446 | return -ENOMEM; |
---|
458 | 447 | |
---|
459 | 448 | ret = platform_get_irq(pdev, 0); |
---|
460 | | - if (ret < 0) { |
---|
461 | | - dev_err(&pdev->dev, "Invalid IRQ\n"); |
---|
| 449 | + if (ret < 0) |
---|
462 | 450 | return ret; |
---|
463 | | - } |
---|
464 | 451 | pmic->irq = ret; |
---|
465 | 452 | |
---|
466 | 453 | dev_set_drvdata(&pdev->dev, pmic); |
---|
467 | 454 | pmic->dev = &pdev->dev; |
---|
468 | 455 | |
---|
| 456 | + pmic->scu = devm_intel_scu_ipc_dev_get(&pdev->dev); |
---|
| 457 | + if (!pmic->scu) |
---|
| 458 | + return -EPROBE_DEFER; |
---|
| 459 | + |
---|
469 | 460 | pmic->regmap = devm_regmap_init(&pdev->dev, NULL, pmic, |
---|
470 | 461 | &bxtwc_regmap_config); |
---|
471 | 462 | if (IS_ERR(pmic->regmap)) { |
---|