2 * intel_pmc_ipc.c: Driver for the Intel PMC IPC mechanism
4 * (C) Copyright 2014-2015 Intel Corporation
6 * This driver is based on Intel SCU IPC driver(intel_scu_opc.c) by
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; version 2
14 * PMC running in ARC processor communicates with other entity running in IA
15 * core through IPC mechanism which in turn messaging between IA core ad PMC.
18 #include <linux/module.h>
19 #include <linux/delay.h>
20 #include <linux/errno.h>
21 #include <linux/init.h>
22 #include <linux/device.h>
24 #include <linux/pci.h>
25 #include <linux/platform_device.h>
26 #include <linux/interrupt.h>
27 #include <linux/pm_qos.h>
28 #include <linux/kernel.h>
29 #include <linux/bitops.h>
30 #include <linux/sched.h>
31 #include <linux/atomic.h>
32 #include <linux/notifier.h>
33 #include <linux/suspend.h>
34 #include <linux/acpi.h>
35 #include <asm/intel_pmc_ipc.h>
36 #include <linux/platform_data/itco_wdt.h>
40 * The IA write to IPC_CMD command register triggers an interrupt to the ARC,
41 * The ARC handles the interrupt and services it, writing optional data to
42 * the IPC1 registers, updates the IPC_STS response register with the status.
45 #define IPC_CMD_MSI 0x100
46 #define IPC_CMD_SIZE 16
47 #define IPC_CMD_SUBCMD 12
48 #define IPC_STATUS 0x04
49 #define IPC_STATUS_IRQ 0x4
50 #define IPC_STATUS_ERR 0x2
51 #define IPC_STATUS_BUSY 0x1
54 #define IPC_WRITE_BUFFER 0x80
55 #define IPC_READ_BUFFER 0x90
58 * 16-byte buffer for sending data associated with IPC command.
60 #define IPC_DATA_BUFFER_SIZE 16
62 #define IPC_LOOP_CNT 3000000
65 #define IPC_TRIGGER_MODE_IRQ true
67 /* exported resources from IFWI */
68 #define PLAT_RESOURCE_IPC_INDEX 0
69 #define PLAT_RESOURCE_IPC_SIZE 0x1000
70 #define PLAT_RESOURCE_GCR_OFFSET 0x1008
71 #define PLAT_RESOURCE_GCR_SIZE 0x4
72 #define PLAT_RESOURCE_BIOS_DATA_INDEX 1
73 #define PLAT_RESOURCE_BIOS_IFACE_INDEX 2
74 #define PLAT_RESOURCE_TELEM_SSRAM_INDEX 3
75 #define PLAT_RESOURCE_ISP_DATA_INDEX 4
76 #define PLAT_RESOURCE_ISP_IFACE_INDEX 5
77 #define PLAT_RESOURCE_GTD_DATA_INDEX 6
78 #define PLAT_RESOURCE_GTD_IFACE_INDEX 7
79 #define PLAT_RESOURCE_ACPI_IO_INDEX 0
82 * BIOS does not create an ACPI device for each PMC function,
83 * but exports multiple resources from one ACPI device(IPC) for
84 * multiple functions. This driver is responsible to create a
85 * platform device and to export resources for those functions.
87 #define TCO_DEVICE_NAME "iTCO_wdt"
88 #define SMI_EN_OFFSET 0x30
90 #define TCO_BASE_OFFSET 0x60
91 #define TCO_REGS_SIZE 16
92 #define PUNIT_DEVICE_NAME "intel_punit_ipc"
93 #define TELEMETRY_DEVICE_NAME "intel_telemetry"
94 #define TELEM_SSRAM_SIZE 240
95 #define TELEM_PMC_SSRAM_OFFSET 0x1B00
96 #define TELEM_PUNIT_SSRAM_OFFSET 0x1A00
98 static const int iTCO_version = 3;
100 static struct intel_pmc_ipc_dev {
102 void __iomem *ipc_base;
106 struct completion cmd_complete;
108 /* The following PMC BARs share the same ACPI device with the IPC */
109 resource_size_t acpi_io_base;
111 struct platform_device *tco_dev;
114 resource_size_t gcr_base;
118 struct platform_device *punit_dev;
121 resource_size_t telem_pmc_ssram_base;
122 resource_size_t telem_punit_ssram_base;
123 int telem_pmc_ssram_size;
124 int telem_punit_ssram_size;
126 struct platform_device *telemetry_dev;
129 static char *ipc_err_sources[] = {
132 [IPC_ERR_CMD_NOT_SUPPORTED] =
133 "command not supported",
134 [IPC_ERR_CMD_NOT_SERVICED] =
135 "command not serviced",
136 [IPC_ERR_UNABLE_TO_SERVICE] =
138 [IPC_ERR_CMD_INVALID] =
140 [IPC_ERR_CMD_FAILED] =
142 [IPC_ERR_EMSECURITY] =
144 [IPC_ERR_UNSIGNEDKERNEL] =
148 /* Prevent concurrent calls to the PMC */
149 static DEFINE_MUTEX(ipclock);
151 static inline void ipc_send_command(u32 cmd)
154 if (ipcdev.irq_mode) {
155 reinit_completion(&ipcdev.cmd_complete);
158 writel(cmd, ipcdev.ipc_base + IPC_CMD);
161 static inline u32 ipc_read_status(void)
163 return readl(ipcdev.ipc_base + IPC_STATUS);
166 static inline void ipc_data_writel(u32 data, u32 offset)
168 writel(data, ipcdev.ipc_base + IPC_WRITE_BUFFER + offset);
171 static inline u8 ipc_data_readb(u32 offset)
173 return readb(ipcdev.ipc_base + IPC_READ_BUFFER + offset);
176 static inline u32 ipc_data_readl(u32 offset)
178 return readl(ipcdev.ipc_base + IPC_READ_BUFFER + offset);
181 static int intel_pmc_ipc_check_status(void)
186 if (ipcdev.irq_mode) {
187 if (0 == wait_for_completion_timeout(
188 &ipcdev.cmd_complete, IPC_MAX_SEC * HZ))
191 int loop_count = IPC_LOOP_CNT;
193 while ((ipc_read_status() & IPC_STATUS_BUSY) && --loop_count)
199 status = ipc_read_status();
200 if (ret == -ETIMEDOUT) {
202 "IPC timed out, TS=0x%x, CMD=0x%x\n",
207 if (status & IPC_STATUS_ERR) {
211 i = (status >> IPC_CMD_SIZE) & 0xFF;
212 if (i < ARRAY_SIZE(ipc_err_sources))
214 "IPC failed: %s, STS=0x%x, CMD=0x%x\n",
215 ipc_err_sources[i], status, ipcdev.cmd);
218 "IPC failed: unknown, STS=0x%x, CMD=0x%x\n",
220 if ((i == IPC_ERR_UNSIGNEDKERNEL) || (i == IPC_ERR_EMSECURITY))
228 * intel_pmc_ipc_simple_command() - Simple IPC command
229 * @cmd: IPC command code.
230 * @sub: IPC command sub type.
232 * Send a simple IPC command to PMC when don't need to specify
233 * input/output data and source/dest pointers.
235 * Return: an IPC error code or 0 on success.
237 int intel_pmc_ipc_simple_command(int cmd, int sub)
241 mutex_lock(&ipclock);
242 if (ipcdev.dev == NULL) {
243 mutex_unlock(&ipclock);
246 ipc_send_command(sub << IPC_CMD_SUBCMD | cmd);
247 ret = intel_pmc_ipc_check_status();
248 mutex_unlock(&ipclock);
252 EXPORT_SYMBOL_GPL(intel_pmc_ipc_simple_command);
255 * intel_pmc_ipc_raw_cmd() - IPC command with data and pointers
256 * @cmd: IPC command code.
257 * @sub: IPC command sub type.
258 * @in: input data of this IPC command.
259 * @inlen: input data length in bytes.
260 * @out: output data of this IPC command.
261 * @outlen: output data length in dwords.
262 * @sptr: data writing to SPTR register.
263 * @dptr: data writing to DPTR register.
265 * Send an IPC command to PMC with input/output data and source/dest pointers.
267 * Return: an IPC error code or 0 on success.
269 int intel_pmc_ipc_raw_cmd(u32 cmd, u32 sub, u8 *in, u32 inlen, u32 *out,
270 u32 outlen, u32 dptr, u32 sptr)
276 if (inlen > IPC_DATA_BUFFER_SIZE || outlen > IPC_DATA_BUFFER_SIZE / 4)
279 mutex_lock(&ipclock);
280 if (ipcdev.dev == NULL) {
281 mutex_unlock(&ipclock);
284 memcpy(wbuf, in, inlen);
285 writel(dptr, ipcdev.ipc_base + IPC_DPTR);
286 writel(sptr, ipcdev.ipc_base + IPC_SPTR);
287 /* The input data register is 32bit register and inlen is in Byte */
288 for (i = 0; i < ((inlen + 3) / 4); i++)
289 ipc_data_writel(wbuf[i], 4 * i);
290 ipc_send_command((inlen << IPC_CMD_SIZE) |
291 (sub << IPC_CMD_SUBCMD) | cmd);
292 ret = intel_pmc_ipc_check_status();
294 /* out is read from 32bit register and outlen is in 32bit */
295 for (i = 0; i < outlen; i++)
296 *out++ = ipc_data_readl(4 * i);
298 mutex_unlock(&ipclock);
302 EXPORT_SYMBOL_GPL(intel_pmc_ipc_raw_cmd);
305 * intel_pmc_ipc_command() - IPC command with input/output data
306 * @cmd: IPC command code.
307 * @sub: IPC command sub type.
308 * @in: input data of this IPC command.
309 * @inlen: input data length in bytes.
310 * @out: output data of this IPC command.
311 * @outlen: output data length in dwords.
313 * Send an IPC command to PMC with input/output data.
315 * Return: an IPC error code or 0 on success.
317 int intel_pmc_ipc_command(u32 cmd, u32 sub, u8 *in, u32 inlen,
318 u32 *out, u32 outlen)
320 return intel_pmc_ipc_raw_cmd(cmd, sub, in, inlen, out, outlen, 0, 0);
322 EXPORT_SYMBOL_GPL(intel_pmc_ipc_command);
324 static irqreturn_t ioc(int irq, void *dev_id)
328 if (ipcdev.irq_mode) {
329 status = ipc_read_status();
330 writel(status | IPC_STATUS_IRQ, ipcdev.ipc_base + IPC_STATUS);
332 complete(&ipcdev.cmd_complete);
337 static int ipc_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
339 resource_size_t pci_resource;
343 ipcdev.dev = &pci_dev_get(pdev)->dev;
344 ipcdev.irq_mode = IPC_TRIGGER_MODE_IRQ;
346 ret = pci_enable_device(pdev);
350 ret = pci_request_regions(pdev, "intel_pmc_ipc");
354 pci_resource = pci_resource_start(pdev, 0);
355 len = pci_resource_len(pdev, 0);
356 if (!pci_resource || !len) {
357 dev_err(&pdev->dev, "Failed to get resource\n");
361 init_completion(&ipcdev.cmd_complete);
363 if (request_irq(pdev->irq, ioc, 0, "intel_pmc_ipc", &ipcdev)) {
364 dev_err(&pdev->dev, "Failed to request irq\n");
368 ipcdev.ipc_base = ioremap_nocache(pci_resource, len);
369 if (!ipcdev.ipc_base) {
370 dev_err(&pdev->dev, "Failed to ioremap ipc base\n");
371 free_irq(pdev->irq, &ipcdev);
378 static void ipc_pci_remove(struct pci_dev *pdev)
380 free_irq(pdev->irq, &ipcdev);
381 pci_release_regions(pdev);
383 iounmap(ipcdev.ipc_base);
387 static const struct pci_device_id ipc_pci_ids[] = {
388 {PCI_VDEVICE(INTEL, 0x0a94), 0},
389 {PCI_VDEVICE(INTEL, 0x1a94), 0},
392 MODULE_DEVICE_TABLE(pci, ipc_pci_ids);
394 static struct pci_driver ipc_pci_driver = {
395 .name = "intel_pmc_ipc",
396 .id_table = ipc_pci_ids,
397 .probe = ipc_pci_probe,
398 .remove = ipc_pci_remove,
401 static ssize_t intel_pmc_ipc_simple_cmd_store(struct device *dev,
402 struct device_attribute *attr,
403 const char *buf, size_t count)
409 ret = sscanf(buf, "%d %d", &cmd, &subcmd);
411 dev_err(dev, "Error args\n");
415 ret = intel_pmc_ipc_simple_command(cmd, subcmd);
417 dev_err(dev, "command %d error with %d\n", cmd, ret);
420 return (ssize_t)count;
423 static ssize_t intel_pmc_ipc_northpeak_store(struct device *dev,
424 struct device_attribute *attr,
425 const char *buf, size_t count)
431 if (kstrtoul(buf, 0, &val))
438 ret = intel_pmc_ipc_simple_command(PMC_IPC_NORTHPEAK_CTRL, subcmd);
440 dev_err(dev, "command north %d error with %d\n", subcmd, ret);
443 return (ssize_t)count;
446 static DEVICE_ATTR(simplecmd, S_IWUSR,
447 NULL, intel_pmc_ipc_simple_cmd_store);
448 static DEVICE_ATTR(northpeak, S_IWUSR,
449 NULL, intel_pmc_ipc_northpeak_store);
451 static struct attribute *intel_ipc_attrs[] = {
452 &dev_attr_northpeak.attr,
453 &dev_attr_simplecmd.attr,
457 static const struct attribute_group intel_ipc_group = {
458 .attrs = intel_ipc_attrs,
461 static struct resource punit_res_array[] = {
464 .flags = IORESOURCE_MEM,
467 .flags = IORESOURCE_MEM,
471 .flags = IORESOURCE_MEM,
474 .flags = IORESOURCE_MEM,
478 .flags = IORESOURCE_MEM,
481 .flags = IORESOURCE_MEM,
485 #define TCO_RESOURCE_ACPI_IO 0
486 #define TCO_RESOURCE_SMI_EN_IO 1
487 #define TCO_RESOURCE_GCR_MEM 2
488 static struct resource tco_res[] = {
491 .flags = IORESOURCE_IO,
495 .flags = IORESOURCE_IO,
499 .flags = IORESOURCE_MEM,
503 static struct itco_wdt_platform_data tco_info = {
504 .name = "Apollo Lake SoC",
508 #define TELEMETRY_RESOURCE_PUNIT_SSRAM 0
509 #define TELEMETRY_RESOURCE_PMC_SSRAM 1
510 static struct resource telemetry_res[] = {
513 .flags = IORESOURCE_MEM,
516 .flags = IORESOURCE_MEM,
520 static int ipc_create_punit_device(void)
522 struct platform_device *pdev;
525 pdev = platform_device_alloc(PUNIT_DEVICE_NAME, -1);
527 dev_err(ipcdev.dev, "Failed to alloc punit platform device\n");
531 pdev->dev.parent = ipcdev.dev;
532 ret = platform_device_add_resources(pdev, punit_res_array,
533 ARRAY_SIZE(punit_res_array));
535 dev_err(ipcdev.dev, "Failed to add platform punit resources\n");
539 ret = platform_device_add(pdev);
541 dev_err(ipcdev.dev, "Failed to add punit platform device\n");
544 ipcdev.punit_dev = pdev;
548 platform_device_put(pdev);
552 static int ipc_create_tco_device(void)
554 struct platform_device *pdev;
555 struct resource *res;
558 pdev = platform_device_alloc(TCO_DEVICE_NAME, -1);
560 dev_err(ipcdev.dev, "Failed to alloc tco platform device\n");
564 pdev->dev.parent = ipcdev.dev;
566 res = tco_res + TCO_RESOURCE_ACPI_IO;
567 res->start = ipcdev.acpi_io_base + TCO_BASE_OFFSET;
568 res->end = res->start + TCO_REGS_SIZE - 1;
570 res = tco_res + TCO_RESOURCE_SMI_EN_IO;
571 res->start = ipcdev.acpi_io_base + SMI_EN_OFFSET;
572 res->end = res->start + SMI_EN_SIZE - 1;
574 res = tco_res + TCO_RESOURCE_GCR_MEM;
575 res->start = ipcdev.gcr_base;
576 res->end = res->start + ipcdev.gcr_size - 1;
578 ret = platform_device_add_resources(pdev, tco_res, ARRAY_SIZE(tco_res));
580 dev_err(ipcdev.dev, "Failed to add tco platform resources\n");
584 ret = platform_device_add_data(pdev, &tco_info, sizeof(tco_info));
586 dev_err(ipcdev.dev, "Failed to add tco platform data\n");
590 ret = platform_device_add(pdev);
592 dev_err(ipcdev.dev, "Failed to add tco platform device\n");
595 ipcdev.tco_dev = pdev;
599 platform_device_put(pdev);
603 static int ipc_create_telemetry_device(void)
605 struct platform_device *pdev;
606 struct resource *res;
609 pdev = platform_device_alloc(TELEMETRY_DEVICE_NAME, -1);
612 "Failed to allocate telemetry platform device\n");
616 pdev->dev.parent = ipcdev.dev;
618 res = telemetry_res + TELEMETRY_RESOURCE_PUNIT_SSRAM;
619 res->start = ipcdev.telem_punit_ssram_base;
620 res->end = res->start + ipcdev.telem_punit_ssram_size - 1;
622 res = telemetry_res + TELEMETRY_RESOURCE_PMC_SSRAM;
623 res->start = ipcdev.telem_pmc_ssram_base;
624 res->end = res->start + ipcdev.telem_pmc_ssram_size - 1;
626 ret = platform_device_add_resources(pdev, telemetry_res,
627 ARRAY_SIZE(telemetry_res));
630 "Failed to add telemetry platform resources\n");
634 ret = platform_device_add(pdev);
637 "Failed to add telemetry platform device\n");
640 ipcdev.telemetry_dev = pdev;
644 platform_device_put(pdev);
648 static int ipc_create_pmc_devices(void)
652 ret = ipc_create_tco_device();
654 dev_err(ipcdev.dev, "Failed to add tco platform device\n");
657 ret = ipc_create_punit_device();
659 dev_err(ipcdev.dev, "Failed to add punit platform device\n");
660 platform_device_unregister(ipcdev.tco_dev);
663 if (!ipcdev.telem_res_inval) {
664 ret = ipc_create_telemetry_device();
667 "Failed to add telemetry platform device\n");
673 static int ipc_plat_get_res(struct platform_device *pdev)
675 struct resource *res, *punit_res;
679 res = platform_get_resource(pdev, IORESOURCE_IO,
680 PLAT_RESOURCE_ACPI_IO_INDEX);
682 dev_err(&pdev->dev, "Failed to get io resource\n");
685 size = resource_size(res);
686 ipcdev.acpi_io_base = res->start;
687 ipcdev.acpi_io_size = size;
688 dev_info(&pdev->dev, "io res: %pR\n", res);
690 punit_res = punit_res_array;
691 /* This is index 0 to cover BIOS data register */
692 res = platform_get_resource(pdev, IORESOURCE_MEM,
693 PLAT_RESOURCE_BIOS_DATA_INDEX);
695 dev_err(&pdev->dev, "Failed to get res of punit BIOS data\n");
699 dev_info(&pdev->dev, "punit BIOS data res: %pR\n", res);
701 /* This is index 1 to cover BIOS interface register */
702 res = platform_get_resource(pdev, IORESOURCE_MEM,
703 PLAT_RESOURCE_BIOS_IFACE_INDEX);
705 dev_err(&pdev->dev, "Failed to get res of punit BIOS iface\n");
709 dev_info(&pdev->dev, "punit BIOS interface res: %pR\n", res);
711 /* This is index 2 to cover ISP data register, optional */
712 res = platform_get_resource(pdev, IORESOURCE_MEM,
713 PLAT_RESOURCE_ISP_DATA_INDEX);
717 dev_info(&pdev->dev, "punit ISP data res: %pR\n", res);
720 /* This is index 3 to cover ISP interface register, optional */
721 res = platform_get_resource(pdev, IORESOURCE_MEM,
722 PLAT_RESOURCE_ISP_IFACE_INDEX);
726 dev_info(&pdev->dev, "punit ISP interface res: %pR\n", res);
729 /* This is index 4 to cover GTD data register, optional */
730 res = platform_get_resource(pdev, IORESOURCE_MEM,
731 PLAT_RESOURCE_GTD_DATA_INDEX);
735 dev_info(&pdev->dev, "punit GTD data res: %pR\n", res);
738 /* This is index 5 to cover GTD interface register, optional */
739 res = platform_get_resource(pdev, IORESOURCE_MEM,
740 PLAT_RESOURCE_GTD_IFACE_INDEX);
744 dev_info(&pdev->dev, "punit GTD interface res: %pR\n", res);
747 res = platform_get_resource(pdev, IORESOURCE_MEM,
748 PLAT_RESOURCE_IPC_INDEX);
750 dev_err(&pdev->dev, "Failed to get ipc resource\n");
753 size = PLAT_RESOURCE_IPC_SIZE;
754 if (!request_mem_region(res->start, size, pdev->name)) {
755 dev_err(&pdev->dev, "Failed to request ipc resource\n");
758 addr = ioremap_nocache(res->start, size);
760 dev_err(&pdev->dev, "I/O memory remapping failed\n");
761 release_mem_region(res->start, size);
764 ipcdev.ipc_base = addr;
766 ipcdev.gcr_base = res->start + PLAT_RESOURCE_GCR_OFFSET;
767 ipcdev.gcr_size = PLAT_RESOURCE_GCR_SIZE;
768 dev_info(&pdev->dev, "ipc res: %pR\n", res);
770 ipcdev.telem_res_inval = 0;
771 res = platform_get_resource(pdev, IORESOURCE_MEM,
772 PLAT_RESOURCE_TELEM_SSRAM_INDEX);
774 dev_err(&pdev->dev, "Failed to get telemetry ssram resource\n");
775 ipcdev.telem_res_inval = 1;
777 ipcdev.telem_punit_ssram_base = res->start +
778 TELEM_PUNIT_SSRAM_OFFSET;
779 ipcdev.telem_punit_ssram_size = TELEM_SSRAM_SIZE;
780 ipcdev.telem_pmc_ssram_base = res->start +
781 TELEM_PMC_SSRAM_OFFSET;
782 ipcdev.telem_pmc_ssram_size = TELEM_SSRAM_SIZE;
783 dev_info(&pdev->dev, "telemetry ssram res: %pR\n", res);
790 static const struct acpi_device_id ipc_acpi_ids[] = {
794 MODULE_DEVICE_TABLE(acpi, ipc_acpi_ids);
797 static int ipc_plat_probe(struct platform_device *pdev)
799 struct resource *res;
802 ipcdev.dev = &pdev->dev;
803 ipcdev.irq_mode = IPC_TRIGGER_MODE_IRQ;
804 init_completion(&ipcdev.cmd_complete);
806 ipcdev.irq = platform_get_irq(pdev, 0);
807 if (ipcdev.irq < 0) {
808 dev_err(&pdev->dev, "Failed to get irq\n");
812 ret = ipc_plat_get_res(pdev);
814 dev_err(&pdev->dev, "Failed to request resource\n");
818 ret = ipc_create_pmc_devices();
820 dev_err(&pdev->dev, "Failed to create pmc devices\n");
824 if (request_irq(ipcdev.irq, ioc, IRQF_NO_SUSPEND,
825 "intel_pmc_ipc", &ipcdev)) {
826 dev_err(&pdev->dev, "Failed to request irq\n");
831 ret = sysfs_create_group(&pdev->dev.kobj, &intel_ipc_group);
833 dev_err(&pdev->dev, "Failed to create sysfs group %d\n",
840 free_irq(ipcdev.irq, &ipcdev);
842 platform_device_unregister(ipcdev.tco_dev);
843 platform_device_unregister(ipcdev.punit_dev);
844 platform_device_unregister(ipcdev.telemetry_dev);
846 iounmap(ipcdev.ipc_base);
847 res = platform_get_resource(pdev, IORESOURCE_MEM,
848 PLAT_RESOURCE_IPC_INDEX);
850 release_mem_region(res->start, PLAT_RESOURCE_IPC_SIZE);
854 static int ipc_plat_remove(struct platform_device *pdev)
856 struct resource *res;
858 sysfs_remove_group(&pdev->dev.kobj, &intel_ipc_group);
859 free_irq(ipcdev.irq, &ipcdev);
860 platform_device_unregister(ipcdev.tco_dev);
861 platform_device_unregister(ipcdev.punit_dev);
862 platform_device_unregister(ipcdev.telemetry_dev);
863 iounmap(ipcdev.ipc_base);
864 res = platform_get_resource(pdev, IORESOURCE_MEM,
865 PLAT_RESOURCE_IPC_INDEX);
867 release_mem_region(res->start, PLAT_RESOURCE_IPC_SIZE);
872 static struct platform_driver ipc_plat_driver = {
873 .remove = ipc_plat_remove,
874 .probe = ipc_plat_probe,
876 .name = "pmc-ipc-plat",
877 .acpi_match_table = ACPI_PTR(ipc_acpi_ids),
881 static int __init intel_pmc_ipc_init(void)
885 ret = platform_driver_register(&ipc_plat_driver);
887 pr_err("Failed to register PMC ipc platform driver\n");
890 ret = pci_register_driver(&ipc_pci_driver);
892 pr_err("Failed to register PMC ipc pci driver\n");
893 platform_driver_unregister(&ipc_plat_driver);
899 static void __exit intel_pmc_ipc_exit(void)
901 pci_unregister_driver(&ipc_pci_driver);
902 platform_driver_unregister(&ipc_plat_driver);
906 MODULE_DESCRIPTION("Intel PMC IPC driver");
907 MODULE_LICENSE("GPL");
909 /* Some modules are dependent on this, so init earlier */
910 fs_initcall(intel_pmc_ipc_init);
911 module_exit(intel_pmc_ipc_exit);