intel_scu_wdt.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Intel Merrifield watchdog platform device library file
  4. *
  5. * (C) Copyright 2014 Intel Corporation
  6. * Author: David Cohen <david.a.cohen@linux.intel.com>
  7. */
  8. #include <linux/init.h>
  9. #include <linux/interrupt.h>
  10. #include <linux/platform_device.h>
  11. #include <asm/cpu_device_id.h>
  12. #include <asm/intel-family.h>
  13. #include <asm/io_apic.h>
  14. #include <asm/hw_irq.h>
  15. #include <linux/platform_data/x86/intel-mid_wdt.h>
  16. #define TANGIER_EXT_TIMER0_MSI 12
  17. static struct platform_device wdt_dev = {
  18. .name = "intel_mid_wdt",
  19. .id = -1,
  20. };
  21. static int tangier_probe(struct platform_device *pdev)
  22. {
  23. struct irq_alloc_info info;
  24. struct intel_mid_wdt_pdata *pdata = pdev->dev.platform_data;
  25. int gsi = TANGIER_EXT_TIMER0_MSI;
  26. int irq;
  27. if (!pdata)
  28. return -EINVAL;
  29. /* IOAPIC builds identity mapping between GSI and IRQ on MID */
  30. ioapic_set_alloc_attr(&info, cpu_to_node(0), 1, 0);
  31. irq = mp_map_gsi_to_irq(gsi, IOAPIC_MAP_ALLOC, &info);
  32. if (irq < 0) {
  33. dev_warn(&pdev->dev, "cannot find interrupt %d in ioapic\n", gsi);
  34. return irq;
  35. }
  36. pdata->irq = irq;
  37. return 0;
  38. }
  39. static struct intel_mid_wdt_pdata tangier_pdata = {
  40. .probe = tangier_probe,
  41. };
  42. static const struct x86_cpu_id intel_mid_cpu_ids[] = {
  43. X86_MATCH_VFM(INTEL_ATOM_SILVERMONT_MID, &tangier_pdata),
  44. {}
  45. };
  46. static int __init register_mid_wdt(void)
  47. {
  48. const struct x86_cpu_id *id;
  49. id = x86_match_cpu(intel_mid_cpu_ids);
  50. if (!id)
  51. return -ENODEV;
  52. wdt_dev.dev.platform_data = (struct intel_mid_wdt_pdata *)id->driver_data;
  53. return platform_device_register(&wdt_dev);
  54. }
  55. arch_initcall(register_mid_wdt);
  56. static void __exit unregister_mid_wdt(void)
  57. {
  58. platform_device_unregister(&wdt_dev);
  59. }
  60. __exitcall(unregister_mid_wdt);