0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <linux/init.h>
0010 #include <linux/interrupt.h>
0011 #include <linux/platform_device.h>
0012 #include <linux/platform_data/intel-mid_wdt.h>
0013
0014 #include <asm/cpu_device_id.h>
0015 #include <asm/intel-family.h>
0016 #include <asm/intel-mid.h>
0017 #include <asm/io_apic.h>
0018 #include <asm/hw_irq.h>
0019
0020 #define TANGIER_EXT_TIMER0_MSI 12
0021
0022 static struct platform_device wdt_dev = {
0023 .name = "intel_mid_wdt",
0024 .id = -1,
0025 };
0026
0027 static int tangier_probe(struct platform_device *pdev)
0028 {
0029 struct irq_alloc_info info;
0030 struct intel_mid_wdt_pdata *pdata = pdev->dev.platform_data;
0031 int gsi = TANGIER_EXT_TIMER0_MSI;
0032 int irq;
0033
0034 if (!pdata)
0035 return -EINVAL;
0036
0037
0038 ioapic_set_alloc_attr(&info, cpu_to_node(0), 1, 0);
0039 irq = mp_map_gsi_to_irq(gsi, IOAPIC_MAP_ALLOC, &info);
0040 if (irq < 0) {
0041 dev_warn(&pdev->dev, "cannot find interrupt %d in ioapic\n", gsi);
0042 return irq;
0043 }
0044
0045 pdata->irq = irq;
0046 return 0;
0047 }
0048
0049 static struct intel_mid_wdt_pdata tangier_pdata = {
0050 .probe = tangier_probe,
0051 };
0052
0053 static const struct x86_cpu_id intel_mid_cpu_ids[] = {
0054 X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT_MID, &tangier_pdata),
0055 {}
0056 };
0057
0058 static int __init register_mid_wdt(void)
0059 {
0060 const struct x86_cpu_id *id;
0061
0062 id = x86_match_cpu(intel_mid_cpu_ids);
0063 if (!id)
0064 return -ENODEV;
0065
0066 wdt_dev.dev.platform_data = (struct intel_mid_wdt_pdata *)id->driver_data;
0067 return platform_device_register(&wdt_dev);
0068 }
0069 arch_initcall(register_mid_wdt);
0070
0071 static void __exit unregister_mid_wdt(void)
0072 {
0073 platform_device_unregister(&wdt_dev);
0074 }
0075 __exitcall(unregister_mid_wdt);