summaryrefslogtreecommitdiff
path: root/drivers/platform/x86/intel_pmc_ipc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/platform/x86/intel_pmc_ipc.c')
-rw-r--r--drivers/platform/x86/intel_pmc_ipc.c214
1 files changed, 174 insertions, 40 deletions
diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c
index 28b2a12bb26d..092519e37de6 100644
--- a/drivers/platform/x86/intel_pmc_ipc.c
+++ b/drivers/platform/x86/intel_pmc_ipc.c
@@ -68,8 +68,13 @@
#define PLAT_RESOURCE_IPC_INDEX 0
#define PLAT_RESOURCE_IPC_SIZE 0x1000
#define PLAT_RESOURCE_GCR_SIZE 0x1000
-#define PLAT_RESOURCE_PUNIT_DATA_INDEX 1
-#define PLAT_RESOURCE_PUNIT_INTER_INDEX 2
+#define PLAT_RESOURCE_BIOS_DATA_INDEX 1
+#define PLAT_RESOURCE_BIOS_IFACE_INDEX 2
+#define PLAT_RESOURCE_TELEM_SSRAM_INDEX 3
+#define PLAT_RESOURCE_ISP_DATA_INDEX 4
+#define PLAT_RESOURCE_ISP_IFACE_INDEX 5
+#define PLAT_RESOURCE_GTD_DATA_INDEX 6
+#define PLAT_RESOURCE_GTD_IFACE_INDEX 7
#define PLAT_RESOURCE_ACPI_IO_INDEX 0
/*
@@ -84,6 +89,10 @@
#define TCO_BASE_OFFSET 0x60
#define TCO_REGS_SIZE 16
#define PUNIT_DEVICE_NAME "intel_punit_ipc"
+#define TELEMETRY_DEVICE_NAME "intel_telemetry"
+#define TELEM_SSRAM_SIZE 240
+#define TELEM_PMC_SSRAM_OFFSET 0x1B00
+#define TELEM_PUNIT_SSRAM_OFFSET 0x1A00
static const int iTCO_version = 3;
@@ -105,11 +114,15 @@ static struct intel_pmc_ipc_dev {
int gcr_size;
/* punit */
- resource_size_t punit_base;
- int punit_size;
- resource_size_t punit_base2;
- int punit_size2;
struct platform_device *punit_dev;
+
+ /* Telemetry */
+ resource_size_t telem_pmc_ssram_base;
+ resource_size_t telem_punit_ssram_base;
+ int telem_pmc_ssram_size;
+ int telem_punit_ssram_size;
+ u8 telem_res_inval;
+ struct platform_device *telemetry_dev;
} ipcdev;
static char *ipc_err_sources[] = {
@@ -444,9 +457,22 @@ static const struct attribute_group intel_ipc_group = {
.attrs = intel_ipc_attrs,
};
-#define PUNIT_RESOURCE_INTER 1
-static struct resource punit_res[] = {
- /* Punit */
+static struct resource punit_res_array[] = {
+ /* Punit BIOS */
+ {
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .flags = IORESOURCE_MEM,
+ },
+ /* Punit ISP */
+ {
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .flags = IORESOURCE_MEM,
+ },
+ /* Punit GTD */
{
.flags = IORESOURCE_MEM,
},
@@ -478,10 +504,21 @@ static struct itco_wdt_platform_data tco_info = {
.version = 3,
};
+#define TELEMETRY_RESOURCE_PUNIT_SSRAM 0
+#define TELEMETRY_RESOURCE_PMC_SSRAM 1
+static struct resource telemetry_res[] = {
+ /*Telemetry*/
+ {
+ .flags = IORESOURCE_MEM,
+ },
+ {
+ .flags = IORESOURCE_MEM,
+ },
+};
+
static int ipc_create_punit_device(void)
{
struct platform_device *pdev;
- struct resource *res;
int ret;
pdev = platform_device_alloc(PUNIT_DEVICE_NAME, -1);
@@ -491,17 +528,8 @@ static int ipc_create_punit_device(void)
}
pdev->dev.parent = ipcdev.dev;
-
- res = punit_res;
- res->start = ipcdev.punit_base;
- res->end = res->start + ipcdev.punit_size - 1;
-
- res = punit_res + PUNIT_RESOURCE_INTER;
- res->start = ipcdev.punit_base2;
- res->end = res->start + ipcdev.punit_size2 - 1;
-
- ret = platform_device_add_resources(pdev, punit_res,
- ARRAY_SIZE(punit_res));
+ ret = platform_device_add_resources(pdev, punit_res_array,
+ ARRAY_SIZE(punit_res_array));
if (ret) {
dev_err(ipcdev.dev, "Failed to add platform punit resources\n");
goto err;
@@ -571,6 +599,51 @@ err:
return ret;
}
+static int ipc_create_telemetry_device(void)
+{
+ struct platform_device *pdev;
+ struct resource *res;
+ int ret;
+
+ pdev = platform_device_alloc(TELEMETRY_DEVICE_NAME, -1);
+ if (!pdev) {
+ dev_err(ipcdev.dev,
+ "Failed to allocate telemetry platform device\n");
+ return -ENOMEM;
+ }
+
+ pdev->dev.parent = ipcdev.dev;
+
+ res = telemetry_res + TELEMETRY_RESOURCE_PUNIT_SSRAM;
+ res->start = ipcdev.telem_punit_ssram_base;
+ res->end = res->start + ipcdev.telem_punit_ssram_size - 1;
+
+ res = telemetry_res + TELEMETRY_RESOURCE_PMC_SSRAM;
+ res->start = ipcdev.telem_pmc_ssram_base;
+ res->end = res->start + ipcdev.telem_pmc_ssram_size - 1;
+
+ ret = platform_device_add_resources(pdev, telemetry_res,
+ ARRAY_SIZE(telemetry_res));
+ if (ret) {
+ dev_err(ipcdev.dev,
+ "Failed to add telemetry platform resources\n");
+ goto err;
+ }
+
+ ret = platform_device_add(pdev);
+ if (ret) {
+ dev_err(ipcdev.dev,
+ "Failed to add telemetry platform device\n");
+ goto err;
+ }
+ ipcdev.telemetry_dev = pdev;
+
+ return 0;
+err:
+ platform_device_put(pdev);
+ return ret;
+}
+
static int ipc_create_pmc_devices(void)
{
int ret;
@@ -585,12 +658,20 @@ static int ipc_create_pmc_devices(void)
dev_err(ipcdev.dev, "Failed to add punit platform device\n");
platform_device_unregister(ipcdev.tco_dev);
}
+
+ if (!ipcdev.telem_res_inval) {
+ ret = ipc_create_telemetry_device();
+ if (ret)
+ dev_warn(ipcdev.dev,
+ "Failed to add telemetry platform device\n");
+ }
+
return ret;
}
static int ipc_plat_get_res(struct platform_device *pdev)
{
- struct resource *res;
+ struct resource *res, *punit_res;
void __iomem *addr;
int size;
@@ -603,32 +684,68 @@ static int ipc_plat_get_res(struct platform_device *pdev)
size = resource_size(res);
ipcdev.acpi_io_base = res->start;
ipcdev.acpi_io_size = size;
- dev_info(&pdev->dev, "io res: %llx %x\n",
- (long long)res->start, (int)resource_size(res));
+ dev_info(&pdev->dev, "io res: %pR\n", res);
+ /* This is index 0 to cover BIOS data register */
+ punit_res = punit_res_array;
res = platform_get_resource(pdev, IORESOURCE_MEM,
- PLAT_RESOURCE_PUNIT_DATA_INDEX);
+ PLAT_RESOURCE_BIOS_DATA_INDEX);
if (!res) {
- dev_err(&pdev->dev, "Failed to get punit resource\n");
+ dev_err(&pdev->dev, "Failed to get res of punit BIOS data\n");
return -ENXIO;
}
- size = resource_size(res);
- ipcdev.punit_base = res->start;
- ipcdev.punit_size = size;
- dev_info(&pdev->dev, "punit data res: %llx %x\n",
- (long long)res->start, (int)resource_size(res));
+ *punit_res = *res;
+ dev_info(&pdev->dev, "punit BIOS data res: %pR\n", res);
res = platform_get_resource(pdev, IORESOURCE_MEM,
- PLAT_RESOURCE_PUNIT_INTER_INDEX);
+ PLAT_RESOURCE_BIOS_IFACE_INDEX);
if (!res) {
- dev_err(&pdev->dev, "Failed to get punit inter resource\n");
+ dev_err(&pdev->dev, "Failed to get res of punit BIOS iface\n");
return -ENXIO;
}
- size = resource_size(res);
- ipcdev.punit_base2 = res->start;
- ipcdev.punit_size2 = size;
- dev_info(&pdev->dev, "punit interface res: %llx %x\n",
- (long long)res->start, (int)resource_size(res));
+ /* This is index 1 to cover BIOS interface register */
+ *++punit_res = *res;
+ dev_info(&pdev->dev, "punit BIOS interface res: %pR\n", res);
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM,
+ PLAT_RESOURCE_ISP_DATA_INDEX);
+ if (!res) {
+ dev_err(&pdev->dev, "Failed to get res of punit ISP data\n");
+ return -ENXIO;
+ }
+ /* This is index 2 to cover ISP data register */
+ *++punit_res = *res;
+ dev_info(&pdev->dev, "punit ISP data res: %pR\n", res);
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM,
+ PLAT_RESOURCE_ISP_IFACE_INDEX);
+ if (!res) {
+ dev_err(&pdev->dev, "Failed to get res of punit ISP iface\n");
+ return -ENXIO;
+ }
+ /* This is index 3 to cover ISP interface register */
+ *++punit_res = *res;
+ dev_info(&pdev->dev, "punit ISP interface res: %pR\n", res);
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM,
+ PLAT_RESOURCE_GTD_DATA_INDEX);
+ if (!res) {
+ dev_err(&pdev->dev, "Failed to get res of punit GTD data\n");
+ return -ENXIO;
+ }
+ /* This is index 4 to cover GTD data register */
+ *++punit_res = *res;
+ dev_info(&pdev->dev, "punit GTD data res: %pR\n", res);
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM,
+ PLAT_RESOURCE_GTD_IFACE_INDEX);
+ if (!res) {
+ dev_err(&pdev->dev, "Failed to get res of punit GTD iface\n");
+ return -ENXIO;
+ }
+ /* This is index 5 to cover GTD interface register */
+ *++punit_res = *res;
+ dev_info(&pdev->dev, "punit GTD interface res: %pR\n", res);
res = platform_get_resource(pdev, IORESOURCE_MEM,
PLAT_RESOURCE_IPC_INDEX);
@@ -651,8 +768,23 @@ static int ipc_plat_get_res(struct platform_device *pdev)
ipcdev.gcr_base = res->start + size;
ipcdev.gcr_size = PLAT_RESOURCE_GCR_SIZE;
- dev_info(&pdev->dev, "ipc res: %llx %x\n",
- (long long)res->start, (int)resource_size(res));
+ dev_info(&pdev->dev, "ipc res: %pR\n", res);
+
+ ipcdev.telem_res_inval = 0;
+ res = platform_get_resource(pdev, IORESOURCE_MEM,
+ PLAT_RESOURCE_TELEM_SSRAM_INDEX);
+ if (!res) {
+ dev_err(&pdev->dev, "Failed to get telemetry ssram resource\n");
+ ipcdev.telem_res_inval = 1;
+ } else {
+ ipcdev.telem_punit_ssram_base = res->start +
+ TELEM_PUNIT_SSRAM_OFFSET;
+ ipcdev.telem_punit_ssram_size = TELEM_SSRAM_SIZE;
+ ipcdev.telem_pmc_ssram_base = res->start +
+ TELEM_PMC_SSRAM_OFFSET;
+ ipcdev.telem_pmc_ssram_size = TELEM_SSRAM_SIZE;
+ dev_info(&pdev->dev, "telemetry ssram res: %pR\n", res);
+ }
return 0;
}
@@ -711,6 +843,7 @@ err_sys:
err_irq:
platform_device_unregister(ipcdev.tco_dev);
platform_device_unregister(ipcdev.punit_dev);
+ platform_device_unregister(ipcdev.telemetry_dev);
err_device:
iounmap(ipcdev.ipc_base);
res = platform_get_resource(pdev, IORESOURCE_MEM,
@@ -728,6 +861,7 @@ static int ipc_plat_remove(struct platform_device *pdev)
free_irq(ipcdev.irq, &ipcdev);
platform_device_unregister(ipcdev.tco_dev);
platform_device_unregister(ipcdev.punit_dev);
+ platform_device_unregister(ipcdev.telemetry_dev);
iounmap(ipcdev.ipc_base);
res = platform_get_resource(pdev, IORESOURCE_MEM,
PLAT_RESOURCE_IPC_INDEX);