todc.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:17k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * include/asm-ppc/todc.h
  3.  *
  4.  * Definitions for the M48Txx and mc146818 series of Time of day/Real Time
  5.  * Clock chips.
  6.  *
  7.  * Author: Mark A. Greer
  8.  *         mgreer@mvista.com
  9.  *
  10.  * Copyright 2001 MontaVista Software Inc.
  11.  *
  12.  * This program is free software; you can redistribute  it and/or modify it
  13.  * under  the terms of  the GNU General  Public License as published by the
  14.  * Free Software Foundation;  either version 2 of the  License, or (at your
  15.  * option) any later version.
  16.  */
  17. /*
  18.  * Support for the M48T37/M48T59/.../mc146818 Real Time Clock chips.
  19.  * Purpose is to make one generic file that handles all of these chips instead
  20.  * of every platform implementing the same code over & over again.
  21.  */
  22. #ifndef __PPC_KERNEL_TODC_H
  23. #define __PPC_KERNEL_TODC_H
  24. typedef struct {
  25. uint rtc_type; /* your particular chip */
  26. /*
  27.  * Following are the addresses of the AS0, AS1, and DATA registers
  28.  * of these chips.  Note that these are board-specific.
  29.  */
  30. unsigned char *nvram_as0;
  31. unsigned char *nvram_as1;
  32. unsigned char *nvram_data;
  33. /*
  34.  * Define bits to stop external set of regs from changing so
  35.  * the chip can be read/written reliably.
  36.  */
  37. unsigned char enable_read;
  38. unsigned char enable_write;
  39. /*
  40.  * Following is the number of AS0 address bits.  This is normally
  41.  * 8 but some bad hardware routes address lines incorrectly.
  42.  */
  43. int as0_bits;
  44. int nvram_size; /* Size of NVRAM on chip */
  45. int sw_flags; /* Software control flags */
  46. /* Following are the register offsets for the particular chip */
  47. int year;
  48. int month;
  49. int day_of_month;
  50. int day_of_week;
  51. int hours;
  52. int minutes;
  53. int seconds;
  54. int control_b;
  55. int control_a;
  56. int watchdog;
  57. int interrupts;
  58. int alarm_date;
  59. int alarm_hour;
  60. int alarm_minutes;
  61. int alarm_seconds;
  62. int century;
  63. int flags;
  64. /*
  65.  * Some RTC chips have their NVRAM buried behind a addr/data pair of
  66.  * regs on the first level/clock registers.  The following fields
  67.  * are the addresses for those addr/data regs.
  68.  */
  69. int nvram_addr_reg;
  70. int nvram_data_reg;
  71. } todc_info_t;
  72. /*
  73.  * Define the types of TODC/RTC variants that are supported in
  74.  * arch/ppc/kernel/todc_time.c
  75.  * Make a new one of these for any chip somehow differs from what's already
  76.  * defined.  That way, if you ever need to put in code to touch those
  77.  * bits/registers in todc_time.c, you can put it inside an
  78.  * 'if (todc_info->rtc_type ==  TODC_TYPE_XXX)' so you won't break
  79.  * anyone else.
  80.  */
  81. #define TODC_TYPE_MK48T35 1
  82. #define TODC_TYPE_MK48T37 2
  83. #define TODC_TYPE_MK48T59 3
  84. #define TODC_TYPE_DS1693 4 /* Dallas DS1693 RTC */
  85. #define TODC_TYPE_DS1743 5 /* Dallas DS1743 RTC */
  86. #define TODC_TYPE_DS1746 6 /* Dallas DS1746 RTC */
  87. #define TODC_TYPE_DS1747 7 /* Dallas DS1747 RTC */
  88. #define TODC_TYPE_DS1501 8 /* Dallas DS1501 RTC */
  89. #define TODC_TYPE_DS1643 9 /* Dallas DS1643 RTC */
  90. #define TODC_TYPE_PC97307 10 /* PC97307 internal RTC */
  91. #define TODC_TYPE_DS1557 11 /* Dallas DS1557 RTC */
  92. #define TODC_TYPE_MC146818 100 /* Leave room for m48txx's */
  93. /*
  94.  * Bit to clear/set to enable reads/writes to the chip
  95.  */
  96. #define TODC_MK48TXX_CNTL_A_R 0x40
  97. #define TODC_MK48TXX_CNTL_A_W 0x80
  98. #define TODC_MK48TXX_DAY_CB 0x80
  99. #define TODC_DS1501_CNTL_B_TE 0x80
  100. /*
  101.  * Define flag bits used by todc routines.
  102.  */
  103. #define TODC_FLAG_2_LEVEL_NVRAM 0x00000001
  104. /*
  105.  * Define the values for the various RTC's that should to into the todc_info
  106.  * table.
  107.  * Note: The XXX_NVRAM_SIZE, XXX_NVRAM_ADDR_REG, and XXX_NVRAM_DATA_REG only
  108.  * matter if XXX_SW_FLAGS has TODC_FLAG_2_LEVEL_NVRAM set.
  109.  */
  110. #define TODC_TYPE_MK48T35_NVRAM_SIZE 0x7ff8
  111. #define TODC_TYPE_MK48T35_SW_FLAGS 0
  112. #define TODC_TYPE_MK48T35_YEAR 0x7fff
  113. #define TODC_TYPE_MK48T35_MONTH 0x7ffe
  114. #define TODC_TYPE_MK48T35_DOM 0x7ffd /* Day of Month */
  115. #define TODC_TYPE_MK48T35_DOW 0x7ffc /* Day of Week */
  116. #define TODC_TYPE_MK48T35_HOURS 0x7ffb
  117. #define TODC_TYPE_MK48T35_MINUTES 0x7ffa
  118. #define TODC_TYPE_MK48T35_SECONDS 0x7ff9
  119. #define TODC_TYPE_MK48T35_CNTL_B 0x7ff9
  120. #define TODC_TYPE_MK48T35_CNTL_A 0x7ff8
  121. #define TODC_TYPE_MK48T35_WATCHDOG 0x0000
  122. #define TODC_TYPE_MK48T35_INTERRUPTS 0x0000
  123. #define TODC_TYPE_MK48T35_ALARM_DATE 0x0000
  124. #define TODC_TYPE_MK48T35_ALARM_HOUR 0x0000
  125. #define TODC_TYPE_MK48T35_ALARM_MINUTES 0x0000
  126. #define TODC_TYPE_MK48T35_ALARM_SECONDS 0x0000
  127. #define TODC_TYPE_MK48T35_CENTURY 0x0000
  128. #define TODC_TYPE_MK48T35_FLAGS 0x0000
  129. #define TODC_TYPE_MK48T35_NVRAM_ADDR_REG 0
  130. #define TODC_TYPE_MK48T35_NVRAM_DATA_REG 0
  131. #define TODC_TYPE_MK48T37_NVRAM_SIZE 0x7ff0
  132. #define TODC_TYPE_MK48T37_SW_FLAGS 0
  133. #define TODC_TYPE_MK48T37_YEAR 0x7fff
  134. #define TODC_TYPE_MK48T37_MONTH 0x7ffe
  135. #define TODC_TYPE_MK48T37_DOM 0x7ffd /* Day of Month */
  136. #define TODC_TYPE_MK48T37_DOW 0x7ffc /* Day of Week */
  137. #define TODC_TYPE_MK48T37_HOURS 0x7ffb
  138. #define TODC_TYPE_MK48T37_MINUTES 0x7ffa
  139. #define TODC_TYPE_MK48T37_SECONDS 0x7ff9
  140. #define TODC_TYPE_MK48T37_CNTL_B 0x7ff9
  141. #define TODC_TYPE_MK48T37_CNTL_A 0x7ff8
  142. #define TODC_TYPE_MK48T37_WATCHDOG 0x7ff7
  143. #define TODC_TYPE_MK48T37_INTERRUPTS 0x7ff6
  144. #define TODC_TYPE_MK48T37_ALARM_DATE 0x7ff5
  145. #define TODC_TYPE_MK48T37_ALARM_HOUR 0x7ff4
  146. #define TODC_TYPE_MK48T37_ALARM_MINUTES 0x7ff3
  147. #define TODC_TYPE_MK48T37_ALARM_SECONDS 0x7ff2
  148. #define TODC_TYPE_MK48T37_CENTURY 0x7ff1
  149. #define TODC_TYPE_MK48T37_FLAGS 0x7ff0
  150. #define TODC_TYPE_MK48T37_NVRAM_ADDR_REG 0
  151. #define TODC_TYPE_MK48T37_NVRAM_DATA_REG 0
  152. #define TODC_TYPE_MK48T59_NVRAM_SIZE 0x1ff0
  153. #define TODC_TYPE_MK48T59_SW_FLAGS 0
  154. #define TODC_TYPE_MK48T59_YEAR 0x1fff
  155. #define TODC_TYPE_MK48T59_MONTH 0x1ffe
  156. #define TODC_TYPE_MK48T59_DOM 0x1ffd /* Day of Month */
  157. #define TODC_TYPE_MK48T59_DOW 0x1ffc /* Day of Week */
  158. #define TODC_TYPE_MK48T59_HOURS 0x1ffb
  159. #define TODC_TYPE_MK48T59_MINUTES 0x1ffa
  160. #define TODC_TYPE_MK48T59_SECONDS 0x1ff9
  161. #define TODC_TYPE_MK48T59_CNTL_B 0x1ff9
  162. #define TODC_TYPE_MK48T59_CNTL_A 0x1ff8
  163. #define TODC_TYPE_MK48T59_WATCHDOG 0x1fff
  164. #define TODC_TYPE_MK48T59_INTERRUPTS 0x1fff
  165. #define TODC_TYPE_MK48T59_ALARM_DATE 0x1fff
  166. #define TODC_TYPE_MK48T59_ALARM_HOUR 0x1fff
  167. #define TODC_TYPE_MK48T59_ALARM_MINUTES 0x1fff
  168. #define TODC_TYPE_MK48T59_ALARM_SECONDS 0x1fff
  169. #define TODC_TYPE_MK48T59_CENTURY 0x1fff
  170. #define TODC_TYPE_MK48T59_FLAGS 0x1fff
  171. #define TODC_TYPE_MK48T59_NVRAM_ADDR_REG 0
  172. #define TODC_TYPE_MK48T59_NVRAM_DATA_REG 0
  173. #define TODC_TYPE_DS1501_NVRAM_SIZE 0x100
  174. #define TODC_TYPE_DS1501_SW_FLAGS TODC_FLAG_2_LEVEL_NVRAM
  175. #define TODC_TYPE_DS1501_YEAR (TODC_TYPE_DS1501_NVRAM_SIZE + 0x06)
  176. #define TODC_TYPE_DS1501_MONTH (TODC_TYPE_DS1501_NVRAM_SIZE + 0x05)
  177. #define TODC_TYPE_DS1501_DOM (TODC_TYPE_DS1501_NVRAM_SIZE + 0x04)
  178. #define TODC_TYPE_DS1501_DOW (TODC_TYPE_DS1501_NVRAM_SIZE + 0x03)
  179. #define TODC_TYPE_DS1501_HOURS (TODC_TYPE_DS1501_NVRAM_SIZE + 0x02)
  180. #define TODC_TYPE_DS1501_MINUTES (TODC_TYPE_DS1501_NVRAM_SIZE + 0x01)
  181. #define TODC_TYPE_DS1501_SECONDS (TODC_TYPE_DS1501_NVRAM_SIZE + 0x00)
  182. #define TODC_TYPE_DS1501_CNTL_B (TODC_TYPE_DS1501_NVRAM_SIZE + 0x0f)
  183. #define TODC_TYPE_DS1501_CNTL_A (TODC_TYPE_DS1501_NVRAM_SIZE + 0x0f)
  184. #define TODC_TYPE_DS1501_WATCHDOG (TODC_TYPE_DS1501_NVRAM_SIZE + 0xff)
  185. #define TODC_TYPE_DS1501_INTERRUPTS (TODC_TYPE_DS1501_NVRAM_SIZE + 0xff)
  186. #define TODC_TYPE_DS1501_ALARM_DATE (TODC_TYPE_DS1501_NVRAM_SIZE + 0x0b)
  187. #define TODC_TYPE_DS1501_ALARM_HOUR (TODC_TYPE_DS1501_NVRAM_SIZE + 0x0a)
  188. #define TODC_TYPE_DS1501_ALARM_MINUTES (TODC_TYPE_DS1501_NVRAM_SIZE + 0x09)
  189. #define TODC_TYPE_DS1501_ALARM_SECONDS (TODC_TYPE_DS1501_NVRAM_SIZE + 0x08)
  190. #define TODC_TYPE_DS1501_CENTURY (TODC_TYPE_DS1501_NVRAM_SIZE + 0x07)
  191. #define TODC_TYPE_DS1501_FLAGS (TODC_TYPE_DS1501_NVRAM_SIZE + 0xff)
  192. #define TODC_TYPE_DS1501_NVRAM_ADDR_REG 0x10
  193. #define TODC_TYPE_DS1501_NVRAM_DATA_REG 0x13
  194. #define TODC_TYPE_DS1557_NVRAM_SIZE 0x7fff0
  195. #define TODC_TYPE_DS1557_SW_FLAGS 0
  196. #define TODC_TYPE_DS1557_YEAR 0x7ffff
  197. #define TODC_TYPE_DS1557_MONTH 0x7fffe
  198. #define TODC_TYPE_DS1557_DOM 0x7fffd /* Day of Month */
  199. #define TODC_TYPE_DS1557_DOW 0x7fffc /* Day of Week */
  200. #define TODC_TYPE_DS1557_HOURS 0x7fffb
  201. #define TODC_TYPE_DS1557_MINUTES 0x7fffa
  202. #define TODC_TYPE_DS1557_SECONDS 0x7fff9
  203. #define TODC_TYPE_DS1557_CNTL_B 0x7fff9
  204. #define TODC_TYPE_DS1557_CNTL_A 0x7fff8 /* control_a R/W regs */
  205. #define TODC_TYPE_DS1557_WATCHDOG 0x7fff7
  206. #define TODC_TYPE_DS1557_INTERRUPTS 0x7fff6
  207. #define TODC_TYPE_DS1557_ALARM_DATE 0x7fff5
  208. #define TODC_TYPE_DS1557_ALARM_HOUR 0x7fff4
  209. #define TODC_TYPE_DS1557_ALARM_MINUTES 0x7fff3
  210. #define TODC_TYPE_DS1557_ALARM_SECONDS 0x7fff2
  211. #define TODC_TYPE_DS1557_CENTURY 0x7fff8
  212. #define TODC_TYPE_DS1557_FLAGS 0x7fff0
  213. #define TODC_TYPE_DS1557_NVRAM_ADDR_REG 0
  214. #define TODC_TYPE_DS1557_NVRAM_DATA_REG 0
  215. #define TODC_TYPE_DS1643_NVRAM_SIZE 0x1ff8
  216. #define TODC_TYPE_DS1643_SW_FLAGS 0
  217. #define TODC_TYPE_DS1643_YEAR 0x1fff
  218. #define TODC_TYPE_DS1643_MONTH 0x1ffe
  219. #define TODC_TYPE_DS1643_DOM 0x1ffd /* Day of Month */
  220. #define TODC_TYPE_DS1643_DOW 0x1ffc /* Day of Week */
  221. #define TODC_TYPE_DS1643_HOURS 0x1ffb
  222. #define TODC_TYPE_DS1643_MINUTES 0x1ffa
  223. #define TODC_TYPE_DS1643_SECONDS 0x1ff9
  224. #define TODC_TYPE_DS1643_CNTL_B 0x1ff9
  225. #define TODC_TYPE_DS1643_CNTL_A 0x1ff8 /* control_a R/W regs */
  226. #define TODC_TYPE_DS1643_WATCHDOG 0x1fff
  227. #define TODC_TYPE_DS1643_INTERRUPTS 0x1fff
  228. #define TODC_TYPE_DS1643_ALARM_DATE 0x1fff
  229. #define TODC_TYPE_DS1643_ALARM_HOUR 0x1fff
  230. #define TODC_TYPE_DS1643_ALARM_MINUTES 0x1fff
  231. #define TODC_TYPE_DS1643_ALARM_SECONDS 0x1fff
  232. #define TODC_TYPE_DS1643_CENTURY 0x1ff8
  233. #define TODC_TYPE_DS1643_FLAGS 0x1fff
  234. #define TODC_TYPE_DS1643_NVRAM_ADDR_REG 0
  235. #define TODC_TYPE_DS1643_NVRAM_DATA_REG 0
  236. #define TODC_TYPE_DS1693_NVRAM_SIZE 0 /* Not handled yet */
  237. #define TODC_TYPE_DS1693_SW_FLAGS 0
  238. #define TODC_TYPE_DS1693_YEAR 0x09
  239. #define TODC_TYPE_DS1693_MONTH 0x08
  240. #define TODC_TYPE_DS1693_DOM 0x07 /* Day of Month */
  241. #define TODC_TYPE_DS1693_DOW 0x06 /* Day of Week */
  242. #define TODC_TYPE_DS1693_HOURS 0x04
  243. #define TODC_TYPE_DS1693_MINUTES 0x02
  244. #define TODC_TYPE_DS1693_SECONDS 0x00
  245. #define TODC_TYPE_DS1693_CNTL_B 0x0b
  246. #define TODC_TYPE_DS1693_CNTL_A 0x0a
  247. #define TODC_TYPE_DS1693_WATCHDOG 0xff
  248. #define TODC_TYPE_DS1693_INTERRUPTS 0xff
  249. #define TODC_TYPE_DS1693_ALARM_DATE 0x49
  250. #define TODC_TYPE_DS1693_ALARM_HOUR 0x05
  251. #define TODC_TYPE_DS1693_ALARM_MINUTES 0x03
  252. #define TODC_TYPE_DS1693_ALARM_SECONDS 0x01
  253. #define TODC_TYPE_DS1693_CENTURY 0x48
  254. #define TODC_TYPE_DS1693_FLAGS 0xff
  255. #define TODC_TYPE_DS1693_NVRAM_ADDR_REG 0
  256. #define TODC_TYPE_DS1693_NVRAM_DATA_REG 0
  257. #define TODC_TYPE_DS1743_NVRAM_SIZE 0x1ff8
  258. #define TODC_TYPE_DS1743_SW_FLAGS 0
  259. #define TODC_TYPE_DS1743_YEAR 0x1fff
  260. #define TODC_TYPE_DS1743_MONTH 0x1ffe
  261. #define TODC_TYPE_DS1743_DOM 0x1ffd /* Day of Month */
  262. #define TODC_TYPE_DS1743_DOW 0x1ffc /* Day of Week */
  263. #define TODC_TYPE_DS1743_HOURS 0x1ffb
  264. #define TODC_TYPE_DS1743_MINUTES 0x1ffa
  265. #define TODC_TYPE_DS1743_SECONDS 0x1ff9
  266. #define TODC_TYPE_DS1743_CNTL_B 0x1ff9
  267. #define TODC_TYPE_DS1743_CNTL_A 0x1ff8 /* control_a R/W regs */
  268. #define TODC_TYPE_DS1743_WATCHDOG 0x1fff
  269. #define TODC_TYPE_DS1743_INTERRUPTS 0x1fff
  270. #define TODC_TYPE_DS1743_ALARM_DATE 0x1fff
  271. #define TODC_TYPE_DS1743_ALARM_HOUR 0x1fff
  272. #define TODC_TYPE_DS1743_ALARM_MINUTES 0x1fff
  273. #define TODC_TYPE_DS1743_ALARM_SECONDS 0x1fff
  274. #define TODC_TYPE_DS1743_CENTURY 0x1ff8
  275. #define TODC_TYPE_DS1743_FLAGS 0x1fff
  276. #define TODC_TYPE_DS1743_NVRAM_ADDR_REG 0
  277. #define TODC_TYPE_DS1743_NVRAM_DATA_REG 0
  278. #define TODC_TYPE_DS1746_NVRAM_SIZE 0x1fff8
  279. #define TODC_TYPE_DS1746_SW_FLAGS 0
  280. #define TODC_TYPE_DS1746_YEAR 0x1ffff
  281. #define TODC_TYPE_DS1746_MONTH 0x1fffe
  282. #define TODC_TYPE_DS1746_DOM 0x1fffd /* Day of Month */
  283. #define TODC_TYPE_DS1746_DOW 0x1fffc /* Day of Week */
  284. #define TODC_TYPE_DS1746_HOURS 0x1fffb
  285. #define TODC_TYPE_DS1746_MINUTES 0x1fffa
  286. #define TODC_TYPE_DS1746_SECONDS 0x1fff9
  287. #define TODC_TYPE_DS1746_CNTL_B 0x1fff9
  288. #define TODC_TYPE_DS1746_CNTL_A 0x1fff8 /* control_a R/W regs */
  289. #define TODC_TYPE_DS1746_WATCHDOG 0x00000
  290. #define TODC_TYPE_DS1746_INTERRUPTS 0x00000
  291. #define TODC_TYPE_DS1746_ALARM_DATE 0x00000
  292. #define TODC_TYPE_DS1746_ALARM_HOUR 0x00000
  293. #define TODC_TYPE_DS1746_ALARM_MINUTES 0x00000
  294. #define TODC_TYPE_DS1746_ALARM_SECONDS 0x00000
  295. #define TODC_TYPE_DS1746_CENTURY 0x00000
  296. #define TODC_TYPE_DS1746_FLAGS 0x00000
  297. #define TODC_TYPE_DS1746_NVRAM_ADDR_REG 0
  298. #define TODC_TYPE_DS1746_NVRAM_DATA_REG 0
  299. #define TODC_TYPE_DS1747_NVRAM_SIZE 0x7fff8
  300. #define TODC_TYPE_DS1747_SW_FLAGS 0
  301. #define TODC_TYPE_DS1747_YEAR 0x7ffff
  302. #define TODC_TYPE_DS1747_MONTH 0x7fffe
  303. #define TODC_TYPE_DS1747_DOM 0x7fffd /* Day of Month */
  304. #define TODC_TYPE_DS1747_DOW 0x7fffc /* Day of Week */
  305. #define TODC_TYPE_DS1747_HOURS 0x7fffb
  306. #define TODC_TYPE_DS1747_MINUTES 0x7fffa
  307. #define TODC_TYPE_DS1747_SECONDS 0x7fff9
  308. #define TODC_TYPE_DS1747_CNTL_B 0x7fff9
  309. #define TODC_TYPE_DS1747_CNTL_A 0x7fff8 /* control_a R/W regs */
  310. #define TODC_TYPE_DS1747_WATCHDOG 0x00000
  311. #define TODC_TYPE_DS1747_INTERRUPTS 0x00000
  312. #define TODC_TYPE_DS1747_ALARM_DATE 0x00000
  313. #define TODC_TYPE_DS1747_ALARM_HOUR 0x00000
  314. #define TODC_TYPE_DS1747_ALARM_MINUTES 0x00000
  315. #define TODC_TYPE_DS1747_ALARM_SECONDS 0x00000
  316. #define TODC_TYPE_DS1747_CENTURY 0x00000
  317. #define TODC_TYPE_DS1747_FLAGS 0x00000
  318. #define TODC_TYPE_DS1747_NVRAM_ADDR_REG 0
  319. #define TODC_TYPE_DS1747_NVRAM_DATA_REG 0
  320. #define TODC_TYPE_MC146818_NVRAM_SIZE 0 /* XXXX */
  321. #define TODC_TYPE_MC146818_SW_FLAGS 0
  322. #define TODC_TYPE_MC146818_YEAR 0x09
  323. #define TODC_TYPE_MC146818_MONTH 0x08
  324. #define TODC_TYPE_MC146818_DOM 0x07 /* Day of Month */
  325. #define TODC_TYPE_MC146818_DOW 0x06 /* Day of Week */
  326. #define TODC_TYPE_MC146818_HOURS 0x04
  327. #define TODC_TYPE_MC146818_MINUTES 0x02
  328. #define TODC_TYPE_MC146818_SECONDS 0x00
  329. #define TODC_TYPE_MC146818_CNTL_B 0x0a
  330. #define TODC_TYPE_MC146818_CNTL_A 0x0b /* control_a R/W regs */
  331. #define TODC_TYPE_MC146818_WATCHDOG 0x0c
  332. #define TODC_TYPE_MC146818_INTERRUPTS 0x0d
  333. #define TODC_TYPE_MC146818_ALARM_DATE 0xff
  334. #define TODC_TYPE_MC146818_ALARM_HOUR 0x05
  335. #define TODC_TYPE_MC146818_ALARM_MINUTES 0x03
  336. #define TODC_TYPE_MC146818_ALARM_SECONDS 0x01
  337. #define TODC_TYPE_MC146818_CENTURY 0xff
  338. #define TODC_TYPE_MC146818_FLAGS 0xff
  339. #define TODC_TYPE_MC146818_NVRAM_ADDR_REG 0
  340. #define TODC_TYPE_MC146818_NVRAM_DATA_REG 0
  341. #define TODC_TYPE_PC97307_NVRAM_SIZE 0 /* No NVRAM? */
  342. #define TODC_TYPE_PC97307_SW_FLAGS 0
  343. #define TODC_TYPE_PC97307_YEAR 0x09
  344. #define TODC_TYPE_PC97307_MONTH 0x08
  345. #define TODC_TYPE_PC97307_DOM 0x07 /* Day of Month */
  346. #define TODC_TYPE_PC97307_DOW 0x06 /* Day of Week */
  347. #define TODC_TYPE_PC97307_HOURS 0x04
  348. #define TODC_TYPE_PC97307_MINUTES 0x02
  349. #define TODC_TYPE_PC97307_SECONDS 0x00
  350. #define TODC_TYPE_PC97307_CNTL_B 0x0a
  351. #define TODC_TYPE_PC97307_CNTL_A 0x0b /* control_a R/W regs */
  352. #define TODC_TYPE_PC97307_WATCHDOG 0x0c
  353. #define TODC_TYPE_PC97307_INTERRUPTS 0x0d
  354. #define TODC_TYPE_PC97307_ALARM_DATE 0xff
  355. #define TODC_TYPE_PC97307_ALARM_HOUR 0x05
  356. #define TODC_TYPE_PC97307_ALARM_MINUTES 0x03
  357. #define TODC_TYPE_PC97307_ALARM_SECONDS 0x01
  358. #define TODC_TYPE_PC97307_CENTURY 0xff
  359. #define TODC_TYPE_PC97307_FLAGS 0xff
  360. #define TODC_TYPE_PC97307_NVRAM_ADDR_REG 0
  361. #define TODC_TYPE_PC97307_NVRAM_DATA_REG 0
  362. /*
  363.  * Define macros to allocate and init the todc_info_t table that will
  364.  * be used by the todc_time.c routines.
  365.  */
  366. #define TODC_ALLOC()
  367. static todc_info_t todc_info_alloc;
  368. todc_info_t *todc_info = &todc_info_alloc;
  369. #define TODC_INIT(clock_type, as0, as1, data, bits) {
  370. todc_info->rtc_type = clock_type;
  371. todc_info->nvram_as0  = (unsigned char *)(as0);
  372. todc_info->nvram_as1  = (unsigned char *)(as1);
  373. todc_info->nvram_data = (unsigned char *)(data);
  374. todc_info->as0_bits = (bits);
  375. todc_info->nvram_size     = clock_type ##_NVRAM_SIZE;
  376. todc_info->sw_flags       = clock_type ##_SW_FLAGS;
  377. todc_info->year           = clock_type ##_YEAR;
  378. todc_info->month          = clock_type ##_MONTH;
  379. todc_info->day_of_month   = clock_type ##_DOM;
  380. todc_info->day_of_week    = clock_type ##_DOW;
  381. todc_info->hours          = clock_type ##_HOURS;
  382. todc_info->minutes        = clock_type ##_MINUTES;
  383. todc_info->seconds        = clock_type ##_SECONDS;
  384. todc_info->control_b      = clock_type ##_CNTL_B;
  385. todc_info->control_a      = clock_type ##_CNTL_A;
  386. todc_info->watchdog       = clock_type ##_WATCHDOG;
  387. todc_info->interrupts     = clock_type ##_INTERRUPTS;
  388. todc_info->alarm_date     = clock_type ##_ALARM_DATE;
  389. todc_info->alarm_hour     = clock_type ##_ALARM_HOUR;
  390. todc_info->alarm_minutes  = clock_type ##_ALARM_MINUTES;
  391. todc_info->alarm_seconds  = clock_type ##_ALARM_SECONDS;
  392. todc_info->century        = clock_type ##_CENTURY;
  393. todc_info->flags          = clock_type ##_FLAGS;
  394. todc_info->nvram_addr_reg = clock_type ##_NVRAM_ADDR_REG;
  395. todc_info->nvram_data_reg = clock_type ##_NVRAM_DATA_REG;
  396. }
  397. #ifndef BCD_TO_BIN
  398. #define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
  399. #endif
  400. #ifndef BIN_TO_BCD
  401. #define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10)
  402. #endif
  403. extern todc_info_t *todc_info;
  404. unsigned char todc_direct_read_val(int addr);
  405. void todc_direct_write_val(int addr, unsigned char val);
  406. unsigned char todc_m48txx_read_val(int addr);
  407. void todc_m48txx_write_val(int addr, unsigned char val);
  408. unsigned char todc_mc146818_read_val(int addr);
  409. void todc_mc146818_write_val(int addr, unsigned char val);
  410. long todc_time_init(void);
  411. unsigned long todc_get_rtc_time(void);
  412. int todc_set_rtc_time(unsigned long nowtime);
  413. void todc_calibrate_decr(void);
  414. #endif /* __PPC_KERNEL_TODC_H */