~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/SLOF/board-js2x/slof/rtc.fs

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
8
\ *
 
9
\ * Contributors:
 
10
\ *     IBM Corporation - initial implementation
 
11
\ ****************************************************************************/
 
12
 
 
13
\ National Semiconductor SIO.
 
14
\ See http://www.national.com/pf/PC/PC87417.html for the datasheet.
 
15
\ PC87417.pdf
 
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
 
18
 
 
19
\ Enable the RTC, set its address at 1070
 
20
\ see PC87417.pdf page 39 (chapter 3.2.3)
 
21
10 7 siocfg!
 
22
1 30 siocfg!
 
23
1070 wbsplit nip dup 60 siocfg! 62 siocfg!
 
24
 
 
25
: rtc@  ( offset -- value )
 
26
   1070 io-c! 1071 io-c@
 
27
;
 
28
 
 
29
: rtc!  ( value offset -- )
 
30
   1070 io-c! 1071 io-c!
 
31
;
 
32
 
 
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
 
36
20 0a rtc!
 
37
\ PC87417.pdf page 155 (chapter 8.3.14) - RTC Control Register B
 
38
\ 02 - 24-hour format enabled
 
39
02 0b rtc!
 
40
\ PC87417.pdf page 156 (chapter 8.3.15) - RTC Control Register C
 
41
00 0c rtc!
 
42
 
 
43
: bcd-to-bin  ( bcd -- bin )
 
44
   dup f and swap 4 rshift a * +
 
45
;
 
46
 
 
47
\ read from the rtc and do the bcd-to-bin conversion
 
48
: rtc-bin@  ( offset -- value )
 
49
   rtc@ bcd-to-bin
 
50
;
 
51
 
 
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
 
54
: .date  ( -- )
 
55
   0 rtc-bin@  ( seconds )
 
56
   2 rtc-bin@
 
57
   4 rtc-bin@
 
58
   7 rtc-bin@
 
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
 
63
;