Commit 25f1ca31 authored by Mika Westerberg's avatar Mika Westerberg Committed by Lee Jones
Browse files

platform/x86: intel_pmc_ipc: Convert to MFD



This driver only creates a bunch of platform devices sharing resources
belonging to the PMC device. This is pretty much what MFD subsystem is
for so move the driver there, renaming it to intel_pmc_bxt.c which
should be more clear what it is.

MFD subsystem provides nice helper APIs for subdevice creation so
convert the driver to use those. Unfortunately the ACPI device includes
separate resources for most of the subdevices so we cannot simply call
mfd_add_devices() to create all of them but instead we need to call it
separately for each device.

The new MFD driver continues to expose two sysfs attributes that allow
userspace to send IPC commands to the PMC/SCU to avoid breaking any
existing applications that may use these. Generally this is bad idea so
document this in the ABI documentation.

Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
parent 0759a873
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
These files allow sending arbitrary IPC commands to the PMC/SCU which
may be dangerous. These will be removed eventually and should not be
used in any new applications.

What:		/sys/bus/platform/devices/INT34D2:00/simplecmd
Date:		Jun 2015
KernelVersion:	4.1
Contact:	Mika Westerberg <mika.westerberg@linux.intel.com>
Description:	This interface allows userspace to send an arbitrary
		IPC command to the PMC/SCU.

		Format: %d %d where first number is command and
		second number is subcommand.

What:		/sys/bus/platform/devices/INT34D2:00/northpeak
Date:		Jun 2015
KernelVersion:	4.1
Contact:	Mika Westerberg <mika.westerberg@linux.intel.com>
Description:	This interface allows userspace to enable and disable
		Northpeak through the PMC/SCU.

		Format: %u.
+0 −47
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_X86_INTEL_PMC_IPC_H_
#define  _ASM_X86_INTEL_PMC_IPC_H_

/* Commands */
#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_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

/* GCR reg offsets from gcr base*/
#define PMC_GCR_PMC_CFG_REG		0x08
#define PMC_GCR_TELEM_DEEP_S0IX_REG	0x78
#define PMC_GCR_TELEM_SHLW_S0IX_REG	0x80

#if IS_ENABLED(CONFIG_INTEL_PMC_IPC)

int intel_pmc_s0ix_counter_read(u64 *data);
int intel_pmc_gcr_read64(u32 offset, u64 *data);

#else

static inline int intel_pmc_s0ix_counter_read(u64 *data)
{
	return -EINVAL;
}

static inline int intel_pmc_gcr_read64(u32 offset, u64 *data)
{
	return -EINVAL;
}

#endif /*CONFIG_INTEL_PMC_IPC*/

#endif
+1 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ struct telemetry_plt_config {
	struct telemetry_unit_config ioss_config;
	struct mutex telem_trace_lock;
	struct mutex telem_lock;
	struct intel_pmc_dev *pmc;
	struct intel_scu_ipc_dev *scu;
	bool telem_in_use;
};
+15 −1
Original line number Diff line number Diff line
@@ -551,7 +551,7 @@ config INTEL_SOC_PMIC

config INTEL_SOC_PMIC_BXTWC
	tristate "Support for Intel Broxton Whiskey Cove PMIC"
	depends on INTEL_PMC_IPC
	depends on MFD_INTEL_PMC_BXT
	select MFD_CORE
	select REGMAP_IRQ
	help
@@ -632,6 +632,20 @@ config MFD_INTEL_MSIC
	  Passage) chip. This chip embeds audio, battery, GPIO, etc.
	  devices used in Intel Medfield platforms.

config MFD_INTEL_PMC_BXT
	tristate "Intel PMC Driver for Broxton"
	depends on X86
	depends on X86_PLATFORM_DEVICES
	depends on ACPI
	select INTEL_SCU_IPC
	select MFD_CORE
	help
	  This driver provides support for the PMC (Power Management
	  Controller) on Intel Broxton and Apollo Lake. The PMC is a
	  multi-function device that exposes IPC, General Control
	  Register and P-unit access. In addition this creates devices
	  for iTCO watchdog and telemetry that are part of the PMC.

config MFD_IPAQ_MICRO
	bool "Atmel Micro ASIC (iPAQ h3100/h3600/h3700) Support"
	depends on SA1100_H3100 || SA1100_H3600
+1 −0
Original line number Diff line number Diff line
@@ -212,6 +212,7 @@ obj-$(CONFIG_MFD_INTEL_LPSS) += intel-lpss.o
obj-$(CONFIG_MFD_INTEL_LPSS_PCI)	+= intel-lpss-pci.o
obj-$(CONFIG_MFD_INTEL_LPSS_ACPI)	+= intel-lpss-acpi.o
obj-$(CONFIG_MFD_INTEL_MSIC)	+= intel_msic.o
obj-$(CONFIG_MFD_INTEL_PMC_BXT)	+= intel_pmc_bxt.o
obj-$(CONFIG_MFD_PALMAS)	+= palmas.o
obj-$(CONFIG_MFD_VIPERBOARD)    += viperboard.o
obj-$(CONFIG_MFD_RC5T583)	+= rc5t583.o rc5t583-irq.o
Loading