1
\ *****************************************************************************
2
\ * Copyright (c) 2004, 2008 IBM Corporation
3
\ * All rights reserved.
4
\ * This program and the accompanying materials
5
\ * are made available under the terms of the BSD License
6
\ * which accompanies this distribution, and is available at
7
\ * http://www.opensource.org/licenses/bsd-license.php
10
\ * IBM Corporation - initial implementation
11
\ ****************************************************************************/
13
\ National Semiconductor SIO.
14
\ See http://www.national.com/pf/PC/PC87417.html for the datasheet.
16
\ moved the RTC initialisation from the device tree to a much earlier point
17
\ so that the RTC can be accessed before device tree is generated
19
\ Enable the RTC, set its address at 1070
20
\ see PC87417.pdf page 39 (chapter 3.2.3)
23
1070 wbsplit nip dup 60 siocfg! 62 siocfg!
25
: rtc@ ( offset -- value )
29
: rtc! ( value offset -- )
33
\ Set sane configuration; BCD mode is required by Linux.
34
\ PC87417.pdf page 153 (chapter 8.3.13) - RTC Control Register A
35
\ 20 - Divider Chain Control = Normal Operation
37
\ PC87417.pdf page 155 (chapter 8.3.14) - RTC Control Register B
38
\ 02 - 24-hour format enabled
40
\ PC87417.pdf page 156 (chapter 8.3.15) - RTC Control Register C
43
: bcd-to-bin ( bcd -- bin )
44
dup f and swap 4 rshift a * +
47
\ read from the rtc and do the bcd-to-bin conversion
48
: rtc-bin@ ( offset -- value )
52
\ to be compatible with the cell boards we provide a .date word
53
\ .date prints the current date and time on the firmware prompt
55
0 rtc-bin@ ( seconds )
59
8 rtc-bin@ ( seconds minutes hours day month )
60
9 rtc-bin@ d# 1900 + dup d# 1970 < IF d# 100 + THEN
61
decimal 4 0.r 2d emit 2 0.r 2d emit 2 0.r space
62
2 0.r 3a emit 2 0.r 3a emit 2 0.r hex