blob: 1794395da96ab72c6786a136947d45eff8154874 [file] [log] [blame]
Rohit Vaswani8f709c02013-02-13 15:49:56 -08001/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13#ifndef _WALLCLK_H
14#define _WALLCLK_H
15
16/* wallclock register offset */
17#define CTRL_REG_OFFSET 0x0
18#define PULSE_CNT_REG_OFFSET 0x4
19#define CLK_CNT_SNAPSHOT_REG_OFFSET 0x8
20#define CLK_CNT_REG_OFFSET 0xC
21#define CLK_BASE_TIME0_OFFSET 0x24
22#define CLK_BASE_TIME1_OFFSET 0x28
23
24/* ctrl register bitmap */
25#define CTRL_TIME_SRC_POS 0
26#define CTRL_TIME_SRC_MASK 0x0000000F
27#define CTRL_SW_BITS_POS 4
28#define CTRL_SW_BITS_MASK 0x7FFFFFF0
29#define CTRL_ENA_DIS_POS 31
30#define CTRL_ENABLE_MASK 0x80000000
31
32/* clock rate from time source */
33#define CLK_RATE 122880000 /* 122.88 Mhz */
34#define PPNS_PULSE 2 /* PP2S */
35
36#define MAX_SFN 1023
37#define SFN_PER_SECOND 100
38
39extern int wallclk_set_sfn(u16 sfn);
40extern int wallclk_get_sfn(void);
41extern int wallclk_set_sfn_ref(u16 sfn);
42extern int wallclk_get_sfn_ref(void);
43extern int wallclk_reg_read(u32 offset, u32 *p);
44extern int wallclk_reg_write(u32 offset, u32 value);
45
46#endif /* _WALLCLK_H */