1 /* 2 * RTC (real-time clock) support for the X1600. 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 #pragma once 23 24 #include <l4/sys/types.h> 25 #include <stdint.h> 26 27 28 29 #ifdef __cplusplus 30 31 #include <l4/devices/rtc-generic.h> 32 33 class Rtc_x1600_chip : public Rtc_chip 34 { 35 protected: 36 void _pre_power_down(); 37 38 public: 39 explicit Rtc_x1600_chip(l4_addr_t addr, Cpm_chip *cpm = NULL); 40 }; 41 42 Rtc_chip *x1600_rtc_chip(l4_addr_t rtc_base, Cpm_chip *cpm); 43 44 #endif /* __cplusplus */ 45 46 47 48 /* C language interface. */ 49 50 EXTERN_C_BEGIN 51 52 void *x1600_rtc_init(l4_addr_t rtc_base, void *cpm); 53 54 enum Clock_identifiers x1600_rtc_get_clock(void *rtc); 55 56 void x1600_rtc_disable(void *rtc); 57 58 void x1600_rtc_enable(void *rtc); 59 60 void x1600_rtc_alarm_disable(void *rtc); 61 62 void x1600_rtc_alarm_enable(void *rtc); 63 64 void x1600_rtc_wakeup_alarm_disable(void *rtc); 65 66 void x1600_rtc_wakeup_alarm_enable(void *rtc); 67 68 uint32_t x1600_rtc_get_seconds(void *rtc); 69 70 void x1600_rtc_set_seconds(void *rtc, uint32_t seconds); 71 72 uint32_t x1600_rtc_get_alarm_seconds(void *rtc); 73 74 void x1600_rtc_set_alarm_seconds(void *rtc, uint32_t seconds); 75 76 void x1600_rtc_set_regulator(void *rtc, uint32_t base, uint32_t adjustment); 77 78 void x1600_rtc_hibernate(void *rtc); 79 80 void x1600_rtc_power_down(void *rtc); 81 82 EXTERN_C_END