aboutsummaryrefslogtreecommitdiffstats
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.c83
1 files changed, 48 insertions, 35 deletions
diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c
index d734763dab69..105cfffe82c6 100644
--- a/drivers/platform/x86/intel_pmc_ipc.c
+++ b/drivers/platform/x86/intel_pmc_ipc.c
@@ -96,18 +96,18 @@ static struct intel_pmc_ipc_dev {
96 struct completion cmd_complete; 96 struct completion cmd_complete;
97 97
98 /* The following PMC BARs share the same ACPI device with the IPC */ 98 /* The following PMC BARs share the same ACPI device with the IPC */
99 void *acpi_io_base; 99 resource_size_t acpi_io_base;
100 int acpi_io_size; 100 int acpi_io_size;
101 struct platform_device *tco_dev; 101 struct platform_device *tco_dev;
102 102
103 /* gcr */ 103 /* gcr */
104 void *gcr_base; 104 resource_size_t gcr_base;
105 int gcr_size; 105 int gcr_size;
106 106
107 /* punit */ 107 /* punit */
108 void *punit_base; 108 resource_size_t punit_base;
109 int punit_size; 109 int punit_size;
110 void *punit_base2; 110 resource_size_t punit_base2;
111 int punit_size2; 111 int punit_size2;
112 struct platform_device *punit_dev; 112 struct platform_device *punit_dev;
113} ipcdev; 113} ipcdev;
@@ -210,10 +210,15 @@ static int intel_pmc_ipc_check_status(void)
210 return ret; 210 return ret;
211} 211}
212 212
213/* 213/**
214 * intel_pmc_ipc_simple_command 214 * intel_pmc_ipc_simple_command() - Simple IPC command
215 * @cmd: command 215 * @cmd: IPC command code.
216 * @sub: sub type 216 * @sub: IPC command sub type.
217 *
218 * Send a simple IPC command to PMC when don't need to specify
219 * input/output data and source/dest pointers.
220 *
221 * Return: an IPC error code or 0 on success.
217 */ 222 */
218int intel_pmc_ipc_simple_command(int cmd, int sub) 223int intel_pmc_ipc_simple_command(int cmd, int sub)
219{ 224{
@@ -232,16 +237,20 @@ int intel_pmc_ipc_simple_command(int cmd, int sub)
232} 237}
233EXPORT_SYMBOL_GPL(intel_pmc_ipc_simple_command); 238EXPORT_SYMBOL_GPL(intel_pmc_ipc_simple_command);
234 239
235/* 240/**
236 * intel_pmc_ipc_raw_cmd 241 * intel_pmc_ipc_raw_cmd() - IPC command with data and pointers
237 * @cmd: command 242 * @cmd: IPC command code.
238 * @sub: sub type 243 * @sub: IPC command sub type.
239 * @in: input data 244 * @in: input data of this IPC command.
240 * @inlen: input length in bytes 245 * @inlen: input data length in bytes.
241 * @out: output data 246 * @out: output data of this IPC command.
242 * @outlen: output length in dwords 247 * @outlen: output data length in dwords.
243 * @sptr: data writing to SPTR register 248 * @sptr: data writing to SPTR register.
244 * @dptr: data writing to DPTR register 249 * @dptr: data writing to DPTR register.
250 *
251 * Send an IPC command to PMC with input/output data and source/dest pointers.
252 *
253 * Return: an IPC error code or 0 on success.
245 */ 254 */
246int intel_pmc_ipc_raw_cmd(u32 cmd, u32 sub, u8 *in, u32 inlen, u32 *out, 255int intel_pmc_ipc_raw_cmd(u32 cmd, u32 sub, u8 *in, u32 inlen, u32 *out,
247 u32 outlen, u32 dptr, u32 sptr) 256 u32 outlen, u32 dptr, u32 sptr)
@@ -278,14 +287,18 @@ int intel_pmc_ipc_raw_cmd(u32 cmd, u32 sub, u8 *in, u32 inlen, u32 *out,
278} 287}
279EXPORT_SYMBOL_GPL(intel_pmc_ipc_raw_cmd); 288EXPORT_SYMBOL_GPL(intel_pmc_ipc_raw_cmd);
280 289
281/* 290/**
282 * intel_pmc_ipc_command 291 * intel_pmc_ipc_command() - IPC command with input/output data
283 * @cmd: command 292 * @cmd: IPC command code.
284 * @sub: sub type 293 * @sub: IPC command sub type.
285 * @in: input data 294 * @in: input data of this IPC command.
286 * @inlen: input length in bytes 295 * @inlen: input data length in bytes.
287 * @out: output data 296 * @out: output data of this IPC command.
288 * @outlen: output length in dwords 297 * @outlen: output data length in dwords.
298 *
299 * Send an IPC command to PMC with input/output data.
300 *
301 * Return: an IPC error code or 0 on success.
289 */ 302 */
290int intel_pmc_ipc_command(u32 cmd, u32 sub, u8 *in, u32 inlen, 303int intel_pmc_ipc_command(u32 cmd, u32 sub, u8 *in, u32 inlen,
291 u32 *out, u32 outlen) 304 u32 *out, u32 outlen)
@@ -480,11 +493,11 @@ static int ipc_create_punit_device(void)
480 pdev->dev.parent = ipcdev.dev; 493 pdev->dev.parent = ipcdev.dev;
481 494
482 res = punit_res; 495 res = punit_res;
483 res->start = (resource_size_t)ipcdev.punit_base; 496 res->start = ipcdev.punit_base;
484 res->end = res->start + ipcdev.punit_size - 1; 497 res->end = res->start + ipcdev.punit_size - 1;
485 498
486 res = punit_res + PUNIT_RESOURCE_INTER; 499 res = punit_res + PUNIT_RESOURCE_INTER;
487 res->start = (resource_size_t)ipcdev.punit_base2; 500 res->start = ipcdev.punit_base2;
488 res->end = res->start + ipcdev.punit_size2 - 1; 501 res->end = res->start + ipcdev.punit_size2 - 1;
489 502
490 ret = platform_device_add_resources(pdev, punit_res, 503 ret = platform_device_add_resources(pdev, punit_res,
@@ -522,15 +535,15 @@ static int ipc_create_tco_device(void)
522 pdev->dev.parent = ipcdev.dev; 535 pdev->dev.parent = ipcdev.dev;
523 536
524 res = tco_res + TCO_RESOURCE_ACPI_IO; 537 res = tco_res + TCO_RESOURCE_ACPI_IO;
525 res->start = (resource_size_t)ipcdev.acpi_io_base + TCO_BASE_OFFSET; 538 res->start = ipcdev.acpi_io_base + TCO_BASE_OFFSET;
526 res->end = res->start + TCO_REGS_SIZE - 1; 539 res->end = res->start + TCO_REGS_SIZE - 1;
527 540
528 res = tco_res + TCO_RESOURCE_SMI_EN_IO; 541 res = tco_res + TCO_RESOURCE_SMI_EN_IO;
529 res->start = (resource_size_t)ipcdev.acpi_io_base + SMI_EN_OFFSET; 542 res->start = ipcdev.acpi_io_base + SMI_EN_OFFSET;
530 res->end = res->start + SMI_EN_SIZE - 1; 543 res->end = res->start + SMI_EN_SIZE - 1;
531 544
532 res = tco_res + TCO_RESOURCE_GCR_MEM; 545 res = tco_res + TCO_RESOURCE_GCR_MEM;
533 res->start = (resource_size_t)ipcdev.gcr_base; 546 res->start = ipcdev.gcr_base;
534 res->end = res->start + ipcdev.gcr_size - 1; 547 res->end = res->start + ipcdev.gcr_size - 1;
535 548
536 ret = platform_device_add_resources(pdev, tco_res, ARRAY_SIZE(tco_res)); 549 ret = platform_device_add_resources(pdev, tco_res, ARRAY_SIZE(tco_res));
@@ -589,7 +602,7 @@ static int ipc_plat_get_res(struct platform_device *pdev)
589 return -ENXIO; 602 return -ENXIO;
590 } 603 }
591 size = resource_size(res); 604 size = resource_size(res);
592 ipcdev.acpi_io_base = (void *)res->start; 605 ipcdev.acpi_io_base = res->start;
593 ipcdev.acpi_io_size = size; 606 ipcdev.acpi_io_size = size;
594 dev_info(&pdev->dev, "io res: %llx %x\n", 607 dev_info(&pdev->dev, "io res: %llx %x\n",
595 (long long)res->start, (int)resource_size(res)); 608 (long long)res->start, (int)resource_size(res));
@@ -601,7 +614,7 @@ static int ipc_plat_get_res(struct platform_device *pdev)
601 return -ENXIO; 614 return -ENXIO;
602 } 615 }
603 size = resource_size(res); 616 size = resource_size(res);
604 ipcdev.punit_base = (void *)res->start; 617 ipcdev.punit_base = res->start;
605 ipcdev.punit_size = size; 618 ipcdev.punit_size = size;
606 dev_info(&pdev->dev, "punit data res: %llx %x\n", 619 dev_info(&pdev->dev, "punit data res: %llx %x\n",
607 (long long)res->start, (int)resource_size(res)); 620 (long long)res->start, (int)resource_size(res));
@@ -613,7 +626,7 @@ static int ipc_plat_get_res(struct platform_device *pdev)
613 return -ENXIO; 626 return -ENXIO;
614 } 627 }
615 size = resource_size(res); 628 size = resource_size(res);
616 ipcdev.punit_base2 = (void *)res->start; 629 ipcdev.punit_base2 = res->start;
617 ipcdev.punit_size2 = size; 630 ipcdev.punit_size2 = size;
618 dev_info(&pdev->dev, "punit interface res: %llx %x\n", 631 dev_info(&pdev->dev, "punit interface res: %llx %x\n",
619 (long long)res->start, (int)resource_size(res)); 632 (long long)res->start, (int)resource_size(res));
@@ -637,7 +650,7 @@ static int ipc_plat_get_res(struct platform_device *pdev)
637 } 650 }
638 ipcdev.ipc_base = addr; 651 ipcdev.ipc_base = addr;
639 652
640 ipcdev.gcr_base = (void *)(res->start + size); 653 ipcdev.gcr_base = res->start + size;
641 ipcdev.gcr_size = PLAT_RESOURCE_GCR_SIZE; 654 ipcdev.gcr_size = PLAT_RESOURCE_GCR_SIZE;
642 dev_info(&pdev->dev, "ipc res: %llx %x\n", 655 dev_info(&pdev->dev, "ipc res: %llx %x\n",
643 (long long)res->start, (int)resource_size(res)); 656 (long long)res->start, (int)resource_size(res));