2 * Intel Merrifield watchdog platform device library file
4 * (C) Copyright 2014 Intel Corporation
5 * Author: David Cohen <david.a.cohen@linux.intel.com>
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
13 #include <linux/init.h>
14 #include <linux/interrupt.h>
15 #include <linux/platform_device.h>
16 #include <linux/platform_data/intel-mid_wdt.h>
18 #include <asm/intel-mid.h>
19 #include <asm/intel_scu_ipc.h>
20 #include <asm/io_apic.h>
22 #define TANGIER_EXT_TIMER0_MSI 15
24 static struct platform_device wdt_dev = {
25 .name = "intel_mid_wdt",
29 static int tangier_probe(struct platform_device *pdev)
32 struct irq_alloc_info info;
33 struct intel_mid_wdt_pdata *pdata = pdev->dev.platform_data;
38 /* IOAPIC builds identity mapping between GSI and IRQ on MID */
40 ioapic_set_alloc_attr(&info, cpu_to_node(0), 1, 0);
41 if (mp_map_gsi_to_irq(gsi, IOAPIC_MAP_ALLOC, &info) <= 0) {
42 dev_warn(&pdev->dev, "cannot find interrupt %d in ioapic\n",
50 static struct intel_mid_wdt_pdata tangier_pdata = {
51 .irq = TANGIER_EXT_TIMER0_MSI,
52 .probe = tangier_probe,
55 static int wdt_scu_status_change(struct notifier_block *nb,
56 unsigned long code, void *data)
58 if (code == SCU_DOWN) {
59 platform_device_unregister(&wdt_dev);
63 return platform_device_register(&wdt_dev);
66 static struct notifier_block wdt_scu_notifier = {
67 .notifier_call = wdt_scu_status_change,
70 static int __init register_mid_wdt(void)
72 if (intel_mid_identify_cpu() != INTEL_MID_CPU_CHIP_TANGIER)
75 wdt_dev.dev.platform_data = &tangier_pdata;
78 * We need to be sure that the SCU IPC is ready before watchdog device
81 intel_scu_notifier_add(&wdt_scu_notifier);
85 rootfs_initcall(register_mid_wdt);