Lines Matching +full:offset +full:- +full:y
1 // SPDX-License-Identifier: GPL-2.0
3 * Miscellaneous Mac68K-specific stuff
30 * Offset between Unix time (1970-based) and Mac time (1904-based). Cuda and PMU
32 * need to be changed to interpret wrapped times as post-2040.
53 return time - RTC_OFFSET; in cuda_read_time()
69 static __u8 cuda_read_pram(int offset) in cuda_read_pram() argument
74 (offset >> 8) & 0xFF, offset & 0xFF) < 0) in cuda_read_pram()
81 static void cuda_write_pram(int offset, __u8 data) in cuda_write_pram() argument
86 (offset >> 8) & 0xFF, offset & 0xFF, data) < 0) in cuda_write_pram()
106 return time - RTC_OFFSET; in pmu_read_time()
121 static __u8 pmu_read_pram(int offset) in pmu_read_pram() argument
126 (offset >> 8) & 0xFF, offset & 0xFF) < 0) in pmu_read_pram()
133 static void pmu_write_pram(int offset, __u8 data) in pmu_write_pram() argument
138 (offset >> 8) & 0xFF, offset & 0xFF, data) < 0) in pmu_write_pram()
197 * data should point to a one-byte buffer for the
215 if (command & 0xFF00) { /* extended (two-byte) command */ in via_pram_command()
219 } else { /* one-byte command */ in via_pram_command()
236 static __u8 via_read_pram(int offset) in via_read_pram() argument
241 static void via_write_pram(int offset, __u8 data) in via_write_pram() argument
248 * This only works on machines with the VIA-based PRAM/RTC, which
249 * is basically any machine with Mac II-style ADB.
277 return (time64_t)result.idata - RTC_OFFSET; in via_read_time()
294 * This only works on machines with the VIA-based PRAM/RTC, which
295 * is basically any machine with Mac II-style ADB.
338 oss->rom_ctrl = OSS_POWEROFF; in oss_shutdown()
360 switch (macintosh_config->ident) { in cuda_shutdown()
375 *-------------------------------------------------------------------
378 *-------------------------------------------------------------------
381 void mac_pram_read(int offset, __u8 *buffer, int len) in mac_pram_read() argument
386 switch (macintosh_config->adb_type) { in mac_pram_read()
407 buffer[i] = (*func)(offset++); in mac_pram_read()
411 void mac_pram_write(int offset, __u8 *buffer, int len) in mac_pram_write() argument
416 switch (macintosh_config->adb_type) { in mac_pram_write()
437 (*func)(offset++, buffer[i]); in mac_pram_write()
445 } else if (macintosh_config->adb_type == MAC_ADB_II) { in mac_poweroff()
448 } else if (macintosh_config->adb_type == MAC_ADB_EGRET || in mac_poweroff()
449 macintosh_config->adb_type == MAC_ADB_CUDA) { in mac_poweroff()
453 } else if (macintosh_config->adb_type == MAC_ADB_PB2) { in mac_poweroff()
465 if (macintosh_config->adb_type == MAC_ADB_II) { in mac_reset()
477 if (macintosh_config->ident == MAC_MODEL_SE30) { in mac_reset()
489 } else if (macintosh_config->adb_type == MAC_ADB_EGRET || in mac_reset()
490 macintosh_config->adb_type == MAC_ADB_CUDA) { in mac_reset()
494 } else if (macintosh_config->adb_type == MAC_ADB_PB2) { in mac_reset()
499 /* 030-specific reset routine. The idea is general, but the in mac_reset()
500 * specific registers to reset are '030-specific. Until I in mac_reset()
501 * have a non-030 machine, I can't test anything else. in mac_reset()
502 * -- C. Scott Ananian <cananian@alumni.princeton.edu> in mac_reset()
507 /* make a 1-to-1 mapping, using the transparent tran. reg. */ in mac_reset()
511 unsigned long offset = phys-virt; in mac_reset() local
545 : : "r" (offset), "a" (rombase) : "a0"); in mac_reset()
566 static void unmktime(time64_t time, long offset, in unmktime() argument
570 /* How many days come before each month (0-12). */ in unmktime()
578 int days, rem, y, wday, yday; in unmktime() local
582 rem += offset; in unmktime()
585 --days; in unmktime()
588 rem -= SECS_PER_DAY; in unmktime()
598 y = 1970; in unmktime()
600 #define DIV(a, b) ((a) / (b) - ((a) % (b) < 0)) in unmktime()
601 #define LEAPS_THRU_END_OF(y) (DIV (y, 4) - DIV (y, 100) + DIV (y, 400)) in unmktime() argument
605 while (days < 0 || days >= (__isleap (y) ? 366 : 365)) in unmktime()
608 long int yg = y + days / 365 - (days % 365 < 0); in unmktime()
610 /* Adjust DAYS and Y to match the guessed year. */ in unmktime()
611 days -= (yg - y) * 365 + in unmktime()
612 LEAPS_THRU_END_OF(yg - 1) - LEAPS_THRU_END_OF(y - 1); in unmktime()
613 y = yg; in unmktime()
615 *yearp = y - 1900; in unmktime()
617 ip = __mon_yday[__isleap(y)]; in unmktime()
618 for (y = 11; days < (long int) ip[y]; --y) in unmktime()
620 days -= ip[y]; in unmktime()
621 *monp = y; in unmktime()
635 switch (macintosh_config->adb_type) { in mac_hwclk()
656 t->tm_wday = 0; in mac_hwclk()
658 &t->tm_year, &t->tm_mon, &t->tm_mday, in mac_hwclk()
659 &t->tm_hour, &t->tm_min, &t->tm_sec); in mac_hwclk()
660 pr_debug("%s: read %04d-%02d-%-2d %02d:%02d:%02d\n", in mac_hwclk()
661 __func__, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, in mac_hwclk()
662 t->tm_hour, t->tm_min, t->tm_sec); in mac_hwclk()
664 pr_debug("%s: tried to write %04d-%02d-%-2d %02d:%02d:%02d\n", in mac_hwclk()
665 __func__, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, in mac_hwclk()
666 t->tm_hour, t->tm_min, t->tm_sec); in mac_hwclk()
668 now = mktime64(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, in mac_hwclk()
669 t->tm_hour, t->tm_min, t->tm_sec); in mac_hwclk()
671 switch (macintosh_config->adb_type) { in mac_hwclk()
689 return -ENODEV; in mac_hwclk()