GNU Linux-libre 4.14.290-gnu1
[releases.git] / arch / x86 / platform / intel-mid / device_libs / platform_mrfld_rtc.c
1 /*
2  * Intel Merrifield legacy RTC initialization file
3  *
4  * (C) Copyright 2017 Intel Corporation
5  *
6  * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; version 2
11  * of the License.
12  */
13
14 #include <linux/init.h>
15
16 #include <asm/hw_irq.h>
17 #include <asm/intel-mid.h>
18 #include <asm/io_apic.h>
19 #include <asm/time.h>
20 #include <asm/x86_init.h>
21
22 static int __init mrfld_legacy_rtc_alloc_irq(void)
23 {
24         struct irq_alloc_info info;
25         int ret;
26
27         if (!x86_platform.legacy.rtc)
28                 return -ENODEV;
29
30         ioapic_set_alloc_attr(&info, NUMA_NO_NODE, 1, 0);
31         ret = mp_map_gsi_to_irq(RTC_IRQ, IOAPIC_MAP_ALLOC, &info);
32         if (ret < 0) {
33                 pr_info("Failed to allocate RTC interrupt. Disabling RTC\n");
34                 x86_platform.legacy.rtc = 0;
35                 return ret;
36         }
37
38         return 0;
39 }
40
41 static int __init mrfld_legacy_rtc_init(void)
42 {
43         if (intel_mid_identify_cpu() != INTEL_MID_CPU_CHIP_TANGIER)
44                 return -ENODEV;
45
46         return mrfld_legacy_rtc_alloc_irq();
47 }
48 arch_initcall(mrfld_legacy_rtc_init);