]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - arch/x86/platform/intel-mid/device_libs/platform_mrfld_wdt.c
Merge remote-tracking branches 'asoc/topic/adsp', 'asoc/topic/ak4613', 'asoc/topic...
[mirror_ubuntu-bionic-kernel.git] / arch / x86 / platform / intel-mid / device_libs / platform_mrfld_wdt.c
CommitLineData
78a3bb9e 1/*
e5dce286 2 * Intel Merrifield watchdog platform device library file
78a3bb9e
DC
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
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>
8c5c86fb 17
78a3bb9e 18#include <asm/intel-mid.h>
8c5c86fb 19#include <asm/intel_scu_ipc.h>
78a3bb9e
DC
20#include <asm/io_apic.h>
21
80354c29 22#define TANGIER_EXT_TIMER0_MSI 12
78a3bb9e
DC
23
24static struct platform_device wdt_dev = {
25 .name = "intel_mid_wdt",
26 .id = -1,
27};
28
29static int tangier_probe(struct platform_device *pdev)
30{
c4d05a2c 31 struct irq_alloc_info info;
78a3bb9e 32 struct intel_mid_wdt_pdata *pdata = pdev->dev.platform_data;
93953395 33 int gsi, irq;
78a3bb9e
DC
34
35 if (!pdata)
36 return -EINVAL;
37
a4355e67
JL
38 /* IOAPIC builds identity mapping between GSI and IRQ on MID */
39 gsi = pdata->irq;
c4d05a2c 40 ioapic_set_alloc_attr(&info, cpu_to_node(0), 1, 0);
93953395
AS
41 irq = mp_map_gsi_to_irq(gsi, IOAPIC_MAP_ALLOC, &info);
42 if (irq < 0) {
43 dev_warn(&pdev->dev, "cannot find interrupt %d in ioapic\n", gsi);
44 return irq;
78a3bb9e
DC
45 }
46
47 return 0;
48}
49
50static struct intel_mid_wdt_pdata tangier_pdata = {
51 .irq = TANGIER_EXT_TIMER0_MSI,
52 .probe = tangier_probe,
53};
54
8c5c86fb
AS
55static int wdt_scu_status_change(struct notifier_block *nb,
56 unsigned long code, void *data)
78a3bb9e 57{
8c5c86fb
AS
58 if (code == SCU_DOWN) {
59 platform_device_unregister(&wdt_dev);
60 return 0;
78a3bb9e
DC
61 }
62
8c5c86fb 63 return platform_device_register(&wdt_dev);
78a3bb9e
DC
64}
65
8c5c86fb
AS
66static struct notifier_block wdt_scu_notifier = {
67 .notifier_call = wdt_scu_status_change,
68};
69
70static int __init register_mid_wdt(void)
71{
72 if (intel_mid_identify_cpu() != INTEL_MID_CPU_CHIP_TANGIER)
73 return -ENODEV;
74
75 wdt_dev.dev.platform_data = &tangier_pdata;
76
77 /*
78 * We need to be sure that the SCU IPC is ready before watchdog device
79 * can be registered:
80 */
81 intel_scu_notifier_add(&wdt_scu_notifier);
82
83 return 0;
84}
e2e2eabb 85arch_initcall(register_mid_wdt);