1 /*
2  * platform_ipc.c: IPC platform library file
3  *
4  * (C) Copyright 2013 Intel Corporation
5  * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; version 2
10  * of the License.
11  */
12 
13 #include <linux/init.h>
14 #include <linux/kernel.h>
15 #include <linux/interrupt.h>
16 #include <linux/sfi.h>
17 #include <linux/gpio.h>
18 #include <asm/intel-mid.h>
19 #include "platform_ipc.h"
20 
ipc_device_handler(struct sfi_device_table_entry * pentry,struct devs_id * dev)21 void __init ipc_device_handler(struct sfi_device_table_entry *pentry,
22 				struct devs_id *dev)
23 {
24 	struct platform_device *pdev;
25 	void *pdata = NULL;
26 	static struct resource res __initdata = {
27 		.name = "IRQ",
28 		.flags = IORESOURCE_IRQ,
29 	};
30 
31 	pr_debug("IPC bus, name = %16.16s, irq = 0x%2x\n",
32 		pentry->name, pentry->irq);
33 
34 	/*
35 	 * We need to call platform init of IPC devices to fill misc_pdata
36 	 * structure. It will be used in msic_init for initialization.
37 	 */
38 	if (dev != NULL)
39 		pdata = dev->get_platform_data(pentry);
40 
41 	/*
42 	 * On Medfield the platform device creation is handled by the MSIC
43 	 * MFD driver so we don't need to do it here.
44 	 */
45 	if (intel_mid_has_msic())
46 		return;
47 
48 	pdev = platform_device_alloc(pentry->name, 0);
49 	if (pdev == NULL) {
50 		pr_err("out of memory for SFI platform device '%s'.\n",
51 			pentry->name);
52 		return;
53 	}
54 	res.start = pentry->irq;
55 	platform_device_add_resources(pdev, &res, 1);
56 
57 	pdev->dev.platform_data = pdata;
58 	intel_scu_device_register(pdev);
59 }
60 
61 static const struct devs_id pmic_audio_dev_id __initconst = {
62 	.name = "pmic_audio",
63 	.type = SFI_DEV_TYPE_IPC,
64 	.delay = 1,
65 	.device_handler = &ipc_device_handler,
66 };
67 
68 sfi_device(pmic_audio_dev_id);
69