1*d874cce4Sray /* $OpenBSD: clock.h,v 1.2 2008/06/26 05:42:12 ray Exp $ */ 295c7671fSmiod /* $NetBSD: clock.h,v 1.2 2002/04/28 17:10:33 uch Exp $ */ 395c7671fSmiod 495c7671fSmiod /*- 595c7671fSmiod * Copyright (c) 2002 The NetBSD Foundation, Inc. 695c7671fSmiod * All rights reserved. 795c7671fSmiod * 895c7671fSmiod * This code is derived from software contributed to The NetBSD Foundation 995c7671fSmiod * by UCHIYAMA Yasushi. 1095c7671fSmiod * 1195c7671fSmiod * Redistribution and use in source and binary forms, with or without 1295c7671fSmiod * modification, are permitted provided that the following conditions 1395c7671fSmiod * are met: 1495c7671fSmiod * 1. Redistributions of source code must retain the above copyright 1595c7671fSmiod * notice, this list of conditions and the following disclaimer. 1695c7671fSmiod * 2. Redistributions in binary form must reproduce the above copyright 1795c7671fSmiod * notice, this list of conditions and the following disclaimer in the 1895c7671fSmiod * documentation and/or other materials provided with the distribution. 1995c7671fSmiod * 2095c7671fSmiod * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 2195c7671fSmiod * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2295c7671fSmiod * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2395c7671fSmiod * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2495c7671fSmiod * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2595c7671fSmiod * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2695c7671fSmiod * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2795c7671fSmiod * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2895c7671fSmiod * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2995c7671fSmiod * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3095c7671fSmiod * POSSIBILITY OF SUCH DAMAGE. 3195c7671fSmiod */ 3295c7671fSmiod 3395c7671fSmiod /* 3495c7671fSmiod * void sh_clock_init(int flags, struct rtc_ops *): 3595c7671fSmiod * flags: 3695c7671fSmiod * SH_CLOCK_NORTC ... If SH RTC module is disabled, set this. 3795c7671fSmiod * internal module don't use RTCCLK. 3895c7671fSmiod * SH_CLOCK_NOINITTODR ... Don't initialize RTC time. 3995c7671fSmiod * rtc_ops: 4095c7671fSmiod * Machine dependent RTC ops pointer. If NULL is specified, use SH 4195c7671fSmiod * internal RTC. 4295c7671fSmiod * 4395c7671fSmiod * void machine_clock_init(void): 4495c7671fSmiod * Implement machine specific part of clock routines. 4595c7671fSmiod * must call sh_clock_init() at exit. 4695c7671fSmiod * 4795c7671fSmiod * int sh_clock_get_cpuclock(void): 4895c7671fSmiod * returns CPU clock estimated by sh_clock_init(). 4995c7671fSmiod * 5095c7671fSmiod * int sh_clock_get_pclock(void): 5195c7671fSmiod * returns PCLOCK. when PCLOCK is not specified by kernel configuration 5295c7671fSmiod * file, this value is estimated by sh_clock_init(). 5395c7671fSmiod * 5495c7671fSmiod */ 5595c7671fSmiod struct rtc_ops; 5695c7671fSmiod struct clock_ymdhms; 5795c7671fSmiod 5895c7671fSmiod void sh_clock_init(int, struct rtc_ops *); 5995c7671fSmiod #define SH_CLOCK_NORTC 0x00000001 6095c7671fSmiod #define SH_CLOCK_NOINITTODR 0x00000002 6195c7671fSmiod void machine_clock_init(void); 6295c7671fSmiod 6395c7671fSmiod int sh_clock_get_cpuclock(void); 6495c7671fSmiod int sh_clock_get_pclock(void); 6595c7671fSmiod 6695c7671fSmiod /* 6795c7671fSmiod * SH RTC module interface. 6895c7671fSmiod */ 6995c7671fSmiod void sh_rtc_init(void *); 7095c7671fSmiod void sh_rtc_get(void *, time_t, struct clock_ymdhms *); 7195c7671fSmiod void sh_rtc_set(void *, struct clock_ymdhms *); 7295c7671fSmiod 7395c7671fSmiod /* 7495c7671fSmiod * machine specific RTC ops 7595c7671fSmiod */ 7695c7671fSmiod struct clock_ymdhms; 7795c7671fSmiod struct rtc_ops { 7895c7671fSmiod void *_cookie; 7995c7671fSmiod void (*init)(void *); 8095c7671fSmiod void (*get)(void *, time_t, struct clock_ymdhms *); 8195c7671fSmiod void (*set)(void *, struct clock_ymdhms *); 8295c7671fSmiod }; 8395c7671fSmiod 84