mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-02-27 08:05:24 +07:00

On OLPC XO-1, the RTC is discovered via device tree from the arch initcall. Don't let the PC platform register another one from its device initcall, it's not going to work: sysfs: cannot create duplicate filename '/devices/platform/rtc_cmos' CPU: 0 PID: 1 Comm: swapper Not tainted 4.19.0-rc6 #12 Hardware name: OLPC XO/XO, BIOS OLPC Ver 1.00.01 06/11/2014 Call Trace: dump_stack+0x16/0x18 sysfs_warn_dup+0x46/0x58 sysfs_create_dir_ns+0x76/0x9b kobject_add_internal+0xed/0x209 ? __schedule+0x3fa/0x447 kobject_add+0x5b/0x66 device_add+0x298/0x535 ? insert_resource_conflict+0x2a/0x3e platform_device_add+0x14d/0x192 ? io_delay_init+0x19/0x19 platform_device_register+0x1c/0x1f add_rtc_cmos+0x16/0x31 do_one_initcall+0x78/0x14a ? do_early_param+0x75/0x75 kernel_init_freeable+0x152/0x1e0 ? rest_init+0xa2/0xa2 kernel_init+0x8/0xd5 ret_from_fork+0x2e/0x38 kobject_add_internal failed for rtc_cmos with -EEXIST, don't try to register things with the same name in the same directory. platform rtc_cmos: registered platform RTC device (no PNP device found) Signed-off-by: Lubomir Rintel <lkundrak@v3.sk> Signed-off-by: Borislav Petkov <bp@suse.de> Acked-by: Thomas Gleixner <tglx@linutronix.de> CC: "H. Peter Anvin" <hpa@zytor.com> CC: Ingo Molnar <mingo@redhat.com> CC: x86-ml <x86@kernel.org> Link: http://lkml.kernel.org/r/20181004160808.307738-1-lkundrak@v3.sk
85 lines
1.8 KiB
C
85 lines
1.8 KiB
C
/*
|
|
* Support for OLPC XO-1 Real Time Clock (RTC)
|
|
*
|
|
* Copyright (C) 2011 One Laptop per Child
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*/
|
|
|
|
#include <linux/mc146818rtc.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/rtc.h>
|
|
#include <linux/of.h>
|
|
|
|
#include <asm/msr.h>
|
|
#include <asm/olpc.h>
|
|
#include <asm/x86_init.h>
|
|
|
|
static void rtc_wake_on(struct device *dev)
|
|
{
|
|
olpc_xo1_pm_wakeup_set(CS5536_PM_RTC);
|
|
}
|
|
|
|
static void rtc_wake_off(struct device *dev)
|
|
{
|
|
olpc_xo1_pm_wakeup_clear(CS5536_PM_RTC);
|
|
}
|
|
|
|
static struct resource rtc_platform_resource[] = {
|
|
[0] = {
|
|
.start = RTC_PORT(0),
|
|
.end = RTC_PORT(1),
|
|
.flags = IORESOURCE_IO,
|
|
},
|
|
[1] = {
|
|
.start = RTC_IRQ,
|
|
.end = RTC_IRQ,
|
|
.flags = IORESOURCE_IRQ,
|
|
}
|
|
};
|
|
|
|
static struct cmos_rtc_board_info rtc_info = {
|
|
.rtc_day_alarm = 0,
|
|
.rtc_mon_alarm = 0,
|
|
.rtc_century = 0,
|
|
.wake_on = rtc_wake_on,
|
|
.wake_off = rtc_wake_off,
|
|
};
|
|
|
|
static struct platform_device xo1_rtc_device = {
|
|
.name = "rtc_cmos",
|
|
.id = -1,
|
|
.num_resources = ARRAY_SIZE(rtc_platform_resource),
|
|
.dev.platform_data = &rtc_info,
|
|
.resource = rtc_platform_resource,
|
|
};
|
|
|
|
static int __init xo1_rtc_init(void)
|
|
{
|
|
int r;
|
|
struct device_node *node;
|
|
|
|
node = of_find_compatible_node(NULL, NULL, "olpc,xo1-rtc");
|
|
if (!node)
|
|
return 0;
|
|
of_node_put(node);
|
|
|
|
pr_info("olpc-xo1-rtc: Initializing OLPC XO-1 RTC\n");
|
|
rdmsrl(MSR_RTC_DOMA_OFFSET, rtc_info.rtc_day_alarm);
|
|
rdmsrl(MSR_RTC_MONA_OFFSET, rtc_info.rtc_mon_alarm);
|
|
rdmsrl(MSR_RTC_CEN_OFFSET, rtc_info.rtc_century);
|
|
|
|
r = platform_device_register(&xo1_rtc_device);
|
|
if (r)
|
|
return r;
|
|
|
|
x86_platform.legacy.rtc = 0;
|
|
|
|
device_init_wakeup(&xo1_rtc_device.dev, 1);
|
|
return 0;
|
|
}
|
|
arch_initcall(xo1_rtc_init);
|