Browse Source

platform/x86: intel_pmc_ipc: Fix iTCO_wdt GCS memory mapping failure

iTCO_wdt driver need access to PMC_CFG GCR register to modify the
noreboot setting. Currently, this is done by passing PMC_CFG reg
address as memory resource to watchdog driver and allowing it directly
modify the PMC_CFG register. But currently PMC driver also has
requirement to memory map the entire GCR register space in this driver.
This causes mem request failure in watchdog driver. So this patch fixes
this issue by adding API to update noreboot flag and passes them
to watchdog driver via platform data.

Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Kuppuswamy Sathyanarayanan 8 năm trước cách đây
mục cha
commit
9d855d468d
1 tập tin đã thay đổi với 17 bổ sung12 xóa
  1. 17 12
      drivers/platform/x86/intel_pmc_ipc.c

+ 17 - 12
drivers/platform/x86/intel_pmc_ipc.c

@@ -112,6 +112,13 @@
 #define TCO_PMC_OFFSET			0x8
 #define TCO_PMC_OFFSET			0x8
 #define TCO_PMC_SIZE			0x4
 #define TCO_PMC_SIZE			0x4
 
 
+/* PMC register bit definitions */
+
+/* PMC_CFG_REG bit masks */
+#define PMC_CFG_NO_REBOOT_MASK		(1 << 4)
+#define PMC_CFG_NO_REBOOT_EN		(1 << 4)
+#define PMC_CFG_NO_REBOOT_DIS		(0 << 4)
+
 static struct intel_pmc_ipc_dev {
 static struct intel_pmc_ipc_dev {
 	struct device *dev;
 	struct device *dev;
 	void __iomem *ipc_base;
 	void __iomem *ipc_base;
@@ -126,8 +133,6 @@ static struct intel_pmc_ipc_dev {
 	struct platform_device *tco_dev;
 	struct platform_device *tco_dev;
 
 
 	/* gcr */
 	/* gcr */
-	resource_size_t gcr_base;
-	int gcr_size;
 	void __iomem *gcr_mem_base;
 	void __iomem *gcr_mem_base;
 	bool has_gcr_regs;
 	bool has_gcr_regs;
 
 
@@ -313,6 +318,14 @@ gcr_ipc_unlock:
 }
 }
 EXPORT_SYMBOL_GPL(intel_pmc_gcr_update);
 EXPORT_SYMBOL_GPL(intel_pmc_gcr_update);
 
 
+static int update_no_reboot_bit(void *priv, bool set)
+{
+	u32 value = set ? PMC_CFG_NO_REBOOT_EN : PMC_CFG_NO_REBOOT_DIS;
+
+	return intel_pmc_gcr_update(PMC_GCR_PMC_CFG_REG,
+				    PMC_CFG_NO_REBOOT_MASK, value);
+}
+
 static int intel_pmc_ipc_check_status(void)
 static int intel_pmc_ipc_check_status(void)
 {
 {
 	int status;
 	int status;
@@ -630,15 +643,13 @@ static struct resource tco_res[] = {
 	{
 	{
 		.flags = IORESOURCE_IO,
 		.flags = IORESOURCE_IO,
 	},
 	},
-	/* GCS */
-	{
-		.flags = IORESOURCE_MEM,
-	},
 };
 };
 
 
 static struct itco_wdt_platform_data tco_info = {
 static struct itco_wdt_platform_data tco_info = {
 	.name = "Apollo Lake SoC",
 	.name = "Apollo Lake SoC",
 	.version = 5,
 	.version = 5,
+	.no_reboot_priv = &ipcdev,
+	.update_no_reboot_bit = update_no_reboot_bit,
 };
 };
 
 
 #define TELEMETRY_RESOURCE_PUNIT_SSRAM	0
 #define TELEMETRY_RESOURCE_PUNIT_SSRAM	0
@@ -695,10 +706,6 @@ static int ipc_create_tco_device(void)
 	res->start = ipcdev.acpi_io_base + SMI_EN_OFFSET;
 	res->start = ipcdev.acpi_io_base + SMI_EN_OFFSET;
 	res->end = res->start + SMI_EN_SIZE - 1;
 	res->end = res->start + SMI_EN_SIZE - 1;
 
 
-	res = tco_res + TCO_RESOURCE_GCR_MEM;
-	res->start = ipcdev.gcr_base + TCO_PMC_OFFSET;
-	res->end = res->start + TCO_PMC_SIZE - 1;
-
 	pdev = platform_device_register_full(&pdevinfo);
 	pdev = platform_device_register_full(&pdevinfo);
 	if (IS_ERR(pdev))
 	if (IS_ERR(pdev))
 		return PTR_ERR(pdev);
 		return PTR_ERR(pdev);
@@ -860,9 +867,7 @@ static int ipc_plat_get_res(struct platform_device *pdev)
 	}
 	}
 	ipcdev.ipc_base = addr;
 	ipcdev.ipc_base = addr;
 
 
-	ipcdev.gcr_base = res->start + PLAT_RESOURCE_GCR_OFFSET;
 	ipcdev.gcr_mem_base = addr + PLAT_RESOURCE_GCR_OFFSET;
 	ipcdev.gcr_mem_base = addr + PLAT_RESOURCE_GCR_OFFSET;
-	ipcdev.gcr_size = PLAT_RESOURCE_GCR_SIZE;
 	dev_info(&pdev->dev, "ipc res: %pR\n", res);
 	dev_info(&pdev->dev, "ipc res: %pR\n", res);
 
 
 	ipcdev.telem_res_inval = 0;
 	ipcdev.telem_res_inval = 0;