irqchip/s3c24xx: Mark init_eint as __maybe_unused
[linux/fpc-iii.git] / drivers / platform / x86 / intel_pmc_ipc.c
blob28b2a12bb26d86c797912e518c261547f20597bf
1 /*
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
7 * Sreedhara DS <sreedhara.ds@intel.com>
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
12 * of the License.
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>
23 #include <linux/pm.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>
39 * IPC registers
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.
44 #define IPC_CMD 0x0
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
52 #define IPC_SPTR 0x08
53 #define IPC_DPTR 0x0C
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
63 #define IPC_MAX_SEC 3
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_SIZE 0x1000
71 #define PLAT_RESOURCE_PUNIT_DATA_INDEX 1
72 #define PLAT_RESOURCE_PUNIT_INTER_INDEX 2
73 #define PLAT_RESOURCE_ACPI_IO_INDEX 0
76 * BIOS does not create an ACPI device for each PMC function,
77 * but exports multiple resources from one ACPI device(IPC) for
78 * multiple functions. This driver is responsible to create a
79 * platform device and to export resources for those functions.
81 #define TCO_DEVICE_NAME "iTCO_wdt"
82 #define SMI_EN_OFFSET 0x30
83 #define SMI_EN_SIZE 4
84 #define TCO_BASE_OFFSET 0x60
85 #define TCO_REGS_SIZE 16
86 #define PUNIT_DEVICE_NAME "intel_punit_ipc"
88 static const int iTCO_version = 3;
90 static struct intel_pmc_ipc_dev {
91 struct device *dev;
92 void __iomem *ipc_base;
93 bool irq_mode;
94 int irq;
95 int cmd;
96 struct completion cmd_complete;
98 /* The following PMC BARs share the same ACPI device with the IPC */
99 resource_size_t acpi_io_base;
100 int acpi_io_size;
101 struct platform_device *tco_dev;
103 /* gcr */
104 resource_size_t gcr_base;
105 int gcr_size;
107 /* punit */
108 resource_size_t punit_base;
109 int punit_size;
110 resource_size_t punit_base2;
111 int punit_size2;
112 struct platform_device *punit_dev;
113 } ipcdev;
115 static char *ipc_err_sources[] = {
116 [IPC_ERR_NONE] =
117 "no error",
118 [IPC_ERR_CMD_NOT_SUPPORTED] =
119 "command not supported",
120 [IPC_ERR_CMD_NOT_SERVICED] =
121 "command not serviced",
122 [IPC_ERR_UNABLE_TO_SERVICE] =
123 "unable to service",
124 [IPC_ERR_CMD_INVALID] =
125 "command invalid",
126 [IPC_ERR_CMD_FAILED] =
127 "command failed",
128 [IPC_ERR_EMSECURITY] =
129 "Invalid Battery",
130 [IPC_ERR_UNSIGNEDKERNEL] =
131 "Unsigned kernel",
134 /* Prevent concurrent calls to the PMC */
135 static DEFINE_MUTEX(ipclock);
137 static inline void ipc_send_command(u32 cmd)
139 ipcdev.cmd = cmd;
140 if (ipcdev.irq_mode) {
141 reinit_completion(&ipcdev.cmd_complete);
142 cmd |= IPC_CMD_MSI;
144 writel(cmd, ipcdev.ipc_base + IPC_CMD);
147 static inline u32 ipc_read_status(void)
149 return readl(ipcdev.ipc_base + IPC_STATUS);
152 static inline void ipc_data_writel(u32 data, u32 offset)
154 writel(data, ipcdev.ipc_base + IPC_WRITE_BUFFER + offset);
157 static inline u8 ipc_data_readb(u32 offset)
159 return readb(ipcdev.ipc_base + IPC_READ_BUFFER + offset);
162 static inline u32 ipc_data_readl(u32 offset)
164 return readl(ipcdev.ipc_base + IPC_READ_BUFFER + offset);
167 static int intel_pmc_ipc_check_status(void)
169 int status;
170 int ret = 0;
172 if (ipcdev.irq_mode) {
173 if (0 == wait_for_completion_timeout(
174 &ipcdev.cmd_complete, IPC_MAX_SEC * HZ))
175 ret = -ETIMEDOUT;
176 } else {
177 int loop_count = IPC_LOOP_CNT;
179 while ((ipc_read_status() & IPC_STATUS_BUSY) && --loop_count)
180 udelay(1);
181 if (loop_count == 0)
182 ret = -ETIMEDOUT;
185 status = ipc_read_status();
186 if (ret == -ETIMEDOUT) {
187 dev_err(ipcdev.dev,
188 "IPC timed out, TS=0x%x, CMD=0x%x\n",
189 status, ipcdev.cmd);
190 return ret;
193 if (status & IPC_STATUS_ERR) {
194 int i;
196 ret = -EIO;
197 i = (status >> IPC_CMD_SIZE) & 0xFF;
198 if (i < ARRAY_SIZE(ipc_err_sources))
199 dev_err(ipcdev.dev,
200 "IPC failed: %s, STS=0x%x, CMD=0x%x\n",
201 ipc_err_sources[i], status, ipcdev.cmd);
202 else
203 dev_err(ipcdev.dev,
204 "IPC failed: unknown, STS=0x%x, CMD=0x%x\n",
205 status, ipcdev.cmd);
206 if ((i == IPC_ERR_UNSIGNEDKERNEL) || (i == IPC_ERR_EMSECURITY))
207 ret = -EACCES;
210 return ret;
214 * intel_pmc_ipc_simple_command() - Simple IPC command
215 * @cmd: IPC command code.
216 * @sub: IPC command sub type.
218 * Send a simple IPC command to PMC when don't need to specify
219 * input/output data and source/dest pointers.
221 * Return: an IPC error code or 0 on success.
223 int intel_pmc_ipc_simple_command(int cmd, int sub)
225 int ret;
227 mutex_lock(&ipclock);
228 if (ipcdev.dev == NULL) {
229 mutex_unlock(&ipclock);
230 return -ENODEV;
232 ipc_send_command(sub << IPC_CMD_SUBCMD | cmd);
233 ret = intel_pmc_ipc_check_status();
234 mutex_unlock(&ipclock);
236 return ret;
238 EXPORT_SYMBOL_GPL(intel_pmc_ipc_simple_command);
241 * intel_pmc_ipc_raw_cmd() - IPC command with data and pointers
242 * @cmd: IPC command code.
243 * @sub: IPC command sub type.
244 * @in: input data of this IPC command.
245 * @inlen: input data length in bytes.
246 * @out: output data of this IPC command.
247 * @outlen: output data length in dwords.
248 * @sptr: data writing to SPTR register.
249 * @dptr: data writing to DPTR register.
251 * Send an IPC command to PMC with input/output data and source/dest pointers.
253 * Return: an IPC error code or 0 on success.
255 int intel_pmc_ipc_raw_cmd(u32 cmd, u32 sub, u8 *in, u32 inlen, u32 *out,
256 u32 outlen, u32 dptr, u32 sptr)
258 u32 wbuf[4] = { 0 };
259 int ret;
260 int i;
262 if (inlen > IPC_DATA_BUFFER_SIZE || outlen > IPC_DATA_BUFFER_SIZE / 4)
263 return -EINVAL;
265 mutex_lock(&ipclock);
266 if (ipcdev.dev == NULL) {
267 mutex_unlock(&ipclock);
268 return -ENODEV;
270 memcpy(wbuf, in, inlen);
271 writel(dptr, ipcdev.ipc_base + IPC_DPTR);
272 writel(sptr, ipcdev.ipc_base + IPC_SPTR);
273 /* The input data register is 32bit register and inlen is in Byte */
274 for (i = 0; i < ((inlen + 3) / 4); i++)
275 ipc_data_writel(wbuf[i], 4 * i);
276 ipc_send_command((inlen << IPC_CMD_SIZE) |
277 (sub << IPC_CMD_SUBCMD) | cmd);
278 ret = intel_pmc_ipc_check_status();
279 if (!ret) {
280 /* out is read from 32bit register and outlen is in 32bit */
281 for (i = 0; i < outlen; i++)
282 *out++ = ipc_data_readl(4 * i);
284 mutex_unlock(&ipclock);
286 return ret;
288 EXPORT_SYMBOL_GPL(intel_pmc_ipc_raw_cmd);
291 * intel_pmc_ipc_command() - IPC command with input/output data
292 * @cmd: IPC command code.
293 * @sub: IPC command sub type.
294 * @in: input data of this IPC command.
295 * @inlen: input data length in bytes.
296 * @out: output data of this IPC command.
297 * @outlen: output data length in dwords.
299 * Send an IPC command to PMC with input/output data.
301 * Return: an IPC error code or 0 on success.
303 int intel_pmc_ipc_command(u32 cmd, u32 sub, u8 *in, u32 inlen,
304 u32 *out, u32 outlen)
306 return intel_pmc_ipc_raw_cmd(cmd, sub, in, inlen, out, outlen, 0, 0);
308 EXPORT_SYMBOL_GPL(intel_pmc_ipc_command);
310 static irqreturn_t ioc(int irq, void *dev_id)
312 int status;
314 if (ipcdev.irq_mode) {
315 status = ipc_read_status();
316 writel(status | IPC_STATUS_IRQ, ipcdev.ipc_base + IPC_STATUS);
318 complete(&ipcdev.cmd_complete);
320 return IRQ_HANDLED;
323 static int ipc_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
325 resource_size_t pci_resource;
326 int ret;
327 int len;
329 ipcdev.dev = &pci_dev_get(pdev)->dev;
330 ipcdev.irq_mode = IPC_TRIGGER_MODE_IRQ;
332 ret = pci_enable_device(pdev);
333 if (ret)
334 return ret;
336 ret = pci_request_regions(pdev, "intel_pmc_ipc");
337 if (ret)
338 return ret;
340 pci_resource = pci_resource_start(pdev, 0);
341 len = pci_resource_len(pdev, 0);
342 if (!pci_resource || !len) {
343 dev_err(&pdev->dev, "Failed to get resource\n");
344 return -ENOMEM;
347 init_completion(&ipcdev.cmd_complete);
349 if (request_irq(pdev->irq, ioc, 0, "intel_pmc_ipc", &ipcdev)) {
350 dev_err(&pdev->dev, "Failed to request irq\n");
351 return -EBUSY;
354 ipcdev.ipc_base = ioremap_nocache(pci_resource, len);
355 if (!ipcdev.ipc_base) {
356 dev_err(&pdev->dev, "Failed to ioremap ipc base\n");
357 free_irq(pdev->irq, &ipcdev);
358 ret = -ENOMEM;
361 return ret;
364 static void ipc_pci_remove(struct pci_dev *pdev)
366 free_irq(pdev->irq, &ipcdev);
367 pci_release_regions(pdev);
368 pci_dev_put(pdev);
369 iounmap(ipcdev.ipc_base);
370 ipcdev.dev = NULL;
373 static const struct pci_device_id ipc_pci_ids[] = {
374 {PCI_VDEVICE(INTEL, 0x0a94), 0},
375 {PCI_VDEVICE(INTEL, 0x1a94), 0},
376 { 0,}
378 MODULE_DEVICE_TABLE(pci, ipc_pci_ids);
380 static struct pci_driver ipc_pci_driver = {
381 .name = "intel_pmc_ipc",
382 .id_table = ipc_pci_ids,
383 .probe = ipc_pci_probe,
384 .remove = ipc_pci_remove,
387 static ssize_t intel_pmc_ipc_simple_cmd_store(struct device *dev,
388 struct device_attribute *attr,
389 const char *buf, size_t count)
391 int subcmd;
392 int cmd;
393 int ret;
395 ret = sscanf(buf, "%d %d", &cmd, &subcmd);
396 if (ret != 2) {
397 dev_err(dev, "Error args\n");
398 return -EINVAL;
401 ret = intel_pmc_ipc_simple_command(cmd, subcmd);
402 if (ret) {
403 dev_err(dev, "command %d error with %d\n", cmd, ret);
404 return ret;
406 return (ssize_t)count;
409 static ssize_t intel_pmc_ipc_northpeak_store(struct device *dev,
410 struct device_attribute *attr,
411 const char *buf, size_t count)
413 unsigned long val;
414 int subcmd;
415 int ret;
417 if (kstrtoul(buf, 0, &val))
418 return -EINVAL;
420 if (val)
421 subcmd = 1;
422 else
423 subcmd = 0;
424 ret = intel_pmc_ipc_simple_command(PMC_IPC_NORTHPEAK_CTRL, subcmd);
425 if (ret) {
426 dev_err(dev, "command north %d error with %d\n", subcmd, ret);
427 return ret;
429 return (ssize_t)count;
432 static DEVICE_ATTR(simplecmd, S_IWUSR,
433 NULL, intel_pmc_ipc_simple_cmd_store);
434 static DEVICE_ATTR(northpeak, S_IWUSR,
435 NULL, intel_pmc_ipc_northpeak_store);
437 static struct attribute *intel_ipc_attrs[] = {
438 &dev_attr_northpeak.attr,
439 &dev_attr_simplecmd.attr,
440 NULL
443 static const struct attribute_group intel_ipc_group = {
444 .attrs = intel_ipc_attrs,
447 #define PUNIT_RESOURCE_INTER 1
448 static struct resource punit_res[] = {
449 /* Punit */
451 .flags = IORESOURCE_MEM,
454 .flags = IORESOURCE_MEM,
458 #define TCO_RESOURCE_ACPI_IO 0
459 #define TCO_RESOURCE_SMI_EN_IO 1
460 #define TCO_RESOURCE_GCR_MEM 2
461 static struct resource tco_res[] = {
462 /* ACPI - TCO */
464 .flags = IORESOURCE_IO,
466 /* ACPI - SMI */
468 .flags = IORESOURCE_IO,
470 /* GCS */
472 .flags = IORESOURCE_MEM,
476 static struct itco_wdt_platform_data tco_info = {
477 .name = "Apollo Lake SoC",
478 .version = 3,
481 static int ipc_create_punit_device(void)
483 struct platform_device *pdev;
484 struct resource *res;
485 int ret;
487 pdev = platform_device_alloc(PUNIT_DEVICE_NAME, -1);
488 if (!pdev) {
489 dev_err(ipcdev.dev, "Failed to alloc punit platform device\n");
490 return -ENOMEM;
493 pdev->dev.parent = ipcdev.dev;
495 res = punit_res;
496 res->start = ipcdev.punit_base;
497 res->end = res->start + ipcdev.punit_size - 1;
499 res = punit_res + PUNIT_RESOURCE_INTER;
500 res->start = ipcdev.punit_base2;
501 res->end = res->start + ipcdev.punit_size2 - 1;
503 ret = platform_device_add_resources(pdev, punit_res,
504 ARRAY_SIZE(punit_res));
505 if (ret) {
506 dev_err(ipcdev.dev, "Failed to add platform punit resources\n");
507 goto err;
510 ret = platform_device_add(pdev);
511 if (ret) {
512 dev_err(ipcdev.dev, "Failed to add punit platform device\n");
513 goto err;
515 ipcdev.punit_dev = pdev;
517 return 0;
518 err:
519 platform_device_put(pdev);
520 return ret;
523 static int ipc_create_tco_device(void)
525 struct platform_device *pdev;
526 struct resource *res;
527 int ret;
529 pdev = platform_device_alloc(TCO_DEVICE_NAME, -1);
530 if (!pdev) {
531 dev_err(ipcdev.dev, "Failed to alloc tco platform device\n");
532 return -ENOMEM;
535 pdev->dev.parent = ipcdev.dev;
537 res = tco_res + TCO_RESOURCE_ACPI_IO;
538 res->start = ipcdev.acpi_io_base + TCO_BASE_OFFSET;
539 res->end = res->start + TCO_REGS_SIZE - 1;
541 res = tco_res + TCO_RESOURCE_SMI_EN_IO;
542 res->start = ipcdev.acpi_io_base + SMI_EN_OFFSET;
543 res->end = res->start + SMI_EN_SIZE - 1;
545 res = tco_res + TCO_RESOURCE_GCR_MEM;
546 res->start = ipcdev.gcr_base;
547 res->end = res->start + ipcdev.gcr_size - 1;
549 ret = platform_device_add_resources(pdev, tco_res, ARRAY_SIZE(tco_res));
550 if (ret) {
551 dev_err(ipcdev.dev, "Failed to add tco platform resources\n");
552 goto err;
555 ret = platform_device_add_data(pdev, &tco_info, sizeof(tco_info));
556 if (ret) {
557 dev_err(ipcdev.dev, "Failed to add tco platform data\n");
558 goto err;
561 ret = platform_device_add(pdev);
562 if (ret) {
563 dev_err(ipcdev.dev, "Failed to add tco platform device\n");
564 goto err;
566 ipcdev.tco_dev = pdev;
568 return 0;
569 err:
570 platform_device_put(pdev);
571 return ret;
574 static int ipc_create_pmc_devices(void)
576 int ret;
578 ret = ipc_create_tco_device();
579 if (ret) {
580 dev_err(ipcdev.dev, "Failed to add tco platform device\n");
581 return ret;
583 ret = ipc_create_punit_device();
584 if (ret) {
585 dev_err(ipcdev.dev, "Failed to add punit platform device\n");
586 platform_device_unregister(ipcdev.tco_dev);
588 return ret;
591 static int ipc_plat_get_res(struct platform_device *pdev)
593 struct resource *res;
594 void __iomem *addr;
595 int size;
597 res = platform_get_resource(pdev, IORESOURCE_IO,
598 PLAT_RESOURCE_ACPI_IO_INDEX);
599 if (!res) {
600 dev_err(&pdev->dev, "Failed to get io resource\n");
601 return -ENXIO;
603 size = resource_size(res);
604 ipcdev.acpi_io_base = res->start;
605 ipcdev.acpi_io_size = size;
606 dev_info(&pdev->dev, "io res: %llx %x\n",
607 (long long)res->start, (int)resource_size(res));
609 res = platform_get_resource(pdev, IORESOURCE_MEM,
610 PLAT_RESOURCE_PUNIT_DATA_INDEX);
611 if (!res) {
612 dev_err(&pdev->dev, "Failed to get punit resource\n");
613 return -ENXIO;
615 size = resource_size(res);
616 ipcdev.punit_base = res->start;
617 ipcdev.punit_size = size;
618 dev_info(&pdev->dev, "punit data res: %llx %x\n",
619 (long long)res->start, (int)resource_size(res));
621 res = platform_get_resource(pdev, IORESOURCE_MEM,
622 PLAT_RESOURCE_PUNIT_INTER_INDEX);
623 if (!res) {
624 dev_err(&pdev->dev, "Failed to get punit inter resource\n");
625 return -ENXIO;
627 size = resource_size(res);
628 ipcdev.punit_base2 = res->start;
629 ipcdev.punit_size2 = size;
630 dev_info(&pdev->dev, "punit interface res: %llx %x\n",
631 (long long)res->start, (int)resource_size(res));
633 res = platform_get_resource(pdev, IORESOURCE_MEM,
634 PLAT_RESOURCE_IPC_INDEX);
635 if (!res) {
636 dev_err(&pdev->dev, "Failed to get ipc resource\n");
637 return -ENXIO;
639 size = PLAT_RESOURCE_IPC_SIZE;
640 if (!request_mem_region(res->start, size, pdev->name)) {
641 dev_err(&pdev->dev, "Failed to request ipc resource\n");
642 return -EBUSY;
644 addr = ioremap_nocache(res->start, size);
645 if (!addr) {
646 dev_err(&pdev->dev, "I/O memory remapping failed\n");
647 release_mem_region(res->start, size);
648 return -ENOMEM;
650 ipcdev.ipc_base = addr;
652 ipcdev.gcr_base = res->start + size;
653 ipcdev.gcr_size = PLAT_RESOURCE_GCR_SIZE;
654 dev_info(&pdev->dev, "ipc res: %llx %x\n",
655 (long long)res->start, (int)resource_size(res));
657 return 0;
660 #ifdef CONFIG_ACPI
661 static const struct acpi_device_id ipc_acpi_ids[] = {
662 { "INT34D2", 0},
665 MODULE_DEVICE_TABLE(acpi, ipc_acpi_ids);
666 #endif
668 static int ipc_plat_probe(struct platform_device *pdev)
670 struct resource *res;
671 int ret;
673 ipcdev.dev = &pdev->dev;
674 ipcdev.irq_mode = IPC_TRIGGER_MODE_IRQ;
675 init_completion(&ipcdev.cmd_complete);
677 ipcdev.irq = platform_get_irq(pdev, 0);
678 if (ipcdev.irq < 0) {
679 dev_err(&pdev->dev, "Failed to get irq\n");
680 return -EINVAL;
683 ret = ipc_plat_get_res(pdev);
684 if (ret) {
685 dev_err(&pdev->dev, "Failed to request resource\n");
686 return ret;
689 ret = ipc_create_pmc_devices();
690 if (ret) {
691 dev_err(&pdev->dev, "Failed to create pmc devices\n");
692 goto err_device;
695 if (request_irq(ipcdev.irq, ioc, 0, "intel_pmc_ipc", &ipcdev)) {
696 dev_err(&pdev->dev, "Failed to request irq\n");
697 ret = -EBUSY;
698 goto err_irq;
701 ret = sysfs_create_group(&pdev->dev.kobj, &intel_ipc_group);
702 if (ret) {
703 dev_err(&pdev->dev, "Failed to create sysfs group %d\n",
704 ret);
705 goto err_sys;
708 return 0;
709 err_sys:
710 free_irq(ipcdev.irq, &ipcdev);
711 err_irq:
712 platform_device_unregister(ipcdev.tco_dev);
713 platform_device_unregister(ipcdev.punit_dev);
714 err_device:
715 iounmap(ipcdev.ipc_base);
716 res = platform_get_resource(pdev, IORESOURCE_MEM,
717 PLAT_RESOURCE_IPC_INDEX);
718 if (res)
719 release_mem_region(res->start, PLAT_RESOURCE_IPC_SIZE);
720 return ret;
723 static int ipc_plat_remove(struct platform_device *pdev)
725 struct resource *res;
727 sysfs_remove_group(&pdev->dev.kobj, &intel_ipc_group);
728 free_irq(ipcdev.irq, &ipcdev);
729 platform_device_unregister(ipcdev.tco_dev);
730 platform_device_unregister(ipcdev.punit_dev);
731 iounmap(ipcdev.ipc_base);
732 res = platform_get_resource(pdev, IORESOURCE_MEM,
733 PLAT_RESOURCE_IPC_INDEX);
734 if (res)
735 release_mem_region(res->start, PLAT_RESOURCE_IPC_SIZE);
736 ipcdev.dev = NULL;
737 return 0;
740 static struct platform_driver ipc_plat_driver = {
741 .remove = ipc_plat_remove,
742 .probe = ipc_plat_probe,
743 .driver = {
744 .name = "pmc-ipc-plat",
745 .acpi_match_table = ACPI_PTR(ipc_acpi_ids),
749 static int __init intel_pmc_ipc_init(void)
751 int ret;
753 ret = platform_driver_register(&ipc_plat_driver);
754 if (ret) {
755 pr_err("Failed to register PMC ipc platform driver\n");
756 return ret;
758 ret = pci_register_driver(&ipc_pci_driver);
759 if (ret) {
760 pr_err("Failed to register PMC ipc pci driver\n");
761 platform_driver_unregister(&ipc_plat_driver);
762 return ret;
764 return ret;
767 static void __exit intel_pmc_ipc_exit(void)
769 pci_unregister_driver(&ipc_pci_driver);
770 platform_driver_unregister(&ipc_plat_driver);
773 MODULE_AUTHOR("Zha Qipeng <qipeng.zha@intel.com>");
774 MODULE_DESCRIPTION("Intel PMC IPC driver");
775 MODULE_LICENSE("GPL");
777 /* Some modules are dependent on this, so init earlier */
778 fs_initcall(intel_pmc_ipc_init);
779 module_exit(intel_pmc_ipc_exit);