aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-02-27 19:22:47 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2010-02-27 19:22:47 -0500
commit847f9c606cad121cebf984639e3eeee1c4db82f8 (patch)
treeecd7aaef6cdfaf908d4d37db2e8f1951b490543a
parent7981164791d18d5ed1dcdfa9598949ed158a5333 (diff)
parent00ebfe58b002f0ff387f60c7cd23bc2b274fce1a (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k: (24 commits) m68k: Define sigcontext ABI of ColdFire m68knommu: NPTL support for uClinux m68k: Add NPTL support m68k: Eliminate unused variable in page_to_phys() m68k: Switch to generic siginfo layout macfb: fix 24-bit visual and stuff macfb: cleanup fbdev: add some missing mac modes mac68k: start CUDA early valkyriefb: various fixes fbdev: mac_var_to_mode() fix mac68k: move macsonic and macmace platform devices mac68k: move mac_esp platform device mac68k: replace mac68k SCC code with platform device pmac-zilog: add platform driver pmac-zilog: cleanup mac68k: rework SWIM platform device mac68k: cleanup ataflop: Killl warning about unused variable flags m68k: Use DIV_ROUND_CLOSEST ...
-rw-r--r--arch/h8300/mm/memory.c4
-rw-r--r--arch/m68k/Kconfig6
-rw-r--r--arch/m68k/amiga/config.c2
-rw-r--r--arch/m68k/configs/mac_defconfig7
-rw-r--r--arch/m68k/configs/multi_defconfig6
-rw-r--r--arch/m68k/include/asm/machw.h25
-rw-r--r--arch/m68k/include/asm/macints.h22
-rw-r--r--arch/m68k/include/asm/ptrace.h2
-rw-r--r--arch/m68k/include/asm/sigcontext.h6
-rw-r--r--arch/m68k/include/asm/siginfo.h91
-rw-r--r--arch/m68k/include/asm/swab.h2
-rw-r--r--arch/m68k/include/asm/thread_info_mm.h1
-rw-r--r--arch/m68k/include/asm/thread_info_no.h1
-rw-r--r--arch/m68k/include/asm/ucontext.h4
-rw-r--r--arch/m68k/include/asm/unistd.h6
-rw-r--r--arch/m68k/include/asm/virtconvert.h7
-rw-r--r--arch/m68k/kernel/entry.S4
-rw-r--r--arch/m68k/kernel/process.c4
-rw-r--r--arch/m68k/kernel/ptrace.c5
-rw-r--r--arch/m68k/kernel/signal.c7
-rw-r--r--arch/m68k/kernel/sys_m68k.c81
-rw-r--r--arch/m68k/mac/Makefile2
-rw-r--r--arch/m68k/mac/config.c344
-rw-r--r--arch/m68k/mac/debug.c365
-rw-r--r--arch/m68k/mac/macints.c101
-rw-r--r--arch/m68k/mac/oss.c20
-rw-r--r--arch/m68k/mac/via.c7
-rw-r--r--arch/m68k/mm/kmap.c5
-rw-r--r--arch/m68knommu/kernel/process.c4
-rw-r--r--arch/m68knommu/kernel/ptrace.c5
-rw-r--r--arch/m68knommu/kernel/sys_m68k.c36
-rw-r--r--arch/m68knommu/kernel/syscalltable.S4
-rw-r--r--arch/m68knommu/mm/memory.c1
-rw-r--r--drivers/block/ataflop.c2
-rw-r--r--drivers/block/swim.c4
-rw-r--r--drivers/char/vme_scc.c12
-rw-r--r--drivers/macintosh/adb.c6
-rw-r--r--drivers/macintosh/via-cuda.c74
-rw-r--r--drivers/net/macmace.c33
-rw-r--r--drivers/net/macsonic.c33
-rw-r--r--drivers/scsi/mac_esp.c57
-rw-r--r--drivers/serial/Kconfig12
-rw-r--r--drivers/serial/pmac_zilog.c240
-rw-r--r--drivers/serial/pmac_zilog.h34
-rw-r--r--drivers/video/macfb.c736
-rw-r--r--drivers/video/macmodes.c80
-rw-r--r--drivers/video/valkyriefb.c6
-rw-r--r--drivers/video/valkyriefb.h31
48 files changed, 1111 insertions, 1436 deletions
diff --git a/arch/h8300/mm/memory.c b/arch/h8300/mm/memory.c
index ccd6ade816dd..40d8aa811e4e 100644
--- a/arch/h8300/mm/memory.c
+++ b/arch/h8300/mm/memory.c
@@ -44,8 +44,8 @@ void cache_push_v (unsigned long vaddr, int len)
44{ 44{
45} 45}
46 46
47/* Map some physical address range into the kernel address space. The 47/*
48 * code is copied and adapted from map_chunk(). 48 * Map some physical address range into the kernel address space.
49 */ 49 */
50 50
51unsigned long kernel_map(unsigned long paddr, unsigned long size, 51unsigned long kernel_map(unsigned long paddr, unsigned long size,
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index ecdc19a299b2..b5da298ba61d 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -536,10 +536,6 @@ config GVPIOEXT_PLIP
536 Say Y to enable doing IP over the parallel port on your GVP 536 Say Y to enable doing IP over the parallel port on your GVP
537 IO-Extender card, N otherwise. 537 IO-Extender card, N otherwise.
538 538
539config MAC_SCC
540 tristate "Macintosh serial support"
541 depends on MAC
542
543config MAC_HID 539config MAC_HID
544 bool 540 bool
545 depends on INPUT_ADBHID 541 depends on INPUT_ADBHID
@@ -595,7 +591,7 @@ config DN_SERIAL
595 591
596config SERIAL_CONSOLE 592config SERIAL_CONSOLE
597 bool "Support for serial port console" 593 bool "Support for serial port console"
598 depends on (AMIGA || ATARI || MAC || SUN3 || SUN3X || VME || APOLLO) && (ATARI_MFPSER=y || ATARI_MIDI=y || MAC_SCC=y || AMIGA_BUILTIN_SERIAL=y || GVPIOEXT=y || MULTIFACE_III_TTY=y || SERIAL=y || MVME147_SCC || SERIAL167 || MVME162_SCC || BVME6000_SCC || DN_SERIAL) 594 depends on (AMIGA || ATARI || SUN3 || SUN3X || VME || APOLLO) && (ATARI_MFPSER=y || ATARI_MIDI=y || AMIGA_BUILTIN_SERIAL=y || GVPIOEXT=y || MULTIFACE_III_TTY=y || SERIAL=y || MVME147_SCC || SERIAL167 || MVME162_SCC || BVME6000_SCC || DN_SERIAL)
599 ---help--- 595 ---help---
600 If you say Y here, it will be possible to use a serial port as the 596 If you say Y here, it will be possible to use a serial port as the
601 system console (the system console is the device which receives all 597 system console (the system console is the device which receives all
diff --git a/arch/m68k/amiga/config.c b/arch/m68k/amiga/config.c
index 6c74751c7b82..d2cc35d98532 100644
--- a/arch/m68k/amiga/config.c
+++ b/arch/m68k/amiga/config.c
@@ -480,7 +480,7 @@ static void __init amiga_sched_init(irq_handler_t timer_routine)
480 static struct resource sched_res = { 480 static struct resource sched_res = {
481 .name = "timer", .start = 0x00bfd400, .end = 0x00bfd5ff, 481 .name = "timer", .start = 0x00bfd400, .end = 0x00bfd5ff,
482 }; 482 };
483 jiffy_ticks = (amiga_eclock+HZ/2)/HZ; 483 jiffy_ticks = DIV_ROUND_CLOSEST(amiga_eclock, HZ);
484 484
485 if (request_resource(&mb_resources._ciab, &sched_res)) 485 if (request_resource(&mb_resources._ciab, &sched_res))
486 printk("Cannot allocate ciab.ta{lo,hi}\n"); 486 printk("Cannot allocate ciab.ta{lo,hi}\n");
diff --git a/arch/m68k/configs/mac_defconfig b/arch/m68k/configs/mac_defconfig
index 9991b64fea57..c5f3232ff916 100644
--- a/arch/m68k/configs/mac_defconfig
+++ b/arch/m68k/configs/mac_defconfig
@@ -701,6 +701,11 @@ CONFIG_VT_HW_CONSOLE_BINDING=y
701# 701#
702# Non-8250 serial port support 702# Non-8250 serial port support
703# 703#
704CONFIG_SERIAL_CORE=y
705CONFIG_SERIAL_CORE_CONSOLE=y
706CONFIG_SERIAL_PMACZILOG=y
707CONFIG_SERIAL_PMACZILOG_TTYS=y
708CONFIG_SERIAL_PMACZILOG_CONSOLE=y
704CONFIG_UNIX98_PTYS=y 709CONFIG_UNIX98_PTYS=y
705# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set 710# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
706CONFIG_LEGACY_PTYS=y 711CONFIG_LEGACY_PTYS=y
@@ -834,9 +839,7 @@ CONFIG_HIDRAW=y
834# 839#
835# Character devices 840# Character devices
836# 841#
837CONFIG_MAC_SCC=y
838CONFIG_MAC_HID=y 842CONFIG_MAC_HID=y
839CONFIG_SERIAL_CONSOLE=y
840 843
841# 844#
842# File systems 845# File systems
diff --git a/arch/m68k/configs/multi_defconfig b/arch/m68k/configs/multi_defconfig
index 69c43e2d8b45..a8bfa3fa71cf 100644
--- a/arch/m68k/configs/multi_defconfig
+++ b/arch/m68k/configs/multi_defconfig
@@ -822,6 +822,11 @@ CONFIG_A2232=y
822# 822#
823# Non-8250 serial port support 823# Non-8250 serial port support
824# 824#
825CONFIG_SERIAL_CORE=y
826CONFIG_SERIAL_CORE_CONSOLE=y
827CONFIG_SERIAL_PMACZILOG=y
828CONFIG_SERIAL_PMACZILOG_TTYS=y
829CONFIG_SERIAL_PMACZILOG_CONSOLE=y
825CONFIG_UNIX98_PTYS=y 830CONFIG_UNIX98_PTYS=y
826# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set 831# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
827CONFIG_LEGACY_PTYS=y 832CONFIG_LEGACY_PTYS=y
@@ -982,7 +987,6 @@ CONFIG_ATARI_MIDI=y
982CONFIG_ATARI_DSP56K=m 987CONFIG_ATARI_DSP56K=m
983CONFIG_AMIGA_BUILTIN_SERIAL=y 988CONFIG_AMIGA_BUILTIN_SERIAL=y
984CONFIG_MULTIFACE_III_TTY=m 989CONFIG_MULTIFACE_III_TTY=m
985CONFIG_MAC_SCC=y
986CONFIG_MAC_HID=y 990CONFIG_MAC_HID=y
987CONFIG_MVME147_SCC=y 991CONFIG_MVME147_SCC=y
988CONFIG_SERIAL167=y 992CONFIG_SERIAL167=y
diff --git a/arch/m68k/include/asm/machw.h b/arch/m68k/include/asm/machw.h
index 2b4de0c2ce4a..a22095164927 100644
--- a/arch/m68k/include/asm/machw.h
+++ b/arch/m68k/include/asm/machw.h
@@ -21,29 +21,4 @@
21#define VIDEOMEMSIZE (4096*1024) 21#define VIDEOMEMSIZE (4096*1024)
22#define VIDEOMEMMASK (-4096*1024) 22#define VIDEOMEMMASK (-4096*1024)
23 23
24#ifndef __ASSEMBLY__
25
26#include <linux/types.h>
27
28#if 0
29/*
30** SCC Z8530
31*/
32
33#define MAC_SCC_BAS (0x50F04000)
34struct MAC_SCC
35 {
36 u_char cha_a_ctrl;
37 u_char char_dummy1;
38 u_char cha_a_data;
39 u_char char_dummy2;
40 u_char cha_b_ctrl;
41 u_char char_dummy3;
42 u_char cha_b_data;
43 };
44# define mac_scc ((*(volatile struct SCC*)MAC_SCC_BAS))
45#endif
46
47#endif /* __ASSEMBLY__ */
48
49#endif /* linux/machw.h */ 24#endif /* linux/machw.h */
diff --git a/arch/m68k/include/asm/macints.h b/arch/m68k/include/asm/macints.h
index 679c48ab4407..ebe1b70fe90c 100644
--- a/arch/m68k/include/asm/macints.h
+++ b/arch/m68k/include/asm/macints.h
@@ -37,7 +37,6 @@
37 37
38#define VIA1_SOURCE_BASE 8 38#define VIA1_SOURCE_BASE 8
39#define VIA2_SOURCE_BASE 16 39#define VIA2_SOURCE_BASE 16
40#define MAC_SCC_SOURCE_BASE 24
41#define PSC3_SOURCE_BASE 24 40#define PSC3_SOURCE_BASE 24
42#define PSC4_SOURCE_BASE 32 41#define PSC4_SOURCE_BASE 32
43#define PSC5_SOURCE_BASE 40 42#define PSC5_SOURCE_BASE 40
@@ -96,26 +95,12 @@
96#define IRQ_PSC3_2 (26) 95#define IRQ_PSC3_2 (26)
97#define IRQ_PSC3_3 (27) 96#define IRQ_PSC3_3 (27)
98 97
99/* Level 4 (SCC) interrupts */
100#define IRQ_SCC (32)
101#define IRQ_SCCA (33)
102#define IRQ_SCCB (34)
103#if 0 /* FIXME: are there multiple interrupt conditions on the SCC ?? */
104/* SCC interrupts */
105#define IRQ_SCCB_TX (32)
106#define IRQ_SCCB_STAT (33)
107#define IRQ_SCCB_RX (34)
108#define IRQ_SCCB_SPCOND (35)
109#define IRQ_SCCA_TX (36)
110#define IRQ_SCCA_STAT (37)
111#define IRQ_SCCA_RX (38)
112#define IRQ_SCCA_SPCOND (39)
113#endif
114
115/* Level 4 (PSC, AV Macs only) interrupts */ 98/* Level 4 (PSC, AV Macs only) interrupts */
116#define IRQ_PSC4_0 (32) 99#define IRQ_PSC4_0 (32)
117#define IRQ_PSC4_1 (33) 100#define IRQ_PSC4_1 (33)
101#define IRQ_MAC_SCC_A IRQ_PSC4_1
118#define IRQ_PSC4_2 (34) 102#define IRQ_PSC4_2 (34)
103#define IRQ_MAC_SCC_B IRQ_PSC4_2
119#define IRQ_PSC4_3 (35) 104#define IRQ_PSC4_3 (35)
120#define IRQ_MAC_MACE_DMA IRQ_PSC4_3 105#define IRQ_MAC_MACE_DMA IRQ_PSC4_3
121 106
@@ -146,6 +131,9 @@
146#define IRQ_BABOON_2 (66) 131#define IRQ_BABOON_2 (66)
147#define IRQ_BABOON_3 (67) 132#define IRQ_BABOON_3 (67)
148 133
134/* On non-PSC machines, the serial ports share an IRQ */
135#define IRQ_MAC_SCC IRQ_AUTO_4
136
149#define SLOT2IRQ(x) (x + 47) 137#define SLOT2IRQ(x) (x + 47)
150#define IRQ2SLOT(x) (x - 47) 138#define IRQ2SLOT(x) (x - 47)
151 139
diff --git a/arch/m68k/include/asm/ptrace.h b/arch/m68k/include/asm/ptrace.h
index ee4011c23281..21605c736f69 100644
--- a/arch/m68k/include/asm/ptrace.h
+++ b/arch/m68k/include/asm/ptrace.h
@@ -71,6 +71,8 @@ struct switch_stack {
71#define PTRACE_GETFPREGS 14 71#define PTRACE_GETFPREGS 14
72#define PTRACE_SETFPREGS 15 72#define PTRACE_SETFPREGS 15
73 73
74#define PTRACE_GET_THREAD_AREA 25
75
74#define PTRACE_SINGLEBLOCK 33 /* resume execution until next branch */ 76#define PTRACE_SINGLEBLOCK 33 /* resume execution until next branch */
75 77
76#ifdef __KERNEL__ 78#ifdef __KERNEL__
diff --git a/arch/m68k/include/asm/sigcontext.h b/arch/m68k/include/asm/sigcontext.h
index 523db2a51cf3..1320eaa4cc2a 100644
--- a/arch/m68k/include/asm/sigcontext.h
+++ b/arch/m68k/include/asm/sigcontext.h
@@ -15,9 +15,15 @@ struct sigcontext {
15 unsigned long sc_pc; 15 unsigned long sc_pc;
16 unsigned short sc_formatvec; 16 unsigned short sc_formatvec;
17#ifndef __uClinux__ 17#ifndef __uClinux__
18# ifdef __mcoldfire__
19 unsigned long sc_fpregs[2][2]; /* room for two fp registers */
20 unsigned long sc_fpcntl[3];
21 unsigned char sc_fpstate[16+6*8];
22# else
18 unsigned long sc_fpregs[2*3]; /* room for two fp registers */ 23 unsigned long sc_fpregs[2*3]; /* room for two fp registers */
19 unsigned long sc_fpcntl[3]; 24 unsigned long sc_fpcntl[3];
20 unsigned char sc_fpstate[216]; 25 unsigned char sc_fpstate[216];
26# endif
21#endif 27#endif
22}; 28};
23 29
diff --git a/arch/m68k/include/asm/siginfo.h b/arch/m68k/include/asm/siginfo.h
index ca7dde8fd223..851d3d784b53 100644
--- a/arch/m68k/include/asm/siginfo.h
+++ b/arch/m68k/include/asm/siginfo.h
@@ -1,97 +1,6 @@
1#ifndef _M68K_SIGINFO_H 1#ifndef _M68K_SIGINFO_H
2#define _M68K_SIGINFO_H 2#define _M68K_SIGINFO_H
3 3
4#ifndef __uClinux__
5#define HAVE_ARCH_SIGINFO_T
6#define HAVE_ARCH_COPY_SIGINFO
7#endif
8
9#include <asm-generic/siginfo.h> 4#include <asm-generic/siginfo.h>
10 5
11#ifndef __uClinux__
12
13typedef struct siginfo {
14 int si_signo;
15 int si_errno;
16 int si_code;
17
18 union {
19 int _pad[SI_PAD_SIZE];
20
21 /* kill() */
22 struct {
23 __kernel_pid_t _pid; /* sender's pid */
24 __kernel_uid_t _uid; /* backwards compatibility */
25 __kernel_uid32_t _uid32; /* sender's uid */
26 } _kill;
27
28 /* POSIX.1b timers */
29 struct {
30 timer_t _tid; /* timer id */
31 int _overrun; /* overrun count */
32 char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)];
33 sigval_t _sigval; /* same as below */
34 int _sys_private; /* not to be passed to user */
35 } _timer;
36
37 /* POSIX.1b signals */
38 struct {
39 __kernel_pid_t _pid; /* sender's pid */
40 __kernel_uid_t _uid; /* backwards compatibility */
41 sigval_t _sigval;
42 __kernel_uid32_t _uid32; /* sender's uid */
43 } _rt;
44
45 /* SIGCHLD */
46 struct {
47 __kernel_pid_t _pid; /* which child */
48 __kernel_uid_t _uid; /* backwards compatibility */
49 int _status; /* exit code */
50 clock_t _utime;
51 clock_t _stime;
52 __kernel_uid32_t _uid32; /* sender's uid */
53 } _sigchld;
54
55 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
56 struct {
57 void *_addr; /* faulting insn/memory ref. */
58 } _sigfault;
59
60 /* SIGPOLL */
61 struct {
62 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
63 int _fd;
64 } _sigpoll;
65 } _sifields;
66} siginfo_t;
67
68#define UID16_SIGINFO_COMPAT_NEEDED
69
70/*
71 * How these fields are to be accessed.
72 */
73#undef si_uid
74#ifdef __KERNEL__
75#define si_uid _sifields._kill._uid32
76#define si_uid16 _sifields._kill._uid
77#else
78#define si_uid _sifields._kill._uid
79#endif
80
81#ifdef __KERNEL__
82
83#include <linux/string.h>
84
85static inline void copy_siginfo(struct siginfo *to, struct siginfo *from)
86{
87 if (from->si_code < 0)
88 memcpy(to, from, sizeof(*to));
89 else
90 /* _sigchld is currently the largest know union member */
91 memcpy(to, from, 3*sizeof(int) + sizeof(from->_sifields._sigchld));
92}
93
94#endif /* __KERNEL__ */
95#endif /* !__uClinux__ */
96
97#endif 6#endif
diff --git a/arch/m68k/include/asm/swab.h b/arch/m68k/include/asm/swab.h
index 5b754aace744..b7b37a40defc 100644
--- a/arch/m68k/include/asm/swab.h
+++ b/arch/m68k/include/asm/swab.h
@@ -14,7 +14,7 @@ static inline __attribute_const__ __u32 __arch_swab32(__u32 val)
14} 14}
15 15
16#define __arch_swab32 __arch_swab32 16#define __arch_swab32 __arch_swab32
17#elif !defined(__uClinux__) 17#elif !defined(__mcoldfire__)
18 18
19static inline __attribute_const__ __u32 __arch_swab32(__u32 val) 19static inline __attribute_const__ __u32 __arch_swab32(__u32 val)
20{ 20{
diff --git a/arch/m68k/include/asm/thread_info_mm.h b/arch/m68k/include/asm/thread_info_mm.h
index 167e518db41b..67266c683453 100644
--- a/arch/m68k/include/asm/thread_info_mm.h
+++ b/arch/m68k/include/asm/thread_info_mm.h
@@ -16,6 +16,7 @@ struct thread_info {
16 struct exec_domain *exec_domain; /* execution domain */ 16 struct exec_domain *exec_domain; /* execution domain */
17 int preempt_count; /* 0 => preemptable, <0 => BUG */ 17 int preempt_count; /* 0 => preemptable, <0 => BUG */
18 __u32 cpu; /* should always be 0 on m68k */ 18 __u32 cpu; /* should always be 0 on m68k */
19 unsigned long tp_value; /* thread pointer */
19 struct restart_block restart_block; 20 struct restart_block restart_block;
20}; 21};
21#endif /* __ASSEMBLY__ */ 22#endif /* __ASSEMBLY__ */
diff --git a/arch/m68k/include/asm/thread_info_no.h b/arch/m68k/include/asm/thread_info_no.h
index a6512bfdd01d..884776f686ca 100644
--- a/arch/m68k/include/asm/thread_info_no.h
+++ b/arch/m68k/include/asm/thread_info_no.h
@@ -37,6 +37,7 @@ struct thread_info {
37 unsigned long flags; /* low level flags */ 37 unsigned long flags; /* low level flags */
38 int cpu; /* cpu we're on */ 38 int cpu; /* cpu we're on */
39 int preempt_count; /* 0 => preemptable, <0 => BUG */ 39 int preempt_count; /* 0 => preemptable, <0 => BUG */
40 unsigned long tp_value; /* thread pointer */
40 struct restart_block restart_block; 41 struct restart_block restart_block;
41}; 42};
42 43
diff --git a/arch/m68k/include/asm/ucontext.h b/arch/m68k/include/asm/ucontext.h
index e4e22669edc0..00dcc5176c57 100644
--- a/arch/m68k/include/asm/ucontext.h
+++ b/arch/m68k/include/asm/ucontext.h
@@ -7,7 +7,11 @@ typedef greg_t gregset_t[NGREG];
7 7
8typedef struct fpregset { 8typedef struct fpregset {
9 int f_fpcntl[3]; 9 int f_fpcntl[3];
10#ifdef __mcoldfire__
11 int f_fpregs[8][2];
12#else
10 int f_fpregs[8*3]; 13 int f_fpregs[8*3];
14#endif
11} fpregset_t; 15} fpregset_t;
12 16
13struct mcontext { 17struct mcontext {
diff --git a/arch/m68k/include/asm/unistd.h b/arch/m68k/include/asm/unistd.h
index 48b87f5ced50..d72a71dabecb 100644
--- a/arch/m68k/include/asm/unistd.h
+++ b/arch/m68k/include/asm/unistd.h
@@ -336,10 +336,14 @@
336#define __NR_pwritev 330 336#define __NR_pwritev 330
337#define __NR_rt_tgsigqueueinfo 331 337#define __NR_rt_tgsigqueueinfo 331
338#define __NR_perf_event_open 332 338#define __NR_perf_event_open 332
339#define __NR_get_thread_area 333
340#define __NR_set_thread_area 334
341#define __NR_atomic_cmpxchg_32 335
342#define __NR_atomic_barrier 336
339 343
340#ifdef __KERNEL__ 344#ifdef __KERNEL__
341 345
342#define NR_syscalls 333 346#define NR_syscalls 337
343 347
344#define __ARCH_WANT_IPC_PARSE_VERSION 348#define __ARCH_WANT_IPC_PARSE_VERSION
345#define __ARCH_WANT_OLD_READDIR 349#define __ARCH_WANT_OLD_READDIR
diff --git a/arch/m68k/include/asm/virtconvert.h b/arch/m68k/include/asm/virtconvert.h
index 3f834b3ab5bd..f35229b8651d 100644
--- a/arch/m68k/include/asm/virtconvert.h
+++ b/arch/m68k/include/asm/virtconvert.h
@@ -31,12 +31,7 @@ static inline void *phys_to_virt(unsigned long address)
31#define page_to_phys(page) \ 31#define page_to_phys(page) \
32 __pa(PAGE_OFFSET + (((page) - pg_data_map[0].node_mem_map) << PAGE_SHIFT)) 32 __pa(PAGE_OFFSET + (((page) - pg_data_map[0].node_mem_map) << PAGE_SHIFT))
33#else 33#else
34#define page_to_phys(_page) ({ \ 34#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
35 struct page *__page = _page; \
36 struct pglist_data *pgdat; \
37 pgdat = pg_data_table[page_to_nid(__page)]; \
38 page_to_pfn(__page) << PAGE_SHIFT; \
39})
40#endif 35#endif
41#else 36#else
42#define page_to_phys(page) (((page) - mem_map) << PAGE_SHIFT) 37#define page_to_phys(page) (((page) - mem_map) << PAGE_SHIFT)
diff --git a/arch/m68k/kernel/entry.S b/arch/m68k/kernel/entry.S
index 77fc7c16bf48..e136b8cbe9b9 100644
--- a/arch/m68k/kernel/entry.S
+++ b/arch/m68k/kernel/entry.S
@@ -761,4 +761,8 @@ sys_call_table:
761 .long sys_pwritev /* 330 */ 761 .long sys_pwritev /* 330 */
762 .long sys_rt_tgsigqueueinfo 762 .long sys_rt_tgsigqueueinfo
763 .long sys_perf_event_open 763 .long sys_perf_event_open
764 .long sys_get_thread_area
765 .long sys_set_thread_area
766 .long sys_atomic_cmpxchg_32 /* 335 */
767 .long sys_atomic_barrier
764 768
diff --git a/arch/m68k/kernel/process.c b/arch/m68k/kernel/process.c
index 05296593e718..17c3f325255d 100644
--- a/arch/m68k/kernel/process.c
+++ b/arch/m68k/kernel/process.c
@@ -251,6 +251,10 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
251 251
252 p->thread.usp = usp; 252 p->thread.usp = usp;
253 p->thread.ksp = (unsigned long)childstack; 253 p->thread.ksp = (unsigned long)childstack;
254
255 if (clone_flags & CLONE_SETTLS)
256 task_thread_info(p)->tp_value = regs->d5;
257
254 /* 258 /*
255 * Must save the current SFC/DFC value, NOT the value when 259 * Must save the current SFC/DFC value, NOT the value when
256 * the parent was last descheduled - RGH 10-08-96 260 * the parent was last descheduled - RGH 10-08-96
diff --git a/arch/m68k/kernel/ptrace.c b/arch/m68k/kernel/ptrace.c
index 1fc217e5f06b..616e59752c29 100644
--- a/arch/m68k/kernel/ptrace.c
+++ b/arch/m68k/kernel/ptrace.c
@@ -245,6 +245,11 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
245 ret = -EFAULT; 245 ret = -EFAULT;
246 break; 246 break;
247 247
248 case PTRACE_GET_THREAD_AREA:
249 ret = put_user(task_thread_info(child)->tp_value,
250 (unsigned long __user *)data);
251 break;
252
248 default: 253 default:
249 ret = ptrace_request(child, request, addr, data); 254 ret = ptrace_request(child, request, addr, data);
250 break; 255 break;
diff --git a/arch/m68k/kernel/signal.c b/arch/m68k/kernel/signal.c
index de2d05ddd86d..4b387538706f 100644
--- a/arch/m68k/kernel/signal.c
+++ b/arch/m68k/kernel/signal.c
@@ -897,10 +897,17 @@ static void setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info,
897 897
898 /* Set up to return from userspace. */ 898 /* Set up to return from userspace. */
899 err |= __put_user(frame->retcode, &frame->pretcode); 899 err |= __put_user(frame->retcode, &frame->pretcode);
900#ifdef __mcoldfire__
901 /* movel #__NR_rt_sigreturn,d0; trap #0 */
902 err |= __put_user(0x203c0000, (long __user *)(frame->retcode + 0));
903 err |= __put_user(0x00004e40 + (__NR_rt_sigreturn << 16),
904 (long __user *)(frame->retcode + 4));
905#else
900 /* moveq #,d0; notb d0; trap #0 */ 906 /* moveq #,d0; notb d0; trap #0 */
901 err |= __put_user(0x70004600 + ((__NR_rt_sigreturn ^ 0xff) << 16), 907 err |= __put_user(0x70004600 + ((__NR_rt_sigreturn ^ 0xff) << 16),
902 (long __user *)(frame->retcode + 0)); 908 (long __user *)(frame->retcode + 0));
903 err |= __put_user(0x4e40, (short __user *)(frame->retcode + 4)); 909 err |= __put_user(0x4e40, (short __user *)(frame->retcode + 4));
910#endif
904 911
905 if (err) 912 if (err)
906 goto give_sigsegv; 913 goto give_sigsegv;
diff --git a/arch/m68k/kernel/sys_m68k.c b/arch/m68k/kernel/sys_m68k.c
index 218f441de667..e3ad2d671973 100644
--- a/arch/m68k/kernel/sys_m68k.c
+++ b/arch/m68k/kernel/sys_m68k.c
@@ -28,6 +28,11 @@
28#include <asm/traps.h> 28#include <asm/traps.h>
29#include <asm/page.h> 29#include <asm/page.h>
30#include <asm/unistd.h> 30#include <asm/unistd.h>
31#include <linux/elf.h>
32#include <asm/tlb.h>
33
34asmlinkage int do_page_fault(struct pt_regs *regs, unsigned long address,
35 unsigned long error_code);
31 36
32asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, 37asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
33 unsigned long prot, unsigned long flags, 38 unsigned long prot, unsigned long flags,
@@ -595,3 +600,79 @@ int kernel_execve(const char *filename, char *const argv[], char *const envp[])
595 : "d" (__a), "d" (__b), "d" (__c)); 600 : "d" (__a), "d" (__b), "d" (__c));
596 return __res; 601 return __res;
597} 602}
603
604asmlinkage unsigned long sys_get_thread_area(void)
605{
606 return current_thread_info()->tp_value;
607}
608
609asmlinkage int sys_set_thread_area(unsigned long tp)
610{
611 current_thread_info()->tp_value = tp;
612 return 0;
613}
614
615/* This syscall gets its arguments in A0 (mem), D2 (oldval) and
616 D1 (newval). */
617asmlinkage int
618sys_atomic_cmpxchg_32(unsigned long newval, int oldval, int d3, int d4, int d5,
619 unsigned long __user * mem)
620{
621 /* This was borrowed from ARM's implementation. */
622 for (;;) {
623 struct mm_struct *mm = current->mm;
624 pgd_t *pgd;
625 pmd_t *pmd;
626 pte_t *pte;
627 spinlock_t *ptl;
628 unsigned long mem_value;
629
630 down_read(&mm->mmap_sem);
631 pgd = pgd_offset(mm, (unsigned long)mem);
632 if (!pgd_present(*pgd))
633 goto bad_access;
634 pmd = pmd_offset(pgd, (unsigned long)mem);
635 if (!pmd_present(*pmd))
636 goto bad_access;
637 pte = pte_offset_map_lock(mm, pmd, (unsigned long)mem, &ptl);
638 if (!pte_present(*pte) || !pte_dirty(*pte)
639 || !pte_write(*pte)) {
640 pte_unmap_unlock(pte, ptl);
641 goto bad_access;
642 }
643
644 mem_value = *mem;
645 if (mem_value == oldval)
646 *mem = newval;
647
648 pte_unmap_unlock(pte, ptl);
649 up_read(&mm->mmap_sem);
650 return mem_value;
651
652 bad_access:
653 up_read(&mm->mmap_sem);
654 /* This is not necessarily a bad access, we can get here if
655 a memory we're trying to write to should be copied-on-write.
656 Make the kernel do the necessary page stuff, then re-iterate.
657 Simulate a write access fault to do that. */
658 {
659 /* The first argument of the function corresponds to
660 D1, which is the first field of struct pt_regs. */
661 struct pt_regs *fp = (struct pt_regs *)&newval;
662
663 /* '3' is an RMW flag. */
664 if (do_page_fault(fp, (unsigned long)mem, 3))
665 /* If the do_page_fault() failed, we don't
666 have anything meaningful to return.
667 There should be a SIGSEGV pending for
668 the process. */
669 return 0xdeadbeef;
670 }
671 }
672}
673
674asmlinkage int sys_atomic_barrier(void)
675{
676 /* no code needed for uniprocs */
677 return 0;
678}
diff --git a/arch/m68k/mac/Makefile b/arch/m68k/mac/Makefile
index daebd80bdef0..b8d4c835f9a2 100644
--- a/arch/m68k/mac/Makefile
+++ b/arch/m68k/mac/Makefile
@@ -3,4 +3,4 @@
3# 3#
4 4
5obj-y := config.o macints.o iop.o via.o oss.o psc.o \ 5obj-y := config.o macints.o iop.o via.o oss.o psc.o \
6 baboon.o macboing.o debug.o misc.o 6 baboon.o macboing.o misc.o
diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c
index be017984a456..0356da9bf763 100644
--- a/arch/m68k/mac/config.c
+++ b/arch/m68k/mac/config.c
@@ -23,6 +23,8 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/vt_kern.h> 24#include <linux/vt_kern.h>
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/adb.h>
27#include <linux/cuda.h>
26 28
27#define BOOTINFO_COMPAT_1_0 29#define BOOTINFO_COMPAT_1_0
28#include <asm/setup.h> 30#include <asm/setup.h>
@@ -44,12 +46,7 @@
44#include <asm/mac_oss.h> 46#include <asm/mac_oss.h>
45#include <asm/mac_psc.h> 47#include <asm/mac_psc.h>
46 48
47/* platform device info */
48
49#define SWIM_IO_SIZE 0x2000 /* SWIM IO resource size */
50
51/* Mac bootinfo struct */ 49/* Mac bootinfo struct */
52
53struct mac_booter_data mac_bi_data; 50struct mac_booter_data mac_bi_data;
54 51
55/* The phys. video addr. - might be bogus on some machines */ 52/* The phys. video addr. - might be bogus on some machines */
@@ -70,8 +67,6 @@ extern void baboon_init(void);
70 67
71extern void mac_mksound(unsigned int, unsigned int); 68extern void mac_mksound(unsigned int, unsigned int);
72 69
73extern void nubus_sweep_video(void);
74
75static void mac_get_model(char *str); 70static void mac_get_model(char *str);
76static void mac_identify(void); 71static void mac_identify(void);
77static void mac_report_hardware(void); 72static void mac_report_hardware(void);
@@ -168,12 +163,6 @@ void __init config_mac(void)
168#if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE) 163#if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
169 mach_beep = mac_mksound; 164 mach_beep = mac_mksound;
170#endif 165#endif
171#ifdef CONFIG_HEARTBEAT
172#if 0
173 mach_heartbeat = mac_heartbeat;
174 mach_heartbeat_irq = IRQ_MAC_TIMER;
175#endif
176#endif
177 166
178 /* 167 /*
179 * Determine hardware present 168 * Determine hardware present
@@ -191,27 +180,19 @@ void __init config_mac(void)
191 if (macintosh_config->ident == MAC_MODEL_IICI 180 if (macintosh_config->ident == MAC_MODEL_IICI
192 || macintosh_config->ident == MAC_MODEL_IIFX) 181 || macintosh_config->ident == MAC_MODEL_IIFX)
193 mach_l2_flush = mac_cache_card_flush; 182 mach_l2_flush = mac_cache_card_flush;
194
195 /*
196 * Check for machine specific fixups.
197 */
198
199#ifdef OLD_NUBUS_CODE
200 nubus_sweep_video();
201#endif
202} 183}
203 184
204 185
205/* 186/*
206 * Macintosh Table: hardcoded model configuration data. 187 * Macintosh Table: hardcoded model configuration data.
207 * 188 *
208 * Much of this was defined by Alan, based on who knows what docs. 189 * Much of this was defined by Alan, based on who knows what docs.
209 * I've added a lot more, and some of that was pure guesswork based 190 * I've added a lot more, and some of that was pure guesswork based
210 * on hardware pages present on the Mac web site. Possibly wildly 191 * on hardware pages present on the Mac web site. Possibly wildly
211 * inaccurate, so look here if a new Mac model won't run. Example: if 192 * inaccurate, so look here if a new Mac model won't run. Example: if
212 * a Mac crashes immediately after the VIA1 registers have been dumped 193 * a Mac crashes immediately after the VIA1 registers have been dumped
213 * to the screen, it probably died attempting to read DirB on a RBV. 194 * to the screen, it probably died attempting to read DirB on a RBV.
214 * Meaning it should have MAC_VIA_IIci here :-) 195 * Meaning it should have MAC_VIA_IIci here :-)
215 */ 196 */
216 197
217struct mac_model *macintosh_config; 198struct mac_model *macintosh_config;
@@ -219,7 +200,7 @@ EXPORT_SYMBOL(macintosh_config);
219 200
220static struct mac_model mac_data_table[] = { 201static struct mac_model mac_data_table[] = {
221 /* 202 /*
222 * We'll pretend to be a Macintosh II, that's pretty safe. 203 * We'll pretend to be a Macintosh II, that's pretty safe.
223 */ 204 */
224 205
225 { 206 {
@@ -230,12 +211,11 @@ static struct mac_model mac_data_table[] = {
230 .scsi_type = MAC_SCSI_OLD, 211 .scsi_type = MAC_SCSI_OLD,
231 .scc_type = MAC_SCC_II, 212 .scc_type = MAC_SCC_II,
232 .nubus_type = MAC_NUBUS, 213 .nubus_type = MAC_NUBUS,
233 .floppy_type = MAC_FLOPPY_IWM 214 .floppy_type = MAC_FLOPPY_IWM,
234 }, 215 },
235 216
236 /* 217 /*
237 * Original MacII hardware 218 * Original Mac II hardware
238 *
239 */ 219 */
240 220
241 { 221 {
@@ -246,7 +226,7 @@ static struct mac_model mac_data_table[] = {
246 .scsi_type = MAC_SCSI_OLD, 226 .scsi_type = MAC_SCSI_OLD,
247 .scc_type = MAC_SCC_II, 227 .scc_type = MAC_SCC_II,
248 .nubus_type = MAC_NUBUS, 228 .nubus_type = MAC_NUBUS,
249 .floppy_type = MAC_FLOPPY_IWM 229 .floppy_type = MAC_FLOPPY_IWM,
250 }, { 230 }, {
251 .ident = MAC_MODEL_IIX, 231 .ident = MAC_MODEL_IIX,
252 .name = "IIx", 232 .name = "IIx",
@@ -255,7 +235,7 @@ static struct mac_model mac_data_table[] = {
255 .scsi_type = MAC_SCSI_OLD, 235 .scsi_type = MAC_SCSI_OLD,
256 .scc_type = MAC_SCC_II, 236 .scc_type = MAC_SCC_II,
257 .nubus_type = MAC_NUBUS, 237 .nubus_type = MAC_NUBUS,
258 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 238 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
259 }, { 239 }, {
260 .ident = MAC_MODEL_IICX, 240 .ident = MAC_MODEL_IICX,
261 .name = "IIcx", 241 .name = "IIcx",
@@ -264,7 +244,7 @@ static struct mac_model mac_data_table[] = {
264 .scsi_type = MAC_SCSI_OLD, 244 .scsi_type = MAC_SCSI_OLD,
265 .scc_type = MAC_SCC_II, 245 .scc_type = MAC_SCC_II,
266 .nubus_type = MAC_NUBUS, 246 .nubus_type = MAC_NUBUS,
267 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 247 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
268 }, { 248 }, {
269 .ident = MAC_MODEL_SE30, 249 .ident = MAC_MODEL_SE30,
270 .name = "SE/30", 250 .name = "SE/30",
@@ -273,13 +253,13 @@ static struct mac_model mac_data_table[] = {
273 .scsi_type = MAC_SCSI_OLD, 253 .scsi_type = MAC_SCSI_OLD,
274 .scc_type = MAC_SCC_II, 254 .scc_type = MAC_SCC_II,
275 .nubus_type = MAC_NUBUS, 255 .nubus_type = MAC_NUBUS,
276 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 256 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
277 }, 257 },
278 258
279 /* 259 /*
280 * Weirdified MacII hardware - all subtly different. Gee thanks 260 * Weirdified Mac II hardware - all subtly different. Gee thanks
281 * Apple. All these boxes seem to have VIA2 in a different place to 261 * Apple. All these boxes seem to have VIA2 in a different place to
282 * the MacII (+1A000 rather than +4000) 262 * the Mac II (+1A000 rather than +4000)
283 * CSA: see http://developer.apple.com/technotes/hw/hw_09.html 263 * CSA: see http://developer.apple.com/technotes/hw/hw_09.html
284 */ 264 */
285 265
@@ -291,7 +271,7 @@ static struct mac_model mac_data_table[] = {
291 .scsi_type = MAC_SCSI_OLD, 271 .scsi_type = MAC_SCSI_OLD,
292 .scc_type = MAC_SCC_II, 272 .scc_type = MAC_SCC_II,
293 .nubus_type = MAC_NUBUS, 273 .nubus_type = MAC_NUBUS,
294 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 274 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
295 }, { 275 }, {
296 .ident = MAC_MODEL_IIFX, 276 .ident = MAC_MODEL_IIFX,
297 .name = "IIfx", 277 .name = "IIfx",
@@ -300,7 +280,7 @@ static struct mac_model mac_data_table[] = {
300 .scsi_type = MAC_SCSI_OLD, 280 .scsi_type = MAC_SCSI_OLD,
301 .scc_type = MAC_SCC_IOP, 281 .scc_type = MAC_SCC_IOP,
302 .nubus_type = MAC_NUBUS, 282 .nubus_type = MAC_NUBUS,
303 .floppy_type = MAC_FLOPPY_SWIM_IOP 283 .floppy_type = MAC_FLOPPY_SWIM_IOP,
304 }, { 284 }, {
305 .ident = MAC_MODEL_IISI, 285 .ident = MAC_MODEL_IISI,
306 .name = "IIsi", 286 .name = "IIsi",
@@ -309,7 +289,7 @@ static struct mac_model mac_data_table[] = {
309 .scsi_type = MAC_SCSI_OLD, 289 .scsi_type = MAC_SCSI_OLD,
310 .scc_type = MAC_SCC_II, 290 .scc_type = MAC_SCC_II,
311 .nubus_type = MAC_NUBUS, 291 .nubus_type = MAC_NUBUS,
312 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 292 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
313 }, { 293 }, {
314 .ident = MAC_MODEL_IIVI, 294 .ident = MAC_MODEL_IIVI,
315 .name = "IIvi", 295 .name = "IIvi",
@@ -318,7 +298,7 @@ static struct mac_model mac_data_table[] = {
318 .scsi_type = MAC_SCSI_OLD, 298 .scsi_type = MAC_SCSI_OLD,
319 .scc_type = MAC_SCC_II, 299 .scc_type = MAC_SCC_II,
320 .nubus_type = MAC_NUBUS, 300 .nubus_type = MAC_NUBUS,
321 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 301 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
322 }, { 302 }, {
323 .ident = MAC_MODEL_IIVX, 303 .ident = MAC_MODEL_IIVX,
324 .name = "IIvx", 304 .name = "IIvx",
@@ -327,11 +307,11 @@ static struct mac_model mac_data_table[] = {
327 .scsi_type = MAC_SCSI_OLD, 307 .scsi_type = MAC_SCSI_OLD,
328 .scc_type = MAC_SCC_II, 308 .scc_type = MAC_SCC_II,
329 .nubus_type = MAC_NUBUS, 309 .nubus_type = MAC_NUBUS,
330 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 310 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
331 }, 311 },
332 312
333 /* 313 /*
334 * Classic models (guessing: similar to SE/30 ?? Nope, similar to LC ...) 314 * Classic models (guessing: similar to SE/30? Nope, similar to LC...)
335 */ 315 */
336 316
337 { 317 {
@@ -342,7 +322,7 @@ static struct mac_model mac_data_table[] = {
342 .scsi_type = MAC_SCSI_OLD, 322 .scsi_type = MAC_SCSI_OLD,
343 .scc_type = MAC_SCC_II, 323 .scc_type = MAC_SCC_II,
344 .nubus_type = MAC_NUBUS, 324 .nubus_type = MAC_NUBUS,
345 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 325 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
346 }, { 326 }, {
347 .ident = MAC_MODEL_CCL, 327 .ident = MAC_MODEL_CCL,
348 .name = "Color Classic", 328 .name = "Color Classic",
@@ -351,11 +331,11 @@ static struct mac_model mac_data_table[] = {
351 .scsi_type = MAC_SCSI_OLD, 331 .scsi_type = MAC_SCSI_OLD,
352 .scc_type = MAC_SCC_II, 332 .scc_type = MAC_SCC_II,
353 .nubus_type = MAC_NUBUS, 333 .nubus_type = MAC_NUBUS,
354 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 334 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
355 }, 335 },
356 336
357 /* 337 /*
358 * Some Mac LC machines. Basically the same as the IIci, ADB like IIsi 338 * Some Mac LC machines. Basically the same as the IIci, ADB like IIsi
359 */ 339 */
360 340
361 { 341 {
@@ -366,7 +346,7 @@ static struct mac_model mac_data_table[] = {
366 .scsi_type = MAC_SCSI_OLD, 346 .scsi_type = MAC_SCSI_OLD,
367 .scc_type = MAC_SCC_II, 347 .scc_type = MAC_SCC_II,
368 .nubus_type = MAC_NUBUS, 348 .nubus_type = MAC_NUBUS,
369 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 349 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
370 }, { 350 }, {
371 .ident = MAC_MODEL_LCII, 351 .ident = MAC_MODEL_LCII,
372 .name = "LC II", 352 .name = "LC II",
@@ -375,7 +355,7 @@ static struct mac_model mac_data_table[] = {
375 .scsi_type = MAC_SCSI_OLD, 355 .scsi_type = MAC_SCSI_OLD,
376 .scc_type = MAC_SCC_II, 356 .scc_type = MAC_SCC_II,
377 .nubus_type = MAC_NUBUS, 357 .nubus_type = MAC_NUBUS,
378 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 358 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
379 }, { 359 }, {
380 .ident = MAC_MODEL_LCIII, 360 .ident = MAC_MODEL_LCIII,
381 .name = "LC III", 361 .name = "LC III",
@@ -384,17 +364,17 @@ static struct mac_model mac_data_table[] = {
384 .scsi_type = MAC_SCSI_OLD, 364 .scsi_type = MAC_SCSI_OLD,
385 .scc_type = MAC_SCC_II, 365 .scc_type = MAC_SCC_II,
386 .nubus_type = MAC_NUBUS, 366 .nubus_type = MAC_NUBUS,
387 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 367 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
388 }, 368 },
389 369
390 /* 370 /*
391 * Quadra. Video is at 0xF9000000, via is like a MacII. We label it differently 371 * Quadra. Video is at 0xF9000000, via is like a MacII. We label it
392 * as some of the stuff connected to VIA2 seems different. Better SCSI chip and 372 * differently as some of the stuff connected to VIA2 seems different.
393 * onboard ethernet using a NatSemi SONIC except the 660AV and 840AV which use an 373 * Better SCSI chip and onboard ethernet using a NatSemi SONIC except
394 * AMD 79C940 (MACE). 374 * the 660AV and 840AV which use an AMD 79C940 (MACE).
395 * The 700, 900 and 950 have some I/O chips in the wrong place to 375 * The 700, 900 and 950 have some I/O chips in the wrong place to
396 * confuse us. The 840AV has a SCSI location of its own (same as 376 * confuse us. The 840AV has a SCSI location of its own (same as
397 * the 660AV). 377 * the 660AV).
398 */ 378 */
399 379
400 { 380 {
@@ -405,7 +385,7 @@ static struct mac_model mac_data_table[] = {
405 .scsi_type = MAC_SCSI_QUADRA, 385 .scsi_type = MAC_SCSI_QUADRA,
406 .scc_type = MAC_SCC_QUADRA, 386 .scc_type = MAC_SCC_QUADRA,
407 .nubus_type = MAC_NUBUS, 387 .nubus_type = MAC_NUBUS,
408 .floppy_type = MAC_FLOPPY_SWIM_ADDR1 388 .floppy_type = MAC_FLOPPY_SWIM_ADDR1,
409 }, { 389 }, {
410 .ident = MAC_MODEL_Q605_ACC, 390 .ident = MAC_MODEL_Q605_ACC,
411 .name = "Quadra 605", 391 .name = "Quadra 605",
@@ -414,7 +394,7 @@ static struct mac_model mac_data_table[] = {
414 .scsi_type = MAC_SCSI_QUADRA, 394 .scsi_type = MAC_SCSI_QUADRA,
415 .scc_type = MAC_SCC_QUADRA, 395 .scc_type = MAC_SCC_QUADRA,
416 .nubus_type = MAC_NUBUS, 396 .nubus_type = MAC_NUBUS,
417 .floppy_type = MAC_FLOPPY_SWIM_ADDR1 397 .floppy_type = MAC_FLOPPY_SWIM_ADDR1,
418 }, { 398 }, {
419 .ident = MAC_MODEL_Q610, 399 .ident = MAC_MODEL_Q610,
420 .name = "Quadra 610", 400 .name = "Quadra 610",
@@ -424,7 +404,7 @@ static struct mac_model mac_data_table[] = {
424 .scc_type = MAC_SCC_QUADRA, 404 .scc_type = MAC_SCC_QUADRA,
425 .ether_type = MAC_ETHER_SONIC, 405 .ether_type = MAC_ETHER_SONIC,
426 .nubus_type = MAC_NUBUS, 406 .nubus_type = MAC_NUBUS,
427 .floppy_type = MAC_FLOPPY_SWIM_ADDR1 407 .floppy_type = MAC_FLOPPY_SWIM_ADDR1,
428 }, { 408 }, {
429 .ident = MAC_MODEL_Q630, 409 .ident = MAC_MODEL_Q630,
430 .name = "Quadra 630", 410 .name = "Quadra 630",
@@ -435,7 +415,7 @@ static struct mac_model mac_data_table[] = {
435 .scc_type = MAC_SCC_QUADRA, 415 .scc_type = MAC_SCC_QUADRA,
436 .ether_type = MAC_ETHER_SONIC, 416 .ether_type = MAC_ETHER_SONIC,
437 .nubus_type = MAC_NUBUS, 417 .nubus_type = MAC_NUBUS,
438 .floppy_type = MAC_FLOPPY_SWIM_ADDR1 418 .floppy_type = MAC_FLOPPY_SWIM_ADDR1,
439 }, { 419 }, {
440 .ident = MAC_MODEL_Q650, 420 .ident = MAC_MODEL_Q650,
441 .name = "Quadra 650", 421 .name = "Quadra 650",
@@ -445,9 +425,9 @@ static struct mac_model mac_data_table[] = {
445 .scc_type = MAC_SCC_QUADRA, 425 .scc_type = MAC_SCC_QUADRA,
446 .ether_type = MAC_ETHER_SONIC, 426 .ether_type = MAC_ETHER_SONIC,
447 .nubus_type = MAC_NUBUS, 427 .nubus_type = MAC_NUBUS,
448 .floppy_type = MAC_FLOPPY_SWIM_ADDR1 428 .floppy_type = MAC_FLOPPY_SWIM_ADDR1,
449 }, 429 },
450 /* The Q700 does have a NS Sonic */ 430 /* The Q700 does have a NS Sonic */
451 { 431 {
452 .ident = MAC_MODEL_Q700, 432 .ident = MAC_MODEL_Q700,
453 .name = "Quadra 700", 433 .name = "Quadra 700",
@@ -457,7 +437,7 @@ static struct mac_model mac_data_table[] = {
457 .scc_type = MAC_SCC_QUADRA, 437 .scc_type = MAC_SCC_QUADRA,
458 .ether_type = MAC_ETHER_SONIC, 438 .ether_type = MAC_ETHER_SONIC,
459 .nubus_type = MAC_NUBUS, 439 .nubus_type = MAC_NUBUS,
460 .floppy_type = MAC_FLOPPY_SWIM_ADDR1 440 .floppy_type = MAC_FLOPPY_SWIM_ADDR1,
461 }, { 441 }, {
462 .ident = MAC_MODEL_Q800, 442 .ident = MAC_MODEL_Q800,
463 .name = "Quadra 800", 443 .name = "Quadra 800",
@@ -467,7 +447,7 @@ static struct mac_model mac_data_table[] = {
467 .scc_type = MAC_SCC_QUADRA, 447 .scc_type = MAC_SCC_QUADRA,
468 .ether_type = MAC_ETHER_SONIC, 448 .ether_type = MAC_ETHER_SONIC,
469 .nubus_type = MAC_NUBUS, 449 .nubus_type = MAC_NUBUS,
470 .floppy_type = MAC_FLOPPY_SWIM_ADDR1 450 .floppy_type = MAC_FLOPPY_SWIM_ADDR1,
471 }, { 451 }, {
472 .ident = MAC_MODEL_Q840, 452 .ident = MAC_MODEL_Q840,
473 .name = "Quadra 840AV", 453 .name = "Quadra 840AV",
@@ -477,7 +457,7 @@ static struct mac_model mac_data_table[] = {
477 .scc_type = MAC_SCC_PSC, 457 .scc_type = MAC_SCC_PSC,
478 .ether_type = MAC_ETHER_MACE, 458 .ether_type = MAC_ETHER_MACE,
479 .nubus_type = MAC_NUBUS, 459 .nubus_type = MAC_NUBUS,
480 .floppy_type = MAC_FLOPPY_AV 460 .floppy_type = MAC_FLOPPY_AV,
481 }, { 461 }, {
482 .ident = MAC_MODEL_Q900, 462 .ident = MAC_MODEL_Q900,
483 .name = "Quadra 900", 463 .name = "Quadra 900",
@@ -487,7 +467,7 @@ static struct mac_model mac_data_table[] = {
487 .scc_type = MAC_SCC_IOP, 467 .scc_type = MAC_SCC_IOP,
488 .ether_type = MAC_ETHER_SONIC, 468 .ether_type = MAC_ETHER_SONIC,
489 .nubus_type = MAC_NUBUS, 469 .nubus_type = MAC_NUBUS,
490 .floppy_type = MAC_FLOPPY_SWIM_IOP 470 .floppy_type = MAC_FLOPPY_SWIM_IOP,
491 }, { 471 }, {
492 .ident = MAC_MODEL_Q950, 472 .ident = MAC_MODEL_Q950,
493 .name = "Quadra 950", 473 .name = "Quadra 950",
@@ -497,60 +477,60 @@ static struct mac_model mac_data_table[] = {
497 .scc_type = MAC_SCC_IOP, 477 .scc_type = MAC_SCC_IOP,
498 .ether_type = MAC_ETHER_SONIC, 478 .ether_type = MAC_ETHER_SONIC,
499 .nubus_type = MAC_NUBUS, 479 .nubus_type = MAC_NUBUS,
500 .floppy_type = MAC_FLOPPY_SWIM_IOP 480 .floppy_type = MAC_FLOPPY_SWIM_IOP,
501 }, 481 },
502 482
503 /* 483 /*
504 * Performa - more LC type machines 484 * Performa - more LC type machines
505 */ 485 */
506 486
507 { 487 {
508 .ident = MAC_MODEL_P460, 488 .ident = MAC_MODEL_P460,
509 .name = "Performa 460", 489 .name = "Performa 460",
510 .adb_type = MAC_ADB_IISI, 490 .adb_type = MAC_ADB_IISI,
511 .via_type = MAC_VIA_IIci, 491 .via_type = MAC_VIA_IIci,
512 .scsi_type = MAC_SCSI_OLD, 492 .scsi_type = MAC_SCSI_OLD,
513 .scc_type = MAC_SCC_II, 493 .scc_type = MAC_SCC_II,
514 .nubus_type = MAC_NUBUS, 494 .nubus_type = MAC_NUBUS,
515 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 495 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
516 }, { 496 }, {
517 .ident = MAC_MODEL_P475, 497 .ident = MAC_MODEL_P475,
518 .name = "Performa 475", 498 .name = "Performa 475",
519 .adb_type = MAC_ADB_CUDA, 499 .adb_type = MAC_ADB_CUDA,
520 .via_type = MAC_VIA_QUADRA, 500 .via_type = MAC_VIA_QUADRA,
521 .scsi_type = MAC_SCSI_QUADRA, 501 .scsi_type = MAC_SCSI_QUADRA,
522 .scc_type = MAC_SCC_II, 502 .scc_type = MAC_SCC_II,
523 .nubus_type = MAC_NUBUS, 503 .nubus_type = MAC_NUBUS,
524 .floppy_type = MAC_FLOPPY_SWIM_ADDR1 504 .floppy_type = MAC_FLOPPY_SWIM_ADDR1,
525 }, { 505 }, {
526 .ident = MAC_MODEL_P475F, 506 .ident = MAC_MODEL_P475F,
527 .name = "Performa 475", 507 .name = "Performa 475",
528 .adb_type = MAC_ADB_CUDA, 508 .adb_type = MAC_ADB_CUDA,
529 .via_type = MAC_VIA_QUADRA, 509 .via_type = MAC_VIA_QUADRA,
530 .scsi_type = MAC_SCSI_QUADRA, 510 .scsi_type = MAC_SCSI_QUADRA,
531 .scc_type = MAC_SCC_II, 511 .scc_type = MAC_SCC_II,
532 .nubus_type = MAC_NUBUS, 512 .nubus_type = MAC_NUBUS,
533 .floppy_type = MAC_FLOPPY_SWIM_ADDR1 513 .floppy_type = MAC_FLOPPY_SWIM_ADDR1,
534 }, { 514 }, {
535 .ident = MAC_MODEL_P520, 515 .ident = MAC_MODEL_P520,
536 .name = "Performa 520", 516 .name = "Performa 520",
537 .adb_type = MAC_ADB_CUDA, 517 .adb_type = MAC_ADB_CUDA,
538 .via_type = MAC_VIA_IIci, 518 .via_type = MAC_VIA_IIci,
539 .scsi_type = MAC_SCSI_OLD, 519 .scsi_type = MAC_SCSI_OLD,
540 .scc_type = MAC_SCC_II, 520 .scc_type = MAC_SCC_II,
541 .nubus_type = MAC_NUBUS, 521 .nubus_type = MAC_NUBUS,
542 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 522 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
543 }, { 523 }, {
544 .ident = MAC_MODEL_P550, 524 .ident = MAC_MODEL_P550,
545 .name = "Performa 550", 525 .name = "Performa 550",
546 .adb_type = MAC_ADB_CUDA, 526 .adb_type = MAC_ADB_CUDA,
547 .via_type = MAC_VIA_IIci, 527 .via_type = MAC_VIA_IIci,
548 .scsi_type = MAC_SCSI_OLD, 528 .scsi_type = MAC_SCSI_OLD,
549 .scc_type = MAC_SCC_II, 529 .scc_type = MAC_SCC_II,
550 .nubus_type = MAC_NUBUS, 530 .nubus_type = MAC_NUBUS,
551 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 531 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
552 }, 532 },
553 /* These have the comm slot, and therefore the possibility of SONIC ethernet */ 533 /* These have the comm slot, and therefore possibly SONIC ethernet */
554 { 534 {
555 .ident = MAC_MODEL_P575, 535 .ident = MAC_MODEL_P575,
556 .name = "Performa 575", 536 .name = "Performa 575",
@@ -560,7 +540,7 @@ static struct mac_model mac_data_table[] = {
560 .scc_type = MAC_SCC_II, 540 .scc_type = MAC_SCC_II,
561 .ether_type = MAC_ETHER_SONIC, 541 .ether_type = MAC_ETHER_SONIC,
562 .nubus_type = MAC_NUBUS, 542 .nubus_type = MAC_NUBUS,
563 .floppy_type = MAC_FLOPPY_SWIM_ADDR1 543 .floppy_type = MAC_FLOPPY_SWIM_ADDR1,
564 }, { 544 }, {
565 .ident = MAC_MODEL_P588, 545 .ident = MAC_MODEL_P588,
566 .name = "Performa 588", 546 .name = "Performa 588",
@@ -571,7 +551,7 @@ static struct mac_model mac_data_table[] = {
571 .scc_type = MAC_SCC_II, 551 .scc_type = MAC_SCC_II,
572 .ether_type = MAC_ETHER_SONIC, 552 .ether_type = MAC_ETHER_SONIC,
573 .nubus_type = MAC_NUBUS, 553 .nubus_type = MAC_NUBUS,
574 .floppy_type = MAC_FLOPPY_SWIM_ADDR1 554 .floppy_type = MAC_FLOPPY_SWIM_ADDR1,
575 }, { 555 }, {
576 .ident = MAC_MODEL_TV, 556 .ident = MAC_MODEL_TV,
577 .name = "TV", 557 .name = "TV",
@@ -580,7 +560,7 @@ static struct mac_model mac_data_table[] = {
580 .scsi_type = MAC_SCSI_OLD, 560 .scsi_type = MAC_SCSI_OLD,
581 .scc_type = MAC_SCC_II, 561 .scc_type = MAC_SCC_II,
582 .nubus_type = MAC_NUBUS, 562 .nubus_type = MAC_NUBUS,
583 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 563 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
584 }, { 564 }, {
585 .ident = MAC_MODEL_P600, 565 .ident = MAC_MODEL_P600,
586 .name = "Performa 600", 566 .name = "Performa 600",
@@ -589,14 +569,14 @@ static struct mac_model mac_data_table[] = {
589 .scsi_type = MAC_SCSI_OLD, 569 .scsi_type = MAC_SCSI_OLD,
590 .scc_type = MAC_SCC_II, 570 .scc_type = MAC_SCC_II,
591 .nubus_type = MAC_NUBUS, 571 .nubus_type = MAC_NUBUS,
592 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 572 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
593 }, 573 },
594 574
595 /* 575 /*
596 * Centris - just guessing again; maybe like Quadra 576 * Centris - just guessing again; maybe like Quadra.
577 * The C610 may or may not have SONIC. We probe to make sure.
597 */ 578 */
598 579
599 /* The C610 may or may not have SONIC. We probe to make sure */
600 { 580 {
601 .ident = MAC_MODEL_C610, 581 .ident = MAC_MODEL_C610,
602 .name = "Centris 610", 582 .name = "Centris 610",
@@ -606,7 +586,7 @@ static struct mac_model mac_data_table[] = {
606 .scc_type = MAC_SCC_QUADRA, 586 .scc_type = MAC_SCC_QUADRA,
607 .ether_type = MAC_ETHER_SONIC, 587 .ether_type = MAC_ETHER_SONIC,
608 .nubus_type = MAC_NUBUS, 588 .nubus_type = MAC_NUBUS,
609 .floppy_type = MAC_FLOPPY_SWIM_ADDR1 589 .floppy_type = MAC_FLOPPY_SWIM_ADDR1,
610 }, { 590 }, {
611 .ident = MAC_MODEL_C650, 591 .ident = MAC_MODEL_C650,
612 .name = "Centris 650", 592 .name = "Centris 650",
@@ -616,7 +596,7 @@ static struct mac_model mac_data_table[] = {
616 .scc_type = MAC_SCC_QUADRA, 596 .scc_type = MAC_SCC_QUADRA,
617 .ether_type = MAC_ETHER_SONIC, 597 .ether_type = MAC_ETHER_SONIC,
618 .nubus_type = MAC_NUBUS, 598 .nubus_type = MAC_NUBUS,
619 .floppy_type = MAC_FLOPPY_SWIM_ADDR1 599 .floppy_type = MAC_FLOPPY_SWIM_ADDR1,
620 }, { 600 }, {
621 .ident = MAC_MODEL_C660, 601 .ident = MAC_MODEL_C660,
622 .name = "Centris 660AV", 602 .name = "Centris 660AV",
@@ -626,7 +606,7 @@ static struct mac_model mac_data_table[] = {
626 .scc_type = MAC_SCC_PSC, 606 .scc_type = MAC_SCC_PSC,
627 .ether_type = MAC_ETHER_MACE, 607 .ether_type = MAC_ETHER_MACE,
628 .nubus_type = MAC_NUBUS, 608 .nubus_type = MAC_NUBUS,
629 .floppy_type = MAC_FLOPPY_AV 609 .floppy_type = MAC_FLOPPY_AV,
630 }, 610 },
631 611
632 /* 612 /*
@@ -643,7 +623,7 @@ static struct mac_model mac_data_table[] = {
643 .scsi_type = MAC_SCSI_OLD, 623 .scsi_type = MAC_SCSI_OLD,
644 .scc_type = MAC_SCC_QUADRA, 624 .scc_type = MAC_SCC_QUADRA,
645 .nubus_type = MAC_NUBUS, 625 .nubus_type = MAC_NUBUS,
646 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 626 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
647 }, { 627 }, {
648 .ident = MAC_MODEL_PB145, 628 .ident = MAC_MODEL_PB145,
649 .name = "PowerBook 145", 629 .name = "PowerBook 145",
@@ -652,7 +632,7 @@ static struct mac_model mac_data_table[] = {
652 .scsi_type = MAC_SCSI_OLD, 632 .scsi_type = MAC_SCSI_OLD,
653 .scc_type = MAC_SCC_QUADRA, 633 .scc_type = MAC_SCC_QUADRA,
654 .nubus_type = MAC_NUBUS, 634 .nubus_type = MAC_NUBUS,
655 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 635 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
656 }, { 636 }, {
657 .ident = MAC_MODEL_PB150, 637 .ident = MAC_MODEL_PB150,
658 .name = "PowerBook 150", 638 .name = "PowerBook 150",
@@ -662,7 +642,7 @@ static struct mac_model mac_data_table[] = {
662 .ide_type = MAC_IDE_PB, 642 .ide_type = MAC_IDE_PB,
663 .scc_type = MAC_SCC_QUADRA, 643 .scc_type = MAC_SCC_QUADRA,
664 .nubus_type = MAC_NUBUS, 644 .nubus_type = MAC_NUBUS,
665 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 645 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
666 }, { 646 }, {
667 .ident = MAC_MODEL_PB160, 647 .ident = MAC_MODEL_PB160,
668 .name = "PowerBook 160", 648 .name = "PowerBook 160",
@@ -671,7 +651,7 @@ static struct mac_model mac_data_table[] = {
671 .scsi_type = MAC_SCSI_OLD, 651 .scsi_type = MAC_SCSI_OLD,
672 .scc_type = MAC_SCC_QUADRA, 652 .scc_type = MAC_SCC_QUADRA,
673 .nubus_type = MAC_NUBUS, 653 .nubus_type = MAC_NUBUS,
674 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 654 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
675 }, { 655 }, {
676 .ident = MAC_MODEL_PB165, 656 .ident = MAC_MODEL_PB165,
677 .name = "PowerBook 165", 657 .name = "PowerBook 165",
@@ -680,7 +660,7 @@ static struct mac_model mac_data_table[] = {
680 .scsi_type = MAC_SCSI_OLD, 660 .scsi_type = MAC_SCSI_OLD,
681 .scc_type = MAC_SCC_QUADRA, 661 .scc_type = MAC_SCC_QUADRA,
682 .nubus_type = MAC_NUBUS, 662 .nubus_type = MAC_NUBUS,
683 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 663 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
684 }, { 664 }, {
685 .ident = MAC_MODEL_PB165C, 665 .ident = MAC_MODEL_PB165C,
686 .name = "PowerBook 165c", 666 .name = "PowerBook 165c",
@@ -689,7 +669,7 @@ static struct mac_model mac_data_table[] = {
689 .scsi_type = MAC_SCSI_OLD, 669 .scsi_type = MAC_SCSI_OLD,
690 .scc_type = MAC_SCC_QUADRA, 670 .scc_type = MAC_SCC_QUADRA,
691 .nubus_type = MAC_NUBUS, 671 .nubus_type = MAC_NUBUS,
692 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 672 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
693 }, { 673 }, {
694 .ident = MAC_MODEL_PB170, 674 .ident = MAC_MODEL_PB170,
695 .name = "PowerBook 170", 675 .name = "PowerBook 170",
@@ -698,7 +678,7 @@ static struct mac_model mac_data_table[] = {
698 .scsi_type = MAC_SCSI_OLD, 678 .scsi_type = MAC_SCSI_OLD,
699 .scc_type = MAC_SCC_QUADRA, 679 .scc_type = MAC_SCC_QUADRA,
700 .nubus_type = MAC_NUBUS, 680 .nubus_type = MAC_NUBUS,
701 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 681 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
702 }, { 682 }, {
703 .ident = MAC_MODEL_PB180, 683 .ident = MAC_MODEL_PB180,
704 .name = "PowerBook 180", 684 .name = "PowerBook 180",
@@ -707,7 +687,7 @@ static struct mac_model mac_data_table[] = {
707 .scsi_type = MAC_SCSI_OLD, 687 .scsi_type = MAC_SCSI_OLD,
708 .scc_type = MAC_SCC_QUADRA, 688 .scc_type = MAC_SCC_QUADRA,
709 .nubus_type = MAC_NUBUS, 689 .nubus_type = MAC_NUBUS,
710 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 690 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
711 }, { 691 }, {
712 .ident = MAC_MODEL_PB180C, 692 .ident = MAC_MODEL_PB180C,
713 .name = "PowerBook 180c", 693 .name = "PowerBook 180c",
@@ -716,7 +696,7 @@ static struct mac_model mac_data_table[] = {
716 .scsi_type = MAC_SCSI_OLD, 696 .scsi_type = MAC_SCSI_OLD,
717 .scc_type = MAC_SCC_QUADRA, 697 .scc_type = MAC_SCC_QUADRA,
718 .nubus_type = MAC_NUBUS, 698 .nubus_type = MAC_NUBUS,
719 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 699 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
720 }, { 700 }, {
721 .ident = MAC_MODEL_PB190, 701 .ident = MAC_MODEL_PB190,
722 .name = "PowerBook 190", 702 .name = "PowerBook 190",
@@ -726,7 +706,7 @@ static struct mac_model mac_data_table[] = {
726 .ide_type = MAC_IDE_BABOON, 706 .ide_type = MAC_IDE_BABOON,
727 .scc_type = MAC_SCC_QUADRA, 707 .scc_type = MAC_SCC_QUADRA,
728 .nubus_type = MAC_NUBUS, 708 .nubus_type = MAC_NUBUS,
729 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 709 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
730 }, { 710 }, {
731 .ident = MAC_MODEL_PB520, 711 .ident = MAC_MODEL_PB520,
732 .name = "PowerBook 520", 712 .name = "PowerBook 520",
@@ -736,7 +716,7 @@ static struct mac_model mac_data_table[] = {
736 .scc_type = MAC_SCC_QUADRA, 716 .scc_type = MAC_SCC_QUADRA,
737 .ether_type = MAC_ETHER_SONIC, 717 .ether_type = MAC_ETHER_SONIC,
738 .nubus_type = MAC_NUBUS, 718 .nubus_type = MAC_NUBUS,
739 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 719 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
740 }, 720 },
741 721
742 /* 722 /*
@@ -757,7 +737,7 @@ static struct mac_model mac_data_table[] = {
757 .scsi_type = MAC_SCSI_OLD, 737 .scsi_type = MAC_SCSI_OLD,
758 .scc_type = MAC_SCC_QUADRA, 738 .scc_type = MAC_SCC_QUADRA,
759 .nubus_type = MAC_NUBUS, 739 .nubus_type = MAC_NUBUS,
760 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 740 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
761 }, { 741 }, {
762 .ident = MAC_MODEL_PB230, 742 .ident = MAC_MODEL_PB230,
763 .name = "PowerBook Duo 230", 743 .name = "PowerBook Duo 230",
@@ -766,7 +746,7 @@ static struct mac_model mac_data_table[] = {
766 .scsi_type = MAC_SCSI_OLD, 746 .scsi_type = MAC_SCSI_OLD,
767 .scc_type = MAC_SCC_QUADRA, 747 .scc_type = MAC_SCC_QUADRA,
768 .nubus_type = MAC_NUBUS, 748 .nubus_type = MAC_NUBUS,
769 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 749 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
770 }, { 750 }, {
771 .ident = MAC_MODEL_PB250, 751 .ident = MAC_MODEL_PB250,
772 .name = "PowerBook Duo 250", 752 .name = "PowerBook Duo 250",
@@ -775,7 +755,7 @@ static struct mac_model mac_data_table[] = {
775 .scsi_type = MAC_SCSI_OLD, 755 .scsi_type = MAC_SCSI_OLD,
776 .scc_type = MAC_SCC_QUADRA, 756 .scc_type = MAC_SCC_QUADRA,
777 .nubus_type = MAC_NUBUS, 757 .nubus_type = MAC_NUBUS,
778 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 758 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
779 }, { 759 }, {
780 .ident = MAC_MODEL_PB270C, 760 .ident = MAC_MODEL_PB270C,
781 .name = "PowerBook Duo 270c", 761 .name = "PowerBook Duo 270c",
@@ -784,7 +764,7 @@ static struct mac_model mac_data_table[] = {
784 .scsi_type = MAC_SCSI_OLD, 764 .scsi_type = MAC_SCSI_OLD,
785 .scc_type = MAC_SCC_QUADRA, 765 .scc_type = MAC_SCC_QUADRA,
786 .nubus_type = MAC_NUBUS, 766 .nubus_type = MAC_NUBUS,
787 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 767 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
788 }, { 768 }, {
789 .ident = MAC_MODEL_PB280, 769 .ident = MAC_MODEL_PB280,
790 .name = "PowerBook Duo 280", 770 .name = "PowerBook Duo 280",
@@ -793,7 +773,7 @@ static struct mac_model mac_data_table[] = {
793 .scsi_type = MAC_SCSI_OLD, 773 .scsi_type = MAC_SCSI_OLD,
794 .scc_type = MAC_SCC_QUADRA, 774 .scc_type = MAC_SCC_QUADRA,
795 .nubus_type = MAC_NUBUS, 775 .nubus_type = MAC_NUBUS,
796 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 776 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
797 }, { 777 }, {
798 .ident = MAC_MODEL_PB280C, 778 .ident = MAC_MODEL_PB280C,
799 .name = "PowerBook Duo 280c", 779 .name = "PowerBook Duo 280c",
@@ -802,17 +782,44 @@ static struct mac_model mac_data_table[] = {
802 .scsi_type = MAC_SCSI_OLD, 782 .scsi_type = MAC_SCSI_OLD,
803 .scc_type = MAC_SCC_QUADRA, 783 .scc_type = MAC_SCC_QUADRA,
804 .nubus_type = MAC_NUBUS, 784 .nubus_type = MAC_NUBUS,
805 .floppy_type = MAC_FLOPPY_SWIM_ADDR2 785 .floppy_type = MAC_FLOPPY_SWIM_ADDR2,
806 }, 786 },
807 787
808 /* 788 /*
809 * Other stuff ?? 789 * Other stuff?
810 */ 790 */
791
811 { 792 {
812 .ident = -1 793 .ident = -1
813 } 794 }
814}; 795};
815 796
797static struct resource scc_a_rsrcs[] = {
798 { .flags = IORESOURCE_MEM },
799 { .flags = IORESOURCE_IRQ },
800};
801
802static struct resource scc_b_rsrcs[] = {
803 { .flags = IORESOURCE_MEM },
804 { .flags = IORESOURCE_IRQ },
805};
806
807struct platform_device scc_a_pdev = {
808 .name = "scc",
809 .id = 0,
810 .num_resources = ARRAY_SIZE(scc_a_rsrcs),
811 .resource = scc_a_rsrcs,
812};
813EXPORT_SYMBOL(scc_a_pdev);
814
815struct platform_device scc_b_pdev = {
816 .name = "scc",
817 .id = 1,
818 .num_resources = ARRAY_SIZE(scc_b_rsrcs),
819 .resource = scc_b_rsrcs,
820};
821EXPORT_SYMBOL(scc_b_pdev);
822
816static void __init mac_identify(void) 823static void __init mac_identify(void)
817{ 824{
818 struct mac_model *m; 825 struct mac_model *m;
@@ -823,7 +830,8 @@ static void __init mac_identify(void)
823 /* no bootinfo model id -> NetBSD booter was used! */ 830 /* no bootinfo model id -> NetBSD booter was used! */
824 /* XXX FIXME: breaks for model > 31 */ 831 /* XXX FIXME: breaks for model > 31 */
825 model = (mac_bi_data.cpuid >> 2) & 63; 832 model = (mac_bi_data.cpuid >> 2) & 63;
826 printk(KERN_WARNING "No bootinfo model ID, using cpuid instead (hey, use Penguin!)\n"); 833 printk(KERN_WARNING "No bootinfo model ID, using cpuid instead "
834 "(obsolete bootloader?)\n");
827 } 835 }
828 836
829 macintosh_config = mac_data_table; 837 macintosh_config = mac_data_table;
@@ -834,10 +842,29 @@ static void __init mac_identify(void)
834 } 842 }
835 } 843 }
836 844
837 /* We need to pre-init the IOPs, if any. Otherwise */ 845 /* Set up serial port resources for the console initcall. */
838 /* the serial console won't work if the user had */ 846
839 /* the serial ports set to "Faster" mode in MacOS. */ 847 scc_a_rsrcs[0].start = (resource_size_t) mac_bi_data.sccbase + 2;
848 scc_a_rsrcs[0].end = scc_a_rsrcs[0].start;
849 scc_b_rsrcs[0].start = (resource_size_t) mac_bi_data.sccbase;
850 scc_b_rsrcs[0].end = scc_b_rsrcs[0].start;
840 851
852 switch (macintosh_config->scc_type) {
853 case MAC_SCC_PSC:
854 scc_a_rsrcs[1].start = scc_a_rsrcs[1].end = IRQ_MAC_SCC_A;
855 scc_b_rsrcs[1].start = scc_b_rsrcs[1].end = IRQ_MAC_SCC_B;
856 break;
857 default:
858 scc_a_rsrcs[1].start = scc_a_rsrcs[1].end = IRQ_MAC_SCC;
859 scc_b_rsrcs[1].start = scc_b_rsrcs[1].end = IRQ_MAC_SCC;
860 break;
861 }
862
863 /*
864 * We need to pre-init the IOPs, if any. Otherwise
865 * the serial console won't work if the user had
866 * the serial ports set to "Faster" mode in MacOS.
867 */
841 iop_preinit(); 868 iop_preinit();
842 869
843 printk(KERN_INFO "Detected Macintosh model: %d \n", model); 870 printk(KERN_INFO "Detected Macintosh model: %d \n", model);
@@ -846,7 +873,8 @@ static void __init mac_identify(void)
846 * Report booter data: 873 * Report booter data:
847 */ 874 */
848 printk(KERN_DEBUG " Penguin bootinfo data:\n"); 875 printk(KERN_DEBUG " Penguin bootinfo data:\n");
849 printk(KERN_DEBUG " Video: addr 0x%lx row 0x%lx depth %lx dimensions %ld x %ld\n", 876 printk(KERN_DEBUG " Video: addr 0x%lx "
877 "row 0x%lx depth %lx dimensions %ld x %ld\n",
850 mac_bi_data.videoaddr, mac_bi_data.videorow, 878 mac_bi_data.videoaddr, mac_bi_data.videorow,
851 mac_bi_data.videodepth, mac_bi_data.dimensions & 0xFFFF, 879 mac_bi_data.videodepth, mac_bi_data.dimensions & 0xFFFF,
852 mac_bi_data.dimensions >> 16); 880 mac_bi_data.dimensions >> 16);
@@ -863,6 +891,10 @@ static void __init mac_identify(void)
863 oss_init(); 891 oss_init();
864 psc_init(); 892 psc_init();
865 baboon_init(); 893 baboon_init();
894
895#ifdef CONFIG_ADB_CUDA
896 find_via_cuda();
897#endif
866} 898}
867 899
868static void __init mac_report_hardware(void) 900static void __init mac_report_hardware(void)
@@ -876,23 +908,50 @@ static void mac_get_model(char *str)
876 strcat(str, macintosh_config->name); 908 strcat(str, macintosh_config->name);
877} 909}
878 910
879static struct resource swim_resources[1]; 911static struct resource swim_rsrc = { .flags = IORESOURCE_MEM };
880 912
881static struct platform_device swim_device = { 913static struct platform_device swim_pdev = {
882 .name = "swim", 914 .name = "swim",
883 .id = -1, 915 .id = -1,
884 .num_resources = ARRAY_SIZE(swim_resources), 916 .num_resources = 1,
885 .resource = swim_resources, 917 .resource = &swim_rsrc,
886}; 918};
887 919
888static struct platform_device *mac_platform_devices[] __initdata = { 920static struct platform_device esp_0_pdev = {
889 &swim_device 921 .name = "mac_esp",
922 .id = 0,
923};
924
925static struct platform_device esp_1_pdev = {
926 .name = "mac_esp",
927 .id = 1,
928};
929
930static struct platform_device sonic_pdev = {
931 .name = "macsonic",
932 .id = -1,
933};
934
935static struct platform_device mace_pdev = {
936 .name = "macmace",
937 .id = -1,
890}; 938};
891 939
892int __init mac_platform_init(void) 940int __init mac_platform_init(void)
893{ 941{
894 u8 *swim_base; 942 u8 *swim_base;
895 943
944 /*
945 * Serial devices
946 */
947
948 platform_device_register(&scc_a_pdev);
949 platform_device_register(&scc_b_pdev);
950
951 /*
952 * Floppy device
953 */
954
896 switch (macintosh_config->floppy_type) { 955 switch (macintosh_config->floppy_type) {
897 case MAC_FLOPPY_SWIM_ADDR1: 956 case MAC_FLOPPY_SWIM_ADDR1:
898 swim_base = (u8 *)(VIA1_BASE + 0x1E000); 957 swim_base = (u8 *)(VIA1_BASE + 0x1E000);
@@ -901,16 +960,47 @@ int __init mac_platform_init(void)
901 swim_base = (u8 *)(VIA1_BASE + 0x16000); 960 swim_base = (u8 *)(VIA1_BASE + 0x16000);
902 break; 961 break;
903 default: 962 default:
904 return 0; 963 swim_base = NULL;
964 break;
905 } 965 }
906 966
907 swim_resources[0].name = "swim-regs"; 967 if (swim_base) {
908 swim_resources[0].start = (resource_size_t)swim_base; 968 swim_rsrc.start = (resource_size_t) swim_base,
909 swim_resources[0].end = (resource_size_t)(swim_base + SWIM_IO_SIZE); 969 swim_rsrc.end = (resource_size_t) swim_base + 0x2000,
910 swim_resources[0].flags = IORESOURCE_MEM; 970 platform_device_register(&swim_pdev);
971 }
972
973 /*
974 * SCSI device(s)
975 */
976
977 switch (macintosh_config->scsi_type) {
978 case MAC_SCSI_QUADRA:
979 case MAC_SCSI_QUADRA3:
980 platform_device_register(&esp_0_pdev);
981 break;
982 case MAC_SCSI_QUADRA2:
983 platform_device_register(&esp_0_pdev);
984 if ((macintosh_config->ident == MAC_MODEL_Q900) ||
985 (macintosh_config->ident == MAC_MODEL_Q950))
986 platform_device_register(&esp_1_pdev);
987 break;
988 }
989
990 /*
991 * Ethernet device
992 */
993
994 switch (macintosh_config->ether_type) {
995 case MAC_ETHER_SONIC:
996 platform_device_register(&sonic_pdev);
997 break;
998 case MAC_ETHER_MACE:
999 platform_device_register(&mace_pdev);
1000 break;
1001 }
911 1002
912 return platform_add_devices(mac_platform_devices, 1003 return 0;
913 ARRAY_SIZE(mac_platform_devices));
914} 1004}
915 1005
916arch_initcall(mac_platform_init); 1006arch_initcall(mac_platform_init);
diff --git a/arch/m68k/mac/debug.c b/arch/m68k/mac/debug.c
deleted file mode 100644
index bce074ceb768..000000000000
--- a/arch/m68k/mac/debug.c
+++ /dev/null
@@ -1,365 +0,0 @@
1/*
2 * linux/arch/m68k/mac/debug.c
3 *
4 * Shamelessly stolen (SCC code and general framework) from:
5 *
6 * linux/arch/m68k/atari/debug.c
7 *
8 * Atari debugging and serial console stuff
9 *
10 * Assembled of parts of former atari/config.c 97-12-18 by Roman Hodek
11 *
12 * This file is subject to the terms and conditions of the GNU General Public
13 * License. See the file COPYING in the main directory of this archive
14 * for more details.
15 */
16
17#include <linux/types.h>
18#include <linux/sched.h>
19#include <linux/tty.h>
20#include <linux/console.h>
21#include <linux/init.h>
22#include <linux/delay.h>
23
24#define BOOTINFO_COMPAT_1_0
25#include <asm/setup.h>
26#include <asm/bootinfo.h>
27#include <asm/macints.h>
28
29extern unsigned long mac_videobase;
30extern unsigned long mac_rowbytes;
31
32extern void mac_serial_print(const char *);
33
34#define DEBUG_HEADS
35#undef DEBUG_SCREEN
36#define DEBUG_SERIAL
37
38/*
39 * These two auxiliary debug functions should go away ASAP. Only usage:
40 * before the console output is up (after head.S come some other crucial
41 * setup routines :-) it permits writing 'data' to the screen as bit patterns
42 * (good luck reading those). Helped to figure that the bootinfo contained
43 * garbage data on the amount and size of memory chunks ...
44 *
45 * The 'pos' argument now simply means 'linefeed after print' ...
46 */
47
48#ifdef DEBUG_SCREEN
49static int peng, line;
50#endif
51
52#if 0
53
54void mac_debugging_short(int pos, short num)
55{
56#ifdef DEBUG_SCREEN
57 unsigned char *pengoffset;
58 unsigned char *pptr;
59 int i;
60#endif
61
62#ifdef DEBUG_SERIAL
63 printk("debug: %d !\n", num);
64#endif
65
66#ifdef DEBUG_SCREEN
67 if (!MACH_IS_MAC) {
68 /* printk("debug: %d !\n", num); */
69 return;
70 }
71
72 /* calculate current offset */
73 pengoffset = (unsigned char *)mac_videobase +
74 (150+line*2) * mac_rowbytes + 80 * peng;
75
76 pptr = pengoffset;
77
78 for (i = 0; i < 8 * sizeof(short); i++) { /* # of bits */
79 /* value mask for bit i, reverse order */
80 *pptr++ = (num & (1 << (8*sizeof(short)-i-1)) ? 0xFF : 0x00);
81 }
82
83 peng++;
84
85 if (pos) {
86 line++;
87 peng = 0;
88 }
89#endif
90}
91
92void mac_debugging_long(int pos, long addr)
93{
94#ifdef DEBUG_SCREEN
95 unsigned char *pengoffset;
96 unsigned char *pptr;
97 int i;
98#endif
99
100#ifdef DEBUG_SERIAL
101 printk("debug: #%ld !\n", addr);
102#endif
103
104#ifdef DEBUG_SCREEN
105 if (!MACH_IS_MAC) {
106 /* printk("debug: #%ld !\n", addr); */
107 return;
108 }
109
110 pengoffset=(unsigned char *)(mac_videobase+(150+line*2)*mac_rowbytes)
111 +80*peng;
112
113 pptr = pengoffset;
114
115 for (i = 0; i < 8 * sizeof(long); i++) { /* # of bits */
116 *pptr++ = (addr & (1 << (8*sizeof(long)-i-1)) ? 0xFF : 0x00);
117 }
118
119 peng++;
120
121 if (pos) {
122 line++;
123 peng = 0;
124 }
125#endif
126}
127
128#endif /* 0 */
129
130#ifdef DEBUG_SERIAL
131/*
132 * TODO: serial debug code
133 */
134
135struct mac_SCC {
136 u_char cha_b_ctrl;
137 u_char char_dummy1;
138 u_char cha_a_ctrl;
139 u_char char_dummy2;
140 u_char cha_b_data;
141 u_char char_dummy3;
142 u_char cha_a_data;
143};
144
145# define scc (*((volatile struct mac_SCC*)mac_bi_data.sccbase))
146
147static int scc_port = -1;
148
149static struct console mac_console_driver = {
150 .name = "debug",
151 .flags = CON_PRINTBUFFER,
152 .index = -1,
153};
154
155/*
156 * Crude hack to get console output to the screen before the framebuffer
157 * is initialized (happens a lot later in 2.1!).
158 * We just use the console routines declared in head.S, this will interfere
159 * with regular framebuffer console output and should be used exclusively
160 * to debug kernel problems manifesting before framebuffer init (aka WSOD)
161 *
162 * To keep this hack from interfering with the regular console driver, either
163 * deregister this driver before/on framebuffer console init, or silence this
164 * function after the fbcon driver is running (will lose console messages!?).
165 * To debug real early bugs, need to write a 'mac_register_console_hack()'
166 * that is called from start_kernel() before setup_arch() and just registers
167 * this driver if Mac.
168 */
169
170static void mac_debug_console_write(struct console *co, const char *str,
171 unsigned int count)
172{
173 mac_serial_print(str);
174}
175
176
177
178/* Mac: loops_per_jiffy min. 19000 ^= .5 us; MFPDELAY was 0.6 us*/
179
180#define uSEC 1
181
182static inline void mac_sccb_out(char c)
183{
184 int i;
185
186 do {
187 for (i = uSEC; i > 0; --i)
188 barrier();
189 } while (!(scc.cha_b_ctrl & 0x04)); /* wait for tx buf empty */
190 for (i = uSEC; i > 0; --i)
191 barrier();
192 scc.cha_b_data = c;
193}
194
195static inline void mac_scca_out(char c)
196{
197 int i;
198
199 do {
200 for (i = uSEC; i > 0; --i)
201 barrier();
202 } while (!(scc.cha_a_ctrl & 0x04)); /* wait for tx buf empty */
203 for (i = uSEC; i > 0; --i)
204 barrier();
205 scc.cha_a_data = c;
206}
207
208static void mac_sccb_console_write(struct console *co, const char *str,
209 unsigned int count)
210{
211 while (count--) {
212 if (*str == '\n')
213 mac_sccb_out('\r');
214 mac_sccb_out(*str++);
215 }
216}
217
218static void mac_scca_console_write(struct console *co, const char *str,
219 unsigned int count)
220{
221 while (count--) {
222 if (*str == '\n')
223 mac_scca_out('\r');
224 mac_scca_out(*str++);
225 }
226}
227
228
229/* The following two functions do a quick'n'dirty initialization of the MFP or
230 * SCC serial ports. They're used by the debugging interface, kgdb, and the
231 * serial console code. */
232#define SCCB_WRITE(reg,val) \
233 do { \
234 int i; \
235 scc.cha_b_ctrl = (reg); \
236 for (i = uSEC; i > 0; --i) \
237 barrier(); \
238 scc.cha_b_ctrl = (val); \
239 for (i = uSEC; i > 0; --i) \
240 barrier(); \
241 } while(0)
242
243#define SCCA_WRITE(reg,val) \
244 do { \
245 int i; \
246 scc.cha_a_ctrl = (reg); \
247 for (i = uSEC; i > 0; --i) \
248 barrier(); \
249 scc.cha_a_ctrl = (val); \
250 for (i = uSEC; i > 0; --i) \
251 barrier(); \
252 } while(0)
253
254/* loops_per_jiffy isn't initialized yet, so we can't use udelay(). This does a
255 * delay of ~ 60us. */
256/* Mac: loops_per_jiffy min. 19000 ^= .5 us; MFPDELAY was 0.6 us*/
257#define LONG_DELAY() \
258 do { \
259 int i; \
260 for (i = 60*uSEC; i > 0; --i) \
261 barrier(); \
262 } while(0)
263
264static void __init mac_init_scc_port(int cflag, int port)
265{
266 /*
267 * baud rates: 1200, 1800, 2400, 4800, 9600, 19.2k, 38.4k, 57.6k, 115.2k
268 */
269
270 static int clksrc_table[9] =
271 /* reg 11: 0x50 = BRG, 0x00 = RTxC, 0x28 = TRxC */
272 { 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x00, 0x00 };
273 static int clkmode_table[9] =
274 /* reg 4: 0x40 = x16, 0x80 = x32, 0xc0 = x64 */
275 { 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0xc0, 0x80 };
276 static int div_table[9] =
277 /* reg12 (BRG low) */
278 { 94, 62, 46, 22, 10, 4, 1, 0, 0 };
279
280 int baud = cflag & CBAUD;
281 int clksrc, clkmode, div, reg3, reg5;
282
283 if (cflag & CBAUDEX)
284 baud += B38400;
285 if (baud < B1200 || baud > B38400+2)
286 baud = B9600; /* use default 9600bps for non-implemented rates */
287 baud -= B1200; /* tables starts at 1200bps */
288
289 clksrc = clksrc_table[baud];
290 clkmode = clkmode_table[baud];
291 div = div_table[baud];
292
293 reg3 = (((cflag & CSIZE) == CS8) ? 0xc0 : 0x40);
294 reg5 = (((cflag & CSIZE) == CS8) ? 0x60 : 0x20) | 0x82 /* assert DTR/RTS */;
295
296 if (port == 1) {
297 (void)scc.cha_b_ctrl; /* reset reg pointer */
298 SCCB_WRITE(9, 0xc0); /* reset */
299 LONG_DELAY(); /* extra delay after WR9 access */
300 SCCB_WRITE(4, (cflag & PARENB) ? ((cflag & PARODD) ? 0x01 : 0x03) : 0 |
301 0x04 /* 1 stopbit */ |
302 clkmode);
303 SCCB_WRITE(3, reg3);
304 SCCB_WRITE(5, reg5);
305 SCCB_WRITE(9, 0); /* no interrupts */
306 LONG_DELAY(); /* extra delay after WR9 access */
307 SCCB_WRITE(10, 0); /* NRZ mode */
308 SCCB_WRITE(11, clksrc); /* main clock source */
309 SCCB_WRITE(12, div); /* BRG value */
310 SCCB_WRITE(13, 0); /* BRG high byte */
311 SCCB_WRITE(14, 1);
312 SCCB_WRITE(3, reg3 | 1);
313 SCCB_WRITE(5, reg5 | 8);
314 } else if (port == 0) {
315 (void)scc.cha_a_ctrl; /* reset reg pointer */
316 SCCA_WRITE(9, 0xc0); /* reset */
317 LONG_DELAY(); /* extra delay after WR9 access */
318 SCCA_WRITE(4, (cflag & PARENB) ? ((cflag & PARODD) ? 0x01 : 0x03) : 0 |
319 0x04 /* 1 stopbit */ |
320 clkmode);
321 SCCA_WRITE(3, reg3);
322 SCCA_WRITE(5, reg5);
323 SCCA_WRITE(9, 0); /* no interrupts */
324 LONG_DELAY(); /* extra delay after WR9 access */
325 SCCA_WRITE(10, 0); /* NRZ mode */
326 SCCA_WRITE(11, clksrc); /* main clock source */
327 SCCA_WRITE(12, div); /* BRG value */
328 SCCA_WRITE(13, 0); /* BRG high byte */
329 SCCA_WRITE(14, 1);
330 SCCA_WRITE(3, reg3 | 1);
331 SCCA_WRITE(5, reg5 | 8);
332 }
333}
334#endif /* DEBUG_SERIAL */
335
336static int __init mac_debug_setup(char *arg)
337{
338 if (!MACH_IS_MAC)
339 return 0;
340
341#ifdef DEBUG_SERIAL
342 if (!strcmp(arg, "ser") || !strcmp(arg, "ser1")) {
343 /* Mac modem port */
344 mac_init_scc_port(B9600|CS8, 0);
345 mac_console_driver.write = mac_scca_console_write;
346 scc_port = 0;
347 } else if (!strcmp(arg, "ser2")) {
348 /* Mac printer port */
349 mac_init_scc_port(B9600|CS8, 1);
350 mac_console_driver.write = mac_sccb_console_write;
351 scc_port = 1;
352 }
353#endif
354#ifdef DEBUG_HEADS
355 if (!strcmp(arg, "scn") || !strcmp(arg, "con")) {
356 /* display, using head.S console routines */
357 mac_console_driver.write = mac_debug_console_write;
358 }
359#endif
360 if (mac_console_driver.write)
361 register_console(&mac_console_driver);
362 return 0;
363}
364
365early_param("debug", mac_debug_setup);
diff --git a/arch/m68k/mac/macints.c b/arch/m68k/mac/macints.c
index 23711074e0e2..900d899f3323 100644
--- a/arch/m68k/mac/macints.c
+++ b/arch/m68k/mac/macints.c
@@ -34,9 +34,7 @@
34 * 34 *
35 * 3 - unused (?) 35 * 3 - unused (?)
36 * 36 *
37 * 4 - SCC (slot number determined by reading RR3 on the SSC itself) 37 * 4 - SCC
38 * - slot 1: SCC channel A
39 * - slot 2: SCC channel B
40 * 38 *
41 * 5 - unused (?) 39 * 5 - unused (?)
42 * [serial errors or special conditions seem to raise level 6 40 * [serial errors or special conditions seem to raise level 6
@@ -55,8 +53,6 @@
55 * - slot 5: Slot $E 53 * - slot 5: Slot $E
56 * 54 *
57 * 4 - SCC IOP 55 * 4 - SCC IOP
58 * - slot 1: SCC channel A
59 * - slot 2: SCC channel B
60 * 56 *
61 * 5 - ISM IOP (ADB?) 57 * 5 - ISM IOP (ADB?)
62 * 58 *
@@ -136,13 +132,8 @@
136#include <asm/irq_regs.h> 132#include <asm/irq_regs.h>
137#include <asm/mac_oss.h> 133#include <asm/mac_oss.h>
138 134
139#define DEBUG_SPURIOUS
140#define SHUTUP_SONIC 135#define SHUTUP_SONIC
141 136
142/* SCC interrupt mask */
143
144static int scc_mask;
145
146/* 137/*
147 * VIA/RBV hooks 138 * VIA/RBV hooks
148 */ 139 */
@@ -191,13 +182,6 @@ extern void baboon_irq_disable(int);
191extern void baboon_irq_clear(int); 182extern void baboon_irq_clear(int);
192 183
193/* 184/*
194 * SCC interrupt routines
195 */
196
197static void scc_irq_enable(unsigned int);
198static void scc_irq_disable(unsigned int);
199
200/*
201 * console_loglevel determines NMI handler function 185 * console_loglevel determines NMI handler function
202 */ 186 */
203 187
@@ -221,8 +205,6 @@ void __init mac_init_IRQ(void)
221#ifdef DEBUG_MACINTS 205#ifdef DEBUG_MACINTS
222 printk("mac_init_IRQ(): Setting things up...\n"); 206 printk("mac_init_IRQ(): Setting things up...\n");
223#endif 207#endif
224 scc_mask = 0;
225
226 m68k_setup_irq_controller(&mac_irq_controller, IRQ_USER, 208 m68k_setup_irq_controller(&mac_irq_controller, IRQ_USER,
227 NUM_MAC_SOURCES - IRQ_USER); 209 NUM_MAC_SOURCES - IRQ_USER);
228 /* Make sure the SONIC interrupt is cleared or things get ugly */ 210 /* Make sure the SONIC interrupt is cleared or things get ugly */
@@ -283,15 +265,16 @@ void mac_enable_irq(unsigned int irq)
283 via_irq_enable(irq); 265 via_irq_enable(irq);
284 break; 266 break;
285 case 3: 267 case 3:
286 case 4:
287 case 5: 268 case 5:
288 case 6: 269 case 6:
289 if (psc_present) 270 if (psc_present)
290 psc_irq_enable(irq); 271 psc_irq_enable(irq);
291 else if (oss_present) 272 else if (oss_present)
292 oss_irq_enable(irq); 273 oss_irq_enable(irq);
293 else if (irq_src == 4) 274 break;
294 scc_irq_enable(irq); 275 case 4:
276 if (psc_present)
277 psc_irq_enable(irq);
295 break; 278 break;
296 case 8: 279 case 8:
297 if (baboon_present) 280 if (baboon_present)
@@ -316,15 +299,16 @@ void mac_disable_irq(unsigned int irq)
316 via_irq_disable(irq); 299 via_irq_disable(irq);
317 break; 300 break;
318 case 3: 301 case 3:
319 case 4:
320 case 5: 302 case 5:
321 case 6: 303 case 6:
322 if (psc_present) 304 if (psc_present)
323 psc_irq_disable(irq); 305 psc_irq_disable(irq);
324 else if (oss_present) 306 else if (oss_present)
325 oss_irq_disable(irq); 307 oss_irq_disable(irq);
326 else if (irq_src == 4) 308 break;
327 scc_irq_disable(irq); 309 case 4:
310 if (psc_present)
311 psc_irq_disable(irq);
328 break; 312 break;
329 case 8: 313 case 8:
330 if (baboon_present) 314 if (baboon_present)
@@ -347,7 +331,6 @@ void mac_clear_irq(unsigned int irq)
347 via_irq_clear(irq); 331 via_irq_clear(irq);
348 break; 332 break;
349 case 3: 333 case 3:
350 case 4:
351 case 5: 334 case 5:
352 case 6: 335 case 6:
353 if (psc_present) 336 if (psc_present)
@@ -355,6 +338,10 @@ void mac_clear_irq(unsigned int irq)
355 else if (oss_present) 338 else if (oss_present)
356 oss_irq_clear(irq); 339 oss_irq_clear(irq);
357 break; 340 break;
341 case 4:
342 if (psc_present)
343 psc_irq_clear(irq);
344 break;
358 case 8: 345 case 8:
359 if (baboon_present) 346 if (baboon_present)
360 baboon_irq_clear(irq); 347 baboon_irq_clear(irq);
@@ -374,13 +361,17 @@ int mac_irq_pending(unsigned int irq)
374 else 361 else
375 return via_irq_pending(irq); 362 return via_irq_pending(irq);
376 case 3: 363 case 3:
377 case 4:
378 case 5: 364 case 5:
379 case 6: 365 case 6:
380 if (psc_present) 366 if (psc_present)
381 return psc_irq_pending(irq); 367 return psc_irq_pending(irq);
382 else if (oss_present) 368 else if (oss_present)
383 return oss_irq_pending(irq); 369 return oss_irq_pending(irq);
370 break;
371 case 4:
372 if (psc_present)
373 psc_irq_pending(irq);
374 break;
384 } 375 }
385 return 0; 376 return 0;
386} 377}
@@ -448,59 +439,3 @@ irqreturn_t mac_nmi_handler(int irq, void *dev_id)
448 in_nmi--; 439 in_nmi--;
449 return IRQ_HANDLED; 440 return IRQ_HANDLED;
450} 441}
451
452/*
453 * Simple routines for masking and unmasking
454 * SCC interrupts in cases where this can't be
455 * done in hardware (only the PSC can do that.)
456 */
457
458static void scc_irq_enable(unsigned int irq)
459{
460 int irq_idx = IRQ_IDX(irq);
461
462 scc_mask |= (1 << irq_idx);
463}
464
465static void scc_irq_disable(unsigned int irq)
466{
467 int irq_idx = IRQ_IDX(irq);
468
469 scc_mask &= ~(1 << irq_idx);
470}
471
472/*
473 * SCC master interrupt handler. We have to do a bit of magic here
474 * to figure out what channel gave us the interrupt; putting this
475 * here is cleaner than hacking it into drivers/char/macserial.c.
476 */
477
478void mac_scc_dispatch(int irq, void *dev_id)
479{
480 volatile unsigned char *scc = (unsigned char *) mac_bi_data.sccbase + 2;
481 unsigned char reg;
482 unsigned long flags;
483
484 /* Read RR3 from the chip. Always do this on channel A */
485 /* This must be an atomic operation so disable irqs. */
486
487 local_irq_save(flags);
488 *scc = 3;
489 reg = *scc;
490 local_irq_restore(flags);
491
492 /* Now dispatch. Bits 0-2 are for channel B and */
493 /* bits 3-5 are for channel A. We can safely */
494 /* ignore the remaining bits here. */
495 /* */
496 /* Note that we're ignoring scc_mask for now. */
497 /* If we actually mask the ints then we tend to */
498 /* get hammered by very persistent SCC irqs, */
499 /* and since they're autovector interrupts they */
500 /* pretty much kill the system. */
501
502 if (reg & 0x38)
503 m68k_handle_int(IRQ_SCCA);
504 if (reg & 0x07)
505 m68k_handle_int(IRQ_SCCB);
506}
diff --git a/arch/m68k/mac/oss.c b/arch/m68k/mac/oss.c
index f3d23d6ebcf8..a9c0f5ab4cc0 100644
--- a/arch/m68k/mac/oss.c
+++ b/arch/m68k/mac/oss.c
@@ -33,7 +33,6 @@ static irqreturn_t oss_irq(int, void *);
33static irqreturn_t oss_nubus_irq(int, void *); 33static irqreturn_t oss_nubus_irq(int, void *);
34 34
35extern irqreturn_t via1_irq(int, void *); 35extern irqreturn_t via1_irq(int, void *);
36extern irqreturn_t mac_scc_dispatch(int, void *);
37 36
38/* 37/*
39 * Initialize the OSS 38 * Initialize the OSS
@@ -69,9 +68,6 @@ void __init oss_register_interrupts(void)
69 if (request_irq(OSS_IRQLEV_SCSI, oss_irq, IRQ_FLG_LOCK, 68 if (request_irq(OSS_IRQLEV_SCSI, oss_irq, IRQ_FLG_LOCK,
70 "scsi", (void *) oss)) 69 "scsi", (void *) oss))
71 pr_err("Couldn't register %s interrupt\n", "scsi"); 70 pr_err("Couldn't register %s interrupt\n", "scsi");
72 if (request_irq(OSS_IRQLEV_IOPSCC, mac_scc_dispatch, IRQ_FLG_LOCK,
73 "scc", mac_scc_dispatch))
74 pr_err("Couldn't register %s interrupt\n", "scc");
75 if (request_irq(OSS_IRQLEV_NUBUS, oss_nubus_irq, IRQ_FLG_LOCK, 71 if (request_irq(OSS_IRQLEV_NUBUS, oss_nubus_irq, IRQ_FLG_LOCK,
76 "nubus", (void *) oss)) 72 "nubus", (void *) oss))
77 pr_err("Couldn't register %s interrupt\n", "nubus"); 73 pr_err("Couldn't register %s interrupt\n", "nubus");
@@ -172,9 +168,7 @@ void oss_irq_enable(int irq) {
172 printk("oss_irq_enable(%d)\n", irq); 168 printk("oss_irq_enable(%d)\n", irq);
173#endif 169#endif
174 switch(irq) { 170 switch(irq) {
175 case IRQ_SCC: 171 case IRQ_MAC_SCC:
176 case IRQ_SCCA:
177 case IRQ_SCCB:
178 oss->irq_level[OSS_IOPSCC] = OSS_IRQLEV_IOPSCC; 172 oss->irq_level[OSS_IOPSCC] = OSS_IRQLEV_IOPSCC;
179 break; 173 break;
180 case IRQ_MAC_ADB: 174 case IRQ_MAC_ADB:
@@ -212,9 +206,7 @@ void oss_irq_disable(int irq) {
212 printk("oss_irq_disable(%d)\n", irq); 206 printk("oss_irq_disable(%d)\n", irq);
213#endif 207#endif
214 switch(irq) { 208 switch(irq) {
215 case IRQ_SCC: 209 case IRQ_MAC_SCC:
216 case IRQ_SCCA:
217 case IRQ_SCCB:
218 oss->irq_level[OSS_IOPSCC] = OSS_IRQLEV_DISABLED; 210 oss->irq_level[OSS_IOPSCC] = OSS_IRQLEV_DISABLED;
219 break; 211 break;
220 case IRQ_MAC_ADB: 212 case IRQ_MAC_ADB:
@@ -250,9 +242,7 @@ void oss_irq_disable(int irq) {
250void oss_irq_clear(int irq) { 242void oss_irq_clear(int irq) {
251 /* FIXME: how to do this on OSS? */ 243 /* FIXME: how to do this on OSS? */
252 switch(irq) { 244 switch(irq) {
253 case IRQ_SCC: 245 case IRQ_MAC_SCC:
254 case IRQ_SCCA:
255 case IRQ_SCCB:
256 oss->irq_pending &= ~OSS_IP_IOPSCC; 246 oss->irq_pending &= ~OSS_IP_IOPSCC;
257 break; 247 break;
258 case IRQ_MAC_ADB: 248 case IRQ_MAC_ADB:
@@ -280,9 +270,7 @@ void oss_irq_clear(int irq) {
280int oss_irq_pending(int irq) 270int oss_irq_pending(int irq)
281{ 271{
282 switch(irq) { 272 switch(irq) {
283 case IRQ_SCC: 273 case IRQ_MAC_SCC:
284 case IRQ_SCCA:
285 case IRQ_SCCB:
286 return oss->irq_pending & OSS_IP_IOPSCC; 274 return oss->irq_pending & OSS_IP_IOPSCC;
287 break; 275 break;
288 case IRQ_MAC_ADB: 276 case IRQ_MAC_ADB:
diff --git a/arch/m68k/mac/via.c b/arch/m68k/mac/via.c
index 11bce3cb6482..e71166daec6a 100644
--- a/arch/m68k/mac/via.c
+++ b/arch/m68k/mac/via.c
@@ -84,8 +84,6 @@ void via_irq_enable(int irq);
84void via_irq_disable(int irq); 84void via_irq_disable(int irq);
85void via_irq_clear(int irq); 85void via_irq_clear(int irq);
86 86
87extern irqreturn_t mac_scc_dispatch(int, void *);
88
89/* 87/*
90 * Initialize the VIAs 88 * Initialize the VIAs
91 * 89 *
@@ -311,11 +309,6 @@ void __init via_register_interrupts(void)
311 if (request_irq(IRQ_AUTO_2, via2_irq, IRQ_FLG_LOCK|IRQ_FLG_FAST, 309 if (request_irq(IRQ_AUTO_2, via2_irq, IRQ_FLG_LOCK|IRQ_FLG_FAST,
312 "via2", (void *) via2)) 310 "via2", (void *) via2))
313 pr_err("Couldn't register %s interrupt\n", "via2"); 311 pr_err("Couldn't register %s interrupt\n", "via2");
314 if (!psc_present) {
315 if (request_irq(IRQ_AUTO_4, mac_scc_dispatch, IRQ_FLG_LOCK,
316 "scc", mac_scc_dispatch))
317 pr_err("Couldn't register %s interrupt\n", "scc");
318 }
319 if (request_irq(IRQ_MAC_NUBUS, via_nubus_irq, 312 if (request_irq(IRQ_MAC_NUBUS, via_nubus_irq,
320 IRQ_FLG_LOCK|IRQ_FLG_FAST, "nubus", (void *) via2)) 313 IRQ_FLG_LOCK|IRQ_FLG_FAST, "nubus", (void *) via2))
321 pr_err("Couldn't register %s interrupt\n", "nubus"); 314 pr_err("Couldn't register %s interrupt\n", "nubus");
diff --git a/arch/m68k/mm/kmap.c b/arch/m68k/mm/kmap.c
index df620ac2a296..69345849454b 100644
--- a/arch/m68k/mm/kmap.c
+++ b/arch/m68k/mm/kmap.c
@@ -99,8 +99,7 @@ static inline void free_io_area(void *addr)
99#endif 99#endif
100 100
101/* 101/*
102 * Map some physical address range into the kernel address space. The 102 * Map some physical address range into the kernel address space.
103 * code is copied and adapted from map_chunk().
104 */ 103 */
105/* Rewritten by Andreas Schwab to remove all races. */ 104/* Rewritten by Andreas Schwab to remove all races. */
106 105
@@ -116,7 +115,7 @@ void __iomem *__ioremap(unsigned long physaddr, unsigned long size, int cachefla
116 /* 115 /*
117 * Don't allow mappings that wrap.. 116 * Don't allow mappings that wrap..
118 */ 117 */
119 if (!size || size > physaddr + size) 118 if (!size || physaddr > (unsigned long)(-size))
120 return NULL; 119 return NULL;
121 120
122#ifdef CONFIG_AMIGA 121#ifdef CONFIG_AMIGA
diff --git a/arch/m68knommu/kernel/process.c b/arch/m68knommu/kernel/process.c
index 5c9ecd427090..959cb249c759 100644
--- a/arch/m68knommu/kernel/process.c
+++ b/arch/m68knommu/kernel/process.c
@@ -221,6 +221,10 @@ int copy_thread(unsigned long clone_flags,
221 221
222 p->thread.usp = usp; 222 p->thread.usp = usp;
223 p->thread.ksp = (unsigned long)childstack; 223 p->thread.ksp = (unsigned long)childstack;
224
225 if (clone_flags & CLONE_SETTLS)
226 task_thread_info(p)->tp_value = regs->d5;
227
224 /* 228 /*
225 * Must save the current SFC/DFC value, NOT the value when 229 * Must save the current SFC/DFC value, NOT the value when
226 * the parent was last descheduled - RGH 10-08-96 230 * the parent was last descheduled - RGH 10-08-96
diff --git a/arch/m68knommu/kernel/ptrace.c b/arch/m68knommu/kernel/ptrace.c
index 4d3828959fb0..85ed2f988f98 100644
--- a/arch/m68knommu/kernel/ptrace.c
+++ b/arch/m68knommu/kernel/ptrace.c
@@ -319,6 +319,11 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
319 } 319 }
320#endif 320#endif
321 321
322 case PTRACE_GET_THREAD_AREA:
323 ret = put_user(task_thread_info(child)->tp_value,
324 (unsigned long __user *)data);
325 break;
326
322 default: 327 default:
323 ret = -EIO; 328 ret = -EIO;
324 break; 329 break;
diff --git a/arch/m68knommu/kernel/sys_m68k.c b/arch/m68knommu/kernel/sys_m68k.c
index b67cbc735a9b..923dd4aab875 100644
--- a/arch/m68knommu/kernel/sys_m68k.c
+++ b/arch/m68knommu/kernel/sys_m68k.c
@@ -190,3 +190,39 @@ int kernel_execve(const char *filename, char *const argv[], char *const envp[])
190 : "d" (__a), "d" (__b), "d" (__c)); 190 : "d" (__a), "d" (__b), "d" (__c));
191 return __res; 191 return __res;
192} 192}
193
194asmlinkage unsigned long sys_get_thread_area(void)
195{
196 return current_thread_info()->tp_value;
197}
198
199asmlinkage int sys_set_thread_area(unsigned long tp)
200{
201 current_thread_info()->tp_value = tp;
202 return 0;
203}
204
205/* This syscall gets its arguments in A0 (mem), D2 (oldval) and
206 D1 (newval). */
207asmlinkage int
208sys_atomic_cmpxchg_32(unsigned long newval, int oldval, int d3, int d4, int d5,
209 unsigned long __user * mem)
210{
211 struct mm_struct *mm = current->mm;
212 unsigned long mem_value;
213
214 down_read(&mm->mmap_sem);
215
216 mem_value = *mem;
217 if (mem_value == oldval)
218 *mem = newval;
219
220 up_read(&mm->mmap_sem);
221 return mem_value;
222}
223
224asmlinkage int sys_atomic_barrier(void)
225{
226 /* no code needed for uniprocs */
227 return 0;
228}
diff --git a/arch/m68knommu/kernel/syscalltable.S b/arch/m68knommu/kernel/syscalltable.S
index 486837efa3d7..56dd01ded148 100644
--- a/arch/m68knommu/kernel/syscalltable.S
+++ b/arch/m68knommu/kernel/syscalltable.S
@@ -351,6 +351,10 @@ ENTRY(sys_call_table)
351 .long sys_pwritev /* 330 */ 351 .long sys_pwritev /* 330 */
352 .long sys_rt_tgsigqueueinfo 352 .long sys_rt_tgsigqueueinfo
353 .long sys_perf_event_open 353 .long sys_perf_event_open
354 .long sys_get_thread_area
355 .long sys_set_thread_area
356 .long sys_atomic_cmpxchg_32 /* 335 */
357 .long sys_atomic_barrier
354 358
355 .rept NR_syscalls-(.-sys_call_table)/4 359 .rept NR_syscalls-(.-sys_call_table)/4
356 .long sys_ni_syscall 360 .long sys_ni_syscall
diff --git a/arch/m68knommu/mm/memory.c b/arch/m68knommu/mm/memory.c
index f93b88b51f9f..d5b9e1357808 100644
--- a/arch/m68knommu/mm/memory.c
+++ b/arch/m68knommu/mm/memory.c
@@ -24,7 +24,6 @@
24 24
25/* 25/*
26 * Map some physical address range into the kernel address space. 26 * Map some physical address range into the kernel address space.
27 * The code is copied and adapted from map_chunk().
28 */ 27 */
29 28
30unsigned long kernel_map(unsigned long paddr, unsigned long size, 29unsigned long kernel_map(unsigned long paddr, unsigned long size,
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
index a5af1d6dda8b..e35cf59cbfde 100644
--- a/drivers/block/ataflop.c
+++ b/drivers/block/ataflop.c
@@ -1470,8 +1470,6 @@ repeat:
1470 1470
1471void do_fd_request(struct request_queue * q) 1471void do_fd_request(struct request_queue * q)
1472{ 1472{
1473 unsigned long flags;
1474
1475 DPRINT(("do_fd_request for pid %d\n",current->pid)); 1473 DPRINT(("do_fd_request for pid %d\n",current->pid));
1476 while( fdc_busy ) sleep_on( &fdc_wait ); 1474 while( fdc_busy ) sleep_on( &fdc_wait );
1477 fdc_busy = 1; 1475 fdc_busy = 1;
diff --git a/drivers/block/swim.c b/drivers/block/swim.c
index 8f569e3df890..821c2833f9cf 100644
--- a/drivers/block/swim.c
+++ b/drivers/block/swim.c
@@ -864,7 +864,7 @@ static int __devinit swim_probe(struct platform_device *dev)
864 struct swim_priv *swd; 864 struct swim_priv *swd;
865 int ret; 865 int ret;
866 866
867 res = platform_get_resource_byname(dev, IORESOURCE_MEM, "swim-regs"); 867 res = platform_get_resource(dev, IORESOURCE_MEM, 0);
868 if (!res) { 868 if (!res) {
869 ret = -ENODEV; 869 ret = -ENODEV;
870 goto out; 870 goto out;
@@ -942,7 +942,7 @@ static int __devexit swim_remove(struct platform_device *dev)
942 942
943 iounmap(swd->base); 943 iounmap(swd->base);
944 944
945 res = platform_get_resource_byname(dev, IORESOURCE_MEM, "swim-regs"); 945 res = platform_get_resource(dev, IORESOURCE_MEM, 0);
946 if (res) 946 if (res)
947 release_mem_region(res->start, resource_size(res)); 947 release_mem_region(res->start, resource_size(res));
948 948
diff --git a/drivers/char/vme_scc.c b/drivers/char/vme_scc.c
index 994e1a58b987..8b24729fec89 100644
--- a/drivers/char/vme_scc.c
+++ b/drivers/char/vme_scc.c
@@ -136,7 +136,7 @@ static const struct tty_port_operations scc_port_ops = {
136 * vme_scc_init() and support functions 136 * vme_scc_init() and support functions
137 *---------------------------------------------------------------------------*/ 137 *---------------------------------------------------------------------------*/
138 138
139static int scc_init_drivers(void) 139static int __init scc_init_drivers(void)
140{ 140{
141 int error; 141 int error;
142 142
@@ -172,7 +172,7 @@ static int scc_init_drivers(void)
172/* ports[] array is indexed by line no (i.e. [0] for ttyS0, [1] for ttyS1). 172/* ports[] array is indexed by line no (i.e. [0] for ttyS0, [1] for ttyS1).
173 */ 173 */
174 174
175static void scc_init_portstructs(void) 175static void __init scc_init_portstructs(void)
176{ 176{
177 struct scc_port *port; 177 struct scc_port *port;
178 int i; 178 int i;
@@ -195,7 +195,7 @@ static void scc_init_portstructs(void)
195 195
196 196
197#ifdef CONFIG_MVME147_SCC 197#ifdef CONFIG_MVME147_SCC
198static int mvme147_scc_init(void) 198static int __init mvme147_scc_init(void)
199{ 199{
200 struct scc_port *port; 200 struct scc_port *port;
201 int error; 201 int error;
@@ -298,7 +298,7 @@ fail:
298 298
299 299
300#ifdef CONFIG_MVME162_SCC 300#ifdef CONFIG_MVME162_SCC
301static int mvme162_scc_init(void) 301static int __init mvme162_scc_init(void)
302{ 302{
303 struct scc_port *port; 303 struct scc_port *port;
304 int error; 304 int error;
@@ -404,7 +404,7 @@ fail:
404 404
405 405
406#ifdef CONFIG_BVME6000_SCC 406#ifdef CONFIG_BVME6000_SCC
407static int bvme6000_scc_init(void) 407static int __init bvme6000_scc_init(void)
408{ 408{
409 struct scc_port *port; 409 struct scc_port *port;
410 int error; 410 int error;
@@ -503,7 +503,7 @@ fail_free_b_rx:
503#endif 503#endif
504 504
505 505
506static int vme_scc_init(void) 506static int __init vme_scc_init(void)
507{ 507{
508 int res = -ENODEV; 508 int res = -ENODEV;
509 509
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index d840a109f833..1c4ee6e77937 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -317,9 +317,11 @@ static int __init adb_init(void)
317 break; 317 break;
318 } 318 }
319 } 319 }
320 if ((adb_controller == NULL) || adb_controller->init()) { 320 if (adb_controller != NULL && adb_controller->init &&
321 printk(KERN_WARNING "Warning: no ADB interface detected\n"); 321 adb_controller->init())
322 adb_controller = NULL; 322 adb_controller = NULL;
323 if (adb_controller == NULL) {
324 printk(KERN_WARNING "Warning: no ADB interface detected\n");
323 } else { 325 } else {
324#ifdef CONFIG_PPC 326#ifdef CONFIG_PPC
325 if (of_machine_is_compatible("AAPL,PowerBook1998") || 327 if (of_machine_is_compatible("AAPL,PowerBook1998") ||
diff --git a/drivers/macintosh/via-cuda.c b/drivers/macintosh/via-cuda.c
index 62dd1fdafecf..971bc9582a5f 100644
--- a/drivers/macintosh/via-cuda.c
+++ b/drivers/macintosh/via-cuda.c
@@ -89,7 +89,6 @@ static int cuda_fully_inited;
89 89
90#ifdef CONFIG_ADB 90#ifdef CONFIG_ADB
91static int cuda_probe(void); 91static int cuda_probe(void);
92static int cuda_init(void);
93static int cuda_send_request(struct adb_request *req, int sync); 92static int cuda_send_request(struct adb_request *req, int sync);
94static int cuda_adb_autopoll(int devs); 93static int cuda_adb_autopoll(int devs);
95static int cuda_reset_adb_bus(void); 94static int cuda_reset_adb_bus(void);
@@ -107,17 +106,42 @@ int cuda_request(struct adb_request *req,
107 106
108#ifdef CONFIG_ADB 107#ifdef CONFIG_ADB
109struct adb_driver via_cuda_driver = { 108struct adb_driver via_cuda_driver = {
110 "CUDA", 109 .name = "CUDA",
111 cuda_probe, 110 .probe = cuda_probe,
112 cuda_init, 111 .send_request = cuda_send_request,
113 cuda_send_request, 112 .autopoll = cuda_adb_autopoll,
114 cuda_adb_autopoll, 113 .poll = cuda_poll,
115 cuda_poll, 114 .reset_bus = cuda_reset_adb_bus,
116 cuda_reset_adb_bus
117}; 115};
118#endif /* CONFIG_ADB */ 116#endif /* CONFIG_ADB */
119 117
120#ifdef CONFIG_PPC 118#ifdef CONFIG_MAC
119int __init find_via_cuda(void)
120{
121 struct adb_request req;
122 int err;
123
124 if (macintosh_config->adb_type != MAC_ADB_CUDA)
125 return 0;
126
127 via = via1;
128 cuda_state = idle;
129
130 err = cuda_init_via();
131 if (err) {
132 printk(KERN_ERR "cuda_init_via() failed\n");
133 via = NULL;
134 return 0;
135 }
136
137 /* enable autopoll */
138 cuda_request(&req, NULL, 3, CUDA_PACKET, CUDA_AUTOPOLL, 1);
139 while (!req.complete)
140 cuda_poll();
141
142 return 1;
143}
144#else
121int __init find_via_cuda(void) 145int __init find_via_cuda(void)
122{ 146{
123 struct adb_request req; 147 struct adb_request req;
@@ -175,7 +199,7 @@ int __init find_via_cuda(void)
175 vias = NULL; 199 vias = NULL;
176 return 0; 200 return 0;
177} 201}
178#endif /* CONFIG_PPC */ 202#endif /* !defined CONFIG_MAC */
179 203
180static int __init via_cuda_start(void) 204static int __init via_cuda_start(void)
181{ 205{
@@ -184,14 +208,14 @@ static int __init via_cuda_start(void)
184 208
185#ifdef CONFIG_MAC 209#ifdef CONFIG_MAC
186 cuda_irq = IRQ_MAC_ADB; 210 cuda_irq = IRQ_MAC_ADB;
187#else /* CONFIG_MAC */ 211#else
188 cuda_irq = irq_of_parse_and_map(vias, 0); 212 cuda_irq = irq_of_parse_and_map(vias, 0);
189 if (cuda_irq == NO_IRQ) { 213 if (cuda_irq == NO_IRQ) {
190 printk(KERN_ERR "via-cuda: can't map interrupts for %s\n", 214 printk(KERN_ERR "via-cuda: can't map interrupts for %s\n",
191 vias->full_name); 215 vias->full_name);
192 return -ENODEV; 216 return -ENODEV;
193 } 217 }
194#endif /* CONFIG_MAC */ 218#endif
195 219
196 if (request_irq(cuda_irq, cuda_interrupt, 0, "ADB", cuda_interrupt)) { 220 if (request_irq(cuda_irq, cuda_interrupt, 0, "ADB", cuda_interrupt)) {
197 printk(KERN_ERR "via-cuda: can't request irq %d\n", cuda_irq); 221 printk(KERN_ERR "via-cuda: can't request irq %d\n", cuda_irq);
@@ -216,28 +240,10 @@ cuda_probe(void)
216#else 240#else
217 if (macintosh_config->adb_type != MAC_ADB_CUDA) 241 if (macintosh_config->adb_type != MAC_ADB_CUDA)
218 return -ENODEV; 242 return -ENODEV;
219 via = via1;
220#endif 243#endif
221 return 0;
222}
223
224static int __init
225cuda_init(void)
226{
227#ifdef CONFIG_PPC
228 if (via == NULL) 244 if (via == NULL)
229 return -ENODEV; 245 return -ENODEV;
230 return 0; 246 return 0;
231#else
232 int err = cuda_init_via();
233 if (err) {
234 printk(KERN_ERR "cuda_init_via() failed\n");
235 return -ENODEV;
236 }
237 out_8(&via[IER], IER_SET|SR_INT); /* enable interrupt from SR */
238
239 return via_cuda_start();
240#endif
241} 247}
242#endif /* CONFIG_ADB */ 248#endif /* CONFIG_ADB */
243 249
@@ -430,9 +436,11 @@ cuda_poll(void)
430 /* cuda_interrupt only takes a normal lock, we disable 436 /* cuda_interrupt only takes a normal lock, we disable
431 * interrupts here to avoid re-entering and thus deadlocking. 437 * interrupts here to avoid re-entering and thus deadlocking.
432 */ 438 */
433 disable_irq(cuda_irq); 439 if (cuda_irq)
440 disable_irq(cuda_irq);
434 cuda_interrupt(0, NULL); 441 cuda_interrupt(0, NULL);
435 enable_irq(cuda_irq); 442 if (cuda_irq)
443 enable_irq(cuda_irq);
436} 444}
437 445
438static irqreturn_t 446static irqreturn_t
@@ -446,7 +454,7 @@ cuda_interrupt(int irq, void *arg)
446 454
447 spin_lock(&cuda_lock); 455 spin_lock(&cuda_lock);
448 456
449 /* On powermacs, this handler is registered for the VIA IRQ. But it uses 457 /* On powermacs, this handler is registered for the VIA IRQ. But they use
450 * just the shift register IRQ -- other VIA interrupt sources are disabled. 458 * just the shift register IRQ -- other VIA interrupt sources are disabled.
451 * On m68k macs, the VIA IRQ sources are dispatched individually. Unless 459 * On m68k macs, the VIA IRQ sources are dispatched individually. Unless
452 * we are polling, the shift register IRQ flag has already been cleared. 460 * we are polling, the shift register IRQ flag has already been cleared.
diff --git a/drivers/net/macmace.c b/drivers/net/macmace.c
index 44f3c2896f20..79408c377875 100644
--- a/drivers/net/macmace.c
+++ b/drivers/net/macmace.c
@@ -39,7 +39,6 @@
39#include "mace.h" 39#include "mace.h"
40 40
41static char mac_mace_string[] = "macmace"; 41static char mac_mace_string[] = "macmace";
42static struct platform_device *mac_mace_device;
43 42
44#define N_TX_BUFF_ORDER 0 43#define N_TX_BUFF_ORDER 0
45#define N_TX_RING (1 << N_TX_BUFF_ORDER) 44#define N_TX_RING (1 << N_TX_BUFF_ORDER)
@@ -752,6 +751,7 @@ static irqreturn_t mace_dma_intr(int irq, void *dev_id)
752 751
753MODULE_LICENSE("GPL"); 752MODULE_LICENSE("GPL");
754MODULE_DESCRIPTION("Macintosh MACE ethernet driver"); 753MODULE_DESCRIPTION("Macintosh MACE ethernet driver");
754MODULE_ALIAS("platform:macmace");
755 755
756static int __devexit mac_mace_device_remove (struct platform_device *pdev) 756static int __devexit mac_mace_device_remove (struct platform_device *pdev)
757{ 757{
@@ -777,47 +777,22 @@ static struct platform_driver mac_mace_driver = {
777 .probe = mace_probe, 777 .probe = mace_probe,
778 .remove = __devexit_p(mac_mace_device_remove), 778 .remove = __devexit_p(mac_mace_device_remove),
779 .driver = { 779 .driver = {
780 .name = mac_mace_string, 780 .name = mac_mace_string,
781 .owner = THIS_MODULE,
781 }, 782 },
782}; 783};
783 784
784static int __init mac_mace_init_module(void) 785static int __init mac_mace_init_module(void)
785{ 786{
786 int err;
787
788 if (!MACH_IS_MAC) 787 if (!MACH_IS_MAC)
789 return -ENODEV; 788 return -ENODEV;
790 789
791 if ((err = platform_driver_register(&mac_mace_driver))) { 790 return platform_driver_register(&mac_mace_driver);
792 printk(KERN_ERR "Driver registration failed\n");
793 return err;
794 }
795
796 mac_mace_device = platform_device_alloc(mac_mace_string, 0);
797 if (!mac_mace_device)
798 goto out_unregister;
799
800 if (platform_device_add(mac_mace_device)) {
801 platform_device_put(mac_mace_device);
802 mac_mace_device = NULL;
803 }
804
805 return 0;
806
807out_unregister:
808 platform_driver_unregister(&mac_mace_driver);
809
810 return -ENOMEM;
811} 791}
812 792
813static void __exit mac_mace_cleanup_module(void) 793static void __exit mac_mace_cleanup_module(void)
814{ 794{
815 platform_driver_unregister(&mac_mace_driver); 795 platform_driver_unregister(&mac_mace_driver);
816
817 if (mac_mace_device) {
818 platform_device_unregister(mac_mace_device);
819 mac_mace_device = NULL;
820 }
821} 796}
822 797
823module_init(mac_mace_init_module); 798module_init(mac_mace_init_module);
diff --git a/drivers/net/macsonic.c b/drivers/net/macsonic.c
index 875d361fb79d..24109c288108 100644
--- a/drivers/net/macsonic.c
+++ b/drivers/net/macsonic.c
@@ -62,7 +62,6 @@
62#include <asm/mac_via.h> 62#include <asm/mac_via.h>
63 63
64static char mac_sonic_string[] = "macsonic"; 64static char mac_sonic_string[] = "macsonic";
65static struct platform_device *mac_sonic_device;
66 65
67#include "sonic.h" 66#include "sonic.h"
68 67
@@ -607,6 +606,7 @@ out:
607MODULE_DESCRIPTION("Macintosh SONIC ethernet driver"); 606MODULE_DESCRIPTION("Macintosh SONIC ethernet driver");
608module_param(sonic_debug, int, 0); 607module_param(sonic_debug, int, 0);
609MODULE_PARM_DESC(sonic_debug, "macsonic debug level (1-4)"); 608MODULE_PARM_DESC(sonic_debug, "macsonic debug level (1-4)");
609MODULE_ALIAS("platform:macsonic");
610 610
611#include "sonic.c" 611#include "sonic.c"
612 612
@@ -627,44 +627,19 @@ static struct platform_driver mac_sonic_driver = {
627 .probe = mac_sonic_probe, 627 .probe = mac_sonic_probe,
628 .remove = __devexit_p(mac_sonic_device_remove), 628 .remove = __devexit_p(mac_sonic_device_remove),
629 .driver = { 629 .driver = {
630 .name = mac_sonic_string, 630 .name = mac_sonic_string,
631 .owner = THIS_MODULE,
631 }, 632 },
632}; 633};
633 634
634static int __init mac_sonic_init_module(void) 635static int __init mac_sonic_init_module(void)
635{ 636{
636 int err; 637 return platform_driver_register(&mac_sonic_driver);
637
638 if ((err = platform_driver_register(&mac_sonic_driver))) {
639 printk(KERN_ERR "Driver registration failed\n");
640 return err;
641 }
642
643 mac_sonic_device = platform_device_alloc(mac_sonic_string, 0);
644 if (!mac_sonic_device)
645 goto out_unregister;
646
647 if (platform_device_add(mac_sonic_device)) {
648 platform_device_put(mac_sonic_device);
649 mac_sonic_device = NULL;
650 }
651
652 return 0;
653
654out_unregister:
655 platform_driver_unregister(&mac_sonic_driver);
656
657 return -ENOMEM;
658} 638}
659 639
660static void __exit mac_sonic_cleanup_module(void) 640static void __exit mac_sonic_cleanup_module(void)
661{ 641{
662 platform_driver_unregister(&mac_sonic_driver); 642 platform_driver_unregister(&mac_sonic_driver);
663
664 if (mac_sonic_device) {
665 platform_device_unregister(mac_sonic_device);
666 mac_sonic_device = NULL;
667 }
668} 643}
669 644
670module_init(mac_sonic_init_module); 645module_init(mac_sonic_init_module);
diff --git a/drivers/scsi/mac_esp.c b/drivers/scsi/mac_esp.c
index dd808ae942a1..4a90eaf7cb63 100644
--- a/drivers/scsi/mac_esp.c
+++ b/drivers/scsi/mac_esp.c
@@ -52,7 +52,6 @@ struct mac_esp_priv {
52 void __iomem *pdma_io; 52 void __iomem *pdma_io;
53 int error; 53 int error;
54}; 54};
55static struct platform_device *internal_pdev, *external_pdev;
56static struct esp *esp_chips[2]; 55static struct esp *esp_chips[2];
57 56
58#define MAC_ESP_GET_PRIV(esp) ((struct mac_esp_priv *) \ 57#define MAC_ESP_GET_PRIV(esp) ((struct mac_esp_priv *) \
@@ -495,29 +494,12 @@ static int __devinit esp_mac_probe(struct platform_device *dev)
495 struct Scsi_Host *host; 494 struct Scsi_Host *host;
496 struct esp *esp; 495 struct esp *esp;
497 int err; 496 int err;
498 int chips_present;
499 struct mac_esp_priv *mep; 497 struct mac_esp_priv *mep;
500 498
501 if (!MACH_IS_MAC) 499 if (!MACH_IS_MAC)
502 return -ENODEV; 500 return -ENODEV;
503 501
504 switch (macintosh_config->scsi_type) { 502 if (dev->id > 1)
505 case MAC_SCSI_QUADRA:
506 case MAC_SCSI_QUADRA3:
507 chips_present = 1;
508 break;
509 case MAC_SCSI_QUADRA2:
510 if ((macintosh_config->ident == MAC_MODEL_Q900) ||
511 (macintosh_config->ident == MAC_MODEL_Q950))
512 chips_present = 2;
513 else
514 chips_present = 1;
515 break;
516 default:
517 chips_present = 0;
518 }
519
520 if (dev->id + 1 > chips_present)
521 return -ENODEV; 503 return -ENODEV;
522 504
523 host = scsi_host_alloc(tpnt, sizeof(struct esp)); 505 host = scsi_host_alloc(tpnt, sizeof(struct esp));
@@ -642,55 +624,26 @@ static struct platform_driver esp_mac_driver = {
642 .probe = esp_mac_probe, 624 .probe = esp_mac_probe,
643 .remove = __devexit_p(esp_mac_remove), 625 .remove = __devexit_p(esp_mac_remove),
644 .driver = { 626 .driver = {
645 .name = DRV_MODULE_NAME, 627 .name = DRV_MODULE_NAME,
628 .owner = THIS_MODULE,
646 }, 629 },
647}; 630};
648 631
649static int __init mac_esp_init(void) 632static int __init mac_esp_init(void)
650{ 633{
651 int err; 634 return platform_driver_register(&esp_mac_driver);
652
653 err = platform_driver_register(&esp_mac_driver);
654 if (err)
655 return err;
656
657 internal_pdev = platform_device_alloc(DRV_MODULE_NAME, 0);
658 if (internal_pdev && platform_device_add(internal_pdev)) {
659 platform_device_put(internal_pdev);
660 internal_pdev = NULL;
661 }
662 external_pdev = platform_device_alloc(DRV_MODULE_NAME, 1);
663 if (external_pdev && platform_device_add(external_pdev)) {
664 platform_device_put(external_pdev);
665 external_pdev = NULL;
666 }
667
668 if (internal_pdev || external_pdev) {
669 return 0;
670 } else {
671 platform_driver_unregister(&esp_mac_driver);
672 return -ENOMEM;
673 }
674} 635}
675 636
676static void __exit mac_esp_exit(void) 637static void __exit mac_esp_exit(void)
677{ 638{
678 platform_driver_unregister(&esp_mac_driver); 639 platform_driver_unregister(&esp_mac_driver);
679
680 if (internal_pdev) {
681 platform_device_unregister(internal_pdev);
682 internal_pdev = NULL;
683 }
684 if (external_pdev) {
685 platform_device_unregister(external_pdev);
686 external_pdev = NULL;
687 }
688} 640}
689 641
690MODULE_DESCRIPTION("Mac ESP SCSI driver"); 642MODULE_DESCRIPTION("Mac ESP SCSI driver");
691MODULE_AUTHOR("Finn Thain <fthain@telegraphics.com.au>"); 643MODULE_AUTHOR("Finn Thain <fthain@telegraphics.com.au>");
692MODULE_LICENSE("GPL v2"); 644MODULE_LICENSE("GPL v2");
693MODULE_VERSION(DRV_VERSION); 645MODULE_VERSION(DRV_VERSION);
646MODULE_ALIAS("platform:" DRV_MODULE_NAME);
694 647
695module_init(mac_esp_init); 648module_init(mac_esp_init);
696module_exit(mac_esp_exit); 649module_exit(mac_esp_exit);
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 9ff47db0b2ce..888a0ce91c4b 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -1086,12 +1086,12 @@ config SERIAL_68360
1086 default y 1086 default y
1087 1087
1088config SERIAL_PMACZILOG 1088config SERIAL_PMACZILOG
1089 tristate "PowerMac z85c30 ESCC support" 1089 tristate "Mac or PowerMac z85c30 ESCC support"
1090 depends on PPC_OF && PPC_PMAC 1090 depends on (M68K && MAC) || (PPC_OF && PPC_PMAC)
1091 select SERIAL_CORE 1091 select SERIAL_CORE
1092 help 1092 help
1093 This driver supports the Zilog z85C30 serial ports found on 1093 This driver supports the Zilog z85C30 serial ports found on
1094 PowerMac machines. 1094 (Power)Mac machines.
1095 Say Y or M if you want to be able to these serial ports. 1095 Say Y or M if you want to be able to these serial ports.
1096 1096
1097config SERIAL_PMACZILOG_TTYS 1097config SERIAL_PMACZILOG_TTYS
@@ -1116,16 +1116,16 @@ config SERIAL_PMACZILOG_TTYS
1116 unable to use the 8250 module for PCMCIA or other 16C550-style 1116 unable to use the 8250 module for PCMCIA or other 16C550-style
1117 UARTs. 1117 UARTs.
1118 1118
1119 Say N unless you need the z85c30 ports on your powermac 1119 Say N unless you need the z85c30 ports on your (Power)Mac
1120 to appear as /dev/ttySn. 1120 to appear as /dev/ttySn.
1121 1121
1122config SERIAL_PMACZILOG_CONSOLE 1122config SERIAL_PMACZILOG_CONSOLE
1123 bool "Console on PowerMac z85c30 serial port" 1123 bool "Console on Mac or PowerMac z85c30 serial port"
1124 depends on SERIAL_PMACZILOG=y 1124 depends on SERIAL_PMACZILOG=y
1125 select SERIAL_CORE_CONSOLE 1125 select SERIAL_CORE_CONSOLE
1126 help 1126 help
1127 If you would like to be able to use the z85c30 serial port 1127 If you would like to be able to use the z85c30 serial port
1128 on your PowerMac as the console, you can do so by answering 1128 on your (Power)Mac as the console, you can do so by answering
1129 Y to this option. 1129 Y to this option.
1130 1130
1131config SERIAL_LH7A40X 1131config SERIAL_LH7A40X
diff --git a/drivers/serial/pmac_zilog.c b/drivers/serial/pmac_zilog.c
index 3e2ae4807ae2..f020de1cdd50 100644
--- a/drivers/serial/pmac_zilog.c
+++ b/drivers/serial/pmac_zilog.c
@@ -63,11 +63,17 @@
63#include <asm/sections.h> 63#include <asm/sections.h>
64#include <asm/io.h> 64#include <asm/io.h>
65#include <asm/irq.h> 65#include <asm/irq.h>
66
67#ifdef CONFIG_PPC_PMAC
66#include <asm/prom.h> 68#include <asm/prom.h>
67#include <asm/machdep.h> 69#include <asm/machdep.h>
68#include <asm/pmac_feature.h> 70#include <asm/pmac_feature.h>
69#include <asm/dbdma.h> 71#include <asm/dbdma.h>
70#include <asm/macio.h> 72#include <asm/macio.h>
73#else
74#include <linux/platform_device.h>
75#define of_machine_is_compatible(x) (0)
76#endif
71 77
72#if defined (CONFIG_SERIAL_PMACZILOG_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 78#if defined (CONFIG_SERIAL_PMACZILOG_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
73#define SUPPORT_SYSRQ 79#define SUPPORT_SYSRQ
@@ -83,11 +89,9 @@
83 89
84static char version[] __initdata = "pmac_zilog: 0.6 (Benjamin Herrenschmidt <benh@kernel.crashing.org>)"; 90static char version[] __initdata = "pmac_zilog: 0.6 (Benjamin Herrenschmidt <benh@kernel.crashing.org>)";
85MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>"); 91MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
86MODULE_DESCRIPTION("Driver for the PowerMac serial ports."); 92MODULE_DESCRIPTION("Driver for the Mac and PowerMac serial ports.");
87MODULE_LICENSE("GPL"); 93MODULE_LICENSE("GPL");
88 94
89#define PWRDBG(fmt, arg...) printk(KERN_DEBUG fmt , ## arg)
90
91#ifdef CONFIG_SERIAL_PMACZILOG_TTYS 95#ifdef CONFIG_SERIAL_PMACZILOG_TTYS
92#define PMACZILOG_MAJOR TTY_MAJOR 96#define PMACZILOG_MAJOR TTY_MAJOR
93#define PMACZILOG_MINOR 64 97#define PMACZILOG_MINOR 64
@@ -153,8 +157,8 @@ static void pmz_load_zsregs(struct uart_pmac_port *uap, u8 *regs)
153 write_zsreg(uap, R10, regs[R10]); 157 write_zsreg(uap, R10, regs[R10]);
154 158
155 /* Set TX/RX controls sans the enable bits. */ 159 /* Set TX/RX controls sans the enable bits. */
156 write_zsreg(uap, R3, regs[R3] & ~RxENABLE); 160 write_zsreg(uap, R3, regs[R3] & ~RxENABLE);
157 write_zsreg(uap, R5, regs[R5] & ~TxENABLE); 161 write_zsreg(uap, R5, regs[R5] & ~TxENABLE);
158 162
159 /* now set R7 "prime" on ESCC */ 163 /* now set R7 "prime" on ESCC */
160 write_zsreg(uap, R15, regs[R15] | EN85C30); 164 write_zsreg(uap, R15, regs[R15] | EN85C30);
@@ -205,7 +209,7 @@ static void pmz_load_zsregs(struct uart_pmac_port *uap, u8 *regs)
205 */ 209 */
206static void pmz_maybe_update_regs(struct uart_pmac_port *uap) 210static void pmz_maybe_update_regs(struct uart_pmac_port *uap)
207{ 211{
208 if (!ZS_REGS_HELD(uap)) { 212 if (!ZS_REGS_HELD(uap)) {
209 if (ZS_TX_ACTIVE(uap)) { 213 if (ZS_TX_ACTIVE(uap)) {
210 uap->flags |= PMACZILOG_FLAG_REGS_HELD; 214 uap->flags |= PMACZILOG_FLAG_REGS_HELD;
211 } else { 215 } else {
@@ -281,7 +285,7 @@ static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap)
281 spin_lock(&uap->port.lock); 285 spin_lock(&uap->port.lock);
282 if (swallow) 286 if (swallow)
283 goto next_char; 287 goto next_char;
284 } 288 }
285#endif /* CONFIG_MAGIC_SYSRQ && CONFIG_SERIAL_CORE_CONSOLE */ 289#endif /* CONFIG_MAGIC_SYSRQ && CONFIG_SERIAL_CORE_CONSOLE */
286 290
287 /* A real serial line, record the character and status. */ 291 /* A real serial line, record the character and status. */
@@ -317,7 +321,7 @@ static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap)
317 321
318 if (uap->port.ignore_status_mask == 0xff || 322 if (uap->port.ignore_status_mask == 0xff ||
319 (r1 & uap->port.ignore_status_mask) == 0) { 323 (r1 & uap->port.ignore_status_mask) == 0) {
320 tty_insert_flip_char(tty, ch, flag); 324 tty_insert_flip_char(tty, ch, flag);
321 } 325 }
322 if (r1 & Rx_OVR) 326 if (r1 & Rx_OVR)
323 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 327 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
@@ -341,7 +345,7 @@ static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap)
341 uap->curregs[R1] &= ~(EXT_INT_ENAB | TxINT_ENAB | RxINT_MASK); 345 uap->curregs[R1] &= ~(EXT_INT_ENAB | TxINT_ENAB | RxINT_MASK);
342 write_zsreg(uap, R1, uap->curregs[R1]); 346 write_zsreg(uap, R1, uap->curregs[R1]);
343 zssync(uap); 347 zssync(uap);
344 dev_err(&uap->dev->ofdev.dev, "pmz: rx irq flood !\n"); 348 pmz_error("pmz: rx irq flood !\n");
345 return tty; 349 return tty;
346} 350}
347 351
@@ -470,47 +474,47 @@ static irqreturn_t pmz_interrupt(int irq, void *dev_id)
470 474
471 uap_a = pmz_get_port_A(uap); 475 uap_a = pmz_get_port_A(uap);
472 uap_b = uap_a->mate; 476 uap_b = uap_a->mate;
473 477
474 spin_lock(&uap_a->port.lock); 478 spin_lock(&uap_a->port.lock);
475 r3 = read_zsreg(uap_a, R3); 479 r3 = read_zsreg(uap_a, R3);
476 480
477#ifdef DEBUG_HARD 481#ifdef DEBUG_HARD
478 pmz_debug("irq, r3: %x\n", r3); 482 pmz_debug("irq, r3: %x\n", r3);
479#endif 483#endif
480 /* Channel A */ 484 /* Channel A */
481 tty = NULL; 485 tty = NULL;
482 if (r3 & (CHAEXT | CHATxIP | CHARxIP)) { 486 if (r3 & (CHAEXT | CHATxIP | CHARxIP)) {
483 write_zsreg(uap_a, R0, RES_H_IUS); 487 write_zsreg(uap_a, R0, RES_H_IUS);
484 zssync(uap_a); 488 zssync(uap_a);
485 if (r3 & CHAEXT) 489 if (r3 & CHAEXT)
486 pmz_status_handle(uap_a); 490 pmz_status_handle(uap_a);
487 if (r3 & CHARxIP) 491 if (r3 & CHARxIP)
488 tty = pmz_receive_chars(uap_a); 492 tty = pmz_receive_chars(uap_a);
489 if (r3 & CHATxIP) 493 if (r3 & CHATxIP)
490 pmz_transmit_chars(uap_a); 494 pmz_transmit_chars(uap_a);
491 rc = IRQ_HANDLED; 495 rc = IRQ_HANDLED;
492 } 496 }
493 spin_unlock(&uap_a->port.lock); 497 spin_unlock(&uap_a->port.lock);
494 if (tty != NULL) 498 if (tty != NULL)
495 tty_flip_buffer_push(tty); 499 tty_flip_buffer_push(tty);
496 500
497 if (uap_b->node == NULL) 501 if (uap_b->node == NULL)
498 goto out; 502 goto out;
499 503
500 spin_lock(&uap_b->port.lock); 504 spin_lock(&uap_b->port.lock);
501 tty = NULL; 505 tty = NULL;
502 if (r3 & (CHBEXT | CHBTxIP | CHBRxIP)) { 506 if (r3 & (CHBEXT | CHBTxIP | CHBRxIP)) {
503 write_zsreg(uap_b, R0, RES_H_IUS); 507 write_zsreg(uap_b, R0, RES_H_IUS);
504 zssync(uap_b); 508 zssync(uap_b);
505 if (r3 & CHBEXT) 509 if (r3 & CHBEXT)
506 pmz_status_handle(uap_b); 510 pmz_status_handle(uap_b);
507 if (r3 & CHBRxIP) 511 if (r3 & CHBRxIP)
508 tty = pmz_receive_chars(uap_b); 512 tty = pmz_receive_chars(uap_b);
509 if (r3 & CHBTxIP) 513 if (r3 & CHBTxIP)
510 pmz_transmit_chars(uap_b); 514 pmz_transmit_chars(uap_b);
511 rc = IRQ_HANDLED; 515 rc = IRQ_HANDLED;
512 } 516 }
513 spin_unlock(&uap_b->port.lock); 517 spin_unlock(&uap_b->port.lock);
514 if (tty != NULL) 518 if (tty != NULL)
515 tty_flip_buffer_push(tty); 519 tty_flip_buffer_push(tty);
516 520
@@ -718,7 +722,7 @@ static void pmz_enable_ms(struct uart_port *port)
718 722
719 if (ZS_IS_ASLEEP(uap)) 723 if (ZS_IS_ASLEEP(uap))
720 return; 724 return;
721 /* NOTE: Not subject to 'transmitter active' rule. */ 725 /* NOTE: Not subject to 'transmitter active' rule. */
722 write_zsreg(uap, R15, uap->curregs[R15]); 726 write_zsreg(uap, R15, uap->curregs[R15]);
723 } 727 }
724} 728}
@@ -748,7 +752,7 @@ static void pmz_break_ctl(struct uart_port *port, int break_state)
748 if (new_reg != uap->curregs[R5]) { 752 if (new_reg != uap->curregs[R5]) {
749 uap->curregs[R5] = new_reg; 753 uap->curregs[R5] = new_reg;
750 754
751 /* NOTE: Not subject to 'transmitter active' rule. */ 755 /* NOTE: Not subject to 'transmitter active' rule. */
752 if (ZS_IS_ASLEEP(uap)) 756 if (ZS_IS_ASLEEP(uap))
753 return; 757 return;
754 write_zsreg(uap, R5, uap->curregs[R5]); 758 write_zsreg(uap, R5, uap->curregs[R5]);
@@ -757,6 +761,8 @@ static void pmz_break_ctl(struct uart_port *port, int break_state)
757 spin_unlock_irqrestore(&port->lock, flags); 761 spin_unlock_irqrestore(&port->lock, flags);
758} 762}
759 763
764#ifdef CONFIG_PPC_PMAC
765
760/* 766/*
761 * Turn power on or off to the SCC and associated stuff 767 * Turn power on or off to the SCC and associated stuff
762 * (port drivers, modem, IR port, etc.) 768 * (port drivers, modem, IR port, etc.)
@@ -792,6 +798,15 @@ static int pmz_set_scc_power(struct uart_pmac_port *uap, int state)
792 return delay; 798 return delay;
793} 799}
794 800
801#else
802
803static int pmz_set_scc_power(struct uart_pmac_port *uap, int state)
804{
805 return 0;
806}
807
808#endif /* !CONFIG_PPC_PMAC */
809
795/* 810/*
796 * FixZeroBug....Works around a bug in the SCC receving channel. 811 * FixZeroBug....Works around a bug in the SCC receving channel.
797 * Inspired from Darwin code, 15 Sept. 2000 -DanM 812 * Inspired from Darwin code, 15 Sept. 2000 -DanM
@@ -908,7 +923,6 @@ static int __pmz_startup(struct uart_pmac_port *uap)
908 /* Remember status for DCD/CTS changes */ 923 /* Remember status for DCD/CTS changes */
909 uap->prev_status = read_zsreg(uap, R0); 924 uap->prev_status = read_zsreg(uap, R0);
910 925
911
912 return pwr_delay; 926 return pwr_delay;
913} 927}
914 928
@@ -955,9 +969,9 @@ static int pmz_startup(struct uart_port *port)
955 } 969 }
956 970
957 pmz_get_port_A(uap)->flags |= PMACZILOG_FLAG_IS_IRQ_ON; 971 pmz_get_port_A(uap)->flags |= PMACZILOG_FLAG_IS_IRQ_ON;
958 if (request_irq(uap->port.irq, pmz_interrupt, IRQF_SHARED, "PowerMac Zilog", uap)) { 972 if (request_irq(uap->port.irq, pmz_interrupt, IRQF_SHARED,
959 dev_err(&uap->dev->ofdev.dev, 973 "SCC", uap)) {
960 "Unable to register zs interrupt handler.\n"); 974 pmz_error("Unable to register zs interrupt handler.\n");
961 pmz_set_scc_power(uap, 0); 975 pmz_set_scc_power(uap, 0);
962 mutex_unlock(&pmz_irq_mutex); 976 mutex_unlock(&pmz_irq_mutex);
963 return -ENXIO; 977 return -ENXIO;
@@ -983,7 +997,7 @@ static int pmz_startup(struct uart_port *port)
983 if (!ZS_IS_EXTCLK(uap)) 997 if (!ZS_IS_EXTCLK(uap))
984 uap->curregs[R1] |= EXT_INT_ENAB; 998 uap->curregs[R1] |= EXT_INT_ENAB;
985 write_zsreg(uap, R1, uap->curregs[R1]); 999 write_zsreg(uap, R1, uap->curregs[R1]);
986 spin_unlock_irqrestore(&port->lock, flags); 1000 spin_unlock_irqrestore(&port->lock, flags);
987 1001
988 pmz_debug("pmz: startup() done.\n"); 1002 pmz_debug("pmz: startup() done.\n");
989 1003
@@ -1003,7 +1017,7 @@ static void pmz_shutdown(struct uart_port *port)
1003 mutex_lock(&pmz_irq_mutex); 1017 mutex_lock(&pmz_irq_mutex);
1004 1018
1005 /* Release interrupt handler */ 1019 /* Release interrupt handler */
1006 free_irq(uap->port.irq, uap); 1020 free_irq(uap->port.irq, uap);
1007 1021
1008 spin_lock_irqsave(&port->lock, flags); 1022 spin_lock_irqsave(&port->lock, flags);
1009 1023
@@ -1051,7 +1065,6 @@ static void pmz_convert_to_zs(struct uart_pmac_port *uap, unsigned int cflag,
1051{ 1065{
1052 int brg; 1066 int brg;
1053 1067
1054
1055 /* Switch to external clocking for IrDA high clock rates. That 1068 /* Switch to external clocking for IrDA high clock rates. That
1056 * code could be re-used for Midi interfaces with different 1069 * code could be re-used for Midi interfaces with different
1057 * multipliers 1070 * multipliers
@@ -1198,7 +1211,7 @@ static void pmz_irda_setup(struct uart_pmac_port *uap, unsigned long *baud)
1198 while ((read_zsreg(uap, R0) & Tx_BUF_EMP) == 0 1211 while ((read_zsreg(uap, R0) & Tx_BUF_EMP) == 0
1199 || (read_zsreg(uap, R1) & ALL_SNT) == 0) { 1212 || (read_zsreg(uap, R1) & ALL_SNT) == 0) {
1200 if (--t <= 0) { 1213 if (--t <= 0) {
1201 dev_err(&uap->dev->ofdev.dev, "transmitter didn't drain\n"); 1214 pmz_error("transmitter didn't drain\n");
1202 return; 1215 return;
1203 } 1216 }
1204 udelay(10); 1217 udelay(10);
@@ -1214,7 +1227,7 @@ static void pmz_irda_setup(struct uart_pmac_port *uap, unsigned long *baud)
1214 read_zsdata(uap); 1227 read_zsdata(uap);
1215 mdelay(10); 1228 mdelay(10);
1216 if (--t <= 0) { 1229 if (--t <= 0) {
1217 dev_err(&uap->dev->ofdev.dev, "receiver didn't drain\n"); 1230 pmz_error("receiver didn't drain\n");
1218 return; 1231 return;
1219 } 1232 }
1220 } 1233 }
@@ -1223,20 +1236,19 @@ static void pmz_irda_setup(struct uart_pmac_port *uap, unsigned long *baud)
1223 uap->curregs[R5] |= DTR; 1236 uap->curregs[R5] |= DTR;
1224 write_zsreg(uap, R5, uap->curregs[R5]); 1237 write_zsreg(uap, R5, uap->curregs[R5]);
1225 zssync(uap); 1238 zssync(uap);
1226 mdelay(1); 1239 mdelay(1);
1227 1240
1228 /* Switch SCC to 19200 */ 1241 /* Switch SCC to 19200 */
1229 pmz_convert_to_zs(uap, CS8, 0, 19200); 1242 pmz_convert_to_zs(uap, CS8, 0, 19200);
1230 pmz_load_zsregs(uap, uap->curregs); 1243 pmz_load_zsregs(uap, uap->curregs);
1231 mdelay(1); 1244 mdelay(1);
1232 1245
1233 /* Write get_version command byte */ 1246 /* Write get_version command byte */
1234 write_zsdata(uap, 1); 1247 write_zsdata(uap, 1);
1235 t = 5000; 1248 t = 5000;
1236 while ((read_zsreg(uap, R0) & Rx_CH_AV) == 0) { 1249 while ((read_zsreg(uap, R0) & Rx_CH_AV) == 0) {
1237 if (--t <= 0) { 1250 if (--t <= 0) {
1238 dev_err(&uap->dev->ofdev.dev, 1251 pmz_error("irda_setup timed out on get_version byte\n");
1239 "irda_setup timed out on get_version byte\n");
1240 goto out; 1252 goto out;
1241 } 1253 }
1242 udelay(10); 1254 udelay(10);
@@ -1244,8 +1256,7 @@ static void pmz_irda_setup(struct uart_pmac_port *uap, unsigned long *baud)
1244 version = read_zsdata(uap); 1256 version = read_zsdata(uap);
1245 1257
1246 if (version < 4) { 1258 if (version < 4) {
1247 dev_info(&uap->dev->ofdev.dev, "IrDA: dongle version %d not supported\n", 1259 pmz_info("IrDA: dongle version %d not supported\n", version);
1248 version);
1249 goto out; 1260 goto out;
1250 } 1261 }
1251 1262
@@ -1254,18 +1265,16 @@ static void pmz_irda_setup(struct uart_pmac_port *uap, unsigned long *baud)
1254 t = 5000; 1265 t = 5000;
1255 while ((read_zsreg(uap, R0) & Rx_CH_AV) == 0) { 1266 while ((read_zsreg(uap, R0) & Rx_CH_AV) == 0) {
1256 if (--t <= 0) { 1267 if (--t <= 0) {
1257 dev_err(&uap->dev->ofdev.dev, 1268 pmz_error("irda_setup timed out on speed mode byte\n");
1258 "irda_setup timed out on speed mode byte\n");
1259 goto out; 1269 goto out;
1260 } 1270 }
1261 udelay(10); 1271 udelay(10);
1262 } 1272 }
1263 t = read_zsdata(uap); 1273 t = read_zsdata(uap);
1264 if (t != cmdbyte) 1274 if (t != cmdbyte)
1265 dev_err(&uap->dev->ofdev.dev, 1275 pmz_error("irda_setup speed mode byte = %x (%x)\n", t, cmdbyte);
1266 "irda_setup speed mode byte = %x (%x)\n", t, cmdbyte);
1267 1276
1268 dev_info(&uap->dev->ofdev.dev, "IrDA setup for %ld bps, dongle version: %d\n", 1277 pmz_info("IrDA setup for %ld bps, dongle version: %d\n",
1269 *baud, version); 1278 *baud, version);
1270 1279
1271 (void)read_zsdata(uap); 1280 (void)read_zsdata(uap);
@@ -1415,7 +1424,7 @@ static void pmz_poll_put_char(struct uart_port *port, unsigned char c)
1415 write_zsdata(uap, c); 1424 write_zsdata(uap, c);
1416} 1425}
1417 1426
1418#endif 1427#endif /* CONFIG_CONSOLE_POLL */
1419 1428
1420static struct uart_ops pmz_pops = { 1429static struct uart_ops pmz_pops = {
1421 .tx_empty = pmz_tx_empty, 1430 .tx_empty = pmz_tx_empty,
@@ -1440,6 +1449,8 @@ static struct uart_ops pmz_pops = {
1440#endif 1449#endif
1441}; 1450};
1442 1451
1452#ifdef CONFIG_PPC_PMAC
1453
1443/* 1454/*
1444 * Setup one port structure after probing, HW is down at this point, 1455 * Setup one port structure after probing, HW is down at this point,
1445 * Unlike sunzilog, we don't need to pre-init the spinlock as we don't 1456 * Unlike sunzilog, we don't need to pre-init the spinlock as we don't
@@ -1463,7 +1474,7 @@ static int __init pmz_init_port(struct uart_pmac_port *uap)
1463 return -ENODEV; 1474 return -ENODEV;
1464 uap->port.mapbase = r_ports.start; 1475 uap->port.mapbase = r_ports.start;
1465 uap->port.membase = ioremap(uap->port.mapbase, 0x1000); 1476 uap->port.membase = ioremap(uap->port.mapbase, 0x1000);
1466 1477
1467 uap->control_reg = uap->port.membase; 1478 uap->control_reg = uap->port.membase;
1468 uap->data_reg = uap->control_reg + 0x10; 1479 uap->data_reg = uap->control_reg + 0x10;
1469 1480
@@ -1590,7 +1601,7 @@ static void pmz_dispose_port(struct uart_pmac_port *uap)
1590} 1601}
1591 1602
1592/* 1603/*
1593 * Called upon match with an escc node in the devive-tree. 1604 * Called upon match with an escc node in the device-tree.
1594 */ 1605 */
1595static int pmz_attach(struct macio_dev *mdev, const struct of_device_id *match) 1606static int pmz_attach(struct macio_dev *mdev, const struct of_device_id *match)
1596{ 1607{
@@ -1812,7 +1823,7 @@ static int __init pmz_probe(void)
1812 pmz_ports[count].node = node_a; 1823 pmz_ports[count].node = node_a;
1813 pmz_ports[count+1].node = node_b; 1824 pmz_ports[count+1].node = node_b;
1814 pmz_ports[count].port.line = count; 1825 pmz_ports[count].port.line = count;
1815 pmz_ports[count+1].port.line = count+1; 1826 pmz_ports[count+1].port.line = count+1;
1816 1827
1817 /* 1828 /*
1818 * Setup the ports for real 1829 * Setup the ports for real
@@ -1836,6 +1847,88 @@ next:
1836 return 0; 1847 return 0;
1837} 1848}
1838 1849
1850#else
1851
1852extern struct platform_device scc_a_pdev, scc_b_pdev;
1853
1854static int __init pmz_init_port(struct uart_pmac_port *uap)
1855{
1856 struct resource *r_ports;
1857 int irq;
1858
1859 r_ports = platform_get_resource(uap->node, IORESOURCE_MEM, 0);
1860 irq = platform_get_irq(uap->node, 0);
1861 if (!r_ports || !irq)
1862 return -ENODEV;
1863
1864 uap->port.mapbase = r_ports->start;
1865 uap->port.membase = (unsigned char __iomem *) r_ports->start;
1866 uap->port.iotype = UPIO_MEM;
1867 uap->port.irq = irq;
1868 uap->port.uartclk = ZS_CLOCK;
1869 uap->port.fifosize = 1;
1870 uap->port.ops = &pmz_pops;
1871 uap->port.type = PORT_PMAC_ZILOG;
1872 uap->port.flags = 0;
1873
1874 uap->control_reg = uap->port.membase;
1875 uap->data_reg = uap->control_reg + 4;
1876 uap->port_type = 0;
1877
1878 pmz_convert_to_zs(uap, CS8, 0, 9600);
1879
1880 return 0;
1881}
1882
1883static int __init pmz_probe(void)
1884{
1885 int err;
1886
1887 pmz_ports_count = 0;
1888
1889 pmz_ports[0].mate = &pmz_ports[1];
1890 pmz_ports[0].port.line = 0;
1891 pmz_ports[0].flags = PMACZILOG_FLAG_IS_CHANNEL_A;
1892 pmz_ports[0].node = &scc_a_pdev;
1893 err = pmz_init_port(&pmz_ports[0]);
1894 if (err)
1895 return err;
1896 pmz_ports_count++;
1897
1898 pmz_ports[1].mate = &pmz_ports[0];
1899 pmz_ports[1].port.line = 1;
1900 pmz_ports[1].flags = 0;
1901 pmz_ports[1].node = &scc_b_pdev;
1902 err = pmz_init_port(&pmz_ports[1]);
1903 if (err)
1904 return err;
1905 pmz_ports_count++;
1906
1907 return 0;
1908}
1909
1910static void pmz_dispose_port(struct uart_pmac_port *uap)
1911{
1912 memset(uap, 0, sizeof(struct uart_pmac_port));
1913}
1914
1915static int __init pmz_attach(struct platform_device *pdev)
1916{
1917 int i;
1918
1919 for (i = 0; i < pmz_ports_count; i++)
1920 if (pmz_ports[i].node == pdev)
1921 return 0;
1922 return -ENODEV;
1923}
1924
1925static int __exit pmz_detach(struct platform_device *pdev)
1926{
1927 return 0;
1928}
1929
1930#endif /* !CONFIG_PPC_PMAC */
1931
1839#ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE 1932#ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE
1840 1933
1841static void pmz_console_write(struct console *con, const char *s, unsigned int count); 1934static void pmz_console_write(struct console *con, const char *s, unsigned int count);
@@ -1896,28 +1989,41 @@ err_out:
1896 return rc; 1989 return rc;
1897} 1990}
1898 1991
1992#ifdef CONFIG_PPC_PMAC
1993
1899static struct of_device_id pmz_match[] = 1994static struct of_device_id pmz_match[] =
1900{ 1995{
1901 { 1996 {
1902 .name = "ch-a", 1997 .name = "ch-a",
1903 }, 1998 },
1904 { 1999 {
1905 .name = "ch-b", 2000 .name = "ch-b",
1906 }, 2001 },
1907 {}, 2002 {},
1908}; 2003};
1909MODULE_DEVICE_TABLE (of, pmz_match); 2004MODULE_DEVICE_TABLE (of, pmz_match);
1910 2005
1911static struct macio_driver pmz_driver = 2006static struct macio_driver pmz_driver = {
1912{
1913 .name = "pmac_zilog", 2007 .name = "pmac_zilog",
1914 .match_table = pmz_match, 2008 .match_table = pmz_match,
1915 .probe = pmz_attach, 2009 .probe = pmz_attach,
1916 .remove = pmz_detach, 2010 .remove = pmz_detach,
1917 .suspend = pmz_suspend, 2011 .suspend = pmz_suspend,
1918 .resume = pmz_resume, 2012 .resume = pmz_resume,
1919}; 2013};
1920 2014
2015#else
2016
2017static struct platform_driver pmz_driver = {
2018 .remove = __exit_p(pmz_detach),
2019 .driver = {
2020 .name = "scc",
2021 .owner = THIS_MODULE,
2022 },
2023};
2024
2025#endif /* !CONFIG_PPC_PMAC */
2026
1921static int __init init_pmz(void) 2027static int __init init_pmz(void)
1922{ 2028{
1923 int rc, i; 2029 int rc, i;
@@ -1952,19 +2058,27 @@ static int __init init_pmz(void)
1952 pmz_dispose_port(&pmz_ports[i]); 2058 pmz_dispose_port(&pmz_ports[i]);
1953 return rc; 2059 return rc;
1954 } 2060 }
1955 2061
1956 /* 2062 /*
1957 * Then we register the macio driver itself 2063 * Then we register the macio driver itself
1958 */ 2064 */
2065#ifdef CONFIG_PPC_PMAC
1959 return macio_register_driver(&pmz_driver); 2066 return macio_register_driver(&pmz_driver);
2067#else
2068 return platform_driver_probe(&pmz_driver, pmz_attach);
2069#endif
1960} 2070}
1961 2071
1962static void __exit exit_pmz(void) 2072static void __exit exit_pmz(void)
1963{ 2073{
1964 int i; 2074 int i;
1965 2075
2076#ifdef CONFIG_PPC_PMAC
1966 /* Get rid of macio-driver (detach from macio) */ 2077 /* Get rid of macio-driver (detach from macio) */
1967 macio_unregister_driver(&pmz_driver); 2078 macio_unregister_driver(&pmz_driver);
2079#else
2080 platform_driver_unregister(&pmz_driver);
2081#endif
1968 2082
1969 for (i = 0; i < pmz_ports_count; i++) { 2083 for (i = 0; i < pmz_ports_count; i++) {
1970 struct uart_pmac_port *uport = &pmz_ports[i]; 2084 struct uart_pmac_port *uport = &pmz_ports[i];
@@ -2034,7 +2148,7 @@ static int __init pmz_console_setup(struct console *co, char *options)
2034 if (of_machine_is_compatible("RackMac1,1") 2148 if (of_machine_is_compatible("RackMac1,1")
2035 || of_machine_is_compatible("RackMac1,2") 2149 || of_machine_is_compatible("RackMac1,2")
2036 || of_machine_is_compatible("MacRISC4")) 2150 || of_machine_is_compatible("MacRISC4"))
2037 baud = 57600; 2151 baud = 57600;
2038 2152
2039 /* 2153 /*
2040 * Check whether an invalid uart number has been specified, and 2154 * Check whether an invalid uart number has been specified, and
diff --git a/drivers/serial/pmac_zilog.h b/drivers/serial/pmac_zilog.h
index f6e77f12acd5..cbc34fbb1b20 100644
--- a/drivers/serial/pmac_zilog.h
+++ b/drivers/serial/pmac_zilog.h
@@ -1,7 +1,15 @@
1#ifndef __PMAC_ZILOG_H__ 1#ifndef __PMAC_ZILOG_H__
2#define __PMAC_ZILOG_H__ 2#define __PMAC_ZILOG_H__
3 3
4#define pmz_debug(fmt,arg...) dev_dbg(&uap->dev->ofdev.dev, fmt, ## arg) 4#ifdef CONFIG_PPC_PMAC
5#define pmz_debug(fmt, arg...) dev_dbg(&uap->dev->ofdev.dev, fmt, ## arg)
6#define pmz_error(fmt, arg...) dev_err(&uap->dev->ofdev.dev, fmt, ## arg)
7#define pmz_info(fmt, arg...) dev_info(&uap->dev->ofdev.dev, fmt, ## arg)
8#else
9#define pmz_debug(fmt, arg...) dev_dbg(&uap->node->dev, fmt, ## arg)
10#define pmz_error(fmt, arg...) dev_err(&uap->node->dev, fmt, ## arg)
11#define pmz_info(fmt, arg...) dev_info(&uap->node->dev, fmt, ## arg)
12#endif
5 13
6/* 14/*
7 * At most 2 ESCCs with 2 ports each 15 * At most 2 ESCCs with 2 ports each
@@ -17,6 +25,7 @@ struct uart_pmac_port {
17 struct uart_port port; 25 struct uart_port port;
18 struct uart_pmac_port *mate; 26 struct uart_pmac_port *mate;
19 27
28#ifdef CONFIG_PPC_PMAC
20 /* macio_dev for the escc holding this port (maybe be null on 29 /* macio_dev for the escc holding this port (maybe be null on
21 * early inited port) 30 * early inited port)
22 */ 31 */
@@ -25,6 +34,9 @@ struct uart_pmac_port {
25 * of "escc" node (ie. ch-a or ch-b) 34 * of "escc" node (ie. ch-a or ch-b)
26 */ 35 */
27 struct device_node *node; 36 struct device_node *node;
37#else
38 struct platform_device *node;
39#endif
28 40
29 /* Port type as obtained from device tree (IRDA, modem, ...) */ 41 /* Port type as obtained from device tree (IRDA, modem, ...) */
30 int port_type; 42 int port_type;
@@ -55,10 +67,12 @@ struct uart_pmac_port {
55 volatile u8 __iomem *control_reg; 67 volatile u8 __iomem *control_reg;
56 volatile u8 __iomem *data_reg; 68 volatile u8 __iomem *data_reg;
57 69
70#ifdef CONFIG_PPC_PMAC
58 unsigned int tx_dma_irq; 71 unsigned int tx_dma_irq;
59 unsigned int rx_dma_irq; 72 unsigned int rx_dma_irq;
60 volatile struct dbdma_regs __iomem *tx_dma_regs; 73 volatile struct dbdma_regs __iomem *tx_dma_regs;
61 volatile struct dbdma_regs __iomem *rx_dma_regs; 74 volatile struct dbdma_regs __iomem *rx_dma_regs;
75#endif
62 76
63 struct ktermios termios_cache; 77 struct ktermios termios_cache;
64}; 78};
@@ -113,7 +127,7 @@ static inline void zssync(struct uart_pmac_port *port)
113#define BRG_TO_BPS(brg, freq) ((freq) / 2 / ((brg) + 2)) 127#define BRG_TO_BPS(brg, freq) ((freq) / 2 / ((brg) + 2))
114#define BPS_TO_BRG(bps, freq) ((((freq) + (bps)) / (2 * (bps))) - 2) 128#define BPS_TO_BRG(bps, freq) ((((freq) + (bps)) / (2 * (bps))) - 2)
115 129
116#define ZS_CLOCK 3686400 /* Z8530 RTxC input clock rate */ 130#define ZS_CLOCK 3686400 /* Z8530 RTxC input clock rate */
117 131
118/* The Zilog register set */ 132/* The Zilog register set */
119 133
@@ -171,7 +185,7 @@ static inline void zssync(struct uart_pmac_port *port)
171 185
172/* Write Register 3 */ 186/* Write Register 3 */
173 187
174#define RxENABLE 0x1 /* Rx Enable */ 188#define RxENABLE 0x1 /* Rx Enable */
175#define SYNC_L_INH 0x2 /* Sync Character Load Inhibit */ 189#define SYNC_L_INH 0x2 /* Sync Character Load Inhibit */
176#define ADD_SM 0x4 /* Address Search Mode (SDLC) */ 190#define ADD_SM 0x4 /* Address Search Mode (SDLC) */
177#define RxCRC_ENAB 0x8 /* Rx CRC Enable */ 191#define RxCRC_ENAB 0x8 /* Rx CRC Enable */
@@ -185,7 +199,7 @@ static inline void zssync(struct uart_pmac_port *port)
185 199
186/* Write Register 4 */ 200/* Write Register 4 */
187 201
188#define PAR_ENAB 0x1 /* Parity Enable */ 202#define PAR_ENAB 0x1 /* Parity Enable */
189#define PAR_EVEN 0x2 /* Parity Even/Odd* */ 203#define PAR_EVEN 0x2 /* Parity Even/Odd* */
190 204
191#define SYNC_ENAB 0 /* Sync Modes Enable */ 205#define SYNC_ENAB 0 /* Sync Modes Enable */
@@ -210,7 +224,7 @@ static inline void zssync(struct uart_pmac_port *port)
210#define TxCRC_ENAB 0x1 /* Tx CRC Enable */ 224#define TxCRC_ENAB 0x1 /* Tx CRC Enable */
211#define RTS 0x2 /* RTS */ 225#define RTS 0x2 /* RTS */
212#define SDLC_CRC 0x4 /* SDLC/CRC-16 */ 226#define SDLC_CRC 0x4 /* SDLC/CRC-16 */
213#define TxENABLE 0x8 /* Tx Enable */ 227#define TxENABLE 0x8 /* Tx Enable */
214#define SND_BRK 0x10 /* Send Break */ 228#define SND_BRK 0x10 /* Send Break */
215#define Tx5 0x0 /* Tx 5 bits (or less)/character */ 229#define Tx5 0x0 /* Tx 5 bits (or less)/character */
216#define Tx7 0x20 /* Tx 7 bits/character */ 230#define Tx7 0x20 /* Tx 7 bits/character */
@@ -372,11 +386,11 @@ static inline void zssync(struct uart_pmac_port *port)
372#define ZS_TX_ACTIVE(UP) ((UP)->flags & PMACZILOG_FLAG_TX_ACTIVE) 386#define ZS_TX_ACTIVE(UP) ((UP)->flags & PMACZILOG_FLAG_TX_ACTIVE)
373#define ZS_WANTS_MODEM_STATUS(UP) ((UP)->flags & PMACZILOG_FLAG_MODEM_STATUS) 387#define ZS_WANTS_MODEM_STATUS(UP) ((UP)->flags & PMACZILOG_FLAG_MODEM_STATUS)
374#define ZS_IS_IRDA(UP) ((UP)->flags & PMACZILOG_FLAG_IS_IRDA) 388#define ZS_IS_IRDA(UP) ((UP)->flags & PMACZILOG_FLAG_IS_IRDA)
375#define ZS_IS_INTMODEM(UP) ((UP)->flags & PMACZILOG_FLAG_IS_INTMODEM) 389#define ZS_IS_INTMODEM(UP) ((UP)->flags & PMACZILOG_FLAG_IS_INTMODEM)
376#define ZS_HAS_DMA(UP) ((UP)->flags & PMACZILOG_FLAG_HAS_DMA) 390#define ZS_HAS_DMA(UP) ((UP)->flags & PMACZILOG_FLAG_HAS_DMA)
377#define ZS_IS_ASLEEP(UP) ((UP)->flags & PMACZILOG_FLAG_IS_ASLEEP) 391#define ZS_IS_ASLEEP(UP) ((UP)->flags & PMACZILOG_FLAG_IS_ASLEEP)
378#define ZS_IS_OPEN(UP) ((UP)->flags & PMACZILOG_FLAG_IS_OPEN) 392#define ZS_IS_OPEN(UP) ((UP)->flags & PMACZILOG_FLAG_IS_OPEN)
379#define ZS_IS_IRQ_ON(UP) ((UP)->flags & PMACZILOG_FLAG_IS_IRQ_ON) 393#define ZS_IS_IRQ_ON(UP) ((UP)->flags & PMACZILOG_FLAG_IS_IRQ_ON)
380#define ZS_IS_EXTCLK(UP) ((UP)->flags & PMACZILOG_FLAG_IS_EXTCLK) 394#define ZS_IS_EXTCLK(UP) ((UP)->flags & PMACZILOG_FLAG_IS_EXTCLK)
381 395
382#endif /* __PMAC_ZILOG_H__ */ 396#endif /* __PMAC_ZILOG_H__ */
diff --git a/drivers/video/macfb.c b/drivers/video/macfb.c
index d66887e8cbb1..43207cc6cc19 100644
--- a/drivers/video/macfb.c
+++ b/drivers/video/macfb.c
@@ -1,29 +1,33 @@
1/* macfb.c: Generic framebuffer for Macs whose colourmaps/modes we 1/*
2 don't know how to set */ 2 * macfb.c: Generic framebuffer for Macs whose colourmaps/modes we
3 3 * don't know how to set.
4/* (c) 1999 David Huggins-Daines <dhd@debian.org> 4 *
5 5 * (c) 1999 David Huggins-Daines <dhd@debian.org>
6 Primarily based on vesafb.c, by Gerd Knorr 6 *
7 (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de> 7 * Primarily based on vesafb.c, by Gerd Knorr
8 8 * (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de>
9 Also uses information and code from: 9 *
10 10 * Also uses information and code from:
11 The original macfb.c from Linux/mac68k 2.0, by Alan Cox, Juergen 11 *
12 Mellinger, Mikael Forselius, Michael Schmitz, and others. 12 * The original macfb.c from Linux/mac68k 2.0, by Alan Cox, Juergen
13 13 * Mellinger, Mikael Forselius, Michael Schmitz, and others.
14 valkyriefb.c, by Martin Costabel, Kevin Schoedel, Barry Nathan, Dan 14 *
15 Jacobowitz, Paul Mackerras, Fabio Riccardi, and Geert Uytterhoeven. 15 * valkyriefb.c, by Martin Costabel, Kevin Schoedel, Barry Nathan, Dan
16 16 * Jacobowitz, Paul Mackerras, Fabio Riccardi, and Geert Uytterhoeven.
17 This code is free software. You may copy, modify, and distribute 17 *
18 it subject to the terms and conditions of the GNU General Public 18 * The VideoToolbox "Bugs" web page at
19 License, version 2, or any later version, at your convenience. */ 19 * http://rajsky.psych.nyu.edu/Tips/VideoBugs.html
20 *
21 * This code is free software. You may copy, modify, and distribute
22 * it subject to the terms and conditions of the GNU General Public
23 * License, version 2, or any later version, at your convenience.
24 */
20 25
21#include <linux/module.h> 26#include <linux/module.h>
22#include <linux/kernel.h> 27#include <linux/kernel.h>
23#include <linux/errno.h> 28#include <linux/errno.h>
24#include <linux/string.h> 29#include <linux/string.h>
25#include <linux/mm.h> 30#include <linux/mm.h>
26#include <linux/slab.h>
27#include <linux/delay.h> 31#include <linux/delay.h>
28#include <linux/nubus.h> 32#include <linux/nubus.h>
29#include <linux/init.h> 33#include <linux/init.h>
@@ -31,9 +35,6 @@
31 35
32#include <asm/setup.h> 36#include <asm/setup.h>
33#include <asm/bootinfo.h> 37#include <asm/bootinfo.h>
34#include <asm/uaccess.h>
35#include <asm/pgtable.h>
36#include <asm/irq.h>
37#include <asm/macintosh.h> 38#include <asm/macintosh.h>
38#include <asm/io.h> 39#include <asm/io.h>
39 40
@@ -44,7 +45,7 @@
44#define DAFB_BASE 0xf9800200 45#define DAFB_BASE 0xf9800200
45 46
46/* Address for the built-in Civic framebuffer in Quadra AVs */ 47/* Address for the built-in Civic framebuffer in Quadra AVs */
47#define CIVIC_BASE 0x50f30800 /* Only tested on 660AV! */ 48#define CIVIC_BASE 0x50f30800
48 49
49/* GSC (Gray Scale Controller) base address */ 50/* GSC (Gray Scale Controller) base address */
50#define GSC_BASE 0x50F20000 51#define GSC_BASE 0x50F20000
@@ -52,37 +53,9 @@
52/* CSC (Color Screen Controller) base address */ 53/* CSC (Color Screen Controller) base address */
53#define CSC_BASE 0x50F20000 54#define CSC_BASE 0x50F20000
54 55
55static int (*macfb_setpalette) (unsigned int regno, unsigned int red, 56static int (*macfb_setpalette)(unsigned int regno, unsigned int red,
56 unsigned int green, unsigned int blue, 57 unsigned int green, unsigned int blue,
57 struct fb_info *info) = NULL; 58 struct fb_info *info);
58static int valkyrie_setpalette (unsigned int regno, unsigned int red,
59 unsigned int green, unsigned int blue,
60 struct fb_info *info);
61static int dafb_setpalette (unsigned int regno, unsigned int red,
62 unsigned int green, unsigned int blue,
63 struct fb_info *fb_info);
64static int rbv_setpalette (unsigned int regno, unsigned int red,
65 unsigned int green, unsigned int blue,
66 struct fb_info *fb_info);
67static int mdc_setpalette (unsigned int regno, unsigned int red,
68 unsigned int green, unsigned int blue,
69 struct fb_info *fb_info);
70static int toby_setpalette (unsigned int regno, unsigned int red,
71 unsigned int green, unsigned int blue,
72 struct fb_info *fb_info);
73static int civic_setpalette (unsigned int regno, unsigned int red,
74 unsigned int green, unsigned int blue,
75 struct fb_info *fb_info);
76static int csc_setpalette (unsigned int regno, unsigned int red,
77 unsigned int green, unsigned int blue,
78 struct fb_info *fb_info);
79
80static struct {
81 unsigned char addr;
82 /* Note: word-aligned */
83 char pad[3];
84 unsigned char lut;
85} __iomem *valkyrie_cmap_regs;
86 59
87static struct { 60static struct {
88 unsigned char addr; 61 unsigned char addr;
@@ -116,15 +89,15 @@ static struct {
116} __iomem *civic_cmap_regs; 89} __iomem *civic_cmap_regs;
117 90
118static struct { 91static struct {
119 char pad1[0x40]; 92 char pad1[0x40];
120 unsigned char clut_waddr; /* 0x40 */ 93 unsigned char clut_waddr; /* 0x40 */
121 char pad2; 94 char pad2;
122 unsigned char clut_data; /* 0x42 */ 95 unsigned char clut_data; /* 0x42 */
123 char pad3[0x3]; 96 char pad3[0x3];
124 unsigned char clut_raddr; /* 0x46 */ 97 unsigned char clut_raddr; /* 0x46 */
125} __iomem *csc_cmap_regs; 98} __iomem *csc_cmap_regs;
126 99
127/* We will leave these the way they are for the time being */ 100/* The registers in these structs are in NuBus slot space */
128struct mdc_cmap_regs { 101struct mdc_cmap_regs {
129 char pad1[0x200200]; 102 char pad1[0x200200];
130 unsigned char addr; 103 unsigned char addr;
@@ -145,13 +118,10 @@ struct jet_cmap_regs {
145 unsigned char lut; 118 unsigned char lut;
146}; 119};
147 120
148#define PIXEL_TO_MM(a) (((a)*10)/28) /* width in mm at 72 dpi */ 121#define PIXEL_TO_MM(a) (((a)*10)/28) /* width in mm at 72 dpi */
149
150/* mode */
151static int video_slot = 0;
152 122
153static struct fb_var_screeninfo macfb_defined = { 123static struct fb_var_screeninfo macfb_defined = {
154 .bits_per_pixel = 8, 124 .bits_per_pixel = 8,
155 .activate = FB_ACTIVATE_NOW, 125 .activate = FB_ACTIVATE_NOW,
156 .width = -1, 126 .width = -1,
157 .height = -1, 127 .height = -1,
@@ -167,181 +137,152 @@ static struct fb_fix_screeninfo macfb_fix = {
167 .accel = FB_ACCEL_NONE, 137 .accel = FB_ACCEL_NONE,
168}; 138};
169 139
140static void *slot_addr;
170static struct fb_info fb_info; 141static struct fb_info fb_info;
171static u32 pseudo_palette[16]; 142static u32 pseudo_palette[16];
172static int inverse = 0; 143static int inverse;
173static int vidtest = 0; 144static int vidtest;
174 145
175static int valkyrie_setpalette (unsigned int regno, unsigned int red, 146/*
176 unsigned int green, unsigned int blue, 147 * Unlike the Valkyrie, the DAFB cannot set individual colormap
177 struct fb_info *info) 148 * registers. Therefore, we do what the MacOS driver does (no
178{ 149 * kidding!) and simply set them one by one until we hit the one we
179 unsigned long flags; 150 * want.
180 151 */
181 red >>= 8; 152static int dafb_setpalette(unsigned int regno, unsigned int red,
182 green >>= 8; 153 unsigned int green, unsigned int blue,
183 blue >>= 8; 154 struct fb_info *info)
184
185 local_irq_save(flags);
186
187 /* tell clut which address to fill */
188 nubus_writeb(regno, &valkyrie_cmap_regs->addr);
189 nop();
190
191 /* send one color channel at a time */
192 nubus_writeb(red, &valkyrie_cmap_regs->lut);
193 nop();
194 nubus_writeb(green, &valkyrie_cmap_regs->lut);
195 nop();
196 nubus_writeb(blue, &valkyrie_cmap_regs->lut);
197
198 local_irq_restore(flags);
199 return 0;
200}
201
202/* Unlike the Valkyrie, the DAFB cannot set individual colormap
203 registers. Therefore, we do what the MacOS driver does (no
204 kidding!) and simply set them one by one until we hit the one we
205 want. */
206static int dafb_setpalette (unsigned int regno, unsigned int red,
207 unsigned int green, unsigned int blue,
208 struct fb_info *info)
209{ 155{
210 /* FIXME: really, really need to use ioremap() here,
211 phys_to_virt() doesn't work anymore */
212 static int lastreg = -1; 156 static int lastreg = -1;
213 unsigned long flags; 157 unsigned long flags;
214
215 red >>= 8;
216 green >>= 8;
217 blue >>= 8;
218 158
219 local_irq_save(flags); 159 local_irq_save(flags);
220 160
221 /* fbdev will set an entire colourmap, but X won't. Hopefully 161 /*
222 this should accommodate both of them */ 162 * fbdev will set an entire colourmap, but X won't. Hopefully
223 if (regno != lastreg+1) { 163 * this should accommodate both of them
164 */
165 if (regno != lastreg + 1) {
224 int i; 166 int i;
225 167
226 /* Stab in the dark trying to reset the CLUT pointer */ 168 /* Stab in the dark trying to reset the CLUT pointer */
227 nubus_writel(0, &dafb_cmap_regs->reset); 169 nubus_writel(0, &dafb_cmap_regs->reset);
228 nop(); 170 nop();
229 171
230 /* Loop until we get to the register we want */ 172 /* Loop until we get to the register we want */
231 for (i = 0; i < regno; i++) { 173 for (i = 0; i < regno; i++) {
232 nubus_writeb(info->cmap.red[i] >> 8, &dafb_cmap_regs->lut); 174 nubus_writeb(info->cmap.red[i] >> 8,
175 &dafb_cmap_regs->lut);
233 nop(); 176 nop();
234 nubus_writeb(info->cmap.green[i] >> 8, &dafb_cmap_regs->lut); 177 nubus_writeb(info->cmap.green[i] >> 8,
178 &dafb_cmap_regs->lut);
235 nop(); 179 nop();
236 nubus_writeb(info->cmap.blue[i] >> 8, &dafb_cmap_regs->lut); 180 nubus_writeb(info->cmap.blue[i] >> 8,
181 &dafb_cmap_regs->lut);
237 nop(); 182 nop();
238 } 183 }
239 } 184 }
240 185
241 nubus_writeb(red, &dafb_cmap_regs->lut); 186 nubus_writeb(red, &dafb_cmap_regs->lut);
242 nop(); 187 nop();
243 nubus_writeb(green, &dafb_cmap_regs->lut); 188 nubus_writeb(green, &dafb_cmap_regs->lut);
244 nop(); 189 nop();
245 nubus_writeb(blue, &dafb_cmap_regs->lut); 190 nubus_writeb(blue, &dafb_cmap_regs->lut);
246 191
247 local_irq_restore(flags); 192 local_irq_restore(flags);
248 lastreg = regno; 193 lastreg = regno;
249 return 0; 194 return 0;
250} 195}
251 196
252/* V8 and Brazil seem to use the same DAC. Sonora does as well. */ 197/* V8 and Brazil seem to use the same DAC. Sonora does as well. */
253static int v8_brazil_setpalette (unsigned int regno, unsigned int red, 198static int v8_brazil_setpalette(unsigned int regno, unsigned int red,
254 unsigned int green, unsigned int blue, 199 unsigned int green, unsigned int blue,
255 struct fb_info *info) 200 struct fb_info *info)
256{ 201{
257 unsigned int bpp = info->var.bits_per_pixel; 202 unsigned int bpp = info->var.bits_per_pixel;
258 unsigned char _red =red>>8;
259 unsigned char _green=green>>8;
260 unsigned char _blue =blue>>8;
261 unsigned char _regno;
262 unsigned long flags; 203 unsigned long flags;
263 204
264 if (bpp > 8) return 1; /* failsafe */ 205 if (bpp > 8)
206 return 1; /* failsafe */
265 207
266 local_irq_save(flags); 208 local_irq_save(flags);
267 209
268 /* On these chips, the CLUT register numbers are spread out 210 /* On these chips, the CLUT register numbers are spread out
269 across the register space. Thus: 211 * across the register space. Thus:
270 212 * In 8bpp, all regnos are valid.
271 In 8bpp, all regnos are valid. 213 * In 4bpp, the regnos are 0x0f, 0x1f, 0x2f, etc, etc
272 214 * In 2bpp, the regnos are 0x3f, 0x7f, 0xbf, 0xff
273 In 4bpp, the regnos are 0x0f, 0x1f, 0x2f, etc, etc 215 */
274 216 regno = (regno << (8 - bpp)) | (0xFF >> bpp);
275 In 2bpp, the regnos are 0x3f, 0x7f, 0xbf, 0xff */ 217 nubus_writeb(regno, &v8_brazil_cmap_regs->addr);
276 _regno = (regno << (8 - bpp)) | (0xFF >> bpp); 218 nop();
277 nubus_writeb(_regno, &v8_brazil_cmap_regs->addr); nop();
278 219
279 /* send one color channel at a time */ 220 /* send one color channel at a time */
280 nubus_writeb(_red, &v8_brazil_cmap_regs->lut); nop(); 221 nubus_writeb(red, &v8_brazil_cmap_regs->lut);
281 nubus_writeb(_green, &v8_brazil_cmap_regs->lut); nop(); 222 nop();
282 nubus_writeb(_blue, &v8_brazil_cmap_regs->lut); 223 nubus_writeb(green, &v8_brazil_cmap_regs->lut);
224 nop();
225 nubus_writeb(blue, &v8_brazil_cmap_regs->lut);
283 226
284 local_irq_restore(flags); 227 local_irq_restore(flags);
285 return 0; 228 return 0;
286} 229}
287 230
288static int rbv_setpalette (unsigned int regno, unsigned int red, 231/* RAM-Based Video */
289 unsigned int green, unsigned int blue, 232static int rbv_setpalette(unsigned int regno, unsigned int red,
290 struct fb_info *info) 233 unsigned int green, unsigned int blue,
234 struct fb_info *info)
291{ 235{
292 /* use MSBs */
293 unsigned char _red =red>>8;
294 unsigned char _green=green>>8;
295 unsigned char _blue =blue>>8;
296 unsigned char _regno;
297 unsigned long flags; 236 unsigned long flags;
298 237
299 if (info->var.bits_per_pixel > 8) return 1; /* failsafe */ 238 if (info->var.bits_per_pixel > 8)
239 return 1; /* failsafe */
300 240
301 local_irq_save(flags); 241 local_irq_save(flags);
302 242
303 /* From the VideoToolbox driver. Seems to be saying that 243 /* From the VideoToolbox driver. Seems to be saying that
304 * regno #254 and #255 are the important ones for 1-bit color, 244 * regno #254 and #255 are the important ones for 1-bit color,
305 * regno #252-255 are the important ones for 2-bit color, etc. 245 * regno #252-255 are the important ones for 2-bit color, etc.
306 */ 246 */
307 _regno = regno + (256-(1 << info->var.bits_per_pixel)); 247 regno += 256 - (1 << info->var.bits_per_pixel);
308 248
309 /* reset clut? (VideoToolbox sez "not necessary") */ 249 /* reset clut? (VideoToolbox sez "not necessary") */
310 nubus_writeb(0xFF, &rbv_cmap_regs->cntl); nop(); 250 nubus_writeb(0xFF, &rbv_cmap_regs->cntl);
311 251 nop();
252
312 /* tell clut which address to use. */ 253 /* tell clut which address to use. */
313 nubus_writeb(_regno, &rbv_cmap_regs->addr); nop(); 254 nubus_writeb(regno, &rbv_cmap_regs->addr);
314 255 nop();
256
315 /* send one color channel at a time. */ 257 /* send one color channel at a time. */
316 nubus_writeb(_red, &rbv_cmap_regs->lut); nop(); 258 nubus_writeb(red, &rbv_cmap_regs->lut);
317 nubus_writeb(_green, &rbv_cmap_regs->lut); nop(); 259 nop();
318 nubus_writeb(_blue, &rbv_cmap_regs->lut); 260 nubus_writeb(green, &rbv_cmap_regs->lut);
319 261 nop();
320 local_irq_restore(flags); /* done. */ 262 nubus_writeb(blue, &rbv_cmap_regs->lut);
263
264 local_irq_restore(flags);
321 return 0; 265 return 0;
322} 266}
323 267
324/* Macintosh Display Card (8x24) */ 268/* Macintosh Display Card (8*24) */
325static int mdc_setpalette(unsigned int regno, unsigned int red, 269static int mdc_setpalette(unsigned int regno, unsigned int red,
326 unsigned int green, unsigned int blue, 270 unsigned int green, unsigned int blue,
327 struct fb_info *info) 271 struct fb_info *info)
328{ 272{
329 volatile struct mdc_cmap_regs *cmap_regs = 273 struct mdc_cmap_regs *cmap_regs = slot_addr;
330 nubus_slot_addr(video_slot);
331 /* use MSBs */
332 unsigned char _red =red>>8;
333 unsigned char _green=green>>8;
334 unsigned char _blue =blue>>8;
335 unsigned char _regno=regno;
336 unsigned long flags; 274 unsigned long flags;
337 275
338 local_irq_save(flags); 276 local_irq_save(flags);
339 277
340 /* the nop's are there to order writes. */ 278 /* the nop's are there to order writes. */
341 nubus_writeb(_regno, &cmap_regs->addr); nop(); 279 nubus_writeb(regno, &cmap_regs->addr);
342 nubus_writeb(_red, &cmap_regs->lut); nop(); 280 nop();
343 nubus_writeb(_green, &cmap_regs->lut); nop(); 281 nubus_writeb(red, &cmap_regs->lut);
344 nubus_writeb(_blue, &cmap_regs->lut); 282 nop();
283 nubus_writeb(green, &cmap_regs->lut);
284 nop();
285 nubus_writeb(blue, &cmap_regs->lut);
345 286
346 local_irq_restore(flags); 287 local_irq_restore(flags);
347 return 0; 288 return 0;
@@ -350,24 +291,26 @@ static int mdc_setpalette(unsigned int regno, unsigned int red,
350/* Toby frame buffer */ 291/* Toby frame buffer */
351static int toby_setpalette(unsigned int regno, unsigned int red, 292static int toby_setpalette(unsigned int regno, unsigned int red,
352 unsigned int green, unsigned int blue, 293 unsigned int green, unsigned int blue,
353 struct fb_info *info) 294 struct fb_info *info)
354{ 295{
355 volatile struct toby_cmap_regs *cmap_regs = 296 struct toby_cmap_regs *cmap_regs = slot_addr;
356 nubus_slot_addr(video_slot);
357 unsigned int bpp = info->var.bits_per_pixel; 297 unsigned int bpp = info->var.bits_per_pixel;
358 /* use MSBs */
359 unsigned char _red =~(red>>8);
360 unsigned char _green=~(green>>8);
361 unsigned char _blue =~(blue>>8);
362 unsigned char _regno = (regno << (8 - bpp)) | (0xFF >> bpp);
363 unsigned long flags; 298 unsigned long flags;
364 299
300 red = ~red;
301 green = ~green;
302 blue = ~blue;
303 regno = (regno << (8 - bpp)) | (0xFF >> bpp);
304
365 local_irq_save(flags); 305 local_irq_save(flags);
366 306
367 nubus_writeb(_regno, &cmap_regs->addr); nop(); 307 nubus_writeb(regno, &cmap_regs->addr);
368 nubus_writeb(_red, &cmap_regs->lut); nop(); 308 nop();
369 nubus_writeb(_green, &cmap_regs->lut); nop(); 309 nubus_writeb(red, &cmap_regs->lut);
370 nubus_writeb(_blue, &cmap_regs->lut); 310 nop();
311 nubus_writeb(green, &cmap_regs->lut);
312 nop();
313 nubus_writeb(blue, &cmap_regs->lut);
371 314
372 local_irq_restore(flags); 315 local_irq_restore(flags);
373 return 0; 316 return 0;
@@ -378,20 +321,18 @@ static int jet_setpalette(unsigned int regno, unsigned int red,
378 unsigned int green, unsigned int blue, 321 unsigned int green, unsigned int blue,
379 struct fb_info *info) 322 struct fb_info *info)
380{ 323{
381 volatile struct jet_cmap_regs *cmap_regs = 324 struct jet_cmap_regs *cmap_regs = slot_addr;
382 nubus_slot_addr(video_slot);
383 /* use MSBs */
384 unsigned char _red = (red>>8);
385 unsigned char _green = (green>>8);
386 unsigned char _blue = (blue>>8);
387 unsigned long flags; 325 unsigned long flags;
388 326
389 local_irq_save(flags); 327 local_irq_save(flags);
390 328
391 nubus_writeb(regno, &cmap_regs->addr); nop(); 329 nubus_writeb(regno, &cmap_regs->addr);
392 nubus_writeb(_red, &cmap_regs->lut); nop(); 330 nop();
393 nubus_writeb(_green, &cmap_regs->lut); nop(); 331 nubus_writeb(red, &cmap_regs->lut);
394 nubus_writeb(_blue, &cmap_regs->lut); 332 nop();
333 nubus_writeb(green, &cmap_regs->lut);
334 nop();
335 nubus_writeb(blue, &cmap_regs->lut);
395 336
396 local_irq_restore(flags); 337 local_irq_restore(flags);
397 return 0; 338 return 0;
@@ -400,53 +341,27 @@ static int jet_setpalette(unsigned int regno, unsigned int red,
400/* 341/*
401 * Civic framebuffer -- Quadra AV built-in video. A chip 342 * Civic framebuffer -- Quadra AV built-in video. A chip
402 * called Sebastian holds the actual color palettes, and 343 * called Sebastian holds the actual color palettes, and
403 * apparently, there are two different banks of 512K RAM 344 * apparently, there are two different banks of 512K RAM
404 * which can act as separate framebuffers for doing video 345 * which can act as separate framebuffers for doing video
405 * input and viewing the screen at the same time! The 840AV 346 * input and viewing the screen at the same time! The 840AV
406 * Can add another 1MB RAM to give the two framebuffers 347 * Can add another 1MB RAM to give the two framebuffers
407 * 1MB RAM apiece. 348 * 1MB RAM apiece.
408 *
409 * FIXME: this doesn't seem to work anymore.
410 */ 349 */
411static int civic_setpalette (unsigned int regno, unsigned int red, 350static int civic_setpalette(unsigned int regno, unsigned int red,
412 unsigned int green, unsigned int blue, 351 unsigned int green, unsigned int blue,
413 struct fb_info *info) 352 struct fb_info *info)
414{ 353{
415 static int lastreg = -1;
416 unsigned long flags; 354 unsigned long flags;
417 int clut_status; 355 int clut_status;
418 356
419 if (info->var.bits_per_pixel > 8) return 1; /* failsafe */ 357 if (info->var.bits_per_pixel > 8)
420 358 return 1; /* failsafe */
421 red >>= 8;
422 green >>= 8;
423 blue >>= 8;
424 359
425 local_irq_save(flags); 360 local_irq_save(flags);
426
427 /*
428 * Set the register address
429 */
430 nubus_writeb(regno, &civic_cmap_regs->addr); nop();
431 361
432 /* 362 /* Set the register address */
433 * Wait for VBL interrupt here; 363 nubus_writeb(regno, &civic_cmap_regs->addr);
434 * They're usually not enabled from Penguin, so we won't check 364 nop();
435 */
436#if 0
437 {
438#define CIVIC_VBL_OFFSET 0x120
439 volatile unsigned long *vbl = nubus_readl(civic_cmap_regs->vbl_addr + CIVIC_VBL_OFFSET);
440 /* do interrupt setup stuff here? */
441 *vbl = 0L; nop(); /* clear */
442 *vbl = 1L; nop(); /* set */
443 while (*vbl != 0L) /* wait for next vbl */
444 {
445 usleep(10); /* needed? */
446 }
447 /* do interrupt shutdown stuff here? */
448 }
449#endif
450 365
451 /* 366 /*
452 * Grab a status word and do some checking; 367 * Grab a status word and do some checking;
@@ -459,39 +374,52 @@ static int civic_setpalette (unsigned int regno, unsigned int red,
459#if 0 374#if 0
460 if ((clut_status & 0x000D) != 0) 375 if ((clut_status & 0x000D) != 0)
461 { 376 {
462 nubus_writeb(0x00, &civic_cmap_regs->lut); nop(); 377 nubus_writeb(0x00, &civic_cmap_regs->lut);
463 nubus_writeb(0x00, &civic_cmap_regs->lut); nop(); 378 nop();
379 nubus_writeb(0x00, &civic_cmap_regs->lut);
380 nop();
464 } 381 }
465#endif 382#endif
466 383
467 nubus_writeb( red, &civic_cmap_regs->lut); nop(); 384 nubus_writeb(red, &civic_cmap_regs->lut);
468 nubus_writeb(green, &civic_cmap_regs->lut); nop(); 385 nop();
469 nubus_writeb( blue, &civic_cmap_regs->lut); nop(); 386 nubus_writeb(green, &civic_cmap_regs->lut);
470 nubus_writeb( 0x00, &civic_cmap_regs->lut); nop(); 387 nop();
388 nubus_writeb(blue, &civic_cmap_regs->lut);
389 nop();
390 nubus_writeb(0x00, &civic_cmap_regs->lut);
471 } 391 }
472 else 392 else
473 { 393 {
474 unsigned char junk; 394 unsigned char junk;
475 395
476 junk = nubus_readb(&civic_cmap_regs->lut); nop(); 396 junk = nubus_readb(&civic_cmap_regs->lut);
477 junk = nubus_readb(&civic_cmap_regs->lut); nop(); 397 nop();
478 junk = nubus_readb(&civic_cmap_regs->lut); nop(); 398 junk = nubus_readb(&civic_cmap_regs->lut);
479 junk = nubus_readb(&civic_cmap_regs->lut); nop(); 399 nop();
400 junk = nubus_readb(&civic_cmap_regs->lut);
401 nop();
402 junk = nubus_readb(&civic_cmap_regs->lut);
403 nop();
480 404
481 if ((clut_status & 0x000D) != 0) 405 if ((clut_status & 0x000D) != 0)
482 { 406 {
483 nubus_writeb(0x00, &civic_cmap_regs->lut); nop(); 407 nubus_writeb(0x00, &civic_cmap_regs->lut);
484 nubus_writeb(0x00, &civic_cmap_regs->lut); nop(); 408 nop();
409 nubus_writeb(0x00, &civic_cmap_regs->lut);
410 nop();
485 } 411 }
486 412
487 nubus_writeb( red, &civic_cmap_regs->lut); nop(); 413 nubus_writeb(red, &civic_cmap_regs->lut);
488 nubus_writeb(green, &civic_cmap_regs->lut); nop(); 414 nop();
489 nubus_writeb( blue, &civic_cmap_regs->lut); nop(); 415 nubus_writeb(green, &civic_cmap_regs->lut);
490 nubus_writeb( junk, &civic_cmap_regs->lut); nop(); 416 nop();
417 nubus_writeb(blue, &civic_cmap_regs->lut);
418 nop();
419 nubus_writeb(junk, &civic_cmap_regs->lut);
491 } 420 }
492 421
493 local_irq_restore(flags); 422 local_irq_restore(flags);
494 lastreg = regno;
495 return 0; 423 return 0;
496} 424}
497 425
@@ -500,16 +428,21 @@ static int civic_setpalette (unsigned int regno, unsigned int red,
500 * (and the 5300 too, but that's a PowerMac). This function 428 * (and the 5300 too, but that's a PowerMac). This function
501 * brought to you in part by the ECSC driver for MkLinux. 429 * brought to you in part by the ECSC driver for MkLinux.
502 */ 430 */
503 431static int csc_setpalette(unsigned int regno, unsigned int red,
504static int csc_setpalette (unsigned int regno, unsigned int red, 432 unsigned int green, unsigned int blue,
505 unsigned int green, unsigned int blue, 433 struct fb_info *info)
506 struct fb_info *info)
507{ 434{
508 mdelay(1); 435 unsigned long flags;
436
437 local_irq_save(flags);
438
439 udelay(1); /* mklinux on PB 5300 waits for 260 ns */
509 nubus_writeb(regno, &csc_cmap_regs->clut_waddr); 440 nubus_writeb(regno, &csc_cmap_regs->clut_waddr);
510 nubus_writeb(red, &csc_cmap_regs->clut_data); 441 nubus_writeb(red, &csc_cmap_regs->clut_data);
511 nubus_writeb(green, &csc_cmap_regs->clut_data); 442 nubus_writeb(green, &csc_cmap_regs->clut_data);
512 nubus_writeb(blue, &csc_cmap_regs->clut_data); 443 nubus_writeb(blue, &csc_cmap_regs->clut_data);
444
445 local_irq_restore(flags);
513 return 0; 446 return 0;
514} 447}
515 448
@@ -518,10 +451,10 @@ static int macfb_setcolreg(unsigned regno, unsigned red, unsigned green,
518 struct fb_info *fb_info) 451 struct fb_info *fb_info)
519{ 452{
520 /* 453 /*
521 * Set a single color register. The values supplied are 454 * Set a single color register. The values supplied are
522 * already rounded down to the hardware's capabilities 455 * already rounded down to the hardware's capabilities
523 * (according to the entries in the `var' structure). Return 456 * (according to the entries in the `var' structure).
524 * != 0 for invalid regno. 457 * Return non-zero for invalid regno.
525 */ 458 */
526 459
527 if (regno >= fb_info->cmap.len) 460 if (regno >= fb_info->cmap.len)
@@ -536,8 +469,8 @@ static int macfb_setcolreg(unsigned regno, unsigned red, unsigned green,
536 case 4: 469 case 4:
537 case 8: 470 case 8:
538 if (macfb_setpalette) 471 if (macfb_setpalette)
539 macfb_setpalette(regno, red, green, blue, 472 macfb_setpalette(regno, red >> 8, green >> 8,
540 fb_info); 473 blue >> 8, fb_info);
541 else 474 else
542 return 1; 475 return 1;
543 break; 476 break;
@@ -555,28 +488,22 @@ static int macfb_setcolreg(unsigned regno, unsigned red, unsigned green,
555 } else { 488 } else {
556 /* 0:5:6:5 */ 489 /* 0:5:6:5 */
557 ((u32*) (fb_info->pseudo_palette))[regno] = 490 ((u32*) (fb_info->pseudo_palette))[regno] =
558 ((red & 0xf800) ) | 491 ((red & 0xf800) >> 0) |
559 ((green & 0xfc00) >> 5) | 492 ((green & 0xfc00) >> 5) |
560 ((blue & 0xf800) >> 11); 493 ((blue & 0xf800) >> 11);
561 } 494 }
562 break; 495 break;
563 /* I'm pretty sure that one or the other of these 496 /*
564 doesn't exist on 68k Macs */ 497 * 24-bit colour almost doesn't exist on 68k Macs --
498 * http://support.apple.com/kb/TA28634 (Old Article: 10992)
499 */
565 case 24: 500 case 24:
566 red >>= 8;
567 green >>= 8;
568 blue >>= 8;
569 ((u32 *)(fb_info->pseudo_palette))[regno] =
570 (red << fb_info->var.red.offset) |
571 (green << fb_info->var.green.offset) |
572 (blue << fb_info->var.blue.offset);
573 break;
574 case 32: 501 case 32:
575 red >>= 8; 502 red >>= 8;
576 green >>= 8; 503 green >>= 8;
577 blue >>= 8; 504 blue >>= 8;
578 ((u32 *)(fb_info->pseudo_palette))[regno] = 505 ((u32 *)(fb_info->pseudo_palette))[regno] =
579 (red << fb_info->var.red.offset) | 506 (red << fb_info->var.red.offset) |
580 (green << fb_info->var.green.offset) | 507 (green << fb_info->var.green.offset) |
581 (blue << fb_info->var.blue.offset); 508 (blue << fb_info->var.blue.offset);
582 break; 509 break;
@@ -597,25 +524,24 @@ static struct fb_ops macfb_ops = {
597static void __init macfb_setup(char *options) 524static void __init macfb_setup(char *options)
598{ 525{
599 char *this_opt; 526 char *this_opt;
600 527
601 if (!options || !*options) 528 if (!options || !*options)
602 return; 529 return;
603 530
604 while ((this_opt = strsep(&options, ",")) != NULL) { 531 while ((this_opt = strsep(&options, ",")) != NULL) {
605 if (!*this_opt) continue; 532 if (!*this_opt)
606 533 continue;
607 if (! strcmp(this_opt, "inverse")) 534
608 inverse=1; 535 if (!strcmp(this_opt, "inverse"))
609 /* This means "turn on experimental CLUT code" */ 536 inverse = 1;
610 else if (!strcmp(this_opt, "vidtest")) 537 else
611 vidtest=1; 538 if (!strcmp(this_opt, "vidtest"))
539 vidtest = 1; /* enable experimental CLUT code */
612 } 540 }
613} 541}
614 542
615static void __init iounmap_macfb(void) 543static void __init iounmap_macfb(void)
616{ 544{
617 if (valkyrie_cmap_regs)
618 iounmap(valkyrie_cmap_regs);
619 if (dafb_cmap_regs) 545 if (dafb_cmap_regs)
620 iounmap(dafb_cmap_regs); 546 iounmap(dafb_cmap_regs);
621 if (v8_brazil_cmap_regs) 547 if (v8_brazil_cmap_regs)
@@ -642,48 +568,55 @@ static int __init macfb_init(void)
642 if (!MACH_IS_MAC) 568 if (!MACH_IS_MAC)
643 return -ENODEV; 569 return -ENODEV;
644 570
645 /* There can only be one internal video controller anyway so 571 if (mac_bi_data.id == MAC_MODEL_Q630 ||
646 we're not too worried about this */ 572 mac_bi_data.id == MAC_MODEL_P588)
573 return -ENODEV; /* See valkyriefb.c */
574
647 macfb_defined.xres = mac_bi_data.dimensions & 0xFFFF; 575 macfb_defined.xres = mac_bi_data.dimensions & 0xFFFF;
648 macfb_defined.yres = mac_bi_data.dimensions >> 16; 576 macfb_defined.yres = mac_bi_data.dimensions >> 16;
649 macfb_defined.bits_per_pixel = mac_bi_data.videodepth; 577 macfb_defined.bits_per_pixel = mac_bi_data.videodepth;
578
650 macfb_fix.line_length = mac_bi_data.videorow; 579 macfb_fix.line_length = mac_bi_data.videorow;
651 macfb_fix.smem_len = macfb_fix.line_length * macfb_defined.yres; 580 macfb_fix.smem_len = macfb_fix.line_length * macfb_defined.yres;
652 /* Note: physical address (since 2.1.127) */ 581 /* Note: physical address (since 2.1.127) */
653 macfb_fix.smem_start = mac_bi_data.videoaddr; 582 macfb_fix.smem_start = mac_bi_data.videoaddr;
654 /* This is actually redundant with the initial mappings. 583
655 However, there are some non-obvious aspects to the way
656 those mappings are set up, so this is in fact the safest
657 way to ensure that this driver will work on every possible
658 Mac */
659 fb_info.screen_base = ioremap(mac_bi_data.videoaddr, macfb_fix.smem_len);
660
661 printk("macfb: framebuffer at 0x%08lx, mapped to 0x%p, size %dk\n",
662 macfb_fix.smem_start, fb_info.screen_base, macfb_fix.smem_len/1024);
663 printk("macfb: mode is %dx%dx%d, linelength=%d\n",
664 macfb_defined.xres, macfb_defined.yres, macfb_defined.bits_per_pixel, macfb_fix.line_length);
665
666 /* 584 /*
667 * Fill in the available video resolution 585 * This is actually redundant with the initial mappings.
586 * However, there are some non-obvious aspects to the way
587 * those mappings are set up, so this is in fact the safest
588 * way to ensure that this driver will work on every possible Mac
668 */ 589 */
669 590 fb_info.screen_base = ioremap(mac_bi_data.videoaddr,
670 macfb_defined.xres_virtual = macfb_defined.xres; 591 macfb_fix.smem_len);
671 macfb_defined.yres_virtual = macfb_defined.yres; 592 if (!fb_info.screen_base)
672 macfb_defined.height = PIXEL_TO_MM(macfb_defined.yres); 593 return -ENODEV;
673 macfb_defined.width = PIXEL_TO_MM(macfb_defined.xres);
674 594
675 printk("macfb: scrolling: redraw\n"); 595 printk("macfb: framebuffer at 0x%08lx, mapped to 0x%p, size %dk\n",
596 macfb_fix.smem_start, fb_info.screen_base,
597 macfb_fix.smem_len / 1024);
598 printk("macfb: mode is %dx%dx%d, linelength=%d\n",
599 macfb_defined.xres, macfb_defined.yres,
600 macfb_defined.bits_per_pixel, macfb_fix.line_length);
601
602 /* Fill in the available video resolution */
603 macfb_defined.xres_virtual = macfb_defined.xres;
676 macfb_defined.yres_virtual = macfb_defined.yres; 604 macfb_defined.yres_virtual = macfb_defined.yres;
605 macfb_defined.height = PIXEL_TO_MM(macfb_defined.yres);
606 macfb_defined.width = PIXEL_TO_MM(macfb_defined.xres);
677 607
678 /* some dummy values for timing to make fbset happy */ 608 /* Some dummy values for timing to make fbset happy */
679 macfb_defined.pixclock = 10000000 / macfb_defined.xres * 1000 / macfb_defined.yres; 609 macfb_defined.pixclock = 10000000 / macfb_defined.xres *
610 1000 / macfb_defined.yres;
680 macfb_defined.left_margin = (macfb_defined.xres / 8) & 0xf8; 611 macfb_defined.left_margin = (macfb_defined.xres / 8) & 0xf8;
681 macfb_defined.hsync_len = (macfb_defined.xres / 8) & 0xf8; 612 macfb_defined.hsync_len = (macfb_defined.xres / 8) & 0xf8;
682 613
683 switch (macfb_defined.bits_per_pixel) { 614 switch (macfb_defined.bits_per_pixel) {
684 case 1: 615 case 1:
685 /* XXX: I think this will catch any program that tries 616 /*
686 to do FBIO_PUTCMAP when the visual is monochrome */ 617 * XXX: I think this will catch any program that tries
618 * to do FBIO_PUTCMAP when the visual is monochrome.
619 */
687 macfb_defined.red.length = macfb_defined.bits_per_pixel; 620 macfb_defined.red.length = macfb_defined.bits_per_pixel;
688 macfb_defined.green.length = macfb_defined.bits_per_pixel; 621 macfb_defined.green.length = macfb_defined.bits_per_pixel;
689 macfb_defined.blue.length = macfb_defined.bits_per_pixel; 622 macfb_defined.blue.length = macfb_defined.bits_per_pixel;
@@ -708,53 +641,52 @@ static int __init macfb_init(void)
708 macfb_defined.green.length = 5; 641 macfb_defined.green.length = 5;
709 macfb_defined.blue.offset = 0; 642 macfb_defined.blue.offset = 0;
710 macfb_defined.blue.length = 5; 643 macfb_defined.blue.length = 5;
711 printk("macfb: directcolor: "
712 "size=1:5:5:5, shift=15:10:5:0\n");
713 video_cmap_len = 16; 644 video_cmap_len = 16;
714 /* Should actually be FB_VISUAL_DIRECTCOLOR, but this 645 /*
715 works too */ 646 * Should actually be FB_VISUAL_DIRECTCOLOR, but this
647 * works too
648 */
716 macfb_fix.visual = FB_VISUAL_TRUECOLOR; 649 macfb_fix.visual = FB_VISUAL_TRUECOLOR;
717 break; 650 break;
718 case 24: 651 case 24:
719 case 32: 652 case 32:
720 /* XXX: have to test these... can any 68k Macs
721 actually do this on internal video? */
722 macfb_defined.red.offset = 16; 653 macfb_defined.red.offset = 16;
723 macfb_defined.red.length = 8; 654 macfb_defined.red.length = 8;
724 macfb_defined.green.offset = 8; 655 macfb_defined.green.offset = 8;
725 macfb_defined.green.length = 8; 656 macfb_defined.green.length = 8;
726 macfb_defined.blue.offset = 0; 657 macfb_defined.blue.offset = 0;
727 macfb_defined.blue.length = 8; 658 macfb_defined.blue.length = 8;
728 printk("macfb: truecolor: "
729 "size=0:8:8:8, shift=0:16:8:0\n");
730 video_cmap_len = 16; 659 video_cmap_len = 16;
731 macfb_fix.visual = FB_VISUAL_TRUECOLOR; 660 macfb_fix.visual = FB_VISUAL_TRUECOLOR;
661 break;
732 default: 662 default:
733 video_cmap_len = 0; 663 video_cmap_len = 0;
734 macfb_fix.visual = FB_VISUAL_MONO01; 664 macfb_fix.visual = FB_VISUAL_MONO01;
735 printk("macfb: unknown or unsupported bit depth: %d\n", macfb_defined.bits_per_pixel); 665 printk("macfb: unknown or unsupported bit depth: %d\n",
666 macfb_defined.bits_per_pixel);
736 break; 667 break;
737 } 668 }
738 669
739 /* Hardware dependent stuff */ 670 /*
740 /* We take a wild guess that if the video physical address is 671 * We take a wild guess that if the video physical address is
741 * in nubus slot space, that the nubus card is driving video. 672 * in nubus slot space, that the nubus card is driving video.
742 * Penguin really ought to tell us whether we are using internal 673 * Penguin really ought to tell us whether we are using internal
743 * video or not. 674 * video or not.
675 * Hopefully we only find one of them. Otherwise our NuBus
676 * code is really broken :-)
744 */ 677 */
745 /* Hopefully we only find one of them. Otherwise our NuBus
746 code is really broken :-) */
747 678
748 while ((ndev = nubus_find_type(NUBUS_CAT_DISPLAY, NUBUS_TYPE_VIDEO, ndev)) 679 while ((ndev = nubus_find_type(NUBUS_CAT_DISPLAY,
749 != NULL) 680 NUBUS_TYPE_VIDEO, ndev)))
750 { 681 {
751 if (!(mac_bi_data.videoaddr >= ndev->board->slot_addr 682 unsigned long base = ndev->board->slot_addr;
752 && (mac_bi_data.videoaddr < 683
753 (unsigned long)nubus_slot_addr(ndev->board->slot+1)))) 684 if (mac_bi_data.videoaddr < base ||
685 mac_bi_data.videoaddr - base > 0xFFFFFF)
754 continue; 686 continue;
687
755 video_is_nubus = 1; 688 video_is_nubus = 1;
756 /* We should probably just use the slot address... */ 689 slot_addr = (unsigned char *)base;
757 video_slot = ndev->board->slot;
758 690
759 switch(ndev->dr_hw) { 691 switch(ndev->dr_hw) {
760 case NUBUS_DRHW_APPLE_MDC: 692 case NUBUS_DRHW_APPLE_MDC:
@@ -771,7 +703,7 @@ static int __init macfb_init(void)
771 strcpy(macfb_fix.id, "Jet"); 703 strcpy(macfb_fix.id, "Jet");
772 macfb_setpalette = jet_setpalette; 704 macfb_setpalette = jet_setpalette;
773 macfb_defined.activate = FB_ACTIVATE_NOW; 705 macfb_defined.activate = FB_ACTIVATE_NOW;
774 break; 706 break;
775 default: 707 default:
776 strcpy(macfb_fix.id, "Generic NuBus"); 708 strcpy(macfb_fix.id, "Generic NuBus");
777 break; 709 break;
@@ -779,30 +711,19 @@ static int __init macfb_init(void)
779 } 711 }
780 712
781 /* If it's not a NuBus card, it must be internal video */ 713 /* If it's not a NuBus card, it must be internal video */
782 /* FIXME: this function is getting way too big. (this driver
783 is too...) */
784 if (!video_is_nubus) 714 if (!video_is_nubus)
785 switch( mac_bi_data.id ) 715 switch (mac_bi_data.id) {
786 { 716 /*
787 /* Valkyrie Quadras */ 717 * DAFB Quadras
788 case MAC_MODEL_Q630: 718 * Note: these first four have the v7 DAFB, which is
789 /* I'm not sure about this one */ 719 * known to be rather unlike the ones used in the
790 case MAC_MODEL_P588: 720 * other models
791 strcpy(macfb_fix.id, "Valkyrie"); 721 */
792 macfb_setpalette = valkyrie_setpalette;
793 macfb_defined.activate = FB_ACTIVATE_NOW;
794 valkyrie_cmap_regs = ioremap(DAC_BASE, 0x1000);
795 break;
796
797 /* DAFB Quadras */
798 /* Note: these first four have the v7 DAFB, which is
799 known to be rather unlike the ones used in the
800 other models */
801 case MAC_MODEL_P475: 722 case MAC_MODEL_P475:
802 case MAC_MODEL_P475F: 723 case MAC_MODEL_P475F:
803 case MAC_MODEL_P575: 724 case MAC_MODEL_P575:
804 case MAC_MODEL_Q605: 725 case MAC_MODEL_Q605:
805 726
806 case MAC_MODEL_Q800: 727 case MAC_MODEL_Q800:
807 case MAC_MODEL_Q650: 728 case MAC_MODEL_Q650:
808 case MAC_MODEL_Q610: 729 case MAC_MODEL_Q610:
@@ -817,17 +738,21 @@ static int __init macfb_init(void)
817 dafb_cmap_regs = ioremap(DAFB_BASE, 0x1000); 738 dafb_cmap_regs = ioremap(DAFB_BASE, 0x1000);
818 break; 739 break;
819 740
820 /* LC II uses the V8 framebuffer */ 741 /*
742 * LC II uses the V8 framebuffer
743 */
821 case MAC_MODEL_LCII: 744 case MAC_MODEL_LCII:
822 strcpy(macfb_fix.id, "V8"); 745 strcpy(macfb_fix.id, "V8");
823 macfb_setpalette = v8_brazil_setpalette; 746 macfb_setpalette = v8_brazil_setpalette;
824 macfb_defined.activate = FB_ACTIVATE_NOW; 747 macfb_defined.activate = FB_ACTIVATE_NOW;
825 v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000); 748 v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000);
826 break; 749 break;
827 750
828 /* IIvi, IIvx use the "Brazil" framebuffer (which is 751 /*
829 very much like the V8, it seems, and probably uses 752 * IIvi, IIvx use the "Brazil" framebuffer (which is
830 the same DAC) */ 753 * very much like the V8, it seems, and probably uses
754 * the same DAC)
755 */
831 case MAC_MODEL_IIVI: 756 case MAC_MODEL_IIVI:
832 case MAC_MODEL_IIVX: 757 case MAC_MODEL_IIVX:
833 case MAC_MODEL_P600: 758 case MAC_MODEL_P600:
@@ -836,12 +761,14 @@ static int __init macfb_init(void)
836 macfb_defined.activate = FB_ACTIVATE_NOW; 761 macfb_defined.activate = FB_ACTIVATE_NOW;
837 v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000); 762 v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000);
838 break; 763 break;
839 764
840 /* LC III (and friends) use the Sonora framebuffer */ 765 /*
841 /* Incidentally this is also used in the non-AV models 766 * LC III (and friends) use the Sonora framebuffer
842 of the x100 PowerMacs */ 767 * Incidentally this is also used in the non-AV models
843 /* These do in fact seem to use the same DAC interface 768 * of the x100 PowerMacs
844 as the LC II. */ 769 * These do in fact seem to use the same DAC interface
770 * as the LC II.
771 */
845 case MAC_MODEL_LCIII: 772 case MAC_MODEL_LCIII:
846 case MAC_MODEL_P520: 773 case MAC_MODEL_P520:
847 case MAC_MODEL_P550: 774 case MAC_MODEL_P550:
@@ -852,9 +779,11 @@ static int __init macfb_init(void)
852 v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000); 779 v8_brazil_cmap_regs = ioremap(DAC_BASE, 0x1000);
853 break; 780 break;
854 781
855 /* IIci and IIsi use the infamous RBV chip 782 /*
856 (the IIsi is just a rebadged and crippled 783 * IIci and IIsi use the infamous RBV chip
857 IIci in a different case, BTW) */ 784 * (the IIsi is just a rebadged and crippled
785 * IIci in a different case, BTW)
786 */
858 case MAC_MODEL_IICI: 787 case MAC_MODEL_IICI:
859 case MAC_MODEL_IISI: 788 case MAC_MODEL_IISI:
860 macfb_setpalette = rbv_setpalette; 789 macfb_setpalette = rbv_setpalette;
@@ -863,7 +792,9 @@ static int __init macfb_init(void)
863 rbv_cmap_regs = ioremap(DAC_BASE, 0x1000); 792 rbv_cmap_regs = ioremap(DAC_BASE, 0x1000);
864 break; 793 break;
865 794
866 /* AVs use the Civic framebuffer */ 795 /*
796 * AVs use the Civic framebuffer
797 */
867 case MAC_MODEL_Q840: 798 case MAC_MODEL_Q840:
868 case MAC_MODEL_C660: 799 case MAC_MODEL_C660:
869 macfb_setpalette = civic_setpalette; 800 macfb_setpalette = civic_setpalette;
@@ -873,15 +804,10 @@ static int __init macfb_init(void)
873 break; 804 break;
874 805
875 806
876 /* Write a setpalette function for your machine, then 807 /*
877 you can add something similar here. These are 808 * Assorted weirdos
878 grouped by classes of video chipsets. Some of this 809 * We think this may be like the LC II
879 information is from the VideoToolbox "Bugs" web 810 */
880 page at
881 http://rajsky.psych.nyu.edu/Tips/VideoBugs.html */
882
883 /* Assorted weirdos */
884 /* We think this may be like the LC II */
885 case MAC_MODEL_LC: 811 case MAC_MODEL_LC:
886 if (vidtest) { 812 if (vidtest) {
887 macfb_setpalette = v8_brazil_setpalette; 813 macfb_setpalette = v8_brazil_setpalette;
@@ -891,7 +817,10 @@ static int __init macfb_init(void)
891 } 817 }
892 strcpy(macfb_fix.id, "LC"); 818 strcpy(macfb_fix.id, "LC");
893 break; 819 break;
894 /* We think this may be like the LC II */ 820
821 /*
822 * We think this may be like the LC II
823 */
895 case MAC_MODEL_CCL: 824 case MAC_MODEL_CCL:
896 if (vidtest) { 825 if (vidtest) {
897 macfb_setpalette = v8_brazil_setpalette; 826 macfb_setpalette = v8_brazil_setpalette;
@@ -902,31 +831,42 @@ static int __init macfb_init(void)
902 strcpy(macfb_fix.id, "Color Classic"); 831 strcpy(macfb_fix.id, "Color Classic");
903 break; 832 break;
904 833
905 /* And we *do* mean "weirdos" */ 834 /*
835 * And we *do* mean "weirdos"
836 */
906 case MAC_MODEL_TV: 837 case MAC_MODEL_TV:
907 strcpy(macfb_fix.id, "Mac TV"); 838 strcpy(macfb_fix.id, "Mac TV");
908 break; 839 break;
909 840
910 /* These don't have colour, so no need to worry */ 841 /*
842 * These don't have colour, so no need to worry
843 */
911 case MAC_MODEL_SE30: 844 case MAC_MODEL_SE30:
912 case MAC_MODEL_CLII: 845 case MAC_MODEL_CLII:
913 strcpy(macfb_fix.id, "Monochrome"); 846 strcpy(macfb_fix.id, "Monochrome");
914 break; 847 break;
915 848
916 /* Powerbooks are particularly difficult. Many of 849 /*
917 them have separate framebuffers for external and 850 * Powerbooks are particularly difficult. Many of
918 internal video, which is admittedly pretty cool, 851 * them have separate framebuffers for external and
919 but will be a bit of a headache to support here. 852 * internal video, which is admittedly pretty cool,
920 Also, many of them are grayscale, and we don't 853 * but will be a bit of a headache to support here.
921 really support that. */ 854 * Also, many of them are grayscale, and we don't
922 855 * really support that.
856 */
857
858 /*
859 * Slot 0 ROM says TIM. No external video. B&W.
860 */
923 case MAC_MODEL_PB140: 861 case MAC_MODEL_PB140:
924 case MAC_MODEL_PB145: 862 case MAC_MODEL_PB145:
925 case MAC_MODEL_PB170: 863 case MAC_MODEL_PB170:
926 strcpy(macfb_fix.id, "DDC"); 864 strcpy(macfb_fix.id, "DDC");
927 break; 865 break;
928 866
929 /* Internal is GSC, External (if present) is ViSC */ 867 /*
868 * Internal is GSC, External (if present) is ViSC
869 */
930 case MAC_MODEL_PB150: /* no external video */ 870 case MAC_MODEL_PB150: /* no external video */
931 case MAC_MODEL_PB160: 871 case MAC_MODEL_PB160:
932 case MAC_MODEL_PB165: 872 case MAC_MODEL_PB165:
@@ -936,13 +876,17 @@ static int __init macfb_init(void)
936 strcpy(macfb_fix.id, "GSC"); 876 strcpy(macfb_fix.id, "GSC");
937 break; 877 break;
938 878
939 /* Internal is TIM, External is ViSC */ 879 /*
880 * Internal is TIM, External is ViSC
881 */
940 case MAC_MODEL_PB165C: 882 case MAC_MODEL_PB165C:
941 case MAC_MODEL_PB180C: 883 case MAC_MODEL_PB180C:
942 strcpy(macfb_fix.id, "TIM"); 884 strcpy(macfb_fix.id, "TIM");
943 break; 885 break;
944 886
945 /* Internal is CSC, External is Keystone+Ariel. */ 887 /*
888 * Internal is CSC, External is Keystone+Ariel.
889 */
946 case MAC_MODEL_PB190: /* external video is optional */ 890 case MAC_MODEL_PB190: /* external video is optional */
947 case MAC_MODEL_PB520: 891 case MAC_MODEL_PB520:
948 case MAC_MODEL_PB250: 892 case MAC_MODEL_PB250:
@@ -954,7 +898,7 @@ static int __init macfb_init(void)
954 strcpy(macfb_fix.id, "CSC"); 898 strcpy(macfb_fix.id, "CSC");
955 csc_cmap_regs = ioremap(CSC_BASE, 0x1000); 899 csc_cmap_regs = ioremap(CSC_BASE, 0x1000);
956 break; 900 break;
957 901
958 default: 902 default:
959 strcpy(macfb_fix.id, "Unknown"); 903 strcpy(macfb_fix.id, "Unknown");
960 break; 904 break;
@@ -969,7 +913,7 @@ static int __init macfb_init(void)
969 err = fb_alloc_cmap(&fb_info.cmap, video_cmap_len, 0); 913 err = fb_alloc_cmap(&fb_info.cmap, video_cmap_len, 0);
970 if (err) 914 if (err)
971 goto fail_unmap; 915 goto fail_unmap;
972 916
973 err = register_framebuffer(&fb_info); 917 err = register_framebuffer(&fb_info);
974 if (err) 918 if (err)
975 goto fail_dealloc; 919 goto fail_dealloc;
diff --git a/drivers/video/macmodes.c b/drivers/video/macmodes.c
index 083f60321ed8..af86c081d2be 100644
--- a/drivers/video/macmodes.c
+++ b/drivers/video/macmodes.c
@@ -33,6 +33,10 @@
33 33
34static const struct fb_videomode mac_modedb[] = { 34static const struct fb_videomode mac_modedb[] = {
35 { 35 {
36 /* 512x384, 60Hz, Non-Interlaced (15.67 MHz dot clock) */
37 "mac2", 60, 512, 384, 63828, 80, 16, 19, 1, 32, 3,
38 0, FB_VMODE_NONINTERLACED
39 }, {
36 /* 640x480, 60 Hz, Non-Interlaced (25.175 MHz dotclock) */ 40 /* 640x480, 60 Hz, Non-Interlaced (25.175 MHz dotclock) */
37 "mac5", 60, 640, 480, 39722, 32, 32, 33, 10, 96, 2, 41 "mac5", 60, 640, 480, 39722, 32, 32, 33, 10, 96, 2,
38 0, FB_VMODE_NONINTERLACED 42 0, FB_VMODE_NONINTERLACED
@@ -41,6 +45,10 @@ static const struct fb_videomode mac_modedb[] = {
41 "mac6", 67, 640, 480, 33334, 80, 80, 39, 3, 64, 3, 45 "mac6", 67, 640, 480, 33334, 80, 80, 39, 3, 64, 3,
42 0, FB_VMODE_NONINTERLACED 46 0, FB_VMODE_NONINTERLACED
43 }, { 47 }, {
48 /* 640x870, 75Hz (portrait), Non-Interlaced (57.28 MHz dot clock) */
49 "mac7", 75, 640, 870, 17457, 80, 32, 42, 3, 80, 3,
50 0, FB_VMODE_NONINTERLACED
51 }, {
44 /* 800x600, 56 Hz, Non-Interlaced (36.00 MHz dotclock) */ 52 /* 800x600, 56 Hz, Non-Interlaced (36.00 MHz dotclock) */
45 "mac9", 56, 800, 600, 27778, 112, 40, 22, 1, 72, 2, 53 "mac9", 56, 800, 600, 27778, 112, 40, 22, 1, 72, 2,
46 FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED 54 FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
@@ -105,10 +113,6 @@ static const struct fb_videomode mac_modedb[] = {
105 "mac1", 60, 512, 384, pixclock, left, right, upper, lower, hslen, vslen, 113 "mac1", 60, 512, 384, pixclock, left, right, upper, lower, hslen, vslen,
106 sync, FB_VMODE_INTERLACED 114 sync, FB_VMODE_INTERLACED
107 }, { 115 }, {
108 /* VMODE_512_384_60: 512x384, 60Hz, Non-Interlaced */
109 "mac2", 60, 512, 384, pixclock, left, right, upper, lower, hslen, vslen,
110 sync, FB_VMODE_NONINTERLACED
111 }, {
112 /* VMODE_640_480_50I: 640x480, 50Hz, Interlaced (PAL) */ 116 /* VMODE_640_480_50I: 640x480, 50Hz, Interlaced (PAL) */
113 "mac3", 50, 640, 480, pixclock, left, right, upper, lower, hslen, vslen, 117 "mac3", 50, 640, 480, pixclock, left, right, upper, lower, hslen, vslen,
114 sync, FB_VMODE_INTERLACED 118 sync, FB_VMODE_INTERLACED
@@ -117,10 +121,6 @@ static const struct fb_videomode mac_modedb[] = {
117 "mac4", 60, 640, 480, pixclock, left, right, upper, lower, hslen, vslen, 121 "mac4", 60, 640, 480, pixclock, left, right, upper, lower, hslen, vslen,
118 sync, FB_VMODE_INTERLACED 122 sync, FB_VMODE_INTERLACED
119 }, { 123 }, {
120 /* VMODE_640_870_75P: 640x870, 75Hz (portrait), Non-Interlaced */
121 "mac7", 75, 640, 870, pixclock, left, right, upper, lower, hslen, vslen,
122 sync, FB_VMODE_NONINTERLACED
123 }, {
124 /* VMODE_768_576_50I: 768x576, 50Hz (PAL full frame), Interlaced */ 124 /* VMODE_768_576_50I: 768x576, 50Hz (PAL full frame), Interlaced */
125 "mac8", 50, 768, 576, pixclock, left, right, upper, lower, hslen, vslen, 125 "mac8", 50, 768, 576, pixclock, left, right, upper, lower, hslen, vslen,
126 sync, FB_VMODE_INTERLACED 126 sync, FB_VMODE_INTERLACED
@@ -134,38 +134,42 @@ static const struct fb_videomode mac_modedb[] = {
134 * 134 *
135 * These MUST be ordered in 135 * These MUST be ordered in
136 * - increasing resolution 136 * - increasing resolution
137 * - decreasing refresh rate 137 * - decreasing pixel clock period
138 */ 138 */
139 139
140static const struct mode_map { 140static const struct mode_map {
141 int vmode; 141 int vmode;
142 const struct fb_videomode *mode; 142 const struct fb_videomode *mode;
143} mac_modes[] = { 143} mac_modes[] = {
144 /* 512x384 */
145 { VMODE_512_384_60, &mac_modedb[0] },
144 /* 640x480 */ 146 /* 640x480 */
145 { VMODE_640_480_67, &mac_modedb[1] }, 147 { VMODE_640_480_60, &mac_modedb[1] },
146 { VMODE_640_480_60, &mac_modedb[0] }, 148 { VMODE_640_480_67, &mac_modedb[2] },
149 /* 640x870 */
150 { VMODE_640_870_75P, &mac_modedb[3] },
147 /* 800x600 */ 151 /* 800x600 */
148 { VMODE_800_600_75, &mac_modedb[5] }, 152 { VMODE_800_600_56, &mac_modedb[4] },
149 { VMODE_800_600_72, &mac_modedb[4] }, 153 { VMODE_800_600_60, &mac_modedb[5] },
150 { VMODE_800_600_60, &mac_modedb[3] }, 154 { VMODE_800_600_75, &mac_modedb[7] },
151 { VMODE_800_600_56, &mac_modedb[2] }, 155 { VMODE_800_600_72, &mac_modedb[6] },
152 /* 832x624 */ 156 /* 832x624 */
153 { VMODE_832_624_75, &mac_modedb[6] }, 157 { VMODE_832_624_75, &mac_modedb[8] },
154 /* 1024x768 */ 158 /* 1024x768 */
155 { VMODE_1024_768_75, &mac_modedb[10] }, 159 { VMODE_1024_768_60, &mac_modedb[9] },
156 { VMODE_1024_768_75V, &mac_modedb[9] }, 160 { VMODE_1024_768_70, &mac_modedb[10] },
157 { VMODE_1024_768_70, &mac_modedb[8] }, 161 { VMODE_1024_768_75V, &mac_modedb[11] },
158 { VMODE_1024_768_60, &mac_modedb[7] }, 162 { VMODE_1024_768_75, &mac_modedb[12] },
159 /* 1152x768 */ 163 /* 1152x768 */
160 { VMODE_1152_768_60, &mac_modedb[14] }, 164 { VMODE_1152_768_60, &mac_modedb[16] },
161 /* 1152x870 */ 165 /* 1152x870 */
162 { VMODE_1152_870_75, &mac_modedb[11] }, 166 { VMODE_1152_870_75, &mac_modedb[13] },
163 /* 1280x960 */ 167 /* 1280x960 */
164 { VMODE_1280_960_75, &mac_modedb[12] }, 168 { VMODE_1280_960_75, &mac_modedb[14] },
165 /* 1280x1024 */ 169 /* 1280x1024 */
166 { VMODE_1280_1024_75, &mac_modedb[13] }, 170 { VMODE_1280_1024_75, &mac_modedb[15] },
167 /* 1600x1024 */ 171 /* 1600x1024 */
168 { VMODE_1600_1024_60, &mac_modedb[15] }, 172 { VMODE_1600_1024_60, &mac_modedb[17] },
169 { -1, NULL } 173 { -1, NULL }
170}; 174};
171 175
@@ -299,7 +303,6 @@ EXPORT_SYMBOL(mac_vmode_to_var);
299int mac_var_to_vmode(const struct fb_var_screeninfo *var, int *vmode, 303int mac_var_to_vmode(const struct fb_var_screeninfo *var, int *vmode,
300 int *cmode) 304 int *cmode)
301{ 305{
302 const struct fb_videomode *mode = NULL;
303 const struct mode_map *map; 306 const struct mode_map *map;
304 307
305 if (var->bits_per_pixel <= 8) 308 if (var->bits_per_pixel <= 8)
@@ -311,8 +314,13 @@ int mac_var_to_vmode(const struct fb_var_screeninfo *var, int *vmode,
311 else 314 else
312 return -EINVAL; 315 return -EINVAL;
313 316
317 /*
318 * Find the mac_mode with a matching resolution or failing that, the
319 * closest larger resolution. Skip modes with a shorter pixel clock period.
320 */
314 for (map = mac_modes; map->vmode != -1; map++) { 321 for (map = mac_modes; map->vmode != -1; map++) {
315 mode = map->mode; 322 const struct fb_videomode *mode = map->mode;
323
316 if (var->xres > mode->xres || var->yres > mode->yres) 324 if (var->xres > mode->xres || var->yres > mode->yres)
317 continue; 325 continue;
318 if (var->xres_virtual > mode->xres || var->yres_virtual > mode->yres) 326 if (var->xres_virtual > mode->xres || var->yres_virtual > mode->yres)
@@ -322,6 +330,24 @@ int mac_var_to_vmode(const struct fb_var_screeninfo *var, int *vmode,
322 if ((var->vmode & FB_VMODE_MASK) != mode->vmode) 330 if ((var->vmode & FB_VMODE_MASK) != mode->vmode)
323 continue; 331 continue;
324 *vmode = map->vmode; 332 *vmode = map->vmode;
333
334 /*
335 * Having found a good resolution, find the matching pixel clock
336 * or failing that, the closest longer pixel clock period.
337 */
338 map++;
339 while (map->vmode != -1) {
340 const struct fb_videomode *clk_mode = map->mode;
341
342 if (mode->xres != clk_mode->xres || mode->yres != clk_mode->yres)
343 break;
344 if (var->pixclock > mode->pixclock)
345 break;
346 if (mode->vmode != clk_mode->vmode)
347 continue;
348 *vmode = map->vmode;
349 map++;
350 }
325 return 0; 351 return 0;
326 } 352 }
327 return -EINVAL; 353 return -EINVAL;
diff --git a/drivers/video/valkyriefb.c b/drivers/video/valkyriefb.c
index 4bb9a0b18950..6b52bf65f0b5 100644
--- a/drivers/video/valkyriefb.c
+++ b/drivers/video/valkyriefb.c
@@ -69,7 +69,7 @@
69#ifdef CONFIG_MAC 69#ifdef CONFIG_MAC
70/* We don't yet have functions to read the PRAM... perhaps we can 70/* We don't yet have functions to read the PRAM... perhaps we can
71 adapt them from the PPC code? */ 71 adapt them from the PPC code? */
72static int default_vmode = VMODE_640_480_67; 72static int default_vmode = VMODE_CHOOSE;
73static int default_cmode = CMODE_8; 73static int default_cmode = CMODE_8;
74#else 74#else
75static int default_vmode = VMODE_NVRAM; 75static int default_vmode = VMODE_NVRAM;
@@ -326,11 +326,11 @@ int __init valkyriefb_init(void)
326 326
327#ifdef CONFIG_MAC 327#ifdef CONFIG_MAC
328 if (!MACH_IS_MAC) 328 if (!MACH_IS_MAC)
329 return 0; 329 return -ENODEV;
330 if (!(mac_bi_data.id == MAC_MODEL_Q630 330 if (!(mac_bi_data.id == MAC_MODEL_Q630
331 /* I'm not sure about this one */ 331 /* I'm not sure about this one */
332 || mac_bi_data.id == MAC_MODEL_P588)) 332 || mac_bi_data.id == MAC_MODEL_P588))
333 return 0; 333 return -ENODEV;
334 334
335 /* Hardcoded addresses... welcome to 68k Macintosh country :-) */ 335 /* Hardcoded addresses... welcome to 68k Macintosh country :-) */
336 frame_buffer_phys = 0xf9000000; 336 frame_buffer_phys = 0xf9000000;
diff --git a/drivers/video/valkyriefb.h b/drivers/video/valkyriefb.h
index 97aaf7bb6417..d787441e5a42 100644
--- a/drivers/video/valkyriefb.h
+++ b/drivers/video/valkyriefb.h
@@ -134,15 +134,7 @@ static struct valkyrie_regvals valkyrie_reg_init_14 = {
134 { 1024, 0 }, 134 { 1024, 0 },
135 1024, 768 135 1024, 768
136}; 136};
137 137#endif /* !defined CONFIG_MAC */
138/* Register values for 800x600, 72Hz mode (11) */
139static struct valkyrie_regvals valkyrie_reg_init_11 = {
140 13,
141 { 17, 27, 3 }, /* pixel clock = 49.63MHz for V=71.66Hz */
142 { 800, 0 },
143 800, 600
144};
145#endif /* CONFIG_MAC */
146 138
147/* Register values for 832x624, 75Hz mode (13) */ 139/* Register values for 832x624, 75Hz mode (13) */
148static struct valkyrie_regvals valkyrie_reg_init_13 = { 140static struct valkyrie_regvals valkyrie_reg_init_13 = {
@@ -152,6 +144,14 @@ static struct valkyrie_regvals valkyrie_reg_init_13 = {
152 832, 624 144 832, 624
153}; 145};
154 146
147/* Register values for 800x600, 72Hz mode (11) */
148static struct valkyrie_regvals valkyrie_reg_init_11 = {
149 13,
150 { 17, 27, 3 }, /* pixel clock = 49.63MHz for V=71.66Hz */
151 { 800, 0 },
152 800, 600
153};
154
155/* Register values for 800x600, 60Hz mode (10) */ 155/* Register values for 800x600, 60Hz mode (10) */
156static struct valkyrie_regvals valkyrie_reg_init_10 = { 156static struct valkyrie_regvals valkyrie_reg_init_10 = {
157 12, 157 12,
@@ -188,24 +188,13 @@ static struct valkyrie_regvals *valkyrie_reg_init[VMODE_MAX] = {
188 NULL, 188 NULL,
189 NULL, 189 NULL,
190 &valkyrie_reg_init_10, 190 &valkyrie_reg_init_10,
191#ifdef CONFIG_MAC
192 NULL,
193 NULL,
194 &valkyrie_reg_init_13,
195 NULL,
196 NULL,
197 NULL,
198 NULL,
199#else
200 &valkyrie_reg_init_11, 191 &valkyrie_reg_init_11,
201 NULL, 192 NULL,
202 &valkyrie_reg_init_13, 193 &valkyrie_reg_init_13,
194#ifndef CONFIG_MAC
203 &valkyrie_reg_init_14, 195 &valkyrie_reg_init_14,
204 &valkyrie_reg_init_15, 196 &valkyrie_reg_init_15,
205 NULL, 197 NULL,
206 &valkyrie_reg_init_17, 198 &valkyrie_reg_init_17,
207#endif 199#endif
208 NULL,
209 NULL,
210 NULL
211}; 200};