2019-06-01 17:08:55 +09:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2014-04-16 07:20:32 +09:00
|
|
|
/*
|
2016-11-19 02:27:23 +09:00
|
|
|
* Intel Merrifield watchdog platform device library file
|
2014-04-16 07:20:32 +09:00
|
|
|
*
|
|
|
|
* (C) Copyright 2014 Intel Corporation
|
|
|
|
* Author: David Cohen <david.a.cohen@linux.intel.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/platform_data/intel-mid_wdt.h>
|
2016-11-19 01:52:24 +09:00
|
|
|
|
2014-04-16 07:20:32 +09:00
|
|
|
#include <asm/intel-mid.h>
|
2016-11-19 01:52:24 +09:00
|
|
|
#include <asm/intel_scu_ipc.h>
|
2014-04-16 07:20:32 +09:00
|
|
|
#include <asm/io_apic.h>
|
2018-07-29 19:15:33 +09:00
|
|
|
#include <asm/hw_irq.h>
|
2014-04-16 07:20:32 +09:00
|
|
|
|
2017-03-13 00:07:44 +09:00
|
|
|
#define TANGIER_EXT_TIMER0_MSI 12
|
2014-04-16 07:20:32 +09:00
|
|
|
|
|
|
|
static struct platform_device wdt_dev = {
|
|
|
|
.name = "intel_mid_wdt",
|
|
|
|
.id = -1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int tangier_probe(struct platform_device *pdev)
|
|
|
|
{
|
2015-04-13 15:11:54 +09:00
|
|
|
struct irq_alloc_info info;
|
2014-04-16 07:20:32 +09:00
|
|
|
struct intel_mid_wdt_pdata *pdata = pdev->dev.platform_data;
|
2017-07-25 02:34:02 +09:00
|
|
|
int gsi = TANGIER_EXT_TIMER0_MSI;
|
|
|
|
int irq;
|
2014-04-16 07:20:32 +09:00
|
|
|
|
|
|
|
if (!pdata)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2014-06-23 11:30:35 +09:00
|
|
|
/* IOAPIC builds identity mapping between GSI and IRQ on MID */
|
2015-04-13 15:11:54 +09:00
|
|
|
ioapic_set_alloc_attr(&info, cpu_to_node(0), 1, 0);
|
2017-01-20 04:24:24 +09:00
|
|
|
irq = mp_map_gsi_to_irq(gsi, IOAPIC_MAP_ALLOC, &info);
|
|
|
|
if (irq < 0) {
|
|
|
|
dev_warn(&pdev->dev, "cannot find interrupt %d in ioapic\n", gsi);
|
|
|
|
return irq;
|
2014-04-16 07:20:32 +09:00
|
|
|
}
|
|
|
|
|
2017-07-25 02:34:02 +09:00
|
|
|
pdata->irq = irq;
|
2014-04-16 07:20:32 +09:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct intel_mid_wdt_pdata tangier_pdata = {
|
|
|
|
.probe = tangier_probe,
|
|
|
|
};
|
|
|
|
|
2016-11-19 01:52:24 +09:00
|
|
|
static int wdt_scu_status_change(struct notifier_block *nb,
|
|
|
|
unsigned long code, void *data)
|
2014-04-16 07:20:32 +09:00
|
|
|
{
|
2016-11-19 01:52:24 +09:00
|
|
|
if (code == SCU_DOWN) {
|
|
|
|
platform_device_unregister(&wdt_dev);
|
|
|
|
return 0;
|
2014-04-16 07:20:32 +09:00
|
|
|
}
|
|
|
|
|
2016-11-19 01:52:24 +09:00
|
|
|
return platform_device_register(&wdt_dev);
|
2014-04-16 07:20:32 +09:00
|
|
|
}
|
|
|
|
|
2016-11-19 01:52:24 +09:00
|
|
|
static struct notifier_block wdt_scu_notifier = {
|
|
|
|
.notifier_call = wdt_scu_status_change,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init register_mid_wdt(void)
|
|
|
|
{
|
|
|
|
if (intel_mid_identify_cpu() != INTEL_MID_CPU_CHIP_TANGIER)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
wdt_dev.dev.platform_data = &tangier_pdata;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We need to be sure that the SCU IPC is ready before watchdog device
|
|
|
|
* can be registered:
|
|
|
|
*/
|
|
|
|
intel_scu_notifier_add(&wdt_scu_notifier);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2017-01-20 04:24:25 +09:00
|
|
|
arch_initcall(register_mid_wdt);
|