aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68k
diff options
context:
space:
mode:
authorAl Viro <viro@ftp.linux.org.uk>2006-01-12 04:06:13 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-12 12:09:00 -0500
commit3272244c2b1a8f13cec83c04b8245fa7fcb47a27 (patch)
treedd6db1d885d98ac5f945d676961b3e267ed31440 /arch/m68k
parentb4290a23cfa9040e2f0de5ab57d6ea65abaf053b (diff)
[PATCH] m68k: switch mac/misc.c to direct use of appropriate cuda/pmu/maciisi requests
kill ADBREQ_RAW use, replace adb_read_time(), etc. with per-type variants, eliminated remapping from pmu ones, fix the ifdefs (PMU->PMU68K) Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Cc: Roman Zippel <zippel@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/m68k')
-rw-r--r--arch/m68k/mac/misc.c323
1 files changed, 218 insertions, 105 deletions
diff --git a/arch/m68k/mac/misc.c b/arch/m68k/mac/misc.c
index 5b80d7cd954a..99dd2c1e9f44 100644
--- a/arch/m68k/mac/misc.c
+++ b/arch/m68k/mac/misc.c
@@ -39,72 +39,163 @@
39extern struct mac_booter_data mac_bi_data; 39extern struct mac_booter_data mac_bi_data;
40static void (*rom_reset)(void); 40static void (*rom_reset)(void);
41 41
42#ifdef CONFIG_ADB 42#ifdef CONFIG_ADB_CUDA
43/* 43static long cuda_read_time(void)
44 * Return the current time as the number of seconds since January 1, 1904.
45 */
46
47static long adb_read_time(void)
48{ 44{
49 volatile struct adb_request req; 45 struct adb_request req;
50 long time; 46 long time;
51 47
52 adb_request((struct adb_request *) &req, NULL, 48 if (cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_GET_TIME) < 0)
53 ADBREQ_RAW|ADBREQ_SYNC, 49 return 0;
54 2, CUDA_PACKET, CUDA_GET_TIME); 50 while (!req.complete)
51 cuda_poll();
55 52
56 time = (req.reply[3] << 24) | (req.reply[4] << 16) 53 time = (req.reply[3] << 24) | (req.reply[4] << 16)
57 | (req.reply[5] << 8) | req.reply[6]; 54 | (req.reply[5] << 8) | req.reply[6];
58 return time - RTC_OFFSET; 55 return time - RTC_OFFSET;
59} 56}
60 57
61/* 58static void cuda_write_time(long data)
62 * Set the current system time 59{
63 */ 60 struct adb_request req;
61 data += RTC_OFFSET;
62 if (cuda_request(&req, NULL, 6, CUDA_PACKET, CUDA_SET_TIME,
63 (data >> 24) & 0xFF, (data >> 16) & 0xFF,
64 (data >> 8) & 0xFF, data & 0xFF) < 0)
65 return;
66 while (!req.complete)
67 cuda_poll();
68}
64 69
65static void adb_write_time(long data) 70static __u8 cuda_read_pram(int offset)
66{ 71{
67 volatile struct adb_request req; 72 struct adb_request req;
73 if (cuda_request(&req, NULL, 4, CUDA_PACKET, CUDA_GET_PRAM,
74 (offset >> 8) & 0xFF, offset & 0xFF) < 0)
75 return 0;
76 while (!req.complete)
77 cuda_poll();
78 return req.reply[3];
79}
68 80
69 data += RTC_OFFSET; 81static void cuda_write_pram(int offset, __u8 data)
82{
83 struct adb_request req;
84 if (cuda_request(&req, NULL, 5, CUDA_PACKET, CUDA_SET_PRAM,
85 (offset >> 8) & 0xFF, offset & 0xFF, data) < 0)
86 return;
87 while (!req.complete)
88 cuda_poll();
89}
90#else
91#define cuda_read_time() 0
92#define cuda_write_time(n)
93#define cuda_read_pram NULL
94#define cuda_write_pram NULL
95#endif
96
97#ifdef CONFIG_ADB_PMU68K
98static long pmu_read_time(void)
99{
100 struct adb_request req;
101 long time;
102
103 if (pmu_request(&req, NULL, 1, PMU_READ_RTC) < 0)
104 return 0;
105 while (!req.complete)
106 pmu_poll();
70 107
71 adb_request((struct adb_request *) &req, NULL, 108 time = (req.reply[0] << 24) | (req.reply[1] << 16)
72 ADBREQ_RAW|ADBREQ_SYNC, 109 | (req.reply[2] << 8) | req.reply[3];
73 6, CUDA_PACKET, CUDA_SET_TIME, 110 return time - RTC_OFFSET;
111}
112
113static void pmu_write_time(long data)
114{
115 struct adb_request req;
116 data += RTC_OFFSET;
117 if (pmu_request(&req, NULL, 5, PMU_SET_RTC,
74 (data >> 24) & 0xFF, (data >> 16) & 0xFF, 118 (data >> 24) & 0xFF, (data >> 16) & 0xFF,
75 (data >> 8) & 0xFF, data & 0xFF); 119 (data >> 8) & 0xFF, data & 0xFF) < 0)
120 return;
121 while (!req.complete)
122 pmu_poll();
76} 123}
77 124
78/* 125static __u8 pmu_read_pram(int offset)
79 * Get a byte from the NVRAM 126{
80 */ 127 struct adb_request req;
128 if (pmu_request(&req, NULL, 3, PMU_READ_NVRAM,
129 (offset >> 8) & 0xFF, offset & 0xFF) < 0)
130 return 0;
131 while (!req.complete)
132 pmu_poll();
133 return req.reply[3];
134}
81 135
82static __u8 adb_read_pram(int offset) 136static void pmu_write_pram(int offset, __u8 data)
83{ 137{
84 volatile struct adb_request req; 138 struct adb_request req;
139 if (pmu_request(&req, NULL, 4, PMU_WRITE_NVRAM,
140 (offset >> 8) & 0xFF, offset & 0xFF, data) < 0)
141 return;
142 while (!req.complete)
143 pmu_poll();
144}
145#else
146#define pmu_read_time() 0
147#define pmu_write_time(n)
148#define pmu_read_pram NULL
149#define pmu_write_pram NULL
150#endif
85 151
86 adb_request((struct adb_request *) &req, NULL, 152#ifdef CONFIG_ADB_MACIISI
87 ADBREQ_RAW|ADBREQ_SYNC, 153extern int maciisi_request(struct adb_request *req,
88 4, CUDA_PACKET, CUDA_GET_PRAM, 154 void (*done)(struct adb_request *), int nbytes, ...);
89 (offset >> 8) & 0xFF, offset & 0xFF); 155
90 return req.reply[3]; 156static long maciisi_read_time(void)
157{
158 struct adb_request req;
159 long time;
160
161 if (maciisi_request(&req, NULL, 2, CUDA_PACKET, CUDA_GET_TIME))
162 return 0;
163
164 time = (req.reply[3] << 24) | (req.reply[4] << 16)
165 | (req.reply[5] << 8) | req.reply[6];
166 return time - RTC_OFFSET;
91} 167}
92 168
93/* 169static void maciisi_write_time(long data)
94 * Write a byte to the NVRAM 170{
95 */ 171 struct adb_request req;
172 data += RTC_OFFSET;
173 maciisi_request(&req, NULL, 6, CUDA_PACKET, CUDA_SET_TIME,
174 (data >> 24) & 0xFF, (data >> 16) & 0xFF,
175 (data >> 8) & 0xFF, data & 0xFF);
176}
96 177
97static void adb_write_pram(int offset, __u8 data) 178static __u8 maciisi_read_pram(int offset)
98{ 179{
99 volatile struct adb_request req; 180 struct adb_request req;
181 if (maciisi_request(&req, NULL, 4, CUDA_PACKET, CUDA_GET_PRAM,
182 (offset >> 8) & 0xFF, offset & 0xFF))
183 return 0;
184 return req.reply[3];
185}
100 186
101 adb_request((struct adb_request *) &req, NULL, 187static void maciisi_write_pram(int offset, __u8 data)
102 ADBREQ_RAW|ADBREQ_SYNC, 188{
103 5, CUDA_PACKET, CUDA_SET_PRAM, 189 struct adb_request req;
104 (offset >> 8) & 0xFF, offset & 0xFF, 190 maciisi_request(&req, NULL, 5, CUDA_PACKET, CUDA_SET_PRAM,
105 data); 191 (offset >> 8) & 0xFF, offset & 0xFF, data);
106} 192}
107#endif /* CONFIG_ADB */ 193#else
194#define maciisi_read_time() 0
195#define maciisi_write_time(n)
196#define maciisi_read_pram NULL
197#define maciisi_write_pram NULL
198#endif
108 199
109/* 200/*
110 * VIA PRAM/RTC access routines 201 * VIA PRAM/RTC access routines
@@ -305,42 +396,55 @@ static void oss_shutdown(void)
305 396
306static void cuda_restart(void) 397static void cuda_restart(void)
307{ 398{
308 adb_request(NULL, NULL, ADBREQ_RAW|ADBREQ_SYNC, 399 struct adb_request req;
309 2, CUDA_PACKET, CUDA_RESET_SYSTEM); 400 if (cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_RESET_SYSTEM) < 0)
401 return;
402 while (!req.complete)
403 cuda_poll();
310} 404}
311 405
312static void cuda_shutdown(void) 406static void cuda_shutdown(void)
313{ 407{
314 adb_request(NULL, NULL, ADBREQ_RAW|ADBREQ_SYNC, 408 struct adb_request req;
315 2, CUDA_PACKET, CUDA_POWERDOWN); 409 if (cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_POWERDOWN) < 0)
410 return;
411 while (!req.complete)
412 cuda_poll();
316} 413}
317 414
318#endif /* CONFIG_ADB_CUDA */ 415#endif /* CONFIG_ADB_CUDA */
319 416
320#ifdef CONFIG_ADB_PMU 417#ifdef CONFIG_ADB_PMU68K
321 418
322void pmu_restart(void) 419void pmu_restart(void)
323{ 420{
324 adb_request(NULL, NULL, ADBREQ_RAW|ADBREQ_SYNC, 421 struct adb_request req;
325 3, PMU_PACKET, PMU_SET_INTR_MASK, 422 if (pmu_request(&req, NULL,
326 PMU_INT_ADB|PMU_INT_TICK); 423 2, PMU_SET_INTR_MASK, PMU_INT_ADB|PMU_INT_TICK) < 0)
327 424 return;
328 adb_request(NULL, NULL, ADBREQ_RAW|ADBREQ_SYNC, 425 while (!req.complete)
329 2, PMU_PACKET, PMU_RESET); 426 pmu_poll();
427 if (pmu_request(&req, NULL, 1, PMU_RESET) < 0)
428 return;
429 while (!req.complete)
430 pmu_poll();
330} 431}
331 432
332void pmu_shutdown(void) 433void pmu_shutdown(void)
333{ 434{
334 adb_request(NULL, NULL, ADBREQ_RAW|ADBREQ_SYNC, 435 struct adb_request req;
335 3, PMU_PACKET, PMU_SET_INTR_MASK, 436 if (pmu_request(&req, NULL,
336 PMU_INT_ADB|PMU_INT_TICK); 437 2, PMU_SET_INTR_MASK, PMU_INT_ADB|PMU_INT_TICK) < 0)
337 438 return;
338 adb_request(NULL, NULL, ADBREQ_RAW|ADBREQ_SYNC, 439 while (!req.complete)
339 6, PMU_PACKET, PMU_SHUTDOWN, 440 pmu_poll();
340 'M', 'A', 'T', 'T'); 441 if (pmu_request(&req, NULL, 5, PMU_SHUTDOWN, 'M', 'A', 'T', 'T') < 0)
442 return;
443 while (!req.complete)
444 pmu_poll();
341} 445}
342 446
343#endif /* CONFIG_ADB_PMU */ 447#endif
344 448
345/* 449/*
346 *------------------------------------------------------------------- 450 *-------------------------------------------------------------------
@@ -351,21 +455,22 @@ void pmu_shutdown(void)
351 455
352void mac_pram_read(int offset, __u8 *buffer, int len) 456void mac_pram_read(int offset, __u8 *buffer, int len)
353{ 457{
354 __u8 (*func)(int) = NULL; 458 __u8 (*func)(int);
355 int i; 459 int i;
356 460
357 if (macintosh_config->adb_type == MAC_ADB_IISI || 461 switch(macintosh_config->adb_type) {
358 macintosh_config->adb_type == MAC_ADB_PB1 || 462 case MAC_ADB_IISI:
359 macintosh_config->adb_type == MAC_ADB_PB2 || 463 func = maciisi_read_pram; break;
360 macintosh_config->adb_type == MAC_ADB_CUDA) { 464 case MAC_ADB_PB1:
361#ifdef CONFIG_ADB 465 case MAC_ADB_PB2:
362 func = adb_read_pram; 466 func = pmu_read_pram; break;
363#else 467 case MAC_ADB_CUDA:
364 return; 468 func = cuda_read_pram; break;
365#endif 469 default:
366 } else {
367 func = via_read_pram; 470 func = via_read_pram;
368 } 471 }
472 if (!func)
473 return;
369 for (i = 0 ; i < len ; i++) { 474 for (i = 0 ; i < len ; i++) {
370 buffer[i] = (*func)(offset++); 475 buffer[i] = (*func)(offset++);
371 } 476 }
@@ -373,21 +478,22 @@ void mac_pram_read(int offset, __u8 *buffer, int len)
373 478
374void mac_pram_write(int offset, __u8 *buffer, int len) 479void mac_pram_write(int offset, __u8 *buffer, int len)
375{ 480{
376 void (*func)(int, __u8) = NULL; 481 void (*func)(int, __u8);
377 int i; 482 int i;
378 483
379 if (macintosh_config->adb_type == MAC_ADB_IISI || 484 switch(macintosh_config->adb_type) {
380 macintosh_config->adb_type == MAC_ADB_PB1 || 485 case MAC_ADB_IISI:
381 macintosh_config->adb_type == MAC_ADB_PB2 || 486 func = maciisi_write_pram; break;
382 macintosh_config->adb_type == MAC_ADB_CUDA) { 487 case MAC_ADB_PB1:
383#ifdef CONFIG_ADB 488 case MAC_ADB_PB2:
384 func = adb_write_pram; 489 func = pmu_write_pram; break;
385#else 490 case MAC_ADB_CUDA:
386 return; 491 func = cuda_write_pram; break;
387#endif 492 default:
388 } else {
389 func = via_write_pram; 493 func = via_write_pram;
390 } 494 }
495 if (!func)
496 return;
391 for (i = 0 ; i < len ; i++) { 497 for (i = 0 ; i < len ; i++) {
392 (*func)(offset++, buffer[i]); 498 (*func)(offset++, buffer[i]);
393 } 499 }
@@ -408,7 +514,7 @@ void mac_poweroff(void)
408 } else if (macintosh_config->adb_type == MAC_ADB_CUDA) { 514 } else if (macintosh_config->adb_type == MAC_ADB_CUDA) {
409 cuda_shutdown(); 515 cuda_shutdown();
410#endif 516#endif
411#ifdef CONFIG_ADB_PMU 517#ifdef CONFIG_ADB_PMU68K
412 } else if (macintosh_config->adb_type == MAC_ADB_PB1 518 } else if (macintosh_config->adb_type == MAC_ADB_PB1
413 || macintosh_config->adb_type == MAC_ADB_PB2) { 519 || macintosh_config->adb_type == MAC_ADB_PB2) {
414 pmu_shutdown(); 520 pmu_shutdown();
@@ -448,7 +554,7 @@ void mac_reset(void)
448 } else if (macintosh_config->adb_type == MAC_ADB_CUDA) { 554 } else if (macintosh_config->adb_type == MAC_ADB_CUDA) {
449 cuda_restart(); 555 cuda_restart();
450#endif 556#endif
451#ifdef CONFIG_ADB_PMU 557#ifdef CONFIG_ADB_PMU68K
452 } else if (macintosh_config->adb_type == MAC_ADB_PB1 558 } else if (macintosh_config->adb_type == MAC_ADB_PB1
453 || macintosh_config->adb_type == MAC_ADB_PB2) { 559 || macintosh_config->adb_type == MAC_ADB_PB2) {
454 pmu_restart(); 560 pmu_restart();
@@ -588,20 +694,22 @@ int mac_hwclk(int op, struct rtc_time *t)
588 unsigned long now; 694 unsigned long now;
589 695
590 if (!op) { /* read */ 696 if (!op) { /* read */
591 if (macintosh_config->adb_type == MAC_ADB_II) { 697 switch (macintosh_config->adb_type) {
698 case MAC_ADB_II:
699 case MAC_ADB_IOP:
592 now = via_read_time(); 700 now = via_read_time();
593 } else 701 break;
594#ifdef CONFIG_ADB 702 case MAC_ADB_IISI:
595 if ((macintosh_config->adb_type == MAC_ADB_IISI) || 703 now = maciisi_read_time();
596 (macintosh_config->adb_type == MAC_ADB_PB1) || 704 break;
597 (macintosh_config->adb_type == MAC_ADB_PB2) || 705 case MAC_ADB_PB1:
598 (macintosh_config->adb_type == MAC_ADB_CUDA)) { 706 case MAC_ADB_PB2:
599 now = adb_read_time(); 707 now = pmu_read_time();
600 } else 708 break;
601#endif 709 case MAC_ADB_CUDA:
602 if (macintosh_config->adb_type == MAC_ADB_IOP) { 710 now = cuda_read_time();
603 now = via_read_time(); 711 break;
604 } else { 712 default:
605 now = 0; 713 now = 0;
606 } 714 }
607 715
@@ -619,15 +727,20 @@ int mac_hwclk(int op, struct rtc_time *t)
619 now = mktime(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, 727 now = mktime(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
620 t->tm_hour, t->tm_min, t->tm_sec); 728 t->tm_hour, t->tm_min, t->tm_sec);
621 729
622 if (macintosh_config->adb_type == MAC_ADB_II) { 730 switch (macintosh_config->adb_type) {
623 via_write_time(now); 731 case MAC_ADB_II:
624 } else if ((macintosh_config->adb_type == MAC_ADB_IISI) || 732 case MAC_ADB_IOP:
625 (macintosh_config->adb_type == MAC_ADB_PB1) ||
626 (macintosh_config->adb_type == MAC_ADB_PB2) ||
627 (macintosh_config->adb_type == MAC_ADB_CUDA)) {
628 adb_write_time(now);
629 } else if (macintosh_config->adb_type == MAC_ADB_IOP) {
630 via_write_time(now); 733 via_write_time(now);
734 break;
735 case MAC_ADB_CUDA:
736 cuda_write_time(now);
737 break;
738 case MAC_ADB_PB1:
739 case MAC_ADB_PB2:
740 pmu_write_time(now);
741 break;
742 case MAC_ADB_IISI:
743 maciisi_write_time(now);
631 } 744 }
632#endif 745#endif
633 } 746 }