1 // SPDX-License-Identifier: GPL-2.0-only
3 * Intel Merrifield watchdog platform device library file
5 * (C) Copyright 2014 Intel Corporation
6 * Author: David Cohen <david.a.cohen@linux.intel.com>
9 #include <linux/init.h>
10 #include <linux/interrupt.h>
11 #include <linux/platform_device.h>
13 #include <asm/cpu_device_id.h>
14 #include <asm/intel-family.h>
15 #include <asm/io_apic.h>
16 #include <asm/hw_irq.h>
18 #include <linux/platform_data/x86/intel-mid_wdt.h>
20 #define TANGIER_EXT_TIMER0_MSI 12
22 static struct platform_device wdt_dev
= {
23 .name
= "intel_mid_wdt",
27 static int tangier_probe(struct platform_device
*pdev
)
29 struct irq_alloc_info info
;
30 struct intel_mid_wdt_pdata
*pdata
= pdev
->dev
.platform_data
;
31 int gsi
= TANGIER_EXT_TIMER0_MSI
;
37 /* IOAPIC builds identity mapping between GSI and IRQ on MID */
38 ioapic_set_alloc_attr(&info
, cpu_to_node(0), 1, 0);
39 irq
= mp_map_gsi_to_irq(gsi
, IOAPIC_MAP_ALLOC
, &info
);
41 dev_warn(&pdev
->dev
, "cannot find interrupt %d in ioapic\n", gsi
);
49 static struct intel_mid_wdt_pdata tangier_pdata
= {
50 .probe
= tangier_probe
,
53 static const struct x86_cpu_id intel_mid_cpu_ids
[] = {
54 X86_MATCH_VFM(INTEL_ATOM_SILVERMONT_MID
, &tangier_pdata
),
58 static int __init
register_mid_wdt(void)
60 const struct x86_cpu_id
*id
;
62 id
= x86_match_cpu(intel_mid_cpu_ids
);
66 wdt_dev
.dev
.platform_data
= (struct intel_mid_wdt_pdata
*)id
->driver_data
;
67 return platform_device_register(&wdt_dev
);
69 arch_initcall(register_mid_wdt
);
71 static void __exit
unregister_mid_wdt(void)
73 platform_device_unregister(&wdt_dev
);
75 __exitcall(unregister_mid_wdt
);