misc.c 16 KB

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