platform_msic.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * platform_msic.c: MSIC platform data initilization 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/kernel.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/scatterlist.h>
  15. #include <linux/init.h>
  16. #include <linux/sfi.h>
  17. #include <linux/mfd/intel_msic.h>
  18. #include <asm/intel_scu_ipc.h>
  19. #include <asm/intel-mid.h>
  20. #include "platform_msic.h"
  21. struct intel_msic_platform_data msic_pdata;
  22. static struct resource msic_resources[] = {
  23. {
  24. .start = INTEL_MSIC_IRQ_PHYS_BASE,
  25. .end = INTEL_MSIC_IRQ_PHYS_BASE + 64 - 1,
  26. .flags = IORESOURCE_MEM,
  27. },
  28. };
  29. static struct platform_device msic_device = {
  30. .name = "intel_msic",
  31. .id = -1,
  32. .dev = {
  33. .platform_data = &msic_pdata,
  34. },
  35. .num_resources = ARRAY_SIZE(msic_resources),
  36. .resource = msic_resources,
  37. };
  38. static int msic_scu_status_change(struct notifier_block *nb,
  39. unsigned long code, void *data)
  40. {
  41. if (code == SCU_DOWN) {
  42. platform_device_unregister(&msic_device);
  43. return 0;
  44. }
  45. return platform_device_register(&msic_device);
  46. }
  47. static int __init msic_init(void)
  48. {
  49. static struct notifier_block msic_scu_notifier = {
  50. .notifier_call = msic_scu_status_change,
  51. };
  52. /*
  53. * We need to be sure that the SCU IPC is ready before MSIC device
  54. * can be registered.
  55. */
  56. if (intel_mid_has_msic())
  57. intel_scu_notifier_add(&msic_scu_notifier);
  58. return 0;
  59. }
  60. arch_initcall(msic_init);
  61. /*
  62. * msic_generic_platform_data - sets generic platform data for the block
  63. * @info: pointer to the SFI device table entry for this block
  64. * @block: MSIC block
  65. *
  66. * Function sets IRQ number from the SFI table entry for given device to
  67. * the MSIC platform data.
  68. */
  69. void *msic_generic_platform_data(void *info, enum intel_msic_block block)
  70. {
  71. struct sfi_device_table_entry *entry = info;
  72. BUG_ON(block < 0 || block >= INTEL_MSIC_BLOCK_LAST);
  73. msic_pdata.irq[block] = entry->irq;
  74. return NULL;
  75. }