Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 35819 | Differences between
and this patch

Collapse All | Expand All

(-)linux-2.4.22/CHANGES (+11 lines)
Line 0 Link Here
1
2.4.22-ben2 : - Remove a hack on the MachineCheck exception handler that seemed
2
                to actually cause a problem on some machines
3
              - Turn legacy serial driver into a module (used by pcmcia modems)
4
	        instead of built-in in pmac defconfig
5
              - Export a couple of symbols needed by recent DRI
6
              - Hopefully close a few possible SMP races along with making the
7
	        IO ops more robust vs. store reordering.
8
              - Fix build without CONFIG_PMAC_PBOOK
9
10
2.4.22-ben1 : First release
11
(-)linux-2.4.22/Documentation/Configure.help (+23 lines)
Lines 27170-27175 Link Here
27170
27170
27171
  If unsure, say N.
27171
  If unsure, say N.
27172
27172
27173
CONFIG_CPU_FREQ
27174
  Clock scaling allows you to change the clock speed of CPUs on the
27175
  fly. This is a nice method to save battery power on notebooks,
27176
  because the lower the clock speed, the less power the CPU consumes.
27177
27178
  For more information, take a look at linux/Documentation/cpufreq or
27179
  at <http://www.brodo.de/cpufreq/>
27180
27181
  If in doubt, say N.
27182
27183
CONFIG_CPU_FREQ_24_API
27184
  This enables the /proc/sys/cpu/ sysctl interface for controlling
27185
  CPUFreq, as known from the 2.4.-kernel patches for CPUFreq. Note
27186
  that some drivers do not support this interface or offer less
27187
  functionality. 
27188
27189
  If you say N here, you'll be able to control CPUFreq using the
27190
  new /proc/cpufreq interface.
27191
27192
  For details, take a look at linux/Documentation/cpufreq. 
27193
27194
  If in doubt, say N.
27195
27173
NatSemi SCx200 support
27196
NatSemi SCx200 support
27174
CONFIG_SCx200
27197
CONFIG_SCx200
27175
  This provides basic support for the National Semiconductor SCx200
27198
  This provides basic support for the National Semiconductor SCx200
(-)linux-2.4.22/Documentation/cpufreq (+361 lines)
Line 0 Link Here
1
     CPU frequency and voltage scaling code in the Linux(TM) kernel
2
3
4
		         L i n u x    C P U F r e q
5
6
7
8
9
		    Dominik Brodowski  <linux@brodo.de>
10
		     David Kimdon <dwhedon@debian.org>
11
12
13
14
   Clock scaling allows you to change the clock speed of the CPUs on the
15
    fly. This is a nice method to save battery power, because the lower
16
            the clock speed, the less power the CPU consumes.
17
18
19
20
Contents:
21
---------
22
1.  Supported architectures
23
2.  User interface
24
2.1   /proc/cpufreq interface  [2.6]
25
2.2.  /proc/sys/cpu/ interface [2.4]
26
3.  CPUFreq core and interfaces
27
3.1   General information
28
3.2   CPUFreq notifiers
29
3.3   CPUFreq architecture drivers
30
4.  Mailing list and Links
31
32
33
34
1. Supported architectures
35
==========================
36
37
ARM:
38
    ARM Integrator, SA 1100, SA1110
39
--------------------------------
40
    This driver will be ported to new CPUFreq core soon, so
41
    far it will not work.
42
43
44
AMD Elan:
45
    SC400, SC410
46
--------------------------------
47
    You need to specify the highest allowed CPU frequency as 
48
    a module parameter ("max_freq") or as boot parameter 
49
    ("elanfreq="). Else the available speed range will be 
50
    limited to the speed at which the CPU runs while this
51
    module is loaded.
52
53
54
VIA Cyrix Longhaul:
55
    VIA Samuel/CyrixIII, VIA Cyrix Samuel/C3, 
56
    VIA Cyrix Ezra, VIA Cyrix Ezra-T
57
--------------------------------
58
    If you do not want to scale the Front Side Bus or voltage,
59
    pass the module parameter "dont_scale_fsb 1" or
60
    "dont_scale_voltage 1". Additionally, it is advised that
61
    you pass the current Front Side Bus speed (in MHz) to 
62
    this module as module parameter "current_fsb", e.g. 
63
    "current_fsb 133" for a Front Side Bus speed of 133 MHz.
64
65
66
Intel SpeedStep:
67
    certain mobile Intel Pentium III (Coppermine), and all mobile
68
    Intel Pentium III-M (Tualatin) and mobile Intel Pentium 4 P4-Ms.
69
--------------------------------
70
    Unfortunately only modern Intel ICH2-M and ICH3-M chipsets are 
71
    supported.
72
73
74
P4 CPU Clock Modulation:
75
    Intel Pentium 4 Xeon processors
76
---------------------------------
77
    Note that you can only switch the speed of two logical CPUs at
78
    once - but each phyiscal CPU may have different throttling levels.
79
80
81
PowerNow! K6:
82
    mobile AMD K6-2+ / mobile K6-3+:
83
--------------------------------
84
    No known issues.
85
86
87
Transmeta Crusoe Longrun:
88
    Transmeta Crusoe processors:
89
--------------------------------
90
    Does not work with the 2.4. /proc/sys/cpu/ interface.
91
92
93
94
2. User Interface
95
=================
96
97
2.1   /proc/cpufreq interface [2.6]
98
***********************************
99
100
Starting in the patches for kernel 2.5.33, CPUFreq uses a "policy"
101
interface /proc/cpufreq.
102
103
When you "cat" this file, you'll find something like:
104
105
--
106
          minimum CPU frequency  -  maximum CPU frequency  -  policy
107
CPU  0       1200000 ( 75%)      -     1600000 (100%)      -  performance
108
--
109
110
This means the current policy allows this CPU to be run anywhere
111
between 1.2 GHz (the value is in kHz) and 1.6 GHz with an eye towards
112
performance.
113
114
To change the policy, "echo" the desired new policy into
115
/proc/cpufreq. Use one of the following formats:
116
117
cpu_nr:min_freq:max_freq:policy
118
cpu_nr%min_freq%max_freq%policy
119
min_freq:max_freq:policy
120
min_freq%max_freq%policy
121
122
with cpu_nr being the CPU which shall be affected, min_freq and
123
max_freq the lower and upper limit of the CPU core frequency in kHz,
124
and policy either "performance" or "powersave".
125
A few examples:
126
127
root@notebook:#echo -n "0:0:0:powersave" > /proc/cpufreq
128
     sets the CPU #0 to the lowest supported frequency.
129
130
root@notebook:#echo -n "1%100%100%performance" > /proc/cpufreq
131
     sets the CPU #1 to the highest supported frequency.
132
133
root@notebook:#echo -n "1000000:2000000:performance" > /proc/cpufreq
134
     to set the frequency of all CPUs between 1 GHz and 2 GHz and to
135
     the policy "performance".
136
137
Please note that the values you "echo" into /proc/cpufreq are
138
validated first, and may be limited by hardware or thermal
139
considerations. Because of this, a read from /proc/cpufreq might 
140
differ from what was written into it.
141
142
143
When you read /proc/cpufreq for the first time after a CPUFreq driver
144
has been initialized, you'll see the "default policy" for this
145
driver. If this does not suit your needs, you can pass a boot
146
parameter to the cpufreq core. Use the following syntax for this:
147
   "cpufreq=min_freq:max_freq:policy", i.e. you may not chose a
148
specific CPU and you need to specify the limits in kHz and not in
149
per cent.
150
151
152
2.2   /proc/cpufreq interface [2.4]
153
***********************************
154
155
Previsiously (and still available as a config option), CPUFreq used 
156
a "sysctl" interface which is located in 
157
	/proc/sys/cpu/0/
158
	/proc/sys/cpu/1/ ...	(SMP only)
159
160
In these directories, you will find three files of importance for
161
CPUFreq: speed-max, speed-min and speed: 
162
163
speed		    shows the current CPU frequency in kHz, 
164
speed-min	    the minimum supported CPU frequency, and
165
speed-max	    the maximum supported CPU frequency.
166
167
168
To change the CPU frequency, "echo" the desired CPU frequency (in kHz)
169
to speed. For example, to set the CPU speed to the lowest/highest
170
allowed frequency do:
171
172
root@notebook:# cat /proc/sys/cpu/0/speed-min > /proc/sys/cpu/0/speed
173
root@notebook:# cat /proc/sys/cpu/0/speed-max > /proc/sys/cpu/0/speed
174
175
176
177
3.  CPUFreq core and interfaces
178
===============================
179
180
3.1   General information
181
*************************
182
183
The CPUFreq core code is located in linux/kernel/cpufreq.c. This
184
cpufreq code offers a standardized interface for the CPUFreq
185
architecture drivers (those pieces of code that do actual
186
frequency transitions), as well as to "notifiers". These are device
187
drivers or other part of the kernel that need to be informed of
188
policy changes (like thermal modules like ACPI) or of all
189
frequency changes (like timing code) or even need to force certain
190
speed limits (like LCD drivers on ARM architecture). Additionally, the
191
kernel "constant" loops_per_jiffy is updated on frequency changes
192
here.
193
194
195
3.2   CPUFreq notifiers
196
***********************
197
198
CPUFreq notifiers conform to the standard kernel notifier interface.
199
See linux/include/linux/notifier.h for details on notifiers.
200
201
There are two different CPUFreq notifiers - policy notifiers and
202
transition notifiers.
203
204
205
3.2.1 CPUFreq policy notifiers
206
******************************
207
208
These are notified when a new policy is intended to be set. Each
209
CPUFreq policy notifier is called three times for a policy transition:
210
211
1.) During CPUFREQ_ADJUST all CPUFreq notifiers may change the limit if
212
    they see a need for this - may it be thermal considerations or
213
    hardware limitations.
214
215
2.) During CPUFREQ_INCOMPATIBLE only changes may be done in order to avoid
216
    hardware failure.
217
218
3.) And during CPUFREQ_NOTIFY all notifiers are informed of the new policy
219
   - if two hardware drivers failed to agree on a new policy before this
220
   stage, the incompatible hardware shall be shut down, and the user
221
   informed of this.
222
223
The phase is specified in the second argument to the notifier.
224
225
The third argument, a void *pointer, points to a struct cpufreq_policy
226
consisting of five values: cpu, min, max, policy and max_cpu_freq. Min 
227
and max are the lower and upper frequencies (in kHz) of the new
228
policy, policy the new policy, cpu the number of the affected CPU or
229
CPUFREQ_ALL_CPUS for all CPUs; and max_cpu_freq the maximum supported
230
CPU frequency. This value is given for informational purposes only.
231
232
233
3.2.2 CPUFreq transition notifiers
234
**********************************
235
236
These are notified twice when the CPUfreq driver switches the CPU core
237
frequency and this change has any external implications.
238
239
The second argument specifies the phase - CPUFREQ_PRECHANGE or
240
CPUFREQ_POSTCHANGE.
241
242
The third argument is a struct cpufreq_freqs with the following
243
values:
244
cpu	- number of the affected CPU or CPUFREQ_ALL_CPUS
245
old	- old frequency
246
new	- new frequency
247
248
249
3.3   CPUFreq architecture drivers
250
**********************************
251
252
CPUFreq architecture drivers are the pieces of kernel code that
253
actually perform CPU frequency transitions. These need to be
254
initialized separately (separate initcalls), and may be
255
modularized. They interact with the CPUFreq core in the following way:
256
257
cpufreq_register()
258
------------------
259
cpufreq_register registers an arch driver to the CPUFreq core. Please
260
note that only one arch driver may be registered at any time. -EBUSY
261
is returned when an arch driver is already registered. The argument to
262
cpufreq_register, struct cpufreq_driver *driver, is described later.
263
264
cpufreq_unregister()
265
--------------------
266
cpufreq_unregister unregisters an arch driver, e.g. on module
267
unloading. Please note that there is no check done that this is called
268
from the driver which actually registered itself to the core, so
269
please only call this function when you are sure the arch driver got
270
registered correctly before.
271
272
cpufreq_notify_transition()
273
---------------------------
274
On "dumb" hardware where only fixed frequency can be set, the driver
275
must call cpufreq_notify_transition() once before, and once after the
276
actual transition.
277
278
struct cpufreq_driver
279
---------------------
280
On initialization, the arch driver is supposed to pass a pointer
281
to a struct cpufreq_driver *cpufreq_driver consisting of the following
282
entries:
283
284
cpufreq_verify_t verify: This is a pointer to a function with the
285
	following definition:
286
	void verify_function (struct cpufreq_policy *policy).
287
	This function must verify the new policy is within the limits
288
	supported by the CPU, and at least one supported CPU is within
289
	this range. It may be useful to use cpufreq.h /
290
	cpufreq_verify_within_limits for this.
291
292
cpufreq_setpolicy_t setpolicy: This is a pointer to a function with
293
	the following definition:
294
	void setpolicy_function (struct cpufreq_policy *policy).
295
	This function must set the CPU to the new policy. If it is a
296
	"dumb" CPU which only allows fixed frequencies to be set, it
297
	shall set it to the lowest within the limit for
298
	CPUFREQ_POLICY_POWERSAVE, and to the highest for
299
	CPUFREQ_POLICY_PERFORMANCE. Once CONFIG_CPU_FREQ_DYNAMIC is
300
	implemented, it can use a dynamic method to adjust the speed
301
	between the lower and upper limit.
302
303
struct cpufreq_policy   *policy: This is an array of NR_CPUS struct
304
	cpufreq_policies, containing the current policies set for these
305
	CPUs. Note that policy[0].max_cpu_freq must contain the
306
	absolute maximum CPU frequency supported by _all_ CPUs.
307
308
In case the driver is expected to run with the 2.4.-style API
309
(/proc/sys/cpu/.../), two more values must be passed
310
#ifdef CONFIG_CPU_FREQ_24_API
311
	unsigned int            cpu_min_freq;
312
	unsigned int            cpu_cur_freq[NR_CPUS];
313
#endif
314
	with cpu_min_freq being the minimum CPU frequency supported by
315
	the CPUs; and the entries in cpu_cur_freq reflecting the
316
	current speed of the appropriate CPU.
317
318
Some Requirements to CPUFreq architecture drivers
319
-------------------------------------------------
320
* Only call cpufreq_register() when the ability to switch CPU
321
  frequencies is _verified_ or can't be missing
322
* cpufreq_unregister() may only be called if cpufreq_register() has
323
  been successfully(!) called before.
324
* kfree() the struct cpufreq_driver only after the call to 
325
  cpufreq_unregister(), unless cpufreq_register() failed.
326
* Be aware that there is currently no error management in the
327
  setpolicy() code in the CPUFreq core. So only call yourself a
328
  cpufreq_driver if you are really a working cpufreq_driver!
329
330
331
332
4. Mailing list and Links
333
*************************
334
335
336
Mailing List
337
------------
338
There is a CPU frequency changing CVS commit and general list where
339
you can report bugs, problems or submit patches. To post a message,
340
send an email to cpufreq@www.linux.org.uk, to subscribe go to
341
http://www.linux.org.uk/mailman/listinfo/cpufreq. Previous post to the
342
mailing list are available to subscribers at
343
http://www.linux.org.uk/mailman/private/cpufreq/.
344
345
346
Links
347
-----
348
the FTP archives:
349
* ftp://ftp.linux.org.uk/pub/linux/cpufreq/
350
351
how to access the CVS repository:
352
* http://cvs.arm.linux.org.uk/
353
354
the CPUFreq Mailing list:
355
* http://www.linux.org.uk/mailman/listinfo/cpufreq
356
357
Clock and voltage scaling for the SA-1100:
358
* http://www.lart.tudelft.nl/projects/scaling
359
360
CPUFreq project homepage
361
* http://www.brodo.de/cpufreq/
(-)linux-2.4.22/Documentation/laptop-mode.sh (+42 lines)
Line 0 Link Here
1
#!/bin/sh
2
#
3
# start of stop laptop mode, best run by a power management daemon when
4
# ac gets connected/disconnected from a laptop
5
#
6
# FIXME: assumes HZ == 100
7
8
# age time, in seconds. should be put into a sysconfig file
9
MAX_AGE=600
10
11
# kernel default dirty buffer age
12
DEF_AGE=30
13
DEF_UPDATE=5
14
15
if [ ! -w /proc/sys/vm/laptop_mode ]; then
16
	echo "Kernel is not patched with laptop_mode patch"
17
	exit 1
18
fi
19
20
case "$1" in
21
	start)
22
		AGE=$((100*$MAX_AGE))
23
		echo -n "Starting laptop mode"
24
		echo "1" > /proc/sys/vm/laptop_mode
25
		echo "30 500 0 0 $AGE $AGE 60 20 0" > /proc/sys/vm/bdflush
26
		echo "."
27
		;;
28
	stop)
29
		U_AGE=$((100*$DEF_UPDATE))
30
		B_AGE=$((100*$DEF_AGE))
31
		echo -n "Stopping laptop mode"
32
		echo "0" > /proc/sys/vm/laptop_mode
33
		echo "30 500 0 0 $U_AGE $B_AGE 60 20 0" > /proc/sys/vm/bdflush
34
		echo "."
35
		;;
36
	*)
37
		echo "$0 {start|stop}"
38
		;;
39
40
esac
41
42
exit 0
(-)linux-2.4.22/Documentation/laptop-mode.txt (+72 lines)
Line 0 Link Here
1
Laptop mode
2
===========
3
4
This small doc describes the 2.4 laptop mode patch.
5
6
Last updated 2003-05-25, Jens Axboe <axboe@suse.de>
7
8
Introduction
9
------------
10
11
A few properties of the Linux vm makes it virtually impossible to attempt
12
to spin down the hard drive in a laptop for a longer period of time (more
13
than a handful of seconds). This means you are lucky if you can even reach
14
the break even point with regards to power consumption, let alone expect any
15
decrease.
16
17
One problem is the age time of dirty buffers. Linux uses 30 seconds per
18
default, so if you dirty any data then flusing of that data will commence
19
at most 30 seconds from then. Another is the journal commit interval of
20
journalled file systems such as ext3, which is 5 seconds on a stock kernel.
21
Both of these are tweakable either from proc/sysctl or as mount options
22
though, and thus partly solvable from user space.
23
24
The kernel update daemon (kupdated) also runs at specific intervals, flushing
25
old dirty data out. Default is every 5 seconds, this too can be tweaked
26
from sysctl.
27
28
So what does the laptop mode patch do? It attempts to fully utilize the
29
hard drive once it has been spun up, flushing the old dirty data out to
30
disk. Instead of flushing just the expired data, it will clean everything.
31
When a read causes the disk to spin up, we kick off this flushing after
32
a few seconds. This means that once the disk spins down again, everything
33
is up to date. That allows longer dirty data and journal expire times.
34
35
It follows that you have to set long expire times to get long spin downs.
36
This means you could potentially loose 10 minutes worth of data, if you
37
set a 10 minute expire count instead of just 30 seconds worth. The biggest
38
risk here is undoubtedly running out of battery.
39
40
Settings
41
--------
42
43
The main knob is /proc/sys/vm/laptop mode. Setting that to 1 switches the
44
vm (and block layer) to laptop mode. Leaving it to 0 makes the kernel work
45
like before. When in laptop mode, you also want to extend the intervals
46
desribed above. See the laptop-mode.sh script for how to do that.
47
48
It can happen that the disk still keeps spinning up and you don't quite
49
know why or what causes it. The laptop mode patch has a little helper for
50
that as well, /proc/sys/vm/block-dump. When set to 1, it will dump info to
51
the kernel message buffer about what process caused the io. Be very careful
52
when playing with this setting, it is advisable to shut down syslog first!
53
54
Result
55
------
56
57
Using the laptop-mode.sh script with its default settings, I get the full
58
10 minutes worth of drive spin down. Provided your work load is cached,
59
the disk will only spin up every 10 minutes (well actually, 9 minutes and 55
60
seconds due to the 5 second delay in flushing dirty data after the last read
61
completes). I can't tell you exactly how much extra battery life you will
62
gain in laptop mode, it will vary greatly on the laptop and workload in
63
question. The only way to know for sure is to try it out. Getting 10% extra
64
battery life is not unrealistic.
65
66
Notes
67
-----
68
69
Patch only changes journal expire time for ext3. reiserfs uses a hardwire
70
value, should be trivial to adapt though (basically just make it call
71
get_buffer_flushtime() and uses that). I have not looked at other
72
journalling file systems, I'll happily accept patches to rectify that!
(-)linux-2.4.22/MAINTAINERS (-1 / +7 lines)
Lines 759-764 Link Here
759
L:      linux-kernel@vger.kernel.org
759
L:      linux-kernel@vger.kernel.org
760
S:      Maintained
760
S:      Maintained
761
761
762
HFSPLUS FILESYSTEM
763
P:	Brad Boyer
764
M:	flar@allandria.com
765
W:	http://sourceforge.net/projects/linux-hfsplus/
766
S:	Maintained
767
762
HGA FRAMEBUFFER DRIVER
768
HGA FRAMEBUFFER DRIVER
763
P:	Ferenc Bakonyi
769
P:	Ferenc Bakonyi
764
M:	fero@drama.obuda.kando.hu
770
M:	fero@drama.obuda.kando.hu
Lines 1309-1315 Link Here
1309
NVIDIA (RIVA) FRAMEBUFFER DRIVER
1315
NVIDIA (RIVA) FRAMEBUFFER DRIVER
1310
P:	Ani Joshi
1316
P:	Ani Joshi
1311
M:	ajoshi@kernel.crashing.org
1317
M:	ajoshi@kernel.crashing.org
1312
L:	linux-nvidia@lists.surfsouth.com
1318
L:      linux-fbdev-devel@lists.sourceforge.net
1313
S:	Maintained
1319
S:	Maintained
1314
1320
1315
OLYMPIC NETWORK DRIVER
1321
OLYMPIC NETWORK DRIVER
(-)linux-2.4.22/Makefile (-1 / +1 lines)
Lines 1-7 Link Here
1
VERSION = 2
1
VERSION = 2
2
PATCHLEVEL = 4
2
PATCHLEVEL = 4
3
SUBLEVEL = 22
3
SUBLEVEL = 22
4
EXTRAVERSION =
4
EXTRAVERSION = -ben2
5
5
6
KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
6
KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
7
7
(-)linux-2.4.22/README.BENH (+23 lines)
Line 0 Link Here
1
Welcome to my PowerMac tree.
2
3
In addition to the standard feature set of kernel.org's 2.4.22, this
4
tree includes small fixes that didn't make it into 2.4.21, including all
5
of what was present as of 2.4.21-ben3. Some of the major additions are:
6
7
 - Laptop mode patch (Jens Axboe). See Documentation/laptop_mode.sh script
8
 - Andrea Arcangeli's silent-stack-overflow patch
9
 - CPU Frequency switching support on some laptops
10
 - Support for UniNorth AGP in the agpgart driver (though it's strongly
11
   recommended that you use Michel's Danzer DRM module for that to work
12
   properly)
13
 - Support for blinking the laptop LED on internal HD activity
14
   (Jens and me)
15
 - Improved support for lba48 capable disks (Jens Axboe)
16
 - Updated rivafb with support for more cards & eMac
17
 - Updated sungem driver, supports more chips & recent PHYs
18
 - Updated dmasound driver to support tumbler & snapper
19
 - Add reporting of OF device path of IDE interfaces in /proc/ide
20
 - Fixes for CompactFlash cards
21
 - Fixes to vmlinux.coff oldworld wrapper
22
 - Better TB sync code for 2 CPU machines from Samuel Rydth
23
(-)linux-2.4.22/arch/alpha/mm/fault.c (-1 / +1 lines)
Lines 124-130 Link Here
124
		goto good_area;
124
		goto good_area;
125
	if (!(vma->vm_flags & VM_GROWSDOWN))
125
	if (!(vma->vm_flags & VM_GROWSDOWN))
126
		goto bad_area;
126
		goto bad_area;
127
	if (expand_stack(vma, address))
127
	if (expand_stack(vma, address, NULL))
128
		goto bad_area;
128
		goto bad_area;
129
/*
129
/*
130
 * Ok, we have a good vm_area for this memory access, so
130
 * Ok, we have a good vm_area for this memory access, so
(-)linux-2.4.22/arch/arm/mm/fault-common.c (-1 / +1 lines)
Lines 254-260 Link Here
254
	goto survive;
254
	goto survive;
255
255
256
check_stack:
256
check_stack:
257
	if (vma->vm_flags & VM_GROWSDOWN && !expand_stack(vma, addr))
257
	if (vma->vm_flags & VM_GROWSDOWN && !expand_stack(vma, addr, NULL))
258
		goto good_area;
258
		goto good_area;
259
out:
259
out:
260
	return fault;
260
	return fault;
(-)linux-2.4.22/arch/cris/mm/fault.c (-1 / +1 lines)
Lines 323-329 Link Here
323
		if (address + PAGE_SIZE < rdusp())
323
		if (address + PAGE_SIZE < rdusp())
324
			goto bad_area;
324
			goto bad_area;
325
	}
325
	}
326
	if (expand_stack(vma, address))
326
	if (expand_stack(vma, address, NULL))
327
		goto bad_area;
327
		goto bad_area;
328
328
329
	/*
329
	/*
(-)linux-2.4.22/arch/i386/mm/fault.c (-4 / +6 lines)
Lines 32-38 Link Here
32
 */
32
 */
33
int __verify_write(const void * addr, unsigned long size)
33
int __verify_write(const void * addr, unsigned long size)
34
{
34
{
35
	struct vm_area_struct * vma;
35
	struct vm_area_struct * vma, * prev_vma;
36
	unsigned long start = (unsigned long) addr;
36
	unsigned long start = (unsigned long) addr;
37
37
38
	if (!size)
38
	if (!size)
Lines 78-84 Link Here
78
check_stack:
78
check_stack:
79
	if (!(vma->vm_flags & VM_GROWSDOWN))
79
	if (!(vma->vm_flags & VM_GROWSDOWN))
80
		goto bad_area;
80
		goto bad_area;
81
	if (expand_stack(vma, start) == 0)
81
	find_vma_prev(current->mm, start, &prev_vma);
82
	if (expand_stack(vma, start, prev_vma) == 0)
82
		goto good_area;
83
		goto good_area;
83
84
84
bad_area:
85
bad_area:
Lines 141-147 Link Here
141
{
142
{
142
	struct task_struct *tsk;
143
	struct task_struct *tsk;
143
	struct mm_struct *mm;
144
	struct mm_struct *mm;
144
	struct vm_area_struct * vma;
145
	struct vm_area_struct * vma, * prev_vma;
145
	unsigned long address;
146
	unsigned long address;
146
	unsigned long page;
147
	unsigned long page;
147
	unsigned long fixup;
148
	unsigned long fixup;
Lines 202-208 Link Here
202
		if (address + 32 < regs->esp)
203
		if (address + 32 < regs->esp)
203
			goto bad_area;
204
			goto bad_area;
204
	}
205
	}
205
	if (expand_stack(vma, address))
206
	find_vma_prev(mm, address, &prev_vma);
207
	if (expand_stack(vma, address, prev_vma))
206
		goto bad_area;
208
		goto bad_area;
207
/*
209
/*
208
 * Ok, we have a good vm_area for this memory access, so
210
 * Ok, we have a good vm_area for this memory access, so
(-)linux-2.4.22/arch/ia64/mm/fault.c (-1 / +1 lines)
Lines 159-165 Link Here
159
		if (rgn_index(address) != rgn_index(vma->vm_start)
159
		if (rgn_index(address) != rgn_index(vma->vm_start)
160
		    || rgn_offset(address) >= RGN_MAP_LIMIT)
160
		    || rgn_offset(address) >= RGN_MAP_LIMIT)
161
			goto bad_area;
161
			goto bad_area;
162
		if (expand_stack(vma, address))
162
		if (expand_stack(vma, address, NULL))
163
			goto bad_area;
163
			goto bad_area;
164
	} else {
164
	} else {
165
		vma = prev_vma;
165
		vma = prev_vma;
(-)linux-2.4.22/arch/m68k/mm/fault.c (-1 / +1 lines)
Lines 120-126 Link Here
120
		if (address + 256 < rdusp())
120
		if (address + 256 < rdusp())
121
			goto map_err;
121
			goto map_err;
122
	}
122
	}
123
	if (expand_stack(vma, address))
123
	if (expand_stack(vma, address, NULL))
124
		goto map_err;
124
		goto map_err;
125
125
126
/*
126
/*
(-)linux-2.4.22/arch/mips/mm/fault.c (-1 / +1 lines)
Lines 114-120 Link Here
114
		goto good_area;
114
		goto good_area;
115
	if (!(vma->vm_flags & VM_GROWSDOWN))
115
	if (!(vma->vm_flags & VM_GROWSDOWN))
116
		goto bad_area;
116
		goto bad_area;
117
	if (expand_stack(vma, address))
117
	if (expand_stack(vma, address, NULL))
118
		goto bad_area;
118
		goto bad_area;
119
/*
119
/*
120
 * Ok, we have a good vm_area for this memory access, so
120
 * Ok, we have a good vm_area for this memory access, so
(-)linux-2.4.22/arch/mips64/mm/fault.c (-1 / +1 lines)
Lines 137-143 Link Here
137
		goto good_area;
137
		goto good_area;
138
	if (!(vma->vm_flags & VM_GROWSDOWN))
138
	if (!(vma->vm_flags & VM_GROWSDOWN))
139
		goto bad_area;
139
		goto bad_area;
140
	if (expand_stack(vma, address))
140
	if (expand_stack(vma, address, NULL))
141
		goto bad_area;
141
		goto bad_area;
142
/*
142
/*
143
 * Ok, we have a good vm_area for this memory access, so
143
 * Ok, we have a good vm_area for this memory access, so
(-)linux-2.4.22/arch/ppc/boot/pmac/coffmain.c (-14 / +20 lines)
Lines 18-23 Link Here
18
extern char _start, _end;
18
extern char _start, _end;
19
19
20
extern char *claim(unsigned, unsigned, unsigned);
20
extern char *claim(unsigned, unsigned, unsigned);
21
extern int map(unsigned, unsigned, unsigned);
21
extern char image_data[], initrd_data[];
22
extern char image_data[], initrd_data[];
22
extern int initrd_len, image_len;
23
extern int initrd_len, image_len;
23
extern int getprop(void *, const char *, void *, int);
24
extern int getprop(void *, const char *, void *, int);
Lines 34-49 Link Here
34
char *begin_avail, *end_avail;
35
char *begin_avail, *end_avail;
35
char *avail_high;
36
char *avail_high;
36
37
37
#define RAM_START	0
38
#define RAM_END		(RAM_START + 0x800000)	/* only 8M mapped with BATs */
39
40
#define PROG_START	RAM_START
41
#define PROG_SIZE	0x00400000
42
43
#define SCRATCH_SIZE	(128 << 10)
38
#define SCRATCH_SIZE	(128 << 10)
44
39
45
static char heap[SCRATCH_SIZE];
40
static char heap[SCRATCH_SIZE];
46
41
42
//static unsigned long ram_start = 0;
43
//static unsigned long ram_end = 0x800000;
44
//static unsigned long prog_start = 0;
45
//static unsigned long prog_size = 0x380000;
46
47
static unsigned long ram_start = 0;
48
static unsigned long ram_end = 0x1000000;
49
static unsigned long prog_start = 0x800000;
50
static unsigned long prog_size = 0x800000;
47
typedef void (*kernel_start_t)(int, int, void *);
51
typedef void (*kernel_start_t)(int, int, void *);
48
52
49
void boot(int a1, int a2, void *prom)
53
void boot(int a1, int a2, void *prom)
Lines 54-85 Link Here
54
    unsigned initrd_start, initrd_size;
58
    unsigned initrd_start, initrd_size;
55
59
56
    printf("coffboot starting: loaded at 0x%p\n", &_start);
60
    printf("coffboot starting: loaded at 0x%p\n", &_start);
57
    setup_bats(RAM_START);
61
    setup_bats(ram_start);
58
62
59
    initrd_size = (char *)(&__ramdisk_end) - (char *)(&__ramdisk_begin);
63
    initrd_size = (char *)(&__ramdisk_end) - (char *)(&__ramdisk_begin);
60
    if (initrd_size) {
64
    if (initrd_size) {
61
	initrd_start = (RAM_END - initrd_size) & ~0xFFF;
65
	initrd_start = (ram_end - initrd_size) & ~0xFFF;
62
	a1 = initrd_start;
66
	a1 = initrd_start;
63
	a2 = initrd_size;
67
	a2 = initrd_size;
64
	claim(initrd_start, RAM_END - initrd_start, 0);
68
	claim(initrd_start, ram_end - initrd_start, 0);
65
	printf("initial ramdisk moving 0x%x <- 0x%p (%x bytes)\n\r",
69
	printf("initial ramdisk moving 0x%x <- 0x%p (%x bytes)\n\r",
66
	       initrd_start, (char *)(&__ramdisk_begin), initrd_size);
70
	       initrd_start, (char *)(&__ramdisk_begin), initrd_size);
67
	memcpy((char *)initrd_start, (char *)(&__ramdisk_begin), initrd_size);
71
	memcpy((char *)initrd_start, (char *)(&__ramdisk_begin), initrd_size);
72
	prog_size = initrd_start - prog_start;
68
    } else
73
    } else
69
	a2 = 0xdeadbeef;
74
	a2 = 0xdeadbeef;
70
75
71
    im = (char *)(&__image_begin);
76
    im = (char *)(&__image_begin);
72
    len = (char *)(&__image_end) - (char *)(&__image_begin);
77
    len = (char *)(&__image_end) - (char *)(&__image_begin);
73
    /* claim 4MB starting at 0 */
78
    /* claim 4MB starting at 0 */
74
    claim(0, PROG_SIZE, 0);
79
    claim(prog_start, prog_size, 0);
75
    dst = (void *) RAM_START;
80
    map(prog_start, prog_start, prog_size);
81
    dst = (void *) prog_start;
76
    if (im[0] == 0x1f && im[1] == 0x8b) {
82
    if (im[0] == 0x1f && im[1] == 0x8b) {
77
	/* set up scratch space */
83
	/* set up scratch space */
78
	begin_avail = avail_high = avail_ram = heap;
84
	begin_avail = avail_high = avail_ram = heap;
79
	end_avail = heap + sizeof(heap);
85
	end_avail = heap + sizeof(heap);
80
	printf("heap at 0x%p\n", avail_ram);
86
	printf("heap at 0x%p\n", avail_ram);
81
	printf("gunzipping (0x%p <- 0x%p:0x%p)...", dst, im, im+len);
87
	printf("gunzipping (0x%p <- 0x%p:0x%p)...", dst, im, im+len);
82
	gunzip(dst, PROG_SIZE, im, &len);
88
	gunzip(dst, prog_size, im, &len);
83
	printf("done %u bytes\n", len);
89
	printf("done %u bytes\n", len);
84
	printf("%u bytes of heap consumed, max in use %u\n",
90
	printf("%u bytes of heap consumed, max in use %u\n",
85
	       avail_high - begin_avail, heap_max);
91
	       avail_high - begin_avail, heap_max);
Lines 89-97 Link Here
89
95
90
    flush_cache(dst, len);
96
    flush_cache(dst, len);
91
    make_bi_recs(((unsigned long) dst + len), "coffboot", _MACH_Pmac,
97
    make_bi_recs(((unsigned long) dst + len), "coffboot", _MACH_Pmac,
92
		    (PROG_START + PROG_SIZE));
98
		    (prog_start + prog_size));
93
99
94
    sa = (unsigned long)PROG_START;
100
    sa = (unsigned long)prog_start;
95
    printf("start address = 0x%x\n", sa);
101
    printf("start address = 0x%x\n", sa);
96
102
97
    (*(kernel_start_t)sa)(a1, a2, prom);
103
    (*(kernel_start_t)sa)(a1, a2, prom);
(-)linux-2.4.22/arch/ppc/boot/pmac/misc.S (-1 / +11 lines)
Lines 9-15 Link Here
9
	.text
9
	.text
10
10
11
/*
11
/*
12
 * Use the BAT3 registers to map the 1st 8MB of RAM to
12
 * Use the BAT2 & 3 registers to map the 1st 16MB of RAM to
13
 * the address given as the 1st argument.
13
 * the address given as the 1st argument.
14
 */
14
 */
15
	.globl	setup_bats
15
	.globl	setup_bats
Lines 22-27 Link Here
22
	mtibatl	3,0			/* invalidate BAT first */
22
	mtibatl	3,0			/* invalidate BAT first */
23
	ori	3,3,4			/* set up BAT registers for 601 */
23
	ori	3,3,4			/* set up BAT registers for 601 */
24
	li	4,0x7f
24
	li	4,0x7f
25
	mtibatu	2,3
26
	mtibatl	2,4
27
	oris	3,3,0x80
28
	oris	4,4,0x80
25
	mtibatu	3,3
29
	mtibatu	3,3
26
	mtibatl	3,4
30
	mtibatl	3,4
27
	b	5f
31
	b	5f
Lines 29-34 Link Here
29
	mtibatu	3,0
33
	mtibatu	3,0
30
	ori	3,3,0xff		/* set up BAT registers for 604 */
34
	ori	3,3,0xff		/* set up BAT registers for 604 */
31
	li	4,2
35
	li	4,2
36
	mtdbatl	2,4
37
	mtdbatu	2,3
38
	mtibatl	2,4
39
	mtibatu	2,3
40
	oris	3,3,0x80
41
	oris	4,4,0x80
32
	mtdbatl	3,4
42
	mtdbatl	3,4
33
	mtdbatu	3,3
43
	mtdbatu	3,3
34
	mtibatl	3,4
44
	mtibatl	3,4
(-)linux-2.4.22/arch/ppc/boot/pmac/start.c (-2 / +40 lines)
Lines 11-22 Link Here
11
extern int strlen(const char *s);
11
extern int strlen(const char *s);
12
extern void boot(int a1, int a2, void *prom);
12
extern void boot(int a1, int a2, void *prom);
13
13
14
int (*prom)(void *args);
14
int (*prom)(void *);
15
15
16
void *chosen_handle;
16
void *chosen_handle;
17
void *stdin;
17
void *stdin;
18
void *stdout;
18
void *stdout;
19
void *stderr;
19
void *stderr;
20
void *prom_mmu;
20
21
21
void exit(void);
22
void exit(void);
22
void *finddevice(const char *name);
23
void *finddevice(const char *name);
Lines 35-40 Link Here
35
    stderr = stdout;
36
    stderr = stdout;
36
    if (getprop(chosen_handle, "stdin", &stdin, sizeof(stdin)) != 4)
37
    if (getprop(chosen_handle, "stdin", &stdin, sizeof(stdin)) != 4)
37
	exit();
38
	exit();
39
    if (getprop(chosen_handle, "mmu", &prom_mmu, sizeof(prom_mmu)) != 4)
40
	exit();
38
41
39
    boot(a1, a2, promptr);
42
    boot(a1, a2, promptr);
40
    for (;;)
43
    for (;;)
Lines 195-200 Link Here
195
}
198
}
196
199
197
int
200
int
201
map(unsigned int phys, unsigned int virt, unsigned int size)
202
{
203
    struct prom_args {
204
	char *service;
205
	int nargs;
206
	int nret;
207
	char *method;
208
	void *mmu_ihandle;    
209
	int misc;
210
	unsigned int phys;
211
	unsigned int virt;
212
	unsigned int size;
213
	int ret0;
214
	int ret1;
215
    } args;
216
217
    if (prom_mmu == 0) {
218
    	printk("map() called, no MMU found\n");
219
    	return -1;
220
    }
221
    args.service = "call-method";
222
    args.nargs = 6;
223
    args.nret = 2;
224
    args.method = "map";
225
    args.mmu_ihandle = prom_mmu;
226
    args.misc = -1;
227
    args.phys = phys;
228
    args.virt = virt;
229
    args.size = size;
230
    (*prom)(&args);
231
232
    return (int)args.ret0;
233
}
234
235
int
198
getprop(void *phandle, const char *name, void *buf, int buflen)
236
getprop(void *phandle, const char *name, void *buf, int buflen)
199
{
237
{
200
    struct prom_args {
238
    struct prom_args {
Lines 330-336 Link Here
330
}
368
}
331
369
332
int
370
int
333
printf(char *fmt, ...)
371
printf(const char *fmt, ...)
334
{
372
{
335
	va_list args;
373
	va_list args;
336
	int n;
374
	int n;
(-)linux-2.4.22/arch/ppc/config.in (+11 lines)
Lines 53-58 Link Here
53
  define_bool CONFIG_PPC_STD_MMU y
53
  define_bool CONFIG_PPC_STD_MMU y
54
fi
54
fi
55
55
56
bool 'CPU Frequency scaling' CONFIG_CPU_FREQ
57
if [ "$CONFIG_CPU_FREQ" = "y" ]; then
58
   bool '  /proc/sys/cpu/ interface (2.4.)' CONFIG_CPU_FREQ_24_API
59
   if [ "$CONFIG_CPU_FREQ_24_API" = "n" ]; then
60
       define_bool CONFIG_CPU_FREQ_26_API y
61
   fi
62
   if [ "$CONFIG_ADB_PMU" = "y" ]; then
63
       bool "  Support for Apple PowerBooks" CONFIG_CPU_FREQ_PMAC
64
   fi
65
fi
66
56
if [ "$CONFIG_8260" = "y" ]; then
67
if [ "$CONFIG_8260" = "y" ]; then
57
  define_bool CONFIG_SERIAL_CONSOLE y
68
  define_bool CONFIG_SERIAL_CONSOLE y
58
  bool 'Support for EST8260' CONFIG_EST8260
69
  bool 'Support for EST8260' CONFIG_EST8260
(-)linux-2.4.22/arch/ppc/configs/briq_defconfig (-21 / +2 lines)
Lines 1-5 Link Here
1
#
1
#
2
# Automatically generated make config: don't edit
2
# Automatically generated by make menuconfig: don't edit
3
#
3
#
4
# CONFIG_UID16 is not set
4
# CONFIG_UID16 is not set
5
# CONFIG_RWSEM_GENERIC_SPINLOCK is not set
5
# CONFIG_RWSEM_GENERIC_SPINLOCK is not set
Lines 30-35 Link Here
30
# CONFIG_8xx is not set
30
# CONFIG_8xx is not set
31
# CONFIG_8260 is not set
31
# CONFIG_8260 is not set
32
CONFIG_PPC_STD_MMU=y
32
CONFIG_PPC_STD_MMU=y
33
# CONFIG_CPU_FREQ is not set
33
CONFIG_ALL_PPC=y
34
CONFIG_ALL_PPC=y
34
# CONFIG_APUS is not set
35
# CONFIG_APUS is not set
35
# CONFIG_SPRUCE is not set
36
# CONFIG_SPRUCE is not set
Lines 191-200 Link Here
191
# CONFIG_KHTTPD is not set
192
# CONFIG_KHTTPD is not set
192
# CONFIG_ATM is not set
193
# CONFIG_ATM is not set
193
# CONFIG_VLAN_8021Q is not set
194
# CONFIG_VLAN_8021Q is not set
194
195
#
196
#  
197
#
198
# CONFIG_IPX is not set
195
# CONFIG_IPX is not set
199
CONFIG_ATALK=m
196
CONFIG_ATALK=m
200
197
Lines 232-241 Link Here
232
# IDE, ATA and ATAPI Block devices
229
# IDE, ATA and ATAPI Block devices
233
#
230
#
234
CONFIG_BLK_DEV_IDE=y
231
CONFIG_BLK_DEV_IDE=y
235
236
#
237
# Please see Documentation/ide.txt for help/info on IDE drives
238
#
239
# CONFIG_BLK_DEV_HD_IDE is not set
232
# CONFIG_BLK_DEV_HD_IDE is not set
240
# CONFIG_BLK_DEV_HD is not set
233
# CONFIG_BLK_DEV_HD is not set
241
CONFIG_BLK_DEV_IDEDISK=y
234
CONFIG_BLK_DEV_IDEDISK=y
Lines 247-256 Link Here
247
CONFIG_BLK_DEV_IDEFLOPPY=y
240
CONFIG_BLK_DEV_IDEFLOPPY=y
248
CONFIG_BLK_DEV_IDESCSI=y
241
CONFIG_BLK_DEV_IDESCSI=y
249
# CONFIG_IDE_TASK_IOCTL is not set
242
# CONFIG_IDE_TASK_IOCTL is not set
250
251
#
252
# IDE chipset support/bugfixes
253
#
254
# CONFIG_BLK_DEV_CMD640 is not set
243
# CONFIG_BLK_DEV_CMD640 is not set
255
# CONFIG_BLK_DEV_CMD640_ENHANCED is not set
244
# CONFIG_BLK_DEV_CMD640_ENHANCED is not set
256
# CONFIG_BLK_DEV_ISAPNP is not set
245
# CONFIG_BLK_DEV_ISAPNP is not set
Lines 588-601 Link Here
588
# Joysticks
577
# Joysticks
589
#
578
#
590
# CONFIG_INPUT_GAMEPORT is not set
579
# CONFIG_INPUT_GAMEPORT is not set
591
592
#
593
# Input core support is needed for gameports
594
#
595
596
#
597
# Input core support is needed for joysticks
598
#
599
# CONFIG_QIC02_TAPE is not set
580
# CONFIG_QIC02_TAPE is not set
600
# CONFIG_IPMI_HANDLER is not set
581
# CONFIG_IPMI_HANDLER is not set
601
# CONFIG_IPMI_PANIC_EVENT is not set
582
# CONFIG_IPMI_PANIC_EVENT is not set
(-)linux-2.4.22/arch/ppc/configs/pmac_defconfig (-178 / +226 lines)
Lines 1-5 Link Here
1
#
1
#
2
# Automatically generated make config: don't edit
2
# Automatically generated by make menuconfig: don't edit
3
#
3
#
4
# CONFIG_UID16 is not set
4
# CONFIG_UID16 is not set
5
# CONFIG_RWSEM_GENERIC_SPINLOCK is not set
5
# CONFIG_RWSEM_GENERIC_SPINLOCK is not set
Lines 24-52 Link Here
24
CONFIG_PPC=y
24
CONFIG_PPC=y
25
CONFIG_PPC32=y
25
CONFIG_PPC32=y
26
CONFIG_6xx=y
26
CONFIG_6xx=y
27
# CONFIG_4xx is not set
27
# CONFIG_40x is not set
28
# CONFIG_POWER3 is not set
28
# CONFIG_POWER3 is not set
29
# CONFIG_POWER4 is not set
29
# CONFIG_POWER4 is not set
30
# CONFIG_8xx is not set
30
# CONFIG_8xx is not set
31
# CONFIG_8260 is not set
31
# CONFIG_8260 is not set
32
CONFIG_PPC_STD_MMU=y
32
CONFIG_PPC_STD_MMU=y
33
CONFIG_CPU_FREQ=y
34
# CONFIG_CPU_FREQ_24_API is not set
35
CONFIG_CPU_FREQ_26_API=y
36
CONFIG_CPU_FREQ_PMAC=y
33
CONFIG_ALL_PPC=y
37
CONFIG_ALL_PPC=y
34
# CONFIG_APUS is not set
38
# CONFIG_APUS is not set
35
# CONFIG_SPRUCE is not set
39
# CONFIG_SPRUCE is not set
36
# CONFIG_LOPEC is not set
40
# CONFIG_LOPEC is not set
41
# CONFIG_PPLUS is not set
37
# CONFIG_PAL4 is not set
42
# CONFIG_PAL4 is not set
38
# CONFIG_GEMINI is not set
43
# CONFIG_GEMINI is not set
39
# CONFIG_SMP is not set
44
# CONFIG_SMP is not set
40
CONFIG_ALTIVEC=y
45
CONFIG_ALTIVEC=y
41
CONFIG_TAU=y
46
# CONFIG_TAU is not set
42
# CONFIG_TAU_INT is not set
43
# CONFIG_TAU_AVERAGE is not set
44
CONFIG_PPC_ISATIMER=y
47
CONFIG_PPC_ISATIMER=y
45
48
46
#
49
#
47
# General setup
50
# General setup
48
#
51
#
49
# CONFIG_HIGHMEM is not set
52
CONFIG_HIGHMEM=y
50
# CONFIG_ISA is not set
53
# CONFIG_ISA is not set
51
# CONFIG_EISA is not set
54
# CONFIG_EISA is not set
52
# CONFIG_SBUS is not set
55
# CONFIG_SBUS is not set
Lines 76-85 Link Here
76
# Parallel port support
79
# Parallel port support
77
#
80
#
78
# CONFIG_PARPORT is not set
81
# CONFIG_PARPORT is not set
79
CONFIG_GEN_RTC=y
82
# CONFIG_GEN_RTC is not set
83
CONFIG_PPC_RTC=y
80
CONFIG_PPC601_SYNC_FIX=y
84
CONFIG_PPC601_SYNC_FIX=y
81
CONFIG_PROC_DEVICETREE=y
85
CONFIG_PROC_DEVICETREE=y
82
CONFIG_PPC_RTAS=y
86
# CONFIG_PPC_RTAS is not set
83
# CONFIG_PREP_RESIDUAL is not set
87
# CONFIG_PREP_RESIDUAL is not set
84
# CONFIG_PROC_PREPRESIDUAL is not set
88
# CONFIG_PROC_PREPRESIDUAL is not set
85
CONFIG_PPCBUG_NVRAM=y
89
CONFIG_PPCBUG_NVRAM=y
Lines 99-105 Link Here
99
#
103
#
100
# Block devices
104
# Block devices
101
#
105
#
102
CONFIG_BLK_DEV_FD=m
106
# CONFIG_BLK_DEV_FD is not set
103
# CONFIG_BLK_DEV_XD is not set
107
# CONFIG_BLK_DEV_XD is not set
104
# CONFIG_PARIDE is not set
108
# CONFIG_PARIDE is not set
105
# CONFIG_BLK_CPQ_DA is not set
109
# CONFIG_BLK_CPQ_DA is not set
Lines 152-161 Link Here
152
#
156
#
153
CONFIG_IP_NF_CONNTRACK=m
157
CONFIG_IP_NF_CONNTRACK=m
154
CONFIG_IP_NF_FTP=m
158
CONFIG_IP_NF_FTP=m
155
CONFIG_IP_NF_AMANDA=m
159
# CONFIG_IP_NF_AMANDA is not set
156
CONFIG_IP_NF_TFTP=m
160
# CONFIG_IP_NF_TFTP is not set
157
CONFIG_IP_NF_IRC=m
161
CONFIG_IP_NF_IRC=m
158
# CONFIG_IP_NF_QUEUE is not set
162
CONFIG_IP_NF_QUEUE=m
159
CONFIG_IP_NF_IPTABLES=m
163
CONFIG_IP_NF_IPTABLES=m
160
CONFIG_IP_NF_MATCH_LIMIT=m
164
CONFIG_IP_NF_MATCH_LIMIT=m
161
CONFIG_IP_NF_MATCH_MAC=m
165
CONFIG_IP_NF_MATCH_MAC=m
Lines 163-168 Link Here
163
CONFIG_IP_NF_MATCH_MARK=m
167
CONFIG_IP_NF_MATCH_MARK=m
164
CONFIG_IP_NF_MATCH_MULTIPORT=m
168
CONFIG_IP_NF_MATCH_MULTIPORT=m
165
CONFIG_IP_NF_MATCH_TOS=m
169
CONFIG_IP_NF_MATCH_TOS=m
170
# CONFIG_IP_NF_MATCH_RECENT is not set
166
CONFIG_IP_NF_MATCH_ECN=m
171
CONFIG_IP_NF_MATCH_ECN=m
167
CONFIG_IP_NF_MATCH_DSCP=m
172
CONFIG_IP_NF_MATCH_DSCP=m
168
CONFIG_IP_NF_MATCH_AH_ESP=m
173
CONFIG_IP_NF_MATCH_AH_ESP=m
Lines 181-209 Link Here
181
CONFIG_IP_NF_NAT_NEEDED=y
186
CONFIG_IP_NF_NAT_NEEDED=y
182
CONFIG_IP_NF_TARGET_MASQUERADE=m
187
CONFIG_IP_NF_TARGET_MASQUERADE=m
183
CONFIG_IP_NF_TARGET_REDIRECT=m
188
CONFIG_IP_NF_TARGET_REDIRECT=m
184
CONFIG_IP_NF_NAT_AMANDA=m
185
# CONFIG_IP_NF_NAT_LOCAL is not set
189
# CONFIG_IP_NF_NAT_LOCAL is not set
186
CONFIG_IP_NF_NAT_SNMP_BASIC=m
190
CONFIG_IP_NF_NAT_SNMP_BASIC=m
187
CONFIG_IP_NF_NAT_IRC=m
191
CONFIG_IP_NF_NAT_IRC=m
188
CONFIG_IP_NF_NAT_FTP=m
192
CONFIG_IP_NF_NAT_FTP=m
189
CONFIG_IP_NF_NAT_TFTP=m
193
CONFIG_IP_NF_MANGLE=m
190
# CONFIG_IP_NF_MANGLE is not set
194
CONFIG_IP_NF_TARGET_TOS=m
191
# CONFIG_IP_NF_TARGET_LOG is not set
195
CONFIG_IP_NF_TARGET_ECN=m
196
CONFIG_IP_NF_TARGET_DSCP=m
197
CONFIG_IP_NF_TARGET_MARK=m
198
CONFIG_IP_NF_TARGET_LOG=m
192
CONFIG_IP_NF_TARGET_ULOG=m
199
CONFIG_IP_NF_TARGET_ULOG=m
193
CONFIG_IP_NF_TARGET_TCPMSS=m
200
CONFIG_IP_NF_TARGET_TCPMSS=m
194
CONFIG_IP_NF_ARPTABLES=m
201
CONFIG_IP_NF_ARPTABLES=m
195
CONFIG_IP_NF_ARPFILTER=m
202
CONFIG_IP_NF_ARPFILTER=m
203
# CONFIG_IP_NF_ARP_MANGLE is not set
196
CONFIG_IP_NF_COMPAT_IPCHAINS=m
204
CONFIG_IP_NF_COMPAT_IPCHAINS=m
197
CONFIG_IP_NF_NAT_NEEDED=y
205
CONFIG_IP_NF_NAT_NEEDED=y
198
# CONFIG_IP_NF_COMPAT_IPFWADM is not set
206
# CONFIG_IP_NF_COMPAT_IPFWADM is not set
199
# CONFIG_IPV6 is not set
207
# CONFIG_IPV6 is not set
200
# CONFIG_KHTTPD is not set
208
# CONFIG_KHTTPD is not set
201
# CONFIG_ATM is not set
209
CONFIG_ATM=y
210
CONFIG_ATM_CLIP=y
211
CONFIG_ATM_CLIP_NO_ICMP=y
212
CONFIG_ATM_LANE=m
213
CONFIG_ATM_MPOA=m
214
CONFIG_ATM_BR2684=m
215
# CONFIG_ATM_BR2684_IPFILTER is not set
202
# CONFIG_VLAN_8021Q is not set
216
# CONFIG_VLAN_8021Q is not set
203
204
#
205
#  
206
#
207
# CONFIG_IPX is not set
217
# CONFIG_IPX is not set
208
CONFIG_ATALK=m
218
CONFIG_ATALK=m
209
219
Lines 241-250 Link Here
241
# IDE, ATA and ATAPI Block devices
251
# IDE, ATA and ATAPI Block devices
242
#
252
#
243
CONFIG_BLK_DEV_IDE=y
253
CONFIG_BLK_DEV_IDE=y
244
245
#
246
# Please see Documentation/ide.txt for help/info on IDE drives
247
#
248
# CONFIG_BLK_DEV_HD_IDE is not set
254
# CONFIG_BLK_DEV_HD_IDE is not set
249
# CONFIG_BLK_DEV_HD is not set
255
# CONFIG_BLK_DEV_HD is not set
250
CONFIG_BLK_DEV_IDEDISK=y
256
CONFIG_BLK_DEV_IDEDISK=y
Lines 255-265 Link Here
255
# CONFIG_BLK_DEV_IDETAPE is not set
261
# CONFIG_BLK_DEV_IDETAPE is not set
256
CONFIG_BLK_DEV_IDEFLOPPY=y
262
CONFIG_BLK_DEV_IDEFLOPPY=y
257
CONFIG_BLK_DEV_IDESCSI=y
263
CONFIG_BLK_DEV_IDESCSI=y
258
# CONFIG_IDE_TASK_IOCTL is not set
264
CONFIG_IDE_TASK_IOCTL=y
259
260
#
261
# IDE chipset support/bugfixes
262
#
263
# CONFIG_BLK_DEV_CMD640 is not set
265
# CONFIG_BLK_DEV_CMD640 is not set
264
# CONFIG_BLK_DEV_CMD640_ENHANCED is not set
266
# CONFIG_BLK_DEV_CMD640_ENHANCED is not set
265
# CONFIG_BLK_DEV_ISAPNP is not set
267
# CONFIG_BLK_DEV_ISAPNP is not set
Lines 272-280 Link Here
272
CONFIG_IDEDMA_PCI_AUTO=y
274
CONFIG_IDEDMA_PCI_AUTO=y
273
# CONFIG_IDEDMA_ONLYDISK is not set
275
# CONFIG_IDEDMA_ONLYDISK is not set
274
CONFIG_BLK_DEV_IDEDMA=y
276
CONFIG_BLK_DEV_IDEDMA=y
275
# CONFIG_IDEDMA_PCI_WIP is not set
277
CONFIG_IDEDMA_PCI_WIP=y
276
# CONFIG_BLK_DEV_ADMA100 is not set
278
# CONFIG_BLK_DEV_ADMA100 is not set
277
# CONFIG_BLK_DEV_AEC62XX is not set
279
CONFIG_BLK_DEV_AEC62XX=y
278
# CONFIG_BLK_DEV_ALI15X3 is not set
280
# CONFIG_BLK_DEV_ALI15X3 is not set
279
# CONFIG_WDC_ALI15X3 is not set
281
# CONFIG_WDC_ALI15X3 is not set
280
# CONFIG_BLK_DEV_AMD74XX is not set
282
# CONFIG_BLK_DEV_AMD74XX is not set
Lines 289-298 Link Here
289
# CONFIG_BLK_DEV_PIIX is not set
291
# CONFIG_BLK_DEV_PIIX is not set
290
# CONFIG_BLK_DEV_NS87415 is not set
292
# CONFIG_BLK_DEV_NS87415 is not set
291
# CONFIG_BLK_DEV_OPTI621 is not set
293
# CONFIG_BLK_DEV_OPTI621 is not set
292
# CONFIG_BLK_DEV_PDC202XX_OLD is not set
294
CONFIG_BLK_DEV_PDC202XX_OLD=y
293
# CONFIG_PDC202XX_BURST is not set
295
CONFIG_PDC202XX_BURST=y
294
CONFIG_BLK_DEV_PDC202XX_NEW=m
296
CONFIG_BLK_DEV_PDC202XX_NEW=y
295
# CONFIG_PDC202XX_FORCE is not set
297
CONFIG_PDC202XX_FORCE=y
296
# CONFIG_BLK_DEV_RZ1000 is not set
298
# CONFIG_BLK_DEV_RZ1000 is not set
297
# CONFIG_BLK_DEV_SC1200 is not set
299
# CONFIG_BLK_DEV_SC1200 is not set
298
# CONFIG_BLK_DEV_SVWKS is not set
300
# CONFIG_BLK_DEV_SVWKS is not set
Lines 303-310 Link Here
303
# CONFIG_BLK_DEV_VIA82CXXX is not set
305
# CONFIG_BLK_DEV_VIA82CXXX is not set
304
CONFIG_BLK_DEV_SL82C105=y
306
CONFIG_BLK_DEV_SL82C105=y
305
CONFIG_BLK_DEV_IDE_PMAC=y
307
CONFIG_BLK_DEV_IDE_PMAC=y
308
CONFIG_BLK_DEV_IDE_PMAC_ATA100FIRST=y
306
CONFIG_BLK_DEV_IDEDMA_PMAC=y
309
CONFIG_BLK_DEV_IDEDMA_PMAC=y
307
CONFIG_BLK_DEV_IDEDMA_PMAC_AUTO=y
310
CONFIG_BLK_DEV_IDEDMA_PMAC_AUTO=y
311
CONFIG_PMU_HD_BLINK=y
308
CONFIG_BLK_DEV_IDEDMA=y
312
CONFIG_BLK_DEV_IDEDMA=y
309
CONFIG_BLK_DEV_IDEPCI=y
313
CONFIG_BLK_DEV_IDEPCI=y
310
# CONFIG_IDE_CHIPSETS is not set
314
# CONFIG_IDE_CHIPSETS is not set
Lines 322-331 Link Here
322
# SCSI support
326
# SCSI support
323
#
327
#
324
CONFIG_SCSI=y
328
CONFIG_SCSI=y
325
326
#
327
# SCSI support type (disk, tape, CD-ROM)
328
#
329
CONFIG_BLK_DEV_SD=y
329
CONFIG_BLK_DEV_SD=y
330
CONFIG_SD_EXTRA_DEVS=40
330
CONFIG_SD_EXTRA_DEVS=40
331
CONFIG_CHR_DEV_ST=y
331
CONFIG_CHR_DEV_ST=y
Lines 334-343 Link Here
334
CONFIG_BLK_DEV_SR_VENDOR=y
334
CONFIG_BLK_DEV_SR_VENDOR=y
335
CONFIG_SR_EXTRA_DEVS=2
335
CONFIG_SR_EXTRA_DEVS=2
336
CONFIG_CHR_DEV_SG=y
336
CONFIG_CHR_DEV_SG=y
337
338
#
339
# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
340
#
341
# CONFIG_SCSI_DEBUG_QUEUES is not set
337
# CONFIG_SCSI_DEBUG_QUEUES is not set
342
# CONFIG_SCSI_MULTI_LUN is not set
338
# CONFIG_SCSI_MULTI_LUN is not set
343
CONFIG_SCSI_CONSTANTS=y
339
CONFIG_SCSI_CONSTANTS=y
Lines 353-359 Link Here
353
# CONFIG_SCSI_AHA1542 is not set
349
# CONFIG_SCSI_AHA1542 is not set
354
# CONFIG_SCSI_AHA1740 is not set
350
# CONFIG_SCSI_AHA1740 is not set
355
# CONFIG_SCSI_AACRAID is not set
351
# CONFIG_SCSI_AACRAID is not set
356
CONFIG_SCSI_AIC7XXX=m
352
CONFIG_SCSI_AIC7XXX=y
357
CONFIG_AIC7XXX_CMDS_PER_DEVICE=253
353
CONFIG_AIC7XXX_CMDS_PER_DEVICE=253
358
CONFIG_AIC7XXX_RESET_DELAY_MS=15000
354
CONFIG_AIC7XXX_RESET_DELAY_MS=15000
359
# CONFIG_AIC7XXX_PROBE_EISA_VL is not set
355
# CONFIG_AIC7XXX_PROBE_EISA_VL is not set
Lines 362-371 Link Here
362
CONFIG_AIC7XXX_DEBUG_MASK=0
358
CONFIG_AIC7XXX_DEBUG_MASK=0
363
# CONFIG_AIC7XXX_REG_PRETTY_PRINT is not set
359
# CONFIG_AIC7XXX_REG_PRETTY_PRINT is not set
364
# CONFIG_SCSI_AIC79XX is not set
360
# CONFIG_SCSI_AIC79XX is not set
365
CONFIG_SCSI_AIC7XXX_OLD=m
366
# CONFIG_AIC7XXX_OLD_TCQ_ON_BY_DEFAULT is not set
367
CONFIG_AIC7XXX_OLD_CMDS_PER_DEVICE=8
368
CONFIG_AIC7XXX_OLD_PROC_STATS=y
369
# CONFIG_SCSI_DPT_I2O is not set
361
# CONFIG_SCSI_DPT_I2O is not set
370
CONFIG_SCSI_ADVANSYS=m
362
CONFIG_SCSI_ADVANSYS=m
371
# CONFIG_SCSI_IN2000 is not set
363
# CONFIG_SCSI_IN2000 is not set
Lines 407-413 Link Here
407
# CONFIG_SCSI_DEBUG is not set
399
# CONFIG_SCSI_DEBUG is not set
408
CONFIG_SCSI_MESH=y
400
CONFIG_SCSI_MESH=y
409
CONFIG_SCSI_MESH_SYNC_RATE=5
401
CONFIG_SCSI_MESH_SYNC_RATE=5
410
CONFIG_SCSI_MESH_RESET_DELAY_MS=500
402
CONFIG_SCSI_MESH_RESET_DELAY_MS=4000
411
CONFIG_SCSI_MAC53C94=y
403
CONFIG_SCSI_MAC53C94=y
412
404
413
#
405
#
Lines 419-445 Link Here
419
# IEEE 1394 (FireWire) support (EXPERIMENTAL)
411
# IEEE 1394 (FireWire) support (EXPERIMENTAL)
420
#
412
#
421
CONFIG_IEEE1394=m
413
CONFIG_IEEE1394=m
422
423
#
424
# Device Drivers
425
#
426
427
#
428
#   Texas Instruments PCILynx requires I2C bit-banging
429
#
430
CONFIG_IEEE1394_OHCI1394=m
414
CONFIG_IEEE1394_OHCI1394=m
431
432
#
433
# Protocol Drivers
434
#
435
CONFIG_IEEE1394_VIDEO1394=m
415
CONFIG_IEEE1394_VIDEO1394=m
436
CONFIG_IEEE1394_SBP2=m
416
CONFIG_IEEE1394_SBP2=m
437
# CONFIG_IEEE1394_SBP2_PHYS_DMA is not set
417
# CONFIG_IEEE1394_SBP2_PHYS_DMA is not set
438
CONFIG_IEEE1394_ETH1394=m
418
CONFIG_IEEE1394_ETH1394=m
439
# CONFIG_IEEE1394_DV1394 is not set
419
CONFIG_IEEE1394_DV1394=m
440
CONFIG_IEEE1394_RAWIO=m
420
CONFIG_IEEE1394_RAWIO=m
441
# CONFIG_IEEE1394_CMP is not set
421
# CONFIG_IEEE1394_CMP is not set
442
# CONFIG_IEEE1394_VERBOSEDEBUG is not set
422
# CONFIG_IEEE1394_VERBOSEDEBUG is not set
423
CONFIG_IEEE1394_OUI_DB=y
443
424
444
#
425
#
445
# Network device support
426
# Network device support
Lines 453-459 Link Here
453
# CONFIG_DUMMY is not set
434
# CONFIG_DUMMY is not set
454
# CONFIG_BONDING is not set
435
# CONFIG_BONDING is not set
455
# CONFIG_EQUALIZER is not set
436
# CONFIG_EQUALIZER is not set
456
# CONFIG_TUN is not set
437
CONFIG_TUN=m
457
# CONFIG_ETHERTAP is not set
438
# CONFIG_ETHERTAP is not set
458
439
459
#
440
#
Lines 480-485 Link Here
480
# CONFIG_AMD8111_ETH is not set
461
# CONFIG_AMD8111_ETH is not set
481
# CONFIG_ADAPTEC_STARFIRE is not set
462
# CONFIG_ADAPTEC_STARFIRE is not set
482
# CONFIG_APRICOT is not set
463
# CONFIG_APRICOT is not set
464
# CONFIG_B44 is not set
483
# CONFIG_CS89x0 is not set
465
# CONFIG_CS89x0 is not set
484
CONFIG_TULIP=y
466
CONFIG_TULIP=y
485
# CONFIG_TULIP_MWI is not set
467
# CONFIG_TULIP_MWI is not set
Lines 507-513 Link Here
507
# CONFIG_SUNDANCE is not set
489
# CONFIG_SUNDANCE is not set
508
# CONFIG_SUNDANCE_MMIO is not set
490
# CONFIG_SUNDANCE_MMIO is not set
509
# CONFIG_TLAN is not set
491
# CONFIG_TLAN is not set
510
# CONFIG_TC35815 is not set
511
# CONFIG_VIA_RHINE is not set
492
# CONFIG_VIA_RHINE is not set
512
# CONFIG_VIA_RHINE_MMIO is not set
493
# CONFIG_VIA_RHINE_MMIO is not set
513
# CONFIG_WINBOND_840 is not set
494
# CONFIG_WINBOND_840 is not set
Lines 537-542 Link Here
537
CONFIG_PPP_DEFLATE=y
518
CONFIG_PPP_DEFLATE=y
538
CONFIG_PPP_BSDCOMP=m
519
CONFIG_PPP_BSDCOMP=m
539
# CONFIG_PPPOE is not set
520
# CONFIG_PPPOE is not set
521
# CONFIG_PPPOATM is not set
540
# CONFIG_SLIP is not set
522
# CONFIG_SLIP is not set
541
523
542
#
524
#
Lines 554-563 Link Here
554
CONFIG_APPLE_AIRPORT=m
536
CONFIG_APPLE_AIRPORT=m
555
# CONFIG_PLX_HERMES is not set
537
# CONFIG_PLX_HERMES is not set
556
CONFIG_PCI_HERMES=m
538
CONFIG_PCI_HERMES=m
557
539
# CONFIG_TMD_HERMES is not set
558
#
559
# Wireless Pcmcia cards support
560
#
561
CONFIG_PCMCIA_HERMES=m
540
CONFIG_PCMCIA_HERMES=m
562
# CONFIG_AIRO_CS is not set
541
# CONFIG_AIRO_CS is not set
563
CONFIG_NET_WIRELESS=y
542
CONFIG_NET_WIRELESS=y
Lines 598-603 Link Here
598
# CONFIG_AIRONET4500_CS is not set
577
# CONFIG_AIRONET4500_CS is not set
599
578
600
#
579
#
580
# ATM drivers
581
#
582
# CONFIG_ATM_TCP is not set
583
# CONFIG_ATM_LANAI is not set
584
# CONFIG_ATM_ENI is not set
585
# CONFIG_ATM_FIRESTREAM is not set
586
# CONFIG_ATM_ZATM is not set
587
# CONFIG_ATM_NICSTAR is not set
588
# CONFIG_ATM_IDT77252 is not set
589
# CONFIG_ATM_AMBASSADOR is not set
590
# CONFIG_ATM_HORIZON is not set
591
# CONFIG_ATM_IA is not set
592
# CONFIG_ATM_FORE200E_MAYBE is not set
593
# CONFIG_ATM_HE is not set
594
595
#
601
# Amateur Radio support
596
# Amateur Radio support
602
#
597
#
603
# CONFIG_HAMRADIO is not set
598
# CONFIG_HAMRADIO is not set
Lines 606-623 Link Here
606
# IrDA (infrared) support
601
# IrDA (infrared) support
607
#
602
#
608
CONFIG_IRDA=m
603
CONFIG_IRDA=m
609
610
#
611
# IrDA protocols
612
#
613
CONFIG_IRLAN=m
604
CONFIG_IRLAN=m
614
CONFIG_IRNET=m
605
CONFIG_IRNET=m
615
CONFIG_IRCOMM=m
606
CONFIG_IRCOMM=m
616
# CONFIG_IRDA_ULTRA is not set
607
CONFIG_IRDA_ULTRA=y
617
618
#
619
# IrDA options
620
#
621
CONFIG_IRDA_CACHE_LAST_LSAP=y
608
CONFIG_IRDA_CACHE_LAST_LSAP=y
622
CONFIG_IRDA_FAST_RR=y
609
CONFIG_IRDA_FAST_RR=y
623
# CONFIG_IRDA_DEBUG is not set
610
# CONFIG_IRDA_DEBUG is not set
Lines 625-645 Link Here
625
#
612
#
626
# Infrared-port device drivers
613
# Infrared-port device drivers
627
#
614
#
628
629
#
630
# SIR device drivers
631
#
632
CONFIG_IRTTY_SIR=m
615
CONFIG_IRTTY_SIR=m
633
# CONFIG_IRPORT_SIR is not set
616
CONFIG_IRPORT_SIR=m
634
635
#
636
# Dongle support
637
#
638
# CONFIG_DONGLE is not set
617
# CONFIG_DONGLE is not set
639
640
#
641
# FIR device drivers
642
#
643
# CONFIG_USB_IRDA is not set
618
# CONFIG_USB_IRDA is not set
644
# CONFIG_NSC_FIR is not set
619
# CONFIG_NSC_FIR is not set
645
# CONFIG_WINBOND_FIR is not set
620
# CONFIG_WINBOND_FIR is not set
Lines 652-658 Link Here
652
#
627
#
653
# ISDN subsystem
628
# ISDN subsystem
654
#
629
#
655
# CONFIG_ISDN is not set
630
CONFIG_ISDN=m
631
CONFIG_ISDN_BOOL=y
632
CONFIG_ISDN_PPP=y
633
# CONFIG_IPPP_FILTER is not set
634
CONFIG_ISDN_PPP_VJ=y
635
CONFIG_ISDN_MPP=y
636
CONFIG_ISDN_PPP_BSDCOMP=m
637
# CONFIG_ISDN_AUDIO is not set
638
639
#
640
# ISDN feature submodules
641
#
642
# CONFIG_ISDN_DRV_LOOP is not set
643
# CONFIG_ISDN_DIVERSION is not set
644
645
#
646
# Passive ISDN cards
647
#
648
CONFIG_ISDN_DRV_HISAX=m
649
CONFIG_ISDN_HISAX=y
650
# CONFIG_HISAX_EURO is not set
651
# CONFIG_HISAX_1TR6 is not set
652
# CONFIG_HISAX_NI1 is not set
653
CONFIG_HISAX_MAX_CARDS=8
654
# CONFIG_HISAX_TELESPCI is not set
655
# CONFIG_HISAX_S0BOX is not set
656
# CONFIG_HISAX_FRITZPCI is not set
657
# CONFIG_HISAX_AVM_A1_PCMCIA is not set
658
# CONFIG_HISAX_ELSA is not set
659
# CONFIG_HISAX_DIEHLDIVA is not set
660
# CONFIG_HISAX_SEDLBAUER is not set
661
# CONFIG_HISAX_NETJET is not set
662
# CONFIG_HISAX_NETJET_U is not set
663
# CONFIG_HISAX_NICCY is not set
664
# CONFIG_HISAX_BKM_A4T is not set
665
# CONFIG_HISAX_SCT_QUADRO is not set
666
CONFIG_HISAX_GAZEL=y
667
# CONFIG_HISAX_HFC_PCI is not set
668
# CONFIG_HISAX_W6692 is not set
669
# CONFIG_HISAX_HFC_SX is not set
670
# CONFIG_HISAX_ENTERNOW_PCI is not set
671
# CONFIG_HISAX_DEBUG is not set
672
# CONFIG_HISAX_SEDLBAUER_CS is not set
673
# CONFIG_HISAX_ELSA_CS is not set
674
# CONFIG_HISAX_AVM_A1_CS is not set
675
CONFIG_HISAX_ST5481=m
676
# CONFIG_HISAX_FRITZ_PCIPNP is not set
677
# CONFIG_USB_AUERISDN is not set
678
679
#
680
# Active ISDN cards
681
#
682
# CONFIG_ISDN_DRV_ICN is not set
683
# CONFIG_ISDN_DRV_PCBIT is not set
684
# CONFIG_ISDN_DRV_SC is not set
685
# CONFIG_ISDN_DRV_ACT2000 is not set
686
# CONFIG_ISDN_DRV_EICON is not set
687
# CONFIG_ISDN_DRV_TPAM is not set
688
# CONFIG_ISDN_CAPI is not set
689
# CONFIG_HYSDN is not set
690
# CONFIG_HYSDN_CAPI is not set
656
691
657
#
692
#
658
# Old CD-ROM drivers (not SCSI, not IDE)
693
# Old CD-ROM drivers (not SCSI, not IDE)
Lines 669-675 Link Here
669
#
704
#
670
CONFIG_FB=y
705
CONFIG_FB=y
671
CONFIG_DUMMY_CONSOLE=y
706
CONFIG_DUMMY_CONSOLE=y
672
# CONFIG_FB_RIVA is not set
707
CONFIG_FB_RIVA=y
673
# CONFIG_FB_CLGEN is not set
708
# CONFIG_FB_CLGEN is not set
674
# CONFIG_FB_PM2 is not set
709
# CONFIG_FB_PM2 is not set
675
# CONFIG_FB_PM3 is not set
710
# CONFIG_FB_PM3 is not set
Lines 682-697 Link Here
682
CONFIG_FB_IMSTT=y
717
CONFIG_FB_IMSTT=y
683
# CONFIG_FB_S3TRIO is not set
718
# CONFIG_FB_S3TRIO is not set
684
# CONFIG_FB_VGA16 is not set
719
# CONFIG_FB_VGA16 is not set
685
CONFIG_FB_MATROX=y
720
# CONFIG_FB_MATROX is not set
686
CONFIG_FB_MATROX_MILLENIUM=y
687
CONFIG_FB_MATROX_MYSTIQUE=y
688
# CONFIG_FB_MATROX_G450 is not set
689
CONFIG_FB_MATROX_G100A=y
690
CONFIG_FB_MATROX_G100=y
691
# CONFIG_FB_MATROX_I2C is not set
692
# CONFIG_FB_MATROX_MAVEN is not set
693
CONFIG_FB_MATROX_PROC=y
694
# CONFIG_FB_MATROX_MULTIHEAD is not set
695
CONFIG_FB_ATY=y
721
CONFIG_FB_ATY=y
696
CONFIG_FB_ATY_GX=y
722
CONFIG_FB_ATY_GX=y
697
CONFIG_FB_ATY_CT=y
723
CONFIG_FB_ATY_CT=y
Lines 742-752 Link Here
742
CONFIG_PMAC_BACKLIGHT=y
768
CONFIG_PMAC_BACKLIGHT=y
743
CONFIG_MAC_FLOPPY=y
769
CONFIG_MAC_FLOPPY=y
744
CONFIG_MAC_SERIAL=y
770
CONFIG_MAC_SERIAL=y
745
# CONFIG_SERIAL_CONSOLE is not set
771
CONFIG_SERIAL_CONSOLE=y
746
CONFIG_ADB=y
772
CONFIG_ADB=y
747
CONFIG_ADB_MACIO=y
773
CONFIG_ADB_MACIO=y
748
CONFIG_INPUT_ADBHID=y
774
CONFIG_INPUT_ADBHID=y
749
CONFIG_MAC_ADBKEYCODES=y
775
# CONFIG_MAC_ADBKEYCODES is not set
750
CONFIG_MAC_EMUMOUSEBTN=y
776
CONFIG_MAC_EMUMOUSEBTN=y
751
CONFIG_MAC_HID=y
777
CONFIG_MAC_HID=y
752
# CONFIG_ANSLCD is not set
778
# CONFIG_ANSLCD is not set
Lines 761-776 Link Here
761
# CONFIG_SERIAL_NONSTANDARD is not set
787
# CONFIG_SERIAL_NONSTANDARD is not set
762
CONFIG_UNIX98_PTYS=y
788
CONFIG_UNIX98_PTYS=y
763
CONFIG_UNIX98_PTY_COUNT=256
789
CONFIG_UNIX98_PTY_COUNT=256
790
# CONFIG_BRIQ_PANEL is not set
764
791
765
#
792
#
766
# I2C support
793
# I2C support
767
#
794
#
768
CONFIG_I2C=m
795
CONFIG_I2C=y
769
# CONFIG_I2C_ALGOBIT is not set
796
# CONFIG_I2C_ALGOBIT is not set
770
# CONFIG_I2C_ALGOPCF is not set
797
# CONFIG_I2C_ALGOPCF is not set
771
CONFIG_I2C_KEYWEST=m
798
CONFIG_I2C_KEYWEST=y
772
CONFIG_I2C_CHARDEV=m
799
CONFIG_I2C_CHARDEV=y
773
CONFIG_I2C_PROC=m
800
CONFIG_I2C_PROC=y
774
801
775
#
802
#
776
# Mice
803
# Mice
Lines 796-805 Link Here
796
# CONFIG_INPUT_EMU10K1 is not set
823
# CONFIG_INPUT_EMU10K1 is not set
797
# CONFIG_INPUT_SERIO is not set
824
# CONFIG_INPUT_SERIO is not set
798
# CONFIG_INPUT_SERPORT is not set
825
# CONFIG_INPUT_SERPORT is not set
799
800
#
801
# Joysticks
802
#
803
# CONFIG_INPUT_ANALOG is not set
826
# CONFIG_INPUT_ANALOG is not set
804
# CONFIG_INPUT_A3D is not set
827
# CONFIG_INPUT_A3D is not set
805
# CONFIG_INPUT_ADI is not set
828
# CONFIG_INPUT_ADI is not set
Lines 842-865 Link Here
842
# Ftape, the floppy tape device driver
865
# Ftape, the floppy tape device driver
843
#
866
#
844
# CONFIG_FTAPE is not set
867
# CONFIG_FTAPE is not set
845
# CONFIG_AGP is not set
868
CONFIG_AGP=m
869
# CONFIG_AGP_INTEL is not set
870
# CONFIG_AGP_I810 is not set
871
# CONFIG_AGP_VIA is not set
872
# CONFIG_AGP_AMD is not set
873
# CONFIG_AGP_AMD_8151 is not set
874
# CONFIG_AGP_SIS is not set
875
# CONFIG_AGP_ALI is not set
876
# CONFIG_AGP_SWORKS is not set
877
CONFIG_AGP_UNINORTH=y
846
# CONFIG_DRM is not set
878
# CONFIG_DRM is not set
847
879
848
#
880
#
849
# PCMCIA character devices
881
# PCMCIA character devices
850
#
882
#
851
# CONFIG_PCMCIA_SERIAL_CS is not set
883
CONFIG_PCMCIA_SERIAL_CS=m
852
# CONFIG_SYNCLINK_CS is not set
884
# CONFIG_SYNCLINK_CS is not set
853
885
854
#
886
#
855
# Multimedia devices
887
# Multimedia devices
856
#
888
#
857
# CONFIG_VIDEO_DEV is not set
889
CONFIG_VIDEO_DEV=m
890
891
#
892
# Video For Linux
893
#
894
# CONFIG_VIDEO_PROC_FS is not set
895
# CONFIG_I2C_PARPORT is not set
896
# CONFIG_VIDEO_BT848 is not set
897
# CONFIG_VIDEO_PMS is not set
898
CONFIG_VIDEO_PLANB=m
899
# CONFIG_VIDEO_CPIA is not set
900
# CONFIG_VIDEO_SAA5249 is not set
901
# CONFIG_TUNER_3036 is not set
902
# CONFIG_VIDEO_STRADIS is not set
903
# CONFIG_VIDEO_ZORAN is not set
904
# CONFIG_VIDEO_ZORAN_BUZ is not set
905
# CONFIG_VIDEO_ZORAN_DC10 is not set
906
# CONFIG_VIDEO_ZORAN_LML33 is not set
907
# CONFIG_VIDEO_ZR36120 is not set
908
# CONFIG_VIDEO_MEYE is not set
909
910
#
911
# Radio Adapters
912
#
913
# CONFIG_RADIO_GEMTEK_PCI is not set
914
# CONFIG_RADIO_MAXIRADIO is not set
915
# CONFIG_RADIO_MAESTRO is not set
916
# CONFIG_RADIO_MIROPCM20 is not set
858
917
859
#
918
#
860
# File systems
919
# File systems
861
#
920
#
862
# CONFIG_QUOTA is not set
921
# CONFIG_QUOTA is not set
922
# CONFIG_QFMT_V2 is not set
863
# CONFIG_AUTOFS_FS is not set
923
# CONFIG_AUTOFS_FS is not set
864
# CONFIG_AUTOFS4_FS is not set
924
# CONFIG_AUTOFS4_FS is not set
865
# CONFIG_REISERFS_FS is not set
925
# CONFIG_REISERFS_FS is not set
Lines 869-874 Link Here
869
# CONFIG_ADFS_FS_RW is not set
929
# CONFIG_ADFS_FS_RW is not set
870
# CONFIG_AFFS_FS is not set
930
# CONFIG_AFFS_FS is not set
871
CONFIG_HFS_FS=m
931
CONFIG_HFS_FS=m
932
CONFIG_HFSPLUS_FS=m
872
# CONFIG_BEFS_FS is not set
933
# CONFIG_BEFS_FS is not set
873
# CONFIG_BEFS_DEBUG is not set
934
# CONFIG_BEFS_DEBUG is not set
874
# CONFIG_BFS_FS is not set
935
# CONFIG_BFS_FS is not set
Lines 897-903 Link Here
897
# CONFIG_NTFS_RW is not set
958
# CONFIG_NTFS_RW is not set
898
# CONFIG_HPFS_FS is not set
959
# CONFIG_HPFS_FS is not set
899
CONFIG_PROC_FS=y
960
CONFIG_PROC_FS=y
900
CONFIG_DEVFS_FS=y
961
# CONFIG_DEVFS_FS is not set
901
# CONFIG_DEVFS_MOUNT is not set
962
# CONFIG_DEVFS_MOUNT is not set
902
# CONFIG_DEVFS_DEBUG is not set
963
# CONFIG_DEVFS_DEBUG is not set
903
CONFIG_DEVPTS_FS=y
964
CONFIG_DEVPTS_FS=y
Lines 918-923 Link Here
918
# CONFIG_INTERMEZZO_FS is not set
979
# CONFIG_INTERMEZZO_FS is not set
919
CONFIG_NFS_FS=y
980
CONFIG_NFS_FS=y
920
# CONFIG_NFS_V3 is not set
981
# CONFIG_NFS_V3 is not set
982
# CONFIG_NFS_DIRECTIO is not set
921
# CONFIG_ROOT_NFS is not set
983
# CONFIG_ROOT_NFS is not set
922
CONFIG_NFSD=y
984
CONFIG_NFSD=y
923
# CONFIG_NFSD_V3 is not set
985
# CONFIG_NFSD_V3 is not set
Lines 963-969 Link Here
963
# Native Language Support
1025
# Native Language Support
964
#
1026
#
965
CONFIG_NLS_DEFAULT="iso8859-1"
1027
CONFIG_NLS_DEFAULT="iso8859-1"
966
# CONFIG_NLS_CODEPAGE_437 is not set
1028
CONFIG_NLS_CODEPAGE_437=m
967
# CONFIG_NLS_CODEPAGE_737 is not set
1029
# CONFIG_NLS_CODEPAGE_737 is not set
968
# CONFIG_NLS_CODEPAGE_775 is not set
1030
# CONFIG_NLS_CODEPAGE_775 is not set
969
# CONFIG_NLS_CODEPAGE_850 is not set
1031
# CONFIG_NLS_CODEPAGE_850 is not set
Lines 999-1005 Link Here
999
# CONFIG_NLS_ISO8859_15 is not set
1061
# CONFIG_NLS_ISO8859_15 is not set
1000
# CONFIG_NLS_KOI8_R is not set
1062
# CONFIG_NLS_KOI8_R is not set
1001
# CONFIG_NLS_KOI8_U is not set
1063
# CONFIG_NLS_KOI8_U is not set
1002
# CONFIG_NLS_UTF8 is not set
1064
CONFIG_NLS_UTF8=m
1003
1065
1004
#
1066
#
1005
# Sound
1067
# Sound
Lines 1007-1014 Link Here
1007
CONFIG_SOUND=m
1069
CONFIG_SOUND=m
1008
CONFIG_DMASOUND_PMAC=m
1070
CONFIG_DMASOUND_PMAC=m
1009
CONFIG_DMASOUND=m
1071
CONFIG_DMASOUND=m
1010
CONFIG_I2C=m
1011
CONFIG_I2C_KEYWEST=m
1012
# CONFIG_SOUND_ALI5455 is not set
1072
# CONFIG_SOUND_ALI5455 is not set
1013
# CONFIG_SOUND_BT878 is not set
1073
# CONFIG_SOUND_BT878 is not set
1014
# CONFIG_SOUND_CMPCI is not set
1074
# CONFIG_SOUND_CMPCI is not set
Lines 1038-1119 Link Here
1038
#
1098
#
1039
CONFIG_USB=y
1099
CONFIG_USB=y
1040
# CONFIG_USB_DEBUG is not set
1100
# CONFIG_USB_DEBUG is not set
1041
1042
#
1043
# Miscellaneous USB options
1044
#
1045
CONFIG_USB_DEVICEFS=y
1101
CONFIG_USB_DEVICEFS=y
1046
# CONFIG_USB_BANDWIDTH is not set
1102
# CONFIG_USB_BANDWIDTH is not set
1047
1048
#
1049
# USB Host Controller Drivers
1050
#
1051
# CONFIG_USB_EHCI_HCD is not set
1103
# CONFIG_USB_EHCI_HCD is not set
1052
# CONFIG_USB_UHCI is not set
1104
# CONFIG_USB_UHCI is not set
1053
# CONFIG_USB_UHCI_ALT is not set
1105
# CONFIG_USB_UHCI_ALT is not set
1054
CONFIG_USB_OHCI=y
1106
CONFIG_USB_OHCI=y
1055
1107
CONFIG_USB_AUDIO=m
1056
#
1057
# USB Device Class drivers
1058
#
1059
# CONFIG_USB_AUDIO is not set
1060
# CONFIG_USB_EMI26 is not set
1108
# CONFIG_USB_EMI26 is not set
1061
# CONFIG_USB_BLUETOOTH is not set
1109
# CONFIG_USB_BLUETOOTH is not set
1062
# CONFIG_USB_MIDI is not set
1110
# CONFIG_USB_MIDI is not set
1063
# CONFIG_USB_STORAGE is not set
1111
CONFIG_USB_STORAGE=m
1064
# CONFIG_USB_STORAGE_DEBUG is not set
1112
CONFIG_USB_STORAGE_DEBUG=y
1065
# CONFIG_USB_STORAGE_DATAFAB is not set
1113
CONFIG_USB_STORAGE_DATAFAB=y
1066
# CONFIG_USB_STORAGE_FREECOM is not set
1114
CONFIG_USB_STORAGE_FREECOM=y
1067
# CONFIG_USB_STORAGE_ISD200 is not set
1115
CONFIG_USB_STORAGE_ISD200=y
1068
# CONFIG_USB_STORAGE_DPCM is not set
1116
CONFIG_USB_STORAGE_DPCM=y
1069
# CONFIG_USB_STORAGE_HP8200e is not set
1117
CONFIG_USB_STORAGE_HP8200e=y
1070
# CONFIG_USB_STORAGE_SDDR09 is not set
1118
CONFIG_USB_STORAGE_SDDR09=y
1071
# CONFIG_USB_STORAGE_SDDR55 is not set
1119
CONFIG_USB_STORAGE_SDDR55=y
1072
# CONFIG_USB_STORAGE_JUMPSHOT is not set
1120
CONFIG_USB_STORAGE_JUMPSHOT=y
1073
CONFIG_USB_ACM=m
1121
CONFIG_USB_ACM=m
1074
CONFIG_USB_PRINTER=m
1122
CONFIG_USB_PRINTER=m
1075
1076
#
1077
# USB Human Interface Devices (HID)
1078
#
1079
CONFIG_USB_HID=y
1123
CONFIG_USB_HID=y
1080
CONFIG_USB_HIDINPUT=y
1124
CONFIG_USB_HIDINPUT=y
1081
# CONFIG_USB_HIDDEV is not set
1125
CONFIG_USB_HIDDEV=y
1082
# CONFIG_USB_AIPTEK is not set
1126
# CONFIG_USB_AIPTEK is not set
1083
# CONFIG_USB_WACOM is not set
1127
# CONFIG_USB_WACOM is not set
1084
# CONFIG_USB_KBTAB is not set
1128
# CONFIG_USB_KBTAB is not set
1085
# CONFIG_USB_POWERMATE is not set
1129
# CONFIG_USB_POWERMATE is not set
1086
1087
#
1088
# USB Imaging devices
1089
#
1090
# CONFIG_USB_DC2XX is not set
1130
# CONFIG_USB_DC2XX is not set
1091
# CONFIG_USB_MDC800 is not set
1131
# CONFIG_USB_MDC800 is not set
1092
CONFIG_USB_SCANNER=m
1132
CONFIG_USB_SCANNER=m
1093
# CONFIG_USB_MICROTEK is not set
1133
# CONFIG_USB_MICROTEK is not set
1094
# CONFIG_USB_HPUSBSCSI is not set
1134
# CONFIG_USB_HPUSBSCSI is not set
1095
1135
# CONFIG_USB_IBMCAM is not set
1096
#
1136
# CONFIG_USB_KONICAWC is not set
1097
# USB Multimedia devices
1137
CONFIG_USB_OV511=m
1098
#
1138
CONFIG_USB_PWC=m
1099
1139
# CONFIG_USB_SE401 is not set
1100
#
1140
# CONFIG_USB_STV680 is not set
1101
#   Video4Linux support is needed for USB Multimedia device support
1141
# CONFIG_USB_VICAM is not set
1102
#
1142
# CONFIG_USB_DSBR is not set
1103
1143
# CONFIG_USB_DABUSB is not set
1104
#
1105
# USB Network adaptors
1106
#
1107
# CONFIG_USB_PEGASUS is not set
1144
# CONFIG_USB_PEGASUS is not set
1108
# CONFIG_USB_RTL8150 is not set
1145
# CONFIG_USB_RTL8150 is not set
1109
# CONFIG_USB_KAWETH is not set
1146
# CONFIG_USB_KAWETH is not set
1110
# CONFIG_USB_CATC is not set
1147
# CONFIG_USB_CATC is not set
1111
# CONFIG_USB_CDCETHER is not set
1148
# CONFIG_USB_AX8817X is not set
1149
CONFIG_USB_CDCETHER=m
1112
# CONFIG_USB_USBNET is not set
1150
# CONFIG_USB_USBNET is not set
1113
1114
#
1115
# USB port drivers
1116
#
1117
# CONFIG_USB_USS720 is not set
1151
# CONFIG_USB_USS720 is not set
1118
1152
1119
#
1153
#
Lines 1132-1139 Link Here
1132
# CONFIG_USB_SERIAL_IR is not set
1166
# CONFIG_USB_SERIAL_IR is not set
1133
# CONFIG_USB_SERIAL_EDGEPORT is not set
1167
# CONFIG_USB_SERIAL_EDGEPORT is not set
1134
# CONFIG_USB_SERIAL_EDGEPORT_TI is not set
1168
# CONFIG_USB_SERIAL_EDGEPORT_TI is not set
1135
# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
1169
CONFIG_USB_SERIAL_KEYSPAN_PDA=m
1136
# CONFIG_USB_SERIAL_KEYSPAN is not set
1170
CONFIG_USB_SERIAL_KEYSPAN=m
1171
CONFIG_USB_SERIAL_KEYSPAN_USA28=y
1172
CONFIG_USB_SERIAL_KEYSPAN_USA28X=y
1173
CONFIG_USB_SERIAL_KEYSPAN_USA28XA=y
1174
CONFIG_USB_SERIAL_KEYSPAN_USA28XB=y
1175
CONFIG_USB_SERIAL_KEYSPAN_USA19=y
1176
CONFIG_USB_SERIAL_KEYSPAN_USA18X=y
1177
CONFIG_USB_SERIAL_KEYSPAN_USA19W=y
1178
CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y
1179
CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y
1180
CONFIG_USB_SERIAL_KEYSPAN_MPR=y
1181
CONFIG_USB_SERIAL_KEYSPAN_USA49W=y
1182
CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y
1137
# CONFIG_USB_SERIAL_MCT_U232 is not set
1183
# CONFIG_USB_SERIAL_MCT_U232 is not set
1138
# CONFIG_USB_SERIAL_KLSI is not set
1184
# CONFIG_USB_SERIAL_KLSI is not set
1139
# CONFIG_USB_SERIAL_KOBIL_SCT is not set
1185
# CONFIG_USB_SERIAL_KOBIL_SCT is not set
Lines 1141-1155 Link Here
1141
# CONFIG_USB_SERIAL_CYBERJACK is not set
1187
# CONFIG_USB_SERIAL_CYBERJACK is not set
1142
# CONFIG_USB_SERIAL_XIRCOM is not set
1188
# CONFIG_USB_SERIAL_XIRCOM is not set
1143
# CONFIG_USB_SERIAL_OMNINET is not set
1189
# CONFIG_USB_SERIAL_OMNINET is not set
1144
1145
#
1146
# USB Miscellaneous drivers
1147
#
1148
# CONFIG_USB_RIO500 is not set
1190
# CONFIG_USB_RIO500 is not set
1149
# CONFIG_USB_AUERSWALD is not set
1191
# CONFIG_USB_AUERSWALD is not set
1150
# CONFIG_USB_TIGL is not set
1192
# CONFIG_USB_TIGL is not set
1151
# CONFIG_USB_BRLVGER is not set
1193
# CONFIG_USB_BRLVGER is not set
1152
# CONFIG_USB_LCD is not set
1194
# CONFIG_USB_LCD is not set
1195
# CONFIG_USB_SPEEDTOUCH is not set
1153
1196
1154
#
1197
#
1155
# Bluetooth support
1198
# Bluetooth support
Lines 1157-1164 Link Here
1157
# CONFIG_BLUEZ is not set
1200
# CONFIG_BLUEZ is not set
1158
1201
1159
#
1202
#
1203
# Cryptographic options
1204
#
1205
# CONFIG_CRYPTO is not set
1206
1207
#
1160
# Library routines
1208
# Library routines
1161
#
1209
#
1210
# CONFIG_CRC32 is not set
1162
CONFIG_ZLIB_INFLATE=y
1211
CONFIG_ZLIB_INFLATE=y
1163
CONFIG_ZLIB_DEFLATE=y
1212
CONFIG_ZLIB_DEFLATE=y
1164
1213
Lines 1171-1177 Link Here
1171
# CONFIG_DEBUG_SLAB is not set
1220
# CONFIG_DEBUG_SLAB is not set
1172
# CONFIG_DEBUG_WAITQ is not set
1221
# CONFIG_DEBUG_WAITQ is not set
1173
# CONFIG_KGDB is not set
1222
# CONFIG_KGDB is not set
1174
CONFIG_XMON=y
1223
# CONFIG_XMON is not set
1175
# CONFIG_BDI_SWITCH is not set
1224
# CONFIG_BDI_SWITCH is not set
1176
# CONFIG_MORE_COMPILE_OPTIONS is not set
1177
CONFIG_BOOTX_TEXT=y
1225
CONFIG_BOOTX_TEXT=y
(-)linux-2.4.22/arch/ppc/kernel/Makefile (-1 / +1 lines)
Lines 45-51 Link Here
45
obj-$(CONFIG_PCI)		+= pci-dma.o
45
obj-$(CONFIG_PCI)		+= pci-dma.o
46
obj-$(CONFIG_KGDB)		+= ppc-stub.o
46
obj-$(CONFIG_KGDB)		+= ppc-stub.o
47
obj-$(CONFIG_PPCBUG_NVRAM)	+= prep_nvram.o
47
obj-$(CONFIG_PPCBUG_NVRAM)	+= prep_nvram.o
48
obj-$(CONFIG_SMP)		+= smp.o
48
obj-$(CONFIG_SMP)		+= smp.o smp-tbsync.o
49
obj-$(CONFIG_TAU)		+= temp.o
49
obj-$(CONFIG_TAU)		+= temp.o
50
ifeq ($(CONFIG_SERIAL)$(CONFIG_GEN550),yy)
50
ifeq ($(CONFIG_SERIAL)$(CONFIG_GEN550),yy)
51
obj-$(CONFIG_KGDB)		+= gen550_kgdb.o gen550_dbg.o
51
obj-$(CONFIG_KGDB)		+= gen550_kgdb.o gen550_dbg.o
(-)linux-2.4.22/arch/ppc/kernel/btext.c (-11 / +3 lines)
Lines 42-63 Link Here
42
static unsigned char vga_font[cmapsz];
42
static unsigned char vga_font[cmapsz];
43
43
44
int boot_text_mapped;
44
int boot_text_mapped;
45
int force_printk_to_btext;
45
46
46
boot_infos_t disp_bi;
47
boot_infos_t disp_bi;
47
48
48
extern char *klimit;
49
extern char *klimit;
49
50
50
/*
51
#define BTEXT
51
 * Powermac can use btext_* after boot for xmon,
52
#define BTDATA
52
 * chrp only uses it during early boot.
53
 */
54
#ifdef CONFIG_XMON
55
#define BTEXT	__pmac
56
#define BTDATA	__pmacdata
57
#else
58
#define BTEXT	__init
59
#define BTDATA	__initdata
60
#endif /* CONFIG_XMON */
61
53
62
/*
54
/*
63
 * This is called only when we are booted via BootX.
55
 * This is called only when we are booted via BootX.
(-)linux-2.4.22/arch/ppc/kernel/entry.S (+6 lines)
Lines 258-263 Link Here
258
	addi	r1,r1,INT_FRAME_SIZE
258
	addi	r1,r1,INT_FRAME_SIZE
259
	blr
259
	blr
260
260
261
       .globl  syscall_direct_return
262
syscall_direct_return:
263
       addi    r1,r3,-STACK_FRAME_OVERHEAD
264
       /* XXX should check syscall tracing here */
265
       b       ret_from_except
266
261
	.globl	ret_from_fork
267
	.globl	ret_from_fork
262
ret_from_fork:
268
ret_from_fork:
263
	bl	schedule_tail
269
	bl	schedule_tail
(-)linux-2.4.22/arch/ppc/kernel/head.S (-4 / +2 lines)
Lines 316-325 Link Here
316
#endif
316
#endif
317
317
318
/* Machine check */
318
/* Machine check */
319
BEGIN_FTR_SECTION
320
	DSSALL
321
	sync
322
END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
323
	STD_EXCEPTION(0x200, MachineCheck, MachineCheckException)
319
	STD_EXCEPTION(0x200, MachineCheck, MachineCheckException)
324
320
325
/* Data access exception. */
321
/* Data access exception. */
Lines 983-989 Link Here
983
	/* enable use of AltiVec after return */
979
	/* enable use of AltiVec after return */
984
	oris	r23,r23,MSR_VEC@h
980
	oris	r23,r23,MSR_VEC@h
985
	mfspr	r5,SPRG3		/* current task's THREAD (phys) */
981
	mfspr	r5,SPRG3		/* current task's THREAD (phys) */
982
	li	r4,1
986
	li	r20,THREAD_VSCR
983
	li	r20,THREAD_VSCR
984
	stw	r4,THREAD_USED_VR(r5)
987
	LVX(vr0,r20,r5)
985
	LVX(vr0,r20,r5)
988
	MTVSCR(vr0)
986
	MTVSCR(vr0)
989
	REST_32VR(0,r20,r5)
987
	REST_32VR(0,r20,r5)
(-)linux-2.4.22/arch/ppc/kernel/irq.c (-1 / +28 lines)
Lines 1-4 Link Here
1
/*
1
 /*
2
 *  arch/ppc/kernel/irq.c
2
 *  arch/ppc/kernel/irq.c
3
 *
3
 *
4
 *  Derived from arch/i386/kernel/irq.c
4
 *  Derived from arch/i386/kernel/irq.c
Lines 75-80 Link Here
75
unsigned long ppc_lost_interrupts[NR_MASK_WORDS];
75
unsigned long ppc_lost_interrupts[NR_MASK_WORDS];
76
atomic_t ppc_n_lost_interrupts;
76
atomic_t ppc_n_lost_interrupts;
77
77
78
#ifdef CONFIG_DEBUG_SPINLOCK
79
int debug_long_irqlock;
80
#endif /* CONFIG_DEBUG_SPINLOCK */
81
78
/* nasty hack for shared irq's since we need to do kmalloc calls but
82
/* nasty hack for shared irq's since we need to do kmalloc calls but
79
 * can't very early in the boot when we need to do a request irq.
83
 * can't very early in the boot when we need to do a request irq.
80
 * this needs to be removed.
84
 * this needs to be removed.
Lines 578-583 Link Here
578
	unsigned long *stack;
582
	unsigned long *stack;
579
	int cpu = smp_processor_id();
583
	int cpu = smp_processor_id();
580
584
585
#ifdef CONFIG_XMON
586
	xmon_printf("\n%s, CPU %d:\n", str, cpu);
587
	xmon_printf("irq:  %d [%d %d]\n",
588
	       atomic_read(&global_irq_count),
589
	       local_irq_count(0),
590
	       local_irq_count(1));
591
	xmon_printf("bh:   %d [%d %d]\n",
592
	       atomic_read(&global_bh_count),
593
	       local_bh_count(0),
594
	       local_bh_count(1));
595
	stack = (unsigned long *) &str;
596
	for (i = 40; i ; i--) {
597
		unsigned long x = *++stack;
598
		if (x > (unsigned long) &init_task_union && x < (unsigned long) &vsprintf) {
599
			xmon_printf("<[%08lx]> ", x);
600
		}
601
	}
602
#endif /* CONFIG_XMON */
581
	printk("\n%s, CPU %d:\n", str, cpu);
603
	printk("\n%s, CPU %d:\n", str, cpu);
582
	printk("irq:  %d [%d %d]\n",
604
	printk("irq:  %d [%d %d]\n",
583
	       atomic_read(&global_irq_count),
605
	       atomic_read(&global_irq_count),
Lines 662-667 Link Here
662
 */
684
 */
663
void synchronize_bh(void)
685
void synchronize_bh(void)
664
{
686
{
687
	smp_mb();
665
	if (atomic_read(&global_bh_count) && !in_interrupt())
688
	if (atomic_read(&global_bh_count) && !in_interrupt())
666
		wait_on_bh();
689
		wait_on_bh();
667
}
690
}
Lines 675-680 Link Here
675
 */
698
 */
676
void synchronize_irq(void)
699
void synchronize_irq(void)
677
{
700
{
701
	smp_mb();
678
	if (atomic_read(&global_irq_count)) {
702
	if (atomic_read(&global_irq_count)) {
679
		/* Stupid approach */
703
		/* Stupid approach */
680
		cli();
704
		cli();
Lines 694-699 Link Here
694
		do {
718
		do {
695
			do {
719
			do {
696
				if (loops-- == 0) {
720
				if (loops-- == 0) {
721
#ifdef CONFIG_XMON
722
					xmon_printf("get_irqlock(%d) waiting, global_irq_holder=%d\n", cpu, global_irq_holder);
723
#endif
697
					printk("get_irqlock(%d) waiting, global_irq_holder=%d\n", cpu, global_irq_holder);
724
					printk("get_irqlock(%d) waiting, global_irq_holder=%d\n", cpu, global_irq_holder);
698
#ifdef CONFIG_XMON
725
#ifdef CONFIG_XMON
699
					xmon(0);
726
					xmon(0);
(-)linux-2.4.22/arch/ppc/kernel/m8xx_setup.c (+1 lines)
Lines 43-48 Link Here
43
#include <asm/machdep.h>
43
#include <asm/machdep.h>
44
#include <asm/bootinfo.h>
44
#include <asm/bootinfo.h>
45
#include <asm/time.h>
45
#include <asm/time.h>
46
#include <asm/i8259.h>
46
47
47
#include "ppc8xx_pic.h"
48
#include "ppc8xx_pic.h"
48
49
(-)linux-2.4.22/arch/ppc/kernel/misc.S (+71 lines)
Lines 200-205 Link Here
200
	mr	r4,r24
200
	mr	r4,r24
201
	bctr
201
	bctr
202
202
203
#ifdef CONFIG_CPU_FREQ_PMAC
204
205
/* This gets called by via-pmu.c to switch the PLL selection
206
 * on 750fx CPU.
207
 */
208
_GLOBAL(low_choose_750fx_pll)
209
	/* Clear MSR:EE */
210
	mfmsr	r7
211
	rlwinm	r0,r7,0,17,15
212
	mtmsr	r0
213
214
	/* If switching to PLL1, disable HID0:BTIC */
215
	cmpli	cr0,r3,0
216
	beq	1f
217
	mfspr	r5,HID0
218
	rlwinm	r5,r5,0,27,25
219
	sync
220
	mtspr	HID0,r5
221
	isync
222
	sync
223
	
224
1:
225
	/* Calc new HID1 value */
226
	mfspr	r4,SPRN_HID1	/* Build a HID1:PS bit from parameter */
227
	rlwinm	r5,r3,16,15,15	/* Clear out HID1:PS from value read */
228
	rlwinm	r4,r4,0,16,14	/* Could have I used rlwimi here ? */
229
	or	r4,r4,r5
230
	mtspr	SPRN_HID1,r4
231
232
	/* Store new HID1 image */
233
	lwz	r6,PROCESSOR(r2)
234
	slwi	r6,r6,2
235
	addis	r6,r6,nap_save_hid1@ha
236
	stw	r4,nap_save_hid1@l(r6)
237
238
	/* If switching to PLL0, enable HID0:BTIC */
239
	cmpli	cr0,r3,0
240
	bne	1f
241
	mfspr	r5,HID0
242
	ori	r5,r5,HID0_BTIC
243
	sync
244
	mtspr	HID0,r5
245
	isync
246
	sync
247
	
248
1:	
249
	/* Return */		
250
	mtmsr	r7
251
	blr
252
253
#endif /* CONFIG_CPU_FREQ_PMAC */
254
255
203
/* void __save_flags_ptr(unsigned long *flags) */
256
/* void __save_flags_ptr(unsigned long *flags) */
204
_GLOBAL(__save_flags_ptr)
257
_GLOBAL(__save_flags_ptr)
205
	mfmsr	r4
258
	mfmsr	r4
Lines 1243-1248 Link Here
1243
	.long sys_ni_syscall 	/*	reserved for sys_io_getevents */
1296
	.long sys_ni_syscall 	/*	reserved for sys_io_getevents */
1244
	.long sys_ni_syscall 	/* 230	reserved for sys_io_submit */
1297
	.long sys_ni_syscall 	/* 230	reserved for sys_io_submit */
1245
	.long sys_ni_syscall 	/*	reserved for sys_io_cancel */
1298
	.long sys_ni_syscall 	/*	reserved for sys_io_cancel */
1299
	.long sys_ni_syscall	/*	reserved for sys_set_tid_address */
1300
	.long sys_ni_syscall	/*	reserved for sys_fadvise64 */
1301
	.long sys_ni_syscall	/*	reserved for sys_exit_group */
1302
	.long sys_ni_syscall	/* 235	reserved for sys_lookup_dcookie */
1303
	.long sys_ni_syscall	/*	reserved for sys_epoll_create */
1304
	.long sys_ni_syscall	/*	reserved for sys_epoll_ctl */
1305
	.long sys_ni_syscall	/*	reserved for sys_epoll_wait */
1306
	.long sys_ni_syscall	/*	reserved for sys_remap_file_pages */
1307
	.long sys_ni_syscall	/* 240	reserved for sys_timer_create */
1308
	.long sys_ni_syscall	/*	reserved for sys_timer_settime */
1309
	.long sys_ni_syscall	/*	reserved for sys_timer_gettime */
1310
	.long sys_ni_syscall	/*	reserved for sys_timer_getoverrun */
1311
	.long sys_ni_syscall	/*	reserved for sys_timer_delete */
1312
	.long sys_ni_syscall	/* 245	reserved for sys_clock_settime */
1313
	.long sys_ni_syscall	/*	reserved for sys_clock_gettime */
1314
	.long sys_ni_syscall	/*	reserved for sys_clock_getres */
1315
	.long sys_ni_syscall	/*	reserved for sys_clock_nanosleep */
1316
	.long sys_swapcontext
1246
1317
1247
	.rept NR_syscalls-(.-sys_call_table)/4
1318
	.rept NR_syscalls-(.-sys_call_table)/4
1248
		.long sys_ni_syscall
1319
		.long sys_ni_syscall
(-)linux-2.4.22/arch/ppc/kernel/mk_defs.c (+1 lines)
Lines 56-61 Link Here
56
	DEFINE(THREAD_VR0, offsetof(struct thread_struct, vr[0]));
56
	DEFINE(THREAD_VR0, offsetof(struct thread_struct, vr[0]));
57
	DEFINE(THREAD_VRSAVE, offsetof(struct thread_struct, vrsave));
57
	DEFINE(THREAD_VRSAVE, offsetof(struct thread_struct, vrsave));
58
	DEFINE(THREAD_VSCR, offsetof(struct thread_struct, vscr));
58
	DEFINE(THREAD_VSCR, offsetof(struct thread_struct, vscr));
59
	DEFINE(THREAD_USED_VR, offsetof(struct thread_struct, used_vr));
59
#endif /* CONFIG_ALTIVEC */
60
#endif /* CONFIG_ALTIVEC */
60
#ifdef CONFIG_4xx
61
#ifdef CONFIG_4xx
61
	DEFINE(THREAD_DBCR0, offsetof(struct thread_struct, dbcr0));
62
	DEFINE(THREAD_DBCR0, offsetof(struct thread_struct, dbcr0));
(-)linux-2.4.22/arch/ppc/kernel/open_pic.c (+17 lines)
Lines 870-875 Link Here
870
static u32 save_irq_src_dest[OPENPIC_MAX_SOURCES];
870
static u32 save_irq_src_dest[OPENPIC_MAX_SOURCES];
871
static u32 save_cpu_task_pri[OPENPIC_MAX_PROCESSORS];
871
static u32 save_cpu_task_pri[OPENPIC_MAX_PROCESSORS];
872
872
873
static void openpic_cached_enable_irq(u_int irq)
874
{
875
	check_arg_irq(irq);
876
	save_irq_src_vp[irq - open_pic_irq_offset] &= ~OPENPIC_MASK; 
877
}
878
879
static void openpic_cached_disable_irq(u_int irq)
880
{
881
	check_arg_irq(irq);
882
	save_irq_src_vp[irq - open_pic_irq_offset] |= OPENPIC_MASK; 
883
}
873
void __pmac
884
void __pmac
874
openpic_sleep_save_intrs(void)
885
openpic_sleep_save_intrs(void)
875
{
886
{
Lines 878-883 Link Here
878
889
879
	spin_lock_irqsave(&openpic_setup_lock, flags);
890
	spin_lock_irqsave(&openpic_setup_lock, flags);
880
891
892
	open_pic.enable = openpic_cached_enable_irq;
893
	open_pic.disable = openpic_cached_disable_irq;
894
881
	for (i=0; i<NumProcessors; i++) {
895
	for (i=0; i<NumProcessors; i++) {
882
		save_cpu_task_pri[i] = openpic_read(&OpenPIC->Processor[i].Current_Task_Priority);
896
		save_cpu_task_pri[i] = openpic_read(&OpenPIC->Processor[i].Current_Task_Priority);
883
		openpic_writefield(&OpenPIC->Processor[i].Current_Task_Priority,
897
		openpic_writefield(&OpenPIC->Processor[i].Current_Task_Priority,
Lines 921-926 Link Here
921
		openpic_write(&OpenPIC->Processor[i].Current_Task_Priority,
935
		openpic_write(&OpenPIC->Processor[i].Current_Task_Priority,
922
			      save_cpu_task_pri[i]);
936
			      save_cpu_task_pri[i]);
923
937
938
	open_pic.enable = openpic_enable_irq;
939
	open_pic.disable = openpic_disable_irq;
940
924
	spin_unlock_irqrestore(&openpic_setup_lock, flags);
941
	spin_unlock_irqrestore(&openpic_setup_lock, flags);
925
}
942
}
926
#endif /* CONFIG_PMAC_PBOOK */
943
#endif /* CONFIG_PMAC_PBOOK */
(-)linux-2.4.22/arch/ppc/kernel/pci.c (-5 / +18 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * Common pmac/prep/chrp pci routines. -- Cort
2
 * Common PCI code for PPC architecture
3
 */
3
 */
4
4
5
#include <linux/config.h>
5
#include <linux/config.h>
Lines 22-28 Link Here
22
#include <asm/irq.h>
22
#include <asm/irq.h>
23
#include <asm/uaccess.h>
23
#include <asm/uaccess.h>
24
24
25
#undef DEBUG
25
#define DEBUG
26
26
27
#ifdef DEBUG
27
#ifdef DEBUG
28
#define DBG(x...) printk(x)
28
#define DBG(x...) printk(x)
Lines 116-121 Link Here
116
	struct pci_controller* hose = dev->sysdata;
116
	struct pci_controller* hose = dev->sysdata;
117
	unsigned long io_offset;
117
	unsigned long io_offset;
118
118
119
	if (dev->vendor == PCI_VENDOR_ID_APPLE && dev->device == PCI_DEVICE_ID_APPLE_KEYLARGO) {
120
		printk("trying to reloc keylargo !! skipping\n");
121
		return;
122
	}
119
	new = res->start;
123
	new = res->start;
120
	res->flags &= ~IORESOURCE_UNSET;
124
	res->flags &= ~IORESOURCE_UNSET;
121
	if (hose && res->flags & IORESOURCE_IO) {
125
	if (hose && res->flags & IORESOURCE_IO) {
Lines 217-223 Link Here
217
	}
221
	}
218
	if (dev->device == PCI_DEVICE_ID_TI_1210 ||
222
	if (dev->device == PCI_DEVICE_ID_TI_1210 ||
219
	    dev->device == PCI_DEVICE_ID_TI_1211 ||
223
	    dev->device == PCI_DEVICE_ID_TI_1211 ||
220
	    dev->device == PCI_DEVICE_ID_TI_1410) {
224
	    dev->device == PCI_DEVICE_ID_TI_1410 ||
225
	    dev->device == PCI_DEVICE_ID_TI_1510) {
221
		u8 val;
226
		u8 val;
222
		/* 0x8c == TI122X_IRQMUX, 2 says to route the INTA
227
		/* 0x8c == TI122X_IRQMUX, 2 says to route the INTA
223
		   signal out the MFUNC0 pin */
228
		   signal out the MFUNC0 pin */
Lines 563-570 Link Here
563
{
568
{
564
	struct resource *pr, *r = &dev->resource[idx];
569
	struct resource *pr, *r = &dev->resource[idx];
565
570
566
	DBG("PCI:%s: Resource %d: %08lx-%08lx (f=%lx)\n",
571
	DBG("PCI:%s: Resource %d: %08lx-%08lx (f=%lx), vd: %04x, dev: %04x\n",
567
	    dev->slot_name, idx, r->start, r->end, r->flags);
572
	    dev->slot_name, idx, r->start, r->end, r->flags,
573
	    dev->vendor, dev->device);
568
	pr = pci_find_parent_resource(dev, r);
574
	pr = pci_find_parent_resource(dev, r);
569
	if (!pr || request_resource(pr, r) < 0) {
575
	if (!pr || request_resource(pr, r) < 0) {
570
		printk(KERN_ERR "PCI: Cannot allocate resource region %d"
576
		printk(KERN_ERR "PCI: Cannot allocate resource region %d"
Lines 1029-1034 Link Here
1029
		}
1035
		}
1030
		ranges += np;
1036
		ranges += np;
1031
	}
1037
	}
1038
	DBG("hose %s, pci_mem_offset: %08lx, start0: %08lx\n",
1039
		dev->name, hose->pci_mem_offset, hose->mem_resources[0].start);
1040
	DBG("  io_base_virt: %p, io_base_phys: %08lx, isa_mem_base: %08lx\n",
1041
		hose->io_base_virt, hose->io_base_phys, isa_mem_base);
1032
}
1042
}
1033
1043
1034
/* We create the "pci-OF-bus-map" property now so it appears in the
1044
/* We create the "pci-OF-bus-map" property now so it appears in the
Lines 1341-1346 Link Here
1341
	return PCI_SLOT(dev->devfn);
1351
	return PCI_SLOT(dev->devfn);
1342
}
1352
}
1343
1353
1354
/* Where does that come from ? Doesn't seem to be correct for us, but we
1355
 * don't use it anyway so ... -BenH.
1356
 */
1344
void __init
1357
void __init
1345
pcibios_fixup_pbus_ranges(struct pci_bus * bus, struct pbus_set_ranges_data * ranges)
1358
pcibios_fixup_pbus_ranges(struct pci_bus * bus, struct pbus_set_ranges_data * ranges)
1346
{
1359
{
(-)linux-2.4.22/arch/ppc/kernel/ppc_ksyms.c (-5 / +14 lines)
Lines 14-19 Link Here
14
#include <linux/irq.h>
14
#include <linux/irq.h>
15
#include <linux/pci.h>
15
#include <linux/pci.h>
16
#include <linux/delay.h>
16
#include <linux/delay.h>
17
#include <linux/vmalloc.h>
17
#include <linux/ide.h>
18
#include <linux/ide.h>
18
19
19
#include <asm/page.h>
20
#include <asm/page.h>
Lines 67-75 Link Here
67
extern int pmac_newworld;
68
extern int pmac_newworld;
68
extern int sys_sigreturn(struct pt_regs *regs);
69
extern int sys_sigreturn(struct pt_regs *regs);
69
70
70
long long __ashrdi3(long long, int);
71
extern long long __ashrdi3(long long, int);
71
long long __ashldi3(long long, int);
72
extern long long __ashldi3(long long, int);
72
long long __lshrdi3(long long, int);
73
extern long long __lshrdi3(long long, int);
74
73
int abs(int);
75
int abs(int);
74
76
75
extern unsigned char __res[];
77
extern unsigned char __res[];
Lines 128-134 Link Here
128
EXPORT_SYMBOL(strcmp);
130
EXPORT_SYMBOL(strcmp);
129
EXPORT_SYMBOL(strncmp);
131
EXPORT_SYMBOL(strncmp);
130
EXPORT_SYMBOL(strcasecmp);
132
EXPORT_SYMBOL(strcasecmp);
131
EXPORT_SYMBOL(__div64_32);
132
133
133
/* EXPORT_SYMBOL(csum_partial); already in net/netsyms.c */
134
/* EXPORT_SYMBOL(csum_partial); already in net/netsyms.c */
134
EXPORT_SYMBOL(csum_partial_copy_generic);
135
EXPORT_SYMBOL(csum_partial_copy_generic);
Lines 192-197 Link Here
192
EXPORT_SYMBOL(flush_icache_user_range);
193
EXPORT_SYMBOL(flush_icache_user_range);
193
EXPORT_SYMBOL(flush_icache_page);
194
EXPORT_SYMBOL(flush_icache_page);
194
EXPORT_SYMBOL(flush_dcache_page);
195
EXPORT_SYMBOL(flush_dcache_page);
196
EXPORT_SYMBOL(local_flush_tlb_page);
195
EXPORT_SYMBOL(xchg_u32);
197
EXPORT_SYMBOL(xchg_u32);
196
#ifdef CONFIG_ALTIVEC
198
#ifdef CONFIG_ALTIVEC
197
EXPORT_SYMBOL(last_task_used_altivec);
199
EXPORT_SYMBOL(last_task_used_altivec);
Lines 288-293 Link Here
288
EXPORT_SYMBOL_NOVERS(memscan);
290
EXPORT_SYMBOL_NOVERS(memscan);
289
EXPORT_SYMBOL_NOVERS(memcmp);
291
EXPORT_SYMBOL_NOVERS(memcmp);
290
EXPORT_SYMBOL_NOVERS(memchr);
292
EXPORT_SYMBOL_NOVERS(memchr);
293
EXPORT_SYMBOL_NOVERS(__div64_32);
291
294
292
EXPORT_SYMBOL(abs);
295
EXPORT_SYMBOL(abs);
293
296
Lines 314-320 Link Here
314
EXPORT_SYMBOL(get_wchan);
317
EXPORT_SYMBOL(get_wchan);
315
EXPORT_SYMBOL(console_drivers);
318
EXPORT_SYMBOL(console_drivers);
316
#ifdef CONFIG_XMON
319
#ifdef CONFIG_XMON
317
extern void xmon_printf(char *fmt, ...);
320
extern void xmon_printf(const char *fmt, ...);
318
EXPORT_SYMBOL(xmon);
321
EXPORT_SYMBOL(xmon);
319
EXPORT_SYMBOL(xmon_printf);
322
EXPORT_SYMBOL(xmon_printf);
320
#endif
323
#endif
Lines 367-373 Link Here
367
EXPORT_SYMBOL(ret_from_intercept);
370
EXPORT_SYMBOL(ret_from_intercept);
368
EXPORT_SYMBOL(cur_cpu_spec);
371
EXPORT_SYMBOL(cur_cpu_spec);
369
#if defined(CONFIG_ALL_PPC)
372
#if defined(CONFIG_ALL_PPC)
373
extern int map_page(unsigned long va, unsigned long pa, int flags);
374
375
EXPORT_SYMBOL(map_page);
376
EXPORT_SYMBOL(get_vm_area);
370
extern unsigned long agp_special_page;
377
extern unsigned long agp_special_page;
371
EXPORT_SYMBOL_NOVERS(agp_special_page);
378
EXPORT_SYMBOL_NOVERS(agp_special_page);
379
EXPORT_SYMBOL(ioremap_bot);
380
EXPORT_SYMBOL(local_flush_tlb_all);
372
#endif /* defined(CONFIG_ALL_PPC) */
381
#endif /* defined(CONFIG_ALL_PPC) */
373
382
(-)linux-2.4.22/arch/ppc/kernel/process.c (-3 / +9 lines)
Lines 417-422 Link Here
417
	memset(current->thread.vr, 0, sizeof(current->thread.vr));
417
	memset(current->thread.vr, 0, sizeof(current->thread.vr));
418
	memset(&current->thread.vscr, 0, sizeof(current->thread.vscr));
418
	memset(&current->thread.vscr, 0, sizeof(current->thread.vscr));
419
	current->thread.vrsave = 0;
419
	current->thread.vrsave = 0;
420
	current->thread.used_vr = 0;
420
#endif /* CONFIG_ALTIVEC */
421
#endif /* CONFIG_ALTIVEC */
421
}
422
}
422
423
Lines 506-519 Link Here
506
	if (sp == NULL)
507
	if (sp == NULL)
507
		asm("mr %0,1" : "=r" (sp));
508
		asm("mr %0,1" : "=r" (sp));
508
	printk("Call backtrace: ");
509
	printk("Call backtrace: ");
510
	if (sp == NULL)
511
		sp = (unsigned long *)_get_SP();
509
	while (sp) {
512
	while (sp) {
510
		if (__get_user( i, &sp[1] ))
513
		if (__get_user(sp, (unsigned long **)sp))
514
			break;
515
		if (sp == NULL)
516
			break;
517
		if (__get_user(i, &sp[1]))
511
			break;
518
			break;
512
		if (cnt++ % 7 == 0)
519
		if (cnt++ % 7 == 0)
513
			printk("\n");
520
			printk("\n");
514
		printk("%08lX ", i);
521
		printk("%08lX ", i);
515
		if (cnt > 32) break;
522
		if (cnt > 32)
516
		if (__get_user(sp, (unsigned long **)sp))
517
			break;
523
			break;
518
	}
524
	}
519
	printk("\n");
525
	printk("\n");
(-)linux-2.4.22/arch/ppc/kernel/semaphore.c (-8 / +7 lines)
Lines 73-81 Link Here
73
	struct task_struct *tsk = current;
73
	struct task_struct *tsk = current;
74
	DECLARE_WAITQUEUE(wait, tsk);
74
	DECLARE_WAITQUEUE(wait, tsk);
75
75
76
	tsk->state = TASK_UNINTERRUPTIBLE;
76
	__set_task_state(tsk, TASK_UNINTERRUPTIBLE);
77
	add_wait_queue_exclusive(&sem->wait, &wait);
77
	add_wait_queue_exclusive(&sem->wait, &wait);
78
	smp_wmb();
79
78
80
	/*
79
	/*
81
	 * Try to get the semaphore.  If the count is > 0, then we've
80
	 * Try to get the semaphore.  If the count is > 0, then we've
Lines 85-94 Link Here
85
	 */
84
	 */
86
	while (__sem_update_count(sem, -1) <= 0) {
85
	while (__sem_update_count(sem, -1) <= 0) {
87
		schedule();
86
		schedule();
88
		tsk->state = TASK_UNINTERRUPTIBLE;
87
		set_task_state(tsk, TASK_UNINTERRUPTIBLE);
89
	}
88
	}
90
	remove_wait_queue(&sem->wait, &wait);
89
	remove_wait_queue(&sem->wait, &wait);
91
	tsk->state = TASK_RUNNING;
90
	__set_task_state(tsk, TASK_RUNNING);
92
91
93
	/*
92
	/*
94
	 * If there are any more sleepers, wake one of them up so
93
	 * If there are any more sleepers, wake one of them up so
Lines 104-112 Link Here
104
	struct task_struct *tsk = current;
103
	struct task_struct *tsk = current;
105
	DECLARE_WAITQUEUE(wait, tsk);
104
	DECLARE_WAITQUEUE(wait, tsk);
106
105
107
	tsk->state = TASK_INTERRUPTIBLE;
106
	__set_task_state(tsk, TASK_INTERRUPTIBLE);
108
	add_wait_queue_exclusive(&sem->wait, &wait);
107
	add_wait_queue_exclusive(&sem->wait, &wait);
109
	smp_wmb();
110
108
111
	while (__sem_update_count(sem, -1) <= 0) {
109
	while (__sem_update_count(sem, -1) <= 0) {
112
		if (signal_pending(current)) {
110
		if (signal_pending(current)) {
Lines 120-129 Link Here
120
			break;
118
			break;
121
		}
119
		}
122
		schedule();
120
		schedule();
123
		tsk->state = TASK_INTERRUPTIBLE;
121
		set_task_state(tsk, TASK_INTERRUPTIBLE);
124
	}
122
	}
125
	tsk->state = TASK_RUNNING;
126
	remove_wait_queue(&sem->wait, &wait);
123
	remove_wait_queue(&sem->wait, &wait);
124
	__set_task_state(tsk, TASK_RUNNING);
125
	
127
	wake_up(&sem->wait);
126
	wake_up(&sem->wait);
128
	return retval;
127
	return retval;
129
}
128
}
(-)linux-2.4.22/arch/ppc/kernel/setup.c (-1 / +24 lines)
Lines 52-57 Link Here
52
struct ide_machdep_calls ppc_ide_md;
52
struct ide_machdep_calls ppc_ide_md;
53
char *sysmap;
53
char *sysmap;
54
unsigned long sysmap_size;
54
unsigned long sysmap_size;
55
int no_nap;
55
56
56
/* Used with the BI_MEMSIZE bootinfo parameter to store the memory
57
/* Used with the BI_MEMSIZE bootinfo parameter to store the memory
57
   size value reported by the boot loader. */
58
   size value reported by the boot loader. */
Lines 152-158 Link Here
152
		return 0;
153
		return 0;
153
	pvr = cpu_data[i].pvr;
154
	pvr = cpu_data[i].pvr;
154
	lpj = cpu_data[i].loops_per_jiffy;
155
	lpj = cpu_data[i].loops_per_jiffy;
155
	seq_printf(m, "processor\t: %lu\n", i);
156
	seq_printf(m, "processor\t: %u\n", i);
156
#else
157
#else
157
	pvr = mfspr(PVR);
158
	pvr = mfspr(PVR);
158
	lpj = loops_per_jiffy;
159
	lpj = loops_per_jiffy;
Lines 329-334 Link Here
329
	      unsigned long r6, unsigned long r7)
330
	      unsigned long r6, unsigned long r7)
330
{
331
{
331
#ifdef CONFIG_BOOTX_TEXT
332
#ifdef CONFIG_BOOTX_TEXT
333
	extern int force_printk_to_btext;
332
	if (boot_text_mapped) {
334
	if (boot_text_mapped) {
333
		btext_clearscreen();
335
		btext_clearscreen();
334
		btext_welcome();
336
		btext_welcome();
Lines 415-420 Link Here
415
	}
417
	}
416
	cmd_line[sizeof(cmd_line) - 1] = 0;
418
	cmd_line[sizeof(cmd_line) - 1] = 0;
417
419
420
	/* Debug stuff, do not merge ! */
421
#ifdef CONFIG_ADB_PMU
422
	if (strstr(cmd_line, "fake_sleep")) {
423
		extern int __fake_sleep;
424
		__fake_sleep = 1;
425
	}
426
#endif /* CONFIG_ADB_PMU */	
427
#ifdef CONFIG_ADB
428
	if (strstr(cmd_line, "adb_sync")) {
429
		extern int __adb_probe_sync;
430
		__adb_probe_sync = 1;
431
	}
432
#endif /* CONFIG_ADB */	
433
	if (strstr(cmd_line, "nol3") && cur_cpu_spec[0]->cpu_features & CPU_FTR_L3CR)
434
		_set_L3CR(0);
435
	if (strstr(cmd_line, "nonap"))
436
		cur_cpu_spec[0]->cpu_features &= ~CPU_FTR_CAN_NAP;
437
#ifdef CONFIG_BOOTX_TEXT
438
	if (strstr(cmd_line, "printkbtext"))
439
		force_printk_to_btext = 1;
440
#endif
418
	switch (_machine) {
441
	switch (_machine) {
419
	case _MACH_Pmac:
442
	case _MACH_Pmac:
420
		pmac_init(r3, r4, r5, r6, r7);
443
		pmac_init(r3, r4, r5, r6, r7);
(-)linux-2.4.22/arch/ppc/kernel/signal.c (-318 / +383 lines)
Lines 40-56 Link Here
40
40
41
#define GP_REGS_SIZE	MIN(sizeof(elf_gregset_t), sizeof(struct pt_regs))
41
#define GP_REGS_SIZE	MIN(sizeof(elf_gregset_t), sizeof(struct pt_regs))
42
42
43
/*
43
extern void syscall_direct_return(struct pt_regs *regs);
44
 * These are the flags in the MSR that the user is allowed to change
45
 * by modifying the saved value of the MSR on the stack.  SE and BE
46
 * should not be in this list since gdb may want to change these.  I.e,
47
 * you should be able to step out of a signal handler to see what
48
 * instruction executes next after the signal handler completes.
49
 * Alternately, if you stepped into a signal handler, you should be
50
 * able to continue 'til the next breakpoint from within the signal
51
 * handler, even if the handler returns.
52
 */
53
#define MSR_USERCHANGE	(MSR_FE0 | MSR_FE1)
54
44
55
int do_signal(sigset_t *oldset, struct pt_regs *regs);
45
int do_signal(sigset_t *oldset, struct pt_regs *regs);
56
46
Lines 117-123 Link Here
117
			 * do_signal() has set R3 to the signal number (the
107
			 * do_signal() has set R3 to the signal number (the
118
			 * first argument of the signal handler), so don't
108
			 * first argument of the signal handler), so don't
119
			 * overwrite that with EINTR !
109
			 * overwrite that with EINTR !
120
			 * In the other cases, do_signal() doesn't touch
110
			 * In the other cases, do_signal() doesn't touch 
121
			 * R3, so it's still set to -EINTR (see above).
111
			 * R3, so it's still set to -EINTR (see above).
122
			 */
112
			 */
123
			return regs->gpr[3];
113
			return regs->gpr[3];
Lines 157-169 Link Here
157
147
158
148
159
int
149
int
160
sys_sigaltstack(const stack_t *uss, stack_t *uoss)
150
sys_sigaltstack(const stack_t *uss, stack_t *uoss, int r5, int r6,
151
		int r7, int r8, struct pt_regs *regs)
161
{
152
{
162
	struct pt_regs *regs = (struct pt_regs *) &uss;
163
	return do_sigaltstack(uss, uoss, regs->gpr[1]);
153
	return do_sigaltstack(uss, uoss, regs->gpr[1]);
164
}
154
}
165
155
166
int
156
int 
167
sys_sigaction(int sig, const struct old_sigaction *act,
157
sys_sigaction(int sig, const struct old_sigaction *act,
168
	      struct old_sigaction *oact)
158
	      struct old_sigaction *oact)
169
{
159
{
Lines 199-468 Link Here
199
 * When we have signals to deliver, we set up on the
189
 * When we have signals to deliver, we set up on the
200
 * user stack, going down from the original stack pointer:
190
 * user stack, going down from the original stack pointer:
201
 *	a sigregs struct
191
 *	a sigregs struct
202
 *	one or more sigcontext structs with
192
 *	a sigcontext struct
203
 *	a gap of __SIGNAL_FRAMESIZE bytes
193
 *	a gap of __SIGNAL_FRAMESIZE bytes
204
 *
194
 *
205
 * Each of these things must be a multiple of 16 bytes in size.
195
 * Each of these things must be a multiple of 16 bytes in size.
206
 *
196
 *
207
 */
197
 */
208
struct sigregs {
198
struct sigregs {
209
	elf_gregset_t	gp_regs;
199
	struct mcontext	mctx;		/* all the register values */
210
	double		fp_regs[ELF_NFPREG];
211
	unsigned long	tramp[2];
212
	/* Programs using the rs6000/xcoff abi can save up to 19 gp regs
200
	/* Programs using the rs6000/xcoff abi can save up to 19 gp regs
213
	   and 18 fp regs below sp before decrementing it. */
201
	   and 18 fp regs below sp before decrementing it. */
214
	int		abigap[56];
202
	int		abigap[56];
215
};
203
};
216
204
217
struct rt_sigframe
205
/* We use the mc_pad field for the signal return trampoline. */
218
{
206
#define tramp	mc_pad
219
	unsigned long	_unused[2];
220
	struct siginfo *pinfo;
221
	void *puc;
222
	struct siginfo info;
223
	struct ucontext uc;
224
};
225
226
207
227
/*
208
/*
228
 *  When we have rt signals to deliver, we set up on the
209
 *  When we have rt signals to deliver, we set up on the
229
 *  user stack, going down from the original stack pointer:
210
 *  user stack, going down from the original stack pointer:
230
 *	   a sigregs struct
211
 *	one rt_sigframe struct (siginfo + ucontext + ABI gap)
231
 *	   one rt_sigframe struct (siginfo + ucontext)
212
 *	a gap of __SIGNAL_FRAMESIZE+16 bytes
232
 *	   a gap of __SIGNAL_FRAMESIZE bytes
213
 *  (the +16 is to get the siginfo and ucontext in the same
214
 *  positions as in older kernels).
233
 *
215
 *
234
 *  Each of these things must be a multiple of 16 bytes in size.
216
 *  Each of these things must be a multiple of 16 bytes in size.
235
 *
217
 *
236
 */
218
 */
237
int sys_rt_sigreturn(struct pt_regs *regs)
219
struct rt_sigframe
238
{
220
{
239
	struct rt_sigframe *rt_sf;
221
	struct siginfo info;
240
	struct sigcontext_struct sigctx;
222
	struct ucontext uc;
241
	struct sigregs *sr;
223
	/* Programs using the rs6000/xcoff abi can save up to 19 gp regs
242
	int ret;
224
	   and 18 fp regs below sp before decrementing it. */
243
	elf_gregset_t saved_regs;  /* an array of ELF_NGREG unsigned longs */
225
	int		abigap[56];
244
	sigset_t set;
226
};
245
	stack_t st;
246
	unsigned long prevsp;
247
227
248
	rt_sf = (struct rt_sigframe *)(regs->gpr[1] + __SIGNAL_FRAMESIZE);
228
/*
249
	if (copy_from_user(&sigctx, &rt_sf->uc.uc_mcontext, sizeof(sigctx))
229
 * Save the current user registers on the user stack.
250
	    || copy_from_user(&set, &rt_sf->uc.uc_sigmask, sizeof(set))
230
 * We only save the altivec registers if the process has used
251
	    || copy_from_user(&st, &rt_sf->uc.uc_stack, sizeof(st)))
231
 * altivec instructions at some point.
252
		goto badframe;
232
 */
253
	sigdelsetmask(&set, ~_BLOCKABLE);
233
static int
254
	spin_lock_irq(&current->sigmask_lock);
234
save_user_regs(struct pt_regs *regs, struct mcontext *frame, int sigret, int mctxsize)
255
	current->blocked = set;
235
{
256
	recalc_sigpending(current);
236
	if (mctxsize && mctxsize < sizeof(struct mcontext))
257
	spin_unlock_irq(&current->sigmask_lock);
237
		return 1;
238
239
	/* save general and floating-point registers */
258
	if (regs->msr & MSR_FP)
240
	if (regs->msr & MSR_FP)
259
		giveup_fpu(current);
241
		giveup_fpu(current);
242
	if (__copy_to_user(&frame->mc_gregs, regs, GP_REGS_SIZE)
243
	    || __copy_to_user(&frame->mc_fregs, current->thread.fpr,
244
			      ELF_NFPREG * sizeof(double)))
245
		return 1;
260
246
261
	rt_sf++;			/* Look at next rt_sigframe */
247
	current->thread.fpscr = 0;	/* turn off all fp exceptions */
262
	if (rt_sf == (struct rt_sigframe *)(sigctx.regs)) {
248
263
		/* Last stacked signal - restore registers -
249
#ifdef CONFIG_ALTIVEC
264
		 * sigctx is initialized to point to the
250
	/* save altivec registers */
265
		 * preamble frame (where registers are stored)
251
	if (current->thread.used_vr) {
266
		 * see handle_signal()
252
		if (regs->msr & MSR_VEC)
267
		 */
253
			giveup_altivec(current);
268
		sr = (struct sigregs *) sigctx.regs;
254
		if (__copy_to_user(&frame->mc_vregs, current->thread.vr,
269
		if (copy_from_user(saved_regs, &sr->gp_regs,
255
				   ELF_NVRREG * sizeof(vector128)))
270
				   sizeof(sr->gp_regs)))
256
			return 1;
271
			goto badframe;
257
		/* set MSR_VEC in the saved MSR value to indicate that
272
		saved_regs[PT_MSR] = (regs->msr & ~MSR_USERCHANGE)
258
		   frame->mc_vregs contains valid data */
273
			| (saved_regs[PT_MSR] & MSR_USERCHANGE);
259
		if (__put_user(regs->msr | MSR_VEC, &frame->mc_gregs[PT_MSR]))
274
		memcpy(regs, saved_regs, GP_REGS_SIZE);
260
			return 1;
275
		if (copy_from_user(current->thread.fpr, &sr->fp_regs,
261
	}
276
				   sizeof(sr->fp_regs)))
262
	/* else assert((regs->msr & MSR_VEC) == 0) */
277
			goto badframe;
263
278
		/* This function sets back the stack flags into
264
	/* We always copy to/from vrsave, it's 0 if we don't have or don't
279
		   the current task structure.  */
265
	 * use altivec. Since VSCR only contains 32 bits saved in the least
280
		sys_sigaltstack(&st, NULL);
266
	 * significant bits of a vector, we "cheat" and stuff VRSAVE in the
281
267
	 * most significant bits of that same vector. --BenH
282
		ret = regs->result;
268
	 */
283
	} else {
269
	if (__put_user(current->thread.vrsave, (u32 *)&frame->mc_vregs[32]))
284
		/* More signals to go */
270
		return 1;
285
		/* Set up registers for next signal handler */
271
#endif /* CONFIG_ALTIVEC */
286
		regs->gpr[1] = (unsigned long)rt_sf - __SIGNAL_FRAMESIZE;
272
287
		if (copy_from_user(&sigctx, &rt_sf->uc.uc_mcontext, sizeof(sigctx)))
273
	if (sigret) {
288
			goto badframe;
274
		/* Set up the sigreturn trampoline: li r0,sigret; sc */
289
		sr = (struct sigregs *) sigctx.regs;
275
		if (__put_user(0x38000000UL + sigret, &frame->tramp[0])
290
		regs->gpr[3] = ret = sigctx.signal;
276
		    || __put_user(0x44000002UL, &frame->tramp[1]))
291
		/* Get the siginfo   */
277
			return 1;
292
		get_user(regs->gpr[4], (unsigned long *)&rt_sf->pinfo);
278
		flush_icache_range((unsigned long) &frame->tramp[0],
293
		/* Get the ucontext */
279
				   (unsigned long) &frame->tramp[2]);
294
		get_user(regs->gpr[5], (unsigned long *)&rt_sf->puc);
295
		regs->gpr[6] = (unsigned long) rt_sf;
296
297
		regs->link = (unsigned long) &sr->tramp;
298
		regs->nip = sigctx.handler;
299
		if (get_user(prevsp, &sr->gp_regs[PT_R1])
300
		    || put_user(prevsp, (unsigned long *) regs->gpr[1]))
301
			goto badframe;
302
		current->thread.fpscr = 0;
303
	}
280
	}
304
	return ret;
305
281
306
badframe:
282
	return 0;
307
	do_exit(SIGSEGV);
308
}
283
}
309
284
285
/*
286
 * Restore the current user register values from the user stack,
287
 * (except for MSR).
288
 */
289
static int
290
restore_user_regs(struct pt_regs *regs, struct mcontext *sr, int mctxsize)
291
{
292
#ifdef CONFIG_ALTIVEC
293
	unsigned long msr;
294
#endif
295
296
	if (mctxsize && mctxsize < sizeof(struct mcontext))
297
		return 1;
298
299
	/* copy up to but not including MSR */
300
	if (__copy_from_user(regs, &sr->mc_gregs, PT_MSR * sizeof(elf_greg_t)))
301
		return 1;
302
	/* copy from orig_r3 (the word after the MSR) up to the end */
303
	if (__copy_from_user(&regs->orig_gpr3, &sr->mc_gregs[PT_ORIG_R3],
304
			     GP_REGS_SIZE - PT_ORIG_R3 * sizeof(elf_greg_t)))
305
		return 1;
306
307
	/* force the process to reload the FP registers from
308
	   current->thread when it next does FP instructions */
309
	regs->msr &= ~MSR_FP;
310
	if (__copy_from_user(current->thread.fpr, &sr->mc_fregs,
311
			     sizeof(sr->mc_fregs)))
312
		return 1;
313
314
#ifdef CONFIG_ALTIVEC
315
	/* force the process to reload the altivec registers from
316
	   current->thread when it next does altivec instructions */
317
	regs->msr &= ~MSR_VEC;
318
	if (!__get_user(msr, &sr->mc_gregs[PT_MSR]) && (msr & MSR_VEC) != 0) {
319
		/* restore altivec registers from the stack */
320
		if (__copy_from_user(current->thread.vr, &sr->mc_vregs,
321
				     sizeof(sr->mc_vregs)))
322
			return 1;
323
	} else if (current->thread.used_vr)
324
		memset(&current->thread.vr, 0, sizeof(current->thread.vr));
325
326
	/* Always get VRSAVE back */
327
	if (__get_user(current->thread.vrsave, (u32 *)&sr->mc_vregs[32]))
328
		return 1;
329
#endif /* CONFIG_ALTIVEC */
330
331
	return 0;
332
}
333
334
/*
335
 * Restore the user process's signal mask
336
 */
310
static void
337
static void
311
setup_rt_frame(struct pt_regs *regs, struct sigregs *frame,
338
restore_sigmask(sigset_t *set)
312
	       signed long newsp)
313
{
339
{
314
	struct rt_sigframe *rt_sf = (struct rt_sigframe *) newsp;
340
	sigdelsetmask(set, ~_BLOCKABLE);
341
	spin_lock_irq(&current->sigmask_lock);
342
	current->blocked = *set;
343
	recalc_sigpending(current);
344
	spin_unlock_irq(&current->sigmask_lock);
345
}
315
346
316
	/* Set up preamble frame */
347
/*
317
	if (verify_area(VERIFY_WRITE, frame, sizeof(*frame)))
348
 * Set up a signal frame for a "real-time" signal handler
349
 * (one which gets siginfo).
350
 */
351
static void
352
handle_rt_signal(unsigned long sig, struct k_sigaction *ka,
353
		 siginfo_t *info, sigset_t *oldset, struct pt_regs * regs,
354
		 unsigned long newsp)
355
{
356
	struct rt_sigframe *rt_sf;
357
	struct mcontext *frame;
358
	unsigned long origsp = newsp;
359
360
	/* Set up Signal Frame */
361
	/* Put a Real Time Context onto stack */
362
	newsp -= sizeof(*rt_sf);
363
	rt_sf = (struct rt_sigframe *) newsp;
364
365
	/* create a stack frame for the caller of the handler */
366
	newsp -= __SIGNAL_FRAMESIZE + 16;
367
368
	if (verify_area(VERIFY_WRITE, (void *) newsp, origsp - newsp))
318
		goto badframe;
369
		goto badframe;
319
	if (regs->msr & MSR_FP)
370
320
		giveup_fpu(current);
371
	/* Put the siginfo & fill in most of the ucontext */
321
	if (__copy_to_user(&frame->gp_regs, regs, GP_REGS_SIZE)
372
	if (__copy_to_user(&rt_sf->info, info, sizeof(*info))
322
	    || __copy_to_user(&frame->fp_regs, current->thread.fpr,
373
	    || __put_user(0, &rt_sf->uc.uc_flags)
323
			      ELF_NFPREG * sizeof(double))
374
	    || __put_user(0, &rt_sf->uc.uc_link)
324
	/* Set up to return from user space.
375
	    || __put_user(current->sas_ss_sp, &rt_sf->uc.uc_stack.ss_sp)
325
	   It calls the sc exception at offset 0x9999
376
	    || __put_user(sas_ss_flags(regs->gpr[1]), 
326
	   for sys_rt_sigreturn().
377
			  &rt_sf->uc.uc_stack.ss_flags)
327
	*/
378
	    || __put_user(current->sas_ss_size, &rt_sf->uc.uc_stack.ss_size)
328
	    || __put_user(0x38006666UL, &frame->tramp[0])	/* li r0,0x6666 */
379
	    || __put_user(&rt_sf->uc.uc_mcontext, &rt_sf->uc.uc_regs)
329
	    || __put_user(0x44000002UL, &frame->tramp[1]))	/* sc */
380
	    || __copy_to_user(&rt_sf->uc.uc_oldsigmask, oldset, sizeof(*oldset))
381
	    || __copy_to_user(&rt_sf->uc.uc_sigmask, oldset, sizeof(*oldset)))
330
		goto badframe;
382
		goto badframe;
331
	flush_icache_range((unsigned long) &frame->tramp[0],
332
			   (unsigned long) &frame->tramp[2]);
333
	current->thread.fpscr = 0;	/* turn off all fp exceptions */
334
383
335
	/* Retrieve rt_sigframe from stack and
384
	/* Save user registers on the stack */
336
	   set up registers for signal handler
385
	frame = &rt_sf->uc.uc_mcontext;
337
	*/
386
	if (save_user_regs(regs, frame, 0x6666, 0))
338
	newsp -= __SIGNAL_FRAMESIZE;
339
	if (put_user(regs->gpr[1], (unsigned long *)newsp)
340
	    || get_user(regs->nip, &rt_sf->uc.uc_mcontext.handler)
341
	    || get_user(regs->gpr[3], &rt_sf->uc.uc_mcontext.signal)
342
	    || get_user(regs->gpr[4], (unsigned long *)&rt_sf->pinfo)
343
	    || get_user(regs->gpr[5], (unsigned long *)&rt_sf->puc))
344
		goto badframe;
387
		goto badframe;
345
388
389
	if (put_user(regs->gpr[1], (unsigned long *)newsp))
390
		goto badframe;
346
	regs->gpr[1] = newsp;
391
	regs->gpr[1] = newsp;
392
	regs->gpr[3] = sig;
393
	regs->gpr[4] = (unsigned long) &rt_sf->info;
394
	regs->gpr[5] = (unsigned long) &rt_sf->uc;
347
	regs->gpr[6] = (unsigned long) rt_sf;
395
	regs->gpr[6] = (unsigned long) rt_sf;
396
	regs->nip = (unsigned long) ka->sa.sa_handler;
348
	regs->link = (unsigned long) frame->tramp;
397
	regs->link = (unsigned long) frame->tramp;
349
398
350
	return;
399
	return;
351
400
352
badframe:
401
badframe:
353
#if DEBUG_SIG
402
#if DEBUG_SIG
354
	printk("badframe in setup_rt_frame, regs=%p frame=%p newsp=%lx\n",
403
	printk("badframe in handle_rt_signal, regs=%p frame=%p newsp=%lx\n",
355
	       regs, frame, newsp);
404
	       regs, frame, newsp);
356
#endif
405
#endif
357
	do_exit(SIGSEGV);
406
	do_exit(SIGSEGV);
358
}
407
}
359
408
360
/*
409
static int do_setcontext(struct ucontext *ucp, struct pt_regs *regs, int mctxsize)
361
 * Do a signal return; undo the signal stack.
362
 */
363
int sys_sigreturn(struct pt_regs *regs)
364
{
410
{
365
	struct sigcontext_struct *sc, sigctx;
366
	struct sigregs *sr;
367
	int ret;
368
	elf_gregset_t saved_regs;  /* an array of ELF_NGREG unsigned longs */
369
	sigset_t set;
411
	sigset_t set;
370
	unsigned long prevsp;
371
412
372
	sc = (struct sigcontext_struct *)(regs->gpr[1] + __SIGNAL_FRAMESIZE);
413
	if (__copy_from_user(&set, &ucp->uc_sigmask, sizeof(set)))
373
	if (copy_from_user(&sigctx, sc, sizeof(sigctx)))
414
		return -EFAULT;
374
		goto badframe;
415
	restore_sigmask(&set);
375
416
376
	set.sig[0] = sigctx.oldmask;
417
	if (restore_user_regs(regs, &ucp->uc_mcontext, mctxsize))
377
#if _NSIG_WORDS > 1
418
		return -EFAULT;
378
	set.sig[1] = sigctx._unused[3];
379
#endif
380
	sigdelsetmask(&set, ~_BLOCKABLE);
381
	spin_lock_irq(&current->sigmask_lock);
382
	current->blocked = set;
383
	recalc_sigpending(current);
384
	spin_unlock_irq(&current->sigmask_lock);
385
	if (regs->msr & MSR_FP )
386
		giveup_fpu(current);
387
419
388
	sc++;			/* Look at next sigcontext */
420
	return 0;
389
	if (sc == (struct sigcontext_struct *)(sigctx.regs)) {
421
}
390
		/* Last stacked signal - restore registers */
422
391
		sr = (struct sigregs *) sigctx.regs;
423
int sys_swapcontext(struct ucontext *old_ctx, struct ucontext *new_ctx,
392
		if (copy_from_user(saved_regs, &sr->gp_regs,
424
		    int mctxtsize, int r6, int r7, int r8, struct pt_regs *regs)
393
				   sizeof(sr->gp_regs)))
425
{
394
			goto badframe;
426
	unsigned char tmp;
395
		saved_regs[PT_MSR] = (regs->msr & ~MSR_USERCHANGE)
427
396
			| (saved_regs[PT_MSR] & MSR_USERCHANGE);
428
	if (old_ctx != NULL) {
397
		memcpy(regs, saved_regs, GP_REGS_SIZE);
429
		if (verify_area(VERIFY_WRITE, old_ctx, sizeof(*old_ctx))
398
430
		    || save_user_regs(regs, &old_ctx->uc_mcontext, 0, mctxtsize)
399
		if (copy_from_user(current->thread.fpr, &sr->fp_regs,
431
		    || __copy_to_user(&old_ctx->uc_sigmask,
400
				   sizeof(sr->fp_regs)))
432
				      &current->blocked, sizeof(sigset_t))
401
			goto badframe;
433
		    /* the next 2 things aren't strictly necessary */
402
434
		    || __copy_to_user(&old_ctx->uc_oldsigmask,
403
		ret = regs->result;
435
				      &current->blocked, sizeof(sigset_t))
404
436
		    || __put_user(&old_ctx->uc_mcontext, &old_ctx->uc_regs))
405
	} else {
437
			return -EFAULT;
406
		/* More signals to go */
407
		regs->gpr[1] = (unsigned long)sc - __SIGNAL_FRAMESIZE;
408
		if (copy_from_user(&sigctx, sc, sizeof(sigctx)))
409
			goto badframe;
410
		sr = (struct sigregs *) sigctx.regs;
411
		regs->gpr[3] = ret = sigctx.signal;
412
		regs->gpr[4] = (unsigned long) sc;
413
		regs->link = (unsigned long) &sr->tramp;
414
		regs->nip = sigctx.handler;
415
416
		if (get_user(prevsp, &sr->gp_regs[PT_R1])
417
		    || put_user(prevsp, (unsigned long *) regs->gpr[1]))
418
			goto badframe;
419
		current->thread.fpscr = 0;
420
	}
438
	}
421
	return ret;
439
	if (new_ctx == NULL)
440
		return 0;
441
	if (verify_area(VERIFY_READ, new_ctx, sizeof(*new_ctx))
442
	    || __get_user(tmp, (u8 *) new_ctx)
443
	    || __get_user(tmp, (u8 *) (new_ctx + 1) - 1))
444
		return -EFAULT;
422
445
423
badframe:
446
	/*
424
	do_exit(SIGSEGV);
447
	 * If we get a fault copying the context into the kernel's
448
	 * image of the user's registers, we can't just return -EFAULT
449
	 * because the user's registers will be corrupted.  For instance
450
	 * the NIP value may have been updated but not some of the
451
	 * other registers.  Given that we have done the verify_area
452
	 * and successfully read the first and last bytes of the region
453
	 * above, this should only happen in an out-of-memory situation
454
	 * or if another thread unmaps the region containing the context.
455
	 * We kill the task with a SIGSEGV in this situation.
456
	 */
457
	if (do_setcontext(new_ctx, regs, mctxtsize))
458
		do_exit(SIGSEGV);
459
	syscall_direct_return(regs);
460
	/* doesn't actually return back to here */
461
	return 0;
425
}
462
}
426
463
427
/*
464
int sys_rt_sigreturn(struct pt_regs *regs)
428
 * Set up a signal frame.
429
 */
430
static void
431
setup_frame(struct pt_regs *regs, struct sigregs *frame,
432
	    unsigned long newsp)
433
{
465
{
434
	struct sigcontext_struct *sc = (struct sigcontext_struct *) newsp;
466
	struct rt_sigframe *rt_sf;
467
	stack_t st;
435
468
436
	if (verify_area(VERIFY_WRITE, frame, sizeof(*frame)))
469
	rt_sf = (struct rt_sigframe *)(regs->gpr[1] + __SIGNAL_FRAMESIZE + 16);
437
		goto badframe;
470
	if (verify_area(VERIFY_READ, rt_sf, sizeof(struct rt_sigframe)))
438
	if (regs->msr & MSR_FP)
471
		goto bad;
439
		giveup_fpu(current);
472
	if (do_setcontext(&rt_sf->uc, regs, 0))
440
	if (__copy_to_user(&frame->gp_regs, regs, GP_REGS_SIZE)
473
		goto bad;
441
	    || __copy_to_user(&frame->fp_regs, current->thread.fpr,
474
442
			      ELF_NFPREG * sizeof(double))
475
	/*
443
	    || __put_user(0x38007777UL, &frame->tramp[0])    /* li r0,0x7777 */
476
	 * It's not clear whether or why it is desirable to save the
444
	    || __put_user(0x44000002UL, &frame->tramp[1]))   /* sc */
477
	 * sigaltstack setting on signal delivery and restore it on
445
		goto badframe;
478
	 * signal return.  But other architectures do this and we have
446
	flush_icache_range((unsigned long) &frame->tramp[0],
479
	 * always done it up until now so it is probably better not to
447
			   (unsigned long) &frame->tramp[2]);
480
	 * change it.  -- paulus
448
	current->thread.fpscr = 0;	/* turn off all fp exceptions */
481
	 */
482
	if (__copy_from_user(&st, &rt_sf->uc.uc_stack, sizeof(st)))
483
		goto bad;
484
	do_sigaltstack(&st, NULL, regs->gpr[1]);
449
485
450
	newsp -= __SIGNAL_FRAMESIZE;
486
	return regs->result;
451
	if (put_user(regs->gpr[1], (unsigned long *)newsp)
452
	    || get_user(regs->nip, &sc->handler)
453
	    || get_user(regs->gpr[3], &sc->signal))
454
		goto badframe;
455
	regs->gpr[1] = newsp;
456
	regs->gpr[4] = (unsigned long) sc;
457
	regs->link = (unsigned long) frame->tramp;
458
487
459
	return;
488
 bad:
460
461
badframe:
462
#if DEBUG_SIG
463
	printk("badframe in setup_frame, regs=%p frame=%p newsp=%lx\n",
464
	       regs, frame, newsp);
465
#endif
466
	do_exit(SIGSEGV);
489
	do_exit(SIGSEGV);
467
}
490
}
468
491
Lines 472-540 Link Here
472
static void
495
static void
473
handle_signal(unsigned long sig, struct k_sigaction *ka,
496
handle_signal(unsigned long sig, struct k_sigaction *ka,
474
	      siginfo_t *info, sigset_t *oldset, struct pt_regs * regs,
497
	      siginfo_t *info, sigset_t *oldset, struct pt_regs * regs,
475
	      unsigned long *newspp, unsigned long frame)
498
	      unsigned long newsp)
476
{
499
{
477
	struct sigcontext_struct *sc;
500
	struct sigcontext *sc;
478
	struct rt_sigframe *rt_sf;
501
	struct sigregs *frame;
479
502
	unsigned long origsp = newsp;
480
	if (regs->trap == 0x0C00 /* System Call! */
481
	    && ((int)regs->result == -ERESTARTNOHAND ||
482
		((int)regs->result == -ERESTARTSYS &&
483
		 !(ka->sa.sa_flags & SA_RESTART))))
484
		regs->result = -EINTR;
485
503
486
	/* Set up Signal Frame */
504
	/* Set up Signal Frame */
487
	if (ka->sa.sa_flags & SA_SIGINFO) {
505
	newsp -= sizeof(struct sigregs);
488
		/* Put a Real Time Context onto stack */
506
	frame = (struct sigregs *) newsp;
489
		*newspp -= sizeof(*rt_sf);
507
490
		rt_sf = (struct rt_sigframe *) *newspp;
508
	/* Put a sigcontext on the stack */
491
		if (verify_area(VERIFY_WRITE, rt_sf, sizeof(*rt_sf)))
509
	newsp -= sizeof(*sc);
492
			goto badframe;
510
	sc = (struct sigcontext *) newsp;
493
511
494
		if (__put_user((unsigned long) ka->sa.sa_handler, &rt_sf->uc.uc_mcontext.handler)
512
	/* create a stack frame for the caller of the handler */
495
		    || __put_user(&rt_sf->info, &rt_sf->pinfo)
513
	newsp -= __SIGNAL_FRAMESIZE;
496
		    || __put_user(&rt_sf->uc, &rt_sf->puc)
514
497
		    /* Put the siginfo */
515
	if (verify_area(VERIFY_WRITE, (void *) newsp, origsp - newsp))
498
		    || __copy_to_user(&rt_sf->info, info, sizeof(*info))
516
		goto badframe;
499
		    /* Create the ucontext */
517
500
		    || __put_user(0, &rt_sf->uc.uc_flags)
518
#if _NSIG != 64
501
		    || __put_user(0, &rt_sf->uc.uc_link)
519
#error "Please adjust handle_signal()"
502
		    || __put_user(current->sas_ss_sp, &rt_sf->uc.uc_stack.ss_sp)
503
		    || __put_user(sas_ss_flags(regs->gpr[1]),
504
				  &rt_sf->uc.uc_stack.ss_flags)
505
		    || __put_user(current->sas_ss_size, &rt_sf->uc.uc_stack.ss_size)
506
		    || __copy_to_user(&rt_sf->uc.uc_sigmask, oldset, sizeof(*oldset))
507
		    /* mcontext.regs points to preamble register frame */
508
		    || __put_user((struct pt_regs *)frame, &rt_sf->uc.uc_mcontext.regs)
509
		    || __put_user(sig, &rt_sf->uc.uc_mcontext.signal))
510
			goto badframe;
511
	} else {
512
		/* Put another sigcontext on the stack */
513
		*newspp -= sizeof(*sc);
514
		sc = (struct sigcontext_struct *) *newspp;
515
		if (verify_area(VERIFY_WRITE, sc, sizeof(*sc)))
516
			goto badframe;
517
518
		if (__put_user((unsigned long) ka->sa.sa_handler, &sc->handler)
519
		    || __put_user(oldset->sig[0], &sc->oldmask)
520
#if _NSIG_WORDS > 1
521
		    || __put_user(oldset->sig[1], &sc->_unused[3])
522
#endif
520
#endif
523
		    || __put_user((struct pt_regs *)frame, &sc->regs)
521
	if (__put_user((unsigned long) ka->sa.sa_handler, &sc->handler)
524
		    || __put_user(sig, &sc->signal))
522
	    || __put_user(oldset->sig[0], &sc->oldmask)
525
			goto badframe;
523
	    || __put_user(oldset->sig[1], &sc->_unused[3])
526
	}
524
	    || __put_user((struct pt_regs *)frame, &sc->regs)
525
	    || __put_user(sig, &sc->signal))
526
		goto badframe;
527
527
528
	if (ka->sa.sa_flags & SA_ONESHOT)
528
	if (save_user_regs(regs, &frame->mctx, 0x7777, 0))
529
		ka->sa.sa_handler = SIG_DFL;
529
		goto badframe;
530
531
	if (put_user(regs->gpr[1], (unsigned long *)newsp))
532
		goto badframe;
533
	regs->gpr[1] = newsp;
534
	regs->gpr[3] = sig;
535
	regs->gpr[4] = (unsigned long) sc;
536
	regs->nip = (unsigned long) ka->sa.sa_handler;
537
	regs->link = (unsigned long) frame->mctx.tramp;
530
538
531
	if (!(ka->sa.sa_flags & SA_NODEFER)) {
532
		spin_lock_irq(&current->sigmask_lock);
533
		sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
534
		sigaddset(&current->blocked,sig);
535
		recalc_sigpending(current);
536
		spin_unlock_irq(&current->sigmask_lock);
537
	}
538
	return;
539
	return;
539
540
540
badframe:
541
badframe:
Lines 547-576 Link Here
547
}
548
}
548
549
549
/*
550
/*
550
 * Note that 'init' is a special process: it doesn't get signals it doesn't
551
 * Do a signal return; undo the signal stack.
551
 * want to handle. Thus you cannot kill init even with a SIGKILL even by
552
 * mistake.
553
 */
552
 */
554
int do_signal(sigset_t *oldset, struct pt_regs *regs)
553
int sys_sigreturn(struct pt_regs *regs)
555
{
554
{
556
	siginfo_t info;
555
	struct sigcontext *sc, sigctx;
557
	struct k_sigaction *ka;
556
	struct mcontext *sr;
558
	unsigned long frame, newsp;
557
	int ret;
558
	sigset_t set;
559
559
560
	if (!oldset)
560
	sc = (struct sigcontext *)(regs->gpr[1] + __SIGNAL_FRAMESIZE);
561
		oldset = &current->blocked;
561
	if (copy_from_user(&sigctx, sc, sizeof(sigctx)))
562
		goto badframe;
562
563
563
	newsp = frame = 0;
564
	set.sig[0] = sigctx.oldmask;
565
	set.sig[1] = sigctx._unused[3];
566
	restore_sigmask(&set);
564
567
565
	for (;;) {
568
	sr = (struct mcontext *) sigctx.regs;
566
		unsigned long signr;
569
	if (verify_area(VERIFY_READ, sr, sizeof(*sr))
570
	    || restore_user_regs(regs, sr, 0))
571
		goto badframe;
572
573
	ret = regs->result;
567
574
575
	return ret;
576
577
badframe:
578
	do_exit(SIGSEGV);
579
}	
580
581
static int get_signal_to_deliver(struct siginfo *infop, struct pt_regs *regs)
582
{
583
	struct k_sigaction *ka;
584
	int signr;
585
586
	for (;;) {
568
		spin_lock_irq(&current->sigmask_lock);
587
		spin_lock_irq(&current->sigmask_lock);
569
		signr = dequeue_signal(&current->blocked, &info);
588
		signr = dequeue_signal(&current->blocked, infop);
570
		spin_unlock_irq(&current->sigmask_lock);
589
		spin_unlock_irq(&current->sigmask_lock);
571
590
572
		if (!signr)
591
		if (!signr)
573
			break;
592
			return 0;
574
593
575
		if ((current->ptrace & PT_PTRACED) && signr != SIGKILL) {
594
		if ((current->ptrace & PT_PTRACED) && signr != SIGKILL) {
576
			/* Let the debugger run.  */
595
			/* Let the debugger run.  */
Lines 589-605 Link Here
589
				continue;
608
				continue;
590
609
591
			/* Update the siginfo structure.  Is this good?  */
610
			/* Update the siginfo structure.  Is this good?  */
592
			if (signr != info.si_signo) {
611
			if (signr != infop->si_signo) {
593
				info.si_signo = signr;
612
				infop->si_signo = signr;
594
				info.si_errno = 0;
613
				infop->si_errno = 0;
595
				info.si_code = SI_USER;
614
				infop->si_code = SI_USER;
596
				info.si_pid = current->p_pptr->pid;
615
				infop->si_pid = current->p_pptr->pid;
597
				info.si_uid = current->p_pptr->uid;
616
				infop->si_uid = current->p_pptr->uid;
598
			}
617
			}
599
618
600
			/* If the (new) signal is now blocked, requeue it.  */
619
			/* If the (new) signal is now blocked, requeue it.  */
601
			if (sigismember(&current->blocked, signr)) {
620
			if (sigismember(&current->blocked, signr)) {
602
				send_sig_info(signr, &info, current);
621
				send_sig_info(signr, infop, current);
603
				continue;
622
				continue;
604
			}
623
			}
605
		}
624
		}
Lines 646-684 Link Here
646
				/* FALLTHRU */
665
				/* FALLTHRU */
647
666
648
			default:
667
			default:
649
				sig_exit(signr, exit_code, &info);
668
				sig_exit(signr, exit_code, infop);
650
				/* NOTREACHED */
669
				/* NOTREACHED */
651
			}
670
			}
652
		}
671
		}
672
		return signr;
673
	}
674
}
675
676
/*
677
 * Note that 'init' is a special process: it doesn't get signals it doesn't
678
 * want to handle. Thus you cannot kill init even with a SIGKILL even by
679
 * mistake.
680
 */
681
int do_signal(sigset_t *oldset, struct pt_regs *regs)
682
{
683
	siginfo_t info;
684
	struct k_sigaction *ka;
685
	unsigned long frame, newsp;
686
	int signr;
687
688
	if (!oldset)
689
		oldset = &current->blocked;
690
691
	newsp = frame = 0;
653
692
654
		if ( (ka->sa.sa_flags & SA_ONSTACK)
693
	signr = get_signal_to_deliver(&info, regs);
655
		     && (! on_sig_stack(regs->gpr[1])))
694
656
			newsp = (current->sas_ss_sp + current->sas_ss_size);
695
	ka = (signr == 0)? NULL: &current->sig->action[signr-1];
657
		else
696
658
			newsp = regs->gpr[1];
697
	if (regs->trap == 0xc00) {		/* system call */
659
		newsp = frame = newsp - sizeof(struct sigregs);
698
		switch ((int) regs->result) {
660
699
		case -ERESTARTSYS:
661
		/* Whee!  Actually deliver the signal.  */
700
			if (signr == 0 || (ka->sa.sa_flags & SA_RESTART))
662
		handle_signal(signr, ka, &info, oldset, regs, &newsp, frame);
701
				goto retry;
663
		break;
702
			/* fall through */
664
	}
703
		case -ERESTARTNOHAND:
665
704
			if (signr > 0) {
666
	if (regs->trap == 0x0C00 /* System Call! */ &&
705
				/* make the system call return an EINTR */
667
	    ((int)regs->result == -ERESTARTNOHAND ||
706
				regs->result = -EINTR;
668
	     (int)regs->result == -ERESTARTSYS ||
707
				break;
669
	     (int)regs->result == -ERESTARTNOINTR)) {
708
			}
670
		regs->gpr[3] = regs->orig_gpr3;
709
			/* fall through */
671
		regs->nip -= 4;		/* Back up & retry system call */
710
		case -ERESTARTNOINTR:
672
		regs->result = 0;
711
		retry:
712
			/* Back up & retry system call */
713
			regs->gpr[3] = regs->orig_gpr3;
714
			regs->nip -= 4;
715
			regs->result = 0;
716
			break;
717
		}
673
	}
718
	}
674
719
675
	if (newsp == frame)
720
	if (signr == 0)
676
		return 0;		/* no signals delivered */
721
		return 0;		/* no signals delivered */
677
722
723
	if ((ka->sa.sa_flags & SA_ONSTACK) && current->sas_ss_size
724
	    && !on_sig_stack(regs->gpr[1]))
725
		newsp = current->sas_ss_sp + current->sas_ss_size;
726
	else
727
		newsp = regs->gpr[1];
728
	newsp &= ~0xfUL;
729
730
	/* Whee!  Actually deliver the signal.  */
678
	if (ka->sa.sa_flags & SA_SIGINFO)
731
	if (ka->sa.sa_flags & SA_SIGINFO)
679
		setup_rt_frame(regs, (struct sigregs *) frame, newsp);
732
		handle_rt_signal(signr, ka, &info, oldset, regs, newsp);
680
	else
733
	else
681
		setup_frame(regs, (struct sigregs *) frame, newsp);
734
		handle_signal(signr, ka, &info, oldset, regs, newsp);
735
736
	if (ka->sa.sa_flags & SA_ONESHOT)
737
		ka->sa.sa_handler = SIG_DFL;
738
739
	if (!(ka->sa.sa_flags & SA_NODEFER)) {
740
		spin_lock_irq(&current->sigmask_lock);
741
		sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
742
		sigaddset(&current->blocked, signr);
743
		recalc_sigpending(current);
744
		spin_unlock_irq(&current->sigmask_lock);
745
	}
746
682
	return 1;
747
	return 1;
683
}
748
}
684
749
(-)linux-2.4.22/arch/ppc/kernel/smp-tbsync.c (+182 lines)
Line 0 Link Here
1
/*
2
 * Smp timebase synchronization for ppc.
3
 *
4
 * Copyright (C) 2003 Samuel Rydh (samuel@ibrium.se)
5
 *
6
 */
7
8
#include <linux/config.h>
9
#include <linux/kernel.h>
10
#include <linux/sched.h>
11
#include <linux/smp.h>
12
#include <linux/unistd.h>
13
#include <linux/init.h>
14
#include <linux/slab.h>
15
#include <asm/atomic.h>
16
#include <asm/smp.h>
17
#include <asm/time.h>
18
19
#define NUM_ITER		300
20
21
enum {
22
	kExit=0, kSetAndTest, kTest
23
};
24
25
static struct {
26
	volatile int		tbu;
27
	volatile int		tbl;
28
	volatile int		mark;
29
	volatile int		cmd;
30
	volatile int		handshake;
31
	int			filler[3];
32
33
	volatile int		ack;
34
	int			filler2[7];
35
36
	volatile int		race_result;
37
} *tbsync;
38
39
static volatile int		running;
40
41
static void __devinit
42
enter_contest( int mark, int add )
43
{
44
	while( (int)(get_tbl() - mark) < 0 )
45
		tbsync->race_result = add;
46
}
47
48
void __devinit
49
smp_generic_take_timebase( void )
50
{
51
	int cmd, tbl, tbu;
52
53
	local_irq_disable();
54
	while( !running )
55
		;
56
	rmb();
57
58
	for( ;; ) {
59
		tbsync->ack = 1;
60
		while( !tbsync->handshake )
61
			;
62
		rmb();
63
64
		cmd = tbsync->cmd;
65
		tbl = tbsync->tbl;
66
		tbu = tbsync->tbu;
67
		tbsync->ack = 0;
68
		if( cmd == kExit )
69
			return;
70
71
		if( cmd == kSetAndTest ) {
72
			while( tbsync->handshake )
73
				;
74
			asm volatile ("mttbl %0" :: "r" (tbl) );
75
			asm volatile ("mttbu %0" :: "r" (tbu) );
76
		} else {
77
			while( tbsync->handshake )
78
				;
79
		}
80
		enter_contest( tbsync->mark, -1 );
81
	}
82
	local_irq_enable();
83
}
84
85
static int __devinit
86
start_contest( int cmd, int offset, int num )
87
{
88
	int i, tbu, tbl, mark, score=0;
89
90
	tbsync->cmd = cmd;
91
92
	local_irq_disable();
93
	for( i=-3; i<num; ) {
94
		tbl = get_tbl() + 400;
95
		tbsync->tbu = tbu = get_tbu();
96
		tbsync->tbl = tbl + offset;
97
		tbsync->mark = mark = tbl + 400;
98
99
		wmb();
100
101
		tbsync->handshake = 1;
102
		while( tbsync->ack )
103
			;
104
105
		while( (int)(get_tbl() - tbl) <= 0 )
106
			;
107
		tbsync->handshake = 0;
108
		enter_contest( mark, 1 );
109
110
		while( !tbsync->ack )
111
			;
112
113
		if( tbsync->tbu != get_tbu() || ((tbsync->tbl ^ get_tbl()) & 0x80000000) )
114
			continue;
115
		if( i++ > 0 )
116
			score += tbsync->race_result;
117
	}
118
	local_irq_enable();
119
	return score;
120
}
121
122
void __devinit
123
smp_generic_give_timebase( void )
124
{
125
	int i, score, score2, old, min=0, max=5000, offset=1000;
126
127
	printk("Synchronizing timebase\n");
128
129
	/* if this fails then this kernel won't work anyway... */
130
	tbsync = kmalloc( sizeof(*tbsync), GFP_KERNEL );
131
	memset( tbsync, 0, sizeof(*tbsync) );
132
	mb();
133
	running = 1;
134
135
	while( !tbsync->ack )
136
		;
137
138
	/* binary search */
139
	for( old=-1 ; old != offset ; offset=(min+max)/2 ) {
140
		score = start_contest( kSetAndTest, offset, NUM_ITER );
141
142
		printk("score %d, offset %d\n", score, offset );
143
144
		if( score > 0 )
145
			max = offset;
146
		else
147
			min = offset;
148
		old = offset;
149
	}
150
	score = start_contest( kSetAndTest, min, NUM_ITER );
151
	score2 = start_contest( kSetAndTest, max, NUM_ITER );
152
153
	printk( "Min %d (score %d), Max %d (score %d)\n", min, score, max, score2 );
154
	score = abs( score );
155
	score2 = abs( score2 );
156
	offset = (score < score2) ? min : max;
157
158
	/* guard against inaccurate mttb */
159
	for( i=0; i<10; i++ ) {
160
		start_contest( kSetAndTest, offset, NUM_ITER/10 );
161
162
		if( (score2=start_contest(kTest, offset, NUM_ITER)) < 0 )
163
			score2 = -score2;
164
		if( score2 <= score || score2 < 20 )
165
			break;
166
	}
167
	printk("Final offset: %d (%d/%d)\n", offset, score2, NUM_ITER );
168
169
	/* exiting */
170
	tbsync->cmd = kExit;
171
	wmb();
172
	tbsync->handshake = 1;
173
	while( tbsync->ack )
174
		;
175
	tbsync->handshake = 0;
176
	kfree( tbsync );
177
	tbsync = NULL;
178
	running = 0;
179
180
	/* all done */
181
	smp_tb_synchronized = 1;
182
}
(-)linux-2.4.22/arch/ppc/kernel/smp.c (-91 / +16 lines)
Lines 55-68 Link Here
55
/* all cpu mappings are 1-1 -- Cort */
55
/* all cpu mappings are 1-1 -- Cort */
56
volatile unsigned long cpu_callin_map[NR_CPUS];
56
volatile unsigned long cpu_callin_map[NR_CPUS];
57
57
58
#define TB_SYNC_PASSES 4
59
volatile unsigned long __initdata tb_sync_flag = 0;
60
volatile unsigned long __initdata tb_offset = 0;
61
62
int start_secondary(void *);
58
int start_secondary(void *);
63
extern int cpu_idle(void *unused);
59
extern int cpu_idle(void *unused);
64
void smp_call_function_interrupt(void);
60
void smp_call_function_interrupt(void);
65
61
62
extern void smp_generic_take_timebase(void);
63
extern void smp_generic_give_timebase(void);
64
66
/* Low level assembly function used to backup CPU 0 state */
65
/* Low level assembly function used to backup CPU 0 state */
67
extern void __save_cpu_setup(void);
66
extern void __save_cpu_setup(void);
68
67
Lines 230-235 Link Here
230
	timeout = 1000000;
229
	timeout = 1000000;
231
	while (atomic_read(&data.started) != cpus) {
230
	while (atomic_read(&data.started) != cpus) {
232
		if (--timeout == 0) {
231
		if (--timeout == 0) {
232
#ifdef CONFIG_XMON
233
			xmon_printf("smp_call_function on cpu %d: other cpus not responding (%d)\n",
234
			       smp_processor_id(), atomic_read(&data.started));
235
#endif			       
233
			printk("smp_call_function on cpu %d: other cpus not responding (%d)\n",
236
			printk("smp_call_function on cpu %d: other cpus not responding (%d)\n",
234
			       smp_processor_id(), atomic_read(&data.started));
237
			       smp_processor_id(), atomic_read(&data.started));
235
			goto out;
238
			goto out;
Lines 242-247 Link Here
242
		timeout = 1000000;
245
		timeout = 1000000;
243
		while (atomic_read(&data.finished) != cpus) {
246
		while (atomic_read(&data.finished) != cpus) {
244
			if (--timeout == 0) {
247
			if (--timeout == 0) {
248
#ifdef CONFIG_XMON
249
				xmon_printf("smp_call_function on cpu %d: other cpus not finishing (%d/%d)\n",
250
				       smp_processor_id(), atomic_read(&data.finished), atomic_read(&data.started));
251
#endif
245
				printk("smp_call_function on cpu %d: other cpus not finishing (%d/%d)\n",
252
				printk("smp_call_function on cpu %d: other cpus not finishing (%d/%d)\n",
246
				       smp_processor_id(), atomic_read(&data.finished), atomic_read(&data.started));
253
				       smp_processor_id(), atomic_read(&data.finished), atomic_read(&data.started));
247
				goto out;
254
				goto out;
Lines 399-479 Link Here
399
		smp_tb_synchronized = 1;
406
		smp_tb_synchronized = 1;
400
}
407
}
401
408
402
void __init smp_software_tb_sync(int cpu)
403
{
404
#define PASSES 4	/* 4 passes.. */
405
	int pass;
406
	int i, j;
407
408
	/* stop - start will be the number of timebase ticks it takes for cpu0
409
	 * to send a message to all others and the first reponse to show up.
410
	 *
411
	 * ASSUMPTION: this time is similiar for all cpus
412
	 * ASSUMPTION: the time to send a one-way message is ping/2
413
	 */
414
	register unsigned long start = 0;
415
	register unsigned long stop = 0;
416
	register unsigned long temp = 0;
417
418
	set_tb(0, 0);
419
420
	/* multiple passes to get in l1 cache.. */
421
	for (pass = 2; pass < 2+PASSES; pass++){
422
		if (cpu == 0){
423
			mb();
424
			for (i = j = 1; i < smp_num_cpus; i++, j++){
425
				/* skip stuck cpus */
426
				while (!cpu_callin_map[j])
427
					++j;
428
				while (cpu_callin_map[j] != pass)
429
					barrier();
430
			}
431
			mb();
432
			tb_sync_flag = pass;
433
			start = get_tbl();	/* start timing */
434
			while (tb_sync_flag)
435
				mb();
436
			stop = get_tbl();	/* end timing */
437
			/* theoretically, the divisor should be 2, but
438
			 * I get better results on my dual mtx. someone
439
			 * please report results on other smp machines..
440
			 */
441
			tb_offset = (stop-start)/4;
442
			mb();
443
			tb_sync_flag = pass;
444
			udelay(10);
445
			mb();
446
			tb_sync_flag = 0;
447
			mb();
448
			set_tb(0,0);
449
			mb();
450
		} else {
451
			cpu_callin_map[cpu] = pass;
452
			mb();
453
			while (!tb_sync_flag)
454
				mb();		/* wait for cpu0 */
455
			mb();
456
			tb_sync_flag = 0;	/* send response for timing */
457
			mb();
458
			while (!tb_sync_flag)
459
				mb();
460
			temp = tb_offset;	/* make sure offset is loaded */
461
			while (tb_sync_flag)
462
				mb();
463
			set_tb(0,temp);		/* now, set the timebase */
464
			mb();
465
		}
466
	}
467
	if (cpu == 0) {
468
		smp_tb_synchronized = 1;
469
		printk("smp_software_tb_sync: %d passes, final offset: %ld\n",
470
			PASSES, tb_offset);
471
	}
472
	/* so time.c doesn't get confused */
473
	set_dec(tb_ticks_per_jiffy);
474
	last_jiffy_stamp(cpu) = 0;
475
}
476
477
void __init smp_commence(void)
409
void __init smp_commence(void)
478
{
410
{
479
	/*
411
	/*
Lines 486-504 Link Here
486
	/* if the smp_ops->setup_cpu function has not already synched the
418
	/* if the smp_ops->setup_cpu function has not already synched the
487
	 * timebases with a nicer hardware-based method, do so now
419
	 * timebases with a nicer hardware-based method, do so now
488
	 *
420
	 *
489
	 * I am open to suggestions for improvements to this method
421
	 * New version backported from Samuel Rydth 2.6 version, unlike 2.6
490
	 * -- Troy <hozer@drgw.net>
422
	 * version works only for 2 CPUs (easy hack)
491
	 *
492
	 * NOTE: if you are debugging, set smp_tb_synchronized for now
493
	 * since if this code runs pretty early and needs all cpus that
494
	 * reported in in smp_callin_map to be working
495
	 *
496
	 * NOTE2: this code doesn't seem to work on > 2 cpus. -- paulus/BenH
497
	 */
423
	 */
498
	if (!smp_tb_synchronized && smp_num_cpus == 2) {
424
	if (!smp_tb_synchronized && smp_num_cpus == 2) {
499
		unsigned long flags;
425
		unsigned long flags;
500
		__save_and_cli(flags);
426
		__save_and_cli(flags);
501
		smp_software_tb_sync(0);
427
		smp_generic_give_timebase();
502
		__restore_flags(flags);
428
		__restore_flags(flags);
503
	}
429
	}
504
}
430
}
Lines 518-526 Link Here
518
		barrier();
444
		barrier();
519
445
520
	/* see smp_commence for more info */
446
	/* see smp_commence for more info */
521
	if (!smp_tb_synchronized && smp_num_cpus == 2) {
447
	if (!smp_tb_synchronized && smp_num_cpus == 2)
522
		smp_software_tb_sync(cpu);
448
		smp_generic_take_timebase();
523
	}
524
	__sti();
449
	__sti();
525
}
450
}
526
451
(-)linux-2.4.22/arch/ppc/kernel/traps.c (-3 / +16 lines)
Lines 85-98 Link Here
85
85
86
void die(const char * str, struct pt_regs * fp, long err)
86
void die(const char * str, struct pt_regs * fp, long err)
87
{
87
{
88
#ifdef CONFIG_BOOTX_TEXT
89
	extern int force_printk_to_btext;
90
#endif
88
	console_verbose();
91
	console_verbose();
89
	spin_lock_irq(&die_lock);
92
	spin_lock_irq(&die_lock);
93
#ifdef CONFIG_BOOTX_TEXT
94
	force_printk_to_btext = 1;
95
#endif	
90
#ifdef CONFIG_PMAC_BACKLIGHT
96
#ifdef CONFIG_PMAC_BACKLIGHT
91
	set_backlight_enable(1);
97
	if (_machine == _MACH_Pmac) {
92
	set_backlight_level(BACKLIGHT_MAX);
98
		set_backlight_enable(1);
93
#endif
99
		set_backlight_level(BACKLIGHT_MAX);
100
	}
101
#endif	
94
	printk("Oops: %s, sig: %ld\n", str, err);
102
	printk("Oops: %s, sig: %ld\n", str, err);
95
	show_regs(fp);
103
	show_regs(fp);
104
#ifdef CONFIG_BOOTX_TEXT
105
	force_printk_to_btext = 0;
106
#endif	
96
	spin_unlock_irq(&die_lock);
107
	spin_unlock_irq(&die_lock);
97
	/* do_exit() should take care of panic'ing from an interrupt
108
	/* do_exit() should take care of panic'ing from an interrupt
98
	 * context so we don't handle it here
109
	 * context so we don't handle it here
Lines 153-161 Link Here
153
164
154
			--nip;
165
			--nip;
155
			rb = (*nip >> 11) & 0x1f;
166
			rb = (*nip >> 11) & 0x1f;
167
#if 0
156
			printk(KERN_DEBUG "%s bad port %lx at %p\n",
168
			printk(KERN_DEBUG "%s bad port %lx at %p\n",
157
			       (*nip & 0x100)? "OUT to": "IN from",
169
			       (*nip & 0x100)? "OUT to": "IN from",
158
			       regs->gpr[rb] - _IO_BASE, nip);
170
			       regs->gpr[rb] - _IO_BASE, nip);
171
#endif			       
159
			regs->nip = fixup;
172
			regs->nip = fixup;
160
			return 1;
173
			return 1;
161
		}
174
		}
(-)linux-2.4.22/arch/ppc/lib/locks.c (+8 lines)
Lines 15-20 Link Here
15
15
16
#if SPINLOCK_DEBUG
16
#if SPINLOCK_DEBUG
17
17
18
/* Route debug output to xmon when possible, there are more chances
19
 * for it to work than the console
20
 */
21
#ifdef CONFIG_XMON
22
extern void xmon_printf(const char* fmt,...);
23
#define printk xmon_printf
24
#endif
25
18
#undef INIT_STUCK
26
#undef INIT_STUCK
19
#define INIT_STUCK 200000000 /*0xffffffff*/
27
#define INIT_STUCK 200000000 /*0xffffffff*/
20
28
(-)linux-2.4.22/arch/ppc/mm/fault.c (-2 / +3 lines)
Lines 96-102 Link Here
96
void do_page_fault(struct pt_regs *regs, unsigned long address,
96
void do_page_fault(struct pt_regs *regs, unsigned long address,
97
		   unsigned long error_code)
97
		   unsigned long error_code)
98
{
98
{
99
	struct vm_area_struct * vma;
99
	struct vm_area_struct * vma, * prev_vma;
100
	struct mm_struct *mm = current->mm;
100
	struct mm_struct *mm = current->mm;
101
	siginfo_t info;
101
	siginfo_t info;
102
	int code = SEGV_MAPERR;
102
	int code = SEGV_MAPERR;
Lines 177-183 Link Here
177
		    && (!user_mode(regs) || !store_updates_sp(regs)))
177
		    && (!user_mode(regs) || !store_updates_sp(regs)))
178
			goto bad_area;
178
			goto bad_area;
179
	}
179
	}
180
	if (expand_stack(vma, address))
180
	vma = find_vma_prev(mm, address, &prev_vma);
181
	if (expand_stack(vma, address, prev_vma))
181
		goto bad_area;
182
		goto bad_area;
182
183
183
good_area:
184
good_area:
(-)linux-2.4.22/arch/ppc/mm/init.c (+11 lines)
Lines 457-462 Link Here
457
	high_memory = (void *) __va(PPC_MEMSTART + total_lowmem);
457
	high_memory = (void *) __va(PPC_MEMSTART + total_lowmem);
458
	num_physpages = max_mapnr;	/* RAM is assumed contiguous */
458
	num_physpages = max_mapnr;	/* RAM is assumed contiguous */
459
459
460
	/* Sanity check: did ioremap_bot stomp over vmalloc space ? We keep
461
	 * a minimal 16Mb guard though if you only have 16Mb left, you'll
462
	 * probably run into trouble, so we also printk something if you
463
	 * have less than 64Mb. This is meant to help diagnosing such problems
464
	 * as debugging it can be really painful. --BenH.
465
	 */
466
	if (VMALLOC_END < (VMALLOC_START + 0x01000000UL))
467
		panic("Argh ! Virtual space exhausted !");
468
	if (VMALLOC_END < (VMALLOC_START + 0x04000000UL))
469
		printk(KERN_WARNING "Warning ! Virtual space small !");
470
460
	totalram_pages += free_all_bootmem();
471
	totalram_pages += free_all_bootmem();
461
472
462
#ifdef CONFIG_BLK_DEV_INITRD
473
#ifdef CONFIG_BLK_DEV_INITRD
(-)linux-2.4.22/arch/ppc/mm/pgtable.c (-1 / +1 lines)
Lines 238-244 Link Here
238
238
239
	printk(KERN_INFO "Memory BAT mapping: BAT2=%ldMb, BAT3=%ldMb,"
239
	printk(KERN_INFO "Memory BAT mapping: BAT2=%ldMb, BAT3=%ldMb,"
240
			" residual: %ldMb\n", __bat2 >> 20, __bat3 >> 20,
240
			" residual: %ldMb\n", __bat2 >> 20, __bat3 >> 20,
241
			(total_lowmem - (__bat2 - __bat3)) >> 20);
241
			(total_memory - (__bat2 - __bat3)) >> 20);
242
242
243
	/* On SMP, we limit the lowmem to the area mapped with BATs.
243
	/* On SMP, we limit the lowmem to the area mapped with BATs.
244
	 * We also assume nobody will do SMP with 601s
244
	 * We also assume nobody will do SMP with 601s
(-)linux-2.4.22/arch/ppc/platforms/Makefile (+3 lines)
Lines 41-46 Link Here
41
					prep_time.o prep_setup.o pmac_sleep.o \
41
					prep_time.o prep_setup.o pmac_sleep.o \
42
					pmac_nvram.o
42
					pmac_nvram.o
43
obj-$(CONFIG_PMAC_BACKLIGHT)	+= pmac_backlight.o
43
obj-$(CONFIG_PMAC_BACKLIGHT)	+= pmac_backlight.o
44
ifeq ($(CONFIG_ALL_PPC),y)
45
obj-$(CONFIG_CPU_FREQ_PMAC)	+= pmac_cpufreq.o
46
endif
44
obj-$(CONFIG_PPC_RTAS)		+= error_log.o proc_rtas.o
47
obj-$(CONFIG_PPC_RTAS)		+= error_log.o proc_rtas.o
45
obj-$(CONFIG_PREP_RESIDUAL)	+= residual.o
48
obj-$(CONFIG_PREP_RESIDUAL)	+= residual.o
46
obj-$(CONFIG_GEMINI)		+= gemini_pci.o gemini_setup.o gemini_prom.o
49
obj-$(CONFIG_GEMINI)		+= gemini_pci.o gemini_setup.o gemini_prom.o
(-)linux-2.4.22/arch/ppc/platforms/pmac_cpufreq.c (+352 lines)
Line 0 Link Here
1
#include <linux/config.h>
2
#include <linux/types.h>
3
#include <linux/errno.h>
4
#include <linux/kernel.h>
5
#include <linux/delay.h>
6
#include <linux/sched.h>
7
#include <linux/adb.h>
8
#include <linux/pmu.h>
9
#include <linux/slab.h>
10
#include <linux/cpufreq.h>
11
#include <linux/init.h>
12
#include <asm/prom.h>
13
#include <asm/machdep.h>
14
#include <asm/irq.h>
15
#include <asm/hardirq.h>
16
#include <asm/pmac_feature.h>
17
#include <asm/mmu_context.h>
18
#include <asm/sections.h>
19
#include <asm/cputable.h>
20
#include <asm/time.h>
21
22
#undef DEBUG_FREQ
23
24
extern void low_choose_750fx_pll(int pll);
25
extern void low_sleep_handler(void);
26
extern void openpic_sleep_save_intrs(void);
27
extern void openpic_sleep_restore_intrs(void);
28
extern void enable_kernel_altivec(void);
29
extern void enable_kernel_fp(void);
30
31
static unsigned int low_freq;
32
static unsigned int hi_freq;
33
static unsigned int cur_freq;
34
static int cpufreq_uses_pmu;
35
36
#define PMAC_CPU_LOW_SPEED	1
37
#define PMAC_CPU_HIGH_SPEED	0
38
39
static inline void
40
wakeup_decrementer(void)
41
{
42
	set_dec(tb_ticks_per_jiffy);
43
	/* No currently-supported powerbook has a 601,
44
	 * so use get_tbl, not native
45
	 */
46
	last_jiffy_stamp(0) = tb_last_stamp = get_tbl();
47
}
48
49
#ifdef DEBUG_FREQ
50
static inline void
51
debug_calc_bogomips(void)
52
{
53
	/* This will cause a recalc of bogomips and display the
54
	 * result. We backup/restore the value to avoid affecting the
55
	 * core cpufreq framework's own calculation.
56
	 */
57
	extern void calibrate_delay(void);
58
59
	unsigned long save_lpj = loops_per_jiffy;
60
	calibrate_delay();
61
	loops_per_jiffy = save_lpj;
62
}
63
#endif
64
65
/* Switch CPU speed under 750FX CPU control
66
 */
67
static int __pmac
68
cpu_750fx_cpu_speed(int low_speed)
69
{
70
#ifdef DEBUG_FREQ
71
	printk(KERN_DEBUG "HID1, before: %x\n", mfspr(SPRN_HID1));	
72
#endif
73
	low_choose_750fx_pll(low_speed);
74
#ifdef DEBUG_FREQ
75
	printk(KERN_DEBUG "HID1, after: %x\n", mfspr(SPRN_HID1));	
76
	debug_calc_bogomips();
77
#endif
78
79
	return 0;
80
}
81
82
/* Switch CPU speed under PMU control
83
 */
84
static int __pmac
85
pmu_set_cpu_speed(unsigned int low_speed)
86
{
87
	struct adb_request req;
88
	unsigned long save_l2cr;
89
	unsigned long save_l3cr;
90
	
91
#ifdef DEBUG_FREQ
92
	printk(KERN_DEBUG "HID1, before: %x\n", mfspr(SPRN_HID1));	
93
#endif
94
	/* Disable all interrupt sources on openpic */
95
	openpic_sleep_save_intrs();
96
97
	/* Make sure the PMU is idle */
98
	pmu_suspend();
99
100
	/* Make sure the decrementer won't interrupt us */
101
	asm volatile("mtdec %0" : : "r" (0x7fffffff));
102
	/* Make sure any pending DEC interrupt occuring while we did
103
	 * the above didn't re-enable the DEC */
104
	mb();
105
	asm volatile("mtdec %0" : : "r" (0x7fffffff));
106
107
	/* We can now disable MSR_EE */
108
	local_irq_disable();
109
110
	/* Giveup the FPU & vec */
111
	enable_kernel_fp();
112
113
#ifdef CONFIG_ALTIVEC
114
	if (cur_cpu_spec[0]->cpu_features & CPU_FTR_ALTIVEC)
115
		enable_kernel_altivec();
116
#endif /* CONFIG_ALTIVEC */
117
118
	/* Save & disable L2 and L3 caches */
119
	save_l3cr = _get_L3CR();	/* (returns -1 if not available) */
120
	save_l2cr = _get_L2CR();	/* (returns -1 if not available) */
121
	if (save_l3cr != 0xffffffff && (save_l3cr & L3CR_L3E) != 0)
122
		_set_L3CR(save_l3cr & 0x7fffffff);
123
	if (save_l2cr != 0xffffffff && (save_l2cr & L2CR_L2E) != 0)
124
		_set_L2CR(save_l2cr & 0x7fffffff);
125
126
	/* Send the new speed command. My assumption is that this command
127
	 * will cause PLL_CFG[0..3] to be changed next time CPU goes to sleep
128
	 */
129
	pmu_request(&req, NULL, 6, PMU_CPU_SPEED, 'W', 'O', 'O', 'F', low_speed);
130
	while (!req.complete)
131
		pmu_poll();
132
	
133
	pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,1,1);
134
135
	low_sleep_handler();
136
	
137
	pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,1,0);
138
139
	/* Restore L2 cache */
140
	if (save_l2cr != 0xffffffff && (save_l2cr & L2CR_L2E) != 0)
141
 		_set_L2CR(save_l2cr);
142
	/* Restore L3 cache */
143
	if (save_l3cr != 0xffffffff && (save_l3cr & L3CR_L3E) != 0)
144
 		_set_L3CR(save_l3cr);
145
146
	/* Restore userland MMU context */
147
	set_context(current->active_mm->context, current->active_mm->pgd);
148
149
	pmu_unlock();
150
	
151
#ifdef DEBUG_FREQ
152
	printk(KERN_DEBUG "HID1, after: %x\n", mfspr(SPRN_HID1));	
153
#endif
154
155
	/* Restore decrementer */
156
	wakeup_decrementer();
157
158
	/* Restore interrupts */
159
	openpic_sleep_restore_intrs();
160
161
	pmu_resume();
162
163
	/* Let interrupts flow again ... */
164
	local_irq_enable();
165
166
#ifdef DEBUG_FREQ
167
	debug_calc_bogomips();
168
#endif
169
170
	return 0;
171
}
172
173
static int __pmac
174
do_set_cpu_speed(int speed_mode)
175
{
176
	struct cpufreq_freqs    freqs;
177
	int rc;
178
	
179
	freqs.old = cur_freq;
180
	freqs.new = (speed_mode == PMAC_CPU_HIGH_SPEED) ? hi_freq : low_freq;
181
	freqs.cpu = CPUFREQ_ALL_CPUS;
182
183
	cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
184
	if (cpufreq_uses_pmu)
185
		rc = pmu_set_cpu_speed(speed_mode);
186
	else
187
		rc = cpu_750fx_cpu_speed(speed_mode);
188
	cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
189
	cur_freq = (speed_mode == PMAC_CPU_HIGH_SPEED) ? hi_freq : low_freq;
190
191
	return rc;
192
}
193
194
static int __pmac
195
pmac_cpufreq_verify(struct cpufreq_policy *policy)
196
{
197
	if (!policy)
198
		return -EINVAL;
199
		
200
	policy->cpu = 0; /* UP only */
201
202
	cpufreq_verify_within_limits(policy, low_freq, hi_freq);
203
204
	if ((policy->min > low_freq) && 
205
	    (policy->max < hi_freq))
206
		policy->max = hi_freq;
207
208
	return 0;
209
}
210
211
static int __pmac
212
pmac_cpufreq_setpolicy(struct cpufreq_policy *policy)
213
{
214
	int rc;
215
	
216
	if (!policy)
217
		return -EINVAL;
218
	if (policy->min > low_freq)
219
		rc = do_set_cpu_speed(PMAC_CPU_HIGH_SPEED);
220
	else if (policy->max < hi_freq)
221
		rc = do_set_cpu_speed(PMAC_CPU_LOW_SPEED);
222
	else if (policy->policy == CPUFREQ_POLICY_POWERSAVE)
223
		rc = do_set_cpu_speed(PMAC_CPU_LOW_SPEED);
224
	else
225
		rc = do_set_cpu_speed(PMAC_CPU_HIGH_SPEED);
226
227
	return rc;
228
}
229
230
unsigned int __pmac
231
pmac_get_cur_cpufreq(void)
232
{
233
	return cur_freq;
234
}
235
236
237
/* Currently, we support the following machines:
238
 * 
239
 *  - Titanium PowerBook 800 (PMU based, 667Mhz & 800Mhz)
240
 *  - Titanium PowerBook 500 (PMU based, 300Mhz & 500Mhz)
241
 *  - iBook2 500 (PMU based, 400Mhz & 500Mhz)
242
 *  - iBook2 700 (CPU based, 400Mhz & 700Mhz, support low voltage)
243
 */
244
static int __init
245
pmac_cpufreq_setup(void)
246
{	
247
	struct device_node	*cpunode;
248
	struct cpufreq_driver   *driver;
249
	u32			*value;
250
	int			has_freq_ctl = 0;
251
	int			rc;
252
	
253
	memset(&driver, 0, sizeof(driver));
254
255
	/* Assume only one CPU */
256
	cpunode = find_type_devices("cpu");
257
	if (!cpunode)
258
		goto out;
259
260
	/* Get current cpu clock freq */
261
	value = (u32 *)get_property(cpunode, "clock-frequency", NULL);
262
	if (!value)
263
		goto out;
264
	cur_freq = (*value) / 1000;
265
266
	/* Check for newer machines */
267
	if (machine_is_compatible("PowerBook3,4") ||
268
	    machine_is_compatible("PowerBook3,5") ||
269
	    machine_is_compatible("MacRISC3")) {
270
		value = (u32 *)get_property(cpunode, "min-clock-frequency", NULL);
271
		if (!value)
272
			goto out;
273
		low_freq = (*value) / 1000;
274
		/* The PowerBook G4 12" (PowerBook6,1) has an error in the device-tree
275
		 * here */
276
		if (low_freq < 100000)
277
			low_freq *= 10;
278
		
279
		value = (u32 *)get_property(cpunode, "max-clock-frequency", NULL);
280
		if (!value)
281
			goto out;
282
		hi_freq = (*value) / 1000;			
283
		has_freq_ctl = 1;
284
		cpufreq_uses_pmu = 1;
285
	}
286
	/* Else check for iBook2 500 */
287
	else if (machine_is_compatible("PowerBook4,1")) {
288
		/* We only know about 500Mhz model */
289
		if (cur_freq < 450000 || cur_freq > 550000)
290
			goto out;
291
		hi_freq = cur_freq;
292
		low_freq = 400000;
293
		has_freq_ctl = 1;
294
		cpufreq_uses_pmu = 1;
295
	}
296
	/* Else check for TiPb 500 */
297
	else if (machine_is_compatible("PowerBook3,2")) {
298
		/* We only know about 500Mhz model */
299
		if (cur_freq < 450000 || cur_freq > 550000)
300
			goto out;
301
		hi_freq = cur_freq;
302
		low_freq = 300000;
303
		has_freq_ctl = 1;
304
		cpufreq_uses_pmu = 1;
305
	}
306
	/* Else check for 750FX */
307
	else if (PVR_VER(mfspr(PVR)) == 0x7000) {
308
		if (get_property(cpunode, "dynamic-power-step", NULL) == NULL)
309
			goto out;	
310
		hi_freq = cur_freq;
311
		value = (u32 *)get_property(cpunode, "reduced-clock-frequency", NULL);
312
		if (!value)
313
			goto out;
314
		low_freq = (*value) / 1000;
315
		cpufreq_uses_pmu = 0;
316
		has_freq_ctl = 1;
317
	}
318
out:
319
	if (!has_freq_ctl)
320
		return -ENODEV;
321
	
322
	/* initialization of main "cpufreq" code*/
323
	driver = kmalloc(sizeof(struct cpufreq_driver) + 
324
			 NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL);
325
	if (!driver)
326
		return -ENOMEM;
327
328
	driver->policy = (struct cpufreq_policy *) (driver + 1);
329
330
#ifdef CONFIG_CPU_FREQ_24_API
331
	driver->cpu_min_freq[0] = low_freq;
332
	driver->cpu_cur_freq[0] = cur_freq;
333
#endif
334
335
	driver->verify      = &pmac_cpufreq_verify;
336
	driver->setpolicy   = &pmac_cpufreq_setpolicy;
337
338
	driver->policy[0].cpu    = 0;
339
	driver->policy[0].min    = low_freq;
340
	driver->policy[0].max    = cur_freq;
341
	driver->policy[0].max_cpu_freq = hi_freq;
342
	driver->policy[0].policy = (cur_freq == low_freq) ? 
343
	    CPUFREQ_POLICY_POWERSAVE : CPUFREQ_POLICY_PERFORMANCE;
344
345
	rc = cpufreq_register(driver);
346
	if (rc)
347
		kfree(driver);
348
	return rc;
349
}
350
351
__initcall(pmac_cpufreq_setup);
352
(-)linux-2.4.22/arch/ppc/platforms/pmac_setup.c (-1 / +43 lines)
Lines 50-55 Link Here
50
#include <linux/seq_file.h>
50
#include <linux/seq_file.h>
51
#include <linux/blkdev.h>
51
#include <linux/blkdev.h>
52
#include <linux/genhd.h>
52
#include <linux/genhd.h>
53
#include <linux/cpufreq.h>
53
54
54
#include <asm/processor.h>
55
#include <asm/processor.h>
55
#include <asm/sections.h>
56
#include <asm/sections.h>
Lines 150-156 Link Here
150
{
151
{
151
	struct device_node *cpu_node;
152
	struct device_node *cpu_node;
152
	int *fp, s;
153
	int *fp, s;
153
154
			
155
#ifdef CONFIG_CPU_FREQ_PMAC
156
	extern unsigned int pmac_get_cur_cpufreq(void);
157
	unsigned int freq = pmac_get_cur_cpufreq();
158
	if (freq != 0) {
159
		seq_printf(m, "clock\t\t: %dMHz\n", freq/1000);
160
		return 0;
161
	}
162
#endif /* CONFIG_CPU_FREQ_PMAC */
154
	cpu_node = find_type_devices("cpu");
163
	cpu_node = find_type_devices("cpu");
155
	if (!cpu_node)
164
	if (!cpu_node)
156
		return 0;
165
		return 0;
Lines 197-208 Link Here
197
			}
206
			}
198
			seq_printf(m, "\n");
207
			seq_printf(m, "\n");
199
		}
208
		}
209
		pp = (char *) get_property(np, "scb#", &plen);
210
		if (pp != NULL)
211
			seq_printf(m, "board revision\t: %08x\n", *((int *)pp));
200
	} else
212
	} else
201
		seq_printf(m, "PowerMac\n");
213
		seq_printf(m, "PowerMac\n");
202
214
203
	/* print parsed model */
215
	/* print parsed model */
204
	seq_printf(m, "detected as\t: %d (%s)\n", mbmodel, mbname);
216
	seq_printf(m, "detected as\t: %d (%s)\n", mbmodel, mbname);
205
	seq_printf(m, "pmac flags\t: %08x\n", mbflags);
217
	seq_printf(m, "pmac flags\t: %08x\n", mbflags);
218
#if 0
219
{
220
	extern long nap_return_count;
221
	extern long nap_enter_count;
222
	extern long nap_save_msscr0;
223
	extern long dbg_nap_ret;
224
	seq_printf(m, "nap_return_count: %d\n", nap_return_count);
225
	seq_printf(m, "nap_enter_count\t: %d\n", nap_enter_count);
226
	seq_printf(m, "nap_save_msscr0\t: %x\n", nap_save_msscr0);
227
	seq_printf(m, "dbg_nap_ret\t: %x\n", dbg_nap_ret);
228
}
229
#endif
206
230
207
	/* find l2 cache info */
231
	/* find l2 cache info */
208
	np = find_devices("l2-cache");
232
	np = find_devices("l2-cache");
Lines 309-314 Link Here
309
	sysctrl_regs = (volatile u32 *) ioremap(0xf8000000, 0x1000);
333
	sysctrl_regs = (volatile u32 *) ioremap(0xf8000000, 0x1000);
310
	ohare_init();
334
	ohare_init();
311
335
336
	/* Check & display some CPU config registers for diagnostic */
337
	if (pvr == 0x8000 || pvr == 0x8001) { /* 745x */
338
		printk(KERN_INFO "CPU MSCCR0 : 0x%08x\n", mfspr(SPRN_MSSCR0));
339
		printk(KERN_INFO "CPU HID1   : 0x%08x\n", mfspr(SPRN_HID1));
340
	}
341
	if (pvr == 0x0008 || pvr == 0x7000) /* 750's */
342
		printk(KERN_INFO "CPU HID1 : 0x%08x\n", mfspr(SPRN_HID1));
343
312
	/* Lookup PCI hosts */
344
	/* Lookup PCI hosts */
313
	pmac_find_bridges();
345
	pmac_find_bridges();
314
346
Lines 329-334 Link Here
329
		}
361
		}
330
	}
362
	}
331
363
364
#if 0
365
	printk("MSSCR0: %x\n", mfspr(SPRN_MSSCR0));
366
#endif
332
	if (ppc_override_l2cr)
367
	if (ppc_override_l2cr)
333
		printk(KERN_INFO "L2CR overriden (0x%x), backside cache is %s\n",
368
		printk(KERN_INFO "L2CR overriden (0x%x), backside cache is %s\n",
334
			ppc_override_l2cr_value, (ppc_override_l2cr_value & 0x80000000)
369
			ppc_override_l2cr_value, (ppc_override_l2cr_value & 0x80000000)
Lines 823-828 Link Here
823
#endif /* CONFIG_VT */
858
#endif /* CONFIG_VT */
824
}
859
}
825
860
861
static int __pmac
862
pmac_ide_reserved_hwifs(void)
863
{
864
	return 0;
865
}
866
826
void __init
867
void __init
827
pmac_init(unsigned long r3, unsigned long r4, unsigned long r5,
868
pmac_init(unsigned long r3, unsigned long r4, unsigned long r5,
828
	  unsigned long r6, unsigned long r7)
869
	  unsigned long r6, unsigned long r7)
Lines 864-869 Link Here
864
	select_adb_keyboard();
905
	select_adb_keyboard();
865
906
866
#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
907
#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
908
        ppc_ide_md.reserved_hwifs	= pmac_ide_reserved_hwifs;
867
#ifdef CONFIG_BLK_DEV_IDE_PMAC
909
#ifdef CONFIG_BLK_DEV_IDE_PMAC
868
        ppc_ide_md.ide_init_hwif	= pmac_ide_init_hwif_ports;
910
        ppc_ide_md.ide_init_hwif	= pmac_ide_init_hwif_ports;
869
        ppc_ide_md.default_io_base	= pmac_ide_get_base;
911
        ppc_ide_md.default_io_base	= pmac_ide_get_base;
(-)linux-2.4.22/arch/ppc/platforms/pmac_sleep.S (-2 / +2 lines)
Lines 44-50 Link Here
44
	.text
44
	.text
45
	.align	5
45
	.align	5
46
46
47
#if defined(CONFIG_PMAC_PBOOK)
47
#if defined(CONFIG_PMAC_PBOOK) || defined(CONFIG_CPU_FREQ_PMAC)
48
48
49
/* This gets called by via-pmu.c late during the sleep process.
49
/* This gets called by via-pmu.c late during the sleep process.
50
 * The PMU was already send the sleep command and will shut us down
50
 * The PMU was already send the sleep command and will shut us down
Lines 372-378 Link Here
372
	isync
372
	isync
373
	rfi
373
	rfi
374
374
375
#endif /* defined(CONFIG_PMAC_PBOOK) */
375
#endif /* defined(CONFIG_PMAC_PBOOK) || defined(CONFIG_CPU_FREQ) */
376
376
377
	.data
377
	.data
378
	.balign	L1_CACHE_LINE_SIZE
378
	.balign	L1_CACHE_LINE_SIZE
(-)linux-2.4.22/arch/ppc/xmon/start.c (-6 / +164 lines)
Lines 12-17 Link Here
12
#include <linux/kernel.h>
12
#include <linux/kernel.h>
13
#include <linux/errno.h>
13
#include <linux/errno.h>
14
#include <linux/sysrq.h>
14
#include <linux/sysrq.h>
15
#include <linux/delay.h>
15
#include <asm/prom.h>
16
#include <asm/prom.h>
16
#include <asm/bootx.h>
17
#include <asm/bootx.h>
17
#include <asm/machdep.h>
18
#include <asm/machdep.h>
Lines 24-39 Link Here
24
#include <asm/bitops.h>
25
#include <asm/bitops.h>
25
#endif
26
#endif
26
27
28
#define CONFIG_XMON_FW
29
27
static volatile unsigned char *sccc, *sccd;
30
static volatile unsigned char *sccc, *sccd;
28
unsigned int TXRDY, RXRDY, DLAB;
31
unsigned int TXRDY, RXRDY, DLAB;
29
extern void xmon_printf(const char *fmt, ...);
32
extern void xmon_printf(const char *fmt, ...);
30
static int xmon_expect(const char *str, unsigned int timeout);
33
static int xmon_expect(const char *str, unsigned int timeout);
34
extern char cmd_line[512];
31
35
32
static int use_screen;
36
static int use_screen;
33
static int via_modem;
37
static int via_modem;
34
static int xmon_use_sccb;
38
static int xmon_use_sccb;
35
static struct device_node *channel_node;
39
static struct device_node *channel_node;
36
40
41
/* There are used when hooked via firewire */
42
#ifdef CONFIG_XMON_FW
43
volatile unsigned int xmon_fw_outbuf_size;
44
volatile unsigned char xmon_fw_outbuf[1024];
45
volatile unsigned int xmon_fw_oflags;
46
volatile unsigned int xmon_fw_iflags;
47
volatile unsigned int xmon_fw_idata;
48
#define XMON_FW_FLAGS_OUT_ENTERED	0x00000001
49
#define XMON_FW_FLAGS_OUT_DATA		0x00000002
50
#define XMON_FW_FLAGS_OUT_ACK		0x00000004
51
#define XMON_FW_FLAGS_IN_ATTACHED	0x00000001
52
#define XMON_FW_FLAGS_IN_DATA		0x00000002
53
#define XMON_FW_FLAGS_IN_ACK		0x00000004
54
#endif
55
37
#define TB_SPEED	25000000
56
#define TB_SPEED	25000000
38
57
39
static inline unsigned int readtb(void)
58
static inline unsigned int readtb(void)
Lines 112-118 Link Here
112
	volatile unsigned char *base;
131
	volatile unsigned char *base;
113
132
114
	use_screen = 0;
133
	use_screen = 0;
115
134
	/* Typically used for firewire debugging */
135
	if (strstr(cmd_line, "xmon_noio"))
136
		return;
116
	if (_machine == _MACH_Pmac) {
137
	if (_machine == _MACH_Pmac) {
117
		struct device_node *np;
138
		struct device_node *np;
118
		unsigned long addr;
139
		unsigned long addr;
Lines 215-234 Link Here
215
	DLAB = 0x80;
236
	DLAB = 0x80;
216
#endif /* platform */
237
#endif /* platform */
217
238
239
#ifdef CONFIG_MAGIC_SYSRQ
218
	__sysrq_put_key_op('x', &sysrq_xmon_op);
240
	__sysrq_put_key_op('x', &sysrq_xmon_op);
241
#endif	
219
}
242
}
220
243
221
static int scc_initialized = 0;
244
static int scc_initialized = 0;
222
245
223
void xmon_init_scc(void);
246
void xmon_init_scc(void);
224
extern void pmu_poll(void);
225
extern void cuda_poll(void);
247
extern void cuda_poll(void);
226
248
227
static inline void do_poll_adb(void)
249
static inline void do_poll_adb(void)
228
{
250
{
229
#ifdef CONFIG_ADB_PMU
251
#ifdef CONFIG_ADB_PMU
230
	if (sys_ctrler == SYS_CTRLER_PMU)
252
	if (sys_ctrler == SYS_CTRLER_PMU)
231
		pmu_poll();
253
		pmu_poll_adb();
232
#endif /* CONFIG_ADB_PMU */
254
#endif /* CONFIG_ADB_PMU */
233
#ifdef CONFIG_ADB_CUDA
255
#ifdef CONFIG_ADB_CUDA
234
	if (sys_ctrler == SYS_CTRLER_CUDA)
256
	if (sys_ctrler == SYS_CTRLER_CUDA)
Lines 236-241 Link Here
236
#endif /* CONFIG_ADB_CUDA */
258
#endif /* CONFIG_ADB_CUDA */
237
}
259
}
238
260
261
#if 0
262
static void
263
bx_printf(const char* fmt, ...)
264
{
265
	static char dbgbuf[2048];
266
	va_list ap;
267
	int n;
268
269
	va_start(ap, fmt);
270
	n = vsprintf(dbgbuf, fmt, ap);
271
	va_end(ap);
272
	btext_drawstring(dbgbuf);
273
}
274
#endif
275
276
#ifdef CONFIG_XMON_FW
277
static int
278
xmon_fw_write(void* ptr, int nb)
279
{
280
	char* p = (char *)ptr;
281
	int c, i;
282
283
	while (nb && (xmon_fw_iflags & XMON_FW_FLAGS_IN_ATTACHED)) {
284
		c = (nb > 1024) ? 1024 : nb;
285
		memcpy((void *)xmon_fw_outbuf, p, c);
286
		xmon_fw_outbuf_size = c;
287
		wmb();
288
		xmon_fw_oflags |= XMON_FW_FLAGS_OUT_DATA;
289
		wmb();
290
		for (i=0; i<1000; i++) {
291
			rmb();
292
			if (xmon_fw_iflags & XMON_FW_FLAGS_IN_ACK)
293
				break;
294
			mdelay(1);
295
		}
296
		xmon_fw_oflags &= ~XMON_FW_FLAGS_OUT_DATA;
297
		wmb();
298
		if ((xmon_fw_iflags & XMON_FW_FLAGS_IN_ACK) == 0) {
299
			xmon_fw_iflags = 0;
300
			break;
301
		}
302
		for (i=0; i<1000; i++) {
303
			rmb();
304
			if ((xmon_fw_iflags & XMON_FW_FLAGS_IN_ACK) == 0)
305
				break;
306
			mdelay(1);
307
		}
308
		if ((xmon_fw_iflags & XMON_FW_FLAGS_IN_ACK) != 0) {
309
			xmon_fw_iflags = 0;
310
			break;
311
		}
312
		nb -= c;
313
		p += c;
314
	}
315
	return (xmon_fw_iflags & XMON_FW_FLAGS_IN_ATTACHED) != 0;
316
}
317
318
static int
319
xmon_fw_read(void* ptr, int nb)
320
{
321
	int t, on, i;
322
	unsigned int k;
323
	char c[3];
324
	char* p = (char *)ptr;
325
	
326
	while (nb) {
327
		t = 0;
328
		on = 0;
329
		while(xmon_fw_iflags & XMON_FW_FLAGS_IN_ATTACHED) {
330
			if (xmon_fw_iflags & XMON_FW_FLAGS_IN_DATA)
331
				break;
332
			if (--t < 0) {
333
				on = 1 - on;
334
				c[0] = on? 0xdb: 0x20;
335
				c[1] = '\b';
336
				if (!xmon_fw_write(c, 2))
337
					break;
338
				t = 2000000;
339
			}
340
			rmb();
341
		}
342
		k = xmon_fw_idata & 0xff;
343
		xmon_fw_oflags |= XMON_FW_FLAGS_OUT_ACK;
344
		wmb();
345
		for (i=0; i<1000; i++) {
346
			rmb();
347
			if ((xmon_fw_iflags & XMON_FW_FLAGS_IN_DATA) == 0)
348
				break;
349
			mdelay(1);
350
		}
351
		if (xmon_fw_iflags & XMON_FW_FLAGS_IN_DATA) {
352
			xmon_fw_iflags = 0;
353
			break;
354
		}
355
		xmon_fw_oflags &= ~XMON_FW_FLAGS_OUT_ACK;
356
		wmb();
357
		if (on) {
358
			c[0] = 0x20; c[1] = '\b';
359
			xmon_fw_write(c, 2);
360
		}
361
		*(p++) = k;
362
		nb--;
363
	}
364
	return (xmon_fw_iflags & XMON_FW_FLAGS_IN_ATTACHED) != 0;
365
}
366
367
#endif /* CONFIG_XMON_FW */
368
239
int
369
int
240
xmon_write(void *handle, void *ptr, int nb)
370
xmon_write(void *handle, void *ptr, int nb)
241
{
371
{
Lines 251-259 Link Here
251
		if (--lock_wait == 0)
381
		if (--lock_wait == 0)
252
			break;
382
			break;
253
#endif
383
#endif
254
384
#ifdef CONFIG_XMON_FW
385
	if (xmon_fw_write(ptr, nb))
386
		goto out;
387
#endif /* CONFIG_XMON_FW */
255
#ifdef CONFIG_BOOTX_TEXT
388
#ifdef CONFIG_BOOTX_TEXT
256
	if (use_screen) {
389
#ifdef CONFIG_MORE_DEBUG
390
	if (1)
391
#else
392
	if (use_screen)
393
#endif
394
	{
257
		/* write it on the screen */
395
		/* write it on the screen */
258
		for (i = 0; i < nb; ++i)
396
		for (i = 0; i < nb; ++i)
259
			btext_drawchar(*p++);
397
			btext_drawchar(*p++);
Lines 262-267 Link Here
262
#endif
400
#endif
263
	if (!scc_initialized)
401
	if (!scc_initialized)
264
		xmon_init_scc();
402
		xmon_init_scc();
403
	if (!sccd)
404
		goto out;
405
	
265
	ct = 0;
406
	ct = 0;
266
	for (i = 0; i < nb; ++i) {
407
	for (i = 0; i < nb; ++i) {
267
		while ((*sccc & TXRDY) == 0)
408
		while ((*sccc & TXRDY) == 0)
Lines 354-359 Link Here
354
    char *p = ptr;
495
    char *p = ptr;
355
    int i;
496
    int i;
356
497
498
#ifdef CONFIG_XMON_FW
499
	if (xmon_fw_read(ptr, nb))
500
		return nb;
501
#endif /* CONFIG_XMON_FW */		
357
#ifdef CONFIG_BOOTX_TEXT
502
#ifdef CONFIG_BOOTX_TEXT
358
    if (use_screen) {
503
    if (use_screen) {
359
	for (i = 0; i < nb; ++i)
504
	for (i = 0; i < nb; ++i)
Lines 363-368 Link Here
363
#endif
508
#endif
364
    if (!scc_initialized)
509
    if (!scc_initialized)
365
	xmon_init_scc();
510
	xmon_init_scc();
511
    if (sccd == NULL)
512
    	return 0;
366
    for (i = 0; i < nb; ++i) {
513
    for (i = 0; i < nb; ++i) {
367
	while ((*sccc & RXRDY) == 0)
514
	while ((*sccc & RXRDY) == 0)
368
	    do_poll_adb();
515
	    do_poll_adb();
Lines 385-391 Link Here
385
532
386
static unsigned char scc_inittab[] = {
533
static unsigned char scc_inittab[] = {
387
    13, 0,		/* set baud rate divisor */
534
    13, 0,		/* set baud rate divisor */
388
    12, 1,
535
//    12, 1,
536
    12, 0,
389
    14, 1,		/* baud rate gen enable, src=rtxc */
537
    14, 1,		/* baud rate gen enable, src=rtxc */
390
    11, 0x50,		/* clocks = br gen */
538
    11, 0x50,		/* clocks = br gen */
391
    5,  0xea,		/* tx 8 bits, assert DTR & RTS */
539
    5,  0xea,		/* tx 8 bits, assert DTR & RTS */
Lines 396-401 Link Here
396
void
544
void
397
xmon_init_scc()
545
xmon_init_scc()
398
{
546
{
547
	if (sccd == NULL && channel_node == NULL)
548
		return;
399
	if ( _machine == _MACH_chrp )
549
	if ( _machine == _MACH_chrp )
400
	{
550
	{
401
		sccd[3] = 0x83; eieio();	/* LCR = 8N1 + DLAB */
551
		sccd[3] = 0x83; eieio();	/* LCR = 8N1 + DLAB */
Lines 634-644 Link Here
634
		pmu_suspend();
784
		pmu_suspend();
635
	}
785
	}
636
#endif
786
#endif
787
#ifdef CONFIG_XMON_FW
788
	xmon_fw_oflags |= XMON_FW_FLAGS_OUT_ENTERED;
789
	wmb();
790
#endif /* CONFIG_XMON_FW */
637
}
791
}
638
792
639
void
793
void
640
xmon_leave(void)
794
xmon_leave(void)
641
{
795
{
796
#ifdef CONFIG_XMON_FW
797
	xmon_fw_oflags &= ~XMON_FW_FLAGS_OUT_ENTERED;
798
	wmb();
799
#endif /* CONFIG_XMON_FW */
642
#ifdef CONFIG_ADB_PMU
800
#ifdef CONFIG_ADB_PMU
643
	if (_machine == _MACH_Pmac) {
801
	if (_machine == _MACH_Pmac) {
644
		pmu_resume();
802
		pmu_resume();
(-)linux-2.4.22/arch/ppc/xmon/xmon.c (-7 / +9 lines)
Lines 209-222 Link Here
209
#endif /* CONFIG_SMP */
209
#endif /* CONFIG_SMP */
210
	remove_bpts();
210
	remove_bpts();
211
#ifdef CONFIG_PMAC_BACKLIGHT
211
#ifdef CONFIG_PMAC_BACKLIGHT
212
	if( setjmp(bus_error_jmp) == 0 ) {
212
	if (_machine == _MACH_Pmac) {
213
		debugger_fault_handler = handle_fault;
213
		if( setjmp(bus_error_jmp) == 0 ) {
214
		sync();
214
			debugger_fault_handler = handle_fault;
215
		set_backlight_enable(1);
215
			sync();
216
		set_backlight_level(BACKLIGHT_MAX);
216
			set_backlight_enable(1);
217
		sync();
217
			set_backlight_level(BACKLIGHT_MAX);
218
			sync();
219
		}
220
		debugger_fault_handler = 0;
218
	}
221
	}
219
	debugger_fault_handler = 0;
220
#endif	/* CONFIG_PMAC_BACKLIGHT */
222
#endif	/* CONFIG_PMAC_BACKLIGHT */
221
	cmd = cmds(excp);
223
	cmd = cmds(excp);
222
	if (cmd == 's') {
224
	if (cmd == 's') {
(-)linux-2.4.22/arch/s390/mm/fault.c (-1 / +1 lines)
Lines 210-216 Link Here
210
                goto good_area;
210
                goto good_area;
211
        if (!(vma->vm_flags & VM_GROWSDOWN))
211
        if (!(vma->vm_flags & VM_GROWSDOWN))
212
                goto bad_area;
212
                goto bad_area;
213
        if (expand_stack(vma, address))
213
	if (expand_stack(vma, address, NULL))
214
                goto bad_area;
214
                goto bad_area;
215
/*
215
/*
216
 * Ok, we have a good vm_area for this memory access, so
216
 * Ok, we have a good vm_area for this memory access, so
(-)linux-2.4.22/arch/s390x/mm/fault.c (-1 / +1 lines)
Lines 210-216 Link Here
210
                goto good_area;
210
                goto good_area;
211
        if (!(vma->vm_flags & VM_GROWSDOWN))
211
        if (!(vma->vm_flags & VM_GROWSDOWN))
212
                goto bad_area;
212
                goto bad_area;
213
        if (expand_stack(vma, address))
213
        if (expand_stack(vma, address, NULL))
214
                goto bad_area;
214
                goto bad_area;
215
/*
215
/*
216
 * Ok, we have a good vm_area for this memory access, so
216
 * Ok, we have a good vm_area for this memory access, so
(-)linux-2.4.22/arch/sh/mm/fault.c (-2 / +2 lines)
Lines 78-84 Link Here
78
check_stack:
78
check_stack:
79
	if (!(vma->vm_flags & VM_GROWSDOWN))
79
	if (!(vma->vm_flags & VM_GROWSDOWN))
80
		goto bad_area;
80
		goto bad_area;
81
	if (expand_stack(vma, start) == 0)
81
	if (expand_stack(vma, start, NULL) == 0)
82
		goto good_area;
82
		goto good_area;
83
83
84
bad_area:
84
bad_area:
Lines 123-129 Link Here
123
		goto good_area;
123
		goto good_area;
124
	if (!(vma->vm_flags & VM_GROWSDOWN))
124
	if (!(vma->vm_flags & VM_GROWSDOWN))
125
		goto bad_area;
125
		goto bad_area;
126
	if (expand_stack(vma, address))
126
	if (expand_stack(vma, address, NULL))
127
		goto bad_area;
127
		goto bad_area;
128
/*
128
/*
129
 * Ok, we have a good vm_area for this memory access, so
129
 * Ok, we have a good vm_area for this memory access, so
(-)linux-2.4.22/arch/sparc/mm/fault.c (-2 / +2 lines)
Lines 251-257 Link Here
251
		goto good_area;
251
		goto good_area;
252
	if(!(vma->vm_flags & VM_GROWSDOWN))
252
	if(!(vma->vm_flags & VM_GROWSDOWN))
253
		goto bad_area;
253
		goto bad_area;
254
	if(expand_stack(vma, address))
254
	if(expand_stack(vma, address, NULL))
255
		goto bad_area;
255
		goto bad_area;
256
	/*
256
	/*
257
	 * Ok, we have a good vm_area for this memory access, so
257
	 * Ok, we have a good vm_area for this memory access, so
Lines 498-504 Link Here
498
		goto good_area;
498
		goto good_area;
499
	if(!(vma->vm_flags & VM_GROWSDOWN))
499
	if(!(vma->vm_flags & VM_GROWSDOWN))
500
		goto bad_area;
500
		goto bad_area;
501
	if(expand_stack(vma, address))
501
	if(expand_stack(vma, address, NULL))
502
		goto bad_area;
502
		goto bad_area;
503
good_area:
503
good_area:
504
	info.si_code = SEGV_ACCERR;
504
	info.si_code = SEGV_ACCERR;
(-)linux-2.4.22/arch/sparc64/mm/fault.c (-1 / +1 lines)
Lines 389-395 Link Here
389
				goto bad_area;
389
				goto bad_area;
390
		}
390
		}
391
	}
391
	}
392
	if (expand_stack(vma, address))
392
	if (expand_stack(vma, address, NULL))
393
		goto bad_area;
393
		goto bad_area;
394
	/*
394
	/*
395
	 * Ok, we have a good vm_area for this memory access, so
395
	 * Ok, we have a good vm_area for this memory access, so
(-)linux-2.4.22/drivers/block/ll_rw_blk.c (+33 lines)
Lines 121-126 Link Here
121
unsigned long blk_max_low_pfn, blk_max_pfn;
121
unsigned long blk_max_low_pfn, blk_max_pfn;
122
int blk_nohighio = 0;
122
int blk_nohighio = 0;
123
123
124
int block_dump = 0;
125
126
static struct timer_list writeback_timer;
127
124
static inline int get_max_sectors(kdev_t dev)
128
static inline int get_max_sectors(kdev_t dev)
125
{
129
{
126
	if (!max_sectors[MAJOR(dev)])
130
	if (!max_sectors[MAJOR(dev)])
Lines 158-163 Link Here
158
	return i;
162
	return i;
159
}
163
}
160
164
165
void blk_queue_activity_fn(request_queue_t *q, activity_fn *fn, void *data)
166
{
167
	q->activity_fn = fn;
168
	q->activity_data = data;
169
}
170
161
/**
171
/**
162
 * blk_cleanup_queue: - release a &request_queue_t when it is no longer needed
172
 * blk_cleanup_queue: - release a &request_queue_t when it is no longer needed
163
 * @q:    the request queue to be released
173
 * @q:    the request queue to be released
Lines 540-545 Link Here
540
	q->head_active    	= 1;
550
	q->head_active    	= 1;
541
551
542
	blk_queue_bounce_limit(q, BLK_BOUNCE_HIGH);
552
	blk_queue_bounce_limit(q, BLK_BOUNCE_HIGH);
553
	blk_queue_activity_fn(q, NULL, NULL);
543
}
554
}
544
555
545
#define blkdev_free_rq(list) list_entry((list)->next, struct request, queue);
556
#define blkdev_free_rq(list) list_entry((list)->next, struct request, queue);
Lines 855-860 Link Here
855
static inline void add_request(request_queue_t * q, struct request * req,
866
static inline void add_request(request_queue_t * q, struct request * req,
856
			       struct list_head *insert_here)
867
			       struct list_head *insert_here)
857
{
868
{
869
	if (q->activity_fn)
870
		q->activity_fn(q->activity_data, req->cmd);
871
858
	drive_stat_acct(req->rq_dev, req->cmd, req->nr_sectors, 1);
872
	drive_stat_acct(req->rq_dev, req->cmd, req->nr_sectors, 1);
859
873
860
	if (!q->plugged && q->head_active && insert_here == &q->queue_head) {
874
	if (!q->plugged && q->head_active && insert_here == &q->queue_head) {
Lines 1302-1307 Link Here
1302
			kstat.pgpgin += count;
1316
			kstat.pgpgin += count;
1303
			break;
1317
			break;
1304
	}
1318
	}
1319
1320
	if (block_dump)
1321
		printk("%s: %s block %lu/%u on %s\n", current->comm, rw == WRITE ? "WRITE" : "READ", bh->b_rsector, count, kdevname(bh->b_rdev));
1305
}
1322
}
1306
1323
1307
/**
1324
/**
Lines 1413-1418 Link Here
1413
extern int stram_device_init (void);
1430
extern int stram_device_init (void);
1414
#endif
1431
#endif
1415
1432
1433
static void blk_writeback_timer(unsigned long data)
1434
{
1435
	wakeup_bdflush();
1436
	wakeup_kupdate();
1437
}
1416
1438
1417
/**
1439
/**
1418
 * end_that_request_first - end I/O on one buffer.
1440
 * end_that_request_first - end I/O on one buffer.
Lines 1469-1478 Link Here
1469
	return 0;
1491
	return 0;
1470
}
1492
}
1471
1493
1494
extern int laptop_mode;
1495
1472
void end_that_request_last(struct request *req)
1496
void end_that_request_last(struct request *req)
1473
{
1497
{
1474
	struct completion *waiting = req->waiting;
1498
	struct completion *waiting = req->waiting;
1475
1499
1500
	/*
1501
	 * schedule the writeout of pending dirty data when the disk is idle
1502
	 */
1503
	if (laptop_mode && req->cmd == READ)
1504
		mod_timer(&writeback_timer, jiffies + 5 * HZ);
1505
1476
	req_finished_io(req);
1506
	req_finished_io(req);
1477
	blkdev_release_request(req);
1507
	blkdev_release_request(req);
1478
	if (waiting)
1508
	if (waiting)
Lines 1500-1505 Link Here
1500
	blk_max_low_pfn = max_low_pfn - 1;
1530
	blk_max_low_pfn = max_low_pfn - 1;
1501
	blk_max_pfn = max_pfn - 1;
1531
	blk_max_pfn = max_pfn - 1;
1502
1532
1533
	init_timer(&writeback_timer);
1534
	writeback_timer.function = blk_writeback_timer;
1535
1503
#ifdef CONFIG_AMIGA_Z2RAM
1536
#ifdef CONFIG_AMIGA_Z2RAM
1504
	z2_init();
1537
	z2_init();
1505
#endif
1538
#endif
(-)linux-2.4.22/drivers/char/Config.in (+1 lines)
Lines 315-320 Link Here
315
   if [ "$CONFIG_IA64" = "y" ]; then
315
   if [ "$CONFIG_IA64" = "y" ]; then
316
      bool '  HP ZX1 AGP support' CONFIG_AGP_HP_ZX1
316
      bool '  HP ZX1 AGP support' CONFIG_AGP_HP_ZX1
317
   fi
317
   fi
318
   dep_bool '  Apple UniNorth support' CONFIG_AGP_UNINORTH $CONFIG_ALL_PPC
318
fi
319
fi
319
320
320
bool 'Direct Rendering Manager (XFree86 DRI support)' CONFIG_DRM
321
bool 'Direct Rendering Manager (XFree86 DRI support)' CONFIG_DRM
(-)linux-2.4.22/drivers/char/agp/agpgart_be.c (-1 / +430 lines)
Lines 52-57 Link Here
52
#ifdef CONFIG_AGP_NVIDIA
52
#ifdef CONFIG_AGP_NVIDIA
53
    #include <asm/msr.h>
53
    #include <asm/msr.h>
54
#endif
54
#endif
55
#ifdef CONFIG_AGP_UNINORTH
56
#include <asm/uninorth.h>
57
#endif
55
58
56
#include <linux/agp_backend.h>
59
#include <linux/agp_backend.h>
57
#include "agp.h"
60
#include "agp.h"
Lines 80-86 Link Here
80
{
83
{
81
#if defined(__i386__) || defined(__x86_64__)
84
#if defined(__i386__) || defined(__x86_64__)
82
	asm volatile ("wbinvd":::"memory");
85
	asm volatile ("wbinvd":::"memory");
83
#elif defined(__alpha__) || defined(__ia64__) || defined(__sparc__)
86
#elif defined(__alpha__) || defined(__ia64__) || defined(__sparc__) || defined(__powerpc__)
84
	/* ??? I wonder if we'll really need to flush caches, or if the
87
	/* ??? I wonder if we'll really need to flush caches, or if the
85
	   core logic can manage to keep the system coherent.  The ARM
88
	   core logic can manage to keep the system coherent.  The ARM
86
	   speaks only of using `cflush' to get things in memory in
89
	   speaks only of using `cflush' to get things in memory in
Lines 4735-4740 Link Here
4735
4738
4736
#endif /* CONFIG_AGP_HP_ZX1 */
4739
#endif /* CONFIG_AGP_HP_ZX1 */
4737
4740
4741
#ifdef CONFIG_AGP_UNINORTH
4742
4743
static int uninorth_fetch_size(void)
4744
{
4745
	int i;
4746
	u32 temp;
4747
	aper_size_info_32 *values;
4748
4749
	pci_read_config_dword(agp_bridge.dev, UNI_N_CFG_GART_BASE, &temp);
4750
	temp &= ~(0xfffff000);
4751
	values = A_SIZE_32(agp_bridge.aperture_sizes);
4752
4753
	for (i = 0; i < agp_bridge.num_aperture_sizes; i++) {
4754
		if (temp == values[i].size_value) {
4755
			agp_bridge.previous_size =
4756
			    agp_bridge.current_size = (void *) (values + i);
4757
			agp_bridge.aperture_size_idx = i;
4758
			return values[i].size;
4759
		}
4760
	}
4761
4762
	agp_bridge.previous_size =
4763
	    agp_bridge.current_size = (void *) (values + 1);
4764
	agp_bridge.aperture_size_idx = 1;
4765
	return values[1].size;
4766
4767
	return 0;
4768
}
4769
4770
static void uninorth_tlbflush(agp_memory * mem)
4771
{
4772
	pci_write_config_dword(agp_bridge.dev, UNI_N_CFG_GART_CTRL,
4773
			UNI_N_CFG_GART_ENABLE | UNI_N_CFG_GART_INVAL);
4774
	pci_write_config_dword(agp_bridge.dev, UNI_N_CFG_GART_CTRL,
4775
			UNI_N_CFG_GART_ENABLE);
4776
	pci_write_config_dword(agp_bridge.dev, UNI_N_CFG_GART_CTRL,
4777
			UNI_N_CFG_GART_ENABLE | UNI_N_CFG_GART_2xRESET);
4778
	pci_write_config_dword(agp_bridge.dev, UNI_N_CFG_GART_CTRL,
4779
			UNI_N_CFG_GART_ENABLE);
4780
}
4781
4782
static void uninorth_cleanup(void)
4783
{
4784
	pci_write_config_dword(agp_bridge.dev, UNI_N_CFG_GART_CTRL,
4785
			UNI_N_CFG_GART_ENABLE | UNI_N_CFG_GART_INVAL);
4786
	pci_write_config_dword(agp_bridge.dev, UNI_N_CFG_GART_CTRL,
4787
			0);
4788
	pci_write_config_dword(agp_bridge.dev, UNI_N_CFG_GART_CTRL,
4789
			UNI_N_CFG_GART_2xRESET);
4790
	pci_write_config_dword(agp_bridge.dev, UNI_N_CFG_GART_CTRL,
4791
			0);
4792
}
4793
4794
static int uninorth_configure(void)
4795
{
4796
	aper_size_info_32 *current_size;
4797
	
4798
	current_size = A_SIZE_32(agp_bridge.current_size);
4799
4800
	printk("agp: configuring for size idx: %d\n", current_size->size_value);
4801
	
4802
	/* aperture size and gatt addr */
4803
	pci_write_config_dword(agp_bridge.dev,
4804
		UNI_N_CFG_GART_BASE,
4805
		(agp_bridge.gatt_bus_addr & 0xfffff000)
4806
			| current_size->size_value);
4807
4808
	/* HACK ALERT
4809
	 * UniNorth seem to be buggy enough not to handle properly when
4810
	 * the AGP aperture isn't mapped at bus physical address 0
4811
	 */
4812
	agp_bridge.gart_bus_addr = 0;
4813
	pci_write_config_dword(agp_bridge.dev,
4814
		UNI_N_CFG_AGP_BASE, agp_bridge.gart_bus_addr);
4815
	
4816
	return 0;
4817
}
4818
4819
static unsigned long uninorth_mask_memory(unsigned long addr, int type)
4820
{
4821
	return addr;/* | agp_bridge.masks[0].mask;*/
4822
}
4823
4824
static int uninorth_insert_memory(agp_memory * mem,
4825
				     off_t pg_start, int type)
4826
{
4827
	int i, j, num_entries;
4828
	void *temp;
4829
4830
	temp = agp_bridge.current_size;
4831
	num_entries = A_SIZE_32(temp)->num_entries;
4832
4833
	if (type != 0 || mem->type != 0) {
4834
		/* The generic routines know nothing of memory types */
4835
		return -EINVAL;
4836
	}
4837
	if ((pg_start + mem->page_count) > num_entries) {
4838
		return -EINVAL;
4839
	}
4840
	j = pg_start;
4841
4842
	while (j < (pg_start + mem->page_count)) {
4843
		if (!PGE_EMPTY(agp_bridge.gatt_table[j])) {
4844
			return -EBUSY;
4845
		}
4846
		j++;
4847
	}
4848
4849
	if (mem->is_flushed == FALSE) {
4850
		CACHE_FLUSH();
4851
		mem->is_flushed = TRUE;
4852
	}
4853
	for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
4854
		agp_bridge.gatt_table[j] = cpu_to_le32((mem->memory[i] & 0xfffff000) | 0x00000001UL);
4855
		flush_dcache_range(__va(mem->memory[i]), __va(mem->memory[i])+0x1000);
4856
	}
4857
	(void)in_le32((volatile u32*)&agp_bridge.gatt_table[pg_start]);
4858
	mb();
4859
	flush_dcache_range((unsigned long)&agp_bridge.gatt_table[pg_start], 
4860
		(unsigned long)&agp_bridge.gatt_table[pg_start + mem->page_count]);
4861
4862
	agp_bridge.tlb_flush(mem);
4863
	return 0;
4864
}
4865
4866
static void uninorth_agp_enable(u32 mode)
4867
{
4868
	struct pci_dev *device = NULL;
4869
	u32 command, scratch, cap_id;
4870
	u8 cap_ptr;
4871
4872
	pci_read_config_dword(agp_bridge.dev,
4873
			      agp_bridge.capndx + 4,
4874
			      &command);
4875
4876
	/*
4877
	 * PASS1: go throu all devices that claim to be
4878
	 *        AGP devices and collect their data.
4879
	 */
4880
4881
	while ((device = pci_find_class(PCI_CLASS_DISPLAY_VGA << 8,
4882
					device)) != NULL) {
4883
		pci_read_config_dword(device, 0x04, &scratch);
4884
4885
		if (!(scratch & 0x00100000))
4886
			continue;
4887
4888
		pci_read_config_byte(device, 0x34, &cap_ptr);
4889
4890
		if (cap_ptr != 0x00) {
4891
			do {
4892
				pci_read_config_dword(device,
4893
						      cap_ptr, &cap_id);
4894
4895
				if ((cap_id & 0xff) != 0x02)
4896
					cap_ptr = (cap_id >> 8) & 0xff;
4897
			}
4898
			while (((cap_id & 0xff) != 0x02) && (cap_ptr != 0x00));
4899
		}
4900
		if (cap_ptr != 0x00) {
4901
			/*
4902
			 * Ok, here we have a AGP device. Disable impossible 
4903
			 * settings, and adjust the readqueue to the minimum.
4904
			 */
4905
4906
			pci_read_config_dword(device, cap_ptr + 4, &scratch);
4907
4908
			/* adjust RQ depth */
4909
			command =
4910
			    ((command & ~0xff000000) |
4911
			     min_t(u32, (mode & 0xff000000),
4912
				 min_t(u32, (command & 0xff000000),
4913
				     (scratch & 0xff000000))));
4914
4915
			/* disable SBA if it's not supported */
4916
			if (!((command & 0x00000200) &&
4917
			      (scratch & 0x00000200) &&
4918
			      (mode & 0x00000200)))
4919
				command &= ~0x00000200;
4920
4921
			/* disable FW if it's not supported */
4922
			if (!((command & 0x00000010) &&
4923
			      (scratch & 0x00000010) &&
4924
			      (mode & 0x00000010)))
4925
				command &= ~0x00000010;
4926
4927
			if (!((command & 4) &&
4928
			      (scratch & 4) &&
4929
			      (mode & 4)))
4930
				command &= ~0x00000004;
4931
4932
			if (!((command & 2) &&
4933
			      (scratch & 2) &&
4934
			      (mode & 2)))
4935
				command &= ~0x00000002;
4936
4937
			if (!((command & 1) &&
4938
			      (scratch & 1) &&
4939
			      (mode & 1)))
4940
				command &= ~0x00000001;
4941
		}
4942
	}
4943
	/*
4944
	 * PASS2: Figure out the 4X/2X/1X setting and enable the
4945
	 *        target (our motherboard chipset).
4946
	 */
4947
4948
	if (command & 4) {
4949
		command &= ~3;	/* 4X */
4950
	}
4951
	if (command & 2) {
4952
		command &= ~5;	/* 2X */
4953
	}
4954
	if (command & 1) {
4955
		command &= ~6;	/* 1X */
4956
	}
4957
	command |= 0x00000100;
4958
4959
	uninorth_tlbflush(NULL);
4960
4961
	do {
4962
		pci_write_config_dword(agp_bridge.dev,
4963
				       agp_bridge.capndx + 8,
4964
				       command);
4965
		pci_read_config_dword(agp_bridge.dev,
4966
				       agp_bridge.capndx + 8,
4967
				       &scratch);
4968
	} while((scratch & 0x100) == 0);
4969
4970
	/*
4971
	 * PASS3: Go throu all AGP devices and update the
4972
	 *        command registers.
4973
	 */
4974
4975
	while ((device = pci_find_class(PCI_CLASS_DISPLAY_VGA << 8,
4976
					device)) != NULL) {
4977
		pci_read_config_dword(device, 0x04, &scratch);
4978
4979
		if (!(scratch & 0x00100000))
4980
			continue;
4981
4982
		pci_read_config_byte(device, 0x34, &cap_ptr);
4983
4984
		if (cap_ptr != 0x00) {
4985
			do {
4986
				pci_read_config_dword(device,
4987
						      cap_ptr, &cap_id);
4988
4989
				if ((cap_id & 0xff) != 0x02)
4990
					cap_ptr = (cap_id >> 8) & 0xff;
4991
			}
4992
			while (((cap_id & 0xff) != 0x02) && (cap_ptr != 0x00));
4993
		}
4994
		if (cap_ptr != 0x00)
4995
			pci_write_config_dword(device, cap_ptr + 8, command);
4996
	}
4997
4998
	uninorth_tlbflush(NULL);
4999
}
5000
5001
static int uninorth_create_gatt_table(void)
5002
{
5003
	char *table;
5004
	char *table_end;
5005
	int size;
5006
	int page_order;
5007
	int num_entries;
5008
	int i;
5009
	void *temp;
5010
	struct page *page;
5011
5012
	/* The generic routines can't handle 2 level gatt's */
5013
	if (agp_bridge.size_type == LVL2_APER_SIZE) {
5014
		return -EINVAL;
5015
	}
5016
5017
	table = NULL;
5018
	i = agp_bridge.aperture_size_idx;
5019
	temp = agp_bridge.current_size;
5020
	size = page_order = num_entries = 0;
5021
5022
	do {
5023
		size = A_SIZE_32(temp)->size;
5024
		page_order = A_SIZE_32(temp)->page_order;
5025
		num_entries = A_SIZE_32(temp)->num_entries;
5026
5027
		table = (char *) __get_free_pages(GFP_KERNEL, page_order);
5028
5029
		if (table == NULL) {
5030
			i++;
5031
			agp_bridge.current_size = A_IDX32();
5032
		} else {
5033
			agp_bridge.aperture_size_idx = i;
5034
		}
5035
	} while ((table == NULL) &&
5036
			 (i < agp_bridge.num_aperture_sizes));
5037
5038
	if (table == NULL) {
5039
		return -ENOMEM;
5040
	}
5041
	table_end = table + ((PAGE_SIZE * (1 << page_order)) - 1);
5042
5043
	for (page = virt_to_page(table); page <= virt_to_page(table_end); page++)
5044
		SetPageReserved(page);
5045
5046
	agp_bridge.gatt_table_real = (unsigned long *) table;
5047
	agp_bridge.gatt_table = (unsigned long *)table;
5048
	agp_bridge.gatt_bus_addr = virt_to_phys(table);
5049
5050
	for (i = 0; i < num_entries; i++) {
5051
		agp_bridge.gatt_table[i] =
5052
		    (unsigned long) agp_bridge.scratch_page;
5053
	}
5054
5055
	flush_dcache_range((unsigned long)table, (unsigned long)table_end);
5056
5057
	return 0;
5058
}
5059
5060
static int uninorth_free_gatt_table(void)
5061
{
5062
	int page_order;
5063
	char *table, *table_end;
5064
	void *temp;
5065
	struct page *page;
5066
5067
	temp = agp_bridge.current_size;
5068
	page_order = A_SIZE_32(temp)->page_order;
5069
5070
	/* Do not worry about freeing memory, because if this is
5071
	 * called, then all agp memory is deallocated and removed
5072
	 * from the table.
5073
	 */
5074
5075
	table = (char *) agp_bridge.gatt_table_real;
5076
	table_end = table + ((PAGE_SIZE * (1 << page_order)) - 1);
5077
5078
	for (page = virt_to_page(table); page <= virt_to_page(table_end); page++)
5079
		ClearPageReserved(page);
5080
5081
	free_pages((unsigned long) agp_bridge.gatt_table_real, page_order);
5082
5083
	return 0;
5084
}
5085
5086
5087
/* Setup function */
5088
static gatt_mask uninorth_masks[] =
5089
{
5090
	{0x00000000, 0}
5091
};
5092
5093
static aper_size_info_32 uninorth_sizes[7] =
5094
{
5095
#if 0 /* Not sure uninorth supports that high aperture sizes */
5096
	{256, 65536, 6, 64},
5097
	{128, 32768, 5, 32},
5098
	{64, 16384, 4, 16},
5099
#endif	
5100
	{32, 8192, 3, 8},
5101
	{16, 4096, 2, 4},
5102
	{8, 2048, 1, 2},
5103
	{4, 1024, 0, 1}
5104
};
5105
5106
static int __init uninorth_setup (struct pci_dev *pdev)
5107
{
5108
	agp_bridge.masks = uninorth_masks;
5109
	agp_bridge.aperture_sizes = (void *)uninorth_sizes;
5110
	agp_bridge.size_type = U32_APER_SIZE;
5111
	agp_bridge.num_aperture_sizes = 4; //7;
5112
	agp_bridge.dev_private_data = NULL;
5113
	agp_bridge.needs_scratch_page = FALSE;
5114
	agp_bridge.configure = uninorth_configure;
5115
	agp_bridge.fetch_size = uninorth_fetch_size;
5116
	agp_bridge.cleanup = uninorth_cleanup;
5117
	agp_bridge.tlb_flush = uninorth_tlbflush;
5118
	agp_bridge.mask_memory = uninorth_mask_memory;
5119
	agp_bridge.agp_enable = uninorth_agp_enable;
5120
	agp_bridge.cache_flush = global_cache_flush;
5121
	agp_bridge.create_gatt_table = uninorth_create_gatt_table;
5122
	agp_bridge.free_gatt_table = uninorth_free_gatt_table;
5123
	agp_bridge.insert_memory = uninorth_insert_memory;
5124
	agp_bridge.remove_memory = agp_generic_remove_memory;
5125
	agp_bridge.alloc_by_type = agp_generic_alloc_by_type;
5126
	agp_bridge.free_by_type = agp_generic_free_by_type;
5127
	agp_bridge.agp_alloc_page = agp_generic_alloc_page;
5128
	agp_bridge.agp_destroy_page = agp_generic_destroy_page;
5129
	agp_bridge.suspend = agp_generic_suspend;
5130
	agp_bridge.resume = agp_generic_resume;
5131
	agp_bridge.cant_use_aperture = 1;
5132
5133
	return 0;
5134
	
5135
	(void) pdev; /* unused */
5136
}
5137
5138
#endif /* CONFIG_AGP_UNINORTH */
5139
4738
/* per-chipset initialization data.
5140
/* per-chipset initialization data.
4739
 * note -- all chipsets for a single vendor MUST be grouped together
5141
 * note -- all chipsets for a single vendor MUST be grouped together
4740
 */
5142
 */
Lines 5167-5172 Link Here
5167
		hp_zx1_setup },
5569
		hp_zx1_setup },
5168
#endif
5570
#endif
5169
5571
5572
#ifdef CONFIG_AGP_UNINORTH
5573
	{ PCI_DEVICE_ID_APPLE_UNI_N_AGP,
5574
		PCI_VENDOR_ID_APPLE,
5575
		APPLE_UNINORTH,
5576
		"Apple",
5577
		"UniNorth",
5578
		uninorth_setup },
5579
	{ PCI_DEVICE_ID_APPLE_UNI_N_AGP_P,
5580
		PCI_VENDOR_ID_APPLE,
5581
		APPLE_UNINORTH,
5582
		"Apple",
5583
		"UniNorth/Pangea",
5584
		uninorth_setup },
5585
	{ PCI_DEVICE_ID_APPLE_UNI_N_AGP15,
5586
		PCI_VENDOR_ID_APPLE,
5587
		APPLE_UNINORTH,
5588
		"Apple",
5589
		"UniNorth 1.5",
5590
		uninorth_setup },
5591
	{ PCI_DEVICE_ID_APPLE_UNI_N_AGP2,
5592
		PCI_VENDOR_ID_APPLE,
5593
		APPLE_UNINORTH,
5594
		"Apple",
5595
		"UniNorth 2",
5596
		uninorth_setup },
5597
#endif /* CONFIG_AGP_UNINORTH */
5598
5170
	{ 0, }, /* dummy final entry, always present */
5599
	{ 0, }, /* dummy final entry, always present */
5171
};
5600
};
5172
5601
(-)linux-2.4.22/drivers/char/defkeymap.c (-4 / +7 lines)
Lines 1-3 Link Here
1
1
/* Do not edit this file! It was automatically generated by   */
2
/* Do not edit this file! It was automatically generated by   */
2
/*    loadkeys --mktable defkeymap.map > defkeymap.c          */
3
/*    loadkeys --mktable defkeymap.map > defkeymap.c          */
3
4
Lines 37-43 Link Here
37
	0xf308,	0xf309,	0xf30b,	0xf304,	0xf305,	0xf306,	0xf30a,	0xf301,
38
	0xf308,	0xf309,	0xf30b,	0xf304,	0xf305,	0xf306,	0xf30a,	0xf301,
38
	0xf302,	0xf303,	0xf300,	0xf310,	0xf206,	0xf200,	0xf03e,	0xf10a,
39
	0xf302,	0xf303,	0xf300,	0xf310,	0xf206,	0xf200,	0xf03e,	0xf10a,
39
	0xf10b,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
40
	0xf10b,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
40
	0xf30e,	0xf702,	0xf30d,	0xf200,	0xf701,	0xf205,	0xf114,	0xf603,
41
	0xf30e,	0xf702,	0xf30d,	0xf01c,	0xf701,	0xf205,	0xf114,	0xf603,
41
	0xf20b,	0xf601,	0xf602,	0xf117,	0xf600,	0xf20a,	0xf115,	0xf116,
42
	0xf20b,	0xf601,	0xf602,	0xf117,	0xf600,	0xf20a,	0xf115,	0xf116,
42
	0xf11a,	0xf10c,	0xf10d,	0xf11b,	0xf11c,	0xf110,	0xf311,	0xf11d,
43
	0xf11a,	0xf10c,	0xf10d,	0xf11b,	0xf11c,	0xf110,	0xf311,	0xf11d,
43
	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
44
	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
Lines 56-62 Link Here
56
	0xf912,	0xf913,	0xf30b,	0xf90e,	0xf90f,	0xf910,	0xf30a,	0xf90b,
57
	0xf912,	0xf913,	0xf30b,	0xf90e,	0xf90f,	0xf910,	0xf30a,	0xf90b,
57
	0xf90c,	0xf90d,	0xf90a,	0xf310,	0xf206,	0xf200,	0xf07c,	0xf516,
58
	0xf90c,	0xf90d,	0xf90a,	0xf310,	0xf206,	0xf200,	0xf07c,	0xf516,
58
	0xf517,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
59
	0xf517,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
59
	0xf30e,	0xf702,	0xf30d,	0xf200,	0xf701,	0xf205,	0xf114,	0xf603,
60
	0xf30e,	0xf702,	0xf30d,	0xf01c,	0xf701,	0xf205,	0xf114,	0xf603,
60
	0xf118,	0xf601,	0xf602,	0xf117,	0xf600,	0xf119,	0xf115,	0xf116,
61
	0xf118,	0xf601,	0xf602,	0xf117,	0xf600,	0xf119,	0xf115,	0xf116,
61
	0xf11a,	0xf10c,	0xf10d,	0xf11b,	0xf11c,	0xf110,	0xf311,	0xf11d,
62
	0xf11a,	0xf10c,	0xf10d,	0xf11b,	0xf11c,	0xf110,	0xf311,	0xf11d,
62
	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
63
	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
Lines 94-100 Link Here
94
	0xf308,	0xf309,	0xf30b,	0xf304,	0xf305,	0xf306,	0xf30a,	0xf301,
95
	0xf308,	0xf309,	0xf30b,	0xf304,	0xf305,	0xf306,	0xf30a,	0xf301,
95
	0xf302,	0xf303,	0xf300,	0xf310,	0xf206,	0xf200,	0xf200,	0xf200,
96
	0xf302,	0xf303,	0xf300,	0xf310,	0xf206,	0xf200,	0xf200,	0xf200,
96
	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
97
	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
97
	0xf30e,	0xf702,	0xf30d,	0xf200,	0xf701,	0xf205,	0xf114,	0xf603,
98
	0xf30e,	0xf702,	0xf30d,	0xf01c,	0xf701,	0xf205,	0xf114,	0xf603,
98
	0xf118,	0xf601,	0xf602,	0xf117,	0xf600,	0xf119,	0xf115,	0xf116,
99
	0xf118,	0xf601,	0xf602,	0xf117,	0xf600,	0xf119,	0xf115,	0xf116,
99
	0xf11a,	0xf10c,	0xf10d,	0xf11b,	0xf11c,	0xf110,	0xf311,	0xf11d,
100
	0xf11a,	0xf10c,	0xf10d,	0xf11b,	0xf11c,	0xf110,	0xf311,	0xf11d,
100
	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
101
	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
Lines 132-138 Link Here
132
	0xf308,	0xf309,	0xf30b,	0xf304,	0xf305,	0xf306,	0xf30a,	0xf301,
133
	0xf308,	0xf309,	0xf30b,	0xf304,	0xf305,	0xf306,	0xf30a,	0xf301,
133
	0xf302,	0xf303,	0xf300,	0xf20c,	0xf206,	0xf200,	0xf200,	0xf50a,
134
	0xf302,	0xf303,	0xf300,	0xf20c,	0xf206,	0xf200,	0xf200,	0xf50a,
134
	0xf50b,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
135
	0xf50b,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
135
	0xf30e,	0xf702,	0xf30d,	0xf200,	0xf701,	0xf205,	0xf114,	0xf603,
136
	0xf30e,	0xf702,	0xf30d,	0xf01c,	0xf701,	0xf205,	0xf114,	0xf603,
136
	0xf118,	0xf601,	0xf602,	0xf117,	0xf600,	0xf119,	0xf115,	0xf20c,
137
	0xf118,	0xf601,	0xf602,	0xf117,	0xf600,	0xf119,	0xf115,	0xf20c,
137
	0xf11a,	0xf10c,	0xf10d,	0xf11b,	0xf11c,	0xf110,	0xf311,	0xf11d,
138
	0xf11a,	0xf10c,	0xf10d,	0xf11b,	0xf11c,	0xf110,	0xf311,	0xf11d,
138
	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
139
	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
Lines 147-152 Link Here
147
148
148
unsigned int keymap_count = 7;
149
unsigned int keymap_count = 7;
149
150
151
150
/*
152
/*
151
 * Philosophy: most people do not define more strings, but they who do
153
 * Philosophy: most people do not define more strings, but they who do
152
 * often want quite a lot of string space. So, we statically allocate
154
 * often want quite a lot of string space. So, we statically allocate
Lines 184-189 Link Here
184
	'\033', '[', 'P', 0, 
186
	'\033', '[', 'P', 0, 
185
};
187
};
186
188
189
187
char *funcbufptr = func_buf;
190
char *funcbufptr = func_buf;
188
int funcbufsize = sizeof(func_buf);
191
int funcbufsize = sizeof(func_buf);
189
int funcbufleft = 0;          /* space left */
192
int funcbufleft = 0;          /* space left */
(-)linux-2.4.22/drivers/char/drm/drmP.h (+12 lines)
Lines 324-329 Link Here
324
			DRM(ioremapfree)( (map)->handle, (map)->size );	\
324
			DRM(ioremapfree)( (map)->handle, (map)->size );	\
325
	} while (0)
325
	} while (0)
326
326
327
#define DRM_IOREMAPAGP(map, dev)						\
328
	(map)->handle = DRM(ioremap_agp)( (map)->offset, (map)->size, (dev) )
329
330
#define DRM_IOREMAPAGPFREE(map)						\
331
	do {								\
332
		if ( (map)->handle && (map)->size )			\
333
			DRM(ioremap_agp_free)( (map)->handle, (map)->size );	\
334
	} while (0)
335
327
#define DRM_FIND_MAP(_map, _o)						\
336
#define DRM_FIND_MAP(_map, _o)						\
328
do {									\
337
do {									\
329
	struct list_head *_list;					\
338
	struct list_head *_list;					\
Lines 758-763 Link Here
758
extern void	     *DRM(ioremap)(unsigned long offset, unsigned long size);
767
extern void	     *DRM(ioremap)(unsigned long offset, unsigned long size);
759
extern void	     DRM(ioremapfree)(void *pt, unsigned long size);
768
extern void	     DRM(ioremapfree)(void *pt, unsigned long size);
760
769
770
extern void	     *DRM(ioremap_agp)(unsigned long offset, unsigned long size, drm_device_t *dev);
771
extern void	     DRM(ioremap_agp_free)(void *pt, unsigned long size);
772
761
#if __REALLY_HAVE_AGP
773
#if __REALLY_HAVE_AGP
762
extern agp_memory    *DRM(alloc_agp)(int pages, u32 type);
774
extern agp_memory    *DRM(alloc_agp)(int pages, u32 type);
763
extern int           DRM(free_agp)(agp_memory *handle, int pages);
775
extern int           DRM(free_agp)(agp_memory *handle, int pages);
(-)linux-2.4.22/drivers/char/drm/drm_memory.h (+102 lines)
Lines 313-318 Link Here
313
	return pt;
313
	return pt;
314
}
314
}
315
315
316
/* PPC specific routine used by ioremap_agp, to be replaced by some
317
 * more generic implementation
318
 */
319
extern int map_page(unsigned long va, unsigned long pa, int flags);
320
321
void *DRM(ioremap_agp)(unsigned long offset, unsigned long size, drm_device_t *dev)
322
{
323
	void *pt;
324
	struct vm_struct *area;
325
	struct drm_agp_mem *agpmem;
326
	unsigned int flags = _PAGE_NO_CACHE|_PAGE_KERNEL|_PAGE_PRESENT|_PAGE_RW|_PAGE_DIRTY;
327
	int err, i;
328
		
329
	printk("drm: ioremap_agp, offset: 0x%08lx, size: 0x%08lx\n", offset, size);
330
	
331
#if __REALLY_HAVE_AGP
332
	if (!size) {
333
		DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
334
			      "Mapping 0 bytes at 0x%08lx\n", offset);
335
		return NULL;
336
	}
337
338
	if (!dev->agp || !dev->agp->cant_use_aperture)
339
		return DRM(ioremap)(offset, size);
340
341
	/* XXX This has to be changed into something more generic
342
	 * this implementation is really only valid on PPC
343
	 */
344
	area = get_vm_area(size, VM_IOREMAP);
345
	if (area == 0) {
346
		spin_lock(&DRM(mem_lock));
347
		++DRM(mem_stats)[DRM_MEM_MAPPINGS].fail_count;
348
		spin_unlock(&DRM(mem_lock));
349
		printk("->NULL\n");
350
		return NULL;
351
	}
352
	pt = (void *)VMALLOC_VMADDR(area->addr);
353
	err = 0;
354
	for (i = 0; i < size && err == 0; i += PAGE_SIZE) {
355
		unsigned long baddr = offset + i;
356
		unsigned long index;
357
		
358
                /*
359
                 * It's AGP memory - find the real physical page to map
360
                 */
361
                for(agpmem = dev->agp->memory; agpmem; agpmem = agpmem->next) {
362
                        if (agpmem->bound <= baddr &&
363
                            agpmem->bound + agpmem->pages * PAGE_SIZE > baddr) 
364
                                break;
365
		}
366
		if (!agpmem) {
367
			printk("drm: not matching AGP page in ioremap_agp\n");
368
			err = 1;
369
			break;
370
		}
371
		index = (baddr - agpmem->bound) >> PAGE_SHIFT;
372
		get_page(virt_to_page(__va(agpmem->memory->memory[index])));
373
		err = map_page(((unsigned long)pt)+i, agpmem->memory->memory[index], flags);
374
	}
375
	if (err) {
376
		vfree((void *)pt);
377
		spin_lock(&DRM(mem_lock));
378
		++DRM(mem_stats)[DRM_MEM_MAPPINGS].fail_count;
379
		spin_unlock(&DRM(mem_lock));
380
		printk("->NULL\n");
381
		return NULL;
382
	}
383
		
384
	spin_lock(&DRM(mem_lock));
385
	++DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count;
386
	DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_allocated += size;
387
	spin_unlock(&DRM(mem_lock));
388
	printk("->pt=0x%p\n", pt);
389
	return pt;
390
#else
391
	return NULL;
392
#endif
393
}
394
395
void DRM(ioremap_agp_free)(void *pt, unsigned long size)
396
{
397
	int alloc_count;
398
	int free_count;
399
400
	if (!pt)
401
		DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
402
			      "Attempt to free NULL pointer\n");
403
	else
404
		vfree(pt);
405
406
	spin_lock(&DRM(mem_lock));
407
	DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_freed += size;
408
	free_count  = ++DRM(mem_stats)[DRM_MEM_MAPPINGS].free_count;
409
	alloc_count =	DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count;
410
	spin_unlock(&DRM(mem_lock));
411
	if (free_count > alloc_count) {
412
		DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
413
			      "Excess frees: %d frees, %d allocs\n",
414
			      free_count, alloc_count);
415
	}
416
}
417
316
void DRM(ioremapfree)(void *pt, unsigned long size)
418
void DRM(ioremapfree)(void *pt, unsigned long size)
317
{
419
{
318
	int alloc_count;
420
	int alloc_count;
(-)linux-2.4.22/drivers/char/drm/drm_vm.h (-10 / +22 lines)
Lines 379-385 Link Here
379
379
380
	if ( !priv->authenticated ) return -EACCES;
380
	if ( !priv->authenticated ) return -EACCES;
381
381
382
	if (!VM_OFFSET(vma)) return DRM(mmap_dma)(filp, vma);
382
	/* We check for "dma". On Apple's UniNorth, it's valid to have
383
	 * the AGP mapped at physical address 0
384
	 * --BenH.
385
	 */
386
	if (!VM_OFFSET(vma) && (!dev->agp ||
387
	    dev->agp->agp_info.device->vendor != PCI_VENDOR_ID_APPLE))
388
		return DRM(mmap_dma)(filp, vma);
383
389
384
				/* A sequential search of a linked list is
390
				/* A sequential search of a linked list is
385
				   fine here because: 1) there will only be
391
				   fine here because: 1) there will only be
Lines 419-434 Link Here
419
425
420
	switch (map->type) {
426
	switch (map->type) {
421
        case _DRM_AGP:
427
        case _DRM_AGP:
422
#if defined(__alpha__)
428
		if (!dev->agp)
423
                /*
429
			return -ENODEV;
424
                 * On Alpha we can't talk to bus dma address from the
430
		if (dev->agp->cant_use_aperture) {
425
                 * CPU, so for memory of type DRM_AGP, we'll deal with
431
	                /*
426
                 * sorting out the real physical pages and mappings
432
	                 * On Alpha we can't talk to bus dma address from the
427
                 * in nopage()
433
	                 * CPU, so for memory of type DRM_AGP, we'll deal with
428
                 */
434
	                 * sorting out the real physical pages and mappings
429
                vma->vm_ops = &DRM(vm_ops);
435
	                 * in nopage()
430
                break;
436
	                 */
437
#if defined(__powerpc__)
438
			pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE;
431
#endif
439
#endif
440
			vma->vm_flags |= VM_IO;
441
	                vma->vm_ops = &DRM(vm_ops);
442
	                break;
443
	        }
432
                /* fall through to _DRM_FRAME_BUFFER... */        
444
                /* fall through to _DRM_FRAME_BUFFER... */        
433
	case _DRM_FRAME_BUFFER:
445
	case _DRM_FRAME_BUFFER:
434
	case _DRM_REGISTERS:
446
	case _DRM_REGISTERS:
(-)linux-2.4.22/drivers/char/drm/r128_cce.c (-7 / +20 lines)
Lines 37-42 Link Here
37
37
38
#define R128_FIFO_DEBUG		0
38
#define R128_FIFO_DEBUG		0
39
39
40
#if __REALLY_HAVE_AGP && defined(CONFIG_ALL_PPC)
41
extern unsigned long agp_special_page;
42
#endif	
43
40
44
41
/* CCE microcode (from ATI) */
45
/* CCE microcode (from ATI) */
42
static u32 r128_cce_microcode[] = {
46
static u32 r128_cce_microcode[] = {
Lines 340-345 Link Here
340
	SET_RING_HEAD( &dev_priv->ring, 0 );
344
	SET_RING_HEAD( &dev_priv->ring, 0 );
341
345
342
	if ( !dev_priv->is_pci ) {
346
	if ( !dev_priv->is_pci ) {
347
#if __REALLY_HAVE_AGP && defined(CONFIG_ALL_PPC)
348
		if (_machine == _MACH_Pmac) {
349
			dev_priv->ring.head = (__volatile__ u32 *) agp_special_page;
350
			SET_RING_HEAD( &dev_priv->ring, 0 );
351
			R128_WRITE( R128_PM4_BUFFER_DL_RPTR_ADDR,
352
				    __pa( dev_priv->ring.head ) );
353
		} else
354
#endif		
343
		R128_WRITE( R128_PM4_BUFFER_DL_RPTR_ADDR,
355
		R128_WRITE( R128_PM4_BUFFER_DL_RPTR_ADDR,
344
			    dev_priv->ring_rptr->offset );
356
			    dev_priv->ring_rptr->offset );
345
	} else {
357
	} else {
Lines 549-557 Link Here
549
				     init->sarea_priv_offset);
561
				     init->sarea_priv_offset);
550
562
551
	if ( !dev_priv->is_pci ) {
563
	if ( !dev_priv->is_pci ) {
552
		DRM_IOREMAP( dev_priv->cce_ring );
564
		DRM_IOREMAPAGP( dev_priv->cce_ring, dev );
553
		DRM_IOREMAP( dev_priv->ring_rptr );
565
		DRM_IOREMAPAGP( dev_priv->ring_rptr, dev );
554
		DRM_IOREMAP( dev_priv->buffers );
566
		DRM_IOREMAPAGP( dev_priv->buffers, dev );
555
		if(!dev_priv->cce_ring->handle ||
567
		if(!dev_priv->cce_ring->handle ||
556
		   !dev_priv->ring_rptr->handle ||
568
		   !dev_priv->ring_rptr->handle ||
557
		   !dev_priv->buffers->handle) {
569
		   !dev_priv->buffers->handle) {
Lines 623-632 Link Here
623
		drm_r128_private_t *dev_priv = dev->dev_private;
635
		drm_r128_private_t *dev_priv = dev->dev_private;
624
636
625
		if ( !dev_priv->is_pci ) {
637
		if ( !dev_priv->is_pci ) {
626
			DRM_IOREMAPFREE( dev_priv->cce_ring );
638
			DRM_IOREMAPAGPFREE( dev_priv->cce_ring );
627
			DRM_IOREMAPFREE( dev_priv->ring_rptr );
639
			DRM_IOREMAPAGPFREE( dev_priv->ring_rptr );
628
			DRM_IOREMAPFREE( dev_priv->buffers );
640
			DRM_IOREMAPAGPFREE( dev_priv->buffers );
629
		} else {
641
		}
642
     		else {
630
			if (!DRM(ati_pcigart_cleanup)( dev,
643
			if (!DRM(ati_pcigart_cleanup)( dev,
631
						dev_priv->phys_pci_gart,
644
						dev_priv->phys_pci_gart,
632
						dev_priv->bus_pci_gart ))
645
						dev_priv->bus_pci_gart ))
(-)linux-2.4.22/drivers/char/drm/r128_drv.h (-1 / +15 lines)
Lines 34-41 Link Here
34
#ifndef __R128_DRV_H__
34
#ifndef __R128_DRV_H__
35
#define __R128_DRV_H__
35
#define __R128_DRV_H__
36
36
37
#ifdef __powerpc__
38
#define GET_RING_HEAD( ring )		in_le32((volatile u32 *)(ring)->head)
39
#define SET_RING_HEAD( ring, val )	out_le32((volatile u32 *)(ring)->head, (val) )
40
#else
37
#define GET_RING_HEAD( ring )		le32_to_cpu( *(ring)->head )
41
#define GET_RING_HEAD( ring )		le32_to_cpu( *(ring)->head )
38
#define SET_RING_HEAD( ring, val )	*(ring)->head = cpu_to_le32( val )
42
#define SET_RING_HEAD( ring, val )	*(ring)->head = cpu_to_le32( val )
43
#endif
39
44
40
typedef struct drm_r128_freelist {
45
typedef struct drm_r128_freelist {
41
   	unsigned int age;
46
   	unsigned int age;
Lines 397-402 Link Here
397
	wmb();								\
402
	wmb();								\
398
	R128_DEREF(reg) = val;						\
403
	R128_DEREF(reg) = val;						\
399
} while (0)
404
} while (0)
405
#elif defined (__powerpc__)
406
#define R128_READ(reg)		in_le32( (volatile u32 *)R128_ADDR( reg ) )
407
#define R128_WRITE(reg,val)	out_le32( (volatile u32 *)R128_ADDR( reg ), (val) )
400
#else
408
#else
401
#define R128_READ(reg)		le32_to_cpu( R128_DEREF( reg ) )
409
#define R128_READ(reg)		le32_to_cpu( R128_DEREF( reg ) )
402
#define R128_WRITE(reg,val)						\
410
#define R128_WRITE(reg,val)						\
Lines 418-423 Link Here
418
	wmb();								\
426
	wmb();								\
419
	R128_DEREF8(reg) = val;						\
427
	R128_DEREF8(reg) = val;						\
420
} while (0)
428
} while (0)
429
#elif defined (__powerpc__)
430
#define R128_READ8(reg)		in_8( (volatile u8 *)R128_ADDR(reg) )
431
#define R128_WRITE8(reg,val)	out_8( (volatile u8 *)R128_ADDR(reg), val )
421
#else
432
#else
422
#define R128_READ8(reg)		R128_DEREF8( reg )
433
#define R128_READ8(reg)		R128_DEREF8( reg )
423
#define R128_WRITE8(reg,val)	do { R128_DEREF8( reg ) = val; } while (0)
434
#define R128_WRITE8(reg,val)	do { R128_DEREF8( reg ) = val; } while (0)
Lines 493-500 Link Here
493
 * Ring control
504
 * Ring control
494
 */
505
 */
495
506
507
#ifdef __powerpc__
508
#define r128_flush_write_combine()	(void)in_le32(ring)
509
#else
496
#define r128_flush_write_combine()	mb()
510
#define r128_flush_write_combine()	mb()
497
511
#endif
498
512
499
#define R128_VERBOSE	0
513
#define R128_VERBOSE	0
500
514
(-)linux-2.4.22/drivers/char/drm/radeon_cp.c (-11 / +24 lines)
Lines 37-48 Link Here
37
37
38
#define RADEON_FIFO_DEBUG	0
38
#define RADEON_FIFO_DEBUG	0
39
39
40
#if defined(__alpha__)
40
#if defined(__alpha__) || defined(__powerpc__)
41
# define PCIGART_ENABLED
41
# define PCIGART_ENABLED
42
#else
42
#else
43
# undef PCIGART_ENABLED
43
# undef PCIGART_ENABLED
44
#endif
44
#endif
45
45
46
#if __REALLY_HAVE_AGP && defined(CONFIG_ALL_PPC)
47
extern unsigned long agp_special_page;
48
#endif	
46
49
47
/* CP microcode (from ATI) */
50
/* CP microcode (from ATI) */
48
static u32 radeon_cp_microcode[][2] = {
51
static u32 radeon_cp_microcode[][2] = {
Lines 313-319 Link Here
313
	return RADEON_READ(RADEON_CLOCK_CNTL_DATA);
316
	return RADEON_READ(RADEON_CLOCK_CNTL_DATA);
314
}
317
}
315
318
316
#if RADEON_FIFO_DEBUG
319
#if 1 /* RADEON_FIFO_DEBUG */
317
static void radeon_status( drm_radeon_private_t *dev_priv )
320
static void radeon_status( drm_radeon_private_t *dev_priv )
318
{
321
{
319
	printk( "%s:\n", __FUNCTION__ );
322
	printk( "%s:\n", __FUNCTION__ );
Lines 400-406 Link Here
400
		udelay( 1 );
403
		udelay( 1 );
401
	}
404
	}
402
405
403
#if RADEON_FIFO_DEBUG
406
#if 1 /* RADEON_FIFO_DEBUG */
407
	printk("wait_for_idle timeout\n");
404
	DRM_ERROR( "failed!\n" );
408
	DRM_ERROR( "failed!\n" );
405
	radeon_status( dev_priv );
409
	radeon_status( dev_priv );
406
#endif
410
#endif
Lines 611-616 Link Here
611
	dev_priv->ring.tail = cur_read_ptr;
615
	dev_priv->ring.tail = cur_read_ptr;
612
616
613
	if ( !dev_priv->is_pci ) {
617
	if ( !dev_priv->is_pci ) {
618
#if __REALLY_HAVE_AGP && defined(CONFIG_ALL_PPC)
619
		if (_machine == _MACH_Pmac) {
620
			dev_priv->ring.head = (__volatile__ u32 *) agp_special_page;
621
			*dev_priv->ring.head = cur_read_ptr;
622
			RADEON_WRITE( RADEON_CP_RB_RPTR_ADDR,
623
				    __pa( dev_priv->ring.head ) );
624
		} else
625
#endif		
614
		RADEON_WRITE( RADEON_CP_RB_RPTR_ADDR,
626
		RADEON_WRITE( RADEON_CP_RB_RPTR_ADDR,
615
			      dev_priv->ring_rptr->offset );
627
			      dev_priv->ring_rptr->offset );
616
	} else {
628
	} else {
Lines 835-843 Link Here
835
				       init->sarea_priv_offset);
847
				       init->sarea_priv_offset);
836
848
837
	if ( !dev_priv->is_pci ) {
849
	if ( !dev_priv->is_pci ) {
838
		DRM_IOREMAP( dev_priv->cp_ring );
850
		DRM_IOREMAPAGP( dev_priv->cp_ring, dev );
839
		DRM_IOREMAP( dev_priv->ring_rptr );
851
		DRM_IOREMAPAGP( dev_priv->ring_rptr, dev );
840
		DRM_IOREMAP( dev_priv->buffers );
852
		DRM_IOREMAPAGP( dev_priv->buffers, dev );
841
		if(!dev_priv->cp_ring->handle ||
853
		if(!dev_priv->cp_ring->handle ||
842
		   !dev_priv->ring_rptr->handle ||
854
		   !dev_priv->ring_rptr->handle ||
843
		   !dev_priv->buffers->handle) {
855
		   !dev_priv->buffers->handle) {
Lines 982-990 Link Here
982
		drm_radeon_private_t *dev_priv = dev->dev_private;
994
		drm_radeon_private_t *dev_priv = dev->dev_private;
983
995
984
		if ( !dev_priv->is_pci ) {
996
		if ( !dev_priv->is_pci ) {
985
			DRM_IOREMAPFREE( dev_priv->cp_ring );
997
			DRM_IOREMAPAGPFREE( dev_priv->cp_ring );
986
			DRM_IOREMAPFREE( dev_priv->ring_rptr );
998
			DRM_IOREMAPAGPFREE( dev_priv->ring_rptr );
987
			DRM_IOREMAPFREE( dev_priv->buffers );
999
			DRM_IOREMAPAGPFREE( dev_priv->buffers );
988
		} else {
1000
		} else {
989
			if (!DRM(ati_pcigart_cleanup)( dev,
1001
			if (!DRM(ati_pcigart_cleanup)( dev,
990
						dev_priv->phys_pci_gart,
1002
						dev_priv->phys_pci_gart,
Lines 1351-1364 Link Here
1351
	int i;
1363
	int i;
1352
1364
1353
	for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) {
1365
	for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) {
1354
		radeon_update_ring_snapshot( ring );
1366
		radeon_update_ring_snapshot( dev_priv, ring );
1355
		if ( ring->space > n )
1367
		if ( ring->space > n )
1356
			return 0;
1368
			return 0;
1357
		udelay( 1 );
1369
		udelay( 1 );
1358
	}
1370
	}
1359
1371
1360
	/* FIXME: This return value is ignored in the BEGIN_RING macro! */
1372
	/* FIXME: This return value is ignored in the BEGIN_RING macro! */
1361
#if RADEON_FIFO_DEBUG
1373
#if 1 /* RADEON_FIFO_DEBUG */
1374
	printk("wait ring timeout\n");
1362
	radeon_status( dev_priv );
1375
	radeon_status( dev_priv );
1363
	DRM_ERROR( "failed!\n" );
1376
	DRM_ERROR( "failed!\n" );
1364
#endif
1377
#endif
(-)linux-2.4.22/drivers/char/drm/radeon_drv.h (-9 / +46 lines)
Lines 31-36 Link Here
31
#ifndef __RADEON_DRV_H__
31
#ifndef __RADEON_DRV_H__
32
#define __RADEON_DRV_H__
32
#define __RADEON_DRV_H__
33
33
34
#if defined(__powerpc__)
35
#define GET_RING_HEAD(ring)		in_le32((volatile u32 *)(ring)->head)
36
#define SET_RING_HEAD(ring,val)		out_le32((volatile u32 *)(ring)->head, (val))
37
#else
38
#define GET_RING_HEAD(ring)		le32_to_cpu(*(ring)->head)
39
#define SET_RING_HEAD(ring,val)		*(ring)->head = cpu_to_le32(val)
40
#endif
41
34
typedef struct drm_radeon_freelist {
42
typedef struct drm_radeon_freelist {
35
   	unsigned int age;
43
   	unsigned int age;
36
   	drm_buf_t *buf;
44
   	drm_buf_t *buf;
Lines 150-161 Link Here
150
extern int radeon_wait_ring( drm_radeon_private_t *dev_priv, int n );
158
extern int radeon_wait_ring( drm_radeon_private_t *dev_priv, int n );
151
159
152
static inline void
160
static inline void
153
radeon_update_ring_snapshot( drm_radeon_ring_buffer_t *ring )
161
radeon_update_ring_snapshot( drm_radeon_private_t *dev_priv, drm_radeon_ring_buffer_t *ring );
154
{
155
	ring->space = (*(volatile int *)ring->head - ring->tail) * sizeof(u32);
156
	if ( ring->space <= 0 )
157
		ring->space += ring->size;
158
}
159
162
160
extern int radeon_do_cp_idle( drm_radeon_private_t *dev_priv );
163
extern int radeon_do_cp_idle( drm_radeon_private_t *dev_priv );
161
extern int radeon_do_cleanup_cp( drm_device_t *dev );
164
extern int radeon_do_cleanup_cp( drm_device_t *dev );
Lines 539-544 Link Here
539
	wmb();								\
542
	wmb();								\
540
	RADEON_DEREF(reg) = val;					\
543
	RADEON_DEREF(reg) = val;					\
541
} while (0)
544
} while (0)
545
#elif defined(__powerpc__)
546
#define RADEON_READ(reg)	in_le32((volatile u32 *)RADEON_ADDR(reg))
547
#define RADEON_WRITE(reg,val)	out_le32((volatile u32 *)RADEON_ADDR(reg), (val))
542
#else
548
#else
543
#define RADEON_READ(reg)	RADEON_DEREF( reg )
549
#define RADEON_READ(reg)	RADEON_DEREF( reg )
544
#define RADEON_WRITE(reg, val)	do { RADEON_DEREF( reg ) = val; } while (0)
550
#define RADEON_WRITE(reg, val)	do { RADEON_DEREF( reg ) = val; } while (0)
Lines 557-562 Link Here
557
	wmb();								\
563
	wmb();								\
558
	RADEON_DEREF8( reg ) = val;					\
564
	RADEON_DEREF8( reg ) = val;					\
559
} while (0)
565
} while (0)
566
#elif defined(__powerpc__)
567
#define RADEON_READ8(reg)	in_8((volatile u8 *)RADEON_ADDR(reg))
568
#define RADEON_WRITE8(reg,val)	out_8((volatile u8 *)RADEON_ADDR(reg), (val))
560
#else
569
#else
561
#define RADEON_READ8(reg)	RADEON_DEREF8( reg )
570
#define RADEON_READ8(reg)	RADEON_DEREF8( reg )
562
#define RADEON_WRITE8(reg, val)	do { RADEON_DEREF8( reg ) = val; } while (0)
571
#define RADEON_WRITE8(reg, val)	do { RADEON_DEREF8( reg ) = val; } while (0)
Lines 652-658 Link Here
652
	drm_radeon_ring_buffer_t *ring = &dev_priv->ring; int i;	\
661
	drm_radeon_ring_buffer_t *ring = &dev_priv->ring; int i;	\
653
	if ( ring->space < ring->high_mark ) {				\
662
	if ( ring->space < ring->high_mark ) {				\
654
		for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) {	\
663
		for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) {	\
655
			radeon_update_ring_snapshot( ring );		\
664
			radeon_update_ring_snapshot( dev_priv, ring );		\
656
			if ( ring->space >= ring->high_mark )		\
665
			if ( ring->space >= ring->high_mark )		\
657
				goto __ring_space_done;			\
666
				goto __ring_space_done;			\
658
			udelay( 1 );					\
667
			udelay( 1 );					\
Lines 694-705 Link Here
694
 * Ring control
703
 * Ring control
695
 */
704
 */
696
705
706
#if defined(__powerpc__)
707
#define radeon_flush_write_combine()	do { mb(); (void)in_le32(ring); mb(); } while(0)
708
#else
697
#define radeon_flush_write_combine()	mb()
709
#define radeon_flush_write_combine()	mb()
698
710
#endif
699
711
700
#define RADEON_VERBOSE	0
712
#define RADEON_VERBOSE	0
713
#define RADEON_DEBUG
701
714
715
#ifdef RADEON_DEBUG
716
#define RING_LOCALS	int write; unsigned int mask; volatile u32 *ring; int dbg;
717
#define DEBUG_INIT(n)	dbg = n
718
#define DEBUG_INC()	do { if (dbg <= 0) printk("Argh 1 ! (%s:%d)\n", __FILE__, __LINE__); \
719
			     dbg--; } while(0)
720
#define DEBUG_END()	do { if (dbg != 0) printk("Argh 2/%d ! (%s:%d)\n", dbg, __FILE__, __LINE__); \
721
			     dbg--; } while(0)
722
#else
702
#define RING_LOCALS	int write; unsigned int mask; volatile u32 *ring;
723
#define RING_LOCALS	int write; unsigned int mask; volatile u32 *ring;
724
#define DEBUG_INIT()
725
#define DEBUG_INC()
726
#define DEBUG_END()
727
#endif
703
728
704
#define BEGIN_RING( n ) do {						\
729
#define BEGIN_RING( n ) do {						\
705
	if ( RADEON_VERBOSE ) {						\
730
	if ( RADEON_VERBOSE ) {						\
Lines 713-718 Link Here
713
	ring = dev_priv->ring.start;					\
738
	ring = dev_priv->ring.start;					\
714
	write = dev_priv->ring.tail;					\
739
	write = dev_priv->ring.tail;					\
715
	mask = dev_priv->ring.tail_mask;				\
740
	mask = dev_priv->ring.tail_mask;				\
741
	DEBUG_INIT(n);							\
716
} while (0)
742
} while (0)
717
743
718
#define ADVANCE_RING() do {						\
744
#define ADVANCE_RING() do {						\
Lines 720-725 Link Here
720
		DRM_INFO( "ADVANCE_RING() wr=0x%06x tail=0x%06x\n",	\
746
		DRM_INFO( "ADVANCE_RING() wr=0x%06x tail=0x%06x\n",	\
721
			  write, dev_priv->ring.tail );			\
747
			  write, dev_priv->ring.tail );			\
722
	}								\
748
	}								\
749
	DEBUG_END();							\
723
	radeon_flush_write_combine();					\
750
	radeon_flush_write_combine();					\
724
	dev_priv->ring.tail = write;					\
751
	dev_priv->ring.tail = write;					\
725
	RADEON_WRITE( RADEON_CP_RB_WPTR, write );			\
752
	RADEON_WRITE( RADEON_CP_RB_WPTR, write );			\
Lines 730-739 Link Here
730
		DRM_INFO( "   OUT_RING( 0x%08x ) at 0x%x\n",		\
757
		DRM_INFO( "   OUT_RING( 0x%08x ) at 0x%x\n",		\
731
			   (unsigned int)(x), write );			\
758
			   (unsigned int)(x), write );			\
732
	}								\
759
	}								\
733
	ring[write++] = (x);						\
760
	DEBUG_INC();							\
761
	ring[write++] = cpu_to_le32(x);					\
734
	write &= mask;							\
762
	write &= mask;							\
735
} while (0)
763
} while (0)
736
764
737
#define RADEON_PERFORMANCE_BOXES	0
765
#define RADEON_PERFORMANCE_BOXES	0
738
766
767
static inline void
768
radeon_update_ring_snapshot( drm_radeon_private_t *dev_priv, drm_radeon_ring_buffer_t *ring )
769
{
770
//	ring->space = (GET_RING_HEAD(ring) - ring->tail) * sizeof(u32);
771
	ring->space = (RADEON_READ(0x710) - ring->tail) * sizeof(u32);
772
	if ( ring->space <= 0 )
773
		ring->space += ring->size;
774
}
775
739
#endif /* __RADEON_DRV_H__ */
776
#endif /* __RADEON_DRV_H__ */
(-)linux-2.4.22/drivers/char/drm/radeon_state.c (-16 / +20 lines)
Lines 849-855 Link Here
849
			u32 *data = (u32 *)
849
			u32 *data = (u32 *)
850
				((char *)dev_priv->buffers->handle
850
				((char *)dev_priv->buffers->handle
851
				 + buf->offset + start);
851
				 + buf->offset + start);
852
			data[dwords++] = RADEON_CP_PACKET2;
852
			data[dwords++] = cpu_to_le32(RADEON_CP_PACKET2);
853
		}
853
		}
854
854
855
		buf_priv->dispatched = 1;
855
		buf_priv->dispatched = 1;
Lines 913-930 Link Here
913
		data = (u32 *)((char *)dev_priv->buffers->handle
913
		data = (u32 *)((char *)dev_priv->buffers->handle
914
			       + buf->offset + start);
914
			       + buf->offset + start);
915
915
916
		data[0] = CP_PACKET3( RADEON_3D_RNDR_GEN_INDX_PRIM, dwords-2 );
916
		data[0] = cpu_to_le32(CP_PACKET3( RADEON_3D_RNDR_GEN_INDX_PRIM, dwords-2 ));
917
917
918
		data[1] = offset;
918
		data[1] = cpu_to_le32(offset);
919
		data[2] = RADEON_MAX_VB_VERTS;
919
		data[2] = cpu_to_le32(RADEON_MAX_VB_VERTS);
920
		data[3] = format;
920
		data[3] = cpu_to_le32(format);
921
		data[4] = (prim | RADEON_PRIM_WALK_IND |
921
		data[4] = cpu_to_le32((prim | RADEON_PRIM_WALK_IND |
922
			   RADEON_COLOR_ORDER_RGBA |
922
			   RADEON_COLOR_ORDER_RGBA |
923
			   RADEON_VTX_FMT_RADEON_MODE |
923
			   RADEON_VTX_FMT_RADEON_MODE |
924
			   (count << RADEON_NUM_VERTICES_SHIFT) );
924
			   (count << RADEON_NUM_VERTICES_SHIFT) ));
925
925
926
		if ( count & 0x1 ) {
926
		if ( count & 0x1 ) {
927
#ifdef __LITTLE_ENDIAN
927
			data[dwords-1] &= 0x0000ffff;
928
			data[dwords-1] &= 0x0000ffff;
929
#else
930
			data[dwords-1] &= 0xffff0000;
931
#endif
928
		}
932
		}
929
933
930
		do {
934
		do {
Lines 1067-1088 Link Here
1067
	 */
1071
	 */
1068
	buffer = (u32 *)((char *)dev_priv->buffers->handle + buf->offset);
1072
	buffer = (u32 *)((char *)dev_priv->buffers->handle + buf->offset);
1069
1073
1070
	buffer[0] = CP_PACKET3( RADEON_CNTL_HOSTDATA_BLT, dwords + 6 );
1074
	buffer[0] = cpu_to_le32(CP_PACKET3( RADEON_CNTL_HOSTDATA_BLT, dwords + 6 ));
1071
	buffer[1] = (RADEON_GMC_DST_PITCH_OFFSET_CNTL |
1075
	buffer[1] = cpu_to_le32((RADEON_GMC_DST_PITCH_OFFSET_CNTL |
1072
		     RADEON_GMC_BRUSH_NONE |
1076
		     RADEON_GMC_BRUSH_NONE |
1073
		     (format << 8) |
1077
		     (format << 8) |
1074
		     RADEON_GMC_SRC_DATATYPE_COLOR |
1078
		     RADEON_GMC_SRC_DATATYPE_COLOR |
1075
		     RADEON_ROP3_S |
1079
		     RADEON_ROP3_S |
1076
		     RADEON_DP_SRC_SOURCE_HOST_DATA |
1080
		     RADEON_DP_SRC_SOURCE_HOST_DATA |
1077
		     RADEON_GMC_CLR_CMP_CNTL_DIS |
1081
		     RADEON_GMC_CLR_CMP_CNTL_DIS |
1078
		     RADEON_GMC_WR_MSK_DIS);
1082
		     RADEON_GMC_WR_MSK_DIS));
1079
1083
1080
	buffer[2] = (tex->pitch << 22) | (tex->offset >> 10);
1084
	buffer[2] = cpu_to_le32((tex->pitch << 22) | (tex->offset >> 10));
1081
	buffer[3] = 0xffffffff;
1085
	buffer[3] = cpu_to_le32(0xffffffff);
1082
	buffer[4] = 0xffffffff;
1086
	buffer[4] = cpu_to_le32(0xffffffff);
1083
	buffer[5] = (y << 16) | image->x;
1087
	buffer[5] = cpu_to_le32((y << 16) | image->x);
1084
	buffer[6] = (height << 16) | image->width;
1088
	buffer[6] = cpu_to_le32((height << 16) | image->width);
1085
	buffer[7] = dwords;
1089
	buffer[7] = cpu_to_le32(dwords);
1086
1090
1087
	buffer += 8;
1091
	buffer += 8;
1088
1092
(-)linux-2.4.22/drivers/i2c/i2c-keywest.c (+2 lines)
Lines 256-261 Link Here
256
	    	len = 1;
256
	    	len = 1;
257
	    	buffer = &data->byte;
257
	    	buffer = &data->byte;
258
	    	iface->cur_mode |= KW_I2C_MODE_STANDARDSUB;
258
	    	iface->cur_mode |= KW_I2C_MODE_STANDARDSUB;
259
	    	//iface->cur_mode |= KW_I2C_MODE_COMBINED;
259
	    	break;
260
	    	break;
260
	    case I2C_SMBUS_WORD_DATA:
261
	    case I2C_SMBUS_WORD_DATA:
261
	    	len = 2;
262
	    	len = 2;
Lines 267-272 Link Here
267
	    	len = data->block[0];
268
	    	len = data->block[0];
268
	    	buffer = &data->block[1];
269
	    	buffer = &data->block[1];
269
	    	iface->cur_mode |= KW_I2C_MODE_STANDARDSUB;
270
	    	iface->cur_mode |= KW_I2C_MODE_STANDARDSUB;
271
	    	//iface->cur_mode |= KW_I2C_MODE_COMBINED;
270
		break;
272
		break;
271
	    default:
273
	    default:
272
	    	return -1;
274
	    	return -1;
(-)linux-2.4.22/drivers/ide/Config.in (+3 lines)
Lines 86-91 Link Here
86
	 dep_bool '      Probe internal Kauai ATA/100 first' CONFIG_BLK_DEV_IDE_PMAC_ATA100FIRST $CONFIG_BLK_DEV_IDE_PMAC
86
	 dep_bool '      Probe internal Kauai ATA/100 first' CONFIG_BLK_DEV_IDE_PMAC_ATA100FIRST $CONFIG_BLK_DEV_IDE_PMAC
87
	 dep_bool '      PowerMac IDE DMA support' CONFIG_BLK_DEV_IDEDMA_PMAC $CONFIG_BLK_DEV_IDE_PMAC
87
	 dep_bool '      PowerMac IDE DMA support' CONFIG_BLK_DEV_IDEDMA_PMAC $CONFIG_BLK_DEV_IDE_PMAC
88
	 dep_bool '        Use DMA by default' CONFIG_BLK_DEV_IDEDMA_PMAC_AUTO $CONFIG_BLK_DEV_IDEDMA_PMAC
88
	 dep_bool '        Use DMA by default' CONFIG_BLK_DEV_IDEDMA_PMAC_AUTO $CONFIG_BLK_DEV_IDEDMA_PMAC
89
	 if [ "$CONFIG_ADB_PMU" = "y" ]; then
90
	     bool '      Blink laptop LED on activity' CONFIG_PMU_HD_BLINK
91
	 fi
89
	 if [ "$CONFIG_BLK_DEV_IDE_PMAC" = "y" ]; then
92
	 if [ "$CONFIG_BLK_DEV_IDE_PMAC" = "y" ]; then
90
	   define_bool CONFIG_BLK_DEV_IDEDMA $CONFIG_BLK_DEV_IDEDMA_PMAC
93
	   define_bool CONFIG_BLK_DEV_IDEDMA $CONFIG_BLK_DEV_IDEDMA_PMAC
91
	 fi
94
	 fi
(-)linux-2.4.22/drivers/ide/arm/rapide.c (+1 lines)
Lines 40-45 Link Here
40
	}
40
	}
41
	hw.io_ports[IDE_CONTROL_OFFSET] = port + 0x206;
41
	hw.io_ports[IDE_CONTROL_OFFSET] = port + 0x206;
42
	hw.irq = ec->irq;
42
	hw.irq = ec->irq;
43
	hw.chipset = ide_generic;
43
44
44
	return ide_register_hw(&hw, NULL);
45
	return ide_register_hw(&hw, NULL);
45
}
46
}
(-)linux-2.4.22/drivers/ide/ide-disk.c (-8 / +19 lines)
Lines 1161-1173 Link Here
1161
{
1161
{
1162
	struct hd_driveid *id = drive->id;
1162
	struct hd_driveid *id = drive->id;
1163
	unsigned long capacity = drive->cyl * drive->head * drive->sect;
1163
	unsigned long capacity = drive->cyl * drive->head * drive->sect;
1164
	unsigned long set_max = idedisk_read_native_max_address(drive);
1164
	unsigned long set_max = 0;
1165
	unsigned long long capacity_2 = capacity;
1165
	unsigned long long capacity_2 = capacity;
1166
	unsigned long long set_max_ext;
1166
	unsigned long long set_max_ext;
1167
1167
1168
	drive->capacity48 = 0;
1168
	drive->capacity48 = 0;
1169
	drive->select.b.lba = 0;
1169
	drive->select.b.lba = 0;
1170
1170
1171
	/* That stupid compact flash doesn't like the command */
1172
	if (!drive->is_flash)
1173
		set_max = idedisk_read_native_max_address(drive);
1174
1171
	(void) idedisk_supports_host_protected_area(drive);
1175
	(void) idedisk_supports_host_protected_area(drive);
1172
1176
1173
	if (id->cfs_enable_2 & 0x0400) {
1177
	if (id->cfs_enable_2 & 0x0400) {
Lines 1566-1572 Link Here
1566
1570
1567
static int set_lba_addressing (ide_drive_t *drive, int arg)
1571
static int set_lba_addressing (ide_drive_t *drive, int arg)
1568
{
1572
{
1569
	return (probe_lba_addressing(drive, arg));
1573
	return probe_lba_addressing(drive, arg);
1570
}
1574
}
1571
1575
1572
static void idedisk_add_settings(ide_drive_t *drive)
1576
static void idedisk_add_settings(ide_drive_t *drive)
Lines 1644-1656 Link Here
1644
		break;
1648
		break;
1645
	}
1649
	}
1646
1650
1647
#if 1
1648
	(void) probe_lba_addressing(drive, 1);
1651
	(void) probe_lba_addressing(drive, 1);
1649
#else
1652
1650
	/* if using 48-bit addressing bump the request size up */
1653
	if (drive->addressing == 1) {
1651
	if (probe_lba_addressing(drive, 1))
1654
		int max_s = 2048, i, off = drive->select.b.unit << PARTN_BITS;
1652
		blk_queue_max_sectors(&drive->queue, 2048);
1655
		ide_hwif_t *hwif = HWIF(drive);
1653
#endif
1656
1657
		if (max_s > hwif->rqsize)
1658
			max_s = hwif->rqsize;
1659
1660
		for (i = 0; i < (1 << PARTN_BITS); i++)
1661
			max_sectors[hwif->major][off + i] = max_s;
1662
1663
		printk("%s: max request size: %dKiB\n", drive->name, max_s / 2);
1664
	}
1654
1665
1655
	/* Extract geometry if we did not already have one for the drive */
1666
	/* Extract geometry if we did not already have one for the drive */
1656
	if (!drive->cyl || !drive->head || !drive->sect) {
1667
	if (!drive->cyl || !drive->head || !drive->sect) {
(-)linux-2.4.22/drivers/ide/ide-probe.c (-4 / +15 lines)
Lines 972-977 Link Here
972
	q->queuedata = HWGROUP(drive);
972
	q->queuedata = HWGROUP(drive);
973
	blk_init_queue(q, do_ide_request);
973
	blk_init_queue(q, do_ide_request);
974
	blk_queue_throttle_sectors(q, 1);
974
	blk_queue_throttle_sectors(q, 1);
975
	/*
976
	 * enable led activity for disk drives only
977
	 */
978
	if (drive->media == ide_disk && HWIF(drive)->led_act)
979
		blk_queue_activity_fn(&drive->queue, HWIF(drive)->led_act, drive);
975
}
980
}
976
981
977
#undef __IRQ_HELL_SPIN
982
#undef __IRQ_HELL_SPIN
Lines 1164-1169 Link Here
1164
1169
1165
	units = MAX_DRIVES;
1170
	units = MAX_DRIVES;
1166
1171
1172
	if (!hwif->rqsize)
1173
		hwif->rqsize = hwif->addressing ? 128 : 65536;
1174
1167
	minors    = units * (1<<PARTN_BITS);
1175
	minors    = units * (1<<PARTN_BITS);
1168
	gd        = kmalloc(sizeof(struct gendisk), GFP_KERNEL);
1176
	gd        = kmalloc(sizeof(struct gendisk), GFP_KERNEL);
1169
	if (!gd)
1177
	if (!gd)
Lines 1193-1203 Link Here
1193
	max_sectors[hwif->major] = max_sect;
1201
	max_sectors[hwif->major] = max_sect;
1194
	max_readahead[hwif->major] = max_ra;
1202
	max_readahead[hwif->major] = max_ra;
1195
	for (unit = 0; unit < minors; ++unit) {
1203
	for (unit = 0; unit < minors; ++unit) {
1204
		int max_s = 128;
1205
1196
		*bs++ = BLOCK_SIZE;
1206
		*bs++ = BLOCK_SIZE;
1197
		/*
1207
1198
		 * IDE can do up to 128K per request == 256
1208
		if (max_s > hwif->rqsize)
1199
		 */
1209
			max_s = hwif->rqsize;
1200
		*max_sect++ = ((hwif->rqsize) ? hwif->rqsize : 128);
1210
1211
		*max_sect++ = max_s;
1201
		*max_ra++ = vm_max_readahead;
1212
		*max_ra++ = vm_max_readahead;
1202
	}
1213
	}
1203
1214
(-)linux-2.4.22/drivers/ide/ppc/pmac.c (-4 / +103 lines)
Lines 38-47 Link Here
38
#include <asm/pmac_feature.h>
38
#include <asm/pmac_feature.h>
39
#include <asm/sections.h>
39
#include <asm/sections.h>
40
#include <asm/irq.h>
40
#include <asm/irq.h>
41
#ifdef CONFIG_PMAC_PBOOK
42
#include <linux/adb.h>
41
#include <linux/adb.h>
43
#include <linux/pmu.h>
42
#include <linux/pmu.h>
44
#endif
45
#include "ide_modes.h"
43
#include "ide_modes.h"
46
#include "ide-timing.h"
44
#include "ide-timing.h"
47
45
Lines 357-362 Link Here
357
};
355
};
358
#endif /* CONFIG_PMAC_PBOOK */
356
#endif /* CONFIG_PMAC_PBOOK */
359
357
358
#ifdef CONFIG_PMU_HD_BLINK
359
360
/* Set to 50ms */
361
#define PMU_HD_BLINK_TIME	(HZ/20)
362
363
static struct adb_request pmu_blink_on, pmu_blink_off;
364
static spinlock_t pmu_blink_lock;
365
static unsigned long pmu_blink_stoptime;
366
static int pmu_blink_ledstate;
367
static struct timer_list pmu_blink_timer;
368
369
static void
370
pmu_hd_blink_timeout(unsigned long data)
371
{
372
	unsigned long flags;
373
	
374
	spin_lock_irqsave(&pmu_blink_lock, flags);
375
376
	/* We may have been triggered again in a racy way, check
377
	 * that we really want to switch it off
378
	 */
379
	if (time_after(pmu_blink_stoptime, jiffies))
380
		goto done;
381
382
	/* Previous req. not complete, try 50ms more */
383
	if (pmu_blink_off.complete == 0)
384
		mod_timer(&pmu_blink_timer, jiffies + PMU_HD_BLINK_TIME);
385
	else if (pmu_blink_ledstate) {
386
		pmu_request(&pmu_blink_off, NULL, 4, 0xee, 4, 0, 0);
387
		pmu_blink_ledstate = 0;
388
	}
389
done:
390
	spin_unlock_irqrestore(&pmu_blink_lock, flags);
391
}
392
393
static void
394
pmu_hd_kick_blink(void *data, int rw)
395
{
396
	unsigned long flags;
397
	
398
	pmu_blink_stoptime = jiffies + PMU_HD_BLINK_TIME;
399
	wmb();
400
	mod_timer(&pmu_blink_timer, pmu_blink_stoptime);
401
	if (pmu_blink_ledstate == 1)
402
		return;
403
	spin_lock_irqsave(&pmu_blink_lock, flags);
404
	if (pmu_blink_on.complete && !pmu_blink_ledstate) {
405
		pmu_request(&pmu_blink_on, NULL, 4, 0xee, 4, 0, 1);
406
		pmu_blink_ledstate = 1;
407
	}
408
	spin_unlock_irqrestore(&pmu_blink_lock, flags);
409
}
410
411
static int
412
pmu_hd_blink_init(void)
413
{
414
	struct device_node *dt;
415
	const char *model;
416
417
	if (pmu_get_model() != PMU_KEYLARGO_BASED)
418
		return 0;
419
	
420
	dt = find_devices("device-tree");
421
	if (dt == NULL)
422
		return 0;
423
	model = (const char *)get_property(dt, "model", NULL);
424
	if (model == NULL)
425
		return 0;
426
	if (strncmp(model, "PowerBook", strlen("PowerBook")) != 0 &&
427
	    strncmp(model, "iBook", strlen("iBook")) != 0)
428
	    	return 0;
429
	
430
	pmu_blink_on.complete = 1;
431
	pmu_blink_off.complete = 1;
432
	spin_lock_init(&pmu_blink_lock);
433
	init_timer(&pmu_blink_timer);
434
	pmu_blink_timer.function = pmu_hd_blink_timeout;
435
436
	return 1;
437
}
438
439
#endif /* CONFIG_PMU_HD_BLINK */
440
360
/*
441
/*
361
 * N.B. this can't be an initfunc, because the media-bay task can
442
 * N.B. this can't be an initfunc, because the media-bay task can
362
 * call ide_[un]register at any time.
443
 * call ide_[un]register at any time.
Lines 462-468 Link Here
462
	ide_hwif_t *hwif = HWIF(drive);
543
	ide_hwif_t *hwif = HWIF(drive);
463
	int result = 1;
544
	int result = 1;
464
	
545
	
465
	disable_irq(hwif->irq);	/* disable_irq_nosync ?? */
546
	disable_irq_nosync(hwif->irq);
466
	udelay(1);
547
	udelay(1);
467
	SELECT_DRIVE(drive);
548
	SELECT_DRIVE(drive);
468
	SELECT_MASK(drive, 0);
549
	SELECT_MASK(drive, 0);
Lines 945-953 Link Here
945
	unsigned long base, regbase;
1026
	unsigned long base, regbase;
946
	int irq;
1027
	int irq;
947
	ide_hwif_t *hwif;
1028
	ide_hwif_t *hwif;
948
1029
#ifdef CONFIG_PMU_HD_BLINK
1030
	int has_blink;
1031
#endif	
949
	if (_machine != _MACH_Pmac)
1032
	if (_machine != _MACH_Pmac)
950
		return;
1033
		return;
1034
951
	pp = &atas;
1035
	pp = &atas;
952
	rp = &removables;
1036
	rp = &removables;
953
	p = find_devices("ATA");
1037
	p = find_devices("ATA");
Lines 957-962 Link Here
957
		p = find_type_devices("ide");
1041
		p = find_type_devices("ide");
958
	if (p == NULL)
1042
	if (p == NULL)
959
		p = find_type_devices("ata");
1043
		p = find_type_devices("ata");
1044
1045
	if (p == NULL)
1046
		return;
1047
1048
#ifdef CONFIG_PMU_HD_BLINK
1049
	has_blink = pmu_hd_blink_init();
1050
#endif /* CONFIG_PMU_HD_BLINK */
1051
960
	/* Move removable devices such as the media-bay CDROM
1052
	/* Move removable devices such as the media-bay CDROM
961
	   on the PB3400 to the end of the list. */
1053
	   on the PB3400 to the end of the list. */
962
	for (; p != NULL; p = nextp) {
1054
	for (; p != NULL; p = nextp) {
Lines 1163-1168 Link Here
1163
			hwif->selectproc = pmac_ide_selectproc;
1255
			hwif->selectproc = pmac_ide_selectproc;
1164
		hwif->speedproc = pmac_ide_tune_chipset;
1256
		hwif->speedproc = pmac_ide_tune_chipset;
1165
1257
1258
#ifdef CONFIG_PMU_HD_BLINK
1259
		if (has_blink)
1260
			hwif->led_act = pmu_hd_kick_blink;
1261
#endif /* CONFIG_PMU_HD_BLINK */
1262
1166
		printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s\n",
1263
		printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s\n",
1167
			i, model_name[pmif->kind], pmif->aapl_bus_id,
1264
			i, model_name[pmif->kind], pmif->aapl_bus_id,
1168
			in_bay ? " (mediabay)" : "");
1265
			in_bay ? " (mediabay)" : "");
Lines 1207-1212 Link Here
1207
#ifdef CONFIG_PMAC_PBOOK
1304
#ifdef CONFIG_PMAC_PBOOK
1208
	pmu_register_sleep_notifier(&idepmac_sleep_notifier);
1305
	pmu_register_sleep_notifier(&idepmac_sleep_notifier);
1209
#endif /* CONFIG_PMAC_PBOOK */
1306
#endif /* CONFIG_PMAC_PBOOK */
1307
1308
	mdelay(IDE_WAKEUP_DELAY_MS);
1210
}
1309
}
1211
1310
1212
#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
1311
#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
(-)linux-2.4.22/drivers/ide/setup-pci.c (-4 / +5 lines)
Lines 51-57 Link Here
51
{
51
{
52
	int h;
52
	int h;
53
	ide_hwif_t *hwif;
53
	ide_hwif_t *hwif;
54
54
	int reserved = ide_reserved_hwifs();
55
	
55
	/*
56
	/*
56
	 * Look for a hwif with matching io_base specified using
57
	 * Look for a hwif with matching io_base specified using
57
	 * parameters to ide_setup().
58
	 * parameters to ide_setup().
Lines 90-107 Link Here
90
	 */
91
	 */
91
	if (bootable) {
92
	if (bootable) {
92
		for (h = 0; h < MAX_HWIFS; ++h) {
93
		for (h = 0; h < MAX_HWIFS; ++h) {
93
			hwif = &ide_hwifs[h];
94
			hwif = ide_hwifs + h;
94
			if (hwif->chipset == ide_unknown)
95
			if (hwif->chipset == ide_unknown)
95
				return hwif;	/* pick an unused entry */
96
				return hwif;	/* pick an unused entry */
96
		}
97
		}
97
	} else {
98
	} else {
98
		for (h = 2; h < MAX_HWIFS; ++h) {
99
		for (h = reserved; h < MAX_HWIFS; ++h) {
99
			hwif = ide_hwifs + h;
100
			hwif = ide_hwifs + h;
100
			if (hwif->chipset == ide_unknown)
101
			if (hwif->chipset == ide_unknown)
101
				return hwif;	/* pick an unused entry */
102
				return hwif;	/* pick an unused entry */
102
		}
103
		}
103
	}
104
	}
104
	for (h = 0; h < 2; ++h) {
105
	for (h = 0; h < reserved; ++h) {
105
		hwif = ide_hwifs + h;
106
		hwif = ide_hwifs + h;
106
		if (hwif->chipset == ide_unknown)
107
		if (hwif->chipset == ide_unknown)
107
			return hwif;	/* pick an unused entry */
108
			return hwif;	/* pick an unused entry */
(-)linux-2.4.22/drivers/macintosh/Makefile (+2 lines)
Lines 35-40 Link Here
35
obj-$(CONFIG_INPUT_ADBHID)	+= adbhid.o
35
obj-$(CONFIG_INPUT_ADBHID)	+= adbhid.o
36
obj-$(CONFIG_PPC_RTC)		+= rtc.o
36
obj-$(CONFIG_PPC_RTC)		+= rtc.o
37
obj-$(CONFIG_ANSLCD)		+= ans-lcd.o
37
obj-$(CONFIG_ANSLCD)		+= ans-lcd.o
38
#obj-$(CONFIG_I2C)		+= therm_pismo.o
39
#obj-$(CONFIG_I2C)		+= therm_albooks.o
38
40
39
obj-$(CONFIG_ADB_PMU)		+= via-pmu.o
41
obj-$(CONFIG_ADB_PMU)		+= via-pmu.o
40
obj-$(CONFIG_ADB_CUDA)		+= via-cuda.o
42
obj-$(CONFIG_ADB_CUDA)		+= via-cuda.o
(-)linux-2.4.22/drivers/macintosh/macserial.c (-11 / +10 lines)
Lines 59-65 Link Here
59
};
59
};
60
#endif
60
#endif
61
61
62
#define SUPPORT_SERIAL_DMA
62
#undef SUPPORT_SERIAL_DMA
63
#define MACSERIAL_VERSION	"2.0"
63
#define MACSERIAL_VERSION	"2.0"
64
64
65
/*
65
/*
Lines 1134-1139 Link Here
1134
 */
1134
 */
1135
static void shutdown(struct mac_serial * info)
1135
static void shutdown(struct mac_serial * info)
1136
{
1136
{
1137
	unsigned long flags;
1138
	
1137
	OPNDBG("Shutting down serial port %d (irq %d)....\n", info->line,
1139
	OPNDBG("Shutting down serial port %d (irq %d)....\n", info->line,
1138
	       info->irq);
1140
	       info->irq);
1139
1141
Lines 1142-1147 Link Here
1142
		return;
1144
		return;
1143
	}
1145
	}
1144
1146
1147
	save_flags(flags); cli(); /* Disable interrupts */
1148
1145
	if (info->has_dma) {
1149
	if (info->has_dma) {
1146
		del_timer(&info->poll_dma_timer);
1150
		del_timer(&info->poll_dma_timer);
1147
		dbdma_reset(info->tx_dma);
1151
		dbdma_reset(info->tx_dma);
Lines 1151-1156 Link Here
1151
	}
1155
	}
1152
	disable_irq(info->irq);
1156
	disable_irq(info->irq);
1153
1157
1158
	restore_flags(flags);
1159
1154
	info->pendregs[1] = info->curregs[1] = 0;
1160
	info->pendregs[1] = info->curregs[1] = 0;
1155
	write_zsreg(info->zs_channel, 1, 0);	/* no interrupts */
1161
	write_zsreg(info->zs_channel, 1, 0);	/* no interrupts */
1156
1162
Lines 1980-1985 Link Here
1980
		return;
1986
		return;
1981
	}
1987
	}
1982
	info->flags |= ZILOG_CLOSING;
1988
	info->flags |= ZILOG_CLOSING;
1989
	restore_flags(flags);
1983
	/*
1990
	/*
1984
	 * Save the termios structure, since this port may have
1991
	 * Save the termios structure, since this port may have
1985
	 * separate termios for callout and dialin.
1992
	 * separate termios for callout and dialin.
Lines 1994-2004 Link Here
1994
	 */
2001
	 */
1995
	OPNDBG("waiting end of Tx... (timeout:%d)\n", info->closing_wait);
2002
	OPNDBG("waiting end of Tx... (timeout:%d)\n", info->closing_wait);
1996
	tty->closing = 1;
2003
	tty->closing = 1;
1997
	if (info->closing_wait != ZILOG_CLOSING_WAIT_NONE) {
2004
	if (info->closing_wait != ZILOG_CLOSING_WAIT_NONE)
1998
		restore_flags(flags);
1999
		tty_wait_until_sent(tty, info->closing_wait);
2005
		tty_wait_until_sent(tty, info->closing_wait);
2000
		save_flags(flags); cli();
2001
	}
2002
2006
2003
	/*
2007
	/*
2004
	 * At this point we stop accepting input.  To do this, we
2008
	 * At this point we stop accepting input.  To do this, we
Lines 2017-2031 Link Here
2017
		 * has completely drained.
2021
		 * has completely drained.
2018
		 */
2022
		 */
2019
		OPNDBG("waiting end of Rx...\n");
2023
		OPNDBG("waiting end of Rx...\n");
2020
		restore_flags(flags);
2021
		rs_wait_until_sent(tty, info->timeout);
2024
		rs_wait_until_sent(tty, info->timeout);
2022
		save_flags(flags); cli();
2023
	}
2025
	}
2024
2026
2025
	shutdown(info);
2027
	shutdown(info);
2026
	/* restore flags now since shutdown() will have disabled this port's
2027
	   specific irqs */
2028
	restore_flags(flags);
2029
2028
2030
	if (tty->driver.flush_buffer)
2029
	if (tty->driver.flush_buffer)
2031
		tty->driver.flush_buffer(tty);
2030
		tty->driver.flush_buffer(tty);
Lines 2880-2886 Link Here
2880
static int __init serial_console_setup(struct console *co, char *options)
2879
static int __init serial_console_setup(struct console *co, char *options)
2881
{
2880
{
2882
	struct mac_serial *info;
2881
	struct mac_serial *info;
2883
	int	baud = 38400;
2882
	int	baud = 57600; /*38400;*/
2884
	int	bits = 8;
2883
	int	bits = 8;
2885
	int	parity = 'n';
2884
	int	parity = 'n';
2886
	int	cflag = CREAD | HUPCL | CLOCAL;
2885
	int	cflag = CREAD | HUPCL | CLOCAL;
(-)linux-2.4.22/drivers/macintosh/therm_pismo.c (+269 lines)
Line 0 Link Here
1
/*
2
 * Device driver for the i2c thermostat found on some laptops
3
 *
4
 * Copyright (C) 2001 Benjamin Herrenschmidt
5
 * 
6
 * Actually, there are 2 DS1775R1 on uninorth I2C busses
7
 */
8
9
#include <linux/config.h>
10
#include <linux/types.h>
11
#include <linux/module.h>
12
#include <linux/errno.h>
13
#include <linux/kernel.h>
14
#include <linux/delay.h>
15
#include <linux/sched.h>
16
#include <linux/i2c.h>
17
#include <linux/slab.h>
18
#include <linux/init.h>
19
#include <asm/prom.h>
20
#include <asm/machdep.h>
21
#include <asm/io.h>
22
#include <asm/system.h>
23
#include <asm/sections.h>
24
25
#define DEBUG
26
27
#define I2C_THERMOSTAT_ADDR	0x49
28
#define I2C_THERMOSTAT_ADDR2	0x48
29
#define MAX_THERMOSTATS		4
30
31
32
MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
33
MODULE_DESCRIPTION("Driver for DS1775 thermostat on Apple laptops");
34
MODULE_LICENSE("GPL");
35
EXPORT_NO_SYMBOLS;
36
37
struct temp_range
38
{
39
	u8	high;	/* Start the fan */
40
	u8	low;	/* Stop the fan */
41
};
42
43
struct apple_thermal_info {
44
	u8			id;			/* Implementation ID */
45
	u8			fan_count;		/* Number of fans */
46
	u8			thermostat_count;	/* Number of thermostats */
47
	u8			unused[5];
48
	struct temp_range	ranges[4];		/* Temperature ranges (may be [])*/
49
};
50
51
struct thermostat {
52
	struct i2c_client	clt;
53
	int			th_num;
54
	// more to come ?
55
};
56
57
static struct apple_thermal_info *thinfo;
58
static struct thermostat* thermostats[MAX_THERMOSTATS];
59
static int therm_count;
60
61
static int	attach_thermostat(struct i2c_adapter *adapter);
62
static int	detach_thermostat(struct i2c_client *client);
63
64
/* What is this supposed to be ? registered ? I hate
65
 * magic numbers like that ...
66
 */
67
#define I2C_DRIVERID_THERMOSTAT (0xDEAD)
68
69
static struct i2c_driver thermostat_driver = {  
70
	name:		"Apple Thermostat",
71
	id:		I2C_DRIVERID_THERMOSTAT,
72
	flags:		I2C_DF_NOTIFY,
73
	attach_adapter:	&attach_thermostat,
74
	detach_client:	&detach_thermostat,
75
	command:	NULL,
76
	inc_use:	NULL,
77
	dec_use:	NULL 
78
};
79
80
static int
81
write_reg(struct thermostat* th, int reg, u8* data, int len)
82
{
83
	u8 tmp[5];
84
	int rc;
85
	
86
	if (len > 4)
87
		return -EINVAL;
88
	tmp[0] = reg;
89
	memcpy(&tmp[1], data, len);
90
	rc = i2c_master_send(&th->clt, (const char *)tmp, len+1);
91
	if (rc < 0)
92
		return rc;
93
	if (rc != (len+1))
94
		return -ENODEV;
95
	return 0;
96
}
97
98
static int
99
read_reg(struct thermostat* th, int reg, u8* data, int len)
100
{
101
	u8 reg_addr;
102
	int rc;
103
104
	reg_addr = (u8)reg;
105
	rc = i2c_master_send(&th->clt, &reg_addr, 1);
106
	if (rc < 0)
107
		return rc;
108
	if (rc != 1)
109
		return -ENODEV;
110
	rc = i2c_master_recv(&th->clt, (char *)data, len);
111
	if (rc < 0)
112
		return rc;
113
	if (rc != len)
114
		return -ENODEV;
115
	return 0;
116
}
117
118
static int
119
attach_one_thermostat(struct i2c_adapter *adapter, int addr, int num)
120
{
121
	struct thermostat* th;
122
	int rc;
123
	u16 t, tlo, thi;
124
	u8 config;
125
	
126
	if (therm_count >= MAX_THERMOSTATS) {
127
		printk(KERN_WARNING "Skipped thermostat %d (%s:%x), max count reached !\n",
128
			num, adapter->name, addr);
129
		return -ENODEV;
130
	}
131
	
132
	th = (struct thermostat *)kmalloc(sizeof(struct thermostat), GFP_KERNEL);
133
	if (!th)
134
		return -ENOMEM;
135
	th->clt.addr = addr;
136
	th->clt.adapter = adapter;
137
	th->clt.driver = &thermostat_driver;
138
	th->clt.flags = 0;
139
	th->clt.data = (void *)therm_count;
140
	th->th_num = num;
141
	strcpy(th->clt.name, "thermostat");
142
143
	rc = read_reg(th, 1, &config, 1);
144
	if (rc < 0) {
145
		printk(KERN_ERR "Thermostat %d (%s:%x) failed to read config !\n",
146
			num, adapter->name, addr);
147
		kfree(th);
148
		return -ENODEV;
149
	}
150
	printk(KERN_INFO "Thermostat %d (%s:%x), config: %02x\n",
151
		num, adapter->name, addr, config);
152
153
	rc = read_reg(th, 0, (u8 *)&t, 2);
154
	if (rc < 0) {
155
		printk(KERN_ERR "Thermostat %d (%s:%x) failed to read temp !\n",
156
			num, adapter->name, addr);
157
		kfree(th);
158
		return -ENODEV;
159
	}
160
	printk(KERN_INFO "Thermostat %d (%s:%x), temp: %04x (about: %d degree C)\n",
161
		num, adapter->name, addr, t, t>>8);
162
163
	thermostats[therm_count++] = th;
164
165
	if (i2c_attach_client(&th->clt)) {
166
		printk(KERN_ERR "Thermostat %d (%s:%x), failed to attach client !\n",
167
			num, adapter->name, addr);
168
		thermostats[--therm_count] = NULL;
169
		kfree(th);
170
		return -ENODEV;
171
	}
172
173
	tlo = thi = 0;
174
	rc = read_reg(th, 2, (u8 *)&tlo, 2);
175
	if (rc < 0) {
176
		printk(KERN_WARNING "Thermostat %d (%s:%x) failed to read low threshold !\n",
177
			num, adapter->name, addr);
178
	}
179
	rc = read_reg(th, 3, (u8 *)&thi, 2);
180
	if (rc < 0) {
181
		printk(KERN_WARNING "Thermostat %d (%s:%x) failed to read high threshold !\n",
182
			num, adapter->name, addr);
183
	}
184
	printk(KERN_INFO "Thermostat %d (%s:%x), tl: %04x (%d degree C), th: %04x (%d degree C)\n",
185
		num, adapter->name, addr, tlo, tlo>>8, thi, thi>>8);
186
	return 0;
187
}
188
189
static int
190
attach_thermostat(struct i2c_adapter *adapter)
191
{
192
	unsigned long bus_no;
193
	int rc;
194
195
	if (strncmp(adapter->name, "uni-n", 5))
196
		return 0;
197
	bus_no = simple_strtoul(adapter->name + 6, NULL, 10);	
198
	rc = attach_one_thermostat(adapter, I2C_THERMOSTAT_ADDR, bus_no);
199
	if (!rc && thinfo->thermostat_count > 2)
200
		attach_one_thermostat(adapter, I2C_THERMOSTAT_ADDR2, bus_no+2);
201
202
	return rc;
203
}
204
205
static int
206
detach_thermostat(struct i2c_client *client)
207
{
208
	int index = (int)client->data;
209
	struct thermostat* th;
210
211
	if (index >= MAX_THERMOSTATS || !thermostats[index]) {
212
		printk(KERN_ERR "Invalid client in deatch_thermostat()\n");
213
		return -ENODEV;
214
	}
215
	th = thermostats[index];
216
	i2c_detach_client(&th->clt);
217
	thermostats[index] = NULL;
218
	
219
	kfree(th);
220
221
	return 0;
222
}
223
224
static int __init
225
thermostat_init(void)
226
{
227
	struct device_node* np;
228
229
	if (!machine_is_compatible("PowerBook3,1"))
230
		return -ENODEV;
231
232
	np = find_devices("power-mgt");
233
	if (!np)
234
		return -ENODEV;
235
	thinfo = (struct apple_thermal_info *)get_property(np, "thermal-info", NULL);
236
	if (!thinfo)
237
		return -ENODEV;
238
		
239
#ifdef DEBUG
240
	printk(KERN_DEBUG " Thermal Infos found :\n");
241
	printk(KERN_DEBUG "   implementation id : %d\n", thinfo->id);
242
	printk(KERN_DEBUG "   fan_count         : %d\n", thinfo->fan_count);
243
	printk(KERN_DEBUG "   thermostat_count  : %d\n", thinfo->thermostat_count);
244
	printk(KERN_DEBUG "   ranges[0]         : %d,%d\n",
245
		thinfo->ranges[0].high, thinfo->ranges[0].low);
246
	printk(KERN_DEBUG "   ranges[1]         : %d,%d\n",
247
		thinfo->ranges[1].high, thinfo->ranges[1].low);
248
	printk(KERN_DEBUG "   ranges[2]         : %d,%d\n",
249
		thinfo->ranges[2].high, thinfo->ranges[2].low);
250
	printk(KERN_DEBUG "   ranges[3]         : %d,%d\n",
251
		thinfo->ranges[3].high, thinfo->ranges[3].low);
252
#endif
253
	/* Check against titaniums & ibooks.... */
254
	if (thinfo->id != 1 && thinfo->id != 2) {
255
		printk(KERN_ERR "thermostat: design id %d unknown !\n", thinfo->id);
256
		return -ENODEV;
257
	}
258
	
259
	return i2c_add_driver(&thermostat_driver);
260
}
261
262
static void __exit
263
thermostat_exit(void)
264
{
265
	i2c_del_driver(&thermostat_driver);
266
}
267
268
module_init(thermostat_init);
269
module_exit(thermostat_exit);
(-)linux-2.4.22/drivers/macintosh/via-pmu.c (-50 / +226 lines)
Lines 64-69 Link Here
64
/* How many iterations between battery polls */
64
/* How many iterations between battery polls */
65
#define BATTERY_POLLING_COUNT	2
65
#define BATTERY_POLLING_COUNT	2
66
66
67
/* Some debugging tools */
68
#ifdef CONFIG_XMON
69
//#define LIVE_DEBUG(req) ((req) && (req)->data[0] == 0x7d)
70
#define LIVE_DEBUG(req) (0)
71
static int whacky_debug;
72
#endif /* CONFIG_XMON */
73
67
static volatile unsigned char *via;
74
static volatile unsigned char *via;
68
75
69
/* VIA registers - spaced 0x200 bytes apart */
76
/* VIA registers - spaced 0x200 bytes apart */
Lines 107-112 Link Here
107
	intack,
114
	intack,
108
	reading,
115
	reading,
109
	reading_intr,
116
	reading_intr,
117
	locked,
110
} pmu_state;
118
} pmu_state;
111
119
112
static volatile enum int_data_state {
120
static volatile enum int_data_state {
Lines 134-139 Link Here
134
static int pmu_has_adb;
142
static int pmu_has_adb;
135
static unsigned char *gpio_reg = NULL;
143
static unsigned char *gpio_reg = NULL;
136
static int gpio_irq = -1;
144
static int gpio_irq = -1;
145
static int gpio_irq_enabled = -1;
137
static volatile int pmu_suspended = 0;
146
static volatile int pmu_suspended = 0;
138
static spinlock_t pmu_lock;
147
static spinlock_t pmu_lock;
139
static u8 pmu_intr_mask;
148
static u8 pmu_intr_mask;
Lines 144-152 Link Here
144
static int sleep_in_progress;
153
static int sleep_in_progress;
145
static int can_sleep;
154
static int can_sleep;
146
#endif /* CONFIG_PMAC_PBOOK */
155
#endif /* CONFIG_PMAC_PBOOK */
156
static unsigned int pmu_irq_stats[11];
147
157
148
static struct proc_dir_entry *proc_pmu_root;
158
static struct proc_dir_entry *proc_pmu_root;
149
static struct proc_dir_entry *proc_pmu_info;
159
static struct proc_dir_entry *proc_pmu_info;
160
static struct proc_dir_entry *proc_pmu_irqstats;
150
static struct proc_dir_entry *proc_pmu_options;
161
static struct proc_dir_entry *proc_pmu_options;
151
162
152
#ifdef CONFIG_PMAC_PBOOK
163
#ifdef CONFIG_PMAC_PBOOK
Lines 185-190 Link Here
185
static void gpio1_interrupt(int irq, void *arg, struct pt_regs *regs);
196
static void gpio1_interrupt(int irq, void *arg, struct pt_regs *regs);
186
static int proc_get_info(char *page, char **start, off_t off,
197
static int proc_get_info(char *page, char **start, off_t off,
187
			  int count, int *eof, void *data);
198
			  int count, int *eof, void *data);
199
static int proc_get_irqstats(char *page, char **start, off_t off,
200
			  int count, int *eof, void *data);
188
#ifdef CONFIG_PMAC_BACKLIGHT
201
#ifdef CONFIG_PMAC_BACKLIGHT
189
static int pmu_set_backlight_level(int level, void* data);
202
static int pmu_set_backlight_level(int level, void* data);
190
static int pmu_set_backlight_enable(int on, int level, void* data);
203
static int pmu_set_backlight_enable(int on, int level, void* data);
Lines 206-212 Link Here
206
	pmu_init,
219
	pmu_init,
207
	pmu_send_request,
220
	pmu_send_request,
208
	pmu_adb_autopoll,
221
	pmu_adb_autopoll,
209
	pmu_poll,
222
	pmu_poll_adb,
210
	pmu_adb_reset_bus
223
	pmu_adb_reset_bus
211
};
224
};
212
#endif /* CONFIG_ADB */
225
#endif /* CONFIG_ADB */
Lines 419-424 Link Here
419
	if (pmu_kind == PMU_KEYLARGO_BASED && gpio_irq != -1) {
432
	if (pmu_kind == PMU_KEYLARGO_BASED && gpio_irq != -1) {
420
		if (request_irq(gpio_irq, gpio1_interrupt, 0, "GPIO1/ADB", (void *)0))
433
		if (request_irq(gpio_irq, gpio1_interrupt, 0, "GPIO1/ADB", (void *)0))
421
			printk(KERN_ERR "pmu: can't get irq %d (GPIO1)\n", gpio_irq);
434
			printk(KERN_ERR "pmu: can't get irq %d (GPIO1)\n", gpio_irq);
435
		gpio_irq_enabled = 1;
422
	}
436
	}
423
437
424
	/* Enable interrupts */
438
	/* Enable interrupts */
Lines 466-471 Link Here
466
		int i;
480
		int i;
467
		proc_pmu_info = create_proc_read_entry("info", 0, proc_pmu_root,
481
		proc_pmu_info = create_proc_read_entry("info", 0, proc_pmu_root,
468
					proc_get_info, NULL);
482
					proc_get_info, NULL);
483
		proc_pmu_irqstats = create_proc_read_entry("interrupts", 0, proc_pmu_root,
484
					proc_get_irqstats, NULL);
469
#ifdef CONFIG_PMAC_PBOOK
485
#ifdef CONFIG_PMAC_PBOOK
470
		for (i=0; i<pmu_battery_count; i++) {
486
		for (i=0; i<pmu_battery_count; i++) {
471
			char title[16];
487
			char title[16];
Lines 540-547 Link Here
540
556
541
	/* Read PMU version */
557
	/* Read PMU version */
542
	pmu_request(&req, NULL, 1, PMU_GET_VERSION);
558
	pmu_request(&req, NULL, 1, PMU_GET_VERSION);
543
	while (!req.complete)
559
	pmu_wait_complete(&req);
544
		pmu_poll();
545
	if (req.reply_len > 0)
560
	if (req.reply_len > 0)
546
		pmu_version = req.reply[0];
561
		pmu_version = req.reply[0];
547
562
Lines 745-751 Link Here
745
760
746
#endif /* CONFIG_PMAC_PBOOK */
761
#endif /* CONFIG_PMAC_PBOOK */
747
762
748
static int
763
static int __pmac
749
proc_get_info(char *page, char **start, off_t off,
764
proc_get_info(char *page, char **start, off_t off,
750
		int count, int *eof, void *data)
765
		int count, int *eof, void *data)
751
{
766
{
Lines 762-769 Link Here
762
	return p - page;
777
	return p - page;
763
}
778
}
764
779
780
static int __pmac
781
proc_get_irqstats(char *page, char **start, off_t off,
782
		  int count, int *eof, void *data)
783
{
784
	int i;
785
	char* p = page;
786
	static const char *irq_names[] = {
787
		"Total CB1 triggered events",
788
		"Total GPIO1 triggered events",
789
		"PC-Card eject button",
790
		"Sound/Brightness button",
791
		"ADB message",
792
		"Battery state change",
793
		"Environment interrupt",
794
		"Tick timer",
795
		"Ghost interrupt (zero len)",
796
		"Empty interrupt (empty mask)",
797
		"Max irqs in a row"
798
        };
799
800
	for (i=0; i<11; i++) {
801
		p += sprintf(p, " %2u: %10u (%s)\n",
802
			     i, pmu_irq_stats[i], irq_names[i]);
803
	}
804
	return p - page;
805
}
806
765
#ifdef CONFIG_PMAC_PBOOK
807
#ifdef CONFIG_PMAC_PBOOK
766
static int
808
static int __pmac
767
proc_get_batt(char *page, char **start, off_t off,
809
proc_get_batt(char *page, char **start, off_t off,
768
		int count, int *eof, void *data)
810
		int count, int *eof, void *data)
769
{
811
{
Lines 788-794 Link Here
788
}
830
}
789
#endif /* CONFIG_PMAC_PBOOK */
831
#endif /* CONFIG_PMAC_PBOOK */
790
832
791
static int
833
static int __pmac
792
proc_read_options(char *page, char **start, off_t off,
834
proc_read_options(char *page, char **start, off_t off,
793
			int count, int *eof, void *data)
835
			int count, int *eof, void *data)
794
{
836
{
Lines 802-808 Link Here
802
	return p - page;
844
	return p - page;
803
}
845
}
804
			
846
			
805
static int
847
static int __pmac
806
proc_write_options(struct file *file, const char *buffer,
848
proc_write_options(struct file *file, const char *buffer,
807
			unsigned long count, void *data)
849
			unsigned long count, void *data)
808
{
850
{
Lines 843-849 Link Here
843
885
844
#ifdef CONFIG_ADB
886
#ifdef CONFIG_ADB
845
/* Send an ADB command */
887
/* Send an ADB command */
846
static int __openfirmware
888
static int __pmac
847
pmu_send_request(struct adb_request *req, int sync)
889
pmu_send_request(struct adb_request *req, int sync)
848
{
890
{
849
	int i, ret;
891
	int i, ret;
Lines 923-929 Link Here
923
}
965
}
924
966
925
/* Enable/disable autopolling */
967
/* Enable/disable autopolling */
926
static int __openfirmware
968
static int __pmac
927
pmu_adb_autopoll(int devs)
969
pmu_adb_autopoll(int devs)
928
{
970
{
929
	struct adb_request req;
971
	struct adb_request req;
Lines 946-952 Link Here
946
}
988
}
947
989
948
/* Reset the ADB bus */
990
/* Reset the ADB bus */
949
static int __openfirmware
991
static int __pmac
950
pmu_adb_reset_bus(void)
992
pmu_adb_reset_bus(void)
951
{
993
{
952
	struct adb_request req;
994
	struct adb_request req;
Lines 971-978 Link Here
971
		printk(KERN_ERR "pmu_adb_reset_bus: pmu_queue_request failed\n");
1013
		printk(KERN_ERR "pmu_adb_reset_bus: pmu_queue_request failed\n");
972
		return -EIO;
1014
		return -EIO;
973
	}
1015
	}
974
	while (!req.complete)
1016
	pmu_wait_complete(&req);
975
		pmu_poll();
976
1017
977
	if (save_autopoll != 0)
1018
	if (save_autopoll != 0)
978
		pmu_adb_autopoll(save_autopoll);
1019
		pmu_adb_autopoll(save_autopoll);
Lines 1008-1014 Link Here
1008
	return pmu_queue_request(req);
1049
	return pmu_queue_request(req);
1009
}
1050
}
1010
1051
1011
int __openfirmware
1052
int __pmac
1012
pmu_queue_request(struct adb_request *req)
1053
pmu_queue_request(struct adb_request *req)
1013
{
1054
{
1014
	unsigned long flags;
1055
	unsigned long flags;
Lines 1050-1056 Link Here
1050
static inline void
1091
static inline void
1051
wait_for_ack(void)
1092
wait_for_ack(void)
1052
{
1093
{
1053
	/* Sightly increased the delay, I had one occurence of the message
1094
	/* Sightly increased the delay, I had one occurrence of the message
1054
	 * reported
1095
	 * reported
1055
	 */
1096
	 */
1056
	int timeout = 4000;
1097
	int timeout = 4000;
Lines 1100-1107 Link Here
1100
		(*done)(req);
1141
		(*done)(req);
1101
}
1142
}
1102
1143
1103
static void __openfirmware
1144
static void __pmac
1104
pmu_start()
1145
pmu_start(void)
1105
{
1146
{
1106
	struct adb_request *req;
1147
	struct adb_request *req;
1107
1148
Lines 1122-1138 Link Here
1122
	wait_for_ack();
1163
	wait_for_ack();
1123
	/* set the shift register to shift out and send a byte */
1164
	/* set the shift register to shift out and send a byte */
1124
	send_byte(req->data[0]);
1165
	send_byte(req->data[0]);
1166
#ifdef CONFIG_XMON
1167
	if (LIVE_DEBUG(req))
1168
		xmon_printf("R");
1169
	else
1170
		whacky_debug = 0;
1171
#endif /* CONFIG_XMON */
1172
}
1173
1174
void __openfirmware
1175
pmu_poll(void)
1176
{
1177
	if (!via)
1178
		return;
1179
	if (disable_poll)
1180
		return;
1181
	via_pmu_interrupt(0, 0, 0);
1125
}
1182
}
1126
1183
1127
void __openfirmware
1184
void __openfirmware
1128
pmu_poll()
1185
pmu_poll_adb(void)
1129
{
1186
{
1130
	if (!via)
1187
	if (!via)
1131
		return;
1188
		return;
1132
	if (disable_poll)
1189
	if (disable_poll)
1133
		return;
1190
		return;
1134
	/* Kicks ADB read when PMU is suspended */
1191
	/* Kicks ADB read when PMU is suspended */
1135
	if (pmu_suspended)
1136
		adb_int_pending = 1;
1192
		adb_int_pending = 1;
1137
	do {
1193
	do {
1138
		via_pmu_interrupt(0, 0, 0);
1194
		via_pmu_interrupt(0, 0, 0);
Lines 1140-1145 Link Here
1140
		|| req_awaiting_reply));
1196
		|| req_awaiting_reply));
1141
}
1197
}
1142
1198
1199
void __openfirmware
1200
pmu_wait_complete(struct adb_request *req)
1201
{
1202
	if (!via)
1203
		return;
1204
	while((pmu_state != idle && pmu_state != locked) || !req->complete)
1205
		via_pmu_interrupt(0, 0, 0);
1206
}
1207
1143
/* This function loops until the PMU is idle and prevents it from
1208
/* This function loops until the PMU is idle and prevents it from
1144
 * anwsering to ADB interrupts. pmu_request can still be called.
1209
 * anwsering to ADB interrupts. pmu_request can still be called.
1145
 * This is done to avoid spurrious shutdowns when we know we'll have
1210
 * This is done to avoid spurrious shutdowns when we know we'll have
Lines 1164-1169 Link Here
1164
1229
1165
	do {
1230
	do {
1166
		spin_unlock_irqrestore(&pmu_lock, flags);
1231
		spin_unlock_irqrestore(&pmu_lock, flags);
1232
		if (req_awaiting_reply)
1233
			adb_int_pending = 1;
1167
		via_pmu_interrupt(0, 0, 0);
1234
		via_pmu_interrupt(0, 0, 0);
1168
		spin_lock_irqsave(&pmu_lock, flags);
1235
		spin_lock_irqsave(&pmu_lock, flags);
1169
		if (!adb_int_pending && pmu_state == idle && !req_awaiting_reply) {
1236
		if (!adb_int_pending && pmu_state == idle && !req_awaiting_reply) {
Lines 1174-1180 Link Here
1174
				pmu_poll();
1241
				pmu_poll();
1175
#else /* SUSPEND_USES_PMU */
1242
#else /* SUSPEND_USES_PMU */
1176
			if (gpio_irq >= 0)
1243
			if (gpio_irq >= 0)
1177
				disable_irq(gpio_irq);
1244
				disable_irq_nosync(gpio_irq);
1178
			out_8(&via[IER], CB1_INT | IER_CLR);
1245
			out_8(&via[IER], CB1_INT | IER_CLR);
1179
			spin_unlock_irqrestore(&pmu_lock, flags);
1246
			spin_unlock_irqrestore(&pmu_lock, flags);
1180
#endif /* SUSPEND_USES_PMU */
1247
#endif /* SUSPEND_USES_PMU */
Lines 1213-1231 Link Here
1213
}
1280
}
1214
1281
1215
/* Interrupt data could be the result data from an ADB cmd */
1282
/* Interrupt data could be the result data from an ADB cmd */
1216
static void __openfirmware
1283
static void __pmac
1217
pmu_handle_data(unsigned char *data, int len, struct pt_regs *regs)
1284
pmu_handle_data(unsigned char *data, int len, struct pt_regs *regs)
1218
{
1285
{
1286
	unsigned char ints, pirq;
1287
	int i = 0;
1288
1219
	asleep = 0;
1289
	asleep = 0;
1220
	if (drop_interrupts || len < 1) {
1290
	if (drop_interrupts || len < 1) {
1221
		adb_int_pending = 0;
1291
		adb_int_pending = 0;
1292
		pmu_irq_stats[8]++;
1222
		return;
1293
		return;
1223
	}
1294
	}
1295
1296
	/* Get PMU interrupt mask */
1297
	ints = data[0];
1298
1299
	/* Record zero interrupts for stats */
1300
	if (ints == 0)
1301
		pmu_irq_stats[9]++;
1302
1303
	/* Hack to deal with ADB autopoll flag */
1304
	if (ints & PMU_INT_ADB)
1305
		ints &= ~(PMU_INT_ADB_AUTO | PMU_INT_AUTO_SRQ_POLL);
1306
1307
next:
1308
1309
	if (ints == 0) {
1310
		if (i > pmu_irq_stats[10])
1311
			pmu_irq_stats[10] = i;
1312
		return;
1313
	}
1314
1315
	for (pirq = 0; pirq < 8; pirq++)
1316
		if (ints & (1 << pirq))
1317
			break;
1318
	pmu_irq_stats[pirq]++;
1319
	i++;
1320
	ints &= ~(1 << pirq);
1321
1224
	/* Note: for some reason, we get an interrupt with len=1,
1322
	/* Note: for some reason, we get an interrupt with len=1,
1225
	 * data[0]==0 after each normal ADB interrupt, at least
1323
	 * data[0]==0 after each normal ADB interrupt, at least
1226
	 * on the Pismo. Still investigating...  --BenH
1324
	 * on the Pismo. Still investigating...  --BenH
1227
	 */
1325
	 */
1228
	if (data[0] & PMU_INT_ADB) {
1326
	if ((1 << pirq) & PMU_INT_ADB) {
1229
		if ((data[0] & PMU_INT_ADB_AUTO) == 0) {
1327
		if ((data[0] & PMU_INT_ADB_AUTO) == 0) {
1230
			struct adb_request *req = req_awaiting_reply;
1328
			struct adb_request *req = req_awaiting_reply;
1231
			if (req == 0) {
1329
			if (req == 0) {
Lines 1263-1294 Link Here
1263
				adb_input(data+1, len-1, regs, 1);
1361
				adb_input(data+1, len-1, regs, 1);
1264
#endif /* CONFIG_ADB */		
1362
#endif /* CONFIG_ADB */		
1265
		}
1363
		}
1266
	} else {
1364
	}
1267
		/* Sound/brightness button pressed */
1365
		/* Sound/brightness button pressed */
1268
		if ((data[0] & PMU_INT_SNDBRT) && len == 3) {
1366
	else if ((1 << pirq) & PMU_INT_SNDBRT) {
1269
#ifdef CONFIG_PMAC_BACKLIGHT
1367
#ifdef CONFIG_PMAC_BACKLIGHT
1368
		if (len == 3)
1270
#ifdef CONFIG_INPUT_ADBHID
1369
#ifdef CONFIG_INPUT_ADBHID
1271
			if (!disable_kernel_backlight)
1370
			if (!disable_kernel_backlight)
1272
#endif /* CONFIG_INPUT_ADBHID */
1371
#endif /* CONFIG_INPUT_ADBHID */
1273
				set_backlight_level(data[1] >> 4);
1372
				set_backlight_level(data[1] >> 4);
1274
#endif /* CONFIG_PMAC_BACKLIGHT */
1373
#endif /* CONFIG_PMAC_BACKLIGHT */
1275
		}
1374
		}
1375
	/* Tick interrupt */
1376
	else if ((1 << pirq) & PMU_INT_TICK) {
1276
#ifdef CONFIG_PMAC_PBOOK
1377
#ifdef CONFIG_PMAC_PBOOK
1277
		/* Environement or tick interrupt, query batteries */
1378
		/* Environement or tick interrupt, query batteries */
1278
		if (pmu_battery_count && (data[0] & PMU_INT_TICK)) {
1379
		if (pmu_battery_count) {
1279
			if ((--query_batt_timer) == 0) {
1380
			if ((--query_batt_timer) == 0) {
1280
				query_battery_state();
1381
				query_battery_state();
1281
				query_batt_timer = BATTERY_POLLING_COUNT;
1382
				query_batt_timer = BATTERY_POLLING_COUNT;
1282
			}
1383
			}
1283
		} else if (pmu_battery_count && (data[0] & PMU_INT_ENVIRONMENT))
1384
		}
1385
        }
1386
	else if ((1 << pirq) & PMU_INT_ENVIRONMENT) {
1387
		if (pmu_battery_count)
1284
			query_battery_state();
1388
			query_battery_state();
1285
 		if (data[0])
1286
			pmu_pass_intr(data, len);
1389
			pmu_pass_intr(data, len);
1390
	} else {
1391
	       pmu_pass_intr(data, len);
1287
#endif /* CONFIG_PMAC_PBOOK */
1392
#endif /* CONFIG_PMAC_PBOOK */
1288
	}
1393
	}
1394
	goto next;
1289
}
1395
}
1290
1396
1291
static struct adb_request* __openfirmware
1397
static struct adb_request* __pmac
1292
pmu_sr_intr(struct pt_regs *regs)
1398
pmu_sr_intr(struct pt_regs *regs)
1293
{
1399
{
1294
	struct adb_request *req;
1400
	struct adb_request *req;
Lines 1315-1331 Link Here
1315
	case sending:
1421
	case sending:
1316
		req = current_req;
1422
		req = current_req;
1317
		if (data_len < 0) {
1423
		if (data_len < 0) {
1424
#ifdef CONFIG_XMON
1425
			if (LIVE_DEBUG(req))
1426
				xmon_printf("s");
1427
#endif /* CONFIG_XMON */
1318
			data_len = req->nbytes - 1;
1428
			data_len = req->nbytes - 1;
1319
			send_byte(data_len);
1429
			send_byte(data_len);
1320
			break;
1430
			break;
1321
		}
1431
		}
1322
		if (data_index <= data_len) {
1432
		if (data_index <= data_len) {
1433
#ifdef CONFIG_XMON
1434
			if (LIVE_DEBUG(req))
1435
				xmon_printf("S");
1436
#endif /* CONFIG_XMON */
1323
			send_byte(req->data[data_index++]);
1437
			send_byte(req->data[data_index++]);
1324
			break;
1438
			break;
1325
		}
1439
		}
1326
		req->sent = 1;
1440
		req->sent = 1;
1327
		data_len = pmu_data_len[req->data[0]][1];
1441
		data_len = pmu_data_len[req->data[0]][1];
1328
		if (data_len == 0) {
1442
		if (data_len == 0) {
1443
#ifdef CONFIG_XMON
1444
			if (LIVE_DEBUG(req))
1445
				xmon_printf("D");
1446
#endif /* CONFIG_XMON */
1329
			pmu_state = idle;
1447
			pmu_state = idle;
1330
			current_req = req->next;
1448
			current_req = req->next;
1331
			if (req->reply_expected)
1449
			if (req->reply_expected)
Lines 1333-1338 Link Here
1333
			else
1451
			else
1334
				return req;
1452
				return req;
1335
		} else {
1453
		} else {
1454
#ifdef CONFIG_XMON
1455
			if (LIVE_DEBUG(req))
1456
				xmon_printf("-");
1457
#endif /* CONFIG_XMON */
1336
			pmu_state = reading;
1458
			pmu_state = reading;
1337
			data_index = 0;
1459
			data_index = 0;
1338
			reply_ptr = req->reply + req->reply_len;
1460
			reply_ptr = req->reply + req->reply_len;
Lines 1346-1360 Link Here
1346
		pmu_state = reading_intr;
1468
		pmu_state = reading_intr;
1347
		reply_ptr = interrupt_data[int_data_last];
1469
		reply_ptr = interrupt_data[int_data_last];
1348
		recv_byte();
1470
		recv_byte();
1471
		if (gpio_irq >= 0 && !gpio_irq_enabled) {
1472
			enable_irq(gpio_irq);
1473
			gpio_irq_enabled = 1;
1474
		}
1349
		break;
1475
		break;
1350
1476
1351
	case reading:
1477
	case reading:
1352
	case reading_intr:
1478
	case reading_intr:
1353
		if (data_len == -1) {
1479
		if (data_len == -1) {
1480
#ifdef CONFIG_XMON
1481
			if (LIVE_DEBUG(current_req))
1482
				xmon_printf("r");
1483
#endif /* CONFIG_XMON */
1354
			data_len = bite;
1484
			data_len = bite;
1355
			if (bite > 32)
1485
			if (bite > 32)
1356
				printk(KERN_ERR "PMU: bad reply len %d\n", bite);
1486
				printk(KERN_ERR "PMU: bad reply len %d\n", bite);
1357
		} else if (data_index < 32) {
1487
		} else if (data_index < 32) {
1488
#ifdef CONFIG_XMON
1489
			if (LIVE_DEBUG(current_req))
1490
				xmon_printf("R");
1491
#endif /* CONFIG_XMON */
1358
			reply_ptr[data_index++] = bite;
1492
			reply_ptr[data_index++] = bite;
1359
		}
1493
		}
1360
		if (data_index < data_len) {
1494
		if (data_index < data_len) {
Lines 1362-1375 Link Here
1362
			break;
1496
			break;
1363
		}
1497
		}
1364
1498
1499
#ifdef CONFIG_XMON
1500
		if (LIVE_DEBUG(current_req)) {
1501
			whacky_debug = 1;
1502
		       	xmon_printf("D");
1503
		}
1504
#endif /* CONFIG_XMON */
1365
		if (pmu_state == reading_intr) {
1505
		if (pmu_state == reading_intr) {
1366
			pmu_state = idle;
1506
			pmu_state = idle;
1367
			int_data_state[int_data_last] = int_data_ready;
1507
			int_data_state[int_data_last] = int_data_ready;
1368
			interrupt_data_len[int_data_last] = data_len;
1508
			interrupt_data_len[int_data_last] = data_len;
1369
		} else {
1509
		} else {
1370
			req = current_req;
1510
			req = current_req;
1511
			/* 
1512
			 * For PMU sleep and freq change requests, we lock the
1513
			 * PMU until it's explicitely unlocked. This avoids any
1514
			 * spurrious event polling getting in
1515
			 */
1371
			current_req = req->next;
1516
			current_req = req->next;
1372
			req->reply_len += data_index;
1517
			req->reply_len += data_index;
1518
			if (req->data[0] == PMU_SLEEP || req->data[0] == PMU_CPU_SPEED)
1519
				pmu_state = locked;
1520
			else
1373
			pmu_state = idle;
1521
			pmu_state = idle;
1374
			return req;
1522
			return req;
1375
		}
1523
		}
Lines 1399-1404 Link Here
1399
		intr = in_8(&via[IFR]) & (SR_INT | CB1_INT);
1547
		intr = in_8(&via[IFR]) & (SR_INT | CB1_INT);
1400
		if (intr == 0)
1548
		if (intr == 0)
1401
			break;
1549
			break;
1550
#ifdef CONFIG_XMON
1551
		if (whacky_debug)
1552
			xmon_printf("|%02x|", intr);
1553
#endif /* CONFIG_XMON */
1402
		if (++nloop > 1000) {
1554
		if (++nloop > 1000) {
1403
			printk(KERN_DEBUG "PMU: stuck in intr loop, "
1555
			printk(KERN_DEBUG "PMU: stuck in intr loop, "
1404
			       "intr=%x, ier=%x pmu_state=%d\n",
1556
			       "intr=%x, ier=%x pmu_state=%d\n",
Lines 1406-1413 Link Here
1406
			break;
1558
			break;
1407
		}
1559
		}
1408
		out_8(&via[IFR], intr);
1560
		out_8(&via[IFR], intr);
1409
		if (intr & CB1_INT)
1561
		if (intr & CB1_INT) {
1410
			adb_int_pending = 1;
1562
			adb_int_pending = 1;
1563
			pmu_irq_stats[0]++;
1564
		}
1411
		if (intr & SR_INT) {
1565
		if (intr & SR_INT) {
1412
			req = pmu_sr_intr(regs);
1566
			req = pmu_sr_intr(regs);
1413
			if (req)
1567
			if (req)
Lines 1418-1423 Link Here
1418
recheck:
1572
recheck:
1419
	if (pmu_state == idle) {
1573
	if (pmu_state == idle) {
1420
		if (adb_int_pending) {
1574
		if (adb_int_pending) {
1575
#ifdef CONFIG_XMON
1576
			if (whacky_debug)
1577
				xmon_printf("!A!");
1578
#endif /* CONFIG_XMON */
1421
			if (int_data_state[0] == int_data_empty)
1579
			if (int_data_state[0] == int_data_empty)
1422
				int_data_last = 0;
1580
				int_data_last = 0;
1423
			else if (int_data_state[1] == int_data_empty)
1581
			else if (int_data_state[1] == int_data_empty)
Lines 1432-1442 Link Here
1432
			wait_for_ack();
1590
			wait_for_ack();
1433
			send_byte(PMU_INT_ACK);
1591
			send_byte(PMU_INT_ACK);
1434
			adb_int_pending = 0;
1592
			adb_int_pending = 0;
1435
no_free_slot:
1436
			;	
1437
		} else if (current_req)
1593
		} else if (current_req)
1438
			pmu_start();
1594
			pmu_start();
1439
	}
1595
	}
1596
no_free_slot:			
1440
	/* Mark the oldest buffer for flushing */
1597
	/* Mark the oldest buffer for flushing */
1441
	if (int_data_state[!int_data_last] == int_data_ready) {
1598
	if (int_data_state[!int_data_last] == int_data_ready) {
1442
		int_data_state[!int_data_last] = int_data_flush;
1599
		int_data_state[!int_data_last] = int_data_flush;
Lines 1465-1481 Link Here
1465
	}
1622
	}
1466
}
1623
}
1467
1624
1625
void __pmac
1626
pmu_unlock(void)
1627
{
1628
	unsigned long flags;
1629
1630
	spin_lock_irqsave(&pmu_lock, flags);
1631
	if (pmu_state == locked)
1632
		pmu_state = idle;
1633
	adb_int_pending = 1;
1634
	spin_unlock_irqrestore(&pmu_lock, flags);
1635
}
1636
1637
1468
static void __openfirmware
1638
static void __openfirmware
1469
gpio1_interrupt(int irq, void *arg, struct pt_regs *regs)
1639
gpio1_interrupt(int irq, void *arg, struct pt_regs *regs)
1470
{
1640
{
1641
	unsigned long flags;
1642
1471
	if ((in_8(gpio_reg + 0x9) & 0x02) == 0) {
1643
	if ((in_8(gpio_reg + 0x9) & 0x02) == 0) {
1644
		spin_lock_irqsave(&pmu_lock, flags);
1645
		if (gpio_irq_enabled > 0) {
1646
			disable_irq_nosync(gpio_irq);
1647
			gpio_irq_enabled = 0;
1648
		}
1649
		pmu_irq_stats[1]++;
1472
		adb_int_pending = 1;
1650
		adb_int_pending = 1;
1651
		spin_unlock_irqrestore(&pmu_lock, flags);
1473
		via_pmu_interrupt(0, 0, 0);
1652
		via_pmu_interrupt(0, 0, 0);
1474
	}
1653
	}
1475
}
1654
}
1476
1655
1477
#ifdef CONFIG_PMAC_BACKLIGHT
1656
#ifdef CONFIG_PMAC_BACKLIGHT
1478
static int backlight_to_bright[] = {
1657
static int backlight_to_bright[] __pmacdata = {
1479
	0x7f, 0x46, 0x42, 0x3e, 0x3a, 0x36, 0x32, 0x2e,
1658
	0x7f, 0x46, 0x42, 0x3e, 0x3a, 0x36, 0x32, 0x2e,
1480
	0x2a, 0x26, 0x22, 0x1e, 0x1a, 0x16, 0x12, 0x0e
1659
	0x2a, 0x26, 0x22, 0x1e, 0x1a, 0x16, 0x12, 0x0e
1481
};
1660
};
Lines 1491-1503 Link Here
1491
	if (on) {
1670
	if (on) {
1492
		pmu_request(&req, NULL, 2, PMU_BACKLIGHT_BRIGHT,
1671
		pmu_request(&req, NULL, 2, PMU_BACKLIGHT_BRIGHT,
1493
			    backlight_to_bright[level]);
1672
			    backlight_to_bright[level]);
1494
		while (!req.complete)
1673
		pmu_wait_complete(&req);
1495
			pmu_poll();
1496
	}
1674
	}
1497
	pmu_request(&req, NULL, 2, PMU_POWER_CTRL,
1675
	pmu_request(&req, NULL, 2, PMU_POWER_CTRL,
1498
		    PMU_POW_BACKLIGHT | (on ? PMU_POW_ON : PMU_POW_OFF));
1676
		    PMU_POW_BACKLIGHT | (on ? PMU_POW_ON : PMU_POW_OFF));
1499
	while (!req.complete)
1677
       	pmu_wait_complete(&req);
1500
		pmu_poll();
1501
1678
1502
	return 0;
1679
	return 0;
1503
}
1680
}
Lines 1521-1527 Link Here
1521
}
1698
}
1522
#endif /* CONFIG_PMAC_BACKLIGHT */
1699
#endif /* CONFIG_PMAC_BACKLIGHT */
1523
1700
1524
void __openfirmware
1701
void __pmac
1525
pmu_enable_irled(int on)
1702
pmu_enable_irled(int on)
1526
{
1703
{
1527
	struct adb_request req;
1704
	struct adb_request req;
Lines 1533-1543 Link Here
1533
1710
1534
	pmu_request(&req, NULL, 2, PMU_POWER_CTRL, PMU_POW_IRLED |
1711
	pmu_request(&req, NULL, 2, PMU_POWER_CTRL, PMU_POW_IRLED |
1535
	    (on ? PMU_POW_ON : PMU_POW_OFF));
1712
	    (on ? PMU_POW_ON : PMU_POW_OFF));
1536
	while (!req.complete)
1713
	pmu_wait_complete(&req);
1537
		pmu_poll();
1538
}
1714
}
1539
1715
1540
void __openfirmware
1716
void __pmac
1541
pmu_restart(void)
1717
pmu_restart(void)
1542
{
1718
{
1543
	struct adb_request req;
1719
	struct adb_request req;
Lines 1554-1566 Link Here
1554
	}
1730
	}
1555
1731
1556
	pmu_request(&req, NULL, 1, PMU_RESET);
1732
	pmu_request(&req, NULL, 1, PMU_RESET);
1557
	while(!req.complete || (pmu_state != idle))
1733
	pmu_wait_complete(&req);
1558
		pmu_poll();
1559
	for (;;)
1734
	for (;;)
1560
		;
1735
		;
1561
}
1736
}
1562
1737
1563
void __openfirmware
1738
void __pmac
1564
pmu_shutdown(void)
1739
pmu_shutdown(void)
1565
{
1740
{
1566
	struct adb_request req;
1741
	struct adb_request req;
Lines 1572-1585 Link Here
1572
	if (pmu_kind != PMU_KEYLARGO_BASED) {
1747
	if (pmu_kind != PMU_KEYLARGO_BASED) {
1573
		pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, PMU_INT_ADB |
1748
		pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, PMU_INT_ADB |
1574
						PMU_INT_TICK );
1749
						PMU_INT_TICK );
1575
		while(!req.complete)
1750
		pmu_wait_complete(&req);
1576
			pmu_poll();
1577
	}
1751
	}
1578
1752
1579
	pmu_request(&req, NULL, 5, PMU_SHUTDOWN,
1753
	pmu_request(&req, NULL, 5, PMU_SHUTDOWN,
1580
		    'M', 'A', 'T', 'T');
1754
		    'M', 'A', 'T', 'T');
1581
	while(!req.complete || (pmu_state != idle))
1755
	pmu_wait_complete(&req);
1582
		pmu_poll();
1583
	for (;;)
1756
	for (;;)
1584
		;
1757
		;
1585
}
1758
}
Lines 2245-2250 Link Here
2245
	set_context(current->active_mm->context, current->active_mm->pgd);
2418
	set_context(current->active_mm->context, current->active_mm->pgd);
2246
2419
2247
	/* Power things up */
2420
	/* Power things up */
2421
	pmu_unlock();
2248
	pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, 0xfc);
2422
	pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, 0xfc);
2249
	while (!req.complete)
2423
	while (!req.complete)
2250
		pmu_poll();
2424
		pmu_poll();
Lines 2410-2415 Link Here
2410
	//pbook_pci_restore();
2584
	//pbook_pci_restore();
2411
2585
2412
#ifdef DEBUG_SLEEP
2586
#ifdef DEBUG_SLEEP
2587
	pmu_unlock();
2413
	pmu_blink(2);
2588
	pmu_blink(2);
2414
#endif		
2589
#endif		
2415
	/* Restore L2 cache */
2590
	/* Restore L2 cache */
Lines 2423-2428 Link Here
2423
	set_context(current->active_mm->context, current->active_mm->pgd);
2598
	set_context(current->active_mm->context, current->active_mm->pgd);
2424
2599
2425
	/* Tell PMU we are ready */
2600
	/* Tell PMU we are ready */
2601
	pmu_unlock();
2426
	pmu_request(&req, NULL, 2, PMU_SYSTEM_READY, 2);
2602
	pmu_request(&req, NULL, 2, PMU_SYSTEM_READY, 2);
2427
	while (!req.complete)
2603
	while (!req.complete)
2428
		pmu_poll();
2604
		pmu_poll();
Lines 2555-2564 Link Here
2555
	out_be32(mem_ctrl_sleep, 0x3f);
2731
	out_be32(mem_ctrl_sleep, 0x3f);
2556
	pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,0);
2732
	pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,0);
2557
	pbook_pci_restore();
2733
	pbook_pci_restore();
2558
2734
	pmu_unlock();
2559
	/* wait for the PMU interrupt sequence to complete */
2560
	while (asleep)
2561
		mb();
2562
2735
2563
	/* reenable interrupts */
2736
	/* reenable interrupts */
2564
	pmac_sleep_restore_intrs();
2737
	pmac_sleep_restore_intrs();
Lines 2921-2928 Link Here
2921
3094
2922
EXPORT_SYMBOL(pmu_request);
3095
EXPORT_SYMBOL(pmu_request);
2923
EXPORT_SYMBOL(pmu_poll);
3096
EXPORT_SYMBOL(pmu_poll);
3097
EXPORT_SYMBOL(pmu_poll_adb);
3098
EXPORT_SYMBOL(pmu_wait_complete);
2924
EXPORT_SYMBOL(pmu_suspend);
3099
EXPORT_SYMBOL(pmu_suspend);
2925
EXPORT_SYMBOL(pmu_resume);
3100
EXPORT_SYMBOL(pmu_resume);
3101
EXPORT_SYMBOL(pmu_unlock);
2926
EXPORT_SYMBOL(pmu_i2c_combined_read);
3102
EXPORT_SYMBOL(pmu_i2c_combined_read);
2927
EXPORT_SYMBOL(pmu_i2c_stdsub_write);
3103
EXPORT_SYMBOL(pmu_i2c_stdsub_write);
2928
EXPORT_SYMBOL(pmu_i2c_simple_read);
3104
EXPORT_SYMBOL(pmu_i2c_simple_read);
(-)linux-2.4.22/drivers/net/Makefile (-2 / +2 lines)
Lines 17-23 Link Here
17
17
18
export-objs     :=	8390.o arlan.o aironet4500_core.o aironet4500_card.o \
18
export-objs     :=	8390.o arlan.o aironet4500_core.o aironet4500_card.o \
19
			ppp_async.o ppp_generic.o slhc.o pppox.o auto_irq.o \
19
			ppp_async.o ppp_generic.o slhc.o pppox.o auto_irq.o \
20
			net_init.o mii.o
20
			net_init.o mii.o sungem_phy.o
21
list-multi	:=	rcpci.o
21
list-multi	:=	rcpci.o
22
rcpci-objs	:=	rcpci45.o rclanmtl.o
22
rcpci-objs	:=	rcpci45.o rclanmtl.o
23
23
Lines 67-73 Link Here
67
obj-$(CONFIG_SUNQE) += sunqe.o
67
obj-$(CONFIG_SUNQE) += sunqe.o
68
obj-$(CONFIG_SUNBMAC) += sunbmac.o
68
obj-$(CONFIG_SUNBMAC) += sunbmac.o
69
obj-$(CONFIG_MYRI_SBUS) += myri_sbus.o
69
obj-$(CONFIG_MYRI_SBUS) += myri_sbus.o
70
obj-$(CONFIG_SUNGEM) += sungem.o
70
obj-$(CONFIG_SUNGEM) += sungem.o sungem_phy.o
71
71
72
obj-$(CONFIG_MACE) += mace.o
72
obj-$(CONFIG_MACE) += mace.o
73
obj-$(CONFIG_BMAC) += bmac.o
73
obj-$(CONFIG_BMAC) += bmac.o
(-)linux-2.4.22/drivers/net/irda/irda-usb.c (+3 lines)
Lines 1386-1391 Link Here
1386
		WARNING("usb-irda: bad class_descriptor type\n");
1386
		WARNING("usb-irda: bad class_descriptor type\n");
1387
	}
1387
	}
1388
	else {
1388
	else {
1389
		le16_to_cpus (&(desc->wBaudRate));
1390
		le16_to_cpus (&(desc->bcdSpecRevision));        
1391
		
1389
#ifdef IU_DUMP_CLASS_DESC
1392
#ifdef IU_DUMP_CLASS_DESC
1390
		irda_usb_dump_class_desc(desc);
1393
		irda_usb_dump_class_desc(desc);
1391
#endif	/* IU_DUMP_CLASS_DESC */
1394
#endif	/* IU_DUMP_CLASS_DESC */
(-)linux-2.4.22/drivers/net/ne2k-pci.c (-2 lines)
Lines 69-76 Link Here
69
#if defined(__powerpc__)
69
#if defined(__powerpc__)
70
#define inl_le(addr)  le32_to_cpu(inl(addr))
70
#define inl_le(addr)  le32_to_cpu(inl(addr))
71
#define inw_le(addr)  le16_to_cpu(inw(addr))
71
#define inw_le(addr)  le16_to_cpu(inw(addr))
72
#define insl insl_ns
73
#define outsl outsl_ns
74
#endif
72
#endif
75
73
76
#define PFX DRV_NAME ": "
74
#define PFX DRV_NAME ": "
(-)linux-2.4.22/drivers/net/pcnet32.c (-1 / +2 lines)
Lines 569-575 Link Here
569
	break;
569
	break;
570
    case 0x2625:
570
    case 0x2625:
571
	chipname = "PCnet/FAST III 79C973"; /* PCI */
571
	chipname = "PCnet/FAST III 79C973"; /* PCI */
572
	fdx = 1; mii = 1;
572
	fdx = 1; mii = 1; fset = 1;
573
	break;
573
	break;
574
    case 0x2626:
574
    case 0x2626:
575
	chipname = "PCnet/Home 79C978"; /* PCI */
575
	chipname = "PCnet/Home 79C978"; /* PCI */
Lines 612-617 Link Here
612
	 
612
	 
613
    if(fset)
613
    if(fset)
614
    {
614
    {
615
	printk(KERN_INFO PFX "Activating Tx error recovery on %s\n", chipname);
615
	a->write_bcr(ioaddr, 18, (a->read_bcr(ioaddr, 18) | 0x0800));
616
	a->write_bcr(ioaddr, 18, (a->read_bcr(ioaddr, 18) | 0x0800));
616
	a->write_csr(ioaddr, 80, (a->read_csr(ioaddr, 80) & 0x0C00) | 0x0c00);
617
	a->write_csr(ioaddr, 80, (a->read_csr(ioaddr, 80) & 0x0C00) | 0x0c00);
617
	dxsuflo = 1;
618
	dxsuflo = 1;
(-)linux-2.4.22/drivers/net/sungem.c (-515 / +308 lines)
Lines 10-19 Link Here
10
 *  - Get rid of all those nasty mdelay's and replace them
10
 *  - Get rid of all those nasty mdelay's and replace them
11
 * with schedule_timeout.
11
 * with schedule_timeout.
12
 *  - Implement WOL
12
 *  - Implement WOL
13
 *  - Currently, forced Gb mode is only supported on bcm54xx
14
 *    PHY for which I use the SPD2 bit of the control register.
15
 *    On m1011 PHY, I can't force as I don't have the specs, but
16
 *    I can at least detect gigabit with autoneg.
17
 */
13
 */
18
14
19
#include <linux/config.h>
15
#include <linux/config.h>
Lines 63-74 Link Here
63
#include <asm/pmac_feature.h>
59
#include <asm/pmac_feature.h>
64
#endif
60
#endif
65
61
62
#include "sungem_phy.h"
66
#include "sungem.h"
63
#include "sungem.h"
67
64
65
/* Stripping FCS is causing problems, disabled for now */
66
#undef STRIP_FCS
67
68
#define DEFAULT_MSG	(NETIF_MSG_DRV		| \
68
#define DEFAULT_MSG	(NETIF_MSG_DRV		| \
69
			 NETIF_MSG_PROBE	| \
69
			 NETIF_MSG_PROBE	| \
70
			 NETIF_MSG_LINK)
70
			 NETIF_MSG_LINK)
71
71
72
#define ADVERTISE_MASK	(SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | \
73
			 SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full | \
74
			 SUPPORTED_1000baseT_Half | SUPPORTED_1000baseT_Full)
75
72
#define DRV_NAME	"sungem"
76
#define DRV_NAME	"sungem"
73
#define DRV_VERSION	"0.97"
77
#define DRV_VERSION	"0.97"
74
#define DRV_RELDATE	"3/20/02"
78
#define DRV_RELDATE	"3/20/02"
Lines 81-104 Link Here
81
MODULE_DESCRIPTION("Sun GEM Gbit ethernet driver");
85
MODULE_DESCRIPTION("Sun GEM Gbit ethernet driver");
82
MODULE_LICENSE("GPL");
86
MODULE_LICENSE("GPL");
83
87
84
MODULE_PARM(gem_debug, "i");
85
MODULE_PARM_DESC(gem_debug, "bitmapped message enable number");
86
MODULE_PARM(link_mode, "i");
87
MODULE_PARM_DESC(link_mode, "default link mode");
88
89
int gem_debug = -1;
90
static int link_mode;
91
92
static u16 link_modes[] __devinitdata = {
93
	BMCR_ANENABLE,			/* 0 : autoneg */
94
	0,				/* 1 : 10bt half duplex */
95
	BMCR_SPEED100,			/* 2 : 100bt half duplex */
96
	BMCR_SPD2, /* bcm54xx only */   /* 3 : 1000bt half duplex */
97
	BMCR_FULLDPLX,			/* 4 : 10bt full duplex */
98
	BMCR_SPEED100|BMCR_FULLDPLX,	/* 5 : 100bt full duplex */
99
	BMCR_SPD2|BMCR_FULLDPLX		/* 6 : 1000bt full duplex */
100
};
101
102
#define GEM_MODULE_NAME	"gem"
88
#define GEM_MODULE_NAME	"gem"
103
#define PFX GEM_MODULE_NAME ": "
89
#define PFX GEM_MODULE_NAME ": "
104
90
Lines 119-130 Link Here
119
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
105
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
120
	{ PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_UNI_N_GMACP,
106
	{ PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_UNI_N_GMACP,
121
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
107
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
108
	{ PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_UNI_N_GMAC2,
109
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
122
	{0, }
110
	{0, }
123
};
111
};
124
112
125
MODULE_DEVICE_TABLE(pci, gem_pci_tbl);
113
MODULE_DEVICE_TABLE(pci, gem_pci_tbl);
126
114
127
static u16 __phy_read(struct gem *gp, int reg, int phy_addr)
115
static u16 __phy_read(struct gem *gp, int phy_addr, int reg)
128
{
116
{
129
	u32 cmd;
117
	u32 cmd;
130
	int limit = 10000;
118
	int limit = 10000;
Lines 150-161 Link Here
150
	return cmd & MIF_FRAME_DATA;
138
	return cmd & MIF_FRAME_DATA;
151
}
139
}
152
140
141
static inline int _phy_read(struct net_device *dev, int mii_id, int reg)
142
{
143
	struct gem *gp = dev->priv;
144
	return __phy_read(gp, mii_id, reg);
145
}
146
153
static inline u16 phy_read(struct gem *gp, int reg)
147
static inline u16 phy_read(struct gem *gp, int reg)
154
{
148
{
155
	return __phy_read(gp, reg, gp->mii_phy_addr);
149
	return __phy_read(gp, gp->mii_phy_addr, reg);
156
}
150
}
157
151
158
static void __phy_write(struct gem *gp, int reg, u16 val, int phy_addr)
152
static void __phy_write(struct gem *gp, int phy_addr, int reg, u16 val)
159
{
153
{
160
	u32 cmd;
154
	u32 cmd;
161
	int limit = 10000;
155
	int limit = 10000;
Lines 177-185 Link Here
177
	}
171
	}
178
}
172
}
179
173
174
static inline void _phy_write(struct net_device *dev, int mii_id, int reg, int val)
175
{
176
	struct gem *gp = dev->priv;
177
	__phy_write(gp, mii_id, reg, val & 0xffff);
178
}
179
180
static inline void phy_write(struct gem *gp, int reg, u16 val)
180
static inline void phy_write(struct gem *gp, int reg, u16 val)
181
{
181
{
182
	__phy_write(gp, reg, val, gp->mii_phy_addr);
182
	__phy_write(gp, gp->mii_phy_addr, reg, val);
183
}
183
}
184
184
185
static void gem_handle_mif_event(struct gem *gp, u32 reg_val, u32 changed_bits)
185
static void gem_handle_mif_event(struct gem *gp, u32 reg_val, u32 changed_bits)
Lines 228-237 Link Here
228
	if (pcs_miistat & PCS_MIISTAT_LS) {
228
	if (pcs_miistat & PCS_MIISTAT_LS) {
229
		printk(KERN_INFO "%s: PCS link is now up.\n",
229
		printk(KERN_INFO "%s: PCS link is now up.\n",
230
		       dev->name);
230
		       dev->name);
231
		netif_carrier_on(gp->dev);
231
	} else {
232
	} else {
232
		printk(KERN_INFO "%s: PCS link is now down.\n",
233
		printk(KERN_INFO "%s: PCS link is now down.\n",
233
		       dev->name);
234
		       dev->name);
234
235
		netif_carrier_off(gp->dev);
235
		/* If this happens and the link timer is not running,
236
		/* If this happens and the link timer is not running,
236
		 * reset so we re-negotiate.
237
		 * reset so we re-negotiate.
237
		 */
238
		 */
Lines 359-364 Link Here
359
360
360
		rxd->status_word = cpu_to_le64(RXDCTRL_FRESH(gp));
361
		rxd->status_word = cpu_to_le64(RXDCTRL_FRESH(gp));
361
	}
362
	}
363
	mb();
362
	gp->rx_new = gp->rx_old = 0;
364
	gp->rx_new = gp->rx_old = 0;
363
365
364
	/* Now we must reprogram the rest of RX unit. */
366
	/* Now we must reprogram the rest of RX unit. */
Lines 400-405 Link Here
400
			gp->dev->name, rxmac_stat);
402
			gp->dev->name, rxmac_stat);
401
403
402
	if (rxmac_stat & MAC_RXSTAT_OFLW) {
404
	if (rxmac_stat & MAC_RXSTAT_OFLW) {
405
		u32 smac = readl(gp->regs + MAC_SMACHINE);
406
407
		printk(KERN_ERR "%s: RX MAC fifo overflow smac[%08x].\n",
408
				dev->name, smac);
403
		gp->net_stats.rx_over_errors++;
409
		gp->net_stats.rx_over_errors++;
404
		gp->net_stats.rx_fifo_errors++;
410
		gp->net_stats.rx_fifo_errors++;
405
411
Lines 667-672 Link Here
667
			count = 0;
673
			count = 0;
668
		}
674
		}
669
	}
675
	}
676
	mb();
670
	if (kick >= 0)
677
	if (kick >= 0)
671
		writel(kick, gp->regs + RXDMA_KICK);
678
		writel(kick, gp->regs + RXDMA_KICK);
672
}
679
}
Lines 893-899 Link Here
893
		/* We must give this initial chunk to the device last.
900
		/* We must give this initial chunk to the device last.
894
		 * Otherwise we could race with the device.
901
		 * Otherwise we could race with the device.
895
		 */
902
		 */
896
		first_len = skb->len - skb->data_len;
903
		first_len = skb_headlen(skb);
897
		first_mapping = pci_map_page(gp->pdev, virt_to_page(skb->data),
904
		first_mapping = pci_map_page(gp->pdev, virt_to_page(skb->data),
898
					     ((unsigned long) skb->data & ~PAGE_MASK),
905
					     ((unsigned long) skb->data & ~PAGE_MASK),
899
					     first_len, PCI_DMA_TODEVICE);
906
					     first_len, PCI_DMA_TODEVICE);
Lines 936-941 Link Here
936
	if (netif_msg_tx_queued(gp))
943
	if (netif_msg_tx_queued(gp))
937
		printk(KERN_DEBUG "%s: tx queued, slot %d, skblen %d\n",
944
		printk(KERN_DEBUG "%s: tx queued, slot %d, skblen %d\n",
938
		       dev->name, entry, skb->len);
945
		       dev->name, entry, skb->len);
946
	mb();
939
	writel(gp->tx_new, gp->regs + TXDMA_KICK);
947
	writel(gp->tx_new, gp->regs + TXDMA_KICK);
940
	spin_unlock_irq(&gp->lock);
948
	spin_unlock_irq(&gp->lock);
941
949
Lines 1003-1009 Link Here
1003
	} while (val & (GREG_SWRST_TXRST | GREG_SWRST_RXRST));
1011
	} while (val & (GREG_SWRST_TXRST | GREG_SWRST_RXRST));
1004
1012
1005
	if (limit <= 0)
1013
	if (limit <= 0)
1006
		printk(KERN_ERR "gem: SW reset is ghetto.\n");
1014
		printk(KERN_ERR "%s: SW reset is ghetto.\n", gp->dev->name);
1007
}
1015
}
1008
1016
1009
/* Must be invoked under gp->lock. */
1017
/* Must be invoked under gp->lock. */
Lines 1030-1165 Link Here
1030
1038
1031
}
1039
}
1032
1040
1033
/* Link modes of the BCM5400 PHY */
1034
static int phy_BCM5400_link_table[8][3] = {
1035
	{ 0, 0, 0 },	/* No link */
1036
	{ 0, 0, 0 },	/* 10BT Half Duplex */
1037
	{ 1, 0, 0 },	/* 10BT Full Duplex */
1038
	{ 0, 1, 0 },	/* 100BT Half Duplex */
1039
	{ 0, 1, 0 },	/* 100BT Half Duplex */
1040
	{ 1, 1, 0 },	/* 100BT Full Duplex*/
1041
	{ 1, 0, 1 },	/* 1000BT */
1042
	{ 1, 0, 1 },	/* 1000BT */
1043
};
1044
1041
1045
/* Must be invoked under gp->lock. */
1042
/* Must be invoked under gp->lock. */
1043
// XXX dbl check what that function should do when called on PCS PHY
1046
static void gem_begin_auto_negotiation(struct gem *gp, struct ethtool_cmd *ep)
1044
static void gem_begin_auto_negotiation(struct gem *gp, struct ethtool_cmd *ep)
1047
{
1045
{
1048
	u16 ctl;
1046
	u32 advertise, features;
1047
	int autoneg;
1048
	int speed;
1049
	int duplex;
1050
1051
	if (gp->phy_type != phy_mii_mdio0 &&
1052
     	    gp->phy_type != phy_mii_mdio1)
1053
     	    	goto non_mii;
1054
1055
	/* Setup advertise */
1056
	if (found_mii_phy(gp))
1057
		features = gp->phy_mii.def->features;
1058
	else
1059
		features = 0;
1060
1061
	advertise = features & ADVERTISE_MASK;
1062
	if (gp->phy_mii.advertising != 0)
1063
		advertise &= gp->phy_mii.advertising;
1064
1065
	autoneg = gp->want_autoneg;
1066
	speed = gp->phy_mii.speed;
1067
	duplex = gp->phy_mii.duplex;
1049
	
1068
	
1050
	/* Setup link parameters */
1069
	/* Setup link parameters */
1051
	if (!ep)
1070
	if (!ep)
1052
		goto start_aneg;
1071
		goto start_aneg;
1053
	if (ep->autoneg == AUTONEG_ENABLE) {
1072
	if (ep->autoneg == AUTONEG_ENABLE) {
1054
		/* TODO: parse ep->advertising */
1073
		advertise = ep->advertising;
1055
		gp->link_advertise |= (ADVERTISE_10HALF | ADVERTISE_10FULL);
1074
		autoneg = 1;
1056
		gp->link_advertise |= (ADVERTISE_100HALF | ADVERTISE_100FULL);
1057
		/* Can I advertise gigabit here ? I'd need BCM PHY docs... */
1058
		gp->link_cntl = BMCR_ANENABLE;
1059
	} else {
1075
	} else {
1060
		gp->link_cntl = 0;
1076
		autoneg = 0;
1061
		if (ep->speed == SPEED_100)
1077
		speed = ep->speed;
1062
			gp->link_cntl |= BMCR_SPEED100;
1078
		duplex = ep->duplex;
1063
		else if (ep->speed == SPEED_1000 && gp->gigabit_capable)
1064
			/* Hrm... check if this is right... */
1065
			gp->link_cntl |= BMCR_SPD2;
1066
		if (ep->duplex == DUPLEX_FULL)
1067
			gp->link_cntl |= BMCR_FULLDPLX;
1068
	}
1079
	}
1069
1080
1070
start_aneg:
1081
start_aneg:
1071
	if (!gp->hw_running)
1082
	/* Sanitize settings based on PHY capabilities */
1083
	if ((features & SUPPORTED_Autoneg) == 0)
1084
		autoneg = 0;
1085
	if (speed == SPEED_1000 &&
1086
	    !(features & (SUPPORTED_1000baseT_Half | SUPPORTED_1000baseT_Full)))
1087
		speed = SPEED_100;
1088
	if (speed == SPEED_100 &&
1089
	    !(features & (SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full)))
1090
		speed = SPEED_10;
1091
	if (duplex == DUPLEX_FULL &&
1092
	    !(features & (SUPPORTED_1000baseT_Full |
1093
	    		  SUPPORTED_100baseT_Full |
1094
	    		  SUPPORTED_10baseT_Full)))
1095
	    	duplex = DUPLEX_HALF;
1096
	if (speed == 0)
1097
		speed = SPEED_10;
1098
	
1099
	/* If HW is down, we don't try to actually setup the PHY, we
1100
	 * just store the settings
1101
	 */
1102
	if (!gp->hw_running) {
1103
		gp->phy_mii.autoneg = gp->want_autoneg = autoneg;
1104
		gp->phy_mii.speed = speed;
1105
		gp->phy_mii.duplex = duplex;
1072
		return;
1106
		return;
1107
	}
1073
1108
1074
	/* Configure PHY & start aneg */
1109
	/* Configure PHY & start aneg */
1075
	ctl = phy_read(gp, MII_BMCR);
1110
	gp->want_autoneg = autoneg;
1076
	ctl &= ~(BMCR_FULLDPLX|BMCR_SPEED100|BMCR_ANENABLE);
1111
	if (autoneg) {
1077
	ctl |= gp->link_cntl;
1112
		if (found_mii_phy(gp))
1078
	if (ctl & BMCR_ANENABLE) {
1113
			gp->phy_mii.def->ops->setup_aneg(&gp->phy_mii, advertise);
1079
		ctl |= BMCR_ANRESTART;
1080
		gp->lstate = link_aneg;
1114
		gp->lstate = link_aneg;
1081
	} else {
1115
	} else {
1116
		if (found_mii_phy(gp))
1117
			gp->phy_mii.def->ops->setup_forced(&gp->phy_mii, speed, duplex);
1082
		gp->lstate = link_force_ok;
1118
		gp->lstate = link_force_ok;
1083
	}
1119
	}
1084
	phy_write(gp, MII_BMCR, ctl);
1085
1120
1121
non_mii:
1086
	gp->timer_ticks = 0;
1122
	gp->timer_ticks = 0;
1087
	mod_timer(&gp->link_timer, jiffies + ((12 * HZ) / 10));
1123
	mod_timer(&gp->link_timer, jiffies + ((12 * HZ) / 10));
1088
}
1124
}
1089
1125
1090
/* Must be invoked under gp->lock. */
1091
static void gem_read_mii_link_mode(struct gem *gp, int *fd, int *spd, int *pause)
1092
{
1093
	u32 val;
1094
1095
	*fd = 0;
1096
	*spd = 10;
1097
	*pause = 0;
1098
	
1099
	if (gp->phy_mod == phymod_bcm5400 ||
1100
	    gp->phy_mod == phymod_bcm5401 ||
1101
	    gp->phy_mod == phymod_bcm5411) {
1102
		int link_mode;	
1103
1104
	    	val = phy_read(gp, MII_BCM5400_AUXSTATUS);
1105
		link_mode = ((val & MII_BCM5400_AUXSTATUS_LINKMODE_MASK) >>
1106
			     MII_BCM5400_AUXSTATUS_LINKMODE_SHIFT);
1107
		*fd = phy_BCM5400_link_table[link_mode][0];
1108
		*spd = phy_BCM5400_link_table[link_mode][2] ?
1109
			1000 :
1110
			(phy_BCM5400_link_table[link_mode][1] ? 100 : 10);
1111
		val = phy_read(gp, MII_LPA);
1112
		if (val & LPA_PAUSE)
1113
			*pause = 1;
1114
	} else {
1115
		val = phy_read(gp, MII_LPA);
1116
1117
		if (val & (LPA_10FULL | LPA_100FULL))
1118
			*fd = 1;
1119
		if (val & (LPA_100FULL | LPA_100HALF))
1120
			*spd = 100;
1121
1122
		if (gp->phy_mod == phymod_m1011) {
1123
			val = phy_read(gp, 0x0a);
1124
			if (val & 0xc00)
1125
				*spd = 1000;
1126
			if (val & 0x800)
1127
				*fd = 1;
1128
		}
1129
	}
1130
}
1131
1132
/* A link-up condition has occurred, initialize and enable the
1126
/* A link-up condition has occurred, initialize and enable the
1133
 * rest of the chip.
1127
 * rest of the chip.
1134
 *
1128
 *
1135
 * Must be invoked under gp->lock.
1129
 * Must be invoked under gp->lock.
1136
 */
1130
 */
1137
static void gem_set_link_modes(struct gem *gp)
1131
static int gem_set_link_modes(struct gem *gp)
1138
{
1132
{
1139
	u32 val;
1133
	u32 val;
1140
	int full_duplex, speed, pause;
1134
	int full_duplex, speed, pause;
1141
1135
1142
	full_duplex = 0;
1136
	full_duplex = 0;
1143
	speed = 10;
1137
	speed = SPEED_10;
1144
	pause = 0;
1138
	pause = 0;
1145
1139
1146
	if (gp->phy_type == phy_mii_mdio0 ||
1140
	if (found_mii_phy(gp)) {
1147
	    gp->phy_type == phy_mii_mdio1) {
1141
	    	if (gp->phy_mii.def->ops->read_link(&gp->phy_mii))
1148
		val = phy_read(gp, MII_BMCR);
1142
	    		return 1;
1149
		if (val & BMCR_ANENABLE)
1143
		full_duplex = (gp->phy_mii.duplex == DUPLEX_FULL);
1150
			gem_read_mii_link_mode(gp, &full_duplex, &speed, &pause);
1144
		speed = gp->phy_mii.speed;
1151
		else {
1145
		pause = gp->phy_mii.pause;
1152
			if (val & BMCR_FULLDPLX)
1146
	} else if (gp->phy_type == phy_serialink ||
1153
				full_duplex = 1;
1147
	    	   gp->phy_type == phy_serdes) {
1154
			if (val & BMCR_SPEED100)
1155
				speed = 100;
1156
		}
1157
	} else {
1158
		u32 pcs_lpa = readl(gp->regs + PCS_MIILP);
1148
		u32 pcs_lpa = readl(gp->regs + PCS_MIILP);
1159
1149
1160
		if (pcs_lpa & PCS_MIIADV_FD)
1150
		if (pcs_lpa & PCS_MIIADV_FD)
1161
			full_duplex = 1;
1151
			full_duplex = 1;
1162
		speed = 1000;
1152
		speed = SPEED_1000;
1163
	}
1153
	}
1164
1154
1165
	if (netif_msg_link(gp))
1155
	if (netif_msg_link(gp))
Lines 1183-1189 Link Here
1183
		val |= MAC_XIFCFG_FLED;
1173
		val |= MAC_XIFCFG_FLED;
1184
	}
1174
	}
1185
1175
1186
	if (speed == 1000)
1176
	if (speed == SPEED_1000)
1187
		val |= (MAC_XIFCFG_GMII);
1177
		val |= (MAC_XIFCFG_GMII);
1188
1178
1189
	writel(val, gp->regs + MAC_XIFCFG);
1179
	writel(val, gp->regs + MAC_XIFCFG);
Lines 1191-1197 Link Here
1191
	/* If gigabit and half-duplex, enable carrier extension
1181
	/* If gigabit and half-duplex, enable carrier extension
1192
	 * mode.  Else, disable it.
1182
	 * mode.  Else, disable it.
1193
	 */
1183
	 */
1194
	if (speed == 1000 && !full_duplex) {
1184
	if (speed == SPEED_1000 && !full_duplex) {
1195
		val = readl(gp->regs + MAC_TXCFG);
1185
		val = readl(gp->regs + MAC_TXCFG);
1196
		writel(val | MAC_TXCFG_TCE, gp->regs + MAC_TXCFG);
1186
		writel(val | MAC_TXCFG_TCE, gp->regs + MAC_TXCFG);
1197
1187
Lines 1239-1288 Link Here
1239
	writel(val, gp->regs + MAC_MCCFG);
1229
	writel(val, gp->regs + MAC_MCCFG);
1240
1230
1241
	gem_start_dma(gp);
1231
	gem_start_dma(gp);
1232
1233
	return 0;
1242
}
1234
}
1243
1235
1244
/* Must be invoked under gp->lock. */
1236
/* Must be invoked under gp->lock. */
1245
static int gem_mdio_link_not_up(struct gem *gp)
1237
static int gem_mdio_link_not_up(struct gem *gp)
1246
{
1238
{
1247
	u16 val;
1239
	switch (gp->lstate) {
1248
	
1240
	case link_force_ret:
1249
	if (gp->lstate == link_force_ret) {
1250
		if (netif_msg_link(gp))
1241
		if (netif_msg_link(gp))
1251
			printk(KERN_INFO "%s: Autoneg failed again, keeping"
1242
			printk(KERN_INFO "%s: Autoneg failed again, keeping"
1252
				" forced mode\n", gp->dev->name);
1243
				" forced mode\n", gp->dev->name);
1253
		phy_write(gp, MII_BMCR, gp->link_fcntl);
1244
		gp->phy_mii.def->ops->setup_forced(&gp->phy_mii,
1245
			gp->last_forced_speed, DUPLEX_HALF);
1254
		gp->timer_ticks = 5;
1246
		gp->timer_ticks = 5;
1255
		gp->lstate = link_force_ok;
1247
		gp->lstate = link_force_ok;
1256
	} else if (gp->lstate == link_aneg) {
1248
		return 0;
1257
		val = phy_read(gp, MII_BMCR);
1249
	case link_aneg:
1258
1259
		if (netif_msg_link(gp))
1250
		if (netif_msg_link(gp))
1260
			printk(KERN_INFO "%s: switching to forced 100bt\n",
1251
			printk(KERN_INFO "%s: switching to forced 100bt\n",
1261
				gp->dev->name);
1252
				gp->dev->name);
1262
		/* Try forced modes. */
1253
		/* Try forced modes. */
1263
		val &= ~(BMCR_ANRESTART | BMCR_ANENABLE);
1254
		gp->phy_mii.def->ops->setup_forced(&gp->phy_mii, SPEED_100,
1264
		val &= ~(BMCR_FULLDPLX);
1255
			DUPLEX_HALF);
1265
		val |= BMCR_SPEED100;
1266
		phy_write(gp, MII_BMCR, val);
1267
		gp->timer_ticks = 5;
1256
		gp->timer_ticks = 5;
1268
		gp->lstate = link_force_try;
1257
		gp->lstate = link_force_try;
1269
	} else {
1258
		return 0;
1259
	case link_force_try:
1270
		/* Downgrade from 100 to 10 Mbps if necessary.
1260
		/* Downgrade from 100 to 10 Mbps if necessary.
1271
		 * If already at 10Mbps, warn user about the
1261
		 * If already at 10Mbps, warn user about the
1272
		 * situation every 10 ticks.
1262
		 * situation every 10 ticks.
1273
		 */
1263
		 */
1274
		val = phy_read(gp, MII_BMCR);
1264
		if (gp->phy_mii.speed == SPEED_100) {
1275
		if (val & BMCR_SPEED100) {
1265
			gp->phy_mii.def->ops->setup_forced(&gp->phy_mii, SPEED_10,
1276
			val &= ~BMCR_SPEED100;
1266
				DUPLEX_HALF);
1277
			phy_write(gp, MII_BMCR, val);
1278
			gp->timer_ticks = 5;
1267
			gp->timer_ticks = 5;
1279
			if (netif_msg_link(gp))
1268
			if (netif_msg_link(gp))
1280
				printk(KERN_INFO "%s: switching to forced 10bt\n",
1269
				printk(KERN_INFO "%s: switching to forced 10bt\n",
1281
					gp->dev->name);
1270
					gp->dev->name);
1271
			return 0;
1282
		} else
1272
		} else
1283
			return 1;
1273
			return 1;
1274
	default:
1275
		return 0;
1284
	}
1276
	}
1285
	return 0;
1286
}
1277
}
1287
1278
1288
static void gem_init_rings(struct gem *);
1279
static void gem_init_rings(struct gem *);
Lines 1322-1328 Link Here
1322
static void gem_link_timer(unsigned long data)
1313
static void gem_link_timer(unsigned long data)
1323
{
1314
{
1324
	struct gem *gp = (struct gem *) data;
1315
	struct gem *gp = (struct gem *) data;
1325
1316
	int restart_aneg = 0;
1317
		
1326
	if (!gp->hw_running)
1318
	if (!gp->hw_running)
1327
		return;
1319
		return;
1328
1320
Lines 1334-1395 Link Here
1334
	if (gp->reset_task_pending)
1326
	if (gp->reset_task_pending)
1335
		goto restart;
1327
		goto restart;
1336
	    	
1328
	    	
1337
	if (gp->phy_type == phy_mii_mdio0 ||
1329
	if (gp->phy_type == phy_serialink ||
1338
	    gp->phy_type == phy_mii_mdio1) {
1330
	    gp->phy_type == phy_serdes) {
1339
		u16 val = phy_read(gp, MII_BMSR);
1340
		u16 cntl = phy_read(gp, MII_BMCR);
1341
		int up;
1342
1343
		/* When using autoneg, we really wait for ANEGCOMPLETE or we may
1344
		 * get a "transcient" incorrect link state
1345
		 */
1346
		if (cntl & BMCR_ANENABLE)
1347
			up = (val & (BMSR_ANEGCOMPLETE | BMSR_LSTATUS)) == (BMSR_ANEGCOMPLETE | BMSR_LSTATUS);
1348
		else
1349
			up = (val & BMSR_LSTATUS) != 0;
1350
		if (up) {
1351
			/* Ok, here we got a link. If we had it due to a forced
1352
			 * fallback, and we were configured for autoneg, we do
1353
			 * retry a short autoneg pass. If you know your hub is
1354
			 * broken, use ethtool ;)
1355
			 */
1356
			if (gp->lstate == link_force_try && (gp->link_cntl & BMCR_ANENABLE)) {
1357
				gp->lstate = link_force_ret;
1358
				gp->link_fcntl = phy_read(gp, MII_BMCR);
1359
				gp->timer_ticks = 5;
1360
				if (netif_msg_link(gp))
1361
					printk(KERN_INFO "%s: Got link after fallback, retrying"
1362
						" autoneg once...\n", gp->dev->name);
1363
				phy_write(gp, MII_BMCR,
1364
					  gp->link_fcntl | BMCR_ANENABLE | BMCR_ANRESTART);
1365
			} else if (gp->lstate != link_up) {
1366
				gp->lstate = link_up;
1367
				if (gp->opened)
1368
					gem_set_link_modes(gp);
1369
			}
1370
		} else {
1371
			int restart = 0;
1372
1373
			/* If the link was previously up, we restart the
1374
			 * whole process
1375
			 */
1376
			if (gp->lstate == link_up) {
1377
				gp->lstate = link_down;
1378
				if (netif_msg_link(gp))
1379
					printk(KERN_INFO "%s: Link down\n",
1380
						gp->dev->name);
1381
				gp->reset_task_pending = 2;
1382
				schedule_task(&gp->reset_task);
1383
				restart = 1;
1384
			} else if (++gp->timer_ticks > 10)
1385
				restart = gem_mdio_link_not_up(gp);
1386
1387
			if (restart) {
1388
				gem_begin_auto_negotiation(gp, NULL);
1389
				goto out_unlock;
1390
			}
1391
		}
1392
	} else {
1393
		u32 val = readl(gp->regs + PCS_MIISTAT);
1331
		u32 val = readl(gp->regs + PCS_MIISTAT);
1394
1332
1395
		if (!(val & PCS_MIISTAT_LS))
1333
		if (!(val & PCS_MIISTAT_LS))
Lines 1397-1407 Link Here
1397
1335
1398
		if ((val & PCS_MIISTAT_LS) != 0) {
1336
		if ((val & PCS_MIISTAT_LS) != 0) {
1399
			gp->lstate = link_up;
1337
			gp->lstate = link_up;
1338
			netif_carrier_on(gp->dev);
1400
			if (gp->opened)
1339
			if (gp->opened)
1401
				gem_set_link_modes(gp);
1340
				(void)gem_set_link_modes(gp);
1402
		}
1341
		}
1342
		goto restart;
1343
	}
1344
	if (found_mii_phy(gp) && gp->phy_mii.def->ops->poll_link(&gp->phy_mii)) {
1345
		/* Ok, here we got a link. If we had it due to a forced
1346
		 * fallback, and we were configured for autoneg, we do
1347
		 * retry a short autoneg pass. If you know your hub is
1348
		 * broken, use ethtool ;)
1349
		 */
1350
		if (gp->lstate == link_force_try && gp->want_autoneg) {
1351
			gp->lstate = link_force_ret;
1352
			gp->last_forced_speed = gp->phy_mii.speed;
1353
			gp->timer_ticks = 5;
1354
			if (netif_msg_link(gp))
1355
				printk(KERN_INFO "%s: Got link after fallback, retrying"
1356
					" autoneg once...\n", gp->dev->name);
1357
			gp->phy_mii.def->ops->setup_aneg(&gp->phy_mii, gp->phy_mii.advertising);
1358
		} else if (gp->lstate != link_up) {
1359
			gp->lstate = link_up;
1360
			netif_carrier_on(gp->dev);
1361
			if (gp->opened && gem_set_link_modes(gp))
1362
				restart_aneg = 1;
1363
		}
1364
	} else {
1365
		/* If the link was previously up, we restart the
1366
		 * whole process
1367
		 */
1368
		if (gp->lstate == link_up) {
1369
			gp->lstate = link_down;
1370
			if (netif_msg_link(gp))
1371
				printk(KERN_INFO "%s: Link down\n",
1372
					gp->dev->name);
1373
			netif_carrier_off(gp->dev);
1374
			gp->reset_task_pending = 2;
1375
			schedule_task(&gp->reset_task);
1376
			restart_aneg = 1;
1377
		} else if (++gp->timer_ticks > 10) {
1378
			if (found_mii_phy(gp))
1379
				restart_aneg = gem_mdio_link_not_up(gp);
1380
			else
1381
				restart_aneg = 1;
1382
		}
1383
	}
1384
	if (restart_aneg) {
1385
		gem_begin_auto_negotiation(gp, NULL);
1386
		goto out_unlock;
1403
	}
1387
	}
1404
1405
restart:
1388
restart:
1406
	mod_timer(&gp->link_timer, jiffies + ((12 * HZ) / 10));
1389
	mod_timer(&gp->link_timer, jiffies + ((12 * HZ) / 10));
1407
out_unlock:
1390
out_unlock:
Lines 1501-1653 Link Here
1501
		txd->control_word = 0;
1484
		txd->control_word = 0;
1502
		txd->buffer = 0;
1485
		txd->buffer = 0;
1503
	}
1486
	}
1504
}
1487
	mb();
1505
1506
/* Must be invoked under gp->lock. */
1507
static int gem_reset_one_mii_phy(struct gem *gp, int phy_addr)
1508
{
1509
	u16 val;
1510
	int limit = 10000;
1511
	
1512
	val = __phy_read(gp, MII_BMCR, phy_addr);
1513
	val &= ~BMCR_ISOLATE;
1514
	val |= BMCR_RESET;
1515
	__phy_write(gp, MII_BMCR, val, phy_addr);
1516
1517
	udelay(100);
1518
1519
	while (limit--) {
1520
		val = __phy_read(gp, MII_BMCR, phy_addr);
1521
		if ((val & BMCR_RESET) == 0)
1522
			break;
1523
		udelay(10);
1524
	}
1525
	if ((val & BMCR_ISOLATE) && limit > 0)
1526
		__phy_write(gp, MII_BMCR, val & ~BMCR_ISOLATE, phy_addr);
1527
	
1528
	return (limit <= 0);
1529
}
1530
1531
/* Must be invoked under gp->lock. */
1532
static void gem_init_bcm5201_phy(struct gem *gp)
1533
{
1534
	u16 data;
1535
1536
	data = phy_read(gp, MII_BCM5201_MULTIPHY);
1537
	data &= ~MII_BCM5201_MULTIPHY_SUPERISOLATE;
1538
	phy_write(gp, MII_BCM5201_MULTIPHY, data);
1539
}
1540
1541
/* Must be invoked under gp->lock. */
1542
static void gem_init_bcm5400_phy(struct gem *gp)
1543
{
1544
	u16 data;
1545
1546
	/* Configure for gigabit full duplex */
1547
	data = phy_read(gp, MII_BCM5400_AUXCONTROL);
1548
	data |= MII_BCM5400_AUXCONTROL_PWR10BASET;
1549
	phy_write(gp, MII_BCM5400_AUXCONTROL, data);
1550
	
1551
	data = phy_read(gp, MII_BCM5400_GB_CONTROL);
1552
	data |= MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP;
1553
	phy_write(gp, MII_BCM5400_GB_CONTROL, data);
1554
	
1555
	mdelay(10);
1556
1557
	/* Reset and configure cascaded 10/100 PHY */
1558
	gem_reset_one_mii_phy(gp, 0x1f);
1559
	
1560
	data = __phy_read(gp, MII_BCM5201_MULTIPHY, 0x1f);
1561
	data |= MII_BCM5201_MULTIPHY_SERIALMODE;
1562
	__phy_write(gp, MII_BCM5201_MULTIPHY, data, 0x1f);
1563
1564
	data = phy_read(gp, MII_BCM5400_AUXCONTROL);
1565
	data &= ~MII_BCM5400_AUXCONTROL_PWR10BASET;
1566
	phy_write(gp, MII_BCM5400_AUXCONTROL, data);
1567
}
1568
1569
/* Must be invoked under gp->lock. */
1570
static void gem_init_bcm5401_phy(struct gem *gp)
1571
{
1572
	u16 data;
1573
	int rev;
1574
1575
	rev = phy_read(gp, MII_PHYSID2) & 0x000f;
1576
	if (rev == 0 || rev == 3) {
1577
		/* Some revisions of 5401 appear to need this
1578
		 * initialisation sequence to disable, according
1579
		 * to OF, "tap power management"
1580
		 * 
1581
		 * WARNING ! OF and Darwin don't agree on the
1582
		 * register addresses. OF seem to interpret the
1583
		 * register numbers below as decimal
1584
		 *
1585
		 * Note: This should (and does) match tg3_init_5401phy_dsp
1586
		 *       in the tg3.c driver. -DaveM
1587
		 */
1588
		phy_write(gp, 0x18, 0x0c20);
1589
		phy_write(gp, 0x17, 0x0012);
1590
		phy_write(gp, 0x15, 0x1804);
1591
		phy_write(gp, 0x17, 0x0013);
1592
		phy_write(gp, 0x15, 0x1204);
1593
		phy_write(gp, 0x17, 0x8006);
1594
		phy_write(gp, 0x15, 0x0132);
1595
		phy_write(gp, 0x17, 0x8006);
1596
		phy_write(gp, 0x15, 0x0232);
1597
		phy_write(gp, 0x17, 0x201f);
1598
		phy_write(gp, 0x15, 0x0a20);
1599
	}
1600
	
1601
	/* Configure for gigabit full duplex */
1602
	data = phy_read(gp, MII_BCM5400_GB_CONTROL);
1603
	data |= MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP;
1604
	phy_write(gp, MII_BCM5400_GB_CONTROL, data);
1605
1606
	mdelay(1);
1607
1608
	/* Reset and configure cascaded 10/100 PHY */
1609
	gem_reset_one_mii_phy(gp, 0x1f);
1610
	
1611
	data = __phy_read(gp, MII_BCM5201_MULTIPHY, 0x1f);
1612
	data |= MII_BCM5201_MULTIPHY_SERIALMODE;
1613
	__phy_write(gp, MII_BCM5201_MULTIPHY, data, 0x1f);
1614
}
1615
1616
/* Must be invoked under gp->lock. */
1617
static void gem_init_bcm5411_phy(struct gem *gp)
1618
{
1619
	u16 data;
1620
1621
	/* Here's some more Apple black magic to setup
1622
	 * some voltage stuffs.
1623
	 */
1624
	phy_write(gp, 0x1c, 0x8c23);
1625
	phy_write(gp, 0x1c, 0x8ca3);
1626
	phy_write(gp, 0x1c, 0x8c23);
1627
1628
	/* Here, Apple seems to want to reset it, do
1629
	 * it as well
1630
	 */
1631
	phy_write(gp, MII_BMCR, BMCR_RESET);
1632
1633
	/* Start autoneg */
1634
	phy_write(gp, MII_BMCR,
1635
		  (BMCR_ANENABLE | BMCR_FULLDPLX |
1636
		   BMCR_ANRESTART | BMCR_SPD2));
1637
1638
	data = phy_read(gp, MII_BCM5400_GB_CONTROL);
1639
	data |= MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP;
1640
	phy_write(gp, MII_BCM5400_GB_CONTROL, data);
1641
}
1488
}
1642
1489
1643
/* Must be invoked under gp->lock. */
1490
/* Must be invoked under gp->lock. */
1644
static void gem_init_phy(struct gem *gp)
1491
static void gem_init_phy(struct gem *gp)
1645
{
1492
{
1646
	u32 mifcfg;
1493
	u32 mifcfg;
1647
1494
	
1648
	if (!gp->wake_on_lan && gp->phy_mod == phymod_bcm5201)
1649
		phy_write(gp, MII_BCM5201_INTERRUPT, 0);
1650
1651
	/* Revert MIF CFG setting done on stop_phy */
1495
	/* Revert MIF CFG setting done on stop_phy */
1652
	mifcfg = readl(gp->regs + MIF_CFG);
1496
	mifcfg = readl(gp->regs + MIF_CFG);
1653
	mifcfg &= ~MIF_CFG_BBMODE;
1497
	mifcfg &= ~MIF_CFG_BBMODE;
Lines 1655-1673 Link Here
1655
	
1499
	
1656
#ifdef CONFIG_ALL_PPC
1500
#ifdef CONFIG_ALL_PPC
1657
	if (gp->pdev->vendor == PCI_VENDOR_ID_APPLE) {
1501
	if (gp->pdev->vendor == PCI_VENDOR_ID_APPLE) {
1658
		int i;
1502
		int i, j;
1659
1503
1504
		/* Those delay sucks, the HW seem to love them though, I'll
1505
		 * serisouly consider breaking some locks here to be able
1506
		 * to schedule instead
1507
		 */
1660
		pmac_call_feature(PMAC_FTR_GMAC_PHY_RESET, gp->of_node, 0, 0);
1508
		pmac_call_feature(PMAC_FTR_GMAC_PHY_RESET, gp->of_node, 0, 0);
1661
		for (i = 0; i < 32; i++) {
1509
		mdelay(10);
1662
			gp->mii_phy_addr = i;
1510
		for (j = 0; j < 3; j++) {
1663
			if (phy_read(gp, MII_BMCR) != 0xffff)
1511
			/* Some PHYs used by apple have problem getting back to us,
1512
			 * we _know_ it's actually at addr 0, that's a hack, but
1513
			 * it helps to do that reset now. I suspect some motherboards
1514
			 * don't wire the PHY reset line properly, thus the PHY doesn't
1515
			 * come back with the above pmac_call_feature.
1516
			 */
1517
			gp->mii_phy_addr = 0;
1518
			phy_write(gp, MII_BMCR, BMCR_RESET);
1519
			/* We should probably break some locks here and schedule... */
1520
			mdelay(10);
1521
			for (i = 0; i < 32; i++) {
1522
				gp->mii_phy_addr = i;
1523
				if (phy_read(gp, MII_BMCR) != 0xffff)
1524
					break;
1525
			}
1526
			if (i == 32) {
1527
				printk(KERN_WARNING "%s: GMAC PHY not responding !\n",
1528
				       gp->dev->name);
1529
				gp->mii_phy_addr = 0;
1530
			} else
1664
				break;
1531
				break;
1665
		}
1532
		}
1666
		if (i == 32) {
1667
			printk(KERN_WARNING "%s: GMAC PHY not responding !\n",
1668
			       gp->dev->name);
1669
			return;
1670
		}
1671
	}
1533
	}
1672
#endif /* CONFIG_ALL_PPC */
1534
#endif /* CONFIG_ALL_PPC */
1673
1535
Lines 1690-1768 Link Here
1690
1552
1691
	if (gp->phy_type == phy_mii_mdio0 ||
1553
	if (gp->phy_type == phy_mii_mdio0 ||
1692
	    gp->phy_type == phy_mii_mdio1) {
1554
	    gp->phy_type == phy_mii_mdio1) {
1693
		u32 phy_id;
1555
	    	// XXX check for errors
1694
		u16 val;
1556
		mii_phy_probe(&gp->phy_mii, gp->mii_phy_addr);
1695
	
1696
		/* Take PHY out of isloate mode and reset it. */
1697
		gem_reset_one_mii_phy(gp, gp->mii_phy_addr);
1698
1699
		phy_id = (phy_read(gp, MII_PHYSID1) << 16 | phy_read(gp, MII_PHYSID2))
1700
			 	& 0xfffffff0;
1701
		printk(KERN_INFO "%s: MII PHY ID: %x ", gp->dev->name, phy_id);
1702
		switch(phy_id) {
1703
		case 0x406210:
1704
			gp->phy_mod = phymod_bcm5201;
1705
			gem_init_bcm5201_phy(gp);
1706
			printk("BCM 5201\n");
1707
			break;
1708
1709
		case 0x4061e0:
1710
			printk("BCM 5221\n");
1711
			gp->phy_mod = phymod_bcm5221;
1712
			break;
1713
1714
		case 0x206040:
1715
			printk("BCM 5400\n");
1716
			gp->phy_mod = phymod_bcm5400;
1717
			gem_init_bcm5400_phy(gp);
1718
			gp->gigabit_capable = 1;
1719
			break;
1720
1721
		case 0x206050:
1722
			printk("BCM 5401\n");
1723
			gp->phy_mod = phymod_bcm5401;
1724
			gem_init_bcm5401_phy(gp);
1725
			gp->gigabit_capable = 1;
1726
			break;
1727
1728
		case 0x206070:
1729
			printk("BCM 5411\n");
1730
			gp->phy_mod = phymod_bcm5411;
1731
			gem_init_bcm5411_phy(gp);
1732
			gp->gigabit_capable = 1;
1733
			break;
1734
		case 0x1410c60:
1735
			printk("M1011 (Marvel ?)\n");
1736
			gp->phy_mod = phymod_m1011;
1737
			gp->gigabit_capable = 1;
1738
			break;
1739
1740
		case 0x18074c0:
1741
			printk("Lucent\n");
1742
			gp->phy_mod = phymod_generic;
1743
			break;
1744
1745
		case 0x437420:
1746
			printk("Enable Semiconductor\n");
1747
			gp->phy_mod = phymod_generic;
1748
			break;
1749
1750
		default:
1751
			printk("Unknown (Using generic mode)\n");
1752
			gp->phy_mod = phymod_generic;
1753
			break;
1754
		};
1755
1557
1756
		/* Init advertisement and enable autonegotiation. */
1558
		/* Init PHY */
1757
		val = phy_read(gp, MII_BMCR);
1559
		if (gp->phy_mii.def && gp->phy_mii.def->ops->init)
1758
		val &= ~BMCR_ANENABLE;
1560
			gp->phy_mii.def->ops->init(&gp->phy_mii);
1759
		phy_write(gp, MII_BMCR, val);
1760
		udelay(10);
1761
		
1762
		phy_write(gp, MII_ADVERTISE,
1763
			  phy_read(gp, MII_ADVERTISE) |
1764
			  (ADVERTISE_10HALF | ADVERTISE_10FULL |
1765
			   ADVERTISE_100HALF | ADVERTISE_100FULL));
1766
	} else {
1561
	} else {
1767
		u32 val;
1562
		u32 val;
1768
		int limit;
1563
		int limit;
Lines 1819-1831 Link Here
1819
		else
1614
		else
1820
			val |= PCS_SCTRL_LOOP;
1615
			val |= PCS_SCTRL_LOOP;
1821
		writel(val, gp->regs + PCS_SCTRL);
1616
		writel(val, gp->regs + PCS_SCTRL);
1822
		gp->gigabit_capable = 1;
1823
	}
1617
	}
1824
1825
	/* BMCR_SPD2 is a broadcom 54xx specific thing afaik */
1826
	if (gp->phy_mod != phymod_bcm5400 && gp->phy_mod != phymod_bcm5401 &&
1827
	    gp->phy_mod != phymod_bcm5411)
1828
	    	gp->link_cntl &= ~BMCR_SPD2;
1829
}
1618
}
1830
1619
1831
/* Must be invoked under gp->lock. */
1620
/* Must be invoked under gp->lock. */
Lines 1914-1922 Link Here
1914
{
1703
{
1915
	unsigned char *e = &gp->dev->dev_addr[0];
1704
	unsigned char *e = &gp->dev->dev_addr[0];
1916
1705
1917
	if (gp->pdev->vendor == PCI_VENDOR_ID_SUN &&
1706
	writel(0x1bf0, gp->regs + MAC_SNDPAUSE);
1918
	    gp->pdev->device == PCI_DEVICE_ID_SUN_GEM)
1919
		writel(0x1bf0, gp->regs + MAC_SNDPAUSE);
1920
1707
1921
	writel(0x00, gp->regs + MAC_IPG0);
1708
	writel(0x00, gp->regs + MAC_IPG0);
1922
	writel(0x08, gp->regs + MAC_IPG1);
1709
	writel(0x08, gp->regs + MAC_IPG1);
Lines 1953-1959 Link Here
1953
	writel(0, gp->regs + MAC_AF0MSK);
1740
	writel(0, gp->regs + MAC_AF0MSK);
1954
1741
1955
	gp->mac_rx_cfg = gem_setup_multicast(gp);
1742
	gp->mac_rx_cfg = gem_setup_multicast(gp);
1956
1743
#ifdef STRIP_FCS
1744
	gp->mac_rx_cfg |= MAC_RXCFG_SFCS;
1745
#endif
1957
	writel(0, gp->regs + MAC_NCOLL);
1746
	writel(0, gp->regs + MAC_NCOLL);
1958
	writel(0, gp->regs + MAC_FASUCC);
1747
	writel(0, gp->regs + MAC_FASUCC);
1959
	writel(0, gp->regs + MAC_ECOLL);
1748
	writel(0, gp->regs + MAC_ECOLL);
Lines 2129-2140 Link Here
2129
		/* Default aneg parameters */
1918
		/* Default aneg parameters */
2130
		gp->timer_ticks = 0;
1919
		gp->timer_ticks = 0;
2131
		gp->lstate = link_down;
1920
		gp->lstate = link_down;
1921
		netif_carrier_off(gp->dev);
2132
1922
2133
		/* Can I advertise gigabit here ? I'd need BCM PHY docs... */
1923
		/* Can I advertise gigabit here ? I'd need BCM PHY docs... */
2134
		gem_begin_auto_negotiation(gp, NULL);
1924
		gem_begin_auto_negotiation(gp, NULL);
2135
	} else {
1925
	} else {
2136
		if (gp->lstate == link_up)
1926
		if (gp->lstate == link_up) {
1927
			netif_carrier_on(gp->dev);
2137
			gem_set_link_modes(gp);
1928
			gem_set_link_modes(gp);
1929
		}
2138
	}
1930
	}
2139
}
1931
}
2140
1932
Lines 2184-2192 Link Here
2184
{
1976
{
2185
	u32 mifcfg;
1977
	u32 mifcfg;
2186
1978
2187
	if (!gp->wake_on_lan && gp->phy_mod == phymod_bcm5201)
2188
		phy_write(gp, MII_BCM5201_INTERRUPT, 0);
2189
2190
	/* Make sure we aren't polling PHY status change. We
1979
	/* Make sure we aren't polling PHY status change. We
2191
	 * don't currently use that feature though
1980
	 * don't currently use that feature though
2192
	 */
1981
	 */
Lines 2194-2202 Link Here
2194
	mifcfg &= ~MIF_CFG_POLL;
1983
	mifcfg &= ~MIF_CFG_POLL;
2195
	writel(mifcfg, gp->regs + MIF_CFG);
1984
	writel(mifcfg, gp->regs + MIF_CFG);
2196
1985
2197
	/* Here's a strange hack used by both MacOS 9 and X */
2198
	phy_write(gp, MII_LPA, phy_read(gp, MII_LPA));
2199
2200
	if (gp->wake_on_lan) {
1986
	if (gp->wake_on_lan) {
2201
		/* Setup wake-on-lan */
1987
		/* Setup wake-on-lan */
2202
	} else
1988
	} else
Lines 2210-2230 Link Here
2210
		gem_stop(gp);
1996
		gem_stop(gp);
2211
		writel(MAC_TXRST_CMD, gp->regs + MAC_TXRST);
1997
		writel(MAC_TXRST_CMD, gp->regs + MAC_TXRST);
2212
		writel(MAC_RXRST_CMD, gp->regs + MAC_RXRST);
1998
		writel(MAC_RXRST_CMD, gp->regs + MAC_RXRST);
2213
		if (gp->phy_mod == phymod_bcm5400 || gp->phy_mod == phymod_bcm5401 ||
1999
	}
2214
		    gp->phy_mod == phymod_bcm5411) {
2215
#if 0 /* Commented out in Darwin... someone has those dawn docs ? */
2216
			phy_write(gp, MII_BMCR, BMCR_PDOWN);
2217
#endif
2218
		} else if (gp->phy_mod == phymod_bcm5201 || gp->phy_mod == phymod_bcm5221) {
2219
#if 0 /* Commented out in Darwin... someone has those dawn docs ? */
2220
			u16 val = phy_read(gp, MII_BCM5201_AUXMODE2)
2221
			phy_write(gp, MII_BCM5201_AUXMODE2,
2222
				  val & ~MII_BCM5201_AUXMODE2_LOWPOWER);
2223
#endif				
2224
			phy_write(gp, MII_BCM5201_MULTIPHY, MII_BCM5201_MULTIPHY_SUPERISOLATE);
2225
		} else if (gp->phy_mod == phymod_m1011)
2226
			phy_write(gp, MII_BMCR, BMCR_PDOWN);
2227
2000
2001
	if (found_mii_phy(gp) && gp->phy_mii.def->ops->suspend)
2002
		gp->phy_mii.def->ops->suspend(&gp->phy_mii, 0 /* wake on lan options */);
2003
2004
	if (!gp->wake_on_lan) {
2228
		/* According to Apple, we must set the MDIO pins to this begnign
2005
		/* According to Apple, we must set the MDIO pins to this begnign
2229
		 * state or we may 1) eat more current, 2) damage some PHYs
2006
		 * state or we may 1) eat more current, 2) damage some PHYs
2230
		 */
2007
		 */
Lines 2330-2344 Link Here
2330
		gp->hw_running = 1;
2107
		gp->hw_running = 1;
2331
	}
2108
	}
2332
2109
2333
	spin_lock_irq(&gp->lock);
2334
2335
	/* We can now request the interrupt as we know it's masked
2110
	/* We can now request the interrupt as we know it's masked
2336
	 * on the controller
2111
	 * on the controller
2337
	 */
2112
	 */
2338
	if (request_irq(gp->pdev->irq, gem_interrupt,
2113
	if (request_irq(gp->pdev->irq, gem_interrupt,
2339
			SA_SHIRQ, dev->name, (void *)dev)) {
2114
			SA_SHIRQ, dev->name, (void *)dev)) {
2340
		spin_unlock_irq(&gp->lock);
2341
2342
		printk(KERN_ERR "%s: failed to request irq !\n", gp->dev->name);
2115
		printk(KERN_ERR "%s: failed to request irq !\n", gp->dev->name);
2343
2116
2344
#ifdef CONFIG_ALL_PPC
2117
#ifdef CONFIG_ALL_PPC
Lines 2349-2358 Link Here
2349
		gp->pm_timer.expires = jiffies + 10*HZ;
2122
		gp->pm_timer.expires = jiffies + 10*HZ;
2350
		add_timer(&gp->pm_timer);
2123
		add_timer(&gp->pm_timer);
2351
		up(&gp->pm_sem);
2124
		up(&gp->pm_sem);
2125
		spin_unlock_irq(&gp->lock);
2352
2126
2353
		return -EAGAIN;
2127
		return -EAGAIN;
2354
	}
2128
	}
2355
2129
2130
       	spin_lock_irq(&gp->lock);
2131
2356
	/* Allocate & setup ring buffers */
2132
	/* Allocate & setup ring buffers */
2357
	gem_init_rings(gp);
2133
	gem_init_rings(gp);
2358
2134
Lines 2526-2532 Link Here
2526
	netif_stop_queue(dev);
2302
	netif_stop_queue(dev);
2527
2303
2528
	rxcfg = readl(gp->regs + MAC_RXCFG);
2304
	rxcfg = readl(gp->regs + MAC_RXCFG);
2529
	gp->mac_rx_cfg = rxcfg_new = gem_setup_multicast(gp);
2305
	rxcfg_new = gem_setup_multicast(gp);
2306
#ifdef STRIP_FCS
2307
	rxcfg_new |= MAC_RXCFG_SFCS;
2308
#endif
2309
	gp->mac_rx_cfg = rxcfg_new;
2530
	
2310
	
2531
	writel(rxcfg & ~MAC_RXCFG_ENAB, gp->regs + MAC_RXCFG);
2311
	writel(rxcfg & ~MAC_RXCFG_ENAB, gp->regs + MAC_RXCFG);
2532
	while (readl(gp->regs + MAC_RXCFG) & MAC_RXCFG_ENAB) {
2312
	while (readl(gp->regs + MAC_RXCFG) & MAC_RXCFG_ENAB) {
Lines 2551-2558 Link Here
2551
static int gem_ethtool_ioctl(struct net_device *dev, void *ep_user)
2331
static int gem_ethtool_ioctl(struct net_device *dev, void *ep_user)
2552
{
2332
{
2553
	struct gem *gp = dev->priv;
2333
	struct gem *gp = dev->priv;
2554
	u16 bmcr;
2555
	int full_duplex, speed, pause;
2556
	struct ethtool_cmd ecmd;
2334
	struct ethtool_cmd ecmd;
2557
2335
2558
	if (copy_from_user(&ecmd, ep_user, sizeof(ecmd)))
2336
	if (copy_from_user(&ecmd, ep_user, sizeof(ecmd)))
Lines 2560-2566 Link Here
2560
		
2338
		
2561
	switch(ecmd.cmd) {
2339
	switch(ecmd.cmd) {
2562
        case ETHTOOL_GDRVINFO: {
2340
        case ETHTOOL_GDRVINFO: {
2563
		struct ethtool_drvinfo info = { cmd: ETHTOOL_GDRVINFO };
2341
		struct ethtool_drvinfo info = { .cmd = ETHTOOL_GDRVINFO };
2564
2342
2565
		strncpy(info.driver, DRV_NAME, ETHTOOL_BUSINFO_LEN);
2343
		strncpy(info.driver, DRV_NAME, ETHTOOL_BUSINFO_LEN);
2566
		strncpy(info.version, DRV_VERSION, ETHTOOL_BUSINFO_LEN);
2344
		strncpy(info.version, DRV_VERSION, ETHTOOL_BUSINFO_LEN);
Lines 2575-2615 Link Here
2575
	}
2353
	}
2576
2354
2577
	case ETHTOOL_GSET:
2355
	case ETHTOOL_GSET:
2578
		ecmd.supported =
2356
		if (gp->phy_type == phy_mii_mdio0 ||
2357
	     	    gp->phy_type == phy_mii_mdio1) {
2358
	     	    	if (gp->phy_mii.def)
2359
	     	    		ecmd.supported = gp->phy_mii.def->features;
2360
	     	    	else
2361
	     	    		ecmd.supported = SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full;
2362
2363
			/* XXX hardcoded stuff for now */
2364
			ecmd.port = PORT_MII;
2365
			ecmd.transceiver = XCVR_EXTERNAL;
2366
			ecmd.phy_address = 0; /* XXX fixed PHYAD */
2367
2368
			/* Return current PHY settings */
2369
			spin_lock_irq(&gp->lock);
2370
			ecmd.autoneg = gp->want_autoneg;
2371
			ecmd.speed = gp->phy_mii.speed;
2372
			ecmd.duplex = gp->phy_mii.duplex;			
2373
			ecmd.advertising = gp->phy_mii.advertising;
2374
			/* If we started with a forced mode, we don't have a default
2375
			 * advertise set, we need to return something sensible so
2376
			 * userland can re-enable autoneg properly */
2377
			if (ecmd.advertising == 0)
2378
				ecmd.advertising = ecmd.supported;
2379
			spin_unlock_irq(&gp->lock);
2380
		} else { // XXX PCS ?
2381
	     	    ecmd.supported =
2579
			(SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
2382
			(SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
2580
			 SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
2383
			 SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
2581
			 SUPPORTED_Autoneg | SUPPORTED_TP | SUPPORTED_MII);
2384
			 SUPPORTED_Autoneg);
2582
2385
		    ecmd.advertising = ecmd.supported;
2583
		if (gp->gigabit_capable)
2584
			ecmd.supported |=
2585
				(SUPPORTED_1000baseT_Half |
2586
				 SUPPORTED_1000baseT_Full);
2587
2588
		/* XXX hardcoded stuff for now */
2589
		ecmd.port = PORT_MII;
2590
		ecmd.transceiver = XCVR_EXTERNAL;
2591
		ecmd.phy_address = 0; /* XXX fixed PHYAD */
2592
2593
		/* Record PHY settings if HW is on. */
2594
		spin_lock_irq(&gp->lock);
2595
		if (gp->hw_running) {
2596
			bmcr = phy_read(gp, MII_BMCR);
2597
			gem_read_mii_link_mode(gp, &full_duplex, &speed, &pause);
2598
		} else
2599
			bmcr = 0;
2600
		spin_unlock_irq(&gp->lock);
2601
		if (bmcr & BMCR_ANENABLE) {
2602
			ecmd.autoneg = AUTONEG_ENABLE;
2603
			ecmd.speed = speed == 10 ? SPEED_10 : (speed == 1000 ? SPEED_1000 : SPEED_100);
2604
			ecmd.duplex = full_duplex ? DUPLEX_FULL : DUPLEX_HALF;
2605
		} else {
2606
			ecmd.autoneg = AUTONEG_DISABLE;
2607
			ecmd.speed =
2608
				(bmcr & BMCR_SPEED100) ?
2609
				SPEED_100 : SPEED_10;
2610
			ecmd.duplex =
2611
				(bmcr & BMCR_FULLDPLX) ?
2612
				DUPLEX_FULL : DUPLEX_HALF;
2613
		}
2386
		}
2614
		if (copy_to_user(ep_user, &ecmd, sizeof(ecmd)))
2387
		if (copy_to_user(ep_user, &ecmd, sizeof(ecmd)))
2615
			return -EFAULT;
2388
			return -EFAULT;
Lines 2621-2633 Link Here
2621
		    ecmd.autoneg != AUTONEG_DISABLE)
2394
		    ecmd.autoneg != AUTONEG_DISABLE)
2622
			return -EINVAL;
2395
			return -EINVAL;
2623
2396
2397
		if (ecmd.autoneg == AUTONEG_ENABLE &&
2398
		    ecmd.advertising == 0)
2399
		    	return -EINVAL;
2400
2624
		if (ecmd.autoneg == AUTONEG_DISABLE &&
2401
		if (ecmd.autoneg == AUTONEG_DISABLE &&
2625
		    ((ecmd.speed != SPEED_100 &&
2402
		    ((ecmd.speed != SPEED_1000 &&
2403
		      ecmd.speed != SPEED_100 &&
2626
		      ecmd.speed != SPEED_10) ||
2404
		      ecmd.speed != SPEED_10) ||
2627
		     (ecmd.duplex != DUPLEX_HALF &&
2405
		     (ecmd.duplex != DUPLEX_HALF &&
2628
		      ecmd.duplex != DUPLEX_FULL)))
2406
		      ecmd.duplex != DUPLEX_FULL)))
2629
			return -EINVAL;
2407
			return -EINVAL;
2630
2408
	      
2631
		/* Apply settings and restart link process. */
2409
		/* Apply settings and restart link process. */
2632
		spin_lock_irq(&gp->lock);
2410
		spin_lock_irq(&gp->lock);
2633
		gem_begin_auto_negotiation(gp, &ecmd);
2411
		gem_begin_auto_negotiation(gp, &ecmd);
Lines 2636-2642 Link Here
2636
		return 0;
2414
		return 0;
2637
2415
2638
	case ETHTOOL_NWAY_RST:
2416
	case ETHTOOL_NWAY_RST:
2639
		if ((gp->link_cntl & BMCR_ANENABLE) == 0)
2417
		if (!gp->want_autoneg)
2640
			return -EINVAL;
2418
			return -EINVAL;
2641
2419
2642
		/* Restart link process. */
2420
		/* Restart link process. */
Lines 2652-2658 Link Here
2652
2430
2653
	/* get link status */
2431
	/* get link status */
2654
	case ETHTOOL_GLINK: {
2432
	case ETHTOOL_GLINK: {
2655
		struct ethtool_value edata = { cmd: ETHTOOL_GLINK };
2433
		struct ethtool_value edata = { .cmd = ETHTOOL_GLINK };
2656
2434
2657
		edata.data = (gp->lstate == link_up);
2435
		edata.data = (gp->lstate == link_up);
2658
		if (copy_to_user(ep_user, &edata, sizeof(edata)))
2436
		if (copy_to_user(ep_user, &edata, sizeof(edata)))
Lines 2662-2668 Link Here
2662
2440
2663
	/* get message-level */
2441
	/* get message-level */
2664
	case ETHTOOL_GMSGLVL: {
2442
	case ETHTOOL_GMSGLVL: {
2665
		struct ethtool_value edata = { cmd: ETHTOOL_GMSGLVL };
2443
		struct ethtool_value edata = { .cmd = ETHTOOL_GMSGLVL };
2666
2444
2667
		edata.data = gp->msg_enable;
2445
		edata.data = gp->msg_enable;
2668
		if (copy_to_user(ep_user, &edata, sizeof(edata)))
2446
		if (copy_to_user(ep_user, &edata, sizeof(edata)))
Lines 2740-2754 Link Here
2740
		/* Fallthrough... */
2518
		/* Fallthrough... */
2741
2519
2742
	case SIOCGMIIREG:		/* Read MII PHY register. */
2520
	case SIOCGMIIREG:		/* Read MII PHY register. */
2743
		data->val_out = __phy_read(gp, data->reg_num & 0x1f, data->phy_id & 0x1f);
2521
		if (!gp->hw_running)
2744
		rc = 0;
2522
			rc = -EIO;
2523
		else {
2524
			data->val_out = __phy_read(gp, data->phy_id & 0x1f, data->reg_num & 0x1f);
2525
			rc = 0;
2526
		}
2745
		break;
2527
		break;
2746
2528
2747
	case SIOCSMIIREG:		/* Write MII PHY register. */
2529
	case SIOCSMIIREG:		/* Write MII PHY register. */
2748
		if (!capable(CAP_NET_ADMIN)) {
2530
		if (!capable(CAP_NET_ADMIN))
2749
			rc = -EPERM;
2531
			rc = -EPERM;
2750
		} else {
2532
		else if (!gp->hw_running)
2751
			__phy_write(gp, data->reg_num & 0x1f, data->val_in, data->phy_id & 0x1f);
2533
			rc = -EIO;
2534
		else {
2535
			__phy_write(gp, data->phy_id & 0x1f, data->reg_num & 0x1f, data->val_in);
2752
			rc = 0;
2536
			rc = 0;
2753
		}
2537
		}
2754
		break;
2538
		break;
Lines 2894-2900 Link Here
2894
	 */
2678
	 */
2895
	if (pdev->vendor == PCI_VENDOR_ID_SUN &&
2679
	if (pdev->vendor == PCI_VENDOR_ID_SUN &&
2896
	    pdev->device == PCI_DEVICE_ID_SUN_GEM &&
2680
	    pdev->device == PCI_DEVICE_ID_SUN_GEM &&
2897
	    !pci_set_dma_mask(pdev, (u64) 0xffffffffffffffff)) {
2681
	    !pci_set_dma_mask(pdev, (u64) 0xffffffffffffffffULL)) {
2898
		pci_using_dac = 1;
2682
		pci_using_dac = 1;
2899
	} else {
2683
	} else {
2900
		err = pci_set_dma_mask(pdev, (u64) 0xffffffff);
2684
		err = pci_set_dma_mask(pdev, (u64) 0xffffffff);
Lines 2934-2940 Link Here
2934
	dev->base_addr = (long) pdev;
2718
	dev->base_addr = (long) pdev;
2935
	gp->dev = dev;
2719
	gp->dev = dev;
2936
2720
2937
	gp->msg_enable = (gem_debug < 0 ? DEFAULT_MSG : gem_debug);
2721
	gp->msg_enable = DEFAULT_MSG;
2938
2722
2939
	spin_lock_init(&gp->lock);
2723
	spin_lock_init(&gp->lock);
2940
	init_MUTEX(&gp->pm_sem);
2724
	init_MUTEX(&gp->pm_sem);
Lines 2950-2962 Link Here
2950
	INIT_TQUEUE(&gp->pm_task, gem_pm_task, gp);
2734
	INIT_TQUEUE(&gp->pm_task, gem_pm_task, gp);
2951
	INIT_TQUEUE(&gp->reset_task, gem_reset_task, gp);
2735
	INIT_TQUEUE(&gp->reset_task, gem_reset_task, gp);
2952
	
2736
	
2953
	/* Default link parameters */
2954
	if (link_mode >= 0 && link_mode <= 6)
2955
		gp->link_cntl = link_modes[link_mode];
2956
	else
2957
		gp->link_cntl = BMCR_ANENABLE;
2958
	gp->lstate = link_down;
2737
	gp->lstate = link_down;
2959
	gp->timer_ticks = 0;
2738
	gp->timer_ticks = 0;
2739
	netif_carrier_off(dev);
2960
2740
2961
	gp->regs = (unsigned long) ioremap(gemreg_base, gemreg_len);
2741
	gp->regs = (unsigned long) ioremap(gemreg_base, gemreg_len);
2962
	if (gp->regs == 0UL) {
2742
	if (gp->regs == 0UL) {
Lines 2977-2992 Link Here
2977
	gem_stop(gp);
2757
	gem_stop(gp);
2978
	spin_unlock_irq(&gp->lock);
2758
	spin_unlock_irq(&gp->lock);
2979
2759
2760
	/* Fill up the mii_phy structure (even if we won't use it) */
2761
	gp->phy_mii.dev = dev;
2762
	gp->phy_mii.mdio_read = _phy_read;
2763
	gp->phy_mii.mdio_write = _phy_write;
2764
2765
	/* By default, we start with autoneg */
2766
	gp->want_autoneg = 1;
2767
	
2980
	if (gem_check_invariants(gp))
2768
	if (gem_check_invariants(gp))
2981
		goto err_out_iounmap;
2769
		goto err_out_iounmap;
2982
2770
2983
	spin_lock_irq(&gp->lock);
2771
	/* It is guaranteed that the returned buffer will be at least
2984
	gp->hw_running = 1;
2985
	gem_init_phy(gp);
2986
	gem_begin_auto_negotiation(gp, NULL);
2987
	spin_unlock_irq(&gp->lock);
2988
2989
	/* It is guarenteed that the returned buffer will be at least
2990
	 * PAGE_SIZE aligned.
2772
	 * PAGE_SIZE aligned.
2991
	 */
2773
	 */
2992
	gp->init_block = (struct gem_init_block *)
2774
	gp->init_block = (struct gem_init_block *)
Lines 3012-3023 Link Here
3012
2794
3013
	printk(KERN_INFO "%s: Sun GEM (PCI) 10/100/1000BaseT Ethernet ",
2795
	printk(KERN_INFO "%s: Sun GEM (PCI) 10/100/1000BaseT Ethernet ",
3014
	       dev->name);
2796
	       dev->name);
3015
3016
	for (i = 0; i < 6; i++)
2797
	for (i = 0; i < 6; i++)
3017
		printk("%2.2x%c", dev->dev_addr[i],
2798
		printk("%2.2x%c", dev->dev_addr[i],
3018
		       i == 5 ? ' ' : ':');
2799
		       i == 5 ? ' ' : ':');
3019
	printk("\n");
2800
	printk("\n");
3020
2801
2802
	/* Detect & init PHY, start autoneg */
2803
	spin_lock_irq(&gp->lock);
2804
	gp->hw_running = 1;
2805
	gem_init_phy(gp);
2806
	gem_begin_auto_negotiation(gp, NULL);
2807
	spin_unlock_irq(&gp->lock);
2808
2809
	if (gp->phy_type == phy_mii_mdio0 ||
2810
     	    gp->phy_type == phy_mii_mdio1)
2811
		printk(KERN_INFO "%s: Found %s PHY\n", dev->name, 
2812
			gp->phy_mii.def ? gp->phy_mii.def->name : "no");
2813
3021
	pci_set_drvdata(pdev, dev);
2814
	pci_set_drvdata(pdev, dev);
3022
2815
3023
	dev->open = gem_open;
2816
	dev->open = gem_open;
(-)linux-2.4.22/drivers/net/sungem.h (-30 / +22 lines)
Lines 805-818 Link Here
805
	u64	buffer;
805
	u64	buffer;
806
};
806
};
807
807
808
#define TXDCTRL_BUFSZ	0x0000000000007fff	/* Buffer Size		*/
808
#define TXDCTRL_BUFSZ	0x0000000000007fffULL	/* Buffer Size		*/
809
#define TXDCTRL_CSTART	0x00000000001f8000	/* CSUM Start Offset	*/
809
#define TXDCTRL_CSTART	0x00000000001f8000ULL	/* CSUM Start Offset	*/
810
#define TXDCTRL_COFF	0x000000001fe00000	/* CSUM Stuff Offset	*/
810
#define TXDCTRL_COFF	0x000000001fe00000ULL	/* CSUM Stuff Offset	*/
811
#define TXDCTRL_CENAB	0x0000000020000000	/* CSUM Enable		*/
811
#define TXDCTRL_CENAB	0x0000000020000000ULL	/* CSUM Enable		*/
812
#define TXDCTRL_EOF	0x0000000040000000	/* End of Frame		*/
812
#define TXDCTRL_EOF	0x0000000040000000ULL	/* End of Frame		*/
813
#define TXDCTRL_SOF	0x0000000080000000	/* Start of Frame	*/
813
#define TXDCTRL_SOF	0x0000000080000000ULL	/* Start of Frame	*/
814
#define TXDCTRL_INTME	0x0000000100000000	/* "Interrupt Me"	*/
814
#define TXDCTRL_INTME	0x0000000100000000ULL	/* "Interrupt Me"	*/
815
#define TXDCTRL_NOCRC	0x0000000200000000	/* No CRC Present	*/
815
#define TXDCTRL_NOCRC	0x0000000200000000ULL	/* No CRC Present	*/
816
816
817
/* GEM requires that RX descriptors are provided four at a time,
817
/* GEM requires that RX descriptors are provided four at a time,
818
 * aligned.  Also, the RX ring may not wrap around.  This means that
818
 * aligned.  Also, the RX ring may not wrap around.  This means that
Lines 840-852 Link Here
840
	u64	buffer;
840
	u64	buffer;
841
};
841
};
842
842
843
#define RXDCTRL_TCPCSUM	0x000000000000ffff	/* TCP Pseudo-CSUM	*/
843
#define RXDCTRL_TCPCSUM	0x000000000000ffffULL	/* TCP Pseudo-CSUM	*/
844
#define RXDCTRL_BUFSZ	0x000000007fff0000	/* Buffer Size		*/
844
#define RXDCTRL_BUFSZ	0x000000007fff0000ULL	/* Buffer Size		*/
845
#define RXDCTRL_OWN	0x0000000080000000	/* GEM owns this entry	*/
845
#define RXDCTRL_OWN	0x0000000080000000ULL	/* GEM owns this entry	*/
846
#define RXDCTRL_HASHVAL	0x0ffff00000000000	/* Hash Value		*/
846
#define RXDCTRL_HASHVAL	0x0ffff00000000000ULL	/* Hash Value		*/
847
#define RXDCTRL_HPASS	0x1000000000000000	/* Passed Hash Filter	*/
847
#define RXDCTRL_HPASS	0x1000000000000000ULL	/* Passed Hash Filter	*/
848
#define RXDCTRL_ALTMAC	0x2000000000000000	/* Matched ALT MAC	*/
848
#define RXDCTRL_ALTMAC	0x2000000000000000ULL	/* Matched ALT MAC	*/
849
#define RXDCTRL_BAD	0x4000000000000000	/* Frame has bad CRC	*/
849
#define RXDCTRL_BAD	0x4000000000000000ULL	/* Frame has bad CRC	*/
850
850
851
#define RXDCTRL_FRESH(gp)	\
851
#define RXDCTRL_FRESH(gp)	\
852
	((((RX_BUF_ALLOC_SIZE(gp) - RX_OFFSET) << 16) & RXDCTRL_BUFSZ) | \
852
	((((RX_BUF_ALLOC_SIZE(gp) - RX_OFFSET) << 16) & RXDCTRL_BUFSZ) | \
Lines 936-951 Link Here
936
	phy_serdes,
936
	phy_serdes,
937
};
937
};
938
938
939
enum gem_phy_model {
940
	phymod_generic,
941
	phymod_bcm5201,
942
	phymod_bcm5221,
943
	phymod_bcm5400,
944
	phymod_bcm5401,
945
	phymod_bcm5411,
946
	phymod_m1011,
947
};
948
949
enum link_state {
939
enum link_state {
950
	link_down = 0,	/* No link, will retry */
940
	link_down = 0,	/* No link, will retry */
951
	link_aneg,	/* Autoneg in progress */
941
	link_aneg,	/* Autoneg in progress */
Lines 980-1000 Link Here
980
	struct net_device_stats net_stats;
970
	struct net_device_stats net_stats;
981
971
982
	enum gem_phy_type	phy_type;
972
	enum gem_phy_type	phy_type;
983
	enum gem_phy_model	phy_mod;
973
	struct mii_phy		phy_mii;
974
	
984
	int			tx_fifo_sz;
975
	int			tx_fifo_sz;
985
	int			rx_fifo_sz;
976
	int			rx_fifo_sz;
986
	int			rx_pause_off;
977
	int			rx_pause_off;
987
	int			rx_pause_on;
978
	int			rx_pause_on;
988
	int			mii_phy_addr;
979
	int			mii_phy_addr;
989
	int			gigabit_capable;
990
980
991
	u32			mac_rx_cfg;
981
	u32			mac_rx_cfg;
992
	u32			swrst_base;
982
	u32			swrst_base;
993
983
994
	/* Autoneg & PHY control */
984
	/* Autoneg & PHY control */
995
	int			link_cntl;
985
	int			want_autoneg;
996
	int			link_advertise;
986
	int			last_forced_speed;
997
	int			link_fcntl;
998
	enum link_state		lstate;
987
	enum link_state		lstate;
999
	struct timer_list	link_timer;
988
	struct timer_list	link_timer;
1000
	int			timer_ticks;
989
	int			timer_ticks;
Lines 1014-1019 Link Here
1014
#endif
1003
#endif
1015
};
1004
};
1016
1005
1006
#define found_mii_phy(gp) ((gp->phy_type == phy_mii_mdio0 || gp->phy_type == phy_mii_mdio1) \
1007
				&& gp->phy_mii.def && gp->phy_mii.def->ops)
1008
			
1017
#define ALIGNED_RX_SKB_ADDR(addr) \
1009
#define ALIGNED_RX_SKB_ADDR(addr) \
1018
        ((((unsigned long)(addr) + (64UL - 1UL)) & ~(64UL - 1UL)) - (unsigned long)(addr))
1010
        ((((unsigned long)(addr) + (64UL - 1UL)) & ~(64UL - 1UL)) - (unsigned long)(addr))
1019
static __inline__ struct sk_buff *gem_alloc_skb(int size, int gfp_flags)
1011
static __inline__ struct sk_buff *gem_alloc_skb(int size, int gfp_flags)
(-)linux-2.4.22/drivers/net/sungem_phy.c (+838 lines)
Line 0 Link Here
1
/*
2
 * PHY drivers for the sungem ethernet driver.
3
 * 
4
 * This file could be shared with other drivers.
5
 * 
6
 * (c) 2002, Benjamin Herrenscmidt (benh@kernel.crashing.org)
7
 *
8
 * TODO:
9
 *  - Implement WOL
10
 *  - Add support for PHYs that provide an IRQ line
11
 *  - Eventually moved the entire polling state machine in
12
 *    there (out of the eth driver), so that it can easily be
13
 *    skipped on PHYs that implement it in hardware.
14
 *  - On LXT971 & BCM5201, Apple uses some chip specific regs
15
 *    to read the link status. Figure out why and if it makes
16
 *    sense to do the same (magic aneg ?)
17
 *  - Apple has some additional power management code for some
18
 *    Broadcom PHYs that they "hide" from the OpenSource version
19
 *    of darwin, still need to reverse engineer that
20
 */
21
22
#include <linux/config.h>
23
24
#include <linux/module.h>
25
26
#include <linux/kernel.h>
27
#include <linux/sched.h>
28
#include <linux/types.h>
29
#include <linux/netdevice.h>
30
#include <linux/etherdevice.h>
31
#include <linux/mii.h>
32
#include <linux/ethtool.h>
33
#include <linux/delay.h>
34
35
#include "sungem_phy.h"
36
37
/* Link modes of the BCM5400 PHY */
38
static int phy_BCM5400_link_table[8][3] = {
39
	{ 0, 0, 0 },	/* No link */
40
	{ 0, 0, 0 },	/* 10BT Half Duplex */
41
	{ 1, 0, 0 },	/* 10BT Full Duplex */
42
	{ 0, 1, 0 },	/* 100BT Half Duplex */
43
	{ 0, 1, 0 },	/* 100BT Half Duplex */
44
	{ 1, 1, 0 },	/* 100BT Full Duplex*/
45
	{ 1, 0, 1 },	/* 1000BT */
46
	{ 1, 0, 1 },	/* 1000BT */
47
};
48
49
static inline int __phy_read(struct mii_phy* phy, int id, int reg)
50
{
51
	return phy->mdio_read(phy->dev, id, reg);
52
}
53
54
static inline void __phy_write(struct mii_phy* phy, int id, int reg, int val)
55
{
56
	phy->mdio_write(phy->dev, id, reg, val);
57
}
58
59
static inline int phy_read(struct mii_phy* phy, int reg)
60
{
61
	return phy->mdio_read(phy->dev, phy->mii_id, reg);
62
}
63
64
static inline void phy_write(struct mii_phy* phy, int reg, int val)
65
{
66
	phy->mdio_write(phy->dev, phy->mii_id, reg, val);
67
}
68
69
static int reset_one_mii_phy(struct mii_phy* phy, int phy_id)
70
{
71
	u16 val;
72
	int limit = 10000;
73
	
74
	val = __phy_read(phy, phy_id, MII_BMCR);
75
	val &= ~BMCR_ISOLATE;
76
	val |= BMCR_RESET;
77
	__phy_write(phy, phy_id, MII_BMCR, val);
78
79
	udelay(100);
80
81
	while (limit--) {
82
		val = __phy_read(phy, phy_id, MII_BMCR);
83
		if ((val & BMCR_RESET) == 0)
84
			break;
85
		udelay(10);
86
	}
87
	if ((val & BMCR_ISOLATE) && limit > 0)
88
		__phy_write(phy, phy_id, MII_BMCR, val & ~BMCR_ISOLATE);
89
	
90
	return (limit <= 0);
91
}
92
93
static int bcm5201_init(struct mii_phy* phy)
94
{
95
	u16 data;
96
97
	data = phy_read(phy, MII_BCM5201_MULTIPHY);
98
	data &= ~MII_BCM5201_MULTIPHY_SUPERISOLATE;
99
	phy_write(phy, MII_BCM5201_MULTIPHY, data);
100
101
	return 0;
102
}
103
104
static int bcm5201_suspend(struct mii_phy* phy, int wol_options)
105
{
106
	if (!wol_options)
107
		phy_write(phy, MII_BCM5201_INTERRUPT, 0);
108
109
	/* Here's a strange hack used by both MacOS 9 and X */
110
	phy_write(phy, MII_LPA, phy_read(phy, MII_LPA));
111
	
112
	if (!wol_options) {
113
#if 0 /* Commented out in Darwin... someone has those dawn docs ? */
114
		u16 val = phy_read(phy, MII_BCM5201_AUXMODE2)
115
		phy_write(phy, MII_BCM5201_AUXMODE2,
116
			  val & ~MII_BCM5201_AUXMODE2_LOWPOWER);
117
#endif			
118
		phy_write(phy, MII_BCM5201_MULTIPHY, MII_BCM5201_MULTIPHY_SUPERISOLATE);
119
	}
120
121
	return 0;
122
}
123
124
static int bcm5221_init(struct mii_phy* phy)
125
{
126
	u16 data;
127
128
	data = phy_read(phy, MII_BCM5221_TEST);
129
	phy_write(phy, MII_BCM5221_TEST,
130
		data | MII_BCM5221_TEST_ENABLE_SHADOWS);
131
132
	data = phy_read(phy, MII_BCM5221_SHDOW_AUX_STAT2);
133
	phy_write(phy, MII_BCM5221_SHDOW_AUX_STAT2,
134
		data | MII_BCM5221_SHDOW_AUX_STAT2_APD);
135
136
	data = phy_read(phy, MII_BCM5221_SHDOW_AUX_MODE4);
137
	phy_write(phy, MII_BCM5221_SHDOW_AUX_MODE4,
138
		data | MII_BCM5221_SHDOW_AUX_MODE4_CLKLOPWR);
139
140
	data = phy_read(phy, MII_BCM5221_TEST);
141
	phy_write(phy, MII_BCM5221_TEST,
142
		data & ~MII_BCM5221_TEST_ENABLE_SHADOWS);
143
144
	return 0;
145
}
146
147
static int bcm5400_init(struct mii_phy* phy)
148
{
149
	u16 data;
150
151
	/* Configure for gigabit full duplex */
152
	data = phy_read(phy, MII_BCM5400_AUXCONTROL);
153
	data |= MII_BCM5400_AUXCONTROL_PWR10BASET;
154
	phy_write(phy, MII_BCM5400_AUXCONTROL, data);
155
	
156
	data = phy_read(phy, MII_BCM5400_GB_CONTROL);
157
	data |= MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP;
158
	phy_write(phy, MII_BCM5400_GB_CONTROL, data);
159
	
160
	mdelay(10);
161
162
	/* Reset and configure cascaded 10/100 PHY */
163
	(void)reset_one_mii_phy(phy, 0x1f);
164
	
165
	data = __phy_read(phy, 0x1f, MII_BCM5201_MULTIPHY);
166
	data |= MII_BCM5201_MULTIPHY_SERIALMODE;
167
	__phy_write(phy, 0x1f, MII_BCM5201_MULTIPHY, data);
168
169
	data = phy_read(phy, MII_BCM5400_AUXCONTROL);
170
	data &= ~MII_BCM5400_AUXCONTROL_PWR10BASET;
171
	phy_write(phy, MII_BCM5400_AUXCONTROL, data);
172
173
	return 0;
174
}
175
176
static int bcm5400_suspend(struct mii_phy* phy, int wol_options)
177
{
178
#if 0 /* Commented out in Darwin... someone has those dawn docs ? */
179
	phy_write(phy, MII_BMCR, BMCR_PDOWN);
180
#endif
181
	return 0;
182
}
183
184
static int bcm5401_init(struct mii_phy* phy)
185
{
186
	u16 data;
187
	int rev;
188
189
	rev = phy_read(phy, MII_PHYSID2) & 0x000f;
190
	if (rev == 0 || rev == 3) {
191
		/* Some revisions of 5401 appear to need this
192
		 * initialisation sequence to disable, according
193
		 * to OF, "tap power management"
194
		 * 
195
		 * WARNING ! OF and Darwin don't agree on the
196
		 * register addresses. OF seem to interpret the
197
		 * register numbers below as decimal
198
		 *
199
		 * Note: This should (and does) match tg3_init_5401phy_dsp
200
		 *       in the tg3.c driver. -DaveM
201
		 */
202
		phy_write(phy, 0x18, 0x0c20);
203
		phy_write(phy, 0x17, 0x0012);
204
		phy_write(phy, 0x15, 0x1804);
205
		phy_write(phy, 0x17, 0x0013);
206
		phy_write(phy, 0x15, 0x1204);
207
		phy_write(phy, 0x17, 0x8006);
208
		phy_write(phy, 0x15, 0x0132);
209
		phy_write(phy, 0x17, 0x8006);
210
		phy_write(phy, 0x15, 0x0232);
211
		phy_write(phy, 0x17, 0x201f);
212
		phy_write(phy, 0x15, 0x0a20);
213
	}
214
	
215
	/* Configure for gigabit full duplex */
216
	data = phy_read(phy, MII_BCM5400_GB_CONTROL);
217
	data |= MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP;
218
	phy_write(phy, MII_BCM5400_GB_CONTROL, data);
219
220
	mdelay(10);
221
222
	/* Reset and configure cascaded 10/100 PHY */
223
	(void)reset_one_mii_phy(phy, 0x1f);
224
	
225
	data = __phy_read(phy, 0x1f, MII_BCM5201_MULTIPHY);
226
	data |= MII_BCM5201_MULTIPHY_SERIALMODE;
227
	__phy_write(phy, 0x1f, MII_BCM5201_MULTIPHY, data);
228
229
	return 0;
230
}
231
232
static int bcm5401_suspend(struct mii_phy* phy, int wol_options)
233
{
234
#if 0 /* Commented out in Darwin... someone has those dawn docs ? */
235
	phy_write(phy, MII_BMCR, BMCR_PDOWN);
236
#endif
237
	return 0;
238
}
239
240
static int bcm5411_init(struct mii_phy* phy)
241
{
242
	u16 data;
243
244
	/* Here's some more Apple black magic to setup
245
	 * some voltage stuffs.
246
	 */
247
	phy_write(phy, 0x1c, 0x8c23);
248
	phy_write(phy, 0x1c, 0x8ca3);
249
	phy_write(phy, 0x1c, 0x8c23);
250
251
	/* Here, Apple seems to want to reset it, do
252
	 * it as well
253
	 */
254
	phy_write(phy, MII_BMCR, BMCR_RESET);
255
	phy_write(phy, MII_BMCR, 0x1340);
256
257
	data = phy_read(phy, MII_BCM5400_GB_CONTROL);
258
	data |= MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP;
259
	phy_write(phy, MII_BCM5400_GB_CONTROL, data);
260
261
	mdelay(10);
262
263
	/* Reset and configure cascaded 10/100 PHY */
264
	(void)reset_one_mii_phy(phy, 0x1f);
265
	
266
	return 0;
267
}
268
269
static int bcm5411_suspend(struct mii_phy* phy, int wol_options)
270
{
271
	phy_write(phy, MII_BMCR, BMCR_PDOWN);
272
273
	return 0;
274
}
275
276
static int bcm5421_init(struct mii_phy* phy)
277
{
278
	u16 data;
279
	int rev;
280
281
	rev = phy_read(phy, MII_PHYSID2) & 0x000f;
282
	if (rev == 0) {
283
		/* This is borrowed from MacOS
284
		 */
285
		phy_write(phy, 0x18, 0x1007);
286
		data = phy_read(phy, 0x18);
287
		phy_write(phy, 0x18, data | 0x0400);
288
		phy_write(phy, 0x18, 0x0007);
289
		data = phy_read(phy, 0x18);
290
		phy_write(phy, 0x18, data | 0x0800);
291
		phy_write(phy, 0x17, 0x000a);
292
		data = phy_read(phy, 0x15);
293
		phy_write(phy, 0x15, data | 0x0200);
294
	}
295
#if 0
296
	/* This has to be verified before I enable it */
297
	/* Enable automatic low-power */
298
	phy_write(phy, 0x1c, 0x9002);
299
	phy_write(phy, 0x1c, 0xa821);
300
	phy_write(phy, 0x1c, 0x941d);
301
#endif
302
	return 0;
303
}
304
305
static int bcm54xx_setup_aneg(struct mii_phy *phy, u32 advertise)
306
{
307
	u16 ctl, adv;
308
	
309
	phy->autoneg = 1;
310
	phy->speed = SPEED_10;
311
	phy->duplex = DUPLEX_HALF;
312
	phy->pause = 0;
313
	phy->advertising = advertise;
314
315
	/* Setup standard advertise */
316
	adv = phy_read(phy, MII_ADVERTISE);
317
	adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4);
318
	if (advertise & ADVERTISED_10baseT_Half)
319
		adv |= ADVERTISE_10HALF;
320
	if (advertise & ADVERTISED_10baseT_Full)
321
		adv |= ADVERTISE_10FULL;
322
	if (advertise & ADVERTISED_100baseT_Half)
323
		adv |= ADVERTISE_100HALF;
324
	if (advertise & ADVERTISED_100baseT_Full)
325
		adv |= ADVERTISE_100FULL;
326
	phy_write(phy, MII_ADVERTISE, adv);
327
328
	/* Setup 1000BT advertise */
329
	adv = phy_read(phy, MII_1000BASETCONTROL);
330
	adv &= ~(MII_1000BASETCONTROL_FULLDUPLEXCAP|MII_1000BASETCONTROL_HALFDUPLEXCAP);
331
	if (advertise & SUPPORTED_1000baseT_Half)
332
		adv |= MII_1000BASETCONTROL_HALFDUPLEXCAP;
333
	if (advertise & SUPPORTED_1000baseT_Full)
334
		adv |= MII_1000BASETCONTROL_FULLDUPLEXCAP;
335
	phy_write(phy, MII_1000BASETCONTROL, adv);
336
337
	/* Start/Restart aneg */
338
	ctl = phy_read(phy, MII_BMCR);
339
	ctl |= (BMCR_ANENABLE | BMCR_ANRESTART);
340
	phy_write(phy, MII_BMCR, ctl);
341
342
	return 0;
343
}
344
345
static int bcm54xx_setup_forced(struct mii_phy *phy, int speed, int fd)
346
{
347
	u16 ctl;
348
	
349
	phy->autoneg = 0;
350
	phy->speed = speed;
351
	phy->duplex = fd;
352
	phy->pause = 0;
353
354
	ctl = phy_read(phy, MII_BMCR);
355
	ctl &= ~(BMCR_FULLDPLX|BMCR_SPEED100|BMCR_SPD2|BMCR_ANENABLE);
356
357
	/* First reset the PHY */
358
	phy_write(phy, MII_BMCR, ctl | BMCR_RESET);
359
360
	/* Select speed & duplex */
361
	switch(speed) {
362
	case SPEED_10:
363
		break;
364
	case SPEED_100:
365
		ctl |= BMCR_SPEED100;
366
		break;
367
	case SPEED_1000:
368
		ctl |= BMCR_SPD2;
369
	}
370
	if (fd == DUPLEX_FULL)
371
		ctl |= BMCR_FULLDPLX;
372
373
	// XXX Should we set the sungem to GII now on 1000BT ?
374
	
375
	phy_write(phy, MII_BMCR, ctl);
376
377
	return 0;
378
}
379
380
static int bcm54xx_read_link(struct mii_phy *phy)
381
{
382
	int link_mode;	
383
	u16 val;
384
	
385
	if (phy->autoneg) {
386
	    	val = phy_read(phy, MII_BCM5400_AUXSTATUS);
387
		link_mode = ((val & MII_BCM5400_AUXSTATUS_LINKMODE_MASK) >>
388
			     MII_BCM5400_AUXSTATUS_LINKMODE_SHIFT);
389
		phy->duplex = phy_BCM5400_link_table[link_mode][0] ? DUPLEX_FULL : DUPLEX_HALF;
390
		phy->speed = phy_BCM5400_link_table[link_mode][2] ?
391
				SPEED_1000 :
392
				(phy_BCM5400_link_table[link_mode][1] ? SPEED_100 : SPEED_10);
393
		val = phy_read(phy, MII_LPA);
394
		phy->pause = ((val & LPA_PAUSE) != 0);
395
	}
396
	/* On non-aneg, we assume what we put in BMCR is the speed,
397
	 * though magic-aneg shouldn't prevent this case from occurring
398
	 */
399
400
	return 0;
401
}
402
403
static int marvell_setup_aneg(struct mii_phy *phy, u32 advertise)
404
{
405
	u16 ctl, adv;
406
	
407
	phy->autoneg = 1;
408
	phy->speed = SPEED_10;
409
	phy->duplex = DUPLEX_HALF;
410
	phy->pause = 0;
411
	phy->advertising = advertise;
412
413
	/* Setup standard advertise */
414
	adv = phy_read(phy, MII_ADVERTISE);
415
	adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4);
416
	if (advertise & ADVERTISED_10baseT_Half)
417
		adv |= ADVERTISE_10HALF;
418
	if (advertise & ADVERTISED_10baseT_Full)
419
		adv |= ADVERTISE_10FULL;
420
	if (advertise & ADVERTISED_100baseT_Half)
421
		adv |= ADVERTISE_100HALF;
422
	if (advertise & ADVERTISED_100baseT_Full)
423
		adv |= ADVERTISE_100FULL;
424
	phy_write(phy, MII_ADVERTISE, adv);
425
426
	/* Setup 1000BT advertise & enable crossover detect
427
	 * XXX How do we advertise 1000BT ? Darwin source is
428
	 * confusing here, they read from specific control and
429
	 * write to control... Someone has specs for those
430
	 * beasts ?
431
	 */
432
	adv = phy_read(phy, MII_M1011_PHY_SPEC_CONTROL);
433
	adv |= MII_M1011_PHY_SPEC_CONTROL_AUTO_MDIX;
434
	adv &= ~(MII_1000BASETCONTROL_FULLDUPLEXCAP |
435
			MII_1000BASETCONTROL_HALFDUPLEXCAP);
436
	if (advertise & SUPPORTED_1000baseT_Half)
437
		adv |= MII_1000BASETCONTROL_HALFDUPLEXCAP;
438
	if (advertise & SUPPORTED_1000baseT_Full)
439
		adv |= MII_1000BASETCONTROL_FULLDUPLEXCAP;
440
	phy_write(phy, MII_1000BASETCONTROL, adv);
441
442
	/* Start/Restart aneg */
443
	ctl = phy_read(phy, MII_BMCR);
444
	ctl |= (BMCR_ANENABLE | BMCR_ANRESTART);
445
	phy_write(phy, MII_BMCR, ctl);
446
447
	return 0;
448
}
449
450
static int marvell_setup_forced(struct mii_phy *phy, int speed, int fd)
451
{
452
	u16 ctl, ctl2;
453
	
454
	phy->autoneg = 0;
455
	phy->speed = speed;
456
	phy->duplex = fd;
457
	phy->pause = 0;
458
459
	ctl = phy_read(phy, MII_BMCR);
460
	ctl &= ~(BMCR_FULLDPLX|BMCR_SPEED100|BMCR_SPD2|BMCR_ANENABLE);
461
	ctl |= BMCR_RESET;
462
463
	/* Select speed & duplex */
464
	switch(speed) {
465
	case SPEED_10:
466
		break;
467
	case SPEED_100:
468
		ctl |= BMCR_SPEED100;
469
		break;
470
	/* I'm not sure about the one below, again, Darwin source is
471
	 * quite confusing and I lack chip specs
472
	 */
473
	case SPEED_1000:
474
		ctl |= BMCR_SPD2;
475
	}
476
	if (fd == DUPLEX_FULL)
477
		ctl |= BMCR_FULLDPLX;
478
479
	/* Disable crossover. Again, the way Apple does it is strange,
480
	 * though I don't assume they are wrong ;)
481
	 */
482
	ctl2 = phy_read(phy, MII_M1011_PHY_SPEC_CONTROL);
483
	ctl2 &= ~(MII_M1011_PHY_SPEC_CONTROL_MANUAL_MDIX |
484
		MII_M1011_PHY_SPEC_CONTROL_AUTO_MDIX |
485
		MII_1000BASETCONTROL_FULLDUPLEXCAP |
486
		MII_1000BASETCONTROL_HALFDUPLEXCAP);
487
	if (speed == SPEED_1000)
488
		ctl2 |= (fd == DUPLEX_FULL) ?
489
			MII_1000BASETCONTROL_FULLDUPLEXCAP :
490
			MII_1000BASETCONTROL_HALFDUPLEXCAP;
491
	phy_write(phy, MII_1000BASETCONTROL, ctl2);
492
493
	// XXX Should we set the sungem to GII now on 1000BT ?
494
	
495
	phy_write(phy, MII_BMCR, ctl);
496
497
	return 0;
498
}
499
500
static int marvell_read_link(struct mii_phy *phy)
501
{
502
	u16 status;
503
504
	if (phy->autoneg) {
505
		status = phy_read(phy, MII_M1011_PHY_SPEC_STATUS);
506
		if ((status & MII_M1011_PHY_SPEC_STATUS_RESOLVED) == 0)
507
			return -EAGAIN;
508
		if (status & MII_M1011_PHY_SPEC_STATUS_1000)
509
			phy->speed = SPEED_1000;
510
		else if (status & MII_M1011_PHY_SPEC_STATUS_100)
511
			phy->speed = SPEED_100;
512
		else
513
			phy->speed = SPEED_10;
514
		if (status & MII_M1011_PHY_SPEC_STATUS_FULLDUPLEX)
515
			phy->duplex = DUPLEX_FULL;
516
		else
517
			phy->duplex = DUPLEX_HALF;
518
		phy->pause = 0; /* XXX Check against spec ! */
519
	}
520
	/* On non-aneg, we assume what we put in BMCR is the speed,
521
	 * though magic-aneg shouldn't prevent this case from occurring
522
	 */
523
524
	return 0;
525
}
526
527
static int genmii_setup_aneg(struct mii_phy *phy, u32 advertise)
528
{
529
	u16 ctl, adv;
530
	
531
	phy->autoneg = 1;
532
	phy->speed = SPEED_10;
533
	phy->duplex = DUPLEX_HALF;
534
	phy->pause = 0;
535
	phy->advertising = advertise;
536
537
	/* Setup standard advertise */
538
	adv = phy_read(phy, MII_ADVERTISE);
539
	adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4);
540
	if (advertise & ADVERTISED_10baseT_Half)
541
		adv |= ADVERTISE_10HALF;
542
	if (advertise & ADVERTISED_10baseT_Full)
543
		adv |= ADVERTISE_10FULL;
544
	if (advertise & ADVERTISED_100baseT_Half)
545
		adv |= ADVERTISE_100HALF;
546
	if (advertise & ADVERTISED_100baseT_Full)
547
		adv |= ADVERTISE_100FULL;
548
	phy_write(phy, MII_ADVERTISE, adv);
549
550
	/* Start/Restart aneg */
551
	ctl = phy_read(phy, MII_BMCR);
552
	ctl |= (BMCR_ANENABLE | BMCR_ANRESTART);
553
	phy_write(phy, MII_BMCR, ctl);
554
555
	return 0;
556
}
557
558
static int genmii_setup_forced(struct mii_phy *phy, int speed, int fd)
559
{
560
	u16 ctl;
561
	
562
	phy->autoneg = 0;
563
	phy->speed = speed;
564
	phy->duplex = fd;
565
	phy->pause = 0;
566
567
	ctl = phy_read(phy, MII_BMCR);
568
	ctl &= ~(BMCR_FULLDPLX|BMCR_SPEED100|BMCR_ANENABLE);
569
570
	/* First reset the PHY */
571
	phy_write(phy, MII_BMCR, ctl | BMCR_RESET);
572
573
	/* Select speed & duplex */
574
	switch(speed) {
575
	case SPEED_10:
576
		break;
577
	case SPEED_100:
578
		ctl |= BMCR_SPEED100;
579
		break;
580
	case SPEED_1000:
581
	default:
582
		return -EINVAL;
583
	}
584
	if (fd == DUPLEX_FULL)
585
		ctl |= BMCR_FULLDPLX;
586
	phy_write(phy, MII_BMCR, ctl);
587
588
	return 0;
589
}
590
591
static int genmii_poll_link(struct mii_phy *phy)
592
{
593
	u16 status;
594
	
595
	(void)phy_read(phy, MII_BMSR);
596
	status = phy_read(phy, MII_BMSR);
597
	if ((status & BMSR_LSTATUS) == 0)
598
		return 0;
599
	if (phy->autoneg && !(status & BMSR_ANEGCOMPLETE))
600
		return 0;
601
	return 1;
602
}
603
604
static int genmii_read_link(struct mii_phy *phy)
605
{
606
	u16 lpa;
607
608
	if (phy->autoneg) {
609
		lpa = phy_read(phy, MII_LPA);
610
611
		if (lpa & (LPA_10FULL | LPA_100FULL))
612
			phy->duplex = DUPLEX_FULL;
613
		else
614
			phy->duplex = DUPLEX_HALF;
615
		if (lpa & (LPA_100FULL | LPA_100HALF))
616
			phy->speed = SPEED_100;
617
		else
618
			phy->speed = SPEED_10;
619
		phy->pause = 0;
620
	}
621
	/* On non-aneg, we assume what we put in BMCR is the speed,
622
	 * though magic-aneg shouldn't prevent this case from occurring
623
	 */
624
625
	 return 0;
626
}
627
628
629
#define MII_BASIC_FEATURES	(SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | \
630
				 SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full | \
631
				 SUPPORTED_Autoneg | SUPPORTED_TP | SUPPORTED_MII)
632
#define MII_GBIT_FEATURES	(MII_BASIC_FEATURES | \
633
				 SUPPORTED_1000baseT_Half | SUPPORTED_1000baseT_Full)
634
635
/* Broadcom BCM 5201 */
636
static struct mii_phy_ops bcm5201_phy_ops = {
637
	init:		bcm5201_init,
638
	suspend:	bcm5201_suspend,
639
	setup_aneg:	genmii_setup_aneg,
640
	setup_forced:	genmii_setup_forced,
641
	poll_link:	genmii_poll_link,
642
	read_link:	genmii_read_link,
643
};
644
645
static struct mii_phy_def bcm5201_phy_def = {
646
	phy_id:		0x00406210,
647
	phy_id_mask:	0xfffffff0,
648
	name:		"BCM5201",
649
	features:	MII_BASIC_FEATURES,
650
	magic_aneg:	0,
651
	ops:		&bcm5201_phy_ops
652
};
653
654
/* Broadcom BCM 5221 */
655
static struct mii_phy_ops bcm5221_phy_ops = {
656
	suspend:	bcm5201_suspend,
657
	init:		bcm5221_init,
658
	setup_aneg:	genmii_setup_aneg,
659
	setup_forced:	genmii_setup_forced,
660
	poll_link:	genmii_poll_link,
661
	read_link:	genmii_read_link,
662
};
663
664
static struct mii_phy_def bcm5221_phy_def = {
665
	phy_id:		0x004061e0,
666
	phy_id_mask:	0xfffffff0,
667
	name:		"BCM5221",
668
	features:	MII_BASIC_FEATURES,
669
	magic_aneg:	0,
670
	ops:		&bcm5221_phy_ops
671
};
672
673
/* Broadcom BCM 5400 */
674
static struct mii_phy_ops bcm5400_phy_ops = {
675
	init:		bcm5400_init,
676
	suspend:	bcm5400_suspend,
677
	setup_aneg:	bcm54xx_setup_aneg,
678
	setup_forced:	bcm54xx_setup_forced,
679
	poll_link:	genmii_poll_link,
680
	read_link:	bcm54xx_read_link,
681
};
682
683
static struct mii_phy_def bcm5400_phy_def = {
684
	phy_id:		0x00206040,
685
	phy_id_mask:	0xfffffff0,
686
	name:		"BCM5400",
687
	features:	MII_GBIT_FEATURES,
688
	magic_aneg:	1,
689
	ops:		&bcm5400_phy_ops
690
};
691
692
/* Broadcom BCM 5401 */
693
static struct mii_phy_ops bcm5401_phy_ops = {
694
	init:		bcm5401_init,
695
	suspend:	bcm5401_suspend,
696
	setup_aneg:	bcm54xx_setup_aneg,
697
	setup_forced:	bcm54xx_setup_forced,
698
	poll_link:	genmii_poll_link,
699
	read_link:	bcm54xx_read_link,
700
};
701
702
static struct mii_phy_def bcm5401_phy_def = {
703
	phy_id:		0x00206050,
704
	phy_id_mask:	0xfffffff0,
705
	name:		"BCM5401",
706
	features:	MII_GBIT_FEATURES,
707
	magic_aneg:	1,
708
	ops:		&bcm5401_phy_ops
709
};
710
711
/* Broadcom BCM 5411 */
712
static struct mii_phy_ops bcm5411_phy_ops = {
713
	init:		bcm5411_init,
714
	suspend:	bcm5411_suspend,
715
	setup_aneg:	bcm54xx_setup_aneg,
716
	setup_forced:	bcm54xx_setup_forced,
717
	poll_link:	genmii_poll_link,
718
	read_link:	bcm54xx_read_link,
719
};
720
721
static struct mii_phy_def bcm5411_phy_def = {
722
	phy_id:		0x00206070,
723
	phy_id_mask:	0xfffffff0,
724
	name:		"BCM5411",
725
	features:	MII_GBIT_FEATURES,
726
	magic_aneg:	1,
727
	ops:		&bcm5411_phy_ops
728
};
729
730
/* Broadcom BCM 5421 */
731
static struct mii_phy_ops bcm5421_phy_ops = {
732
	init:		bcm5421_init,
733
	suspend:	bcm5411_suspend,
734
	setup_aneg:	bcm54xx_setup_aneg,
735
	setup_forced:	bcm54xx_setup_forced,
736
	poll_link:	genmii_poll_link,
737
	read_link:	bcm54xx_read_link,
738
};
739
740
static struct mii_phy_def bcm5421_phy_def = {
741
	phy_id:		0x002060e0,
742
	phy_id_mask:	0xfffffff0,
743
	name:		"BCM5421",
744
	features:	MII_GBIT_FEATURES,
745
	magic_aneg:	1,
746
	ops:		&bcm5421_phy_ops
747
};
748
749
/* Marvell 88E1101 (Apple seem to deal with 2 different revs,
750
 * I masked out the 8 last bits to get both, but some specs
751
 * would be useful here) --BenH.
752
 */
753
static struct mii_phy_ops marvell_phy_ops = {
754
	setup_aneg:	marvell_setup_aneg,
755
	setup_forced:	marvell_setup_forced,
756
	poll_link:	genmii_poll_link,
757
	read_link:	marvell_read_link
758
};
759
760
static struct mii_phy_def marvell_phy_def = {
761
	phy_id:		0x01410c00,
762
	phy_id_mask:	0xffffff00,
763
	name:		"Marvell 88E1101",
764
	features:	MII_GBIT_FEATURES,
765
	magic_aneg:	1,
766
	ops:		&marvell_phy_ops
767
};
768
769
/* Generic implementation for most 10/100 PHYs */
770
static struct mii_phy_ops generic_phy_ops = {
771
	setup_aneg:	genmii_setup_aneg,
772
	setup_forced:	genmii_setup_forced,
773
	poll_link:	genmii_poll_link,
774
	read_link:	genmii_read_link
775
};
776
777
static struct mii_phy_def genmii_phy_def = {
778
	phy_id:		0x00000000,
779
	phy_id_mask:	0x00000000,
780
	name:		"Generic MII",
781
	features:	MII_BASIC_FEATURES,
782
	magic_aneg:	0,
783
	ops:		&generic_phy_ops
784
};
785
786
static struct mii_phy_def* mii_phy_table[] = {
787
	&bcm5201_phy_def,
788
	&bcm5221_phy_def,
789
	&bcm5400_phy_def,
790
	&bcm5401_phy_def,
791
	&bcm5411_phy_def,
792
	&bcm5421_phy_def,
793
	&marvell_phy_def,
794
	&genmii_phy_def,
795
	NULL
796
};
797
798
int mii_phy_probe(struct mii_phy *phy, int mii_id)
799
{
800
	int rc;
801
	u32 id;
802
	struct mii_phy_def* def;
803
	int i;
804
805
	/* We do not reset the mii_phy structure as the driver
806
	 * may re-probe the PHY regulary
807
	 */
808
	phy->mii_id = mii_id;
809
	
810
	/* Take PHY out of isloate mode and reset it. */
811
	rc = reset_one_mii_phy(phy, mii_id);
812
	if (rc)
813
		goto fail;
814
815
	/* Read ID and find matching entry */	
816
	id = (phy_read(phy, MII_PHYSID1) << 16 | phy_read(phy, MII_PHYSID2))
817
			 	& 0xfffffff0;
818
	for (i=0; (def = mii_phy_table[i]) != NULL; i++)
819
		if ((id & def->phy_id_mask) == def->phy_id)
820
			break;
821
	/* Should never be NULL (we have a generic entry), but... */
822
	if (def == NULL)
823
		goto fail;
824
825
	phy->def = def;
826
	
827
	return 0;
828
fail:
829
	phy->speed = 0;
830
	phy->duplex = 0;
831
	phy->pause = 0;
832
	phy->advertising = 0;
833
	return -ENODEV;
834
}
835
836
EXPORT_SYMBOL(mii_phy_probe);
837
MODULE_LICENSE("GPL");
838
(-)linux-2.4.22/drivers/net/sungem_phy.h (+116 lines)
Line 0 Link Here
1
#ifndef __SUNGEM_PHY_H__
2
#define __SUNGEM_PHY_H__
3
4
struct mii_phy;
5
6
/* Operations supported by any kind of PHY */
7
struct mii_phy_ops
8
{
9
	int		(*init)(struct mii_phy *phy);
10
	int		(*suspend)(struct mii_phy *phy, int wol_options);
11
	int		(*setup_aneg)(struct mii_phy *phy, u32 advertise);
12
	int		(*setup_forced)(struct mii_phy *phy, int speed, int fd);
13
	int		(*poll_link)(struct mii_phy *phy);
14
	int		(*read_link)(struct mii_phy *phy);
15
};
16
17
/* Structure used to statically define an mii/gii based PHY */
18
struct mii_phy_def
19
{
20
	u32				phy_id;		/* Concatenated ID1 << 16 | ID2 */
21
	u32				phy_id_mask;	/* Significant bits */
22
	u32				features;	/* Ethtool SUPPORTED_* defines */
23
	int				magic_aneg;	/* Autoneg does all speed test for us */
24
	const char*			name;
25
	const struct mii_phy_ops*	ops;
26
};
27
28
/* An instance of a PHY, partially borrowed from mii_if_info */
29
struct mii_phy
30
{
31
	struct mii_phy_def*	def;
32
	int			advertising;
33
	int			mii_id;
34
35
	/* 1: autoneg enabled, 0: disabled */
36
	int			autoneg;
37
38
	/* forced speed & duplex (no autoneg)
39
	 * partner speed & duplex & pause (autoneg)
40
	 */
41
	int			speed;
42
	int			duplex;
43
	int			pause;
44
45
	/* Provided by host chip */
46
	struct net_device*	dev;
47
	int (*mdio_read) (struct net_device *dev, int mii_id, int reg);
48
	void (*mdio_write) (struct net_device *dev, int mii_id, int reg, int val);
49
};
50
51
/* Pass in a struct mii_phy with dev, mdio_read and mdio_write
52
 * filled, the remaining fields will be filled on return
53
 */
54
extern int mii_phy_probe(struct mii_phy *phy, int mii_id);
55
56
57
/* MII definitions missing from mii.h */
58
59
#define BMCR_SPD2	0x0040		/* Gigabit enable (bcm54xx)	*/
60
#define LPA_PAUSE	0x0400
61
62
/* More PHY registers (model specific) */
63
64
/* MII BCM5201 MULTIPHY interrupt register */
65
#define MII_BCM5201_INTERRUPT			0x1A
66
#define MII_BCM5201_INTERRUPT_INTENABLE		0x4000
67
68
#define MII_BCM5201_AUXMODE2			0x1B
69
#define MII_BCM5201_AUXMODE2_LOWPOWER		0x0008
70
71
#define MII_BCM5201_MULTIPHY                    0x1E
72
73
/* MII BCM5201 MULTIPHY register bits */
74
#define MII_BCM5201_MULTIPHY_SERIALMODE         0x0002
75
#define MII_BCM5201_MULTIPHY_SUPERISOLATE       0x0008
76
77
/* MII BCM5221 Additional registers */
78
#define MII_BCM5221_TEST			0x1f
79
#define MII_BCM5221_TEST_ENABLE_SHADOWS		0x0080
80
#define MII_BCM5221_SHDOW_AUX_STAT2		0x1b
81
#define MII_BCM5221_SHDOW_AUX_STAT2_APD		0x0020
82
#define MII_BCM5221_SHDOW_AUX_MODE4		0x1a
83
#define MII_BCM5221_SHDOW_AUX_MODE4_CLKLOPWR	0x0004
84
85
/* MII BCM5400 1000-BASET Control register */
86
#define MII_BCM5400_GB_CONTROL			0x09
87
#define MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP	0x0200
88
89
/* MII BCM5400 AUXCONTROL register */
90
#define MII_BCM5400_AUXCONTROL                  0x18
91
#define MII_BCM5400_AUXCONTROL_PWR10BASET       0x0004
92
93
/* MII BCM5400 AUXSTATUS register */
94
#define MII_BCM5400_AUXSTATUS                   0x19
95
#define MII_BCM5400_AUXSTATUS_LINKMODE_MASK     0x0700
96
#define MII_BCM5400_AUXSTATUS_LINKMODE_SHIFT    8  
97
98
/* 1000BT control (Marvell & BCM54xx at least) */
99
#define MII_1000BASETCONTROL			0x09
100
#define MII_1000BASETCONTROL_FULLDUPLEXCAP	0x0200
101
#define MII_1000BASETCONTROL_HALFDUPLEXCAP	0x0100
102
103
/* Marvell 88E1011 PHY control */
104
#define MII_M1011_PHY_SPEC_CONTROL		0x10
105
#define MII_M1011_PHY_SPEC_CONTROL_MANUAL_MDIX	0x20
106
#define MII_M1011_PHY_SPEC_CONTROL_AUTO_MDIX	0x40
107
108
/* Marvell 88E1011 PHY status */
109
#define MII_M1011_PHY_SPEC_STATUS		0x11
110
#define MII_M1011_PHY_SPEC_STATUS_1000		0x8000
111
#define MII_M1011_PHY_SPEC_STATUS_100		0x4000
112
#define MII_M1011_PHY_SPEC_STATUS_SPD_MASK	0xc000
113
#define MII_M1011_PHY_SPEC_STATUS_FULLDUPLEX	0x2000
114
#define MII_M1011_PHY_SPEC_STATUS_RESOLVED	0x0800
115
116
#endif /* __SUNGEM_PHY_H__ */
(-)linux-2.4.22/drivers/net/tg3.c (+2 lines)
Lines 145-150 Link Here
145
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
145
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
146
	{ PCI_VENDOR_ID_ALTIMA, PCI_DEVICE_ID_ALTIMA_AC9100,
146
	{ PCI_VENDOR_ID_ALTIMA, PCI_DEVICE_ID_ALTIMA_AC9100,
147
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
147
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
148
	{ PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_TIGON3,
149
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
148
	{ 0, }
150
	{ 0, }
149
};
151
};
150
152
(-)linux-2.4.22/drivers/net/tulip/tulip_core.c (+9 lines)
Lines 474-479 Link Here
474
	} else
474
	} else
475
		tulip_select_media(dev, 1);
475
		tulip_select_media(dev, 1);
476
476
477
	/* check for Apple 100BaseTX card and disable loops */
478
	if ((dev->dev_addr[0] == 0x00) &&
479
	    (dev->dev_addr[1] == 0x05) &&
480
	    (dev->dev_addr[2] == 0x02) &&
481
	    (tp->chip_id == DC21140)) {
482
		outl(0x10f, ioaddr + CSR12);
483
		outl(0x03, ioaddr + CSR12);
484
	}
485
	
477
	/* Start the chip's Tx to process setup frame. */
486
	/* Start the chip's Tx to process setup frame. */
478
	tulip_stop_rxtx(tp);
487
	tulip_stop_rxtx(tp);
479
	barrier();
488
	barrier();
(-)linux-2.4.22/drivers/net/wan/8253x/build (+8 lines)
Line 0 Link Here
1
cc -g  -o 8253xcfg -I. -U__KERNEL__ 8253xcfg.c
2
cc -g  -o 8253xspeed -I. -U__KERNEL__ 8253xspeed.c
3
cc -g  -o 8253xmode -I. -U__KERNEL__ 8253xmode.c
4
cc -g  -o 8253xpeer -I. -U__KERNEL__ 8253xpeer.c
5
cc -g  -o eprom9050 -I. -U__KERNEL__ eprom9050.c
6
7
8
(-)linux-2.4.22/drivers/net/wireless/Config.in (+1 lines)
Lines 15-20 Link Here
15
if [ "$CONFIG_PCI" = "y" ]; then
15
if [ "$CONFIG_PCI" = "y" ]; then
16
   dep_tristate '    Hermes in PLX9052 based PCI adaptor support (Netgear MA301 etc.) (EXPERIMENTAL)' CONFIG_PLX_HERMES $CONFIG_HERMES $CONFIG_EXPERIMENTAL
16
   dep_tristate '    Hermes in PLX9052 based PCI adaptor support (Netgear MA301 etc.) (EXPERIMENTAL)' CONFIG_PLX_HERMES $CONFIG_HERMES $CONFIG_EXPERIMENTAL
17
   dep_tristate '    Prism 2.5 PCI 802.11b adaptor support (EXPERIMENTAL)' CONFIG_PCI_HERMES $CONFIG_HERMES $CONFIG_EXPERIMENTAL
17
   dep_tristate '    Prism 2.5 PCI 802.11b adaptor support (EXPERIMENTAL)' CONFIG_PCI_HERMES $CONFIG_HERMES $CONFIG_EXPERIMENTAL
18
   dep_tristate '    Prism II devices connected via a TMD7160 (EXPERIMENTAL)' CONFIG_TMD_HERMES $CONFIG_HERMES $CONFIG_EXPERIMENTAL
18
fi
19
fi
19
20
20
# If Pcmcia is compiled in, offer Pcmcia cards...
21
# If Pcmcia is compiled in, offer Pcmcia cards...
(-)linux-2.4.22/drivers/net/wireless/Makefile (+1 lines)
Lines 19-24 Link Here
19
obj-$(CONFIG_APPLE_AIRPORT)	+= airport.o
19
obj-$(CONFIG_APPLE_AIRPORT)	+= airport.o
20
obj-$(CONFIG_PLX_HERMES)	+= orinoco_plx.o
20
obj-$(CONFIG_PLX_HERMES)	+= orinoco_plx.o
21
obj-$(CONFIG_PCI_HERMES)	+= orinoco_pci.o
21
obj-$(CONFIG_PCI_HERMES)	+= orinoco_pci.o
22
obj-$(CONFIG_TMD_HERMES)	+= orinoco_tmd.o
22
23
23
obj-$(CONFIG_AIRO)		+= airo.o
24
obj-$(CONFIG_AIRO)		+= airo.o
24
obj-$(CONFIG_AIRO_CS)		+= airo_cs.o airo.o
25
obj-$(CONFIG_AIRO_CS)		+= airo_cs.o airo.o
(-)linux-2.4.22/drivers/pci/pci.c (-5 / +12 lines)
Lines 28-34 Link Here
28
#include <asm/page.h>
28
#include <asm/page.h>
29
#include <asm/dma.h>	/* isa_dma_bridge_buggy */
29
#include <asm/dma.h>	/* isa_dma_bridge_buggy */
30
30
31
#undef DEBUG
31
#define DEBUG
32
32
33
#ifdef DEBUG
33
#ifdef DEBUG
34
#define DBG(x...) printk(x)
34
#define DBG(x...) printk(x)
Lines 1059-1074 Link Here
1059
	unsigned int pos, reg, next;
1059
	unsigned int pos, reg, next;
1060
	u32 l, sz;
1060
	u32 l, sz;
1061
	struct resource *res;
1061
	struct resource *res;
1062
	int is_kl = (dev->device == 0x22 && dev->vendor == 0x106b);
1062
1063
1064
	if (is_kl)
1065
		howmany = 1;
1063
	for(pos=0; pos<howmany; pos = next) {
1066
	for(pos=0; pos<howmany; pos = next) {
1064
		next = pos+1;
1067
		next = pos+1;
1065
		res = &dev->resource[pos];
1068
		res = &dev->resource[pos];
1066
		res->name = dev->name;
1069
		res->name = dev->name;
1067
		reg = PCI_BASE_ADDRESS_0 + (pos << 2);
1070
		reg = PCI_BASE_ADDRESS_0 + (pos << 2);
1068
		pci_read_config_dword(dev, reg, &l);
1071
		pci_read_config_dword(dev, reg, &l);
1069
		pci_write_config_dword(dev, reg, ~0);
1072
		if (is_kl)
1070
		pci_read_config_dword(dev, reg, &sz);
1073
			sz = 0x00080000;
1071
		pci_write_config_dword(dev, reg, l);
1074
		else {
1075
			pci_write_config_dword(dev, reg, ~0);
1076
			pci_read_config_dword(dev, reg, &sz);
1077
			pci_write_config_dword(dev, reg, l);
1078
		}
1072
		if (!sz || sz == 0xffffffff)
1079
		if (!sz || sz == 0xffffffff)
1073
			continue;
1080
			continue;
1074
		if (l == 0xffffffff)
1081
		if (l == 0xffffffff)
Lines 1309-1315 Link Here
1309
		if (!pass)
1316
		if (!pass)
1310
			return max;
1317
			return max;
1311
		pci_read_config_word(dev, PCI_COMMAND, &cr);
1318
		pci_read_config_word(dev, PCI_COMMAND, &cr);
1312
		pci_write_config_word(dev, PCI_COMMAND, 0x0000);
1319
		//pci_write_config_word(dev, PCI_COMMAND, 0x0000);
1313
		pci_write_config_word(dev, PCI_STATUS, 0xffff);
1320
		pci_write_config_word(dev, PCI_STATUS, 0xffff);
1314
1321
1315
		child = pci_add_new_bus(bus, dev, ++max);
1322
		child = pci_add_new_bus(bus, dev, ++max);
(-)linux-2.4.22/drivers/sound/dmasound/Config.in (-5 / +19 lines)
Lines 27-39 Link Here
27
fi
27
fi
28
28
29
# the new dmasound_pmac driver needs access to the i2c bus
29
# the new dmasound_pmac driver needs access to the i2c bus
30
# and nvram.
30
if [ "$CONFIG_DMASOUND_PMAC" = "y" ] ; then
31
if [ "$CONFIG_DMASOUND_PMAC" = "y" ] ; then
31
   define_tristate CONFIG_I2C y
32
   if [ "$CONFIG_I2C" != "y" ]; then
32
   define_tristate CONFIG_I2C_KEYWEST y
33
      define_tristate CONFIG_I2C y
34
   fi
35
   if [ "$CONFIG_I2C_KEYWEST" != "y" ]; then
36
      define_tristate CONFIG_I2C_KEYWEST y
37
   fi
38
   if [ "$CONFIG_NVRAM" != "y" -a "$CONFIG_NVRAM" != "m" ]; then
39
      define_tristate CONFIG_NVRAM y
40
   fi
33
else
41
else
34
   if [ "$CONFIG_DMASOUND_PMAC" = "m" ] ; then
42
   if [ "$CONFIG_DMASOUND_PMAC" = "m" ] ; then
35
   define_tristate CONFIG_I2C m
43
      if [ "$CONFIG_I2C" != "y" -a "$CONFIG_I2C" != "m" ]; then
36
   define_tristate CONFIG_I2C_KEYWEST m
44
         define_tristate CONFIG_I2C m
45
      fi
46
      if [ "$CONFIG_I2C_KEYWEST" != "y" -a "$CONFIG_I2C_KEYWEST" != "m" ]; then
47
         define_tristate CONFIG_I2C_KEYWEST m
48
      fi
49
      if [ "$CONFIG_NVRAM" != "y" -a "$CONFIG_NVRAM" != "m" ]; then
50
         define_tristate CONFIG_NVRAM y
51
      fi
37
   fi
52
   fi
38
fi
53
fi
39
(-)linux-2.4.22/drivers/sound/dmasound/Makefile (-1 / +2 lines)
Lines 13-19 Link Here
13
13
14
list-multi := dmasound_pmac.o
14
list-multi := dmasound_pmac.o
15
15
16
dmasound_pmac-objs := dmasound_awacs.o trans_16.o tas3001c.o dac3550a.o
16
dmasound_pmac-objs := dmasound_awacs.o trans_16.o dac3550a.o tas_common.o \
17
			tas3001c.o tas3001c_tables.o tas3004.o tas3004_tables.o
17
18
18
obj-$(CONFIG_DMASOUND)        += dmasound_core.o
19
obj-$(CONFIG_DMASOUND)        += dmasound_core.o
19
obj-$(CONFIG_DMASOUND_ATARI)  += dmasound_atari.o
20
obj-$(CONFIG_DMASOUND_ATARI)  += dmasound_atari.o
(-)linux-2.4.22/drivers/sound/dmasound/awacs_defs.h (-1 / +17 lines)
Lines 168-175 Link Here
168
168
169
#define RATE_LOW	1	/* HIGH = 48kHz, etc;  LOW = 44.1kHz, etc. */
169
#define RATE_LOW	1	/* HIGH = 48kHz, etc;  LOW = 44.1kHz, etc. */
170
170
171
171
/*******************/
172
/* Burgundy values */
172
/* Burgundy values */
173
/*******************/
173
174
174
#define MASK_ADDR_BURGUNDY_INPSEL21 (0x11 << 12)
175
#define MASK_ADDR_BURGUNDY_INPSEL21 (0x11 << 12)
175
#define MASK_ADDR_BURGUNDY_INPSEL3 (0x12 << 12)
176
#define MASK_ADDR_BURGUNDY_INPSEL3 (0x12 << 12)
Lines 232-235 Link Here
232
#define DEF_BURGUNDY_ATTENLINEOUT (0xCC)
233
#define DEF_BURGUNDY_ATTENLINEOUT (0xCC)
233
#define DEF_BURGUNDY_ATTENHP (0xCC)
234
#define DEF_BURGUNDY_ATTENHP (0xCC)
234
235
236
/*********************/
237
/* i2s layout values */
238
/*********************/
239
240
#define I2S_REG_INT_CTL			0x00
241
#define I2S_REG_SERIAL_FORMAT		0x10
242
#define I2S_REG_CODEC_MSG_OUT		0x20
243
#define I2S_REG_CODEC_MSG_IN		0x30
244
#define I2S_REG_FRAME_COUNT		0x40
245
#define I2S_REG_FRAME_MATCH		0x50
246
#define I2S_REG_DATAWORD_SIZES		0x60
247
#define I2S_REG_PEAKLEVEL_SEL		0x70
248
#define I2S_REG_PEAKLEVEL_IN0		0x80
249
#define I2S_REG_PEAKLEVEL_IN1		0x90
250
235
#endif /* _AWACS_DEFS_H_ */
251
#endif /* _AWACS_DEFS_H_ */
(-)linux-2.4.22/drivers/sound/dmasound/dmasound_awacs.c (-261 / +341 lines)
Lines 45-51 Link Here
45
 *      01/02/2002 [0.7] - BenH
45
 *      01/02/2002 [0.7] - BenH
46
 *	        - all sort of minor bits went in since the latest update, I
46
 *	        - all sort of minor bits went in since the latest update, I
47
 *	          bumped the version number for that reason
47
 *	          bumped the version number for that reason
48
*/
48
 *
49
 *      07/26/2002 [0.8] - BenH
50
 *	        - More minor bits since last changelog (I should be more careful
51
 *	          with those)
52
 *	        - Support for snapper & better tumbler integration by Toby Sargeant
53
 *	        - Headphone detect for scremer by Julien Blache
54
 *	        - More tumbler fixed by Andreas Schwab
55
 */
49
56
50
/* GENERAL FIXME/TODO: check that the assumptions about what is written to
57
/* GENERAL FIXME/TODO: check that the assumptions about what is written to
51
   mac-io is valid for DACA & Tumbler.
58
   mac-io is valid for DACA & Tumbler.
Lines 88-97 Link Here
88
95
89
#include "awacs_defs.h"
96
#include "awacs_defs.h"
90
#include "dmasound.h"
97
#include "dmasound.h"
98
#include "tas3001c.h"
99
#include "tas3004.h"
100
#include "tas_common.h"
91
101
92
#define DMASOUND_AWACS_REVISION	0
102
#define DMASOUND_AWACS_REVISION	0
93
#define DMASOUND_AWACS_EDITION	7
103
#define DMASOUND_AWACS_EDITION	7
94
104
105
#define AWACS_SNAPPER   110	/* fake revision # for snapper */
95
#define AWACS_BURGUNDY	100	/* fake revision # for burgundy */
106
#define AWACS_BURGUNDY	100	/* fake revision # for burgundy */
96
#define AWACS_TUMBLER    90	/* fake revision # for tumbler */
107
#define AWACS_TUMBLER    90	/* fake revision # for tumbler */
97
#define AWACS_DACA	 80	/* fake revision # for daca (ibook) */
108
#define AWACS_DACA	 80	/* fake revision # for daca (ibook) */
Lines 102-112 Link Here
102
 */
113
 */
103
static int awacs_irq, awacs_tx_irq, awacs_rx_irq;
114
static int awacs_irq, awacs_tx_irq, awacs_rx_irq;
104
static volatile struct awacs_regs *awacs;
115
static volatile struct awacs_regs *awacs;
116
static volatile u32 *i2s;
105
static volatile struct dbdma_regs *awacs_txdma, *awacs_rxdma;
117
static volatile struct dbdma_regs *awacs_txdma, *awacs_rxdma;
106
static int awacs_rate_index;
118
static int awacs_rate_index;
107
static int awacs_subframe;
119
static int awacs_subframe;
108
static int awacs_spkr_vol;
120
static int awacs_spkr_vol;
109
static struct device_node* awacs_node;
121
static struct device_node* awacs_node;
122
static struct device_node* i2s_node;
110
123
111
static char awacs_name[64];
124
static char awacs_name[64];
112
static int awacs_revision;
125
static int awacs_revision;
Lines 163-168 Link Here
163
static int cd_lev = 0x6363 ; /* 99 % */
176
static int cd_lev = 0x6363 ; /* 99 % */
164
static int line_lev = 0 ;
177
static int line_lev = 0 ;
165
178
179
static int hdp_connected = 0;
180
166
/*
181
/*
167
 * Stuff for outputting a beep.  The values range from -327 to +327
182
 * Stuff for outputting a beep.  The values range from -327 to +327
168
 * so we can multiply by an amplitude in the range 0..100 to get a
183
 * so we can multiply by an amplitude in the range 0..100 to get a
Lines 293-311 Link Here
293
extern int daca_enter_sleep(void);
308
extern int daca_enter_sleep(void);
294
extern int daca_leave_sleep(void);
309
extern int daca_leave_sleep(void);
295
310
296
extern int tas_init(void);
297
extern int tas_cleanup(void);
298
extern int tumbler_set_volume(uint left_vol, uint right_vol);
299
extern void tumbler_get_volume(uint * left_vol, uint  *right_vol);
300
extern void tumbler_set_treble(int treble);
301
extern void tumbler_get_treble(int *treble);
302
extern void tumbler_set_bass(int bass);
303
extern void tumbler_get_bass(int *bass);
304
extern void tumbler_set_pcm_lvl(int pcm_lvl);
305
extern void tumbler_get_pcm_lvl(int *pcm_lvl);
306
extern int tumbler_enter_sleep(void);
307
extern int tumbler_leave_sleep(void);
308
309
#define TRY_LOCK()	\
311
#define TRY_LOCK()	\
310
	if ((rc = down_interruptible(&dmasound_sem)) != 0)	\
312
	if ((rc = down_interruptible(&dmasound_sem)) != 0)	\
311
		return rc;
313
		return rc;
Lines 332-338 Link Here
332
}
334
}
333
335
334
336
335
/*** AE - TUMBLER START *********************************************************/
337
/*** AE - TUMBLER / SNAPPER START ************************************************/
336
338
337
339
338
int gpio_audio_reset, gpio_audio_reset_pol;
340
int gpio_audio_reset, gpio_audio_reset_pol;
Lines 394-410 Link Here
394
	return ((pmac_call_feature(PMAC_FTR_READ_GPIO, NULL, gpio_addr, 0) & 0x02) !=0);
396
	return ((pmac_call_feature(PMAC_FTR_READ_GPIO, NULL, gpio_addr, 0) & 0x02) !=0);
395
}
397
}
396
398
399
/*
400
 * Headphone interrupt via GPIO (Tumbler, Snapper, DACA)
401
 */
397
static void
402
static void
398
headphone_intr(int irq, void *devid, struct pt_regs *regs)
403
headphone_intr(int irq, void *devid, struct pt_regs *regs)
399
{
404
{
400
	if (read_audio_gpio(gpio_headphone_detect) == gpio_headphone_detect_pol) {
405
	if (read_audio_gpio(gpio_headphone_detect) == gpio_headphone_detect_pol) {
401
		printk(KERN_INFO "Audio jack plugged, muting speakers.\n");
406
		printk(KERN_INFO "Audio jack plugged, muting speakers.\n");
402
		write_audio_gpio(gpio_amp_mute, gpio_amp_mute_pol);
403
		write_audio_gpio(gpio_headphone_mute, !gpio_headphone_mute_pol);
407
		write_audio_gpio(gpio_headphone_mute, !gpio_headphone_mute_pol);
408
		write_audio_gpio(gpio_amp_mute, gpio_amp_mute_pol);
409
		tas_output_device_change(sound_device_id,TAS_OUTPUT_HEADPHONES,0);
404
	} else {
410
	} else {
405
		printk(KERN_INFO "Audio jack unplugged, enabling speakers.\n");
411
		printk(KERN_INFO "Audio jack unplugged, enabling speakers.\n");
406
		write_audio_gpio(gpio_amp_mute, !gpio_amp_mute_pol);
412
		write_audio_gpio(gpio_amp_mute, !gpio_amp_mute_pol);
407
		write_audio_gpio(gpio_headphone_mute, gpio_headphone_mute_pol);
413
		write_audio_gpio(gpio_headphone_mute, gpio_headphone_mute_pol);
414
		tas_output_device_change(sound_device_id,TAS_OUTPUT_INTERNAL_SPKR,0);
408
	}
415
	}
409
}
416
}
410
417
Lines 412-418 Link Here
412
/* Initialize tumbler */
419
/* Initialize tumbler */
413
420
414
static int
421
static int
415
awacs_tumbler_init(void)
422
tas_dmasound_init(void)
416
{
423
{
417
	setup_audio_gpio(
424
	setup_audio_gpio(
418
		"audio-hw-reset",
425
		"audio-hw-reset",
Lines 469-483 Link Here
469
476
470
477
471
static int
478
static int
472
awacs_tumbler_cleanup(void)
479
tas_dmasound_cleanup(void)
473
{
480
{
474
	if (gpio_headphone_irq)
481
	if (gpio_headphone_irq)
475
		free_irq(gpio_headphone_irq, 0);
482
		free_irq(gpio_headphone_irq, 0);
476
	return 0;
483
	return 0;
477
}
484
}
478
485
486
/* We don't support 48k yet */
487
static int tas_freqs[1] = { 44100 } ;
488
static int tas_freqs_ok[1] = { 1 } ;
479
489
480
/*** AE - TUMBLER END *********************************************************/
490
/* don't know what to do really - just have to leave it where
491
 * OF left things
492
*/
493
494
static int
495
tas_set_frame_rate(void)
496
{
497
	if (i2s) {
498
		out_le32(i2s + (I2S_REG_SERIAL_FORMAT >> 2), 0x41190000);
499
		out_le32(i2s + (I2S_REG_DATAWORD_SIZES >> 2), 0x02000200);
500
	}
501
	dmasound.hard.speed = 44100 ;
502
	awacs_rate_index = 0 ;
503
	return 44100 ;
504
}
505
506
static int
507
tas_mixer_ioctl(u_int cmd, u_long arg)
508
{
509
	int data;
510
	int rc;
511
512
        rc=tas_device_ioctl(cmd, arg);
513
        if (rc != -EINVAL) {
514
        	return rc;
515
        }
516
517
        if ((cmd & ~0xff) == MIXER_WRITE(0) &&
518
            tas_supported_mixers() & (1<<(cmd & 0xff))) {
519
		rc = get_user(data, (int *)(arg));
520
                if (rc<0) return rc;
521
		tas_set_mixer_level(cmd & 0xff, data);
522
		tas_get_mixer_level(cmd & 0xff, &data);
523
		return ioctl_return2((int *)(arg), data);
524
        }
525
        if ((cmd & ~0xff) == MIXER_READ(0) &&
526
            tas_supported_mixers() & (1<<(cmd & 0xff))) {
527
		tas_get_mixer_level(cmd & 0xff, &data);
528
		return ioctl_return2((int *)(arg), data);
529
        }
530
531
	switch(cmd) {
532
	case SOUND_MIXER_READ_DEVMASK:
533
		data = tas_supported_mixers() | SOUND_MASK_SPEAKER;
534
		rc = IOCTL_OUT(arg, data);
535
		break;
536
	case SOUND_MIXER_READ_STEREODEVS:
537
		data = tas_stereo_mixers();
538
		rc = IOCTL_OUT(arg, data);
539
		break;
540
	case SOUND_MIXER_READ_CAPS:
541
		rc = IOCTL_OUT(arg, 0);
542
		break;
543
	case SOUND_MIXER_READ_RECMASK:
544
		data = 0;
545
		rc = IOCTL_OUT(arg, data);
546
		break;
547
	case SOUND_MIXER_READ_RECSRC:
548
		data = 0;
549
		rc = IOCTL_OUT(arg, data);
550
		break;
551
	case SOUND_MIXER_WRITE_RECSRC:
552
 		IOCTL_IN(arg, data);
553
		data =0;
554
 		rc = IOCTL_OUT(arg, data);
555
 		break;
556
	case SOUND_MIXER_WRITE_SPEAKER:	/* really bell volume */
557
 		IOCTL_IN(arg, data);
558
 		beep_vol = data & 0xff;
559
 		/* fall through */
560
	case SOUND_MIXER_READ_SPEAKER:
561
		rc = IOCTL_OUT(arg, (beep_vol<<8) | beep_vol);
562
 		break;
563
	case SOUND_MIXER_OUTMASK:
564
	case SOUND_MIXER_OUTSRC:
565
	default:
566
		rc = -EINVAL;
567
	}
568
569
	return rc;
570
}
571
572
static void __init
573
tas_init_frame_rates(unsigned int *prop, unsigned int l)
574
{
575
	int i ;
576
	if (prop) {
577
		for (i=0; i<1; i++)
578
			tas_freqs_ok[i] = 0;
579
		for (l /= sizeof(int); l > 0; --l) {
580
			unsigned int r = *prop++;
581
			/* Apple 'Fixed' format */
582
			if (r >= 0x10000)
583
				r >>= 16;
584
			for (i = 0; i < 1; ++i) {
585
				if (r == tas_freqs[i]) {
586
					tas_freqs_ok[i] = 1;
587
					break;
588
				}
589
			}
590
		}
591
	}
592
	/* else we assume that all the rates are available */
593
}
594
595
596
/*** AE - TUMBLER / SNAPPER END ************************************************/
481
597
482
598
483
599
Lines 509-516 Link Here
509
625
510
static int __init PMacIrqInit(void)
626
static int __init PMacIrqInit(void)
511
{
627
{
512
	if (request_irq(awacs_irq, pmac_awacs_intr, 0, "Built-in Sound misc", 0)
628
	if (awacs)
513
	    || request_irq(awacs_tx_irq, pmac_awacs_tx_intr, 0, "Built-in Sound out", 0)
629
		if (request_irq(awacs_irq, pmac_awacs_intr, 0, "Built-in Sound misc", 0))
630
			return 0;
631
	if (request_irq(awacs_tx_irq, pmac_awacs_tx_intr, 0, "Built-in Sound out", 0)
514
	    || request_irq(awacs_rx_irq, pmac_awacs_rx_intr, 0, "Built-in Sound in", 0))
632
	    || request_irq(awacs_rx_irq, pmac_awacs_rx_intr, 0, "Built-in Sound in", 0))
515
		return 0;
633
		return 0;
516
	return 1;
634
	return 1;
Lines 523-545 Link Here
523
	DBDMA_DO_STOP(awacs_txdma);
641
	DBDMA_DO_STOP(awacs_txdma);
524
	DBDMA_DO_STOP(awacs_rxdma);
642
	DBDMA_DO_STOP(awacs_rxdma);
525
643
526
	/* disable interrupts from awacs interface */
644
	if (awacs)
527
	out_le32(&awacs->control, in_le32(&awacs->control) & 0xfff);
645
		/* disable interrupts from awacs interface */
528
646
		out_le32(&awacs->control, in_le32(&awacs->control) & 0xfff);
647
	
529
	/* Switch off the sound clock */
648
	/* Switch off the sound clock */
530
	pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, awacs_node, 0, 0);
649
	pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, awacs_node, 0, 0);
531
	/* Make sure proper bits are set on pismo & tipb */
650
	/* Make sure proper bits are set on pismo & tipb */
532
	if (machine_is_compatible("PowerBook3,1") ||
651
	if ((machine_is_compatible("PowerBook3,1") ||
533
	    machine_is_compatible("PowerBook3,2")) {
652
	    machine_is_compatible("PowerBook3,2")) && awacs) {
534
		awacs_reg[1] |= MASK_PAROUT0 | MASK_PAROUT1;
653
		awacs_reg[1] |= MASK_PAROUT0 | MASK_PAROUT1;
535
		awacs_write(MASK_ADDR1 | awacs_reg[1]);
654
		awacs_write(MASK_ADDR1 | awacs_reg[1]);
536
		wait_ms(200);
655
		wait_ms(200);
537
	}
656
	}
538
	free_irq(awacs_irq, 0);
657
	if (awacs)
658
		free_irq(awacs_irq, 0);
539
	free_irq(awacs_tx_irq, 0);
659
	free_irq(awacs_tx_irq, 0);
540
	free_irq(awacs_rx_irq, 0);
660
	free_irq(awacs_rx_irq, 0);
541
	/* all OF versions I've seen use this value */
661
	
542
	iounmap((void *)awacs);
662
	if (awacs)
663
		iounmap((void *)awacs);
664
	if (i2s)
665
		iounmap((void *)i2s);
543
	iounmap((void *)awacs_txdma);
666
	iounmap((void *)awacs_txdma);
544
	iounmap((void *)awacs_rxdma);
667
	iounmap((void *)awacs_rxdma);
545
668
Lines 555-561 Link Here
555
		kfree(beep_dbdma_cmd_space);
678
		kfree(beep_dbdma_cmd_space);
556
	if (beep_buf) {
679
	if (beep_buf) {
557
		kfree(beep_buf);
680
		kfree(beep_buf);
681
#ifdef CONFIG_VT
558
		kd_mksound = orig_mksound;
682
		kd_mksound = orig_mksound;
683
#endif		
559
	}
684
	}
560
#ifdef CONFIG_PMAC_PBOOK
685
#ifdef CONFIG_PMAC_PBOOK
561
	pmu_unregister_sleep_notifier(&awacs_sleep_notifier);
686
	pmu_unregister_sleep_notifier(&awacs_sleep_notifier);
Lines 569-594 Link Here
569
	DBDMA_DO_STOP(awacs_txdma);
694
	DBDMA_DO_STOP(awacs_txdma);
570
}
695
}
571
696
572
static int tumbler_freqs[2] = { 48000, 44100 } ;
573
static int tumbler_freqs_ok[2] = { 1, 1 } ;
574
575
/* don't know what to do really - just have to leave it where
576
 * OF left things
577
*/
578
579
static int tumbler_set_frame_rate(void)
580
{
581
	dmasound.hard.speed = 44100 ;
582
	awacs_rate_index = 0 ;
583
	return 44100 ;
584
}
585
586
/* don't know what to do really - just have to leave it where
697
/* don't know what to do really - just have to leave it where
587
 * OF left things
698
 * OF left things
588
*/
699
*/
589
700
590
static int daca_set_frame_rate(void)
701
static int daca_set_frame_rate(void)
591
{
702
{
703
	if (i2s) {
704
		out_le32(i2s + (I2S_REG_SERIAL_FORMAT >> 2), 0x41190000);
705
		out_le32(i2s + (I2S_REG_DATAWORD_SIZES >> 2), 0x02000200);
706
	}
592
	dmasound.hard.speed = 44100 ;
707
	dmasound.hard.speed = 44100 ;
593
	awacs_rate_index = 0 ;
708
	awacs_rate_index = 0 ;
594
	return 44100 ;
709
	return 44100 ;
Lines 599-605 Link Here
599
};
714
};
600
static int awacs_freqs_ok[8] = { 1, 1, 1, 1, 1, 1, 1, 1 };
715
static int awacs_freqs_ok[8] = { 1, 1, 1, 1, 1, 1, 1, 1 };
601
716
602
static int awacs_set_frame_rate(int desired, int catch_r)
717
static int
718
awacs_set_frame_rate(int desired, int catch_r)
603
{
719
{
604
	int tolerance, i = 8 ;
720
	int tolerance, i = 8 ;
605
	/*
721
	/*
Lines 623-635 Link Here
623
	return dmasound.hard.speed;
739
	return dmasound.hard.speed;
624
}
740
}
625
741
626
static int burgundy_frame_rates = 1 ;
742
static int
627
static int burgundy_set_frame_rate(void)
743
burgundy_set_frame_rate(void)
628
{
744
{
629
#ifdef DEBUG_DMASOUND
630
if (burgundy_frame_rates > 1)
631
	printk("dmasound_pmac: warning Burgundy had more than one frame rate\n");
632
#endif
633
	awacs_rate_index = 0 ;
745
	awacs_rate_index = 0 ;
634
	awacs_reg[1] = (awacs_reg[1] & ~MASK_SAMPLERATE) ;
746
	awacs_reg[1] = (awacs_reg[1] & ~MASK_SAMPLERATE) ;
635
	/* XXX disable error interrupt on burgundy for now */
747
	/* XXX disable error interrupt on burgundy for now */
Lines 637-660 Link Here
637
	return 44100 ;
749
	return 44100 ;
638
}
750
}
639
751
640
static int set_frame_rate(int desired, int catch_r)
752
static int
753
set_frame_rate(int desired, int catch_r)
641
{
754
{
642
	switch (awacs_revision) {
755
	switch (awacs_revision) {
643
		case AWACS_BURGUNDY:
756
		case AWACS_BURGUNDY:
644
			dmasound.hard.speed =
757
			dmasound.hard.speed = burgundy_set_frame_rate();
645
			  burgundy_set_frame_rate();
646
			break ;
758
			break ;
647
		case AWACS_TUMBLER:
759
		case AWACS_TUMBLER:
648
			dmasound.hard.speed =
760
		case AWACS_SNAPPER:
649
			  tumbler_set_frame_rate();
761
			dmasound.hard.speed = tas_set_frame_rate();
650
			break ;
762
			break ;
651
		case AWACS_DACA:
763
		case AWACS_DACA:
652
			dmasound.hard.speed =
764
			dmasound.hard.speed =
653
			  daca_set_frame_rate();
765
			  daca_set_frame_rate();
654
			break ;
766
			break ;
655
		default:
767
		default:
656
			dmasound.hard.speed =
768
			dmasound.hard.speed = awacs_set_frame_rate(desired,
657
			  awacs_set_frame_rate(desired, catch_r);
769
						catch_r);
658
			break ;
770
			break ;
659
	}
771
	}
660
	return dmasound.hard.speed ;
772
	return dmasound.hard.speed ;
Lines 704-714 Link Here
704
		dmasound.trans_write = &transAwacsExpand;
816
		dmasound.trans_write = &transAwacsExpand;
705
	dmasound.trans_read = &transAwacsNormalRead;
817
	dmasound.trans_read = &transAwacsNormalRead;
706
818
707
	if (hw_can_byteswap && (dmasound.hard.format == AFMT_S16_LE))
819
	if (awacs) {
708
		out_le32(&awacs->byteswap, BS_VAL);
820
		if (hw_can_byteswap && (dmasound.hard.format == AFMT_S16_LE))
709
	else
821
			out_le32(&awacs->byteswap, BS_VAL);
710
		out_le32(&awacs->byteswap, 0);
822
		else
711
823
			out_le32(&awacs->byteswap, 0);
824
	}
825
	
712
	expand_bal = -dmasound.soft.speed;
826
	expand_bal = -dmasound.soft.speed;
713
}
827
}
714
828
Lines 793-799 Link Here
793
907
794
static int PMacSetVolume(int volume)
908
static int PMacSetVolume(int volume)
795
{
909
{
796
	return awacs_volume_setter(volume, 2, MASK_AMUTE, 6);
910
	printk(KERN_WARNING "Bogus call to PMacSetVolume !\n");
911
	return 0;
912
}
913
914
static void awacs_setup_for_beep(int speed)
915
{
916
	out_le32(&awacs->control,
917
		 (in_le32(&awacs->control) & ~0x1f00)
918
		 | ((speed > 0 ? speed : awacs_rate_index) << 8));
919
920
	if (hw_can_byteswap && (dmasound.hard.format == AFMT_S16_LE) && speed == -1)
921
		out_le32(&awacs->byteswap, BS_VAL);
922
	else
923
		out_le32(&awacs->byteswap, 0);
797
}
924
}
798
925
799
static void __PMacPlay(void)
926
static void __PMacPlay(void)
Lines 816-830 Link Here
816
		out_le32(&awacs_txdma->control, (RUN|PAUSE|FLUSH|WAKE) << 16);
943
		out_le32(&awacs_txdma->control, (RUN|PAUSE|FLUSH|WAKE) << 16);
817
		while ( (in_le32(&awacs_txdma->status) & RUN) && count--)
944
		while ( (in_le32(&awacs_txdma->status) & RUN) && count--)
818
			udelay(1);
945
			udelay(1);
819
		/* FIXME: check that this is OK for other chip sets */
946
		if (awacs)
820
		out_le32(&awacs->control,
947
			awacs_setup_for_beep(-1);
821
			 (in_le32(&awacs->control) & ~0x1f00)
822
			 | (awacs_rate_index << 8));
823
824
		if (hw_can_byteswap && (dmasound.hard.format == AFMT_S16_LE))
825
			out_le32(&awacs->byteswap, BS_VAL);
826
		else
827
			out_le32(&awacs->byteswap, 0);
828
		out_le32(&awacs_txdma->cmdptr,
948
		out_le32(&awacs_txdma->cmdptr,
829
			 virt_to_bus(&(awacs_tx_cmds[next_frg])));
949
			 virt_to_bus(&(awacs_tx_cmds[next_frg])));
830
950
Lines 925-930 Link Here
925
{
1045
{
926
	int i = write_sq.front;
1046
	int i = write_sq.front;
927
	int stat;
1047
	int stat;
1048
	int i_nowrap = write_sq.front;
928
	volatile struct dbdma_cmd *cp;
1049
	volatile struct dbdma_cmd *cp;
929
	/* != 0 when we are dealing with a DEAD xfer */
1050
	/* != 0 when we are dealing with a DEAD xfer */
930
	static int emergency_in_use = 0 ;
1051
	static int emergency_in_use = 0 ;
Lines 981-986 Link Here
981
			emergency_in_use = 0 ; /* done that */
1102
			emergency_in_use = 0 ; /* done that */
982
		--write_sq.count;
1103
		--write_sq.count;
983
		--write_sq.active;
1104
		--write_sq.active;
1105
		i_nowrap++;
984
		if (++i >= write_sq.max_count)
1106
		if (++i >= write_sq.max_count)
985
			i = 0;
1107
			i = 0;
986
	}
1108
	}
Lines 993-999 Link Here
993
	}
1115
	}
994
1116
995
	/* if we used some data up then wake the writer to supply some more*/
1117
	/* if we used some data up then wake the writer to supply some more*/
996
	if (i != write_sq.front)
1118
	if (i_nowrap != write_sq.front)
997
		WAKE_UP(write_sq.action_queue);
1119
		WAKE_UP(write_sq.action_queue);
998
	write_sq.front = i;
1120
	write_sq.front = i;
999
1121
Lines 1090-1098 Link Here
1090
pmac_awacs_intr(int irq, void *devid, struct pt_regs *regs)
1212
pmac_awacs_intr(int irq, void *devid, struct pt_regs *regs)
1091
{
1213
{
1092
	int ctrl = in_le32(&awacs->control);
1214
	int ctrl = in_le32(&awacs->control);
1215
	int status = in_le32(&awacs->codec_stat);
1216
	int r1;
1093
1217
1094
	if (ctrl & MASK_PORTCHG) {
1218
 	if (ctrl & MASK_PORTCHG) {
1095
		/* do something when headphone is plugged/unplugged? */
1219
		/* tested on Screamer, should work on others too */
1220
		if (awacs_revision == AWACS_SCREAMER) {
1221
			if (((status & MASK_HDPCONN) >> 3) && (hdp_connected == 0)) {
1222
				hdp_connected = 1;
1223
				
1224
				r1 = awacs_reg[1] | MASK_SPKMUTE;
1225
				awacs_reg[1] = r1;
1226
				awacs_write(r1 | MASK_ADDR_MUTE);
1227
			} else if (((status & MASK_HDPCONN) >> 3 == 0) && (hdp_connected == 1)) {
1228
				hdp_connected = 0;
1229
				
1230
				r1 = awacs_reg[1] & ~MASK_SPKMUTE;
1231
				awacs_reg[1] = r1;
1232
				awacs_write(r1 | MASK_ADDR_MUTE);
1233
			}
1234
		}
1096
	}
1235
	}
1097
	if (ctrl & MASK_CNTLERR) {
1236
	if (ctrl & MASK_CNTLERR) {
1098
		int err = (in_le32(&awacs->codec_stat) & MASK_ERRCODE) >> 16;
1237
		int err = (in_le32(&awacs->codec_stat) & MASK_ERRCODE) >> 16;
Lines 1108-1114 Link Here
1108
awacs_write(int val)
1247
awacs_write(int val)
1109
{
1248
{
1110
	int count = 300 ;
1249
	int count = 300 ;
1111
	if (awacs_revision >= AWACS_DACA)
1250
	if (awacs_revision >= AWACS_DACA || !awacs)
1112
		return ;
1251
		return ;
1113
1252
1114
	while ((in_le32(&awacs->codec_ctrl) & MASK_NEWECMD) && count--)
1253
	while ((in_le32(&awacs->codec_ctrl) & MASK_NEWECMD) && count--)
Lines 1131-1144 Link Here
1131
		out_le32(&awacs_txdma->control, (RUN|PAUSE|FLUSH|WAKE) << 16);
1270
		out_le32(&awacs_txdma->control, (RUN|PAUSE|FLUSH|WAKE) << 16);
1132
		while ((in_le32(&awacs_txdma->status) & RUN) && count--)
1271
		while ((in_le32(&awacs_txdma->status) & RUN) && count--)
1133
			udelay(1);
1272
			udelay(1);
1134
		/* FIXME: check this is OK for DACA, Tumbler */
1273
		if (awacs)
1135
		out_le32(&awacs->control,
1274
			awacs_setup_for_beep(-1);
1136
			 (in_le32(&awacs->control) & ~0x1f00)
1137
			 | (awacs_rate_index << 8));
1138
		if (hw_can_byteswap && (dmasound.hard.format == AFMT_S16_LE))
1139
			out_le32(&awacs->byteswap, BS_VAL);
1140
		else
1141
			out_le32(&awacs->byteswap, 0);
1142
		beep_playing = 0;
1275
		beep_playing = 0;
1143
	}
1276
	}
1144
	restore_flags(flags);
1277
	restore_flags(flags);
Lines 1233-1243 Link Here
1233
		out_le32(&awacs_txdma->control, (RUN|WAKE|FLUSH|PAUSE) << 16);
1366
		out_le32(&awacs_txdma->control, (RUN|WAKE|FLUSH|PAUSE) << 16);
1234
		while ((in_le32(&awacs_txdma->status) & RUN) && count--)
1367
		while ((in_le32(&awacs_txdma->status) & RUN) && count--)
1235
			udelay(1); /* timeout > 2 samples at lowest rate*/
1368
			udelay(1); /* timeout > 2 samples at lowest rate*/
1236
		/* FIXME: check this is OK on DACA, Tumbler */
1369
		if (awacs)
1237
		out_le32(&awacs->control,
1370
			awacs_setup_for_beep(beep_speed);
1238
			 (in_le32(&awacs->control) & ~0x1f00)
1239
			 | (beep_speed << 8));
1240
		out_le32(&awacs->byteswap, 0); /* force BE */
1241
		out_le32(&awacs_txdma->cmdptr, virt_to_bus(beep_dbdma_cmd));
1371
		out_le32(&awacs_txdma->cmdptr, virt_to_bus(beep_dbdma_cmd));
1242
		(void)in_le32(&awacs_txdma->status);
1372
		(void)in_le32(&awacs_txdma->status);
1243
		out_le32(&awacs_txdma->control, RUN | (RUN << 16));
1373
		out_le32(&awacs_txdma->control, RUN | (RUN << 16));
Lines 1263-1272 Link Here
1263
		awacs_write(awacs_reg[1] + MASK_ADDR1);
1393
		awacs_write(awacs_reg[1] + MASK_ADDR1);
1264
		awacs_write(awacs_reg[7] + MASK_ADDR7);
1394
		awacs_write(awacs_reg[7] + MASK_ADDR7);
1265
	}
1395
	}
1266
	if (hw_can_byteswap && (dmasound.hard.format == AFMT_S16_LE))
1396
	if (awacs) {
1267
		out_le32(&awacs->byteswap, BS_VAL);
1397
		if (hw_can_byteswap && (dmasound.hard.format == AFMT_S16_LE))
1268
	else
1398
			out_le32(&awacs->byteswap, BS_VAL);
1269
		out_le32(&awacs->byteswap, 0);
1399
		else
1400
			out_le32(&awacs->byteswap, 0);
1401
	}
1270
}
1402
}
1271
1403
1272
#ifdef CONFIG_PMAC_PBOOK
1404
#ifdef CONFIG_PMAC_PBOOK
Lines 1293-1301 Link Here
1293
		/* stop rx - if going - a bit of a daft user... but */
1425
		/* stop rx - if going - a bit of a daft user... but */
1294
		out_le32(&awacs_rxdma->control, (RUN|WAKE|FLUSH << 16));
1426
		out_le32(&awacs_rxdma->control, (RUN|WAKE|FLUSH << 16));
1295
		/* deny interrupts */
1427
		/* deny interrupts */
1428
		if (awacs)
1429
			disable_irq(awacs_irq);
1430
		disable_irq(awacs_tx_irq);
1431
		disable_irq(awacs_rx_irq);
1432
		/* Chip specific sleep code */
1296
		switch (awacs_revision) {
1433
		switch (awacs_revision) {
1297
			case AWACS_TUMBLER:
1434
			case AWACS_TUMBLER:
1298
				tumbler_enter_sleep(); /* Stub for now */
1435
			case AWACS_SNAPPER:
1436
				write_audio_gpio(gpio_headphone_mute, gpio_headphone_mute_pol);
1437
				write_audio_gpio(gpio_amp_mute, gpio_amp_mute_pol);
1438
				tas_enter_sleep();
1439
				write_audio_gpio(gpio_audio_reset, gpio_audio_reset_pol);
1299
				break ;
1440
				break ;
1300
			case AWACS_DACA:
1441
			case AWACS_DACA:
1301
				daca_enter_sleep();
1442
				daca_enter_sleep();
Lines 1308-1324 Link Here
1308
				out_le32(&awacs->control, 0x11) ;
1449
				out_le32(&awacs->control, 0x11) ;
1309
				break ;
1450
				break ;
1310
		}
1451
		}
1311
		disable_irq(awacs_irq);
1312
		disable_irq(awacs_tx_irq);
1313
		disable_irq(awacs_rx_irq);
1314
		/* Disable sound clock */
1452
		/* Disable sound clock */
1315
		pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, awacs_node, 0, 0);
1453
		pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, awacs_node, 0, 0);
1316
		/* According to Darwin, we do that after turning off the sound
1454
		/* According to Darwin, we do that after turning off the sound
1317
		 * chip clock. All this will have to be cleaned up once we properly
1455
		 * chip clock. All this will have to be cleaned up once we properly
1318
		 * parse the OF sound-objects
1456
		 * parse the OF sound-objects
1319
		 */
1457
		 */
1320
		if (machine_is_compatible("PowerBook3,1") ||
1458
		if ((machine_is_compatible("PowerBook3,1") ||
1321
		    machine_is_compatible("PowerBook3,2")) {
1459
		    machine_is_compatible("PowerBook3,2")) && awacs) {
1322
			awacs_reg[1] |= MASK_PAROUT0 | MASK_PAROUT1;
1460
			awacs_reg[1] |= MASK_PAROUT0 | MASK_PAROUT1;
1323
			awacs_write(MASK_ADDR1 | awacs_reg[1]);
1461
			awacs_write(MASK_ADDR1 | awacs_reg[1]);
1324
			wait_ms(200);
1462
			wait_ms(200);
Lines 1327-1334 Link Here
1327
	case PBOOK_WAKE:
1465
	case PBOOK_WAKE:
1328
		/* Enable sound clock */
1466
		/* Enable sound clock */
1329
		pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, awacs_node, 0, 1);
1467
		pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, awacs_node, 0, 1);
1330
		if (machine_is_compatible("PowerBook3,1") ||
1468
		if ((machine_is_compatible("PowerBook3,1") ||
1331
		    machine_is_compatible("PowerBook3,2")) {
1469
		    machine_is_compatible("PowerBook3,2")) && awacs) {
1332
			wait_ms(100);
1470
			wait_ms(100);
1333
			awacs_reg[1] &= ~(MASK_PAROUT0 | MASK_PAROUT1);
1471
			awacs_reg[1] &= ~(MASK_PAROUT0 | MASK_PAROUT1);
1334
			awacs_write(MASK_ADDR1 | awacs_reg[1]);
1472
			awacs_write(MASK_ADDR1 | awacs_reg[1]);
Lines 1338-1345 Link Here
1338
 		/* restore settings */
1476
 		/* restore settings */
1339
		switch (awacs_revision) {
1477
		switch (awacs_revision) {
1340
			case AWACS_TUMBLER:
1478
			case AWACS_TUMBLER:
1479
			case AWACS_SNAPPER:
1480
				write_audio_gpio(gpio_headphone_mute, gpio_headphone_mute_pol);
1481
				write_audio_gpio(gpio_amp_mute, gpio_amp_mute_pol);
1482
				write_audio_gpio(gpio_audio_reset, gpio_audio_reset_pol);
1483
				wait_ms(100);
1484
				write_audio_gpio(gpio_audio_reset, !gpio_audio_reset_pol);
1485
				wait_ms(150);
1486
				tas_leave_sleep(); /* Stub for now */
1341
				headphone_intr(0,0,0);
1487
				headphone_intr(0,0,0);
1342
				tumbler_leave_sleep(); /* Stub for now */
1343
				break;
1488
				break;
1344
			case AWACS_DACA:
1489
			case AWACS_DACA:
1345
				wait_ms(10); /* Check this !!! */
1490
				wait_ms(10); /* Check this !!! */
Lines 1354-1370 Link Here
1354
				break ;
1499
				break ;
1355
		}
1500
		}
1356
		/* Recalibrate chip */
1501
		/* Recalibrate chip */
1357
		if (awacs_revision == AWACS_SCREAMER)
1502
		if (awacs_revision == AWACS_SCREAMER && awacs)
1358
			awacs_recalibrate();
1503
			awacs_recalibrate();
1359
		/* Make sure dma is stopped */
1504
		/* Make sure dma is stopped */
1360
		PMacSilence();
1505
		PMacSilence();
1361
		enable_irq(awacs_irq);
1506
		if (awacs)
1507
			enable_irq(awacs_irq);
1362
		enable_irq(awacs_tx_irq);
1508
		enable_irq(awacs_tx_irq);
1363
 		enable_irq(awacs_rx_irq);
1509
 		enable_irq(awacs_rx_irq);
1364
 		/* OK, allow ints back again */
1510
 		if (awacs) {
1365
 		out_le32(&awacs->control, MASK_IEPC
1511
 			/* OK, allow ints back again */
1366
 		 	| (awacs_rate_index << 8) | 0x11
1512
	 		out_le32(&awacs->control, MASK_IEPC
1367
 			 | (awacs_revision < AWACS_DACA ? MASK_IEE: 0));
1513
 			 	| (awacs_rate_index << 8) | 0x11
1514
 				 | (awacs_revision < AWACS_DACA ? MASK_IEE: 0));
1515
 		}
1368
 		if (macio_base && is_pbook_g3) {
1516
 		if (macio_base && is_pbook_g3) {
1369
			/* FIXME: should restore the setup we had...*/
1517
			/* FIXME: should restore the setup we had...*/
1370
			out_8(macio_base + 0x37, 3);
1518
			out_8(macio_base + 0x37, 3);
Lines 1952-1958 Link Here
1952
	case SOUND_MIXER_READ_SPEAKER:
2100
	case SOUND_MIXER_READ_SPEAKER:
1953
		data = awacs_burgundy_rcb(MASK_ADDR_BURGUNDY_ATTENSPEAKER);
2101
		data = awacs_burgundy_rcb(MASK_ADDR_BURGUNDY_ATTENSPEAKER);
1954
		data = (((data & 0xf)*100)/16) + ((((data>>4)*100)/16)<<8);
2102
		data = (((data & 0xf)*100)/16) + ((((data>>4)*100)/16)<<8);
1955
		rc = IOCTL_OUT(arg, ~data);
2103
		rc = IOCTL_OUT(arg, (~data) & 0x0000ffff);
1956
		break;
2104
		break;
1957
	case SOUND_MIXER_WRITE_ALTPCM:	/* really bell volume */
2105
	case SOUND_MIXER_WRITE_ALTPCM:	/* really bell volume */
1958
		IOCTL_IN(arg, data);
2106
		IOCTL_IN(arg, data);
Lines 2007-2095 Link Here
2007
	return rc;
2155
	return rc;
2008
}
2156
}
2009
2157
2010
static int tumbler_mixer_ioctl(u_int cmd, u_long arg)
2011
{
2012
	int data;
2013
	int rc;
2014
2015
	/* We are, we are, we are... Tumbler (and very dumb) */
2016
	/* Ok, we're not THAT dumb anymore, but still pretty dumb :-) */
2017
2018
	switch(cmd) {
2019
	case SOUND_MIXER_READ_DEVMASK:
2020
		data =  SOUND_MASK_VOLUME | SOUND_MASK_ALTPCM |
2021
			SOUND_MASK_BASS | SOUND_MASK_TREBLE |
2022
			SOUND_MASK_PCM;
2023
		rc = IOCTL_OUT(arg, data);
2024
		break;
2025
	case SOUND_MIXER_READ_RECMASK:
2026
		data = 0;
2027
		rc = IOCTL_OUT(arg, data);
2028
		break;
2029
	case SOUND_MIXER_READ_RECSRC:
2030
		data = 0;
2031
		rc = IOCTL_OUT(arg, data);
2032
		break;
2033
	case SOUND_MIXER_WRITE_RECSRC:
2034
		IOCTL_IN(arg, data);
2035
		data =0;
2036
		rc = IOCTL_OUT(arg, data);
2037
		break;
2038
	case SOUND_MIXER_READ_STEREODEVS:
2039
		data = SOUND_MASK_VOLUME | SOUND_MASK_PCM;
2040
		rc = IOCTL_OUT(arg, data);
2041
		break;
2042
	case SOUND_MIXER_READ_CAPS:
2043
		rc = IOCTL_OUT(arg, 0);
2044
		break;
2045
	case SOUND_MIXER_WRITE_BASS:
2046
		IOCTL_IN(arg, data);
2047
		tumbler_set_bass(data);
2048
		/* Fall through */
2049
	case SOUND_MIXER_READ_BASS:
2050
		tumbler_get_bass(&data);
2051
		rc = IOCTL_OUT(arg, data);
2052
		break;
2053
	case SOUND_MIXER_WRITE_TREBLE:
2054
		IOCTL_IN(arg, data);
2055
		tumbler_set_treble(data);
2056
		/* Fall through */
2057
	case SOUND_MIXER_READ_TREBLE:
2058
		tumbler_get_treble(&data);
2059
		rc = IOCTL_OUT(arg, data);
2060
		break;
2061
	case SOUND_MIXER_WRITE_PCM:
2062
		IOCTL_IN(arg, data);
2063
		tumbler_set_pcm_lvl(data);
2064
		/* Fall through */
2065
	case SOUND_MIXER_READ_PCM:
2066
		tumbler_get_pcm_lvl(&data);
2067
		IOCTL_OUT(arg, data);
2068
		break;
2069
	case SOUND_MIXER_WRITE_VOLUME:
2070
		IOCTL_IN(arg, data);
2071
		tumbler_set_volume(data, data);
2072
		/* Fall through */
2073
	case SOUND_MIXER_READ_VOLUME:
2074
		tumbler_get_volume(& data, &data);
2075
		rc = IOCTL_OUT(arg, data);
2076
		break;
2077
	case SOUND_MIXER_WRITE_ALTPCM:	/* really bell volume */
2078
		IOCTL_IN(arg, data);
2079
		beep_vol = data & 0xff;
2080
		/* fall through */
2081
	case SOUND_MIXER_READ_ALTPCM:
2082
		rc = IOCTL_OUT(arg, beep_vol);
2083
		break;
2084
	case SOUND_MIXER_OUTMASK:
2085
	case SOUND_MIXER_OUTSRC:
2086
	default:
2087
		rc = -EINVAL;
2088
	}
2089
2090
	return rc;
2091
}
2092
2093
static int daca_mixer_ioctl(u_int cmd, u_long arg)
2158
static int daca_mixer_ioctl(u_int cmd, u_long arg)
2094
{
2159
{
2095
	int data;
2160
	int data;
Lines 2154-2160 Link Here
2154
			rc = daca_mixer_ioctl(cmd, arg);
2219
			rc = daca_mixer_ioctl(cmd, arg);
2155
			break;
2220
			break;
2156
		case AWACS_TUMBLER:
2221
		case AWACS_TUMBLER:
2157
			rc = tumbler_mixer_ioctl(cmd, arg);
2222
		case AWACS_SNAPPER:
2223
			rc = tas_mixer_ioctl(cmd, arg);
2158
			break ;
2224
			break ;
2159
		default: /* ;-)) */
2225
		default: /* ;-)) */
2160
			rc = awacs_mixer_ioctl(cmd, arg);
2226
			rc = awacs_mixer_ioctl(cmd, arg);
Lines 2171-2177 Link Here
2171
		case AWACS_TUMBLER:
2237
		case AWACS_TUMBLER:
2172
		  printk("AE-Init tumbler mixer\n");
2238
		  printk("AE-Init tumbler mixer\n");
2173
		  break ;
2239
		  break ;
2174
		  
2240
		case AWACS_SNAPPER:
2241
		  printk("AE-Init snapper mixer\n");
2242
		  break ;
2175
		case AWACS_DACA:
2243
		case AWACS_DACA:
2176
		case AWACS_BURGUNDY:
2244
		case AWACS_BURGUNDY:
2177
			break ;	/* don't know yet */
2245
			break ;	/* don't know yet */
Lines 2362-2373 Link Here
2362
			len += sprintf(b,"44100 ") ;
2430
			len += sprintf(b,"44100 ") ;
2363
			break ;
2431
			break ;
2364
		case AWACS_TUMBLER:
2432
		case AWACS_TUMBLER:
2365
			for (i=0; i<2; i++){
2433
		case AWACS_SNAPPER:
2366
				if (tumbler_freqs_ok[i])
2434
			for (i=0; i<1; i++){
2367
					len += sprintf(b+len,"%d ", tumbler_freqs[i]) ;
2435
				if (tas_freqs_ok[i])
2436
					len += sprintf(b+len,"%d ", tas_freqs[i]) ;
2368
			}
2437
			}
2369
			break ;
2438
			break ;
2370
2371
		case AWACS_AWACS:
2439
		case AWACS_AWACS:
2372
		case AWACS_SCREAMER:
2440
		case AWACS_SCREAMER:
2373
		default:
2441
		default:
Lines 2469-2476 Link Here
2469
  code that looks for chip properties knows how to go about it.
2537
  code that looks for chip properties knows how to go about it.
2470
*/
2538
*/
2471
2539
2472
static struct device_node
2540
static struct device_node* __init
2473
__init *get_snd_io_node(void)
2541
get_snd_io_node(void)
2474
{
2542
{
2475
	struct device_node *np = NULL;
2543
	struct device_node *np = NULL;
2476
2544
Lines 2491-2497 Link Here
2491
	 * this seems to be what iBooks (& Tumbler) have.
2559
	 * this seems to be what iBooks (& Tumbler) have.
2492
	 */
2560
	 */
2493
	if (np == NULL)
2561
	if (np == NULL)
2494
		np = find_devices("i2s-a");
2562
		np = i2s_node = find_devices("i2s-a");
2495
2563
2496
	/* if we didn't find this - perhaps we are on an early model
2564
	/* if we didn't find this - perhaps we are on an early model
2497
	 * which _only_ has an 'awacs' node
2565
	 * which _only_ has an 'awacs' node
Lines 2511-2518 Link Here
2511
   we have to deduce the info other ways for these.
2579
   we have to deduce the info other ways for these.
2512
*/
2580
*/
2513
2581
2514
static struct device_node
2582
static struct device_node* __init
2515
__init *get_snd_info_node(struct device_node *io)
2583
get_snd_info_node(struct device_node *io)
2516
{
2584
{
2517
	struct device_node *info;
2585
	struct device_node *info;
2518
2586
Lines 2526-2533 Link Here
2526
/* Find out what type of codec we have.
2594
/* Find out what type of codec we have.
2527
*/
2595
*/
2528
2596
2529
static int
2597
static int __init
2530
__init get_codec_type(struct device_node *info)
2598
get_codec_type(struct device_node *info)
2531
{
2599
{
2532
	/* already set if pre-davbus model and info will be NULL */
2600
	/* already set if pre-davbus model and info will be NULL */
2533
	int codec = awacs_revision ;
2601
	int codec = awacs_revision ;
Lines 2544-2557 Link Here
2544
			codec = AWACS_DACA;
2612
			codec = AWACS_DACA;
2545
		if (device_is_compatible(info, "tumbler"))
2613
		if (device_is_compatible(info, "tumbler"))
2546
			codec = AWACS_TUMBLER;
2614
			codec = AWACS_TUMBLER;
2615
		if (device_is_compatible(info, "snapper"))
2616
			codec = AWACS_SNAPPER;
2547
	}
2617
	}
2548
	return codec ;
2618
	return codec ;
2549
}
2619
}
2550
2620
2551
/* find out what type, if any, of expansion card we have
2621
/* find out what type, if any, of expansion card we have
2552
*/
2622
*/
2553
static void
2623
static void __init
2554
__init get_expansion_type(void)
2624
get_expansion_type(void)
2555
{
2625
{
2556
	if (find_devices("perch") != NULL)
2626
	if (find_devices("perch") != NULL)
2557
		has_perch = 1;
2627
		has_perch = 1;
Lines 2569-2576 Link Here
2569
 *       Set dmasound.mach.max_dsp_rate on the basis of these routines.
2639
 *       Set dmasound.mach.max_dsp_rate on the basis of these routines.
2570
*/
2640
*/
2571
2641
2572
static void
2642
static void __init
2573
__init init_awacs_frame_rates(unsigned int *prop, unsigned int l)
2643
awacs_init_frame_rates(unsigned int *prop, unsigned int l)
2574
{
2644
{
2575
	int i ;
2645
	int i ;
2576
	if (prop) {
2646
	if (prop) {
Lines 2592-2622 Link Here
2592
	/* else we assume that all the rates are available */
2662
	/* else we assume that all the rates are available */
2593
}
2663
}
2594
2664
2595
static void
2665
static void __init
2596
__init init_tumbler_frame_rates(unsigned int *prop, unsigned int l)
2666
burgundy_init_frame_rates(unsigned int *prop, unsigned int l)
2597
{
2598
	int i ;
2599
	if (prop) {
2600
		for (i=0; i<2; i++)
2601
			tumbler_freqs_ok[i] = 0;
2602
		for (l /= sizeof(int); l > 0; --l) {
2603
			unsigned int r = *prop++;
2604
			/* Apple 'Fixed' format */
2605
			if (r >= 0x10000)
2606
				r >>= 16;
2607
			for (i = 0; i < 2; ++i) {
2608
				if (r == tumbler_freqs[i]) {
2609
					tumbler_freqs_ok[i] = 1;
2610
					break;
2611
				}
2612
			}
2613
		}
2614
	}
2615
	/* else we assume that all the rates are available */
2616
}
2617
2618
static void
2619
__init init_burgundy_frame_rates(unsigned int *prop, unsigned int l)
2620
{
2667
{
2621
	int temp[9] ;
2668
	int temp[9] ;
2622
	int i = 0 ;
2669
	int i = 0 ;
Lines 2641-2648 Link Here
2641
#endif
2688
#endif
2642
}
2689
}
2643
2690
2644
static void
2691
static void __init
2645
__init init_daca_frame_rates(unsigned int *prop, unsigned int l)
2692
daca_init_frame_rates(unsigned int *prop, unsigned int l)
2646
{
2693
{
2647
	int temp[9] ;
2694
	int temp[9] ;
2648
	int i = 0 ;
2695
	int i = 0 ;
Lines 2668-2688 Link Here
2668
#endif
2715
#endif
2669
}
2716
}
2670
2717
2671
static void
2718
static void __init
2672
__init init_frame_rates(unsigned int *prop, unsigned int l)
2719
init_frame_rates(unsigned int *prop, unsigned int l)
2673
{
2720
{
2674
	switch (awacs_revision){
2721
	switch (awacs_revision) {
2675
		case AWACS_TUMBLER:
2722
		case AWACS_TUMBLER:
2676
			init_tumbler_frame_rates(prop, l);
2723
		case AWACS_SNAPPER:
2724
			tas_init_frame_rates(prop, l);
2677
			break ;
2725
			break ;
2678
		case AWACS_DACA:
2726
		case AWACS_DACA:
2679
			init_daca_frame_rates(prop, l);
2727
			daca_init_frame_rates(prop, l);
2680
			break ;
2728
			break ;
2681
		case AWACS_BURGUNDY:
2729
		case AWACS_BURGUNDY:
2682
			init_burgundy_frame_rates(prop, l);
2730
			burgundy_init_frame_rates(prop, l);
2683
			break ;
2731
			break ;
2684
		default: /* ;-))) */
2732
		default:
2685
			init_awacs_frame_rates(prop, l);
2733
			awacs_init_frame_rates(prop, l);
2686
			break ;
2734
			break ;
2687
	}
2735
	}
2688
}
2736
}
Lines 2690-2700 Link Here
2690
/* find things/machines that can't do mac-io byteswap
2738
/* find things/machines that can't do mac-io byteswap
2691
*/
2739
*/
2692
2740
2693
static void
2741
static void __init
2694
__init set_hw_byteswap(struct device_node *io)
2742
set_hw_byteswap(struct device_node *io)
2695
{
2743
{
2696
	struct device_node *mio ;
2744
	struct device_node *mio ;
2697
	unsigned int *p, kl = 0 ;
2745
	unsigned int kl = 0 ;
2698
2746
2699
	/* if seems that Keylargo can't byte-swap  */
2747
	/* if seems that Keylargo can't byte-swap  */
2700
2748
Lines 2741-2749 Link Here
2741
		if( beep_dbdma_cmd_space ) kfree(beep_dbdma_cmd_space) ;
2789
		if( beep_dbdma_cmd_space ) kfree(beep_dbdma_cmd_space) ;
2742
		return -ENOMEM ;
2790
		return -ENOMEM ;
2743
	}
2791
	}
2792
#ifdef CONFIG_VT
2744
	/* OK, we should be safe to claim the mksound vector now */
2793
	/* OK, we should be safe to claim the mksound vector now */
2745
	orig_mksound = kd_mksound;
2794
	orig_mksound = kd_mksound;
2746
	kd_mksound = awacs_mksound;
2795
	kd_mksound = awacs_mksound;
2796
#endif
2747
	return 0 ;
2797
	return 0 ;
2748
}
2798
}
2749
2799
Lines 2839-2861 Link Here
2839
	}
2889
	}
2840
2890
2841
	/* all OF versions I've seen use this value */
2891
	/* all OF versions I've seen use this value */
2842
	awacs = (volatile struct awacs_regs *)
2892
	if (i2s_node)
2843
		ioremap(io->addrs[0].address, 0x1000);
2893
		i2s = (u32 *)ioremap(io->addrs[0].address, 0x1000);
2894
	else
2895
		awacs = (volatile struct awacs_regs *)
2896
			ioremap(io->addrs[0].address, 0x1000);
2844
	awacs_txdma = (volatile struct dbdma_regs *)
2897
	awacs_txdma = (volatile struct dbdma_regs *)
2845
		ioremap(io->addrs[1].address, 0x100);
2898
		ioremap(io->addrs[1].address, 0x100);
2846
	awacs_rxdma = (volatile struct dbdma_regs *)
2899
	awacs_rxdma = (volatile struct dbdma_regs *)
2847
		ioremap(io->addrs[2].address, 0x100);
2900
		ioremap(io->addrs[2].address, 0x100);
2848
2901
2849
#ifdef CONFIG_PMAC_PBOOK
2850
	/* first of all make sure that the chip is powered up....*/
2902
	/* first of all make sure that the chip is powered up....*/
2851
	pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, io, 0, 1);
2903
	pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, io, 0, 1);
2852
	if (awacs_revision == AWACS_SCREAMER)
2904
	if (awacs_revision == AWACS_SCREAMER && awacs)
2853
		awacs_recalibrate();
2905
		awacs_recalibrate();
2854
#endif
2906
2855
	awacs_irq = io->intrs[0].line;
2907
	awacs_irq = io->intrs[0].line;
2856
	awacs_tx_irq = io->intrs[1].line;
2908
	awacs_tx_irq = io->intrs[1].line;
2857
	awacs_rx_irq = io->intrs[2].line;
2909
	awacs_rx_irq = io->intrs[2].line;
2858
2910
2911
	/* Hack for legacy crap that will be killed someday */
2859
	awacs_node = io;
2912
	awacs_node = io;
2860
2913
2861
	/* if we have an awacs or screamer - probe the chip to make
2914
	/* if we have an awacs or screamer - probe the chip to make
Lines 2906-2913 Link Here
2906
		/* if it's there use it to set up frame rates */
2959
		/* if it's there use it to set up frame rates */
2907
		init_frame_rates(prop, l) ;
2960
		init_frame_rates(prop, l) ;
2908
	}
2961
	}
2909
	
2962
2910
	out_le32(&awacs->control, 0x11); /* set everything quiesent */
2963
	if (awacs)
2964
		out_le32(&awacs->control, 0x11); /* set everything quiesent */
2911
2965
2912
	set_hw_byteswap(io) ; /* figure out if the h/w can do it */
2966
	set_hw_byteswap(io) ; /* figure out if the h/w can do it */
2913
2967
Lines 2942-2950 Link Here
2942
#ifdef CONFIG_KMOD
2996
#ifdef CONFIG_KMOD
2943
			request_module("i2c-keywest");
2997
			request_module("i2c-keywest");
2944
#endif /* CONFIG_KMOD */	
2998
#endif /* CONFIG_KMOD */	
2945
			awacs_tumbler_init();
2999
                        tas_register_driver(&tas3001c_hooks);
2946
			tas_init();
3000
			tas_init(I2C_DRIVERID_TAS3001C, I2C_DRIVERNAME_TAS3001C);
3001
			tas_dmasound_init();
3002
			tas_post_init();
2947
			break ;
3003
			break ;
3004
		case AWACS_SNAPPER:
3005
#ifdef CONFIG_KMOD
3006
			request_module("i2c-keywest");
3007
#endif /* CONFIG_KMOD */	
3008
                        tas_register_driver(&tas3004_hooks);
3009
			tas_init(I2C_DRIVERID_TAS3004,I2C_DRIVERNAME_TAS3004);
3010
			tas_dmasound_init();
3011
			tas_post_init();
3012
			break;
2948
		case AWACS_DACA:
3013
		case AWACS_DACA:
2949
#ifdef CONFIG_KMOD
3014
#ifdef CONFIG_KMOD
2950
			request_module("i2c-keywest");
3015
			request_module("i2c-keywest");
Lines 3028-3038 Link Here
3028
		dmasound.mach.hardware_afmts = AFMT_S16_BE ;
3093
		dmasound.mach.hardware_afmts = AFMT_S16_BE ;
3029
3094
3030
	/* shut out chips that do output only.
3095
	/* shut out chips that do output only.
3031
	   may need to extend this to machines which have no inputs - even tho'
3096
	 * may need to extend this to machines which have no inputs - even tho'
3032
	   they use screamer - IIRC one of the powerbooks is like this.
3097
	 * they use screamer - IIRC one of the powerbooks is like this.
3033
	*/
3098
	 *
3099
	 * FIXME: Actually, some TUMBLER and SNAPPER do have inputs...  
3100
	 */
3034
3101
3035
	if (awacs_revision != AWACS_TUMBLER && awacs_revision != AWACS_DACA) {
3102
	if (awacs_revision != AWACS_TUMBLER &&
3103
            awacs_revision != AWACS_SNAPPER &&
3104
            awacs_revision != AWACS_DACA) {
3036
		dmasound.mach.capabilities = DSP_CAP_DUPLEX ;
3105
		dmasound.mach.capabilities = DSP_CAP_DUPLEX ;
3037
		dmasound.mach.record = PMacRecord ;
3106
		dmasound.mach.record = PMacRecord ;
3038
	}
3107
	}
Lines 3050-3055 Link Here
3050
		case AWACS_TUMBLER:
3119
		case AWACS_TUMBLER:
3051
			sprintf(awacs_name, "PowerMac Tumbler ") ;
3120
			sprintf(awacs_name, "PowerMac Tumbler ") ;
3052
			break ;
3121
			break ;
3122
		case AWACS_SNAPPER:
3123
			sprintf(awacs_name, "PowerMac Snapper ") ;
3124
			break ;
3053
		case AWACS_SCREAMER:
3125
		case AWACS_SCREAMER:
3054
			sprintf(awacs_name, "PowerMac Screamer ") ;
3126
			sprintf(awacs_name, "PowerMac Screamer ") ;
3055
			break ;
3127
			break ;
Lines 3066-3072 Link Here
3066
{
3138
{
3067
	switch (awacs_revision) {
3139
	switch (awacs_revision) {
3068
		case AWACS_TUMBLER:
3140
		case AWACS_TUMBLER:
3069
			awacs_tumbler_cleanup();
3141
		case AWACS_SNAPPER:
3142
			tas_dmasound_cleanup();
3070
			tas_cleanup();
3143
			tas_cleanup();
3071
			break ;
3144
			break ;
3072
		case AWACS_DACA:
3145
		case AWACS_DACA:
Lines 3081-3083 Link Here
3081
3154
3082
module_init(dmasound_awacs_init);
3155
module_init(dmasound_awacs_init);
3083
module_exit(dmasound_awacs_cleanup);
3156
module_exit(dmasound_awacs_cleanup);
3157
/*
3158
 * Local Variables:
3159
 * tab-width: 8
3160
 * indent-tabs-mode: t
3161
 * c-basic-offset: 8
3162
 * End:
3163
 */
(-)linux-2.4.22/drivers/sound/dmasound/tas3001c.c (-293 / +723 lines)
Lines 1-38 Link Here
1
/*
1
/*
2
 * Driver for the i2c/i2s based TA3001C sound chip used
2
 * Driver for the i2c/i2s based TA3004 sound chip used
3
 * on some Apple hardware. Also known as "tumbler".
3
 * on some Apple hardware. Also known as "snapper".
4
 *
4
 *
5
 *  This file is subject to the terms and conditions of the GNU General Public
5
 * Tobias Sargeant <tobias.sargeant@bigpond.com>
6
 *  License.  See the file COPYING in the main directory of this archive
6
 * Based upon, tas3001c.c by Christopher C. Chimelis <chris@debian.org>:
7
 *  for more details.
8
 *
9
 * Modified by Christopher C. Chimelis <chris@debian.org>:
10
 *
7
 *
11
 *   TODO:
8
 *   TODO:
12
 *   -----
9
 *   -----
13
 *   * Enable DRC since the TiBook speakers are less than good
14
 *   * Enable control over input line 2 (is this connected?)
10
 *   * Enable control over input line 2 (is this connected?)
15
 *   * Play with the dual six-stage cascading biquad filtering to see how
11
 *   * Implement sleep support (at least mute everything and
16
 *     we can use it to our advantage (currently not implemented)
12
 *   * set gains to minimum during sleep)
17
 *   * Reorganise driver a bit to make it cleaner and easier to work with
13
 *   * Look into some of Darwin's tweaks regarding the mute
18
 *     (read: use the header file more :-P)
14
 *   * lines (delays & different behaviour on some HW)
19
 *   * Implement sleep support
20
 *
21
 *   Version 0.4:
22
 *   ------------
23
 *   * Balance control finally works (can someone document OSS better please?)
24
 *   * Moved to a struct for common values referenced in the driver
25
 *   * Put stubs in for sleep/wake-up support for now.  This will take some
26
 *     experimentation to make sure that the timing is right, since the
27
 *     TAS hardware requires specific timing while enabling low-power mode.
28
 *     I may cheat for now and just reset the chip on wake-up, but I'd rather
29
 *     not if I don't have to.
30
 *
31
 *   Version 0.3:
32
 *   ------------
33
 *   * Fixed volume control
34
 *   * Added bass and treble control
35
 *   * Added PCM line level control (mixer 1 in the TAS manual)
36
 *
15
 *
37
 */
16
 */
38
17
Lines 45-447 Link Here
45
#include <linux/types.h>
24
#include <linux/types.h>
46
#include <linux/i2c.h>
25
#include <linux/i2c.h>
47
#include <linux/init.h>
26
#include <linux/init.h>
27
#include <linux/soundcard.h>
48
#include <asm/uaccess.h>
28
#include <asm/uaccess.h>
49
#include <asm/errno.h>
29
#include <asm/errno.h>
50
#include <asm/io.h>
30
#include <asm/io.h>
51
#include <asm/prom.h>
31
#include <asm/prom.h>
52
32
53
#include "dmasound.h"
33
#include "dmasound.h"
34
#include "tas_common.h"
54
#include "tas3001c.h"
35
#include "tas3001c.h"
55
36
56
#define I2C_DRIVERID_TAS (0xFEBA)
37
#include "tas_ioctl.h"
57
38
58
#define TAS_VERSION	"0.3"
39
#define TAS3001C_BIQUAD_FILTER_COUNT  6
59
#define TAS_DATE	"20011214"
40
#define TAS3001C_BIQUAD_CHANNEL_COUNT 2
60
41
61
#define TAS_SETTING_MAX	100
42
#define VOL_DEFAULT	(100 * 4 / 5)
43
#define INPUT_DEFAULT	(100 * 4 / 5)
44
#define BASS_DEFAULT	(100 / 2)
45
#define TREBLE_DEFAULT	(100 / 2)
46
47
struct tas3001c_data_t {
48
	struct tas_data_t super;
49
	int device_id;
50
	int output_id;
51
	int speaker_id;
52
	struct tas_drce_t drce_state;
53
};
62
54
63
#define VOL_DEFAULT	(((((TAS_SETTING_MAX*4)/5)<<0)<<8) | (((TAS_SETTING_MAX*4)/5)<<0))
64
#define INPUT_DEFAULT	(((TAS_SETTING_MAX*4)/5)<<0)
65
#define BASS_DEFAULT	((TAS_SETTING_MAX/2)<<0)
66
#define TREBLE_DEFAULT	((TAS_SETTING_MAX/2)<<0)
67
55
68
static struct i2c_client * tumbler_client = NULL;
56
static const union tas_biquad_t
57
tas3001c_eq_unity={
58
	buf: { 0x100000, 0x000000, 0x000000, 0x000000, 0x000000 }
59
};
69
60
70
int tumbler_enter_sleep(void);
71
int tumbler_leave_sleep(void);
72
61
73
static int tas_attach_adapter(struct i2c_adapter *adapter);
62
static inline unsigned char db_to_regval(short db) {
74
static int tas_detect_client(struct i2c_adapter *adapter, int address);
63
	int r=0;
75
static int tas_detach_client(struct i2c_client *client);
76
64
77
/* Unique ID allocation */
65
	r=(db+0x59a0) / 0x60;
78
static int tas_id;
79
static int tas_initialized;
80
66
81
static struct device_node* tas_node;
67
	if (r < 0x91) return 0x91;
82
static u8 tas_i2c_address = 0x34;
68
	if (r > 0xef) return 0xef;
69
	return r;
70
}
83
71
84
struct tas_data_t {
72
static inline short quantize_db(short db) {
85
	uint left_vol;		/* left volume */
73
	return db_to_regval(db) * 0x60 - 0x59a0;
86
	uint right_vol;		/* right volume */
74
}
87
	uint treble;		/* treble */
88
	uint bass;		/* bass */
89
	uint pcm_level;		/* pcm level */
90
};
91
75
92
struct i2c_driver tas_driver = {  
93
	name:		"TAS3001C driver  V 0.3",
94
	id:		I2C_DRIVERID_TAS,
95
	flags:		I2C_DF_NOTIFY,
96
	attach_adapter:	&tas_attach_adapter,
97
	detach_client:	&tas_detach_client,
98
	command:	NULL,
99
	inc_use:	NULL, /* &tas_inc_use, */
100
	dec_use:	NULL  /* &tas_dev_use  */
101
};
102
76
103
int
77
static inline int
104
tumbler_get_volume(uint * left_vol, uint  *right_vol)
78
register_width(enum tas3001c_reg_t r)
105
{
79
{
106
	struct tas_data_t *data;
80
	switch(r) {
81
	case TAS3001C_REG_MCR:
82
 	case TAS3001C_REG_TREBLE:
83
	case TAS3001C_REG_BASS:
84
		return 1;
107
85
108
	if (!tumbler_client)
86
	case TAS3001C_REG_DRC:
109
		return -1;
87
		return 2;
110
88
111
	data = (struct tas_data_t *) (tumbler_client->data);
89
	case TAS3001C_REG_MIXER1:
112
	*left_vol = data->left_vol;
90
	case TAS3001C_REG_MIXER2:
113
	*right_vol = data->right_vol;
91
		return 3;
114
	
92
115
	return 0;
93
	case TAS3001C_REG_VOLUME:
94
		return 6;
95
96
	case TAS3001C_REG_LEFT_BIQUAD0:
97
	case TAS3001C_REG_LEFT_BIQUAD1:
98
	case TAS3001C_REG_LEFT_BIQUAD2:
99
	case TAS3001C_REG_LEFT_BIQUAD3:
100
	case TAS3001C_REG_LEFT_BIQUAD4:
101
	case TAS3001C_REG_LEFT_BIQUAD5:
102
	case TAS3001C_REG_LEFT_BIQUAD6:
103
104
	case TAS3001C_REG_RIGHT_BIQUAD0:
105
	case TAS3001C_REG_RIGHT_BIQUAD1:
106
	case TAS3001C_REG_RIGHT_BIQUAD2:
107
	case TAS3001C_REG_RIGHT_BIQUAD3:
108
	case TAS3001C_REG_RIGHT_BIQUAD4:
109
	case TAS3001C_REG_RIGHT_BIQUAD5:
110
	case TAS3001C_REG_RIGHT_BIQUAD6:
111
		return 15;
112
113
	default:
114
		return 0;
115
	}
116
}
116
}
117
117
118
int
118
static int
119
tumbler_set_register(uint reg, uint size, char *block)
119
tas3001c_write_register(	struct tas3001c_data_t *self,
120
{
120
				enum tas3001c_reg_t reg_num,
121
	if (i2c_smbus_write_block_data(tumbler_client, reg, size, block) < 0) {
121
				char *data,
122
		printk("tas3001c: I2C write failed \n");  
122
				uint write_mode)
123
		return -1; 
123
{
124
	if (reg_num==TAS3001C_REG_MCR ||
125
	    reg_num==TAS3001C_REG_BASS ||
126
	    reg_num==TAS3001C_REG_TREBLE) {
127
		return tas_write_byte_register(&self->super,
128
					       (uint)reg_num,
129
					       *data,
130
					       write_mode);
131
	} else {
132
		return tas_write_register(&self->super,
133
					  (uint)reg_num,
134
					  register_width(reg_num),
135
					  data,
136
					  write_mode);
124
	}
137
	}
125
	return 0;
126
}
138
}
127
139
128
int
140
static int
129
tumbler_get_pcm_lvl(uint *pcm_lvl)
141
tas3001c_sync_register(	struct tas3001c_data_t *self,
142
			enum tas3001c_reg_t reg_num)
130
{
143
{
131
	struct tas_data_t *data;
144
	if (reg_num==TAS3001C_REG_MCR ||
132
145
	    reg_num==TAS3001C_REG_BASS ||
133
	if (!tumbler_client)
146
	    reg_num==TAS3001C_REG_TREBLE) {
134
		return -1;
147
		return tas_sync_byte_register(&self->super,
148
					      (uint)reg_num,
149
					      register_width(reg_num));
150
	} else {
151
		return tas_sync_register(&self->super,
152
					 (uint)reg_num,
153
					 register_width(reg_num));
154
	}
155
}
135
156
136
	data = (struct tas_data_t *) (tumbler_client->data);
157
static int
137
	*pcm_lvl = data->pcm_level;
158
tas3001c_read_register(	struct tas3001c_data_t *self,
159
			enum tas3001c_reg_t reg_num,
160
			char *data,
161
			uint write_mode)
162
{
163
	return tas_read_register(&self->super,
164
				 (uint)reg_num,
165
				 register_width(reg_num),
166
				 data);
167
}
168
169
static inline int
170
tas3001c_fast_load(struct tas3001c_data_t *self, int fast)
171
{
172
	if (fast)
173
		self->super.shadow[TAS3001C_REG_MCR][0] |= 0x80;
174
	else
175
		self->super.shadow[TAS3001C_REG_MCR][0] &= 0x7f;
176
	return tas3001c_sync_register(self,TAS3001C_REG_MCR);
177
}
178
179
static uint
180
tas3001c_supported_mixers(struct tas3001c_data_t *self)
181
{
182
	return SOUND_MASK_VOLUME |
183
		SOUND_MASK_PCM |
184
		SOUND_MASK_ALTPCM |
185
		SOUND_MASK_TREBLE |
186
		SOUND_MASK_BASS;
187
}
138
188
139
	return 0;
189
static int
190
tas3001c_mixer_is_stereo(struct tas3001c_data_t *self,int mixer)
191
{
192
	switch(mixer) {
193
	case SOUND_MIXER_VOLUME:
194
		return 1;
195
	default:
196
		return 0;
197
	}
140
}
198
}
141
199
142
int
200
static uint
143
tumbler_get_treble(uint *treble)
201
tas3001c_stereo_mixers(struct tas3001c_data_t *self)
144
{
202
{
145
	struct tas_data_t *data;
203
	uint r=tas3001c_supported_mixers(self);
204
	uint i;
205
	
206
	for (i=1; i<SOUND_MIXER_NRDEVICES; i++)
207
		if (r&(1<<i) && !tas3001c_mixer_is_stereo(self,i))
208
			r &= ~(1<<i);
209
	return r;
210
}
146
211
147
	if (!tumbler_client)
212
static int
213
tas3001c_get_mixer_level(struct tas3001c_data_t *self,int mixer,uint *level)
214
{
215
	if (!self)
148
		return -1;
216
		return -1;
149
217
		
150
	data = (struct tas_data_t *) (tumbler_client->data);
218
	*level=self->super.mixer[mixer];
151
	*treble = data->treble;
152
	
219
	
153
	return 0;
220
	return 0;
154
}
221
}
155
222
156
int
223
static int
157
tumbler_get_bass(uint *bass)
224
tas3001c_set_mixer_level(struct tas3001c_data_t *self,int mixer,uint level)
158
{
225
{
159
	struct tas_data_t *data;
226
	int rc;
160
227
	tas_shadow_t *shadow;
161
	if (!tumbler_client)
162
		return -1;
163
228
164
	data = (struct tas_data_t *) (tumbler_client->data);
229
	uint temp;
165
	*bass = data->bass;
230
	uint offset=0;
166
231
232
	if (!self)
233
		return -1;
234
		
235
	shadow=self->super.shadow;
236
237
	if (!tas3001c_mixer_is_stereo(self,mixer))
238
		level = tas_mono_to_stereo(level);
239
240
	switch(mixer) {
241
	case SOUND_MIXER_VOLUME:
242
		temp = tas3001c_gain.master[level&0xff];
243
		shadow[TAS3001C_REG_VOLUME][0] = (temp >> 16) & 0xff;
244
		shadow[TAS3001C_REG_VOLUME][1] = (temp >> 8)  & 0xff;
245
		shadow[TAS3001C_REG_VOLUME][2] = (temp >> 0)  & 0xff;
246
		temp = tas3001c_gain.master[(level>>8)&0xff];
247
		shadow[TAS3001C_REG_VOLUME][3] = (temp >> 16) & 0xff;
248
		shadow[TAS3001C_REG_VOLUME][4] = (temp >> 8)  & 0xff;
249
		shadow[TAS3001C_REG_VOLUME][5] = (temp >> 0)  & 0xff;
250
		rc = tas3001c_sync_register(self,TAS3001C_REG_VOLUME);
251
		break;
252
	case SOUND_MIXER_ALTPCM:
253
		/* tas3001c_fast_load(self, 1); */
254
		level = tas_mono_to_stereo(level);
255
		temp = tas3001c_gain.mixer[level&0xff];
256
		shadow[TAS3001C_REG_MIXER2][offset+0] = (temp >> 16) & 0xff;
257
		shadow[TAS3001C_REG_MIXER2][offset+1] = (temp >> 8)  & 0xff;
258
		shadow[TAS3001C_REG_MIXER2][offset+2] = (temp >> 0)  & 0xff;
259
		rc = tas3001c_sync_register(self,TAS3001C_REG_MIXER2);
260
		/* tas3001c_fast_load(self, 0); */
261
		break;
262
	case SOUND_MIXER_PCM:
263
		/* tas3001c_fast_load(self, 1); */
264
		level = tas_mono_to_stereo(level);
265
		temp = tas3001c_gain.mixer[level&0xff];
266
		shadow[TAS3001C_REG_MIXER1][offset+0] = (temp >> 16) & 0xff;
267
		shadow[TAS3001C_REG_MIXER1][offset+1] = (temp >> 8)  & 0xff;
268
		shadow[TAS3001C_REG_MIXER1][offset+2] = (temp >> 0)  & 0xff;
269
		rc = tas3001c_sync_register(self,TAS3001C_REG_MIXER1);
270
		/* tas3001c_fast_load(self, 0); */
271
		break;
272
	case SOUND_MIXER_TREBLE:
273
		temp = tas3001c_gain.treble[level&0xff];
274
		shadow[TAS3001C_REG_TREBLE][0]=temp&0xff;
275
		rc = tas3001c_sync_register(self,TAS3001C_REG_TREBLE);
276
		break;
277
	case SOUND_MIXER_BASS:
278
		temp = tas3001c_gain.bass[level&0xff];
279
		shadow[TAS3001C_REG_BASS][0]=temp&0xff;
280
		rc = tas3001c_sync_register(self,TAS3001C_REG_BASS);
281
		break;
282
	default:
283
		rc = -1;
284
		break;
285
	}
286
	if (rc < 0)
287
		return rc;
288
	self->super.mixer[mixer]=level;
167
	return 0;
289
	return 0;
168
}
290
}
169
291
170
int
292
static int
171
tumbler_set_bass(uint bass)
293
tas3001c_leave_sleep(struct tas3001c_data_t *self)
172
{
294
{
173
	uint cur_bass_pers = bass;
295
	unsigned char mcr = (1<<6)+(2<<4)+(2<<2);
174
	char block;
175
	struct tas_data_t *data;
176
296
177
	if (!tumbler_client)
297
	if (!self)
178
		return -1;
298
		return -1;
179
299
180
	data = (struct tas_data_t *) (tumbler_client->data);
300
	/* Make sure something answers on the i2c bus */
301
	if (tas3001c_write_register(self, TAS3001C_REG_MCR, &mcr,
302
	    WRITE_NORMAL|FORCE_WRITE) < 0)
303
	    	return -1;
304
305
	tas3001c_fast_load(self, 1);
306
307
	(void)tas3001c_sync_register(self,TAS3001C_REG_RIGHT_BIQUAD0);
308
	(void)tas3001c_sync_register(self,TAS3001C_REG_RIGHT_BIQUAD1);
309
	(void)tas3001c_sync_register(self,TAS3001C_REG_RIGHT_BIQUAD2);
310
	(void)tas3001c_sync_register(self,TAS3001C_REG_RIGHT_BIQUAD3);
311
	(void)tas3001c_sync_register(self,TAS3001C_REG_RIGHT_BIQUAD4);
312
	(void)tas3001c_sync_register(self,TAS3001C_REG_RIGHT_BIQUAD5);
313
314
	(void)tas3001c_sync_register(self,TAS3001C_REG_LEFT_BIQUAD0);
315
	(void)tas3001c_sync_register(self,TAS3001C_REG_LEFT_BIQUAD1);
316
	(void)tas3001c_sync_register(self,TAS3001C_REG_LEFT_BIQUAD2);
317
	(void)tas3001c_sync_register(self,TAS3001C_REG_LEFT_BIQUAD3);
318
	(void)tas3001c_sync_register(self,TAS3001C_REG_LEFT_BIQUAD4);
319
	(void)tas3001c_sync_register(self,TAS3001C_REG_LEFT_BIQUAD5);
181
320
182
	bass &= 0xff;
321
	tas3001c_fast_load(self, 0);
183
	if (bass > TAS_SETTING_MAX)
184
		bass = TAS_SETTING_MAX;
185
	bass = ((bass * 72) / TAS_SETTING_MAX) << 0;
186
	bass = tas_bass_table[bass];
187
	block = (bass >> 0)  & 0xff;
188
322
189
	if (tumbler_set_register(TAS_SET_BASS, &block) < 0) {
323
	(void)tas3001c_sync_register(self,TAS3001C_REG_BASS);
190
		printk("tas3001c: failed to set bass \n");  
324
	(void)tas3001c_sync_register(self,TAS3001C_REG_TREBLE);
325
	(void)tas3001c_sync_register(self,TAS3001C_REG_MIXER1);
326
	(void)tas3001c_sync_register(self,TAS3001C_REG_MIXER2);
327
	(void)tas3001c_sync_register(self,TAS3001C_REG_VOLUME);
328
329
	return 0;
330
}
331
332
static int
333
tas3001c_enter_sleep(struct tas3001c_data_t *self)
334
{
335
	/* Stub for now, but I have the details on low-power mode */
336
	if (!self)
191
		return -1; 
337
		return -1; 
192
	}
193
	data->bass = cur_bass_pers;
194
	return 0;
338
	return 0;
195
}
339
}
196
340
197
int
341
static int
198
tumbler_set_treble(uint treble)
342
tas3001c_sync_biquad(	struct tas3001c_data_t *self,
343
			u_int channel,
344
			u_int filter)
199
{
345
{
200
	uint cur_treble_pers = treble;
346
	enum tas3001c_reg_t reg;
201
	char block;
202
	struct tas_data_t *data;
203
347
204
	if (!tumbler_client)
348
	if (channel >= TAS3001C_BIQUAD_CHANNEL_COUNT ||
205
		return -1;
349
	    filter  >= TAS3001C_BIQUAD_FILTER_COUNT) return -EINVAL;
206
350
207
	data = (struct tas_data_t *) (tumbler_client->data);
351
	reg=( channel ? TAS3001C_REG_RIGHT_BIQUAD0 : TAS3001C_REG_LEFT_BIQUAD0 ) + filter;
208
352
209
	treble &= 0xff;
353
	return tas3001c_sync_register(self,reg);
210
	if (treble > TAS_SETTING_MAX)
354
}
211
		treble = TAS_SETTING_MAX;
355
212
	treble = ((treble * 72) / TAS_SETTING_MAX) << 0;
356
static int
213
	treble = tas_treble_table[treble];
357
tas3001c_write_biquad_shadow(	struct tas3001c_data_t *self,
214
	block = (treble >> 0)  & 0xff;
358
				u_int channel,
359
				u_int filter,
360
				const union tas_biquad_t *biquad)
361
{
362
	tas_shadow_t *shadow=self->super.shadow;
363
	enum tas3001c_reg_t reg;
364
365
	if (channel >= TAS3001C_BIQUAD_CHANNEL_COUNT ||
366
	    filter  >= TAS3001C_BIQUAD_FILTER_COUNT) return -EINVAL;
367
368
	reg=( channel ? TAS3001C_REG_RIGHT_BIQUAD0 : TAS3001C_REG_LEFT_BIQUAD0 ) + filter;
369
370
	SET_4_20(shadow[reg], 0,biquad->coeff.b0);
371
	SET_4_20(shadow[reg], 3,biquad->coeff.b1);
372
	SET_4_20(shadow[reg], 6,biquad->coeff.b2);
373
	SET_4_20(shadow[reg], 9,biquad->coeff.a1);
374
	SET_4_20(shadow[reg],12,biquad->coeff.a2);
215
375
216
	if (tumbler_set_register(TAS_SET_TREBLE, &block) < 0) {
217
		printk("tas3001c: failed to set treble \n");  
218
		return -1; 
219
	}
220
	data->treble = cur_treble_pers;
221
	return 0;
376
	return 0;
222
}
377
}
223
378
224
int
379
static int
225
tumbler_set_pcm_lvl(uint pcm_lvl)
380
tas3001c_write_biquad(	struct tas3001c_data_t *self,
381
			u_int channel,
382
			u_int filter,
383
			const union tas_biquad_t *biquad)
226
{
384
{
227
	uint pcm_lvl_pers = pcm_lvl;
385
	int rc;
228
	unsigned char block[3];
229
	struct tas_data_t *data;
230
386
231
	if (!tumbler_client)
387
	rc=tas3001c_write_biquad_shadow(self, channel, filter, biquad);
232
		return -1;
388
	if (rc < 0) return rc;
233
389
234
	data = (struct tas_data_t *) (tumbler_client->data);
390
	return tas3001c_sync_biquad(self, channel, filter);
391
}
235
392
236
	pcm_lvl &= 0xff;
393
static int
237
	if (pcm_lvl > TAS_SETTING_MAX)
394
tas3001c_write_biquad_list(	struct tas3001c_data_t *self,
238
		pcm_lvl = TAS_SETTING_MAX;
395
				u_int filter_count,
239
	pcm_lvl = ((pcm_lvl * 176) / TAS_SETTING_MAX) << 0;
396
				u_int flags,
397
				struct tas_biquad_ctrl_t *biquads)
398
{
399
	int i;
400
	int rc;
240
401
241
	pcm_lvl = tas_input_table[pcm_lvl];
402
	if (flags & TAS_BIQUAD_FAST_LOAD) tas3001c_fast_load(self,1);
242
403
243
	block[0] = (pcm_lvl >> 16) & 0xff;
404
	for (i=0; i<filter_count; i++) {
244
	block[1] = (pcm_lvl >> 8)  & 0xff;
405
		rc=tas3001c_write_biquad(self,
245
	block[2] = (pcm_lvl >> 0)  & 0xff;
406
					 biquads[i].channel,
407
					 biquads[i].filter,
408
					 &biquads[i].data);
409
		if (rc < 0) break;
410
	}
246
411
247
	if (tumbler_set_register(TAS_SET_MIXER1, block) < 0) {
412
	if (flags & TAS_BIQUAD_FAST_LOAD) {
248
		printk("tas3001c: failed to set input level \n");  
413
		tas3001c_fast_load(self,0);
249
		return -1; 
414
415
		(void)tas3001c_sync_register(self,TAS3001C_REG_BASS);
416
		(void)tas3001c_sync_register(self,TAS3001C_REG_TREBLE);
417
		(void)tas3001c_sync_register(self,TAS3001C_REG_MIXER1);
418
		(void)tas3001c_sync_register(self,TAS3001C_REG_MIXER2);
419
		(void)tas3001c_sync_register(self,TAS3001C_REG_VOLUME);
250
	}
420
	}
251
	data->pcm_level = pcm_lvl_pers;
252
421
253
	return 0;
422
	return rc;
254
}
423
}
255
424
256
int
425
static int
257
tumbler_set_volume(uint left_vol, uint right_vol)
426
tas3001c_read_biquad(	struct tas3001c_data_t *self,
427
			u_int channel,
428
			u_int filter,
429
			union tas_biquad_t *biquad)
430
{
431
	tas_shadow_t *shadow=self->super.shadow;
432
	enum tas3001c_reg_t reg;
433
434
	if (channel >= TAS3001C_BIQUAD_CHANNEL_COUNT ||
435
	    filter  >= TAS3001C_BIQUAD_FILTER_COUNT) return -EINVAL;
436
437
	reg=( channel ? TAS3001C_REG_RIGHT_BIQUAD0 : TAS3001C_REG_LEFT_BIQUAD0 ) + filter;
438
439
	biquad->coeff.b0=GET_4_20(shadow[reg], 0);
440
	biquad->coeff.b1=GET_4_20(shadow[reg], 3);
441
	biquad->coeff.b2=GET_4_20(shadow[reg], 6);
442
	biquad->coeff.a1=GET_4_20(shadow[reg], 9);
443
	biquad->coeff.a2=GET_4_20(shadow[reg],12);
444
	
445
	return 0;	
446
}
447
448
static int
449
tas3001c_eq_rw(	struct tas3001c_data_t *self,
450
		u_int cmd,
451
		u_long arg)
258
{
452
{
259
	uint left_vol_pers = left_vol;
453
	int rc;
260
	uint right_vol_pers = right_vol;
454
	struct tas_biquad_ctrl_t biquad;
261
	unsigned char block[6];
262
	struct tas_data_t *data;
263
455
264
	if (!tumbler_client)
456
	if (copy_from_user((void *)&biquad, (const void *)arg, sizeof(struct tas_biquad_ctrl_t))) {
265
		return -1;
457
		return -EFAULT;
458
	}
266
459
267
	data = (struct tas_data_t *) (tumbler_client->data);
460
	if (cmd & SIOC_IN) {
461
		rc=tas3001c_write_biquad(self, biquad.channel, biquad.filter, &biquad.data);
462
		if (rc != 0) return rc;
463
	}
268
464
269
	left_vol &= 0xff;
465
	if (cmd & SIOC_OUT) {
270
	if (left_vol > TAS_SETTING_MAX)
466
		rc=tas3001c_read_biquad(self, biquad.channel, biquad.filter, &biquad.data);
271
		left_vol = TAS_SETTING_MAX;
467
		if (rc != 0) return rc;
468
469
		if (copy_to_user((void *)arg, (const void *)&biquad, sizeof(struct tas_biquad_ctrl_t))) {
470
			return -EFAULT;
471
		}
272
472
273
	right_vol = (right_vol >> 8) & 0xff;
473
	}
274
	if (right_vol > TAS_SETTING_MAX)
474
	return 0;
275
		right_vol = TAS_SETTING_MAX;
475
}
276
476
277
	left_vol = ((left_vol * 176) / TAS_SETTING_MAX) << 0;
477
static int
278
	right_vol = ((right_vol * 176) / TAS_SETTING_MAX) << 0;
478
tas3001c_eq_list_rw(	struct tas3001c_data_t *self,
479
			u_int cmd,
480
			u_long arg)
481
{
482
	int rc;
483
	int filter_count;
484
	int flags;
485
	int i,j;
486
	char sync_required[2][6];
487
	struct tas_biquad_ctrl_t biquad;
488
489
	memset(sync_required,0,sizeof(sync_required));
490
491
	if (copy_from_user((void *)&filter_count,
492
			   (const void *)arg + offsetof(struct tas_biquad_ctrl_list_t,filter_count),
493
			   sizeof(int))) {
494
		return -EFAULT;
495
	}
279
496
280
	left_vol = tas_volume_table[left_vol];
497
	if (copy_from_user((void *)&flags,
281
	right_vol = tas_volume_table[right_vol];
498
			   (const void *)arg + offsetof(struct tas_biquad_ctrl_list_t,flags),
499
			   sizeof(int))) {
500
		return -EFAULT;
501
	}
282
502
283
	block[0] = (left_vol >> 16) & 0xff;
503
	if (cmd & SIOC_IN) {
284
	block[1] = (left_vol >> 8)  & 0xff;
504
	}
285
	block[2] = (left_vol >> 0)  & 0xff;
286
505
287
	block[3] = (right_vol >> 16) & 0xff;
506
	for (i=0; i < filter_count; i++) {
288
	block[4] = (right_vol >> 8)  & 0xff;
507
		if (copy_from_user((void *)&biquad,
289
	block[5] = (right_vol >> 0)  & 0xff;
508
				   (const void *)arg + offsetof(struct tas_biquad_ctrl_list_t, biquads[i]),
509
				   sizeof(struct tas_biquad_ctrl_t))) {
510
			return -EFAULT;
511
		}
512
513
		if (cmd & SIOC_IN) {
514
			sync_required[biquad.channel][biquad.filter]=1;
515
			rc=tas3001c_write_biquad_shadow(self, biquad.channel, biquad.filter, &biquad.data);
516
			if (rc != 0) return rc;
517
		}
518
519
		if (cmd & SIOC_OUT) {
520
			rc=tas3001c_read_biquad(self, biquad.channel, biquad.filter, &biquad.data);
521
			if (rc != 0) return rc;
522
523
			if (copy_to_user((void *)arg + offsetof(struct tas_biquad_ctrl_list_t, biquads[i]),
524
					 (const void *)&biquad,
525
					 sizeof(struct tas_biquad_ctrl_t))) {
526
				return -EFAULT;
527
			}
528
		}
529
	}
290
530
291
	if (tumbler_set_register(TAS_SET_VOLUME, block) < 0) {
531
	if (cmd & SIOC_IN) {
292
		printk("tas3001c: failed to set volume \n");  
532
		if (flags & TAS_BIQUAD_FAST_LOAD) tas3001c_fast_load(self,1);
293
		return -1; 
533
		for (i=0; i<2; i++) {
534
			for (j=0; j<6; j++) {
535
				if (sync_required[i][j]) {
536
					rc=tas3001c_sync_biquad(self, i, j);
537
					if (rc < 0) return rc;
538
				}
539
			}
540
		}
541
		if (flags & TAS_BIQUAD_FAST_LOAD) {
542
			tas3001c_fast_load(self,0);
543
			/* now we need to set up the mixers again,
544
			   because leaving fast mode resets them. */
545
			(void)tas3001c_sync_register(self,TAS3001C_REG_BASS);
546
			(void)tas3001c_sync_register(self,TAS3001C_REG_TREBLE);
547
			(void)tas3001c_sync_register(self,TAS3001C_REG_MIXER1);
548
			(void)tas3001c_sync_register(self,TAS3001C_REG_MIXER2);
549
			(void)tas3001c_sync_register(self,TAS3001C_REG_VOLUME);
550
		}
294
	}
551
	}
295
	data->left_vol = left_vol_pers;
296
	data->right_vol = right_vol_pers;
297
552
298
	return 0;
553
	return 0;
299
}
554
}
300
555
301
int
556
static int
302
tumbler_leave_sleep(void)
557
tas3001c_update_drce(	struct tas3001c_data_t *self,
303
{
558
			int flags,
304
	/* Stub for now, but I have the details on low-power mode */
559
			struct tas_drce_t *drce)
305
	if (!tumbler_client)
560
{
306
		return -1;
561
	tas_shadow_t *shadow;
562
	shadow=self->super.shadow;
563
564
	shadow[TAS3001C_REG_DRC][1] = 0xc1;
565
566
	if (flags & TAS_DRCE_THRESHOLD) {
567
		self->drce_state.threshold=quantize_db(drce->threshold);
568
		shadow[TAS3001C_REG_DRC][2] = db_to_regval(self->drce_state.threshold);
569
	}
307
570
308
	return 0;
571
	if (flags & TAS_DRCE_ENABLE) {
572
		self->drce_state.enable = drce->enable;
573
	}
574
575
	if (!self->drce_state.enable) {
576
		shadow[TAS3001C_REG_DRC][0] = 0xf0;
577
	}
578
579
#ifdef DEBUG_DRCE
580
	printk("DRCE IOCTL: set [ ENABLE:%x THRESH:%x\n",
581
	       self->drce_state.enable,
582
	       self->drce_state.threshold);
583
584
	printk("DRCE IOCTL: reg [ %02x %02x ]\n",
585
	       (unsigned char)shadow[TAS3001C_REG_DRC][0],
586
	       (unsigned char)shadow[TAS3001C_REG_DRC][1]);
587
#endif
588
589
	return tas3001c_sync_register(self, TAS3001C_REG_DRC);
309
}
590
}
310
591
311
int
592
static int
312
tumbler_enter_sleep(void)
593
tas3001c_drce_rw(	struct tas3001c_data_t *self,
594
			u_int cmd,
595
			u_long arg)
313
{
596
{
314
	/* Stub for now, but I have the details on low-power mode */
597
	int rc;
315
	if (!tumbler_client)
598
	struct tas_drce_ctrl_t drce_ctrl;
316
		return -1;
599
600
	if (copy_from_user((void *)&drce_ctrl,
601
			   (const void *)arg,
602
			   sizeof(struct tas_drce_ctrl_t))) {
603
		return -EFAULT;
604
	}
605
606
#ifdef DEBUG_DRCE
607
	printk("DRCE IOCTL: input [ FLAGS:%x ENABLE:%x THRESH:%x\n",
608
	       drce_ctrl.flags,
609
	       drce_ctrl.data.enable,
610
	       drce_ctrl.data.threshold);
611
#endif
612
613
	if (cmd & SIOC_IN) {
614
		rc = tas3001c_update_drce(self, drce_ctrl.flags, &drce_ctrl.data);
615
		if (rc < 0)
616
			return rc;
617
	}
618
619
	if (cmd & SIOC_OUT) {
620
		if (drce_ctrl.flags & TAS_DRCE_ENABLE)
621
			drce_ctrl.data.enable = self->drce_state.enable;
622
623
		if (drce_ctrl.flags & TAS_DRCE_THRESHOLD)
624
			drce_ctrl.data.threshold = self->drce_state.threshold;
625
626
		if (copy_to_user((void *)arg,
627
				 (const void *)&drce_ctrl,
628
				 sizeof(struct tas_drce_ctrl_t))) {
629
			return -EFAULT;
630
		}
631
	}
317
632
318
	return 0;
633
	return 0;
319
}
634
}
320
635
321
static int
636
static void
322
tas_attach_adapter(struct i2c_adapter *adapter)
637
tas3001c_update_device_parameters(struct tas3001c_data_t *self)
323
{
638
{
324
	if (!strncmp(adapter->name, "mac-io", 6))
639
	int i,j;
325
		tas_detect_client(adapter, tas_i2c_address);
326
640
327
	return 0;
641
	if (!self) return;
642
643
	if (self->output_id == TAS_OUTPUT_HEADPHONES) {
644
		tas3001c_fast_load(self, 1);
645
646
		for (i=0; i<TAS3001C_BIQUAD_CHANNEL_COUNT; i++) {
647
			for (j=0; j<TAS3001C_BIQUAD_FILTER_COUNT; j++) {
648
				tas3001c_write_biquad(self, i, j, &tas3001c_eq_unity);
649
			}
650
		}
651
652
		tas3001c_fast_load(self, 0);
653
654
		(void)tas3001c_sync_register(self,TAS3001C_REG_BASS);
655
		(void)tas3001c_sync_register(self,TAS3001C_REG_TREBLE);
656
		(void)tas3001c_sync_register(self,TAS3001C_REG_MIXER1);
657
		(void)tas3001c_sync_register(self,TAS3001C_REG_MIXER2);
658
		(void)tas3001c_sync_register(self,TAS3001C_REG_VOLUME);
659
660
		return;
661
	}
662
663
	for (i=0; tas3001c_eq_prefs[i]; i++) {
664
		struct tas_eq_pref_t *eq = tas3001c_eq_prefs[i];
665
666
		if (eq->device_id == self->device_id &&
667
		    (eq->output_id == 0 || eq->output_id == self->output_id) &&
668
		    (eq->speaker_id == 0 || eq->speaker_id == self->speaker_id)) {
669
670
			tas3001c_update_drce(self, TAS_DRCE_ALL, eq->drce);
671
			tas3001c_write_biquad_list(self, eq->filter_count, TAS_BIQUAD_FAST_LOAD, eq->biquads);
672
673
			break;
674
		}
675
	}
328
}
676
}
329
677
330
static int
678
static void
331
tas_init_client(struct i2c_client * new_client)
679
tas3001c_device_change_handler(void *self)
332
{
680
{
333
	/* Make sure something answers on the i2c bus
681
	if (!self) return;
334
	*/
335
682
336
	if (i2c_smbus_write_byte_data(new_client, 1, (1<<6)+(2<<4)+(2<<2)+0) < 0)
683
	tas3001c_update_device_parameters((struct tas3001c_data_t *)self);
337
		return -1;
684
}
685
686
static struct tq_struct device_change_task;
338
687
339
	tumbler_client = new_client;
688
static int
689
tas3001c_output_device_change(	struct tas3001c_data_t *self,
690
				int device_id,
691
				int output_id,
692
				int speaker_id)
693
{
694
	self->device_id=device_id;
695
	self->output_id=output_id;
696
	self->speaker_id=speaker_id;
340
697
341
	tumbler_set_volume(VOL_DEFAULT, VOL_DEFAULT);
698
	schedule_task(&device_change_task);
342
	tumbler_set_pcm_lvl(INPUT_DEFAULT);
343
	tumbler_set_bass(BASS_DEFAULT);
344
	tumbler_set_treble(TREBLE_DEFAULT);
345
699
346
	return 0;
700
	return 0;
347
}
701
}
348
702
349
static int
703
static int
350
tas_detect_client(struct i2c_adapter *adapter, int address)
704
tas3001c_device_ioctl(	struct tas3001c_data_t *self,
351
{
705
			u_int cmd,
352
	int rc = 0;
706
			u_long arg)
353
	struct i2c_client *new_client;
707
{
354
	struct tas_data_t *data;
708
	switch (cmd) {
355
	const char *client_name = "tas 3001c Digital Equalizer";
709
	case TAS_READ_EQ:
356
710
	case TAS_WRITE_EQ:
357
	new_client = kmalloc(
711
		return tas3001c_eq_rw(self, cmd, arg);
358
			     sizeof(struct i2c_client) + sizeof(struct tas_data_t),
712
359
			     GFP_KERNEL);
713
	case TAS_READ_EQ_LIST:
360
	if (!new_client) {
714
	case TAS_WRITE_EQ_LIST:
361
		rc = -ENOMEM;
715
		return tas3001c_eq_list_rw(self, cmd, arg);
362
		goto bail;
363
	}
364
716
365
	/* This is tricky, but it will set the data to the right value. */
717
	case TAS_READ_EQ_FILTER_COUNT:
366
	new_client->data = new_client + 1;
718
		put_user(TAS3001C_BIQUAD_FILTER_COUNT, (uint *)(arg));
367
	data = (struct tas_data_t *) (new_client->data);
719
		return 0;
368
720
369
	new_client->addr = address;
721
	case TAS_READ_EQ_CHANNEL_COUNT:
370
	new_client->data = data;
722
		put_user(TAS3001C_BIQUAD_CHANNEL_COUNT, (uint *)(arg));
371
	new_client->adapter = adapter;
723
		return 0;
372
	new_client->driver = &tas_driver;
373
	new_client->flags = 0;
374
724
375
	strcpy(new_client->name,client_name);
725
	case TAS_READ_DRCE:
726
	case TAS_WRITE_DRCE:
727
		return tas3001c_drce_rw(self, cmd, arg);
376
728
377
	new_client->id = tas_id++; /* Automatically unique */
729
	case TAS_READ_DRCE_CAPS:
730
		put_user(TAS_DRCE_ENABLE | TAS_DRCE_THRESHOLD, (uint *)(arg));
731
		return 0;
378
732
379
	if (tas_init_client(new_client)) {
733
	case TAS_READ_DRCE_MIN:
380
		rc = -ENODEV;
734
	case TAS_READ_DRCE_MAX: {
381
		goto bail;
735
		struct tas_drce_ctrl_t drce_ctrl;
736
737
		if (copy_from_user((void *)&drce_ctrl,
738
				   (const void *)arg,
739
				   sizeof(struct tas_drce_ctrl_t))) {
740
			return -EFAULT;
741
		}
742
743
		if (drce_ctrl.flags & TAS_DRCE_THRESHOLD) {
744
			if (cmd == TAS_READ_DRCE_MIN) {
745
				drce_ctrl.data.threshold=-36<<8;
746
			} else {
747
				drce_ctrl.data.threshold=-6<<8;
748
			}
749
		}
750
751
		if (copy_to_user((void *)arg,
752
				 (const void *)&drce_ctrl,
753
				 sizeof(struct tas_drce_ctrl_t))) {
754
			return -EFAULT;
755
		}
382
	}
756
	}
383
384
	/* Tell the i2c layer a new client has arrived */
385
	if (i2c_attach_client(new_client)) {
386
		rc = -ENODEV;
387
		goto bail;
388
	}
757
	}
389
bail:
758
390
	if (rc && new_client)
759
	return -EINVAL;
391
		kfree(new_client);
392
	return rc;
393
}
760
}
394
761
395
static int
762
static int
396
tas_detach_client(struct i2c_client *client)
763
tas3001c_init_mixer(struct tas3001c_data_t *self)
397
{
764
{
398
	if (client == tumbler_client)
765
	unsigned char mcr = (1<<6)+(2<<4)+(2<<2);
399
		tumbler_client = NULL;
766
767
	/* Make sure something answers on the i2c bus */
768
	if (tas3001c_write_register(self, TAS3001C_REG_MCR, &mcr,
769
	    WRITE_NORMAL|FORCE_WRITE) < 0)
770
		return -1;
771
772
	tas3001c_fast_load(self, 1);
773
774
	(void)tas3001c_sync_register(self,TAS3001C_REG_RIGHT_BIQUAD0);
775
	(void)tas3001c_sync_register(self,TAS3001C_REG_RIGHT_BIQUAD1);
776
	(void)tas3001c_sync_register(self,TAS3001C_REG_RIGHT_BIQUAD2);
777
	(void)tas3001c_sync_register(self,TAS3001C_REG_RIGHT_BIQUAD3);
778
	(void)tas3001c_sync_register(self,TAS3001C_REG_RIGHT_BIQUAD4);
779
	(void)tas3001c_sync_register(self,TAS3001C_REG_RIGHT_BIQUAD5);
780
	(void)tas3001c_sync_register(self,TAS3001C_REG_RIGHT_BIQUAD6);
781
782
	(void)tas3001c_sync_register(self,TAS3001C_REG_LEFT_BIQUAD0);
783
	(void)tas3001c_sync_register(self,TAS3001C_REG_LEFT_BIQUAD1);
784
	(void)tas3001c_sync_register(self,TAS3001C_REG_LEFT_BIQUAD2);
785
	(void)tas3001c_sync_register(self,TAS3001C_REG_LEFT_BIQUAD3);
786
	(void)tas3001c_sync_register(self,TAS3001C_REG_LEFT_BIQUAD4);
787
	(void)tas3001c_sync_register(self,TAS3001C_REG_LEFT_BIQUAD5);
788
	(void)tas3001c_sync_register(self,TAS3001C_REG_LEFT_BIQUAD6);
789
790
	tas3001c_fast_load(self, 0);
791
792
	tas3001c_set_mixer_level(self, SOUND_MIXER_VOLUME, VOL_DEFAULT<<8 | VOL_DEFAULT);
793
	tas3001c_set_mixer_level(self, SOUND_MIXER_PCM, INPUT_DEFAULT<<8 | INPUT_DEFAULT);
794
	tas3001c_set_mixer_level(self, SOUND_MIXER_ALTPCM, 0);
400
795
401
	i2c_detach_client(client);
796
	tas3001c_set_mixer_level(self, SOUND_MIXER_BASS, BASS_DEFAULT);
402
	kfree(client);
797
	tas3001c_set_mixer_level(self, SOUND_MIXER_TREBLE, TREBLE_DEFAULT);
403
798
404
	return 0;
799
	return 0;
405
}
800
}
406
801
407
int
802
static int
408
tas_cleanup(void)
803
tas3001c_uninit_mixer(struct tas3001c_data_t *self)
409
{
804
{
410
	if (!tas_initialized)
805
	tas3001c_set_mixer_level(self, SOUND_MIXER_VOLUME, 0);
411
		return -ENODEV;
806
	tas3001c_set_mixer_level(self, SOUND_MIXER_PCM,    0);
412
	i2c_del_driver(&tas_driver);
807
	tas3001c_set_mixer_level(self, SOUND_MIXER_ALTPCM, 0);
413
	tas_initialized = 0;
808
809
	tas3001c_set_mixer_level(self, SOUND_MIXER_BASS,   0);
810
	tas3001c_set_mixer_level(self, SOUND_MIXER_TREBLE, 0);
414
811
415
	return 0;
812
	return 0;
416
}
813
}
417
814
418
int
815
static int
419
tas_init(void)
816
tas3001c_init(struct i2c_client *client)
420
{
817
{
421
	int rc;
818
	struct tas3001c_data_t *self;
422
	u32* paddr;
819
	int i,j;
423
424
	if (tas_initialized)
425
		return 0;
426
820
427
	tas_node = find_devices("deq");
821
	self = kmalloc(sizeof(struct tas3001c_data_t) +
428
	if (tas_node == NULL)
822
			TAS3001C_REG_MAX * sizeof(tas_shadow_t),
429
		return -ENODEV;
823
			GFP_KERNEL);
430
824
	if (self == NULL)
431
	printk(KERN_INFO "tas3001c driver version %s (%s)\n",TAS_VERSION,TAS_DATE);
825
		return -ENOMEM;
432
	paddr = (u32 *)get_property(tas_node, "i2c-address", NULL);
826
	client->data = (void *)self;
433
	if (paddr) {
827
	self->super.client = client;
434
		tas_i2c_address = (*paddr) >> 1;
828
	self->super.shadow = (tas_shadow_t *)(self+1);
435
		printk(KERN_INFO "using i2c address: 0x%x from device-tree\n",
829
436
		       tas_i2c_address);
830
	self->output_id=TAS_OUTPUT_HEADPHONES;
437
	} else    
831
	self->device_id=0;
438
		printk(KERN_INFO "using i2c address: 0x%x (default)\n", tas_i2c_address);
832
	self->speaker_id=0;
439
833
440
	if ((rc = i2c_add_driver(&tas_driver))) {
834
	for (i=0; i<TAS3001C_BIQUAD_CHANNEL_COUNT; i++) {
441
		printk("tas3001c: Driver registration failed, module not inserted.\n");
835
		for (j=0; j<TAS3001C_BIQUAD_FILTER_COUNT; j++) {
442
		tas_cleanup();
836
			tas3001c_write_biquad_shadow(self, i, j, &tas3001c_eq_unity);
443
		return rc;
837
		}
444
	}
838
	}
445
	tas_initialized = 1;
839
	INIT_TQUEUE(&device_change_task, tas3001c_device_change_handler, (void *)self);
840
446
	return 0;
841
	return 0;
447
}
842
}
843
844
static void
845
tas3001c_uninit(struct tas3001c_data_t *self)
846
{
847
	tas3001c_uninit_mixer(self);
848
	kfree(self);
849
}
850
851
struct tas_driver_hooks_t tas3001c_hooks = {
852
	init:                   (tas_hook_init_t)tas3001c_init,
853
	post_init:              (tas_hook_post_init_t)tas3001c_init_mixer,
854
	uninit:                 (tas_hook_uninit_t)tas3001c_uninit,
855
856
	get_mixer_level:        (tas_hook_get_mixer_level_t)tas3001c_get_mixer_level,
857
	set_mixer_level:        (tas_hook_set_mixer_level_t)tas3001c_set_mixer_level,
858
859
	enter_sleep:            (tas_hook_enter_sleep_t)tas3001c_enter_sleep,
860
	leave_sleep:            (tas_hook_leave_sleep_t)tas3001c_leave_sleep,
861
862
	supported_mixers:       (tas_hook_supported_mixers_t)tas3001c_supported_mixers,
863
	mixer_is_stereo:        (tas_hook_mixer_is_stereo_t)tas3001c_mixer_is_stereo,
864
	stereo_mixers:          (tas_hook_stereo_mixers_t)tas3001c_stereo_mixers,
865
866
	output_device_change:   (tas_hook_output_device_change_t)tas3001c_output_device_change,
867
868
	device_ioctl:           (tas_hook_device_ioctl_t)tas3001c_device_ioctl
869
};
870
871
/*
872
 * Local Variables:
873
 * tab-width: 8
874
 * indent-tabs-mode: t
875
 * c-basic-offset: 8
876
 * End:
877
 */
(-)linux-2.4.22/drivers/sound/dmasound/tas3001c.h (-227 / +43 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * Header file for the i2c/i2s based TA3001C sound chip used
2
 * Header file for the i2c/i2s based TA3001c sound chip used
3
 * on some Apple hardware. Also known as "tumbler".
3
 * on some Apple hardware. Also known as "tumbler".
4
 *
4
 *
5
 *  This file is subject to the terms and conditions of the GNU General Public
5
 *  This file is subject to the terms and conditions of the GNU General Public
Lines 9-248 Link Here
9
 * Written by Christopher C. Chimelis <chris@debian.org>
9
 * Written by Christopher C. Chimelis <chris@debian.org>
10
 */
10
 */
11
11
12
#ifndef _tas3001c_h_
12
#ifndef _TAS3001C_H_
13
#define _tas3001c_h_
13
#define _TAS3001C_H_
14
14
15
/*
15
#include <linux/types.h>
16
 * Macros that correspond to the registers that we write to
17
 * when setting the various values.
18
 */
19
#define TAS_DRC			0x02	/* DRC		*/
20
#define TAS_VOLUME		0x04	/* Volume	*/
21
#define TAS_TREBLE		0x05	/* Treble	*/
22
#define TAS_BASS		0x06	/* Bass		*/
23
#define TAS_MIXER1		0x07	/* PCM line	*/
24
#define TAS_MIXER2		0x08	/* Input (Unk)	*/
25
26
/*
27
 * Macros that define various arguments to tas_set_register()
28
 */
29
#define TAS_SET_DRC		TAS_DRC, 2
30
#define TAS_SET_VOLUME		TAS_VOLUME, 6
31
#define TAS_SET_TREBLE		TAS_TREBLE, 1
32
#define TAS_SET_BASS		TAS_BASS, 1
33
#define TAS_SET_MIXER1		TAS_MIXER1, 3
34
#define TAS_SET_MIXER2		TAS_MIXER2, 3
35
16
17
#include "tas_common.h"
18
#include "tas_eq_prefs.h"
36
19
37
/*
20
/*
38
 * tas_volume_table contains lookup values for the volume settings
21
 * Macros that correspond to the registers that we write to
39
 * for tumbler.  This is straight from the programming manual
22
 * when setting the various values.
40
 * for the chip, however, it's zero-sourced for your shopping pleasure
41
 * (meaning, you'll have to compute the difference between the desired
42
 * dB and the index value of the proper setting.
43
 *
44
 * This table should've been replaced by the formula:
45
 * 	dB = 20 log(x)
46
 * but, since there's no log() or supporting functions like exp(),
47
 * my implementation of the above won't work. Yeah, I could do it
48
 * the hard way, but this table is just easier :-)
49
 *
50
 * For reference, -70 dB = tas_volume_table[0]
51
 */
23
 */
52
24
53
static unsigned int tas_volume_table[] = {
25
#define TAS3001C_VERSION	"0.3"
54
	0x00000015,	0x00000016,	0x00000017,	/* -70.0, -69.5, -69.0 */
26
#define TAS3001C_DATE	        "20011214"
55
	0x00000019,	0x0000001a,	0x0000001c,	/* -68.5, -68.0, -67.5 */
56
	0x0000001d,	0x0000001f,	0x00000021,	/* -67.0, -66.5, -66.0 */
57
	0x00000023,	0x00000025,	0x00000027,	/* -65.5, -65.0, -64.5 */
58
	0x00000029,	0x0000002c,	0x0000002e,	/* -64.0, -63.5, -63.0 */
59
	0x00000031,	0x00000034,	0x00000037,	/* -62.5, -62.0, -61.5 */
60
	0x0000003a,	0x0000003e,	0x00000042,	/* -61.0, -60.5, -60.0 */
61
	0x00000045,	0x0000004a,	0x0000004e,	/* -59.5, -59.0, -58.5 */
62
	0x00000053,	0x00000057,	0x0000005d,	/* -58.0, -57.5, -57.0 */
63
	0x00000062,	0x00000068,	0x0000006e,	/* -56.5, -56.0, -55.5 */
64
	0x00000075,	0x0000007b,	0x00000083,	/* -55.0, -54.5, -54.0 */
65
	0x0000008b,	0x00000093,	0x0000009b,	/* -53.5, -53.0, -52.5 */
66
	0x000000a5,	0x000000ae,	0x000000b9,	/* -52.0, -51.5, -51.0 */
67
	0x000000c4,	0x000000cf,	0x000000dc,	/* -50.5, -50.0, -49.5 */
68
	0x000000e9,	0x000000f6,	0x00000105,	/* -49.0, -48.5, -48.0 */
69
	0x00000114,	0x00000125,	0x00000136,	/* -47.5, -47.0, -46.5 */
70
	0x00000148,	0x0000015c,	0x00000171,	/* -46.0, -45.5, -45.0 */
71
	0x00000186,	0x0000019e,	0x000001b6,	/* -44.5, -44.0, -43.5 */
72
	0x000001d0,	0x000001eb,	0x00000209,	/* -43.0, -42.5, -42.0 */
73
	0x00000227,	0x00000248,	0x0000026b,	/* -41.5, -41.0, -40.5 */
74
	0x0000028f,	0x000002b6,	0x000002df,	/* -40.0, -39.5, -39.0 */
75
	0x0000030b,	0x00000339,	0x0000036a,	/* -38.5, -38.0, -37.5 */
76
	0x0000039e,	0x000003d5,	0x0000040f,	/* -37.0, -36.5, -36.0 */
77
	0x0000044c,	0x0000048d,	0x000004d2,	/* -35.5, -35.0, -34.5 */
78
	0x0000051c,	0x00000569,	0x000005bb,	/* -34.0, -33.5, -33.0 */
79
	0x00000612,	0x0000066e,	0x000006d0,	/* -32.5, -32.0, -31.5 */
80
	0x00000737,	0x000007a5,	0x00000818,	/* -31.0, -30.5, -30.0 */
81
	0x00000893,	0x00000915,	0x0000099f,	/* -29.5, -29.0, -28.5 */
82
	0x00000a31,	0x00000acc,	0x00000b6f,	/* -28.0, -27.5, -27.0 */
83
	0x00000c1d,	0x00000cd5,	0x00000d97,	/* -26.5, -26.0, -25.5 */
84
	0x00000e65,	0x00000f40,	0x00001027,	/* -25.0, -24.5, -24.0 */
85
	0x0000111c,	0x00001220,	0x00001333,	/* -23.5, -23.0, -22.5 */
86
	0x00001456,	0x0000158a,	0x000016d1,	/* -22.0, -21.5, -21.0 */
87
	0x0000182b,	0x0000199a,	0x00001b1e,	/* -20.5, -20.0, -19.5 */
88
	0x00001cb9,	0x00001e6d,	0x0000203a,	/* -19.0, -18.5, -18.0 */
89
	0x00002223,	0x00002429,	0x0000264e,	/* -17.5, -17.0, -16.5 */
90
	0x00002893,	0x00002afa,	0x00002d86,	/* -16.0, -15.5, -15.0 */
91
	0x00003039,	0x00003314,	0x0000361b,	/* -14.5, -14.0, -13.5 */
92
	0x00003950,	0x00003cb5,	0x0000404e,	/* -13.0, -12.5, -12.0 */
93
	0x0000441d,	0x00004827,	0x00004c6d,	/* -11.5, -11.0, -10.5 */
94
	0x000050f4,	0x000055c0,	0x00005ad5,	/* -10.0, -09.5, -09.0 */
95
	0x00006037,	0x000065ea,	0x00006bf4,	/* -08.5, -08.0, -07.5 */
96
	0x0000725a,	0x00007920,	0x0000804e,	/* -07.0, -06.5, -06.0 */
97
	0x000087e8,	0x00008ff6,	0x0000987d,	/* -05.5, -05.0, -04.5 */
98
	0x0000a186,	0x0000ab19,	0x0000b53c,	/* -04.0, -03.5, -03.0 */
99
	0x0000bff9,	0x0000cb59,	0x0000d766,	/* -02.5, -02.0, -01.5 */
100
	0x0000e429,	0x0000f1ae,	0x00010000,	/* -01.0, -00.5,  00.0 */
101
	0x00010f2b,	0x00011f3d,	0x00013042,	/* +00.5, +01.0, +01.5 */
102
	0x00014249,	0x00015562,	0x0001699c,	/* +02.0, +02.5, +03.0 */
103
	0x00017f09,	0x000195bc,	0x0001adc6,	/* +03.5, +04.0, +04.5 */
104
	0x0001c73d,	0x0001e237,	0x0001feca,	/* +05.0, +05.5, +06.0 */
105
	0x00021d0e,	0x00023d1d,	0x00025f12,	/* +06.5, +07.0, +07.5 */
106
	0x0002830b,	0x0002a925,	0x0002d182,	/* +08.0, +08.5, +09.0 */
107
	0x0002fc42,	0x0003298b,	0x00035983,	/* +09.5, +10.0, +10.5 */
108
	0x00038c53,	0x0003c225,	0x0003fb28,	/* +11.0, +11.5, +12.0 */
109
	0x0004378b,	0x00047783,	0x0004bb44,	/* +12.5, +13.0, +13.5 */
110
	0x0005030a,	0x00054f10,	0x00059f98,	/* +14.0, +14.5, +15.0 */
111
	0x0005f4e5,	0x00064f40,	0x0006aef6,	/* +15.5, +16.0, +16.5 */
112
	0x00071457,	0x00077fbb,	0x0007f17b	/* +17.0, +17.5, +18.0 */
113
};
114
27
115
/* tas_treble_table[] is a lookup table that holds the values to drop into
28
#define I2C_DRIVERNAME_TAS3001C "TAS3001c driver V " TAS3001C_VERSION
116
 * the treble setting register on the TAS.  Again, there is a formula for
29
#define I2C_DRIVERID_TAS3001C   (I2C_DRIVERID_TAS_BASE+0)
117
 * this one, but we use this instead due to lack of real math functions
118
 * in the kernel.
119
 */
120
static char tas_treble_table[] = {
121
	0x96,		0x95,		0x94,	/* -18.0, -17.5, -17.0 */
122
	0x93,		0x92,		0x91,	/* -16.5, -16.0, -15.5 */
123
	0x90,		0x8f,		0x8e,	/* -15.0, -14.5, -14.0 */
124
	0x8d,		0x8c,		0x8b,	/* -13.5, -13.0, -12.5 */
125
	0x8a,		0x89,		0x88,	/* -12.0, -11.5, -11.0 */
126
	0x87,		0x86,		0x85,	/* -10.5, -10.0, -09.5 */
127
	0x84,		0x83,		0x82,	/* -09.0, -08.5, -08.0 */
128
	0x81,		0x80,		0x7f,	/* -07.5, -07.0, -06.5 */
129
	0x7e,		0x7d,		0x7c,	/* -06.0, -05.5, -05.0 */
130
	0x7b,		0x7a,		0x79,	/* -04.5, -04.0, -03.5 */
131
	0x78,		0x77,		0x76,	/* -03.0, -02.5, -02.0 */
132
	0x75,		0x74,		0x73,	/* -01.5, -01.0, -00.5 */
133
	0x72,		0x71,		0x70,	/*  00.0, +00.5, +01.0 */
134
	0x6e,		0x6d,		0x6c,	/* +01.5, +02.0, +02.5 */
135
	0x6b,		0x69,		0x68,	/* +03.0, +03.5, +04.0 */
136
	0x66,		0x65,		0x63,	/* +04.5, +05.0, +05.5 */
137
	0x62,		0x60,		0x5e,	/* +06.0, +06.5, +07.0 */
138
	0x5c,		0x5a,		0x57,	/* +07.5, +08.0, +08.5 */
139
	0x55,		0x52,		0x4f,	/* +09.0, +09.5, +10.0 */
140
	0x4c,		0x49,		0x45,	/* +10.5, +11.0, +11.5 */
141
	0x42,		0x3e,		0x3a,	/* +12.0, +12.5, +13.0 */
142
	0x36,		0x32,		0x2d,	/* +13.5, +14.0, +14.5 */
143
	0x28,		0x22,		0x1c,	/* +15.0, +15.5, +16.0 */
144
	0x16,		0x10,		0x09,	/* +16.5, +17.0, +17.5 */
145
	0x01					/* +18.0	       */
146
};
147
30
148
/* tas_bass_table[] is a lookup table that holds the values to drop into
31
extern  struct tas_driver_hooks_t tas3001c_hooks;
149
 * the bass setting register on the TAS.  Again, there is a formula for
32
extern struct tas_gain_t tas3001c_gain;
150
 * this one, but we use this instead due to lack of real math functions
33
extern struct tas_eq_pref_t *tas3001c_eq_prefs[];
151
 * in the kernel.
34
152
 */
35
enum tas3001c_reg_t {
153
static char tas_bass_table[] = {
36
  TAS3001C_REG_MCR                    = 0x01,
154
	0x86,		0x82,		0x7f,	/* -18.0, -17.5, -17.0 */
37
  TAS3001C_REG_DRC                    = 0x02,
155
	0x7d,		0x7a,		0x78,	/* -16.5, -16.0, -15.5 */
38
156
	0x76,		0x74,		0x72,	/* -15.0, -14.5, -14.0 */
39
  TAS3001C_REG_VOLUME                 = 0x04,
157
	0x70,		0x6e,		0x6d,   /* -13.5, -13.0, -12.5 */
40
  TAS3001C_REG_TREBLE                 = 0x05,
158
	0x6b,		0x69,		0x66,	/* -12.0, -11.5, -11.0 */
41
  TAS3001C_REG_BASS                   = 0x06,
159
	0x64,		0x61,		0x5f,	/* -10.5, -10.0, -09.5 */
42
  TAS3001C_REG_MIXER1                 = 0x07,
160
	0x5d,		0x5c,		0x5a,	/* -09.0, -08.5, -08.0 */
43
  TAS3001C_REG_MIXER2                 = 0x08,
161
	0x59,		0x58,		0x56,	/* -07.5, -07.0, -06.5 */
44
162
	0x55,		0x54,		0x53,	/* -06.0, -05.5, -05.0 */
45
  TAS3001C_REG_LEFT_BIQUAD0           = 0x0a,
163
	0x51,		0x4f,		0x4d,	/* -04.5, -04.0, -03.5 */
46
  TAS3001C_REG_LEFT_BIQUAD1           = 0x0b,
164
	0x4b,		0x49,		0x46,	/* -03.0, -02.5, -02.0 */
47
  TAS3001C_REG_LEFT_BIQUAD2           = 0x0c,
165
	0x44,		0x42,		0x40,	/* -01.5, -01.0, -00.5 */
48
  TAS3001C_REG_LEFT_BIQUAD3           = 0x0d,
166
	0x3e,		0x3c,		0x3b,	/*  00.0, +00.5, +01.0 */
49
  TAS3001C_REG_LEFT_BIQUAD4           = 0x0e,
167
	0x39,		0x38,		0x36,	/* +01.5, +02.0, +02.5 */
50
  TAS3001C_REG_LEFT_BIQUAD5           = 0x0f,
168
	0x35,		0x33,		0x31,	/* +03.0, +03.5, +04.0 */
51
  TAS3001C_REG_LEFT_BIQUAD6           = 0x10,
169
	0x30,		0x2e,		0x2c,	/* +04.5, +05.0, +05.5 */
52
  
170
	0x2b,		0x29,		0x28,	/* +06.0, +06.5, +07.0 */
53
  TAS3001C_REG_RIGHT_BIQUAD0          = 0x13,
171
	0x26,		0x25,		0x23,	/* +07.5, +08.0, +08.5 */
54
  TAS3001C_REG_RIGHT_BIQUAD1          = 0x14,
172
	0x21,		0x1f,		0x1c,	/* +09.0, +09.5, +10.0 */
55
  TAS3001C_REG_RIGHT_BIQUAD2          = 0x15,
173
	0x19,		0x18,		0x17,	/* +10.5, +11.0, +11.5 */
56
  TAS3001C_REG_RIGHT_BIQUAD3          = 0x16,
174
	0x16,		0x14,		0x13,	/* +12.0, +12.5, +13.0 */
57
  TAS3001C_REG_RIGHT_BIQUAD4          = 0x17,
175
	0x12,		0x10,		0x0f,	/* +13.5, +14.0, +14.5 */
58
  TAS3001C_REG_RIGHT_BIQUAD5          = 0x18,
176
	0x0d,		0x0b,		0x0a,	/* +15.0, +15.5, +16.0 */
59
  TAS3001C_REG_RIGHT_BIQUAD6          = 0x19,
177
	0x08,		0x06,		0x03,	/* +16.5, +17.0, +17.5 */
178
	0x01					/* +18.0	       */
179
};
180
60
181
/* tas_input_table[] is a lookup table that holds the values to drop into
61
  TAS3001C_REG_MAX                    = 0x20
182
 * the setting registers on the TAS for "mixers 1 & 2" (which are the input
183
 * lines).  Again, there is a formula for these, but we use this instead
184
 * due to lack of real math functions in the kernel.
185
 */
186
static unsigned int tas_input_table[] = {
187
	0x00014b,	0x00015f,	0x000174,	/* -70.0, -69.5, -69.0 */
188
	0x00018a,	0x0001a1,	0x0001ba,	/* -68.5, -68.0, -67.5 */
189
	0x0001d4,	0x0001f0,	0x00020d,	/* -67.0, -66.5, -66.0 */
190
	0x00022c,	0x00024d,	0x000270,	/* -65.5, -65.0, -64.5 */
191
	0x000295,	0x0002bc,	0x0002e6,	/* -64.0, -63.5, -63.0 */
192
	0x000312,	0x000340,	0x000372,	/* -62.5, -62.0, -61.5 */
193
	0x0003a6,	0x0003dd,	0x000418,	/* -61.0, -60.5, -60.0 */
194
	0x000456,	0x000498,	0x0004de,	/* -59.5, -59.0, -58.5 */
195
	0x000528,	0x000576,	0x0005c9,	/* -58.0, -57.5, -57.0 */
196
	0x000620,	0x00067d,	0x0006e0,	/* -56.5, -56.0, -55.5 */
197
	0x000748,	0x0007b7,	0x00082c,	/* -55.0, -54.5, -54.0 */
198
	0x0008a8,	0x00092b,	0x0009b6,	/* -53.5, -53.0, -52.5 */
199
	0x000a49,	0x000ae5,	0x000b8b,	/* -52.0, -51.5, -51.0 */
200
	0x000c3a,	0x000cf3,	0x000db8,	/* -50.5, -50.0, -49.5 */
201
	0x000e88,	0x000f64,	0x00104e,	/* -49.0, -48.5, -48.0 */
202
	0x001145,	0x00124b,	0x001361,	/* -47.5, -47.0, -46.5 */
203
	0x001487,	0x0015be,	0x001708,	/* -46.0, -45.5, -45.0 */
204
	0x001865,	0x0019d8,	0x001b60,	/* -44.5, -44.0, -43.5 */
205
	0x001cff,	0x001eb7,	0x002089,	/* -43.0, -42.5, -42.0 */
206
	0x002276,	0x002481,	0x0026ab,	/* -41.5, -41.0, -40.5 */
207
	0x0028f5,	0x002b63,	0x002df5,	/* -40.0, -39.5, -39.0 */
208
	0x0030ae,	0x003390,	0x00369e,	/* -38.5, -38.0, -37.5 */
209
	0x0039db,	0x003d49,	0x0040ea,	/* -37.0, -36.5, -36.0 */
210
	0x0044c3,	0x0048d6,	0x004d27,	/* -35.5, -35.0, -34.5 */
211
	0x0051b9,	0x005691,	0x005bb2,	/* -34.0, -33.5, -33.0 */
212
	0x006121,	0x0066e3,	0x006cfb,	/* -32.5, -32.0, -31.5 */
213
	0x007370,	0x007a48,	0x008186,	/* -31.0, -30.5, -30.0 */
214
	0x008933,	0x009154,	0x0099f1,	/* -29.5, -29.0, -28.5 */
215
	0x00a310,	0x00acba,	0x00b6f6,	/* -28.0, -27.5, -27.0 */
216
	0x00c1cd,	0x00cd49,	0x00d973,	/* -26.5, -26.0, -25.5 */
217
	0x00e655,	0x00f3fb,	0x010270,	/* -25.0, -24.5, -24.0 */
218
	0x0111c0,	0x0121f9,	0x013328,	/* -23.5, -23.0, -22.5 */
219
	0x01455b,	0x0158a2,	0x016d0e,	/* -22.0, -21.5, -21.0 */
220
	0x0182af,	0x019999,	0x01b1de,	/* -20.5, -20.0, -19.5 */
221
	0x01cb94,	0x01e6cf,	0x0203a7,	/* -19.0, -18.5, -18.0 */
222
	0x022235,	0x024293,	0x0264db,	/* -17.5, -17.0, -16.5 */
223
	0x02892c,	0x02afa3,	0x02d862,	/* -16.0, -15.5, -15.0 */
224
	0x03038a,	0x033142,	0x0361af,	/* -14.5, -14.0, -13.5 */
225
	0x0394fa,	0x03cb50,	0x0404de,	/* -13.0, -12.5, -12.0 */
226
	0x0441d5,	0x048268,	0x04c6d0,	/* -11.5, -11.0, -10.5 */
227
	0x050f44,	0x055c04,	0x05ad50,	/* -10.0, -09.5, -09.0 */
228
	0x06036e,	0x065ea5,	0x06bf44,	/* -08.5, -08.0, -07.5 */
229
	0x07259d,	0x079207,	0x0804dc,	/* -07.0, -06.5, -06.0 */
230
	0x087e80,	0x08ff59,	0x0987d5,	/* -05.5, -05.0, -04.5 */
231
	0x0a1866,	0x0ab189,	0x0b53be,	/* -04.0, -03.5, -03.0 */
232
	0x0bff91,	0x0cb591,	0x0d765a,	/* -02.5, -02.0, -01.5 */
233
	0x0e4290,	0x0f1adf,	0x100000,	/* -01.0, -00.5,  00.0 */
234
	0x10f2b4,	0x11f3c9,	0x13041a,	/* +00.5, +01.0, +01.5 */
235
	0x14248e,	0x15561a,	0x1699c0,	/* +02.0, +02.5, +03.0 */
236
	0x17f094,	0x195bb8,	0x1adc61,	/* +03.5, +04.0, +04.5 */
237
	0x1c73d5,	0x1e236d,	0x1fec98,	/* +05.0, +05.5, +06.0 */
238
	0x21d0d9,	0x23d1cd,	0x25f125,	/* +06.5, +07.0, +07.5 */
239
	0x2830af,	0x2a9254,	0x2d1818,	/* +08.0, +08.5, +09.0 */
240
	0x2fc420,	0x3298b0,	0x35982f,	/* +09.5, +10.0, +10.5 */
241
	0x38c528,	0x3c224c,	0x3fb278,	/* +11.0, +11.5, +12.0 */
242
	0x437880,	0x477828,	0x4bb446,	/* +12.5, +13.0, +13.5 */
243
	0x5030a1,	0x54f106,	0x59f980,	/* +14.0, +14.5, +15.0 */
244
	0x5f4e52,	0x64f403,	0x6aef5d,	/* +15.5, +16.0, +16.5 */
245
	0x714575,	0x77fbaa,	0x7f17af	/* +17.0, +17.5, +18.0 */
246
};
62
};
247
63
248
#endif /* _tas3001c_h_ */
64
#endif /* _TAS3001C_H_ */
(-)linux-2.4.22/drivers/sound/dmasound/tas3001c_tables.c (+375 lines)
Line 0 Link Here
1
#include "tas_common.h"
2
#include "tas_eq_prefs.h"
3
4
static struct tas_drce_t eqp_0e_2_1_drce = {
5
  enable:    1,
6
  above:     { val: 3.0 * (1<<8), expand: 0 },
7
  below:     { val: 1.0 * (1<<8), expand: 0 },
8
  threshold: -15.33  * (1<<8),
9
  energy:    2.4     * (1<<12),
10
  attack:    0.013   * (1<<12),
11
  decay:     0.212   * (1<<12),
12
};
13
14
static struct tas_biquad_ctrl_t eqp_0e_2_1_biquads[]={
15
  { channel: 0, filter: 0, data: { coeff: { 0x0FCAD3, 0xE06A58, 0x0FCAD3, 0xE06B09, 0x0F9657 } } },
16
  { channel: 0, filter: 1, data: { coeff: { 0x041731, 0x082E63, 0x041731, 0xFD8D08, 0x02CFBD } } },
17
  { channel: 0, filter: 2, data: { coeff: { 0x0FFDC7, 0xE0524C, 0x0FBFAA, 0xE0524C, 0x0FBD72 } } },
18
  { channel: 0, filter: 3, data: { coeff: { 0x0F3D35, 0xE228CA, 0x0EC7B2, 0xE228CA, 0x0E04E8 } } },
19
  { channel: 0, filter: 4, data: { coeff: { 0x0FCEBF, 0xE181C2, 0x0F2656, 0xE181C2, 0x0EF516 } } },
20
  { channel: 0, filter: 5, data: { coeff: { 0x0EC417, 0x073E22, 0x0B0633, 0x073E22, 0x09CA4A } } },
21
22
  { channel: 1, filter: 0, data: { coeff: { 0x0FCAD3, 0xE06A58, 0x0FCAD3, 0xE06B09, 0x0F9657 } } },
23
  { channel: 1, filter: 1, data: { coeff: { 0x041731, 0x082E63, 0x041731, 0xFD8D08, 0x02CFBD } } },
24
  { channel: 1, filter: 2, data: { coeff: { 0x0FFDC7, 0xE0524C, 0x0FBFAA, 0xE0524C, 0x0FBD72 } } },
25
  { channel: 1, filter: 3, data: { coeff: { 0x0F3D35, 0xE228CA, 0x0EC7B2, 0xE228CA, 0x0E04E8 } } },
26
  { channel: 1, filter: 4, data: { coeff: { 0x0FCEBF, 0xE181C2, 0x0F2656, 0xE181C2, 0x0EF516 } } },
27
  { channel: 1, filter: 5, data: { coeff: { 0x0EC417, 0x073E22, 0x0B0633, 0x073E22, 0x09CA4A } } },
28
};
29
30
static struct tas_eq_pref_t eqp_0e_2_1 = {
31
  sample_rate:  44100,
32
  device_id:    0x0e,
33
  output_id:    TAS_OUTPUT_EXTERNAL_SPKR,
34
  speaker_id:   0x01,
35
36
  drce:         &eqp_0e_2_1_drce,
37
38
  filter_count: 12,
39
  biquads:      eqp_0e_2_1_biquads
40
};
41
42
/* ======================================================================== */
43
44
static struct tas_drce_t eqp_10_1_0_drce={
45
  enable:    1,
46
  above:     { val: 3.0 * (1<<8), expand: 0 },
47
  below:     { val: 1.0 * (1<<8), expand: 0 },
48
  threshold: -12.46  * (1<<8),
49
  energy:    2.4     * (1<<12),
50
  attack:    0.013   * (1<<12),
51
  decay:     0.212   * (1<<12),
52
};
53
54
static struct tas_biquad_ctrl_t eqp_10_1_0_biquads[]={
55
  { channel: 0, filter: 0, data: { coeff: { 0x0F4A12, 0xE16BDA, 0x0F4A12, 0xE173F0, 0x0E9C3A } } },
56
  { channel: 0, filter: 1, data: { coeff: { 0x02DD54, 0x05BAA8, 0x02DD54, 0xF8001D, 0x037532 } } },
57
  { channel: 0, filter: 2, data: { coeff: { 0x0E2FC7, 0xE4D5DC, 0x0D7477, 0xE4D5DC, 0x0BA43F } } },
58
  { channel: 0, filter: 3, data: { coeff: { 0x0E7899, 0xE67CCA, 0x0D0E93, 0xE67CCA, 0x0B872D } } },
59
  { channel: 0, filter: 4, data: { coeff: { 0x100000, 0x000000, 0x000000, 0x000000, 0x000000 } } },
60
  { channel: 0, filter: 5, data: { coeff: { 0x100000, 0x000000, 0x000000, 0x000000, 0x000000 } } },
61
62
  { channel: 1, filter: 0, data: { coeff: { 0x0F4A12, 0xE16BDA, 0x0F4A12, 0xE173F0, 0x0E9C3A } } },
63
  { channel: 1, filter: 1, data: { coeff: { 0x02DD54, 0x05BAA8, 0x02DD54, 0xF8001D, 0x037532 } } },
64
  { channel: 1, filter: 2, data: { coeff: { 0x0E2FC7, 0xE4D5DC, 0x0D7477, 0xE4D5DC, 0x0BA43F } } },
65
  { channel: 1, filter: 3, data: { coeff: { 0x0E7899, 0xE67CCA, 0x0D0E93, 0xE67CCA, 0x0B872D } } },
66
  { channel: 1, filter: 4, data: { coeff: { 0x100000, 0x000000, 0x000000, 0x000000, 0x000000 } } },
67
  { channel: 1, filter: 5, data: { coeff: { 0x100000, 0x000000, 0x000000, 0x000000, 0x000000 } } },
68
};
69
70
static struct tas_eq_pref_t eqp_10_1_0 = {
71
  sample_rate:  44100,
72
  device_id:    0x10,
73
  output_id:    TAS_OUTPUT_INTERNAL_SPKR,
74
  speaker_id:   0x00,
75
76
  drce:         &eqp_10_1_0_drce,
77
78
  filter_count: 12,
79
  biquads:      eqp_10_1_0_biquads
80
};
81
82
/* ======================================================================== */
83
84
static struct tas_drce_t eqp_15_2_1_drce={
85
  enable:    1,
86
  above:     { val: 3.0 * (1<<8), expand: 0 },
87
  below:     { val: 1.0 * (1<<8), expand: 0 },
88
  threshold: -15.33  * (1<<8),
89
  energy:    2.4     * (1<<12),
90
  attack:    0.013   * (1<<12),
91
  decay:     0.212   * (1<<12),
92
};
93
94
static struct tas_biquad_ctrl_t eqp_15_2_1_biquads[]={
95
  { channel: 0, filter: 0, data: { coeff: { 0x0FE143, 0xE05204, 0x0FCCC5, 0xE05266, 0x0FAE6B } } },
96
  { channel: 0, filter: 1, data: { coeff: { 0x102383, 0xE03A03, 0x0FA325, 0xE03A03, 0x0FC6A8 } } },
97
  { channel: 0, filter: 2, data: { coeff: { 0x0FF2AB, 0xE06285, 0x0FB20A, 0xE06285, 0x0FA4B5 } } },
98
  { channel: 0, filter: 3, data: { coeff: { 0x0F544D, 0xE35971, 0x0D8F3A, 0xE35971, 0x0CE388 } } },
99
  { channel: 0, filter: 4, data: { coeff: { 0x13E1D3, 0xF3ECB5, 0x042227, 0xF3ECB5, 0x0803FA } } },
100
  { channel: 0, filter: 5, data: { coeff: { 0x0AC119, 0x034181, 0x078AB1, 0x034181, 0x024BCA } } },
101
102
  { channel: 1, filter: 0, data: { coeff: { 0x0FE143, 0xE05204, 0x0FCCC5, 0xE05266, 0x0FAE6B } } },
103
  { channel: 1, filter: 1, data: { coeff: { 0x102383, 0xE03A03, 0x0FA325, 0xE03A03, 0x0FC6A8 } } },
104
  { channel: 1, filter: 2, data: { coeff: { 0x0FF2AB, 0xE06285, 0x0FB20A, 0xE06285, 0x0FA4B5 } } },
105
  { channel: 1, filter: 3, data: { coeff: { 0x0F544D, 0xE35971, 0x0D8F3A, 0xE35971, 0x0CE388 } } },
106
  { channel: 1, filter: 4, data: { coeff: { 0x13E1D3, 0xF3ECB5, 0x042227, 0xF3ECB5, 0x0803FA } } },
107
  { channel: 1, filter: 5, data: { coeff: { 0x0AC119, 0x034181, 0x078AB1, 0x034181, 0x024BCA } } },
108
};
109
110
static struct tas_eq_pref_t eqp_15_2_1 = {
111
  sample_rate:  44100,
112
  device_id:    0x15,
113
  output_id:    TAS_OUTPUT_EXTERNAL_SPKR,
114
  speaker_id:   0x01,
115
116
  drce:         &eqp_15_2_1_drce,
117
118
  filter_count: 12,
119
  biquads:      eqp_15_2_1_biquads
120
};
121
122
/* ======================================================================== */
123
124
static struct tas_drce_t eqp_15_1_0_drce={
125
  enable:    1,
126
  above:     { val: 3.0 * (1<<8), expand: 0 },
127
  below:     { val: 1.0 * (1<<8), expand: 0 },
128
  threshold: 0.0     * (1<<8),
129
  energy:    2.4     * (1<<12),
130
  attack:    0.013   * (1<<12),
131
  decay:     0.212   * (1<<12),
132
};
133
134
static struct tas_biquad_ctrl_t eqp_15_1_0_biquads[]={
135
  { channel: 0, filter: 0, data: { coeff: { 0x0FAD08, 0xE0A5EF, 0x0FAD08, 0xE0A79D, 0x0F5BBE } } },
136
  { channel: 0, filter: 1, data: { coeff: { 0x04B38D, 0x09671B, 0x04B38D, 0x000F71, 0x02BEC5 } } },
137
  { channel: 0, filter: 2, data: { coeff: { 0x0FDD32, 0xE0A56F, 0x0F8A69, 0xE0A56F, 0x0F679C } } },
138
  { channel: 0, filter: 3, data: { coeff: { 0x0FD284, 0xE135FB, 0x0F2161, 0xE135FB, 0x0EF3E5 } } },
139
  { channel: 0, filter: 4, data: { coeff: { 0x0E81B1, 0xE6283F, 0x0CE49D, 0xE6283F, 0x0B664F } } },
140
  { channel: 0, filter: 5, data: { coeff: { 0x0F2D62, 0xE98797, 0x0D1E19, 0xE98797, 0x0C4B7B } } },
141
142
  { channel: 1, filter: 0, data: { coeff: { 0x0FAD08, 0xE0A5EF, 0x0FAD08, 0xE0A79D, 0x0F5BBE } } },
143
  { channel: 1, filter: 1, data: { coeff: { 0x04B38D, 0x09671B, 0x04B38D, 0x000F71, 0x02BEC5 } } },
144
  { channel: 1, filter: 2, data: { coeff: { 0x0FDD32, 0xE0A56F, 0x0F8A69, 0xE0A56F, 0x0F679C } } },
145
  { channel: 1, filter: 3, data: { coeff: { 0x0FD284, 0xE135FB, 0x0F2161, 0xE135FB, 0x0EF3E5 } } },
146
  { channel: 1, filter: 4, data: { coeff: { 0x0E81B1, 0xE6283F, 0x0CE49D, 0xE6283F, 0x0B664F } } },
147
  { channel: 1, filter: 5, data: { coeff: { 0x0F2D62, 0xE98797, 0x0D1E19, 0xE98797, 0x0C4B7B } } },
148
};
149
150
static struct tas_eq_pref_t eqp_15_1_0 = {
151
  sample_rate:  44100,
152
  device_id:    0x15,
153
  output_id:    TAS_OUTPUT_INTERNAL_SPKR,
154
  speaker_id:   0x00,
155
156
  drce:         &eqp_15_1_0_drce,
157
158
  filter_count: 12,
159
  biquads:      eqp_15_1_0_biquads
160
};
161
162
/* ======================================================================== */
163
164
static struct tas_drce_t eqp_0f_2_1_drce={
165
  enable:    1,
166
  above:     { val: 3.0 * (1<<8), expand: 0 },
167
  below:     { val: 1.0 * (1<<8), expand: 0 },
168
  threshold: -15.33  * (1<<8),
169
  energy:    2.4     * (1<<12),
170
  attack:    0.013   * (1<<12),
171
  decay:     0.212   * (1<<12),
172
};
173
174
static struct tas_biquad_ctrl_t eqp_0f_2_1_biquads[]={
175
  { channel: 0, filter: 0, data: { coeff: { 0x0FE143, 0xE05204, 0x0FCCC5, 0xE05266, 0x0FAE6B } } },
176
  { channel: 0, filter: 1, data: { coeff: { 0x102383, 0xE03A03, 0x0FA325, 0xE03A03, 0x0FC6A8 } } },
177
  { channel: 0, filter: 2, data: { coeff: { 0x0FF2AB, 0xE06285, 0x0FB20A, 0xE06285, 0x0FA4B5 } } },
178
  { channel: 0, filter: 3, data: { coeff: { 0x0F544D, 0xE35971, 0x0D8F3A, 0xE35971, 0x0CE388 } } },
179
  { channel: 0, filter: 4, data: { coeff: { 0x13E1D3, 0xF3ECB5, 0x042227, 0xF3ECB5, 0x0803FA } } },
180
  { channel: 0, filter: 5, data: { coeff: { 0x0AC119, 0x034181, 0x078AB1, 0x034181, 0x024BCA } } },
181
182
  { channel: 1, filter: 0, data: { coeff: { 0x0FE143, 0xE05204, 0x0FCCC5, 0xE05266, 0x0FAE6B } } },
183
  { channel: 1, filter: 1, data: { coeff: { 0x102383, 0xE03A03, 0x0FA325, 0xE03A03, 0x0FC6A8 } } },
184
  { channel: 1, filter: 2, data: { coeff: { 0x0FF2AB, 0xE06285, 0x0FB20A, 0xE06285, 0x0FA4B5 } } },
185
  { channel: 1, filter: 3, data: { coeff: { 0x0F544D, 0xE35971, 0x0D8F3A, 0xE35971, 0x0CE388 } } },
186
  { channel: 1, filter: 4, data: { coeff: { 0x13E1D3, 0xF3ECB5, 0x042227, 0xF3ECB5, 0x0803FA } } },
187
  { channel: 1, filter: 5, data: { coeff: { 0x0AC119, 0x034181, 0x078AB1, 0x034181, 0x024BCA } } },
188
};
189
190
static struct tas_eq_pref_t eqp_0f_2_1 = {
191
  sample_rate:  44100,
192
  device_id:    0x0f,
193
  output_id:    TAS_OUTPUT_EXTERNAL_SPKR,
194
  speaker_id:   0x01,
195
196
  drce:         &eqp_0f_2_1_drce,
197
198
  filter_count: 12,
199
  biquads:      eqp_0f_2_1_biquads
200
};
201
202
/* ======================================================================== */
203
204
static struct tas_drce_t eqp_0f_1_0_drce={
205
  enable:    1,
206
  above:     { val: 3.0 * (1<<8), expand: 0 },
207
  below:     { val: 1.0 * (1<<8), expand: 0 },
208
  threshold: -15.33  * (1<<8),
209
  energy:    2.4     * (1<<12),
210
  attack:    0.013   * (1<<12),
211
  decay:     0.212   * (1<<12),
212
};
213
214
static struct tas_biquad_ctrl_t eqp_0f_1_0_biquads[]={
215
  { channel: 0, filter: 0, data: { coeff: { 0x0FCAD3, 0xE06A58, 0x0FCAD3, 0xE06B09, 0x0F9657 } } },
216
  { channel: 0, filter: 1, data: { coeff: { 0x041731, 0x082E63, 0x041731, 0xFD8D08, 0x02CFBD } } },
217
  { channel: 0, filter: 2, data: { coeff: { 0x0FFDC7, 0xE0524C, 0x0FBFAA, 0xE0524C, 0x0FBD72 } } },
218
  { channel: 0, filter: 3, data: { coeff: { 0x0F3D35, 0xE228CA, 0x0EC7B2, 0xE228CA, 0x0E04E8 } } },
219
  { channel: 0, filter: 4, data: { coeff: { 0x0FCEBF, 0xE181C2, 0x0F2656, 0xE181C2, 0x0EF516 } } },
220
  { channel: 0, filter: 5, data: { coeff: { 0x0EC417, 0x073E22, 0x0B0633, 0x073E22, 0x09CA4A } } },
221
222
  { channel: 1, filter: 0, data: { coeff: { 0x0FCAD3, 0xE06A58, 0x0FCAD3, 0xE06B09, 0x0F9657 } } },
223
  { channel: 1, filter: 1, data: { coeff: { 0x041731, 0x082E63, 0x041731, 0xFD8D08, 0x02CFBD } } },
224
  { channel: 1, filter: 2, data: { coeff: { 0x0FFDC7, 0xE0524C, 0x0FBFAA, 0xE0524C, 0x0FBD72 } } },
225
  { channel: 1, filter: 3, data: { coeff: { 0x0F3D35, 0xE228CA, 0x0EC7B2, 0xE228CA, 0x0E04E8 } } },
226
  { channel: 1, filter: 4, data: { coeff: { 0x0FCEBF, 0xE181C2, 0x0F2656, 0xE181C2, 0x0EF516 } } },
227
  { channel: 1, filter: 5, data: { coeff: { 0x0EC417, 0x073E22, 0x0B0633, 0x073E22, 0x09CA4A } } },
228
};
229
230
static struct tas_eq_pref_t eqp_0f_1_0 = {
231
  sample_rate:  44100,
232
  device_id:    0x0f,
233
  output_id:    TAS_OUTPUT_INTERNAL_SPKR,
234
  speaker_id:   0x00,
235
236
  drce:         &eqp_0f_1_0_drce,
237
238
  filter_count: 12,
239
  biquads:      eqp_0f_1_0_biquads
240
};
241
242
/* ======================================================================== */
243
244
static uint tas3001c_master_tab[]={
245
	       0x0,       0x75,       0x9c,       0xbb,
246
	      0xdb,       0xfb,      0x11e,      0x143,
247
	     0x16b,      0x196,      0x1c3,      0x1f5,
248
	     0x229,      0x263,      0x29f,      0x2e1,
249
	     0x328,      0x373,      0x3c5,      0x41b,
250
	     0x478,      0x4dc,      0x547,      0x5b8,
251
	     0x633,      0x6b5,      0x740,      0x7d5,
252
	     0x873,      0x91c,      0x9d2,      0xa92,
253
	     0xb5e,      0xc39,      0xd22,      0xe19,
254
	     0xf20,     0x1037,     0x1161,     0x129e,
255
	    0x13ed,     0x1551,     0x16ca,     0x185d,
256
	    0x1a08,     0x1bcc,     0x1dac,     0x1fa7,
257
	    0x21c1,     0x23fa,     0x2655,     0x28d6,
258
	    0x2b7c,     0x2e4a,     0x3141,     0x3464,
259
	    0x37b4,     0x3b35,     0x3ee9,     0x42d3,
260
	    0x46f6,     0x4b53,     0x4ff0,     0x54ce,
261
	    0x59f2,     0x5f5f,     0x6519,     0x6b24,
262
	    0x7183,     0x783c,     0x7f53,     0x86cc,
263
	    0x8ead,     0x96fa,     0x9fba,     0xa8f2,
264
	    0xb2a7,     0xbce1,     0xc7a5,     0xd2fa,
265
	    0xdee8,     0xeb75,     0xf8aa,    0x1068e,
266
	   0x1152a,    0x12487,    0x134ad,    0x145a5,
267
	   0x1577b,    0x16a37,    0x17df5,    0x192bd,
268
	   0x1a890,    0x1bf7b,    0x1d78d,    0x1f0d1,
269
	   0x20b55,    0x22727,    0x24456,    0x262f2,
270
	   0x2830b
271
};
272
273
static uint tas3001c_mixer_tab[]={
274
	       0x0,      0x748,      0x9be,      0xbaf,
275
	     0xda4,      0xfb1,     0x11de,     0x1431,
276
	    0x16ad,     0x1959,     0x1c37,     0x1f4b,
277
	    0x2298,     0x2628,     0x29fb,     0x2e12,
278
	    0x327d,     0x3734,     0x3c47,     0x41b4,
279
	    0x4787,     0x4dbe,     0x546d,     0x5b86,
280
	    0x632e,     0x6b52,     0x7400,     0x7d54,
281
	    0x873b,     0x91c6,     0x9d1a,     0xa920,
282
	    0xb5e5,     0xc38c,     0xd21b,     0xe18f,
283
	    0xf1f5,    0x1036a,    0x1160f,    0x129d6,
284
	   0x13ed0,    0x1550c,    0x16ca0,    0x185c9,
285
	   0x1a07b,    0x1bcc3,    0x1dab9,    0x1fa75,
286
	   0x21c0f,    0x23fa3,    0x26552,    0x28d64,
287
	   0x2b7c9,    0x2e4a2,    0x31411,    0x3463b,
288
	   0x37b44,    0x3b353,    0x3ee94,    0x42d30,
289
	   0x46f55,    0x4b533,    0x4fefc,    0x54ce5,
290
	   0x59f25,    0x5f5f6,    0x65193,    0x6b23c,
291
	   0x71835,    0x783c3,    0x7f52c,    0x86cc0,
292
	   0x8eacc,    0x96fa5,    0x9fba0,    0xa8f1a,
293
	   0xb2a71,    0xbce0a,    0xc7a4a,    0xd2fa0,
294
	   0xdee7b,    0xeb752,    0xf8a9f,   0x1068e4,
295
	  0x1152a3,   0x12486a,   0x134ac8,   0x145a55,
296
	  0x1577ac,   0x16a370,   0x17df51,   0x192bc2,
297
	  0x1a88f8,   0x1bf7b7,   0x1d78c9,   0x1f0d04,
298
	  0x20b542,   0x227268,   0x244564,   0x262f26,
299
	  0x2830af
300
};
301
302
static uint tas3001c_treble_tab[]={
303
	      0x96,       0x95,       0x95,       0x94,
304
	      0x93,       0x92,       0x92,       0x91,
305
	      0x90,       0x90,       0x8f,       0x8e,
306
	      0x8d,       0x8d,       0x8c,       0x8b,
307
	      0x8a,       0x8a,       0x89,       0x88,
308
	      0x88,       0x87,       0x86,       0x85,
309
	      0x85,       0x84,       0x83,       0x83,
310
	      0x82,       0x81,       0x80,       0x80,
311
	      0x7f,       0x7e,       0x7e,       0x7d,
312
	      0x7c,       0x7b,       0x7b,       0x7a,
313
	      0x79,       0x78,       0x78,       0x77,
314
	      0x76,       0x76,       0x75,       0x74,
315
	      0x73,       0x73,       0x72,       0x71,
316
	      0x71,       0x70,       0x6e,       0x6d,
317
	      0x6d,       0x6c,       0x6b,       0x6a,
318
	      0x69,       0x68,       0x67,       0x66,
319
	      0x65,       0x63,       0x62,       0x62,
320
	      0x60,       0x5f,       0x5d,       0x5c,
321
	      0x5a,       0x58,       0x56,       0x55,
322
	      0x53,       0x51,       0x4f,       0x4c,
323
	      0x4a,       0x48,       0x45,       0x43,
324
	      0x40,       0x3d,       0x3a,       0x37,
325
	      0x35,       0x32,       0x2e,       0x2a,
326
	      0x27,       0x22,       0x1e,       0x1a,
327
	      0x15,       0x11,        0xc,        0x7,
328
	       0x1
329
};
330
331
static uint tas3001c_bass_tab[]={
332
	      0x86,       0x83,       0x81,       0x7f,
333
	      0x7d,       0x7b,       0x79,       0x78,
334
	      0x76,       0x75,       0x74,       0x72,
335
	      0x71,       0x6f,       0x6e,       0x6d,
336
	      0x6c,       0x6b,       0x69,       0x67,
337
	      0x65,       0x64,       0x61,       0x60,
338
	      0x5e,       0x5d,       0x5c,       0x5b,
339
	      0x5a,       0x59,       0x58,       0x57,
340
	      0x56,       0x55,       0x55,       0x54,
341
	      0x53,       0x52,       0x50,       0x4f,
342
	      0x4d,       0x4c,       0x4b,       0x49,
343
	      0x47,       0x45,       0x44,       0x42,
344
	      0x41,       0x3f,       0x3e,       0x3d,
345
	      0x3c,       0x3b,       0x39,       0x38,
346
	      0x37,       0x36,       0x35,       0x34,
347
	      0x33,       0x31,       0x30,       0x2f,
348
	      0x2e,       0x2c,       0x2b,       0x2b,
349
	      0x29,       0x28,       0x27,       0x26,
350
	      0x25,       0x24,       0x22,       0x21,
351
	      0x20,       0x1e,       0x1c,       0x19,
352
	      0x18,       0x18,       0x17,       0x16,
353
	      0x15,       0x14,       0x13,       0x12,
354
	      0x11,       0x10,        0xf,        0xe,
355
	       0xd,        0xb,        0xa,        0x9,
356
	       0x8,        0x6,        0x4,        0x2,
357
	       0x1
358
};
359
360
struct tas_gain_t tas3001c_gain = {
361
  master: tas3001c_master_tab,
362
  treble: tas3001c_treble_tab,
363
  bass:   tas3001c_bass_tab,
364
  mixer:  tas3001c_mixer_tab
365
};
366
367
struct tas_eq_pref_t *tas3001c_eq_prefs[]={
368
  &eqp_0e_2_1,
369
  &eqp_10_1_0,
370
  &eqp_15_2_1,
371
  &eqp_15_1_0,
372
  &eqp_0f_2_1,
373
  &eqp_0f_1_0,
374
  NULL
375
};
(-)linux-2.4.22/drivers/sound/dmasound/tas3004.c (+1173 lines)
Line 0 Link Here
1
/*
2
 * Driver for the i2c/i2s based TA3004 sound chip used
3
 * on some Apple hardware. Also known as "snapper".
4
 *
5
 * Tobias Sargeant <tobias.sargeant@bigpond.com>
6
 * Based upon tas3001c.c by Christopher C. Chimelis <chris@debian.org>:
7
 *
8
 *   TODO:
9
 *   -----
10
 *   * Enable control over input line 2 (is this connected?)
11
 *   * Implement sleep support (at least mute everything and
12
 *   * set gains to minimum during sleep)
13
 *
14
 */
15
16
#include <linux/version.h>
17
#include <linux/module.h>
18
#include <linux/slab.h>
19
#include <linux/proc_fs.h>
20
#include <linux/ioport.h>
21
#include <linux/sysctl.h>
22
#include <linux/types.h>
23
#include <linux/i2c.h>
24
#include <linux/init.h>
25
#include <linux/soundcard.h>
26
#include <linux/interrupt.h>
27
28
#include <asm/uaccess.h>
29
#include <asm/errno.h>
30
#include <asm/io.h>
31
#include <asm/prom.h>
32
33
#include "dmasound.h"
34
#include "tas_common.h"
35
#include "tas3004.h"
36
37
#include "tas_ioctl.h"
38
39
/* #define DEBUG_DRCE */
40
41
#define TAS3004_BIQUAD_FILTER_COUNT  7
42
#define TAS3004_BIQUAD_CHANNEL_COUNT 2
43
44
#define VOL_DEFAULT	(100 * 4 / 5)
45
#define INPUT_DEFAULT	(100 * 4 / 5)
46
#define BASS_DEFAULT	(100 / 2)
47
#define TREBLE_DEFAULT	(100 / 2)
48
49
struct tas3004_data_t {
50
	struct tas_data_t super;
51
	int device_id;
52
	int output_id;
53
	int speaker_id;
54
	struct tas_drce_t drce_state;
55
};
56
57
#define MAKE_TIME(sec,usec) (((sec)<<12) + (50000+(usec/10)*(1<<12))/100000)
58
59
#define MAKE_RATIO(i,f) (((i)<<8) + ((500+(f)*(1<<8))/1000))
60
61
62
static const union tas_biquad_t
63
tas3004_eq_unity={
64
	buf: { 0x100000, 0x000000, 0x000000, 0x000000, 0x000000 }
65
};
66
67
68
static const struct tas_drce_t
69
tas3004_drce_min={
70
	enable:		1,
71
	above:		{ val: MAKE_RATIO(16,0),	expand:0 },
72
	below:		{ val: MAKE_RATIO(2,0),		expand:0 },
73
	threshold:	-0x59a0,
74
	energy:		MAKE_TIME(0,  1700),
75
	attack:		MAKE_TIME(0,  1700),
76
	decay:		MAKE_TIME(0,  1700)
77
};
78
79
80
static const struct tas_drce_t
81
tas3004_drce_max={
82
	enable:		1,
83
	above:		{ val: MAKE_RATIO(1,500),	expand:1 },
84
	below:		{ val: MAKE_RATIO(2,0),		expand:1 },
85
	threshold:	-0x0,
86
	energy:		MAKE_TIME(2,400000),
87
	attack:		MAKE_TIME(2,400000),
88
	decay:		MAKE_TIME(2,400000)
89
};
90
91
92
static const unsigned short time_constants[]={
93
	MAKE_TIME(0,  1700),
94
	MAKE_TIME(0,  3500),
95
	MAKE_TIME(0,  6700),
96
	MAKE_TIME(0, 13000),
97
	MAKE_TIME(0, 26000),
98
	MAKE_TIME(0, 53000),
99
	MAKE_TIME(0,106000),
100
	MAKE_TIME(0,212000),
101
	MAKE_TIME(0,425000),
102
	MAKE_TIME(0,850000),
103
	MAKE_TIME(1,700000),
104
	MAKE_TIME(2,400000),
105
};
106
107
static const unsigned short above_threshold_compression_ratio[]={
108
	MAKE_RATIO( 1, 70),
109
	MAKE_RATIO( 1,140),
110
	MAKE_RATIO( 1,230),
111
	MAKE_RATIO( 1,330),
112
	MAKE_RATIO( 1,450),
113
	MAKE_RATIO( 1,600),
114
	MAKE_RATIO( 1,780),
115
	MAKE_RATIO( 2,  0),
116
	MAKE_RATIO( 2,290),
117
	MAKE_RATIO( 2,670),
118
	MAKE_RATIO( 3,200),
119
	MAKE_RATIO( 4,  0),
120
	MAKE_RATIO( 5,330),
121
	MAKE_RATIO( 8,  0),
122
	MAKE_RATIO(16,  0),
123
};
124
125
static const unsigned short above_threshold_expansion_ratio[]={
126
	MAKE_RATIO(1, 60),
127
	MAKE_RATIO(1,130),
128
	MAKE_RATIO(1,190),
129
	MAKE_RATIO(1,250),
130
	MAKE_RATIO(1,310),
131
	MAKE_RATIO(1,380),
132
	MAKE_RATIO(1,440),
133
	MAKE_RATIO(1,500)
134
};
135
136
static const unsigned short below_threshold_compression_ratio[]={
137
	MAKE_RATIO(1, 70),
138
	MAKE_RATIO(1,140),
139
	MAKE_RATIO(1,230),
140
	MAKE_RATIO(1,330),
141
	MAKE_RATIO(1,450),
142
	MAKE_RATIO(1,600),
143
	MAKE_RATIO(1,780),
144
	MAKE_RATIO(2,  0)
145
};
146
147
static const unsigned short below_threshold_expansion_ratio[]={
148
	MAKE_RATIO(1, 60),
149
	MAKE_RATIO(1,130),
150
	MAKE_RATIO(1,190),
151
	MAKE_RATIO(1,250),
152
	MAKE_RATIO(1,310),
153
	MAKE_RATIO(1,380),
154
	MAKE_RATIO(1,440),
155
	MAKE_RATIO(1,500),
156
	MAKE_RATIO(1,560),
157
	MAKE_RATIO(1,630),
158
	MAKE_RATIO(1,690),
159
	MAKE_RATIO(1,750),
160
	MAKE_RATIO(1,810),
161
	MAKE_RATIO(1,880),
162
	MAKE_RATIO(1,940),
163
	MAKE_RATIO(2,  0)
164
};
165
166
static inline int
167
search(	unsigned short val,
168
	const unsigned short *arr,
169
	const int arrsize) {
170
	/*
171
	 * This could be a binary search, but for small tables,
172
	 * a linear search is likely to be faster
173
	 */
174
175
	int i;
176
177
	for (i=0; i < arrsize; i++)
178
		if (arr[i] >= val)
179
			goto _1;
180
	return arrsize-1;
181
 _1:
182
	if (i == 0)
183
		return 0;
184
	return (arr[i]-val < val-arr[i-1]) ? i : i-1;
185
}
186
187
#define SEARCH(a, b) search(a, b, ARRAY_SIZE(b))
188
189
static inline int
190
time_index(unsigned short time) {
191
	return SEARCH(time, time_constants);
192
}
193
194
195
static inline int
196
above_threshold_compression_index(unsigned short ratio) {
197
	return SEARCH(ratio, above_threshold_compression_ratio);
198
}
199
200
201
static inline int
202
above_threshold_expansion_index(unsigned short ratio) {
203
	return SEARCH(ratio, above_threshold_expansion_ratio);
204
}
205
206
207
static inline int
208
below_threshold_compression_index(unsigned short ratio) {
209
	return SEARCH(ratio, below_threshold_compression_ratio);
210
}
211
212
213
static inline int
214
below_threshold_expansion_index(unsigned short ratio) {
215
	return SEARCH(ratio, below_threshold_expansion_ratio);
216
}
217
218
219
static inline unsigned char db_to_regval(short db) {
220
	int r=0;
221
222
	r=(db+0x59a0) / 0x60;
223
224
	if (r < 0x91) return 0x91;
225
	if (r > 0xef) return 0xef;
226
	return r;
227
}
228
229
230
static inline short quantize_db(short db) {
231
	return db_to_regval(db) * 0x60 - 0x59a0;
232
}
233
234
235
static inline int
236
register_width(enum tas3004_reg_t r)
237
{
238
	switch(r) {
239
	case TAS3004_REG_MCR:
240
 	case TAS3004_REG_TREBLE:
241
	case TAS3004_REG_BASS:
242
	case TAS3004_REG_ANALOG_CTRL:
243
	case TAS3004_REG_TEST1:
244
	case TAS3004_REG_TEST2:
245
	case TAS3004_REG_MCR2:
246
		return 1;
247
248
	case TAS3004_REG_LEFT_LOUD_BIQUAD_GAIN:
249
	case TAS3004_REG_RIGHT_LOUD_BIQUAD_GAIN:
250
		return 3;
251
252
	case TAS3004_REG_DRC:
253
	case TAS3004_REG_VOLUME:
254
		return 6;
255
256
	case TAS3004_REG_LEFT_MIXER:
257
	case TAS3004_REG_RIGHT_MIXER:
258
		return 9;
259
260
	case TAS3004_REG_TEST:
261
		return 10;
262
263
	case TAS3004_REG_LEFT_BIQUAD0:
264
	case TAS3004_REG_LEFT_BIQUAD1:
265
	case TAS3004_REG_LEFT_BIQUAD2:
266
	case TAS3004_REG_LEFT_BIQUAD3:
267
	case TAS3004_REG_LEFT_BIQUAD4:
268
	case TAS3004_REG_LEFT_BIQUAD5:
269
	case TAS3004_REG_LEFT_BIQUAD6:
270
271
	case TAS3004_REG_RIGHT_BIQUAD0:
272
	case TAS3004_REG_RIGHT_BIQUAD1:
273
	case TAS3004_REG_RIGHT_BIQUAD2:
274
	case TAS3004_REG_RIGHT_BIQUAD3:
275
	case TAS3004_REG_RIGHT_BIQUAD4:
276
	case TAS3004_REG_RIGHT_BIQUAD5:
277
	case TAS3004_REG_RIGHT_BIQUAD6:
278
279
	case TAS3004_REG_LEFT_LOUD_BIQUAD:
280
	case TAS3004_REG_RIGHT_LOUD_BIQUAD:
281
		return 15;
282
283
	default:
284
		return 0;
285
	}
286
}
287
288
289
static int
290
tas3004_write_register(	struct tas3004_data_t *self,
291
			enum tas3004_reg_t reg_num,
292
			char *data,
293
			uint write_mode)
294
{
295
	if (reg_num==TAS3004_REG_MCR ||
296
	    reg_num==TAS3004_REG_BASS ||
297
	    reg_num==TAS3004_REG_TREBLE) {
298
		return tas_write_byte_register(&self->super,
299
					       (uint)reg_num,
300
					       *data,
301
					       write_mode);
302
	} else {
303
		return tas_write_register(&self->super,
304
					  (uint)reg_num,
305
					  register_width(reg_num),
306
					  data,
307
					  write_mode);
308
	}
309
}
310
311
312
static int
313
tas3004_sync_register(	struct tas3004_data_t *self,
314
			enum tas3004_reg_t reg_num)
315
{
316
	if (reg_num==TAS3004_REG_MCR ||
317
	    reg_num==TAS3004_REG_BASS ||
318
	    reg_num==TAS3004_REG_TREBLE) {
319
		return tas_sync_byte_register(&self->super,
320
					      (uint)reg_num,
321
					      register_width(reg_num));
322
	} else {
323
		return tas_sync_register(&self->super,
324
					 (uint)reg_num,
325
					 register_width(reg_num));
326
	}
327
}
328
329
330
static int
331
tas3004_read_register(	struct tas3004_data_t *self,
332
			enum tas3004_reg_t reg_num,
333
			char *data,
334
			uint write_mode)
335
{
336
	return tas_read_register(&self->super,
337
				 (uint)reg_num,
338
				 register_width(reg_num),
339
				 data);
340
}
341
342
343
static inline int
344
tas3004_fast_load(struct tas3004_data_t *self, int fast)
345
{
346
	if (fast)
347
		self->super.shadow[TAS3004_REG_MCR][0] |= 0x80;
348
	else
349
		self->super.shadow[TAS3004_REG_MCR][0] &= 0x7f;
350
	return tas3004_sync_register(self,TAS3004_REG_MCR);
351
}
352
353
354
static uint
355
tas3004_supported_mixers(struct tas3004_data_t *self)
356
{
357
	return SOUND_MASK_VOLUME |
358
		SOUND_MASK_PCM |
359
		SOUND_MASK_ALTPCM |
360
		SOUND_MASK_IMIX |
361
		SOUND_MASK_TREBLE |
362
		SOUND_MASK_BASS;
363
}
364
365
366
static int
367
tas3004_mixer_is_stereo(struct tas3004_data_t *self, int mixer)
368
{
369
	switch(mixer) {
370
	case SOUND_MIXER_VOLUME:
371
	case SOUND_MIXER_PCM:
372
	case SOUND_MIXER_ALTPCM:
373
	case SOUND_MIXER_IMIX:
374
		return 1;
375
	default:
376
		return 0;
377
	}
378
}
379
380
381
static uint
382
tas3004_stereo_mixers(struct tas3004_data_t *self)
383
{
384
	uint r = tas3004_supported_mixers(self);
385
	uint i;
386
	
387
	for (i=1; i<SOUND_MIXER_NRDEVICES; i++)
388
		if (r&(1<<i) && !tas3004_mixer_is_stereo(self,i))
389
			r &= ~(1<<i);
390
	return r;
391
}
392
393
394
static int
395
tas3004_get_mixer_level(struct tas3004_data_t *self, int mixer, uint *level)
396
{
397
	if (!self)
398
		return -1;
399
400
	*level = self->super.mixer[mixer];
401
402
	return 0;
403
}
404
405
406
static int
407
tas3004_set_mixer_level(struct tas3004_data_t *self, int mixer, uint level)
408
{
409
	int rc;
410
	tas_shadow_t *shadow;
411
	uint temp;
412
	uint offset=0;
413
414
	if (!self)
415
		return -1;
416
417
	shadow = self->super.shadow;
418
419
	if (!tas3004_mixer_is_stereo(self,mixer))
420
		level = tas_mono_to_stereo(level);
421
	switch(mixer) {
422
	case SOUND_MIXER_VOLUME:
423
		temp = tas3004_gain.master[level&0xff];
424
		SET_4_20(shadow[TAS3004_REG_VOLUME], 0, temp);
425
		temp = tas3004_gain.master[(level>>8)&0xff];
426
		SET_4_20(shadow[TAS3004_REG_VOLUME], 3, temp);
427
		rc = tas3004_sync_register(self,TAS3004_REG_VOLUME);
428
		break;
429
	case SOUND_MIXER_IMIX:
430
		offset += 3;
431
	case SOUND_MIXER_ALTPCM:
432
		offset += 3;
433
	case SOUND_MIXER_PCM:
434
		/*
435
		 * Don't load these in fast mode. The documentation
436
		 * says it can be done in either mode, but testing it
437
		 * shows that fast mode produces ugly clicking.
438
		*/
439
		/* tas3004_fast_load(self,1); */
440
		temp = tas3004_gain.mixer[level&0xff];
441
		SET_4_20(shadow[TAS3004_REG_LEFT_MIXER], offset, temp);
442
		temp = tas3004_gain.mixer[(level>>8)&0xff];
443
		SET_4_20(shadow[TAS3004_REG_RIGHT_MIXER], offset, temp);
444
		rc = tas3004_sync_register(self,TAS3004_REG_LEFT_MIXER);
445
		if (rc == 0)
446
			rc=tas3004_sync_register(self,TAS3004_REG_RIGHT_MIXER);
447
		/* tas3004_fast_load(self,0); */
448
		break;
449
	case SOUND_MIXER_TREBLE:
450
		temp = tas3004_gain.treble[level&0xff];
451
		shadow[TAS3004_REG_TREBLE][0]=temp&0xff;
452
		rc = tas3004_sync_register(self,TAS3004_REG_TREBLE);
453
		break;
454
	case SOUND_MIXER_BASS:
455
		temp = tas3004_gain.bass[level&0xff];
456
		shadow[TAS3004_REG_BASS][0]=temp&0xff;
457
		rc = tas3004_sync_register(self,TAS3004_REG_BASS);
458
		break;
459
	default:
460
		rc = -1;
461
		break;
462
	}
463
	if (rc < 0)
464
		return rc;
465
	self->super.mixer[mixer] = level;
466
	
467
	return 0;
468
}
469
470
471
static int
472
tas3004_leave_sleep(struct tas3004_data_t *self)
473
{
474
	unsigned char mcr = (1<<6)+(2<<4)+(2<<2);
475
476
	if (!self)
477
		return -1;
478
479
	/* Make sure something answers on the i2c bus */
480
	if (tas3004_write_register(self, TAS3004_REG_MCR, &mcr,
481
	    WRITE_NORMAL | FORCE_WRITE) < 0)
482
		return -1;
483
484
	tas3004_fast_load(self, 1);
485
486
	(void)tas3004_sync_register(self,TAS3004_REG_RIGHT_BIQUAD0);
487
	(void)tas3004_sync_register(self,TAS3004_REG_RIGHT_BIQUAD1);
488
	(void)tas3004_sync_register(self,TAS3004_REG_RIGHT_BIQUAD2);
489
	(void)tas3004_sync_register(self,TAS3004_REG_RIGHT_BIQUAD3);
490
	(void)tas3004_sync_register(self,TAS3004_REG_RIGHT_BIQUAD4);
491
	(void)tas3004_sync_register(self,TAS3004_REG_RIGHT_BIQUAD5);
492
	(void)tas3004_sync_register(self,TAS3004_REG_RIGHT_BIQUAD6);
493
494
	(void)tas3004_sync_register(self,TAS3004_REG_LEFT_BIQUAD0);
495
	(void)tas3004_sync_register(self,TAS3004_REG_LEFT_BIQUAD1);
496
	(void)tas3004_sync_register(self,TAS3004_REG_LEFT_BIQUAD2);
497
	(void)tas3004_sync_register(self,TAS3004_REG_LEFT_BIQUAD3);
498
	(void)tas3004_sync_register(self,TAS3004_REG_LEFT_BIQUAD4);
499
	(void)tas3004_sync_register(self,TAS3004_REG_LEFT_BIQUAD5);
500
	(void)tas3004_sync_register(self,TAS3004_REG_LEFT_BIQUAD6);
501
502
	tas3004_fast_load(self, 0);
503
504
	(void)tas3004_sync_register(self,TAS3004_REG_VOLUME);
505
	(void)tas3004_sync_register(self,TAS3004_REG_LEFT_MIXER);
506
	(void)tas3004_sync_register(self,TAS3004_REG_RIGHT_MIXER);
507
	(void)tas3004_sync_register(self,TAS3004_REG_TREBLE);
508
	(void)tas3004_sync_register(self,TAS3004_REG_BASS);
509
510
	return 0;
511
}
512
513
514
static int
515
tas3004_enter_sleep(struct tas3004_data_t *self)
516
{
517
	if (!self)
518
		return -1; 
519
	return 0;
520
}
521
522
523
static int
524
tas3004_sync_biquad(	struct tas3004_data_t *self,
525
			u_int channel,
526
			u_int filter)
527
{
528
	enum tas3004_reg_t reg;
529
530
	if (channel >= TAS3004_BIQUAD_CHANNEL_COUNT ||
531
	    filter  >= TAS3004_BIQUAD_FILTER_COUNT) return -EINVAL;
532
533
	reg=( channel ? TAS3004_REG_RIGHT_BIQUAD0 : TAS3004_REG_LEFT_BIQUAD0 ) + filter;
534
535
	return tas3004_sync_register(self,reg);
536
}
537
538
539
static int
540
tas3004_write_biquad_shadow(	struct tas3004_data_t *self,
541
				u_int channel,
542
				u_int filter,
543
				const union tas_biquad_t *biquad)
544
{
545
	tas_shadow_t *shadow=self->super.shadow;
546
	enum tas3004_reg_t reg;
547
548
	if (channel >= TAS3004_BIQUAD_CHANNEL_COUNT ||
549
	    filter  >= TAS3004_BIQUAD_FILTER_COUNT) return -EINVAL;
550
551
	reg=( channel ? TAS3004_REG_RIGHT_BIQUAD0 : TAS3004_REG_LEFT_BIQUAD0 ) + filter;
552
553
	SET_4_20(shadow[reg], 0,biquad->coeff.b0);
554
	SET_4_20(shadow[reg], 3,biquad->coeff.b1);
555
	SET_4_20(shadow[reg], 6,biquad->coeff.b2);
556
	SET_4_20(shadow[reg], 9,biquad->coeff.a1);
557
	SET_4_20(shadow[reg],12,biquad->coeff.a2);
558
559
	return 0;
560
}
561
562
563
static int
564
tas3004_write_biquad(	struct tas3004_data_t *self,
565
			u_int channel,
566
			u_int filter,
567
			const union tas_biquad_t *biquad)
568
{
569
	int rc;
570
571
	rc=tas3004_write_biquad_shadow(self, channel, filter, biquad);
572
	if (rc < 0) return rc;
573
574
	return tas3004_sync_biquad(self, channel, filter);
575
}
576
577
578
static int
579
tas3004_write_biquad_list(	struct tas3004_data_t *self,
580
				u_int filter_count,
581
				u_int flags,
582
				struct tas_biquad_ctrl_t *biquads)
583
{
584
	int i;
585
	int rc;
586
587
	if (flags & TAS_BIQUAD_FAST_LOAD) tas3004_fast_load(self,1);
588
589
	for (i=0; i<filter_count; i++) {
590
		rc=tas3004_write_biquad(self,
591
					biquads[i].channel,
592
					biquads[i].filter,
593
					&biquads[i].data);
594
		if (rc < 0) break;
595
	}
596
597
	if (flags & TAS_BIQUAD_FAST_LOAD) tas3004_fast_load(self,0);
598
599
	return rc;
600
}
601
602
603
static int
604
tas3004_read_biquad(	struct tas3004_data_t *self,
605
			u_int channel,
606
			u_int filter,
607
			union tas_biquad_t *biquad)
608
{
609
	tas_shadow_t *shadow=self->super.shadow;
610
	enum tas3004_reg_t reg;
611
612
	if (channel >= TAS3004_BIQUAD_CHANNEL_COUNT ||
613
	    filter  >= TAS3004_BIQUAD_FILTER_COUNT) return -EINVAL;
614
615
	reg=( channel ? TAS3004_REG_RIGHT_BIQUAD0 : TAS3004_REG_LEFT_BIQUAD0 ) + filter;
616
617
	biquad->coeff.b0=GET_4_20(shadow[reg], 0);
618
	biquad->coeff.b1=GET_4_20(shadow[reg], 3);
619
	biquad->coeff.b2=GET_4_20(shadow[reg], 6);
620
	biquad->coeff.a1=GET_4_20(shadow[reg], 9);
621
	biquad->coeff.a2=GET_4_20(shadow[reg],12);
622
	
623
	return 0;	
624
}
625
626
627
static int
628
tas3004_eq_rw(	struct tas3004_data_t *self,
629
		u_int cmd,
630
		u_long arg)
631
{
632
	int rc;
633
	struct tas_biquad_ctrl_t biquad;
634
635
	if (copy_from_user((void *)&biquad, (const void *)arg, sizeof(struct tas_biquad_ctrl_t))) {
636
		return -EFAULT;
637
	}
638
639
	if (cmd & SIOC_IN) {
640
		rc=tas3004_write_biquad(self, biquad.channel, biquad.filter, &biquad.data);
641
		if (rc != 0) return rc;
642
	}
643
644
	if (cmd & SIOC_OUT) {
645
		rc=tas3004_read_biquad(self, biquad.channel, biquad.filter, &biquad.data);
646
		if (rc != 0) return rc;
647
648
		if (copy_to_user((void *)arg, (const void *)&biquad, sizeof(struct tas_biquad_ctrl_t))) {
649
			return -EFAULT;
650
		}
651
652
	}
653
	return 0;
654
}
655
656
657
static int
658
tas3004_eq_list_rw(	struct tas3004_data_t *self,
659
			u_int cmd,
660
			u_long arg)
661
{
662
	int rc = 0;
663
	int filter_count;
664
	int flags;
665
	int i,j;
666
	char sync_required[TAS3004_BIQUAD_CHANNEL_COUNT][TAS3004_BIQUAD_FILTER_COUNT];
667
	struct tas_biquad_ctrl_t biquad;
668
669
	memset(sync_required,0,sizeof(sync_required));
670
671
	if (copy_from_user((void *)&filter_count,
672
			   (const void *)arg + offsetof(struct tas_biquad_ctrl_list_t,filter_count),
673
			   sizeof(int))) {
674
		return -EFAULT;
675
	}
676
677
	if (copy_from_user((void *)&flags,
678
			   (const void *)arg + offsetof(struct tas_biquad_ctrl_list_t,flags),
679
			   sizeof(int))) {
680
		return -EFAULT;
681
	}
682
683
	if (cmd & SIOC_IN) {
684
	}
685
686
	for (i=0; i < filter_count; i++) {
687
		if (copy_from_user((void *)&biquad,
688
				   (const void *)arg + offsetof(struct tas_biquad_ctrl_list_t, biquads[i]),
689
				   sizeof(struct tas_biquad_ctrl_t))) {
690
			return -EFAULT;
691
		}
692
693
		if (cmd & SIOC_IN) {
694
			sync_required[biquad.channel][biquad.filter]=1;
695
			rc=tas3004_write_biquad_shadow(self, biquad.channel, biquad.filter, &biquad.data);
696
			if (rc != 0) return rc;
697
		}
698
699
		if (cmd & SIOC_OUT) {
700
			rc=tas3004_read_biquad(self, biquad.channel, biquad.filter, &biquad.data);
701
			if (rc != 0) return rc;
702
703
			if (copy_to_user((void *)arg + offsetof(struct tas_biquad_ctrl_list_t, biquads[i]),
704
					 (const void *)&biquad,
705
					 sizeof(struct tas_biquad_ctrl_t))) {
706
				return -EFAULT;
707
			}
708
		}
709
	}
710
711
	if (cmd & SIOC_IN) {
712
		/*
713
		 * This is OK for the tas3004. For the
714
		 * tas3001c, going into fast load mode causes
715
		 * the treble and bass to be reset to 0dB, and
716
		 * volume controls to be muted.
717
		 */
718
		if (flags & TAS_BIQUAD_FAST_LOAD) tas3004_fast_load(self,1);
719
		for (i=0; i<TAS3004_BIQUAD_CHANNEL_COUNT; i++) {
720
			for (j=0; j<TAS3004_BIQUAD_FILTER_COUNT; j++) {
721
				if (sync_required[i][j]) {
722
					rc=tas3004_sync_biquad(self, i, j);
723
					if (rc < 0) goto out;
724
				}
725
			}
726
		}
727
	out:
728
		if (flags & TAS_BIQUAD_FAST_LOAD)
729
			tas3004_fast_load(self,0);
730
	}
731
732
	return rc;
733
}
734
735
736
static int
737
tas3004_update_drce(	struct tas3004_data_t *self,
738
			int flags,
739
			struct tas_drce_t *drce)
740
{
741
	tas_shadow_t *shadow;
742
	int i;
743
	shadow=self->super.shadow;
744
745
	if (flags & TAS_DRCE_ABOVE_RATIO) {
746
		self->drce_state.above.expand = drce->above.expand;
747
		if (drce->above.val == (1<<8)) {
748
			self->drce_state.above.val = 1<<8;
749
			shadow[TAS3004_REG_DRC][0] = 0x02;
750
					
751
		} else if (drce->above.expand) {
752
			i=above_threshold_expansion_index(drce->above.val);
753
			self->drce_state.above.val=above_threshold_expansion_ratio[i];
754
			shadow[TAS3004_REG_DRC][0] = 0x0a + (i<<3);
755
		} else {
756
			i=above_threshold_compression_index(drce->above.val);
757
			self->drce_state.above.val=above_threshold_compression_ratio[i];
758
			shadow[TAS3004_REG_DRC][0] = 0x08 + (i<<3);
759
		}
760
	}
761
762
	if (flags & TAS_DRCE_BELOW_RATIO) {
763
		self->drce_state.below.expand = drce->below.expand;
764
		if (drce->below.val == (1<<8)) {
765
			self->drce_state.below.val = 1<<8;
766
			shadow[TAS3004_REG_DRC][1] = 0x02;
767
					
768
		} else if (drce->below.expand) {
769
			i=below_threshold_expansion_index(drce->below.val);
770
			self->drce_state.below.val=below_threshold_expansion_ratio[i];
771
			shadow[TAS3004_REG_DRC][1] = 0x08 + (i<<3);
772
		} else {
773
			i=below_threshold_compression_index(drce->below.val);
774
			self->drce_state.below.val=below_threshold_compression_ratio[i];
775
			shadow[TAS3004_REG_DRC][1] = 0x0a + (i<<3);
776
		}
777
	}
778
779
	if (flags & TAS_DRCE_THRESHOLD) {
780
		self->drce_state.threshold=quantize_db(drce->threshold);
781
		shadow[TAS3004_REG_DRC][2] = db_to_regval(self->drce_state.threshold);
782
	}
783
784
	if (flags & TAS_DRCE_ENERGY) {
785
		i=time_index(drce->energy);
786
		self->drce_state.energy=time_constants[i];
787
		shadow[TAS3004_REG_DRC][3] = 0x40 + (i<<4);
788
	}
789
790
	if (flags & TAS_DRCE_ATTACK) {
791
		i=time_index(drce->attack);
792
		self->drce_state.attack=time_constants[i];
793
		shadow[TAS3004_REG_DRC][4] = 0x40 + (i<<4);
794
	}
795
796
	if (flags & TAS_DRCE_DECAY) {
797
		i=time_index(drce->decay);
798
		self->drce_state.decay=time_constants[i];
799
		shadow[TAS3004_REG_DRC][5] = 0x40 + (i<<4);
800
	}
801
802
	if (flags & TAS_DRCE_ENABLE) {
803
		self->drce_state.enable = drce->enable;
804
	}
805
806
	if (!self->drce_state.enable) {
807
		shadow[TAS3004_REG_DRC][0] |= 0x01;
808
	}
809
810
#ifdef DEBUG_DRCE
811
	printk("DRCE: set [ ENABLE:%x ABOVE:%x/%x BELOW:%x/%x THRESH:%x ENERGY:%x ATTACK:%x DECAY:%x\n",
812
	       self->drce_state.enable,
813
	       self->drce_state.above.expand,self->drce_state.above.val,
814
	       self->drce_state.below.expand,self->drce_state.below.val,
815
	       self->drce_state.threshold,
816
	       self->drce_state.energy,
817
	       self->drce_state.attack,
818
	       self->drce_state.decay);
819
820
	printk("DRCE: reg [ %02x %02x %02x %02x %02x %02x ]\n",
821
	       (unsigned char)shadow[TAS3004_REG_DRC][0],
822
	       (unsigned char)shadow[TAS3004_REG_DRC][1],
823
	       (unsigned char)shadow[TAS3004_REG_DRC][2],
824
	       (unsigned char)shadow[TAS3004_REG_DRC][3],
825
	       (unsigned char)shadow[TAS3004_REG_DRC][4],
826
	       (unsigned char)shadow[TAS3004_REG_DRC][5]);
827
#endif
828
829
	return tas3004_sync_register(self, TAS3004_REG_DRC);
830
}
831
832
833
static int
834
tas3004_drce_rw(	struct tas3004_data_t *self,
835
			u_int cmd,
836
			u_long arg)
837
{
838
	int rc;
839
	struct tas_drce_ctrl_t drce_ctrl;
840
841
	if (copy_from_user((void *)&drce_ctrl,
842
			   (const void *)arg,
843
			   sizeof(struct tas_drce_ctrl_t))) {
844
		return -EFAULT;
845
	}
846
847
#ifdef DEBUG_DRCE
848
	printk("DRCE: input [ FLAGS:%x ENABLE:%x ABOVE:%x/%x BELOW:%x/%x THRESH:%x ENERGY:%x ATTACK:%x DECAY:%x\n",
849
	       drce_ctrl.flags,
850
	       drce_ctrl.data.enable,
851
	       drce_ctrl.data.above.expand,drce_ctrl.data.above.val,
852
	       drce_ctrl.data.below.expand,drce_ctrl.data.below.val,
853
	       drce_ctrl.data.threshold,
854
	       drce_ctrl.data.energy,
855
	       drce_ctrl.data.attack,
856
	       drce_ctrl.data.decay);
857
#endif
858
859
	if (cmd & SIOC_IN) {
860
		rc = tas3004_update_drce(self, drce_ctrl.flags, &drce_ctrl.data);
861
		if (rc < 0) return rc;
862
	}
863
864
	if (cmd & SIOC_OUT) {
865
		if (drce_ctrl.flags & TAS_DRCE_ENABLE)
866
			drce_ctrl.data.enable = self->drce_state.enable;
867
		if (drce_ctrl.flags & TAS_DRCE_ABOVE_RATIO)
868
			drce_ctrl.data.above = self->drce_state.above;
869
		if (drce_ctrl.flags & TAS_DRCE_BELOW_RATIO)
870
			drce_ctrl.data.below = self->drce_state.below;
871
		if (drce_ctrl.flags & TAS_DRCE_THRESHOLD)
872
			drce_ctrl.data.threshold = self->drce_state.threshold;
873
		if (drce_ctrl.flags & TAS_DRCE_ENERGY)
874
			drce_ctrl.data.energy = self->drce_state.energy;
875
		if (drce_ctrl.flags & TAS_DRCE_ATTACK)
876
			drce_ctrl.data.attack = self->drce_state.attack;
877
		if (drce_ctrl.flags & TAS_DRCE_DECAY)
878
			drce_ctrl.data.decay = self->drce_state.decay;
879
880
		if (copy_to_user((void *)arg,
881
				 (const void *)&drce_ctrl,
882
				 sizeof(struct tas_drce_ctrl_t))) {
883
			return -EFAULT;
884
		}
885
	}
886
887
	return 0;
888
}
889
890
891
static void
892
tas3004_update_device_parameters(struct tas3004_data_t *self)
893
{
894
	char data;
895
	int i;
896
897
	if (!self) return;
898
899
	if (self->output_id == TAS_OUTPUT_HEADPHONES) {
900
		/* turn on allPass when headphones are plugged in */
901
		data = 0x02;
902
	} else {
903
		data = 0x00;
904
	}
905
906
	tas3004_write_register(self, TAS3004_REG_MCR2, &data, WRITE_NORMAL | FORCE_WRITE);
907
908
	for (i=0; tas3004_eq_prefs[i]; i++) {
909
		struct tas_eq_pref_t *eq = tas3004_eq_prefs[i];
910
911
		if (eq->device_id == self->device_id &&
912
		    (eq->output_id == 0 || eq->output_id == self->output_id) &&
913
		    (eq->speaker_id == 0 || eq->speaker_id == self->speaker_id)) {
914
915
			tas3004_update_drce(self, TAS_DRCE_ALL, eq->drce);
916
			tas3004_write_biquad_list(self, eq->filter_count, TAS_BIQUAD_FAST_LOAD, eq->biquads);
917
918
			break;
919
		}
920
	}
921
}
922
923
static void
924
tas3004_device_change_handler(void *self)
925
{
926
	if (!self) return;
927
928
	tas3004_update_device_parameters((struct tas3004_data_t *)self);
929
}
930
931
static struct tq_struct device_change_task;
932
933
static int
934
tas3004_output_device_change(	struct tas3004_data_t *self,
935
				int device_id,
936
				int output_id,
937
				int speaker_id)
938
{
939
	self->device_id=device_id;
940
	self->output_id=output_id;
941
	self->speaker_id=speaker_id;
942
943
	schedule_task(&device_change_task);
944
945
	return 0;
946
}
947
948
949
static int
950
tas3004_device_ioctl(	struct tas3004_data_t *self,
951
			u_int cmd,
952
			u_long arg)
953
{
954
	switch (cmd) {
955
	case TAS_READ_EQ:
956
	case TAS_WRITE_EQ:
957
		return tas3004_eq_rw(self, cmd, arg);
958
959
	case TAS_READ_EQ_LIST:
960
	case TAS_WRITE_EQ_LIST:
961
		return tas3004_eq_list_rw(self, cmd, arg);
962
963
	case TAS_READ_EQ_FILTER_COUNT:
964
		put_user(TAS3004_BIQUAD_FILTER_COUNT, (uint *)(arg));
965
		return 0;
966
967
	case TAS_READ_EQ_CHANNEL_COUNT:
968
		put_user(TAS3004_BIQUAD_CHANNEL_COUNT, (uint *)(arg));
969
		return 0;
970
971
	case TAS_READ_DRCE:
972
	case TAS_WRITE_DRCE:
973
		return tas3004_drce_rw(self, cmd, arg);
974
975
	case TAS_READ_DRCE_CAPS:
976
		put_user(TAS_DRCE_ENABLE         |
977
			 TAS_DRCE_ABOVE_RATIO    |
978
			 TAS_DRCE_BELOW_RATIO    |
979
			 TAS_DRCE_THRESHOLD      |
980
			 TAS_DRCE_ENERGY         |
981
			 TAS_DRCE_ATTACK         |
982
			 TAS_DRCE_DECAY,
983
			 (uint *)(arg));
984
		return 0;
985
986
	case TAS_READ_DRCE_MIN:
987
	case TAS_READ_DRCE_MAX: {
988
		struct tas_drce_ctrl_t drce_ctrl;
989
		const struct tas_drce_t *drce_copy;
990
991
		if (copy_from_user((void *)&drce_ctrl,
992
				   (const void *)arg,
993
				   sizeof(struct tas_drce_ctrl_t))) {
994
			return -EFAULT;
995
		}
996
997
		if (cmd == TAS_READ_DRCE_MIN) {
998
			drce_copy=&tas3004_drce_min;
999
		} else {
1000
			drce_copy=&tas3004_drce_max;
1001
		}
1002
1003
		if (drce_ctrl.flags & TAS_DRCE_ABOVE_RATIO) {
1004
			drce_ctrl.data.above=drce_copy->above;
1005
		}
1006
		if (drce_ctrl.flags & TAS_DRCE_BELOW_RATIO) {
1007
			drce_ctrl.data.below=drce_copy->below;
1008
		}
1009
		if (drce_ctrl.flags & TAS_DRCE_THRESHOLD) {
1010
			drce_ctrl.data.threshold=drce_copy->threshold;
1011
		}
1012
		if (drce_ctrl.flags & TAS_DRCE_ENERGY) {
1013
			drce_ctrl.data.energy=drce_copy->energy;
1014
		}
1015
		if (drce_ctrl.flags & TAS_DRCE_ATTACK) {
1016
			drce_ctrl.data.attack=drce_copy->attack;
1017
		}
1018
		if (drce_ctrl.flags & TAS_DRCE_DECAY) {
1019
			drce_ctrl.data.decay=drce_copy->decay;
1020
		}
1021
1022
		if (copy_to_user((void *)arg,
1023
				 (const void *)&drce_ctrl,
1024
				 sizeof(struct tas_drce_ctrl_t))) {
1025
			return -EFAULT;
1026
		}
1027
	}
1028
	}
1029
1030
	return -EINVAL;
1031
}
1032
1033
1034
static int
1035
tas3004_init_mixer(struct tas3004_data_t *self)
1036
{
1037
	unsigned char mcr = (1<<6)+(2<<4)+(2<<2);
1038
1039
	/* Make sure something answers on the i2c bus */
1040
	if (tas3004_write_register(self, TAS3004_REG_MCR, &mcr,
1041
	    WRITE_NORMAL | FORCE_WRITE) < 0)
1042
		return -1;
1043
1044
	tas3004_fast_load(self, 1);
1045
1046
	(void)tas3004_sync_register(self,TAS3004_REG_RIGHT_BIQUAD0);
1047
	(void)tas3004_sync_register(self,TAS3004_REG_RIGHT_BIQUAD1);
1048
	(void)tas3004_sync_register(self,TAS3004_REG_RIGHT_BIQUAD2);
1049
	(void)tas3004_sync_register(self,TAS3004_REG_RIGHT_BIQUAD3);
1050
	(void)tas3004_sync_register(self,TAS3004_REG_RIGHT_BIQUAD4);
1051
	(void)tas3004_sync_register(self,TAS3004_REG_RIGHT_BIQUAD5);
1052
	(void)tas3004_sync_register(self,TAS3004_REG_RIGHT_BIQUAD6);
1053
1054
	(void)tas3004_sync_register(self,TAS3004_REG_LEFT_BIQUAD0);
1055
	(void)tas3004_sync_register(self,TAS3004_REG_LEFT_BIQUAD1);
1056
	(void)tas3004_sync_register(self,TAS3004_REG_LEFT_BIQUAD2);
1057
	(void)tas3004_sync_register(self,TAS3004_REG_LEFT_BIQUAD3);
1058
	(void)tas3004_sync_register(self,TAS3004_REG_LEFT_BIQUAD4);
1059
	(void)tas3004_sync_register(self,TAS3004_REG_LEFT_BIQUAD5);
1060
	(void)tas3004_sync_register(self,TAS3004_REG_LEFT_BIQUAD6);
1061
1062
	tas3004_sync_register(self, TAS3004_REG_DRC);
1063
1064
	tas3004_sync_register(self, TAS3004_REG_MCR2);
1065
1066
	tas3004_fast_load(self, 0);
1067
1068
	tas3004_set_mixer_level(self, SOUND_MIXER_VOLUME, VOL_DEFAULT<<8 | VOL_DEFAULT);
1069
	tas3004_set_mixer_level(self, SOUND_MIXER_PCM, INPUT_DEFAULT<<8 | INPUT_DEFAULT);
1070
	tas3004_set_mixer_level(self, SOUND_MIXER_ALTPCM, 0);
1071
	tas3004_set_mixer_level(self, SOUND_MIXER_IMIX, 0);
1072
1073
	tas3004_set_mixer_level(self, SOUND_MIXER_BASS, BASS_DEFAULT);
1074
	tas3004_set_mixer_level(self, SOUND_MIXER_TREBLE, TREBLE_DEFAULT);
1075
1076
	return 0;
1077
}
1078
1079
1080
static int
1081
tas3004_uninit_mixer(struct tas3004_data_t *self)
1082
{
1083
	tas3004_set_mixer_level(self, SOUND_MIXER_VOLUME, 0);
1084
	tas3004_set_mixer_level(self, SOUND_MIXER_PCM, 0);
1085
	tas3004_set_mixer_level(self, SOUND_MIXER_ALTPCM, 0);
1086
	tas3004_set_mixer_level(self, SOUND_MIXER_IMIX, 0);
1087
1088
	tas3004_set_mixer_level(self, SOUND_MIXER_BASS, 0);
1089
	tas3004_set_mixer_level(self, SOUND_MIXER_TREBLE, 0);
1090
1091
	return 0;
1092
}
1093
1094
1095
static int
1096
tas3004_init(struct i2c_client *client)
1097
{
1098
	char drce_init[]={ 0x69, 0x22, 0x9f, 0xb0, 0x60, 0xa0 };
1099
	char mcr2 = 0;
1100
1101
	struct tas3004_data_t *self;
1102
	int i, j;
1103
1104
	self = kmalloc(sizeof(struct tas3004_data_t) +
1105
			TAS3004_REG_MAX * sizeof(tas_shadow_t),
1106
			GFP_KERNEL);
1107
	if (self == NULL)
1108
		return -ENOMEM;
1109
1110
	memset(self,
1111
	       0,
1112
	       sizeof(struct tas3004_data_t) +
1113
	       TAS3004_REG_MAX * sizeof(tas_shadow_t));
1114
1115
	client->data = (void *)self;
1116
1117
	self->super.client = client;
1118
	self->super.shadow = (tas_shadow_t *)(self+1);
1119
1120
	self->output_id=TAS_OUTPUT_HEADPHONES;
1121
	self->device_id=0;
1122
	self->speaker_id=0;
1123
1124
	for (i=0; i<TAS3004_BIQUAD_CHANNEL_COUNT; i++) {
1125
		for (j=0; j<TAS3004_BIQUAD_FILTER_COUNT; j++) {
1126
			tas3004_write_biquad_shadow(self, i, j, &tas3004_eq_unity);
1127
		}
1128
	}
1129
1130
	tas3004_write_register(self, TAS3004_REG_MCR2, &mcr2, WRITE_SHADOW);
1131
	tas3004_write_register(self, TAS3004_REG_DRC, drce_init, WRITE_SHADOW);
1132
1133
	INIT_TQUEUE(&device_change_task, tas3004_device_change_handler, (void *)self);
1134
1135
	return 0;
1136
}
1137
1138
1139
static void 
1140
tas3004_uninit(struct tas3004_data_t *self)
1141
{
1142
	tas3004_uninit_mixer(self);
1143
	kfree(self);
1144
}
1145
1146
1147
struct tas_driver_hooks_t tas3004_hooks = {
1148
	init:                   (tas_hook_init_t)tas3004_init,
1149
	post_init:              (tas_hook_post_init_t)tas3004_init_mixer,
1150
	uninit:                 (tas_hook_uninit_t)tas3004_uninit,
1151
1152
	get_mixer_level:        (tas_hook_get_mixer_level_t)tas3004_get_mixer_level,
1153
	set_mixer_level:        (tas_hook_set_mixer_level_t)tas3004_set_mixer_level,
1154
1155
	enter_sleep:            (tas_hook_enter_sleep_t)tas3004_enter_sleep,
1156
	leave_sleep:            (tas_hook_leave_sleep_t)tas3004_leave_sleep,
1157
1158
	supported_mixers:       (tas_hook_supported_mixers_t)tas3004_supported_mixers,
1159
	mixer_is_stereo:        (tas_hook_mixer_is_stereo_t)tas3004_mixer_is_stereo,
1160
	stereo_mixers:          (tas_hook_stereo_mixers_t)tas3004_stereo_mixers,
1161
1162
	output_device_change:   (tas_hook_output_device_change_t)tas3004_output_device_change,
1163
1164
	device_ioctl:           (tas_hook_device_ioctl_t)tas3004_device_ioctl
1165
};
1166
1167
/*
1168
 * Local Variables:
1169
 * tab-width: 8
1170
 * indent-tabs-mode: t
1171
 * c-basic-offset: 8
1172
 * End:
1173
 */
(-)linux-2.4.22/drivers/sound/dmasound/tas3004.h (+77 lines)
Line 0 Link Here
1
/*
2
 * Header file for the i2c/i2s based TA3004 sound chip used
3
 * on some Apple hardware. Also known as "tumbler".
4
 *
5
 *  This file is subject to the terms and conditions of the GNU General Public
6
 *  License.  See the file COPYING in the main directory of this archive
7
 *  for more details.
8
 *
9
 * Written by Christopher C. Chimelis <chris@debian.org>
10
 */
11
12
#ifndef _TAS3004_H_
13
#define _TAS3004_H_
14
15
#include <linux/types.h>
16
17
#include "tas_common.h"
18
#include "tas_eq_prefs.h"
19
20
/*
21
 * Macros that correspond to the registers that we write to
22
 * when setting the various values.
23
 */
24
25
#define TAS3004_VERSION	        "0.3"
26
#define TAS3004_DATE	        "20011214"
27
28
#define I2C_DRIVERNAME_TAS3004 "TAS3004 driver V " TAS3004_VERSION
29
#define I2C_DRIVERID_TAS3004    (I2C_DRIVERID_TAS_BASE+1)
30
31
extern  struct tas_driver_hooks_t tas3004_hooks;
32
extern struct tas_gain_t tas3004_gain;
33
extern struct tas_eq_pref_t *tas3004_eq_prefs[];
34
35
enum tas3004_reg_t {
36
  TAS3004_REG_MCR                    = 0x01,
37
  TAS3004_REG_DRC                    = 0x02,
38
39
  TAS3004_REG_VOLUME                 = 0x04,
40
  TAS3004_REG_TREBLE                 = 0x05,
41
  TAS3004_REG_BASS                   = 0x06,
42
  TAS3004_REG_LEFT_MIXER             = 0x07,
43
  TAS3004_REG_RIGHT_MIXER            = 0x08,
44
45
  TAS3004_REG_LEFT_BIQUAD0           = 0x0a,
46
  TAS3004_REG_LEFT_BIQUAD1           = 0x0b,
47
  TAS3004_REG_LEFT_BIQUAD2           = 0x0c,
48
  TAS3004_REG_LEFT_BIQUAD3           = 0x0d,
49
  TAS3004_REG_LEFT_BIQUAD4           = 0x0e,
50
  TAS3004_REG_LEFT_BIQUAD5           = 0x0f,
51
  TAS3004_REG_LEFT_BIQUAD6           = 0x10,
52
  
53
  TAS3004_REG_RIGHT_BIQUAD0          = 0x13,
54
  TAS3004_REG_RIGHT_BIQUAD1          = 0x14,
55
  TAS3004_REG_RIGHT_BIQUAD2          = 0x15,
56
  TAS3004_REG_RIGHT_BIQUAD3          = 0x16,
57
  TAS3004_REG_RIGHT_BIQUAD4          = 0x17,
58
  TAS3004_REG_RIGHT_BIQUAD5          = 0x18,
59
  TAS3004_REG_RIGHT_BIQUAD6          = 0x19,
60
61
  TAS3004_REG_LEFT_LOUD_BIQUAD       = 0x21,
62
  TAS3004_REG_RIGHT_LOUD_BIQUAD      = 0x22,
63
64
  TAS3004_REG_LEFT_LOUD_BIQUAD_GAIN  = 0x23,
65
  TAS3004_REG_RIGHT_LOUD_BIQUAD_GAIN = 0x24,
66
67
  TAS3004_REG_TEST                   = 0x29,
68
69
  TAS3004_REG_ANALOG_CTRL            = 0x40,
70
  TAS3004_REG_TEST1                  = 0x41,
71
  TAS3004_REG_TEST2                  = 0x42,
72
  TAS3004_REG_MCR2                   = 0x43,
73
74
  TAS3004_REG_MAX                    = 0x44
75
};
76
77
#endif /* _TAS3004_H_ */
(-)linux-2.4.22/drivers/sound/dmasound/tas3004_tables.c (+301 lines)
Line 0 Link Here
1
#include "tas3004.h"
2
#include "tas_eq_prefs.h"
3
4
static struct tas_drce_t eqp_17_1_0_drce={
5
    enable:    1,
6
    above:     { val: 3.0 * (1<<8), expand: 0 },
7
    below:     { val: 1.0 * (1<<8), expand: 0 },
8
    threshold: -19.12  * (1<<8),
9
    energy:    2.4     * (1<<12),
10
    attack:    0.013   * (1<<12),
11
    decay:     0.212   * (1<<12),
12
};
13
14
static struct tas_biquad_ctrl_t eqp_17_1_0_biquads[]={
15
  { channel: 0, filter: 0, data: { coeff: { 0x0fd0d4, 0xe05e56, 0x0fd0d4, 0xe05ee1, 0x0fa234 } } },
16
  { channel: 0, filter: 1, data: { coeff: { 0x0910d7, 0x088e1a, 0x030651, 0x01dcb1, 0x02c892 } } },
17
  { channel: 0, filter: 2, data: { coeff: { 0x0ff895, 0xe0970b, 0x0f7f00, 0xe0970b, 0x0f7795 } } },
18
  { channel: 0, filter: 3, data: { coeff: { 0x0fd1c4, 0xe1ac22, 0x0ec8cf, 0xe1ac22, 0x0e9a94 } } },
19
  { channel: 0, filter: 4, data: { coeff: { 0x0f7c1c, 0xe3cc03, 0x0df786, 0xe3cc03, 0x0d73a2 } } },
20
  { channel: 0, filter: 5, data: { coeff: { 0x11fb92, 0xf5a1a0, 0x073cd2, 0xf5a1a0, 0x093865 } } },
21
  { channel: 0, filter: 6, data: { coeff: { 0x0e17a9, 0x068b6c, 0x08a0e5, 0x068b6c, 0x06b88e } } },
22
23
  { channel: 1, filter: 0, data: { coeff: { 0x0fd0d4, 0xe05e56, 0x0fd0d4, 0xe05ee1, 0x0fa234 } } },
24
  { channel: 1, filter: 1, data: { coeff: { 0x0910d7, 0x088e1a, 0x030651, 0x01dcb1, 0x02c892 } } },
25
  { channel: 1, filter: 2, data: { coeff: { 0x0ff895, 0xe0970b, 0x0f7f00, 0xe0970b, 0x0f7795 } } },
26
  { channel: 1, filter: 3, data: { coeff: { 0x0fd1c4, 0xe1ac22, 0x0ec8cf, 0xe1ac22, 0x0e9a94 } } },
27
  { channel: 1, filter: 4, data: { coeff: { 0x0f7c1c, 0xe3cc03, 0x0df786, 0xe3cc03, 0x0d73a2 } } },
28
  { channel: 1, filter: 5, data: { coeff: { 0x11fb92, 0xf5a1a0, 0x073cd2, 0xf5a1a0, 0x093865 } } },
29
  { channel: 1, filter: 6, data: { coeff: { 0x0e17a9, 0x068b6c, 0x08a0e5, 0x068b6c, 0x06b88e } } }
30
};
31
32
static struct tas_eq_pref_t eqp_17_1_0 = {
33
  sample_rate:  44100,
34
  device_id:    0x17,
35
  output_id:    TAS_OUTPUT_INTERNAL_SPKR,
36
  speaker_id:   0x00,
37
38
  drce:         &eqp_17_1_0_drce,
39
40
  filter_count: 14,
41
  biquads:      eqp_17_1_0_biquads
42
};
43
44
/* ======================================================================== */
45
46
static struct tas_drce_t eqp_18_1_0_drce={
47
  enable:    1,
48
  above:     { val: 3.0 * (1<<8), expand: 0 },
49
  below:     { val: 1.0 * (1<<8), expand: 0 },
50
  threshold: -13.14  * (1<<8),
51
  energy:    2.4     * (1<<12),
52
  attack:    0.013   * (1<<12),
53
  decay:     0.212   * (1<<12),
54
};
55
56
static struct tas_biquad_ctrl_t eqp_18_1_0_biquads[]={
57
  { channel: 0, filter: 0, data: { coeff: { 0x0f5514, 0xe155d7, 0x0f5514, 0xe15cfa, 0x0eb14b } } },
58
  { channel: 0, filter: 1, data: { coeff: { 0x06ec33, 0x02abe3, 0x015eef, 0xf764d9, 0x03922d } } },
59
  { channel: 0, filter: 2, data: { coeff: { 0x0ef5f2, 0xe67d1f, 0x0bcf37, 0xe67d1f, 0x0ac529 } } },
60
  { channel: 0, filter: 3, data: { coeff: { 0x0db050, 0xe5be4d, 0x0d0c78, 0xe5be4d, 0x0abcc8 } } },
61
  { channel: 0, filter: 4, data: { coeff: { 0x0f1298, 0xe64ec6, 0x0cc03e, 0xe64ec6, 0x0bd2d7 } } },
62
  { channel: 0, filter: 5, data: { coeff: { 0x0c641a, 0x06537a, 0x08d155, 0x06537a, 0x053570 } } },
63
  { channel: 0, filter: 6, data: { coeff: { 0x100000, 0x000000, 0x000000, 0x000000, 0x000000 } } },
64
65
  { channel: 1, filter: 0, data: { coeff: { 0x0f5514, 0xe155d7, 0x0f5514, 0xe15cfa, 0x0eb14b } } },
66
  { channel: 1, filter: 1, data: { coeff: { 0x06ec33, 0x02abe3, 0x015eef, 0xf764d9, 0x03922d } } },
67
  { channel: 1, filter: 2, data: { coeff: { 0x0ef5f2, 0xe67d1f, 0x0bcf37, 0xe67d1f, 0x0ac529 } } },
68
  { channel: 1, filter: 3, data: { coeff: { 0x0db050, 0xe5be4d, 0x0d0c78, 0xe5be4d, 0x0abcc8 } } },
69
  { channel: 1, filter: 4, data: { coeff: { 0x0f1298, 0xe64ec6, 0x0cc03e, 0xe64ec6, 0x0bd2d7 } } },
70
  { channel: 1, filter: 5, data: { coeff: { 0x0c641a, 0x06537a, 0x08d155, 0x06537a, 0x053570 } } },
71
  { channel: 1, filter: 6, data: { coeff: { 0x100000, 0x000000, 0x000000, 0x000000, 0x000000 } } }
72
};
73
74
static struct tas_eq_pref_t eqp_18_1_0 = {
75
  sample_rate:  44100,
76
  device_id:    0x18,
77
  output_id:    TAS_OUTPUT_INTERNAL_SPKR,
78
  speaker_id:   0x00,
79
80
  drce:         &eqp_18_1_0_drce,
81
82
  filter_count: 14,
83
  biquads:      eqp_18_1_0_biquads
84
};
85
86
/* ======================================================================== */
87
88
static struct tas_drce_t eqp_1a_1_0_drce={
89
  enable:    1,
90
  above:     { val: 3.0 * (1<<8), expand: 0 },
91
  below:     { val: 1.0 * (1<<8), expand: 0 },
92
  threshold: -10.75  * (1<<8),
93
  energy:    2.4     * (1<<12),
94
  attack:    0.013   * (1<<12),
95
  decay:     0.212   * (1<<12),
96
};
97
98
static struct tas_biquad_ctrl_t eqp_1a_1_0_biquads[]={
99
  { channel: 0, filter: 0, data: { coeff: { 0x0fb8fd, 0xe08e04, 0x0fb8fd, 0xe08f40, 0x0f7336 } } },
100
  { channel: 0, filter: 1, data: { coeff: { 0x06371d, 0x0c6e3a, 0x06371d, 0x05bfd3, 0x031ca2 } } },
101
  { channel: 0, filter: 2, data: { coeff: { 0x0fa1c0, 0xe18692, 0x0f030e, 0xe18692, 0x0ea4ce } } },
102
  { channel: 0, filter: 3, data: { coeff: { 0x0fe495, 0xe17eff, 0x0f0452, 0xe17eff, 0x0ee8e7 } } },
103
  { channel: 0, filter: 4, data: { coeff: { 0x100857, 0xe7e71c, 0x0e9599, 0xe7e71c, 0x0e9df1 } } },
104
  { channel: 0, filter: 5, data: { coeff: { 0x0fb26e, 0x06a82c, 0x0db2b4, 0x06a82c, 0x0d6522 } } },
105
  { channel: 0, filter: 6, data: { coeff: { 0x11419d, 0xf06cbf, 0x0a4f6e, 0xf06cbf, 0x0b910c } } },
106
107
  { channel: 1, filter: 0, data: { coeff: { 0x0fb8fd, 0xe08e04, 0x0fb8fd, 0xe08f40, 0x0f7336 } } },
108
  { channel: 1, filter: 1, data: { coeff: { 0x06371d, 0x0c6e3a, 0x06371d, 0x05bfd3, 0x031ca2 } } },
109
  { channel: 1, filter: 2, data: { coeff: { 0x0fa1c0, 0xe18692, 0x0f030e, 0xe18692, 0x0ea4ce } } },
110
  { channel: 1, filter: 3, data: { coeff: { 0x0fe495, 0xe17eff, 0x0f0452, 0xe17eff, 0x0ee8e7 } } },
111
  { channel: 1, filter: 4, data: { coeff: { 0x100857, 0xe7e71c, 0x0e9599, 0xe7e71c, 0x0e9df1 } } },
112
  { channel: 1, filter: 5, data: { coeff: { 0x0fb26e, 0x06a82c, 0x0db2b4, 0x06a82c, 0x0d6522 } } },
113
  { channel: 1, filter: 6, data: { coeff: { 0x11419d, 0xf06cbf, 0x0a4f6e, 0xf06cbf, 0x0b910c } } }
114
};
115
116
static struct tas_eq_pref_t eqp_1a_1_0 = {
117
  sample_rate:  44100,
118
  device_id:    0x1a,
119
  output_id:    TAS_OUTPUT_INTERNAL_SPKR,
120
  speaker_id:   0x00,
121
122
  drce:         &eqp_1a_1_0_drce,
123
124
  filter_count: 14,
125
  biquads:      eqp_1a_1_0_biquads
126
};
127
128
/* ======================================================================== */
129
130
static struct tas_drce_t eqp_1c_1_0_drce={
131
  enable:    1,
132
  above:     { val: 3.0 * (1<<8), expand: 0 },
133
  below:     { val: 1.0 * (1<<8), expand: 0 },
134
  threshold: -14.34  * (1<<8),
135
  energy:    2.4     * (1<<12),
136
  attack:    0.013   * (1<<12),
137
  decay:     0.212   * (1<<12),
138
};
139
140
static struct tas_biquad_ctrl_t eqp_1c_1_0_biquads[]={
141
  { channel: 0, filter: 0, data: { coeff: { 0x0f4f95, 0xe160d4, 0x0f4f95, 0xe1686e, 0x0ea6c5 } } },
142
  { channel: 0, filter: 1, data: { coeff: { 0x066b92, 0x0290d4, 0x0148a0, 0xf6853f, 0x03bfc7 } } },
143
  { channel: 0, filter: 2, data: { coeff: { 0x0f57dc, 0xe51c91, 0x0dd1cb, 0xe51c91, 0x0d29a8 } } },
144
  { channel: 0, filter: 3, data: { coeff: { 0x0df1cb, 0xe4fa84, 0x0d7cdc, 0xe4fa84, 0x0b6ea7 } } },
145
  { channel: 0, filter: 4, data: { coeff: { 0x0eba36, 0xe6aa48, 0x0b9f52, 0xe6aa48, 0x0a5989 } } },
146
  { channel: 0, filter: 5, data: { coeff: { 0x0caf02, 0x05ef9d, 0x084beb, 0x05ef9d, 0x04faee } } },
147
  { channel: 0, filter: 6, data: { coeff: { 0x0fc686, 0xe22947, 0x0e4b5d, 0xe22947, 0x0e11e4 } } },
148
149
  { channel: 1, filter: 0, data: { coeff: { 0x0f4f95, 0xe160d4, 0x0f4f95, 0xe1686e, 0x0ea6c5 } } },
150
  { channel: 1, filter: 1, data: { coeff: { 0x066b92, 0x0290d4, 0x0148a0, 0xf6853f, 0x03bfc7 } } },
151
  { channel: 1, filter: 2, data: { coeff: { 0x0f57dc, 0xe51c91, 0x0dd1cb, 0xe51c91, 0x0d29a8 } } },
152
  { channel: 1, filter: 3, data: { coeff: { 0x0df1cb, 0xe4fa84, 0x0d7cdc, 0xe4fa84, 0x0b6ea7 } } },
153
  { channel: 1, filter: 4, data: { coeff: { 0x0eba36, 0xe6aa48, 0x0b9f52, 0xe6aa48, 0x0a5989 } } },
154
  { channel: 1, filter: 5, data: { coeff: { 0x0caf02, 0x05ef9d, 0x084beb, 0x05ef9d, 0x04faee } } },
155
  { channel: 1, filter: 6, data: { coeff: { 0x0fc686, 0xe22947, 0x0e4b5d, 0xe22947, 0x0e11e4 } } }
156
};
157
158
static struct tas_eq_pref_t eqp_1c_1_0 = {
159
  sample_rate:  44100,
160
  device_id:    0x1c,
161
  output_id:    TAS_OUTPUT_INTERNAL_SPKR,
162
  speaker_id:   0x00,
163
164
  drce:         &eqp_1c_1_0_drce,
165
166
  filter_count: 14,
167
  biquads:      eqp_1c_1_0_biquads
168
};
169
170
/* ======================================================================== */
171
172
static uint tas3004_master_tab[]={
173
	       0x0,       0x75,       0x9c,       0xbb,
174
	      0xdb,       0xfb,      0x11e,      0x143,
175
	     0x16b,      0x196,      0x1c3,      0x1f5,
176
	     0x229,      0x263,      0x29f,      0x2e1,
177
	     0x328,      0x373,      0x3c5,      0x41b,
178
	     0x478,      0x4dc,      0x547,      0x5b8,
179
	     0x633,      0x6b5,      0x740,      0x7d5,
180
	     0x873,      0x91c,      0x9d2,      0xa92,
181
	     0xb5e,      0xc39,      0xd22,      0xe19,
182
	     0xf20,     0x1037,     0x1161,     0x129e,
183
	    0x13ed,     0x1551,     0x16ca,     0x185d,
184
	    0x1a08,     0x1bcc,     0x1dac,     0x1fa7,
185
	    0x21c1,     0x23fa,     0x2655,     0x28d6,
186
	    0x2b7c,     0x2e4a,     0x3141,     0x3464,
187
	    0x37b4,     0x3b35,     0x3ee9,     0x42d3,
188
	    0x46f6,     0x4b53,     0x4ff0,     0x54ce,
189
	    0x59f2,     0x5f5f,     0x6519,     0x6b24,
190
	    0x7183,     0x783c,     0x7f53,     0x86cc,
191
	    0x8ead,     0x96fa,     0x9fba,     0xa8f2,
192
	    0xb2a7,     0xbce1,     0xc7a5,     0xd2fa,
193
	    0xdee8,     0xeb75,     0xf8aa,    0x1068e,
194
	   0x1152a,    0x12487,    0x134ad,    0x145a5,
195
	   0x1577b,    0x16a37,    0x17df5,    0x192bd,
196
	   0x1a890,    0x1bf7b,    0x1d78d,    0x1f0d1,
197
	   0x20b55,    0x22727,    0x24456,    0x262f2,
198
	   0x2830b
199
};
200
201
static uint tas3004_mixer_tab[]={
202
	       0x0,      0x748,      0x9be,      0xbaf,
203
	     0xda4,      0xfb1,     0x11de,     0x1431,
204
	    0x16ad,     0x1959,     0x1c37,     0x1f4b,
205
	    0x2298,     0x2628,     0x29fb,     0x2e12,
206
	    0x327d,     0x3734,     0x3c47,     0x41b4,
207
	    0x4787,     0x4dbe,     0x546d,     0x5b86,
208
	    0x632e,     0x6b52,     0x7400,     0x7d54,
209
	    0x873b,     0x91c6,     0x9d1a,     0xa920,
210
	    0xb5e5,     0xc38c,     0xd21b,     0xe18f,
211
	    0xf1f5,    0x1036a,    0x1160f,    0x129d6,
212
	   0x13ed0,    0x1550c,    0x16ca0,    0x185c9,
213
	   0x1a07b,    0x1bcc3,    0x1dab9,    0x1fa75,
214
	   0x21c0f,    0x23fa3,    0x26552,    0x28d64,
215
	   0x2b7c9,    0x2e4a2,    0x31411,    0x3463b,
216
	   0x37b44,    0x3b353,    0x3ee94,    0x42d30,
217
	   0x46f55,    0x4b533,    0x4fefc,    0x54ce5,
218
	   0x59f25,    0x5f5f6,    0x65193,    0x6b23c,
219
	   0x71835,    0x783c3,    0x7f52c,    0x86cc0,
220
	   0x8eacc,    0x96fa5,    0x9fba0,    0xa8f1a,
221
	   0xb2a71,    0xbce0a,    0xc7a4a,    0xd2fa0,
222
	   0xdee7b,    0xeb752,    0xf8a9f,   0x1068e4,
223
	  0x1152a3,   0x12486a,   0x134ac8,   0x145a55,
224
	  0x1577ac,   0x16a370,   0x17df51,   0x192bc2,
225
	  0x1a88f8,   0x1bf7b7,   0x1d78c9,   0x1f0d04,
226
	  0x20b542,   0x227268,   0x244564,   0x262f26,
227
	  0x2830af
228
};
229
230
static uint tas3004_treble_tab[]={
231
	      0x96,       0x95,       0x95,       0x94,
232
	      0x93,       0x92,       0x92,       0x91,
233
	      0x90,       0x90,       0x8f,       0x8e,
234
	      0x8d,       0x8d,       0x8c,       0x8b,
235
	      0x8a,       0x8a,       0x89,       0x88,
236
	      0x88,       0x87,       0x86,       0x85,
237
	      0x85,       0x84,       0x83,       0x83,
238
	      0x82,       0x81,       0x80,       0x80,
239
	      0x7f,       0x7e,       0x7e,       0x7d,
240
	      0x7c,       0x7b,       0x7b,       0x7a,
241
	      0x79,       0x78,       0x78,       0x77,
242
	      0x76,       0x76,       0x75,       0x74,
243
	      0x73,       0x73,       0x72,       0x71,
244
	      0x71,       0x68,       0x45,       0x5b,
245
	      0x6d,       0x6c,       0x6b,       0x6a,
246
	      0x69,       0x68,       0x67,       0x66,
247
	      0x65,       0x63,       0x62,       0x62,
248
	      0x60,       0x5e,       0x5c,       0x5b,
249
	      0x59,       0x57,       0x55,       0x53,
250
	      0x52,       0x4f,       0x4d,       0x4a,
251
	      0x48,       0x46,       0x43,       0x40,
252
	      0x3d,       0x3a,       0x36,       0x33,
253
	      0x2f,       0x2c,       0x27,       0x23,
254
	      0x1f,       0x1a,       0x15,        0xf,
255
	       0x8,        0x5,        0x2,        0x1,
256
	       0x1
257
};
258
259
static uint tas3004_bass_tab[]={
260
	      0x96,       0x95,       0x95,       0x94,
261
	      0x93,       0x92,       0x92,       0x91,
262
	      0x90,       0x90,       0x8f,       0x8e,
263
	      0x8d,       0x8d,       0x8c,       0x8b,
264
	      0x8a,       0x8a,       0x89,       0x88,
265
	      0x88,       0x87,       0x86,       0x85,
266
	      0x85,       0x84,       0x83,       0x83,
267
	      0x82,       0x81,       0x80,       0x80,
268
	      0x7f,       0x7e,       0x7e,       0x7d,
269
	      0x7c,       0x7b,       0x7b,       0x7a,
270
	      0x79,       0x78,       0x78,       0x77,
271
	      0x76,       0x76,       0x75,       0x74,
272
	      0x73,       0x73,       0x72,       0x71,
273
	      0x70,       0x6f,       0x6e,       0x6d,
274
	      0x6c,       0x6b,       0x6a,       0x6a,
275
	      0x69,       0x67,       0x66,       0x66,
276
	      0x65,       0x63,       0x62,       0x62,
277
	      0x61,       0x60,       0x5e,       0x5d,
278
	      0x5b,       0x59,       0x57,       0x55,
279
	      0x53,       0x51,       0x4f,       0x4c,
280
	      0x4a,       0x48,       0x46,       0x44,
281
	      0x41,       0x3e,       0x3b,       0x38,
282
	      0x36,       0x33,       0x2f,       0x2b,
283
	      0x28,       0x24,       0x20,       0x1c,
284
	      0x17,       0x12,        0xd,        0x7,
285
	       0x1
286
};
287
288
struct tas_gain_t tas3004_gain={
289
  master: tas3004_master_tab,
290
  treble: tas3004_treble_tab,
291
  bass:   tas3004_bass_tab,
292
  mixer:  tas3004_mixer_tab
293
};
294
295
struct tas_eq_pref_t *tas3004_eq_prefs[]={
296
  &eqp_17_1_0,
297
  &eqp_18_1_0,
298
  &eqp_1a_1_0,
299
  &eqp_1c_1_0,
300
  NULL
301
};
(-)linux-2.4.22/drivers/sound/dmasound/tas_common.c (+256 lines)
Line 0 Link Here
1
#include <linux/version.h>
2
#include <linux/module.h>
3
#include <linux/slab.h>
4
#include <linux/proc_fs.h>
5
#include <linux/ioport.h>
6
#include <linux/sysctl.h>
7
#include <linux/types.h>
8
#include <linux/i2c.h>
9
#include <linux/init.h>
10
#include <linux/soundcard.h>
11
#include <asm/uaccess.h>
12
#include <asm/errno.h>
13
#include <asm/io.h>
14
#include <asm/prom.h>
15
16
#include "tas_common.h"
17
18
#define CALL0(proc)								\
19
	do {									\
20
		struct tas_data_t *self;					\
21
		if (!tas_client || driver_hooks == NULL)			\
22
			return -1;						\
23
		self = (struct tas_data_t *)tas_client->data;			\
24
		if (driver_hooks->proc)						\
25
			return driver_hooks->proc(self);			\
26
		else								\
27
			return -EINVAL;						\
28
	} while (0)
29
30
#define CALL(proc,arg...)							\
31
	do {									\
32
		struct tas_data_t *self;					\
33
		if (!tas_client || driver_hooks == NULL)			\
34
			return -1;						\
35
		self = (struct tas_data_t *)tas_client->data;			\
36
		if (driver_hooks->proc)						\
37
			return driver_hooks->proc(self, ## arg);		\
38
		else								\
39
			return -EINVAL;						\
40
	} while (0)
41
42
43
static u8 tas_i2c_address = 0x34;
44
static struct i2c_client * tas_client = NULL;
45
46
static int tas_initialized = 0;
47
static struct device_node* tas_node = NULL;
48
49
static int tas_attach_adapter(struct i2c_adapter *);
50
static int tas_detach_client(struct i2c_client *);
51
52
struct i2c_driver tas_driver = {
53
	name:		"",
54
	id:             0,
55
	flags:		I2C_DF_NOTIFY,
56
	attach_adapter:	&tas_attach_adapter,
57
	detach_client:	&tas_detach_client,
58
	command:	NULL,
59
	inc_use:	NULL,
60
	dec_use:	NULL
61
};
62
63
struct tas_driver_hooks_t *driver_hooks;
64
65
int
66
tas_register_driver(struct tas_driver_hooks_t *hooks)
67
{
68
	driver_hooks = hooks;
69
	return 0;
70
}
71
72
int
73
tas_get_mixer_level(int mixer, uint *level)
74
{
75
	CALL(get_mixer_level,mixer,level);
76
}
77
78
int
79
tas_set_mixer_level(int mixer,uint level)
80
{
81
	CALL(set_mixer_level,mixer,level);
82
}
83
84
int
85
tas_enter_sleep(void)
86
{
87
	CALL0(enter_sleep);
88
}
89
90
int
91
tas_leave_sleep(void)
92
{
93
	CALL0(leave_sleep);
94
}
95
96
int
97
tas_supported_mixers(void)
98
{
99
	CALL0(supported_mixers);
100
}
101
102
int
103
tas_mixer_is_stereo(int mixer)
104
{
105
	CALL(mixer_is_stereo,mixer);
106
}
107
108
int
109
tas_stereo_mixers(void)
110
{
111
	CALL0(stereo_mixers);
112
}
113
114
int
115
tas_output_device_change(int device_id,int layout_id,int speaker_id)
116
{
117
	CALL(output_device_change,device_id,layout_id,speaker_id);
118
}
119
120
int
121
tas_device_ioctl(u_int cmd, u_long arg)
122
{
123
	CALL(device_ioctl,cmd,arg);
124
}
125
126
int
127
tas_post_init(void)
128
{
129
	CALL0(post_init);
130
}
131
132
static int
133
tas_detect_client(struct i2c_adapter *adapter, int address)
134
{
135
	int rc = 0;
136
	struct i2c_client *new_client;
137
	struct tas_data_t *data;
138
	const char *client_name = "tas Digital Equalizer";
139
140
	if (driver_hooks == NULL) {
141
		printk(KERN_ERR "tas_detect_client called with no hooks !\n");
142
		return -ENODEV;
143
	}
144
	
145
	new_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
146
	if (!new_client) {
147
		rc = -ENOMEM;
148
		goto bail;
149
	}
150
151
	new_client->data = NULL;
152
153
	new_client->addr = address;
154
	new_client->data = data;
155
	new_client->adapter = adapter;
156
	new_client->driver = &tas_driver;
157
	new_client->flags = 0;
158
159
	strcpy(new_client->name,client_name);
160
161
	new_client->id = 0; /* Only one instance supported */
162
163
        if (driver_hooks->init && driver_hooks->init(new_client)) {
164
		rc = -ENODEV;
165
		goto bail;
166
	}
167
168
	/* Tell the i2c layer a new client has arrived */
169
	if (i2c_attach_client(new_client)) {
170
        	if (driver_hooks->uninit)
171
			driver_hooks->uninit((struct tas_data_t *)new_client->data);
172
		rc = -ENODEV;
173
		goto bail;
174
	}
175
176
	tas_client = new_client;
177
bail:
178
	if (rc && new_client) {
179
		tas_client = NULL;
180
		kfree(new_client);
181
	}
182
	return rc;
183
}
184
185
static int
186
tas_attach_adapter(struct i2c_adapter *adapter)
187
{
188
	if (!strncmp(adapter->name, "mac-io", 6))
189
		return tas_detect_client(adapter, tas_i2c_address);
190
	return 0;
191
}
192
193
static int
194
tas_detach_client(struct i2c_client *client)
195
{
196
	if (client == tas_client) {
197
		driver_hooks->uninit((struct tas_data_t *)client->data);
198
199
		i2c_detach_client(client);
200
		kfree(client);
201
	}
202
	return 0;
203
}
204
205
int __init
206
tas_cleanup(void)
207
{
208
	if (!tas_initialized)
209
		return -ENODEV;
210
	i2c_del_driver(&tas_driver);
211
	tas_initialized = 0;
212
213
	return 0;
214
}
215
216
int __init
217
tas_init(int driver_id, const char *driver_name)
218
{
219
	int rc;
220
	u32* paddr;
221
222
	if (tas_initialized)
223
		return 0;
224
225
        strncpy(tas_driver.name,driver_name,31);
226
        tas_driver.name[31]=0;
227
        tas_driver.id=driver_id;
228
229
	tas_node = find_devices("deq");
230
	if (tas_node == NULL)
231
		return -ENODEV;
232
233
	printk(KERN_INFO "tas driver [%s])\n",tas_driver.name);
234
	paddr = (u32 *)get_property(tas_node, "i2c-address", NULL);
235
	if (paddr) {
236
		tas_i2c_address = (*paddr) >> 1;
237
		printk(KERN_INFO "using i2c address: 0x%x from device-tree\n",
238
		       tas_i2c_address);
239
	} else    
240
		printk(KERN_INFO "using i2c address: 0x%x (default)\n", tas_i2c_address);
241
242
	if ((rc = i2c_add_driver(&tas_driver))) {
243
		printk("tas: Driver registration failed, module not inserted.\n");
244
		tas_cleanup();
245
		return rc;
246
	}
247
	tas_initialized = 1;
248
	return 0;
249
}
250
/*
251
 * Local Variables:
252
 * tab-width: 8
253
 * indent-tabs-mode: t
254
 * c-basic-offset: 8
255
 * End:
256
 */
(-)linux-2.4.22/drivers/sound/dmasound/tas_common.h (+284 lines)
Line 0 Link Here
1
#ifndef _TAS_COMMON_H_
2
#define _TAS_COMMON_H_
3
4
#include <linux/i2c.h>
5
#include <linux/soundcard.h>
6
#include <asm/string.h>
7
8
#define I2C_DRIVERID_TAS_BASE   (0xFEBA)
9
10
#define SET_4_20(shadow, offset, val)                        \
11
	do {                                                 \
12
		(shadow)[(offset)+0] = ((val) >> 16) & 0xff; \
13
		(shadow)[(offset)+1] = ((val) >> 8)  & 0xff; \
14
		(shadow)[(offset)+2] = ((val) >> 0)  & 0xff; \
15
	} while (0)
16
17
#define GET_4_20(shadow, offset)                             \
18
	(((u_int)((shadow)[(offset)+0]) << 16) |             \
19
	 ((u_int)((shadow)[(offset)+1]) <<  8) |             \
20
	 ((u_int)((shadow)[(offset)+2]) <<  0))
21
22
23
#define TAS_BIQUAD_FAST_LOAD 0x01
24
25
#define TAS_DRCE_ENABLE           0x01
26
#define TAS_DRCE_ABOVE_RATIO      0x02
27
#define TAS_DRCE_BELOW_RATIO      0x04
28
#define TAS_DRCE_THRESHOLD        0x08
29
#define TAS_DRCE_ENERGY           0x10
30
#define TAS_DRCE_ATTACK           0x20
31
#define TAS_DRCE_DECAY            0x40
32
33
#define TAS_DRCE_ALL              0x7f
34
35
36
#define TAS_OUTPUT_HEADPHONES     0x00
37
#define TAS_OUTPUT_INTERNAL_SPKR  0x01
38
#define TAS_OUTPUT_EXTERNAL_SPKR  0x02
39
40
41
union tas_biquad_t {
42
	struct {
43
		int b0,b1,b2,a1,a2;
44
	} coeff;
45
	int buf[5];
46
};
47
48
struct tas_biquad_ctrl_t {
49
	u_int channel:4;
50
	u_int filter:4;
51
52
	union tas_biquad_t data;
53
};
54
55
struct tas_biquad_ctrl_list_t {
56
	int flags;
57
	int filter_count;
58
	struct tas_biquad_ctrl_t biquads[0];
59
};
60
61
struct tas_ratio_t {
62
	unsigned short val;    /* 8.8                        */
63
	unsigned short expand; /* 0 = compress, !0 = expand. */
64
};
65
66
struct tas_drce_t {
67
	unsigned short enable;
68
	struct tas_ratio_t above;
69
	struct tas_ratio_t below;
70
	short threshold;       /* dB,       8.8 signed    */
71
	unsigned short energy; /* seconds,  4.12 unsigned */
72
	unsigned short attack; /* seconds,  4.12 unsigned */
73
	unsigned short decay;  /* seconds,  4.12 unsigned */
74
};
75
76
struct tas_drce_ctrl_t {
77
	uint flags;
78
79
	struct tas_drce_t data;
80
};
81
82
struct tas_gain_t
83
{
84
  unsigned int *master;
85
  unsigned int *treble;
86
  unsigned int *bass;
87
  unsigned int *mixer;
88
};
89
90
typedef char tas_shadow_t[16];
91
92
struct tas_data_t
93
{
94
	struct i2c_client *client;
95
	tas_shadow_t *shadow;
96
	uint mixer[SOUND_MIXER_NRDEVICES];
97
};
98
99
typedef int (*tas_hook_init_t)(struct i2c_client *);
100
typedef int (*tas_hook_post_init_t)(struct tas_data_t *);
101
typedef void (*tas_hook_uninit_t)(struct tas_data_t *);
102
103
typedef int (*tas_hook_get_mixer_level_t)(struct tas_data_t *,int,uint *);
104
typedef int (*tas_hook_set_mixer_level_t)(struct tas_data_t *,int,uint);
105
106
typedef int (*tas_hook_enter_sleep_t)(struct tas_data_t *);
107
typedef int (*tas_hook_leave_sleep_t)(struct tas_data_t *);
108
109
typedef int (*tas_hook_supported_mixers_t)(struct tas_data_t *);
110
typedef int (*tas_hook_mixer_is_stereo_t)(struct tas_data_t *,int);
111
typedef int (*tas_hook_stereo_mixers_t)(struct tas_data_t *);
112
113
typedef int (*tas_hook_output_device_change_t)(struct tas_data_t *,int,int,int);
114
typedef int (*tas_hook_device_ioctl_t)(struct tas_data_t *,u_int,u_long);
115
116
struct tas_driver_hooks_t {
117
	/*
118
	 * All hardware initialisation must be performed in
119
	 * post_init(), as tas_dmasound_init() does a hardware reset.
120
	 *
121
	 * init() is called before tas_dmasound_init() so that
122
	 * ouput_device_change() is always called after i2c driver
123
	 * initialisation. The implication is that
124
	 * output_device_change() must cope with the fact that it
125
	 * may be called before post_init().
126
	 */
127
128
	tas_hook_init_t                   init;
129
	tas_hook_post_init_t              post_init;
130
	tas_hook_uninit_t                 uninit;
131
132
	tas_hook_get_mixer_level_t        get_mixer_level;
133
	tas_hook_set_mixer_level_t        set_mixer_level;
134
135
	tas_hook_enter_sleep_t            enter_sleep;
136
	tas_hook_leave_sleep_t            leave_sleep;
137
138
	tas_hook_supported_mixers_t       supported_mixers;
139
	tas_hook_mixer_is_stereo_t        mixer_is_stereo;
140
	tas_hook_stereo_mixers_t          stereo_mixers;
141
142
	tas_hook_output_device_change_t   output_device_change;
143
	tas_hook_device_ioctl_t           device_ioctl;
144
};
145
146
enum tas_write_mode_t {
147
	WRITE_HW     = 0x01,
148
	WRITE_SHADOW = 0x02,
149
	WRITE_NORMAL = 0x03,
150
	FORCE_WRITE  = 0x04
151
};
152
153
static inline uint
154
tas_mono_to_stereo(uint mono)
155
{
156
	mono &=0xff;
157
	return mono | (mono<<8);
158
}
159
160
/*
161
 * Todo: make these functions a bit more efficient !
162
 */
163
static inline int
164
tas_write_register(	struct tas_data_t *self,
165
			uint reg_num,
166
			uint reg_width,
167
			char *data,
168
			uint write_mode)
169
{
170
	int rc;
171
172
	if (reg_width==0 || data==NULL || self==NULL)
173
		return -EINVAL;
174
	if (!(write_mode & FORCE_WRITE) &&
175
	    !memcmp(data,self->shadow[reg_num],reg_width))
176
	    	return 0;
177
178
	if (write_mode & WRITE_SHADOW)
179
		memcpy(self->shadow[reg_num],data,reg_width);
180
	if (write_mode & WRITE_HW) {
181
		rc=i2c_smbus_write_block_data(self->client,
182
					      reg_num,
183
					      reg_width,
184
					      data);
185
		if (rc < 0) {
186
			printk("tas: I2C block write failed \n");  
187
			return rc; 
188
		}
189
	}
190
	return 0;
191
}
192
193
static inline int
194
tas_sync_register(	struct tas_data_t *self,
195
			uint reg_num,
196
			uint reg_width)
197
{
198
	int rc;
199
200
	if (reg_width==0 || self==NULL)
201
		return -EINVAL;
202
	rc=i2c_smbus_write_block_data(self->client,
203
				      reg_num,
204
				      reg_width,
205
				      self->shadow[reg_num]);
206
	if (rc < 0) {
207
		printk("tas: I2C block write failed \n");
208
		return rc;
209
	}
210
	return 0;
211
}
212
213
static inline int
214
tas_write_byte_register(	struct tas_data_t *self,
215
				uint reg_num,
216
				char data,
217
				uint write_mode)
218
{
219
	if (self==NULL)
220
		return -1;
221
	if (!(write_mode & FORCE_WRITE) && data != self->shadow[reg_num][0])
222
		return 0;
223
	if (write_mode & WRITE_SHADOW)
224
		self->shadow[reg_num][0]=data;
225
	if (write_mode & WRITE_HW) {
226
		if (i2c_smbus_write_byte_data(self->client, reg_num, data) < 0) {
227
			printk("tas: I2C byte write failed \n");  
228
			return -1; 
229
		}
230
	}
231
	return 0;
232
}
233
234
static inline int
235
tas_sync_byte_register(	struct tas_data_t *self,
236
			uint reg_num,
237
			uint reg_width)
238
{
239
	if (reg_width==0 || self==NULL)
240
		return -1;
241
	if (i2c_smbus_write_byte_data(
242
	    self->client, reg_num, self->shadow[reg_num][0]) < 0) {
243
		printk("tas: I2C byte write failed \n");
244
		return -1;
245
	}
246
	return 0;
247
}
248
249
static inline int
250
tas_read_register(	struct tas_data_t *self,
251
			uint reg_num,
252
			uint reg_width,
253
			char *data)
254
{
255
	if (reg_width==0 || data==NULL || self==NULL)
256
		return -1;
257
	memcpy(data,self->shadow[reg_num],reg_width);
258
	return 0;
259
}
260
261
extern int tas_register_driver(struct tas_driver_hooks_t *hooks);
262
263
extern int tas_get_mixer_level(int mixer,uint *level);
264
extern int tas_set_mixer_level(int mixer,uint level);
265
extern int tas_enter_sleep(void);
266
extern int tas_leave_sleep(void);
267
extern int tas_supported_mixers(void);
268
extern int tas_mixer_is_stereo(int mixer);
269
extern int tas_stereo_mixers(void);
270
extern int tas_output_device_change(int,int,int);
271
extern int tas_device_ioctl(u_int, u_long);
272
273
extern int tas_cleanup(void);
274
extern int tas_init(int driver_id,const char *driver_name);
275
extern int tas_post_init(void);
276
277
#endif /* _TAS_COMMON_H_ */
278
/*
279
 * Local Variables:
280
 * tab-width: 8
281
 * indent-tabs-mode: t
282
 * c-basic-offset: 8
283
 * End:
284
 */
(-)linux-2.4.22/drivers/sound/dmasound/tas_eq_prefs.h (+24 lines)
Line 0 Link Here
1
#ifndef _TAS_EQ_PREFS_H_
2
#define _TAS_EQ_PREFS_H_
3
4
struct tas_eq_pref_t {
5
	u_int sample_rate;
6
	u_int device_id;
7
	u_int output_id;
8
	u_int speaker_id;
9
10
	struct tas_drce_t *drce;
11
12
	u_int filter_count;
13
	struct tas_biquad_ctrl_t *biquads;
14
};
15
16
#endif /* _TAS_EQ_PREFS_H_ */
17
18
/*
19
 * Local Variables:
20
 * tab-width: 8
21
 * indent-tabs-mode: t
22
 * c-basic-offset: 8
23
 * End:
24
 */
(-)linux-2.4.22/drivers/sound/dmasound/tas_ioctl.h (+24 lines)
Line 0 Link Here
1
#ifndef _TAS_IOCTL_H_
2
#define _TAS_IOCTL_H_
3
4
#include <linux/i2c.h>
5
#include <linux/soundcard.h>
6
7
8
#define TAS_READ_EQ              _SIOR('t',0,struct tas_biquad_ctrl_t)
9
#define TAS_WRITE_EQ             _SIOW('t',0,struct tas_biquad_ctrl_t)
10
11
#define TAS_READ_EQ_LIST         _SIOR('t',1,struct tas_biquad_ctrl_t)
12
#define TAS_WRITE_EQ_LIST        _SIOW('t',1,struct tas_biquad_ctrl_t)
13
14
#define TAS_READ_EQ_FILTER_COUNT  _SIOR('t',2,int)
15
#define TAS_READ_EQ_CHANNEL_COUNT _SIOR('t',3,int)
16
17
#define TAS_READ_DRCE            _SIOR('t',4,struct tas_drce_ctrl_t)
18
#define TAS_WRITE_DRCE           _SIOW('t',4,struct tas_drce_ctrl_t)
19
20
#define TAS_READ_DRCE_CAPS       _SIOR('t',5,int)
21
#define TAS_READ_DRCE_MIN        _SIOR('t',6,int)
22
#define TAS_READ_DRCE_MAX        _SIOR('t',7,int)
23
24
#endif
(-)linux-2.4.22/drivers/usb/host/usb-ohci.c (-13 / +41 lines)
Lines 714-721 Link Here
714
		list_add (&urb->urb_list, entry);
714
		list_add (&urb->urb_list, entry);
715
715
716
		/* drive timeouts by SF (messy, but works) */
716
		/* drive timeouts by SF (messy, but works) */
717
		writel (OHCI_INTR_SF, &ohci->regs->intrenable);	
717
		if (!ohci->sleeping) {
718
		(void)readl (&ohci->regs->intrdisable); /* PCI posting flush */
718
			writel (OHCI_INTR_SF, &ohci->regs->intrenable);	
719
			(void)readl (&ohci->regs->intrdisable); /* PCI posting flush */
720
		}
719
	}
721
	}
720
#endif
722
#endif
721
723
Lines 1010-1015 Link Here
1010
	case PIPE_CONTROL:
1012
	case PIPE_CONTROL:
1011
		ed->hwNextED = 0;
1013
		ed->hwNextED = 0;
1012
		if (ohci->ed_controltail == NULL) {
1014
		if (ohci->ed_controltail == NULL) {
1015
			io_barrier();
1013
			writel (ed->dma, &ohci->regs->ed_controlhead);
1016
			writel (ed->dma, &ohci->regs->ed_controlhead);
1014
		} else {
1017
		} else {
1015
			ohci->ed_controltail->hwNextED = cpu_to_le32 (ed->dma);
1018
			ohci->ed_controltail->hwNextED = cpu_to_le32 (ed->dma);
Lines 1018-1023 Link Here
1018
		if (!ohci->ed_controltail && !ohci->ed_rm_list[0] &&
1021
		if (!ohci->ed_controltail && !ohci->ed_rm_list[0] &&
1019
			!ohci->ed_rm_list[1] && !ohci->sleeping) {
1022
			!ohci->ed_rm_list[1] && !ohci->sleeping) {
1020
			ohci->hc_control |= OHCI_CTRL_CLE;
1023
			ohci->hc_control |= OHCI_CTRL_CLE;
1024
			io_barrier();
1021
			writel (ohci->hc_control, &ohci->regs->control);
1025
			writel (ohci->hc_control, &ohci->regs->control);
1022
		}
1026
		}
1023
		ohci->ed_controltail = edi;	  
1027
		ohci->ed_controltail = edi;	  
Lines 1026-1031 Link Here
1026
	case PIPE_BULK:
1030
	case PIPE_BULK:
1027
		ed->hwNextED = 0;
1031
		ed->hwNextED = 0;
1028
		if (ohci->ed_bulktail == NULL) {
1032
		if (ohci->ed_bulktail == NULL) {
1033
			io_barrier();
1029
			writel (ed->dma, &ohci->regs->ed_bulkhead);
1034
			writel (ed->dma, &ohci->regs->ed_bulkhead);
1030
		} else {
1035
		} else {
1031
			ohci->ed_bulktail->hwNextED = cpu_to_le32 (ed->dma);
1036
			ohci->ed_bulktail->hwNextED = cpu_to_le32 (ed->dma);
Lines 1034-1039 Link Here
1034
		if (!ohci->ed_bulktail && !ohci->ed_rm_list[0] &&
1039
		if (!ohci->ed_bulktail && !ohci->ed_rm_list[0] &&
1035
			!ohci->ed_rm_list[1] && !ohci->sleeping) {
1040
			!ohci->ed_rm_list[1] && !ohci->sleeping) {
1036
			ohci->hc_control |= OHCI_CTRL_BLE;
1041
			ohci->hc_control |= OHCI_CTRL_BLE;
1042
			io_barrier();
1037
			writel (ohci->hc_control, &ohci->regs->control);
1043
			writel (ohci->hc_control, &ohci->regs->control);
1038
		}
1044
		}
1039
		ohci->ed_bulktail = edi;	  
1045
		ohci->ed_bulktail = edi;	  
Lines 1126-1132 Link Here
1126
		if (ed->ed_prev == NULL) {
1132
		if (ed->ed_prev == NULL) {
1127
			if (!ed->hwNextED) {
1133
			if (!ed->hwNextED) {
1128
				ohci->hc_control &= ~OHCI_CTRL_CLE;
1134
				ohci->hc_control &= ~OHCI_CTRL_CLE;
1129
				writel (ohci->hc_control, &ohci->regs->control);
1135
				if (!ohci->sleeping)
1136
				    writel (ohci->hc_control, &ohci->regs->control);
1130
			}
1137
			}
1131
			writel (le32_to_cpup (&ed->hwNextED), &ohci->regs->ed_controlhead);
1138
			writel (le32_to_cpup (&ed->hwNextED), &ohci->regs->ed_controlhead);
1132
		} else {
1139
		} else {
Lines 1143-1149 Link Here
1143
		if (ed->ed_prev == NULL) {
1150
		if (ed->ed_prev == NULL) {
1144
			if (!ed->hwNextED) {
1151
			if (!ed->hwNextED) {
1145
				ohci->hc_control &= ~OHCI_CTRL_BLE;
1152
				ohci->hc_control &= ~OHCI_CTRL_BLE;
1146
				writel (ohci->hc_control, &ohci->regs->control);
1153
				if (!ohci->sleeping)
1154
				    writel (ohci->hc_control, &ohci->regs->control);
1147
			}
1155
			}
1148
			writel (le32_to_cpup (&ed->hwNextED), &ohci->regs->ed_bulkhead);
1156
			writel (le32_to_cpup (&ed->hwNextED), &ohci->regs->ed_bulkhead);
1149
		} else {
1157
		} else {
Lines 1272-1287 Link Here
1272
		return;
1280
		return;
1273
	
1281
	
1274
	ed->hwINFO |= cpu_to_le32 (OHCI_ED_SKIP);
1282
	ed->hwINFO |= cpu_to_le32 (OHCI_ED_SKIP);
1283
	io_barrier();
1275
1284
1276
	if (!ohci->disabled) {
1285
	if (!ohci->disabled) {
1277
		switch (ed->type) {
1286
		switch (ed->type) {
1278
			case PIPE_CONTROL: /* stop control list */
1287
			case PIPE_CONTROL: /* stop control list */
1279
				ohci->hc_control &= ~OHCI_CTRL_CLE;
1288
				ohci->hc_control &= ~OHCI_CTRL_CLE;
1280
				writel (ohci->hc_control, &ohci->regs->control); 
1289
				if (!ohci->sleeping)
1290
				    writel (ohci->hc_control, &ohci->regs->control); 
1281
  				break;
1291
  				break;
1282
			case PIPE_BULK: /* stop bulk list */
1292
			case PIPE_BULK: /* stop bulk list */
1283
				ohci->hc_control &= ~OHCI_CTRL_BLE;
1293
				ohci->hc_control &= ~OHCI_CTRL_BLE;
1284
				writel (ohci->hc_control, &ohci->regs->control); 
1294
				if (!ohci->sleeping)
1295
				    writel (ohci->hc_control, &ohci->regs->control); 
1285
				break;
1296
				break;
1286
		}
1297
		}
1287
	}
1298
	}
Lines 1413-1419 Link Here
1413
			}
1424
			}
1414
1425
1415
			if (!ohci->sleeping) {
1426
			if (!ohci->sleeping) {
1416
				wmb();
1427
				io_barrier();
1417
				writel (OHCI_BLF, &ohci->regs->cmdstatus); /* start bulk list */
1428
				writel (OHCI_BLF, &ohci->regs->cmdstatus); /* start bulk list */
1418
				(void)readl (&ohci->regs->intrdisable); /* PCI posting flush */
1429
				(void)readl (&ohci->regs->intrdisable); /* PCI posting flush */
1419
			}
1430
			}
Lines 1442-1448 Link Here
1442
 				TD_CC | TD_DP_IN | TD_T_DATA1: TD_CC | TD_DP_OUT | TD_T_DATA1;
1453
 				TD_CC | TD_DP_IN | TD_T_DATA1: TD_CC | TD_DP_OUT | TD_T_DATA1;
1443
			td_fill (ohci, info, data, 0, urb, cnt++);
1454
			td_fill (ohci, info, data, 0, urb, cnt++);
1444
			if (!ohci->sleeping) {
1455
			if (!ohci->sleeping) {
1445
				wmb();
1456
				io_barrier();
1446
				writel (OHCI_CLF, &ohci->regs->cmdstatus); /* start Control list */
1457
				writel (OHCI_CLF, &ohci->regs->cmdstatus); /* start Control list */
1447
				(void)readl (&ohci->regs->intrdisable); /* PCI posting flush */
1458
				(void)readl (&ohci->regs->intrdisable); /* PCI posting flush */
1448
			}
1459
			}
Lines 1550-1555 Link Here
1550
  	
1561
  	
1551
	td_list_hc = le32_to_cpup (&ohci->hcca->done_head) & 0xfffffff0;
1562
	td_list_hc = le32_to_cpup (&ohci->hcca->done_head) & 0xfffffff0;
1552
	ohci->hcca->done_head = 0;
1563
	ohci->hcca->done_head = 0;
1564
	wmb();
1553
	
1565
	
1554
	while (td_list_hc) {		
1566
	while (td_list_hc) {		
1555
		td_list = dma_to_td (ohci, td_list_hc);
1567
		td_list = dma_to_td (ohci, td_list_hc);
Lines 1658-1663 Link Here
1658
   	
1670
   	
1659
	/* maybe reenable control and bulk lists */ 
1671
	/* maybe reenable control and bulk lists */ 
1660
	if (!ohci->disabled) {
1672
	if (!ohci->disabled) {
1673
		io_barrier();
1661
		if (ctrl) 	/* reset control list */
1674
		if (ctrl) 	/* reset control list */
1662
			writel (0, &ohci->regs->ed_controlcurrent);
1675
			writel (0, &ohci->regs->ed_controlcurrent);
1663
		if (bulk)	/* reset bulk list */
1676
		if (bulk)	/* reset bulk list */
Lines 2318-2323 Link Here
2318
	struct ohci_regs * regs = ohci->regs;
2331
	struct ohci_regs * regs = ohci->regs;
2319
 	int ints; 
2332
 	int ints; 
2320
2333
2334
	/* Sanity check */
2335
	if (ohci->sleeping)
2336
	    return;
2337
2321
	/* avoid (slow) readl if only WDH happened */
2338
	/* avoid (slow) readl if only WDH happened */
2322
	if ((ohci->hcca->done_head != 0)
2339
	if ((ohci->hcca->done_head != 0)
2323
			&& !(le32_to_cpup (&ohci->hcca->done_head) & 0x01)) {
2340
			&& !(le32_to_cpup (&ohci->hcca->done_head) & 0x01)) {
Lines 2624-2629 Link Here
2624
	if (pci_enable_device(dev) < 0)
2641
	if (pci_enable_device(dev) < 0)
2625
		return -ENODEV;
2642
		return -ENODEV;
2626
2643
2644
#ifdef CONFIG_PMAC_PBOOK
2645
	{
2646
		struct device_node *of_node;
2647
2648
		/* Re-enable USB PAD & cell clock */
2649
		of_node = pci_device_to_OF_node (dev);
2650
		if (of_node)
2651
			pmac_call_feature(PMAC_FTR_USB_ENABLE, of_node, 0, 1);
2652
	}
2653
#endif
2627
        if (!dev->irq) {
2654
        if (!dev->irq) {
2628
        	err("found OHCI device with no IRQ assigned. check BIOS settings!");
2655
        	err("found OHCI device with no IRQ assigned. check BIOS settings!");
2629
		pci_disable_device (dev);
2656
		pci_disable_device (dev);
Lines 2719-2724 Link Here
2719
	info ("USB suspend: usb-%s", dev->slot_name);
2746
	info ("USB suspend: usb-%s", dev->slot_name);
2720
	ohci->sleeping = 1;
2747
	ohci->sleeping = 1;
2721
2748
2749
#ifdef CONFIG_PMAC_PBOOK
2750
	if (_machine == _MACH_Pmac)
2751
		disable_irq (ohci->irq);
2752
	/* else, 2.4 assumes shared irqs -- don't disable */
2753
#endif
2754
2722
	/* First stop processing */
2755
	/* First stop processing */
2723
  	spin_lock_irqsave (&usb_ed_lock, flags);
2756
  	spin_lock_irqsave (&usb_ed_lock, flags);
2724
	ohci->hc_control &= ~(OHCI_CTRL_PLE|OHCI_CTRL_CLE|OHCI_CTRL_BLE|OHCI_CTRL_IE);
2757
	ohci->hc_control &= ~(OHCI_CTRL_PLE|OHCI_CTRL_CLE|OHCI_CTRL_BLE|OHCI_CTRL_IE);
Lines 2732-2742 Link Here
2732
	if (!readl (&ohci->regs->intrstatus) & OHCI_INTR_SF)
2765
	if (!readl (&ohci->regs->intrstatus) & OHCI_INTR_SF)
2733
		mdelay (1);
2766
		mdelay (1);
2734
		
2767
		
2735
#ifdef CONFIG_PMAC_PBOOK
2736
	if (_machine == _MACH_Pmac)
2737
		disable_irq (ohci->irq);
2738
	/* else, 2.4 assumes shared irqs -- don't disable */
2739
#endif
2740
	/* Enable remote wakeup */
2768
	/* Enable remote wakeup */
2741
	writel (readl(&ohci->regs->intrenable) | OHCI_INTR_RD, &ohci->regs->intrenable);
2769
	writel (readl(&ohci->regs->intrenable) | OHCI_INTR_RD, &ohci->regs->intrenable);
2742
2770
(-)linux-2.4.22/drivers/usb/host/usb-ohci.h (-2 / +2 lines)
Lines 58-64 Link Here
58
58
59
	dma_addr_t dma;
59
	dma_addr_t dma;
60
	__u32 unused[3];
60
	__u32 unused[3];
61
} __attribute((aligned(16)));
61
} __attribute((aligned(32)));
62
typedef struct ed ed_t;
62
typedef struct ed ed_t;
63
63
64
 
64
 
Lines 567-573 Link Here
567
		return -ENOMEM;
567
		return -ENOMEM;
568
	ohci->dev_cache = pci_pool_create ("ohci_dev", ohci->ohci_dev,
568
	ohci->dev_cache = pci_pool_create ("ohci_dev", ohci->ohci_dev,
569
		sizeof (struct ohci_device),
569
		sizeof (struct ohci_device),
570
		16 /* byte alignment */,
570
		32 /* byte alignment */,
571
		0 /* no page-crossing issues */,
571
		0 /* no page-crossing issues */,
572
		GFP_KERNEL | OHCI_MEM_FLAGS);
572
		GFP_KERNEL | OHCI_MEM_FLAGS);
573
	if (!ohci->dev_cache)
573
	if (!ohci->dev_cache)
(-)linux-2.4.22/drivers/usb/storage/scsiglue.c (-3 / +8 lines)
Lines 75-90 Link Here
75
{
75
{
76
	struct us_data *us;
76
	struct us_data *us;
77
	char local_name[32];
77
	char local_name[32];
78
	/* Note: this function gets called with io_request_lock spinlock helt! */
78
	spin_unlock_irq(&io_request_lock);
79
	
79
	/* This is not nice at all, but how else are we to get the
80
	/* This is not nice at all, but how else are we to get the
80
	 * data here? */
81
	 * data here? */
81
	us = (struct us_data *)sht->proc_dir;
82
	us = (struct us_data *)sht->proc_dir;
82
83
83
	/* set up the name of our subdirectory under /proc/scsi/ */
84
	/* set up the name of our subdirectory under /proc/scsi/ */
84
	sprintf(local_name, "usb-storage-%d", us->host_number);
85
	sprintf(local_name, "usb-storage-%d", us->host_number);
85
	sht->proc_name = kmalloc (strlen(local_name) + 1, GFP_ATOMIC);
86
	sht->proc_name = kmalloc (strlen(local_name) + 1, GFP_KERNEL);
86
	if (!sht->proc_name) 
87
	if (!sht->proc_name) {
88
		spin_lock_irq(&io_request_lock);
87
		return 0;
89
		return 0;
90
	}
88
	strcpy(sht->proc_name, local_name);
91
	strcpy(sht->proc_name, local_name);
89
92
90
	/* we start with no /proc directory entry */
93
	/* we start with no /proc directory entry */
Lines 95-106 Link Here
95
	if (us->host) {
98
	if (us->host) {
96
		us->host->hostdata[0] = (unsigned long)us;
99
		us->host->hostdata[0] = (unsigned long)us;
97
		us->host_no = us->host->host_no;
100
		us->host_no = us->host->host_no;
101
		spin_lock_irq(&io_request_lock);
98
		return 1;
102
		return 1;
99
	}
103
	}
100
104
101
	/* odd... didn't register properly.  Abort and free pointers */
105
	/* odd... didn't register properly.  Abort and free pointers */
102
	kfree(sht->proc_name);
106
	kfree(sht->proc_name);
103
	sht->proc_name = NULL;
107
	sht->proc_name = NULL;
108
	spin_lock_irq(&io_request_lock);
104
	return 0;
109
	return 0;
105
}
110
}
106
111
(-)linux-2.4.22/drivers/video/Config.in (-1 / +1 lines)
Lines 73-79 Link Here
73
      dep_bool '  Apple "valkyrie" display support' CONFIG_FB_VALKYRIE $CONFIG_ALL_PPC
73
      dep_bool '  Apple "valkyrie" display support' CONFIG_FB_VALKYRIE $CONFIG_ALL_PPC
74
      bool '  Chips 65550 display support' CONFIG_FB_CT65550
74
      bool '  Chips 65550 display support' CONFIG_FB_CT65550
75
      bool '  IMS Twin Turbo display support' CONFIG_FB_IMSTT
75
      bool '  IMS Twin Turbo display support' CONFIG_FB_IMSTT
76
      bool '  S3 Trio display support' CONFIG_FB_S3TRIO
76
      dep_bool '  S3 Trio display support' CONFIG_FB_S3TRIO $CONFIG_ALL_PPC
77
      tristate '  VGA 16-color graphics console' CONFIG_FB_VGA16
77
      tristate '  VGA 16-color graphics console' CONFIG_FB_VGA16
78
   fi
78
   fi
79
   if [ "$CONFIG_PARISC" = "y" ]; then
79
   if [ "$CONFIG_PARISC" = "y" ]; then
(-)linux-2.4.22/drivers/video/aty/atyfb.h (+1 lines)
Lines 124-129 Link Here
124
#endif
124
#endif
125
    } fbcon_cmap;
125
    } fbcon_cmap;
126
    u8 blitter_may_be_busy;
126
    u8 blitter_may_be_busy;
127
    int asleep;
127
#ifdef __sparc__
128
#ifdef __sparc__
128
    u8 mmaped;
129
    u8 mmaped;
129
    int open;
130
    int open;
(-)linux-2.4.22/drivers/video/aty/atyfb_base.c (-14 / +38 lines)
Lines 748-753 Link Here
748
748
749
    info->current_par = *par;
749
    info->current_par = *par;
750
750
751
    if (info->asleep)
752
    	return;
751
    if (info->blitter_may_be_busy)
753
    if (info->blitter_may_be_busy)
752
	wait_for_idle(info);
754
	wait_for_idle(info);
753
    tmp = aty_ld_8(CRTC_GEN_CNTL + 3, info);
755
    tmp = aty_ld_8(CRTC_GEN_CNTL + 3, info);
Lines 1192-1197 Link Here
1192
	return -EINVAL;
1194
	return -EINVAL;
1193
    par->crtc.xoffset = xoffset;
1195
    par->crtc.xoffset = xoffset;
1194
    par->crtc.yoffset = yoffset;
1196
    par->crtc.yoffset = yoffset;
1197
1198
    if (info->asleep)
1199
       	return 0;
1200
1195
    set_off_pitch(par, info);
1201
    set_off_pitch(par, info);
1196
    return 0;
1202
    return 0;
1197
}
1203
}
Lines 1660-1665 Link Here
1660
			}
1666
			}
1661
			break;
1667
			break;
1662
		case PBOOK_SLEEP_NOW:
1668
		case PBOOK_SLEEP_NOW:
1669
			acquire_console_sem();
1663
			if (currcon >= 0)
1670
			if (currcon >= 0)
1664
				fb_display[currcon].dispsw = &fbcon_dummy;
1671
				fb_display[currcon].dispsw = &fbcon_dummy;
1665
			if (info->blitter_may_be_busy)
1672
			if (info->blitter_may_be_busy)
Lines 1675-1685 Link Here
1675
1682
1676
			/* Blank display and LCD */
1683
			/* Blank display and LCD */
1677
			atyfbcon_blank(VESA_POWERDOWN+1, (struct fb_info *)info);
1684
			atyfbcon_blank(VESA_POWERDOWN+1, (struct fb_info *)info);
1685
			info->asleep = 1;
1678
1686
1679
			/* Set chip to "suspend" mode */
1687
			/* Set chip to "suspend" mode */
1680
			result = aty_power_mgmt(1, info);
1688
			result = aty_power_mgmt(1, info);
1689
			release_console_sem();
1681
			break;
1690
			break;
1682
		case PBOOK_WAKE:
1691
		case PBOOK_WAKE:
1692
			acquire_console_sem();
1683
			/* Wakeup chip */
1693
			/* Wakeup chip */
1684
			result = aty_power_mgmt(0, info);
1694
			result = aty_power_mgmt(0, info);
1685
1695
Lines 1690-1695 Link Here
1690
				vfree(info->save_framebuffer);
1700
				vfree(info->save_framebuffer);
1691
				info->save_framebuffer = 0;
1701
				info->save_framebuffer = 0;
1692
			}
1702
			}
1703
			info->asleep = 0;
1693
			/* Restore display */
1704
			/* Restore display */
1694
			if (currcon >= 0) {
1705
			if (currcon >= 0) {
1695
				atyfb_set_dispsw(&fb_display[currcon],
1706
				atyfb_set_dispsw(&fb_display[currcon],
Lines 1697-1702 Link Here
1697
					info->current_par.accel_flags & FB_ACCELF_TEXT);
1708
					info->current_par.accel_flags & FB_ACCELF_TEXT);
1698
			}
1709
			}
1699
			atyfbcon_blank(0, (struct fb_info *)info);
1710
			atyfbcon_blank(0, (struct fb_info *)info);
1711
			/* XXX We may want to re-call atyfb_set_par and make
1712
			 * sure panning & cursor & palette are correct as we
1713
			 * skipped any change to these during suspend.
1714
			 */
1715
			release_console_sem();
1700
			break;
1716
			break;
1701
		}
1717
		}
1702
	}
1718
	}
Lines 2720-2725 Link Here
2720
    struct fb_info_aty *info = (struct fb_info_aty *)fb;
2736
    struct fb_info_aty *info = (struct fb_info_aty *)fb;
2721
    u8 gen_cntl;
2737
    u8 gen_cntl;
2722
2738
2739
    if (info->asleep)
2740
       	return;
2741
2723
#ifdef CONFIG_PMAC_BACKLIGHT
2742
#ifdef CONFIG_PMAC_BACKLIGHT
2724
    if ((_machine == _MACH_Pmac) && blank)
2743
    if ((_machine == _MACH_Pmac) && blank)
2725
    	set_backlight_enable(0);
2744
    	set_backlight_enable(0);
Lines 2792-2814 Link Here
2792
    info->palette[regno].red = red;
2811
    info->palette[regno].red = red;
2793
    info->palette[regno].green = green;
2812
    info->palette[regno].green = green;
2794
    info->palette[regno].blue = blue;
2813
    info->palette[regno].blue = blue;
2795
    i = aty_ld_8(DAC_CNTL, info) & 0xfc;
2814
    if (!info->asleep) {
2796
    if (M64_HAS(EXTRA_BRIGHT))
2815
        i = aty_ld_8(DAC_CNTL, info) & 0xfc;
2797
	i |= 0x2;	/*DAC_CNTL|0x2 turns off the extra brightness for gt*/
2816
        if (M64_HAS(EXTRA_BRIGHT))
2798
    aty_st_8(DAC_CNTL, i, info);
2817
	    i |= 0x2;	/*DAC_CNTL|0x2 turns off the extra brightness for gt*/
2799
    aty_st_8(DAC_MASK, 0xff, info);
2818
        aty_st_8(DAC_CNTL, i, info);
2800
    scale = (M64_HAS(INTEGRATED) && info->current_par.crtc.bpp == 16) ? 3 : 0;
2819
        aty_st_8(DAC_MASK, 0xff, info);
2820
        scale = (M64_HAS(INTEGRATED) && info->current_par.crtc.bpp == 16) ? 3 : 0;
2801
#ifdef CONFIG_ATARI
2821
#ifdef CONFIG_ATARI
2802
    out_8(&info->aty_cmap_regs->windex, regno << scale);
2822
        out_8(&info->aty_cmap_regs->windex, regno << scale);
2803
    out_8(&info->aty_cmap_regs->lut, red);
2823
        out_8(&info->aty_cmap_regs->lut, red);
2804
    out_8(&info->aty_cmap_regs->lut, green);
2824
        out_8(&info->aty_cmap_regs->lut, green);
2805
    out_8(&info->aty_cmap_regs->lut, blue);
2825
        out_8(&info->aty_cmap_regs->lut, blue);
2806
#else
2826
#else
2807
    writeb(regno << scale, &info->aty_cmap_regs->windex);
2827
        writeb(regno << scale, &info->aty_cmap_regs->windex);
2808
    writeb(red, &info->aty_cmap_regs->lut);
2828
        writeb(red, &info->aty_cmap_regs->lut);
2809
    writeb(green, &info->aty_cmap_regs->lut);
2829
        writeb(green, &info->aty_cmap_regs->lut);
2810
    writeb(blue, &info->aty_cmap_regs->lut);
2830
        writeb(blue, &info->aty_cmap_regs->lut);
2811
#endif
2831
#endif
2832
    }
2812
    if (regno < 16)
2833
    if (regno < 16)
2813
	switch (info->current_par.crtc.bpp) {
2834
	switch (info->current_par.crtc.bpp) {
2814
#ifdef FBCON_HAS_CFB16
2835
#ifdef FBCON_HAS_CFB16
Lines 2859-2864 Link Here
2859
    struct vc_data *conp = p->conp;
2880
    struct vc_data *conp = p->conp;
2860
    u32 yres, yoffset, sy, height;
2881
    u32 yres, yoffset, sy, height;
2861
2882
2883
    if (info->asleep)
2884
    	return 0;
2885
    	
2862
    yres = ((par->crtc.v_tot_disp >> 16) & 0x7ff) + 1;
2886
    yres = ((par->crtc.v_tot_disp >> 16) & 0x7ff) + 1;
2863
    yoffset = fb_display[con].var.yoffset;
2887
    yoffset = fb_display[con].var.yoffset;
2864
2888
(-)linux-2.4.22/drivers/video/aty/mach64_cursor.c (-5 / +7 lines)
Lines 54-60 Link Here
54
	const u8 *blue = cursor_color_map;
54
	const u8 *blue = cursor_color_map;
55
	int i;
55
	int i;
56
56
57
	if (!c)
57
	if (!c || fb->asleep)
58
		return;
58
		return;
59
59
60
#ifdef __sparc__
60
#ifdef __sparc__
Lines 81-87 Link Here
81
	u8 *ram, m, b;
81
	u8 *ram, m, b;
82
	int x, y;
82
	int x, y;
83
83
84
	if (!c)
84
	if (!c || fb->asleep)
85
		return;
85
		return;
86
86
87
#ifdef __sparc__
87
#ifdef __sparc__
Lines 118-124 Link Here
118
	u16 xoff, yoff;
118
	u16 xoff, yoff;
119
	int x, y;
119
	int x, y;
120
120
121
	if (!c)
121
	if (!c || fb->asleep)
122
		return;
122
		return;
123
123
124
#ifdef __sparc__
124
#ifdef __sparc__
Lines 297-304 Link Here
297
	    c->mask[i][height-1] = (j >= 8) ? 0xff : (0xff << (8 - j));
297
	    c->mask[i][height-1] = (j >= 8) ? 0xff : (0xff << (8 - j));
298
	}
298
	}
299
299
300
	aty_set_cursor_color(fb);
300
	if (!fb->asleep) {
301
	aty_set_cursor_shape(fb);
301
		aty_set_cursor_color(fb);
302
		aty_set_cursor_shape(fb);
303
	}
302
    }
304
    }
303
    return 1;
305
    return 1;
304
}
306
}
(-)linux-2.4.22/drivers/video/aty128fb.c (-20 / +20 lines)
Lines 55-61 Link Here
55
#include <linux/ioport.h>
55
#include <linux/ioport.h>
56
#include <asm/io.h>
56
#include <asm/io.h>
57
57
58
#ifdef CONFIG_PPC
58
#ifdef CONFIG_ALL_PPC
59
#include <asm/prom.h>
59
#include <asm/prom.h>
60
#include <asm/pci-bridge.h>
60
#include <asm/pci-bridge.h>
61
#include <video/macmodes.h>
61
#include <video/macmodes.h>
Lines 101-107 Link Here
101
#define DBG(fmt, args...)
101
#define DBG(fmt, args...)
102
#endif
102
#endif
103
103
104
#ifndef CONFIG_PPC
104
#ifndef CONFIG_ALL_PPC
105
/* default mode */
105
/* default mode */
106
static struct fb_var_screeninfo default_var __initdata = {
106
static struct fb_var_screeninfo default_var __initdata = {
107
    /* 640x480, 60 Hz, Non-Interlaced (25.175 MHz dotclock) */
107
    /* 640x480, 60 Hz, Non-Interlaced (25.175 MHz dotclock) */
Lines 111-117 Link Here
111
    0, FB_VMODE_NONINTERLACED
111
    0, FB_VMODE_NONINTERLACED
112
};
112
};
113
113
114
#else /* CONFIG_PPC */
114
#else /* CONFIG_ALL_PPC */
115
/* default to 1024x768 at 75Hz on PPC - this will work
115
/* default to 1024x768 at 75Hz on PPC - this will work
116
 * on the iMac, the usual 640x480 @ 60Hz doesn't. */
116
 * on the iMac, the usual 640x480 @ 60Hz doesn't. */
117
static struct fb_var_screeninfo default_var = {
117
static struct fb_var_screeninfo default_var = {
Lines 121-127 Link Here
121
    0, 0, -1, -1, 0, 12699, 160, 32, 28, 1, 96, 3,
121
    0, 0, -1, -1, 0, 12699, 160, 32, 28, 1, 96, 3,
122
    FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
122
    FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
123
};
123
};
124
#endif /* CONFIG_PPC */
124
#endif /* CONFIG_ALL_PPC */
125
125
126
/* default modedb mode */
126
/* default modedb mode */
127
/* 640x480, 60 Hz, Non-Interlaced (25.172 MHz dotclock) */
127
/* 640x480, 60 Hz, Non-Interlaced (25.172 MHz dotclock) */
Lines 171-177 Link Here
171
 };
171
 };
172
172
173
/* packed BIOS settings */
173
/* packed BIOS settings */
174
#ifndef CONFIG_PPC
174
#ifndef CONFIG_ALL_PPC
175
typedef struct {
175
typedef struct {
176
	u8 clock_chip_type;
176
	u8 clock_chip_type;
177
	u8 struct_size;
177
	u8 struct_size;
Lines 196-202 Link Here
196
	u32 XCLK_min_freq;
196
	u32 XCLK_min_freq;
197
	u32 XCLK_max_freq;
197
	u32 XCLK_max_freq;
198
} __attribute__ ((packed)) PLL_BLOCK;
198
} __attribute__ ((packed)) PLL_BLOCK;
199
#endif /* !CONFIG_PPC */
199
#endif /* !CONFIG_ALL_PPC */
200
200
201
/* onboard memory information */
201
/* onboard memory information */
202
struct aty128_meminfo {
202
struct aty128_meminfo {
Lines 233-239 Link Here
233
233
234
static char *mode_option __initdata = NULL;
234
static char *mode_option __initdata = NULL;
235
235
236
#ifdef CONFIG_PPC
236
#ifdef CONFIG_ALL_PPC
237
static int default_vmode __initdata = VMODE_1024_768_60;
237
static int default_vmode __initdata = VMODE_1024_768_60;
238
static int default_cmode __initdata = CMODE_8;
238
static int default_cmode __initdata = CMODE_8;
239
#endif
239
#endif
Lines 397-403 Link Here
397
                               const struct aty128_chip_info *aci);
397
                               const struct aty128_chip_info *aci);
398
static struct fb_info_aty128 *aty128_board_list_add(struct fb_info_aty128
398
static struct fb_info_aty128 *aty128_board_list_add(struct fb_info_aty128
399
				*board_list, struct fb_info_aty128 *new_node);
399
				*board_list, struct fb_info_aty128 *new_node);
400
#if !defined(CONFIG_PPC) && !defined(__sparc__)
400
#if !defined(CONFIG_ALL_PPC) && !defined(__sparc__)
401
static void __init aty128_get_pllinfo(struct fb_info_aty128 *info,
401
static void __init aty128_get_pllinfo(struct fb_info_aty128 *info,
402
			char *bios_seg);
402
			char *bios_seg);
403
static char __init *aty128find_ROM(struct fb_info_aty128 *info);
403
static char __init *aty128find_ROM(struct fb_info_aty128 *info);
Lines 1778-1784 Link Here
1778
            mtrr = 0;
1778
            mtrr = 0;
1779
        }
1779
        }
1780
#endif
1780
#endif
1781
#ifdef CONFIG_PPC
1781
#ifdef CONFIG_ALL_PPC
1782
        /* vmode and cmode depreciated */
1782
        /* vmode and cmode depreciated */
1783
	else if (!strncmp(this_opt, "vmode:", 6)) {
1783
	else if (!strncmp(this_opt, "vmode:", 6)) {
1784
            unsigned int vmode = simple_strtoul(this_opt+6, NULL, 0);
1784
            unsigned int vmode = simple_strtoul(this_opt+6, NULL, 0);
Lines 1801-1807 Link Here
1801
		break;
1801
		break;
1802
            }
1802
            }
1803
        }
1803
        }
1804
#endif /* CONFIG_PPC */
1804
#endif /* CONFIG_ALL_PPC */
1805
        else
1805
        else
1806
            mode_option = this_opt;
1806
            mode_option = this_opt;
1807
    }
1807
    }
Lines 1858-1864 Link Here
1858
#endif
1858
#endif
1859
    
1859
    
1860
    var = default_var;
1860
    var = default_var;
1861
#ifdef CONFIG_PPC
1861
#ifdef CONFIG_ALL_PPC
1862
    if (_machine == _MACH_Pmac) {
1862
    if (_machine == _MACH_Pmac) {
1863
        if (mode_option) {
1863
        if (mode_option) {
1864
            if (!mac_find_mode(&var, &info->fb_info, mode_option, 8))
1864
            if (!mac_find_mode(&var, &info->fb_info, mode_option, 8))
Lines 1897-1903 Link Here
1897
                var = default_var;
1897
                var = default_var;
1898
        }
1898
        }
1899
    } else
1899
    } else
1900
#endif /* CONFIG_PPC */
1900
#endif /* CONFIG_ALL_PPC */
1901
    {
1901
    {
1902
        if (fb_find_mode(&var, &info->fb_info, mode_option, NULL, 0,
1902
        if (fb_find_mode(&var, &info->fb_info, mode_option, NULL, 0,
1903
                          &defaultmode, 8) == 0)
1903
                          &defaultmode, 8) == 0)
Lines 2011-2017 Link Here
2011
	struct fb_info_aty128 *info = NULL;
2011
	struct fb_info_aty128 *info = NULL;
2012
	unsigned long fb_addr, reg_addr;
2012
	unsigned long fb_addr, reg_addr;
2013
	int err;
2013
	int err;
2014
#if !defined(CONFIG_PPC) && !defined(__sparc__)
2014
#if !defined(CONFIG_ALL_PPC) && !defined(__sparc__)
2015
	char *bios_seg = NULL;
2015
	char *bios_seg = NULL;
2016
#endif
2016
#endif
2017
2017
Lines 2074-2080 Link Here
2074
		goto err_out;
2074
		goto err_out;
2075
	}
2075
	}
2076
2076
2077
#if !defined(CONFIG_PPC) && !defined(__sparc__)
2077
#if !defined(CONFIG_ALL_PPC) && !defined(__sparc__)
2078
	if (!(bios_seg = aty128find_ROM(info)))
2078
	if (!(bios_seg = aty128find_ROM(info)))
2079
		printk(KERN_INFO "aty128fb: Rage128 BIOS not located. "
2079
		printk(KERN_INFO "aty128fb: Rage128 BIOS not located. "
2080
					"Guessing...\n");
2080
					"Guessing...\n");
Lines 2126-2132 Link Here
2126
2126
2127
2127
2128
/* PPC and Sparc cannot read video ROM */
2128
/* PPC and Sparc cannot read video ROM */
2129
#if !defined(CONFIG_PPC) && !defined(__sparc__)
2129
#if !defined(CONFIG_ALL_PPC) && !defined(__sparc__)
2130
static char __init
2130
static char __init
2131
*aty128find_ROM(struct fb_info_aty128 *info)
2131
*aty128find_ROM(struct fb_info_aty128 *info)
2132
{
2132
{
Lines 2218-2231 Link Here
2218
			info->constants.dotclock);
2218
			info->constants.dotclock);
2219
2219
2220
}           
2220
}           
2221
#endif /* !CONFIG_PPC */
2221
#endif /* !CONFIG_ALL_PPC */
2222
2222
2223
2223
2224
/* fill in known card constants if pll_block is not available */
2224
/* fill in known card constants if pll_block is not available */
2225
static void __init
2225
static void __init
2226
aty128_timings(struct fb_info_aty128 *info)
2226
aty128_timings(struct fb_info_aty128 *info)
2227
{
2227
{
2228
#ifdef CONFIG_PPC
2228
#ifdef CONFIG_ALL_PPC
2229
    /* instead of a table lookup, assume OF has properly
2229
    /* instead of a table lookup, assume OF has properly
2230
     * setup the PLL registers and use their values
2230
     * setup the PLL registers and use their values
2231
     * to set the XCLK values and reference divider values */
2231
     * to set the XCLK values and reference divider values */
Lines 2240-2246 Link Here
2240
    if (!info->constants.dotclock)
2240
    if (!info->constants.dotclock)
2241
        info->constants.dotclock = 2950;
2241
        info->constants.dotclock = 2950;
2242
2242
2243
#ifdef CONFIG_PPC
2243
#ifdef CONFIG_ALL_PPC
2244
    x_mpll_ref_fb_div = aty_ld_pll(X_MPLL_REF_FB_DIV);
2244
    x_mpll_ref_fb_div = aty_ld_pll(X_MPLL_REF_FB_DIV);
2245
    xclk_cntl = aty_ld_pll(XCLK_CNTL) & 0x7;
2245
    xclk_cntl = aty_ld_pll(XCLK_CNTL) & 0x7;
2246
    Nx = (x_mpll_ref_fb_div & 0x00ff00) >> 8;
2246
    Nx = (x_mpll_ref_fb_div & 0x00ff00) >> 8;
Lines 2468-2476 Link Here
2468
#define ATY_MIRROR_CRT_ON	0x00000002
2468
#define ATY_MIRROR_CRT_ON	0x00000002
2469
2469
2470
/* out param: u32*	backlight value: 0 to 15 */
2470
/* out param: u32*	backlight value: 0 to 15 */
2471
#define FBIO_ATY128_GET_MIRROR	_IOR('@', 1, sizeof(__u32*))
2471
#define FBIO_ATY128_GET_MIRROR	_IOR('@', 1, __u32)
2472
/* in param: u32*	backlight value: 0 to 15 */
2472
/* in param: u32*	backlight value: 0 to 15 */
2473
#define FBIO_ATY128_SET_MIRROR	_IOW('@', 2, sizeof(__u32*))
2473
#define FBIO_ATY128_SET_MIRROR	_IOW('@', 2, __u32)
2474
2474
2475
static int aty128fb_ioctl(struct inode *inode, struct file *file, u_int cmd,
2475
static int aty128fb_ioctl(struct inode *inode, struct file *file, u_int cmd,
2476
		       u_long arg, int con, struct fb_info *info)
2476
		       u_long arg, int con, struct fb_info *info)
(-)linux-2.4.22/drivers/video/offb.c (+4 lines)
Lines 448-453 Link Here
448
		unsigned long regbase = dp->addrs[1].address;
448
		unsigned long regbase = dp->addrs[1].address;
449
		info->cmap_adr = ioremap(regbase, 0x1FFF);
449
		info->cmap_adr = ioremap(regbase, 0x1FFF);
450
		info->cmap_type = cmap_radeon;
450
		info->cmap_type = cmap_radeon;
451
	} else if (dp && !strncmp(name, "ATY,BlueStar", 12)) {
452
		unsigned long regbase = dp->addrs[2].address;
453
		info->cmap_adr = ioremap(regbase, 0x1FFF);
454
		info->cmap_type = cmap_radeon;
451
	} else if (!strncmp(name, "ATY,", 4)) {
455
	} else if (!strncmp(name, "ATY,", 4)) {
452
		/* Hrm... this is bad... any recent ATI not covered
456
		/* Hrm... this is bad... any recent ATI not covered
453
		 * by the previous cases will get there, while this
457
		 * by the previous cases will get there, while this
(-)linux-2.4.22/drivers/video/radeon.h (+9 lines)
Lines 368-373 Link Here
368
#define DST_PITCH_OFFSET                       0x142C
368
#define DST_PITCH_OFFSET                       0x142C
369
#define DEFAULT_PITCH_OFFSET                   0x16E0  
369
#define DEFAULT_PITCH_OFFSET                   0x16E0  
370
#define DEFAULT_SC_BOTTOM_RIGHT                0x16E8  
370
#define DEFAULT_SC_BOTTOM_RIGHT                0x16E8  
371
#define SRC_PITCH_OFFSET                       0x1428
372
#define DST_PITCH_OFFSET                       0x142C
371
#define DP_GUI_MASTER_CNTL                     0x146C  
373
#define DP_GUI_MASTER_CNTL                     0x146C  
372
#define SC_TOP_LEFT                            0x16EC  
374
#define SC_TOP_LEFT                            0x16EC  
373
#define SC_BOTTOM_RIGHT                        0x16F0  
375
#define SC_BOTTOM_RIGHT                        0x16F0  
Lines 376-381 Link Here
376
#define RB2D_DSTCACHE_CTLSTAT		       0x342C
378
#define RB2D_DSTCACHE_CTLSTAT		       0x342C
377
#define LVDS_GEN_CNTL			       0x02d0
379
#define LVDS_GEN_CNTL			       0x02d0
378
#define LVDS_PLL_CNTL			       0x02d4
380
#define LVDS_PLL_CNTL			       0x02d4
381
#define FP2_GEN_CNTL                           0x0288
379
#define TMDS_CNTL                              0x0294
382
#define TMDS_CNTL                              0x0294
380
#define TMDS_CRC			       0x02a0
383
#define TMDS_CRC			       0x02a0
381
#define TMDS_TRANSMITTER_CNTL		       0x02a4
384
#define TMDS_TRANSMITTER_CNTL		       0x02a4
Lines 801-806 Link Here
801
/* MPLL_CNTL bit constants */
804
/* MPLL_CNTL bit constants */
802
#define MPLL_RESET                                 0x00000001
805
#define MPLL_RESET                                 0x00000001
803
806
807
/* MDLL_CKO bit constants */
808
#define MCKOA_SLEEP                                0x00000001
809
#define MCKOA_RESET                                0x00000002
810
#define MCKOA_REF_SKEW_MASK                        0x00000700
811
#define MCKOA_FB_SKEW_MASK                         0x00007000
812
804
/* MDLL_RDCKA bit constants */
813
/* MDLL_RDCKA bit constants */
805
#define MRDCKA0_SLEEP                              0x00000001
814
#define MRDCKA0_SLEEP                              0x00000001
806
#define MRDCKA0_RESET                              0x00000002
815
#define MRDCKA0_RESET                              0x00000002
(-)linux-2.4.22/drivers/video/riva/Makefile (-1 / +1 lines)
Lines 9-15 Link Here
9
9
10
O_TARGET := rivafb.o
10
O_TARGET := rivafb.o
11
11
12
obj-y    := fbdev.o riva_hw.o accel.o
12
obj-y    := fbdev.o nv_setup.o riva_hw.o accel.o
13
obj-m    := $(O_TARGET)
13
obj-m    := $(O_TARGET)
14
14
15
include $(TOPDIR)/Rules.make
15
include $(TOPDIR)/Rules.make
(-)linux-2.4.22/drivers/video/riva/accel.c (-23 / +21 lines)
Lines 14-19 Link Here
14
14
15
inline void wait_for_idle(struct rivafb_info *rinfo)
15
inline void wait_for_idle(struct rivafb_info *rinfo)
16
{
16
{
17
	mb();
17
	while (rinfo->riva.Busy(&rinfo->riva));
18
	while (rinfo->riva.Busy(&rinfo->riva));
18
}
19
}
19
20
Lines 48-54 Link Here
48
49
49
	RIVA_FIFO_FREE(rinfo->riva, Bitmap, 2);
50
	RIVA_FIFO_FREE(rinfo->riva, Bitmap, 2);
50
	rinfo->riva.Bitmap->UnclippedRectangle[0].TopLeft     = (sx << 16) | sy; 
51
	rinfo->riva.Bitmap->UnclippedRectangle[0].TopLeft     = (sx << 16) | sy; 
52
	wmb();
51
	rinfo->riva.Bitmap->UnclippedRectangle[0].WidthHeight = (width << 16) | height;
53
	rinfo->riva.Bitmap->UnclippedRectangle[0].WidthHeight = (width << 16) | height;
54
	wmb();
52
}
55
}
53
56
54
static void fbcon_riva_bmove(struct display *p, int sy, int sx, int dy, int dx,
57
static void fbcon_riva_bmove(struct display *p, int sy, int sx, int dy, int dx,
Lines 66-71 Link Here
66
	RIVA_FIFO_FREE(rinfo->riva, Blt, 3);
69
	RIVA_FIFO_FREE(rinfo->riva, Blt, 3);
67
	rinfo->riva.Blt->TopLeftSrc  = (sy << 16) | sx;
70
	rinfo->riva.Blt->TopLeftSrc  = (sy << 16) | sx;
68
	rinfo->riva.Blt->TopLeftDst  = (dy << 16) | dx;
71
	rinfo->riva.Blt->TopLeftDst  = (dy << 16) | dx;
72
	wmb();
69
	rinfo->riva.Blt->WidthHeight = (height  << 16) | width;
73
	rinfo->riva.Blt->WidthHeight = (height  << 16) | width;
70
74
71
	wait_for_idle(rinfo);
75
	wait_for_idle(rinfo);
Lines 141-147 Link Here
141
        rinfo->riva.Bitmap->Color1E           = fgx;
145
        rinfo->riva.Bitmap->Color1E           = fgx;
142
        rinfo->riva.Bitmap->WidthHeightInE  = (h << 16) | 32;
146
        rinfo->riva.Bitmap->WidthHeightInE  = (h << 16) | 32;
143
        rinfo->riva.Bitmap->WidthHeightOutE = (h << 16) | 32;
147
        rinfo->riva.Bitmap->WidthHeightOutE = (h << 16) | 32;
148
	wmb();
144
        rinfo->riva.Bitmap->PointE          = (yy << 16) | (xx & 0xFFFF);
149
        rinfo->riva.Bitmap->PointE          = (yy << 16) | (xx & 0xFFFF);
150
	wmb();
145
	
151
	
146
	d = &rinfo->riva.Bitmap->MonochromeData01E;
152
	d = &rinfo->riva.Bitmap->MonochromeData01E;
147
	for (i = h; i > 0; i-=16) {
153
	for (i = h; i > 0; i-=16) {
Lines 151-160 Link Here
151
			cnt = i;
157
			cnt = i;
152
		RIVA_FIFO_FREE(rinfo->riva, Bitmap, cnt);
158
		RIVA_FIFO_FREE(rinfo->riva, Bitmap, cnt);
153
		for (j = 0; j < cnt; j++) {
159
		for (j = 0; j < cnt; j++) {
154
			if (w <= 8) 
160
			if (w <= 8) {
161
#ifdef __BIG_ENDIAN
162
				cdat2 = (*cdat++) << 24;
163
#else
155
				cdat2 = *cdat++;
164
				cdat2 = *cdat++;
156
			else
165
#endif				
166
			} else {
167
#ifdef __BIG_ENDIAN
157
				cdat2 = *((u16*)cdat)++;
168
				cdat2 = *((u16*)cdat)++;
169
#else
170
				cdat2 = (*((u16*)cdat)++) << 16;
171
#endif			
172
			}
158
			fbcon_reverse_order(&cdat2);
173
			fbcon_reverse_order(&cdat2);
159
			d[j] = cdat2;
174
			d[j] = cdat2;
160
		}
175
		}
Lines 228-236 Link Here
228
243
229
	RIVA_FIFO_FREE(rinfo->riva, Rop, 1);
244
	RIVA_FIFO_FREE(rinfo->riva, Rop, 1);
230
	rinfo->riva.Rop->Rop3 = 0x66; // XOR
245
	rinfo->riva.Rop->Rop3 = 0x66; // XOR
246
	wmb();
231
	riva_rectfill(rinfo, yy, xx, fontheight(p), fontwidth(p), 0x0f);
247
	riva_rectfill(rinfo, yy, xx, fontheight(p), fontwidth(p), 0x0f);
232
	RIVA_FIFO_FREE(rinfo->riva, Rop, 1);
248
	RIVA_FIFO_FREE(rinfo->riva, Rop, 1);
233
	rinfo->riva.Rop->Rop3 = 0xCC; // back to COPY
249
	rinfo->riva.Rop->Rop3 = 0xCC; // back to COPY
250
	wmb();
234
}
251
}
235
252
236
static void fbcon_riva8_clear_margins(struct vc_data *conp, struct display *p,
253
static void fbcon_riva8_clear_margins(struct vc_data *conp, struct display *p,
Lines 243-259 Link Here
243
	setup:		fbcon_riva8_setup,
260
	setup:		fbcon_riva8_setup,
244
	bmove:		fbcon_riva_bmove,
261
	bmove:		fbcon_riva_bmove,
245
	clear:		fbcon_riva8_clear,
262
	clear:		fbcon_riva8_clear,
246
#ifdef __BIG_ENDIAN
247
	putc:		fbcon_cfb8_putc,
248
	putcs:		fbcon_cfb8_putcs,
249
	revc:		fbcon_cfb8_revc,
250
	clear_margins:	fbcon_cfb8_clear_margins,
251
#else
252
	putc:		fbcon_riva8_putc,
263
	putc:		fbcon_riva8_putc,
253
	putcs:		fbcon_riva8_putcs,
264
	putcs:		fbcon_riva8_putcs,
254
	revc:		fbcon_riva8_revc,
265
	revc:		fbcon_riva8_revc,
255
	clear_margins:	fbcon_riva8_clear_margins,
266
	clear_margins:	fbcon_riva8_clear_margins,
256
#endif	
257
	fontwidthmask:	FONTWIDTHRANGE(4, 16)
267
	fontwidthmask:	FONTWIDTHRANGE(4, 16)
258
};
268
};
259
#endif
269
#endif
Lines 268-276 Link Here
268
278
269
	RIVA_FIFO_FREE(rinfo->riva, Rop, 1);
279
	RIVA_FIFO_FREE(rinfo->riva, Rop, 1);
270
	rinfo->riva.Rop->Rop3 = 0x66; // XOR
280
	rinfo->riva.Rop->Rop3 = 0x66; // XOR
281
	wmb();
271
	riva_rectfill(rinfo, yy, xx, fontheight(p), fontwidth(p), 0xffffffff);
282
	riva_rectfill(rinfo, yy, xx, fontheight(p), fontwidth(p), 0xffffffff);
272
	RIVA_FIFO_FREE(rinfo->riva, Rop, 1);
283
	RIVA_FIFO_FREE(rinfo->riva, Rop, 1);
273
	rinfo->riva.Rop->Rop3 = 0xCC; // back to COPY
284
	rinfo->riva.Rop->Rop3 = 0xCC; // back to COPY
285
	wmb();
274
}
286
}
275
#endif
287
#endif
276
288
Lines 353-369 Link Here
353
	setup:		fbcon_riva16_setup,
365
	setup:		fbcon_riva16_setup,
354
	bmove:		fbcon_riva_bmove,
366
	bmove:		fbcon_riva_bmove,
355
	clear:		fbcon_riva16_clear,
367
	clear:		fbcon_riva16_clear,
356
#ifdef __BIG_ENDIAN
357
	putc:		fbcon_cfb16_putc,
358
	putcs:		fbcon_cfb16_putcs,
359
	revc:		fbcon_cfb16_revc,
360
	clear_margins:	fbcon_cfb16_clear_margins,
361
#else
362
	putc:		fbcon_riva16_putc,
368
	putc:		fbcon_riva16_putc,
363
	putcs:		fbcon_riva16_putcs,
369
	putcs:		fbcon_riva16_putcs,
364
	revc:		fbcon_riva1632_revc,
370
	revc:		fbcon_riva1632_revc,
365
	clear_margins:	fbcon_riva16_clear_margins,
371
	clear_margins:	fbcon_riva16_clear_margins,
366
#endif
367
	fontwidthmask:	FONTWIDTHRANGE(4, 16)
372
	fontwidthmask:	FONTWIDTHRANGE(4, 16)
368
};
373
};
369
#endif
374
#endif
Lines 434-450 Link Here
434
	setup:		fbcon_riva32_setup,
439
	setup:		fbcon_riva32_setup,
435
	bmove:		fbcon_riva_bmove,
440
	bmove:		fbcon_riva_bmove,
436
	clear:		fbcon_riva32_clear,
441
	clear:		fbcon_riva32_clear,
437
#ifdef __BIG_ENDIAN
438
	putc:		fbcon_cfb32_putc,
439
	putcs:		fbcon_cfb32_putcs,
440
	revc:		fbcon_cfb32_revc,
441
	clear_margins:	fbcon_cfb32_clear_margins,
442
#else
443
	putc:		fbcon_riva32_putc,
442
	putc:		fbcon_riva32_putc,
444
	putcs:		fbcon_riva32_putcs,
443
	putcs:		fbcon_riva32_putcs,
445
	revc:		fbcon_riva1632_revc,
444
	revc:		fbcon_riva1632_revc,
446
	clear_margins:	fbcon_riva32_clear_margins,
445
	clear_margins:	fbcon_riva32_clear_margins,
447
#endif
448
	fontwidthmask:	FONTWIDTHRANGE(4, 16)
446
	fontwidthmask:	FONTWIDTHRANGE(4, 16)
449
};
447
};
450
#endif
448
#endif
(-)linux-2.4.22/drivers/video/riva/fbdev.c (-193 / +416 lines)
Lines 1-12 Link Here
1
/*
1
/*
2
 * linux/drivers/video/riva/fbdev.c
2
 * linux/drivers/video/riva/fbdev.c - nVidia RIVA 128/TNT/TNT2 fb driver
3
 *
3
 *
4
 * nVidia RIVA 128/TNT/TNT2/GeForce2/3 fb driver
4
 * Maintained by Ani Joshi <ajoshi@shell.unixbox.com>
5
 *
6
 * Maintained by Ani Joshi <ajoshi@kernel.crashing.org>
7
 *
5
 *
8
 * Copyright 1999-2000 Jeff Garzik
6
 * Copyright 1999-2000 Jeff Garzik
9
 * Copyright 2000-2003 Ani Joshi
10
 *
7
 *
11
 * Contributors:
8
 * Contributors:
12
 *
9
 *
Lines 17-22 Link Here
17
 *
14
 *
18
 *	Jindrich Makovicka:  Accel code help, hw cursor, mtrr
15
 *	Jindrich Makovicka:  Accel code help, hw cursor, mtrr
19
 *
16
 *
17
 *	Paul Richards:  Bug fixes, updates
18
 *
19
 *	Benjamin Herrenschmidt:  Fix accel on big endian, PPC fixes
20
 *
20
 * Initial template from skeletonfb.c, created 28 Dec 1997 by Geert Uytterhoeven
21
 * Initial template from skeletonfb.c, created 28 Dec 1997 by Geert Uytterhoeven
21
 * Includes riva_hw.c from nVidia, see copyright below.
22
 * Includes riva_hw.c from nVidia, see copyright below.
22
 * KGI code provided the basis for state storage, init, and mode switching.
23
 * KGI code provided the basis for state storage, init, and mode switching.
Lines 55-64 Link Here
55
#error This driver requires PCI support.
56
#error This driver requires PCI support.
56
#endif
57
#endif
57
58
58
59
#include <linux/adb.h>
60
#include <linux/pmu.h>
61
#include <asm/prom.h>
62
#include <asm/pci-bridge.h>
59
63
60
/* version number of this driver */
64
/* version number of this driver */
61
#define RIVAFB_VERSION "0.9.4"
65
#define RIVAFB_VERSION "0.9.4b"
62
66
63
67
64
68
Lines 131-153 Link Here
131
	CH_RIVA_128 = 0,
135
	CH_RIVA_128 = 0,
132
	CH_RIVA_TNT,
136
	CH_RIVA_TNT,
133
	CH_RIVA_TNT2,
137
	CH_RIVA_TNT2,
134
	CH_RIVA_UTNT2,	/* UTNT2 */
138
	CH_RIVA_UTNT2,
135
	CH_RIVA_VTNT2,	/* VTNT2 */
139
	CH_RIVA_VTNT2,
136
	CH_RIVA_UVTNT2,	/* VTNT2 */
140
	CH_RIVA_UVTNT2,
137
	CH_RIVA_ITNT2,	/* ITNT2 */
141
	CH_RIVA_ITNT2,
138
	CH_GEFORCE_SDR,
142
	CH_GEFORCE_SDR,
139
	CH_GEFORCE_DDR,
143
	CH_GEFORCE_DDR,
140
	CH_QUADRO,
144
	CH_QUADRO,
141
	CH_GEFORCE2_MX,
145
	CH_GEFORCE2_MX,
146
	CH_GEFORCE2_MX2,
147
	CH_GEFORCE2_GO,
142
	CH_QUADRO2_MXR,
148
	CH_QUADRO2_MXR,
143
	CH_GEFORCE2_GTS,
149
	CH_GEFORCE2_GTS,
150
	CH_GEFORCE2_GTS2,
144
	CH_GEFORCE2_ULTRA,
151
	CH_GEFORCE2_ULTRA,
145
	CH_QUADRO2_PRO,
152
	CH_QUADRO2_PRO,
146
	CH_GEFORCE2_GO,
153
	CH_GEFORCE4_MX_460,
147
        CH_GEFORCE3,
154
	CH_GEFORCE4_MX_440,
148
        CH_GEFORCE3_1,
155
	CH_GEFORCE4_MX_420,
149
        CH_GEFORCE3_2,
156
	CH_GEFORCE4_440_GO,
150
        CH_QUADRO_DDC
157
	CH_GEFORCE4_420_GO,
158
	CH_GEFORCE4_420_GO_M32,
159
	CH_QUADRO4_500XGL,
160
	CH_GEFORCE4_440_GO_M64,
161
	CH_QUADRO4_200,
162
	CH_QUADRO4_550XGL,
163
	CH_QUADRO4_500_GOGL,
164
	CH_IGEFORCE2,
165
	CH_GEFORCE3,
166
	CH_GEFORCE3_1,
167
	CH_GEFORCE3_2,
168
	CH_QUADRO_DDC,
169
	CH_GEFORCE4_TI_4600,
170
	CH_GEFORCE4_TI_4400,
171
	CH_GEFORCE4_TI_4200,
172
	CH_QUADRO4_900XGL,
173
	CH_QUADRO4_750XGL,
174
	CH_QUADRO4_700XGL
151
};
175
};
152
176
153
/* directly indexed by riva_chips enum, above */
177
/* directly indexed by riva_chips enum, above */
Lines 162-180 Link Here
162
	{ "RIVA-VTNT2", NV_ARCH_04 },
186
	{ "RIVA-VTNT2", NV_ARCH_04 },
163
	{ "RIVA-UVTNT2", NV_ARCH_04 },
187
	{ "RIVA-UVTNT2", NV_ARCH_04 },
164
	{ "RIVA-ITNT2", NV_ARCH_04 },
188
	{ "RIVA-ITNT2", NV_ARCH_04 },
165
	{ "GeForce-SDR", NV_ARCH_10},
189
	{ "GeForce-SDR", NV_ARCH_10 },
166
	{ "GeForce-DDR", NV_ARCH_10},
190
	{ "GeForce-DDR", NV_ARCH_10 },
167
	{ "Quadro", NV_ARCH_10},
191
	{ "Quadro", NV_ARCH_10 },
168
	{ "GeForce2-MX", NV_ARCH_10},
192
	{ "GeForce2-MX", NV_ARCH_10 },
169
	{ "Quadro2-MXR", NV_ARCH_10},
193
	{ "GeForce2-MX", NV_ARCH_10 },
170
	{ "GeForce2-GTS", NV_ARCH_10},
194
	{ "GeForce2-GO", NV_ARCH_10 },
171
	{ "GeForce2-ULTRA", NV_ARCH_10},
195
	{ "Quadro2-MXR", NV_ARCH_10 },
172
	{ "Quadro2-PRO", NV_ARCH_10},
196
	{ "GeForce2-GTS", NV_ARCH_10 },
173
        { "GeForce2-Go", NV_ARCH_10},
197
	{ "GeForce2-GTS", NV_ARCH_10 },
174
        { "GeForce3", NV_ARCH_20}, 
198
	{ "GeForce2-ULTRA", NV_ARCH_10 },
175
        { "GeForce3 Ti 200", NV_ARCH_20},
199
	{ "Quadro2-PRO", NV_ARCH_10 },
176
        { "GeForce3 Ti 500", NV_ARCH_20},
200
	{ "GeForce4-MX-460", NV_ARCH_20 },
177
        { "Quadro DDC", NV_ARCH_20}
201
	{ "GeForce4-MX-440", NV_ARCH_20 },
202
	{ "GeForce4-MX-420", NV_ARCH_20 },
203
	{ "GeForce4-440-GO", NV_ARCH_20 },
204
	{ "GeForce4-420-GO", NV_ARCH_20 },
205
	{ "GeForce4-420-GO-M32", NV_ARCH_20 },
206
	{ "Quadro4-500-XGL", NV_ARCH_20 },
207
	{ "GeForce4-440-GO-M64", NV_ARCH_20 },
208
	{ "Quadro4-200", NV_ARCH_20 },
209
	{ "Quadro4-550-XGL", NV_ARCH_20 },
210
	{ "Quadro4-500-GOGL", NV_ARCH_20 },
211
	{ "GeForce2", NV_ARCH_20 },
212
	{ "GeForce3", NV_ARCH_20 }, 
213
	{ "GeForce3 Ti 200", NV_ARCH_20 },
214
	{ "GeForce3 Ti 500", NV_ARCH_20 },
215
	{ "Quadro DDC", NV_ARCH_20 },
216
	{ "GeForce4 Ti 4600", NV_ARCH_20 },
217
	{ "GeForce4 Ti 4400", NV_ARCH_20 },
218
	{ "GeForce4 Ti 4200", NV_ARCH_20 },
219
	{ "Quadro4-900-XGL", NV_ARCH_20 },
220
	{ "Quadro4-750-XGL", NV_ARCH_20 },
221
	{ "Quadro4-700-XGL", NV_ARCH_20 }
178
};
222
};
179
223
180
static struct pci_device_id rivafb_pci_tbl[] __devinitdata = {
224
static struct pci_device_id rivafb_pci_tbl[] __devinitdata = {
Lines 201-227 Link Here
201
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX,
245
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX,
202
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE2_MX },
246
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE2_MX },
203
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX2,
247
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX2,
204
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE2_MX },
248
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE2_MX2 },
249
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_GO,
250
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE2_GO },
205
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO2_MXR,
251
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO2_MXR,
206
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_QUADRO2_MXR },
252
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_QUADRO2_MXR },
207
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS,
253
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS,
208
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE2_GTS },
254
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE2_GTS },
209
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS2,
255
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS2,
210
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE2_GTS },
256
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE2_GTS2 },
211
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_ULTRA,
257
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_ULTRA,
212
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE2_ULTRA },
258
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE2_ULTRA },
213
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO2_PRO,
259
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO2_PRO,
214
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_QUADRO2_PRO },
260
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_QUADRO2_PRO },
215
        { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_GO,
261
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_460,
216
          PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE2_GO },
262
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE4_MX_460 },
217
        { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE3,
263
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440,
218
          PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE3 },
264
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE4_MX_440 },
219
        { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE3_1,
265
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_420,
220
          PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE3_1 },
266
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE4_MX_420 },
221
        { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE3_2,
267
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_440_GO,
222
          PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE3_2 },
268
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE4_440_GO },
223
        { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO_DDC,
269
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_420_GO,
224
          PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_QUADRO_DDC },
270
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE4_420_GO },
271
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_420_GO_M32,
272
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE4_420_GO_M32 },
273
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO4_500XGL,
274
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_QUADRO4_500XGL },
275
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_440_GO_M64,
276
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE4_440_GO_M64 },
277
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO4_200,
278
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_QUADRO4_200 },
279
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO4_550XGL,
280
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_QUADRO4_550XGL },
281
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO4_500_GOGL,
282
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_QUADRO4_500_GOGL },
283
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_IGEFORCE2,
284
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_IGEFORCE2 },
285
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE3,
286
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE3 },
287
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE3_1,
288
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE3_1 },
289
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE3_2,
290
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE3_2 },
291
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO_DDC,
292
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_QUADRO_DDC },
293
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4600,
294
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE4_TI_4600 },
295
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4400,
296
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE4_TI_4400 },
297
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4200,
298
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE4_TI_4200 },
299
 	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO4_900XGL,
300
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_QUADRO4_900XGL },
301
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO4_750XGL,
302
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_QUADRO4_750XGL },
303
	{ PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO4_700XGL,
304
	  PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_QUADRO4_700XGL },
225
	{ 0, } /* terminate list */
305
	{ 0, } /* terminate list */
226
};
306
};
227
MODULE_DEVICE_TABLE(pci, rivafb_pci_tbl);
307
MODULE_DEVICE_TABLE(pci, rivafb_pci_tbl);
Lines 278-289 Link Here
278
358
279
/* command line data, set in rivafb_setup() */
359
/* command line data, set in rivafb_setup() */
280
static char fontname[40] __initdata = { 0 };
360
static char fontname[40] __initdata = { 0 };
281
static char noaccel __initdata = 0;
361
static int noaccel __initdata = 0;
282
static char nomove = 0;
362
static int nomove = 0;
283
static char nohwcursor __initdata = 0;
363
static int nohwcursor __initdata = 0;
284
static char noblink = 0;
364
static int noblink = 0;
365
static int flatpanel __initdata = -1; /* Autodetect later */
366
static int forceCRTC __initdata = -1;
285
#ifdef CONFIG_MTRR
367
#ifdef CONFIG_MTRR
286
static char nomtrr __initdata = 0;
368
static int nomtrr __initdata = 0;
287
#endif
369
#endif
288
370
289
#ifndef MODULE
371
#ifndef MODULE
Lines 342-348 Link Here
342
	0xEB							/* MISC */
424
	0xEB							/* MISC */
343
};
425
};
344
426
427
/*
428
 * Here is some specific support for the eMac machine
429
 * 
430
 * This machine is "special" because of it's ivad2 display
431
 * controller and fixed horizontal timing requirements.
432
 * 
433
 * Right now, all I do is to set a fixed working 1024x768
434
 * mode at boot (I also have a 1280x960 at hand, if you
435
 * prefer...).
436
 * 
437
 * I expect to do things better in a future 2.5 version
438
 * though.
439
 * 
440
 * I also turn off the screen during blanking using IVAD
441
 * i2c accesses, that's the basis we can use to later
442
 * implement full IVAD support (geometry setting,
443
 * brightness, ...).
444
 */
445
#if defined(CONFIG_ALL_PPC) && defined(CONFIG_ADB_PMU)
446
447
static int ivad_iic_addr = -1;
448
449
/* Default mode for eMac */
450
static struct fb_var_screeninfo emac_default_var = {
451
	xres:		1024,
452
	yres:		768,
453
	xres_virtual:	1024,
454
	yres_virtual:	768,
455
	xoffset:	0,
456
	yoffset:	0,
457
	bits_per_pixel:	8,
458
	grayscale:	0,
459
	red:		{0, 6, 0},
460
	green:		{0, 6, 0},
461
	blue:		{0, 6, 0},
462
	transp:		{0, 0, 0},
463
	nonstd:		0,
464
	activate:	0,
465
	height:		-1,
466
	width:		-1,
467
	accel_flags:	0,
468
	pixclock:	10081,
469
	left_margin:	208,
470
	right_margin:	48,
471
	upper_margin:	31,
472
	lower_margin:	1,
473
	hsync_len:	96,
474
	vsync_len:	3,
475
	sync:		FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
476
	vmode:		FB_VMODE_NONINTERLACED
477
};
478
479
static void
480
init_ivad(void)
481
{
482
	if (machine_is_compatible("PowerMac4,4")) {
483
		struct device_node* np = find_devices("ivad2");
484
		unsigned int* prop;
485
		
486
		if (np == NULL)
487
			return;
488
		prop = (unsigned int*)get_property(np, "iic-address", NULL);
489
		if (np == NULL) {
490
			printk(KERN_INFO "IVAD2 found but has no iic-address property !\n");
491
			return;
492
		}
493
		ivad_iic_addr = *prop;
494
		printk(KERN_INFO "Found IVAD2, iic address is: 0x%02x\n", ivad_iic_addr);
495
		rivafb_default_var = emac_default_var;
496
	}
497
}
498
499
#define IVAD_CONTRAST_REG	0x00
500
501
static void
502
set_ivad_contrast(u8 contrast)
503
{
504
	int rc;
505
506
	if (ivad_iic_addr < 0)
507
		return;
508
	rc = pmu_i2c_stdsub_write(PMU_I2C_BUS_POWER, ivad_iic_addr, IVAD_CONTRAST_REG, &contrast, 1);
509
	if (rc < 0)
510
		printk(KERN_ERR "IVAD2: Can't set contrast !\n");
511
}
345
512
513
#endif /* defined(CONFIG_ALL_PPC) && defined(CONFIG_ADB_PMU) */
346
514
347
/* ------------------------------------------------------------------------- *
515
/* ------------------------------------------------------------------------- *
348
 *
516
 *
Lines 445-451 Link Here
445
	if (rinfo->cursor->vbl_cnt && --rinfo->cursor->vbl_cnt == 0) {
613
	if (rinfo->cursor->vbl_cnt && --rinfo->cursor->vbl_cnt == 0) {
446
		rinfo->cursor->on ^= 1;
614
		rinfo->cursor->on ^= 1;
447
		if (rinfo->cursor->on)
615
		if (rinfo->cursor->on)
448
			*(rinfo->riva.CURSORPOS) = (rinfo->cursor->pos.x & 0xFFFF)
616
			rinfo->riva.PRAMDAC[0x0000300/4] = (rinfo->cursor->pos.x & 0xFFFF)
449
						   | (rinfo->cursor->pos.y << 16);
617
						   | (rinfo->cursor->pos.y << 16);
450
		rinfo->riva.ShowHideCursor(&rinfo->riva, rinfo->cursor->on);
618
		rinfo->riva.ShowHideCursor(&rinfo->riva, rinfo->cursor->on);
451
		if (!noblink)
619
		if (!noblink)
Lines 646-652 Link Here
646
		if (c->last_move_delay <= 1) { /* rapid cursor movement */
814
		if (c->last_move_delay <= 1) { /* rapid cursor movement */
647
			c->vbl_cnt = CURSOR_SHOW_DELAY;
815
			c->vbl_cnt = CURSOR_SHOW_DELAY;
648
		} else {
816
		} else {
649
			*(rinfo->riva.CURSORPOS) = (x & 0xFFFF) | (y << 16);
817
			rinfo->riva.PRAMDAC[0x0000300/4] = (x & 0xFFFF) | (y << 16);
650
			rinfo->riva.ShowHideCursor(&rinfo->riva, 1);
818
			rinfo->riva.ShowHideCursor(&rinfo->riva, 1);
651
			if (!noblink) c->vbl_cnt = CURSOR_HIDE_DELAY;
819
			if (!noblink) c->vbl_cnt = CURSOR_HIDE_DELAY;
652
			c->on = 1;
820
			c->on = 1;
Lines 886-894 Link Here
886
	hEnd = (hDisplaySize + video_mode->right_margin +
1054
	hEnd = (hDisplaySize + video_mode->right_margin +
887
		video_mode->hsync_len) / 8 - 1;
1055
		video_mode->hsync_len) / 8 - 1;
888
	hTotal = (hDisplaySize + video_mode->right_margin +
1056
	hTotal = (hDisplaySize + video_mode->right_margin +
889
		  video_mode->hsync_len + video_mode->left_margin) / 8 - 1;
1057
		  video_mode->hsync_len + video_mode->left_margin) / 8 - 5;
890
	hBlankStart = hDisplay;
1058
	hBlankStart = hDisplay;
891
	hBlankEnd = hTotal;
1059
	hBlankEnd = hTotal + 4;
1060
892
	height = video_mode->yres_virtual;
1061
	height = video_mode->yres_virtual;
893
	vDisplay = video_mode->yres - 1;
1062
	vDisplay = video_mode->yres - 1;
894
	vStart = video_mode->yres + video_mode->lower_margin - 1;
1063
	vStart = video_mode->yres + video_mode->lower_margin - 1;
Lines 897-924 Link Here
897
	vTotal = video_mode->yres + video_mode->lower_margin +
1066
	vTotal = video_mode->yres + video_mode->lower_margin +
898
		 video_mode->vsync_len + video_mode->upper_margin + 2;
1067
		 video_mode->vsync_len + video_mode->upper_margin + 2;
899
	vBlankStart = vDisplay;
1068
	vBlankStart = vDisplay;
900
	vBlankEnd = vTotal;
1069
	vBlankEnd = vTotal + 1;
901
	dotClock = 1000000000 / video_mode->pixclock;
1070
	dotClock = 1000000000 / video_mode->pixclock;
902
1071
903
	memcpy(&newmode, &reg_template, sizeof(struct riva_regs));
1072
	memcpy(&newmode, &reg_template, sizeof(struct riva_regs));
904
1073
905
	newmode.ext.screen = SetBitField(hBlankEnd,6:6,4:4)
1074
	if (rinfo->FlatPanel) {
906
                  | SetBitField(vBlankStart,10:10,3:3)
907
                  | SetBitField(vStart,10:10,2:2)
908
                  | SetBitField(vDisplay,10:10,1:1)
909
                  | SetBitField(vTotal,10:10,0:0);
910
    
911
    	newmode.ext.horiz  = SetBitField(hTotal,8:8,0:0)
912
                  | SetBitField(hDisplay,8:8,1:1)
913
                  | SetBitField(hBlankStart,8:8,2:2)
914
                  | SetBitField(hStart,8:8,3:3);
915
916
    	newmode.ext.extra  = SetBitField(vTotal,11:11,0:0)
917
                    | SetBitField(vDisplay,11:11,2:2)
918
                    | SetBitField(vStart,11:11,4:4)
919
                    | SetBitField(vBlankStart,11:11,6:6);
920
921
	if (rinfo->riva.flatPanel) {
922
		vStart = vTotal - 3;
1075
		vStart = vTotal - 3;
923
		vEnd = vTotal - 2;
1076
		vEnd = vTotal - 2;
924
		vBlankStart = vStart;
1077
		vBlankStart = vStart;
Lines 927-940 Link Here
927
		hBlankEnd = hTotal + 4;
1080
		hBlankEnd = hTotal + 4;
928
	}
1081
	}
929
1082
930
	newmode.crtc[0x0] = Set8Bits (hTotal - 4);
1083
	newmode.crtc[0x0] = Set8Bits (hTotal); 
931
	newmode.crtc[0x1] = Set8Bits (hDisplay);
1084
	newmode.crtc[0x1] = Set8Bits (hDisplay);
932
	newmode.crtc[0x2] = Set8Bits (hBlankStart);
1085
	newmode.crtc[0x2] = Set8Bits (hBlankStart);
933
	newmode.crtc[0x3] = SetBitField(hBlankEnd,4:0,4:0)
1086
	newmode.crtc[0x3] = SetBitField (hBlankEnd, 4: 0, 4:0) | SetBit (7);
934
                | SetBit(7);
935
	newmode.crtc[0x4] = Set8Bits (hStart);
1087
	newmode.crtc[0x4] = Set8Bits (hStart);
936
	newmode.crtc[0x5] = SetBitField (hBlankEnd, 5: 5, 7:7)
1088
	newmode.crtc[0x5] = SetBitField (hBlankEnd, 5: 5, 7:7)
937
 		| SetBitField (hEnd, 4: 0, 4:0);
1089
		| SetBitField (hEnd, 4: 0, 4:0);
938
	newmode.crtc[0x6] = SetBitField (vTotal, 7: 0, 7:0);
1090
	newmode.crtc[0x6] = SetBitField (vTotal, 7: 0, 7:0);
939
	newmode.crtc[0x7] = SetBitField (vTotal, 8: 8, 0:0)
1091
	newmode.crtc[0x7] = SetBitField (vTotal, 8: 8, 0:0)
940
		| SetBitField (vDisplay, 8: 8, 1:1)
1092
		| SetBitField (vDisplay, 8: 8, 1:1)
Lines 950-986 Link Here
950
	newmode.crtc[0x11] = SetBitField (vEnd, 3: 0, 3:0)
1102
	newmode.crtc[0x11] = SetBitField (vEnd, 3: 0, 3:0)
951
		| SetBit (5);
1103
		| SetBit (5);
952
	newmode.crtc[0x12] = Set8Bits (vDisplay);
1104
	newmode.crtc[0x12] = Set8Bits (vDisplay);
953
	newmode.crtc[0x13] = ((width / 8) * ((bpp + 1) / 8)) & 0xFF;
1105
	newmode.crtc[0x13] = (width / 8) * ((bpp + 1) / 8);
954
	newmode.crtc[0x15] = Set8Bits (vBlankStart);
1106
	newmode.crtc[0x15] = Set8Bits (vBlankStart);
955
	newmode.crtc[0x16] = Set8Bits (vBlankEnd);
1107
	newmode.crtc[0x16] = Set8Bits (vBlankEnd);
956
1108
1109
	newmode.ext.screen = SetBitField(hBlankEnd,6:6,4:4)
1110
		| SetBitField(vBlankStart,10:10,3:3)
1111
		| SetBitField(vStart,10:10,2:2)
1112
		| SetBitField(vDisplay,10:10,1:1)
1113
		| SetBitField(vTotal,10:10,0:0);
1114
	newmode.ext.horiz  = SetBitField(hTotal,8:8,0:0) 
1115
		| SetBitField(hDisplay,8:8,1:1)
1116
		| SetBitField(hBlankStart,8:8,2:2)
1117
		| SetBitField(hStart,8:8,3:3);
1118
	newmode.ext.extra  = SetBitField(vTotal,11:11,0:0)
1119
		| SetBitField(vDisplay,11:11,2:2)
1120
		| SetBitField(vStart,11:11,4:4)
1121
		| SetBitField(vBlankStart,11:11,6:6); 
1122
1123
	/* CalcStateExt does this already */
1124
	/*
957
	newmode.ext.bpp = bpp;
1125
	newmode.ext.bpp = bpp;
958
	newmode.ext.width = width;
1126
	newmode.ext.width = width;
959
	newmode.ext.height = height;
1127
	newmode.ext.height = height;
1128
	*/
1129
	newmode.ext.interlace = 0xff; /* interlace off */
1130
1131
	if(rinfo->riva.Architecture >= NV_ARCH_10)
1132
		rinfo->riva.CURSOR = (U032 *)(rinfo->fb_base + rinfo->riva.CursorStart);
960
1133
961
	rinfo->riva.CalcStateExt(&rinfo->riva, &newmode.ext, bpp, width,
1134
	rinfo->riva.CalcStateExt(&rinfo->riva, &newmode.ext, bpp, width,
962
				  hDisplaySize, hDisplay, hStart, hEnd,
1135
				  hDisplaySize, height, dotClock);
963
				  hTotal, height, vDisplay, vStart, vEnd,
964
				  vTotal, dotClock);
965
1136
966
	newmode.ext.scale = rinfo->riva.PRAMDAC[0x00000848/4] & 0xfff000ff;
1137
	newmode.ext.scale = rinfo->riva.PRAMDAC[0x00000848/4] & 0xfff000ff;
967
1138
	if(rinfo->FlatPanel == 1) {
968
	if (rinfo->riva.flatPanel) {
969
		newmode.ext.pixel |= (1 << 7);
1139
		newmode.ext.pixel |= (1 << 7);
970
		newmode.ext.scale |= (1 << 8);
1140
		newmode.ext.scale |= (1 << 8) ;
971
	}
1141
	}
972
1142
	if(rinfo->SecondCRTC) {
973
	newmode.ext.vpll2 = rinfo->riva.PRAMDAC[0x00000520/4];
1143
		newmode.ext.head  = rinfo->riva.PCRTC0[0x00000860/4] & ~0x00001000;
974
1144
		newmode.ext.head2 = rinfo->riva.PCRTC0[0x00002860/4] | 0x00001000;
975
#if defined(__powerpc__)
1145
		newmode.ext.crtcOwner = 3;
976
	/*
977
	 * XXX only Mac cards use second DAC for flat panel
978
	 */
979
	if (rinfo->riva.flatPanel) {
980
		newmode.ext.pllsel |= 0x20000800;
1146
		newmode.ext.pllsel |= 0x20000800;
981
		newmode.ext.vpll2 = newmode.ext.vpll;
1147
		newmode.ext.vpll2 = newmode.ext.vpll;
1148
	} else if(rinfo->riva.twoHeads) {
1149
		newmode.ext.head  =  rinfo->riva.PCRTC0[0x00000860/4] | 0x00001000;
1150
		newmode.ext.head2 =  rinfo->riva.PCRTC0[0x00002860/4] & ~0x00001000;
1151
		newmode.ext.crtcOwner = 0;
1152
		newmode.ext.vpll2 = rinfo->riva.PRAMDAC0[0x00000520/4];
982
	}
1153
	}
983
#endif
1154
1155
	newmode.ext.cursorConfig = 0x02000100;
1156
	
1157
	newmode.misc_output &= 0x3f;
1158
	if ((video_mode->sync & FB_SYNC_HOR_HIGH_ACT) == 0)
1159
		newmode.misc_output |= 0x40;
1160
	if ((video_mode->sync & FB_SYNC_VERT_HIGH_ACT) == 0)
1161
		newmode.misc_output |= 0x80;
1162
		
984
	rinfo->current_state = newmode;
1163
	rinfo->current_state = newmode;
985
	riva_load_state(rinfo, &rinfo->current_state);
1164
	riva_load_state(rinfo, &rinfo->current_state);
986
1165
Lines 1463-1468 Link Here
1463
1642
1464
	accel = v.accel_flags & FB_ACCELF_TEXT;
1643
	accel = v.accel_flags & FB_ACCELF_TEXT;
1465
1644
1645
	/* Accel seem to not work properly on GeForce4's yet...*/
1646
	if (rivainfo->riva.Architecture == NV_ARCH_20) {
1647
		v.accel_flags &= ~FB_ACCELF_TEXT;
1648
		accel = 0;
1649
	}
1650
1466
	switch (v.bits_per_pixel) {
1651
	switch (v.bits_per_pixel) {
1467
#ifdef FBCON_HAS_CFB8
1652
#ifdef FBCON_HAS_CFB8
1468
	case 1 ... 8:
1653
	case 1 ... 8:
Lines 1802-1807 Link Here
1802
			vesa |= 0xc0;
1987
			vesa |= 0xc0;
1803
			break;
1988
			break;
1804
		}
1989
		}
1990
#if defined(CONFIG_ALL_PPC) && defined(CONFIG_ADB_PMU)
1991
		set_ivad_contrast(0);
1992
#endif
1993
	} else {
1994
#if defined(CONFIG_ALL_PPC) && defined(CONFIG_ADB_PMU)
1995
		set_ivad_contrast(0xff);
1996
#endif
1805
	}
1997
	}
1806
1998
1807
	SEQout(rinfo, 0x01, tmp);
1999
	SEQout(rinfo, 0x01, tmp);
Lines 1841-1847 Link Here
1841
	if (rinfo->use_default_var)
2033
	if (rinfo->use_default_var)
1842
		/* We will use the modified default var */
2034
		/* We will use the modified default var */
1843
		rinfo->disp.var = rivafb_default_var;
2035
		rinfo->disp.var = rivafb_default_var;
1844
2036
	
1845
	return 0;
2037
	return 0;
1846
}
2038
}
1847
2039
Lines 1877-1882 Link Here
1877
2069
1878
	riva_set_dispsw(rinfo, disp);
2070
	riva_set_dispsw(rinfo, disp);
1879
2071
2072
	if (disp->var.accel_flags & FB_ACCELF_TEXT) {
2073
		if (nomove)
2074
			disp->scrollmode = SCROLL_YNOMOVE;
2075
		else
2076
			disp->scrollmode = 0;
2077
	} else
2078
		disp->scrollmode = SCROLL_YREDRAW;
2079
1880
	DPRINTK("EXIT, returning 0\n");
2080
	DPRINTK("EXIT, returning 0\n");
1881
	return 0;
2081
	return 0;
1882
2082
Lines 1913-1931 Link Here
1913
}
2113
}
1914
2114
1915
#ifdef CONFIG_ALL_PPC
2115
#ifdef CONFIG_ALL_PPC
2116
/*
2117
 * For now we only retreive EDID for flat panels, we'll fix that
2118
 * once we know what to do of non-flat panel EDIDs, that is typically
2119
 * in 2.5 --BenH.
2120
 */
1916
static int riva_get_EDID_OF(struct rivafb_info *rinfo)
2121
static int riva_get_EDID_OF(struct rivafb_info *rinfo)
1917
{
2122
{
1918
	struct device_node *dp;
2123
        struct device_node *dp;
1919
	unsigned char *pedid = NULL;
2124
        unsigned char *pedid = NULL;
1920
2125
        unsigned char *disptype = NULL;
1921
	dp = pci_device_to_OF_node(rinfo->pd);
2126
        static char *propnames[] = {
1922
	pedid = (unsigned char *)get_property(dp, "EDID,B", 0);
2127
        	"DFP,EDID", "LCD,EDID", "EDID", "EDID1", "EDID,B", "EDID,A", NULL };
1923
2128
        int i;  
1924
	if (pedid) {
2129
1925
		rinfo->EDID = pedid;
2130
        dp = pci_device_to_OF_node(rinfo->pd);
1926
		return 1;
2131
        for (; dp != NULL; dp = dp->child) {
1927
	} else
2132
               	disptype = (unsigned char *)get_property(dp, "display-type", NULL);
1928
		return 0;
2133
                if (disptype == NULL)
2134
                	continue;
2135
                if (strncmp(disptype, "LCD", 3) != 0)
2136
                	continue;
2137
                for (i = 0; propnames[i] != NULL; ++i) {
2138
                        pedid = (unsigned char *)
2139
                                get_property(dp, propnames[i], NULL);
2140
                        if (pedid != NULL) {
2141
                                rinfo->EDID = pedid;
2142
                                return 1;
2143
                        }
2144
                }
2145
        }
2146
        return 0;
1929
}
2147
}
1930
#endif /* CONFIG_ALL_PPC */
2148
#endif /* CONFIG_ALL_PPC */
1931
2149
Lines 1939-1966 Link Here
1939
	/* jump to detailed timing block section */
2157
	/* jump to detailed timing block section */
1940
	block += 54;
2158
	block += 54;
1941
2159
1942
        rinfo->clock = (block[0] + (block[1] << 8));
2160
	rinfo->clock = (block[0] + (block[1] << 8));
1943
        rinfo->panel_xres = (block[2] + ((block[4] & 0xf0) << 4));
2161
	rinfo->panel_xres = (block[2] + ((block[4] & 0xf0) << 4));
1944
        rinfo->hblank = (block[3] + ((block[4] & 0x0f) << 8));
2162
	rinfo->hblank = (block[3] + ((block[4] & 0x0f) << 8));
1945
        rinfo->panel_yres = (block[5] + ((block[7] & 0xf0) << 4));
2163
	rinfo->panel_yres = (block[5] + ((block[7] & 0xf0) << 4));
1946
        rinfo->vblank = (block[6] + ((block[7] & 0x0f) << 8));
2164
	rinfo->vblank = (block[6] + ((block[7] & 0x0f) << 8));
1947
        rinfo->hOver_plus = (block[8] + ((block[11] & 0xc0) << 2));
2165
	rinfo->hOver_plus = (block[8] + ((block[11] & 0xc0) << 2));
1948
        rinfo->hSync_width = (block[9] + ((block[11] & 0x30) << 4));
2166
	rinfo->hSync_width = (block[9] + ((block[11] & 0x30) << 4));
1949
        rinfo->vOver_plus = ((block[10] >> 4) + ((block[11] & 0x0c) << 2));
2167
	rinfo->vOver_plus = ((block[10] >> 4) + ((block[11] & 0x0c) << 2));
1950
        rinfo->vSync_width = ((block[10] & 0x0f) + ((block[11] & 0x03) << 4));
2168
	rinfo->vSync_width = ((block[10] & 0x0f) + ((block[11] & 0x03) << 4));
1951
        rinfo->interlaced = ((block[17] & 0x80) >> 7);
2169
	rinfo->interlaced = ((block[17] & 0x80) >> 7);
1952
        rinfo->synct = ((block[17] & 0x18) >> 3);
2170
	rinfo->synct = ((block[17] & 0x18) >> 3);
1953
        rinfo->misc = ((block[17] & 0x06) >> 1);
2171
	rinfo->misc = ((block[17] & 0x06) >> 1);
1954
        rinfo->hAct_high = rinfo->vAct_high = 0;
2172
	rinfo->hAct_high = rinfo->vAct_high = 0;
1955
        if (rinfo->synct == 3) {
2173
	if (rinfo->synct == 3) {
1956
                if (rinfo->misc & 2)
2174
		if (rinfo->misc & 2)
1957
                        rinfo->hAct_high = 1;
2175
			rinfo->hAct_high = 1;
1958
                if (rinfo->misc & 1)
2176
		if (rinfo->misc & 1)
1959
                        rinfo->vAct_high = 1;
2177
			rinfo->vAct_high = 1;
1960
	}
2178
	}
1961
2179
1962
	printk("rivafb: detected DFP panel size from EDID: %dx%d\n",
2180
	printk(KERN_INFO PFX
1963
		rinfo->panel_xres, rinfo->panel_yres);
2181
			"detected DFP panel size from EDID: %dx%d\n", 
2182
			rinfo->panel_xres, rinfo->panel_yres);
1964
2183
1965
	rinfo->got_dfpinfo = 1;
2184
	rinfo->got_dfpinfo = 1;
1966
2185
Lines 2020-2026 Link Here
2020
	if (riva_dfp_parse_EDID(rinfo))
2239
	if (riva_dfp_parse_EDID(rinfo))
2021
		riva_update_default_var(rinfo);
2240
		riva_update_default_var(rinfo);
2022
2241
2023
	rinfo->riva.flatPanel = rinfo->got_dfpinfo;
2242
	if (rinfo->FlatPanel == -1 && rinfo->got_dfpinfo == 1) /* if user specified flatpanel, we respect that */
2243
		rinfo->FlatPanel = 1;
2024
}
2244
}
2025
2245
2026
2246
Lines 2049-2054 Link Here
2049
	rinfo->drvr_name = rci->name;
2269
	rinfo->drvr_name = rci->name;
2050
	rinfo->riva.Architecture = rci->arch_rev;
2270
	rinfo->riva.Architecture = rci->arch_rev;
2051
2271
2272
	rinfo->Chipset = (pd->vendor << 16) | pd->device;
2273
	printk(KERN_INFO PFX "nVidia device/chipset %X\n", rinfo->Chipset);
2274
	
2275
	rinfo->FlatPanel = flatpanel;
2276
	if (flatpanel == 1)
2277
		printk(KERN_INFO PFX "flatpanel support enabled\n");
2278
	rinfo->forceCRTC = forceCRTC;
2279
	
2052
	rinfo->pd = pd;
2280
	rinfo->pd = pd;
2053
	rinfo->base0_region_size = pci_resource_len(pd, 0);
2281
	rinfo->base0_region_size = pci_resource_len(pd, 0);
2054
	rinfo->base1_region_size = pci_resource_len(pd, 1);
2282
	rinfo->base1_region_size = pci_resource_len(pd, 1);
Lines 2061-2164 Link Here
2061
		cmd |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
2289
		cmd |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
2062
		pci_write_config_word(pd, PCI_COMMAND, cmd);
2290
		pci_write_config_word(pd, PCI_COMMAND, cmd);
2063
	}
2291
	}
2064
 
2292
	
2065
	rinfo->ctrl_base_phys = pci_resource_start(rinfo->pd, 0);
2293
	rinfo->ctrl_base_phys = pci_resource_start(rinfo->pd, 0);
2066
	rinfo->fb_base_phys = pci_resource_start(rinfo->pd, 1);
2294
	rinfo->fb_base_phys = pci_resource_start(rinfo->pd, 1);
2067
2295
2296
	if (!request_mem_region(rinfo->ctrl_base_phys,
2297
				rinfo->base0_region_size, "rivafb")) {
2298
		printk(KERN_ERR PFX "cannot reserve MMIO region\n");
2299
		goto err_out_kfree;
2300
	}
2301
2068
	rinfo->ctrl_base = ioremap(rinfo->ctrl_base_phys,
2302
	rinfo->ctrl_base = ioremap(rinfo->ctrl_base_phys,
2069
				   rinfo->base0_region_size);
2303
				   rinfo->base0_region_size);
2070
	if (!rinfo->ctrl_base) {
2304
	if (!rinfo->ctrl_base) {
2071
		printk(KERN_ERR PFX "cannot ioremap MMIO base\n");
2305
		printk(KERN_ERR PFX "cannot ioremap MMIO base\n");
2072
		goto err_out_free_base1;
2306
		goto err_out_free_base0;
2073
	}
2307
	}
2074
	
2308
	
2075
	riva_get_EDID(rinfo);
2309
	riva_get_EDID(rinfo);
2076
2310
2077
	riva_get_dfpinfo(rinfo);
2311
	riva_get_dfpinfo(rinfo);
2078
2312
2079
	rinfo->riva.EnableIRQ = 0;
2313
	switch (rinfo->riva.Architecture) {
2080
	rinfo->riva.PRAMDAC = (unsigned *)(rinfo->ctrl_base + 0x00680000);
2314
	case NV_ARCH_03:
2081
	rinfo->riva.PFB = (unsigned *)(rinfo->ctrl_base + 0x00100000);
2315
		/* Riva128's PRAMIN is in the "framebuffer" space
2082
	rinfo->riva.PFIFO = (unsigned *)(rinfo->ctrl_base + 0x00002000);
2316
		 * Since these cards were never made with more than 8 megabytes
2083
	rinfo->riva.PGRAPH = (unsigned *)(rinfo->ctrl_base + 0x00400000);
2317
		 * we can safely allocate this seperately.
2084
	rinfo->riva.PEXTDEV = (unsigned *)(rinfo->ctrl_base + 0x00101000);
2085
	rinfo->riva.PTIMER = (unsigned *)(rinfo->ctrl_base + 0x00009000);
2086
	rinfo->riva.PMC = (unsigned *)(rinfo->ctrl_base + 0x00000000);
2087
	rinfo->riva.FIFO = (unsigned *)(rinfo->ctrl_base + 0x00800000);
2088
2089
	rinfo->riva.PCIO = (U008 *)(rinfo->ctrl_base + 0x00601000);
2090
	rinfo->riva.PDIO = (U008 *)(rinfo->ctrl_base + 0x00681000);
2091
	rinfo->riva.PVIO = (U008 *)(rinfo->ctrl_base + 0x000C0000);
2092
2093
	rinfo->riva.IO = (MISCin(rinfo) & 0x01) ? 0x3D0 : 0x3B0;
2094
2095
	if (rinfo->riva.Architecture == NV_ARCH_03) {
2096
		/*
2097
		 * We have to map the full BASE_1 aperture for Riva128's
2098
		 * because they use the PRAMIN set in "framebuffer" space
2099
		 */
2318
		 */
2100
		if (!request_mem_region(rinfo->fb_base_phys,
2319
		if (!request_mem_region(rinfo->fb_base_phys + 0x00C00000,
2101
					rinfo->base1_region_size, "rivafb")) {
2320
					 0x00008000, "rivafb")) {
2102
			printk(KERN_ERR PFX "cannot reserve FB region\n");
2321
			printk(KERN_ERR PFX "cannot reserve PRAMIN region\n");
2103
			goto err_out_free_base0;
2104
		}
2105
	
2106
		rinfo->fb_base = ioremap(rinfo->fb_base_phys,
2107
					 rinfo->base1_region_size);
2108
		if (!rinfo->fb_base) {
2109
			printk(KERN_ERR PFX "cannot ioremap FB base\n");
2110
			goto err_out_iounmap_ctrl;
2322
			goto err_out_iounmap_ctrl;
2111
		}
2323
		}
2112
	}
2324
		rinfo->riva.PRAMIN = ioremap(rinfo->fb_base_phys + 0x00C00000,
2113
2325
				 0x00008000);
2114
2326
		if (!rinfo->riva.PRAMIN) {
2115
	switch (rinfo->riva.Architecture) {
2327
			printk(KERN_ERR PFX "cannot ioremap PRAMIN region\n");
2116
	case NV_ARCH_03:
2328
			goto err_out_free_nv3_pramin;
2117
		rinfo->riva.PRAMIN = (unsigned *)(rinfo->fb_base + 0x00C00000);
2329
		}
2118
		break;
2330
		break;
2119
	case NV_ARCH_04:
2331
	case NV_ARCH_04:
2120
	case NV_ARCH_10:
2332
	case NV_ARCH_10:
2121
	case NV_ARCH_20:
2333
	case NV_ARCH_20:
2122
		rinfo->riva.PCRTC = (unsigned *)(rinfo->ctrl_base + 0x00600000);
2334
		rinfo->riva.PCRTC0 = (unsigned *)(rinfo->ctrl_base + 0x00600000);
2123
		rinfo->riva.PRAMIN = (unsigned *)(rinfo->ctrl_base + 0x00710000);
2335
		rinfo->riva.PRAMIN = (unsigned *)(rinfo->ctrl_base + 0x00710000);
2124
		break;
2336
		break;
2125
	}
2337
	}
2126
2338
2127
#if defined(__powerpc__)
2339
	riva_common_setup(rinfo);
2128
	/*
2129
	 * XXX Mac cards use the second DAC for the panel
2130
	 */
2131
	if (rinfo->riva.flatPanel) {
2132
		printk("rivafb: using second CRTC\n");
2133
		rinfo->riva.PCIO = rinfo->riva.PCIO + 0x2000;
2134
		rinfo->riva.PCRTC = rinfo->riva.PCRTC + 0x800;
2135
		rinfo->riva.PRAMDAC = rinfo->riva.PRAMDAC + 0x800;
2136
		rinfo->riva.PDIO = rinfo->riva.PDIO + 0x2000;
2137
	}
2138
#endif
2139
2140
	RivaGetConfig(&rinfo->riva);
2141
2340
2142
	rinfo->ram_amount = rinfo->riva.RamAmountKBytes * 1024;
2341
	rinfo->ram_amount = rinfo->riva.RamAmountKBytes * 1024;
2143
	rinfo->dclk_max = rinfo->riva.MaxVClockFreqKHz * 1000;
2342
	rinfo->dclk_max = rinfo->riva.MaxVClockFreqKHz * 1000;
2144
2343
2145
	if (rinfo->riva.Architecture != NV_ARCH_03) {
2344
	if (!request_mem_region(rinfo->fb_base_phys,
2146
		/*
2345
				rinfo->ram_amount, "rivafb")) {
2147
		 * Now the _normal_ chipsets can just map the amount of
2346
		printk(KERN_ERR PFX "cannot reserve FB region\n");
2148
		 * real physical ram instead of the whole aperture
2347
		goto err_out_iounmap_nv3_pramin;
2149
		 */
2348
	}
2150
		if (!request_mem_region(rinfo->fb_base_phys,
2151
					rinfo->ram_amount, "rivafb")) {
2152
			printk(KERN_ERR PFX "cannot reserve FB region\n");
2153
			goto err_out_free_base0;
2154
		}
2155
	
2349
	
2156
		rinfo->fb_base = ioremap(rinfo->fb_base_phys,
2350
	rinfo->fb_base = ioremap(rinfo->fb_base_phys,
2157
					 rinfo->ram_amount);
2351
				 rinfo->ram_amount);
2158
		if (!rinfo->fb_base) {
2352
	if (!rinfo->fb_base) {
2159
			printk(KERN_ERR PFX "cannot ioremap FB base\n");
2353
		printk(KERN_ERR PFX "cannot ioremap FB base\n");
2160
			goto err_out_iounmap_ctrl;
2354
		goto err_out_free_base1;
2161
		}
2162
	}
2355
	}
2163
2356
2164
#ifdef CONFIG_MTRR
2357
#ifdef CONFIG_MTRR
Lines 2215-2224 Link Here
2215
	rivafb_exit_cursor(rinfo);
2408
	rivafb_exit_cursor(rinfo);
2216
/* err_out_iounmap_fb: */
2409
/* err_out_iounmap_fb: */
2217
	iounmap(rinfo->fb_base);
2410
	iounmap(rinfo->fb_base);
2411
err_out_free_base1:
2412
	release_mem_region(rinfo->fb_base_phys, rinfo->ram_amount);
2413
err_out_iounmap_nv3_pramin:
2414
	if (rinfo->riva.Architecture == NV_ARCH_03) 
2415
		iounmap((caddr_t)rinfo->riva.PRAMIN);
2416
err_out_free_nv3_pramin:
2417
	if (rinfo->riva.Architecture == NV_ARCH_03)
2418
		release_mem_region(rinfo->fb_base_phys + 0x00C00000, 0x00008000);
2218
err_out_iounmap_ctrl:
2419
err_out_iounmap_ctrl:
2219
	iounmap(rinfo->ctrl_base);
2420
	iounmap(rinfo->ctrl_base);
2220
err_out_free_base1:
2221
	release_mem_region(rinfo->fb_base_phys, rinfo->base1_region_size);
2222
err_out_free_base0:
2421
err_out_free_base0:
2223
	release_mem_region(rinfo->ctrl_base_phys, rinfo->base0_region_size);
2422
	release_mem_region(rinfo->ctrl_base_phys, rinfo->base0_region_size);
2224
err_out_kfree:
2423
err_out_kfree:
Lines 2256-2261 Link Here
2256
	release_mem_region(board->fb_base_phys,
2455
	release_mem_region(board->fb_base_phys,
2257
			   board->ram_amount);
2456
			   board->ram_amount);
2258
2457
2458
	if (board->riva.Architecture == NV_ARCH_03) {
2459
		iounmap((caddr_t)board->riva.PRAMIN);
2460
		release_mem_region(board->fb_base_phys + 0x00C00000, 0x00008000);
2461
	}
2462
	
2259
	kfree(board);
2463
	kfree(board);
2260
2464
2261
	pci_set_drvdata(pd, NULL);
2465
	pci_set_drvdata(pd, NULL);
Lines 2301-2306 Link Here
2301
		} else if (!strncmp(this_opt, "nomtrr", 6)) {
2505
		} else if (!strncmp(this_opt, "nomtrr", 6)) {
2302
			nomtrr = 1;
2506
			nomtrr = 1;
2303
#endif
2507
#endif
2508
		} else if (!strncmp(this_opt, "forceCRTC", 9)) {
2509
			char *p;
2510
			
2511
			p = this_opt + 9;
2512
			if (!*p || !*(++p)) continue; 
2513
			forceCRTC = *p - '0';
2514
			if (forceCRTC < 0 || forceCRTC > 1) 
2515
				forceCRTC = -1;
2516
		} else if (!strncmp(this_opt, "flatpanel", 9)) {
2517
			flatpanel = 1;
2304
		} else if (!strncmp(this_opt, "nohwcursor", 10)) {
2518
		} else if (!strncmp(this_opt, "nohwcursor", 10)) {
2305
			nohwcursor = 1;
2519
			nohwcursor = 1;
2306
		} else
2520
		} else
Lines 2331-2339 Link Here
2331
#ifdef MODULE
2545
#ifdef MODULE
2332
	if (font) strncpy(fontname, font, sizeof(fontname)-1);
2546
	if (font) strncpy(fontname, font, sizeof(fontname)-1);
2333
#endif
2547
#endif
2548
#if defined(CONFIG_ALL_PPC) && defined(CONFIG_ADB_PMU)
2549
	init_ivad();
2550
#endif	
2334
	err = pci_module_init(&rivafb_driver);
2551
	err = pci_module_init(&rivafb_driver);
2335
	if (err)
2552
	if (err)
2336
		return err;
2553
		return err;
2554
	pci_register_driver(&rivafb_driver);
2337
	return 0;
2555
	return 0;
2338
}
2556
}
2339
2557
Lines 2357-2362 Link Here
2357
MODULE_PARM_DESC(nohwcursor, "Disables hardware cursor (0 or 1=disabled) (default=0)");
2575
MODULE_PARM_DESC(nohwcursor, "Disables hardware cursor (0 or 1=disabled) (default=0)");
2358
MODULE_PARM(noblink, "i");
2576
MODULE_PARM(noblink, "i");
2359
MODULE_PARM_DESC(noblink, "Disables hardware cursor blinking (0 or 1=disabled) (default=0)");
2577
MODULE_PARM_DESC(noblink, "Disables hardware cursor blinking (0 or 1=disabled) (default=0)");
2578
MODULE_PARM(flatpanel, "i");
2579
MODULE_PARM_DESC(flatpanel, "Enables experimental flat panel support for some chipsets. (0 or 1=enabled) (default=0)");
2580
MODULE_PARM(forceCRTC, "i");
2581
MODULE_PARM_DESC(forceCRTC, "Forces usage of a particular CRTC in case autodetection fails. (0 or 1) (default=autodetect)");
2582
2360
#ifdef CONFIG_MTRR
2583
#ifdef CONFIG_MTRR
2361
MODULE_PARM(nomtrr, "i");
2584
MODULE_PARM(nomtrr, "i");
2362
MODULE_PARM_DESC(nomtrr, "Disables MTRR support (0 or 1=disabled) (default=0)");
2585
MODULE_PARM_DESC(nomtrr, "Disables MTRR support (0 or 1=disabled) (default=0)");
Lines 2364-2368 Link Here
2364
#endif /* MODULE */
2587
#endif /* MODULE */
2365
2588
2366
MODULE_AUTHOR("Ani Joshi, maintainer");
2589
MODULE_AUTHOR("Ani Joshi, maintainer");
2367
MODULE_DESCRIPTION("Framebuffer driver for nVidia Riva 128, TNT, TNT2");
2590
MODULE_DESCRIPTION("Framebuffer driver for nVidia Riva 128, TNT, TNT2, and the GeForce series");
2368
MODULE_LICENSE("GPL");
2591
MODULE_LICENSE("GPL");
(-)linux-2.4.22/drivers/video/riva/nv4ref.h (-1 / +1 lines)
Lines 41-47 Link Here
41
 * GPL licensing note -- nVidia is allowing a liberal interpretation of
41
 * GPL licensing note -- nVidia is allowing a liberal interpretation of
42
 * the documentation restriction above, to merely say that this nVidia's
42
 * the documentation restriction above, to merely say that this nVidia's
43
 * copyright and disclaimer should be included with all code derived
43
 * copyright and disclaimer should be included with all code derived
44
 * from this source.  -- Jeff Garzik <jgarzik@pobox.com>, 01/Nov/99 
44
 * from this source.  -- Jeff Garzik <jgarzik@mandrakesoft.com>, 01/Nov/99 
45
 */
45
 */
46
46
47
 /***************************************************************************\
47
 /***************************************************************************\
(-)linux-2.4.22/drivers/video/riva/nv_setup.c (+262 lines)
Line 0 Link Here
1
/* $XConsortium: nv_driver.c /main/3 1996/10/28 05:13:37 kaleb $ */
2
/*
3
 * Copyright 1996-1997  David J. McKay
4
 *
5
 * Permission is hereby granted, free of charge, to any person obtaining a
6
 * copy of this software and associated documentation files (the "Software"),
7
 * to deal in the Software without restriction, including without limitation
8
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
 * and/or sell copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following conditions:
11
 *
12
 * The above copyright notice and this permission notice shall be included in
13
 * all copies or substantial portions of the Software.
14
 *
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18
 * DAVID J. MCKAY BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
20
 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
 * SOFTWARE.
22
 */
23
24
/*
25
 * GPL licensing note -- nVidia is allowing a liberal interpretation of
26
 * the documentation restriction above, to merely say that this nVidia's
27
 * copyright and disclaimer should be included with all code derived
28
 * from this source.  -- Jeff Garzik <jgarzik@mandrakesoft.com>, 01/Nov/99 
29
 */
30
31
/* Hacked together from mga driver and 3.3.4 NVIDIA driver by Jarno Paananen
32
   <jpaana@s2.org> */
33
34
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c,v 1.18 2002/08/0
35
5 20:47:06 mvojkovi Exp $ */
36
37
#include <linux/delay.h>
38
#include <linux/pci_ids.h>
39
#include "nv_type.h"
40
#include "rivafb.h"
41
#include "nvreg.h"
42
43
44
#ifndef CONFIG_PCI		/* sanity check */
45
#error This driver requires PCI support.
46
#endif
47
48
#define PFX "rivafb: "
49
50
static inline unsigned char MISCin(struct rivafb_info *rinfo)
51
{
52
	return (VGA_RD08(rinfo->riva.PVIO, 0x3cc));
53
}
54
55
static Bool 
56
riva_is_connected(struct rivafb_info *rinfo, Bool second)
57
{
58
	volatile U032 *PRAMDAC = rinfo->riva.PRAMDAC0;
59
	U032 reg52C, reg608;
60
	Bool present;
61
62
	if(second) PRAMDAC += 0x800;
63
64
	reg52C = PRAMDAC[0x052C/4];
65
	reg608 = PRAMDAC[0x0608/4];
66
67
	PRAMDAC[0x0608/4] = reg608 & ~0x00010000;
68
69
	PRAMDAC[0x052C/4] = reg52C & 0x0000FEEE;
70
	mdelay(1); 
71
	PRAMDAC[0x052C/4] |= 1;
72
73
	rinfo->riva.PRAMDAC0[0x0610/4] = 0x94050140;
74
	rinfo->riva.PRAMDAC0[0x0608/4] |= 0x00001000;
75
76
	mdelay(1);
77
78
	present = (PRAMDAC[0x0608/4] & (1 << 28)) ? TRUE : FALSE;
79
80
	rinfo->riva.PRAMDAC0[0x0608/4] &= 0x0000EFFF;
81
82
	PRAMDAC[0x052C/4] = reg52C;
83
	PRAMDAC[0x0608/4] = reg608;
84
85
	return present;
86
}
87
88
static void
89
riva_override_CRTC(struct rivafb_info *rinfo)
90
{
91
	printk(KERN_INFO PFX
92
		"Detected CRTC controller %i being used\n",
93
		rinfo->SecondCRTC ? 1 : 0);
94
95
	if(rinfo->forceCRTC != -1) {
96
		printk(KERN_INFO PFX
97
			"Forcing usage of CRTC %i\n", rinfo->forceCRTC);
98
		rinfo->SecondCRTC = rinfo->forceCRTC;
99
	}
100
}
101
102
static void
103
riva_is_second(struct rivafb_info *rinfo)
104
{
105
	if(rinfo->FlatPanel == 1) {
106
		switch(rinfo->Chipset & 0xffff) {
107
		case 0x0174:
108
		case 0x0175:
109
		case 0x0176:
110
		case 0x0177:
111
		case 0x0179:
112
		case 0x017C:
113
		case 0x017D:
114
		case 0x0186:
115
		case 0x0187:
116
		/* this might not be a good default for the chips below */
117
		case 0x0286:
118
		case 0x028C:
119
		case 0x0316:
120
		case 0x0317:
121
		case 0x031A:
122
		case 0x031B:
123
		case 0x031C:
124
		case 0x031D:
125
		case 0x031E:
126
		case 0x031F:
127
		case 0x0324:
128
		case 0x0325:
129
		case 0x0328:
130
		case 0x0329:
131
		case 0x032C:
132
		case 0x032D:
133
			rinfo->SecondCRTC = TRUE;
134
			break;
135
		default:
136
			rinfo->SecondCRTC = FALSE;
137
			break;
138
		}
139
	} else {
140
		if(riva_is_connected(rinfo, 0)) {
141
			if(rinfo->riva.PRAMDAC0[0x0000052C/4] & 0x100)
142
				rinfo->SecondCRTC = TRUE;
143
			else
144
				rinfo->SecondCRTC = FALSE;
145
		} else 
146
		if (riva_is_connected(rinfo, 1)) {
147
			if(rinfo->riva.PRAMDAC0[0x0000252C/4] & 0x100)
148
				rinfo->SecondCRTC = TRUE;
149
			else
150
				rinfo->SecondCRTC = FALSE;
151
		} else /* default */
152
			rinfo->SecondCRTC = FALSE;
153
	}
154
155
	riva_override_CRTC(rinfo);
156
}
157
158
void
159
riva_common_setup(struct rivafb_info *rinfo)
160
{
161
	rinfo->riva.EnableIRQ = 0;
162
	rinfo->riva.PRAMDAC0 = (unsigned *)(rinfo->ctrl_base + 0x00680000);
163
	rinfo->riva.PFB = (unsigned *)(rinfo->ctrl_base + 0x00100000);
164
	rinfo->riva.PFIFO = (unsigned *)(rinfo->ctrl_base + 0x00002000);
165
	rinfo->riva.PGRAPH = (unsigned *)(rinfo->ctrl_base + 0x00400000);
166
	rinfo->riva.PEXTDEV = (unsigned *)(rinfo->ctrl_base + 0x00101000);
167
	rinfo->riva.PTIMER = (unsigned *)(rinfo->ctrl_base + 0x00009000);
168
	rinfo->riva.PMC = (unsigned *)(rinfo->ctrl_base + 0x00000000);
169
	rinfo->riva.FIFO = (unsigned *)(rinfo->ctrl_base + 0x00800000);
170
	rinfo->riva.PCIO0 = (U008 *)(rinfo->ctrl_base + 0x00601000);
171
	rinfo->riva.PDIO0 = (U008 *)(rinfo->ctrl_base + 0x00681000);
172
	rinfo->riva.PVIO = (U008 *)(rinfo->ctrl_base + 0x000C0000);
173
174
	rinfo->riva.IO = (MISCin(rinfo) & 0x01) ? 0x3D0 : 0x3B0;
175
	
176
	if(rinfo->FlatPanel == -1) {
177
		switch(rinfo->Chipset) {
178
		case 0x0112:   /* known laptop chips */
179
		case 0x0174:
180
		case 0x0175:
181
		case 0x0176:
182
		case 0x0177:
183
		case 0x0179:
184
		case 0x017C:
185
		case 0x017D:
186
		case 0x0186:
187
		case 0x0187:
188
		case 0x0286:
189
		case 0x028C:
190
		case 0x0316:
191
		case 0x0317:
192
		case 0x031A:
193
		case 0x031B:
194
		case 0x031C:
195
		case 0x031D:
196
		case 0x031E:
197
		case 0x031F:
198
		case 0x0324:
199
		case 0x0325:
200
		case 0x0328:
201
		case 0x0329:
202
		case 0x032C:
203
		case 0x032D:
204
			printk(KERN_INFO PFX 
205
				"On a laptop.  Assuming Digital Flat Panel\n");
206
			rinfo->FlatPanel = 1;
207
			break;
208
		default:
209
			break;
210
		}
211
	}
212
	
213
	switch (rinfo->Chipset & 0x0ff0) {
214
	case 0x0110:
215
		if (rinfo->Chipset == NV_CHIP_GEFORCE2_GO)
216
			rinfo->SecondCRTC = TRUE; 
217
#if defined(__powerpc__)
218
		if (rinfo->FlatPanel == 1)
219
			rinfo->SecondCRTC = TRUE;
220
#endif
221
		riva_override_CRTC(rinfo);
222
		break;
223
	case 0x0170:
224
	case 0x0180:
225
	case 0x01F0:
226
	case 0x0250:
227
	case 0x0280:
228
	case 0x0300:
229
	case 0x0310:
230
	case 0x0320:
231
	case 0x0330:
232
	case 0x0340:
233
		riva_is_second(rinfo);
234
		break;
235
	default:
236
		break;
237
	}
238
239
	if (rinfo->riva.Architecture == NV_ARCH_03)
240
		rinfo->riva.PCRTC = rinfo->riva.PCRTC0 = rinfo->riva.PGRAPH;
241
242
	if (rinfo->SecondCRTC) {
243
		rinfo->riva.PCIO = rinfo->riva.PCIO0 + 0x2000;
244
		rinfo->riva.PCRTC = rinfo->riva.PCRTC0 + 0x800;
245
		rinfo->riva.PRAMDAC = rinfo->riva.PRAMDAC0 + 0x800;
246
		rinfo->riva.PDIO = rinfo->riva.PDIO0 + 0x2000;
247
	} else {
248
		rinfo->riva.PCIO = rinfo->riva.PCIO0;
249
		rinfo->riva.PCRTC = rinfo->riva.PCRTC0;
250
		rinfo->riva.PRAMDAC = rinfo->riva.PRAMDAC0;
251
		rinfo->riva.PDIO = rinfo->riva.PDIO0;
252
	}
253
254
	RivaGetConfig(&rinfo->riva, rinfo->Chipset);
255
256
	if (rinfo->FlatPanel == -1) {
257
		/* Fix me, need x86 DDC code */
258
		rinfo->FlatPanel = 0;
259
	}
260
	rinfo->riva.flatPanel = (rinfo->FlatPanel > 0) ? TRUE : FALSE;
261
}
262
(-)linux-2.4.22/drivers/video/riva/nv_type.h (+58 lines)
Line 0 Link Here
1
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h,v 1.35 2002/08/05 20:47:06 mvojkovi Exp $ */
2
3
#ifndef __NV_STRUCT_H__
4
#define __NV_STRUCT_H__
5
6
#define NV_CHIP_RIVA_128            ((PCI_VENDOR_ID_NVIDIA_SGS << 16)| PCI_DEVICE_ID_NVIDIA_RIVA128)
7
#define NV_CHIP_TNT                 ((PCI_VENDOR_ID_NVIDIA << 16)| PCI_DEVICE_ID_NVIDIA_TNT)
8
#define NV_CHIP_TNT2                ((PCI_VENDOR_ID_NVIDIA << 16)| PCI_DEVICE_ID_NVIDIA_TNT2)
9
#define NV_CHIP_UTNT2               ((PCI_VENDOR_ID_NVIDIA << 16)| PCI_DEVICE_ID_NVIDIA_UTNT2)
10
#define NV_CHIP_VTNT2               ((PCI_VENDOR_ID_NVIDIA << 16)| PCI_DEVICE_ID_NVIDIA_VTNT2)
11
#define NV_CHIP_UVTNT2              ((PCI_VENDOR_ID_NVIDIA << 16)| PCI_DEVICE_ID_NVIDIA_UVTNT2)
12
#define NV_CHIP_ITNT2               ((PCI_VENDOR_ID_NVIDIA << 16)| PCI_DEVICE_ID_NVIDIA_ITNT2)
13
#define NV_CHIP_GEFORCE_256         ((PCI_VENDOR_ID_NVIDIA << 16)| PCI_DEVICE_ID_NVIDIA_GEFORCE_256)
14
#define NV_CHIP_GEFORCE_DDR         ((PCI_VENDOR_ID_NVIDIA << 16)| PCI_DEVICE_ID_NVIDIA_GEFORCE_DDR)
15
#define NV_CHIP_QUADRO              ((PCI_VENDOR_ID_NVIDIA << 16)| PCI_DEVICE_ID_NVIDIA_QUADRO)
16
#define NV_CHIP_GEFORCE2_MX         ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX)
17
#define NV_CHIP_GEFORCE2_MX_100     ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX_100)
18
#define NV_CHIP_QUADRO2_MXR         ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_QUADRO2_MXR)
19
#define NV_CHIP_GEFORCE2_GO         ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE2_GO)
20
#define NV_CHIP_GEFORCE2_GTS        ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS)
21
#define NV_CHIP_GEFORCE2_TI         ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE2_TI)
22
#define NV_CHIP_GEFORCE2_ULTRA      ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE2_ULTRA)
23
#define NV_CHIP_QUADRO2_PRO         ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_QUADRO2_PRO)
24
#define NV_CHIP_GEFORCE4_MX_460     ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_460)
25
#define NV_CHIP_GEFORCE4_MX_440     ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440)
26
#define NV_CHIP_GEFORCE4_MX_420     ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_420)
27
#define NV_CHIP_GEFORCE4_440_GO     ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE4_440_GO)
28
#define NV_CHIP_GEFORCE4_420_GO     ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE4_420_GO)
29
#define NV_CHIP_GEFORCE4_420_GO_M32 ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE4_420_GO_M32)
30
#define NV_CHIP_QUADRO4_500XGL      ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_QUADRO4_500XGL)
31
#define NV_CHIP_GEFORCE4_440_GO_M64 ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE4_440_GO_M64)
32
#define NV_CHIP_QUADRO4_200         ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_QUADRO4_200)
33
#define NV_CHIP_QUADRO4_550XGL      ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_QUADRO4_550XGL)
34
#define NV_CHIP_QUADRO4_500_GOGL    ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_QUADRO4_500_GOGL)
35
#define NV_CHIP_0x0180              ((PCI_VENDOR_ID_NVIDIA << 16) | 0x0180)
36
#define NV_CHIP_0x0181              ((PCI_VENDOR_ID_NVIDIA << 16) | 0x0181)
37
#define NV_CHIP_0x0182              ((PCI_VENDOR_ID_NVIDIA << 16) | 0x0182)
38
#define NV_CHIP_0x0188              ((PCI_VENDOR_ID_NVIDIA << 16) | 0x0188)
39
#define NV_CHIP_0x018A              ((PCI_VENDOR_ID_NVIDIA << 16) | 0x018A)
40
#define NV_CHIP_0x018B              ((PCI_VENDOR_ID_NVIDIA << 16) | 0x018B)
41
#define NV_CHIP_IGEFORCE2           ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_IGEFORCE2)
42
#define NV_CHIP_0x01F0              ((PCI_VENDOR_ID_NVIDIA << 16) | 0x01F0)
43
#define NV_CHIP_GEFORCE3            ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE3)
44
#define NV_CHIP_GEFORCE3_TI_200     ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE3_TI_200)
45
#define NV_CHIP_GEFORCE3_TI_500     ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE3_TI_500)
46
#define NV_CHIP_QUADRO_DCC          ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_QUADRO_DCC)
47
#define NV_CHIP_GEFORCE4_TI_4600    ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4600)
48
#define NV_CHIP_GEFORCE4_TI_4400    ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4400)
49
#define NV_CHIP_GEFORCE4_TI_4200    ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4200)
50
#define NV_CHIP_QUADRO4_900XGL      ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_QUADRO4_900XGL)
51
#define NV_CHIP_QUADRO4_750XGL      ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_QUADRO4_750XGL)
52
#define NV_CHIP_QUADRO4_700XGL      ((PCI_VENDOR_ID_NVIDIA << 16) | PCI_DEVICE_ID_NVIDIA_QUADRO4_700XGL)
53
#define NV_CHIP_0x0280              ((PCI_VENDOR_ID_NVIDIA << 16) | 0x0280)
54
#define NV_CHIP_0x0281              ((PCI_VENDOR_ID_NVIDIA << 16) | 0x0281)
55
#define NV_CHIP_0x0288              ((PCI_VENDOR_ID_NVIDIA << 16) | 0x0288)
56
#define NV_CHIP_0x0289              ((PCI_VENDOR_ID_NVIDIA << 16) | 0x0289)
57
58
#endif /* __NV_STRUCT_H__ */
(-)linux-2.4.22/drivers/video/riva/riva_hw.c (-166 / +334 lines)
Lines 41-53 Link Here
41
 * GPL licensing note -- nVidia is allowing a liberal interpretation of
41
 * GPL licensing note -- nVidia is allowing a liberal interpretation of
42
 * the documentation restriction above, to merely say that this nVidia's
42
 * the documentation restriction above, to merely say that this nVidia's
43
 * copyright and disclaimer should be included with all code derived
43
 * copyright and disclaimer should be included with all code derived
44
 * from this source.  -- Jeff Garzik <jgarzik@pobox.com>, 01/Nov/99 
44
 * from this source.  -- Jeff Garzik <jgarzik@mandrakesoft.com>, 01/Nov/99 
45
 */
45
 */
46
46
47
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.c,v 1.8 2000/02/08 17:19:11 dawes Exp $ */
47
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.c,v 1.33 2002/08/05 20:47:06 mvojkovi Exp $ */
48
48
49
#include <linux/pci_ids.h>
50
#include <linux/pci.h>
49
#include "riva_hw.h"
51
#include "riva_hw.h"
50
#include "riva_tbl.h"
52
#include "riva_tbl.h"
53
#include "nv_type.h"
54
51
/*
55
/*
52
 * This file is an OS-agnostic file used to make RIVA 128 and RIVA TNT
56
 * This file is an OS-agnostic file used to make RIVA 128 and RIVA TNT
53
 * operate identically (except TNT has more memory and better 3D quality.
57
 * operate identically (except TNT has more memory and better 3D quality.
Lines 73-104 Link Here
73
{
77
{
74
    return ((chip->Rop->FifoFree < chip->FifoEmptyCount) || (chip->PGRAPH[0x00000700/4] & 0x01));
78
    return ((chip->Rop->FifoFree < chip->FifoEmptyCount) || (chip->PGRAPH[0x00000700/4] & 0x01));
75
}
79
}
76
static void nv3LockUnlock
80
81
static void vgaLockUnlock
77
(
82
(
78
    RIVA_HW_INST *chip,
83
    RIVA_HW_INST *chip,
79
    int           LockUnlock
84
    int           Lock
80
)
85
)
81
{
86
{
82
    VGA_WR08(chip->PVIO, 0x3C4, 0x06);
87
    U008 cr11;
83
    VGA_WR08(chip->PVIO, 0x3C5, LockUnlock ? 0x99 : 0x57);
88
    VGA_WR08(chip->PCIO, 0x3D4, 0x11);
89
    cr11 = VGA_RD08(chip->PCIO, 0x3D5);
90
    if(Lock) cr11 |= 0x80;
91
    else cr11 &= ~0x80;
92
    VGA_WR08(chip->PCIO, 0x3D5, cr11);
84
}
93
}
85
static void nv4LockUnlock
94
static void nv3LockUnlock
86
(
95
(
87
    RIVA_HW_INST *chip,
96
    RIVA_HW_INST *chip,
88
    int           LockUnlock
97
    int           Lock
89
)
98
)
90
{
99
{
91
    VGA_WR08(chip->PCIO, 0x3D4, 0x1F);
100
    VGA_WR08(chip->PVIO, 0x3C4, 0x06);
92
    VGA_WR08(chip->PCIO, 0x3D5, LockUnlock ? 0x99 : 0x57);
101
    VGA_WR08(chip->PVIO, 0x3C5, Lock ? 0x99 : 0x57);
102
    vgaLockUnlock(chip, Lock);
93
}
103
}
94
static void nv10LockUnlock
104
static void nv4LockUnlock
95
(
105
(
96
    RIVA_HW_INST *chip,
106
    RIVA_HW_INST *chip,
97
    int           LockUnlock
107
    int           Lock
98
)
108
)
99
{
109
{
100
    VGA_WR08(chip->PCIO, 0x3D4, 0x1F);
110
    VGA_WR08(chip->PCIO, 0x3D4, 0x1F);
101
    VGA_WR08(chip->PCIO, 0x3D5, LockUnlock ? 0x99 : 0x57);
111
    VGA_WR08(chip->PCIO, 0x3D5, Lock ? 0x99 : 0x57);
112
    vgaLockUnlock(chip, Lock);
102
}
113
}
103
114
104
static int ShowHideCursor
115
static int ShowHideCursor
Lines 107-119 Link Here
107
    int           ShowHide
118
    int           ShowHide
108
)
119
)
109
{
120
{
110
    int current;
121
    int cursor;
111
    current                     =  chip->CurrentState->cursor1;
122
    cursor                      =  chip->CurrentState->cursor1;
112
    chip->CurrentState->cursor1 = (chip->CurrentState->cursor1 & 0xFE) |
123
    chip->CurrentState->cursor1 = (chip->CurrentState->cursor1 & 0xFE) |
113
	                          (ShowHide & 0x01);
124
                                  (ShowHide & 0x01);
114
    VGA_WR08(chip->PCIO, 0x3D4, 0x31);
125
    VGA_WR08(chip->PCIO, 0x3D4, 0x31);
115
    VGA_WR08(chip->PCIO, 0x3D5, chip->CurrentState->cursor1);
126
    VGA_WR08(chip->PCIO, 0x3D5, chip->CurrentState->cursor1);
116
    return (current & 0x01);
127
    return (cursor & 0x01);
117
}
128
}
118
129
119
/****************************************************************************\
130
/****************************************************************************\
Lines 604-610 Link Here
604
    nv3_sim_state sim_data;
615
    nv3_sim_state sim_data;
605
    unsigned int M, N, P, pll, MClk;
616
    unsigned int M, N, P, pll, MClk;
606
    
617
    
607
    pll = chip->PRAMDAC[0x00000504/4];
618
    pll = chip->PRAMDAC0[0x00000504/4]; 
608
    M = (pll >> 0) & 0xFF; N = (pll >> 8) & 0xFF; P = (pll >> 16) & 0x0F;
619
    M = (pll >> 0) & 0xFF; N = (pll >> 8) & 0xFF; P = (pll >> 16) & 0x0F;
609
    MClk = (N * chip->CrystalFreqKHz / M) >> P;
620
    MClk = (N * chip->CrystalFreqKHz / M) >> P;
610
    sim_data.pix_bpp        = (char)pixelDepth;
621
    sim_data.pix_bpp        = (char)pixelDepth;
Lines 791-800 Link Here
791
    nv4_sim_state sim_data;
802
    nv4_sim_state sim_data;
792
    unsigned int M, N, P, pll, MClk, NVClk, cfg1;
803
    unsigned int M, N, P, pll, MClk, NVClk, cfg1;
793
804
794
    pll = chip->PRAMDAC[0x00000504/4];
805
    pll = chip->PRAMDAC0[0x00000504/4];
795
    M = (pll >> 0)  & 0xFF; N = (pll >> 8)  & 0xFF; P = (pll >> 16) & 0x0F;
806
    M = (pll >> 0)  & 0xFF; N = (pll >> 8)  & 0xFF; P = (pll >> 16) & 0x0F;
796
    MClk  = (N * chip->CrystalFreqKHz / M) >> P;
807
    MClk  = (N * chip->CrystalFreqKHz / M) >> P;
797
    pll = chip->PRAMDAC[0x00000500/4];
808
    pll = chip->PRAMDAC0[0x00000500/4];
798
    M = (pll >> 0)  & 0xFF; N = (pll >> 8)  & 0xFF; P = (pll >> 16) & 0x0F;
809
    M = (pll >> 0)  & 0xFF; N = (pll >> 8)  & 0xFF; P = (pll >> 16) & 0x0F;
799
    NVClk  = (N * chip->CrystalFreqKHz / M) >> P;
810
    NVClk  = (N * chip->CrystalFreqKHz / M) >> P;
800
    cfg1 = chip->PFB[0x00000204/4];
811
    cfg1 = chip->PFB[0x00000204/4];
Lines 1052-1061 Link Here
1052
    nv10_sim_state sim_data;
1063
    nv10_sim_state sim_data;
1053
    unsigned int M, N, P, pll, MClk, NVClk, cfg1;
1064
    unsigned int M, N, P, pll, MClk, NVClk, cfg1;
1054
1065
1055
    pll = chip->PRAMDAC[0x00000504/4];
1066
    pll = chip->PRAMDAC0[0x00000504/4];
1056
    M = (pll >> 0)  & 0xFF; N = (pll >> 8)  & 0xFF; P = (pll >> 16) & 0x0F;
1067
    M = (pll >> 0)  & 0xFF; N = (pll >> 8)  & 0xFF; P = (pll >> 16) & 0x0F;
1057
    MClk  = (N * chip->CrystalFreqKHz / M) >> P;
1068
    MClk  = (N * chip->CrystalFreqKHz / M) >> P;
1058
    pll = chip->PRAMDAC[0x00000500/4];
1069
    pll = chip->PRAMDAC0[0x00000500/4];
1059
    M = (pll >> 0)  & 0xFF; N = (pll >> 8)  & 0xFF; P = (pll >> 16) & 0x0F;
1070
    M = (pll >> 0)  & 0xFF; N = (pll >> 8)  & 0xFF; P = (pll >> 16) & 0x0F;
1060
    NVClk  = (N * chip->CrystalFreqKHz / M) >> P;
1071
    NVClk  = (N * chip->CrystalFreqKHz / M) >> P;
1061
    cfg1 = chip->PFB[0x00000204/4];
1072
    cfg1 = chip->PFB[0x00000204/4];
Lines 1081-1086 Link Here
1081
    }
1092
    }
1082
}
1093
}
1083
1094
1095
static void nForceUpdateArbitrationSettings
1096
(
1097
    unsigned      VClk,
1098
    unsigned      pixelDepth,
1099
    unsigned     *burst,
1100
    unsigned     *lwm,
1101
    RIVA_HW_INST *chip
1102
)
1103
{
1104
    nv10_fifo_info fifo_data;
1105
    nv10_sim_state sim_data;
1106
    unsigned int M, N, P, pll, MClk, NVClk;
1107
    unsigned int uMClkPostDiv;
1108
    struct pci_dev *dev;
1109
1110
    dev = pci_find_slot(0, 3);
1111
    pci_read_config_dword(dev, 0x6C, &uMClkPostDiv);
1112
    uMClkPostDiv = (uMClkPostDiv >> 8) & 0xf;
1113
1114
    if(!uMClkPostDiv) uMClkPostDiv = 4;
1115
    MClk = 400000 / uMClkPostDiv;
1116
1117
    pll = chip->PRAMDAC0[0x00000500/4];
1118
    M = (pll >> 0)  & 0xFF; N = (pll >> 8)  & 0xFF; P = (pll >> 16) & 0x0F;
1119
    NVClk  = (N * chip->CrystalFreqKHz / M) >> P;
1120
    sim_data.pix_bpp        = (char)pixelDepth;
1121
    sim_data.enable_video   = 0;
1122
    sim_data.enable_mp      = 0;
1123
1124
    dev = pci_find_slot(0, 1);
1125
    pci_read_config_dword(dev, 0x7C, &sim_data.memory_type);
1126
    sim_data.memory_type    = (sim_data.memory_type >> 12) & 1;
1127
1128
    sim_data.memory_width   = 64;
1129
    sim_data.mem_latency    = 3;
1130
    sim_data.mem_aligned    = 1;
1131
    sim_data.mem_page_miss  = 10;
1132
    sim_data.gr_during_vid  = 0;
1133
    sim_data.pclk_khz       = VClk;
1134
    sim_data.mclk_khz       = MClk;
1135
    sim_data.nvclk_khz      = NVClk;
1136
    nv10CalcArbitration(&fifo_data, &sim_data);
1137
    if (fifo_data.valid)
1138
    {
1139
        int  b = fifo_data.graphics_burst_size >> 4;
1140
        *burst = 0;
1141
        while (b >>= 1) (*burst)++;
1142
        *lwm   = fifo_data.graphics_lwm >> 3;
1143
    }
1144
}
1145
1084
/****************************************************************************\
1146
/****************************************************************************\
1085
*                                                                            *
1147
*                                                                            *
1086
*                          RIVA Mode State Routines                          *
1148
*                          RIVA Mode State Routines                          *
Lines 1093-1099 Link Here
1093
static int CalcVClock
1155
static int CalcVClock
1094
(
1156
(
1095
    int           clockIn,
1157
    int           clockIn,
1096
    int           double_scan,
1097
    int          *clockOut,
1158
    int          *clockOut,
1098
    int          *mOut,
1159
    int          *mOut,
1099
    int          *nOut,
1160
    int          *nOut,
Lines 1109-1126 Link Here
1109
    DeltaOld = 0xFFFFFFFF;
1170
    DeltaOld = 0xFFFFFFFF;
1110
1171
1111
    VClk     = (unsigned)clockIn;
1172
    VClk     = (unsigned)clockIn;
1112
    if (double_scan)
1113
        VClk *= 2;
1114
    
1173
    
1115
    if (chip->CrystalFreqKHz == 14318)
1174
    if (chip->CrystalFreqKHz == 13500)
1116
    {
1175
    {
1117
        lowM  = 8;
1176
        lowM  = 7;
1118
        highM = 14 - (chip->Architecture == NV_ARCH_03);
1177
        highM = 13 - (chip->Architecture == NV_ARCH_03);
1119
    }
1178
    }
1120
    else
1179
    else
1121
    {
1180
    {
1122
        lowM  = 7;
1181
        lowM  = 8;
1123
        highM = 13 - (chip->Architecture == NV_ARCH_03);
1182
        highM = 14 - (chip->Architecture == NV_ARCH_03);
1124
    }                      
1183
    }                      
1125
1184
1126
    highP = 4 - (chip->Architecture == NV_ARCH_03);
1185
    highP = 4 - (chip->Architecture == NV_ARCH_03);
Lines 1131-1137 Link Here
1131
        {
1190
        {
1132
            for (M = lowM; M <= highM; M++)
1191
            for (M = lowM; M <= highM; M++)
1133
            {
1192
            {
1134
                N    = (VClk * M / chip->CrystalFreqKHz) << P;
1193
                N    = (VClk << P) * M / chip->CrystalFreqKHz;
1194
                if(N <= 255) {
1135
                Freq = (chip->CrystalFreqKHz * N / M) >> P;
1195
                Freq = (chip->CrystalFreqKHz * N / M) >> P;
1136
                if (Freq > VClk)
1196
                if (Freq > VClk)
1137
                    DeltaNew = Freq - VClk;
1197
                    DeltaNew = Freq - VClk;
Lines 1148-1153 Link Here
1148
            }
1208
            }
1149
        }
1209
        }
1150
    }
1210
    }
1211
    }
1151
    return (DeltaOld != 0xFFFFFFFF);
1212
    return (DeltaOld != 0xFFFFFFFF);
1152
}
1213
}
1153
/*
1214
/*
Lines 1161-1175 Link Here
1161
    int            bpp,
1222
    int            bpp,
1162
    int            width,
1223
    int            width,
1163
    int            hDisplaySize,
1224
    int            hDisplaySize,
1164
    int            hDisplay,
1165
    int            hStart,
1166
    int            hEnd,
1167
    int            hTotal,
1168
    int            height,
1225
    int            height,
1169
    int            vDisplay,
1170
    int            vStart,
1171
    int            vEnd,
1172
    int            vTotal,
1173
    int            dotClock
1226
    int            dotClock
1174
)
1227
)
1175
{
1228
{
Lines 1177-1191 Link Here
1177
    /*
1230
    /*
1178
     * Save mode parameters.
1231
     * Save mode parameters.
1179
     */
1232
     */
1180
    state->bpp    = bpp;
1233
    state->bpp    = bpp;    /* this is not bitsPerPixel, it's 8,15,16,32 */
1181
    state->width  = width;
1234
    state->width  = width;
1182
    state->height = height;
1235
    state->height = height;
1183
    /*
1236
    /*
1184
     * Extended RIVA registers.
1237
     * Extended RIVA registers.
1185
     */
1238
     */
1186
    pixelDepth = (bpp + 1)/8;
1239
    pixelDepth = (bpp + 1)/8;
1187
    CalcVClock(dotClock, hDisplaySize < 512,  /* double scan? */
1240
    CalcVClock(dotClock, &VClk, &m, &n, &p, chip);
1188
               &VClk, &m, &n, &p, chip);
1189
1241
1190
    switch (chip->Architecture)
1242
    switch (chip->Architecture)
1191
    {
1243
    {
Lines 1220-1248 Link Here
1220
            state->repaint1 = hDisplaySize < 1280 ? 0x04 : 0x00;
1272
            state->repaint1 = hDisplaySize < 1280 ? 0x04 : 0x00;
1221
            break;
1273
            break;
1222
        case NV_ARCH_10:
1274
        case NV_ARCH_10:
1223
	case NV_ARCH_20:
1275
        case NV_ARCH_20:
1224
            nv10UpdateArbitrationSettings(VClk, 
1276
            if((chip->Chipset == NV_CHIP_IGEFORCE2) ||
1277
               (chip->Chipset == NV_CHIP_0x01F0))
1278
            {
1279
                nForceUpdateArbitrationSettings(VClk,
1280
                                          pixelDepth * 8,
1281
                                         &(state->arbitration0),
1282
                                         &(state->arbitration1),
1283
                                          chip);
1284
            } else {
1285
                nv10UpdateArbitrationSettings(VClk, 
1225
                                          pixelDepth * 8, 
1286
                                          pixelDepth * 8, 
1226
                                         &(state->arbitration0),
1287
                                         &(state->arbitration0),
1227
                                         &(state->arbitration1),
1288
                                         &(state->arbitration1),
1228
                                          chip);
1289
                                          chip);
1229
            state->cursor0  = 0x00;
1290
            }
1230
            state->cursor1  = 0xFC;
1291
            state->cursor0  = 0x80 | (chip->CursorStart >> 17);
1231
            state->cursor2  = 0x00000000;
1292
            state->cursor1  = (chip->CursorStart >> 11) << 2;
1293
            state->cursor2  = chip->CursorStart >> 24;
1232
            state->pllsel   = 0x10000700;
1294
            state->pllsel   = 0x10000700;
1233
            state->config   = chip->PFB[0x00000200/4];
1295
            state->config   = chip->PFB[0x00000200/4];
1234
            state->general  = bpp == 16 ? 0x00101100 : 0x00100100;
1296
            state->general  = bpp == 16 ? 0x00101100 : 0x00100100;
1235
            state->repaint1 = hDisplaySize < 1280 ? 0x04 : 0x00;
1297
            state->repaint1 = hDisplaySize < 1280 ? 0x04 : 0x00;
1236
            break;
1298
            break;
1237
    }
1299
    }
1300
1301
    /* Paul Richards: below if block borks things in kernel for some reason */
1302
    /* if((bpp != 8) && (chip->Architecture != NV_ARCH_03))
1303
    state->general |= 0x00000030; */
1304
1238
    state->vpll     = (p << 16) | (n << 8) | m;
1305
    state->vpll     = (p << 16) | (n << 8) | m;
1239
    state->screen   = ((hTotal   & 0x040) >> 2)
1240
                    | ((vDisplay & 0x400) >> 7)
1241
                    | ((vStart   & 0x400) >> 8)
1242
                    | ((vDisplay & 0x400) >> 9)
1243
                    | ((vTotal   & 0x400) >> 10);
1244
    state->repaint0 = (((width/8)*pixelDepth) & 0x700) >> 3;
1306
    state->repaint0 = (((width/8)*pixelDepth) & 0x700) >> 3;
1245
    state->horiz    = hTotal     < 260 ? 0x00 : 0x01;
1246
    state->pixel    = pixelDepth > 2   ? 3    : pixelDepth;
1307
    state->pixel    = pixelDepth > 2   ? 3    : pixelDepth;
1247
    state->offset0  =
1308
    state->offset0  =
1248
    state->offset1  =
1309
    state->offset1  =
Lines 1286-1292 Link Here
1286
            chip->Tri05 = (RivaTexturedTriangle05 *)&(chip->FIFO[0x0000E000/4]);
1347
            chip->Tri05 = (RivaTexturedTriangle05 *)&(chip->FIFO[0x0000E000/4]);
1287
            break;
1348
            break;
1288
        case NV_ARCH_10:
1349
        case NV_ARCH_10:
1289
	case NV_ARCH_20:
1350
        case NV_ARCH_20:
1290
            /*
1351
            /*
1291
             * Initialize state for the RivaTriangle3D05 routines.
1352
             * Initialize state for the RivaTriangle3D05 routines.
1292
             */
1353
             */
Lines 1395-1401 Link Here
1395
            chip->PGRAPH[0x0000067C/4] = state->pitch3;
1456
            chip->PGRAPH[0x0000067C/4] = state->pitch3;
1396
            break;
1457
            break;
1397
        case NV_ARCH_10:
1458
        case NV_ARCH_10:
1398
	case NV_ARCH_20:
1459
        case NV_ARCH_20:
1460
            if(chip->twoHeads) {
1461
               VGA_WR08(chip->PCIO, 0x03D4, 0x44);
1462
               VGA_WR08(chip->PCIO, 0x03D5, state->crtcOwner);
1463
               chip->LockUnlock(chip, 0);
1464
            }
1465
1399
            LOAD_FIXED_STATE(nv10,PFIFO);
1466
            LOAD_FIXED_STATE(nv10,PFIFO);
1400
            LOAD_FIXED_STATE(nv10,PRAMIN);
1467
            LOAD_FIXED_STATE(nv10,PRAMIN);
1401
            LOAD_FIXED_STATE(nv10,PGRAPH);
1468
            LOAD_FIXED_STATE(nv10,PGRAPH);
Lines 1425-1463 Link Here
1425
                    break;
1492
                    break;
1426
            }
1493
            }
1427
1494
1428
	    if (chip->Architecture == NV_ARCH_10) {
1495
            if(chip->Architecture == NV_ARCH_10) {
1429
            	chip->PGRAPH[0x00000640/4] = state->offset0;
1496
                chip->PGRAPH[0x00000640/4] = state->offset0;
1430
            	chip->PGRAPH[0x00000644/4] = state->offset1;
1497
                chip->PGRAPH[0x00000644/4] = state->offset1;
1431
            	chip->PGRAPH[0x00000648/4] = state->offset2;
1498
                chip->PGRAPH[0x00000648/4] = state->offset2;
1432
            	chip->PGRAPH[0x0000064C/4] = state->offset3;
1499
                chip->PGRAPH[0x0000064C/4] = state->offset3;
1433
            	chip->PGRAPH[0x00000670/4] = state->pitch0;
1500
                chip->PGRAPH[0x00000670/4] = state->pitch0;
1434
            	chip->PGRAPH[0x00000674/4] = state->pitch1;
1501
                chip->PGRAPH[0x00000674/4] = state->pitch1;
1435
            	chip->PGRAPH[0x00000678/4] = state->pitch2;
1502
                chip->PGRAPH[0x00000678/4] = state->pitch2;
1436
            	chip->PGRAPH[0x0000067C/4] = state->pitch3;
1503
                chip->PGRAPH[0x0000067C/4] = state->pitch3;
1437
            	chip->PGRAPH[0x00000680/4] = state->pitch3;
1504
                chip->PGRAPH[0x00000680/4] = state->pitch3;
1438
	    } else {
1505
        } else {
1439
		chip->PGRAPH[0x00000820/4] = state->offset0;
1506
        chip->PGRAPH[0x00000820/4] = state->offset0;
1440
		chip->PGRAPH[0x00000824/4] = state->offset1;
1507
        chip->PGRAPH[0x00000824/4] = state->offset1;
1441
		chip->PGRAPH[0x00000828/4] = state->offset2;
1508
        chip->PGRAPH[0x00000828/4] = state->offset2;
1442
		chip->PGRAPH[0x0000082C/4] = state->offset3;
1509
        chip->PGRAPH[0x0000082C/4] = state->offset3;
1443
		chip->PGRAPH[0x00000850/4] = state->pitch0;
1510
        chip->PGRAPH[0x00000850/4] = state->pitch0;
1444
		chip->PGRAPH[0x00000854/4] = state->pitch1;
1511
        chip->PGRAPH[0x00000854/4] = state->pitch1;
1445
		chip->PGRAPH[0x00000858/4] = state->pitch2;
1512
        chip->PGRAPH[0x00000858/4] = state->pitch2;
1446
		chip->PGRAPH[0x0000085C/4] = state->pitch3;
1513
        chip->PGRAPH[0x0000085C/4] = state->pitch3;
1447
		chip->PGRAPH[0x00000860/4] = state->pitch3;
1514
        chip->PGRAPH[0x00000860/4] = state->pitch3;
1448
		chip->PGRAPH[0x00000864/4] = state->pitch3;
1515
        chip->PGRAPH[0x00000864/4] = state->pitch3;
1449
		chip->PGRAPH[0x000009A4/4] = chip->PFB[0x00000200/4];
1516
        chip->PGRAPH[0x000009A4/4] = chip->PFB[0x00000200/4];
1450
		chip->PGRAPH[0x000009A8/4] = chip->PFB[0x00000204/4];
1517
        chip->PGRAPH[0x000009A8/4] = chip->PFB[0x00000204/4];
1451
	    }
1518
        }
1452
1519
            if(chip->twoHeads) {
1453
	    chip->PFB[0x00000240/4] = 0;
1520
               chip->PCRTC0[0x00000860/4] = state->head;
1454
	    chip->PFB[0x00000244/4] = 0;
1521
               chip->PCRTC0[0x00002860/4] = state->head2;
1455
	    chip->PFB[0x00000248/4] = 0;
1522
            }
1456
	    chip->PFB[0x0000024C/4] = 0;
1523
            chip->PRAMDAC[0x00000404/4] |= (1 << 25);
1457
	    chip->PFB[0x00000250/4] = 0;
1524
1458
	    chip->PFB[0x00000244/4] = 0;
1525
            chip->PMC[0x00008704/4] = 1;
1459
	    chip->PFB[0x00000248/4] = 0;
1526
            chip->PMC[0x00008140/4] = 0;
1460
	    chip->PFB[0x0000024C/4] = 0;
1527
            chip->PMC[0x00008920/4] = 0;
1528
            chip->PMC[0x00008924/4] = 0;
1529
            chip->PMC[0x00008908/4] = 0x01ffffff;
1530
            chip->PMC[0x0000890C/4] = 0x01ffffff;
1531
            chip->PMC[0x00001588/4] = 0;
1532
1533
            chip->PFB[0x00000240/4] = 0;
1534
            chip->PFB[0x00000244/4] = 0;
1535
            chip->PFB[0x00000248/4] = 0;
1536
            chip->PFB[0x0000024C/4] = 0;
1537
            chip->PFB[0x00000250/4] = 0;
1538
            chip->PFB[0x00000254/4] = 0;
1539
            chip->PFB[0x00000258/4] = 0;
1540
            chip->PFB[0x0000025C/4] = 0;
1461
1541
1462
            chip->PGRAPH[0x00000B00/4] = chip->PFB[0x00000240/4];
1542
            chip->PGRAPH[0x00000B00/4] = chip->PFB[0x00000240/4];
1463
            chip->PGRAPH[0x00000B04/4] = chip->PFB[0x00000244/4];
1543
            chip->PGRAPH[0x00000B04/4] = chip->PFB[0x00000244/4];
Lines 1533-1547 Link Here
1533
            for (i = 0; i < 4; i++)
1613
            for (i = 0; i < 4; i++)
1534
                chip->PGRAPH[0x00000F54/4] = 0x00000000;
1614
                chip->PGRAPH[0x00000F54/4] = 0x00000000;
1535
1615
1536
	    if (chip->flatPanel) {
1616
            chip->PCRTC[0x00000810/4] = state->cursorConfig;
1537
		VGA_WR08(chip->PCIO, 0x3d4, 0x53);
1617
1538
		VGA_WR08(chip->PCIO, 0x3d5, 0);
1618
            if(chip->flatPanel) {
1539
		VGA_WR08(chip->PCIO, 0x3d4, 0x54);
1619
               if((chip->Chipset & 0x0ff0) == 0x0110) {
1540
		VGA_WR08(chip->PCIO, 0x3d5, 0);
1620
                   chip->PRAMDAC[0x0528/4] = state->dither;
1541
		VGA_WR08(chip->PCIO, 0x3d4, 0x21);
1621
               } else 
1542
		VGA_WR08(chip->PCIO, 0x3d5, 0xfa);
1622
               if((chip->Chipset & 0x0ff0) >= 0x0170) {
1543
	    }
1623
                   chip->PRAMDAC[0x083C/4] = state->dither;
1544
            break;
1624
               }
1625
            
1626
               VGA_WR08(chip->PCIO, 0x03D4, 0x53);
1627
               VGA_WR08(chip->PCIO, 0x03D5, 0);
1628
               VGA_WR08(chip->PCIO, 0x03D4, 0x54);
1629
               VGA_WR08(chip->PCIO, 0x03D5, 0);
1630
               VGA_WR08(chip->PCIO, 0x03D4, 0x21);
1631
               VGA_WR08(chip->PCIO, 0x03D5, 0xfa);
1632
            }
1633
1634
            VGA_WR08(chip->PCIO, 0x03D4, 0x41);
1635
            VGA_WR08(chip->PCIO, 0x03D5, state->extra);
1545
    }
1636
    }
1546
    LOAD_FIXED_STATE(Riva,FIFO);
1637
    LOAD_FIXED_STATE(Riva,FIFO);
1547
    UpdateFifoState(chip);
1638
    UpdateFifoState(chip);
Lines 1566-1590 Link Here
1566
    VGA_WR08(chip->PCIO, 0x03D5, state->cursor0);
1657
    VGA_WR08(chip->PCIO, 0x03D5, state->cursor0);
1567
    VGA_WR08(chip->PCIO, 0x03D4, 0x31);
1658
    VGA_WR08(chip->PCIO, 0x03D4, 0x31);
1568
    VGA_WR08(chip->PCIO, 0x03D5, state->cursor1);
1659
    VGA_WR08(chip->PCIO, 0x03D5, state->cursor1);
1569
    VGA_WR08(chip->PCIO, 0x03D4, 0x41);
1660
    VGA_WR08(chip->PCIO, 0x03D4, 0x2F);
1570
    VGA_WR08(chip->PCIO, 0x03D5, state->extra);
1661
    VGA_WR08(chip->PCIO, 0x03D5, state->cursor2);
1571
1662
    VGA_WR08(chip->PCIO, 0x03D4, 0x39);
1572
    if (!chip->flatPanel) {
1663
    VGA_WR08(chip->PCIO, 0x03D5, state->interlace);
1573
        chip->PRAMDAC[0x00000508/4]  = state->vpll;
1664
1574
        chip->PRAMDAC[0x00000520/4]  = state->vpll2;
1665
    if(!chip->flatPanel) {
1575
        chip->PRAMDAC[0x0000050C/4]  = state->pllsel;
1666
       chip->PRAMDAC0[0x00000508/4] = state->vpll;
1576
    } else {
1667
       chip->PRAMDAC0[0x0000050C/4] = state->pllsel;
1577
	chip->PRAMDAC[0x00000848/4]  = state->scale;
1668
       if(chip->twoHeads)
1578
    }
1669
          chip->PRAMDAC0[0x00000520/4] = state->vpll2;
1579
    chip->PRAMDAC[0x00000300/4]  = state->cursor2;
1670
    }  else {
1580
    chip->PRAMDAC[0x00000508/4]  = state->vpll;
1671
       chip->PRAMDAC[0x00000848/4]  = state->scale;
1581
    chip->PRAMDAC[0x0000050C/4]  = state->pllsel;
1672
    }  
1582
    chip->PRAMDAC[0x00000600/4]  = state->general;
1673
    chip->PRAMDAC[0x00000600/4]  = state->general;
1674
1583
    /*
1675
    /*
1584
     * Turn off VBlank enable and reset.
1676
     * Turn off VBlank enable and reset.
1585
     */
1677
     */
1586
    *(chip->VBLANKENABLE) = 0;
1678
    chip->PCRTC[0x00000140/4] = 0;
1587
    *(chip->VBLANK)       = chip->VBlankBit;
1679
    chip->PCRTC[0x00000100/4] = chip->VBlankBit;
1588
    /*
1680
    /*
1589
     * Set interrupt enable.
1681
     * Set interrupt enable.
1590
     */    
1682
     */    
Lines 1627-1640 Link Here
1627
    state->cursor0      = VGA_RD08(chip->PCIO, 0x03D5);
1719
    state->cursor0      = VGA_RD08(chip->PCIO, 0x03D5);
1628
    VGA_WR08(chip->PCIO, 0x03D4, 0x31);
1720
    VGA_WR08(chip->PCIO, 0x03D4, 0x31);
1629
    state->cursor1      = VGA_RD08(chip->PCIO, 0x03D5);
1721
    state->cursor1      = VGA_RD08(chip->PCIO, 0x03D5);
1630
    VGA_WR08(chip->PCIO, 0x03D4, 0x41);
1722
    VGA_WR08(chip->PCIO, 0x03D4, 0x2F);
1631
    state->extra        = VGA_RD08(chip->PCIO, 0x03D5);
1723
    state->cursor2      = VGA_RD08(chip->PCIO, 0x03D5);
1632
    state->cursor2      = chip->PRAMDAC[0x00000300/4];
1724
    VGA_WR08(chip->PCIO, 0x03D4, 0x39);
1633
    state->vpll         = chip->PRAMDAC[0x00000508/4];
1725
    state->interlace    = VGA_RD08(chip->PCIO, 0x03D5);
1634
    state->vpll2        = chip->PRAMDAC[0x00000520/4];
1726
    state->vpll         = chip->PRAMDAC0[0x00000508/4];
1635
    state->pllsel       = chip->PRAMDAC[0x0000050C/4];
1727
    state->vpll2        = chip->PRAMDAC0[0x00000520/4];
1728
    state->pllsel       = chip->PRAMDAC0[0x0000050C/4];
1636
    state->general      = chip->PRAMDAC[0x00000600/4];
1729
    state->general      = chip->PRAMDAC[0x00000600/4];
1637
    state->scale	= chip->PRAMDAC[0x00000848/4];
1730
    state->scale        = chip->PRAMDAC[0x00000848/4];
1638
    state->config       = chip->PFB[0x00000200/4];
1731
    state->config       = chip->PFB[0x00000200/4];
1639
    switch (chip->Architecture)
1732
    switch (chip->Architecture)
1640
    {
1733
    {
Lines 1659-1665 Link Here
1659
            state->pitch3   = chip->PGRAPH[0x0000067C/4];
1752
            state->pitch3   = chip->PGRAPH[0x0000067C/4];
1660
            break;
1753
            break;
1661
        case NV_ARCH_10:
1754
        case NV_ARCH_10:
1662
	case NV_ARCH_20:
1755
        case NV_ARCH_20:
1663
            state->offset0  = chip->PGRAPH[0x00000640/4];
1756
            state->offset0  = chip->PGRAPH[0x00000640/4];
1664
            state->offset1  = chip->PGRAPH[0x00000644/4];
1757
            state->offset1  = chip->PGRAPH[0x00000644/4];
1665
            state->offset2  = chip->PGRAPH[0x00000648/4];
1758
            state->offset2  = chip->PGRAPH[0x00000648/4];
Lines 1668-1673 Link Here
1668
            state->pitch1   = chip->PGRAPH[0x00000674/4];
1761
            state->pitch1   = chip->PGRAPH[0x00000674/4];
1669
            state->pitch2   = chip->PGRAPH[0x00000678/4];
1762
            state->pitch2   = chip->PGRAPH[0x00000678/4];
1670
            state->pitch3   = chip->PGRAPH[0x0000067C/4];
1763
            state->pitch3   = chip->PGRAPH[0x0000067C/4];
1764
            if(chip->twoHeads) {
1765
               state->head     = chip->PCRTC0[0x00000860/4];
1766
               state->head2    = chip->PCRTC0[0x00002860/4];
1767
               VGA_WR08(chip->PCIO, 0x03D4, 0x44);
1768
               state->crtcOwner = VGA_RD08(chip->PCIO, 0x03D5);
1769
            }
1770
            VGA_WR08(chip->PCIO, 0x03D4, 0x41);
1771
            state->extra = VGA_RD08(chip->PCIO, 0x03D5);
1772
            state->cursorConfig = chip->PCRTC[0x00000810/4];
1773
1774
            if((chip->Chipset & 0x0ff0) == 0x0110) {
1775
                state->dither = chip->PRAMDAC[0x0528/4];
1776
            } else 
1777
            if((chip->Chipset & 0x0ff0) >= 0x0170) {
1778
                state->dither = chip->PRAMDAC[0x083C/4];
1779
            }
1671
            break;
1780
            break;
1672
    }
1781
    }
1673
}
1782
}
Lines 1677-1682 Link Here
1677
    unsigned      start
1786
    unsigned      start
1678
)
1787
)
1679
{
1788
{
1789
    chip->PCRTC[0x800/4] = start;
1790
}
1791
1792
static void SetStartAddress3
1793
(
1794
    RIVA_HW_INST *chip,
1795
    unsigned      start
1796
)
1797
{
1680
    int offset = start >> 2;
1798
    int offset = start >> 2;
1681
    int pan    = (start & 3) << 1;
1799
    int pan    = (start & 3) << 1;
1682
    unsigned char tmp;
1800
    unsigned char tmp;
Lines 1857-1867 Link Here
1857
                break;
1975
                break;
1858
        }
1976
        }
1859
    }        
1977
    }        
1860
    chip->CrystalFreqKHz   = (chip->PEXTDEV[0x00000000/4] & 0x00000020) ? 14318 : 13500;
1978
    chip->CrystalFreqKHz   = (chip->PEXTDEV[0x00000000/4] & 0x00000040) ? 14318 : 13500;
1861
    chip->CURSOR           = &(chip->PRAMIN[0x00008000/4 - 0x0800/4]);
1979
    chip->CURSOR           = &(chip->PRAMIN[0x00008000/4 - 0x0800/4]);
1862
    chip->CURSORPOS        = &(chip->PRAMDAC[0x0300/4]);
1863
    chip->VBLANKENABLE     = &(chip->PGRAPH[0x0140/4]);
1864
    chip->VBLANK           = &(chip->PGRAPH[0x0100/4]);
1865
    chip->VBlankBit        = 0x00000100;
1980
    chip->VBlankBit        = 0x00000100;
1866
    chip->MaxVClockFreqKHz = 256000;
1981
    chip->MaxVClockFreqKHz = 256000;
1867
    /*
1982
    /*
Lines 1872-1878 Link Here
1872
    chip->CalcStateExt    = CalcStateExt;
1987
    chip->CalcStateExt    = CalcStateExt;
1873
    chip->LoadStateExt    = LoadStateExt;
1988
    chip->LoadStateExt    = LoadStateExt;
1874
    chip->UnloadStateExt  = UnloadStateExt;
1989
    chip->UnloadStateExt  = UnloadStateExt;
1875
    chip->SetStartAddress = SetStartAddress;
1990
    chip->SetStartAddress = SetStartAddress3;
1876
    chip->SetSurfaces2D   = nv3SetSurfaces2D;
1991
    chip->SetSurfaces2D   = nv3SetSurfaces2D;
1877
    chip->SetSurfaces3D   = nv3SetSurfaces3D;
1992
    chip->SetSurfaces3D   = nv3SetSurfaces3D;
1878
    chip->LockUnlock      = nv3LockUnlock;
1993
    chip->LockUnlock      = nv3LockUnlock;
Lines 1920-1928 Link Here
1920
    }
2035
    }
1921
    chip->CrystalFreqKHz   = (chip->PEXTDEV[0x00000000/4] & 0x00000040) ? 14318 : 13500;
2036
    chip->CrystalFreqKHz   = (chip->PEXTDEV[0x00000000/4] & 0x00000040) ? 14318 : 13500;
1922
    chip->CURSOR           = &(chip->PRAMIN[0x00010000/4 - 0x0800/4]);
2037
    chip->CURSOR           = &(chip->PRAMIN[0x00010000/4 - 0x0800/4]);
1923
    chip->CURSORPOS        = &(chip->PRAMDAC[0x0300/4]);
1924
    chip->VBLANKENABLE     = &(chip->PCRTC[0x0140/4]);
1925
    chip->VBLANK           = &(chip->PCRTC[0x0100/4]);
1926
    chip->VBlankBit        = 0x00000001;
2038
    chip->VBlankBit        = 0x00000001;
1927
    chip->MaxVClockFreqKHz = 350000;
2039
    chip->MaxVClockFreqKHz = 350000;
1928
    /*
2040
    /*
Lines 1940-1980 Link Here
1940
}
2052
}
1941
static void nv10GetConfig
2053
static void nv10GetConfig
1942
(
2054
(
1943
    RIVA_HW_INST *chip
2055
    RIVA_HW_INST *chip,
2056
    unsigned int chipset
1944
)
2057
)
1945
{
2058
{
1946
#if defined(__BIG_ENDIAN)
2059
    struct pci_dev* dev;
1947
    chip->PMC[0x00000004/4] = 0x01000001;
2060
    int amt;
2061
2062
#ifdef __BIG_ENDIAN
2063
    /* turn on big endian register access */
2064
    if(!(chip->PMC[0x00000004/4] & 0x01000001))
2065
        chip->PMC[0x00000004/4] = 0x01000001;
1948
#endif
2066
#endif
2067
1949
    /*
2068
    /*
1950
     * Fill in chip configuration.
2069
     * Fill in chip configuration.
1951
     */
2070
     */
1952
    switch ((chip->PFB[0x0000020C/4] >> 20) & 0x000000FF)
2071
    if(chipset == NV_CHIP_IGEFORCE2) {
1953
    {
2072
        dev = pci_find_slot(0, 1);
1954
        case 0x02:
2073
        pci_read_config_dword(dev, 0x7C, &amt);
1955
            chip->RamAmountKBytes = 1024 * 2;
2074
        chip->RamAmountKBytes = (((amt >> 6) & 31) + 1) * 1024;
1956
            break;
2075
    } else if(chipset == NV_CHIP_0x01F0) {
1957
        case 0x04:
2076
        dev = pci_find_slot(0, 1);
1958
            chip->RamAmountKBytes = 1024 * 4;
2077
        pci_read_config_dword(dev, 0x84, &amt);
1959
            break;
2078
        chip->RamAmountKBytes = (((amt >> 4) & 127) + 1) * 1024;
1960
        case 0x08:
2079
    } else {
1961
            chip->RamAmountKBytes = 1024 * 8;
2080
        switch ((chip->PFB[0x0000020C/4] >> 20) & 0x000000FF)
1962
            break;
2081
        {
1963
        case 0x10:
2082
            case 0x02:
1964
            chip->RamAmountKBytes = 1024 * 16;
2083
                chip->RamAmountKBytes = 1024 * 2;
1965
            break;
2084
                break;
1966
        case 0x20:
2085
            case 0x04:
1967
            chip->RamAmountKBytes = 1024 * 32;
2086
                chip->RamAmountKBytes = 1024 * 4;
1968
            break;
2087
                break;
1969
        case 0x40:
2088
            case 0x08:
1970
            chip->RamAmountKBytes = 1024 * 64;
2089
                chip->RamAmountKBytes = 1024 * 8;
1971
            break;
2090
                break;
1972
        case 0x80:
2091
            case 0x10:
1973
            chip->RamAmountKBytes = 1024 * 128;
2092
                chip->RamAmountKBytes = 1024 * 16;
1974
            break;
2093
                break;
1975
        default:
2094
            case 0x20:
1976
            chip->RamAmountKBytes = 1024 * 16;
2095
                chip->RamAmountKBytes = 1024 * 32;
1977
            break;
2096
                break;
2097
            case 0x40:
2098
                chip->RamAmountKBytes = 1024 * 64;
2099
                break;
2100
            case 0x80:
2101
                chip->RamAmountKBytes = 1024 * 128;
2102
                break;
2103
            default:
2104
                chip->RamAmountKBytes = 1024 * 16;
2105
                break;
2106
        }
1978
    }
2107
    }
1979
    switch ((chip->PFB[0x00000000/4] >> 3) & 0x00000003)
2108
    switch ((chip->PFB[0x00000000/4] >> 3) & 0x00000003)
1980
    {
2109
    {
Lines 1985-1995 Link Here
1985
            chip->RamBandwidthKBytesPerSec = 1000000;
2114
            chip->RamBandwidthKBytesPerSec = 1000000;
1986
            break;
2115
            break;
1987
    }
2116
    }
1988
    chip->CrystalFreqKHz   = (chip->PEXTDEV[0x00000000/4] & 0x00000040) ? 14318 : 13500;
2117
    chip->CrystalFreqKHz = (chip->PEXTDEV[0x0000/4] & (1 << 6)) ? 14318 :
1989
    chip->CURSOR           = &(chip->PRAMIN[0x00010000/4 - 0x0800/4]);
2118
                                                                  13500;
1990
    chip->CURSORPOS        = &(chip->PRAMDAC[0x0300/4]);
2119
1991
    chip->VBLANKENABLE     = &(chip->PCRTC[0x0140/4]);
2120
    switch (chipset & 0x0ff0) {
1992
    chip->VBLANK           = &(chip->PCRTC[0x0100/4]);
2121
    case 0x0170:
2122
    case 0x0180:
2123
    case 0x01F0:
2124
    case 0x0250:
2125
    case 0x0280:
2126
    case 0x0300:
2127
    case 0x0310:
2128
    case 0x0320:
2129
    case 0x0330:
2130
    case 0x0340:
2131
       if(chip->PEXTDEV[0x0000/4] & (1 << 22))
2132
           chip->CrystalFreqKHz = 27000;
2133
       break;
2134
    default:
2135
       break;
2136
    }
2137
2138
    chip->CursorStart      = (chip->RamAmountKBytes - 128) * 1024;
2139
    chip->CURSOR           = NULL;  /* can't set this here */
1993
    chip->VBlankBit        = 0x00000001;
2140
    chip->VBlankBit        = 0x00000001;
1994
    chip->MaxVClockFreqKHz = 350000;
2141
    chip->MaxVClockFreqKHz = 350000;
1995
    /*
2142
    /*
Lines 2003-2013 Link Here
2003
    chip->SetStartAddress = SetStartAddress;
2150
    chip->SetStartAddress = SetStartAddress;
2004
    chip->SetSurfaces2D   = nv10SetSurfaces2D;
2151
    chip->SetSurfaces2D   = nv10SetSurfaces2D;
2005
    chip->SetSurfaces3D   = nv10SetSurfaces3D;
2152
    chip->SetSurfaces3D   = nv10SetSurfaces3D;
2006
    chip->LockUnlock      = nv10LockUnlock;
2153
    chip->LockUnlock      = nv4LockUnlock;
2154
2155
    switch(chipset & 0x0ff0) {
2156
    case 0x0110:
2157
    case 0x0170:
2158
    case 0x0180:
2159
    case 0x01F0:
2160
    case 0x0250:
2161
    case 0x0280:
2162
    case 0x0300:
2163
    case 0x0310:
2164
    case 0x0320:
2165
    case 0x0330:
2166
    case 0x0340:
2167
        chip->twoHeads = TRUE;
2168
        break;
2169
    default:
2170
        chip->twoHeads = FALSE;
2171
        break;
2172
    }
2007
}
2173
}
2008
int RivaGetConfig
2174
int RivaGetConfig
2009
(
2175
(
2010
    RIVA_HW_INST *chip
2176
    RIVA_HW_INST *chip,
2177
    unsigned int chipset
2011
)
2178
)
2012
{
2179
{
2013
    /*
2180
    /*
Lines 2026-2037 Link Here
2026
            nv4GetConfig(chip);
2193
            nv4GetConfig(chip);
2027
            break;
2194
            break;
2028
        case NV_ARCH_10:
2195
        case NV_ARCH_10:
2029
	case NV_ARCH_20:
2196
        case NV_ARCH_20:
2030
            nv10GetConfig(chip);
2197
            nv10GetConfig(chip, chipset);
2031
            break;
2198
            break;
2032
        default:
2199
        default:
2033
            return (-1);
2200
            return (-1);
2034
    }
2201
    }
2202
    chip->Chipset = chipset;
2035
    /*
2203
    /*
2036
     * Fill in FIFO pointers.
2204
     * Fill in FIFO pointers.
2037
     */
2205
     */
(-)linux-2.4.22/drivers/video/riva/riva_hw.h (-17 / +52 lines)
Lines 41-54 Link Here
41
 * GPL licensing note -- nVidia is allowing a liberal interpretation of
41
 * GPL licensing note -- nVidia is allowing a liberal interpretation of
42
 * the documentation restriction above, to merely say that this nVidia's
42
 * the documentation restriction above, to merely say that this nVidia's
43
 * copyright and disclaimer should be included with all code derived
43
 * copyright and disclaimer should be included with all code derived
44
 * from this source.  -- Jeff Garzik <jgarzik@pobox.com>, 01/Nov/99 
44
 * from this source.  -- Jeff Garzik <jgarzik@mandrakesoft.com>, 01/Nov/99 
45
 */
45
 */
46
46
47
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.h,v 1.6 2000/02/08 17:19:12 dawes Exp $ */
47
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.h,v 1.21 2002/10/14 18:22:46 mvojkovi Exp $ */
48
#ifndef __RIVA_HW_H__
48
#ifndef __RIVA_HW_H__
49
#define __RIVA_HW_H__
49
#define __RIVA_HW_H__
50
#define RIVA_SW_VERSION 0x00010003
50
#define RIVA_SW_VERSION 0x00010003
51
51
52
#ifndef Bool
53
typedef int Bool;
54
#endif
55
56
#ifndef TRUE
57
#define TRUE 1
58
#endif
59
#ifndef FALSE
60
#define FALSE 0
61
#endif
62
#ifndef NULL
63
#define NULL 0
64
#endif
65
52
/*
66
/*
53
 * Typedefs to force certain sized values.
67
 * Typedefs to force certain sized values.
54
 */
68
 */
Lines 99-105 Link Here
99
#else
113
#else
100
    U016 FifoFree;
114
    U016 FifoFree;
101
    U016 Nop;
115
    U016 Nop;
102
#endif 
116
#endif
103
    U032 reserved01[0x0BB];
117
    U032 reserved01[0x0BB];
104
    U032 Rop3;
118
    U032 Rop3;
105
} RivaRop;
119
} RivaRop;
Lines 269-275 Link Here
269
#else
283
#else
270
    U016 FifoFree;
284
    U016 FifoFree;
271
    U016 Nop;
285
    U016 Nop;
272
#endif    
286
#endif
273
    U032 reserved01[0x0BC];
287
    U032 reserved01[0x0BC];
274
    U032 TextureOffset;
288
    U032 TextureOffset;
275
    U032 TextureFormat;
289
    U032 TextureFormat;
Lines 299-305 Link Here
299
#else
313
#else
300
    U016 FifoFree;
314
    U016 FifoFree;
301
    U016 Nop;
315
    U016 Nop;
302
#endif    
316
#endif
303
    U032 reserved01[0x0BB];
317
    U032 reserved01[0x0BB];
304
    U032 ColorKey;
318
    U032 ColorKey;
305
    U032 TextureOffset;
319
    U032 TextureOffset;
Lines 337-343 Link Here
337
#else
351
#else
338
    U016 FifoFree;
352
    U016 FifoFree;
339
    U016 Nop[1];
353
    U016 Nop[1];
340
#endif    
354
#endif
341
    U032 reserved01[0x0BC];
355
    U032 reserved01[0x0BC];
342
    U032 Color;             /* source color               0304-0307*/
356
    U032 Color;             /* source color               0304-0307*/
343
    U032 Reserved02[0x03e];
357
    U032 Reserved02[0x03e];
Lines 397-402 Link Here
397
*                                                                           *
411
*                                                                           *
398
\***************************************************************************/
412
\***************************************************************************/
399
413
414
#define FP_ENABLE  1
415
#define FP_DITHER  2
416
400
struct _riva_hw_inst;
417
struct _riva_hw_inst;
401
struct _riva_hw_state;
418
struct _riva_hw_state;
402
/*
419
/*
Lines 409-414 Link Here
409
     */
426
     */
410
    U032 Architecture;
427
    U032 Architecture;
411
    U032 Version;
428
    U032 Version;
429
    U032 Chipset;
412
    U032 CrystalFreqKHz;
430
    U032 CrystalFreqKHz;
413
    U032 RamAmountKBytes;
431
    U032 RamAmountKBytes;
414
    U032 MaxVClockFreqKHz;
432
    U032 MaxVClockFreqKHz;
Lines 418-429 Link Here
418
    U032 VBlankBit;
436
    U032 VBlankBit;
419
    U032 FifoFreeCount;
437
    U032 FifoFreeCount;
420
    U032 FifoEmptyCount;
438
    U032 FifoEmptyCount;
439
    U032 CursorStart;
421
    U032 flatPanel;
440
    U032 flatPanel;
441
    Bool twoHeads;
422
    /*
442
    /*
423
     * Non-FIFO registers.
443
     * Non-FIFO registers.
424
     */
444
     */
445
    volatile U032 *PCRTC0;
425
    volatile U032 *PCRTC;
446
    volatile U032 *PCRTC;
426
    volatile U032 *PRAMDAC;
447
    volatile U032 *PRAMDAC0;
427
    volatile U032 *PFB;
448
    volatile U032 *PFB;
428
    volatile U032 *PFIFO;
449
    volatile U032 *PFIFO;
429
    volatile U032 *PGRAPH;
450
    volatile U032 *PGRAPH;
Lines 433-449 Link Here
433
    volatile U032 *PRAMIN;
454
    volatile U032 *PRAMIN;
434
    volatile U032 *FIFO;
455
    volatile U032 *FIFO;
435
    volatile U032 *CURSOR;
456
    volatile U032 *CURSOR;
436
    volatile U032 *CURSORPOS;
457
    volatile U008 *PCIO0;
437
    volatile U032 *VBLANKENABLE;
438
    volatile U032 *VBLANK;
439
    volatile U008 *PCIO;
458
    volatile U008 *PCIO;
440
    volatile U008 *PVIO;
459
    volatile U008 *PVIO;
460
    volatile U008 *PDIO0;
441
    volatile U008 *PDIO;
461
    volatile U008 *PDIO;
462
    volatile U032 *PRAMDAC;
442
    /*
463
    /*
443
     * Common chip functions.
464
     * Common chip functions.
444
     */
465
     */
445
    int  (*Busy)(struct _riva_hw_inst *);
466
    int  (*Busy)(struct _riva_hw_inst *);
446
    void (*CalcStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *,int,int,int,int,int,int,int,int,int,int,int,int,int);
467
    void (*CalcStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *,int,int,int,int,int);
447
    void (*LoadStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *);
468
    void (*LoadStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *);
448
    void (*UnloadStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *);
469
    void (*UnloadStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *);
449
    void (*SetStartAddress)(struct _riva_hw_inst *,U032);
470
    void (*SetStartAddress)(struct _riva_hw_inst *,U032);
Lines 476-485 Link Here
476
    U032 bpp;
497
    U032 bpp;
477
    U032 width;
498
    U032 width;
478
    U032 height;
499
    U032 height;
500
    U032 interlace;
479
    U032 repaint0;
501
    U032 repaint0;
480
    U032 repaint1;
502
    U032 repaint1;
481
    U032 screen;
503
    U032 screen;
482
    U032 scale;
504
    U032 scale;
505
    U032 dither;
483
    U032 extra;
506
    U032 extra;
484
    U032 pixel;
507
    U032 pixel;
485
    U032 horiz;
508
    U032 horiz;
Lines 489-495 Link Here
489
    U032 vpll2;
512
    U032 vpll2;
490
    U032 pllsel;
513
    U032 pllsel;
491
    U032 general;
514
    U032 general;
515
    U032 crtcOwner;
516
    U032 head; 
517
    U032 head2; 
492
    U032 config;
518
    U032 config;
519
    U032 cursorConfig;	
493
    U032 cursor0;
520
    U032 cursor0;
494
    U032 cursor1;
521
    U032 cursor1;
495
    U032 cursor2;
522
    U032 cursor2;
Lines 505-520 Link Here
505
/*
532
/*
506
 * External routines.
533
 * External routines.
507
 */
534
 */
508
int RivaGetConfig(RIVA_HW_INST *);
535
int RivaGetConfig(RIVA_HW_INST *, unsigned int);
509
/*
536
/*
510
 * FIFO Free Count. Should attempt to yield processor if RIVA is busy.
537
 * FIFO Free Count. Should attempt to yield processor if RIVA is busy.
511
 */
538
 */
512
539
513
#define RIVA_FIFO_FREE(hwinst,hwptr,cnt)                           \
540
/*
514
{                                                                  \
541
 * The mb()'s work around some lockup problems I experienced with some
515
   while ((hwinst).FifoFreeCount < (cnt))                          \
542
 * GeForceII MX cards, neither I nor Mark Vojkovich knows for sure what's
516
	(hwinst).FifoFreeCount = (hwinst).hwptr->FifoFree >> 2;        \
543
 * going on there. --BenH
517
   (hwinst).FifoFreeCount -= (cnt);                                \
544
 */ 
545
#define RIVA_FIFO_FREE(hwinst,hwptr,cnt)                            \
546
{                                                                   \
547
    while ((hwinst).FifoFreeCount < (cnt)) {                        \
548
    	mb();                                              \
549
    	mb();	                                            \
550
        (hwinst).FifoFreeCount = (hwinst).hwptr->FifoFree >> 2;     \
551
    } \
552
    (hwinst).FifoFreeCount -= (cnt);                                \
518
}
553
}
519
#endif /* __RIVA_HW_H__ */
554
#endif /* __RIVA_HW_H__ */
520
555
(-)linux-2.4.22/drivers/video/riva/riva_tbl.h (-13 / +35 lines)
Lines 41-50 Link Here
41
 * GPL licensing note -- nVidia is allowing a liberal interpretation of
41
 * GPL licensing note -- nVidia is allowing a liberal interpretation of
42
 * the documentation restriction above, to merely say that this nVidia's
42
 * the documentation restriction above, to merely say that this nVidia's
43
 * copyright and disclaimer should be included with all code derived
43
 * copyright and disclaimer should be included with all code derived
44
 * from this source.  -- Jeff Garzik <jgarzik@pobox.com>, 01/Nov/99 
44
 * from this source.  -- Jeff Garzik <jgarzik@mandrakesoft.com>, 01/Nov/99 
45
 */
45
 */
46
46
47
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_tbl.h,v 1.5 2000/02/08 17:19:12 dawes Exp $ */
47
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_tbl.h,v 1.9 2002/01/30 01:35:03 mvojkovi Exp $ */
48
49
48
/*
50
/*
49
 * RIVA Fixed Functionality Init Tables.
51
 * RIVA Fixed Functionality Init Tables.
50
 */
52
 */
Lines 69-74 Link Here
69
    {0x00001800, 0x80000010},
71
    {0x00001800, 0x80000010},
70
    {0x00002000, 0x80000011},
72
    {0x00002000, 0x80000011},
71
    {0x00002800, 0x80000012},
73
    {0x00002800, 0x80000012},
74
    {0x00003000, 0x80000016},
72
    {0x00003800, 0x80000013}
75
    {0x00003800, 0x80000013}
73
};
76
};
74
static unsigned nv3TablePFIFO[][2] =
77
static unsigned nv3TablePFIFO[][2] =
Lines 174-179 Link Here
174
    {0x00000249, 0x00CC0346},
177
    {0x00000249, 0x00CC0346},
175
    {0x0000024C, 0x80000013},
178
    {0x0000024C, 0x80000013},
176
    {0x0000024D, 0x00D70347},
179
    {0x0000024D, 0x00D70347},
180
    {0x00000258, 0x80000016},
181
    {0x00000259, 0x00CA034C},
177
    {0x00000D05, 0x00000000},
182
    {0x00000D05, 0x00000000},
178
    {0x00000D06, 0x00000000},
183
    {0x00000D06, 0x00000000},
179
    {0x00000D07, 0x00000000},
184
    {0x00000D07, 0x00000000},
Lines 210-216 Link Here
210
    {0x00000D2C, 0x10830200},
215
    {0x00000D2C, 0x10830200},
211
    {0x00000D2D, 0x00000000},
216
    {0x00000D2D, 0x00000000},
212
    {0x00000D2E, 0x00000000},
217
    {0x00000D2E, 0x00000000},
213
    {0x00000D2F, 0x00000000} 
218
    {0x00000D2F, 0x00000000},
219
    {0x00000D31, 0x00000000},
220
    {0x00000D32, 0x00000000},
221
    {0x00000D33, 0x00000000}
214
};
222
};
215
static unsigned nv3TablePRAMIN_8BPP[][2] =
223
static unsigned nv3TablePRAMIN_8BPP[][2] =
216
{
224
{
Lines 222-228 Link Here
222
    {0x00000D10, 0x10118203},
230
    {0x00000D10, 0x10118203},
223
    {0x00000D14, 0x10110203},
231
    {0x00000D14, 0x10110203},
224
    {0x00000D18, 0x10110203},
232
    {0x00000D18, 0x10110203},
225
    {0x00000D1C, 0x10419208}
233
    {0x00000D1C, 0x10419208},
234
    {0x00000D30, 0x10118203}
226
};
235
};
227
static unsigned nv3TablePRAMIN_15BPP[][2] =
236
static unsigned nv3TablePRAMIN_15BPP[][2] =
228
{
237
{
Lines 234-240 Link Here
234
    {0x00000D10, 0x10118200},
243
    {0x00000D10, 0x10118200},
235
    {0x00000D14, 0x10110200},
244
    {0x00000D14, 0x10110200},
236
    {0x00000D18, 0x10110200},
245
    {0x00000D18, 0x10110200},
237
    {0x00000D1C, 0x10419208}
246
    {0x00000D1C, 0x10419208},
247
    {0x00000D30, 0x10118200}
238
};
248
};
239
static unsigned nv3TablePRAMIN_32BPP[][2] =
249
static unsigned nv3TablePRAMIN_32BPP[][2] =
240
{
250
{
Lines 246-252 Link Here
246
    {0x00000D10, 0x10118201},
256
    {0x00000D10, 0x10118201},
247
    {0x00000D14, 0x10110201},
257
    {0x00000D14, 0x10110201},
248
    {0x00000D18, 0x10110201},
258
    {0x00000D18, 0x10110201},
249
    {0x00000D1C, 0x10419208}
259
    {0x00000D1C, 0x10419208},
260
    {0x00000D30, 0x10118201}
250
};
261
};
251
static unsigned nv4TableFIFO[][2] =
262
static unsigned nv4TableFIFO[][2] =
252
{
263
{
Lines 370-375 Link Here
370
    {0x00000009, 0x80011149},
381
    {0x00000009, 0x80011149},
371
    {0x0000000A, 0x80000015},
382
    {0x0000000A, 0x80000015},
372
    {0x0000000B, 0x8001114A},
383
    {0x0000000B, 0x8001114A},
384
    {0x0000000C, 0x80000016},
385
    {0x0000000D, 0x8001114F},
373
    {0x00000020, 0x80000000},
386
    {0x00000020, 0x80000000},
374
    {0x00000021, 0x80011142},
387
    {0x00000021, 0x80011142},
375
    {0x00000022, 0x80000001},
388
    {0x00000022, 0x80000001},
Lines 437-443 Link Here
437
    {0x00000537, 0x00000000},
450
    {0x00000537, 0x00000000},
438
    {0x00000538, 0x0000005B},
451
    {0x00000538, 0x0000005B},
439
    {0x0000053A, 0x11401140},
452
    {0x0000053A, 0x11401140},
440
    {0x0000053B, 0x00000000} 
453
    {0x0000053B, 0x00000000},
454
    {0x0000053C, 0x0300A01C},
455
    {0x0000053E, 0x11401140},
456
    {0x0000053F, 0x00000000}
441
};
457
};
442
static unsigned nv4TablePRAMIN_8BPP[][2] =
458
static unsigned nv4TablePRAMIN_8BPP[][2] =
443
{
459
{
Lines 452-458 Link Here
452
    {0x0000052D, 0x00000302},
468
    {0x0000052D, 0x00000302},
453
    {0x0000052E, 0x00000302},
469
    {0x0000052E, 0x00000302},
454
    {0x00000535, 0x00000000},
470
    {0x00000535, 0x00000000},
455
    {0x00000539, 0x00000000} 
471
    {0x00000539, 0x00000000},
472
    {0x0000053D, 0x00000302}
456
};
473
};
457
static unsigned nv4TablePRAMIN_15BPP[][2] =
474
static unsigned nv4TablePRAMIN_15BPP[][2] =
458
{
475
{
Lines 467-473 Link Here
467
    {0x0000052D, 0x00000902},
484
    {0x0000052D, 0x00000902},
468
    {0x0000052E, 0x00000902},
485
    {0x0000052E, 0x00000902},
469
    {0x00000535, 0x00000702},
486
    {0x00000535, 0x00000702},
470
    {0x00000539, 0x00000702} 
487
    {0x00000539, 0x00000702},
488
    {0x0000053D, 0x00000902}
471
};
489
};
472
static unsigned nv4TablePRAMIN_16BPP[][2] =
490
static unsigned nv4TablePRAMIN_16BPP[][2] =
473
{
491
{
Lines 482-488 Link Here
482
    {0x0000052D, 0x00000C02},
500
    {0x0000052D, 0x00000C02},
483
    {0x0000052E, 0x00000C02},
501
    {0x0000052E, 0x00000C02},
484
    {0x00000535, 0x00000702},
502
    {0x00000535, 0x00000702},
485
    {0x00000539, 0x00000702} 
503
    {0x00000539, 0x00000702},
504
    {0x0000053D, 0x00000C02}
486
};
505
};
487
static unsigned nv4TablePRAMIN_32BPP[][2] =
506
static unsigned nv4TablePRAMIN_32BPP[][2] =
488
{
507
{
Lines 497-503 Link Here
497
    {0x0000052D, 0x00000E02},
516
    {0x0000052D, 0x00000E02},
498
    {0x0000052E, 0x00000E02},
517
    {0x0000052E, 0x00000E02},
499
    {0x00000535, 0x00000E02},
518
    {0x00000535, 0x00000E02},
500
    {0x00000539, 0x00000E02} 
519
    {0x00000539, 0x00000E02},
520
    {0x0000053D, 0x00000E02}
501
};
521
};
502
static unsigned nv10TableFIFO[][2] =
522
static unsigned nv10TableFIFO[][2] =
503
{
523
{
Lines 810-815 Link Here
810
    {0x00000009, 0x80011149},
830
    {0x00000009, 0x80011149},
811
    {0x0000000A, 0x80000015},
831
    {0x0000000A, 0x80000015},
812
    {0x0000000B, 0x8001114A},
832
    {0x0000000B, 0x8001114A},
833
    {0x0000000C, 0x80000016},
834
    {0x0000000D, 0x80011150},
813
    {0x00000020, 0x80000000},
835
    {0x00000020, 0x80000000},
814
    {0x00000021, 0x80011142},
836
    {0x00000021, 0x80011142},
815
    {0x00000022, 0x80000001},
837
    {0x00000022, 0x80000001},
Lines 831-837 Link Here
831
    {0x00000502, 0x00000002},
853
    {0x00000502, 0x00000002},
832
    {0x00000503, 0x00000002},
854
    {0x00000503, 0x00000002},
833
#ifdef __BIG_ENDIAN
855
#ifdef __BIG_ENDIAN
834
    {0x00000508, 0x01088043},
856
    {0x00000508, 0x01088043}, 
835
#else
857
#else
836
    {0x00000508, 0x01008043},
858
    {0x00000508, 0x01008043},
837
#endif
859
#endif
Lines 946-952 Link Here
946
    {0x0000052E, 0x00000902},
968
    {0x0000052E, 0x00000902},
947
    {0x00000535, 0x00000902},
969
    {0x00000535, 0x00000902},
948
    {0x00000539, 0x00000902}, 
970
    {0x00000539, 0x00000902}, 
949
    {0x0000053D, 0x00000902}, 
971
    {0x0000053D, 0x00000902},
950
    {0x00000541, 0x00000902}
972
    {0x00000541, 0x00000902}
951
};
973
};
952
static unsigned nv10TablePRAMIN_16BPP[][2] =
974
static unsigned nv10TablePRAMIN_16BPP[][2] =
(-)linux-2.4.22/drivers/video/riva/rivafb.h (+6 lines)
Lines 92-97 Link Here
92
#ifdef CONFIG_MTRR
92
#ifdef CONFIG_MTRR
93
	struct { int vram; int vram_valid; } mtrr;
93
	struct { int vram; int vram_valid; } mtrr;
94
#endif
94
#endif
95
	unsigned int Chipset;
96
	int forceCRTC;
97
	Bool SecondCRTC;
98
	int FlatPanel;
95
};
99
};
96
100
101
void riva_common_setup(struct rivafb_info*);
102
97
#endif /* __RIVAFB_H */
103
#endif /* __RIVAFB_H */
(-)linux-2.4.22/fs/buffer.c (-5 / +37 lines)
Lines 88-93 Link Here
88
static int osync_buffers_list(struct list_head *);
88
static int osync_buffers_list(struct list_head *);
89
static void __refile_buffer(struct buffer_head *);
89
static void __refile_buffer(struct buffer_head *);
90
90
91
/*
92
 * A global sysctl-controlled flag which puts the machine into "laptop mode"
93
 */
94
int laptop_mode;
95
96
static DECLARE_WAIT_QUEUE_HEAD(kupdate_wait);
97
91
/* This is used by some architectures to estimate available memory. */
98
/* This is used by some architectures to estimate available memory. */
92
atomic_t buffermem_pages = ATOMIC_INIT(0);
99
atomic_t buffermem_pages = ATOMIC_INIT(0);
93
100
Lines 1016-1022 Link Here
1016
	dirty *= 100;
1023
	dirty *= 100;
1017
	dirty_limit = tot * bdf_prm.b_un.nfract_stop_bdflush;
1024
	dirty_limit = tot * bdf_prm.b_un.nfract_stop_bdflush;
1018
1025
1019
	if (dirty > dirty_limit)
1026
	if (!laptop_mode && dirty > dirty_limit)
1020
		return 0;
1027
		return 0;
1021
	return 1;
1028
	return 1;
1022
}
1029
}
Lines 1066-1071 Link Here
1066
void mark_buffer_dirty(struct buffer_head *bh)
1073
void mark_buffer_dirty(struct buffer_head *bh)
1067
{
1074
{
1068
	if (!atomic_set_buffer_dirty(bh)) {
1075
	if (!atomic_set_buffer_dirty(bh)) {
1076
		if (block_dump)
1077
			printk("%s: dirtied buffer\n", current->comm);
1069
		__mark_dirty(bh);
1078
		__mark_dirty(bh);
1070
		balance_dirty();
1079
		balance_dirty();
1071
	}
1080
	}
Lines 1077-1082 Link Here
1077
}
1086
}
1078
EXPORT_SYMBOL(set_buffer_flushtime);
1087
EXPORT_SYMBOL(set_buffer_flushtime);
1079
1088
1089
unsigned long get_buffer_flushtime(void)
1090
{
1091
	return bdf_prm.b_un.age_buffer;
1092
}
1093
EXPORT_SYMBOL(get_buffer_flushtime);
1094
1095
1080
/*
1096
/*
1081
 * A buffer may need to be moved from one buffer list to another
1097
 * A buffer may need to be moved from one buffer list to another
1082
 * (e.g. in case it is not shared any more). Handle this.
1098
 * (e.g. in case it is not shared any more). Handle this.
Lines 2859-2864 Link Here
2859
	wake_up_interruptible(&bdflush_wait);
2875
	wake_up_interruptible(&bdflush_wait);
2860
}
2876
}
2861
2877
2878
void wakeup_kupdate(void)
2879
{
2880
	if (waitqueue_active(&kupdate_wait))
2881
		wake_up(&kupdate_wait);
2882
}
2883
2862
/* 
2884
/* 
2863
 * Here we attempt to write back old buffers.  We also try to flush inodes 
2885
 * Here we attempt to write back old buffers.  We also try to flush inodes 
2864
 * and supers as well, since this function is essentially "update", and 
2886
 * and supers as well, since this function is essentially "update", and 
Lines 2879-2885 Link Here
2879
2901
2880
		spin_lock(&lru_list_lock);
2902
		spin_lock(&lru_list_lock);
2881
		bh = lru_list[BUF_DIRTY];
2903
		bh = lru_list[BUF_DIRTY];
2882
		if (!bh || time_before(jiffies, bh->b_flushtime))
2904
		if (!bh)
2905
			break;
2906
		if (time_before(jiffies, bh->b_flushtime) && !laptop_mode)
2883
			break;
2907
			break;
2884
		if (write_some_buffers(NODEV))
2908
		if (write_some_buffers(NODEV))
2885
			continue;
2909
			continue;
Lines 3027-3042 Link Here
3027
	complete((struct completion *)startup);
3051
	complete((struct completion *)startup);
3028
3052
3029
	for (;;) {
3053
	for (;;) {
3054
		DECLARE_WAITQUEUE(wait, tsk);
3055
3056
		add_wait_queue(&kupdate_wait, &wait);
3057
3030
		/* update interval */
3058
		/* update interval */
3031
		interval = bdf_prm.b_un.interval;
3059
		interval = bdf_prm.b_un.interval;
3032
		if (interval) {
3060
		if (interval) {
3033
			tsk->state = TASK_INTERRUPTIBLE;
3061
			tsk->state = TASK_INTERRUPTIBLE;
3034
			schedule_timeout(interval);
3062
			schedule_timeout(interval);
3035
		} else {
3063
		} else {
3036
		stop_kupdate:
3037
			tsk->state = TASK_STOPPED;
3064
			tsk->state = TASK_STOPPED;
3038
			schedule(); /* wait for SIGCONT */
3065
			schedule(); /* wait for SIGCONT */
3039
		}
3066
		}
3067
		remove_wait_queue(&kupdate_wait, &wait);
3040
		/* check for sigstop */
3068
		/* check for sigstop */
3041
		if (signal_pending(tsk)) {
3069
		if (signal_pending(tsk)) {
3042
			int stopped = 0;
3070
			int stopped = 0;
Lines 3047-3059 Link Here
3047
			}
3075
			}
3048
			recalc_sigpending(tsk);
3076
			recalc_sigpending(tsk);
3049
			spin_unlock_irq(&tsk->sigmask_lock);
3077
			spin_unlock_irq(&tsk->sigmask_lock);
3050
			if (stopped)
3078
			if (stopped) {
3051
				goto stop_kupdate;
3079
				tsk->state = TASK_STOPPED;
3080
				schedule(); /* wait for SIGCONT */
3081
			}
3052
		}
3082
		}
3053
#ifdef DEBUG
3083
#ifdef DEBUG
3054
		printk(KERN_DEBUG "kupdate() activated...\n");
3084
		printk(KERN_DEBUG "kupdate() activated...\n");
3055
#endif
3085
#endif
3056
		sync_old_buffers();
3086
		sync_old_buffers();
3087
		if (laptop_mode)
3088
			fsync_dev(NODEV);
3057
		run_task_queue(&tq_disk);
3089
		run_task_queue(&tq_disk);
3058
	}
3090
	}
3059
}
3091
}
(-)linux-2.4.22/fs/hfsplus/hfsplus_fs.h (+1 lines)
Lines 211-216 Link Here
211
	hfsplus_cat_key key;
211
	hfsplus_cat_key key;
212
};
212
};
213
213
214
214
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
215
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
215
typedef long sector_t;
216
typedef long sector_t;
216
#endif
217
#endif
(-)linux-2.4.22/fs/jbd/transaction.c (-1 / +5 lines)
Lines 56-62 Link Here
56
	transaction->t_journal = journal;
56
	transaction->t_journal = journal;
57
	transaction->t_state = T_RUNNING;
57
	transaction->t_state = T_RUNNING;
58
	transaction->t_tid = journal->j_transaction_sequence++;
58
	transaction->t_tid = journal->j_transaction_sequence++;
59
	transaction->t_expires = jiffies + journal->j_commit_interval;
59
	/*
60
	 * have to do it here, otherwise changed age_buffers since boot
61
	 * wont have any effect
62
	 */
63
	transaction->t_expires = jiffies + get_buffer_flushtime();
60
	INIT_LIST_HEAD(&transaction->t_jcb);
64
	INIT_LIST_HEAD(&transaction->t_jcb);
61
65
62
	/* Set up the commit timer for the new transaction. */
66
	/* Set up the commit timer for the new transaction. */
(-)linux-2.4.22/fs/namespace.c (-1 / +1 lines)
Lines 763-769 Link Here
763
		return -EPERM;
763
		return -EPERM;
764
	}
764
	}
765
765
766
	new_ns = kmalloc(sizeof(struct namespace *), GFP_KERNEL);
766
	new_ns = kmalloc(sizeof(struct namespace), GFP_KERNEL);
767
	if (!new_ns)
767
	if (!new_ns)
768
		goto out;
768
		goto out;
769
769
(-)linux-2.4.22/include/asm-ppc/atomic.h (-1 / +8 lines)
Lines 18-26 Link Here
18
extern void atomic_set_mask(unsigned long mask, unsigned long *addr);
18
extern void atomic_set_mask(unsigned long mask, unsigned long *addr);
19
19
20
#ifdef CONFIG_SMP
20
#ifdef CONFIG_SMP
21
#define SMP_ISYNC	"\n\tisync"
21
#define SMP_ISYNC	"\n\tisync\n"
22
#define SMP_EIEIO	"\n\teieio\n"
22
#else
23
#else
23
#define SMP_ISYNC
24
#define SMP_ISYNC
25
#define SMP_EIEIO
24
#endif
26
#endif
25
27
26
/* Erratum #77 on the 405 means we need a sync or dcbt before every stwcx.
28
/* Erratum #77 on the 405 means we need a sync or dcbt before every stwcx.
Lines 52-57 Link Here
52
	int t;
54
	int t;
53
55
54
	__asm__ __volatile__(
56
	__asm__ __volatile__(
57
	SMP_EIEIO
55
"1:	lwarx	%0,0,%2		# atomic_add_return\n\
58
"1:	lwarx	%0,0,%2		# atomic_add_return\n\
56
	add	%0,%1,%0\n"
59
	add	%0,%1,%0\n"
57
	PPC405_ERR77(0,%2)
60
	PPC405_ERR77(0,%2)
Lines 85-90 Link Here
85
	int t;
88
	int t;
86
89
87
	__asm__ __volatile__(
90
	__asm__ __volatile__(
91
	SMP_EIEIO
88
"1:	lwarx	%0,0,%2		# atomic_sub_return\n\
92
"1:	lwarx	%0,0,%2		# atomic_sub_return\n\
89
	subf	%0,%1,%0\n"
93
	subf	%0,%1,%0\n"
90
	PPC405_ERR77(0,%2)
94
	PPC405_ERR77(0,%2)
Lines 118-123 Link Here
118
	int t;
122
	int t;
119
123
120
	__asm__ __volatile__(
124
	__asm__ __volatile__(
125
	SMP_EIEIO
121
"1:	lwarx	%0,0,%1		# atomic_inc_return\n\
126
"1:	lwarx	%0,0,%1		# atomic_inc_return\n\
122
	addic	%0,%0,1\n"
127
	addic	%0,%0,1\n"
123
	PPC405_ERR77(0,%1)
128
	PPC405_ERR77(0,%1)
Lines 151-156 Link Here
151
	int t;
156
	int t;
152
157
153
	__asm__ __volatile__(
158
	__asm__ __volatile__(
159
	SMP_EIEIO
154
"1:	lwarx	%0,0,%1		# atomic_dec_return\n\
160
"1:	lwarx	%0,0,%1		# atomic_dec_return\n\
155
	addic	%0,%0,-1\n"
161
	addic	%0,%0,-1\n"
156
	PPC405_ERR77(0,%1)
162
	PPC405_ERR77(0,%1)
Lines 176-181 Link Here
176
	int t;
182
	int t;
177
183
178
	__asm__ __volatile__(
184
	__asm__ __volatile__(
185
	SMP_EIEIO
179
"1:	lwarx	%0,0,%1		# atomic_dec_if_positive\n\
186
"1:	lwarx	%0,0,%1		# atomic_dec_if_positive\n\
180
	addic.	%0,%0,-1\n\
187
	addic.	%0,%0,-1\n\
181
	blt-	2f\n"
188
	blt-	2f\n"
(-)linux-2.4.22/include/asm-ppc/elf.h (-1 / +1 lines)
Lines 10-16 Link Here
10
10
11
#define ELF_NGREG	48	/* includes nip, msr, lr, etc. */
11
#define ELF_NGREG	48	/* includes nip, msr, lr, etc. */
12
#define ELF_NFPREG	33	/* includes fpscr */
12
#define ELF_NFPREG	33	/* includes fpscr */
13
#define ELF_NVRREG	33	/* includes vscr */
13
#define ELF_NVRREG	33	/* includes vscr & vrsave */
14
14
15
/*
15
/*
16
 * These are used to set parameters in the core dumps.
16
 * These are used to set parameters in the core dumps.
(-)linux-2.4.22/include/asm-ppc/hardirq.h (+17 lines)
Lines 54-65 Link Here
54
extern unsigned volatile long global_irq_lock;
54
extern unsigned volatile long global_irq_lock;
55
extern atomic_t global_irq_count;
55
extern atomic_t global_irq_count;
56
56
57
#ifdef CONFIG_DEBUG_SPINLOCK
58
extern int debug_long_irqlock;
59
extern void print_backtrace(unsigned long *sp);
60
#endif /* CONFIG_DEBUG_SPINLOCK */
61
57
static inline void release_irqlock(int cpu)
62
static inline void release_irqlock(int cpu)
58
{
63
{
59
	/* if we didn't own the irq lock, just ignore.. */
64
	/* if we didn't own the irq lock, just ignore.. */
60
	if (global_irq_holder == (unsigned char) cpu) {
65
	if (global_irq_holder == (unsigned char) cpu) {
61
		global_irq_holder = NO_PROC_ID;
66
		global_irq_holder = NO_PROC_ID;
62
		clear_bit(0,&global_irq_lock);
67
		clear_bit(0,&global_irq_lock);
68
#ifdef CONFIG_DEBUG_SPINLOCK
69
		if (debug_long_irqlock) {
70
			debug_long_irqlock = 0;
71
			printk("Release long irq lock\n");
72
			print_backtrace(NULL);
73
		}
74
#endif /* CONFIG_DEBUG_SPINLOCK */
63
	}
75
	}
64
}
76
}
65
77
Lines 69-74 Link Here
69
81
70
	++local_irq_count(cpu);
82
	++local_irq_count(cpu);
71
	atomic_inc(&global_irq_count);
83
	atomic_inc(&global_irq_count);
84
	smp_mb__after_atomic_inc();
72
	while (test_bit(0,&global_irq_lock)) {
85
	while (test_bit(0,&global_irq_lock)) {
73
		if (cpu == global_irq_holder) {
86
		if (cpu == global_irq_holder) {
74
			printk("uh oh, interrupt while we hold global irq lock! (CPU %d)\n", cpu);
87
			printk("uh oh, interrupt while we hold global irq lock! (CPU %d)\n", cpu);
Lines 79-84 Link Here
79
		}
92
		}
80
		if (loops-- == 0) {
93
		if (loops-- == 0) {
81
			printk("do_IRQ waiting for irq lock (holder=%d)\n", global_irq_holder);
94
			printk("do_IRQ waiting for irq lock (holder=%d)\n", global_irq_holder);
95
#ifdef CONFIG_DEBUG_SPINLOCK
96
			debug_long_irqlock = 1;
97
#endif
82
#ifdef CONFIG_XMON
98
#ifdef CONFIG_XMON
83
			xmon(0);
99
			xmon(0);
84
#endif
100
#endif
Lines 88-93 Link Here
88
104
89
static inline void hardirq_exit(int cpu)
105
static inline void hardirq_exit(int cpu)
90
{
106
{
107
	smp_mb__after_atomic_dec();
91
	atomic_dec(&global_irq_count);
108
	atomic_dec(&global_irq_count);
92
	--local_irq_count(cpu);
109
	--local_irq_count(cpu);
93
}
110
}
(-)linux-2.4.22/include/asm-ppc/highmem.h (-1 / +1 lines)
Lines 28-34 Link Here
28
#include <asm/pgtable.h>
28
#include <asm/pgtable.h>
29
29
30
/* undef for production */
30
/* undef for production */
31
#define HIGHMEM_DEBUG 1
31
#define HIGHMEM_DEBUG 0
32
32
33
extern pte_t *kmap_pte;
33
extern pte_t *kmap_pte;
34
extern pgprot_t kmap_prot;
34
extern pgprot_t kmap_prot;
(-)linux-2.4.22/include/asm-ppc/ide.h (+12 lines)
Lines 34-39 Link Here
34
                                     ide_ioreg_t data_port,
34
                                     ide_ioreg_t data_port,
35
                                     ide_ioreg_t ctrl_port,
35
                                     ide_ioreg_t ctrl_port,
36
                                     int *irq);
36
                                     int *irq);
37
        int         (*reserved_hwifs)(void);
37
};
38
};
38
39
39
extern struct ide_machdep_calls ppc_ide_md;
40
extern struct ide_machdep_calls ppc_ide_md;
Lines 112-117 Link Here
112
#define IDE_ARCH_ACK_INTR 1
113
#define IDE_ARCH_ACK_INTR 1
113
#endif
114
#endif
114
115
116
/*
117
 * How many IDE slots are "reserved" for bootable devices
118
 */
119
#define IDE_ARCH_RESERVED_HWIFS 1
120
static inline int ide_reserved_hwifs(void)
121
{
122
	if (ppc_ide_md.reserved_hwifs)
123
		return ppc_ide_md.reserved_hwifs();
124
	return 2;
125
}
126
115
#endif /* __KERNEL__ */
127
#endif /* __KERNEL__ */
116
128
117
#endif /* __ASMPPC_IDE_H */
129
#endif /* __ASMPPC_IDE_H */
(-)linux-2.4.22/include/asm-ppc/io.h (-8 / +14 lines)
Lines 287-295 Link Here
287
/* Enforce in-order execution of data I/O.
287
/* Enforce in-order execution of data I/O.
288
 * No distinction between read/write on PPC; use eieio for all three.
288
 * No distinction between read/write on PPC; use eieio for all three.
289
 */
289
 */
290
#define iobarrier_rw() eieio()
290
#if 0
291
#define iobarrier_r()  eieio()
291
#define iobarrier_rw()	eieio()
292
#define iobarrier_w()  eieio()
292
#define iobarrier_r()	eieio()
293
#define iobarrier_w()	eieio()
294
#endif
295
extern inline void io_barrier(void)
296
{
297
	__asm__ __volatile__ ("sync" : : : "memory");
298
}
293
299
294
/*
300
/*
295
 * 8, 16 and 32 bit, big and little endian I/O operations, with barrier.
301
 * 8, 16 and 32 bit, big and little endian I/O operations, with barrier.
Lines 311-317 Link Here
311
317
312
extern inline void out_8(volatile unsigned char *addr, int val)
318
extern inline void out_8(volatile unsigned char *addr, int val)
313
{
319
{
314
	__asm__ __volatile__("stb%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
320
	__asm__ __volatile__("sync; stb%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
315
}
321
}
316
322
317
extern inline int in_le16(volatile unsigned short *addr)
323
extern inline int in_le16(volatile unsigned short *addr)
Lines 337-349 Link Here
337
343
338
extern inline void out_le16(volatile unsigned short *addr, int val)
344
extern inline void out_le16(volatile unsigned short *addr, int val)
339
{
345
{
340
	__asm__ __volatile__("sthbrx %1,0,%2; eieio" : "=m" (*addr) :
346
	__asm__ __volatile__("sync; sthbrx %1,0,%2; eieio" : "=m" (*addr) :
341
			      "r" (val), "r" (addr));
347
			      "r" (val), "r" (addr));
342
}
348
}
343
349
344
extern inline void out_be16(volatile unsigned short *addr, int val)
350
extern inline void out_be16(volatile unsigned short *addr, int val)
345
{
351
{
346
	__asm__ __volatile__("sth%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
352
	__asm__ __volatile__("sync; sth%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
347
}
353
}
348
354
349
extern inline unsigned in_le32(volatile unsigned *addr)
355
extern inline unsigned in_le32(volatile unsigned *addr)
Lines 369-381 Link Here
369
375
370
extern inline void out_le32(volatile unsigned *addr, int val)
376
extern inline void out_le32(volatile unsigned *addr, int val)
371
{
377
{
372
	__asm__ __volatile__("stwbrx %1,0,%2; eieio" : "=m" (*addr) :
378
	__asm__ __volatile__("sync; stwbrx %1,0,%2; eieio" : "=m" (*addr) :
373
			     "r" (val), "r" (addr));
379
			     "r" (val), "r" (addr));
374
}
380
}
375
381
376
extern inline void out_be32(volatile unsigned *addr, int val)
382
extern inline void out_be32(volatile unsigned *addr, int val)
377
{
383
{
378
	__asm__ __volatile__("stw%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
384
	__asm__ __volatile__("sync; stw%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
379
}
385
}
380
386
381
static inline int check_signature(unsigned long io_addr,
387
static inline int check_signature(unsigned long io_addr,
(-)linux-2.4.22/include/asm-ppc/page.h (+2 lines)
Lines 17-23 Link Here
17
#include <asm/system.h> /* for xmon definition */
17
#include <asm/system.h> /* for xmon definition */
18
18
19
#ifdef CONFIG_XMON
19
#ifdef CONFIG_XMON
20
extern void xmon_printf(const char *fmt, ...);
20
#define BUG() do { \
21
#define BUG() do { \
22
	xmon_printf("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
21
	printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
23
	printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
22
	xmon(0); \
24
	xmon(0); \
23
} while (0)
25
} while (0)
(-)linux-2.4.22/include/asm-ppc/pmac_feature.h (-2 / +2 lines)
Lines 96-103 Link Here
96
#define PMAC_TYPE_UNKNOWN_CORE99	0x5f
96
#define PMAC_TYPE_UNKNOWN_CORE99	0x5f
97
97
98
/* MacRisc2 with UniNorth 2.0 */
98
/* MacRisc2 with UniNorth 2.0 */
99
#define PMAC_TYPE_RACKMAC		0x80	/* XServe */
99
#define PMAC_TYPE_RACKMAC		0x80	/* XServes (all) */
100
#define PMAC_TYPE_WINDTUNNEL		0x81
100
#define PMAC_TYPE_WINDTUNNEL		0x81	/* Windtunnel */
101
101
102
/* MacRISC2 machines based on the Pangea chipset
102
/* MacRISC2 machines based on the Pangea chipset
103
 */
103
 */
(-)linux-2.4.22/include/asm-ppc/ppc4xx_serial.h (+101 lines)
Line 0 Link Here
1
/*
2
 *    Copyright 2000 MontaVista Software Inc.
3
 *	PPC405GP modifications
4
 * 	Author: MontaVista Software, Inc.
5
 *         	frank_rowand@mvista.com or source@mvista.com
6
 * 	   	debbie_chu@mvista.com
7
 *
8
 *    Module name: ppc405_serial.h
9
 *
10
 *    Description:
11
 *      Macros, definitions, and data structures specific to the IBM PowerPC
12
 *      405 on-chip serial port devices.
13
 */
14
15
#ifdef __KERNEL__
16
#ifndef __ASMPPC_PPC4xx_SERIAL_H
17
#define __ASMPPC_PPC4xx_SERIAL_H
18
19
#include <linux/config.h>
20
21
#ifdef CONFIG_SERIAL_MANY_PORTS
22
#define RS_TABLE_SIZE	64
23
#else
24
#define RS_TABLE_SIZE	4
25
#endif
26
27
#define PPC405GP_UART0_INT	0
28
#define PPC405GP_UART1_INT	1
29
30
/*
31
** 405GP UARTs are *not* PCI devices, so need to specify a non-pci memory
32
** address and an io_type of SERIAL_IO_MEM.
33
*/
34
35
#define PPC405GP_UART0_IO_BASE	(u8 *) 0xef600300
36
#define PPC405GP_UART1_IO_BASE	(u8 *) 0xef600400
37
38
/*
39
**  - there is no config option for this
40
**  - this name could be more informative
41
**  - also see arch/ppc/kernel/ppc405_serial.c
42
**
43
** #define CONFIG_PPC405GP_INTERNAL_CLOCK
44
*/
45
#ifdef	CONFIG_PPC405GP_INTERNAL_CLOCK
46
#define BASE_BAUD		201600
47
#else
48
#define BASE_BAUD		691200
49
#endif
50
51
52
#ifdef CONFIG_SERIAL_DETECT_IRQ
53
#define STD_COM_FLAGS	(ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ)
54
#define STD_COM4_FLAGS	(ASYNC_BOOT_AUTOCONF | ASYNC_AUTO_IRQ)
55
#else
56
#define STD_COM_FLAGS	(ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
57
#define STD_COM4_FLAGS	(ASYNC_BOOT_AUTOCONF)
58
#endif
59
60
61
#ifdef CONFIG_STB03XXX
62
63
#define UART0_IO_BASE 0x40040000
64
#define UART0_INT     20
65
66
#define STD_SERIAL_PORT_DFNS \
67
    /* ttyS0 */ \
68
    { 0, BASE_BAUD, 0, UART0_INT, STD_COM_FLAGS, 0, 0, 0, 0, 0, 0, 0, \
69
    UART0_IO_BASE, 0, 0, 0, {}, {}, {}, SERIAL_IO_MEM, NULL },
70
71
#elif defined(CONFIG_UART1_DFLT_CONSOLE)
72
73
#define STD_SERIAL_PORT_DFNS \
74
    /* ttyS1 */ \
75
    { 0, BASE_BAUD, 0, PPC405GP_UART1_INT, STD_COM_FLAGS, 0, 0, 0, 0, 0, 0, 0, \
76
    PPC405GP_UART1_IO_BASE, 0, 0, 0, {}, {}, {}, SERIAL_IO_MEM, NULL },        \
77
    /* ttyS0 */ \
78
    { 0, BASE_BAUD, 0, PPC405GP_UART0_INT, STD_COM_FLAGS, 0, 0, 0, 0, 0, 0, 0, \
79
    PPC405GP_UART0_IO_BASE, 0, 0, 0, {}, {}, {}, SERIAL_IO_MEM, NULL },
80
81
#else
82
83
#define STD_SERIAL_PORT_DFNS \
84
    /* ttyS0 */ \
85
    { 0, BASE_BAUD, 0, PPC405GP_UART0_INT, STD_COM_FLAGS, 0, 0, 0, 0, 0, 0, 0, \
86
    PPC405GP_UART0_IO_BASE, 0, 0, 0, {}, {}, {}, SERIAL_IO_MEM, NULL },        \
87
    /* ttyS1 */ \
88
    { 0, BASE_BAUD, 0, PPC405GP_UART1_INT, STD_COM_FLAGS, 0, 0, 0, 0, 0, 0, 0, \
89
    PPC405GP_UART1_IO_BASE, 0, 0, 0, {}, {}, {}, SERIAL_IO_MEM, NULL },
90
91
#endif
92
93
94
#define SERIAL_PORT_DFNS     \
95
	STD_SERIAL_PORT_DFNS \
96
	{}
97
98
99
100
#endif	/* __ASMPPC_PPC4xx_SERIAL_H */
101
#endif /* __KERNEL__ */
(-)linux-2.4.22/include/asm-ppc/processor.h (+1 lines)
Lines 716-721 Link Here
716
	vector128	vr[32];		/* Complete AltiVec set */
716
	vector128	vr[32];		/* Complete AltiVec set */
717
	vector128	vscr;		/* AltiVec status */
717
	vector128	vscr;		/* AltiVec status */
718
	unsigned long	vrsave;
718
	unsigned long	vrsave;
719
	int		used_vr;	/* set if process has used altivec */
719
#endif /* CONFIG_ALTIVEC */
720
#endif /* CONFIG_ALTIVEC */
720
#if defined(CONFIG_4xx)
721
#if defined(CONFIG_4xx)
721
	/* Saved 4xx debug registers */
722
	/* Saved 4xx debug registers */
(-)linux-2.4.22/include/asm-ppc/semaphore.h (-11 / +4 lines)
Lines 87-95 Link Here
87
	/*
87
	/*
88
	 * Try to get the semaphore, take the slow path if we fail.
88
	 * Try to get the semaphore, take the slow path if we fail.
89
	 */
89
	 */
90
	if (atomic_dec_return(&sem->count) < 0)
90
	if (unlikely(atomic_dec_return(&sem->count) < 0))
91
		__down(sem);
91
		__down(sem);
92
	smp_wmb();
93
}
92
}
94
93
95
extern inline int down_interruptible(struct semaphore * sem)
94
extern inline int down_interruptible(struct semaphore * sem)
Lines 100-122 Link Here
100
	CHECK_MAGIC(sem->__magic);
99
	CHECK_MAGIC(sem->__magic);
101
#endif
100
#endif
102
101
103
	if (atomic_dec_return(&sem->count) < 0)
102
	if (unlikely(atomic_dec_return(&sem->count) < 0))
104
		ret = __down_interruptible(sem);
103
		ret = __down_interruptible(sem);
105
	smp_wmb();
106
	return ret;
104
	return ret;
107
}
105
}
108
106
109
extern inline int down_trylock(struct semaphore * sem)
107
extern inline int down_trylock(struct semaphore * sem)
110
{
108
{
111
	int ret;
112
113
#if WAITQUEUE_DEBUG
109
#if WAITQUEUE_DEBUG
114
	CHECK_MAGIC(sem->__magic);
110
	CHECK_MAGIC(sem->__magic);
115
#endif
111
#endif
116
112
117
	ret = atomic_dec_if_positive(&sem->count) < 0;
113
	return atomic_dec_if_positive(&sem->count) < 0;
118
	smp_wmb();
119
	return ret;
120
}
114
}
121
115
122
extern inline void up(struct semaphore * sem)
116
extern inline void up(struct semaphore * sem)
Lines 125-132 Link Here
125
	CHECK_MAGIC(sem->__magic);
119
	CHECK_MAGIC(sem->__magic);
126
#endif
120
#endif
127
121
128
	smp_wmb();
122
	if (unlikely(atomic_inc_return(&sem->count) <= 0))
129
	if (atomic_inc_return(&sem->count) <= 0)
130
		__up(sem);
123
		__up(sem);
131
}
124
}
132
125
(-)linux-2.4.22/include/asm-ppc/sigcontext.h (-2 / +1 lines)
Lines 3-10 Link Here
3
3
4
#include <asm/ptrace.h>
4
#include <asm/ptrace.h>
5
5
6
6
struct sigcontext {
7
struct sigcontext_struct {
8
	unsigned long	_unused[4];
7
	unsigned long	_unused[4];
9
	int		signal;
8
	int		signal;
10
	unsigned long	handler;
9
	unsigned long	handler;
(-)linux-2.4.22/include/asm-ppc/smp.h (+4 lines)
Lines 17-22 Link Here
17
17
18
#ifndef __ASSEMBLY__
18
#ifndef __ASSEMBLY__
19
19
20
#define cpu_online(cpu) (cpu_online_map & (1<<(cpu)))
21
20
struct cpuinfo_PPC {
22
struct cpuinfo_PPC {
21
	unsigned long loops_per_jiffy;
23
	unsigned long loops_per_jiffy;
22
	unsigned long pvr;
24
	unsigned long pvr;
Lines 69-74 Link Here
69
71
70
#else /* !(CONFIG_SMP) */
72
#else /* !(CONFIG_SMP) */
71
73
74
#define cpu_online(cpu) ((cpu) == 0)
75
72
#endif /* !(CONFIG_SMP) */
76
#endif /* !(CONFIG_SMP) */
73
77
74
#endif /* !(_PPC_SMP_H) */
78
#endif /* !(_PPC_SMP_H) */
(-)linux-2.4.22/include/asm-ppc/ucontext.h (-6 / +20 lines)
Lines 1-14 Link Here
1
#ifndef _ASMPPC_UCONTEXT_H
1
#ifndef _ASMPPC_UCONTEXT_H
2
#define _ASMPPC_UCONTEXT_H
2
#define _ASMPPC_UCONTEXT_H
3
3
4
/* Copied from i386. */
4
#include <asm/elf.h>
5
#include <asm/signal.h>
6
7
struct mcontext {
8
	elf_gregset_t	mc_gregs;
9
	elf_fpregset_t	mc_fregs;
10
	unsigned long	mc_pad[2];
11
	elf_vrregset_t	mc_vregs __attribute__((__aligned__(16)));
12
};
5
13
6
struct ucontext {
14
struct ucontext {
7
	unsigned long	  uc_flags;
15
	unsigned long	 uc_flags;
8
	struct ucontext  *uc_link;
16
	struct ucontext *uc_link;
9
	stack_t		  uc_stack;
17
	stack_t		 uc_stack;
10
	struct sigcontext_struct uc_mcontext;
18
	int		 uc_pad[7];
11
	sigset_t	  uc_sigmask;	/* mask last for extensibility */
19
	struct mcontext	*uc_regs;	/* backward compat */
20
	sigset_t	 uc_oldsigmask;	/* backward compat */
21
	int		 uc_pad2;
22
	sigset_t	 uc_sigmask;
23
	/* glibc has 1024-bit signal masks, ours are 64-bit */
24
	int		 uc_maskext[30];
25
	struct mcontext	 uc_mcontext;
12
};
26
};
13
27
14
#endif /* !_ASMPPC_UCONTEXT_H */
28
#endif /* !_ASMPPC_UCONTEXT_H */
(-)linux-2.4.22/include/linux/agp_backend.h (+1 lines)
Lines 90-95 Link Here
90
	NVIDIA_NFORCE2,
90
	NVIDIA_NFORCE2,
91
	NVIDIA_GENERIC,
91
	NVIDIA_GENERIC,
92
	HP_ZX1,
92
	HP_ZX1,
93
	APPLE_UNINORTH
93
};
94
};
94
95
95
typedef struct _agp_version {
96
typedef struct _agp_version {
(-)linux-2.4.22/include/linux/blkdev.h (+7 lines)
Lines 63-68 Link Here
63
typedef int (make_request_fn) (request_queue_t *q, int rw, struct buffer_head *bh);
63
typedef int (make_request_fn) (request_queue_t *q, int rw, struct buffer_head *bh);
64
typedef void (plug_device_fn) (request_queue_t *q, kdev_t device);
64
typedef void (plug_device_fn) (request_queue_t *q, kdev_t device);
65
typedef void (unplug_device_fn) (void *q);
65
typedef void (unplug_device_fn) (void *q);
66
typedef void (activity_fn) (void *data, int rw);
67
66
68
67
struct request_list {
69
struct request_list {
68
	unsigned int count;
70
	unsigned int count;
Lines 114-125 Link Here
114
	merge_requests_fn	* merge_requests_fn;
116
	merge_requests_fn	* merge_requests_fn;
115
	make_request_fn		* make_request_fn;
117
	make_request_fn		* make_request_fn;
116
	plug_device_fn		* plug_device_fn;
118
	plug_device_fn		* plug_device_fn;
119
	activity_fn		* activity_fn;
120
117
	/*
121
	/*
118
	 * The queue owner gets to use this for whatever they like.
122
	 * The queue owner gets to use this for whatever they like.
119
	 * ll_rw_blk doesn't touch it.
123
	 * ll_rw_blk doesn't touch it.
120
	 */
124
	 */
121
	void			* queuedata;
125
	void			* queuedata;
122
126
127
	void			* activity_data;
128
123
	/*
129
	/*
124
	 * This is used to remove the plug when tq_disk runs.
130
	 * This is used to remove the plug when tq_disk runs.
125
	 */
131
	 */
Lines 246-251 Link Here
246
extern void blk_queue_throttle_sectors(request_queue_t *, int);
252
extern void blk_queue_throttle_sectors(request_queue_t *, int);
247
extern void blk_queue_make_request(request_queue_t *, make_request_fn *);
253
extern void blk_queue_make_request(request_queue_t *, make_request_fn *);
248
extern void generic_unplug_device(void *);
254
extern void generic_unplug_device(void *);
255
extern void blk_queue_activity_fn(request_queue_t *, activity_fn *, void *);
249
extern inline int blk_seg_merge_ok(struct buffer_head *, struct buffer_head *);
256
extern inline int blk_seg_merge_ok(struct buffer_head *, struct buffer_head *);
250
257
251
extern int * blk_size[MAX_BLKDEV];
258
extern int * blk_size[MAX_BLKDEV];
(-)linux-2.4.22/include/linux/cpufreq.h (+247 lines)
Line 0 Link Here
1
/*
2
 *  linux/include/linux/cpufreq.h
3
 *
4
 *  Copyright (C) 2001 Russell King
5
 *            (C) 2002 Dominik Brodowski <linux@brodo.de>
6
 *            
7
 *
8
 * $Id: cpufreq.h,v 1.29 2002/11/11 15:35:47 db Exp $
9
 *
10
 * This program is free software; you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License version 2 as
12
 * published by the Free Software Foundation.
13
 */
14
#ifndef _LINUX_CPUFREQ_H
15
#define _LINUX_CPUFREQ_H
16
17
#include <linux/config.h>
18
#include <linux/notifier.h>
19
#include <linux/threads.h>
20
21
22
/*********************************************************************
23
 *                     CPUFREQ NOTIFIER INTERFACE                    *
24
 *********************************************************************/
25
26
int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list);
27
int cpufreq_unregister_notifier(struct notifier_block *nb, unsigned int list);
28
29
#define CPUFREQ_TRANSITION_NOTIFIER     (0)
30
#define CPUFREQ_POLICY_NOTIFIER         (1)
31
32
#define CPUFREQ_ALL_CPUS        ((NR_CPUS))
33
34
35
/********************** cpufreq policy notifiers *********************/
36
37
#define CPUFREQ_POLICY_POWERSAVE        (1)
38
#define CPUFREQ_POLICY_PERFORMANCE      (2)
39
40
/* values here are CPU kHz so that hardware which doesn't run with some
41
 * frequencies can complain without having to guess what per cent / per
42
 * mille means. */
43
struct cpufreq_policy {
44
	unsigned int            cpu;    /* cpu nr or CPUFREQ_ALL_CPUS */
45
	unsigned int            min;    /* in kHz */
46
	unsigned int            max;    /* in kHz */
47
        unsigned int            policy; /* see above */
48
	unsigned int            max_cpu_freq; /* for information */
49
};
50
51
#define CPUFREQ_ADJUST          (0)
52
#define CPUFREQ_INCOMPATIBLE    (1)
53
#define CPUFREQ_NOTIFY          (2)
54
55
56
/******************** cpufreq transition notifiers *******************/
57
58
#define CPUFREQ_PRECHANGE	(0)
59
#define CPUFREQ_POSTCHANGE	(1)
60
61
struct cpufreq_freqs {
62
	unsigned int cpu;      /* cpu nr or CPUFREQ_ALL_CPUS */
63
	unsigned int old;
64
	unsigned int new;
65
};
66
67
68
/**
69
 * cpufreq_scale - "old * mult / div" calculation for large values (32-bit-arch safe)
70
 * @old:   old value
71
 * @div:   divisor
72
 * @mult:  multiplier
73
 *
74
 * Needed for loops_per_jiffy and similar calculations.  We do it 
75
 * this way to avoid math overflow on 32-bit machines.  This will
76
 * become architecture dependent once high-resolution-timer is
77
 * merged (or any other thing that introduces sc_math.h).
78
 *
79
 *    new = old * mult / div
80
 */
81
static inline unsigned long cpufreq_scale(unsigned long old, u_int div, u_int mult)
82
{
83
	unsigned long val, carry;
84
85
	mult /= 100;
86
	div  /= 100;
87
        val   = (old / div) * mult;
88
        carry = old % div;
89
	carry = carry * mult / div;
90
91
	return carry + val;
92
};
93
94
95
/*********************************************************************
96
 *                      DYNAMIC CPUFREQ INTERFACE                    *
97
 *********************************************************************/
98
#ifdef CONFIG_CPU_FREQ_DYNAMIC
99
/* TBD */
100
#endif /* CONFIG_CPU_FREQ_DYNAMIC */
101
102
103
/*********************************************************************
104
 *                      CPUFREQ DRIVER INTERFACE                     *
105
 *********************************************************************/
106
107
typedef int (*cpufreq_policy_t)          (struct cpufreq_policy *policy);
108
109
struct cpufreq_driver {
110
	/* needed by all drivers */
111
	cpufreq_policy_t        verify;
112
	cpufreq_policy_t        setpolicy;
113
	struct cpufreq_policy   *policy;
114
#ifdef CONFIG_CPU_FREQ_DYNAMIC
115
	/* TBD */
116
#endif
117
	/* 2.4. compatible API */
118
#ifdef CONFIG_CPU_FREQ_24_API
119
	unsigned int            cpu_min_freq[NR_CPUS];
120
	unsigned int            cpu_cur_freq[NR_CPUS];
121
#endif
122
};
123
124
int cpufreq_register(struct cpufreq_driver *driver_data);
125
int cpufreq_unregister(void);
126
127
void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state);
128
129
130
static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, unsigned int min, unsigned int max) 
131
{
132
	if (policy->min < min)
133
		policy->min = min;
134
	if (policy->max < min)
135
		policy->max = min;
136
	if (policy->min > max)
137
		policy->min = max;
138
	if (policy->max > max)
139
		policy->max = max;
140
	if (policy->min > policy->max)
141
		policy->min = policy->max;
142
	return;
143
}
144
145
/*********************************************************************
146
 *                        CPUFREQ 2.6. INTERFACE                     *
147
 *********************************************************************/
148
int cpufreq_set_policy(struct cpufreq_policy *policy);
149
int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu);
150
151
#ifdef CONFIG_PM
152
int cpufreq_restore(void);
153
#endif
154
155
156
#ifdef CONFIG_CPU_FREQ_24_API
157
/*********************************************************************
158
 *                        CPUFREQ 2.4. INTERFACE                     *
159
 *********************************************************************/
160
int cpufreq_setmax(unsigned int cpu);
161
int cpufreq_set(unsigned int kHz, unsigned int cpu);
162
unsigned int cpufreq_get(unsigned int cpu);
163
164
/* /proc/sys/cpu */
165
enum {
166
	CPU_NR   = 1,           /* compatibilty reasons */
167
	CPU_NR_0 = 1,
168
	CPU_NR_1 = 2,
169
	CPU_NR_2 = 3,
170
	CPU_NR_3 = 4,
171
	CPU_NR_4 = 5,
172
	CPU_NR_5 = 6,
173
	CPU_NR_6 = 7,
174
	CPU_NR_7 = 8,
175
	CPU_NR_8 = 9,
176
	CPU_NR_9 = 10,
177
	CPU_NR_10 = 11,
178
	CPU_NR_11 = 12,
179
	CPU_NR_12 = 13,
180
	CPU_NR_13 = 14,
181
	CPU_NR_14 = 15,
182
	CPU_NR_15 = 16,
183
	CPU_NR_16 = 17,
184
	CPU_NR_17 = 18,
185
	CPU_NR_18 = 19,
186
	CPU_NR_19 = 20,
187
	CPU_NR_20 = 21,
188
	CPU_NR_21 = 22,
189
	CPU_NR_22 = 23,
190
	CPU_NR_23 = 24,
191
	CPU_NR_24 = 25,
192
	CPU_NR_25 = 26,
193
	CPU_NR_26 = 27,
194
	CPU_NR_27 = 28,
195
	CPU_NR_28 = 29,
196
	CPU_NR_29 = 30,
197
	CPU_NR_30 = 31,
198
	CPU_NR_31 = 32,
199
};
200
201
/* /proc/sys/cpu/{0,1,...,(NR_CPUS-1)} */
202
enum {
203
	CPU_NR_FREQ_MAX = 1,
204
	CPU_NR_FREQ_MIN = 2,
205
	CPU_NR_FREQ = 3,
206
};
207
208
#define CTL_CPU_VARS_SPEED_MAX(cpunr) { \
209
                .ctl_name	= CPU_NR_FREQ_MAX, \
210
                .data		= &cpu_max_freq[cpunr], \
211
                .procname	= "speed-max", \
212
                .maxlen		= sizeof(cpu_max_freq[cpunr]),\
213
                .mode		= 0444, \
214
                .proc_handler	= proc_dointvec, }
215
216
#define CTL_CPU_VARS_SPEED_MIN(cpunr) { \
217
                .ctl_name	= CPU_NR_FREQ_MIN, \
218
                .data		= &cpu_min_freq[cpunr], \
219
                .procname	= "speed-min", \
220
                .maxlen		= sizeof(cpu_min_freq[cpunr]),\
221
                .mode		= 0444, \
222
                .proc_handler	= proc_dointvec, }
223
224
#define CTL_CPU_VARS_SPEED(cpunr) { \
225
                .ctl_name	= CPU_NR_FREQ, \
226
                .procname	= "speed", \
227
                .mode		= 0644, \
228
                .proc_handler	= cpufreq_procctl, \
229
                .strategy	= cpufreq_sysctl, \
230
                .extra1		= (void*) (cpunr), }
231
232
#define CTL_TABLE_CPU_VARS(cpunr) static ctl_table ctl_cpu_vars_##cpunr[] = {\
233
                CTL_CPU_VARS_SPEED_MAX(cpunr), \
234
                CTL_CPU_VARS_SPEED_MIN(cpunr), \
235
                CTL_CPU_VARS_SPEED(cpunr),  \
236
                { .ctl_name = 0, }, }
237
238
/* the ctl_table entry for each CPU */
239
#define CPU_ENUM(s) { \
240
                .ctl_name	= (CPU_NR + s), \
241
                .procname	= #s, \
242
                .mode		= 0555, \
243
                .child		= ctl_cpu_vars_##s }
244
245
#endif /* CONFIG_CPU_FREQ_24_API */
246
247
#endif /* _LINUX_CPUFREQ_H */
(-)linux-2.4.22/include/linux/fs.h (+3 lines)
Lines 1255-1260 Link Here
1255
}
1255
}
1256
1256
1257
extern void set_buffer_flushtime(struct buffer_head *);
1257
extern void set_buffer_flushtime(struct buffer_head *);
1258
extern unsigned long get_buffer_flushtime(void);
1258
extern void balance_dirty(void);
1259
extern void balance_dirty(void);
1259
extern int check_disk_change(kdev_t);
1260
extern int check_disk_change(kdev_t);
1260
extern int invalidate_inodes(struct super_block *);
1261
extern int invalidate_inodes(struct super_block *);
Lines 1445-1452 Link Here
1445
	return get_hash_table(sb->s_dev, block, sb->s_blocksize);
1446
	return get_hash_table(sb->s_dev, block, sb->s_blocksize);
1446
}
1447
}
1447
extern void wakeup_bdflush(void);
1448
extern void wakeup_bdflush(void);
1449
extern void wakeup_kupdate(void);
1448
extern void put_unused_buffer_head(struct buffer_head * bh);
1450
extern void put_unused_buffer_head(struct buffer_head * bh);
1449
extern struct buffer_head * get_unused_buffer_head(int async);
1451
extern struct buffer_head * get_unused_buffer_head(int async);
1452
extern int block_dump;
1450
1453
1451
extern int brw_page(int, struct page *, kdev_t, int [], int);
1454
extern int brw_page(int, struct page *, kdev_t, int [], int);
1452
1455
(-)linux-2.4.22/include/linux/ide.h (+9 lines)
Lines 345-350 Link Here
345
# define ide_ack_intr(hwif) (1)
345
# define ide_ack_intr(hwif) (1)
346
#endif
346
#endif
347
347
348
/* Do we have arch-specififed "reserved" IDE slots for bootable
349
 * devices ? By default, we have 2
350
 */
351
#ifndef IDE_ARCH_RESERVED_HWIFS
352
# define ide_reserved_hwifs()	2
353
#endif
354
348
/* Currently only Atari needs it */
355
/* Currently only Atari needs it */
349
#ifndef IDE_ARCH_LOCK
356
#ifndef IDE_ARCH_LOCK
350
# define ide_release_lock()			do {} while (0)
357
# define ide_release_lock()			do {} while (0)
Lines 1005-1010 Link Here
1005
	unsigned	no_dsc     : 1;	/* 0 default, 1 dsc_overlap disabled */
1012
	unsigned	no_dsc     : 1;	/* 0 default, 1 dsc_overlap disabled */
1006
1013
1007
	void		*hwif_data;	/* extra hwif data */
1014
	void		*hwif_data;	/* extra hwif data */
1015
1016
	void (*led_act)(void *data, int rw);
1008
} ide_hwif_t;
1017
} ide_hwif_t;
1009
1018
1010
/*
1019
/*
(-)linux-2.4.22/include/linux/mm.h (-10 / +27 lines)
Lines 634-645 Link Here
634
634
635
	return gfp_mask;
635
	return gfp_mask;
636
}
636
}
637
	
637
638
/* vma is the first one with  address < vma->vm_end,
638
extern int heap_stack_gap;
639
 * and even  address < vma->vm_start. Have to extend vma. */
639
640
static inline int expand_stack(struct vm_area_struct * vma, unsigned long address)
640
/*
641
 * vma is the first one with  address < vma->vm_end,
642
 * and even  address < vma->vm_start. Have to extend vma.
643
 *
644
 * Locking: vm_start can decrease under you if you only hold
645
 * the read semaphore, you either need the write semaphore
646
 * or both the read semaphore and the page_table_lock acquired
647
 * if you want vm_start consistent. vm_end and the vma layout
648
 * are just consistent with only the read semaphore acquired
649
 * instead.
650
 */
651
#define EXPAND_STACK_HAS_3_ARGS
652
static inline int expand_stack(struct vm_area_struct * vma, unsigned long address,
653
			       struct vm_area_struct * prev_vma)
641
{
654
{
642
	unsigned long grow;
655
	unsigned long grow;
656
	int err = -ENOMEM;
643
657
644
	/*
658
	/*
645
	 * vma->vm_start/vm_end cannot change under us because the caller is required
659
	 * vma->vm_start/vm_end cannot change under us because the caller is required
Lines 647-666 Link Here
647
	 * before relocating the vma range ourself.
661
	 * before relocating the vma range ourself.
648
	 */
662
	 */
649
	address &= PAGE_MASK;
663
	address &= PAGE_MASK;
650
 	spin_lock(&vma->vm_mm->page_table_lock);
664
	if (prev_vma && prev_vma->vm_end + (heap_stack_gap << PAGE_SHIFT) > address)
665
		goto out;
666
	spin_lock(&vma->vm_mm->page_table_lock);
651
	grow = (vma->vm_start - address) >> PAGE_SHIFT;
667
	grow = (vma->vm_start - address) >> PAGE_SHIFT;
652
	if (vma->vm_end - address > current->rlim[RLIMIT_STACK].rlim_cur ||
668
	if (vma->vm_end - address > current->rlim[RLIMIT_STACK].rlim_cur ||
653
	    ((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) > current->rlim[RLIMIT_AS].rlim_cur) {
669
	    ((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) > current->rlim[RLIMIT_AS].rlim_cur)
654
		spin_unlock(&vma->vm_mm->page_table_lock);
670
		goto out_unlock;
655
		return -ENOMEM;
656
	}
657
	vma->vm_start = address;
671
	vma->vm_start = address;
658
	vma->vm_pgoff -= grow;
672
	vma->vm_pgoff -= grow;
659
	vma->vm_mm->total_vm += grow;
673
	vma->vm_mm->total_vm += grow;
660
	if (vma->vm_flags & VM_LOCKED)
674
	if (vma->vm_flags & VM_LOCKED)
661
		vma->vm_mm->locked_vm += grow;
675
		vma->vm_mm->locked_vm += grow;
676
	err = 0;
677
 out_unlock:
662
	spin_unlock(&vma->vm_mm->page_table_lock);
678
	spin_unlock(&vma->vm_mm->page_table_lock);
663
	return 0;
679
 out:
680
	return err;
664
}
681
}
665
682
666
/* Look up the first VMA which satisfies  addr < vm_end,  NULL if none. */
683
/* Look up the first VMA which satisfies  addr < vm_end,  NULL if none. */
(-)linux-2.4.22/include/linux/pci_ids.h (-28 / +47 lines)
Lines 403-411 Link Here
403
#define PCI_DEVICE_ID_IBM_MPIC		0x0046
403
#define PCI_DEVICE_ID_IBM_MPIC		0x0046
404
#define PCI_DEVICE_ID_IBM_3780IDSP	0x007d
404
#define PCI_DEVICE_ID_IBM_3780IDSP	0x007d
405
#define PCI_DEVICE_ID_IBM_CHUKAR	0x0096
405
#define PCI_DEVICE_ID_IBM_CHUKAR	0x0096
406
#define PCI_DEVICE_ID_IBM_CPC700	0x00f9
406
#define PCI_DEVICE_ID_IBM_CPC710_PCI64	0x00fc
407
#define PCI_DEVICE_ID_IBM_CPC710_PCI64	0x00fc
407
#define PCI_DEVICE_ID_IBM_CPC710_PCI32	0x0105
408
#define PCI_DEVICE_ID_IBM_CPC710_PCI32	0x0105
408
#define	PCI_DEVICE_ID_IBM_405GP		0x0156
409
#define PCI_DEVICE_ID_IBM_405GP		0x0156
409
#define PCI_DEVICE_ID_IBM_SERVERAIDI960	0x01bd
410
#define PCI_DEVICE_ID_IBM_SERVERAIDI960	0x01bd
410
#define PCI_DEVICE_ID_IBM_MPIC_2	0xffff
411
#define PCI_DEVICE_ID_IBM_MPIC_2	0xffff
411
412
Lines 654-659 Link Here
654
#define PCI_DEVICE_ID_TI_4410		0xac41
655
#define PCI_DEVICE_ID_TI_4410		0xac41
655
#define PCI_DEVICE_ID_TI_4451		0xac42
656
#define PCI_DEVICE_ID_TI_4451		0xac42
656
#define PCI_DEVICE_ID_TI_1420		0xac51
657
#define PCI_DEVICE_ID_TI_1420		0xac51
658
#define PCI_DEVICE_ID_TI_1510		0xac56
657
659
658
#define PCI_VENDOR_ID_SONY		0x104d
660
#define PCI_VENDOR_ID_SONY		0x104d
659
#define PCI_DEVICE_ID_SONY_CXD3222	0x8039
661
#define PCI_DEVICE_ID_SONY_CXD3222	0x8039
Lines 747-752 Link Here
747
#define PCI_DEVICE_ID_APPLE_UNI_N_AGP_P	0x0027
749
#define PCI_DEVICE_ID_APPLE_UNI_N_AGP_P	0x0027
748
#define PCI_DEVICE_ID_APPLE_UNI_N_AGP15	0x002d
750
#define PCI_DEVICE_ID_APPLE_UNI_N_AGP15	0x002d
749
#define PCI_DEVICE_ID_APPLE_UNI_N_FW2	0x0030
751
#define PCI_DEVICE_ID_APPLE_UNI_N_FW2	0x0030
752
#define PCI_DEVICE_ID_APPLE_UNI_N_GMAC2	0x0032
753
#define PCI_DEVICE_ID_APPLE_UNI_N_AGP2	0x0034
754
#define PCI_DEVICE_ID_APPLE_KEYLARGO_I	0x003e
755
#define PCI_DEVICE_ID_APPLE_TIGON3	0x1645
750
756
751
#define PCI_VENDOR_ID_YAMAHA		0x1073
757
#define PCI_VENDOR_ID_YAMAHA		0x1073
752
#define PCI_DEVICE_ID_YAMAHA_724	0x0004
758
#define PCI_DEVICE_ID_YAMAHA_724	0x0004
Lines 957-989 Link Here
957
#define PCI_DEVICE_ID_CERN_HIPPI_DST	0x0021
963
#define PCI_DEVICE_ID_CERN_HIPPI_DST	0x0021
958
#define PCI_DEVICE_ID_CERN_HIPPI_SRC	0x0022
964
#define PCI_DEVICE_ID_CERN_HIPPI_SRC	0x0022
959
965
960
#define PCI_VENDOR_ID_NVIDIA			0x10de
966
#define PCI_VENDOR_ID_NVIDIA				0x10de
961
#define PCI_DEVICE_ID_NVIDIA_TNT		0x0020
967
#define PCI_DEVICE_ID_NVIDIA_TNT			0x0020
962
#define PCI_DEVICE_ID_NVIDIA_TNT2		0x0028
968
#define PCI_DEVICE_ID_NVIDIA_TNT2			0x0028
963
#define PCI_DEVICE_ID_NVIDIA_UTNT2		0x0029
969
#define PCI_DEVICE_ID_NVIDIA_UTNT2			0x0029
964
#define PCI_DEVICE_ID_NVIDIA_VTNT2		0x002C
970
#define PCI_DEVICE_ID_NVIDIA_VTNT2			0x002C
965
#define PCI_DEVICE_ID_NVIDIA_UVTNT2		0x002D
971
#define PCI_DEVICE_ID_NVIDIA_UVTNT2			0x002D
966
#define PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE	0x0065
972
#define PCI_DEVICE_ID_NVIDIA_ITNT2			0x00A0
967
#define PCI_DEVICE_ID_NVIDIA_ITNT2		0x00A0
973
#define PCI_DEVICE_ID_NVIDIA_GEFORCE_SDR		0x0100
968
#define PCI_DEVICE_ID_NVIDIA_GEFORCE_SDR	0x0100
974
#define PCI_DEVICE_ID_NVIDIA_GEFORCE_DDR		0x0101
969
#define PCI_DEVICE_ID_NVIDIA_GEFORCE_DDR	0x0101
975
#define PCI_DEVICE_ID_NVIDIA_QUADRO			0x0103
970
#define PCI_DEVICE_ID_NVIDIA_QUADRO		0x0103
976
#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX		0x0110
971
#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX	0x0110
977
#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX2		0x0111
972
#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX2	0x0111
978
#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GO		0x0112
973
#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GO	0x0112
979
#define PCI_DEVICE_ID_NVIDIA_QUADRO2_MXR		0x0113
974
#define PCI_DEVICE_ID_NVIDIA_QUADRO2_MXR	0x0113
980
#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS		0x0150
975
#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS	0x0150
981
#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS2		0x0151
976
#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS2	0x0151
982
#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_ULTRA		0x0152
977
#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_ULTRA	0x0152
983
#define PCI_DEVICE_ID_NVIDIA_QUADRO2_PRO		0x0153
978
#define PCI_DEVICE_ID_NVIDIA_QUADRO2_PRO	0x0153
984
#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_460 		0x0170
979
#define PCI_DEVICE_ID_NVIDIA_IGEFORCE2		0x01a0
985
#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_440 		0x0171
980
#define PCI_DEVICE_ID_NVIDIA_NFORCE		0x01a4
986
#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_MX_420 		0x0172
981
#define PCI_DEVICE_ID_NVIDIA_NFORCE_IDE		0x01bc
987
#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_440_GO		0x0174
982
#define PCI_DEVICE_ID_NVIDIA_NFORCE2		0x01e0
988
#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_420_GO		0x0175
983
#define PCI_DEVICE_ID_NVIDIA_GEFORCE3		0x0200
989
#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_420_GO_M32	0x0176
984
#define PCI_DEVICE_ID_NVIDIA_GEFORCE3_1		0x0201
990
#define PCI_DEVICE_ID_NVIDIA_QUADRO4_500XGL		0x0178
985
#define PCI_DEVICE_ID_NVIDIA_GEFORCE3_2		0x0202
991
#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_440_GO_M64	0x0179
986
#define PCI_DEVICE_ID_NVIDIA_QUADRO_DDC		0x0203
992
#define PCI_DEVICE_ID_NVIDIA_QUADRO4_200		0x017A
993
#define PCI_DEVICE_ID_NVIDIA_QUADRO4_550XGL		0x017B
994
#define PCI_DEVICE_ID_NVIDIA_QUADRO4_500_GOGL		0x017C
995
#define PCI_DEVICE_ID_NVIDIA_IGEFORCE2			0x01a0
996
#define PCI_DEVICE_ID_NVIDIA_GEFORCE3			0x0200
997
#define PCI_DEVICE_ID_NVIDIA_GEFORCE3_1			0x0201
998
#define PCI_DEVICE_ID_NVIDIA_GEFORCE3_2			0x0202
999
#define PCI_DEVICE_ID_NVIDIA_QUADRO_DDC			0x0203
1000
#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4600		0x0250
1001
#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4400		0x0251
1002
#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4200		0x0253
1003
#define PCI_DEVICE_ID_NVIDIA_QUADRO4_900XGL		0x0258
1004
#define PCI_DEVICE_ID_NVIDIA_QUADRO4_750XGL		0x0259
1005
#define PCI_DEVICE_ID_NVIDIA_QUADRO4_700XGL		0x025B
987
1006
988
#define PCI_VENDOR_ID_IMS		0x10e0
1007
#define PCI_VENDOR_ID_IMS		0x10e0
989
#define PCI_DEVICE_ID_IMS_8849		0x8849
1008
#define PCI_DEVICE_ID_IMS_8849		0x8849
(-)linux-2.4.22/include/linux/pmu.h (+3 lines)
Lines 143-148 Link Here
143
		void (*done)(struct adb_request *), int nbytes, ...);
143
		void (*done)(struct adb_request *), int nbytes, ...);
144
144
145
extern void pmu_poll(void);
145
extern void pmu_poll(void);
146
extern void pmu_poll_adb(void); /* For use by xmon */
147
extern void pmu_wait_complete(struct adb_request *req);
146
148
147
/* For use before switching interrupts off for a long time;
149
/* For use before switching interrupts off for a long time;
148
 * warning: not stackable
150
 * warning: not stackable
Lines 154-159 Link Here
154
156
155
extern void pmu_restart(void);
157
extern void pmu_restart(void);
156
extern void pmu_shutdown(void);
158
extern void pmu_shutdown(void);
159
extern void pmu_unlock(void);
157
160
158
extern int pmu_present(void);
161
extern int pmu_present(void);
159
extern int pmu_get_model(void);
162
extern int pmu_get_model(void);
(-)linux-2.4.22/include/linux/sysctl.h (+3 lines)
Lines 146-151 Link Here
146
	VM_MAX_MAP_COUNT=11,	/* int: Maximum number of active map areas */
146
	VM_MAX_MAP_COUNT=11,	/* int: Maximum number of active map areas */
147
	VM_MIN_READAHEAD=12,    /* Min file readahead */
147
	VM_MIN_READAHEAD=12,    /* Min file readahead */
148
	VM_MAX_READAHEAD=13,    /* Max file readahead */
148
	VM_MAX_READAHEAD=13,    /* Max file readahead */
149
	VM_HEAP_STACK_GAP=14,	/* int: page gap between heap and stack */
150
	VM_LAPTOP_MODE=15,
151
	VM_BLOCK_DUMP=16,
149
};
152
};
150
153
151
154
(-)linux-2.4.22/include/linux/wait.h (-2 / +8 lines)
Lines 90-100 Link Here
90
 * spurious .aligns.
90
 * spurious .aligns.
91
 */
91
 */
92
#if WAITQUEUE_DEBUG
92
#if WAITQUEUE_DEBUG
93
#ifdef CONFIG_XMON
94
extern void xmon_printf(const char* fmt, ...);
95
#define wqbug_printf	xmon_printf
96
#else
97
#define wqbug_printf	printk
98
#endif
93
#define WQ_BUG()	BUG()
99
#define WQ_BUG()	BUG()
94
#define CHECK_MAGIC(x)							\
100
#define CHECK_MAGIC(x)							\
95
	do {									\
101
	do {									\
96
		if ((x) != (long)&(x)) {					\
102
		if ((x) != (long)&(x)) {					\
97
			printk("bad magic %lx (should be %lx), ",		\
103
			wqbug_printf("bad magic %lx (should be %lx), ",		\
98
				(long)x, (long)&(x));				\
104
				(long)x, (long)&(x));				\
99
			WQ_BUG();						\
105
			WQ_BUG();						\
100
		}								\
106
		}								\
Lines 102-108 Link Here
102
#define CHECK_MAGIC_WQHEAD(x)							\
108
#define CHECK_MAGIC_WQHEAD(x)							\
103
	do {									\
109
	do {									\
104
		if ((x)->__magic != (long)&((x)->__magic)) {			\
110
		if ((x)->__magic != (long)&((x)->__magic)) {			\
105
			printk("bad magic %lx (should be %lx, creator %lx), ",	\
111
			wqbug_printf("bad magic %lx (should be %lx, creator %lx), ",	\
106
			(x)->__magic, (long)&((x)->__magic), (x)->__creator);	\
112
			(x)->__magic, (long)&((x)->__magic), (x)->__creator);	\
107
			WQ_BUG();						\
113
			WQ_BUG();						\
108
		}								\
114
		}								\
(-)linux-2.4.22/init/main.c (-1 / +1 lines)
Lines 161-167 Link Here
161
   better than 1% */
161
   better than 1% */
162
#define LPS_PREC 8
162
#define LPS_PREC 8
163
163
164
void __init calibrate_delay(void)
164
void /*__init*/ calibrate_delay(void)
165
{
165
{
166
	unsigned long ticks, loopbit;
166
	unsigned long ticks, loopbit;
167
	int lps_precision = LPS_PREC;
167
	int lps_precision = LPS_PREC;
(-)linux-2.4.22/kernel/Makefile (-1 / +2 lines)
Lines 9-15 Link Here
9
9
10
O_TARGET := kernel.o
10
O_TARGET := kernel.o
11
11
12
export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o printk.o
12
export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o printk.o cpufreq.o
13
13
14
obj-y     = sched.o dma.o fork.o exec_domain.o panic.o printk.o \
14
obj-y     = sched.o dma.o fork.o exec_domain.o panic.o printk.o \
15
	    module.o exit.o itimer.o info.o time.o softirq.o resource.o \
15
	    module.o exit.o itimer.o info.o time.o softirq.o resource.o \
Lines 19-24 Link Here
19
obj-$(CONFIG_UID16) += uid16.o
19
obj-$(CONFIG_UID16) += uid16.o
20
obj-$(CONFIG_MODULES) += ksyms.o
20
obj-$(CONFIG_MODULES) += ksyms.o
21
obj-$(CONFIG_PM) += pm.o
21
obj-$(CONFIG_PM) += pm.o
22
obj-$(CONFIG_CPU_FREQ) += cpufreq.o
22
23
23
ifneq ($(CONFIG_IA64),y)
24
ifneq ($(CONFIG_IA64),y)
24
# According to Alan Modra <alan@linuxcare.com.au>, the -fno-omit-frame-pointer is
25
# According to Alan Modra <alan@linuxcare.com.au>, the -fno-omit-frame-pointer is
(-)linux-2.4.22/kernel/cpufreq.c (+1130 lines)
Line 0 Link Here
1
/*
2
 *  linux/kernel/cpufreq.c
3
 *
4
 *  Copyright (C) 2001 Russell King
5
 *            (C) 2002 Dominik Brodowski <linux@brodo.de>
6
 *
7
 *  $Id: cpufreq.c,v 1.50 2002/11/11 15:35:48 db Exp $
8
 *
9
 * This program is free software; you can redistribute it and/or modify
10
 * it under the terms of the GNU General Public License version 2 as
11
 * published by the Free Software Foundation.
12
 *
13
 */
14
15
#include <linux/kernel.h>
16
#include <linux/module.h>
17
#include <linux/init.h>
18
#include <linux/notifier.h>
19
#include <linux/cpufreq.h>
20
#include <linux/delay.h>
21
#include <asm/system.h>
22
#include <linux/interrupt.h>
23
#include <linux/spinlock.h>
24
#include <linux/ctype.h>
25
#include <linux/proc_fs.h>
26
27
#include <asm/uaccess.h>
28
29
#ifdef CONFIG_CPU_FREQ_24_API
30
#include <linux/sysctl.h>
31
#endif
32
33
34
/**
35
 * The "cpufreq driver" - the arch- or hardware-dependend low
36
 * level driver of CPUFreq support, and its locking mutex. 
37
 * cpu_max_freq is in kHz.
38
 */
39
static struct cpufreq_driver   	*cpufreq_driver;
40
static DECLARE_MUTEX            (cpufreq_driver_sem);
41
42
43
/**
44
 * Two notifier lists: the "policy" list is involved in the 
45
 * validation process for a new CPU frequency policy; the 
46
 * "transition" list for kernel code that needs to handle
47
 * changes to devices when the CPU clock speed changes.
48
 * The mutex locks both lists. If both cpufreq_driver_sem
49
 * and cpufreq_notifier_sem need to be hold, get cpufreq_driver_sem
50
 * first.
51
 */
52
static struct notifier_block    *cpufreq_policy_notifier_list;
53
static struct notifier_block    *cpufreq_transition_notifier_list;
54
static DECLARE_MUTEX            (cpufreq_notifier_sem);
55
56
57
/**
58
 * The cpufreq default policy. Can be set by a "cpufreq=..." command
59
 * line option.
60
 */
61
static struct cpufreq_policy default_policy = {
62
	.cpu    = CPUFREQ_ALL_CPUS,
63
	.min    = 0,
64
	.max    = 0,
65
	.policy = 0,
66
};
67
68
69
#ifdef CONFIG_CPU_FREQ_24_API
70
/**
71
 * A few values needed by the 2.4.-compatible API
72
 */
73
static unsigned int     cpu_max_freq[NR_CPUS];
74
static unsigned int     cpu_min_freq[NR_CPUS];
75
static unsigned int     cpu_cur_freq[NR_CPUS];
76
#endif
77
78
79
80
/*********************************************************************
81
 *                              2.6. API                             *
82
 *********************************************************************/
83
84
/**
85
 * cpufreq_parse_policy - parse a policy string
86
 * @input_string: the string to parse.
87
 * @policy: the policy written inside input_string
88
 *
89
 * This function parses a "policy string" - something the user echo'es into
90
 * /proc/cpufreq or gives as boot parameter - into a struct cpufreq_policy.
91
 * If there are invalid/missing entries, they are replaced with current
92
 * cpufreq policy.
93
 */
94
static int cpufreq_parse_policy(char input_string[42], struct cpufreq_policy *policy)
95
{
96
	unsigned int            min = 0;
97
	unsigned int            max = 0;
98
	unsigned int            cpu = 0;
99
	char			policy_string[42] = {'\0'};
100
	struct cpufreq_policy   current_policy;
101
	unsigned int            result = -EFAULT;
102
	unsigned int            i = 0;
103
104
	if (!policy)
105
		return -EINVAL;
106
107
	policy->min = 0;
108
	policy->max = 0;
109
	policy->policy = 0;
110
	policy->cpu = CPUFREQ_ALL_CPUS;
111
112
	if (sscanf(input_string, "%d:%d:%d:%s", &cpu, &min, &max, policy_string) == 4) 
113
	{
114
		policy->min = min;
115
		policy->max = max;
116
		policy->cpu = cpu;
117
		result = 0;
118
		goto scan_policy;
119
	}
120
	if (sscanf(input_string, "%d%%%d%%%d%%%s", &cpu, &min, &max, policy_string) == 4)
121
	{
122
		if (!cpufreq_get_policy(&current_policy, cpu)) {
123
			policy->min = (min * current_policy.max_cpu_freq) / 100;
124
			policy->max = (max * current_policy.max_cpu_freq) / 100;
125
			policy->cpu = cpu;
126
			result = 0;
127
			goto scan_policy;
128
		}
129
	}
130
131
	if (sscanf(input_string, "%d:%d:%s", &min, &max, policy_string) == 3) 
132
	{
133
		policy->min = min;
134
		policy->max = max;
135
		result = 0;
136
		goto scan_policy;
137
	}
138
139
	if (sscanf(input_string, "%d%%%d%%%s", &min, &max, policy_string) == 3)
140
	{
141
		if (!cpufreq_get_policy(&current_policy, cpu)) {
142
			policy->min = (min * current_policy.max_cpu_freq) / 100;
143
			policy->max = (max * current_policy.max_cpu_freq) / 100;
144
			result = 0;
145
			goto scan_policy;
146
		}
147
	}
148
149
	return -EINVAL;
150
151
scan_policy:
152
153
	for (i=0;i<sizeof(policy_string);i++){
154
		if (policy_string[i]=='\0')
155
			break;
156
		policy_string[i] = tolower(policy_string[i]);
157
	}
158
159
	if (!strncmp(policy_string, "powersave", 6) ||  
160
            !strncmp(policy_string, "eco", 3) ||       
161
	    !strncmp(policy_string, "batter", 6) ||
162
	    !strncmp(policy_string, "low", 3)) 
163
	{
164
		result = 0;
165
		policy->policy = CPUFREQ_POLICY_POWERSAVE;
166
	}
167
	else if (!strncmp(policy_string, "performance",6) ||
168
	    !strncmp(policy_string, "high",4) ||
169
	    !strncmp(policy_string, "full",4))
170
	{
171
		result = 0;
172
		policy->policy = CPUFREQ_POLICY_PERFORMANCE;
173
	}
174
	else if (!cpufreq_get_policy(&current_policy, policy->cpu))
175
	{
176
		policy->policy = current_policy.policy;
177
	}
178
	else
179
	{
180
		policy->policy = 0;
181
	}
182
183
	return result;
184
}
185
186
187
/*
188
 * cpufreq command line parameter.  Must be hard values (kHz)
189
 *  cpufreq=1000000:2000000:PERFORMANCE   
190
 * to set the default CPUFreq policy.
191
 */
192
static int __init cpufreq_setup(char *str)
193
{
194
	cpufreq_parse_policy(str, &default_policy);
195
	default_policy.cpu = CPUFREQ_ALL_CPUS;
196
	return 1;
197
}
198
__setup("cpufreq=", cpufreq_setup);
199
200
201
#ifdef CONFIG_PROC_FS
202
203
/**
204
 * cpufreq_proc_read - read /proc/cpufreq
205
 *
206
 * This function prints out the current cpufreq policy.
207
 */
208
static int cpufreq_proc_read (
209
	char			*page,
210
	char			**start,
211
	off_t			off,
212
	int 			count,
213
	int 			*eof,
214
	void			*data)
215
{
216
	char			*p = page;
217
	int			len = 0;
218
	struct cpufreq_policy   policy;
219
	unsigned int            min_pctg = 0;
220
	unsigned int            max_pctg = 0;
221
	unsigned int            i = 0;
222
223
	if (off != 0)
224
		goto end;
225
226
	p += sprintf(p, "          minimum CPU frequency  -  maximum CPU frequency  -  policy\n");
227
	for (i=0;i<NR_CPUS;i++) {
228
		if (!cpu_online(i))
229
			continue;
230
231
		cpufreq_get_policy(&policy, i);
232
233
		if (!policy.max_cpu_freq)
234
			continue;
235
236
		min_pctg = (policy.min * 100) / policy.max_cpu_freq;
237
		max_pctg = (policy.max * 100) / policy.max_cpu_freq;
238
239
		p += sprintf(p, "CPU%3d    %9d kHz (%3d %%)  -  %9d kHz (%3d %%)  -  ",
240
			     i , policy.min, min_pctg, policy.max, max_pctg);
241
		switch (policy.policy) {
242
		case CPUFREQ_POLICY_POWERSAVE:
243
			p += sprintf(p, "powersave\n");
244
			break;
245
		case CPUFREQ_POLICY_PERFORMANCE:
246
			p += sprintf(p, "performance\n");
247
			break;
248
		default:
249
			p += sprintf(p, "INVALID\n");
250
			break;
251
		}
252
	}
253
end:
254
	len = (p - page);
255
	if (len <= off+count) 
256
		*eof = 1;
257
	*start = page + off;
258
	len -= off;
259
	if (len>count) 
260
		len = count;
261
	if (len<0) 
262
		len = 0;
263
264
	return len;
265
}
266
267
268
/**
269
 * cpufreq_proc_write - handles writing into /proc/cpufreq
270
 *
271
 * This function calls the parsing script and then sets the policy
272
 * accordingly.
273
 */
274
static int cpufreq_proc_write (
275
        struct file		*file,
276
        const char		*buffer,
277
        unsigned long		count,
278
        void			*data)
279
{
280
	int                     result = 0;
281
	char			proc_string[42] = {'\0'};
282
	struct cpufreq_policy   policy;
283
284
285
	if ((count > sizeof(proc_string) - 1))
286
		return -EINVAL;
287
	
288
	if (copy_from_user(proc_string, buffer, count))
289
		return -EFAULT;
290
	
291
	proc_string[count] = '\0';
292
293
	result = cpufreq_parse_policy(proc_string, &policy);
294
	if (result)
295
		return -EFAULT;
296
297
	cpufreq_set_policy(&policy);
298
299
	return count;
300
}
301
302
303
/**
304
 * cpufreq_proc_init - add "cpufreq" to the /proc root directory
305
 *
306
 * This function adds "cpufreq" to the /proc root directory.
307
 */
308
static unsigned int cpufreq_proc_init (void)
309
{
310
	struct proc_dir_entry *entry = NULL;
311
312
        /* are these acceptable values? */
313
	entry = create_proc_entry("cpufreq", S_IFREG|S_IRUGO|S_IWUSR, 
314
				  &proc_root);
315
316
	if (!entry) {
317
		printk(KERN_ERR "unable to create /proc/cpufreq entry\n");
318
		return -EIO;
319
	} else {
320
		entry->read_proc = cpufreq_proc_read;
321
		entry->write_proc = cpufreq_proc_write;
322
	}
323
324
	return 0;
325
}
326
327
328
/**
329
 * cpufreq_proc_exit - removes "cpufreq" from the /proc root directory.
330
 *
331
 * This function removes "cpufreq" from the /proc root directory.
332
 */
333
static void cpufreq_proc_exit (void)
334
{
335
	remove_proc_entry("cpufreq", &proc_root);
336
	return;
337
}
338
#endif /* CONFIG_PROC_FS */
339
340
341
342
/*********************************************************************
343
 *                        2.4. COMPATIBLE API                        *
344
 *********************************************************************/
345
346
#ifdef CONFIG_CPU_FREQ_24_API
347
/** 
348
 * cpufreq_set - set the CPU frequency
349
 * @freq: target frequency in kHz
350
 * @cpu: CPU for which the frequency is to be set
351
 *
352
 * Sets the CPU frequency to freq.
353
 */
354
int cpufreq_set(unsigned int freq, unsigned int cpu)
355
{
356
	struct cpufreq_policy policy;
357
	down(&cpufreq_driver_sem);
358
	if (!cpufreq_driver || !cpu_max_freq) {
359
		up(&cpufreq_driver_sem);
360
		return -EINVAL;
361
	}
362
363
	policy.min = freq;
364
	policy.max = freq;
365
	policy.policy = CPUFREQ_POLICY_POWERSAVE;
366
	policy.cpu = cpu;
367
	
368
	up(&cpufreq_driver_sem);
369
370
	return cpufreq_set_policy(&policy);
371
}
372
EXPORT_SYMBOL_GPL(cpufreq_set);
373
374
375
/** 
376
 * cpufreq_setmax - set the CPU to the maximum frequency
377
 * @cpu - affected cpu;
378
 *
379
 * Sets the CPU frequency to the maximum frequency supported by
380
 * this CPU.
381
 */
382
int cpufreq_setmax(unsigned int cpu)
383
{
384
	if (!cpu_online(cpu) && (cpu != CPUFREQ_ALL_CPUS))
385
		return -EINVAL;
386
	return cpufreq_set(cpu_max_freq[cpu], cpu);
387
}
388
EXPORT_SYMBOL_GPL(cpufreq_setmax);
389
390
391
/** 
392
 * cpufreq_get - get the current CPU frequency (in kHz)
393
 * @cpu: CPU number - currently without effect.
394
 *
395
 * Get the CPU current (static) CPU frequency
396
 */
397
unsigned int cpufreq_get(unsigned int cpu)
398
{
399
	if (!cpu_online(cpu))
400
		return -EINVAL;
401
	return cpu_cur_freq[cpu];
402
}
403
EXPORT_SYMBOL(cpufreq_get);
404
405
406
#ifdef CONFIG_SYSCTL
407
408
409
/*********************** cpufreq_sysctl interface ********************/
410
static int
411
cpufreq_procctl(ctl_table *ctl, int write, struct file *filp,
412
		void *buffer, size_t *lenp)
413
{
414
	char buf[16], *p;
415
	int cpu = (int) ctl->extra1;
416
	int len, left = *lenp;
417
418
	if (!left || (filp->f_pos && !write) || !cpu_online(cpu)) {
419
		*lenp = 0;
420
		return 0;
421
	}
422
423
	if (write) {
424
		unsigned int freq;
425
426
		len = left;
427
		if (left > sizeof(buf))
428
			left = sizeof(buf);
429
		if (copy_from_user(buf, buffer, left))
430
			return -EFAULT;
431
		buf[sizeof(buf) - 1] = '\0';
432
433
		freq = simple_strtoul(buf, &p, 0);
434
		cpufreq_set(freq, cpu);
435
	} else {
436
		len = sprintf(buf, "%d\n", cpufreq_get(cpu));
437
		if (len > left)
438
			len = left;
439
		if (copy_to_user(buffer, buf, len))
440
			return -EFAULT;
441
	}
442
443
	*lenp = len;
444
	filp->f_pos += len;
445
	return 0;
446
}
447
448
static int
449
cpufreq_sysctl(ctl_table *table, int *name, int nlen,
450
	       void *oldval, size_t *oldlenp,
451
	       void *newval, size_t newlen, void **context)
452
{
453
	int cpu = (int) table->extra1;
454
455
	if (!cpu_online(cpu))
456
		return -EINVAL;
457
458
	if (oldval && oldlenp) {
459
		size_t oldlen;
460
461
		if (get_user(oldlen, oldlenp))
462
			return -EFAULT;
463
464
		if (oldlen != sizeof(unsigned int))
465
			return -EINVAL;
466
467
		if (put_user(cpufreq_get(cpu), (unsigned int *)oldval) ||
468
		    put_user(sizeof(unsigned int), oldlenp))
469
			return -EFAULT;
470
	}
471
	if (newval && newlen) {
472
		unsigned int freq;
473
474
		if (newlen != sizeof(unsigned int))
475
			return -EINVAL;
476
477
		if (get_user(freq, (unsigned int *)newval))
478
			return -EFAULT;
479
480
		cpufreq_set(freq, cpu);
481
	}
482
	return 1;
483
}
484
485
/* ctl_table ctl_cpu_vars_{0,1,...,(NR_CPUS-1)} */
486
/* due to NR_CPUS tweaking, a lot of if/endifs are required, sorry */
487
        CTL_TABLE_CPU_VARS(0);
488
#if NR_CPUS > 1
489
	CTL_TABLE_CPU_VARS(1);
490
#endif
491
#if NR_CPUS > 2
492
	CTL_TABLE_CPU_VARS(2);
493
#endif
494
#if NR_CPUS > 3
495
	CTL_TABLE_CPU_VARS(3);
496
#endif
497
#if NR_CPUS > 4
498
	CTL_TABLE_CPU_VARS(4);
499
#endif
500
#if NR_CPUS > 5
501
	CTL_TABLE_CPU_VARS(5);
502
#endif
503
#if NR_CPUS > 6
504
	CTL_TABLE_CPU_VARS(6);
505
#endif
506
#if NR_CPUS > 7
507
	CTL_TABLE_CPU_VARS(7);
508
#endif
509
#if NR_CPUS > 8
510
	CTL_TABLE_CPU_VARS(8);
511
#endif
512
#if NR_CPUS > 9
513
	CTL_TABLE_CPU_VARS(9);
514
#endif
515
#if NR_CPUS > 10
516
	CTL_TABLE_CPU_VARS(10);
517
#endif
518
#if NR_CPUS > 11
519
	CTL_TABLE_CPU_VARS(11);
520
#endif
521
#if NR_CPUS > 12
522
	CTL_TABLE_CPU_VARS(12);
523
#endif
524
#if NR_CPUS > 13
525
	CTL_TABLE_CPU_VARS(13);
526
#endif
527
#if NR_CPUS > 14
528
	CTL_TABLE_CPU_VARS(14);
529
#endif
530
#if NR_CPUS > 15
531
	CTL_TABLE_CPU_VARS(15);
532
#endif
533
#if NR_CPUS > 16
534
	CTL_TABLE_CPU_VARS(16);
535
#endif
536
#if NR_CPUS > 17
537
	CTL_TABLE_CPU_VARS(17);
538
#endif
539
#if NR_CPUS > 18
540
	CTL_TABLE_CPU_VARS(18);
541
#endif
542
#if NR_CPUS > 19
543
	CTL_TABLE_CPU_VARS(19);
544
#endif
545
#if NR_CPUS > 20
546
	CTL_TABLE_CPU_VARS(20);
547
#endif
548
#if NR_CPUS > 21
549
	CTL_TABLE_CPU_VARS(21);
550
#endif
551
#if NR_CPUS > 22
552
	CTL_TABLE_CPU_VARS(22);
553
#endif
554
#if NR_CPUS > 23
555
	CTL_TABLE_CPU_VARS(23);
556
#endif
557
#if NR_CPUS > 24
558
	CTL_TABLE_CPU_VARS(24);
559
#endif
560
#if NR_CPUS > 25
561
	CTL_TABLE_CPU_VARS(25);
562
#endif
563
#if NR_CPUS > 26
564
	CTL_TABLE_CPU_VARS(26);
565
#endif
566
#if NR_CPUS > 27
567
	CTL_TABLE_CPU_VARS(27);
568
#endif
569
#if NR_CPUS > 28
570
	CTL_TABLE_CPU_VARS(28);
571
#endif
572
#if NR_CPUS > 29
573
	CTL_TABLE_CPU_VARS(29);
574
#endif
575
#if NR_CPUS > 30
576
	CTL_TABLE_CPU_VARS(30);
577
#endif
578
#if NR_CPUS > 31
579
	CTL_TABLE_CPU_VARS(31);
580
#endif
581
#if NR_CPUS > 32
582
#error please extend CPU enumeration
583
#endif
584
585
/* due to NR_CPUS tweaking, a lot of if/endifs are required, sorry */
586
static ctl_table ctl_cpu_table[NR_CPUS + 1] = {
587
	CPU_ENUM(0),
588
#if NR_CPUS > 1
589
	CPU_ENUM(1),
590
#endif
591
#if NR_CPUS > 2
592
	CPU_ENUM(2),
593
#endif
594
#if NR_CPUS > 3
595
	CPU_ENUM(3),
596
#endif
597
#if NR_CPUS > 4
598
	CPU_ENUM(4),
599
#endif
600
#if NR_CPUS > 5
601
	CPU_ENUM(5),
602
#endif
603
#if NR_CPUS > 6
604
	CPU_ENUM(6),
605
#endif
606
#if NR_CPUS > 7
607
	CPU_ENUM(7),
608
#endif
609
#if NR_CPUS > 8
610
	CPU_ENUM(8),
611
#endif
612
#if NR_CPUS > 9
613
	CPU_ENUM(9),
614
#endif
615
#if NR_CPUS > 10
616
	CPU_ENUM(10),
617
#endif
618
#if NR_CPUS > 11
619
	CPU_ENUM(11),
620
#endif
621
#if NR_CPUS > 12
622
	CPU_ENUM(12),
623
#endif
624
#if NR_CPUS > 13
625
	CPU_ENUM(13),
626
#endif
627
#if NR_CPUS > 14
628
	CPU_ENUM(14),
629
#endif
630
#if NR_CPUS > 15
631
	CPU_ENUM(15),
632
#endif
633
#if NR_CPUS > 16
634
	CPU_ENUM(16),
635
#endif
636
#if NR_CPUS > 17
637
	CPU_ENUM(17),
638
#endif
639
#if NR_CPUS > 18
640
	CPU_ENUM(18),
641
#endif
642
#if NR_CPUS > 19
643
	CPU_ENUM(19),
644
#endif
645
#if NR_CPUS > 20
646
	CPU_ENUM(20),
647
#endif
648
#if NR_CPUS > 21
649
	CPU_ENUM(21),
650
#endif
651
#if NR_CPUS > 22
652
	CPU_ENUM(22),
653
#endif
654
#if NR_CPUS > 23
655
	CPU_ENUM(23),
656
#endif
657
#if NR_CPUS > 24
658
	CPU_ENUM(24),
659
#endif
660
#if NR_CPUS > 25
661
	CPU_ENUM(25),
662
#endif
663
#if NR_CPUS > 26
664
	CPU_ENUM(26),
665
#endif
666
#if NR_CPUS > 27
667
	CPU_ENUM(27),
668
#endif
669
#if NR_CPUS > 28
670
	CPU_ENUM(28),
671
#endif
672
#if NR_CPUS > 29
673
	CPU_ENUM(29),
674
#endif
675
#if NR_CPUS > 30
676
	CPU_ENUM(30),
677
#endif
678
#if NR_CPUS > 31
679
	CPU_ENUM(31),
680
#endif
681
#if NR_CPUS > 32
682
#error please extend CPU enumeration
683
#endif
684
	{
685
		.ctl_name	= 0,
686
	}
687
};
688
689
static ctl_table ctl_cpu[2] = {
690
	{
691
		.ctl_name	= CTL_CPU,
692
		.procname	= "cpu",
693
		.mode		= 0555,
694
		.child		= ctl_cpu_table,
695
	},
696
	{
697
		.ctl_name	= 0,
698
	}
699
};
700
701
struct ctl_table_header *cpufreq_sysctl_table;
702
703
static inline void cpufreq_sysctl_init(void)
704
{
705
	cpufreq_sysctl_table = register_sysctl_table(ctl_cpu, 0);
706
}
707
708
static inline void cpufreq_sysctl_exit(void)
709
{
710
	unregister_sysctl_table(cpufreq_sysctl_table);
711
}
712
713
#else
714
#define cpufreq_sysctl_init()
715
#define cpufreq_sysctl_exit()
716
#endif /* CONFIG_SYSCTL */
717
#endif /* CONFIG_CPU_FREQ_24_API */
718
719
720
721
/*********************************************************************
722
 *                     NOTIFIER LISTS INTERFACE                      *
723
 *********************************************************************/
724
725
/**
726
 *	cpufreq_register_notifier - register a driver with cpufreq
727
 *	@nb: notifier function to register
728
 *      @list: CPUFREQ_TRANSITION_NOTIFIER or CPUFREQ_POLICY_NOTIFIER
729
 *
730
 *	Add a driver to one of two lists: either a list of drivers that 
731
 *      are notified about clock rate changes (once before and once after
732
 *      the transition), or a list of drivers that are notified about
733
 *      changes in cpufreq policy.
734
 *
735
 *	This function may sleep, and has the same return conditions as
736
 *	notifier_chain_register.
737
 */
738
int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list)
739
{
740
	int ret;
741
742
	down(&cpufreq_notifier_sem);
743
	switch (list) {
744
	case CPUFREQ_TRANSITION_NOTIFIER:
745
		ret = notifier_chain_register(&cpufreq_transition_notifier_list, nb);
746
		break;
747
	case CPUFREQ_POLICY_NOTIFIER:
748
		ret = notifier_chain_register(&cpufreq_policy_notifier_list, nb);
749
		break;
750
	default:
751
		ret = -EINVAL;
752
	}
753
	up(&cpufreq_notifier_sem);
754
755
	return ret;
756
}
757
EXPORT_SYMBOL(cpufreq_register_notifier);
758
759
760
/**
761
 *	cpufreq_unregister_notifier - unregister a driver with cpufreq
762
 *	@nb: notifier block to be unregistered
763
 *      @list: CPUFREQ_TRANSITION_NOTIFIER or CPUFREQ_POLICY_NOTIFIER
764
 *
765
 *	Remove a driver from the CPU frequency notifier list.
766
 *
767
 *	This function may sleep, and has the same return conditions as
768
 *	notifier_chain_unregister.
769
 */
770
int cpufreq_unregister_notifier(struct notifier_block *nb, unsigned int list)
771
{
772
	int ret;
773
774
	down(&cpufreq_notifier_sem);
775
	switch (list) {
776
	case CPUFREQ_TRANSITION_NOTIFIER:
777
		ret = notifier_chain_unregister(&cpufreq_transition_notifier_list, nb);
778
		break;
779
	case CPUFREQ_POLICY_NOTIFIER:
780
		ret = notifier_chain_unregister(&cpufreq_policy_notifier_list, nb);
781
		break;
782
	default:
783
		ret = -EINVAL;
784
	}
785
	up(&cpufreq_notifier_sem);
786
787
	return ret;
788
}
789
EXPORT_SYMBOL(cpufreq_unregister_notifier);
790
791
792
793
/*********************************************************************
794
 *                          POLICY INTERFACE                         *
795
 *********************************************************************/
796
797
/**
798
 * cpufreq_get_policy - get the current cpufreq_policy
799
 * @policy: struct cpufreq_policy into which the current cpufreq_policy is written
800
 *
801
 * Reads the current cpufreq policy.
802
 */
803
int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu)
804
{
805
	down(&cpufreq_driver_sem);
806
	if (!cpufreq_driver  || !policy || 
807
	    (cpu >= NR_CPUS) || (!cpu_online(cpu))) {
808
		up(&cpufreq_driver_sem);
809
		return -EINVAL;
810
	}
811
	
812
	policy->min    = cpufreq_driver->policy[cpu].min;
813
	policy->max    = cpufreq_driver->policy[cpu].max;
814
	policy->policy = cpufreq_driver->policy[cpu].policy;
815
	policy->max_cpu_freq = cpufreq_driver->policy[cpu].max_cpu_freq;
816
	policy->cpu    = cpu;
817
818
	up(&cpufreq_driver_sem);
819
820
	return 0;
821
}
822
EXPORT_SYMBOL(cpufreq_get_policy);
823
824
825
/**
826
 *	cpufreq_set_policy - set a new CPUFreq policy
827
 *	@policy: policy to be set.
828
 *
829
 *	Sets a new CPU frequency and voltage scaling policy.
830
 */
831
int cpufreq_set_policy(struct cpufreq_policy *policy)
832
{
833
	unsigned int i;
834
	int ret;
835
836
	down(&cpufreq_driver_sem);
837
	if (!cpufreq_driver || !cpufreq_driver->verify || 
838
	    !cpufreq_driver->setpolicy || !policy ||
839
	    (policy->cpu > NR_CPUS)) {
840
		up(&cpufreq_driver_sem);
841
		return -EINVAL;
842
	}
843
844
	if (policy->cpu == CPUFREQ_ALL_CPUS)
845
		policy->max_cpu_freq = cpufreq_driver->policy[0].max_cpu_freq;
846
	else
847
		policy->max_cpu_freq = cpufreq_driver->policy[policy->cpu].max_cpu_freq;
848
849
850
	/* verify the cpu speed can be set within this limit */
851
	ret = cpufreq_driver->verify(policy);
852
	if (ret) {
853
		up(&cpufreq_driver_sem);
854
		return ret;
855
	}
856
857
	down(&cpufreq_notifier_sem);
858
859
	/* adjust if neccessary - all reasons */
860
	notifier_call_chain(&cpufreq_policy_notifier_list, CPUFREQ_ADJUST,
861
			    policy);
862
863
	/* adjust if neccessary - hardware incompatibility*/
864
	notifier_call_chain(&cpufreq_policy_notifier_list, CPUFREQ_INCOMPATIBLE,
865
			    policy);
866
867
	/* verify the cpu speed can be set within this limit,
868
	   which might be different to the first one */
869
	ret = cpufreq_driver->verify(policy);
870
	if (ret) {
871
		up(&cpufreq_notifier_sem);
872
		up(&cpufreq_driver_sem);
873
		return ret;
874
	}
875
876
	/* notification of the new policy */
877
	notifier_call_chain(&cpufreq_policy_notifier_list, CPUFREQ_NOTIFY,
878
			    policy);
879
880
	up(&cpufreq_notifier_sem);
881
882
	if (policy->cpu == CPUFREQ_ALL_CPUS) {
883
		for (i=0;i<NR_CPUS;i++) {
884
			cpufreq_driver->policy[i].min    = policy->min;
885
			cpufreq_driver->policy[i].max    = policy->max;
886
			cpufreq_driver->policy[i].policy = policy->policy;
887
		} 
888
	} else {
889
		cpufreq_driver->policy[policy->cpu].min    = policy->min;
890
		cpufreq_driver->policy[policy->cpu].max    = policy->max;
891
		cpufreq_driver->policy[policy->cpu].policy = policy->policy;
892
	}
893
894
#ifdef CONFIG_CPU_FREQ_24_API
895
	if (policy->cpu == CPUFREQ_ALL_CPUS) {
896
		for (i=0;i<NR_CPUS;i++)
897
			cpu_cur_freq[i] = policy->max;
898
	} else
899
		cpu_cur_freq[policy->cpu] = policy->max;
900
#endif
901
902
	ret = cpufreq_driver->setpolicy(policy);
903
	
904
	up(&cpufreq_driver_sem);
905
906
	return ret;
907
}
908
EXPORT_SYMBOL(cpufreq_set_policy);
909
910
911
912
/*********************************************************************
913
 *                    DYNAMIC CPUFREQ SWITCHING                      *
914
 *********************************************************************/
915
#ifdef CONFIG_CPU_FREQ_DYNAMIC
916
/* TBD */
917
#endif /* CONFIG_CPU_FREQ_DYNAMIC */
918
919
920
921
/*********************************************************************
922
 *            EXTERNALLY AFFECTING FREQUENCY CHANGES                 *
923
 *********************************************************************/
924
925
/**
926
 * adjust_jiffies - adjust the system "loops_per_jiffy"
927
 *
928
 * This function alters the system "loops_per_jiffy" for the clock
929
 * speed change. Note that loops_per_jiffy is only updated if all
930
 * CPUs are affected - else there is a need for per-CPU loops_per_jiffy
931
 * values which are provided by various architectures. 
932
 */
933
static inline void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci)
934
{
935
	if ((val == CPUFREQ_PRECHANGE  && ci->old < ci->new) ||
936
	    (val == CPUFREQ_POSTCHANGE && ci->old > ci->new))
937
		if (ci->cpu == CPUFREQ_ALL_CPUS)
938
			loops_per_jiffy = cpufreq_scale(loops_per_jiffy, ci->old, ci->new);
939
}
940
941
942
/**
943
 * cpufreq_notify_transition - call notifier chain and adjust_jiffies on frequency transition
944
 *
945
 * This function calls the transition notifiers and the "adjust_jiffies" function. It is called
946
 * twice on all CPU frequency changes that have external effects. 
947
 */
948
void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state)
949
{
950
	down(&cpufreq_notifier_sem);
951
	switch (state) {
952
	case CPUFREQ_PRECHANGE:
953
		notifier_call_chain(&cpufreq_transition_notifier_list, CPUFREQ_PRECHANGE, freqs);
954
		adjust_jiffies(CPUFREQ_PRECHANGE, freqs);		
955
		break;
956
	case CPUFREQ_POSTCHANGE:
957
		adjust_jiffies(CPUFREQ_POSTCHANGE, freqs);
958
		notifier_call_chain(&cpufreq_transition_notifier_list, CPUFREQ_POSTCHANGE, freqs);
959
#ifdef CONFIG_CPU_FREQ_24_API
960
		if (freqs->cpu == CPUFREQ_ALL_CPUS) {
961
			int i;
962
			for (i=0;i<NR_CPUS;i++)
963
				cpu_cur_freq[i] = freqs->new;
964
		} else
965
			cpu_cur_freq[freqs->cpu] = freqs->new;
966
#endif
967
		break;
968
	}
969
	up(&cpufreq_notifier_sem);
970
}
971
EXPORT_SYMBOL_GPL(cpufreq_notify_transition);
972
973
974
975
/*********************************************************************
976
 *               REGISTER / UNREGISTER CPUFREQ DRIVER                *
977
 *********************************************************************/
978
979
/**
980
 * cpufreq_register - register a CPU Frequency driver
981
 * @driver_data: A struct cpufreq_driver containing the values submitted by the CPU Frequency driver.
982
 *
983
 *   Registers a CPU Frequency driver to this core code. This code 
984
 * returns zero on success, -EBUSY when another driver got here first
985
 * (and isn't unregistered in the meantime). 
986
 *
987
 */
988
int cpufreq_register(struct cpufreq_driver *driver_data)
989
{
990
	unsigned int            ret;
991
	unsigned int            i;
992
	struct cpufreq_policy   policy;
993
994
	if (cpufreq_driver)
995
		return -EBUSY;
996
	
997
	if (!driver_data || !driver_data->verify || 
998
	    !driver_data->setpolicy)
999
		return -EINVAL;
1000
1001
	down(&cpufreq_driver_sem);
1002
	cpufreq_driver        = driver_data;
1003
	
1004
	/* check for a default policy - if it exists, use it on _all_ CPUs*/
1005
	for (i=0; i<NR_CPUS; i++)
1006
	{
1007
		if (default_policy.policy)
1008
			cpufreq_driver->policy[i].policy = default_policy.policy;
1009
		if (default_policy.min)
1010
			cpufreq_driver->policy[i].min = default_policy.min;
1011
		if (default_policy.max)
1012
			cpufreq_driver->policy[i].max = default_policy.max;
1013
	}
1014
1015
	/* set default policy on all CPUs. Must be called per-CPU and not
1016
	 * with CPUFREQ_ALL_CPUs as there might be no common policy for all
1017
	 * CPUs (UltraSPARC etc.)
1018
	 */
1019
	for (i=0; i<NR_CPUS; i++)
1020
	{
1021
		policy.policy = cpufreq_driver->policy[i].policy;
1022
		policy.min    = cpufreq_driver->policy[i].min;
1023
		policy.max    = cpufreq_driver->policy[i].max;
1024
		policy.cpu    = i;
1025
		up(&cpufreq_driver_sem);
1026
		ret = cpufreq_set_policy(&policy);
1027
		down(&cpufreq_driver_sem);
1028
		if (ret) {
1029
			cpufreq_driver = NULL;
1030
			up(&cpufreq_driver_sem);
1031
			return ret;
1032
		}
1033
	}
1034
1035
	up(&cpufreq_driver_sem);
1036
1037
	cpufreq_proc_init();
1038
1039
#ifdef CONFIG_CPU_FREQ_24_API
1040
 	down(&cpufreq_driver_sem);
1041
	for (i=0; i<NR_CPUS; i++) 
1042
	{
1043
		cpu_min_freq[i] = driver_data->cpu_min_freq[i];
1044
		cpu_max_freq[i] = driver_data->policy[i].max_cpu_freq;
1045
		cpu_cur_freq[i] = driver_data->cpu_cur_freq[i];
1046
	}
1047
	up(&cpufreq_driver_sem);
1048
1049
	cpufreq_sysctl_init();
1050
#endif
1051
1052
	return 0;
1053
}
1054
EXPORT_SYMBOL_GPL(cpufreq_register);
1055
1056
1057
/**
1058
 * cpufreq_unregister - unregister the current CPUFreq driver
1059
 *
1060
 *    Unregister the current CPUFreq driver. Only call this if you have 
1061
 * the right to do so, i.e. if you have succeeded in initialising before!
1062
 * Returns zero if successful, and -EINVAL if the cpufreq_driver is
1063
 * currently not initialised.
1064
 */
1065
int cpufreq_unregister(void)
1066
{
1067
	down(&cpufreq_driver_sem);
1068
1069
	if (!cpufreq_driver) {
1070
		up(&cpufreq_driver_sem);
1071
		return -EINVAL;
1072
	}
1073
1074
	cpufreq_driver = NULL;
1075
1076
	up(&cpufreq_driver_sem);
1077
1078
	cpufreq_proc_exit();
1079
1080
#ifdef CONFIG_CPU_FREQ_24_API
1081
	cpufreq_sysctl_exit();
1082
#endif
1083
1084
	return 0;
1085
}
1086
EXPORT_SYMBOL_GPL(cpufreq_unregister);
1087
1088
1089
#ifdef CONFIG_PM
1090
/**
1091
 *	cpufreq_restore - restore the CPU clock frequency after resume
1092
 *
1093
 *	Restore the CPU clock frequency so that our idea of the current
1094
 *	frequency reflects the actual hardware.
1095
 */
1096
int cpufreq_restore(void)
1097
{
1098
	struct cpufreq_policy policy;
1099
	unsigned int i;
1100
	unsigned int ret = 0;
1101
1102
	if (in_interrupt())
1103
		panic("cpufreq_restore() called from interrupt context!");
1104
1105
	for (i=0;i<NR_CPUS;i++) {
1106
		if (!cpu_online(i))
1107
			continue;
1108
1109
		down(&cpufreq_driver_sem);
1110
		if (!cpufreq_driver) {
1111
			up(&cpufreq_driver_sem);
1112
			return 0;
1113
		}
1114
	
1115
		policy.min    = cpufreq_driver->policy[i].min;
1116
		policy.max    = cpufreq_driver->policy[i].max;
1117
		policy.policy = cpufreq_driver->policy[i].policy;
1118
		policy.cpu    = i;
1119
		up(&cpufreq_driver_sem);
1120
1121
		ret += cpufreq_set_policy(&policy);
1122
	}
1123
1124
	return ret;
1125
}
1126
EXPORT_SYMBOL_GPL(cpufreq_restore);
1127
#else
1128
#define cpufreq_restore()
1129
#endif /* CONFIG_PM */
1130
(-)linux-2.4.22/kernel/panic.c (+4 lines)
Lines 48-53 Link Here
48
#if defined(CONFIG_ARCH_S390)
48
#if defined(CONFIG_ARCH_S390)
49
        unsigned long caller = (unsigned long) __builtin_return_address(0);
49
        unsigned long caller = (unsigned long) __builtin_return_address(0);
50
#endif
50
#endif
51
#ifdef CONFIG_BOOTX_TEXT
52
	extern int force_printk_to_btext;
53
	force_printk_to_btext = 1;
54
#endif
51
55
52
	bust_spinlocks(1);
56
	bust_spinlocks(1);
53
	va_start(args, fmt);
57
	va_start(args, fmt);
(-)linux-2.4.22/kernel/printk.c (-2 / +10 lines)
Lines 26-32 Link Here
26
#include <linux/module.h>
26
#include <linux/module.h>
27
#include <linux/interrupt.h>			/* For in_interrupt() */
27
#include <linux/interrupt.h>			/* For in_interrupt() */
28
#include <linux/config.h>
28
#include <linux/config.h>
29
29
#ifdef CONFIG_BOOTX_TEXT
30
#include <asm/btext.h>
31
#endif
30
#include <asm/uaccess.h>
32
#include <asm/uaccess.h>
31
33
32
#if defined(CONFIG_MULTIQUAD) || defined(CONFIG_IA64)
34
#if defined(CONFIG_MULTIQUAD) || defined(CONFIG_IA64)
Lines 412-417 Link Here
412
	char *p;
414
	char *p;
413
	static char printk_buf[1024];
415
	static char printk_buf[1024];
414
	static int log_level_unknown = 1;
416
	static int log_level_unknown = 1;
417
#ifdef CONFIG_BOOTX_TEXT
418
	extern int force_printk_to_btext;
419
#endif
415
420
416
	if (oops_in_progress) {
421
	if (oops_in_progress) {
417
		/* If a crash is occurring, make sure we can't deadlock */
422
		/* If a crash is occurring, make sure we can't deadlock */
Lines 427-433 Link Here
427
	va_start(args, fmt);
432
	va_start(args, fmt);
428
	printed_len = vsnprintf(printk_buf, sizeof(printk_buf), fmt, args);
433
	printed_len = vsnprintf(printk_buf, sizeof(printk_buf), fmt, args);
429
	va_end(args);
434
	va_end(args);
430
435
#ifdef CONFIG_BOOTX_TEXT
436
	if (force_printk_to_btext)
437
		btext_drawstring(printk_buf);
438
#endif /* CONFIG_BOOTX_TEXT */
431
	/*
439
	/*
432
	 * Copy the output into log_buf.  If the caller didn't provide
440
	 * Copy the output into log_buf.  If the caller didn't provide
433
	 * appropriate log level tags, we insert them here
441
	 * appropriate log level tags, we insert them here
(-)linux-2.4.22/kernel/resource.c (+5 lines)
Lines 118-123 Link Here
118
	write_lock(&resource_lock);
118
	write_lock(&resource_lock);
119
	conflict = __request_resource(root, new);
119
	conflict = __request_resource(root, new);
120
	write_unlock(&resource_lock);
120
	write_unlock(&resource_lock);
121
	if (conflict) {
122
		printk("resource conflict with: %lx..%lx (%lx), name: %s\n",
123
			conflict->start, conflict->end, conflict->flags,
124
			conflict->name ? conflict->name : "<NULL>");
125
	}
121
	return conflict ? -EBUSY : 0;
126
	return conflict ? -EBUSY : 0;
122
}
127
}
123
128
(-)linux-2.4.22/kernel/sysctl.c (+8 lines)
Lines 51-56 Link Here
51
extern int core_uses_pid;
51
extern int core_uses_pid;
52
extern char core_pattern[];
52
extern char core_pattern[];
53
extern int cad_pid;
53
extern int cad_pid;
54
extern int laptop_mode;
55
extern int block_dump;
54
56
55
/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
57
/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
56
static int maxolduid = 65535;
58
static int maxolduid = 65535;
Lines 284-295 Link Here
284
	 &pgt_cache_water, 2*sizeof(int), 0644, NULL, &proc_dointvec},
286
	 &pgt_cache_water, 2*sizeof(int), 0644, NULL, &proc_dointvec},
285
	{VM_PAGE_CLUSTER, "page-cluster", 
287
	{VM_PAGE_CLUSTER, "page-cluster", 
286
	 &page_cluster, sizeof(int), 0644, NULL, &proc_dointvec},
288
	 &page_cluster, sizeof(int), 0644, NULL, &proc_dointvec},
289
	{VM_HEAP_STACK_GAP, "heap-stack-gap", 
290
	 &heap_stack_gap, sizeof(int), 0644, NULL, &proc_dointvec},
287
	{VM_MIN_READAHEAD, "min-readahead",
291
	{VM_MIN_READAHEAD, "min-readahead",
288
	&vm_min_readahead,sizeof(int), 0644, NULL, &proc_dointvec},
292
	&vm_min_readahead,sizeof(int), 0644, NULL, &proc_dointvec},
289
	{VM_MAX_READAHEAD, "max-readahead",
293
	{VM_MAX_READAHEAD, "max-readahead",
290
	&vm_max_readahead,sizeof(int), 0644, NULL, &proc_dointvec},
294
	&vm_max_readahead,sizeof(int), 0644, NULL, &proc_dointvec},
291
	{VM_MAX_MAP_COUNT, "max_map_count",
295
	{VM_MAX_MAP_COUNT, "max_map_count",
292
	 &max_map_count, sizeof(int), 0644, NULL, &proc_dointvec},
296
	 &max_map_count, sizeof(int), 0644, NULL, &proc_dointvec},
297
	{VM_LAPTOP_MODE, "laptop_mode",
298
	 &laptop_mode, sizeof(int), 0644, NULL, &proc_dointvec},
299
	{VM_BLOCK_DUMP, "block_dump",
300
	 &block_dump, sizeof(int), 0644, NULL, &proc_dointvec},
293
	{0}
301
	{0}
294
};
302
};
295
303
(-)linux-2.4.22/mm/filemap.c (+2 lines)
Lines 165-170 Link Here
165
165
166
			if (mapping && mapping->host)
166
			if (mapping && mapping->host)
167
				mark_inode_dirty_pages(mapping->host);
167
				mark_inode_dirty_pages(mapping->host);
168
			if (block_dump)
169
				printk("%s: dirtied page\n", current->comm);
168
		}
170
		}
169
	}
171
	}
170
}
172
}
(-)linux-2.4.22/mm/mmap.c (-3 / +11 lines)
Lines 45-50 Link Here
45
};
45
};
46
46
47
int sysctl_overcommit_memory;
47
int sysctl_overcommit_memory;
48
int heap_stack_gap = 1;
48
int max_map_count = DEFAULT_MAX_MAP_COUNT;
49
int max_map_count = DEFAULT_MAX_MAP_COUNT;
49
50
50
/* Check that a process has enough memory to allocate a
51
/* Check that a process has enough memory to allocate a
Lines 630-638 Link Here
630
631
631
	for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) {
632
	for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) {
632
		/* At this point:  (!vma || addr < vma->vm_end). */
633
		/* At this point:  (!vma || addr < vma->vm_end). */
634
		unsigned long __heap_stack_gap;
633
		if (TASK_SIZE - len < addr)
635
		if (TASK_SIZE - len < addr)
634
			return -ENOMEM;
636
			return -ENOMEM;
635
		if (!vma || addr + len <= vma->vm_start)
637
		if (!vma)
638
			return addr;
639
		__heap_stack_gap = 0;
640
		if (vma->vm_flags & VM_GROWSDOWN)
641
			__heap_stack_gap = heap_stack_gap << PAGE_SHIFT;
642
		if (addr + len + __heap_stack_gap <= vma->vm_start)
636
			return addr;
643
			return addr;
637
		addr = vma->vm_end;
644
		addr = vma->vm_end;
638
	}
645
	}
Lines 741-747 Link Here
741
748
742
struct vm_area_struct * find_extend_vma(struct mm_struct * mm, unsigned long addr)
749
struct vm_area_struct * find_extend_vma(struct mm_struct * mm, unsigned long addr)
743
{
750
{
744
	struct vm_area_struct * vma;
751
	struct vm_area_struct * vma, * prev_vma;
745
	unsigned long start;
752
	unsigned long start;
746
753
747
	addr &= PAGE_MASK;
754
	addr &= PAGE_MASK;
Lines 753-759 Link Here
753
	if (!(vma->vm_flags & VM_GROWSDOWN))
760
	if (!(vma->vm_flags & VM_GROWSDOWN))
754
		return NULL;
761
		return NULL;
755
	start = vma->vm_start;
762
	start = vma->vm_start;
756
	if (expand_stack(vma, addr))
763
	find_vma_prev(mm, addr, &prev_vma);
764
	if (expand_stack(vma, addr, prev_vma))
757
		return NULL;
765
		return NULL;
758
	if (vma->vm_flags & VM_LOCKED) {
766
	if (vma->vm_flags & VM_LOCKED) {
759
		make_pages_present(addr, start);
767
		make_pages_present(addr, start);

Return to bug 35819