macintosh: Use common code to access RTC
Now that the 68k Mac port has adopted the via-pmu driver, the same RTC
code can be shared between m68k and powerpc. Replace duplicated code in
arch/powerpc and arch/m68k with common RTC accessors for Cuda and PMU.
Drop the problematic WARN_ON which was introduced in commit 22db552b50
("powerpc/powermac: Fix rtc read/write functions").
Tested-by: Stan Johnson <userm57@yahoo.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
This commit is contained in:

committed by
Michael Ellerman

parent
053c5a753e
commit
0792a2c8e0
@@ -766,3 +766,38 @@ cuda_input(unsigned char *buf, int nb)
|
||||
buf, nb, false);
|
||||
}
|
||||
}
|
||||
|
||||
/* Offset between Unix time (1970-based) and Mac time (1904-based) */
|
||||
#define RTC_OFFSET 2082844800
|
||||
|
||||
time64_t cuda_get_time(void)
|
||||
{
|
||||
struct adb_request req;
|
||||
u32 now;
|
||||
|
||||
if (cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_GET_TIME) < 0)
|
||||
return 0;
|
||||
while (!req.complete)
|
||||
cuda_poll();
|
||||
if (req.reply_len != 7)
|
||||
pr_err("%s: got %d byte reply\n", __func__, req.reply_len);
|
||||
now = (req.reply[3] << 24) + (req.reply[4] << 16) +
|
||||
(req.reply[5] << 8) + req.reply[6];
|
||||
return (time64_t)now - RTC_OFFSET;
|
||||
}
|
||||
|
||||
int cuda_set_rtc_time(struct rtc_time *tm)
|
||||
{
|
||||
u32 now;
|
||||
struct adb_request req;
|
||||
|
||||
now = lower_32_bits(rtc_tm_to_time64(tm) + RTC_OFFSET);
|
||||
if (cuda_request(&req, NULL, 6, CUDA_PACKET, CUDA_SET_TIME,
|
||||
now >> 24, now >> 16, now >> 8, now) < 0)
|
||||
return -ENXIO;
|
||||
while (!req.complete)
|
||||
cuda_poll();
|
||||
if ((req.reply_len != 3) && (req.reply_len != 7))
|
||||
pr_err("%s: got %d byte reply\n", __func__, req.reply_len);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user