setup enviroment for compilation
[linux-2.4.21-pre4.git] / Documentation / powerpc / todc.txt
1         Documentation for arch/ppc/kernel/todc_time.c
2         =============================================
3
4 Author: Mark A. Greer (mgreer@mvista.com)
5 Date:   3.5.2001
6
7 Last Change: 7.20.2001
8
9 arch/ppc/kernel/todc_time.c supports the mk48txx and mc146818 family of
10 Time-of-Day (todc)/RealTime Clocks (rtc).  Its intent is to replace most or all
11 of the *_time.c files in arch/ppc/kernel that have very similar code.
12
13 To hook into the routines of this file, do the following:
14
15 - Add '#include "todc.h"' to your *_setup.c file.
16 - Add a line similar to 'TODC_ALLOC();' outside of the scope of any routine.
17 - Add a line similar to 'TODC_INIT(TODC_TYPE_MK48T37, as0, as1, data, bits)'
18   where 'as0' is the nvram as0 address, 'as1' is the nvram as1 address,
19   'data' is the TODC chip's data register address, and 'bits' is the number of
20   address bits used by the as0 register (rest are used by as1).
21 - Set 'ppc_md.time_init', 'ppc_md.set_rtc_time', and 'ppc_md.get_rtc_time' to
22   'todc_time_init', 'todc_set_rtc_time', and 'todc_get_rtc_time', respectively.
23 - If you want to use the TODC to calibrate you decrementer, set
24   'ppc_md.calibrate_decr' to 'todc_calibrate_decr'.
25
26 There are 3 sets of pre-defined todc access register routines:
27 - 'todc_direct_read_val' and 'todc_direct_write_val' for direct access
28   (e.g., mk48txx whose NVRAM & TODC/RTC registers are directly mapped into the
29   physical address space of the processor);
30 - 'todc_m48txx_read_val' and 'todc_m48txx_write_val' for an mk48txx whose NVRAM
31   & TODC/RTC registers are accessed via address strobe & data registers;
32 - 'todc_mc146818_read_val' and 'todc_mc146818_write_val' for mc146818 RTC whose
33   registers are accessed via an address/data registers pair.
34
35 To use one of these sets of access routines, set 'ppc_md.nvram_read_val' and
36 'ppc_md.nvram_write_val' to the appropriate values for your TODC and board
37 combination.
38
39 For an example using a mk48txx, look at arch/ppc/kernel/mcpn765_setup.c;
40 for an example using a mc146818, look at arch/ppc/kernel/sandpoint_setup.c.
41
42 If your board doesn't have a full 8 bits wired to AS0, you can change the
43 'as0_bits' in the 'todc_info_t' structure.  See arch/ppc/kernel/menf1_setup.c
44 for an example.
45
46 Adding support for other closely related TODC chips should be easy.  To do so,
47 you simply add the appropriate macros to arch/ppc/kernel/todc.h.
48
49 If you encounter problems, please email me at mgreer@mvista.com