2019-06-01 08:08:55 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2014-04-15 22:20:32 +00:00
|
|
|
/*
|
2016-11-18 17:27:23 +00:00
|
|
|
* Intel Merrifield watchdog platform device library file
|
2014-04-15 22:20:32 +00: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-18 16:52:24 +00:00
|
|
|
|
2018-07-02 17:45:36 +00:00
|
|
|
#include <asm/cpu_device_id.h>
|
|
|
|
#include <asm/intel-family.h>
|
2014-04-15 22:20:32 +00:00
|
|
|
#include <asm/intel-mid.h>
|
|
|
|
#include <asm/io_apic.h>
|
2018-07-29 10:15:33 +00:00
|
|
|
#include <asm/hw_irq.h>
|
2014-04-15 22:20:32 +00:00
|
|
|
|
2017-03-12 15:07:44 +00:00
|
|
|
#define TANGIER_EXT_TIMER0_MSI 12
|
2014-04-15 22:20:32 +00:00
|
|
|
|
|
|
|
static struct platform_device wdt_dev = {
|
|
|
|
.name = "intel_mid_wdt",
|
|
|
|
.id = -1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int tangier_probe(struct platform_device *pdev)
|
|
|
|
{
|
2015-04-13 06:11:54 +00:00
|
|
|
struct irq_alloc_info info;
|
2014-04-15 22:20:32 +00:00
|
|
|
struct intel_mid_wdt_pdata *pdata = pdev->dev.platform_data;
|
2017-07-24 17:34:02 +00:00
|
|
|
int gsi = TANGIER_EXT_TIMER0_MSI;
|
|
|
|
int irq;
|
2014-04-15 22:20:32 +00:00
|
|
|
|
|
|
|
if (!pdata)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2014-06-23 02:30:35 +00:00
|
|
|
/* IOAPIC builds identity mapping between GSI and IRQ on MID */
|
2015-04-13 06:11:54 +00:00
|
|
|
ioapic_set_alloc_attr(&info, cpu_to_node(0), 1, 0);
|
2017-01-19 19:24:24 +00: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-15 22:20:32 +00:00
|
|
|
}
|
|
|
|
|
2017-07-24 17:34:02 +00:00
|
|
|
pdata->irq = irq;
|
2014-04-15 22:20:32 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct intel_mid_wdt_pdata tangier_pdata = {
|
|
|
|
.probe = tangier_probe,
|
|
|
|
};
|
|
|
|
|
2018-07-02 17:45:36 +00:00
|
|
|
static const struct x86_cpu_id intel_mid_cpu_ids[] = {
|
|
|
|
X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT_MID, &tangier_pdata),
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2016-11-18 16:52:24 +00:00
|
|
|
static int __init register_mid_wdt(void)
|
|
|
|
{
|
2018-07-02 17:45:36 +00:00
|
|
|
const struct x86_cpu_id *id;
|
|
|
|
|
|
|
|
id = x86_match_cpu(intel_mid_cpu_ids);
|
|
|
|
if (!id)
|
2016-11-18 16:52:24 +00:00
|
|
|
return -ENODEV;
|
|
|
|
|
2021-02-04 15:05:08 +00:00
|
|
|
wdt_dev.dev.platform_data = (struct intel_mid_wdt_pdata *)id->driver_data;
|
2020-10-23 16:14:15 +00:00
|
|
|
return platform_device_register(&wdt_dev);
|
2016-11-18 16:52:24 +00:00
|
|
|
}
|
2017-01-19 19:24:25 +00:00
|
|
|
arch_initcall(register_mid_wdt);
|
2020-10-23 16:14:15 +00:00
|
|
|
|
|
|
|
static void __exit unregister_mid_wdt(void)
|
|
|
|
{
|
|
|
|
platform_device_unregister(&wdt_dev);
|
|
|
|
}
|
|
|
|
__exitcall(unregister_mid_wdt);
|