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