drm/dp_mst: Add helper to get port number at specific LCT from RAD
[drm/drm-misc.git] / drivers / platform / x86 / intel_scu_wdt.c
blob746d47d334061ae923c5658019679563708b39a5
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Intel Merrifield watchdog platform device library file
5 * (C) Copyright 2014 Intel Corporation
6 * Author: David Cohen <david.a.cohen@linux.intel.com>
7 */
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",
24 .id = -1,
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;
32 int irq;
34 if (!pdata)
35 return -EINVAL;
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);
40 if (irq < 0) {
41 dev_warn(&pdev->dev, "cannot find interrupt %d in ioapic\n", gsi);
42 return irq;
45 pdata->irq = irq;
46 return 0;
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);
63 if (!id)
64 return -ENODEV;
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);