misc.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. /*
  2. * Miscellaneous Mac68K-specific stuff
  3. */
  4. #include <linux/types.h>
  5. #include <linux/errno.h>
  6. #include <linux/kernel.h>
  7. #include <linux/delay.h>
  8. #include <linux/sched.h>
  9. #include <linux/time.h>
  10. #include <linux/rtc.h>
  11. #include <linux/mm.h>
  12. #include <linux/adb.h>
  13. #include <linux/cuda.h>
  14. #include <linux/pmu.h>
  15. #include <linux/uaccess.h>
  16. #include <asm/io.h>
  17. #include <asm/segment.h>
  18. #include <asm/setup.h>
  19. #include <asm/macintosh.h>
  20. #include <asm/mac_via.h>
  21. #include <asm/mac_oss.h>
  22. #include <asm/machdep.h>
  23. /* Offset between Unix time (1970-based) and Mac time (1904-based) */
  24. #define RTC_OFFSET 2082844800
  25. static void (*rom_reset)(void);
  26. #ifdef CONFIG_ADB_CUDA
  27. static long cuda_read_time(void)
  28. {
  29. struct adb_request req;
  30. long time;
  31. if (cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_GET_TIME) < 0)
  32. return 0;
  33. while (!req.complete)
  34. cuda_poll();
  35. time = (req.reply[3] << 24) | (req.reply[4] << 16)
  36. | (req.reply[5] << 8) | req.reply[6];
  37. return time - RTC_OFFSET;
  38. }
  39. static void cuda_write_time(long data)
  40. {
  41. struct adb_request req;
  42. data += RTC_OFFSET;
  43. if (cuda_request(&req, NULL, 6, CUDA_PACKET, CUDA_SET_TIME,
  44. (data >> 24) & 0xFF, (data >> 16) & 0xFF,
  45. (data >> 8) & 0xFF, data & 0xFF) < 0)
  46. return;
  47. while (!req.complete)
  48. cuda_poll();
  49. }
  50. static __u8 cuda_read_pram(int offset)
  51. {
  52. struct adb_request req;
  53. if (cuda_request(&req, NULL, 4, CUDA_PACKET, CUDA_GET_PRAM,
  54. (offset >> 8) & 0xFF, offset & 0xFF) < 0)
  55. return 0;
  56. while (!req.complete)
  57. cuda_poll();
  58. return req.reply[3];
  59. }
  60. static void cuda_write_pram(int offset, __u8 data)
  61. {
  62. struct adb_request req;
  63. if (cuda_request(&req, NULL, 5, CUDA_PACKET, CUDA_SET_PRAM,
  64. (offset >> 8) & 0xFF, offset & 0xFF, data) < 0)
  65. return;
  66. while (!req.complete)
  67. cuda_poll();
  68. }
  69. #else
  70. #define cuda_read_time() 0
  71. #define cuda_write_time(n)
  72. #define cuda_read_pram NULL
  73. #define cuda_write_pram NULL
  74. #endif
  75. #ifdef CONFIG_ADB_PMU68K
  76. static long pmu_read_time(void)
  77. {
  78. struct adb_request req;
  79. long time;
  80. if (pmu_request(&req, NULL, 1, PMU_READ_RTC) < 0)
  81. return 0;
  82. while (!req.complete)
  83. pmu_poll();
  84. time = (req.reply[1] << 24) | (req.reply[2] << 16)
  85. | (req.reply[3] << 8) | req.reply[4];
  86. return time - RTC_OFFSET;
  87. }
  88. static void pmu_write_time(long data)
  89. {
  90. struct adb_request req;
  91. data += RTC_OFFSET;
  92. if (pmu_request(&req, NULL, 5, PMU_SET_RTC,
  93. (data >> 24) & 0xFF, (data >> 16) & 0xFF,
  94. (data >> 8) & 0xFF, data & 0xFF) < 0)
  95. return;
  96. while (!req.complete)
  97. pmu_poll();
  98. }
  99. static __u8 pmu_read_pram(int offset)
  100. {
  101. struct adb_request req;
  102. if (pmu_request(&req, NULL, 3, PMU_READ_NVRAM,
  103. (offset >> 8) & 0xFF, offset & 0xFF) < 0)
  104. return 0;
  105. while (!req.complete)
  106. pmu_poll();
  107. return req.reply[3];
  108. }
  109. static void pmu_write_pram(int offset, __u8 data)
  110. {
  111. struct adb_request req;
  112. if (pmu_request(&req, NULL, 4, PMU_WRITE_NVRAM,
  113. (offset >> 8) & 0xFF, offset & 0xFF, data) < 0)
  114. return;
  115. while (!req.complete)
  116. pmu_poll();
  117. }
  118. #else
  119. #define pmu_read_time() 0
  120. #define pmu_write_time(n)
  121. #define pmu_read_pram NULL
  122. #define pmu_write_pram NULL
  123. #endif
  124. /*
  125. * VIA PRAM/RTC access routines
  126. *
  127. * Must be called with interrupts disabled and
  128. * the RTC should be enabled.
  129. */
  130. static __u8 via_pram_readbyte(void)
  131. {
  132. int i,reg;
  133. __u8 data;
  134. reg = via1[vBufB] & ~VIA1B_vRTCClk;
  135. /* Set the RTC data line to be an input. */
  136. via1[vDirB] &= ~VIA1B_vRTCData;
  137. /* The bits of the byte come out in MSB order */
  138. data = 0;
  139. for (i = 0 ; i < 8 ; i++) {
  140. via1[vBufB] = reg;
  141. via1[vBufB] = reg | VIA1B_vRTCClk;
  142. data = (data << 1) | (via1[vBufB] & VIA1B_vRTCData);
  143. }
  144. /* Return RTC data line to output state */
  145. via1[vDirB] |= VIA1B_vRTCData;
  146. return data;
  147. }
  148. static void via_pram_writebyte(__u8 data)
  149. {
  150. int i,reg,bit;
  151. reg = via1[vBufB] & ~(VIA1B_vRTCClk | VIA1B_vRTCData);
  152. /* The bits of the byte go in in MSB order */
  153. for (i = 0 ; i < 8 ; i++) {
  154. bit = data & 0x80? 1 : 0;
  155. data <<= 1;
  156. via1[vBufB] = reg | bit;
  157. via1[vBufB] = reg | bit | VIA1B_vRTCClk;
  158. }
  159. }
  160. /*
  161. * Execute a VIA PRAM/RTC command. For read commands
  162. * data should point to a one-byte buffer for the
  163. * resulting data. For write commands it should point
  164. * to the data byte to for the command.
  165. *
  166. * This function disables all interrupts while running.
  167. */
  168. static void via_pram_command(int command, __u8 *data)
  169. {
  170. unsigned long flags;
  171. int is_read;
  172. local_irq_save(flags);
  173. /* Enable the RTC and make sure the strobe line is high */
  174. via1[vBufB] = (via1[vBufB] | VIA1B_vRTCClk) & ~VIA1B_vRTCEnb;
  175. if (command & 0xFF00) { /* extended (two-byte) command */
  176. via_pram_writebyte((command & 0xFF00) >> 8);
  177. via_pram_writebyte(command & 0xFF);
  178. is_read = command & 0x8000;
  179. } else { /* one-byte command */
  180. via_pram_writebyte(command);
  181. is_read = command & 0x80;
  182. }
  183. if (is_read) {
  184. *data = via_pram_readbyte();
  185. } else {
  186. via_pram_writebyte(*data);
  187. }
  188. /* All done, disable the RTC */
  189. via1[vBufB] |= VIA1B_vRTCEnb;
  190. local_irq_restore(flags);
  191. }
  192. static __u8 via_read_pram(int offset)
  193. {
  194. return 0;
  195. }
  196. static void via_write_pram(int offset, __u8 data)
  197. {
  198. }
  199. /*
  200. * Return the current time in seconds since January 1, 1904.
  201. *
  202. * This only works on machines with the VIA-based PRAM/RTC, which
  203. * is basically any machine with Mac II-style ADB.
  204. */
  205. static long via_read_time(void)
  206. {
  207. union {
  208. __u8 cdata[4];
  209. long idata;
  210. } result, last_result;
  211. int count = 1;
  212. via_pram_command(0x81, &last_result.cdata[3]);
  213. via_pram_command(0x85, &last_result.cdata[2]);
  214. via_pram_command(0x89, &last_result.cdata[1]);
  215. via_pram_command(0x8D, &last_result.cdata[0]);
  216. /*
  217. * The NetBSD guys say to loop until you get the same reading
  218. * twice in a row.
  219. */
  220. while (1) {
  221. via_pram_command(0x81, &result.cdata[3]);
  222. via_pram_command(0x85, &result.cdata[2]);
  223. via_pram_command(0x89, &result.cdata[1]);
  224. via_pram_command(0x8D, &result.cdata[0]);
  225. if (result.idata == last_result.idata)
  226. return result.idata - RTC_OFFSET;
  227. if (++count > 10)
  228. break;
  229. last_result.idata = result.idata;
  230. }
  231. pr_err("via_read_time: failed to read a stable value; "
  232. "got 0x%08lx then 0x%08lx\n",
  233. last_result.idata, result.idata);
  234. return 0;
  235. }
  236. /*
  237. * Set the current time to a number of seconds since January 1, 1904.
  238. *
  239. * This only works on machines with the VIA-based PRAM/RTC, which
  240. * is basically any machine with Mac II-style ADB.
  241. */
  242. static void via_write_time(long time)
  243. {
  244. union {
  245. __u8 cdata[4];
  246. long idata;
  247. } data;
  248. __u8 temp;
  249. /* Clear the write protect bit */
  250. temp = 0x55;
  251. via_pram_command(0x35, &temp);
  252. data.idata = time + RTC_OFFSET;
  253. via_pram_command(0x01, &data.cdata[3]);
  254. via_pram_command(0x05, &data.cdata[2]);
  255. via_pram_command(0x09, &data.cdata[1]);
  256. via_pram_command(0x0D, &data.cdata[0]);
  257. /* Set the write protect bit */
  258. temp = 0xD5;
  259. via_pram_command(0x35, &temp);
  260. }
  261. static void via_shutdown(void)
  262. {
  263. if (rbv_present) {
  264. via2[rBufB] &= ~0x04;
  265. } else {
  266. /* Direction of vDirB is output */
  267. via2[vDirB] |= 0x04;
  268. /* Send a value of 0 on that line */
  269. via2[vBufB] &= ~0x04;
  270. mdelay(1000);
  271. }
  272. }
  273. /*
  274. * FIXME: not sure how this is supposed to work exactly...
  275. */
  276. static void oss_shutdown(void)
  277. {
  278. oss->rom_ctrl = OSS_POWEROFF;
  279. }
  280. #ifdef CONFIG_ADB_CUDA
  281. static void cuda_restart(void)
  282. {
  283. struct adb_request req;
  284. if (cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_RESET_SYSTEM) < 0)
  285. return;
  286. while (!req.complete)
  287. cuda_poll();
  288. }
  289. static void cuda_shutdown(void)
  290. {
  291. struct adb_request req;
  292. if (cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_POWERDOWN) < 0)
  293. return;
  294. while (!req.complete)
  295. cuda_poll();
  296. }
  297. #endif /* CONFIG_ADB_CUDA */
  298. #ifdef CONFIG_ADB_PMU68K
  299. void pmu_restart(void)
  300. {
  301. struct adb_request req;
  302. if (pmu_request(&req, NULL,
  303. 2, PMU_SET_INTR_MASK, PMU_INT_ADB|PMU_INT_TICK) < 0)
  304. return;
  305. while (!req.complete)
  306. pmu_poll();
  307. if (pmu_request(&req, NULL, 1, PMU_RESET) < 0)
  308. return;
  309. while (!req.complete)
  310. pmu_poll();
  311. }
  312. void pmu_shutdown(void)
  313. {
  314. struct adb_request req;
  315. if (pmu_request(&req, NULL,
  316. 2, PMU_SET_INTR_MASK, PMU_INT_ADB|PMU_INT_TICK) < 0)
  317. return;
  318. while (!req.complete)
  319. pmu_poll();
  320. if (pmu_request(&req, NULL, 5, PMU_SHUTDOWN, 'M', 'A', 'T', 'T') < 0)
  321. return;
  322. while (!req.complete)
  323. pmu_poll();
  324. }
  325. #endif
  326. /*
  327. *-------------------------------------------------------------------
  328. * Below this point are the generic routines; they'll dispatch to the
  329. * correct routine for the hardware on which we're running.
  330. *-------------------------------------------------------------------
  331. */
  332. void mac_pram_read(int offset, __u8 *buffer, int len)
  333. {
  334. __u8 (*func)(int);
  335. int i;
  336. switch(macintosh_config->adb_type) {
  337. case MAC_ADB_PB1:
  338. case MAC_ADB_PB2:
  339. func = pmu_read_pram; break;
  340. case MAC_ADB_EGRET:
  341. case MAC_ADB_CUDA:
  342. func = cuda_read_pram; break;
  343. default:
  344. func = via_read_pram;
  345. }
  346. if (!func)
  347. return;
  348. for (i = 0 ; i < len ; i++) {
  349. buffer[i] = (*func)(offset++);
  350. }
  351. }
  352. void mac_pram_write(int offset, __u8 *buffer, int len)
  353. {
  354. void (*func)(int, __u8);
  355. int i;
  356. switch(macintosh_config->adb_type) {
  357. case MAC_ADB_PB1:
  358. case MAC_ADB_PB2:
  359. func = pmu_write_pram; break;
  360. case MAC_ADB_EGRET:
  361. case MAC_ADB_CUDA:
  362. func = cuda_write_pram; break;
  363. default:
  364. func = via_write_pram;
  365. }
  366. if (!func)
  367. return;
  368. for (i = 0 ; i < len ; i++) {
  369. (*func)(offset++, buffer[i]);
  370. }
  371. }
  372. void mac_poweroff(void)
  373. {
  374. if (oss_present) {
  375. oss_shutdown();
  376. } else if (macintosh_config->adb_type == MAC_ADB_II) {
  377. via_shutdown();
  378. #ifdef CONFIG_ADB_CUDA
  379. } else if (macintosh_config->adb_type == MAC_ADB_EGRET ||
  380. macintosh_config->adb_type == MAC_ADB_CUDA) {
  381. cuda_shutdown();
  382. #endif
  383. #ifdef CONFIG_ADB_PMU68K
  384. } else if (macintosh_config->adb_type == MAC_ADB_PB1
  385. || macintosh_config->adb_type == MAC_ADB_PB2) {
  386. pmu_shutdown();
  387. #endif
  388. }
  389. local_irq_enable();
  390. printk("It is now safe to turn off your Macintosh.\n");
  391. while(1);
  392. }
  393. void mac_reset(void)
  394. {
  395. if (macintosh_config->adb_type == MAC_ADB_II) {
  396. unsigned long flags;
  397. /* need ROMBASE in booter */
  398. /* indeed, plus need to MAP THE ROM !! */
  399. if (mac_bi_data.rombase == 0)
  400. mac_bi_data.rombase = 0x40800000;
  401. /* works on some */
  402. rom_reset = (void *) (mac_bi_data.rombase + 0xa);
  403. if (macintosh_config->ident == MAC_MODEL_SE30) {
  404. /*
  405. * MSch: Machines known to crash on ROM reset ...
  406. */
  407. } else {
  408. local_irq_save(flags);
  409. rom_reset();
  410. local_irq_restore(flags);
  411. }
  412. #ifdef CONFIG_ADB_CUDA
  413. } else if (macintosh_config->adb_type == MAC_ADB_EGRET ||
  414. macintosh_config->adb_type == MAC_ADB_CUDA) {
  415. cuda_restart();
  416. #endif
  417. #ifdef CONFIG_ADB_PMU68K
  418. } else if (macintosh_config->adb_type == MAC_ADB_PB1
  419. || macintosh_config->adb_type == MAC_ADB_PB2) {
  420. pmu_restart();
  421. #endif
  422. } else if (CPU_IS_030) {
  423. /* 030-specific reset routine. The idea is general, but the
  424. * specific registers to reset are '030-specific. Until I
  425. * have a non-030 machine, I can't test anything else.
  426. * -- C. Scott Ananian <cananian@alumni.princeton.edu>
  427. */
  428. unsigned long rombase = 0x40000000;
  429. /* make a 1-to-1 mapping, using the transparent tran. reg. */
  430. unsigned long virt = (unsigned long) mac_reset;
  431. unsigned long phys = virt_to_phys(mac_reset);
  432. unsigned long addr = (phys&0xFF000000)|0x8777;
  433. unsigned long offset = phys-virt;
  434. local_irq_disable(); /* lets not screw this up, ok? */
  435. __asm__ __volatile__(".chip 68030\n\t"
  436. "pmove %0,%/tt0\n\t"
  437. ".chip 68k"
  438. : : "m" (addr));
  439. /* Now jump to physical address so we can disable MMU */
  440. __asm__ __volatile__(
  441. ".chip 68030\n\t"
  442. "lea %/pc@(1f),%/a0\n\t"
  443. "addl %0,%/a0\n\t"/* fixup target address and stack ptr */
  444. "addl %0,%/sp\n\t"
  445. "pflusha\n\t"
  446. "jmp %/a0@\n\t" /* jump into physical memory */
  447. "0:.long 0\n\t" /* a constant zero. */
  448. /* OK. Now reset everything and jump to reset vector. */
  449. "1:\n\t"
  450. "lea %/pc@(0b),%/a0\n\t"
  451. "pmove %/a0@, %/tc\n\t" /* disable mmu */
  452. "pmove %/a0@, %/tt0\n\t" /* disable tt0 */
  453. "pmove %/a0@, %/tt1\n\t" /* disable tt1 */
  454. "movel #0, %/a0\n\t"
  455. "movec %/a0, %/vbr\n\t" /* clear vector base register */
  456. "movec %/a0, %/cacr\n\t" /* disable caches */
  457. "movel #0x0808,%/a0\n\t"
  458. "movec %/a0, %/cacr\n\t" /* flush i&d caches */
  459. "movew #0x2700,%/sr\n\t" /* set up status register */
  460. "movel %1@(0x0),%/a0\n\t"/* load interrupt stack pointer */
  461. "movec %/a0, %/isp\n\t"
  462. "movel %1@(0x4),%/a0\n\t" /* load reset vector */
  463. "reset\n\t" /* reset external devices */
  464. "jmp %/a0@\n\t" /* jump to the reset vector */
  465. ".chip 68k"
  466. : : "r" (offset), "a" (rombase) : "a0");
  467. }
  468. /* should never get here */
  469. local_irq_enable();
  470. printk ("Restart failed. Please restart manually.\n");
  471. while(1);
  472. }
  473. /*
  474. * This function translates seconds since 1970 into a proper date.
  475. *
  476. * Algorithm cribbed from glibc2.1, __offtime().
  477. */
  478. #define SECS_PER_MINUTE (60)
  479. #define SECS_PER_HOUR (SECS_PER_MINUTE * 60)
  480. #define SECS_PER_DAY (SECS_PER_HOUR * 24)
  481. static void unmktime(unsigned long time, long offset,
  482. int *yearp, int *monp, int *dayp,
  483. int *hourp, int *minp, int *secp)
  484. {
  485. /* How many days come before each month (0-12). */
  486. static const unsigned short int __mon_yday[2][13] =
  487. {
  488. /* Normal years. */
  489. { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
  490. /* Leap years. */
  491. { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
  492. };
  493. long int days, rem, y, wday, yday;
  494. const unsigned short int *ip;
  495. days = time / SECS_PER_DAY;
  496. rem = time % SECS_PER_DAY;
  497. rem += offset;
  498. while (rem < 0) {
  499. rem += SECS_PER_DAY;
  500. --days;
  501. }
  502. while (rem >= SECS_PER_DAY) {
  503. rem -= SECS_PER_DAY;
  504. ++days;
  505. }
  506. *hourp = rem / SECS_PER_HOUR;
  507. rem %= SECS_PER_HOUR;
  508. *minp = rem / SECS_PER_MINUTE;
  509. *secp = rem % SECS_PER_MINUTE;
  510. /* January 1, 1970 was a Thursday. */
  511. wday = (4 + days) % 7; /* Day in the week. Not currently used */
  512. if (wday < 0) wday += 7;
  513. y = 1970;
  514. #define DIV(a, b) ((a) / (b) - ((a) % (b) < 0))
  515. #define LEAPS_THRU_END_OF(y) (DIV (y, 4) - DIV (y, 100) + DIV (y, 400))
  516. #define __isleap(year) \
  517. ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
  518. while (days < 0 || days >= (__isleap (y) ? 366 : 365))
  519. {
  520. /* Guess a corrected year, assuming 365 days per year. */
  521. long int yg = y + days / 365 - (days % 365 < 0);
  522. /* Adjust DAYS and Y to match the guessed year. */
  523. days -= ((yg - y) * 365
  524. + LEAPS_THRU_END_OF (yg - 1)
  525. - LEAPS_THRU_END_OF (y - 1));
  526. y = yg;
  527. }
  528. *yearp = y - 1900;
  529. yday = days; /* day in the year. Not currently used. */
  530. ip = __mon_yday[__isleap(y)];
  531. for (y = 11; days < (long int) ip[y]; --y)
  532. continue;
  533. days -= ip[y];
  534. *monp = y;
  535. *dayp = days + 1; /* day in the month */
  536. return;
  537. }
  538. /*
  539. * Read/write the hardware clock.
  540. */
  541. int mac_hwclk(int op, struct rtc_time *t)
  542. {
  543. unsigned long now;
  544. if (!op) { /* read */
  545. switch (macintosh_config->adb_type) {
  546. case MAC_ADB_II:
  547. case MAC_ADB_IOP:
  548. now = via_read_time();
  549. break;
  550. case MAC_ADB_PB1:
  551. case MAC_ADB_PB2:
  552. now = pmu_read_time();
  553. break;
  554. case MAC_ADB_EGRET:
  555. case MAC_ADB_CUDA:
  556. now = cuda_read_time();
  557. break;
  558. default:
  559. now = 0;
  560. }
  561. t->tm_wday = 0;
  562. unmktime(now, 0,
  563. &t->tm_year, &t->tm_mon, &t->tm_mday,
  564. &t->tm_hour, &t->tm_min, &t->tm_sec);
  565. #if 0
  566. printk("mac_hwclk: read %04d-%02d-%-2d %02d:%02d:%02d\n",
  567. t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
  568. t->tm_hour, t->tm_min, t->tm_sec);
  569. #endif
  570. } else { /* write */
  571. #if 0
  572. printk("mac_hwclk: tried to write %04d-%02d-%-2d %02d:%02d:%02d\n",
  573. t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
  574. t->tm_hour, t->tm_min, t->tm_sec);
  575. #endif
  576. now = mktime(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
  577. t->tm_hour, t->tm_min, t->tm_sec);
  578. switch (macintosh_config->adb_type) {
  579. case MAC_ADB_II:
  580. case MAC_ADB_IOP:
  581. via_write_time(now);
  582. break;
  583. case MAC_ADB_EGRET:
  584. case MAC_ADB_CUDA:
  585. cuda_write_time(now);
  586. break;
  587. case MAC_ADB_PB1:
  588. case MAC_ADB_PB2:
  589. pmu_write_time(now);
  590. break;
  591. }
  592. }
  593. return 0;
  594. }
  595. /*
  596. * Set minutes/seconds in the hardware clock
  597. */
  598. int mac_set_clock_mmss (unsigned long nowtime)
  599. {
  600. struct rtc_time now;
  601. mac_hwclk(0, &now);
  602. now.tm_sec = nowtime % 60;
  603. now.tm_min = (nowtime / 60) % 60;
  604. mac_hwclk(1, &now);
  605. return 0;
  606. }