|
|
1.1 ! root 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: \ read from the rtc and do the bcd-to-bin conversion ! 44: : rtc-bin@ ( offset -- value ) ! 45: rtc@ bcd-to-bin ! 46: ; ! 47: ! 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 ! 50: : .date ( -- ) ! 51: 0 rtc-bin@ ( seconds ) ! 52: 2 rtc-bin@ ! 53: 4 rtc-bin@ ! 54: 7 rtc-bin@ ! 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 ! 59: ;
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.