1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/pkg/devices/lib/rtc/src/jz4780.cc Sat May 04 01:31:54 2024 +0200
1.3 @@ -0,0 +1,107 @@
1.4 +/*
1.5 + * Real-time clock support.
1.6 + *
1.7 + * Copyright (C) 2023, 2024 Paul Boddie <paul@boddie.org.uk>
1.8 + *
1.9 + * This program is free software; you can redistribute it and/or
1.10 + * modify it under the terms of the GNU General Public License as
1.11 + * published by the Free Software Foundation; either version 2 of
1.12 + * the License, or (at your option) any later version.
1.13 + *
1.14 + * This program is distributed in the hope that it will be useful,
1.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.17 + * GNU General Public License for more details.
1.18 + *
1.19 + * You should have received a copy of the GNU General Public License
1.20 + * along with this program; if not, write to the Free Software
1.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
1.22 + * Boston, MA 02110-1301, USA
1.23 + */
1.24 +
1.25 +#include "rtc-jz4780.h"
1.26 +#include "rtc-defs.h"
1.27 +
1.28 +
1.29 +
1.30 +// Peripheral abstraction.
1.31 +
1.32 +Rtc_jz4780_chip::Rtc_jz4780_chip(l4_addr_t addr, Cpm_chip *cpm)
1.33 +: Rtc_chip(addr, cpm)
1.34 +{
1.35 +}
1.36 +
1.37 +Rtc_chip *jz4780_rtc_chip(l4_addr_t rtc_base, Cpm_chip *cpm)
1.38 +{
1.39 + return new Rtc_jz4780_chip(rtc_base, cpm);
1.40 +}
1.41 +
1.42 +
1.43 +
1.44 +// C language interface functions.
1.45 +
1.46 +void
1.47 +*jz4780_rtc_init(l4_addr_t rtc_base, void *cpm)
1.48 +{
1.49 + return (void *) jz4780_rtc_chip(rtc_base, static_cast<Cpm_chip *>(cpm));
1.50 +}
1.51 +
1.52 +enum Clock_identifiers jz4780_rtc_get_clock(void *rtc)
1.53 +{
1.54 + return static_cast<Rtc_chip *>(rtc)->get_clock();
1.55 +}
1.56 +
1.57 +void jz4780_rtc_disable(void *rtc)
1.58 +{
1.59 + static_cast<Rtc_chip *>(rtc)->disable();
1.60 +}
1.61 +
1.62 +void jz4780_rtc_enable(void *rtc)
1.63 +{
1.64 + static_cast<Rtc_chip *>(rtc)->enable();
1.65 +}
1.66 +
1.67 +void jz4780_rtc_alarm_disable(void *rtc)
1.68 +{
1.69 + static_cast<Rtc_chip *>(rtc)->alarm_disable();
1.70 +}
1.71 +
1.72 +void jz4780_rtc_alarm_enable(void *rtc)
1.73 +{
1.74 + static_cast<Rtc_chip *>(rtc)->alarm_enable();
1.75 +}
1.76 +
1.77 +uint32_t jz4780_rtc_get_seconds(void *rtc)
1.78 +{
1.79 + return static_cast<Rtc_chip *>(rtc)->get_seconds();
1.80 +}
1.81 +
1.82 +void jz4780_rtc_set_seconds(void *rtc, uint32_t seconds)
1.83 +{
1.84 + static_cast<Rtc_chip *>(rtc)->set_seconds(seconds);
1.85 +}
1.86 +
1.87 +uint32_t jz4780_rtc_get_alarm_seconds(void *rtc)
1.88 +{
1.89 + return static_cast<Rtc_chip *>(rtc)->get_alarm_seconds();
1.90 +}
1.91 +
1.92 +void jz4780_rtc_set_alarm_seconds(void *rtc, uint32_t seconds)
1.93 +{
1.94 + static_cast<Rtc_chip *>(rtc)->set_alarm_seconds(seconds);
1.95 +}
1.96 +
1.97 +void jz4780_rtc_set_regulator(void *rtc, uint32_t base, uint32_t adjustment)
1.98 +{
1.99 + static_cast<Rtc_chip *>(rtc)->set_regulator(base, adjustment);
1.100 +}
1.101 +
1.102 +void jz4780_rtc_hibernate(void *rtc)
1.103 +{
1.104 + static_cast<Rtc_chip *>(rtc)->hibernate();
1.105 +}
1.106 +
1.107 +void jz4780_rtc_power_down(void *rtc)
1.108 +{
1.109 + static_cast<Rtc_chip *>(rtc)->power_down();
1.110 +}