Path: blob/master/arch/x86/platform/olpc/olpc-xo1-rtc.c
26489 views
// SPDX-License-Identifier: GPL-2.0-or-later1/*2* Support for OLPC XO-1 Real Time Clock (RTC)3*4* Copyright (C) 2011 One Laptop per Child5*/67#include <linux/mc146818rtc.h>8#include <linux/platform_device.h>9#include <linux/rtc.h>10#include <linux/of.h>1112#include <asm/msr.h>13#include <asm/olpc.h>14#include <asm/x86_init.h>1516static void rtc_wake_on(struct device *dev)17{18olpc_xo1_pm_wakeup_set(CS5536_PM_RTC);19}2021static void rtc_wake_off(struct device *dev)22{23olpc_xo1_pm_wakeup_clear(CS5536_PM_RTC);24}2526static struct resource rtc_platform_resource[] = {27[0] = {28.start = RTC_PORT(0),29.end = RTC_PORT(1),30.flags = IORESOURCE_IO,31},32[1] = {33.start = RTC_IRQ,34.end = RTC_IRQ,35.flags = IORESOURCE_IRQ,36}37};3839static struct cmos_rtc_board_info rtc_info = {40.rtc_day_alarm = 0,41.rtc_mon_alarm = 0,42.rtc_century = 0,43.wake_on = rtc_wake_on,44.wake_off = rtc_wake_off,45};4647static struct platform_device xo1_rtc_device = {48.name = "rtc_cmos",49.id = -1,50.num_resources = ARRAY_SIZE(rtc_platform_resource),51.dev.platform_data = &rtc_info,52.resource = rtc_platform_resource,53};5455static int __init xo1_rtc_init(void)56{57int r;58struct device_node *node;5960node = of_find_compatible_node(NULL, NULL, "olpc,xo1-rtc");61if (!node)62return 0;63of_node_put(node);6465pr_info("olpc-xo1-rtc: Initializing OLPC XO-1 RTC\n");66rdmsrq(MSR_RTC_DOMA_OFFSET, rtc_info.rtc_day_alarm);67rdmsrq(MSR_RTC_MONA_OFFSET, rtc_info.rtc_mon_alarm);68rdmsrq(MSR_RTC_CEN_OFFSET, rtc_info.rtc_century);6970r = platform_device_register(&xo1_rtc_device);71if (r)72return r;7374x86_platform.legacy.rtc = 0;7576device_init_wakeup(&xo1_rtc_device.dev, 1);77return 0;78}79arch_initcall(xo1_rtc_init);808182