platform:x86: add Intel Broxton PMC IPC driver
Subsystems (2)
PATCH v4 1/1 platform:x86: add Intel Broxton PMC IPC driver
From: "qipeng.zha" <[email protected]>
This driver provides support for PMC control on Broxton platforms, PMC is ARC processor which defined some IPC commands for communication with other entities running in IA
--- arch/x86/include/asm/intel_pmc_ipc.h | 82 ++++ drivers/platform/x86/Kconfig | 7 + drivers/platform/x86/Makefile | 1 + drivers/platform/x86/intel_pmc_ipc.c | 766 +++++++++++++++++++++++++++++++++++ 4 files changed, 856 insertions(+) create mode 100644 arch/x86/include/asm/intel_pmc_ipc.h create mode 100644 drivers/platform/x86/intel_pmc_ipc.c
arch/x86/include/asm/intel_pmc_ipc.h new file +82 -0
@@ -0,0 +1,82 @@ +#ifndef _ASM_X86_INTEL_PMC_IPC_H_ +#define _ASM_X86_INTEL_PMC_IPC_H_ + +/* Commands */ +#define PMC_IPC_PMIC_ACCESS 0xFF +#define PMC_IPC_PMIC_ACCESS_READ 0x0 +#define PMC_IPC_PMIC_ACCESS_WRITE 0x1 +#define PMC_IPC_USB_PWR_CTRL 0xF0 +#define PMC_IPC_PMIC_BLACKLIST_SEL 0xEF +#define PMC_IPC_PHY_CONFIG 0xEE +#define PMC_IPC_NORTHPEAK_CTRL 0xED +#define PMC_IPC_PM_DEBUG 0xEC +#define PMC_IPC_PMC_TELEMTRY 0xEB +#define PMC_IPC_PMC_FW_MSG_CTRL 0xEA + +/* IPC return code */ +#define IPC_ERR_NONE 0 +#define IPC_ERR_CMD_NOT_SUPPORTED 1 +#define IPC_ERR_CMD_NOT_SERVICED 2 +#define IPC_ERR_UNABLE_TO_SERVICE 3 +#define IPC_ERR_CMD_INVALID 4 +#define IPC_ERR_CMD_FAILED 5 +#define IPC_ERR_EMSECURITY 6 +#define IPC_ERR_UNSIGNEDKERNEL 7 + +#if IS_ENABLED (CONFIG_INTEL_PMC_IPC ) + +/* +* intel_pmc_ipc_simple_command +* @cmd: command +* @sub: sub type +*/ +int intel_pmc_ipc_simple_command (int cmd,int sub); + +/* +* intel_pmc_ipc_raw_cmd +* @cmd: command +* @sub: sub type +* @in: input data +* @inlen: input length in bytes +* @out: output data +* @outlen: output length in dwords +* @sptr: data writing to SPTR register +* @dptr: data writing to DPTR register +*/ +int intel_pmc_ipc_raw_cmd (u32 cmd,u32 sub,u8 *in,u32 inlen, +u32 *out,u32 outlen,u32 dptr,u32 sptr); + +/* +* intel_pmc_ipc_command +* @cmd: command +* @sub: sub type +* @in: input data +* @inlen: input length in bytes +* @out: output data +* @outlen: output length in dwords +*/ +int intel_pmc_ipc_command (u32 cmd,u32 sub,u8 *in,u32 inlen, +u32 *out,u32 outlen); + +#else + +static inline int intel_pmc_ipc_simple_command (int cmd,int sub) +{ +return -EINVAL ; +} + +static inline int intel_pmc_ipc_raw_cmd (u32 cmd,u32 sub,u8 *in,u32 inlen, +u32 *out,u32 outlen,u32 dptr,u32 sptr) +{ +return -EINVAL ; +} + +static inline int intel_pmc_ipc_command (u32 cmd,u32 sub,u8 *in,u32 inlen, +u32 *out,u32 outlen) +{ +return -EINVAL ; +} + +#endif /*CONFIG_INTEL_PMC_IPC*/ + +#endif
drivers/platform/x86/Kconfig +7 -0
@@ -884,4 +884,11 @@ config PVPANIC a paravirtualized device provided by QEMU; it lets a virtual machine (guest) communicate panic events to the host. +config INTEL_PMC_IPC + tristate "Intel PMC IPC Driver" + ---help--- + This driver provides support for PMC control on some Intel platforms, + PMC is ARC processor which defined some IPC commands for communication + with other entities which running in IA. + endif # X86_PLATFORM_DEVICES
drivers/platform/x86/Makefile +1 -0
@@ -58,3 +58,4 @@ obj-$(CONFIG_INTEL_SMARTCONNECT) += intel-smartconnect.o obj-$(CONFIG_PVPANIC) += pvpanic.o obj-$(CONFIG_ALIENWARE_WMI) += alienware-wmi.o +obj-$(CONFIG_INTEL_PMC_IPC) += intel_pmc_ipc.o
drivers/platform/x86/intel_pmc_ipc.c new file +766 -0
766 lines not on this page · raw message
Signature · 1 line
1.8.3.2
Quoted 5 lines · qipeng.zha
From: "qipeng.zha" <[email protected]>
This driver provides support for PMC control on Broxton platforms, PMC is ARC processor which defined some IPC commands for communication with other entities running in IA
A credit to intel_scu_ipc.c is probably in order here - I presume you modeled this heavily on that driver?
Quoted 3 lines
Signed-off-by qipeng.zha <[email protected]>---
Please provide a change log for the various bersions
It really helps to get code reviews if you will take the time to provide your reviewers with the context they need review the delta from what they have previously reviewed. See Documentation/SubmittingPatches. This is especially critical for a 1000 line patch.
Specifically, Alan gave some broad feeback which is generally difficult to determine if you followed.
Also, Jacob and Fei discussed the regmap interface, and that possibly that would come later. Is this in the works for this driver?
A few minor nits below, spelling, DEVICE_ATTR_RW usage, etc.
drivers/platform/x86/intel_pmc_ipc.c line 326
Quoted 13 lines
arch/x86/include/asm/intel_pmc_ipc.h | 82 ++++ drivers/platform/x86/Kconfig | 7 + drivers/platform/x86/Makefile | 1 + drivers/platform/x86/intel_pmc_ipc.c | 766 +++++++++++++++++++++++++++++++++++ 4 files changed, 856 insertions(+) create mode 100644 arch/x86/include/asm/intel_pmc_ipc.h create mode 100644 drivers/platform/x86/intel_pmc_ipc.cdrivers/platform/x86/intel_pmc_ipc.c new file +4
-0+ pci_resource =pci_resource_start (pdev,0 ); + len =pci_resource_len (pdev,0 ); +if (!pci_resource || !len) { +dev_err (&pdev->dev,"Fail to get resource\n" );
Here and elsewhere, please use the past tense: "Failed"
drivers/platform/x86/intel_pmc_ipc.c line 427
Quoted 12 lines
drivers/platform/x86/intel_pmc_ipc.c new file +12
-0+static DEVICE_ATTR(simplecmd, S_IWUSR | S_IRUSR, + NULL, + intel_pmc_ipc_simple_cmd_store); +static DEVICE_ATTR(northpeak, S_IWUSR | S_IRUSR, + NULL, + intel_pmc_ipc_northpeak_store); + +static struct attribute *intel_ipc_attrs[] = { + &dev_attr_northpeak.attr, + &dev_attr_simplecmd.attr, +NULL +};
Please use the DEVICE_ATTR_RW macro.
drivers/platform/x86/intel_pmc_ipc.c line 498
Quoted 3 lines
drivers/platform/x86/intel_pmc_ipc.c new file +3
-0+ ret =platform_device_add (pdev); +if (ret) { +dev_err (ipcdev.dev,"Fail to add punit platform devcie\n" );
s/devcie/device/
drivers/platform/x86/intel_pmc_ipc.c line 765
Quoted 6 lines
drivers/platform/x86/intel_pmc_ipc.c new file +6
-0+ +MODULE_AUTHOR ("qipeng <[email protected]>" ); +MODULE_DESCRIPTION ("Intel PMC IPC driver" ); +MODULE_LICENSE ("GPL" ); + +fs_initcall (intel_pmc_ipc_init);
If not using module_init(), please document why you need an alternate init priority.
Signature · 2 lines
Darren Hart Intel Open Source Technology Center
Quoted 7 lines · Darren Hart
Quoted 7 lines
drivers/platform/x86/intel_pmc_ipc.c new file +7
-0+static DEVICE_ATTR(simplecmd, S_IWUSR | S_IRUSR, + NULL, + intel_pmc_ipc_simple_cmd_store); +static DEVICE_ATTR(northpeak, S_IWUSR | S_IRUSR, + NULL, + intel_pmc_ipc_northpeak_store); +
Quoted 8 lines
drivers/platform/x86/intel_pmc_ipc.c line 427
Quoted 5 lines
drivers/platform/x86/intel_pmc_ipc.c new file +5
-0+static struct attribute *intel_ipc_attrs[] = { + &dev_attr_northpeak.attr, + &dev_attr_simplecmd.attr, +NULL +};Please use the
DEVICE_ATTR_RWmacro.
Minor nit-nit: Those attributes don't have any "show" function so you cannot use DEVICE_ATTR_RW. If they really are not intended to be readable, then the DEVICE_ATTR_WO macro could be used for that.
Bjørn