platform_wdt.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * platform_wdt.c: Watchdog platform library file
  3. *
  4. * (C) Copyright 2014 Intel Corporation
  5. * Author: David Cohen <david.a.cohen@linux.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/interrupt.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/platform_data/intel-mid_wdt.h>
  16. #include <asm/intel-mid.h>
  17. #include <asm/io_apic.h>
  18. #define TANGIER_EXT_TIMER0_MSI 15
  19. static struct platform_device wdt_dev = {
  20. .name = "intel_mid_wdt",
  21. .id = -1,
  22. };
  23. static int tangier_probe(struct platform_device *pdev)
  24. {
  25. int gsi;
  26. struct intel_mid_wdt_pdata *pdata = pdev->dev.platform_data;
  27. if (!pdata)
  28. return -EINVAL;
  29. /* IOAPIC builds identity mapping between GSI and IRQ on MID */
  30. gsi = pdata->irq;
  31. if (mp_set_gsi_attr(gsi, 1, 0, cpu_to_node(0)) ||
  32. mp_map_gsi_to_irq(gsi, IOAPIC_MAP_ALLOC) <= 0) {
  33. dev_warn(&pdev->dev, "cannot find interrupt %d in ioapic\n",
  34. gsi);
  35. return -EINVAL;
  36. }
  37. return 0;
  38. }
  39. static struct intel_mid_wdt_pdata tangier_pdata = {
  40. .irq = TANGIER_EXT_TIMER0_MSI,
  41. .probe = tangier_probe,
  42. };
  43. static int __init register_mid_wdt(void)
  44. {
  45. if (intel_mid_identify_cpu() == INTEL_MID_CPU_CHIP_TANGIER) {
  46. wdt_dev.dev.platform_data = &tangier_pdata;
  47. return platform_device_register(&wdt_dev);
  48. }
  49. return -ENODEV;
  50. }
  51. rootfs_initcall(register_mid_wdt);