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 \ read from the rtc and do the bcd-to-bin conversion
44 : rtc-bin@ ( offset -- value )
48 \ to be compatible with the cell boards we provide a .date word
49 \ .date prints the current date and time on the firmware prompt
51 0 rtc-bin@ ( seconds )
55 8 rtc-bin@ ( seconds minutes hours day month )
56 9 rtc-bin@ d# 1900 + dup d# 1970 < IF d# 100 + THEN
57 decimal 4 0.r 2d emit 2 0.r 2d emit 2 0.r space
58 2 0.r 3a emit 2 0.r 3a emit 2 0.r hex