1 // SPDX-License-Identifier: GPL-2.0
3 * RTC subsystem, proc interface
5 * Copyright (C) 2005-06 Tower Technologies
6 * Author: Alessandro Zummo <a.zummo@towertech.it>
8 * based on arch/arm/common/rtctime.c
11 #include <linux/module.h>
12 #include <linux/rtc.h>
13 #include <linux/proc_fs.h>
14 #include <linux/seq_file.h>
20 #if defined(CONFIG_RTC_HCTOSYS_DEVICE)
21 static bool is_rtc_hctosys(struct rtc_device *rtc)
26 size = snprintf(name, NAME_SIZE, "rtc%d", rtc->id);
27 if (size >= NAME_SIZE)
30 return !strncmp(name, CONFIG_RTC_HCTOSYS_DEVICE, NAME_SIZE);
33 static bool is_rtc_hctosys(struct rtc_device *rtc)
35 return (rtc->id == 0);
39 static int rtc_proc_show(struct seq_file *seq, void *offset)
42 struct rtc_device *rtc = seq->private;
43 const struct rtc_class_ops *ops = rtc->ops;
44 struct rtc_wkalrm alrm;
47 err = rtc_read_time(rtc, &tm);
51 "rtc_date\t: %ptRd\n",
55 err = rtc_read_alarm(rtc, &alrm);
57 seq_printf(seq, "alrm_time\t: %ptRt\n", &alrm.time);
58 seq_printf(seq, "alrm_date\t: %ptRd\n", &alrm.time);
59 seq_printf(seq, "alarm_IRQ\t: %s\n",
60 alrm.enabled ? "yes" : "no");
61 seq_printf(seq, "alrm_pending\t: %s\n",
62 alrm.pending ? "yes" : "no");
63 seq_printf(seq, "update IRQ enabled\t: %s\n",
64 (rtc->uie_rtctimer.enabled) ? "yes" : "no");
65 seq_printf(seq, "periodic IRQ enabled\t: %s\n",
66 (rtc->pie_enabled) ? "yes" : "no");
67 seq_printf(seq, "periodic IRQ frequency\t: %d\n",
69 seq_printf(seq, "max user IRQ frequency\t: %d\n",
73 seq_printf(seq, "24hr\t\t: yes\n");
76 ops->proc(rtc->dev.parent, seq);
81 void rtc_proc_add_device(struct rtc_device *rtc)
83 if (is_rtc_hctosys(rtc))
84 proc_create_single_data("driver/rtc", 0, NULL, rtc_proc_show,
88 void rtc_proc_del_device(struct rtc_device *rtc)
90 if (is_rtc_hctosys(rtc))
91 remove_proc_entry("driver/rtc", NULL);