/* * Samsung exynos4210 Real Time Clock * * Copyright (c) 2012 Samsung Electronics Co., Ltd. * Ogurtsov Oleg * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, see . * */ /* Description: * Register RTCCON: * CLKSEL Bit[1] not used * CLKOUTEN Bit[9] not used */ #include "qemu/osdep.h" #include "hw/sysbus.h" #include "qemu/timer.h" #include "qemu-common.h" #include "qemu/bcd.h" #include "hw/ptimer.h" #include "hw/hw.h" #include "sysemu/sysemu.h" #include "hw/arm/exynos4210.h" #define DEBUG_RTC 0 #if DEBUG_RTC #define DPRINTF(fmt, ...) \ do { fprintf(stdout, "RTC: [%24s:%5d] " fmt, __func__, __LINE__, \ ## __VA_ARGS__); } while (0) #else #define DPRINTF(fmt, ...) do {} while (0) #endif #define EXYNOS4210_RTC_REG_MEM_SIZE 0x0100 #define INTP 0x0030 #define RTCCON 0x0040 #define TICCNT 0x0044 #define RTCALM 0x0050 #define ALMSEC 0x0054 #define ALMMIN 0x0058 #define ALMHOUR 0x005C #define ALMDAY 0x0060 #define ALMMON 0x0064 #define ALMYEAR 0x0068 #define BCDSEC 0x0070 #define BCDMIN 0x0074 #define BCDHOUR 0x0078 #define BCDDAY 0x007C #define BCDDAYWEEK 0x0080 #define BCDMON 0x0084 #define BCDYEAR 0x0088 #define CURTICNT 0x0090 #define TICK_TIMER_ENABLE 0x0100 #define TICNT_THRESHOLD 2 #define RTC_ENABLE 0x0001 #define INTP_TICK_ENABLE 0x0001 #define INTP_ALM_ENABLE 0x0002 #define ALARM_INT_ENABLE 0x0040 #define RTC_BASE_FREQ 32768 #define TYPE_EXYNOS4210_RTC "exynos4210.rtc" #define EXYNOS4210_RTC(obj) \ OBJECT_CHECK(Exynos4210RTCState, (obj), TYPE_EXYNOS4210_RTC) typedef struct Exynos4210RTCState { SysBusDevice parent_obj; MemoryRegion iomem; /* registers */ uint32_t reg_intp; uint32_t reg_rtccon; uint32_t reg_ticcnt; uint32_t reg_rtcalm; uint32_t reg_almsec; uint32_t reg_almmin; uint32_t reg_almhour; uint32_t reg_almday; uint32_t reg_almmon; uint32_t reg_almyear; uint32_t reg_curticcnt; ptimer_state *ptimer; /* tick timer */ ptimer_state *ptimer_1Hz; /* clock timer */ uint32_t freq; qemu_irq tick_irq; /* Time Tick Generator irq */ qemu_irq alm_irq; /* alarm irq */ struct tm current_tm; /* current time */ } Exynos4210RTCState; #define TICCKSEL(value) ((value & (0x0F << 4)) >> 4) /*** VMState ***/ static const VMStateDescription vmstate_exynos4210_rtc_state = { .name = "exynos4210.rtc", .version_id = 1, .minimum_version_id = 1, .fields = (VMStateField[]) { VMSTATE_UINT32(reg_intp, Exynos4210RTCState), VMSTATE_UINT32(reg_rtccon, Exynos4210RTCState), VMSTATE_UINT32(reg_ticcnt, Exynos4210RTCState), VMSTATE_UINT32(reg_rtcalm, Exynos4210RTCState), VMSTATE_UINT32(reg_almsec, Exynos4210RTCState), VMSTATE_UINT32(reg_almmin, Exynos4210RTCState), VMSTATE_UINT32(reg_almhour, Exynos4210RTCState), VMSTATE_UINT32(reg_almday, Exynos4210RTCState), VMSTATE_UINT32(reg_almmon, Exynos4210RTCState), VMSTATE_UINT32(reg_almyear, Exynos4210RTCState), VMSTATE_UINT32(reg_curticcnt, Exynos4210RTCState), VMSTATE_PTIMER(ptimer, Exynos4210RTCState), VMSTATE_PTIMER(ptimer_1Hz, Exynos4210RTCState), VMSTATE_UINT32(freq, Exynos4210RTCState), VMSTATE_INT32(current_tm.tm_sec, Exynos4210RTCState), VMSTATE_INT32(current_tm.tm_min, Exynos4210RTCState), VMSTATE_INT32(current_tm.tm_hour, Exynos4210RTCState), VMSTATE_INT32(current_tm.tm_wday, Exynos4210RTCState), VMSTATE_INT32(current_tm.tm_mday, Exynos4210RTCState), VMSTATE_INT32(current_tm.tm_mon, Exynos4210RTCState), VMSTATE_INT32(current_tm.tm_year, Exynos4210RTCState), VMSTATE_END_OF_LIST() } }; #define BCD3DIGITS(x) \
# Copyright 2017 Spirent Communications.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Wrapper for Collectd as a collector
"""
c_ops, s, "exynos4210-rtc", EXYNOS4210_RTC_REG_MEM_SIZE); sysbus_init_mmio(dev, &s->iomem); } static void exynos4210_rtc_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); dc->reset = exynos4210_rtc_reset; dc->vmsd = &vmstate_exynos4210_rtc_state; } static const TypeInfo exynos4210_rtc_info = { .name = TYPE_EXYNOS4210_RTC, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(Exynos4210RTCState), .instance_init = exynos4210_rtc_init, .class_init = exynos4210_rtc_class_init, }; static void exynos4210_rtc_register_types(void) { type_register_static(&exynos4210_rtc_info); } type_init(exynos4210_rtc_register_types)