platform_ipc.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #include <linux/init.h>
  13. #include <linux/kernel.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/sfi.h>
  16. #include <linux/gpio.h>
  17. #include <asm/intel-mid.h>
  18. #include "platform_ipc.h"
  19. void __init ipc_device_handler(struct sfi_device_table_entry *pentry,
  20. struct devs_id *dev)
  21. {
  22. struct platform_device *pdev;
  23. void *pdata = NULL;
  24. static struct resource res __initdata = {
  25. .name = "IRQ",
  26. .flags = IORESOURCE_IRQ,
  27. };
  28. pr_debug("IPC bus, name = %16.16s, irq = 0x%2x\n",
  29. pentry->name, pentry->irq);
  30. /*
  31. * We need to call platform init of IPC devices to fill misc_pdata
  32. * structure. It will be used in msic_init for initialization.
  33. */
  34. if (dev != NULL)
  35. pdata = dev->get_platform_data(pentry);
  36. /*
  37. * On Medfield the platform device creation is handled by the MSIC
  38. * MFD driver so we don't need to do it here.
  39. */
  40. if (intel_mid_has_msic())
  41. return;
  42. pdev = platform_device_alloc(pentry->name, 0);
  43. if (pdev == NULL) {
  44. pr_err("out of memory for SFI platform device '%s'.\n",
  45. pentry->name);
  46. return;
  47. }
  48. res.start = pentry->irq;
  49. platform_device_add_resources(pdev, &res, 1);
  50. pdev->dev.platform_data = pdata;
  51. intel_scu_device_register(pdev);
  52. }
  53. static const struct devs_id pmic_audio_dev_id __initconst = {
  54. .name = "pmic_audio",
  55. .type = SFI_DEV_TYPE_IPC,
  56. .delay = 1,
  57. .device_handler = &ipc_device_handler,
  58. };
  59. sfi_device(pmic_audio_dev_id);