1 /* 2 * Real-time clock support. 3 * 4 * Copyright (C) 2023, 2024 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA 20 */ 21 22 #include "rtc-jz4780.h" 23 #include "rtc-defs.h" 24 25 26 27 // Peripheral abstraction. 28 29 Rtc_jz4780_chip::Rtc_jz4780_chip(l4_addr_t addr, Cpm_chip *cpm) 30 : Rtc_chip(addr, cpm) 31 { 32 } 33 34 Rtc_chip *jz4780_rtc_chip(l4_addr_t rtc_base, Cpm_chip *cpm) 35 { 36 return new Rtc_jz4780_chip(rtc_base, cpm); 37 } 38 39 40 41 // C language interface functions. 42 43 void 44 *jz4780_rtc_init(l4_addr_t rtc_base, void *cpm) 45 { 46 return (void *) jz4780_rtc_chip(rtc_base, static_cast<Cpm_chip *>(cpm)); 47 } 48 49 enum Clock_identifiers jz4780_rtc_get_clock(void *rtc) 50 { 51 return static_cast<Rtc_chip *>(rtc)->get_clock(); 52 } 53 54 void jz4780_rtc_disable(void *rtc) 55 { 56 static_cast<Rtc_chip *>(rtc)->disable(); 57 } 58 59 void jz4780_rtc_enable(void *rtc) 60 { 61 static_cast<Rtc_chip *>(rtc)->enable(); 62 } 63 64 void jz4780_rtc_alarm_disable(void *rtc) 65 { 66 static_cast<Rtc_chip *>(rtc)->alarm_disable(); 67 } 68 69 void jz4780_rtc_alarm_enable(void *rtc) 70 { 71 static_cast<Rtc_chip *>(rtc)->alarm_enable(); 72 } 73 74 uint32_t jz4780_rtc_get_seconds(void *rtc) 75 { 76 return static_cast<Rtc_chip *>(rtc)->get_seconds(); 77 } 78 79 void jz4780_rtc_set_seconds(void *rtc, uint32_t seconds) 80 { 81 static_cast<Rtc_chip *>(rtc)->set_seconds(seconds); 82 } 83 84 uint32_t jz4780_rtc_get_alarm_seconds(void *rtc) 85 { 86 return static_cast<Rtc_chip *>(rtc)->get_alarm_seconds(); 87 } 88 89 void jz4780_rtc_set_alarm_seconds(void *rtc, uint32_t seconds) 90 { 91 static_cast<Rtc_chip *>(rtc)->set_alarm_seconds(seconds); 92 } 93 94 void jz4780_rtc_set_regulator(void *rtc, uint32_t base, uint32_t adjustment) 95 { 96 static_cast<Rtc_chip *>(rtc)->set_regulator(base, adjustment); 97 } 98 99 void jz4780_rtc_hibernate(void *rtc) 100 { 101 static_cast<Rtc_chip *>(rtc)->hibernate(); 102 } 103 104 void jz4780_rtc_power_down(void *rtc) 105 { 106 static_cast<Rtc_chip *>(rtc)->power_down(); 107 }