aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin
diff options
context:
space:
mode:
authorBryan Wu <bryan.wu@analog.com>2007-05-06 17:50:22 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-07 15:12:58 -0400
commit1394f03221790a988afc3e4b3cb79f2e477246a9 (patch)
tree2c1963c9a4f2d84a5e021307fde240c5d567cf70 /arch/blackfin
parent73243284463a761e04d69d22c7516b2be7de096c (diff)
blackfin architecture
This adds support for the Analog Devices Blackfin processor architecture, and currently supports the BF533, BF532, BF531, BF537, BF536, BF534, and BF561 (Dual Core) devices, with a variety of development platforms including those avaliable from Analog Devices (BF533-EZKit, BF533-STAMP, BF537-STAMP, BF561-EZKIT), and Bluetechnix! Tinyboards. The Blackfin architecture was jointly developed by Intel and Analog Devices Inc. (ADI) as the Micro Signal Architecture (MSA) core and introduced it in December of 2000. Since then ADI has put this core into its Blackfin processor family of devices. The Blackfin core has the advantages of a clean, orthogonal,RISC-like microprocessor instruction set. It combines a dual-MAC (Multiply/Accumulate), state-of-the-art signal processing engine and single-instruction, multiple-data (SIMD) multimedia capabilities into a single instruction-set architecture. The Blackfin architecture, including the instruction set, is described by the ADSP-BF53x/BF56x Blackfin Processor Programming Reference http://blackfin.uclinux.org/gf/download/frsrelease/29/2549/Blackfin_PRM.pdf The Blackfin processor is already supported by major releases of gcc, and there are binary and source rpms/tarballs for many architectures at: http://blackfin.uclinux.org/gf/project/toolchain/frs There is complete documentation, including "getting started" guides available at: http://docs.blackfin.uclinux.org/ which provides links to the sources and patches you will need in order to set up a cross-compiling environment for bfin-linux-uclibc This patch, as well as the other patches (toolchain, distribution, uClibc) are actively supported by Analog Devices Inc, at: http://blackfin.uclinux.org/ We have tested this on LTP, and our test plan (including pass/fails) can be found at: http://docs.blackfin.uclinux.org/doku.php?id=testing_the_linux_kernel [m.kozlowski@tuxland.pl: balance parenthesis in blackfin header files] Signed-off-by: Bryan Wu <bryan.wu@analog.com> Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl> Signed-off-by: Aubrey Li <aubrey.li@analog.com> Signed-off-by: Jie Zhang <jie.zhang@analog.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/blackfin')
-rw-r--r--arch/blackfin/Kconfig989
-rw-r--r--arch/blackfin/Makefile80
-rw-r--r--arch/blackfin/boot/Makefile27
-rw-r--r--arch/blackfin/defconfig1314
-rw-r--r--arch/blackfin/kernel/Makefile14
-rw-r--r--arch/blackfin/kernel/asm-offsets.c136
-rw-r--r--arch/blackfin/kernel/bfin_dma_5xx.c742
-rw-r--r--arch/blackfin/kernel/bfin_gpio.c637
-rw-r--r--arch/blackfin/kernel/bfin_ksyms.c119
-rw-r--r--arch/blackfin/kernel/dma-mapping.c183
-rw-r--r--arch/blackfin/kernel/dualcore_test.c49
-rw-r--r--arch/blackfin/kernel/entry.S94
-rw-r--r--arch/blackfin/kernel/flat.c101
-rw-r--r--arch/blackfin/kernel/init_task.c60
-rw-r--r--arch/blackfin/kernel/irqchip.c147
-rw-r--r--arch/blackfin/kernel/module.c429
-rw-r--r--arch/blackfin/kernel/process.c394
-rw-r--r--arch/blackfin/kernel/ptrace.c430
-rw-r--r--arch/blackfin/kernel/setup.c902
-rw-r--r--arch/blackfin/kernel/signal.c356
-rw-r--r--arch/blackfin/kernel/sys_bfin.c115
-rw-r--r--arch/blackfin/kernel/time.c326
-rw-r--r--arch/blackfin/kernel/traps.c649
-rw-r--r--arch/blackfin/kernel/vmlinux.lds.S228
-rw-r--r--arch/blackfin/lib/Makefile11
-rw-r--r--arch/blackfin/lib/ashldi3.c58
-rw-r--r--arch/blackfin/lib/ashrdi3.c59
-rw-r--r--arch/blackfin/lib/checksum.c140
-rw-r--r--arch/blackfin/lib/divsi3.S216
-rw-r--r--arch/blackfin/lib/gcclib.h47
-rw-r--r--arch/blackfin/lib/ins.S69
-rw-r--r--arch/blackfin/lib/lshrdi3.c72
-rw-r--r--arch/blackfin/lib/memchr.S70
-rw-r--r--arch/blackfin/lib/memcmp.S110
-rw-r--r--arch/blackfin/lib/memcpy.S142
-rw-r--r--arch/blackfin/lib/memmove.S103
-rw-r--r--arch/blackfin/lib/memset.S109
-rw-r--r--arch/blackfin/lib/modsi3.S79
-rw-r--r--arch/blackfin/lib/muldi3.c99
-rw-r--r--arch/blackfin/lib/outs.S62
-rw-r--r--arch/blackfin/lib/smulsi3_highpart.S30
-rw-r--r--arch/blackfin/lib/strcmp.c11
-rw-r--r--arch/blackfin/lib/strcpy.c11
-rw-r--r--arch/blackfin/lib/strncmp.c11
-rw-r--r--arch/blackfin/lib/strncpy.c11
-rw-r--r--arch/blackfin/lib/udivsi3.S298
-rw-r--r--arch/blackfin/lib/umodsi3.S66
-rw-r--r--arch/blackfin/lib/umulsi3_highpart.S23
-rw-r--r--arch/blackfin/mach-bf533/Kconfig92
-rw-r--r--arch/blackfin/mach-bf533/Makefile9
-rw-r--r--arch/blackfin/mach-bf533/boards/Makefile8
-rw-r--r--arch/blackfin/mach-bf533/boards/cm_bf533.c267
-rw-r--r--arch/blackfin/mach-bf533/boards/ezkit.c224
-rw-r--r--arch/blackfin/mach-bf533/boards/generic_board.c95
-rw-r--r--arch/blackfin/mach-bf533/boards/stamp.c321
-rw-r--r--arch/blackfin/mach-bf533/cpu.c161
-rw-r--r--arch/blackfin/mach-bf533/head.S774
-rw-r--r--arch/blackfin/mach-bf533/ints-priority.c65
-rw-r--r--arch/blackfin/mach-bf537/Kconfig141
-rw-r--r--arch/blackfin/mach-bf537/Makefile9
-rw-r--r--arch/blackfin/mach-bf537/boards/Makefile9
-rw-r--r--arch/blackfin/mach-bf537/boards/cm_bf537.c364
-rw-r--r--arch/blackfin/mach-bf537/boards/eth_mac.c51
-rw-r--r--arch/blackfin/mach-bf537/boards/generic_board.c445
-rw-r--r--arch/blackfin/mach-bf537/boards/led.S183
-rw-r--r--arch/blackfin/mach-bf537/boards/pnav10.c523
-rw-r--r--arch/blackfin/mach-bf537/boards/stamp.c615
-rw-r--r--arch/blackfin/mach-bf537/cpu.c161
-rw-r--r--arch/blackfin/mach-bf537/head.S602
-rw-r--r--arch/blackfin/mach-bf537/ints-priority.c74
-rw-r--r--arch/blackfin/mach-bf561/Kconfig222
-rw-r--r--arch/blackfin/mach-bf561/Makefile9
-rw-r--r--arch/blackfin/mach-bf561/boards/Makefile7
-rw-r--r--arch/blackfin/mach-bf561/boards/cm_bf561.c289
-rw-r--r--arch/blackfin/mach-bf561/boards/ezkit.c147
-rw-r--r--arch/blackfin/mach-bf561/boards/generic_board.c82
-rw-r--r--arch/blackfin/mach-bf561/coreb.c402
-rw-r--r--arch/blackfin/mach-bf561/head.S512
-rw-r--r--arch/blackfin/mach-bf561/ints-priority.c108
-rw-r--r--arch/blackfin/mach-common/Makefile12
-rw-r--r--arch/blackfin/mach-common/cache.S253
-rw-r--r--arch/blackfin/mach-common/cacheinit.S137
-rw-r--r--arch/blackfin/mach-common/cplbhdlr.S130
-rw-r--r--arch/blackfin/mach-common/cplbinfo.c211
-rw-r--r--arch/blackfin/mach-common/cplbmgr.S607
-rw-r--r--arch/blackfin/mach-common/dpmc.S418
-rw-r--r--arch/blackfin/mach-common/entry.S1207
-rw-r--r--arch/blackfin/mach-common/interrupt.S253
-rw-r--r--arch/blackfin/mach-common/ints-priority-dc.c476
-rw-r--r--arch/blackfin/mach-common/ints-priority-sc.c577
-rw-r--r--arch/blackfin/mach-common/irqpanic.c194
-rw-r--r--arch/blackfin/mach-common/lock.S204
-rw-r--r--arch/blackfin/mach-common/pm.c181
-rw-r--r--arch/blackfin/mm/Makefile5
-rw-r--r--arch/blackfin/mm/blackfin_sram.c540
-rw-r--r--arch/blackfin/mm/blackfin_sram.h38
-rw-r--r--arch/blackfin/mm/init.c208
-rw-r--r--arch/blackfin/oprofile/Kconfig29
-rw-r--r--arch/blackfin/oprofile/Makefile14
-rw-r--r--arch/blackfin/oprofile/common.c168
-rw-r--r--arch/blackfin/oprofile/op_blackfin.h98
-rw-r--r--arch/blackfin/oprofile/op_model_bf533.c161
-rw-r--r--arch/blackfin/oprofile/timer_int.c74
103 files changed, 23594 insertions, 0 deletions
diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
new file mode 100644
index 000000000000..1a4930509325
--- /dev/null
+++ b/arch/blackfin/Kconfig
@@ -0,0 +1,989 @@
1#
2# For a description of the syntax of this configuration file,
3# see Documentation/kbuild/kconfig-language.txt.
4#
5
6mainmenu "uClinux/Blackfin (w/o MMU) Kernel Configuration"
7
8config MMU
9 bool
10 default n
11
12config FPU
13 bool
14 default n
15
16config RWSEM_GENERIC_SPINLOCK
17 bool
18 default y
19
20config RWSEM_XCHGADD_ALGORITHM
21 bool
22 default n
23
24config BLACKFIN
25 bool
26 default y
27
28config BFIN
29 bool
30 default y
31
32config SEMAPHORE_SLEEPERS
33 bool
34 default y
35
36config GENERIC_FIND_NEXT_BIT
37 bool
38 default y
39
40config GENERIC_HWEIGHT
41 bool
42 default y
43
44config GENERIC_HARDIRQS
45 bool
46 default y
47
48config GENERIC_IRQ_PROBE
49 bool
50 default y
51
52config GENERIC_TIME
53 bool
54 default n
55
56config GENERIC_CALIBRATE_DELAY
57 bool
58 default y
59
60config FORCE_MAX_ZONEORDER
61 int
62 default "14"
63
64config GENERIC_CALIBRATE_DELAY
65 bool
66 default y
67
68config IRQCHIP_DEMUX_GPIO
69 bool
70 default y
71
72source "init/Kconfig"
73source "kernel/Kconfig.preempt"
74
75menu "Blackfin Processor Options"
76
77comment "Processor and Board Settings"
78
79choice
80 prompt "CPU"
81 default BF533
82
83config BF531
84 bool "BF531"
85 help
86 BF531 Processor Support.
87
88config BF532
89 bool "BF532"
90 help
91 BF532 Processor Support.
92
93config BF533
94 bool "BF533"
95 help
96 BF533 Processor Support.
97
98config BF534
99 bool "BF534"
100 help
101 BF534 Processor Support.
102
103config BF536
104 bool "BF536"
105 help
106 BF536 Processor Support.
107
108config BF537
109 bool "BF537"
110 help
111 BF537 Processor Support.
112
113config BF561
114 bool "BF561"
115 help
116 Not Supported Yet - Work in progress - BF561 Processor Support.
117
118endchoice
119
120choice
121 prompt "Silicon Rev"
122 default BF_REV_0_2 if BF537
123 default BF_REV_0_3 if BF533
124
125config BF_REV_0_2
126 bool "0.2"
127 depends on (BF537 || BF536 || BF534)
128
129config BF_REV_0_3
130 bool "0.3"
131 depends on (BF561 || BF537 || BF536 || BF534 || BF533 || BF532 || BF531)
132
133config BF_REV_0_4
134 bool "0.4"
135 depends on (BF561 || BF533 || BF532 || BF531)
136
137config BF_REV_0_5
138 bool "0.5"
139 depends on (BF561 || BF533 || BF532 || BF531)
140
141endchoice
142
143config BFIN_DUAL_CORE
144 bool
145 depends on (BF561)
146 default y
147
148config BFIN_SINGLE_CORE
149 bool
150 depends on !BFIN_DUAL_CORE
151 default y
152
153choice
154 prompt "System type"
155 default BFIN533_STAMP
156 help
157 Do NOT change the board here. Please use the top level
158 configuration to ensure that all the other settings are
159 correct.
160
161config BFIN533_EZKIT
162 bool "BF533-EZKIT"
163 depends on (BF533 || BF532 || BF531)
164 help
165 BF533-EZKIT-LITE board Support.
166
167config BFIN533_STAMP
168 bool "BF533-STAMP"
169 depends on (BF533 || BF532 || BF531)
170 help
171 BF533-STAMP board Support.
172
173config BFIN537_STAMP
174 bool "BF537-STAMP"
175 depends on (BF537 || BF536 || BF534)
176 help
177 BF537-STAMP board Support.
178
179config BFIN533_BLUETECHNIX_CM
180 bool "Bluetechnix CM-BF533"
181 depends on (BF533)
182 help
183 CM-BF533 support for EVAL- and DEV-Board.
184
185config BFIN537_BLUETECHNIX_CM
186 bool "Bluetechnix CM-BF537"
187 depends on (BF537)
188 help
189 CM-BF537 support for EVAL- and DEV-Board.
190
191config BFIN561_BLUETECHNIX_CM
192 bool "BF561-CM"
193 depends on (BF561)
194 help
195 CM-BF561 support for EVAL- and DEV-Board.
196
197config BFIN561_EZKIT
198 bool "BF561-EZKIT"
199 depends on (BF561)
200 help
201 BF561-EZKIT-LITE board Support.
202
203config PNAV10
204 bool "PNAV 1.0 board"
205 depends on (BF537)
206 help
207 PNAV 1.0 board Support.
208
209config GENERIC_BOARD
210 bool "Custom"
211 depends on (BF537 || BF536 \
212 || BF534 || BF561 || BF535 || BF533 || BF532 || BF531)
213 help
214 GENERIC or Custom board Support.
215
216endchoice
217
218config MEM_GENERIC_BOARD
219 bool
220 depends on GENERIC_BOARD
221 default y
222
223config MEM_MT48LC64M4A2FB_7E
224 bool
225 depends on (BFIN533_STAMP)
226 default y
227
228config MEM_MT48LC16M16A2TG_75
229 bool
230 depends on (BFIN533_EZKIT || BFIN561_EZKIT \
231 || BFIN533_BLUETECHNIX_CM || BFIN537_BLUETECHNIX_CM)
232 default y
233
234config MEM_MT48LC32M8A2_75
235 bool
236 depends on (BFIN537_STAMP || PNAV10)
237 default y
238
239config MEM_MT48LC8M32B2B5_7
240 bool
241 depends on (BFIN561_BLUETECHNIX_CM)
242 default y
243
244config BFIN_SHARED_FLASH_ENET
245 bool
246 depends on (BFIN533_STAMP)
247 default y
248
249source "arch/blackfin/mach-bf533/Kconfig"
250source "arch/blackfin/mach-bf561/Kconfig"
251source "arch/blackfin/mach-bf537/Kconfig"
252
253menu "Board customizations"
254
255config CMDLINE_BOOL
256 bool "Default bootloader kernel arguments"
257
258config CMDLINE
259 string "Initial kernel command string"
260 depends on CMDLINE_BOOL
261 default "console=ttyBF0,57600"
262 help
263 If you don't have a boot loader capable of passing a command line string
264 to the kernel, you may specify one here. As a minimum, you should specify
265 the memory size and the root device (e.g., mem=8M, root=/dev/nfs).
266
267comment "Board Setup"
268
269config CLKIN_HZ
270 int "Crystal Frequency in Hz"
271 default "11059200" if BFIN533_STAMP
272 default "27000000" if BFIN533_EZKIT
273 default "25000000" if BFIN537_STAMP
274 default "30000000" if BFIN561_EZKIT
275 default "24576000" if PNAV10
276 help
277 The frequency of CLKIN crystal oscillator on the board in Hz.
278
279config MEM_SIZE
280 int "SDRAM Memory Size in MBytes"
281 default 32 if BFIN533_EZKIT
282 default 64 if BFIN537_STAMP
283 default 64 if BFIN561_EZKIT
284 default 128 if BFIN533_STAMP
285 default 64 if PNAV10
286
287config MEM_ADD_WIDTH
288 int "SDRAM Memory Address Width"
289 default 9 if BFIN533_EZKIT
290 default 9 if BFIN561_EZKIT
291 default 10 if BFIN537_STAMP
292 default 11 if BFIN533_STAMP
293 default 10 if PNAV10
294
295config ENET_FLASH_PIN
296 int "PF port/pin used for flash and ethernet sharing"
297 depends on (BFIN533_STAMP)
298 default 0
299 help
300 PF port/pin used for flash and ethernet sharing to allow other PF
301 pins to be used on other platforms without having to touch common
302 code.
303 For example: PF0 --> 0,PF1 --> 1,PF2 --> 2, etc.
304
305config BOOT_LOAD
306 hex "Kernel load address for booting"
307 default "0x1000"
308 help
309 This option allows you to set the load address of the kernel.
310 This can be useful if you are on a board which has a small amount
311 of memory or you wish to reserve some memory at the beginning of
312 the address space.
313
314 Note that you generally want to keep this value at or above 4k
315 (0x1000) as this will allow the kernel to capture NULL pointer
316 references.
317
318comment "LED Status Indicators"
319 depends on (BFIN533_STAMP || BFIN533_BLUETECHNIX_CM)
320
321config BFIN_ALIVE_LED
322 bool "Enable Board Alive"
323 depends on (BFIN533_STAMP || BFIN533_BLUETECHNIX_CM)
324 default n
325 help
326 Blink the LEDs you select when the kernel is running. Helps detect
327 a hung kernel.
328
329config BFIN_ALIVE_LED_NUM
330 int "LED"
331 depends on BFIN_ALIVE_LED
332 range 1 3 if BFIN533_STAMP
333 default "3" if BFIN533_STAMP
334 help
335 Select the LED (marked on the board) for you to blink.
336
337config BFIN_IDLE_LED
338 bool "Enable System Load/Idle LED"
339 depends on (BFIN533_STAMP || BFIN533_BLUETECHNIX_CM)
340 default n
341 help
342 Blinks the LED you select when to determine kernel load.
343
344config BFIN_IDLE_LED_NUM
345 int "LED"
346 depends on BFIN_IDLE_LED
347 range 1 3 if BFIN533_STAMP
348 default "2" if BFIN533_STAMP
349 help
350 Select the LED (marked on the board) for you to blink.
351
352#
353# Sorry - but you need to put the hex address here -
354#
355
356# Flag Data register
357config BFIN_ALIVE_LED_PORT
358 hex
359 default 0xFFC00700 if (BFIN533_STAMP)
360
361# Peripheral Flag Direction Register
362config BFIN_ALIVE_LED_DPORT
363 hex
364 default 0xFFC00730 if (BFIN533_STAMP)
365
366config BFIN_ALIVE_LED_PIN
367 hex
368 default 0x04 if (BFIN533_STAMP && BFIN_ALIVE_LED_NUM = 1)
369 default 0x08 if (BFIN533_STAMP && BFIN_ALIVE_LED_NUM = 2)
370 default 0x10 if (BFIN533_STAMP && BFIN_ALIVE_LED_NUM = 3)
371
372config BFIN_IDLE_LED_PORT
373 hex
374 default 0xFFC00700 if (BFIN533_STAMP)
375
376# Peripheral Flag Direction Register
377config BFIN_IDLE_LED_DPORT
378 hex
379 default 0xFFC00730 if (BFIN533_STAMP)
380
381config BFIN_IDLE_LED_PIN
382 hex
383 default 0x04 if (BFIN533_STAMP && BFIN_IDLE_LED_NUM = 1)
384 default 0x08 if (BFIN533_STAMP && BFIN_IDLE_LED_NUM = 2)
385 default 0x10 if (BFIN533_STAMP && BFIN_IDLE_LED_NUM = 3)
386
387comment "Console UART Setup"
388
389choice
390 prompt "Baud Rate"
391 default BAUD_57600
392config BAUD_9600
393 bool "9600"
394config BAUD_19200
395 bool "19200"
396config BAUD_38400
397 bool "38400"
398config BAUD_57600
399 bool "57600"
400config BAUD_115200
401 bool "115200"
402endchoice
403
404choice
405 prompt "Parity"
406 default BAUD_NO_PARITY
407config BAUD_NO_PARITY
408 bool "No Parity"
409config BAUD_PARITY
410 bool "Parity"
411endchoice
412
413choice
414 prompt "Stop Bits"
415 default BAUD_1_STOPBIT
416config BAUD_1_STOPBIT
417 bool "1"
418config BAUD_2_STOPBIT
419 bool "2"
420endchoice
421
422endmenu
423
424
425menu "Blackfin Kernel Optimizations"
426
427comment "Timer Tick"
428
429source kernel/Kconfig.hz
430
431comment "Memory Optimizations"
432
433config I_ENTRY_L1
434 bool "Locate interrupt entry code in L1 Memory"
435 default y
436 help
437 If enabled interrupt entry code (STORE/RESTORE CONTEXT) is linked
438 into L1 instruction memory.(less latency)
439
440config EXCPT_IRQ_SYSC_L1
441 bool "Locate entire ASM lowlevel excepetion / interrupt - Syscall and CPLB handler code in L1 Memory"
442 default y
443 help
444 If enabled entire ASM lowlevel exception and interrupt entry code (STORE/RESTORE CONTEXT) is linked
445 into L1 instruction memory.(less latency)
446
447config DO_IRQ_L1
448 bool "Locate frequently called do_irq dispatcher function in L1 Memory"
449 default y
450 help
451 If enabled frequently called do_irq dispatcher function is linked
452 into L1 instruction memory.(less latency)
453
454config CORE_TIMER_IRQ_L1
455 bool "Locate frequently called timer_interrupt() function in L1 Memory"
456 default y
457 help
458 If enabled frequently called timer_interrupt() function is linked
459 into L1 instruction memory.(less latency)
460
461config IDLE_L1
462 bool "Locate frequently idle function in L1 Memory"
463 default y
464 help
465 If enabled frequently called idle function is linked
466 into L1 instruction memory.(less latency)
467
468config SCHEDULE_L1
469 bool "Locate kernel schedule function in L1 Memory"
470 default y
471 help
472 If enabled frequently called kernel schedule is linked
473 into L1 instruction memory.(less latency)
474
475config ARITHMETIC_OPS_L1
476 bool "Locate kernel owned arithmetic functions in L1 Memory"
477 default y
478 help
479 If enabled arithmetic functions are linked
480 into L1 instruction memory.(less latency)
481
482config ACCESS_OK_L1
483 bool "Locate access_ok function in L1 Memory"
484 default y
485 help
486 If enabled access_ok function is linked
487 into L1 instruction memory.(less latency)
488
489config MEMSET_L1
490 bool "Locate memset function in L1 Memory"
491 default y
492 help
493 If enabled memset function is linked
494 into L1 instruction memory.(less latency)
495
496config MEMCPY_L1
497 bool "Locate memcpy function in L1 Memory"
498 default y
499 help
500 If enabled memcpy function is linked
501 into L1 instruction memory.(less latency)
502
503config SYS_BFIN_SPINLOCK_L1
504 bool "Locate sys_bfin_spinlock function in L1 Memory"
505 default y
506 help
507 If enabled sys_bfin_spinlock function is linked
508 into L1 instruction memory.(less latency)
509
510config IP_CHECKSUM_L1
511 bool "Locate IP Checksum function in L1 Memory"
512 default n
513 help
514 If enabled IP Checksum function is linked
515 into L1 instruction memory.(less latency)
516
517config CACHELINE_ALIGNED_L1
518 bool "Locate cacheline_aligned data to L1 Data Memory"
519 default y
520 depends on !BF531
521 help
522 If enabled cacheline_anligned data is linked
523 into L1 data memory.(less latency)
524
525config SYSCALL_TAB_L1
526 bool "Locate Syscall Table L1 Data Memory"
527 default n
528 depends on !BF531
529 help
530 If enabled the Syscall LUT is linked
531 into L1 data memory.(less latency)
532
533config CPLB_SWITCH_TAB_L1
534 bool "Locate CPLB Switch Tables L1 Data Memory"
535 default n
536 depends on !BF531
537 help
538 If enabled the CPLB Switch Tables are linked
539 into L1 data memory.(less latency)
540
541endmenu
542
543
544choice
545 prompt "Kernel executes from"
546 help
547 Choose the memory type that the kernel will be running in.
548
549config RAMKERNEL
550 bool "RAM"
551 help
552 The kernel will be resident in RAM when running.
553
554config ROMKERNEL
555 bool "ROM"
556 help
557 The kernel will be resident in FLASH/ROM when running.
558
559endchoice
560
561source "mm/Kconfig"
562
563config LARGE_ALLOCS
564 bool "Allow allocating large blocks (> 1MB) of memory"
565 help
566 Allow the slab memory allocator to keep chains for very large
567 memory sizes - upto 32MB. You may need this if your system has
568 a lot of RAM, and you need to able to allocate very large
569 contiguous chunks. If unsure, say N.
570
571config BFIN_DMA_5XX
572 bool "Enable DMA Support"
573 depends on (BF533 || BF532 || BF531 || BF537 || BF536 || BF534 || BF561)
574 default y
575 help
576 DMA driver for BF5xx.
577
578choice
579 prompt "Uncached SDRAM region"
580 default DMA_UNCACHED_1M
581 depends BFIN_DMA_5XX
582config DMA_UNCACHED_2M
583 bool "Enable 2M DMA region"
584config DMA_UNCACHED_1M
585 bool "Enable 1M DMA region"
586config DMA_UNCACHED_NONE
587 bool "Disable DMA region"
588endchoice
589
590
591comment "Cache Support"
592config BLKFIN_CACHE
593 bool "Enable ICACHE"
594config BLKFIN_DCACHE
595 bool "Enable DCACHE"
596config BLKFIN_DCACHE_BANKA
597 bool "Enable only 16k BankA DCACHE - BankB is SRAM"
598 depends on BLKFIN_DCACHE && !BF531
599 default n
600config BLKFIN_CACHE_LOCK
601 bool "Enable Cache Locking"
602
603choice
604 prompt "Policy"
605 depends on BLKFIN_DCACHE
606 default BLKFIN_WB
607config BLKFIN_WB
608 bool "Write back"
609 help
610 Write Back Policy:
611 Cached data will be written back to SDRAM only when needed.
612 This can give a nice increase in performance, but beware of
613 broken drivers that do not properly invalidate/flush their
614 cache.
615
616 Write Through Policy:
617 Cached data will always be written back to SDRAM when the
618 cache is updated. This is a completely safe setting, but
619 performance is worse than Write Back.
620
621 If you are unsure of the options and you want to be safe,
622 then go with Write Through.
623
624config BLKFIN_WT
625 bool "Write through"
626 help
627 Write Back Policy:
628 Cached data will be written back to SDRAM only when needed.
629 This can give a nice increase in performance, but beware of
630 broken drivers that do not properly invalidate/flush their
631 cache.
632
633 Write Through Policy:
634 Cached data will always be written back to SDRAM when the
635 cache is updated. This is a completely safe setting, but
636 performance is worse than Write Back.
637
638 If you are unsure of the options and you want to be safe,
639 then go with Write Through.
640
641endchoice
642
643config L1_MAX_PIECE
644 int "Set the max L1 SRAM pieces"
645 default 16
646 help
647 Set the max memory pieces for the L1 SRAM allocation algorithm.
648 Min value is 16. Max value is 1024.
649
650menu "Clock Settings"
651
652
653config BFIN_KERNEL_CLOCK
654 bool "Re-program Clocks while Kernel boots?"
655 default n
656 help
657 This option decides if kernel clocks are re-programed from the
658 bootloader settings. If the clocks are not set, the SDRAM settings
659 are also not changed, and the Bootloader does 100% of the hardware
660 configuration.
661
662config VCO_MULT
663 int "VCO Multiplier"
664 depends on BFIN_KERNEL_CLOCK
665 default "22" if BFIN533_EZKIT
666 default "45" if BFIN533_STAMP
667 default "20" if BFIN537_STAMP
668 default "22" if BFIN533_BLUETECHNIX_CM
669 default "20" if BFIN537_BLUETECHNIX_CM
670 default "20" if BFIN561_BLUETECHNIX_CM
671 default "20" if BFIN561_EZKIT
672
673config CCLK_DIV
674 int "Core Clock Divider"
675 depends on BFIN_KERNEL_CLOCK
676 default 1 if BFIN533_EZKIT
677 default 1 if BFIN533_STAMP
678 default 1 if BFIN537_STAMP
679 default 1 if BFIN533_BLUETECHNIX_CM
680 default 1 if BFIN537_BLUETECHNIX_CM
681 default 1 if BFIN561_BLUETECHNIX_CM
682 default 1 if BFIN561_EZKIT
683
684config SCLK_DIV
685 int "System Clock Divider"
686 depends on BFIN_KERNEL_CLOCK
687 default 5 if BFIN533_EZKIT
688 default 5 if BFIN533_STAMP
689 default 4 if BFIN537_STAMP
690 default 5 if BFIN533_BLUETECHNIX_CM
691 default 4 if BFIN537_BLUETECHNIX_CM
692 default 4 if BFIN561_BLUETECHNIX_CM
693 default 5 if BFIN561_EZKIT
694
695config CLKIN_HALF
696 bool "Half ClockIn"
697 depends on BFIN_KERNEL_CLOCK
698 default n
699
700config PLL_BYPASS
701 bool "Bypass PLL"
702 depends on BFIN_KERNEL_CLOCK
703 default n
704
705endmenu
706
707comment "Asynchonous Memory Configuration"
708
709menu "EBIU_AMBCTL Global Control"
710config C_AMCKEN
711 bool "Enable CLKOUT"
712 default y
713
714config C_CDPRIO
715 bool "DMA has priority over core for ext. accesses"
716 default n
717
718config C_B0PEN
719 depends on BF561
720 bool "Bank 0 16 bit packing enable"
721 default y
722
723config C_B1PEN
724 depends on BF561
725 bool "Bank 1 16 bit packing enable"
726 default y
727
728config C_B2PEN
729 depends on BF561
730 bool "Bank 2 16 bit packing enable"
731 default y
732
733config C_B3PEN
734 depends on BF561
735 bool "Bank 3 16 bit packing enable"
736 default n
737
738choice
739 prompt"Enable Asynchonous Memory Banks"
740 default C_AMBEN_ALL
741
742config C_AMBEN
743 bool "Disable All Banks"
744
745config C_AMBEN_B0
746 bool "Enable Bank 0"
747
748config C_AMBEN_B0_B1
749 bool "Enable Bank 0 & 1"
750
751config C_AMBEN_B0_B1_B2
752 bool "Enable Bank 0 & 1 & 2"
753
754config C_AMBEN_ALL
755 bool "Enable All Banks"
756endchoice
757endmenu
758
759menu "EBIU_AMBCTL Control"
760config BANK_0
761 hex "Bank 0"
762 default 0x7BB0
763
764config BANK_1
765 hex "Bank 1"
766 default 0x7BB0
767
768config BANK_2
769 hex "Bank 2"
770 default 0x7BB0
771
772config BANK_3
773 hex "Bank 3"
774 default 0x99B3
775endmenu
776
777endmenu
778
779#############################################################################
780menu "Bus options (PCI, PCMCIA, EISA, MCA, ISA)"
781
782config PCI
783 bool "PCI support"
784 help
785 Support for PCI bus.
786
787source "drivers/pci/Kconfig"
788
789config HOTPLUG
790 bool "Support for hot-pluggable device"
791 help
792 Say Y here if you want to plug devices into your computer while
793 the system is running, and be able to use them quickly. In many
794 cases, the devices can likewise be unplugged at any time too.
795
796 One well known example of this is PCMCIA- or PC-cards, credit-card
797 size devices such as network cards, modems or hard drives which are
798 plugged into slots found on all modern laptop computers. Another
799 example, used on modern desktops as well as laptops, is USB.
800
801 Enable HOTPLUG and KMOD, and build a modular kernel. Get agent
802 software (at <http://linux-hotplug.sourceforge.net/>) and install it.
803 Then your kernel will automatically call out to a user mode "policy
804 agent" (/sbin/hotplug) to load modules and set up software needed
805 to use devices as you hotplug them.
806
807source "drivers/pcmcia/Kconfig"
808
809source "drivers/pci/hotplug/Kconfig"
810
811endmenu
812
813menu "Executable file formats"
814
815source "fs/Kconfig.binfmt"
816
817endmenu
818
819menu "Power management options"
820source "kernel/power/Kconfig"
821
822choice
823 prompt "Select PM Wakeup Event Source"
824 default PM_WAKEUP_GPIO_BY_SIC_IWR
825 depends on PM
826 help
827 If you have a GPIO already configured as input with the corresponding PORTx_MASK
828 bit set - "Specify Wakeup Event by SIC_IWR value"
829
830config PM_WAKEUP_GPIO_BY_SIC_IWR
831 bool "Specify Wakeup Event by SIC_IWR value"
832config PM_WAKEUP_BY_GPIO
833 bool "Cause Wakeup Event by GPIO"
834config PM_WAKEUP_GPIO_API
835 bool "Configure Wakeup Event by PM GPIO API"
836
837endchoice
838
839config PM_WAKEUP_SIC_IWR
840 hex "Wakeup Events (SIC_IWR)"
841 depends on PM_WAKEUP_GPIO_BY_SIC_IWR
842 default 0x80000000 if (BF537 || BF536 || BF534)
843 default 0x100000 if (BF533 || BF532 || BF531)
844
845config PM_WAKEUP_GPIO_NUMBER
846 int "Wakeup GPIO number"
847 range 0 47
848 depends on PM_WAKEUP_BY_GPIO
849 default 2 if BFIN537_STAMP
850
851choice
852 prompt "GPIO Polarity"
853 depends on PM_WAKEUP_BY_GPIO
854 default PM_WAKEUP_GPIO_POLAR_H
855config PM_WAKEUP_GPIO_POLAR_H
856 bool "Active High"
857config PM_WAKEUP_GPIO_POLAR_L
858 bool "Active Low"
859config PM_WAKEUP_GPIO_POLAR_EDGE_F
860 bool "Falling EDGE"
861config PM_WAKEUP_GPIO_POLAR_EDGE_R
862 bool "Rising EDGE"
863config PM_WAKEUP_GPIO_POLAR_EDGE_B
864 bool "Both EDGE"
865endchoice
866
867endmenu
868
869if (BF537 || BF533)
870
871menu "CPU Frequency scaling"
872
873source "drivers/cpufreq/Kconfig"
874
875config CPU_FREQ
876 bool
877 default n
878 help
879 If you want to enable this option, you should select the
880 DPMC driver from Character Devices.
881endmenu
882
883endif
884
885source "net/Kconfig"
886
887source "drivers/Kconfig"
888
889source "fs/Kconfig"
890
891source "arch/blackfin/oprofile/Kconfig"
892
893menu "Kernel hacking"
894
895source "lib/Kconfig.debug"
896
897config DEBUG_HWERR
898 bool "Hardware error interrupt debugging"
899 depends on DEBUG_KERNEL
900 help
901 When enabled, the hardware error interrupt is never disabled, and
902 will happen immediately when an error condition occurs. This comes
903 at a slight cost in code size, but is necessary if you are getting
904 hardware error interrupts and need to know where they are coming
905 from.
906
907config DEBUG_ICACHE_CHECK
908 bool "Check Instruction cache coherancy"
909 depends on DEBUG_KERNEL
910 depends on DEBUG_HWERR
911 help
912 Say Y here if you are getting wierd unexplained errors. This will
913 ensure that icache is what SDRAM says it should be, by doing a
914 byte wise comparision between SDRAM and instruction cache. This
915 also relocates the irq_panic() function to L1 memory, (which is
916 un-cached).
917
918config DEBUG_KERNEL_START
919 bool "Debug Kernel Startup"
920 depends on DEBUG_KERNEL
921 help
922 Say Y here to put in an mini-execption handler before the kernel
923 replaces the bootloader exception handler. This will stop kernels
924 from dieing at startup with no visible error messages.
925
926config DEBUG_SERIAL_EARLY_INIT
927 bool "Initialize serial driver early"
928 default n
929 depends on SERIAL_BFIN
930 help
931 Say Y here if you want to get kernel output early when kernel
932 crashes before the normal console initialization. If this option
933 is enable, console output will always go to the ttyBF0, no matter
934 what kernel boot paramters you set.
935
936config DEBUG_HUNT_FOR_ZERO
937 bool "Catch NULL pointer reads/writes"
938 default y
939 help
940 Say Y here to catch reads/writes to anywhere in the memory range
941 from 0x0000 - 0x0FFF (the first 4k) of memory. This is useful in
942 catching common programming errors such as NULL pointer dereferences.
943
944 Misbehaving applications will be killed (generate a SEGV) while the
945 kernel will trigger a panic.
946
947 Enabling this option will take up an extra entry in CPLB table.
948 Otherwise, there is no extra overhead.
949
950config DEBUG_BFIN_NO_KERN_HWTRACE
951 bool "Trace user apps (turn off hwtrace in kernel)"
952 default n
953 help
954 Some pieces of the kernel contain a lot of flow changes which can
955 quickly fill up the hardware trace buffer. When debugging crashes,
956 the hardware trace may indicate that the problem lies in kernel
957 space when in reality an application is buggy.
958
959 Say Y here to disable hardware tracing in some known "jumpy" pieces
960 of code so that the trace buffer will extend further back.
961
962config DUAL_CORE_TEST_MODULE
963 tristate "Dual Core Test Module"
964 depends on (BF561)
965 default n
966 help
967 Say Y here to build-in dual core test module for dual core test.
968
969config CPLB_INFO
970 bool "Display the CPLB information"
971 help
972 Display the CPLB information.
973
974config ACCESS_CHECK
975 bool "Check the user pointer address"
976 default y
977 help
978 Usually the pointer transfer from user space is checked to see if its
979 address is in the kernel space.
980
981 Say N here to disable that check to improve the performance.
982
983endmenu
984
985source "security/Kconfig"
986
987source "crypto/Kconfig"
988
989source "lib/Kconfig"
diff --git a/arch/blackfin/Makefile b/arch/blackfin/Makefile
new file mode 100644
index 000000000000..52d4dbdb2b1a
--- /dev/null
+++ b/arch/blackfin/Makefile
@@ -0,0 +1,80 @@
1#
2# arch/blackfin/Makefile
3#
4# This file is subject to the terms and conditions of the GNU General Public
5# License. See the file "COPYING" in the main directory of this archive
6# for more details.
7#
8
9
10CROSS_COMPILE ?= bfin-uclinux-
11LDFLAGS_vmlinux := -X
12OBJCOPYFLAGS := -O binary -R .note -R .comment -S
13GZFLAGS := -9
14
15CFLAGS_MODULE += -mlong-calls
16KALLSYMS += --symbol-prefix=_
17
18
19# setup the machine name and the machine dependent settings
20machine-$(CONFIG_BF531) := bf533
21machine-$(CONFIG_BF532) := bf533
22machine-$(CONFIG_BF533) := bf533
23machine-$(CONFIG_BF534) := bf537
24machine-$(CONFIG_BF536) := bf537
25machine-$(CONFIG_BF537) := bf537
26machine-$(CONFIG_BF561) := bf561
27MACHINE := $(machine-y)
28export MACHINE
29
30
31head-y := arch/$(ARCH)/mach-$(MACHINE)/head.o arch/$(ARCH)/kernel/init_task.o
32
33core-y += arch/$(ARCH)/kernel/ arch/$(ARCH)/mm/ arch/$(ARCH)/mach-common/
34
35# If we have a machine-specific directory, then include it in the build.
36ifneq ($(machine-y),)
37core-y += arch/$(ARCH)/mach-$(MACHINE)/
38core-y += arch/$(ARCH)/mach-$(MACHINE)/boards/
39endif
40
41libs-y += arch/$(ARCH)/lib/
42
43drivers-$(CONFIG_OPROFILE) += arch/$(ARCH)/oprofile/
44
45
46
47# Update machine arch symlinks if something which affects
48# them changed. We use .mach to indicate when they were updated
49# last, otherwise make uses the target directory mtime.
50
51include/asm-blackfin/.mach: $(wildcard include/config/arch/*.h) include/config/auto.conf
52 @echo ' SYMLINK include/asm-$(ARCH)/mach-$(MACHINE) -> include/asm-$(ARCH)/mach'
53ifneq ($(KBUILD_SRC),)
54 $(Q)mkdir -p include/asm-$(ARCH)
55 $(Q)ln -fsn $(srctree)/include/asm-$(ARCH)/mach-$(MACHINE) include/asm-$(ARCH)/mach
56else
57 $(Q)ln -fsn mach-$(MACHINE) include/asm-$(ARCH)/mach
58endif
59 @touch $@
60
61CLEAN_FILES += \
62 include/asm-$(ARCH)/asm-offsets.h \
63 arch/$(ARCH)/kernel/asm-offsets.s \
64 include/asm-$(ARCH)/mach \
65 include/asm-$(ARCH)/.mach
66
67archprepare: include/asm-blackfin/.mach
68archclean:
69 $(Q)$(MAKE) $(clean)=$(boot)
70
71
72all: vmImage
73boot := arch/$(ARCH)/boot
74BOOT_TARGETS = vmImage
75.PHONY: $(BOOT_TARGETS)
76$(BOOT_TARGETS): vmlinux
77 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
78define archhelp
79 echo '* vmImage - Kernel-only image for U-Boot (arch/$(ARCH)/boot/vmImage)'
80endef
diff --git a/arch/blackfin/boot/Makefile b/arch/blackfin/boot/Makefile
new file mode 100644
index 000000000000..49e8098d4c21
--- /dev/null
+++ b/arch/blackfin/boot/Makefile
@@ -0,0 +1,27 @@
1#
2# arch/blackfin/boot/Makefile
3#
4# This file is subject to the terms and conditions of the GNU General Public
5# License. See the file "COPYING" in the main directory of this archive
6# for more details.
7#
8
9MKIMAGE := $(srctree)/scripts/mkuboot.sh
10
11targets := vmImage
12extra-y += vmlinux.bin vmlinux.gz
13
14quiet_cmd_uimage = UIMAGE $@
15 cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A $(ARCH) -O linux -T kernel \
16 -C gzip -a $(CONFIG_BOOT_LOAD) -e $(CONFIG_BOOT_LOAD) -n 'Linux-$(KERNELRELEASE)' \
17 -d $< $@
18
19$(obj)/vmlinux.bin: vmlinux FORCE
20 $(call if_changed,objcopy)
21
22$(obj)/vmlinux.gz: $(obj)/vmlinux.bin FORCE
23 $(call if_changed,gzip)
24
25$(obj)/vmImage: $(obj)/vmlinux.gz
26 $(call if_changed,uimage)
27 @echo 'Kernel: $@ is ready'
diff --git a/arch/blackfin/defconfig b/arch/blackfin/defconfig
new file mode 100644
index 000000000000..d5904ca994cf
--- /dev/null
+++ b/arch/blackfin/defconfig
@@ -0,0 +1,1314 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.20
4#
5# CONFIG_MMU is not set
6# CONFIG_FPU is not set
7CONFIG_RWSEM_GENERIC_SPINLOCK=y
8# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
9CONFIG_BFIN=y
10CONFIG_SEMAPHORE_SLEEPERS=y
11CONFIG_GENERIC_FIND_NEXT_BIT=y
12CONFIG_GENERIC_HWEIGHT=y
13CONFIG_GENERIC_HARDIRQS=y
14CONFIG_GENERIC_IRQ_PROBE=y
15CONFIG_GENERIC_CALIBRATE_DELAY=y
16CONFIG_UCLINUX=y
17CONFIG_FORCE_MAX_ZONEORDER=14
18CONFIG_IRQCHIP_DEMUX_GPIO=y
19CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
20
21#
22# Code maturity level options
23#
24CONFIG_EXPERIMENTAL=y
25CONFIG_BROKEN_ON_SMP=y
26CONFIG_INIT_ENV_ARG_LIMIT=32
27
28#
29# General setup
30#
31CONFIG_LOCALVERSION=""
32CONFIG_LOCALVERSION_AUTO=y
33CONFIG_SYSVIPC=y
34# CONFIG_IPC_NS is not set
35# CONFIG_POSIX_MQUEUE is not set
36# CONFIG_BSD_PROCESS_ACCT is not set
37# CONFIG_TASKSTATS is not set
38# CONFIG_UTS_NS is not set
39# CONFIG_AUDIT is not set
40# CONFIG_IKCONFIG is not set
41CONFIG_SYSFS_DEPRECATED=y
42# CONFIG_RELAY is not set
43CONFIG_INITRAMFS_SOURCE=""
44# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
45CONFIG_SYSCTL=y
46CONFIG_EMBEDDED=y
47CONFIG_UID16=y
48CONFIG_SYSCTL_SYSCALL=y
49CONFIG_KALLSYMS=y
50# CONFIG_KALLSYMS_EXTRA_PASS is not set
51CONFIG_HOTPLUG=y
52CONFIG_PRINTK=y
53CONFIG_BUG=y
54CONFIG_ELF_CORE=y
55CONFIG_BASE_FULL=y
56CONFIG_FUTEX=y
57CONFIG_EPOLL=y
58# CONFIG_LIMIT_PAGECACHE is not set
59CONFIG_BUDDY=y
60# CONFIG_NP2 is not set
61CONFIG_SLAB=y
62CONFIG_VM_EVENT_COUNTERS=y
63CONFIG_RT_MUTEXES=y
64CONFIG_TINY_SHMEM=y
65CONFIG_BASE_SMALL=0
66# CONFIG_SLOB is not set
67
68#
69# Loadable module support
70#
71CONFIG_MODULES=y
72CONFIG_MODULE_UNLOAD=y
73# CONFIG_MODULE_FORCE_UNLOAD is not set
74# CONFIG_MODVERSIONS is not set
75# CONFIG_MODULE_SRCVERSION_ALL is not set
76CONFIG_KMOD=y
77
78#
79# Block layer
80#
81CONFIG_BLOCK=y
82# CONFIG_LBD is not set
83# CONFIG_BLK_DEV_IO_TRACE is not set
84# CONFIG_LSF is not set
85
86#
87# IO Schedulers
88#
89CONFIG_IOSCHED_NOOP=y
90CONFIG_IOSCHED_AS=y
91# CONFIG_IOSCHED_DEADLINE is not set
92CONFIG_IOSCHED_CFQ=y
93CONFIG_DEFAULT_AS=y
94# CONFIG_DEFAULT_DEADLINE is not set
95# CONFIG_DEFAULT_CFQ is not set
96# CONFIG_DEFAULT_NOOP is not set
97CONFIG_DEFAULT_IOSCHED="anticipatory"
98
99#
100# Blackfin Processor Options
101#
102
103#
104# Processor and Board Settings
105#
106# CONFIG_BF531 is not set
107# CONFIG_BF532 is not set
108# CONFIG_BF533 is not set
109# CONFIG_BF534 is not set
110# CONFIG_BF535 is not set
111# CONFIG_BF536 is not set
112CONFIG_BF537=y
113# CONFIG_BF561 is not set
114CONFIG_BF_REV_0_2=y
115# CONFIG_BF_REV_0_3 is not set
116# CONFIG_BF_REV_0_4 is not set
117# CONFIG_BF_REV_0_5 is not set
118CONFIG_BLACKFIN=y
119CONFIG_BFIN_SINGLE_CORE=y
120# CONFIG_BFIN533_EZKIT is not set
121# CONFIG_BFIN533_STAMP is not set
122CONFIG_BFIN537_STAMP=y
123# CONFIG_BFIN533_BLUETECHNIX_CM is not set
124# CONFIG_BFIN537_BLUETECHNIX_CM is not set
125# CONFIG_BFIN561_BLUETECHNIX_CM is not set
126# CONFIG_BFIN561_EZKIT is not set
127# CONFIG_PNAV10 is not set
128# CONFIG_GENERIC_BOARD is not set
129CONFIG_MEM_MT48LC32M8A2_75=y
130CONFIG_IRQ_PLL_WAKEUP=7
131
132#
133# BF537 Specific Configuration
134#
135
136#
137# PORT F/G Selection
138#
139CONFIG_BF537_PORT_F=y
140# CONFIG_BF537_PORT_G is not set
141# CONFIG_BF537_PORT_H is not set
142
143#
144# Interrupt Priority Assignment
145#
146
147#
148# Priority
149#
150CONFIG_IRQ_DMA_ERROR=7
151CONFIG_IRQ_ERROR=7
152CONFIG_IRQ_RTC=8
153CONFIG_IRQ_PPI=8
154CONFIG_IRQ_SPORT0_RX=9
155CONFIG_IRQ_SPORT0_TX=9
156CONFIG_IRQ_SPORT1_RX=9
157CONFIG_IRQ_SPORT1_TX=9
158CONFIG_IRQ_TWI=10
159CONFIG_IRQ_SPI=10
160CONFIG_IRQ_UART0_RX=10
161CONFIG_IRQ_UART0_TX=10
162CONFIG_IRQ_UART1_RX=10
163CONFIG_IRQ_UART1_TX=10
164CONFIG_IRQ_CAN_RX=11
165CONFIG_IRQ_CAN_TX=11
166CONFIG_IRQ_MAC_RX=11
167CONFIG_IRQ_MAC_TX=11
168CONFIG_IRQ_TMR0=12
169CONFIG_IRQ_TMR1=12
170CONFIG_IRQ_TMR2=12
171CONFIG_IRQ_TMR3=12
172CONFIG_IRQ_TMR4=12
173CONFIG_IRQ_TMR5=12
174CONFIG_IRQ_TMR6=12
175CONFIG_IRQ_TMR7=12
176CONFIG_IRQ_PROG_INTA=12
177CONFIG_IRQ_PORTG_INTB=12
178CONFIG_IRQ_MEM_DMA0=13
179CONFIG_IRQ_MEM_DMA1=13
180CONFIG_IRQ_WATCH=13
181
182#
183# Board customizations
184#
185
186#
187# Board Setup
188#
189CONFIG_CLKIN_HZ=25000000
190CONFIG_MEM_SIZE=64
191CONFIG_MEM_ADD_WIDTH=10
192CONFIG_BOOT_LOAD=0x1000
193
194#
195# Console UART Setup
196#
197# CONFIG_BAUD_9600 is not set
198# CONFIG_BAUD_19200 is not set
199# CONFIG_BAUD_38400 is not set
200CONFIG_BAUD_57600=y
201# CONFIG_BAUD_115200 is not set
202CONFIG_BAUD_NO_PARITY=y
203# CONFIG_BAUD_PARITY is not set
204CONFIG_BAUD_1_STOPBIT=y
205# CONFIG_BAUD_2_STOPBIT is not set
206
207#
208# Blackfin Kernel Optimizations
209#
210
211#
212# Timer Tick
213#
214# CONFIG_HZ_100 is not set
215CONFIG_HZ_250=y
216# CONFIG_HZ_300 is not set
217# CONFIG_HZ_1000 is not set
218CONFIG_HZ=250
219
220#
221# Memory Optimizations
222#
223CONFIG_I_ENTRY_L1=y
224CONFIG_RAMKERNEL=y
225# CONFIG_ROMKERNEL is not set
226CONFIG_SELECT_MEMORY_MODEL=y
227CONFIG_FLATMEM_MANUAL=y
228# CONFIG_DISCONTIGMEM_MANUAL is not set
229# CONFIG_SPARSEMEM_MANUAL is not set
230CONFIG_FLATMEM=y
231CONFIG_FLAT_NODE_MEM_MAP=y
232# CONFIG_SPARSEMEM_STATIC is not set
233CONFIG_SPLIT_PTLOCK_CPUS=4
234# CONFIG_RESOURCES_64BIT is not set
235CONFIG_LARGE_ALLOCS=y
236CONFIG_BFIN_DMA_5XX=y
237# CONFIG_DMA_UNCACHED_2M is not set
238CONFIG_DMA_UNCACHED_1M=y
239# CONFIG_DMA_UNCACHED_NONE is not set
240
241#
242# Cache Support
243#
244CONFIG_BLKFIN_CACHE=y
245CONFIG_BLKFIN_DCACHE=y
246# CONFIG_BLKFIN_CACHE_LOCK is not set
247# CONFIG_BLKFIN_WB is not set
248CONFIG_BLKFIN_WT=y
249CONFIG_L1_MAX_PIECE=16
250
251#
252# Clock Settings
253#
254# CONFIG_BFIN_KERNEL_CLOCK is not set
255
256#
257# Asynchonous Memory Configuration
258#
259
260#
261# EBIU_AMBCTL Global Control
262#
263CONFIG_C_AMCKEN=y
264CONFIG_C_CDPRIO=y
265# CONFIG_C_AMBEN is not set
266# CONFIG_C_AMBEN_B0 is not set
267# CONFIG_C_AMBEN_B0_B1 is not set
268# CONFIG_C_AMBEN_B0_B1_B2 is not set
269CONFIG_C_AMBEN_ALL=y
270
271#
272# EBIU_AMBCTL Control
273#
274CONFIG_BANK_0=0x7BB0
275CONFIG_BANK_1=0x7BB0
276CONFIG_BANK_2=0x7BB0
277CONFIG_BANK_3=0x99B3
278
279#
280# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
281#
282# CONFIG_PCI is not set
283
284#
285# PCCARD (PCMCIA/CardBus) support
286#
287# CONFIG_PCCARD is not set
288
289#
290# PCI Hotplug Support
291#
292
293#
294# Executable file formats
295#
296CONFIG_BINFMT_ELF_FDPIC=y
297CONFIG_BINFMT_FLAT=y
298CONFIG_BINFMT_ZFLAT=y
299# CONFIG_BINFMT_SHARED_FLAT is not set
300# CONFIG_BINFMT_MISC is not set
301
302#
303# Power management options
304#
305CONFIG_PM=y
306CONFIG_PM_LEGACY=y
307# CONFIG_PM_DEBUG is not set
308# CONFIG_PM_SYSFS_DEPRECATED is not set
309CONFIG_PM_WAKEUP_GPIO_BY_SIC_IWR=y
310# CONFIG_PM_WAKEUP_BY_GPIO is not set
311# CONFIG_PM_WAKEUP_GPIO_API is not set
312CONFIG_PM_WAKEUP_SIC_IWR=0x80000000
313
314#
315# CPU Frequency scaling
316#
317# CONFIG_CPU_FREQ is not set
318
319#
320# Networking
321#
322CONFIG_NET=y
323
324#
325# Networking options
326#
327# CONFIG_NETDEBUG is not set
328CONFIG_PACKET=y
329# CONFIG_PACKET_MMAP is not set
330CONFIG_UNIX=y
331CONFIG_XFRM=y
332# CONFIG_XFRM_USER is not set
333# CONFIG_XFRM_SUB_POLICY is not set
334# CONFIG_NET_KEY is not set
335CONFIG_INET=y
336# CONFIG_IP_MULTICAST is not set
337# CONFIG_IP_ADVANCED_ROUTER is not set
338CONFIG_IP_FIB_HASH=y
339CONFIG_IP_PNP=y
340# CONFIG_IP_PNP_DHCP is not set
341# CONFIG_IP_PNP_BOOTP is not set
342# CONFIG_IP_PNP_RARP is not set
343# CONFIG_NET_IPIP is not set
344# CONFIG_NET_IPGRE is not set
345# CONFIG_ARPD is not set
346CONFIG_SYN_COOKIES=y
347# CONFIG_INET_AH is not set
348# CONFIG_INET_ESP is not set
349# CONFIG_INET_IPCOMP is not set
350# CONFIG_INET_XFRM_TUNNEL is not set
351# CONFIG_INET_TUNNEL is not set
352CONFIG_INET_XFRM_MODE_TRANSPORT=y
353CONFIG_INET_XFRM_MODE_TUNNEL=y
354CONFIG_INET_XFRM_MODE_BEET=y
355CONFIG_INET_DIAG=y
356CONFIG_INET_TCP_DIAG=y
357# CONFIG_TCP_CONG_ADVANCED is not set
358CONFIG_TCP_CONG_CUBIC=y
359CONFIG_DEFAULT_TCP_CONG="cubic"
360# CONFIG_TCP_MD5SIG is not set
361# CONFIG_IPV6 is not set
362# CONFIG_INET6_XFRM_TUNNEL is not set
363# CONFIG_INET6_TUNNEL is not set
364# CONFIG_NETLABEL is not set
365# CONFIG_NETWORK_SECMARK is not set
366# CONFIG_NETFILTER is not set
367
368#
369# DCCP Configuration (EXPERIMENTAL)
370#
371# CONFIG_IP_DCCP is not set
372
373#
374# SCTP Configuration (EXPERIMENTAL)
375#
376# CONFIG_IP_SCTP is not set
377
378#
379# TIPC Configuration (EXPERIMENTAL)
380#
381# CONFIG_TIPC is not set
382# CONFIG_ATM is not set
383# CONFIG_BRIDGE is not set
384# CONFIG_VLAN_8021Q is not set
385# CONFIG_DECNET is not set
386# CONFIG_LLC2 is not set
387# CONFIG_IPX is not set
388# CONFIG_ATALK is not set
389# CONFIG_X25 is not set
390# CONFIG_LAPB is not set
391# CONFIG_ECONET is not set
392# CONFIG_WAN_ROUTER is not set
393
394#
395# QoS and/or fair queueing
396#
397# CONFIG_NET_SCHED is not set
398
399#
400# Network testing
401#
402# CONFIG_NET_PKTGEN is not set
403# CONFIG_HAMRADIO is not set
404CONFIG_IRDA=m
405
406#
407# IrDA protocols
408#
409CONFIG_IRLAN=m
410CONFIG_IRCOMM=m
411# CONFIG_IRDA_ULTRA is not set
412
413#
414# IrDA options
415#
416CONFIG_IRDA_CACHE_LAST_LSAP=y
417# CONFIG_IRDA_FAST_RR is not set
418# CONFIG_IRDA_DEBUG is not set
419
420#
421# Infrared-port device drivers
422#
423
424#
425# SIR device drivers
426#
427CONFIG_IRTTY_SIR=m
428
429#
430# Dongle support
431#
432# CONFIG_DONGLE is not set
433
434#
435# Old SIR device drivers
436#
437# CONFIG_IRPORT_SIR is not set
438
439#
440# Old Serial dongle support
441#
442
443#
444# FIR device drivers
445#
446# CONFIG_BT is not set
447# CONFIG_IEEE80211 is not set
448
449#
450# Device Drivers
451#
452
453#
454# Generic Driver Options
455#
456CONFIG_STANDALONE=y
457CONFIG_PREVENT_FIRMWARE_BUILD=y
458# CONFIG_FW_LOADER is not set
459# CONFIG_SYS_HYPERVISOR is not set
460
461#
462# Connector - unified userspace <-> kernelspace linker
463#
464# CONFIG_CONNECTOR is not set
465
466#
467# Memory Technology Devices (MTD)
468#
469CONFIG_MTD=y
470# CONFIG_MTD_DEBUG is not set
471# CONFIG_MTD_CONCAT is not set
472CONFIG_MTD_PARTITIONS=y
473# CONFIG_MTD_REDBOOT_PARTS is not set
474# CONFIG_MTD_CMDLINE_PARTS is not set
475
476#
477# User Modules And Translation Layers
478#
479CONFIG_MTD_CHAR=m
480CONFIG_MTD_BLKDEVS=y
481CONFIG_MTD_BLOCK=y
482# CONFIG_FTL is not set
483# CONFIG_NFTL is not set
484# CONFIG_INFTL is not set
485# CONFIG_RFD_FTL is not set
486# CONFIG_SSFDC is not set
487
488#
489# RAM/ROM/Flash chip drivers
490#
491# CONFIG_MTD_CFI is not set
492CONFIG_MTD_JEDECPROBE=m
493CONFIG_MTD_GEN_PROBE=m
494# CONFIG_MTD_CFI_ADV_OPTIONS is not set
495CONFIG_MTD_MAP_BANK_WIDTH_1=y
496CONFIG_MTD_MAP_BANK_WIDTH_2=y
497CONFIG_MTD_MAP_BANK_WIDTH_4=y
498# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
499# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
500# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
501CONFIG_MTD_CFI_I1=y
502CONFIG_MTD_CFI_I2=y
503# CONFIG_MTD_CFI_I4 is not set
504# CONFIG_MTD_CFI_I8 is not set
505# CONFIG_MTD_CFI_INTELEXT is not set
506# CONFIG_MTD_CFI_AMDSTD is not set
507# CONFIG_MTD_CFI_STAA is not set
508CONFIG_MTD_MW320D=m
509CONFIG_MTD_RAM=y
510CONFIG_MTD_ROM=m
511# CONFIG_MTD_ABSENT is not set
512# CONFIG_MTD_OBSOLETE_CHIPS is not set
513
514#
515# Mapping drivers for chip access
516#
517CONFIG_MTD_COMPLEX_MAPPINGS=y
518# CONFIG_MTD_PHYSMAP is not set
519CONFIG_MTD_BF5xx=m
520CONFIG_BFIN_FLASH_SIZE=0x400000
521CONFIG_EBIU_FLASH_BASE=0x20000000
522
523#
524# FLASH_EBIU_AMBCTL Control
525#
526CONFIG_BFIN_FLASH_BANK_0=0x7BB0
527CONFIG_BFIN_FLASH_BANK_1=0x7BB0
528CONFIG_BFIN_FLASH_BANK_2=0x7BB0
529CONFIG_BFIN_FLASH_BANK_3=0x7BB0
530CONFIG_MTD_UCLINUX=y
531# CONFIG_MTD_PLATRAM is not set
532
533#
534# Self-contained MTD device drivers
535#
536# CONFIG_MTD_DATAFLASH is not set
537# CONFIG_MTD_M25P80 is not set
538# CONFIG_MTD_SLRAM is not set
539# CONFIG_MTD_PHRAM is not set
540# CONFIG_MTD_MTDRAM is not set
541# CONFIG_MTD_BLOCK2MTD is not set
542
543#
544# Disk-On-Chip Device Drivers
545#
546# CONFIG_MTD_DOC2000 is not set
547# CONFIG_MTD_DOC2001 is not set
548# CONFIG_MTD_DOC2001PLUS is not set
549
550#
551# NAND Flash Device Drivers
552#
553CONFIG_MTD_NAND=m
554# CONFIG_MTD_NAND_VERIFY_WRITE is not set
555# CONFIG_MTD_NAND_ECC_SMC is not set
556CONFIG_MTD_NAND_BFIN=m
557CONFIG_BFIN_NAND_BASE=0x20212000
558CONFIG_BFIN_NAND_CLE=2
559CONFIG_BFIN_NAND_ALE=1
560CONFIG_BFIN_NAND_READY=3
561CONFIG_MTD_NAND_IDS=m
562# CONFIG_MTD_NAND_DISKONCHIP is not set
563# CONFIG_MTD_NAND_NANDSIM is not set
564
565#
566# OneNAND Flash Device Drivers
567#
568# CONFIG_MTD_ONENAND is not set
569
570#
571# Parallel port support
572#
573# CONFIG_PARPORT is not set
574
575#
576# Plug and Play support
577#
578
579#
580# Block devices
581#
582# CONFIG_BLK_DEV_COW_COMMON is not set
583# CONFIG_BLK_DEV_LOOP is not set
584# CONFIG_BLK_DEV_NBD is not set
585CONFIG_BLK_DEV_RAM=y
586CONFIG_BLK_DEV_RAM_COUNT=16
587CONFIG_BLK_DEV_RAM_SIZE=4096
588CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
589# CONFIG_BLK_DEV_INITRD is not set
590# CONFIG_CDROM_PKTCDVD is not set
591# CONFIG_ATA_OVER_ETH is not set
592
593#
594# Misc devices
595#
596# CONFIG_TIFM_CORE is not set
597
598#
599# ATA/ATAPI/MFM/RLL support
600#
601# CONFIG_IDE is not set
602
603#
604# SCSI device support
605#
606# CONFIG_RAID_ATTRS is not set
607# CONFIG_SCSI is not set
608# CONFIG_SCSI_NETLINK is not set
609
610#
611# Serial ATA (prod) and Parallel ATA (experimental) drivers
612#
613# CONFIG_ATA is not set
614
615#
616# Multi-device support (RAID and LVM)
617#
618# CONFIG_MD is not set
619
620#
621# Fusion MPT device support
622#
623# CONFIG_FUSION is not set
624
625#
626# IEEE 1394 (FireWire) support
627#
628
629#
630# I2O device support
631#
632
633#
634# Network device support
635#
636CONFIG_NETDEVICES=y
637# CONFIG_DUMMY is not set
638# CONFIG_BONDING is not set
639# CONFIG_EQUALIZER is not set
640# CONFIG_TUN is not set
641
642#
643# PHY device support
644#
645# CONFIG_PHYLIB is not set
646
647#
648# Ethernet (10 or 100Mbit)
649#
650CONFIG_NET_ETHERNET=y
651CONFIG_MII=y
652# CONFIG_SMC91X is not set
653CONFIG_BFIN_MAC=y
654CONFIG_BFIN_MAC_USE_L1=y
655CONFIG_BFIN_TX_DESC_NUM=10
656CONFIG_BFIN_RX_DESC_NUM=20
657# CONFIG_BFIN_MAC_RMII is not set
658
659#
660# Ethernet (1000 Mbit)
661#
662
663#
664# Ethernet (10000 Mbit)
665#
666
667#
668# Token Ring devices
669#
670
671#
672# Wireless LAN (non-hamradio)
673#
674# CONFIG_NET_RADIO is not set
675
676#
677# Wan interfaces
678#
679# CONFIG_WAN is not set
680# CONFIG_PPP is not set
681# CONFIG_SLIP is not set
682# CONFIG_SHAPER is not set
683# CONFIG_NETCONSOLE is not set
684# CONFIG_NETPOLL is not set
685# CONFIG_NET_POLL_CONTROLLER is not set
686
687#
688# ISDN subsystem
689#
690# CONFIG_ISDN is not set
691
692#
693# Telephony Support
694#
695# CONFIG_PHONE is not set
696
697#
698# Input device support
699#
700CONFIG_INPUT=y
701# CONFIG_INPUT_FF_MEMLESS is not set
702
703#
704# Userland interfaces
705#
706# CONFIG_INPUT_MOUSEDEV is not set
707# CONFIG_INPUT_JOYDEV is not set
708# CONFIG_INPUT_TSDEV is not set
709CONFIG_INPUT_EVDEV=m
710# CONFIG_INPUT_EVBUG is not set
711
712#
713# Input Device Drivers
714#
715# CONFIG_INPUT_KEYBOARD is not set
716# CONFIG_INPUT_MOUSE is not set
717# CONFIG_INPUT_JOYSTICK is not set
718# CONFIG_INPUT_TOUCHSCREEN is not set
719CONFIG_INPUT_MISC=y
720# CONFIG_INPUT_UINPUT is not set
721# CONFIG_BF53X_PFBUTTONS is not set
722CONFIG_TWI_KEYPAD=m
723CONFIG_BFIN_TWIKEYPAD_IRQ_PFX=72
724
725#
726# Hardware I/O ports
727#
728# CONFIG_SERIO is not set
729# CONFIG_GAMEPORT is not set
730
731#
732# Character devices
733#
734# CONFIG_AD9960 is not set
735# CONFIG_SPI_ADC_BF533 is not set
736# CONFIG_BF533_PFLAGS is not set
737# CONFIG_BF5xx_PPIFCD is not set
738# CONFIG_BF5xx_TIMERS is not set
739# CONFIG_BF5xx_PPI is not set
740CONFIG_BFIN_SPORT=y
741# CONFIG_BFIN_TIMER_LATENCY is not set
742CONFIG_TWI_LCD=m
743CONFIG_TWI_LCD_SLAVE_ADDR=34
744# CONFIG_AD5304 is not set
745# CONFIG_VT is not set
746# CONFIG_SERIAL_NONSTANDARD is not set
747
748#
749# Serial drivers
750#
751# CONFIG_SERIAL_8250 is not set
752
753#
754# Non-8250 serial port support
755#
756CONFIG_SERIAL_BFIN=y
757CONFIG_SERIAL_BFIN_CONSOLE=y
758CONFIG_SERIAL_BFIN_DMA=y
759# CONFIG_SERIAL_BFIN_PIO is not set
760CONFIG_SERIAL_BFIN_UART0=y
761# CONFIG_BFIN_UART0_CTSRTS is not set
762# CONFIG_SERIAL_BFIN_UART1 is not set
763CONFIG_SERIAL_CORE=y
764CONFIG_SERIAL_CORE_CONSOLE=y
765# CONFIG_SERIAL_BFIN_SPORT is not set
766CONFIG_UNIX98_PTYS=y
767# CONFIG_LEGACY_PTYS is not set
768
769#
770# CAN, the car bus and industrial fieldbus
771#
772CONFIG_CAN4LINUX=y
773
774#
775# linux embedded drivers
776#
777# CONFIG_CAN_MCF5282 is not set
778# CONFIG_CAN_UNCTWINCAN is not set
779CONFIG_CAN_BLACKFIN=m
780
781#
782# IPMI
783#
784# CONFIG_IPMI_HANDLER is not set
785
786#
787# Watchdog Cards
788#
789# CONFIG_WATCHDOG is not set
790CONFIG_HW_RANDOM=y
791# CONFIG_GEN_RTC is not set
792CONFIG_BLACKFIN_DPMC=y
793# CONFIG_DTLK is not set
794# CONFIG_R3964 is not set
795# CONFIG_RAW_DRIVER is not set
796
797#
798# TPM devices
799#
800# CONFIG_TCG_TPM is not set
801
802#
803# I2C support
804#
805CONFIG_I2C=m
806CONFIG_I2C_CHARDEV=m
807
808#
809# I2C Algorithms
810#
811# CONFIG_I2C_ALGOBIT is not set
812# CONFIG_I2C_ALGOPCF is not set
813# CONFIG_I2C_ALGOPCA is not set
814
815#
816# I2C Hardware Bus support
817#
818# CONFIG_I2C_BFIN_GPIO is not set
819CONFIG_I2C_BFIN_TWI=m
820CONFIG_TWICLK_KHZ=50
821# CONFIG_I2C_OCORES is not set
822# CONFIG_I2C_PARPORT_LIGHT is not set
823# CONFIG_I2C_STUB is not set
824# CONFIG_I2C_PCA_ISA is not set
825
826#
827# Miscellaneous I2C Chip support
828#
829# CONFIG_SENSORS_DS1337 is not set
830# CONFIG_SENSORS_DS1374 is not set
831CONFIG_SENSORS_AD5252=m
832# CONFIG_SENSORS_EEPROM is not set
833# CONFIG_SENSORS_PCF8574 is not set
834# CONFIG_SENSORS_PCF8575 is not set
835# CONFIG_SENSORS_PCA9539 is not set
836# CONFIG_SENSORS_PCF8591 is not set
837# CONFIG_SENSORS_MAX6875 is not set
838# CONFIG_I2C_DEBUG_CORE is not set
839# CONFIG_I2C_DEBUG_ALGO is not set
840# CONFIG_I2C_DEBUG_BUS is not set
841# CONFIG_I2C_DEBUG_CHIP is not set
842
843#
844# SPI support
845#
846CONFIG_SPI=y
847CONFIG_SPI_MASTER=y
848
849#
850# SPI Master Controller Drivers
851#
852# CONFIG_SPI_BITBANG is not set
853CONFIG_SPI_BFIN=y
854
855#
856# SPI Protocol Masters
857#
858
859#
860# Dallas's 1-wire bus
861#
862# CONFIG_W1 is not set
863
864#
865# Hardware Monitoring support
866#
867CONFIG_HWMON=y
868# CONFIG_HWMON_VID is not set
869# CONFIG_SENSORS_ABITUGURU is not set
870# CONFIG_SENSORS_ADM1021 is not set
871# CONFIG_SENSORS_ADM1025 is not set
872# CONFIG_SENSORS_ADM1026 is not set
873# CONFIG_SENSORS_ADM1031 is not set
874# CONFIG_SENSORS_ADM9240 is not set
875# CONFIG_SENSORS_ASB100 is not set
876# CONFIG_SENSORS_ATXP1 is not set
877# CONFIG_SENSORS_DS1621 is not set
878# CONFIG_SENSORS_F71805F is not set
879# CONFIG_SENSORS_FSCHER is not set
880# CONFIG_SENSORS_FSCPOS is not set
881# CONFIG_SENSORS_GL518SM is not set
882# CONFIG_SENSORS_GL520SM is not set
883# CONFIG_SENSORS_IT87 is not set
884# CONFIG_SENSORS_LM63 is not set
885# CONFIG_SENSORS_LM70 is not set
886# CONFIG_SENSORS_LM75 is not set
887# CONFIG_SENSORS_LM77 is not set
888# CONFIG_SENSORS_LM78 is not set
889# CONFIG_SENSORS_LM80 is not set
890# CONFIG_SENSORS_LM83 is not set
891# CONFIG_SENSORS_LM85 is not set
892# CONFIG_SENSORS_LM87 is not set
893# CONFIG_SENSORS_LM90 is not set
894# CONFIG_SENSORS_LM92 is not set
895# CONFIG_SENSORS_MAX1619 is not set
896# CONFIG_SENSORS_PC87360 is not set
897# CONFIG_SENSORS_PC87427 is not set
898# CONFIG_SENSORS_SMSC47M1 is not set
899# CONFIG_SENSORS_SMSC47M192 is not set
900# CONFIG_SENSORS_SMSC47B397 is not set
901# CONFIG_SENSORS_VT1211 is not set
902# CONFIG_SENSORS_W83781D is not set
903# CONFIG_SENSORS_W83791D is not set
904# CONFIG_SENSORS_W83792D is not set
905# CONFIG_SENSORS_W83793 is not set
906# CONFIG_SENSORS_W83L785TS is not set
907# CONFIG_SENSORS_W83627HF is not set
908# CONFIG_SENSORS_W83627EHF is not set
909# CONFIG_HWMON_DEBUG_CHIP is not set
910
911#
912# Multimedia devices
913#
914# CONFIG_VIDEO_DEV is not set
915
916#
917# Digital Video Broadcasting Devices
918#
919# CONFIG_DVB is not set
920
921#
922# Graphics support
923#
924CONFIG_FIRMWARE_EDID=y
925CONFIG_FB=m
926CONFIG_FB_CFB_FILLRECT=m
927CONFIG_FB_CFB_COPYAREA=m
928CONFIG_FB_CFB_IMAGEBLIT=m
929# CONFIG_FB_MACMODES is not set
930# CONFIG_FB_BACKLIGHT is not set
931# CONFIG_FB_MODE_HELPERS is not set
932# CONFIG_FB_TILEBLITTING is not set
933CONFIG_FB_BFIN_7171=m
934CONFIG_FB_BFIN_7393=m
935CONFIG_NTSC=y
936# CONFIG_PAL is not set
937# CONFIG_NTSC_640x480 is not set
938# CONFIG_PAL_640x480 is not set
939# CONFIG_NTSC_YCBCR is not set
940# CONFIG_PAL_YCBCR is not set
941CONFIG_ADV7393_1XMEM=y
942# CONFIG_ADV7393_2XMEM is not set
943CONFIG_FB_BF537_LQ035=m
944CONFIG_LQ035_SLAVE_ADDR=0x58
945# CONFIG_FB_BFIN_LANDSCAPE is not set
946# CONFIG_FB_BFIN_BGR is not set
947# CONFIG_FB_S1D13XXX is not set
948# CONFIG_FB_VIRTUAL is not set
949
950#
951# Logo configuration
952#
953# CONFIG_LOGO is not set
954CONFIG_BACKLIGHT_LCD_SUPPORT=y
955CONFIG_BACKLIGHT_CLASS_DEVICE=m
956CONFIG_BACKLIGHT_DEVICE=y
957CONFIG_LCD_CLASS_DEVICE=m
958CONFIG_LCD_DEVICE=y
959
960#
961# Sound
962#
963CONFIG_SOUND=m
964
965#
966# Advanced Linux Sound Architecture
967#
968CONFIG_SND=m
969CONFIG_SND_TIMER=m
970CONFIG_SND_PCM=m
971# CONFIG_SND_SEQUENCER is not set
972CONFIG_SND_OSSEMUL=y
973CONFIG_SND_MIXER_OSS=m
974CONFIG_SND_PCM_OSS=m
975CONFIG_SND_PCM_OSS_PLUGINS=y
976# CONFIG_SND_DYNAMIC_MINORS is not set
977CONFIG_SND_SUPPORT_OLD_API=y
978CONFIG_SND_VERBOSE_PROCFS=y
979# CONFIG_SND_VERBOSE_PRINTK is not set
980# CONFIG_SND_DEBUG is not set
981
982#
983# Generic devices
984#
985# CONFIG_SND_DUMMY is not set
986# CONFIG_SND_MTPAV is not set
987# CONFIG_SND_SERIAL_U16550 is not set
988# CONFIG_SND_MPU401 is not set
989
990#
991# Open Sound System
992#
993# CONFIG_SOUND_PRIME is not set
994
995#
996# HID Devices
997#
998CONFIG_HID=y
999
1000#
1001# USB support
1002#
1003CONFIG_USB_ARCH_HAS_HCD=y
1004# CONFIG_USB_ARCH_HAS_OHCI is not set
1005# CONFIG_USB_ARCH_HAS_EHCI is not set
1006# CONFIG_USB is not set
1007
1008#
1009# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
1010#
1011
1012#
1013# USB Gadget Support
1014#
1015# CONFIG_USB_GADGET is not set
1016
1017#
1018# MMC/SD Card support
1019#
1020# CONFIG_SPI_MMC is not set
1021# CONFIG_MMC is not set
1022
1023#
1024# LED devices
1025#
1026# CONFIG_NEW_LEDS is not set
1027
1028#
1029# LED drivers
1030#
1031
1032#
1033# LED Triggers
1034#
1035
1036#
1037# InfiniBand support
1038#
1039
1040#
1041# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
1042#
1043
1044#
1045# Real Time Clock
1046#
1047CONFIG_RTC_LIB=y
1048CONFIG_RTC_CLASS=y
1049CONFIG_RTC_HCTOSYS=y
1050CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
1051# CONFIG_RTC_DEBUG is not set
1052
1053#
1054# RTC interfaces
1055#
1056CONFIG_RTC_INTF_SYSFS=y
1057CONFIG_RTC_INTF_PROC=y
1058CONFIG_RTC_INTF_DEV=y
1059# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
1060
1061#
1062# RTC drivers
1063#
1064# CONFIG_RTC_DRV_X1205 is not set
1065# CONFIG_RTC_DRV_DS1307 is not set
1066# CONFIG_RTC_DRV_DS1553 is not set
1067# CONFIG_RTC_DRV_ISL1208 is not set
1068# CONFIG_RTC_DRV_DS1672 is not set
1069# CONFIG_RTC_DRV_DS1742 is not set
1070# CONFIG_RTC_DRV_PCF8563 is not set
1071# CONFIG_RTC_DRV_PCF8583 is not set
1072# CONFIG_RTC_DRV_RS5C348 is not set
1073# CONFIG_RTC_DRV_RS5C372 is not set
1074# CONFIG_RTC_DRV_M48T86 is not set
1075# CONFIG_RTC_DRV_TEST is not set
1076# CONFIG_RTC_DRV_MAX6902 is not set
1077# CONFIG_RTC_DRV_V3020 is not set
1078CONFIG_RTC_DRV_BFIN=y
1079
1080#
1081# DMA Engine support
1082#
1083# CONFIG_DMA_ENGINE is not set
1084
1085#
1086# DMA Clients
1087#
1088
1089#
1090# DMA Devices
1091#
1092
1093#
1094# Virtualization
1095#
1096
1097#
1098# PBX support
1099#
1100# CONFIG_PBX is not set
1101
1102#
1103# File systems
1104#
1105CONFIG_EXT2_FS=y
1106CONFIG_EXT2_FS_XATTR=y
1107# CONFIG_EXT2_FS_POSIX_ACL is not set
1108# CONFIG_EXT2_FS_SECURITY is not set
1109# CONFIG_EXT3_FS is not set
1110# CONFIG_EXT4DEV_FS is not set
1111CONFIG_FS_MBCACHE=y
1112# CONFIG_REISERFS_FS is not set
1113# CONFIG_JFS_FS is not set
1114# CONFIG_FS_POSIX_ACL is not set
1115# CONFIG_XFS_FS is not set
1116# CONFIG_GFS2_FS is not set
1117# CONFIG_OCFS2_FS is not set
1118# CONFIG_MINIX_FS is not set
1119# CONFIG_ROMFS_FS is not set
1120CONFIG_INOTIFY=y
1121CONFIG_INOTIFY_USER=y
1122# CONFIG_QUOTA is not set
1123CONFIG_DNOTIFY=y
1124# CONFIG_AUTOFS_FS is not set
1125# CONFIG_AUTOFS4_FS is not set
1126# CONFIG_FUSE_FS is not set
1127
1128#
1129# CD-ROM/DVD Filesystems
1130#
1131# CONFIG_ISO9660_FS is not set
1132# CONFIG_UDF_FS is not set
1133
1134#
1135# DOS/FAT/NT Filesystems
1136#
1137# CONFIG_MSDOS_FS is not set
1138# CONFIG_VFAT_FS is not set
1139# CONFIG_NTFS_FS is not set
1140
1141#
1142# Pseudo filesystems
1143#
1144CONFIG_PROC_FS=y
1145CONFIG_PROC_SYSCTL=y
1146CONFIG_SYSFS=y
1147# CONFIG_TMPFS is not set
1148# CONFIG_HUGETLB_PAGE is not set
1149CONFIG_RAMFS=y
1150# CONFIG_CONFIGFS_FS is not set
1151
1152#
1153# Miscellaneous filesystems
1154#
1155# CONFIG_ADFS_FS is not set
1156# CONFIG_AFFS_FS is not set
1157# CONFIG_HFS_FS is not set
1158# CONFIG_HFSPLUS_FS is not set
1159# CONFIG_BEFS_FS is not set
1160# CONFIG_BFS_FS is not set
1161# CONFIG_EFS_FS is not set
1162CONFIG_YAFFS_FS=m
1163CONFIG_YAFFS_YAFFS1=y
1164# CONFIG_YAFFS_DOES_ECC is not set
1165CONFIG_YAFFS_YAFFS2=y
1166CONFIG_YAFFS_AUTO_YAFFS2=y
1167# CONFIG_YAFFS_DISABLE_LAZY_LOAD is not set
1168CONFIG_YAFFS_CHECKPOINT_RESERVED_BLOCKS=10
1169# CONFIG_YAFFS_DISABLE_WIDE_TNODES is not set
1170# CONFIG_YAFFS_ALWAYS_CHECK_CHUNK_ERASED is not set
1171CONFIG_YAFFS_SHORT_NAMES_IN_RAM=y
1172CONFIG_JFFS2_FS=m
1173CONFIG_JFFS2_FS_DEBUG=0
1174CONFIG_JFFS2_FS_WRITEBUFFER=y
1175# CONFIG_JFFS2_SUMMARY is not set
1176# CONFIG_JFFS2_FS_XATTR is not set
1177# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
1178CONFIG_JFFS2_ZLIB=y
1179CONFIG_JFFS2_RTIME=y
1180# CONFIG_JFFS2_RUBIN is not set
1181# CONFIG_CRAMFS is not set
1182# CONFIG_VXFS_FS is not set
1183# CONFIG_HPFS_FS is not set
1184# CONFIG_QNX4FS_FS is not set
1185# CONFIG_SYSV_FS is not set
1186# CONFIG_UFS_FS is not set
1187
1188#
1189# Network File Systems
1190#
1191CONFIG_NFS_FS=m
1192CONFIG_NFS_V3=y
1193# CONFIG_NFS_V3_ACL is not set
1194# CONFIG_NFS_V4 is not set
1195# CONFIG_NFS_DIRECTIO is not set
1196# CONFIG_NFSD is not set
1197CONFIG_LOCKD=m
1198CONFIG_LOCKD_V4=y
1199CONFIG_NFS_COMMON=y
1200CONFIG_SUNRPC=m
1201# CONFIG_RPCSEC_GSS_KRB5 is not set
1202# CONFIG_RPCSEC_GSS_SPKM3 is not set
1203CONFIG_SMB_FS=m
1204# CONFIG_SMB_NLS_DEFAULT is not set
1205# CONFIG_CIFS is not set
1206# CONFIG_NCP_FS is not set
1207# CONFIG_CODA_FS is not set
1208# CONFIG_AFS_FS is not set
1209# CONFIG_9P_FS is not set
1210
1211#
1212# Partition Types
1213#
1214# CONFIG_PARTITION_ADVANCED is not set
1215CONFIG_MSDOS_PARTITION=y
1216
1217#
1218# Native Language Support
1219#
1220CONFIG_NLS=m
1221CONFIG_NLS_DEFAULT="iso8859-1"
1222# CONFIG_NLS_CODEPAGE_437 is not set
1223# CONFIG_NLS_CODEPAGE_737 is not set
1224# CONFIG_NLS_CODEPAGE_775 is not set
1225# CONFIG_NLS_CODEPAGE_850 is not set
1226# CONFIG_NLS_CODEPAGE_852 is not set
1227# CONFIG_NLS_CODEPAGE_855 is not set
1228# CONFIG_NLS_CODEPAGE_857 is not set
1229# CONFIG_NLS_CODEPAGE_860 is not set
1230# CONFIG_NLS_CODEPAGE_861 is not set
1231# CONFIG_NLS_CODEPAGE_862 is not set
1232# CONFIG_NLS_CODEPAGE_863 is not set
1233# CONFIG_NLS_CODEPAGE_864 is not set
1234# CONFIG_NLS_CODEPAGE_865 is not set
1235# CONFIG_NLS_CODEPAGE_866 is not set
1236# CONFIG_NLS_CODEPAGE_869 is not set
1237# CONFIG_NLS_CODEPAGE_936 is not set
1238# CONFIG_NLS_CODEPAGE_950 is not set
1239# CONFIG_NLS_CODEPAGE_932 is not set
1240# CONFIG_NLS_CODEPAGE_949 is not set
1241# CONFIG_NLS_CODEPAGE_874 is not set
1242# CONFIG_NLS_ISO8859_8 is not set
1243# CONFIG_NLS_CODEPAGE_1250 is not set
1244# CONFIG_NLS_CODEPAGE_1251 is not set
1245# CONFIG_NLS_ASCII is not set
1246# CONFIG_NLS_ISO8859_1 is not set
1247# CONFIG_NLS_ISO8859_2 is not set
1248# CONFIG_NLS_ISO8859_3 is not set
1249# CONFIG_NLS_ISO8859_4 is not set
1250# CONFIG_NLS_ISO8859_5 is not set
1251# CONFIG_NLS_ISO8859_6 is not set
1252# CONFIG_NLS_ISO8859_7 is not set
1253# CONFIG_NLS_ISO8859_9 is not set
1254# CONFIG_NLS_ISO8859_13 is not set
1255# CONFIG_NLS_ISO8859_14 is not set
1256# CONFIG_NLS_ISO8859_15 is not set
1257# CONFIG_NLS_KOI8_R is not set
1258# CONFIG_NLS_KOI8_U is not set
1259# CONFIG_NLS_UTF8 is not set
1260
1261#
1262# Distributed Lock Manager
1263#
1264# CONFIG_DLM is not set
1265
1266#
1267# Profiling support
1268#
1269# CONFIG_PROFILING is not set
1270
1271#
1272# Kernel hacking
1273#
1274# CONFIG_PRINTK_TIME is not set
1275CONFIG_ENABLE_MUST_CHECK=y
1276# CONFIG_MAGIC_SYSRQ is not set
1277# CONFIG_UNUSED_SYMBOLS is not set
1278# CONFIG_DEBUG_FS is not set
1279# CONFIG_HEADERS_CHECK is not set
1280# CONFIG_DEBUG_KERNEL is not set
1281CONFIG_LOG_BUF_SHIFT=14
1282# CONFIG_DEBUG_BUGVERBOSE is not set
1283CONFIG_DEBUG_HUNT_FOR_ZERO=y
1284# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
1285# CONFIG_BOOTPARAM is not set
1286# CONFIG_NO_KERNEL_MSG is not set
1287CONFIG_CPLB_INFO=y
1288# CONFIG_NO_ACCESS_CHECK is not set
1289
1290#
1291# Security options
1292#
1293# CONFIG_KEYS is not set
1294CONFIG_SECURITY=y
1295# CONFIG_SECURITY_NETWORK is not set
1296CONFIG_SECURITY_CAPABILITIES=y
1297
1298#
1299# Cryptographic options
1300#
1301# CONFIG_CRYPTO is not set
1302
1303#
1304# Library routines
1305#
1306CONFIG_BITREVERSE=y
1307CONFIG_CRC_CCITT=m
1308# CONFIG_CRC16 is not set
1309CONFIG_CRC32=y
1310# CONFIG_LIBCRC32C is not set
1311CONFIG_ZLIB_INFLATE=y
1312CONFIG_ZLIB_DEFLATE=m
1313CONFIG_PLIST=y
1314CONFIG_IOMAP_COPY=y
diff --git a/arch/blackfin/kernel/Makefile b/arch/blackfin/kernel/Makefile
new file mode 100644
index 000000000000..f3b7d2f9d49c
--- /dev/null
+++ b/arch/blackfin/kernel/Makefile
@@ -0,0 +1,14 @@
1#
2# arch/blackfin/kernel/Makefile
3#
4
5extra-y := init_task.o vmlinux.lds
6
7obj-y := \
8 entry.o process.o bfin_ksyms.o ptrace.o setup.o signal.o \
9 sys_bfin.o time.o traps.o irqchip.o dma-mapping.o bfin_gpio.o \
10 flat.o
11
12obj-$(CONFIG_MODULES) += module.o
13obj-$(CONFIG_BFIN_DMA_5XX) += bfin_dma_5xx.o
14obj-$(CONFIG_DUAL_CORE_TEST_MODULE) += dualcore_test.o
diff --git a/arch/blackfin/kernel/asm-offsets.c b/arch/blackfin/kernel/asm-offsets.c
new file mode 100644
index 000000000000..41d9a9f89700
--- /dev/null
+++ b/arch/blackfin/kernel/asm-offsets.c
@@ -0,0 +1,136 @@
1/*
2 * File: arch/blackfin/kernel/asm-offsets.c
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description: generate definitions needed by assembly language modules.
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/stddef.h>
31#include <linux/sched.h>
32#include <linux/kernel_stat.h>
33#include <linux/ptrace.h>
34#include <linux/hardirq.h>
35#include <asm/irq.h>
36#include <asm/thread_info.h>
37
38#define DEFINE(sym, val) \
39 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
40
41int main(void)
42{
43 /* offsets into the task struct */
44 DEFINE(TASK_STATE, offsetof(struct task_struct, state));
45 DEFINE(TASK_FLAGS, offsetof(struct task_struct, flags));
46 DEFINE(TASK_PTRACE, offsetof(struct task_struct, ptrace));
47 DEFINE(TASK_BLOCKED, offsetof(struct task_struct, blocked));
48 DEFINE(TASK_THREAD, offsetof(struct task_struct, thread));
49 DEFINE(TASK_THREAD_INFO, offsetof(struct task_struct, thread_info));
50 DEFINE(TASK_MM, offsetof(struct task_struct, mm));
51 DEFINE(TASK_ACTIVE_MM, offsetof(struct task_struct, active_mm));
52 DEFINE(TASK_SIGPENDING, offsetof(struct task_struct, pending));
53
54 /* offsets into the irq_cpustat_t struct */
55 DEFINE(CPUSTAT_SOFTIRQ_PENDING,
56 offsetof(irq_cpustat_t, __softirq_pending));
57
58 /* offsets into the thread struct */
59 DEFINE(THREAD_KSP, offsetof(struct thread_struct, ksp));
60 DEFINE(THREAD_USP, offsetof(struct thread_struct, usp));
61 DEFINE(THREAD_SR, offsetof(struct thread_struct, seqstat));
62 DEFINE(PT_SR, offsetof(struct thread_struct, seqstat));
63 DEFINE(THREAD_ESP0, offsetof(struct thread_struct, esp0));
64 DEFINE(THREAD_PC, offsetof(struct thread_struct, pc));
65 DEFINE(KERNEL_STACK_SIZE, THREAD_SIZE);
66
67 /* offsets into the pt_regs */
68 DEFINE(PT_ORIG_P0, offsetof(struct pt_regs, orig_p0));
69 DEFINE(PT_ORIG_PC, offsetof(struct pt_regs, orig_pc));
70 DEFINE(PT_R0, offsetof(struct pt_regs, r0));
71 DEFINE(PT_R1, offsetof(struct pt_regs, r1));
72 DEFINE(PT_R2, offsetof(struct pt_regs, r2));
73 DEFINE(PT_R3, offsetof(struct pt_regs, r3));
74 DEFINE(PT_R4, offsetof(struct pt_regs, r4));
75 DEFINE(PT_R5, offsetof(struct pt_regs, r5));
76 DEFINE(PT_R6, offsetof(struct pt_regs, r6));
77 DEFINE(PT_R7, offsetof(struct pt_regs, r7));
78
79 DEFINE(PT_P0, offsetof(struct pt_regs, p0));
80 DEFINE(PT_P1, offsetof(struct pt_regs, p1));
81 DEFINE(PT_P2, offsetof(struct pt_regs, p2));
82 DEFINE(PT_P3, offsetof(struct pt_regs, p3));
83 DEFINE(PT_P4, offsetof(struct pt_regs, p4));
84 DEFINE(PT_P5, offsetof(struct pt_regs, p5));
85
86 DEFINE(PT_FP, offsetof(struct pt_regs, fp));
87 DEFINE(PT_USP, offsetof(struct pt_regs, usp));
88 DEFINE(PT_I0, offsetof(struct pt_regs, i0));
89 DEFINE(PT_I1, offsetof(struct pt_regs, i1));
90 DEFINE(PT_I2, offsetof(struct pt_regs, i2));
91 DEFINE(PT_I3, offsetof(struct pt_regs, i3));
92 DEFINE(PT_M0, offsetof(struct pt_regs, m0));
93 DEFINE(PT_M1, offsetof(struct pt_regs, m1));
94 DEFINE(PT_M2, offsetof(struct pt_regs, m2));
95 DEFINE(PT_M3, offsetof(struct pt_regs, m3));
96 DEFINE(PT_L0, offsetof(struct pt_regs, l0));
97 DEFINE(PT_L1, offsetof(struct pt_regs, l1));
98 DEFINE(PT_L2, offsetof(struct pt_regs, l2));
99 DEFINE(PT_L3, offsetof(struct pt_regs, l3));
100 DEFINE(PT_B0, offsetof(struct pt_regs, b0));
101 DEFINE(PT_B1, offsetof(struct pt_regs, b1));
102 DEFINE(PT_B2, offsetof(struct pt_regs, b2));
103 DEFINE(PT_B3, offsetof(struct pt_regs, b3));
104 DEFINE(PT_A0X, offsetof(struct pt_regs, a0x));
105 DEFINE(PT_A0W, offsetof(struct pt_regs, a0w));
106 DEFINE(PT_A1X, offsetof(struct pt_regs, a1x));
107 DEFINE(PT_A1W, offsetof(struct pt_regs, a1w));
108 DEFINE(PT_LC0, offsetof(struct pt_regs, lc0));
109 DEFINE(PT_LC1, offsetof(struct pt_regs, lc1));
110 DEFINE(PT_LT0, offsetof(struct pt_regs, lt0));
111 DEFINE(PT_LT1, offsetof(struct pt_regs, lt1));
112 DEFINE(PT_LB0, offsetof(struct pt_regs, lb0));
113 DEFINE(PT_LB1, offsetof(struct pt_regs, lb1));
114 DEFINE(PT_ASTAT, offsetof(struct pt_regs, astat));
115 DEFINE(PT_RESERVED, offsetof(struct pt_regs, reserved));
116 DEFINE(PT_RETS, offsetof(struct pt_regs, rets));
117 DEFINE(PT_PC, offsetof(struct pt_regs, pc));
118 DEFINE(PT_RETX, offsetof(struct pt_regs, retx));
119 DEFINE(PT_RETN, offsetof(struct pt_regs, retn));
120 DEFINE(PT_RETE, offsetof(struct pt_regs, rete));
121 DEFINE(PT_SEQSTAT, offsetof(struct pt_regs, seqstat));
122 DEFINE(PT_SYSCFG, offsetof(struct pt_regs, syscfg));
123 DEFINE(PT_IPEND, offsetof(struct pt_regs, ipend));
124 DEFINE(SIZEOF_PTREGS, sizeof(struct pt_regs));
125 DEFINE(PT_TEXT_ADDR, sizeof(struct pt_regs)); /* Needed by gdb */
126 DEFINE(PT_TEXT_END_ADDR, 4 + sizeof(struct pt_regs));/* Needed by gdb */
127 DEFINE(PT_DATA_ADDR, 8 + sizeof(struct pt_regs)); /* Needed by gdb */
128 DEFINE(PT_FDPIC_EXEC, 12 + sizeof(struct pt_regs)); /* Needed by gdb */
129 DEFINE(PT_FDPIC_INTERP, 16 + sizeof(struct pt_regs));/* Needed by gdb */
130
131 /* signal defines */
132 DEFINE(SIGSEGV, SIGSEGV);
133 DEFINE(SIGTRAP, SIGTRAP);
134
135 return 0;
136}
diff --git a/arch/blackfin/kernel/bfin_dma_5xx.c b/arch/blackfin/kernel/bfin_dma_5xx.c
new file mode 100644
index 000000000000..8ea079ebecb5
--- /dev/null
+++ b/arch/blackfin/kernel/bfin_dma_5xx.c
@@ -0,0 +1,742 @@
1/*
2 * File: arch/blackfin/kernel/bfin_dma_5xx.c
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description: This file contains the simple DMA Implementation for Blackfin
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/errno.h>
31#include <linux/module.h>
32#include <linux/sched.h>
33#include <linux/interrupt.h>
34#include <linux/kernel.h>
35#include <linux/param.h>
36
37#include <asm/dma.h>
38#include <asm/cacheflush.h>
39
40/* Remove unused code not exported by symbol or internally called */
41#define REMOVE_DEAD_CODE
42
43/**************************************************************************
44 * Global Variables
45***************************************************************************/
46
47static struct dma_channel dma_ch[MAX_BLACKFIN_DMA_CHANNEL];
48#if defined (CONFIG_BF561)
49static struct dma_register *base_addr[MAX_BLACKFIN_DMA_CHANNEL] = {
50 (struct dma_register *) DMA1_0_NEXT_DESC_PTR,
51 (struct dma_register *) DMA1_1_NEXT_DESC_PTR,
52 (struct dma_register *) DMA1_2_NEXT_DESC_PTR,
53 (struct dma_register *) DMA1_3_NEXT_DESC_PTR,
54 (struct dma_register *) DMA1_4_NEXT_DESC_PTR,
55 (struct dma_register *) DMA1_5_NEXT_DESC_PTR,
56 (struct dma_register *) DMA1_6_NEXT_DESC_PTR,
57 (struct dma_register *) DMA1_7_NEXT_DESC_PTR,
58 (struct dma_register *) DMA1_8_NEXT_DESC_PTR,
59 (struct dma_register *) DMA1_9_NEXT_DESC_PTR,
60 (struct dma_register *) DMA1_10_NEXT_DESC_PTR,
61 (struct dma_register *) DMA1_11_NEXT_DESC_PTR,
62 (struct dma_register *) DMA2_0_NEXT_DESC_PTR,
63 (struct dma_register *) DMA2_1_NEXT_DESC_PTR,
64 (struct dma_register *) DMA2_2_NEXT_DESC_PTR,
65 (struct dma_register *) DMA2_3_NEXT_DESC_PTR,
66 (struct dma_register *) DMA2_4_NEXT_DESC_PTR,
67 (struct dma_register *) DMA2_5_NEXT_DESC_PTR,
68 (struct dma_register *) DMA2_6_NEXT_DESC_PTR,
69 (struct dma_register *) DMA2_7_NEXT_DESC_PTR,
70 (struct dma_register *) DMA2_8_NEXT_DESC_PTR,
71 (struct dma_register *) DMA2_9_NEXT_DESC_PTR,
72 (struct dma_register *) DMA2_10_NEXT_DESC_PTR,
73 (struct dma_register *) DMA2_11_NEXT_DESC_PTR,
74 (struct dma_register *) MDMA1_D0_NEXT_DESC_PTR,
75 (struct dma_register *) MDMA1_S0_NEXT_DESC_PTR,
76 (struct dma_register *) MDMA1_D1_NEXT_DESC_PTR,
77 (struct dma_register *) MDMA1_S1_NEXT_DESC_PTR,
78 (struct dma_register *) MDMA2_D0_NEXT_DESC_PTR,
79 (struct dma_register *) MDMA2_S0_NEXT_DESC_PTR,
80 (struct dma_register *) MDMA2_D1_NEXT_DESC_PTR,
81 (struct dma_register *) MDMA2_S1_NEXT_DESC_PTR,
82 (struct dma_register *) IMDMA_D0_NEXT_DESC_PTR,
83 (struct dma_register *) IMDMA_S0_NEXT_DESC_PTR,
84 (struct dma_register *) IMDMA_D1_NEXT_DESC_PTR,
85 (struct dma_register *) IMDMA_S1_NEXT_DESC_PTR,
86};
87#else
88static struct dma_register *base_addr[MAX_BLACKFIN_DMA_CHANNEL] = {
89 (struct dma_register *) DMA0_NEXT_DESC_PTR,
90 (struct dma_register *) DMA1_NEXT_DESC_PTR,
91 (struct dma_register *) DMA2_NEXT_DESC_PTR,
92 (struct dma_register *) DMA3_NEXT_DESC_PTR,
93 (struct dma_register *) DMA4_NEXT_DESC_PTR,
94 (struct dma_register *) DMA5_NEXT_DESC_PTR,
95 (struct dma_register *) DMA6_NEXT_DESC_PTR,
96 (struct dma_register *) DMA7_NEXT_DESC_PTR,
97#if (defined(CONFIG_BF537) || defined(CONFIG_BF534) || defined(CONFIG_BF536))
98 (struct dma_register *) DMA8_NEXT_DESC_PTR,
99 (struct dma_register *) DMA9_NEXT_DESC_PTR,
100 (struct dma_register *) DMA10_NEXT_DESC_PTR,
101 (struct dma_register *) DMA11_NEXT_DESC_PTR,
102#endif
103 (struct dma_register *) MDMA_D0_NEXT_DESC_PTR,
104 (struct dma_register *) MDMA_S0_NEXT_DESC_PTR,
105 (struct dma_register *) MDMA_D1_NEXT_DESC_PTR,
106 (struct dma_register *) MDMA_S1_NEXT_DESC_PTR,
107};
108#endif
109
110/*------------------------------------------------------------------------------
111 * Set the Buffer Clear bit in the Configuration register of specific DMA
112 * channel. This will stop the descriptor based DMA operation.
113 *-----------------------------------------------------------------------------*/
114static void clear_dma_buffer(unsigned int channel)
115{
116 dma_ch[channel].regs->cfg |= RESTART;
117 SSYNC();
118 dma_ch[channel].regs->cfg &= ~RESTART;
119 SSYNC();
120}
121
122int __init blackfin_dma_init(void)
123{
124 int i;
125
126 printk(KERN_INFO "Blackfin DMA Controller\n");
127
128 for (i = 0; i < MAX_BLACKFIN_DMA_CHANNEL; i++) {
129 dma_ch[i].chan_status = DMA_CHANNEL_FREE;
130 dma_ch[i].regs = base_addr[i];
131 mutex_init(&(dma_ch[i].dmalock));
132 }
133
134 return 0;
135}
136
137arch_initcall(blackfin_dma_init);
138
139/*
140 * Form the channel find the irq number for that channel.
141 */
142#if !defined(CONFIG_BF561)
143
144static int bf533_channel2irq(unsigned int channel)
145{
146 int ret_irq = -1;
147
148 switch (channel) {
149 case CH_PPI:
150 ret_irq = IRQ_PPI;
151 break;
152
153#if (defined(CONFIG_BF537) || defined(CONFIG_BF534) || defined(CONFIG_BF536))
154 case CH_EMAC_RX:
155 ret_irq = IRQ_MAC_RX;
156 break;
157
158 case CH_EMAC_TX:
159 ret_irq = IRQ_MAC_TX;
160 break;
161
162 case CH_UART1_RX:
163 ret_irq = IRQ_UART1_RX;
164 break;
165
166 case CH_UART1_TX:
167 ret_irq = IRQ_UART1_TX;
168 break;
169#endif
170
171 case CH_SPORT0_RX:
172 ret_irq = IRQ_SPORT0_RX;
173 break;
174
175 case CH_SPORT0_TX:
176 ret_irq = IRQ_SPORT0_TX;
177 break;
178
179 case CH_SPORT1_RX:
180 ret_irq = IRQ_SPORT1_RX;
181 break;
182
183 case CH_SPORT1_TX:
184 ret_irq = IRQ_SPORT1_TX;
185 break;
186
187 case CH_SPI:
188 ret_irq = IRQ_SPI;
189 break;
190
191 case CH_UART_RX:
192 ret_irq = IRQ_UART_RX;
193 break;
194
195 case CH_UART_TX:
196 ret_irq = IRQ_UART_TX;
197 break;
198
199 case CH_MEM_STREAM0_SRC:
200 case CH_MEM_STREAM0_DEST:
201 ret_irq = IRQ_MEM_DMA0;
202 break;
203
204 case CH_MEM_STREAM1_SRC:
205 case CH_MEM_STREAM1_DEST:
206 ret_irq = IRQ_MEM_DMA1;
207 break;
208 }
209 return ret_irq;
210}
211
212# define channel2irq(channel) bf533_channel2irq(channel)
213
214#else
215
216static int bf561_channel2irq(unsigned int channel)
217{
218 int ret_irq = -1;
219
220 switch (channel) {
221 case CH_PPI0:
222 ret_irq = IRQ_PPI0;
223 break;
224 case CH_PPI1:
225 ret_irq = IRQ_PPI1;
226 break;
227 case CH_SPORT0_RX:
228 ret_irq = IRQ_SPORT0_RX;
229 break;
230 case CH_SPORT0_TX:
231 ret_irq = IRQ_SPORT0_TX;
232 break;
233 case CH_SPORT1_RX:
234 ret_irq = IRQ_SPORT1_RX;
235 break;
236 case CH_SPORT1_TX:
237 ret_irq = IRQ_SPORT1_TX;
238 break;
239 case CH_SPI:
240 ret_irq = IRQ_SPI;
241 break;
242 case CH_UART_RX:
243 ret_irq = IRQ_UART_RX;
244 break;
245 case CH_UART_TX:
246 ret_irq = IRQ_UART_TX;
247 break;
248
249 case CH_MEM_STREAM0_SRC:
250 case CH_MEM_STREAM0_DEST:
251 ret_irq = IRQ_MEM_DMA0;
252 break;
253 case CH_MEM_STREAM1_SRC:
254 case CH_MEM_STREAM1_DEST:
255 ret_irq = IRQ_MEM_DMA1;
256 break;
257 case CH_MEM_STREAM2_SRC:
258 case CH_MEM_STREAM2_DEST:
259 ret_irq = IRQ_MEM_DMA2;
260 break;
261 case CH_MEM_STREAM3_SRC:
262 case CH_MEM_STREAM3_DEST:
263 ret_irq = IRQ_MEM_DMA3;
264 break;
265
266 case CH_IMEM_STREAM0_SRC:
267 case CH_IMEM_STREAM0_DEST:
268 ret_irq = IRQ_IMEM_DMA0;
269 break;
270 case CH_IMEM_STREAM1_SRC:
271 case CH_IMEM_STREAM1_DEST:
272 ret_irq = IRQ_IMEM_DMA1;
273 break;
274 }
275 return ret_irq;
276}
277
278# define channel2irq(channel) bf561_channel2irq(channel)
279
280#endif
281
282/*------------------------------------------------------------------------------
283 * Request the specific DMA channel from the system.
284 *-----------------------------------------------------------------------------*/
285int request_dma(unsigned int channel, char *device_id)
286{
287
288 pr_debug("request_dma() : BEGIN \n");
289 mutex_lock(&(dma_ch[channel].dmalock));
290
291 if ((dma_ch[channel].chan_status == DMA_CHANNEL_REQUESTED)
292 || (dma_ch[channel].chan_status == DMA_CHANNEL_ENABLED)) {
293 mutex_unlock(&(dma_ch[channel].dmalock));
294 pr_debug("DMA CHANNEL IN USE \n");
295 return -EBUSY;
296 } else {
297 dma_ch[channel].chan_status = DMA_CHANNEL_REQUESTED;
298 pr_debug("DMA CHANNEL IS ALLOCATED \n");
299 }
300
301 mutex_unlock(&(dma_ch[channel].dmalock));
302
303 dma_ch[channel].device_id = device_id;
304 dma_ch[channel].irq_callback = NULL;
305
306 /* This is to be enabled by putting a restriction -
307 * you have to request DMA, before doing any operations on
308 * descriptor/channel
309 */
310 pr_debug("request_dma() : END \n");
311 return channel;
312}
313EXPORT_SYMBOL(request_dma);
314
315int set_dma_callback(unsigned int channel, dma_interrupt_t callback, void *data)
316{
317 int ret_irq = 0;
318
319 BUG_ON(!(dma_ch[channel].chan_status != DMA_CHANNEL_FREE
320 && channel < MAX_BLACKFIN_DMA_CHANNEL));
321
322 if (callback != NULL) {
323 int ret_val;
324 ret_irq = channel2irq(channel);
325
326 dma_ch[channel].data = data;
327
328 ret_val =
329 request_irq(ret_irq, (void *)callback, IRQF_DISABLED,
330 dma_ch[channel].device_id, data);
331 if (ret_val) {
332 printk(KERN_NOTICE
333 "Request irq in DMA engine failed.\n");
334 return -EPERM;
335 }
336 dma_ch[channel].irq_callback = callback;
337 }
338 return 0;
339}
340EXPORT_SYMBOL(set_dma_callback);
341
342void free_dma(unsigned int channel)
343{
344 int ret_irq;
345
346 pr_debug("freedma() : BEGIN \n");
347 BUG_ON(!(dma_ch[channel].chan_status != DMA_CHANNEL_FREE
348 && channel < MAX_BLACKFIN_DMA_CHANNEL));
349
350 /* Halt the DMA */
351 disable_dma(channel);
352 clear_dma_buffer(channel);
353
354 if (dma_ch[channel].irq_callback != NULL) {
355 ret_irq = channel2irq(channel);
356 free_irq(ret_irq, dma_ch[channel].data);
357 }
358
359 /* Clear the DMA Variable in the Channel */
360 mutex_lock(&(dma_ch[channel].dmalock));
361 dma_ch[channel].chan_status = DMA_CHANNEL_FREE;
362 mutex_unlock(&(dma_ch[channel].dmalock));
363
364 pr_debug("freedma() : END \n");
365}
366EXPORT_SYMBOL(free_dma);
367
368void dma_enable_irq(unsigned int channel)
369{
370 int ret_irq;
371
372 pr_debug("dma_enable_irq() : BEGIN \n");
373 BUG_ON(!(dma_ch[channel].chan_status != DMA_CHANNEL_FREE
374 && channel < MAX_BLACKFIN_DMA_CHANNEL));
375
376 ret_irq = channel2irq(channel);
377 enable_irq(ret_irq);
378}
379EXPORT_SYMBOL(dma_enable_irq);
380
381void dma_disable_irq(unsigned int channel)
382{
383 int ret_irq;
384
385 pr_debug("dma_disable_irq() : BEGIN \n");
386 BUG_ON(!(dma_ch[channel].chan_status != DMA_CHANNEL_FREE
387 && channel < MAX_BLACKFIN_DMA_CHANNEL));
388
389 ret_irq = channel2irq(channel);
390 disable_irq(ret_irq);
391}
392EXPORT_SYMBOL(dma_disable_irq);
393
394int dma_channel_active(unsigned int channel)
395{
396 if (dma_ch[channel].chan_status == DMA_CHANNEL_FREE) {
397 return 0;
398 } else {
399 return 1;
400 }
401}
402EXPORT_SYMBOL(dma_channel_active);
403
404/*------------------------------------------------------------------------------
405* stop the specific DMA channel.
406*-----------------------------------------------------------------------------*/
407void disable_dma(unsigned int channel)
408{
409 pr_debug("stop_dma() : BEGIN \n");
410
411 BUG_ON(!(dma_ch[channel].chan_status != DMA_CHANNEL_FREE
412 && channel < MAX_BLACKFIN_DMA_CHANNEL));
413
414 dma_ch[channel].regs->cfg &= ~DMAEN; /* Clean the enable bit */
415 SSYNC();
416 dma_ch[channel].chan_status = DMA_CHANNEL_REQUESTED;
417 /* Needs to be enabled Later */
418 pr_debug("stop_dma() : END \n");
419 return;
420}
421EXPORT_SYMBOL(disable_dma);
422
423void enable_dma(unsigned int channel)
424{
425 pr_debug("enable_dma() : BEGIN \n");
426
427 BUG_ON(!(dma_ch[channel].chan_status != DMA_CHANNEL_FREE
428 && channel < MAX_BLACKFIN_DMA_CHANNEL));
429
430 dma_ch[channel].chan_status = DMA_CHANNEL_ENABLED;
431 dma_ch[channel].regs->curr_x_count = 0;
432 dma_ch[channel].regs->curr_y_count = 0;
433
434 dma_ch[channel].regs->cfg |= DMAEN; /* Set the enable bit */
435 SSYNC();
436 pr_debug("enable_dma() : END \n");
437 return;
438}
439EXPORT_SYMBOL(enable_dma);
440
441/*------------------------------------------------------------------------------
442* Set the Start Address register for the specific DMA channel
443* This function can be used for register based DMA,
444* to setup the start address
445* addr: Starting address of the DMA Data to be transferred.
446*-----------------------------------------------------------------------------*/
447void set_dma_start_addr(unsigned int channel, unsigned long addr)
448{
449 pr_debug("set_dma_start_addr() : BEGIN \n");
450
451 BUG_ON(!(dma_ch[channel].chan_status != DMA_CHANNEL_FREE
452 && channel < MAX_BLACKFIN_DMA_CHANNEL));
453
454 dma_ch[channel].regs->start_addr = addr;
455 SSYNC();
456 pr_debug("set_dma_start_addr() : END\n");
457}
458EXPORT_SYMBOL(set_dma_start_addr);
459
460void set_dma_next_desc_addr(unsigned int channel, unsigned long addr)
461{
462 pr_debug("set_dma_next_desc_addr() : BEGIN \n");
463
464 BUG_ON(!(dma_ch[channel].chan_status != DMA_CHANNEL_FREE
465 && channel < MAX_BLACKFIN_DMA_CHANNEL));
466
467 dma_ch[channel].regs->next_desc_ptr = addr;
468 SSYNC();
469 pr_debug("set_dma_start_addr() : END\n");
470}
471EXPORT_SYMBOL(set_dma_next_desc_addr);
472
473void set_dma_x_count(unsigned int channel, unsigned short x_count)
474{
475 BUG_ON(!(dma_ch[channel].chan_status != DMA_CHANNEL_FREE
476 && channel < MAX_BLACKFIN_DMA_CHANNEL));
477
478 dma_ch[channel].regs->x_count = x_count;
479 SSYNC();
480}
481EXPORT_SYMBOL(set_dma_x_count);
482
483void set_dma_y_count(unsigned int channel, unsigned short y_count)
484{
485 BUG_ON(!(dma_ch[channel].chan_status != DMA_CHANNEL_FREE
486 && channel < MAX_BLACKFIN_DMA_CHANNEL));
487
488 dma_ch[channel].regs->y_count = y_count;
489 SSYNC();
490}
491EXPORT_SYMBOL(set_dma_y_count);
492
493void set_dma_x_modify(unsigned int channel, short x_modify)
494{
495 BUG_ON(!(dma_ch[channel].chan_status != DMA_CHANNEL_FREE
496 && channel < MAX_BLACKFIN_DMA_CHANNEL));
497
498 dma_ch[channel].regs->x_modify = x_modify;
499 SSYNC();
500}
501EXPORT_SYMBOL(set_dma_x_modify);
502
503void set_dma_y_modify(unsigned int channel, short y_modify)
504{
505 BUG_ON(!(dma_ch[channel].chan_status != DMA_CHANNEL_FREE
506 && channel < MAX_BLACKFIN_DMA_CHANNEL));
507
508 dma_ch[channel].regs->y_modify = y_modify;
509 SSYNC();
510}
511EXPORT_SYMBOL(set_dma_y_modify);
512
513void set_dma_config(unsigned int channel, unsigned short config)
514{
515 BUG_ON(!(dma_ch[channel].chan_status != DMA_CHANNEL_FREE
516 && channel < MAX_BLACKFIN_DMA_CHANNEL));
517
518 dma_ch[channel].regs->cfg = config;
519 SSYNC();
520}
521EXPORT_SYMBOL(set_dma_config);
522
523unsigned short
524set_bfin_dma_config(char direction, char flow_mode,
525 char intr_mode, char dma_mode, char width)
526{
527 unsigned short config;
528
529 config =
530 ((direction << 1) | (width << 2) | (dma_mode << 4) |
531 (intr_mode << 6) | (flow_mode << 12) | RESTART);
532 return config;
533}
534EXPORT_SYMBOL(set_bfin_dma_config);
535
536void set_dma_sg(unsigned int channel, struct dmasg * sg, int nr_sg)
537{
538 BUG_ON(!(dma_ch[channel].chan_status != DMA_CHANNEL_FREE
539 && channel < MAX_BLACKFIN_DMA_CHANNEL));
540
541 dma_ch[channel].regs->cfg |= ((nr_sg & 0x0F) << 8);
542
543 dma_ch[channel].regs->next_desc_ptr = (unsigned int)sg;
544
545 SSYNC();
546}
547EXPORT_SYMBOL(set_dma_sg);
548
549/*------------------------------------------------------------------------------
550 * Get the DMA status of a specific DMA channel from the system.
551 *-----------------------------------------------------------------------------*/
552unsigned short get_dma_curr_irqstat(unsigned int channel)
553{
554 BUG_ON(!(dma_ch[channel].chan_status != DMA_CHANNEL_FREE
555 && channel < MAX_BLACKFIN_DMA_CHANNEL));
556
557 return dma_ch[channel].regs->irq_status;
558}
559EXPORT_SYMBOL(get_dma_curr_irqstat);
560
561/*------------------------------------------------------------------------------
562 * Clear the DMA_DONE bit in DMA status. Stop the DMA completion interrupt.
563 *-----------------------------------------------------------------------------*/
564void clear_dma_irqstat(unsigned int channel)
565{
566 BUG_ON(!(dma_ch[channel].chan_status != DMA_CHANNEL_FREE
567 && channel < MAX_BLACKFIN_DMA_CHANNEL));
568 dma_ch[channel].regs->irq_status |= 3;
569}
570EXPORT_SYMBOL(clear_dma_irqstat);
571
572/*------------------------------------------------------------------------------
573 * Get current DMA xcount of a specific DMA channel from the system.
574 *-----------------------------------------------------------------------------*/
575unsigned short get_dma_curr_xcount(unsigned int channel)
576{
577 BUG_ON(!(dma_ch[channel].chan_status != DMA_CHANNEL_FREE
578 && channel < MAX_BLACKFIN_DMA_CHANNEL));
579
580 return dma_ch[channel].regs->curr_x_count;
581}
582EXPORT_SYMBOL(get_dma_curr_xcount);
583
584/*------------------------------------------------------------------------------
585 * Get current DMA ycount of a specific DMA channel from the system.
586 *-----------------------------------------------------------------------------*/
587unsigned short get_dma_curr_ycount(unsigned int channel)
588{
589 BUG_ON(!(dma_ch[channel].chan_status != DMA_CHANNEL_FREE
590 && channel < MAX_BLACKFIN_DMA_CHANNEL));
591
592 return dma_ch[channel].regs->curr_y_count;
593}
594EXPORT_SYMBOL(get_dma_curr_ycount);
595
596void *dma_memcpy(void *dest, const void *src, size_t size)
597{
598 int direction; /* 1 - address decrease, 0 - address increase */
599 int flag_align; /* 1 - address aligned, 0 - address unaligned */
600 int flag_2D; /* 1 - 2D DMA needed, 0 - 1D DMA needed */
601
602 if (size <= 0)
603 return NULL;
604
605 if ((unsigned long)src < memory_end)
606 blackfin_dcache_flush_range((unsigned int)src,
607 (unsigned int)(src + size));
608
609 bfin_write_MDMA_D0_IRQ_STATUS(DMA_DONE | DMA_ERR);
610
611 if ((unsigned long)src < (unsigned long)dest)
612 direction = 1;
613 else
614 direction = 0;
615
616 if ((((unsigned long)dest % 2) == 0) && (((unsigned long)src % 2) == 0)
617 && ((size % 2) == 0))
618 flag_align = 1;
619 else
620 flag_align = 0;
621
622 if (size > 0x10000) /* size > 64K */
623 flag_2D = 1;
624 else
625 flag_2D = 0;
626
627 /* Setup destination and source start address */
628 if (direction) {
629 if (flag_align) {
630 bfin_write_MDMA_D0_START_ADDR(dest + size - 2);
631 bfin_write_MDMA_S0_START_ADDR(src + size - 2);
632 } else {
633 bfin_write_MDMA_D0_START_ADDR(dest + size - 1);
634 bfin_write_MDMA_S0_START_ADDR(src + size - 1);
635 }
636 } else {
637 bfin_write_MDMA_D0_START_ADDR(dest);
638 bfin_write_MDMA_S0_START_ADDR(src);
639 }
640
641 /* Setup destination and source xcount */
642 if (flag_2D) {
643 if (flag_align) {
644 bfin_write_MDMA_D0_X_COUNT(1024 / 2);
645 bfin_write_MDMA_S0_X_COUNT(1024 / 2);
646 } else {
647 bfin_write_MDMA_D0_X_COUNT(1024);
648 bfin_write_MDMA_S0_X_COUNT(1024);
649 }
650 bfin_write_MDMA_D0_Y_COUNT(size >> 10);
651 bfin_write_MDMA_S0_Y_COUNT(size >> 10);
652 } else {
653 if (flag_align) {
654 bfin_write_MDMA_D0_X_COUNT(size / 2);
655 bfin_write_MDMA_S0_X_COUNT(size / 2);
656 } else {
657 bfin_write_MDMA_D0_X_COUNT(size);
658 bfin_write_MDMA_S0_X_COUNT(size);
659 }
660 }
661
662 /* Setup destination and source xmodify and ymodify */
663 if (direction) {
664 if (flag_align) {
665 bfin_write_MDMA_D0_X_MODIFY(-2);
666 bfin_write_MDMA_S0_X_MODIFY(-2);
667 if (flag_2D) {
668 bfin_write_MDMA_D0_Y_MODIFY(-2);
669 bfin_write_MDMA_S0_Y_MODIFY(-2);
670 }
671 } else {
672 bfin_write_MDMA_D0_X_MODIFY(-1);
673 bfin_write_MDMA_S0_X_MODIFY(-1);
674 if (flag_2D) {
675 bfin_write_MDMA_D0_Y_MODIFY(-1);
676 bfin_write_MDMA_S0_Y_MODIFY(-1);
677 }
678 }
679 } else {
680 if (flag_align) {
681 bfin_write_MDMA_D0_X_MODIFY(2);
682 bfin_write_MDMA_S0_X_MODIFY(2);
683 if (flag_2D) {
684 bfin_write_MDMA_D0_Y_MODIFY(2);
685 bfin_write_MDMA_S0_Y_MODIFY(2);
686 }
687 } else {
688 bfin_write_MDMA_D0_X_MODIFY(1);
689 bfin_write_MDMA_S0_X_MODIFY(1);
690 if (flag_2D) {
691 bfin_write_MDMA_D0_Y_MODIFY(1);
692 bfin_write_MDMA_S0_Y_MODIFY(1);
693 }
694 }
695 }
696
697 /* Enable source DMA */
698 if (flag_2D) {
699 if (flag_align) {
700 bfin_write_MDMA_S0_CONFIG(DMAEN | DMA2D | WDSIZE_16);
701 bfin_write_MDMA_D0_CONFIG(WNR | DI_EN | DMAEN | DMA2D | WDSIZE_16);
702 } else {
703 bfin_write_MDMA_S0_CONFIG(DMAEN | DMA2D);
704 bfin_write_MDMA_D0_CONFIG(WNR | DI_EN | DMAEN | DMA2D);
705 }
706 } else {
707 if (flag_align) {
708 bfin_write_MDMA_S0_CONFIG(DMAEN | WDSIZE_16);
709 bfin_write_MDMA_D0_CONFIG(WNR | DI_EN | DMAEN | WDSIZE_16);
710 } else {
711 bfin_write_MDMA_S0_CONFIG(DMAEN);
712 bfin_write_MDMA_D0_CONFIG(WNR | DI_EN | DMAEN);
713 }
714 }
715
716 while (!(bfin_read_MDMA_D0_IRQ_STATUS() & DMA_DONE))
717 ;
718
719 bfin_write_MDMA_D0_IRQ_STATUS(bfin_read_MDMA_D0_IRQ_STATUS() |
720 (DMA_DONE | DMA_ERR));
721
722 bfin_write_MDMA_S0_CONFIG(0);
723 bfin_write_MDMA_D0_CONFIG(0);
724
725 if ((unsigned long)dest < memory_end)
726 blackfin_dcache_invalidate_range((unsigned int)dest,
727 (unsigned int)(dest + size));
728
729 return dest;
730}
731EXPORT_SYMBOL(dma_memcpy);
732
733void *safe_dma_memcpy(void *dest, const void *src, size_t size)
734{
735 int flags = 0;
736 void *addr;
737 local_irq_save(flags);
738 addr = dma_memcpy(dest, src, size);
739 local_irq_restore(flags);
740 return addr;
741}
742EXPORT_SYMBOL(safe_dma_memcpy);
diff --git a/arch/blackfin/kernel/bfin_gpio.c b/arch/blackfin/kernel/bfin_gpio.c
new file mode 100644
index 000000000000..e9f24a9a46ba
--- /dev/null
+++ b/arch/blackfin/kernel/bfin_gpio.c
@@ -0,0 +1,637 @@
1/*
2 * File: arch/blackfin/kernel/bfin_gpio.c
3 * Based on:
4 * Author: Michael Hennerich (hennerich@blackfin.uclinux.org)
5 *
6 * Created:
7 * Description: GPIO Abstraction Layer
8 *
9 * Modified:
10 * Copyright 2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30/*
31* Number BF537/6/4 BF561 BF533/2/1
32*
33* GPIO_0 PF0 PF0 PF0
34* GPIO_1 PF1 PF1 PF1
35* GPIO_2 PF2 PF2 PF2
36* GPIO_3 PF3 PF3 PF3
37* GPIO_4 PF4 PF4 PF4
38* GPIO_5 PF5 PF5 PF5
39* GPIO_6 PF6 PF6 PF6
40* GPIO_7 PF7 PF7 PF7
41* GPIO_8 PF8 PF8 PF8
42* GPIO_9 PF9 PF9 PF9
43* GPIO_10 PF10 PF10 PF10
44* GPIO_11 PF11 PF11 PF11
45* GPIO_12 PF12 PF12 PF12
46* GPIO_13 PF13 PF13 PF13
47* GPIO_14 PF14 PF14 PF14
48* GPIO_15 PF15 PF15 PF15
49* GPIO_16 PG0 PF16
50* GPIO_17 PG1 PF17
51* GPIO_18 PG2 PF18
52* GPIO_19 PG3 PF19
53* GPIO_20 PG4 PF20
54* GPIO_21 PG5 PF21
55* GPIO_22 PG6 PF22
56* GPIO_23 PG7 PF23
57* GPIO_24 PG8 PF24
58* GPIO_25 PG9 PF25
59* GPIO_26 PG10 PF26
60* GPIO_27 PG11 PF27
61* GPIO_28 PG12 PF28
62* GPIO_29 PG13 PF29
63* GPIO_30 PG14 PF30
64* GPIO_31 PG15 PF31
65* GPIO_32 PH0 PF32
66* GPIO_33 PH1 PF33
67* GPIO_34 PH2 PF34
68* GPIO_35 PH3 PF35
69* GPIO_36 PH4 PF36
70* GPIO_37 PH5 PF37
71* GPIO_38 PH6 PF38
72* GPIO_39 PH7 PF39
73* GPIO_40 PH8 PF40
74* GPIO_41 PH9 PF41
75* GPIO_42 PH10 PF42
76* GPIO_43 PH11 PF43
77* GPIO_44 PH12 PF44
78* GPIO_45 PH13 PF45
79* GPIO_46 PH14 PF46
80* GPIO_47 PH15 PF47
81*/
82
83#include <linux/module.h>
84#include <linux/err.h>
85#include <asm/blackfin.h>
86#include <asm/gpio.h>
87#include <linux/irq.h>
88
89#ifdef BF533_FAMILY
90static struct gpio_port_t *gpio_bankb[gpio_bank(MAX_BLACKFIN_GPIOS)] = {
91 (struct gpio_port_t *) FIO_FLAG_D,
92};
93#endif
94
95#ifdef BF537_FAMILY
96static struct gpio_port_t *gpio_bankb[gpio_bank(MAX_BLACKFIN_GPIOS)] = {
97 (struct gpio_port_t *) PORTFIO,
98 (struct gpio_port_t *) PORTGIO,
99 (struct gpio_port_t *) PORTHIO,
100};
101
102static unsigned short *port_fer[gpio_bank(MAX_BLACKFIN_GPIOS)] = {
103 (unsigned short *) PORTF_FER,
104 (unsigned short *) PORTG_FER,
105 (unsigned short *) PORTH_FER,
106};
107
108#endif
109
110#ifdef BF561_FAMILY
111static struct gpio_port_t *gpio_bankb[gpio_bank(MAX_BLACKFIN_GPIOS)] = {
112 (struct gpio_port_t *) FIO0_FLAG_D,
113 (struct gpio_port_t *) FIO1_FLAG_D,
114 (struct gpio_port_t *) FIO2_FLAG_D,
115};
116#endif
117
118static unsigned short reserved_map[gpio_bank(MAX_BLACKFIN_GPIOS)];
119
120#ifdef CONFIG_PM
121static unsigned short wakeup_map[gpio_bank(MAX_BLACKFIN_GPIOS)];
122static unsigned char wakeup_flags_map[MAX_BLACKFIN_GPIOS];
123static struct gpio_port_s gpio_bank_saved[gpio_bank(MAX_BLACKFIN_GPIOS)];
124
125#ifdef BF533_FAMILY
126static unsigned int sic_iwr_irqs[gpio_bank(MAX_BLACKFIN_GPIOS)] = {IRQ_PROG_INTB};
127#endif
128
129#ifdef BF537_FAMILY
130static unsigned int sic_iwr_irqs[gpio_bank(MAX_BLACKFIN_GPIOS)] = {IRQ_PROG_INTB, IRQ_PORTG_INTB, IRQ_MAC_TX};
131#endif
132
133#ifdef BF561_FAMILY
134static unsigned int sic_iwr_irqs[gpio_bank(MAX_BLACKFIN_GPIOS)] = {IRQ_PROG0_INTB, IRQ_PROG1_INTB, IRQ_PROG2_INTB};
135#endif
136
137#endif /* CONFIG_PM */
138
139inline int check_gpio(unsigned short gpio)
140{
141 if (gpio > MAX_BLACKFIN_GPIOS)
142 return -EINVAL;
143 return 0;
144}
145
146#ifdef BF537_FAMILY
147void port_setup(unsigned short gpio, unsigned short usage)
148{
149 if (usage == GPIO_USAGE) {
150 if (*port_fer[gpio_bank(gpio)] & gpio_bit(gpio))
151 printk(KERN_WARNING "bfin-gpio: Possible Conflict with Peripheral "
152 "usage and GPIO %d detected!\n", gpio);
153 *port_fer[gpio_bank(gpio)] &= ~gpio_bit(gpio);
154 } else
155 *port_fer[gpio_bank(gpio)] |= gpio_bit(gpio);
156 SSYNC();
157}
158#else
159# define port_setup(...) do { } while (0)
160#endif
161
162
163void default_gpio(unsigned short gpio)
164{
165 unsigned short bank,bitmask;
166
167 bank = gpio_bank(gpio);
168 bitmask = gpio_bit(gpio);
169
170 gpio_bankb[bank]->maska_clear = bitmask;
171 gpio_bankb[bank]->maskb_clear = bitmask;
172 SSYNC();
173 gpio_bankb[bank]->inen &= ~bitmask;
174 gpio_bankb[bank]->dir &= ~bitmask;
175 gpio_bankb[bank]->polar &= ~bitmask;
176 gpio_bankb[bank]->both &= ~bitmask;
177 gpio_bankb[bank]->edge &= ~bitmask;
178}
179
180
181int __init bfin_gpio_init(void)
182{
183 int i;
184
185 printk(KERN_INFO "Blackfin GPIO Controller\n");
186
187 for (i = 0; i < MAX_BLACKFIN_GPIOS; i+=GPIO_BANKSIZE)
188 reserved_map[gpio_bank(i)] = 0;
189
190#if defined(BF537_FAMILY) && (defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE))
191# if defined(CONFIG_BFIN_MAC_RMII)
192 reserved_map[PORT_H] = 0xC373;
193# else
194 reserved_map[PORT_H] = 0xFFFF;
195# endif
196#endif
197
198 return 0;
199}
200
201arch_initcall(bfin_gpio_init);
202
203
204/***********************************************************
205*
206* FUNCTIONS: Blackfin General Purpose Ports Access Functions
207*
208* INPUTS/OUTPUTS:
209* gpio - GPIO Number between 0 and MAX_BLACKFIN_GPIOS
210*
211*
212* DESCRIPTION: These functions abstract direct register access
213* to Blackfin processor General Purpose
214* Ports Regsiters
215*
216* CAUTION: These functions do not belong to the GPIO Driver API
217*************************************************************
218* MODIFICATION HISTORY :
219**************************************************************/
220
221/* Set a specific bit */
222
223#define SET_GPIO(name) \
224void set_gpio_ ## name(unsigned short gpio, unsigned short arg) \
225{ \
226 unsigned long flags; \
227 BUG_ON(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio))); \
228 local_irq_save(flags); \
229 if (arg) \
230 gpio_bankb[gpio_bank(gpio)]->name |= gpio_bit(gpio); \
231 else \
232 gpio_bankb[gpio_bank(gpio)]->name &= ~gpio_bit(gpio); \
233 local_irq_restore(flags); \
234} \
235EXPORT_SYMBOL(set_gpio_ ## name);
236
237SET_GPIO(dir)
238SET_GPIO(inen)
239SET_GPIO(polar)
240SET_GPIO(edge)
241SET_GPIO(both)
242
243
244#define SET_GPIO_SC(name) \
245void set_gpio_ ## name(unsigned short gpio, unsigned short arg) \
246{ \
247 BUG_ON(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio))); \
248 if (arg) \
249 gpio_bankb[gpio_bank(gpio)]->name ## _set = gpio_bit(gpio); \
250 else \
251 gpio_bankb[gpio_bank(gpio)]->name ## _clear = gpio_bit(gpio); \
252} \
253EXPORT_SYMBOL(set_gpio_ ## name);
254
255SET_GPIO_SC(maska)
256SET_GPIO_SC(maskb)
257
258#if defined(ANOMALY_05000311)
259void set_gpio_data(unsigned short gpio, unsigned short arg)
260{
261 unsigned long flags;
262 BUG_ON(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio)));
263 local_irq_save(flags);
264 if (arg)
265 gpio_bankb[gpio_bank(gpio)]->data_set = gpio_bit(gpio);
266 else
267 gpio_bankb[gpio_bank(gpio)]->data_clear = gpio_bit(gpio);
268 bfin_read_CHIPID();
269 local_irq_restore(flags);
270}
271EXPORT_SYMBOL(set_gpio_data);
272#else
273SET_GPIO_SC(data)
274#endif
275
276
277#if defined(ANOMALY_05000311)
278void set_gpio_toggle(unsigned short gpio)
279{
280 unsigned long flags;
281 BUG_ON(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio)));
282 local_irq_save(flags);
283 gpio_bankb[gpio_bank(gpio)]->toggle = gpio_bit(gpio);
284 bfin_read_CHIPID();
285 local_irq_restore(flags);
286}
287#else
288void set_gpio_toggle(unsigned short gpio)
289{
290 BUG_ON(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio)));
291 gpio_bankb[gpio_bank(gpio)]->toggle = gpio_bit(gpio);
292}
293#endif
294EXPORT_SYMBOL(set_gpio_toggle);
295
296
297/*Set current PORT date (16-bit word)*/
298
299#define SET_GPIO_P(name) \
300void set_gpiop_ ## name(unsigned short gpio, unsigned short arg) \
301{ \
302 gpio_bankb[gpio_bank(gpio)]->name = arg; \
303} \
304EXPORT_SYMBOL(set_gpiop_ ## name);
305
306SET_GPIO_P(dir)
307SET_GPIO_P(inen)
308SET_GPIO_P(polar)
309SET_GPIO_P(edge)
310SET_GPIO_P(both)
311SET_GPIO_P(maska)
312SET_GPIO_P(maskb)
313
314
315#if defined(ANOMALY_05000311)
316void set_gpiop_data(unsigned short gpio, unsigned short arg)
317{
318 unsigned long flags;
319 local_irq_save(flags);
320 gpio_bankb[gpio_bank(gpio)]->data = arg;
321 bfin_read_CHIPID();
322 local_irq_restore(flags);
323}
324EXPORT_SYMBOL(set_gpiop_data);
325#else
326SET_GPIO_P(data)
327#endif
328
329
330
331/* Get a specific bit */
332
333#define GET_GPIO(name) \
334unsigned short get_gpio_ ## name(unsigned short gpio) \
335{ \
336 return (0x01 & (gpio_bankb[gpio_bank(gpio)]->name >> gpio_sub_n(gpio))); \
337} \
338EXPORT_SYMBOL(get_gpio_ ## name);
339
340GET_GPIO(dir)
341GET_GPIO(inen)
342GET_GPIO(polar)
343GET_GPIO(edge)
344GET_GPIO(both)
345GET_GPIO(maska)
346GET_GPIO(maskb)
347
348
349#if defined(ANOMALY_05000311)
350unsigned short get_gpio_data(unsigned short gpio)
351{
352 unsigned long flags;
353 unsigned short ret;
354 BUG_ON(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio)));
355 local_irq_save(flags);
356 ret = 0x01 & (gpio_bankb[gpio_bank(gpio)]->data >> gpio_sub_n(gpio));
357 bfin_read_CHIPID();
358 local_irq_restore(flags);
359 return ret;
360}
361EXPORT_SYMBOL(get_gpio_data);
362#else
363GET_GPIO(data)
364#endif
365
366/*Get current PORT date (16-bit word)*/
367
368#define GET_GPIO_P(name) \
369unsigned short get_gpiop_ ## name(unsigned short gpio) \
370{ \
371 return (gpio_bankb[gpio_bank(gpio)]->name);\
372} \
373EXPORT_SYMBOL(get_gpiop_ ## name);
374
375GET_GPIO_P(dir)
376GET_GPIO_P(inen)
377GET_GPIO_P(polar)
378GET_GPIO_P(edge)
379GET_GPIO_P(both)
380GET_GPIO_P(maska)
381GET_GPIO_P(maskb)
382
383#if defined(ANOMALY_05000311)
384unsigned short get_gpiop_data(unsigned short gpio)
385{
386 unsigned long flags;
387 unsigned short ret;
388 local_irq_save(flags);
389 ret = gpio_bankb[gpio_bank(gpio)]->data;
390 bfin_read_CHIPID();
391 local_irq_restore(flags);
392 return ret;
393}
394EXPORT_SYMBOL(get_gpiop_data);
395#else
396GET_GPIO_P(data)
397#endif
398
399#ifdef CONFIG_PM
400/***********************************************************
401*
402* FUNCTIONS: Blackfin PM Setup API
403*
404* INPUTS/OUTPUTS:
405* gpio - GPIO Number between 0 and MAX_BLACKFIN_GPIOS
406* type -
407* PM_WAKE_RISING
408* PM_WAKE_FALLING
409* PM_WAKE_HIGH
410* PM_WAKE_LOW
411* PM_WAKE_BOTH_EDGES
412*
413* DESCRIPTION: Blackfin PM Driver API
414*
415* CAUTION:
416*************************************************************
417* MODIFICATION HISTORY :
418**************************************************************/
419int gpio_pm_wakeup_request(unsigned short gpio, unsigned char type)
420{
421 unsigned long flags;
422
423 if ((check_gpio(gpio) < 0) || !type)
424 return -EINVAL;
425
426 local_irq_save(flags);
427
428 wakeup_map[gpio_bank(gpio)] |= gpio_bit(gpio);
429 wakeup_flags_map[gpio] = type;
430 local_irq_restore(flags);
431
432 return 0;
433}
434EXPORT_SYMBOL(gpio_pm_wakeup_request);
435
436void gpio_pm_wakeup_free(unsigned short gpio)
437{
438 unsigned long flags;
439
440 if (check_gpio(gpio) < 0)
441 return;
442
443 local_irq_save(flags);
444
445 wakeup_map[gpio_bank(gpio)] &= ~gpio_bit(gpio);
446
447 local_irq_restore(flags);
448}
449EXPORT_SYMBOL(gpio_pm_wakeup_free);
450
451static int bfin_gpio_wakeup_type(unsigned short gpio, unsigned char type)
452{
453 port_setup(gpio, GPIO_USAGE);
454 set_gpio_dir(gpio, 0);
455 set_gpio_inen(gpio, 1);
456
457 if (type & (PM_WAKE_RISING | PM_WAKE_FALLING))
458 set_gpio_edge(gpio, 1);
459 else
460 set_gpio_edge(gpio, 0);
461
462 if ((type & (PM_WAKE_BOTH_EDGES)) == (PM_WAKE_BOTH_EDGES))
463 set_gpio_both(gpio, 1);
464 else
465 set_gpio_both(gpio, 0);
466
467 if ((type & (PM_WAKE_FALLING | PM_WAKE_LOW)))
468 set_gpio_polar(gpio, 1);
469 else
470 set_gpio_polar(gpio, 0);
471
472 SSYNC();
473
474 return 0;
475}
476
477u32 gpio_pm_setup(void)
478{
479 u32 sic_iwr = 0;
480 u16 bank, mask, i, gpio;
481
482 for (i = 0; i < MAX_BLACKFIN_GPIOS; i+=GPIO_BANKSIZE) {
483 mask = wakeup_map[gpio_bank(i)];
484 bank = gpio_bank(i);
485
486 gpio_bank_saved[bank].maskb = gpio_bankb[bank]->maskb;
487 gpio_bankb[bank]->maskb = 0;
488
489 if (mask) {
490#ifdef BF537_FAMILY
491 gpio_bank_saved[bank].fer = *port_fer[bank];
492#endif
493 gpio_bank_saved[bank].inen = gpio_bankb[bank]->inen;
494 gpio_bank_saved[bank].polar = gpio_bankb[bank]->polar;
495 gpio_bank_saved[bank].dir = gpio_bankb[bank]->dir;
496 gpio_bank_saved[bank].edge = gpio_bankb[bank]->edge;
497 gpio_bank_saved[bank].both = gpio_bankb[bank]->both;
498
499 gpio = i;
500
501 while (mask) {
502 if (mask & 1) {
503 bfin_gpio_wakeup_type(gpio, wakeup_flags_map[gpio]);
504 set_gpio_data(gpio, 0); /*Clear*/
505 }
506 gpio++;
507 mask >>= 1;
508 }
509
510 sic_iwr |= 1 << (sic_iwr_irqs[bank] - (IRQ_CORETMR + 1));
511 gpio_bankb[bank]->maskb_set = wakeup_map[gpio_bank(i)];
512 }
513 }
514
515 if (sic_iwr)
516 return sic_iwr;
517 else
518 return IWR_ENABLE_ALL;
519}
520
521
522void gpio_pm_restore(void)
523{
524 u16 bank, mask, i;
525
526 for (i = 0; i < MAX_BLACKFIN_GPIOS; i+=GPIO_BANKSIZE) {
527 mask = wakeup_map[gpio_bank(i)];
528 bank = gpio_bank(i);
529
530 if (mask) {
531#ifdef BF537_FAMILY
532 *port_fer[bank] = gpio_bank_saved[bank].fer;
533#endif
534 gpio_bankb[bank]->inen = gpio_bank_saved[bank].inen;
535 gpio_bankb[bank]->dir = gpio_bank_saved[bank].dir;
536 gpio_bankb[bank]->polar = gpio_bank_saved[bank].polar;
537 gpio_bankb[bank]->edge = gpio_bank_saved[bank].edge;
538 gpio_bankb[bank]->both = gpio_bank_saved[bank].both;
539 }
540
541 gpio_bankb[bank]->maskb = gpio_bank_saved[bank].maskb;
542 }
543}
544
545#endif
546
547/***********************************************************
548*
549* FUNCTIONS: Blackfin GPIO Driver
550*
551* INPUTS/OUTPUTS:
552* gpio - GPIO Number between 0 and MAX_BLACKFIN_GPIOS
553*
554*
555* DESCRIPTION: Blackfin GPIO Driver API
556*
557* CAUTION:
558*************************************************************
559* MODIFICATION HISTORY :
560**************************************************************/
561
562int gpio_request(unsigned short gpio, const char *label)
563{
564 unsigned long flags;
565
566 if (check_gpio(gpio) < 0)
567 return -EINVAL;
568
569 local_irq_save(flags);
570
571 if (unlikely(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio))) {
572 printk(KERN_ERR "bfin-gpio: GPIO %d is already reserved!\n", gpio);
573 dump_stack();
574 local_irq_restore(flags);
575 return -EBUSY;
576 }
577 reserved_map[gpio_bank(gpio)] |= gpio_bit(gpio);
578
579 local_irq_restore(flags);
580
581 port_setup(gpio, GPIO_USAGE);
582
583 return 0;
584}
585EXPORT_SYMBOL(gpio_request);
586
587
588void gpio_free(unsigned short gpio)
589{
590 unsigned long flags;
591
592 if (check_gpio(gpio) < 0)
593 return;
594
595 local_irq_save(flags);
596
597 if (unlikely(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio)))) {
598 printk(KERN_ERR "bfin-gpio: GPIO %d wasn't reserved!\n", gpio);
599 dump_stack();
600 local_irq_restore(flags);
601 return;
602 }
603
604 default_gpio(gpio);
605
606 reserved_map[gpio_bank(gpio)] &= ~gpio_bit(gpio);
607
608 local_irq_restore(flags);
609}
610EXPORT_SYMBOL(gpio_free);
611
612
613void gpio_direction_input(unsigned short gpio)
614{
615 unsigned long flags;
616
617 BUG_ON(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio)));
618
619 local_irq_save(flags);
620 gpio_bankb[gpio_bank(gpio)]->dir &= ~gpio_bit(gpio);
621 gpio_bankb[gpio_bank(gpio)]->inen |= gpio_bit(gpio);
622 local_irq_restore(flags);
623}
624EXPORT_SYMBOL(gpio_direction_input);
625
626void gpio_direction_output(unsigned short gpio)
627{
628 unsigned long flags;
629
630 BUG_ON(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio)));
631
632 local_irq_save(flags);
633 gpio_bankb[gpio_bank(gpio)]->inen &= ~gpio_bit(gpio);
634 gpio_bankb[gpio_bank(gpio)]->dir |= gpio_bit(gpio);
635 local_irq_restore(flags);
636}
637EXPORT_SYMBOL(gpio_direction_output);
diff --git a/arch/blackfin/kernel/bfin_ksyms.c b/arch/blackfin/kernel/bfin_ksyms.c
new file mode 100644
index 000000000000..f64ecb638fab
--- /dev/null
+++ b/arch/blackfin/kernel/bfin_ksyms.c
@@ -0,0 +1,119 @@
1/*
2 * File: arch/blackfin/kernel/bfin_ksyms.c
3 * Based on: none - original work
4 * Author:
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/module.h>
31#include <asm/irq.h>
32#include <asm/checksum.h>
33#include <asm/cacheflush.h>
34#include <asm/uaccess.h>
35
36/* platform dependent support */
37
38EXPORT_SYMBOL(__ioremap);
39EXPORT_SYMBOL(strcmp);
40EXPORT_SYMBOL(strncmp);
41EXPORT_SYMBOL(dump_thread);
42
43EXPORT_SYMBOL(ip_fast_csum);
44
45EXPORT_SYMBOL(kernel_thread);
46
47EXPORT_SYMBOL(__up);
48EXPORT_SYMBOL(__down);
49EXPORT_SYMBOL(__down_trylock);
50EXPORT_SYMBOL(__down_interruptible);
51
52EXPORT_SYMBOL(is_in_rom);
53
54/* Networking helper routines. */
55EXPORT_SYMBOL(csum_partial_copy);
56
57/* The following are special because they're not called
58 * explicitly (the C compiler generates them). Fortunately,
59 * their interface isn't gonna change any time soon now, so
60 * it's OK to leave it out of version control.
61 */
62EXPORT_SYMBOL(memcpy);
63EXPORT_SYMBOL(memset);
64EXPORT_SYMBOL(memcmp);
65EXPORT_SYMBOL(memmove);
66EXPORT_SYMBOL(memchr);
67EXPORT_SYMBOL(get_wchan);
68
69/*
70 * libgcc functions - functions that are used internally by the
71 * compiler... (prototypes are not correct though, but that
72 * doesn't really matter since they're not versioned).
73 */
74extern void __ashldi3(void);
75extern void __ashrdi3(void);
76extern void __smulsi3_highpart(void);
77extern void __umulsi3_highpart(void);
78extern void __divsi3(void);
79extern void __lshrdi3(void);
80extern void __modsi3(void);
81extern void __muldi3(void);
82extern void __udivsi3(void);
83extern void __umodsi3(void);
84
85/* gcc lib functions */
86EXPORT_SYMBOL(__ashldi3);
87EXPORT_SYMBOL(__ashrdi3);
88EXPORT_SYMBOL(__umulsi3_highpart);
89EXPORT_SYMBOL(__smulsi3_highpart);
90EXPORT_SYMBOL(__divsi3);
91EXPORT_SYMBOL(__lshrdi3);
92EXPORT_SYMBOL(__modsi3);
93EXPORT_SYMBOL(__muldi3);
94EXPORT_SYMBOL(__udivsi3);
95EXPORT_SYMBOL(__umodsi3);
96
97EXPORT_SYMBOL(outsb);
98EXPORT_SYMBOL(insb);
99EXPORT_SYMBOL(outsw);
100EXPORT_SYMBOL(insw);
101EXPORT_SYMBOL(outsl);
102EXPORT_SYMBOL(insl);
103EXPORT_SYMBOL(irq_flags);
104EXPORT_SYMBOL(iounmap);
105EXPORT_SYMBOL(blackfin_dcache_invalidate_range);
106EXPORT_SYMBOL(blackfin_icache_dcache_flush_range);
107EXPORT_SYMBOL(blackfin_icache_flush_range);
108EXPORT_SYMBOL(blackfin_dcache_flush_range);
109EXPORT_SYMBOL(blackfin_dflush_page);
110
111EXPORT_SYMBOL(csum_partial);
112EXPORT_SYMBOL(__init_begin);
113EXPORT_SYMBOL(__init_end);
114EXPORT_SYMBOL(_ebss_l1);
115EXPORT_SYMBOL(_stext_l1);
116EXPORT_SYMBOL(_etext_l1);
117EXPORT_SYMBOL(_sdata_l1);
118EXPORT_SYMBOL(_ebss_b_l1);
119EXPORT_SYMBOL(_sdata_b_l1);
diff --git a/arch/blackfin/kernel/dma-mapping.c b/arch/blackfin/kernel/dma-mapping.c
new file mode 100644
index 000000000000..539eb24e062f
--- /dev/null
+++ b/arch/blackfin/kernel/dma-mapping.c
@@ -0,0 +1,183 @@
1/*
2 * File: arch/blackfin/kernel/dma-mapping.c
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description: Dynamic DMA mapping support.
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/types.h>
31#include <linux/mm.h>
32#include <linux/string.h>
33#include <linux/bootmem.h>
34#include <linux/spinlock.h>
35#include <linux/device.h>
36#include <linux/dma-mapping.h>
37#include <asm/cacheflush.h>
38#include <asm/io.h>
39#include <asm/bfin-global.h>
40
41static spinlock_t dma_page_lock;
42static unsigned int *dma_page;
43static unsigned int dma_pages;
44static unsigned long dma_base;
45static unsigned long dma_size;
46static unsigned int dma_initialized;
47
48void dma_alloc_init(unsigned long start, unsigned long end)
49{
50 spin_lock_init(&dma_page_lock);
51 dma_initialized = 0;
52
53 dma_page = (unsigned int *)__get_free_page(GFP_KERNEL);
54 memset(dma_page, 0, PAGE_SIZE);
55 dma_base = PAGE_ALIGN(start);
56 dma_size = PAGE_ALIGN(end) - PAGE_ALIGN(start);
57 dma_pages = dma_size >> PAGE_SHIFT;
58 memset((void *)dma_base, 0, DMA_UNCACHED_REGION);
59 dma_initialized = 1;
60
61 printk(KERN_INFO "%s: dma_page @ 0x%p - %d pages at 0x%08lx\n", __FUNCTION__,
62 dma_page, dma_pages, dma_base);
63}
64
65static inline unsigned int get_pages(size_t size)
66{
67 return ((size - 1) >> PAGE_SHIFT) + 1;
68}
69
70static unsigned long __alloc_dma_pages(unsigned int pages)
71{
72 unsigned long ret = 0, flags;
73 int i, count = 0;
74
75 if (dma_initialized == 0)
76 dma_alloc_init(_ramend - DMA_UNCACHED_REGION, _ramend);
77
78 spin_lock_irqsave(&dma_page_lock, flags);
79
80 for (i = 0; i < dma_pages;) {
81 if (dma_page[i++] == 0) {
82 if (++count == pages) {
83 while (count--)
84 dma_page[--i] = 1;
85 ret = dma_base + (i << PAGE_SHIFT);
86 break;
87 }
88 } else
89 count = 0;
90 }
91 spin_unlock_irqrestore(&dma_page_lock, flags);
92 return ret;
93}
94
95static void __free_dma_pages(unsigned long addr, unsigned int pages)
96{
97 unsigned long page = (addr - dma_base) >> PAGE_SHIFT;
98 unsigned long flags;
99 int i;
100
101 if ((page + pages) > dma_pages) {
102 printk(KERN_ERR "%s: freeing outside range.\n", __FUNCTION__);
103 BUG();
104 }
105
106 spin_lock_irqsave(&dma_page_lock, flags);
107 for (i = page; i < page + pages; i++) {
108 dma_page[i] = 0;
109 }
110 spin_unlock_irqrestore(&dma_page_lock, flags);
111}
112
113void *dma_alloc_coherent(struct device *dev, size_t size,
114 dma_addr_t * dma_handle, gfp_t gfp)
115{
116 void *ret;
117
118 ret = (void *)__alloc_dma_pages(get_pages(size));
119
120 if (ret) {
121 memset(ret, 0, size);
122 *dma_handle = virt_to_phys(ret);
123 }
124
125 return ret;
126}
127EXPORT_SYMBOL(dma_alloc_coherent);
128
129void
130dma_free_coherent(struct device *dev, size_t size, void *vaddr,
131 dma_addr_t dma_handle)
132{
133 __free_dma_pages((unsigned long)vaddr, get_pages(size));
134}
135EXPORT_SYMBOL(dma_free_coherent);
136
137/*
138 * Dummy functions defined for some existing drivers
139 */
140
141dma_addr_t
142dma_map_single(struct device *dev, void *ptr, size_t size,
143 enum dma_data_direction direction)
144{
145 BUG_ON(direction == DMA_NONE);
146
147 invalidate_dcache_range((unsigned long)ptr,
148 (unsigned long)ptr + size);
149
150 return (dma_addr_t) ptr;
151}
152EXPORT_SYMBOL(dma_map_single);
153
154int
155dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
156 enum dma_data_direction direction)
157{
158 int i;
159
160 BUG_ON(direction == DMA_NONE);
161
162 for (i = 0; i < nents; i++)
163 invalidate_dcache_range(sg_dma_address(&sg[i]),
164 sg_dma_address(&sg[i]) +
165 sg_dma_len(&sg[i]));
166
167 return nents;
168}
169EXPORT_SYMBOL(dma_map_sg);
170
171void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
172 enum dma_data_direction direction)
173{
174 BUG_ON(direction == DMA_NONE);
175}
176EXPORT_SYMBOL(dma_unmap_single);
177
178void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
179 int nhwentries, enum dma_data_direction direction)
180{
181 BUG_ON(direction == DMA_NONE);
182}
183EXPORT_SYMBOL(dma_unmap_sg);
diff --git a/arch/blackfin/kernel/dualcore_test.c b/arch/blackfin/kernel/dualcore_test.c
new file mode 100644
index 000000000000..8b89c99f9dfa
--- /dev/null
+++ b/arch/blackfin/kernel/dualcore_test.c
@@ -0,0 +1,49 @@
1/*
2 * File: arch/blackfin/kernel/dualcore_test.c
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description: Small test code for CoreB on a BF561
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/init.h>
31#include <linux/module.h>
32
33static int *testarg = (int*)0xfeb00000;
34
35static int test_init(void)
36{
37 *testarg = 1;
38 printk("Dual core test module inserted: set testarg = [%d]\n @ [%p]\n",
39 *testarg, testarg);
40 return 0;
41}
42
43static void test_exit(void)
44{
45 printk("Dual core test module removed: testarg = [%d]\n", *testarg);
46}
47
48module_init(test_init);
49module_exit(test_exit);
diff --git a/arch/blackfin/kernel/entry.S b/arch/blackfin/kernel/entry.S
new file mode 100644
index 000000000000..5880b270bd50
--- /dev/null
+++ b/arch/blackfin/kernel/entry.S
@@ -0,0 +1,94 @@
1/*
2 * File: arch/blackfin/kernel/entry.S
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/linkage.h>
31#include <asm/thread_info.h>
32#include <asm/errno.h>
33#include <asm/asm-offsets.h>
34
35#include <asm/mach-common/context.S>
36
37#ifdef CONFIG_EXCPT_IRQ_SYSC_L1
38.section .l1.text
39#else
40.text
41#endif
42
43ENTRY(_ret_from_fork)
44 SP += -12;
45 call _schedule_tail;
46 SP += 12;
47 r0 = [sp + PT_IPEND];
48 cc = bittst(r0,1);
49 if cc jump .Lin_kernel;
50 RESTORE_CONTEXT
51 rti;
52.Lin_kernel:
53 bitclr(r0,1);
54 [sp + PT_IPEND] = r0;
55 /* do a 'fake' RTI by jumping to [RETI]
56 * to avoid clearing supervisor mode in child
57 */
58 RESTORE_ALL_SYS
59 p0 = reti;
60 jump (p0);
61
62ENTRY(_sys_fork)
63 r0 = -EINVAL;
64 rts;
65
66ENTRY(_sys_vfork)
67 r0 = sp;
68 r0 += 24;
69 [--sp] = rets;
70 SP += -12;
71 call _bfin_vfork;
72 SP += 12;
73 rets = [sp++];
74 rts;
75
76ENTRY(_sys_clone)
77 r0 = sp;
78 r0 += 24;
79 [--sp] = rets;
80 SP += -12;
81 call _bfin_clone;
82 SP += 12;
83 rets = [sp++];
84 rts;
85
86ENTRY(_sys_rt_sigreturn)
87 r0 = sp;
88 r0 += 24;
89 [--sp] = rets;
90 SP += -12;
91 call _do_rt_sigreturn;
92 SP += 12;
93 rets = [sp++];
94 rts;
diff --git a/arch/blackfin/kernel/flat.c b/arch/blackfin/kernel/flat.c
new file mode 100644
index 000000000000..a92587b628b5
--- /dev/null
+++ b/arch/blackfin/kernel/flat.c
@@ -0,0 +1,101 @@
1/*
2 * arch/blackfin/kernel/flat.c
3 *
4 * Copyright (C) 2007 Analog Devices, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/module.h>
22#include <linux/sched.h>
23#include <linux/flat.h>
24
25#define FLAT_BFIN_RELOC_TYPE_16_BIT 0
26#define FLAT_BFIN_RELOC_TYPE_16H_BIT 1
27#define FLAT_BFIN_RELOC_TYPE_32_BIT 2
28
29unsigned long bfin_get_addr_from_rp(unsigned long *ptr,
30 unsigned long relval,
31 unsigned long flags,
32 unsigned long *persistent)
33{
34 unsigned short *usptr = (unsigned short *)ptr;
35 int type = (relval >> 26) & 7;
36 unsigned long val;
37
38 switch (type) {
39 case FLAT_BFIN_RELOC_TYPE_16_BIT:
40 case FLAT_BFIN_RELOC_TYPE_16H_BIT:
41 usptr = (unsigned short *)ptr;
42 pr_debug("*usptr = %x", get_unaligned(usptr));
43 val = get_unaligned(usptr);
44 val += *persistent;
45 break;
46
47 case FLAT_BFIN_RELOC_TYPE_32_BIT:
48 pr_debug("*ptr = %lx", get_unaligned(ptr));
49 val = get_unaligned(ptr);
50 break;
51
52 default:
53 pr_debug("BINFMT_FLAT: Unknown relocation type %x\n",
54 type);
55
56 return 0;
57 }
58
59 /*
60 * Stack-relative relocs contain the offset into the stack, we
61 * have to add the stack's start address here and return 1 from
62 * flat_addr_absolute to prevent the normal address calculations
63 */
64 if (relval & (1 << 29))
65 return val + current->mm->context.end_brk;
66
67 if ((flags & FLAT_FLAG_GOTPIC) == 0)
68 val = htonl(val);
69 return val;
70}
71EXPORT_SYMBOL(bfin_get_addr_from_rp);
72
73/*
74 * Insert the address ADDR into the symbol reference at RP;
75 * RELVAL is the raw relocation-table entry from which RP is derived
76 */
77void bfin_put_addr_at_rp(unsigned long *ptr, unsigned long addr,
78 unsigned long relval)
79{
80 unsigned short *usptr = (unsigned short *)ptr;
81 int type = (relval >> 26) & 7;
82
83 switch (type) {
84 case FLAT_BFIN_RELOC_TYPE_16_BIT:
85 put_unaligned(addr, usptr);
86 pr_debug("new value %x at %p", get_unaligned(usptr),
87 usptr);
88 break;
89
90 case FLAT_BFIN_RELOC_TYPE_16H_BIT:
91 put_unaligned(addr >> 16, usptr);
92 pr_debug("new value %x", get_unaligned(usptr));
93 break;
94
95 case FLAT_BFIN_RELOC_TYPE_32_BIT:
96 put_unaligned(addr, ptr);
97 pr_debug("new ptr =%lx", get_unaligned(ptr));
98 break;
99 }
100}
101EXPORT_SYMBOL(bfin_put_addr_at_rp);
diff --git a/arch/blackfin/kernel/init_task.c b/arch/blackfin/kernel/init_task.c
new file mode 100644
index 000000000000..b45188f8512e
--- /dev/null
+++ b/arch/blackfin/kernel/init_task.c
@@ -0,0 +1,60 @@
1/*
2 * File: arch/blackfin/kernel/init_task.c
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description: This file contains the simple DMA Implementation for Blackfin
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/mm.h>
31#include <linux/module.h>
32#include <linux/init_task.h>
33#include <linux/mqueue.h>
34
35static struct fs_struct init_fs = INIT_FS;
36static struct files_struct init_files = INIT_FILES;
37static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
38static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
39
40struct mm_struct init_mm = INIT_MM(init_mm);
41EXPORT_SYMBOL(init_mm);
42
43/*
44 * Initial task structure.
45 *
46 * All other task structs will be allocated on slabs in fork.c
47 */
48struct task_struct init_task = INIT_TASK(init_task);
49EXPORT_SYMBOL(init_task);
50
51/*
52 * Initial thread structure.
53 *
54 * We need to make sure that this is 8192-byte aligned due to the
55 * way process stacks are handled. This is done by having a special
56 * "init_task" linker map entry.
57 */
58union thread_union init_thread_union
59 __attribute__ ((__section__(".data.init_task"))) = {
60INIT_THREAD_INFO(init_task)};
diff --git a/arch/blackfin/kernel/irqchip.c b/arch/blackfin/kernel/irqchip.c
new file mode 100644
index 000000000000..df5bf022cf79
--- /dev/null
+++ b/arch/blackfin/kernel/irqchip.c
@@ -0,0 +1,147 @@
1/*
2 * File: arch/blackfin/kernel/irqchip.c
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description: This file contains the simple DMA Implementation for Blackfin
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/kernel_stat.h>
31#include <linux/module.h>
32#include <linux/random.h>
33#include <linux/seq_file.h>
34#include <linux/kallsyms.h>
35#include <linux/interrupt.h>
36#include <linux/irq.h>
37
38static unsigned long irq_err_count;
39static spinlock_t irq_controller_lock;
40
41/*
42 * Dummy mask/unmask handler
43 */
44void dummy_mask_unmask_irq(unsigned int irq)
45{
46}
47
48void ack_bad_irq(unsigned int irq)
49{
50 irq_err_count += 1;
51 printk(KERN_ERR "IRQ: spurious interrupt %d\n", irq);
52}
53EXPORT_SYMBOL(ack_bad_irq);
54
55static struct irq_chip bad_chip = {
56 .ack = dummy_mask_unmask_irq,
57 .mask = dummy_mask_unmask_irq,
58 .unmask = dummy_mask_unmask_irq,
59};
60
61static struct irq_desc bad_irq_desc = {
62 .chip = &bad_chip,
63 .handle_irq = handle_bad_irq,
64 .depth = 1,
65};
66
67int show_interrupts(struct seq_file *p, void *v)
68{
69 int i = *(loff_t *) v;
70 struct irqaction *action;
71 unsigned long flags;
72
73 if (i < NR_IRQS) {
74 spin_lock_irqsave(&irq_desc[i].lock, flags);
75 action = irq_desc[i].action;
76 if (!action)
77 goto unlock;
78
79 seq_printf(p, "%3d: %10u ", i, kstat_irqs(i));
80 seq_printf(p, " %s", action->name);
81 for (action = action->next; action; action = action->next)
82 seq_printf(p, ", %s", action->name);
83
84 seq_putc(p, '\n');
85 unlock:
86 spin_unlock_irqrestore(&irq_desc[i].lock, flags);
87 } else if (i == NR_IRQS) {
88 seq_printf(p, "Err: %10lu\n", irq_err_count);
89 }
90 return 0;
91}
92
93/*
94 * do_IRQ handles all hardware IRQ's. Decoded IRQs should not
95 * come via this function. Instead, they should provide their
96 * own 'handler'
97 */
98
99#ifdef CONFIG_DO_IRQ_L1
100asmlinkage void asm_do_IRQ(unsigned int irq, struct pt_regs *regs)__attribute__((l1_text));
101#endif
102
103asmlinkage void asm_do_IRQ(unsigned int irq, struct pt_regs *regs)
104{
105 struct pt_regs *old_regs;
106 struct irq_desc *desc = irq_desc + irq;
107 unsigned short pending, other_ints;
108
109 old_regs = set_irq_regs(regs);
110
111 /*
112 * Some hardware gives randomly wrong interrupts. Rather
113 * than crashing, do something sensible.
114 */
115 if (irq >= NR_IRQS)
116 desc = &bad_irq_desc;
117
118 irq_enter();
119
120 generic_handle_irq(irq);
121
122 /* If we're the only interrupt running (ignoring IRQ15 which is for
123 syscalls), lower our priority to IRQ14 so that softirqs run at
124 that level. If there's another, lower-level interrupt, irq_exit
125 will defer softirqs to that. */
126 CSYNC();
127 pending = bfin_read_IPEND() & ~0x8000;
128 other_ints = pending & (pending - 1);
129 if (other_ints == 0)
130 lower_to_irq14();
131 irq_exit();
132
133 set_irq_regs(old_regs);
134}
135
136void __init init_IRQ(void)
137{
138 struct irq_desc *desc;
139 int irq;
140
141 spin_lock_init(&irq_controller_lock);
142 for (irq = 0, desc = irq_desc; irq < NR_IRQS; irq++, desc++) {
143 *desc = bad_irq_desc;
144 }
145
146 init_arch_irq();
147}
diff --git a/arch/blackfin/kernel/module.c b/arch/blackfin/kernel/module.c
new file mode 100644
index 000000000000..372f756f1ad9
--- /dev/null
+++ b/arch/blackfin/kernel/module.c
@@ -0,0 +1,429 @@
1/*
2 * File: arch/blackfin/kernel/module.c
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30
31#include <linux/moduleloader.h>
32#include <linux/elf.h>
33#include <linux/vmalloc.h>
34#include <linux/fs.h>
35#include <linux/string.h>
36#include <linux/kernel.h>
37#include <asm/dma.h>
38#include <asm/cacheflush.h>
39
40/*
41 * handle arithmetic relocations.
42 * See binutils/bfd/elf32-bfin.c for more details
43 */
44#define RELOC_STACK_SIZE 100
45static uint32_t reloc_stack[RELOC_STACK_SIZE];
46static unsigned int reloc_stack_tos;
47
48#define is_reloc_stack_empty() ((reloc_stack_tos > 0)?0:1)
49
50static void reloc_stack_push(uint32_t value)
51{
52 reloc_stack[reloc_stack_tos++] = value;
53}
54
55static uint32_t reloc_stack_pop(void)
56{
57 return reloc_stack[--reloc_stack_tos];
58}
59
60static uint32_t reloc_stack_operate(unsigned int oper, struct module *mod)
61{
62 uint32_t value;
63
64 switch (oper) {
65 case R_add:
66 value = reloc_stack[reloc_stack_tos - 2] +
67 reloc_stack[reloc_stack_tos - 1];
68 reloc_stack_tos -= 2;
69 break;
70 case R_sub:
71 value = reloc_stack[reloc_stack_tos - 2] -
72 reloc_stack[reloc_stack_tos - 1];
73 reloc_stack_tos -= 2;
74 break;
75 case R_mult:
76 value = reloc_stack[reloc_stack_tos - 2] *
77 reloc_stack[reloc_stack_tos - 1];
78 reloc_stack_tos -= 2;
79 break;
80 case R_div:
81 value = reloc_stack[reloc_stack_tos - 2] /
82 reloc_stack[reloc_stack_tos - 1];
83 reloc_stack_tos -= 2;
84 break;
85 case R_mod:
86 value = reloc_stack[reloc_stack_tos - 2] %
87 reloc_stack[reloc_stack_tos - 1];
88 reloc_stack_tos -= 2;
89 break;
90 case R_lshift:
91 value = reloc_stack[reloc_stack_tos - 2] <<
92 reloc_stack[reloc_stack_tos - 1];
93 reloc_stack_tos -= 2;
94 break;
95 case R_rshift:
96 value = reloc_stack[reloc_stack_tos - 2] >>
97 reloc_stack[reloc_stack_tos - 1];
98 reloc_stack_tos -= 2;
99 break;
100 case R_and:
101 value = reloc_stack[reloc_stack_tos - 2] &
102 reloc_stack[reloc_stack_tos - 1];
103 reloc_stack_tos -= 2;
104 break;
105 case R_or:
106 value = reloc_stack[reloc_stack_tos - 2] |
107 reloc_stack[reloc_stack_tos - 1];
108 reloc_stack_tos -= 2;
109 break;
110 case R_xor:
111 value = reloc_stack[reloc_stack_tos - 2] ^
112 reloc_stack[reloc_stack_tos - 1];
113 reloc_stack_tos -= 2;
114 break;
115 case R_land:
116 value = reloc_stack[reloc_stack_tos - 2] &&
117 reloc_stack[reloc_stack_tos - 1];
118 reloc_stack_tos -= 2;
119 break;
120 case R_lor:
121 value = reloc_stack[reloc_stack_tos - 2] ||
122 reloc_stack[reloc_stack_tos - 1];
123 reloc_stack_tos -= 2;
124 break;
125 case R_neg:
126 value = -reloc_stack[reloc_stack_tos - 1];
127 reloc_stack_tos--;
128 break;
129 case R_comp:
130 value = ~reloc_stack[reloc_stack_tos - 1];
131 reloc_stack_tos -= 1;
132 break;
133 default:
134 printk(KERN_WARNING "module %s: unhandled reloction\n",
135 mod->name);
136 return 0;
137 }
138
139 /* now push the new value back on stack */
140 reloc_stack_push(value);
141
142 return value;
143}
144
145void *module_alloc(unsigned long size)
146{
147 if (size == 0)
148 return NULL;
149 return vmalloc(size);
150}
151
152/* Free memory returned from module_alloc */
153void module_free(struct module *mod, void *module_region)
154{
155 vfree(module_region);
156}
157
158/* Transfer the section to the L1 memory */
159int
160module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
161 char *secstrings, struct module *mod)
162{
163 Elf_Shdr *s, *sechdrs_end = sechdrs + hdr->e_shnum;
164 void *dest = NULL;
165
166 for (s = sechdrs; s < sechdrs_end; ++s) {
167 if ((strcmp(".l1.text", secstrings + s->sh_name) == 0) ||
168 ((strcmp(".text", secstrings + s->sh_name)==0) &&
169 (hdr->e_flags & FLG_CODE_IN_L1) && (s->sh_size > 0))) {
170 mod->arch.text_l1 = s;
171 dest = l1_inst_sram_alloc(s->sh_size);
172 if (dest == NULL) {
173 printk(KERN_ERR
174 "module %s: L1 instruction memory allocation failed\n",
175 mod->name);
176 return -1;
177 }
178 dma_memcpy(dest, (void *)s->sh_addr, s->sh_size);
179 s->sh_flags &= ~SHF_ALLOC;
180 s->sh_addr = (unsigned long)dest;
181 }
182 if ((strcmp(".l1.data", secstrings + s->sh_name) == 0)||
183 ((strcmp(".data", secstrings + s->sh_name)==0) &&
184 (hdr->e_flags & FLG_DATA_IN_L1) && (s->sh_size > 0))) {
185 mod->arch.data_a_l1 = s;
186 dest = l1_data_sram_alloc(s->sh_size);
187 if (dest == NULL) {
188 printk(KERN_ERR
189 "module %s: L1 data memory allocation failed\n",
190 mod->name);
191 return -1;
192 }
193 memcpy(dest, (void *)s->sh_addr, s->sh_size);
194 s->sh_flags &= ~SHF_ALLOC;
195 s->sh_addr = (unsigned long)dest;
196 }
197 if (strcmp(".l1.bss", secstrings + s->sh_name) == 0 ||
198 ((strcmp(".bss", secstrings + s->sh_name)==0) &&
199 (hdr->e_flags & FLG_DATA_IN_L1) && (s->sh_size > 0))) {
200 mod->arch.bss_a_l1 = s;
201 dest = l1_data_sram_alloc(s->sh_size);
202 if (dest == NULL) {
203 printk(KERN_ERR
204 "module %s: L1 data memory allocation failed\n",
205 mod->name);
206 return -1;
207 }
208 memset(dest, 0, s->sh_size);
209 s->sh_flags &= ~SHF_ALLOC;
210 s->sh_addr = (unsigned long)dest;
211 }
212 if (strcmp(".l1.data.B", secstrings + s->sh_name) == 0) {
213 mod->arch.data_b_l1 = s;
214 dest = l1_data_B_sram_alloc(s->sh_size);
215 if (dest == NULL) {
216 printk(KERN_ERR
217 "module %s: L1 data memory allocation failed\n",
218 mod->name);
219 return -1;
220 }
221 memcpy(dest, (void *)s->sh_addr, s->sh_size);
222 s->sh_flags &= ~SHF_ALLOC;
223 s->sh_addr = (unsigned long)dest;
224 }
225 if (strcmp(".l1.bss.B", secstrings + s->sh_name) == 0) {
226 mod->arch.bss_b_l1 = s;
227 dest = l1_data_B_sram_alloc(s->sh_size);
228 if (dest == NULL) {
229 printk(KERN_ERR
230 "module %s: L1 data memory allocation failed\n",
231 mod->name);
232 return -1;
233 }
234 memset(dest, 0, s->sh_size);
235 s->sh_flags &= ~SHF_ALLOC;
236 s->sh_addr = (unsigned long)dest;
237 }
238 }
239 return 0;
240}
241
242int
243apply_relocate(Elf_Shdr * sechdrs, const char *strtab,
244 unsigned int symindex, unsigned int relsec, struct module *me)
245{
246 printk(KERN_ERR "module %s: .rel unsupported\n", me->name);
247 return -ENOEXEC;
248}
249
250/*************************************************************************/
251/* FUNCTION : apply_relocate_add */
252/* ABSTRACT : Blackfin specific relocation handling for the loadable */
253/* modules. Modules are expected to be .o files. */
254/* Arithmetic relocations are handled. */
255/* We do not expect LSETUP to be split and hence is not */
256/* handled. */
257/* R_byte and R_byte2 are also not handled as the gas */
258/* does not generate it. */
259/*************************************************************************/
260int
261apply_relocate_add(Elf_Shdr * sechdrs, const char *strtab,
262 unsigned int symindex, unsigned int relsec,
263 struct module *mod)
264{
265 unsigned int i;
266 unsigned short tmp;
267 Elf32_Rela *rel = (void *)sechdrs[relsec].sh_addr;
268 Elf32_Sym *sym;
269 uint32_t *location32;
270 uint16_t *location16;
271 uint32_t value;
272
273 pr_debug("Applying relocate section %u to %u\n", relsec,
274 sechdrs[relsec].sh_info);
275 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
276 /* This is where to make the change */
277 location16 =
278 (uint16_t *) (sechdrs[sechdrs[relsec].sh_info].sh_addr +
279 rel[i].r_offset);
280 location32 = (uint32_t *) location16;
281 /* This is the symbol it is referring to. Note that all
282 undefined symbols have been resolved. */
283 sym = (Elf32_Sym *) sechdrs[symindex].sh_addr
284 + ELF32_R_SYM(rel[i].r_info);
285 if (is_reloc_stack_empty()) {
286 value = sym->st_value;
287 } else {
288 value = reloc_stack_pop();
289 }
290 value += rel[i].r_addend;
291 pr_debug("location is %x, value is %x type is %d \n",
292 (unsigned int) location32, value,
293 ELF32_R_TYPE(rel[i].r_info));
294
295 switch (ELF32_R_TYPE(rel[i].r_info)) {
296
297 case R_pcrel24:
298 case R_pcrel24_jump_l:
299 /* Add the value, subtract its postition */
300 location16 =
301 (uint16_t *) (sechdrs[sechdrs[relsec].sh_info].
302 sh_addr + rel[i].r_offset - 2);
303 location32 = (uint32_t *) location16;
304 value -= (uint32_t) location32;
305 value >>= 1;
306 pr_debug("value is %x, before %x-%x after %x-%x\n", value,
307 *location16, *(location16 + 1),
308 (*location16 & 0xff00) | (value >> 16 & 0x00ff),
309 value & 0xffff);
310 *location16 =
311 (*location16 & 0xff00) | (value >> 16 & 0x00ff);
312 *(location16 + 1) = value & 0xffff;
313 break;
314 case R_pcrel12_jump:
315 case R_pcrel12_jump_s:
316 value -= (uint32_t) location32;
317 value >>= 1;
318 *location16 = (value & 0xfff);
319 break;
320 case R_pcrel10:
321 value -= (uint32_t) location32;
322 value >>= 1;
323 *location16 = (value & 0x3ff);
324 break;
325 case R_luimm16:
326 pr_debug("before %x after %x\n", *location16,
327 (value & 0xffff));
328 tmp = (value & 0xffff);
329 if((unsigned long)location16 >= L1_CODE_START) {
330 dma_memcpy(location16, &tmp, 2);
331 } else
332 *location16 = tmp;
333 break;
334 case R_huimm16:
335 pr_debug("before %x after %x\n", *location16,
336 ((value >> 16) & 0xffff));
337 tmp = ((value >> 16) & 0xffff);
338 if((unsigned long)location16 >= L1_CODE_START) {
339 dma_memcpy(location16, &tmp, 2);
340 } else
341 *location16 = tmp;
342 break;
343 case R_rimm16:
344 *location16 = (value & 0xffff);
345 break;
346 case R_byte4_data:
347 pr_debug("before %x after %x\n", *location32, value);
348 *location32 = value;
349 break;
350 case R_push:
351 reloc_stack_push(value);
352 break;
353 case R_const:
354 reloc_stack_push(rel[i].r_addend);
355 break;
356 case R_add:
357 case R_sub:
358 case R_mult:
359 case R_div:
360 case R_mod:
361 case R_lshift:
362 case R_rshift:
363 case R_and:
364 case R_or:
365 case R_xor:
366 case R_land:
367 case R_lor:
368 case R_neg:
369 case R_comp:
370 reloc_stack_operate(ELF32_R_TYPE(rel[i].r_info), mod);
371 break;
372 default:
373 printk(KERN_ERR "module %s: Unknown relocation: %u\n",
374 mod->name, ELF32_R_TYPE(rel[i].r_info));
375 return -ENOEXEC;
376 }
377 }
378 return 0;
379}
380
381int
382module_finalize(const Elf_Ehdr * hdr,
383 const Elf_Shdr * sechdrs, struct module *mod)
384{
385 unsigned int i, strindex = 0, symindex = 0;
386 char *secstrings;
387
388 secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
389
390 for (i = 1; i < hdr->e_shnum; i++) {
391 /* Internal symbols and strings. */
392 if (sechdrs[i].sh_type == SHT_SYMTAB) {
393 symindex = i;
394 strindex = sechdrs[i].sh_link;
395 }
396 }
397
398 for (i = 1; i < hdr->e_shnum; i++) {
399 const char *strtab = (char *)sechdrs[strindex].sh_addr;
400 unsigned int info = sechdrs[i].sh_info;
401
402 /* Not a valid relocation section? */
403 if (info >= hdr->e_shnum)
404 continue;
405
406 if ((sechdrs[i].sh_type == SHT_RELA) &&
407 ((strcmp(".rela.l1.text", secstrings + sechdrs[i].sh_name) == 0)||
408 ((strcmp(".rela.text", secstrings + sechdrs[i].sh_name) == 0) &&
409 (hdr->e_flags & FLG_CODE_IN_L1)))) {
410 apply_relocate_add((Elf_Shdr *) sechdrs, strtab,
411 symindex, i, mod);
412 }
413 }
414 return 0;
415}
416
417void module_arch_cleanup(struct module *mod)
418{
419 if ((mod->arch.text_l1) && (mod->arch.text_l1->sh_addr))
420 l1_inst_sram_free((void*)mod->arch.text_l1->sh_addr);
421 if ((mod->arch.data_a_l1) && (mod->arch.data_a_l1->sh_addr))
422 l1_data_sram_free((void*)mod->arch.data_a_l1->sh_addr);
423 if ((mod->arch.bss_a_l1) && (mod->arch.bss_a_l1->sh_addr))
424 l1_data_sram_free((void*)mod->arch.bss_a_l1->sh_addr);
425 if ((mod->arch.data_b_l1) && (mod->arch.data_b_l1->sh_addr))
426 l1_data_B_sram_free((void*)mod->arch.data_b_l1->sh_addr);
427 if ((mod->arch.bss_b_l1) && (mod->arch.bss_b_l1->sh_addr))
428 l1_data_B_sram_free((void*)mod->arch.bss_b_l1->sh_addr);
429}
diff --git a/arch/blackfin/kernel/process.c b/arch/blackfin/kernel/process.c
new file mode 100644
index 000000000000..3eff7439d8d3
--- /dev/null
+++ b/arch/blackfin/kernel/process.c
@@ -0,0 +1,394 @@
1/*
2 * File: arch/blackfin/kernel/process.c
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description: Blackfin architecture-dependent process handling.
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/module.h>
31#include <linux/smp_lock.h>
32#include <linux/unistd.h>
33#include <linux/user.h>
34#include <linux/a.out.h>
35
36#include <asm/blackfin.h>
37#include <asm/uaccess.h>
38
39#define LED_ON 0
40#define LED_OFF 1
41
42asmlinkage void ret_from_fork(void);
43
44/* Points to the SDRAM backup memory for the stack that is currently in
45 * L1 scratchpad memory.
46 */
47void *current_l1_stack_save;
48
49/* The number of tasks currently using a L1 stack area. The SRAM is
50 * allocated/deallocated whenever this changes from/to zero.
51 */
52int nr_l1stack_tasks;
53
54/* Start and length of the area in L1 scratchpad memory which we've allocated
55 * for process stacks.
56 */
57void *l1_stack_base;
58unsigned long l1_stack_len;
59
60/*
61 * Powermanagement idle function, if any..
62 */
63void (*pm_idle)(void) = NULL;
64EXPORT_SYMBOL(pm_idle);
65
66void (*pm_power_off)(void) = NULL;
67EXPORT_SYMBOL(pm_power_off);
68
69/*
70 * We are using a different LED from the one used to indicate timer interrupt.
71 */
72#if defined(CONFIG_BFIN_IDLE_LED)
73static inline void leds_switch(int flag)
74{
75 unsigned short tmp = 0;
76
77 tmp = bfin_read_CONFIG_BFIN_IDLE_LED_PORT();
78 SSYNC();
79
80 if (flag == LED_ON)
81 tmp &= ~CONFIG_BFIN_IDLE_LED_PIN; /* light on */
82 else
83 tmp |= CONFIG_BFIN_IDLE_LED_PIN; /* light off */
84
85 bfin_write_CONFIG_BFIN_IDLE_LED_PORT(tmp);
86 SSYNC();
87
88}
89#else
90static inline void leds_switch(int flag)
91{
92}
93#endif
94
95/*
96 * The idle loop on BFIN
97 */
98#ifdef CONFIG_IDLE_L1
99void default_idle(void)__attribute__((l1_text));
100void cpu_idle(void)__attribute__((l1_text));
101#endif
102
103void default_idle(void)
104{
105 while (!need_resched()) {
106 leds_switch(LED_OFF);
107 local_irq_disable();
108 if (likely(!need_resched()))
109 idle_with_irq_disabled();
110 local_irq_enable();
111 leds_switch(LED_ON);
112 }
113}
114
115void (*idle)(void) = default_idle;
116
117/*
118 * The idle thread. There's no useful work to be
119 * done, so just try to conserve power and have a
120 * low exit latency (ie sit in a loop waiting for
121 * somebody to say that they'd like to reschedule)
122 */
123void cpu_idle(void)
124{
125 /* endless idle loop with no priority at all */
126 while (1) {
127 idle();
128 preempt_enable_no_resched();
129 schedule();
130 preempt_disable();
131 }
132}
133
134void machine_restart(char *__unused)
135{
136#if defined(CONFIG_BLKFIN_CACHE)
137 bfin_write_IMEM_CONTROL(0x01);
138 SSYNC();
139#endif
140 bfin_reset();
141 /* Dont do anything till the reset occurs */
142 while (1) {
143 SSYNC();
144 }
145}
146
147void machine_halt(void)
148{
149 for (;;)
150 asm volatile ("idle");
151}
152
153void machine_power_off(void)
154{
155 for (;;)
156 asm volatile ("idle");
157}
158
159void show_regs(struct pt_regs *regs)
160{
161 printk(KERN_NOTICE "\n");
162 printk(KERN_NOTICE
163 "PC: %08lu Status: %04lu SysStatus: %04lu RETS: %08lu\n",
164 regs->pc, regs->astat, regs->seqstat, regs->rets);
165 printk(KERN_NOTICE
166 "A0.x: %08lx A0.w: %08lx A1.x: %08lx A1.w: %08lx\n",
167 regs->a0x, regs->a0w, regs->a1x, regs->a1w);
168 printk(KERN_NOTICE "P0: %08lx P1: %08lx P2: %08lx P3: %08lx\n",
169 regs->p0, regs->p1, regs->p2, regs->p3);
170 printk(KERN_NOTICE "P4: %08lx P5: %08lx\n", regs->p4, regs->p5);
171 printk(KERN_NOTICE "R0: %08lx R1: %08lx R2: %08lx R3: %08lx\n",
172 regs->r0, regs->r1, regs->r2, regs->r3);
173 printk(KERN_NOTICE "R4: %08lx R5: %08lx R6: %08lx R7: %08lx\n",
174 regs->r4, regs->r5, regs->r6, regs->r7);
175
176 if (!(regs->ipend))
177 printk("USP: %08lx\n", rdusp());
178}
179
180/* Fill in the fpu structure for a core dump. */
181
182int dump_fpu(struct pt_regs *regs, elf_fpregset_t * fpregs)
183{
184 return 1;
185}
186
187/*
188 * This gets run with P1 containing the
189 * function to call, and R1 containing
190 * the "args". Note P0 is clobbered on the way here.
191 */
192void kernel_thread_helper(void);
193__asm__(".section .text\n"
194 ".align 4\n"
195 "_kernel_thread_helper:\n\t"
196 "\tsp += -12;\n\t"
197 "\tr0 = r1;\n\t" "\tcall (p1);\n\t" "\tcall _do_exit;\n" ".previous");
198
199/*
200 * Create a kernel thread.
201 */
202pid_t kernel_thread(int (*fn) (void *), void *arg, unsigned long flags)
203{
204 struct pt_regs regs;
205
206 memset(&regs, 0, sizeof(regs));
207
208 regs.r1 = (unsigned long)arg;
209 regs.p1 = (unsigned long)fn;
210 regs.pc = (unsigned long)kernel_thread_helper;
211 regs.orig_p0 = -1;
212 /* Set bit 2 to tell ret_from_fork we should be returning to kernel
213 mode. */
214 regs.ipend = 0x8002;
215 __asm__ __volatile__("%0 = syscfg;":"=da"(regs.syscfg):);
216 return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs, 0, NULL,
217 NULL);
218}
219
220void flush_thread(void)
221{
222}
223
224asmlinkage int bfin_vfork(struct pt_regs *regs)
225{
226 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, rdusp(), regs, 0, NULL,
227 NULL);
228}
229
230asmlinkage int bfin_clone(struct pt_regs *regs)
231{
232 unsigned long clone_flags;
233 unsigned long newsp;
234
235 /* syscall2 puts clone_flags in r0 and usp in r1 */
236 clone_flags = regs->r0;
237 newsp = regs->r1;
238 if (!newsp)
239 newsp = rdusp();
240 else
241 newsp -= 12;
242 return do_fork(clone_flags, newsp, regs, 0, NULL, NULL);
243}
244
245int
246copy_thread(int nr, unsigned long clone_flags,
247 unsigned long usp, unsigned long topstk,
248 struct task_struct *p, struct pt_regs *regs)
249{
250 struct pt_regs *childregs;
251
252 childregs = (struct pt_regs *) (task_stack_page(p) + THREAD_SIZE) - 1;
253 *childregs = *regs;
254 childregs->r0 = 0;
255
256 p->thread.usp = usp;
257 p->thread.ksp = (unsigned long)childregs;
258 p->thread.pc = (unsigned long)ret_from_fork;
259
260 return 0;
261}
262
263/*
264 * fill in the user structure for a core dump..
265 */
266void dump_thread(struct pt_regs *regs, struct user *dump)
267{
268 dump->magic = CMAGIC;
269 dump->start_code = 0;
270 dump->start_stack = rdusp() & ~(PAGE_SIZE - 1);
271 dump->u_tsize = ((unsigned long)current->mm->end_code) >> PAGE_SHIFT;
272 dump->u_dsize = ((unsigned long)(current->mm->brk +
273 (PAGE_SIZE - 1))) >> PAGE_SHIFT;
274 dump->u_dsize -= dump->u_tsize;
275 dump->u_ssize = 0;
276
277 if (dump->start_stack < TASK_SIZE)
278 dump->u_ssize =
279 ((unsigned long)(TASK_SIZE -
280 dump->start_stack)) >> PAGE_SHIFT;
281
282 dump->u_ar0 = (struct user_regs_struct *)((int)&dump->regs - (int)dump);
283
284 dump->regs.r0 = regs->r0;
285 dump->regs.r1 = regs->r1;
286 dump->regs.r2 = regs->r2;
287 dump->regs.r3 = regs->r3;
288 dump->regs.r4 = regs->r4;
289 dump->regs.r5 = regs->r5;
290 dump->regs.r6 = regs->r6;
291 dump->regs.r7 = regs->r7;
292 dump->regs.p0 = regs->p0;
293 dump->regs.p1 = regs->p1;
294 dump->regs.p2 = regs->p2;
295 dump->regs.p3 = regs->p3;
296 dump->regs.p4 = regs->p4;
297 dump->regs.p5 = regs->p5;
298 dump->regs.orig_p0 = regs->orig_p0;
299 dump->regs.a0w = regs->a0w;
300 dump->regs.a1w = regs->a1w;
301 dump->regs.a0x = regs->a0x;
302 dump->regs.a1x = regs->a1x;
303 dump->regs.rets = regs->rets;
304 dump->regs.astat = regs->astat;
305 dump->regs.pc = regs->pc;
306}
307
308/*
309 * sys_execve() executes a new program.
310 */
311
312asmlinkage int sys_execve(char *name, char **argv, char **envp)
313{
314 int error;
315 char *filename;
316 struct pt_regs *regs = (struct pt_regs *)((&name) + 6);
317
318 lock_kernel();
319 filename = getname(name);
320 error = PTR_ERR(filename);
321 if (IS_ERR(filename))
322 goto out;
323 error = do_execve(filename, argv, envp, regs);
324 putname(filename);
325 out:
326 unlock_kernel();
327 return error;
328}
329
330unsigned long get_wchan(struct task_struct *p)
331{
332 unsigned long fp, pc;
333 unsigned long stack_page;
334 int count = 0;
335 if (!p || p == current || p->state == TASK_RUNNING)
336 return 0;
337
338 stack_page = (unsigned long)p;
339 fp = p->thread.usp;
340 do {
341 if (fp < stack_page + sizeof(struct thread_info) ||
342 fp >= 8184 + stack_page)
343 return 0;
344 pc = ((unsigned long *)fp)[1];
345 if (!in_sched_functions(pc))
346 return pc;
347 fp = *(unsigned long *)fp;
348 }
349 while (count++ < 16);
350 return 0;
351}
352
353#if defined(CONFIG_ACCESS_CHECK)
354int _access_ok(unsigned long addr, unsigned long size)
355{
356
357 if (addr > (addr + size))
358 return 0;
359 if (segment_eq(get_fs(),KERNEL_DS))
360 return 1;
361#ifdef CONFIG_MTD_UCLINUX
362 if (addr >= memory_start && (addr + size) <= memory_end)
363 return 1;
364 if (addr >= memory_mtd_end && (addr + size) <= physical_mem_end)
365 return 1;
366#else
367 if (addr >= memory_start && (addr + size) <= physical_mem_end)
368 return 1;
369#endif
370 if (addr >= (unsigned long)__init_begin &&
371 addr + size <= (unsigned long)__init_end)
372 return 1;
373 if (addr >= L1_SCRATCH_START
374 && addr + size <= L1_SCRATCH_START + L1_SCRATCH_LENGTH)
375 return 1;
376#if L1_CODE_LENGTH != 0
377 if (addr >= L1_CODE_START + (_etext_l1 - _stext_l1)
378 && addr + size <= L1_CODE_START + L1_CODE_LENGTH)
379 return 1;
380#endif
381#if L1_DATA_A_LENGTH != 0
382 if (addr >= L1_DATA_A_START + (_ebss_l1 - _sdata_l1)
383 && addr + size <= L1_DATA_A_START + L1_DATA_A_LENGTH)
384 return 1;
385#endif
386#if L1_DATA_B_LENGTH != 0
387 if (addr >= L1_DATA_B_START
388 && addr + size <= L1_DATA_B_START + L1_DATA_B_LENGTH)
389 return 1;
390#endif
391 return 0;
392}
393EXPORT_SYMBOL(_access_ok);
394#endif /* CONFIG_ACCESS_CHECK */
diff --git a/arch/blackfin/kernel/ptrace.c b/arch/blackfin/kernel/ptrace.c
new file mode 100644
index 000000000000..d7c8e514cb92
--- /dev/null
+++ b/arch/blackfin/kernel/ptrace.c
@@ -0,0 +1,430 @@
1/*
2 * File: arch/blackfin/kernel/ptrace.c
3 * Based on: Taken from linux/kernel/ptrace.c
4 * Author: linux/kernel/ptrace.c is by Ross Biro 1/23/92, edited by Linus Torvalds
5 *
6 * Created: 1/23/92
7 * Description:
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/kernel.h>
31#include <linux/sched.h>
32#include <linux/mm.h>
33#include <linux/smp.h>
34#include <linux/smp_lock.h>
35#include <linux/errno.h>
36#include <linux/ptrace.h>
37#include <linux/user.h>
38#include <linux/signal.h>
39
40#include <asm/uaccess.h>
41#include <asm/page.h>
42#include <asm/pgtable.h>
43#include <asm/system.h>
44#include <asm/processor.h>
45#include <asm/asm-offsets.h>
46#include <asm/dma.h>
47
48#define MAX_SHARED_LIBS 3
49#define TEXT_OFFSET 0
50/*
51 * does not yet catch signals sent when the child dies.
52 * in exit.c or in signal.c.
53 */
54
55/* determines which bits in the SYSCFG reg the user has access to. */
56/* 1 = access 0 = no access */
57#define SYSCFG_MASK 0x0007 /* SYSCFG reg */
58/* sets the trace bits. */
59#define TRACE_BITS 0x0001
60
61/* Find the stack offset for a register, relative to thread.esp0. */
62#define PT_REG(reg) ((long)&((struct pt_regs *)0)->reg)
63
64/*
65 * Get the address of the live pt_regs for the specified task.
66 * These are saved onto the top kernel stack when the process
67 * is not running.
68 *
69 * Note: if a user thread is execve'd from kernel space, the
70 * kernel stack will not be empty on entry to the kernel, so
71 * ptracing these tasks will fail.
72 */
73static inline struct pt_regs *get_user_regs(struct task_struct *task)
74{
75 return (struct pt_regs *)
76 ((unsigned long)task->thread_info +
77 (THREAD_SIZE - sizeof(struct pt_regs)));
78}
79
80/*
81 * Get all user integer registers.
82 */
83static inline int ptrace_getregs(struct task_struct *tsk, void __user * uregs)
84{
85 struct pt_regs *regs = get_user_regs(tsk);
86 return copy_to_user(uregs, regs, sizeof(struct pt_regs)) ? -EFAULT : 0;
87}
88
89/* Mapping from PT_xxx to the stack offset at which the register is
90 * saved. Notice that usp has no stack-slot and needs to be treated
91 * specially (see get_reg/put_reg below).
92 */
93
94/*
95 * Get contents of register REGNO in task TASK.
96 */
97static inline long get_reg(struct task_struct *task, int regno)
98{
99 unsigned char *reg_ptr;
100
101 struct pt_regs *regs =
102 (struct pt_regs *)((unsigned long)task->thread_info +
103 (THREAD_SIZE - sizeof(struct pt_regs)));
104 reg_ptr = (char *)regs;
105
106 switch (regno) {
107 case PT_USP:
108 return task->thread.usp;
109 default:
110 if (regno <= 216)
111 return *(long *)(reg_ptr + regno);
112 }
113 /* slight mystery ... never seems to come here but kernel misbehaves without this code! */
114
115 printk(KERN_WARNING "Request to get for unknown register %d\n", regno);
116 return 0;
117}
118
119/*
120 * Write contents of register REGNO in task TASK.
121 */
122static inline int
123put_reg(struct task_struct *task, int regno, unsigned long data)
124{
125 char * reg_ptr;
126
127 struct pt_regs *regs =
128 (struct pt_regs *)((unsigned long)task->thread_info +
129 (THREAD_SIZE - sizeof(struct pt_regs)));
130 reg_ptr = (char *)regs;
131
132 switch (regno) {
133 case PT_PC:
134 /*********************************************************************/
135 /* At this point the kernel is most likely in exception. */
136 /* The RETX register will be used to populate the pc of the process. */
137 /*********************************************************************/
138 regs->retx = data;
139 regs->pc = data;
140 break;
141 case PT_RETX:
142 break; /* regs->retx = data; break; */
143 case PT_USP:
144 regs->usp = data;
145 task->thread.usp = data;
146 break;
147 default:
148 if (regno <= 216)
149 *(long *)(reg_ptr + regno) = data;
150 }
151 return 0;
152}
153
154/*
155 * check that an address falls within the bounds of the target process's memory mappings
156 */
157static inline int is_user_addr_valid(struct task_struct *child,
158 unsigned long start, unsigned long len)
159{
160 struct vm_list_struct *vml;
161 struct sram_list_struct *sraml;
162
163 for (vml = child->mm->context.vmlist; vml; vml = vml->next)
164 if (start >= vml->vma->vm_start && start + len <= vml->vma->vm_end)
165 return 0;
166
167 for (sraml = child->mm->context.sram_list; sraml; sraml = sraml->next)
168 if (start >= (unsigned long)sraml->addr
169 && start + len <= (unsigned long)sraml->addr + sraml->length)
170 return 0;
171
172 return -EIO;
173}
174
175/*
176 * Called by kernel/ptrace.c when detaching..
177 *
178 * Make sure the single step bit is not set.
179 */
180void ptrace_disable(struct task_struct *child)
181{
182 unsigned long tmp;
183 /* make sure the single step bit is not set. */
184 tmp = get_reg(child, PT_SR) & ~(TRACE_BITS << 16);
185 put_reg(child, PT_SR, tmp);
186}
187
188long arch_ptrace(struct task_struct *child, long request, long addr, long data)
189{
190 int ret;
191 int add = 0;
192
193 switch (request) {
194 /* when I and D space are separate, these will need to be fixed. */
195 case PTRACE_PEEKDATA:
196 pr_debug("ptrace: PEEKDATA\n");
197 add = MAX_SHARED_LIBS * 4; /* space between text and data */
198 /* fall through */
199 case PTRACE_PEEKTEXT: /* read word at location addr. */
200 {
201 unsigned long tmp = 0;
202 int copied;
203
204 ret = -EIO;
205 pr_debug("ptrace: PEEKTEXT at addr 0x%08lx + add %d %ld\n", addr, add,
206 sizeof(data));
207 if (is_user_addr_valid(child, addr + add, sizeof(tmp)) < 0)
208 break;
209 pr_debug("ptrace: user address is valid\n");
210
211#if L1_CODE_LENGTH != 0
212 if (addr + add >= L1_CODE_START
213 && addr + add + sizeof(tmp) <= L1_CODE_START + L1_CODE_LENGTH) {
214 safe_dma_memcpy (&tmp, (const void *)(addr + add), sizeof(tmp));
215 copied = sizeof(tmp);
216 } else
217#endif
218 copied =
219 access_process_vm(child, addr + add, &tmp,
220 sizeof(tmp), 0);
221 pr_debug("ptrace: copied size %d [0x%08lx]\n", copied, tmp);
222 if (copied != sizeof(tmp))
223 break;
224 ret = put_user(tmp, (unsigned long *)data);
225 break;
226 }
227
228 /* read the word at location addr in the USER area. */
229 case PTRACE_PEEKUSR:
230 {
231 unsigned long tmp;
232 ret = -EIO;
233 tmp = 0;
234 if ((addr & 3) || (addr > (sizeof(struct pt_regs) + 16))) {
235 printk(KERN_WARNING "ptrace error : PEEKUSR : temporarily returning "
236 "0 - %x sizeof(pt_regs) is %lx\n",
237 (int)addr, sizeof(struct pt_regs));
238 break;
239 }
240 if (addr == sizeof(struct pt_regs)) {
241 /* PT_TEXT_ADDR */
242 tmp = child->mm->start_code + TEXT_OFFSET;
243 } else if (addr == (sizeof(struct pt_regs) + 4)) {
244 /* PT_TEXT_END_ADDR */
245 tmp = child->mm->end_code;
246 } else if (addr == (sizeof(struct pt_regs) + 8)) {
247 /* PT_DATA_ADDR */
248 tmp = child->mm->start_data;
249#ifdef CONFIG_BINFMT_ELF_FDPIC
250 } else if (addr == (sizeof(struct pt_regs) + 12)) {
251 tmp = child->mm->context.exec_fdpic_loadmap;
252 } else if (addr == (sizeof(struct pt_regs) + 16)) {
253 tmp = child->mm->context.interp_fdpic_loadmap;
254#endif
255 } else {
256 tmp = get_reg(child, addr);
257 }
258 ret = put_user(tmp, (unsigned long *)data);
259 break;
260 }
261
262 /* when I and D space are separate, this will have to be fixed. */
263 case PTRACE_POKEDATA:
264 printk(KERN_NOTICE "ptrace: PTRACE_PEEKDATA\n");
265 /* fall through */
266 case PTRACE_POKETEXT: /* write the word at location addr. */
267 {
268 int copied;
269
270 ret = -EIO;
271 pr_debug("ptrace: POKETEXT at addr 0x%08lx + add %d %ld bytes %lx\n",
272 addr, add, sizeof(data), data);
273 if (is_user_addr_valid(child, addr + add, sizeof(data)) < 0)
274 break;
275 pr_debug("ptrace: user address is valid\n");
276
277#if L1_CODE_LENGTH != 0
278 if (addr + add >= L1_CODE_START
279 && addr + add + sizeof(data) <= L1_CODE_START + L1_CODE_LENGTH) {
280 safe_dma_memcpy ((void *)(addr + add), &data, sizeof(data));
281 copied = sizeof(data);
282 } else
283#endif
284 copied =
285 access_process_vm(child, addr + add, &data,
286 sizeof(data), 1);
287 pr_debug("ptrace: copied size %d\n", copied);
288 if (copied != sizeof(data))
289 break;
290 ret = 0;
291 break;
292 }
293
294 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
295 ret = -EIO;
296 if ((addr & 3) || (addr > (sizeof(struct pt_regs) + 16))) {
297 printk(KERN_WARNING "ptrace error : POKEUSR: temporarily returning 0\n");
298 break;
299 }
300
301 if (addr >= (sizeof(struct pt_regs))) {
302 ret = 0;
303 break;
304 }
305 if (addr == PT_SYSCFG) {
306 data &= SYSCFG_MASK;
307 data |= get_reg(child, PT_SYSCFG);
308 }
309 ret = put_reg(child, addr, data);
310 break;
311
312 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
313 case PTRACE_CONT:
314 { /* restart after signal. */
315 long tmp;
316
317 pr_debug("ptrace_cont\n");
318
319 ret = -EIO;
320 if (!valid_signal(data))
321 break;
322 if (request == PTRACE_SYSCALL)
323 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
324 else
325 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
326
327 child->exit_code = data;
328 /* make sure the single step bit is not set. */
329 tmp = get_reg(child, PT_SYSCFG) & ~(TRACE_BITS);
330 put_reg(child, PT_SYSCFG, tmp);
331 pr_debug("before wake_up_process\n");
332 wake_up_process(child);
333 ret = 0;
334 break;
335 }
336
337 /*
338 * make the child exit. Best I can do is send it a sigkill.
339 * perhaps it should be put in the status that it wants to
340 * exit.
341 */
342 case PTRACE_KILL:
343 {
344 long tmp;
345 ret = 0;
346 if (child->exit_state == EXIT_ZOMBIE) /* already dead */
347 break;
348 child->exit_code = SIGKILL;
349 /* make sure the single step bit is not set. */
350 tmp = get_reg(child, PT_SYSCFG) & ~(TRACE_BITS);
351 put_reg(child, PT_SYSCFG, tmp);
352 wake_up_process(child);
353 break;
354 }
355
356 case PTRACE_SINGLESTEP:
357 { /* set the trap flag. */
358 long tmp;
359
360 pr_debug("single step\n");
361 ret = -EIO;
362 if (!valid_signal(data))
363 break;
364 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
365
366 tmp = get_reg(child, PT_SYSCFG) | (TRACE_BITS);
367 put_reg(child, PT_SYSCFG, tmp);
368
369 child->exit_code = data;
370 /* give it a chance to run. */
371 wake_up_process(child);
372 ret = 0;
373 break;
374 }
375
376 case PTRACE_DETACH:
377 { /* detach a process that was attached. */
378 ret = ptrace_detach(child, data);
379 break;
380 }
381
382 case PTRACE_GETREGS:
383 {
384
385 /* Get all gp regs from the child. */
386 ret = ptrace_getregs(child, (void __user *)data);
387 break;
388 }
389
390 case PTRACE_SETREGS:
391 {
392 printk(KERN_NOTICE
393 "ptrace: SETREGS: **** NOT IMPLEMENTED ***\n");
394 /* Set all gp regs in the child. */
395 ret = 0;
396 break;
397 }
398 default:
399 ret = ptrace_request(child, request, addr, data);
400 break;
401 }
402
403 return ret;
404}
405
406asmlinkage void syscall_trace(void)
407{
408
409 if (!test_thread_flag(TIF_SYSCALL_TRACE))
410 return;
411
412 if (!(current->ptrace & PT_PTRACED))
413 return;
414
415 /* the 0x80 provides a way for the tracing parent to distinguish
416 * between a syscall stop and SIGTRAP delivery
417 */
418 ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
419 ? 0x80 : 0));
420
421 /*
422 * this isn't the same as continuing with a signal, but it will do
423 * for normal use. strace only continues with a signal if the
424 * stopping signal is not SIGTRAP. -brl
425 */
426 if (current->exit_code) {
427 send_sig(current->exit_code, current, 1);
428 current->exit_code = 0;
429 }
430}
diff --git a/arch/blackfin/kernel/setup.c b/arch/blackfin/kernel/setup.c
new file mode 100644
index 000000000000..342bb8dd56ac
--- /dev/null
+++ b/arch/blackfin/kernel/setup.c
@@ -0,0 +1,902 @@
1/*
2 * File: arch/blackfin/kernel/setup.c
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/delay.h>
31#include <linux/console.h>
32#include <linux/bootmem.h>
33#include <linux/seq_file.h>
34#include <linux/cpu.h>
35#include <linux/module.h>
36#include <linux/console.h>
37#include <linux/tty.h>
38
39#include <linux/ext2_fs.h>
40#include <linux/cramfs_fs.h>
41#include <linux/romfs_fs.h>
42
43#include <asm/cacheflush.h>
44#include <asm/blackfin.h>
45#include <asm/cplbinit.h>
46
47unsigned long memory_start, memory_end, physical_mem_end;
48unsigned long reserved_mem_dcache_on;
49unsigned long reserved_mem_icache_on;
50EXPORT_SYMBOL(memory_start);
51EXPORT_SYMBOL(memory_end);
52EXPORT_SYMBOL(physical_mem_end);
53EXPORT_SYMBOL(_ramend);
54
55#ifdef CONFIG_MTD_UCLINUX
56unsigned long memory_mtd_end, memory_mtd_start, mtd_size;
57unsigned long _ebss;
58EXPORT_SYMBOL(memory_mtd_end);
59EXPORT_SYMBOL(memory_mtd_start);
60EXPORT_SYMBOL(mtd_size);
61#endif
62
63char command_line[COMMAND_LINE_SIZE];
64
65#if defined(CONFIG_BLKFIN_DCACHE) || defined(CONFIG_BLKFIN_CACHE)
66static void generate_cpl_tables(void);
67#endif
68
69void __init bf53x_cache_init(void)
70{
71#if defined(CONFIG_BLKFIN_DCACHE) || defined(CONFIG_BLKFIN_CACHE)
72 generate_cpl_tables();
73#endif
74
75#ifdef CONFIG_BLKFIN_CACHE
76 bfin_icache_init();
77 printk(KERN_INFO "Instruction Cache Enabled\n");
78#endif
79
80#ifdef CONFIG_BLKFIN_DCACHE
81 bfin_dcache_init();
82 printk(KERN_INFO "Data Cache Enabled"
83# if defined CONFIG_BLKFIN_WB
84 " (write-back)"
85# elif defined CONFIG_BLKFIN_WT
86 " (write-through)"
87# endif
88 "\n");
89#endif
90}
91
92void bf53x_relocate_l1_mem(void)
93{
94 unsigned long l1_code_length;
95 unsigned long l1_data_a_length;
96 unsigned long l1_data_b_length;
97
98 l1_code_length = _etext_l1 - _stext_l1;
99 if (l1_code_length > L1_CODE_LENGTH)
100 l1_code_length = L1_CODE_LENGTH;
101 /* cannot complain as printk is not available as yet.
102 * But we can continue booting and complain later!
103 */
104
105 /* Copy _stext_l1 to _etext_l1 to L1 instruction SRAM */
106 dma_memcpy(_stext_l1, _l1_lma_start, l1_code_length);
107
108 l1_data_a_length = _ebss_l1 - _sdata_l1;
109 if (l1_data_a_length > L1_DATA_A_LENGTH)
110 l1_data_a_length = L1_DATA_A_LENGTH;
111
112 /* Copy _sdata_l1 to _ebss_l1 to L1 data bank A SRAM */
113 dma_memcpy(_sdata_l1, _l1_lma_start + l1_code_length, l1_data_a_length);
114
115 l1_data_b_length = _ebss_b_l1 - _sdata_b_l1;
116 if (l1_data_b_length > L1_DATA_B_LENGTH)
117 l1_data_b_length = L1_DATA_B_LENGTH;
118
119 /* Copy _sdata_b_l1 to _ebss_b_l1 to L1 data bank B SRAM */
120 dma_memcpy(_sdata_b_l1, _l1_lma_start + l1_code_length +
121 l1_data_a_length, l1_data_b_length);
122
123}
124
125/*
126 * Initial parsing of the command line. Currently, we support:
127 * - Controlling the linux memory size: mem=xxx[KMG]
128 * - Controlling the physical memory size: max_mem=xxx[KMG][$][#]
129 * $ -> reserved memory is dcacheable
130 * # -> reserved memory is icacheable
131 */
132static __init void parse_cmdline_early(char *cmdline_p)
133{
134 char c = ' ', *to = cmdline_p;
135 unsigned int memsize;
136 for (;;) {
137 if (c == ' ') {
138
139 if (!memcmp(to, "mem=", 4)) {
140 to += 4;
141 memsize = memparse(to, &to);
142 if (memsize)
143 _ramend = memsize;
144
145 } else if (!memcmp(to, "max_mem=", 8)) {
146 to += 8;
147 memsize = memparse(to, &to);
148 if (memsize) {
149 physical_mem_end = memsize;
150 if (*to != ' ') {
151 if (*to == '$'
152 || *(to + 1) == '$')
153 reserved_mem_dcache_on =
154 1;
155 if (*to == '#'
156 || *(to + 1) == '#')
157 reserved_mem_icache_on =
158 1;
159 }
160 }
161 }
162
163 }
164 c = *(to++);
165 if (!c)
166 break;
167 }
168}
169
170void __init setup_arch(char **cmdline_p)
171{
172 int bootmap_size;
173 unsigned long l1_length, sclk, cclk;
174#ifdef CONFIG_MTD_UCLINUX
175 unsigned long mtd_phys = 0;
176#endif
177
178 cclk = get_cclk();
179 sclk = get_sclk();
180
181#if !defined(CONFIG_BFIN_KERNEL_CLOCK) && defined(ANOMALY_05000273)
182 if (cclk == sclk)
183 panic("ANOMALY 05000273, SCLK can not be same as CCLK");
184#endif
185
186#if defined(ANOMALY_05000266)
187 bfin_read_IMDMA_D0_IRQ_STATUS();
188 bfin_read_IMDMA_D1_IRQ_STATUS();
189#endif
190
191#ifdef DEBUG_SERIAL_EARLY_INIT
192 bfin_console_init(); /* early console registration */
193 /* this give a chance to get printk() working before crash. */
194#endif
195
196#if defined(CONFIG_CHR_DEV_FLASH) || defined(CONFIG_BLK_DEV_FLASH)
197 /* we need to initialize the Flashrom device here since we might
198 * do things with flash early on in the boot
199 */
200 flash_probe();
201#endif
202
203#if defined(CONFIG_CMDLINE_BOOL)
204 memset(command_line, 0, sizeof(command_line));
205 strncpy(&command_line[0], CONFIG_CMDLINE, sizeof(command_line));
206 command_line[sizeof(command_line) - 1] = 0;
207#endif
208
209 /* Keep a copy of command line */
210 *cmdline_p = &command_line[0];
211 memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
212 boot_command_line[COMMAND_LINE_SIZE - 1] = 0;
213
214 /* setup memory defaults from the user config */
215 physical_mem_end = 0;
216 _ramend = CONFIG_MEM_SIZE * 1024 * 1024;
217
218 parse_cmdline_early(&command_line[0]);
219
220 if (physical_mem_end == 0)
221 physical_mem_end = _ramend;
222
223 /* by now the stack is part of the init task */
224 memory_end = _ramend - DMA_UNCACHED_REGION;
225
226 _ramstart = (unsigned long)__bss_stop;
227 memory_start = PAGE_ALIGN(_ramstart);
228
229#if defined(CONFIG_MTD_UCLINUX)
230 /* generic memory mapped MTD driver */
231 memory_mtd_end = memory_end;
232
233 mtd_phys = _ramstart;
234 mtd_size = PAGE_ALIGN(*((unsigned long *)(mtd_phys + 8)));
235
236# if defined(CONFIG_EXT2_FS) || defined(CONFIG_EXT3_FS)
237 if (*((unsigned short *)(mtd_phys + 0x438)) == EXT2_SUPER_MAGIC)
238 mtd_size =
239 PAGE_ALIGN(*((unsigned long *)(mtd_phys + 0x404)) << 10);
240# endif
241
242# if defined(CONFIG_CRAMFS)
243 if (*((unsigned long *)(mtd_phys)) == CRAMFS_MAGIC)
244 mtd_size = PAGE_ALIGN(*((unsigned long *)(mtd_phys + 0x4)));
245# endif
246
247# if defined(CONFIG_ROMFS_FS)
248 if (((unsigned long *)mtd_phys)[0] == ROMSB_WORD0
249 && ((unsigned long *)mtd_phys)[1] == ROMSB_WORD1)
250 mtd_size =
251 PAGE_ALIGN(be32_to_cpu(((unsigned long *)mtd_phys)[2]));
252# if (defined(CONFIG_BLKFIN_CACHE) && defined(ANOMALY_05000263))
253 /* Due to a Hardware Anomaly we need to limit the size of usable
254 * instruction memory to max 60MB, 56 if HUNT_FOR_ZERO is on
255 * 05000263 - Hardware loop corrupted when taking an ICPLB exception
256 */
257# if (defined(CONFIG_DEBUG_HUNT_FOR_ZERO))
258 if (memory_end >= 56 * 1024 * 1024)
259 memory_end = 56 * 1024 * 1024;
260# else
261 if (memory_end >= 60 * 1024 * 1024)
262 memory_end = 60 * 1024 * 1024;
263# endif /* CONFIG_DEBUG_HUNT_FOR_ZERO */
264# endif /* ANOMALY_05000263 */
265# endif /* CONFIG_ROMFS_FS */
266
267 memory_end -= mtd_size;
268
269 if (mtd_size == 0) {
270 console_init();
271 panic("Don't boot kernel without rootfs attached.\n");
272 }
273
274 /* Relocate MTD image to the top of memory after the uncached memory area */
275 dma_memcpy((char *)memory_end, __bss_stop, mtd_size);
276
277 memory_mtd_start = memory_end;
278 _ebss = memory_mtd_start; /* define _ebss for compatible */
279#endif /* CONFIG_MTD_UCLINUX */
280
281#if (defined(CONFIG_BLKFIN_CACHE) && defined(ANOMALY_05000263))
282 /* Due to a Hardware Anomaly we need to limit the size of usable
283 * instruction memory to max 60MB, 56 if HUNT_FOR_ZERO is on
284 * 05000263 - Hardware loop corrupted when taking an ICPLB exception
285 */
286#if (defined(CONFIG_DEBUG_HUNT_FOR_ZERO))
287 if (memory_end >= 56 * 1024 * 1024)
288 memory_end = 56 * 1024 * 1024;
289#else
290 if (memory_end >= 60 * 1024 * 1024)
291 memory_end = 60 * 1024 * 1024;
292#endif /* CONFIG_DEBUG_HUNT_FOR_ZERO */
293 printk(KERN_NOTICE "Warning: limiting memory to %liMB due to hardware anomaly 05000263\n", memory_end >> 20);
294#endif /* ANOMALY_05000263 */
295
296#if !defined(CONFIG_MTD_UCLINUX)
297 memory_end -= SIZE_4K; /*In case there is no valid CPLB behind memory_end make sure we don't get to close*/
298#endif
299 init_mm.start_code = (unsigned long)_stext;
300 init_mm.end_code = (unsigned long)_etext;
301 init_mm.end_data = (unsigned long)_edata;
302 init_mm.brk = (unsigned long)0;
303
304 init_leds();
305
306 printk(KERN_INFO "Blackfin support (C) 2004-2007 Analog Devices, Inc.\n");
307 printk(KERN_INFO "Compiled for ADSP-%s Rev 0.%d\n", CPU, bfin_compiled_revid());
308 if (bfin_revid() != bfin_compiled_revid())
309 printk(KERN_ERR "Warning: Compiled for Rev %d, but running on Rev %d\n",
310 bfin_compiled_revid(), bfin_revid());
311 if (bfin_revid() < SUPPORTED_REVID)
312 printk(KERN_ERR "Warning: Unsupported Chip Revision ADSP-%s Rev 0.%d detected\n",
313 CPU, bfin_revid());
314 printk(KERN_INFO "Blackfin Linux support by http://blackfin.uclinux.org/\n");
315
316 printk(KERN_INFO "Processor Speed: %lu MHz core clock and %lu Mhz System Clock\n",
317 cclk / 1000000, sclk / 1000000);
318
319#if defined(ANOMALY_05000273)
320 if ((cclk >> 1) <= sclk)
321 printk("\n\n\nANOMALY_05000273: CCLK must be >= 2*SCLK !!!\n\n\n");
322#endif
323
324 printk(KERN_INFO "Board Memory: %ldMB\n", physical_mem_end >> 20);
325 printk(KERN_INFO "Kernel Managed Memory: %ldMB\n", _ramend >> 20);
326
327 printk(KERN_INFO "Memory map:\n"
328 KERN_INFO " text = 0x%p-0x%p\n"
329 KERN_INFO " init = 0x%p-0x%p\n"
330 KERN_INFO " data = 0x%p-0x%p\n"
331 KERN_INFO " stack = 0x%p-0x%p\n"
332 KERN_INFO " bss = 0x%p-0x%p\n"
333 KERN_INFO " available = 0x%p-0x%p\n"
334#ifdef CONFIG_MTD_UCLINUX
335 KERN_INFO " rootfs = 0x%p-0x%p\n"
336#endif
337#if DMA_UNCACHED_REGION > 0
338 KERN_INFO " DMA Zone = 0x%p-0x%p\n"
339#endif
340 , _stext, _etext,
341 __init_begin, __init_end,
342 _sdata, _edata,
343 (void*)&init_thread_union, (void*)((int)(&init_thread_union) + 0x2000),
344 __bss_start, __bss_stop,
345 (void*)_ramstart, (void*)memory_end
346#ifdef CONFIG_MTD_UCLINUX
347 , (void*)memory_mtd_start, (void*)(memory_mtd_start + mtd_size)
348#endif
349#if DMA_UNCACHED_REGION > 0
350 , (void*)(_ramend - DMA_UNCACHED_REGION), (void*)(_ramend)
351#endif
352 );
353
354 /*
355 * give all the memory to the bootmap allocator, tell it to put the
356 * boot mem_map at the start of memory
357 */
358 bootmap_size = init_bootmem_node(NODE_DATA(0), memory_start >> PAGE_SHIFT, /* map goes here */
359 PAGE_OFFSET >> PAGE_SHIFT,
360 memory_end >> PAGE_SHIFT);
361 /*
362 * free the usable memory, we have to make sure we do not free
363 * the bootmem bitmap so we then reserve it after freeing it :-)
364 */
365 free_bootmem(memory_start, memory_end - memory_start);
366
367 reserve_bootmem(memory_start, bootmap_size);
368 /*
369 * get kmalloc into gear
370 */
371 paging_init();
372
373 /* check the size of the l1 area */
374 l1_length = _etext_l1 - _stext_l1;
375 if (l1_length > L1_CODE_LENGTH)
376 panic("L1 memory overflow\n");
377
378 l1_length = _ebss_l1 - _sdata_l1;
379 if (l1_length > L1_DATA_A_LENGTH)
380 panic("L1 memory overflow\n");
381
382 bf53x_cache_init();
383
384#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
385# if defined(CONFIG_BFIN_SHARED_FLASH_ENET) && defined(CONFIG_BFIN533_STAMP)
386 /* setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC */
387 bfin_write_FIO_DIR(bfin_read_FIO_DIR() | (1 << CONFIG_ENET_FLASH_PIN));
388 bfin_write_FIO_FLAG_S(1 << CONFIG_ENET_FLASH_PIN);
389 SSYNC();
390# endif
391# if defined (CONFIG_BFIN561_EZKIT)
392 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));
393 SSYNC();
394# endif /* defined (CONFIG_BFIN561_EZKIT) */
395#endif
396
397 printk(KERN_INFO "Hardware Trace Enabled\n");
398 bfin_write_TBUFCTL(0x03);
399}
400
401#if defined(CONFIG_BF561)
402static struct cpu cpu[2];
403#else
404static struct cpu cpu[1];
405#endif
406static int __init topology_init(void)
407{
408#if defined (CONFIG_BF561)
409 register_cpu(&cpu[0], 0);
410 register_cpu(&cpu[1], 1);
411 return 0;
412#else
413 return register_cpu(cpu, 0);
414#endif
415}
416
417subsys_initcall(topology_init);
418
419#if defined(CONFIG_BLKFIN_DCACHE) || defined(CONFIG_BLKFIN_CACHE)
420u16 lock_kernel_check(u32 start, u32 end)
421{
422 if ((start <= (u32) _stext && end >= (u32) _end)
423 || (start >= (u32) _stext && end <= (u32) _end))
424 return IN_KERNEL;
425 return 0;
426}
427
428static unsigned short __init
429fill_cplbtab(struct cplb_tab *table,
430 unsigned long start, unsigned long end,
431 unsigned long block_size, unsigned long cplb_data)
432{
433 int i;
434
435 switch (block_size) {
436 case SIZE_4M:
437 i = 3;
438 break;
439 case SIZE_1M:
440 i = 2;
441 break;
442 case SIZE_4K:
443 i = 1;
444 break;
445 case SIZE_1K:
446 default:
447 i = 0;
448 break;
449 }
450
451 cplb_data = (cplb_data & ~(3 << 16)) | (i << 16);
452
453 while ((start < end) && (table->pos < table->size)) {
454
455 table->tab[table->pos++] = start;
456
457 if (lock_kernel_check(start, start + block_size) == IN_KERNEL)
458 table->tab[table->pos++] =
459 cplb_data | CPLB_LOCK | CPLB_DIRTY;
460 else
461 table->tab[table->pos++] = cplb_data;
462
463 start += block_size;
464 }
465 return 0;
466}
467
468static unsigned short __init
469close_cplbtab(struct cplb_tab *table)
470{
471
472 while (table->pos < table->size) {
473
474 table->tab[table->pos++] = 0;
475 table->tab[table->pos++] = 0; /* !CPLB_VALID */
476 }
477 return 0;
478}
479
480static void __init generate_cpl_tables(void)
481{
482
483 u16 i, j, process;
484 u32 a_start, a_end, as, ae, as_1m;
485
486 struct cplb_tab *t_i = NULL;
487 struct cplb_tab *t_d = NULL;
488 struct s_cplb cplb;
489
490 cplb.init_i.size = MAX_CPLBS;
491 cplb.init_d.size = MAX_CPLBS;
492 cplb.switch_i.size = MAX_SWITCH_I_CPLBS;
493 cplb.switch_d.size = MAX_SWITCH_D_CPLBS;
494
495 cplb.init_i.pos = 0;
496 cplb.init_d.pos = 0;
497 cplb.switch_i.pos = 0;
498 cplb.switch_d.pos = 0;
499
500 cplb.init_i.tab = icplb_table;
501 cplb.init_d.tab = dcplb_table;
502 cplb.switch_i.tab = ipdt_table;
503 cplb.switch_d.tab = dpdt_table;
504
505 cplb_data[SDRAM_KERN].end = memory_end;
506
507#ifdef CONFIG_MTD_UCLINUX
508 cplb_data[SDRAM_RAM_MTD].start = memory_mtd_start;
509 cplb_data[SDRAM_RAM_MTD].end = memory_mtd_start + mtd_size;
510 cplb_data[SDRAM_RAM_MTD].valid = mtd_size > 0;
511# if defined(CONFIG_ROMFS_FS)
512 cplb_data[SDRAM_RAM_MTD].attr |= I_CPLB;
513
514 /*
515 * The ROMFS_FS size is often not multiple of 1MB.
516 * This can cause multiple CPLB sets covering the same memory area.
517 * This will then cause multiple CPLB hit exceptions.
518 * Workaround: We ensure a contiguous memory area by extending the kernel
519 * memory section over the mtd section.
520 * For ROMFS_FS memory must be covered with ICPLBs anyways.
521 * So there is no difference between kernel and mtd memory setup.
522 */
523
524 cplb_data[SDRAM_KERN].end = memory_mtd_start + mtd_size;;
525 cplb_data[SDRAM_RAM_MTD].valid = 0;
526
527# endif
528#else
529 cplb_data[SDRAM_RAM_MTD].valid = 0;
530#endif
531
532 cplb_data[SDRAM_DMAZ].start = _ramend - DMA_UNCACHED_REGION;
533 cplb_data[SDRAM_DMAZ].end = _ramend;
534
535 cplb_data[RES_MEM].start = _ramend;
536 cplb_data[RES_MEM].end = physical_mem_end;
537
538 if (reserved_mem_dcache_on)
539 cplb_data[RES_MEM].d_conf = SDRAM_DGENERIC;
540 else
541 cplb_data[RES_MEM].d_conf = SDRAM_DNON_CHBL;
542
543 if (reserved_mem_icache_on)
544 cplb_data[RES_MEM].i_conf = SDRAM_IGENERIC;
545 else
546 cplb_data[RES_MEM].i_conf = SDRAM_INON_CHBL;
547
548 for (i = ZERO_P; i <= L2_MEM; i++) {
549
550 if (cplb_data[i].valid) {
551
552 as_1m = cplb_data[i].start % SIZE_1M;
553
554 /* We need to make sure all sections are properly 1M aligned
555 * However between Kernel Memory and the Kernel mtd section, depending on the
556 * rootfs size, there can be overlapping memory areas.
557 */
558
559 if (as_1m && i!=L1I_MEM && i!=L1D_MEM) {
560#ifdef CONFIG_MTD_UCLINUX
561 if (i == SDRAM_RAM_MTD) {
562 if ((cplb_data[SDRAM_KERN].end + 1) > cplb_data[SDRAM_RAM_MTD].start)
563 cplb_data[SDRAM_RAM_MTD].start = (cplb_data[i].start & (-2*SIZE_1M)) + SIZE_1M;
564 else
565 cplb_data[SDRAM_RAM_MTD].start = (cplb_data[i].start & (-2*SIZE_1M));
566 } else
567#endif
568 printk(KERN_WARNING "Unaligned Start of %s at 0x%X\n",
569 cplb_data[i].name, cplb_data[i].start);
570 }
571
572 as = cplb_data[i].start % SIZE_4M;
573 ae = cplb_data[i].end % SIZE_4M;
574
575 if (as)
576 a_start = cplb_data[i].start + (SIZE_4M - (as));
577 else
578 a_start = cplb_data[i].start;
579
580 a_end = cplb_data[i].end - ae;
581
582 for (j = INITIAL_T; j <= SWITCH_T; j++) {
583
584 switch (j) {
585 case INITIAL_T:
586 if (cplb_data[i].attr & INITIAL_T) {
587 t_i = &cplb.init_i;
588 t_d = &cplb.init_d;
589 process = 1;
590 } else
591 process = 0;
592 break;
593 case SWITCH_T:
594 if (cplb_data[i].attr & SWITCH_T) {
595 t_i = &cplb.switch_i;
596 t_d = &cplb.switch_d;
597 process = 1;
598 } else
599 process = 0;
600 break;
601 default:
602 process = 0;
603 break;
604 }
605
606 if (process) {
607 if (cplb_data[i].attr & I_CPLB) {
608
609 if (cplb_data[i].psize) {
610 fill_cplbtab(t_i,
611 cplb_data[i].start,
612 cplb_data[i].end,
613 cplb_data[i].psize,
614 cplb_data[i].i_conf);
615 } else {
616 /*icplb_table */
617#if (defined(CONFIG_BLKFIN_CACHE) && defined(ANOMALY_05000263))
618 if (i == SDRAM_KERN) {
619 fill_cplbtab(t_i,
620 cplb_data[i].start,
621 cplb_data[i].end,
622 SIZE_4M,
623 cplb_data[i].i_conf);
624 } else
625#endif
626 {
627 fill_cplbtab(t_i,
628 cplb_data[i].start,
629 a_start,
630 SIZE_1M,
631 cplb_data[i].i_conf);
632 fill_cplbtab(t_i,
633 a_start,
634 a_end,
635 SIZE_4M,
636 cplb_data[i].i_conf);
637 fill_cplbtab(t_i, a_end,
638 cplb_data[i].end,
639 SIZE_1M,
640 cplb_data[i].i_conf);
641 }
642 }
643
644 }
645 if (cplb_data[i].attr & D_CPLB) {
646
647 if (cplb_data[i].psize) {
648 fill_cplbtab(t_d,
649 cplb_data[i].start,
650 cplb_data[i].end,
651 cplb_data[i].psize,
652 cplb_data[i].d_conf);
653 } else {
654/*dcplb_table*/
655 fill_cplbtab(t_d,
656 cplb_data[i].start,
657 a_start, SIZE_1M,
658 cplb_data[i].d_conf);
659 fill_cplbtab(t_d, a_start,
660 a_end, SIZE_4M,
661 cplb_data[i].d_conf);
662 fill_cplbtab(t_d, a_end,
663 cplb_data[i].end,
664 SIZE_1M,
665 cplb_data[i].d_conf);
666
667 }
668
669 }
670 }
671 }
672
673 }
674 }
675
676/* close tables */
677
678 close_cplbtab(&cplb.init_i);
679 close_cplbtab(&cplb.init_d);
680
681 cplb.init_i.tab[cplb.init_i.pos] = -1;
682 cplb.init_d.tab[cplb.init_d.pos] = -1;
683 cplb.switch_i.tab[cplb.switch_i.pos] = -1;
684 cplb.switch_d.tab[cplb.switch_d.pos] = -1;
685
686}
687
688#endif
689
690static inline u_long get_vco(void)
691{
692 u_long msel;
693 u_long vco;
694
695 msel = (bfin_read_PLL_CTL() >> 9) & 0x3F;
696 if (0 == msel)
697 msel = 64;
698
699 vco = CONFIG_CLKIN_HZ;
700 vco >>= (1 & bfin_read_PLL_CTL()); /* DF bit */
701 vco = msel * vco;
702 return vco;
703}
704
705/*Get the Core clock*/
706u_long get_cclk(void)
707{
708 u_long csel, ssel;
709 if (bfin_read_PLL_STAT() & 0x1)
710 return CONFIG_CLKIN_HZ;
711
712 ssel = bfin_read_PLL_DIV();
713 csel = ((ssel >> 4) & 0x03);
714 ssel &= 0xf;
715 if (ssel && ssel < (1 << csel)) /* SCLK > CCLK */
716 return get_vco() / ssel;
717 return get_vco() >> csel;
718}
719
720EXPORT_SYMBOL(get_cclk);
721
722/* Get the System clock */
723u_long get_sclk(void)
724{
725 u_long ssel;
726
727 if (bfin_read_PLL_STAT() & 0x1)
728 return CONFIG_CLKIN_HZ;
729
730 ssel = (bfin_read_PLL_DIV() & 0xf);
731 if (0 == ssel) {
732 printk(KERN_WARNING "Invalid System Clock\n");
733 ssel = 1;
734 }
735
736 return get_vco() / ssel;
737}
738
739EXPORT_SYMBOL(get_sclk);
740
741/*
742 * Get CPU information for use by the procfs.
743 */
744static int show_cpuinfo(struct seq_file *m, void *v)
745{
746 char *cpu, *mmu, *fpu, *name;
747 uint32_t revid;
748
749 u_long cclk = 0, sclk = 0;
750 u_int dcache_size = 0, dsup_banks = 0;
751
752 cpu = CPU;
753 mmu = "none";
754 fpu = "none";
755 revid = bfin_revid();
756 name = bfin_board_name;
757
758 cclk = get_cclk();
759 sclk = get_sclk();
760
761 seq_printf(m, "CPU:\t\tADSP-%s Rev. 0.%d\n"
762 "MMU:\t\t%s\n"
763 "FPU:\t\t%s\n"
764 "Core Clock:\t%9lu Hz\n"
765 "System Clock:\t%9lu Hz\n"
766 "BogoMips:\t%lu.%02lu\n"
767 "Calibration:\t%lu loops\n",
768 cpu, revid, mmu, fpu,
769 cclk,
770 sclk,
771 (loops_per_jiffy * HZ) / 500000,
772 ((loops_per_jiffy * HZ) / 5000) % 100,
773 (loops_per_jiffy * HZ));
774 seq_printf(m, "Board Name:\t%s\n", name);
775 seq_printf(m, "Board Memory:\t%ld MB\n", physical_mem_end >> 20);
776 seq_printf(m, "Kernel Memory:\t%ld MB\n", (unsigned long)_ramend >> 20);
777 if (bfin_read_IMEM_CONTROL() & (ENICPLB | IMC))
778 seq_printf(m, "I-CACHE:\tON\n");
779 else
780 seq_printf(m, "I-CACHE:\tOFF\n");
781 if ((bfin_read_DMEM_CONTROL()) & (ENDCPLB | DMC_ENABLE))
782 seq_printf(m, "D-CACHE:\tON"
783#if defined CONFIG_BLKFIN_WB
784 " (write-back)"
785#elif defined CONFIG_BLKFIN_WT
786 " (write-through)"
787#endif
788 "\n");
789 else
790 seq_printf(m, "D-CACHE:\tOFF\n");
791
792
793 switch(bfin_read_DMEM_CONTROL() & (1 << DMC0_P | 1 << DMC1_P)) {
794 case ACACHE_BSRAM:
795 seq_printf(m, "DBANK-A:\tCACHE\n" "DBANK-B:\tSRAM\n");
796 dcache_size = 16;
797 dsup_banks = 1;
798 break;
799 case ACACHE_BCACHE:
800 seq_printf(m, "DBANK-A:\tCACHE\n" "DBANK-B:\tCACHE\n");
801 dcache_size = 32;
802 dsup_banks = 2;
803 break;
804 case ASRAM_BSRAM:
805 seq_printf(m, "DBANK-A:\tSRAM\n" "DBANK-B:\tSRAM\n");
806 dcache_size = 0;
807 dsup_banks = 0;
808 break;
809 default:
810 break;
811 }
812
813
814 seq_printf(m, "I-CACHE Size:\t%dKB\n", BLKFIN_ICACHESIZE / 1024);
815 seq_printf(m, "D-CACHE Size:\t%dKB\n", dcache_size);
816 seq_printf(m, "I-CACHE Setup:\t%d Sub-banks/%d Ways, %d Lines/Way\n",
817 BLKFIN_ISUBBANKS, BLKFIN_IWAYS, BLKFIN_ILINES);
818 seq_printf(m,
819 "D-CACHE Setup:\t%d Super-banks/%d Sub-banks/%d Ways, %d Lines/Way\n",
820 dsup_banks, BLKFIN_DSUBBANKS, BLKFIN_DWAYS,
821 BLKFIN_DLINES);
822#ifdef CONFIG_BLKFIN_CACHE_LOCK
823 switch (read_iloc()) {
824 case WAY0_L:
825 seq_printf(m, "Way0 Locked-Down\n");
826 break;
827 case WAY1_L:
828 seq_printf(m, "Way1 Locked-Down\n");
829 break;
830 case WAY01_L:
831 seq_printf(m, "Way0,Way1 Locked-Down\n");
832 break;
833 case WAY2_L:
834 seq_printf(m, "Way2 Locked-Down\n");
835 break;
836 case WAY02_L:
837 seq_printf(m, "Way0,Way2 Locked-Down\n");
838 break;
839 case WAY12_L:
840 seq_printf(m, "Way1,Way2 Locked-Down\n");
841 break;
842 case WAY012_L:
843 seq_printf(m, "Way0,Way1 & Way2 Locked-Down\n");
844 break;
845 case WAY3_L:
846 seq_printf(m, "Way3 Locked-Down\n");
847 break;
848 case WAY03_L:
849 seq_printf(m, "Way0,Way3 Locked-Down\n");
850 break;
851 case WAY13_L:
852 seq_printf(m, "Way1,Way3 Locked-Down\n");
853 break;
854 case WAY013_L:
855 seq_printf(m, "Way 0,Way1,Way3 Locked-Down\n");
856 break;
857 case WAY32_L:
858 seq_printf(m, "Way3,Way2 Locked-Down\n");
859 break;
860 case WAY320_L:
861 seq_printf(m, "Way3,Way2,Way0 Locked-Down\n");
862 break;
863 case WAY321_L:
864 seq_printf(m, "Way3,Way2,Way1 Locked-Down\n");
865 break;
866 case WAYALL_L:
867 seq_printf(m, "All Ways are locked\n");
868 break;
869 default:
870 seq_printf(m, "No Ways are locked\n");
871 }
872#endif
873 return 0;
874}
875
876static void *c_start(struct seq_file *m, loff_t *pos)
877{
878 return *pos < NR_CPUS ? ((void *)0x12345678) : NULL;
879}
880
881static void *c_next(struct seq_file *m, void *v, loff_t *pos)
882{
883 ++*pos;
884 return c_start(m, pos);
885}
886
887static void c_stop(struct seq_file *m, void *v)
888{
889}
890
891struct seq_operations cpuinfo_op = {
892 .start = c_start,
893 .next = c_next,
894 .stop = c_stop,
895 .show = show_cpuinfo,
896};
897
898void cmdline_init(unsigned long r0)
899{
900 if (r0)
901 strncpy(command_line, (char *)r0, COMMAND_LINE_SIZE);
902}
diff --git a/arch/blackfin/kernel/signal.c b/arch/blackfin/kernel/signal.c
new file mode 100644
index 000000000000..316e65c3439d
--- /dev/null
+++ b/arch/blackfin/kernel/signal.c
@@ -0,0 +1,356 @@
1/*
2 * File: arch/blackfin/kernel/signal.c
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/signal.h>
31#include <linux/syscalls.h>
32#include <linux/ptrace.h>
33#include <linux/tty.h>
34#include <linux/personality.h>
35#include <linux/binfmts.h>
36#include <linux/freezer.h>
37
38#include <asm/uaccess.h>
39#include <asm/cacheflush.h>
40#include <asm/ucontext.h>
41
42#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
43
44struct fdpic_func_descriptor {
45 unsigned long text;
46 unsigned long GOT;
47};
48
49struct rt_sigframe {
50 int sig;
51 struct siginfo *pinfo;
52 void *puc;
53 char retcode[8];
54 struct siginfo info;
55 struct ucontext uc;
56};
57
58asmlinkage int sys_sigaltstack(const stack_t * uss, stack_t * uoss)
59{
60 return do_sigaltstack(uss, uoss, rdusp());
61}
62
63static inline int
64rt_restore_sigcontext(struct pt_regs *regs, struct sigcontext *sc, int *pr0)
65{
66 unsigned long usp = 0;
67 int err = 0;
68
69#define RESTORE(x) err |= __get_user(regs->x, &sc->sc_##x)
70
71 /* restore passed registers */
72 RESTORE(r0); RESTORE(r1); RESTORE(r2); RESTORE(r3);
73 RESTORE(r4); RESTORE(r5); RESTORE(r6); RESTORE(r7);
74 RESTORE(p0); RESTORE(p1); RESTORE(p2); RESTORE(p3);
75 RESTORE(p4); RESTORE(p5);
76 err |= __get_user(usp, &sc->sc_usp);
77 wrusp(usp);
78 RESTORE(a0w); RESTORE(a1w);
79 RESTORE(a0x); RESTORE(a1x);
80 RESTORE(astat);
81 RESTORE(rets);
82 RESTORE(pc);
83 RESTORE(retx);
84 RESTORE(fp);
85 RESTORE(i0); RESTORE(i1); RESTORE(i2); RESTORE(i3);
86 RESTORE(m0); RESTORE(m1); RESTORE(m2); RESTORE(m3);
87 RESTORE(l0); RESTORE(l1); RESTORE(l2); RESTORE(l3);
88 RESTORE(b0); RESTORE(b1); RESTORE(b2); RESTORE(b3);
89 RESTORE(lc0); RESTORE(lc1);
90 RESTORE(lt0); RESTORE(lt1);
91 RESTORE(lb0); RESTORE(lb1);
92 RESTORE(seqstat);
93
94 regs->orig_p0 = -1; /* disable syscall checks */
95
96 *pr0 = regs->r0;
97 return err;
98}
99
100asmlinkage int do_rt_sigreturn(unsigned long __unused)
101{
102 struct pt_regs *regs = (struct pt_regs *)__unused;
103 unsigned long usp = rdusp();
104 struct rt_sigframe *frame = (struct rt_sigframe *)(usp);
105 sigset_t set;
106 int r0;
107
108 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
109 goto badframe;
110 if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
111 goto badframe;
112
113 sigdelsetmask(&set, ~_BLOCKABLE);
114 spin_lock_irq(&current->sighand->siglock);
115 current->blocked = set;
116 recalc_sigpending();
117 spin_unlock_irq(&current->sighand->siglock);
118
119 if (rt_restore_sigcontext(regs, &frame->uc.uc_mcontext, &r0))
120 goto badframe;
121
122 if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->usp) == -EFAULT)
123 goto badframe;
124
125 return r0;
126
127 badframe:
128 force_sig(SIGSEGV, current);
129 return 0;
130}
131
132static inline int rt_setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs)
133{
134 int err = 0;
135
136#define SETUP(x) err |= __put_user(regs->x, &sc->sc_##x)
137
138 SETUP(r0); SETUP(r1); SETUP(r2); SETUP(r3);
139 SETUP(r4); SETUP(r5); SETUP(r6); SETUP(r7);
140 SETUP(p0); SETUP(p1); SETUP(p2); SETUP(p3);
141 SETUP(p4); SETUP(p5);
142 err |= __put_user(rdusp(), &sc->sc_usp);
143 SETUP(a0w); SETUP(a1w);
144 SETUP(a0x); SETUP(a1x);
145 SETUP(astat);
146 SETUP(rets);
147 SETUP(pc);
148 SETUP(retx);
149 SETUP(fp);
150 SETUP(i0); SETUP(i1); SETUP(i2); SETUP(i3);
151 SETUP(m0); SETUP(m1); SETUP(m2); SETUP(m3);
152 SETUP(l0); SETUP(l1); SETUP(l2); SETUP(l3);
153 SETUP(b0); SETUP(b1); SETUP(b2); SETUP(b3);
154 SETUP(lc0); SETUP(lc1);
155 SETUP(lt0); SETUP(lt1);
156 SETUP(lb0); SETUP(lb1);
157 SETUP(seqstat);
158
159 return err;
160}
161
162static inline void push_cache(unsigned long vaddr, unsigned int len)
163{
164 flush_icache_range(vaddr, vaddr + len);
165}
166
167static inline void *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
168 size_t frame_size)
169{
170 unsigned long usp;
171
172 /* Default to using normal stack. */
173 usp = rdusp();
174
175 /* This is the X/Open sanctioned signal stack switching. */
176 if (ka->sa.sa_flags & SA_ONSTACK) {
177 if (!on_sig_stack(usp))
178 usp = current->sas_ss_sp + current->sas_ss_size;
179 }
180 return (void *)((usp - frame_size) & -8UL);
181}
182
183static int
184setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t * info,
185 sigset_t * set, struct pt_regs *regs)
186{
187 struct rt_sigframe *frame;
188 int err = 0;
189
190 frame = get_sigframe(ka, regs, sizeof(*frame));
191
192 err |= __put_user((current_thread_info()->exec_domain
193 && current_thread_info()->exec_domain->signal_invmap
194 && sig < 32
195 ? current_thread_info()->exec_domain->
196 signal_invmap[sig] : sig), &frame->sig);
197
198 err |= __put_user(&frame->info, &frame->pinfo);
199 err |= __put_user(&frame->uc, &frame->puc);
200 err |= copy_siginfo_to_user(&frame->info, info);
201
202 /* Create the ucontext. */
203 err |= __put_user(0, &frame->uc.uc_flags);
204 err |= __put_user(0, &frame->uc.uc_link);
205 err |=
206 __put_user((void *)current->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
207 err |= __put_user(sas_ss_flags(rdusp()), &frame->uc.uc_stack.ss_flags);
208 err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
209 err |= rt_setup_sigcontext(&frame->uc.uc_mcontext, regs);
210 err |= copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
211
212 /* Set up to return from userspace. */
213 err |= __put_user(0x28, &(frame->retcode[0]));
214 err |= __put_user(0xe1, &(frame->retcode[1]));
215 err |= __put_user(0xad, &(frame->retcode[2]));
216 err |= __put_user(0x00, &(frame->retcode[3]));
217 err |= __put_user(0xa0, &(frame->retcode[4]));
218 err |= __put_user(0x00, &(frame->retcode[5]));
219
220 if (err)
221 goto give_sigsegv;
222
223 push_cache((unsigned long)&frame->retcode, sizeof(frame->retcode));
224
225 /* Set up registers for signal handler */
226 wrusp((unsigned long)frame);
227 if (get_personality & FDPIC_FUNCPTRS) {
228 struct fdpic_func_descriptor __user *funcptr =
229 (struct fdpic_func_descriptor *) ka->sa.sa_handler;
230 __get_user(regs->pc, &funcptr->text);
231 __get_user(regs->p3, &funcptr->GOT);
232 } else
233 regs->pc = (unsigned long)ka->sa.sa_handler;
234 regs->rets = (unsigned long)(frame->retcode);
235
236 regs->r0 = frame->sig;
237 regs->r1 = (unsigned long)(&frame->info);
238 regs->r2 = (unsigned long)(&frame->uc);
239
240 return 0;
241
242 give_sigsegv:
243 if (sig == SIGSEGV)
244 ka->sa.sa_handler = SIG_DFL;
245 force_sig(SIGSEGV, current);
246 return -EFAULT;
247}
248
249static inline void
250handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler)
251{
252 switch (regs->r0) {
253 case -ERESTARTNOHAND:
254 if (!has_handler)
255 goto do_restart;
256 regs->r0 = -EINTR;
257 break;
258
259 case -ERESTARTSYS:
260 if (has_handler && !(ka->sa.sa_flags & SA_RESTART)) {
261 regs->r0 = -EINTR;
262 break;
263 }
264 /* fallthrough */
265 case -ERESTARTNOINTR:
266 do_restart:
267 regs->p0 = regs->orig_p0;
268 regs->r0 = regs->orig_r0;
269 regs->pc -= 2;
270 break;
271 }
272}
273
274/*
275 * OK, we're invoking a handler
276 */
277static int
278handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
279 sigset_t *oldset, struct pt_regs *regs)
280{
281 int ret;
282
283 /* are we from a system call? to see pt_regs->orig_p0 */
284 if (regs->orig_p0 >= 0)
285 /* If so, check system call restarting.. */
286 handle_restart(regs, ka, 1);
287
288 /* set up the stack frame */
289 ret = setup_rt_frame(sig, ka, info, oldset, regs);
290
291 if (ret == 0) {
292 spin_lock_irq(&current->sighand->siglock);
293 sigorsets(&current->blocked, &current->blocked,
294 &ka->sa.sa_mask);
295 if (!(ka->sa.sa_flags & SA_NODEFER))
296 sigaddset(&current->blocked, sig);
297 recalc_sigpending();
298 spin_unlock_irq(&current->sighand->siglock);
299 }
300 return ret;
301}
302
303/*
304 * Note that 'init' is a special process: it doesn't get signals it doesn't
305 * want to handle. Thus you cannot kill init even with a SIGKILL even by
306 * mistake.
307 *
308 * Note that we go through the signals twice: once to check the signals
309 * that the kernel can handle, and then we build all the user-level signal
310 * handling stack-frames in one go after that.
311 */
312asmlinkage void do_signal(struct pt_regs *regs)
313{
314 siginfo_t info;
315 int signr;
316 struct k_sigaction ka;
317 sigset_t *oldset;
318
319 current->thread.esp0 = (unsigned long)regs;
320
321 if (try_to_freeze())
322 goto no_signal;
323
324 if (test_thread_flag(TIF_RESTORE_SIGMASK))
325 oldset = &current->saved_sigmask;
326 else
327 oldset = &current->blocked;
328
329 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
330 if (signr > 0) {
331 /* Whee! Actually deliver the signal. */
332 if (handle_signal(signr, &info, &ka, oldset, regs) == 0) {
333 /* a signal was successfully delivered; the saved
334 * sigmask will have been stored in the signal frame,
335 * and will be restored by sigreturn, so we can simply
336 * clear the TIF_RESTORE_SIGMASK flag */
337 if (test_thread_flag(TIF_RESTORE_SIGMASK))
338 clear_thread_flag(TIF_RESTORE_SIGMASK);
339 }
340
341 return;
342 }
343
344no_signal:
345 /* Did we come from a system call? */
346 if (regs->orig_p0 >= 0)
347 /* Restart the system call - no handlers present */
348 handle_restart(regs, NULL, 0);
349
350 /* if there's no signal to deliver, we just put the saved sigmask
351 * back */
352 if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
353 clear_thread_flag(TIF_RESTORE_SIGMASK);
354 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
355 }
356}
diff --git a/arch/blackfin/kernel/sys_bfin.c b/arch/blackfin/kernel/sys_bfin.c
new file mode 100644
index 000000000000..f436e6743f5a
--- /dev/null
+++ b/arch/blackfin/kernel/sys_bfin.c
@@ -0,0 +1,115 @@
1/*
2 * File: arch/blackfin/kernel/sys_bfin.c
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description: This file contains various random system calls that
8 * have a non-standard calling sequence on the Linux/bfin
9 * platform.
10 *
11 * Modified:
12 * Copyright 2004-2006 Analog Devices Inc.
13 *
14 * Bugs: Enter bugs at http://blackfin.uclinux.org/
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, see the file COPYING, or write
28 * to the Free Software Foundation, Inc.,
29 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 */
31
32#include <linux/smp_lock.h>
33#include <linux/spinlock.h>
34#include <linux/sem.h>
35#include <linux/msg.h>
36#include <linux/shm.h>
37#include <linux/syscalls.h>
38#include <linux/mman.h>
39#include <linux/file.h>
40
41#include <asm/cacheflush.h>
42#include <asm/uaccess.h>
43#include <asm/ipc.h>
44#include <asm/dma.h>
45#include <asm/unistd.h>
46
47/*
48 * sys_pipe() is the normal C calling standard for creating
49 * a pipe. It's not the way unix traditionally does this, though.
50 */
51asmlinkage int sys_pipe(unsigned long *fildes)
52{
53 int fd[2];
54 int error;
55
56 error = do_pipe(fd);
57 if (!error) {
58 if (copy_to_user(fildes, fd, 2 * sizeof(int)))
59 error = -EFAULT;
60 }
61 return error;
62}
63
64/* common code for old and new mmaps */
65static inline long
66do_mmap2(unsigned long addr, unsigned long len,
67 unsigned long prot, unsigned long flags,
68 unsigned long fd, unsigned long pgoff)
69{
70 int error = -EBADF;
71 struct file *file = NULL;
72
73 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
74 if (!(flags & MAP_ANONYMOUS)) {
75 file = fget(fd);
76 if (!file)
77 goto out;
78 }
79
80 down_write(&current->mm->mmap_sem);
81 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
82 up_write(&current->mm->mmap_sem);
83
84 if (file)
85 fput(file);
86 out:
87 return error;
88}
89
90asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
91 unsigned long prot, unsigned long flags,
92 unsigned long fd, unsigned long pgoff)
93{
94 return do_mmap2(addr, len, prot, flags, fd, pgoff);
95}
96
97asmlinkage int sys_getpagesize(void)
98{
99 return PAGE_SIZE;
100}
101
102asmlinkage void *sys_sram_alloc(size_t size, unsigned long flags)
103{
104 return sram_alloc_with_lsl(size, flags);
105}
106
107asmlinkage int sys_sram_free(const void *addr)
108{
109 return sram_free_with_lsl(addr);
110}
111
112asmlinkage void *sys_dma_memcpy(void *dest, const void *src, size_t len)
113{
114 return safe_dma_memcpy(dest, src, len);
115}
diff --git a/arch/blackfin/kernel/time.c b/arch/blackfin/kernel/time.c
new file mode 100644
index 000000000000..f578176b6d92
--- /dev/null
+++ b/arch/blackfin/kernel/time.c
@@ -0,0 +1,326 @@
1/*
2 * File: arch/blackfin/kernel/time.c
3 * Based on: none - original work
4 * Author:
5 *
6 * Created:
7 * Description: This file contains the bfin-specific time handling details.
8 * Most of the stuff is located in the machine specific files.
9 *
10 * Modified:
11 * Copyright 2004-2006 Analog Devices Inc.
12 *
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, see the file COPYING, or write
27 * to the Free Software Foundation, Inc.,
28 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 */
30
31#include <linux/module.h>
32#include <linux/profile.h>
33#include <linux/interrupt.h>
34#include <linux/time.h>
35#include <linux/irq.h>
36
37#include <asm/blackfin.h>
38
39/* This is an NTP setting */
40#define TICK_SIZE (tick_nsec / 1000)
41
42static void time_sched_init(irqreturn_t(*timer_routine)
43 (int, void *));
44static unsigned long gettimeoffset(void);
45static inline void do_leds(void);
46
47#if (defined(CONFIG_BFIN_ALIVE_LED) || defined(CONFIG_BFIN_IDLE_LED))
48void __init init_leds(void)
49{
50 unsigned int tmp = 0;
51
52#if defined(CONFIG_BFIN_ALIVE_LED)
53 /* config pins as output. */
54 tmp = bfin_read_CONFIG_BFIN_ALIVE_LED_DPORT();
55 SSYNC();
56 bfin_write_CONFIG_BFIN_ALIVE_LED_DPORT(tmp | CONFIG_BFIN_ALIVE_LED_PIN);
57 SSYNC();
58
59 /* First set led be off */
60 tmp = bfin_read_CONFIG_BFIN_ALIVE_LED_PORT();
61 SSYNC();
62 bfin_write_CONFIG_BFIN_ALIVE_LED_PORT(tmp | CONFIG_BFIN_ALIVE_LED_PIN); /* light off */
63 SSYNC();
64#endif
65
66#if defined(CONFIG_BFIN_IDLE_LED)
67 /* config pins as output. */
68 tmp = bfin_read_CONFIG_BFIN_IDLE_LED_DPORT();
69 SSYNC();
70 bfin_write_CONFIG_BFIN_IDLE_LED_DPORT(tmp | CONFIG_BFIN_IDLE_LED_PIN);
71 SSYNC();
72
73 /* First set led be off */
74 tmp = bfin_read_CONFIG_BFIN_IDLE_LED_PORT();
75 SSYNC();
76 bfin_write_CONFIG_BFIN_IDLE_LED_PORT(tmp | CONFIG_BFIN_IDLE_LED_PIN); /* light off */
77 SSYNC();
78#endif
79}
80#else
81void __init init_leds(void)
82{
83}
84#endif
85
86#if defined(CONFIG_BFIN_ALIVE_LED)
87static inline void do_leds(void)
88{
89 static unsigned int count = 50;
90 static int flag = 0;
91 unsigned short tmp = 0;
92
93 if (--count == 0) {
94 count = 50;
95 flag = ~flag;
96 }
97 tmp = bfin_read_CONFIG_BFIN_ALIVE_LED_PORT();
98 SSYNC();
99
100 if (flag)
101 tmp &= ~CONFIG_BFIN_ALIVE_LED_PIN; /* light on */
102 else
103 tmp |= CONFIG_BFIN_ALIVE_LED_PIN; /* light off */
104
105 bfin_write_CONFIG_BFIN_ALIVE_LED_PORT(tmp);
106 SSYNC();
107
108}
109#else
110static inline void do_leds(void)
111{
112}
113#endif
114
115static struct irqaction bfin_timer_irq = {
116 .name = "BFIN Timer Tick",
117 .flags = IRQF_DISABLED
118};
119
120/*
121 * The way that the Blackfin core timer works is:
122 * - CCLK is divided by a programmable 8-bit pre-scaler (TSCALE)
123 * - Every time TSCALE ticks, a 32bit is counted down (TCOUNT)
124 *
125 * If you take the fastest clock (1ns, or 1GHz to make the math work easier)
126 * 10ms is 10,000,000 clock ticks, which fits easy into a 32-bit counter
127 * (32 bit counter is 4,294,967,296ns or 4.2 seconds) so, we don't need
128 * to use TSCALE, and program it to zero (which is pass CCLK through).
129 * If you feel like using it, try to keep HZ * TIMESCALE to some
130 * value that divides easy (like power of 2).
131 */
132
133#define TIME_SCALE 1
134
135static void
136time_sched_init(irqreturn_t(*timer_routine) (int, void *))
137{
138 u32 tcount;
139
140 /* power up the timer, but don't enable it just yet */
141 bfin_write_TCNTL(1);
142 CSYNC();
143
144 /*
145 * the TSCALE prescaler counter.
146 */
147 bfin_write_TSCALE((TIME_SCALE - 1));
148
149 tcount = ((get_cclk() / (HZ * TIME_SCALE)) - 1);
150 bfin_write_TPERIOD(tcount);
151 bfin_write_TCOUNT(tcount);
152
153 /* now enable the timer */
154 CSYNC();
155
156 bfin_write_TCNTL(7);
157
158 bfin_timer_irq.handler = (irq_handler_t)timer_routine;
159 /* call setup_irq instead of request_irq because request_irq calls
160 * kmalloc which has not been initialized yet
161 */
162 setup_irq(IRQ_CORETMR, &bfin_timer_irq);
163}
164
165/*
166 * Should return useconds since last timer tick
167 */
168static unsigned long gettimeoffset(void)
169{
170 unsigned long offset;
171 unsigned long clocks_per_jiffy;
172
173 clocks_per_jiffy = bfin_read_TPERIOD();
174 offset =
175 (clocks_per_jiffy -
176 bfin_read_TCOUNT()) / (((clocks_per_jiffy + 1) * HZ) /
177 USEC_PER_SEC);
178
179 /* Check if we just wrapped the counters and maybe missed a tick */
180 if ((bfin_read_ILAT() & (1 << IRQ_CORETMR))
181 && (offset < (100000 / HZ / 2)))
182 offset += (USEC_PER_SEC / HZ);
183
184 return offset;
185}
186
187static inline int set_rtc_mmss(unsigned long nowtime)
188{
189 return 0;
190}
191
192/*
193 * timer_interrupt() needs to keep up the real-time clock,
194 * as well as call the "do_timer()" routine every clocktick
195 */
196#ifdef CONFIG_CORE_TIMER_IRQ_L1
197irqreturn_t timer_interrupt(int irq, void *dummy)__attribute__((l1_text));
198#endif
199
200irqreturn_t timer_interrupt(int irq, void *dummy)
201{
202 /* last time the cmos clock got updated */
203 static long last_rtc_update = 0;
204
205 write_seqlock(&xtime_lock);
206
207 do_timer(1);
208 do_leds();
209
210#ifndef CONFIG_SMP
211 update_process_times(user_mode(get_irq_regs()));
212#endif
213 profile_tick(CPU_PROFILING);
214
215 /*
216 * If we have an externally synchronized Linux clock, then update
217 * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
218 * called as close as possible to 500 ms before the new second starts.
219 */
220
221 if (ntp_synced() &&
222 xtime.tv_sec > last_rtc_update + 660 &&
223 (xtime.tv_nsec / NSEC_PER_USEC) >=
224 500000 - ((unsigned)TICK_SIZE) / 2
225 && (xtime.tv_nsec / NSEC_PER_USEC) <=
226 500000 + ((unsigned)TICK_SIZE) / 2) {
227 if (set_rtc_mmss(xtime.tv_sec) == 0)
228 last_rtc_update = xtime.tv_sec;
229 else
230 /* Do it again in 60s. */
231 last_rtc_update = xtime.tv_sec - 600;
232 }
233 write_sequnlock(&xtime_lock);
234 return IRQ_HANDLED;
235}
236
237void __init time_init(void)
238{
239 time_t secs_since_1970 = (365 * 37 + 9) * 24 * 60 * 60; /* 1 Jan 2007 */
240
241#ifdef CONFIG_RTC_DRV_BFIN
242 /* [#2663] hack to filter junk RTC values that would cause
243 * userspace to have to deal with time values greater than
244 * 2^31 seconds (which uClibc cannot cope with yet)
245 */
246 if ((bfin_read_RTC_STAT() & 0xC0000000) == 0xC0000000) {
247 printk(KERN_NOTICE "bfin-rtc: invalid date; resetting\n");
248 bfin_write_RTC_STAT(0);
249 }
250#endif
251
252 /* Initialize xtime. From now on, xtime is updated with timer interrupts */
253 xtime.tv_sec = secs_since_1970;
254 xtime.tv_nsec = 0;
255
256 wall_to_monotonic.tv_sec = -xtime.tv_sec;
257
258 time_sched_init(timer_interrupt);
259}
260
261#ifndef CONFIG_GENERIC_TIME
262void do_gettimeofday(struct timeval *tv)
263{
264 unsigned long flags;
265 unsigned long seq;
266 unsigned long usec, sec;
267
268 do {
269 seq = read_seqbegin_irqsave(&xtime_lock, flags);
270 usec = gettimeoffset();
271 sec = xtime.tv_sec;
272 usec += (xtime.tv_nsec / NSEC_PER_USEC);
273 }
274 while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
275
276 while (usec >= USEC_PER_SEC) {
277 usec -= USEC_PER_SEC;
278 sec++;
279 }
280
281 tv->tv_sec = sec;
282 tv->tv_usec = usec;
283}
284EXPORT_SYMBOL(do_gettimeofday);
285
286int do_settimeofday(struct timespec *tv)
287{
288 time_t wtm_sec, sec = tv->tv_sec;
289 long wtm_nsec, nsec = tv->tv_nsec;
290
291 if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
292 return -EINVAL;
293
294 write_seqlock_irq(&xtime_lock);
295 /*
296 * This is revolting. We need to set the xtime.tv_usec
297 * correctly. However, the value in this location is
298 * is value at the last tick.
299 * Discover what correction gettimeofday
300 * would have done, and then undo it!
301 */
302 nsec -= (gettimeoffset() * NSEC_PER_USEC);
303
304 wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
305 wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);
306
307 set_normalized_timespec(&xtime, sec, nsec);
308 set_normalized_timespec(&wall_to_monotonic, wtm_sec, wtm_nsec);
309
310 ntp_clear();
311
312 write_sequnlock_irq(&xtime_lock);
313 clock_was_set();
314
315 return 0;
316}
317EXPORT_SYMBOL(do_settimeofday);
318#endif /* !CONFIG_GENERIC_TIME */
319
320/*
321 * Scheduler clock - returns current time in nanosec units.
322 */
323unsigned long long sched_clock(void)
324{
325 return (unsigned long long)jiffies *(NSEC_PER_SEC / HZ);
326}
diff --git a/arch/blackfin/kernel/traps.c b/arch/blackfin/kernel/traps.c
new file mode 100644
index 000000000000..9556b73de808
--- /dev/null
+++ b/arch/blackfin/kernel/traps.c
@@ -0,0 +1,649 @@
1/*
2 * File: arch/blackfin/kernel/traps.c
3 * Based on:
4 * Author: Hamish Macdonald
5 *
6 * Created:
7 * Description: uses S/W interrupt 15 for the system calls
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <asm/uaccess.h>
31#include <asm/traps.h>
32#include <asm/cacheflush.h>
33#include <asm/blackfin.h>
34#include <asm/uaccess.h>
35#include <asm/irq_handler.h>
36#include <linux/interrupt.h>
37#include <linux/module.h>
38#include <linux/kallsyms.h>
39
40#ifdef CONFIG_KGDB
41# include <linux/debugger.h>
42# include <linux/kgdb.h>
43#endif
44
45/* Initiate the event table handler */
46void __init trap_init(void)
47{
48 CSYNC();
49 bfin_write_EVT3(trap);
50 CSYNC();
51}
52
53asmlinkage void trap_c(struct pt_regs *fp);
54
55int kstack_depth_to_print = 48;
56
57static int printk_address(unsigned long address)
58{
59 struct vm_list_struct *vml;
60 struct task_struct *p;
61 struct mm_struct *mm;
62
63#ifdef CONFIG_KALLSYMS
64 unsigned long offset = 0, symsize;
65 const char *symname;
66 char *modname;
67 char *delim = ":";
68 char namebuf[128];
69
70 /* look up the address and see if we are in kernel space */
71 symname = kallsyms_lookup(address, &symsize, &offset, &modname, namebuf);
72
73 if (symname) {
74 /* yeah! kernel space! */
75 if (!modname)
76 modname = delim = "";
77 return printk("<0x%p> { %s%s%s%s + 0x%lx }",
78 (void*)address, delim, modname, delim, symname,
79 (unsigned long)offset);
80
81 }
82#endif
83
84 /* looks like we're off in user-land, so let's walk all the
85 * mappings of all our processes and see if we can't be a whee
86 * bit more specific
87 */
88 write_lock_irq(&tasklist_lock);
89 for_each_process(p) {
90 mm = get_task_mm(p);
91 if (!mm)
92 continue;
93
94 vml = mm->context.vmlist;
95 while (vml) {
96 struct vm_area_struct *vma = vml->vma;
97
98 if (address >= vma->vm_start && address < vma->vm_end) {
99 char *name = p->comm;
100 struct file *file = vma->vm_file;
101 if (file) {
102 char _tmpbuf[256];
103 name = d_path(file->f_dentry,
104 file->f_vfsmnt,
105 _tmpbuf,
106 sizeof(_tmpbuf));
107 }
108
109 write_unlock_irq(&tasklist_lock);
110 return printk("<0x%p> [ %s + 0x%lx ]",
111 (void*)address, name,
112 (unsigned long)
113 ((address - vma->vm_start) +
114 (vma->vm_pgoff << PAGE_SHIFT)));
115 }
116
117 vml = vml->next;
118 }
119 }
120 write_unlock_irq(&tasklist_lock);
121
122 /* we were unable to find this address anywhere */
123 return printk("[<0x%p>]", (void*)address);
124}
125
126#define trace_buffer_save(x) \
127 do { \
128 (x) = bfin_read_TBUFCTL(); \
129 bfin_write_TBUFCTL((x) & ~TBUFEN); \
130 } while (0)
131#define trace_buffer_restore(x) \
132 do { \
133 bfin_write_TBUFCTL((x)); \
134 } while (0)
135
136asmlinkage void trap_c(struct pt_regs *fp)
137{
138 int j, sig = 0;
139 siginfo_t info;
140 unsigned long trapnr = fp->seqstat & SEQSTAT_EXCAUSE;
141
142#ifdef CONFIG_KGDB
143# define CHK_DEBUGGER_TRAP() do { CHK_DEBUGGER(trapnr, sig, info.si_code, fp,); } while (0)
144# define CHK_DEBUGGER_TRAP_MAYBE() do { if (kgdb_connected) CHK_DEBUGGER_TRAP(); } while (0)
145#else
146# define CHK_DEBUGGER_TRAP() do { } while (0)
147# define CHK_DEBUGGER_TRAP_MAYBE() do { } while (0)
148#endif
149
150 trace_buffer_save(j);
151
152 /* trap_c() will be called for exceptions. During exceptions
153 * processing, the pc value should be set with retx value.
154 * With this change we can cleanup some code in signal.c- TODO
155 */
156 fp->orig_pc = fp->retx;
157 /* printk("exception: 0x%x, ipend=%x, reti=%x, retx=%x\n",
158 trapnr, fp->ipend, fp->pc, fp->retx); */
159
160 /* send the appropriate signal to the user program */
161 switch (trapnr) {
162
163 /* This table works in conjuction with the one in ./mach-common/entry.S
164 * Some exceptions are handled there (in assembly, in exception space)
165 * Some are handled here, (in C, in interrupt space)
166 * Some, like CPLB, are handled in both, where the normal path is
167 * handled in assembly/exception space, and the error path is handled
168 * here
169 */
170
171 /* 0x00 - Linux Syscall, getting here is an error */
172 /* 0x01 - userspace gdb breakpoint, handled here */
173 case VEC_EXCPT01:
174 info.si_code = TRAP_ILLTRAP;
175 sig = SIGTRAP;
176 CHK_DEBUGGER_TRAP_MAYBE();
177 /* Check if this is a breakpoint in kernel space */
178 if (fp->ipend & 0xffc0)
179 return;
180 else
181 break;
182#ifdef CONFIG_KGDB
183 case VEC_EXCPT02 : /* gdb connection */
184 info.si_code = TRAP_ILLTRAP;
185 sig = SIGTRAP;
186 CHK_DEBUGGER_TRAP();
187 return;
188#else
189 /* 0x02 - User Defined, Caught by default */
190#endif
191 /* 0x03 - Atomic test and set */
192 case VEC_EXCPT03:
193 info.si_code = SEGV_STACKFLOW;
194 sig = SIGSEGV;
195 printk(KERN_EMERG EXC_0x03);
196 CHK_DEBUGGER_TRAP();
197 break;
198 /* 0x04 - spinlock - handled by _ex_spinlock,
199 getting here is an error */
200 /* 0x05 - User Defined, Caught by default */
201 /* 0x06 - User Defined, Caught by default */
202 /* 0x07 - User Defined, Caught by default */
203 /* 0x08 - User Defined, Caught by default */
204 /* 0x09 - User Defined, Caught by default */
205 /* 0x0A - User Defined, Caught by default */
206 /* 0x0B - User Defined, Caught by default */
207 /* 0x0C - User Defined, Caught by default */
208 /* 0x0D - User Defined, Caught by default */
209 /* 0x0E - User Defined, Caught by default */
210 /* 0x0F - User Defined, Caught by default */
211 /* 0x10 HW Single step, handled here */
212 case VEC_STEP:
213 info.si_code = TRAP_STEP;
214 sig = SIGTRAP;
215 CHK_DEBUGGER_TRAP_MAYBE();
216 /* Check if this is a single step in kernel space */
217 if (fp->ipend & 0xffc0)
218 return;
219 else
220 break;
221 /* 0x11 - Trace Buffer Full, handled here */
222 case VEC_OVFLOW:
223 info.si_code = TRAP_TRACEFLOW;
224 sig = SIGTRAP;
225 printk(KERN_EMERG EXC_0x11);
226 CHK_DEBUGGER_TRAP();
227 break;
228 /* 0x12 - Reserved, Caught by default */
229 /* 0x13 - Reserved, Caught by default */
230 /* 0x14 - Reserved, Caught by default */
231 /* 0x15 - Reserved, Caught by default */
232 /* 0x16 - Reserved, Caught by default */
233 /* 0x17 - Reserved, Caught by default */
234 /* 0x18 - Reserved, Caught by default */
235 /* 0x19 - Reserved, Caught by default */
236 /* 0x1A - Reserved, Caught by default */
237 /* 0x1B - Reserved, Caught by default */
238 /* 0x1C - Reserved, Caught by default */
239 /* 0x1D - Reserved, Caught by default */
240 /* 0x1E - Reserved, Caught by default */
241 /* 0x1F - Reserved, Caught by default */
242 /* 0x20 - Reserved, Caught by default */
243 /* 0x21 - Undefined Instruction, handled here */
244 case VEC_UNDEF_I:
245 info.si_code = ILL_ILLOPC;
246 sig = SIGILL;
247 printk(KERN_EMERG EXC_0x21);
248 CHK_DEBUGGER_TRAP();
249 break;
250 /* 0x22 - Illegal Instruction Combination, handled here */
251 case VEC_ILGAL_I:
252 info.si_code = ILL_ILLPARAOP;
253 sig = SIGILL;
254 printk(KERN_EMERG EXC_0x22);
255 CHK_DEBUGGER_TRAP();
256 break;
257 /* 0x23 - Data CPLB Protection Violation,
258 normal case is handled in _cplb_hdr */
259 case VEC_CPLB_VL:
260 info.si_code = ILL_CPLB_VI;
261 sig = SIGILL;
262 printk(KERN_EMERG EXC_0x23);
263 CHK_DEBUGGER_TRAP();
264 break;
265 /* 0x24 - Data access misaligned, handled here */
266 case VEC_MISALI_D:
267 info.si_code = BUS_ADRALN;
268 sig = SIGBUS;
269 printk(KERN_EMERG EXC_0x24);
270 CHK_DEBUGGER_TRAP();
271 break;
272 /* 0x25 - Unrecoverable Event, handled here */
273 case VEC_UNCOV:
274 info.si_code = ILL_ILLEXCPT;
275 sig = SIGILL;
276 printk(KERN_EMERG EXC_0x25);
277 CHK_DEBUGGER_TRAP();
278 break;
279 /* 0x26 - Data CPLB Miss, normal case is handled in _cplb_hdr,
280 error case is handled here */
281 case VEC_CPLB_M:
282 info.si_code = BUS_ADRALN;
283 sig = SIGBUS;
284 printk(KERN_EMERG EXC_0x26);
285 CHK_DEBUGGER_TRAP();
286 break;
287 /* 0x27 - Data CPLB Multiple Hits - Linux Trap Zero, handled here */
288 case VEC_CPLB_MHIT:
289 info.si_code = ILL_CPLB_MULHIT;
290#ifdef CONFIG_DEBUG_HUNT_FOR_ZERO
291 sig = SIGSEGV;
292 printk(KERN_EMERG "\n\nNULL pointer access (probably)\n");
293#else
294 sig = SIGILL;
295 printk(KERN_EMERG EXC_0x27);
296#endif
297 CHK_DEBUGGER_TRAP();
298 break;
299 /* 0x28 - Emulation Watchpoint, handled here */
300 case VEC_WATCH:
301 info.si_code = TRAP_WATCHPT;
302 sig = SIGTRAP;
303 pr_debug(EXC_0x28);
304 CHK_DEBUGGER_TRAP_MAYBE();
305 /* Check if this is a watchpoint in kernel space */
306 if (fp->ipend & 0xffc0)
307 return;
308 else
309 break;
310#ifdef CONFIG_BF535
311 /* 0x29 - Instruction fetch access error (535 only) */
312 case VEC_ISTRU_VL: /* ADSP-BF535 only (MH) */
313 info.si_code = BUS_OPFETCH;
314 sig = SIGBUS;
315 printk(KERN_EMERG "BF535: VEC_ISTRU_VL\n");
316 CHK_DEBUGGER_TRAP();
317 break;
318#else
319 /* 0x29 - Reserved, Caught by default */
320#endif
321 /* 0x2A - Instruction fetch misaligned, handled here */
322 case VEC_MISALI_I:
323 info.si_code = BUS_ADRALN;
324 sig = SIGBUS;
325 printk(KERN_EMERG EXC_0x2A);
326 CHK_DEBUGGER_TRAP();
327 break;
328 /* 0x2B - Instruction CPLB protection Violation,
329 handled in _cplb_hdr */
330 case VEC_CPLB_I_VL:
331 info.si_code = ILL_CPLB_VI;
332 sig = SIGILL;
333 printk(KERN_EMERG EXC_0x2B);
334 CHK_DEBUGGER_TRAP();
335 break;
336 /* 0x2C - Instruction CPLB miss, handled in _cplb_hdr */
337 case VEC_CPLB_I_M:
338 info.si_code = ILL_CPLB_MISS;
339 sig = SIGBUS;
340 printk(KERN_EMERG EXC_0x2C);
341 CHK_DEBUGGER_TRAP();
342 break;
343 /* 0x2D - Instruction CPLB Multiple Hits, handled here */
344 case VEC_CPLB_I_MHIT:
345 info.si_code = ILL_CPLB_MULHIT;
346#ifdef CONFIG_DEBUG_HUNT_FOR_ZERO
347 sig = SIGSEGV;
348 printk(KERN_EMERG "\n\nJump to address 0 - 0x0fff\n");
349#else
350 sig = SIGILL;
351 printk(KERN_EMERG EXC_0x2D);
352#endif
353 CHK_DEBUGGER_TRAP();
354 break;
355 /* 0x2E - Illegal use of Supervisor Resource, handled here */
356 case VEC_ILL_RES:
357 info.si_code = ILL_PRVOPC;
358 sig = SIGILL;
359 printk(KERN_EMERG EXC_0x2E);
360 CHK_DEBUGGER_TRAP();
361 break;
362 /* 0x2F - Reserved, Caught by default */
363 /* 0x30 - Reserved, Caught by default */
364 /* 0x31 - Reserved, Caught by default */
365 /* 0x32 - Reserved, Caught by default */
366 /* 0x33 - Reserved, Caught by default */
367 /* 0x34 - Reserved, Caught by default */
368 /* 0x35 - Reserved, Caught by default */
369 /* 0x36 - Reserved, Caught by default */
370 /* 0x37 - Reserved, Caught by default */
371 /* 0x38 - Reserved, Caught by default */
372 /* 0x39 - Reserved, Caught by default */
373 /* 0x3A - Reserved, Caught by default */
374 /* 0x3B - Reserved, Caught by default */
375 /* 0x3C - Reserved, Caught by default */
376 /* 0x3D - Reserved, Caught by default */
377 /* 0x3E - Reserved, Caught by default */
378 /* 0x3F - Reserved, Caught by default */
379 default:
380 info.si_code = TRAP_ILLTRAP;
381 sig = SIGTRAP;
382 printk(KERN_EMERG "Caught Unhandled Exception, code = %08lx\n",
383 (fp->seqstat & SEQSTAT_EXCAUSE));
384 CHK_DEBUGGER_TRAP();
385 break;
386 }
387
388 info.si_signo = sig;
389 info.si_errno = 0;
390 info.si_addr = (void *)fp->pc;
391 force_sig_info(sig, &info, current);
392 if (sig != 0 && sig != SIGTRAP) {
393 unsigned long stack;
394 dump_bfin_regs(fp, (void *)fp->retx);
395 dump_bfin_trace_buffer();
396 show_stack(current, &stack);
397 if (current->mm == NULL)
398 panic("Kernel exception");
399 }
400
401 /* if the address that we are about to return to is not valid, set it
402 * to a valid address, if we have a current application or panic
403 */
404 if (!(fp->pc <= physical_mem_end
405#if L1_CODE_LENGTH != 0
406 || (fp->pc >= L1_CODE_START &&
407 fp->pc <= (L1_CODE_START + L1_CODE_LENGTH))
408#endif
409 )) {
410 if (current->mm) {
411 fp->pc = current->mm->start_code;
412 } else {
413 printk(KERN_EMERG "I can't return to memory that doesn't exist - bad things happen\n");
414 panic("Help - I've fallen and can't get up\n");
415 }
416 }
417
418 trace_buffer_restore(j);
419 return;
420}
421
422/* Typical exception handling routines */
423
424void dump_bfin_trace_buffer(void)
425{
426 int tflags;
427 trace_buffer_save(tflags);
428
429 if (likely(bfin_read_TBUFSTAT() & TBUFCNT)) {
430 int i;
431 printk(KERN_EMERG "Hardware Trace:\n");
432 for (i = 0; bfin_read_TBUFSTAT() & TBUFCNT; i++) {
433 printk(KERN_EMERG "%2i Target : ", i);
434 printk_address((unsigned long)bfin_read_TBUF());
435 printk("\n" KERN_EMERG " Source : ");
436 printk_address((unsigned long)bfin_read_TBUF());
437 printk("\n");
438 }
439 }
440
441 trace_buffer_restore(tflags);
442}
443EXPORT_SYMBOL(dump_bfin_trace_buffer);
444
445static void show_trace(struct task_struct *tsk, unsigned long *sp)
446{
447 unsigned long addr;
448
449 printk("\nCall Trace:");
450#ifdef CONFIG_KALLSYMS
451 printk("\n");
452#endif
453
454 while (!kstack_end(sp)) {
455 addr = *sp++;
456 /*
457 * If the address is either in the text segment of the
458 * kernel, or in the region which contains vmalloc'ed
459 * memory, it *may* be the address of a calling
460 * routine; if so, print it so that someone tracing
461 * down the cause of the crash will be able to figure
462 * out the call path that was taken.
463 */
464 if (kernel_text_address(addr))
465 print_ip_sym(addr);
466 }
467
468 printk("\n");
469}
470
471void show_stack(struct task_struct *task, unsigned long *stack)
472{
473 unsigned long *endstack, addr;
474 int i;
475
476 /* Cannot call dump_bfin_trace_buffer() here as show_stack() is
477 * called externally in some places in the kernel.
478 */
479
480 if (!stack) {
481 if (task)
482 stack = (unsigned long *)task->thread.ksp;
483 else
484 stack = (unsigned long *)&stack;
485 }
486
487 addr = (unsigned long)stack;
488 endstack = (unsigned long *)PAGE_ALIGN(addr);
489
490 printk(KERN_EMERG "Stack from %08lx:", (unsigned long)stack);
491 for (i = 0; i < kstack_depth_to_print; i++) {
492 if (stack + 1 > endstack)
493 break;
494 if (i % 8 == 0)
495 printk("\n" KERN_EMERG " ");
496 printk(" %08lx", *stack++);
497 }
498
499 show_trace(task, stack);
500}
501
502void dump_stack(void)
503{
504 unsigned long stack;
505 int tflags;
506 trace_buffer_save(tflags);
507 dump_bfin_trace_buffer();
508 show_stack(current, &stack);
509 trace_buffer_restore(tflags);
510}
511
512EXPORT_SYMBOL(dump_stack);
513
514void dump_bfin_regs(struct pt_regs *fp, void *retaddr)
515{
516 if (current->pid) {
517 printk("\nCURRENT PROCESS:\n\n");
518 printk("COMM=%s PID=%d\n", current->comm, current->pid);
519 } else {
520 printk
521 ("\nNo Valid pid - Either things are really messed up, or you are in the kernel\n");
522 }
523
524 if (current->mm) {
525 printk("TEXT = 0x%p-0x%p DATA = 0x%p-0x%p\n"
526 "BSS = 0x%p-0x%p USER-STACK = 0x%p\n\n",
527 (void*)current->mm->start_code,
528 (void*)current->mm->end_code,
529 (void*)current->mm->start_data,
530 (void*)current->mm->end_data,
531 (void*)current->mm->end_data,
532 (void*)current->mm->brk,
533 (void*)current->mm->start_stack);
534 }
535
536 printk("return address: 0x%p; contents of [PC-16...PC+8]:\n", retaddr);
537 if (retaddr != 0 && retaddr <= (void*)physical_mem_end
538#if L1_CODE_LENGTH != 0
539 /* FIXME: Copy the code out of L1 Instruction SRAM through dma
540 memcpy. */
541 && !(retaddr >= (void*)L1_CODE_START
542 && retaddr < (void*)(L1_CODE_START + L1_CODE_LENGTH))
543#endif
544 ) {
545 int i = 0;
546 unsigned short x = 0;
547 for (i = -16; i < 8; i++) {
548 if (get_user(x, (unsigned short *)retaddr + i))
549 break;
550#ifndef CONFIG_DEBUG_HWERR
551 /* If one of the last few instructions was a STI
552 * it is likily that the error occured awhile ago
553 * and we just noticed
554 */
555 if (x >= 0x0040 && x <= 0x0047 && i <= 0)
556 panic("\n\nWARNING : You should reconfigure the kernel to turn on\n"
557 " 'Hardware error interrupt debugging'\n"
558 " The rest of this error is meanless\n");
559#endif
560
561 if (i == -8)
562 printk("\n");
563 if (i == 0)
564 printk("X\n");
565 printk("%04x ", x);
566 }
567 } else
568 printk("Cannot look at the [PC] for it is in unreadable L1 SRAM - sorry\n");
569
570 printk("\n\n");
571
572 printk("RETE: %08lx RETN: %08lx RETX: %08lx RETS: %08lx\n",
573 fp->rete, fp->retn, fp->retx, fp->rets);
574 printk("IPEND: %04lx SYSCFG: %04lx\n", fp->ipend, fp->syscfg);
575 printk("SEQSTAT: %08lx SP: %08lx\n", (long)fp->seqstat, (long)fp);
576 printk("R0: %08lx R1: %08lx R2: %08lx R3: %08lx\n",
577 fp->r0, fp->r1, fp->r2, fp->r3);
578 printk("R4: %08lx R5: %08lx R6: %08lx R7: %08lx\n",
579 fp->r4, fp->r5, fp->r6, fp->r7);
580 printk("P0: %08lx P1: %08lx P2: %08lx P3: %08lx\n",
581 fp->p0, fp->p1, fp->p2, fp->p3);
582 printk("P4: %08lx P5: %08lx FP: %08lx\n", fp->p4, fp->p5, fp->fp);
583 printk("A0.w: %08lx A0.x: %08lx A1.w: %08lx A1.x: %08lx\n",
584 fp->a0w, fp->a0x, fp->a1w, fp->a1x);
585
586 printk("LB0: %08lx LT0: %08lx LC0: %08lx\n", fp->lb0, fp->lt0,
587 fp->lc0);
588 printk("LB1: %08lx LT1: %08lx LC1: %08lx\n", fp->lb1, fp->lt1,
589 fp->lc1);
590 printk("B0: %08lx L0: %08lx M0: %08lx I0: %08lx\n", fp->b0, fp->l0,
591 fp->m0, fp->i0);
592 printk("B1: %08lx L1: %08lx M1: %08lx I1: %08lx\n", fp->b1, fp->l1,
593 fp->m1, fp->i1);
594 printk("B2: %08lx L2: %08lx M2: %08lx I2: %08lx\n", fp->b2, fp->l2,
595 fp->m2, fp->i2);
596 printk("B3: %08lx L3: %08lx M3: %08lx I3: %08lx\n", fp->b3, fp->l3,
597 fp->m3, fp->i3);
598
599 printk("\nUSP: %08lx ASTAT: %08lx\n", rdusp(), fp->astat);
600 if ((long)fp->seqstat & SEQSTAT_EXCAUSE) {
601 printk(KERN_EMERG "DCPLB_FAULT_ADDR=%p\n", (void*)bfin_read_DCPLB_FAULT_ADDR());
602 printk(KERN_EMERG "ICPLB_FAULT_ADDR=%p\n", (void*)bfin_read_ICPLB_FAULT_ADDR());
603 }
604
605 printk("\n\n");
606}
607
608#ifdef CONFIG_SYS_BFIN_SPINLOCK_L1
609asmlinkage int sys_bfin_spinlock(int *spinlock)__attribute__((l1_text));
610#endif
611
612asmlinkage int sys_bfin_spinlock(int *spinlock)
613{
614 int ret = 0;
615 int tmp = 0;
616
617 local_irq_disable();
618 ret = get_user(tmp, spinlock);
619 if (ret == 0) {
620 if (tmp)
621 ret = 1;
622 tmp = 1;
623 put_user(tmp, spinlock);
624 }
625 local_irq_enable();
626 return ret;
627}
628
629void panic_cplb_error(int cplb_panic, struct pt_regs *fp)
630{
631 switch (cplb_panic) {
632 case CPLB_NO_UNLOCKED:
633 printk(KERN_EMERG "All CPLBs are locked\n");
634 break;
635 case CPLB_PROT_VIOL:
636 return;
637 case CPLB_NO_ADDR_MATCH:
638 return;
639 case CPLB_UNKNOWN_ERR:
640 printk(KERN_EMERG "Unknown CPLB Exception\n");
641 break;
642 }
643
644 printk(KERN_EMERG "DCPLB_FAULT_ADDR=%p\n", (void*)bfin_read_DCPLB_FAULT_ADDR());
645 printk(KERN_EMERG "ICPLB_FAULT_ADDR=%p\n", (void*)bfin_read_ICPLB_FAULT_ADDR());
646 dump_bfin_regs(fp, (void *)fp->retx);
647 dump_stack();
648 panic("Unrecoverable event\n");
649}
diff --git a/arch/blackfin/kernel/vmlinux.lds.S b/arch/blackfin/kernel/vmlinux.lds.S
new file mode 100644
index 000000000000..6ae9ebbd8e58
--- /dev/null
+++ b/arch/blackfin/kernel/vmlinux.lds.S
@@ -0,0 +1,228 @@
1/*
2 * File: arch/blackfin/kernel/vmlinux.lds.S
3 * Based on: none - original work
4 * Author:
5 *
6 * Created: Tue Sep 21 2004
7 * Description: Master linker script for blackfin architecture
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#define VMLINUX_SYMBOL(_sym_) _##_sym_
31
32#include <asm-generic/vmlinux.lds.h>
33#include <asm/mem_map.h>
34
35
36OUTPUT_FORMAT("elf32-bfin")
37ENTRY(__start)
38_jiffies = _jiffies_64;
39
40MEMORY
41{
42 ram : ORIGIN = CONFIG_BOOT_LOAD, LENGTH = (CONFIG_MEM_SIZE * 1024 * 1024) - (CONFIG_BOOT_LOAD)
43 l1_data_a : ORIGIN = L1_DATA_A_START, LENGTH = L1_DATA_A_LENGTH
44 l1_data_b : ORIGIN = L1_DATA_B_START, LENGTH = L1_DATA_B_LENGTH
45 l1_code : ORIGIN = L1_CODE_START, LENGTH = L1_CODE_LENGTH
46 l1_scratch : ORIGIN = L1_SCRATCH_START, LENGTH = L1_SCRATCH_LENGTH
47}
48
49SECTIONS
50{
51 . = CONFIG_BOOT_LOAD;
52
53 .text :
54 {
55 _text = .;
56 __stext = .;
57 *(.text)
58 SCHED_TEXT
59 *(.text.lock)
60 . = ALIGN(16);
61 ___start___ex_table = .;
62 *(__ex_table)
63 ___stop___ex_table = .;
64
65 *($code)
66 *(.rodata)
67 *(.rodata.*)
68 *(__vermagic) /* Kernel version magic */
69 *(.rodata1)
70 *(.fixup)
71 *(.spinlock.text)
72
73 /* Kernel symbol table: Normal symbols */
74 . = ALIGN(4);
75 ___start___ksymtab = .;
76 *(__ksymtab)
77 ___stop___ksymtab = .;
78
79 /* Kernel symbol table: GPL-only symbols */
80 ___start___ksymtab_gpl = .;
81 *(__ksymtab_gpl)
82 ___stop___ksymtab_gpl = .;
83
84 /* Kernel symbol table: Normal unused symbols */ \
85 ___start___ksymtab_unused = .;
86 *(__ksymtab_unused)
87 ___stop___ksymtab_unused = .;
88
89 /* Kernel symbol table: GPL-only unused symbols */
90 ___start___ksymtab_unused_gpl = .;
91 *(__ksymtab_unused_gpl)
92 ___stop___ksymtab_unused_gpl = .;
93
94
95 /* Kernel symbol table: GPL-future symbols */
96 ___start___ksymtab_gpl_future = .;
97 *(__ksymtab_gpl_future)
98 ___stop___ksymtab_gpl_future = .;
99
100 /* Kernel symbol table: Normal symbols */
101 ___start___kcrctab = .;
102 *(__kcrctab)
103 ___stop___kcrctab = .;
104
105 /* Kernel symbol table: GPL-only symbols */
106 ___start___kcrctab_gpl = .;
107 *(__kcrctab_gpl)
108 ___stop___kcrctab_gpl = .;
109
110 /* Kernel symbol table: GPL-future symbols */
111 ___start___kcrctab_gpl_future = .;
112 *(__kcrctab_gpl_future)
113 ___stop___kcrctab_gpl_future = .;
114
115 /* Kernel symbol table: strings */
116 *(__ksymtab_strings)
117
118 . = ALIGN(4);
119 __etext = .;
120 } > ram
121
122 .init :
123 {
124 . = ALIGN(4096);
125 ___init_begin = .;
126 __sinittext = .;
127 *(.init.text)
128 __einittext = .;
129 *(.init.data)
130 . = ALIGN(16);
131 ___setup_start = .;
132 *(.init.setup)
133 ___setup_end = .;
134 ___start___param = .;
135 *(__param)
136 ___stop___param = .;
137 ___initcall_start = .;
138 INITCALLS
139 ___initcall_end = .;
140 ___con_initcall_start = .;
141 *(.con_initcall.init)
142 ___con_initcall_end = .;
143 ___security_initcall_start = .;
144 *(.security_initcall.init)
145 ___security_initcall_end = .;
146 . = ALIGN(4);
147 ___initramfs_start = .;
148 *(.init.ramfs)
149 ___initramfs_end = .;
150 . = ALIGN(4);
151 ___init_end = .;
152 } > ram
153
154 __l1_lma_start = .;
155
156 .text_l1 :
157 {
158 . = ALIGN(4);
159 __stext_l1 = .;
160 *(.l1.text)
161
162 . = ALIGN(4);
163 __etext_l1 = .;
164 } > l1_code AT > ram
165
166 .data_l1 :
167 {
168 . = ALIGN(4);
169 __sdata_l1 = .;
170 *(.l1.data)
171 __edata_l1 = .;
172
173 . = ALIGN(4);
174 __sbss_l1 = .;
175 *(.l1.bss)
176
177 . = ALIGN(32);
178 *(.data_l1.cacheline_aligned)
179
180 . = ALIGN(4);
181 __ebss_l1 = .;
182 } > l1_data_a AT > ram
183 .data_b_l1 :
184 {
185 . = ALIGN(4);
186 __sdata_b_l1 = .;
187 *(.l1.data.B)
188 __edata_b_l1 = .;
189
190 . = ALIGN(4);
191 __sbss_b_l1 = .;
192 *(.l1.bss.B)
193
194 . = ALIGN(4);
195 __ebss_b_l1 = .;
196 } > l1_data_b AT > ram
197
198 .data :
199 {
200 __sdata = .;
201 . = ALIGN(0x2000);
202 *(.data.init_task)
203 *(.data)
204
205 . = ALIGN(32);
206 *(.data.cacheline_aligned)
207
208 . = ALIGN(0x2000);
209 __edata = .;
210 } > ram
211
212 /DISCARD/ : { /* Exit code and data*/
213 *(.exit.text)
214 *(.exit.data)
215 *(.exitcall.exit)
216 } > ram
217
218 .bss :
219 {
220 . = ALIGN(4);
221 ___bss_start = .;
222 *(.bss)
223 *(COMMON)
224 . = ALIGN(4);
225 ___bss_stop = .;
226 __end = . ;
227 } > ram
228}
diff --git a/arch/blackfin/lib/Makefile b/arch/blackfin/lib/Makefile
new file mode 100644
index 000000000000..635288fc5f54
--- /dev/null
+++ b/arch/blackfin/lib/Makefile
@@ -0,0 +1,11 @@
1#
2# arch/blackfin/lib/Makefile
3#
4
5lib-y := \
6 ashldi3.o ashrdi3.o lshrdi3.o \
7 muldi3.o divsi3.o udivsi3.o modsi3.o umodsi3.o \
8 checksum.o memcpy.o memset.o memcmp.o memchr.o memmove.o \
9 strcmp.o strcpy.o strncmp.o strncpy.o \
10 umulsi3_highpart.o smulsi3_highpart.o \
11 ins.o outs.o
diff --git a/arch/blackfin/lib/ashldi3.c b/arch/blackfin/lib/ashldi3.c
new file mode 100644
index 000000000000..a8c279e9b192
--- /dev/null
+++ b/arch/blackfin/lib/ashldi3.c
@@ -0,0 +1,58 @@
1/*
2 * File: arch/blackfin/lib/ashldi3.c
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include "gcclib.h"
31
32#ifdef CONFIG_ARITHMETIC_OPS_L1
33DItype __ashldi3(DItype u, word_type b)__attribute__((l1_text));
34#endif
35
36DItype __ashldi3(DItype u, word_type b)
37{
38 DIunion w;
39 word_type bm;
40 DIunion uu;
41
42 if (b == 0)
43 return u;
44
45 uu.ll = u;
46
47 bm = (sizeof(SItype) * BITS_PER_UNIT) - b;
48 if (bm <= 0) {
49 w.s.low = 0;
50 w.s.high = (USItype) uu.s.low << -bm;
51 } else {
52 USItype carries = (USItype) uu.s.low >> bm;
53 w.s.low = (USItype) uu.s.low << b;
54 w.s.high = ((USItype) uu.s.high << b) | carries;
55 }
56
57 return w.ll;
58}
diff --git a/arch/blackfin/lib/ashrdi3.c b/arch/blackfin/lib/ashrdi3.c
new file mode 100644
index 000000000000..a0d3419329ca
--- /dev/null
+++ b/arch/blackfin/lib/ashrdi3.c
@@ -0,0 +1,59 @@
1/*
2 * File: arch/blackfin/lib/ashrdi3.c
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include "gcclib.h"
31
32#ifdef CONFIG_ARITHMETIC_OPS_L1
33DItype __ashrdi3(DItype u, word_type b)__attribute__((l1_text));
34#endif
35
36DItype __ashrdi3(DItype u, word_type b)
37{
38 DIunion w;
39 word_type bm;
40 DIunion uu;
41
42 if (b == 0)
43 return u;
44
45 uu.ll = u;
46
47 bm = (sizeof(SItype) * BITS_PER_UNIT) - b;
48 if (bm <= 0) {
49 /* w.s.high = 1..1 or 0..0 */
50 w.s.high = uu.s.high >> (sizeof(SItype) * BITS_PER_UNIT - 1);
51 w.s.low = uu.s.high >> -bm;
52 } else {
53 USItype carries = (USItype) uu.s.high << bm;
54 w.s.high = uu.s.high >> b;
55 w.s.low = ((USItype) uu.s.low >> b) | carries;
56 }
57
58 return w.ll;
59}
diff --git a/arch/blackfin/lib/checksum.c b/arch/blackfin/lib/checksum.c
new file mode 100644
index 000000000000..42768e0c80ca
--- /dev/null
+++ b/arch/blackfin/lib/checksum.c
@@ -0,0 +1,140 @@
1/*
2 * File: arch/blackfin/lib/checksum.c
3 * Based on: none - original work
4 * Author:
5 *
6 * Created:
7 * Description: An implementation of the TCP/IP protocol suite for the LINUX
8 * operating system. INET is implemented using the BSD Socket
9 * interface as the means of communication with the user level.
10 *
11 * Modified:
12 * Copyright 2004-2006 Analog Devices Inc.
13 *
14 * Bugs: Enter bugs at http://blackfin.uclinux.org/
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, see the file COPYING, or write
28 * to the Free Software Foundation, Inc.,
29 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 */
31
32#include <net/checksum.h>
33#include <asm/checksum.h>
34
35#ifdef CONFIG_IP_CHECKSUM_L1
36static unsigned short do_csum(const unsigned char *buff, int len)__attribute__((l1_text));
37#endif
38
39static unsigned short do_csum(const unsigned char *buff, int len)
40{
41 register unsigned long sum = 0;
42 int swappem = 0;
43
44 if (1 & (unsigned long)buff) {
45 sum = *buff << 8;
46 buff++;
47 len--;
48 ++swappem;
49 }
50
51 while (len > 1) {
52 sum += *(unsigned short *)buff;
53 buff += 2;
54 len -= 2;
55 }
56
57 if (len > 0)
58 sum += *buff;
59
60 /* Fold 32-bit sum to 16 bits */
61 while (sum >> 16)
62 sum = (sum & 0xffff) + (sum >> 16);
63
64 if (swappem)
65 sum = ((sum & 0xff00) >> 8) + ((sum & 0x00ff) << 8);
66
67 return sum;
68
69}
70
71/*
72 * This is a version of ip_compute_csum() optimized for IP headers,
73 * which always checksum on 4 octet boundaries.
74 */
75unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl)
76{
77 return ~do_csum(iph, ihl * 4);
78}
79
80/*
81 * computes the checksum of a memory block at buff, length len,
82 * and adds in "sum" (32-bit)
83 *
84 * returns a 32-bit number suitable for feeding into itself
85 * or csum_tcpudp_magic
86 *
87 * this function must be called with even lengths, except
88 * for the last fragment, which may be odd
89 *
90 * it's best to have buff aligned on a 32-bit boundary
91 */
92unsigned int csum_partial(const unsigned char *buff, int len, unsigned int sum)
93{
94 /*
95 * Just in case we get nasty checksum data...
96 * Like 0xffff6ec3 in the case of our IPv6 multicast header.
97 * We fold to begin with, as well as at the end.
98 */
99 sum = (sum & 0xffff) + (sum >> 16);
100
101 sum += do_csum(buff, len);
102
103 sum = (sum & 0xffff) + (sum >> 16);
104
105 return sum;
106}
107
108/*
109 * this routine is used for miscellaneous IP-like checksums, mainly
110 * in icmp.c
111 */
112unsigned short ip_compute_csum(const unsigned char *buff, int len)
113{
114 return ~do_csum(buff, len);
115}
116
117/*
118 * copy from fs while checksumming, otherwise like csum_partial
119 */
120
121unsigned int
122csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst,
123 int len, int sum, int *csum_err)
124{
125 if (csum_err)
126 *csum_err = 0;
127 memcpy(dst, src, len);
128 return csum_partial(dst, len, sum);
129}
130
131/*
132 * copy from ds while checksumming, otherwise like csum_partial
133 */
134
135unsigned int csum_partial_copy(const unsigned char *src, unsigned char *dst,
136 int len, int sum)
137{
138 memcpy(dst, src, len);
139 return csum_partial(dst, len, sum);
140}
diff --git a/arch/blackfin/lib/divsi3.S b/arch/blackfin/lib/divsi3.S
new file mode 100644
index 000000000000..3e29861852b2
--- /dev/null
+++ b/arch/blackfin/lib/divsi3.S
@@ -0,0 +1,216 @@
1/*
2 * File: arch/blackfin/lib/divsi3.S
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description: 16 / 32 bit signed division.
8 * Special cases :
9 * 1) If(numerator == 0)
10 * return 0
11 * 2) If(denominator ==0)
12 * return positive max = 0x7fffffff
13 * 3) If(numerator == denominator)
14 * return 1
15 * 4) If(denominator ==1)
16 * return numerator
17 * 5) If(denominator == -1)
18 * return -numerator
19 *
20 * Operand : R0 - Numerator (i)
21 * R1 - Denominator (i)
22 * R0 - Quotient (o)
23 * Registers Used : R2-R7,P0-P2
24 *
25 * Modified:
26 * Copyright 2004-2006 Analog Devices Inc.
27 *
28 * Bugs: Enter bugs at http://blackfin.uclinux.org/
29 *
30 * This program is free software; you can redistribute it and/or modify
31 * it under the terms of the GNU General Public License as published by
32 * the Free Software Foundation; either version 2 of the License, or
33 * (at your option) any later version.
34 *
35 * This program is distributed in the hope that it will be useful,
36 * but WITHOUT ANY WARRANTY; without even the implied warranty of
37 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38 * GNU General Public License for more details.
39 *
40 * You should have received a copy of the GNU General Public License
41 * along with this program; if not, see the file COPYING, or write
42 * to the Free Software Foundation, Inc.,
43 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
44 */
45
46.global ___divsi3;
47
48#ifdef CONFIG_ARITHMETIC_OPS_L1
49.section .l1.text
50#else
51.text
52#endif
53
54.align 2;
55___divsi3 :
56
57
58 R3 = R0 ^ R1;
59 R0 = ABS R0;
60
61 CC = V;
62
63 r3 = rot r3 by -1;
64 r1 = abs r1; /* now both positive, r3.30 means "negate result",
65 ** r3.31 means overflow, add one to result
66 */
67 cc = r0 < r1;
68 if cc jump .Lret_zero;
69 r2 = r1 >> 15;
70 cc = r2;
71 if cc jump .Lidents;
72 r2 = r1 << 16;
73 cc = r2 <= r0;
74 if cc jump .Lidents;
75
76 DIVS(R0, R1);
77 DIVQ(R0, R1);
78 DIVQ(R0, R1);
79 DIVQ(R0, R1);
80 DIVQ(R0, R1);
81 DIVQ(R0, R1);
82 DIVQ(R0, R1);
83 DIVQ(R0, R1);
84 DIVQ(R0, R1);
85 DIVQ(R0, R1);
86 DIVQ(R0, R1);
87 DIVQ(R0, R1);
88 DIVQ(R0, R1);
89 DIVQ(R0, R1);
90 DIVQ(R0, R1);
91 DIVQ(R0, R1);
92 DIVQ(R0, R1);
93
94 R0 = R0.L (Z);
95 r1 = r3 >> 31; /* add overflow issue back in */
96 r0 = r0 + r1;
97 r1 = -r0;
98 cc = bittst(r3, 30);
99 if cc r0 = r1;
100 RTS;
101
102/* Can't use the primitives. Test common identities.
103** If the identity is true, return the value in R2.
104*/
105
106.Lidents:
107 CC = R1 == 0; /* check for divide by zero */
108 IF CC JUMP .Lident_return;
109
110 CC = R0 == 0; /* check for division of zero */
111 IF CC JUMP .Lzero_return;
112
113 CC = R0 == R1; /* check for identical operands */
114 IF CC JUMP .Lident_return;
115
116 CC = R1 == 1; /* check for divide by 1 */
117 IF CC JUMP .Lident_return;
118
119 R2.L = ONES R1;
120 R2 = R2.L (Z);
121 CC = R2 == 1;
122 IF CC JUMP .Lpower_of_two;
123
124 /* Identities haven't helped either.
125 ** Perform the full division process.
126 */
127
128 P1 = 31; /* Set loop counter */
129
130 [--SP] = (R7:5); /* Push registers R5-R7 */
131 R2 = -R1;
132 [--SP] = R2;
133 R2 = R0 << 1; /* R2 lsw of dividend */
134 R6 = R0 ^ R1; /* Get sign */
135 R5 = R6 >> 31; /* Shift sign to LSB */
136
137 R0 = 0 ; /* Clear msw partial remainder */
138 R2 = R2 | R5; /* Shift quotient bit */
139 R6 = R0 ^ R1; /* Get new quotient bit */
140
141 LSETUP(.Llst,.Llend) LC0 = P1; /* Setup loop */
142.Llst: R7 = R2 >> 31; /* record copy of carry from R2 */
143 R2 = R2 << 1; /* Shift 64 bit dividend up by 1 bit */
144 R0 = R0 << 1 || R5 = [SP];
145 R0 = R0 | R7; /* and add carry */
146 CC = R6 < 0; /* Check quotient(AQ) */
147 /* we might be subtracting divisor (AQ==0) */
148 IF CC R5 = R1; /* or we might be adding divisor (AQ==1)*/
149 R0 = R0 + R5; /* do add or subtract, as indicated by AQ */
150 R6 = R0 ^ R1; /* Generate next quotient bit */
151 R5 = R6 >> 31;
152 /* Assume AQ==1, shift in zero */
153 BITTGL(R5,0); /* tweak AQ to be what we want to shift in */
154.Llend: R2 = R2 + R5; /* and then set shifted-in value to
155 ** tweaked AQ.
156 */
157 r1 = r3 >> 31;
158 r2 = r2 + r1;
159 cc = bittst(r3,30);
160 r0 = -r2;
161 if !cc r0 = r2;
162 SP += 4;
163 (R7:5)= [SP++]; /* Pop registers R6-R7 */
164 RTS;
165
166.Lident_return:
167 CC = R1 == 0; /* check for divide by zero => 0x7fffffff */
168 R2 = -1 (X);
169 R2 >>= 1;
170 IF CC JUMP .Ltrue_ident_return;
171
172 CC = R0 == R1; /* check for identical operands => 1 */
173 R2 = 1 (Z);
174 IF CC JUMP .Ltrue_ident_return;
175
176 R2 = R0; /* assume divide by 1 => numerator */
177 /*FALLTHRU*/
178
179.Ltrue_ident_return:
180 R0 = R2; /* Return an identity value */
181 R2 = -R2;
182 CC = bittst(R3,30);
183 IF CC R0 = R2;
184.Lzero_return:
185 RTS; /* ...including zero */
186
187.Lpower_of_two:
188 /* Y has a single bit set, which means it's a power of two.
189 ** That means we can perform the division just by shifting
190 ** X to the right the appropriate number of bits
191 */
192
193 /* signbits returns the number of sign bits, minus one.
194 ** 1=>30, 2=>29, ..., 0x40000000=>0. Which means we need
195 ** to shift right n-signbits spaces. It also means 0x80000000
196 ** is a special case, because that *also* gives a signbits of 0
197 */
198
199 R2 = R0 >> 31;
200 CC = R1 < 0;
201 IF CC JUMP .Ltrue_ident_return;
202
203 R1.l = SIGNBITS R1;
204 R1 = R1.L (Z);
205 R1 += -30;
206 R0 = LSHIFT R0 by R1.L;
207 r1 = r3 >> 31;
208 r0 = r0 + r1;
209 R2 = -R0; // negate result if necessary
210 CC = bittst(R3,30);
211 IF CC R0 = R2;
212 RTS;
213
214.Lret_zero:
215 R0 = 0;
216 RTS;
diff --git a/arch/blackfin/lib/gcclib.h b/arch/blackfin/lib/gcclib.h
new file mode 100644
index 000000000000..9ccd39a135ee
--- /dev/null
+++ b/arch/blackfin/lib/gcclib.h
@@ -0,0 +1,47 @@
1/*
2 * File: arch/blackfin/lib/gcclib.h
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#define BITS_PER_UNIT 8
31#define SI_TYPE_SIZE (sizeof (SItype) * BITS_PER_UNIT)
32
33typedef unsigned int UQItype __attribute__ ((mode(QI)));
34typedef int SItype __attribute__ ((mode(SI)));
35typedef unsigned int USItype __attribute__ ((mode(SI)));
36typedef int DItype __attribute__ ((mode(DI)));
37typedef int word_type __attribute__ ((mode(__word__)));
38typedef unsigned int UDItype __attribute__ ((mode(DI)));
39
40struct DIstruct {
41 SItype low, high;
42};
43
44typedef union {
45 struct DIstruct s;
46 DItype ll;
47} DIunion;
diff --git a/arch/blackfin/lib/ins.S b/arch/blackfin/lib/ins.S
new file mode 100644
index 000000000000..730d2b427538
--- /dev/null
+++ b/arch/blackfin/lib/ins.S
@@ -0,0 +1,69 @@
1/*
2 * File: arch/blackfin/lib/ins.S
3 * Based on:
4 * Author: Bas Vermeulen <bas@buyways.nl>
5 *
6 * Created: Tue Mar 22 15:27:24 CEST 2005
7 * Description: Implementation of ins{bwl} for BlackFin processors using zero overhead loops.
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 * Copyright (C) 2005 Bas Vermeulen, BuyWays BV <bas@buyways.nl>
12 *
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, see the file COPYING, or write
27 * to the Free Software Foundation, Inc.,
28 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 */
30
31#include <linux/linkage.h>
32
33.align 2
34
35ENTRY(_insl)
36 P0 = R0; /* P0 = port */
37 cli R3;
38 P1 = R1; /* P1 = address */
39 P2 = R2; /* P2 = count */
40 SSYNC;
41 LSETUP( .Llong_loop_s, .Llong_loop_e) LC0 = P2;
42.Llong_loop_s: R0 = [P0];
43.Llong_loop_e: [P1++] = R0;
44 sti R3;
45 RTS;
46
47ENTRY(_insw)
48 P0 = R0; /* P0 = port */
49 cli R3;
50 P1 = R1; /* P1 = address */
51 P2 = R2; /* P2 = count */
52 SSYNC;
53 LSETUP( .Lword_loop_s, .Lword_loop_e) LC0 = P2;
54.Lword_loop_s: R0 = W[P0];
55.Lword_loop_e: W[P1++] = R0;
56 sti R3;
57 RTS;
58
59ENTRY(_insb)
60 P0 = R0; /* P0 = port */
61 cli R3;
62 P1 = R1; /* P1 = address */
63 P2 = R2; /* P2 = count */
64 SSYNC;
65 LSETUP( .Lbyte_loop_s, .Lbyte_loop_e) LC0 = P2;
66.Lbyte_loop_s: R0 = B[P0];
67.Lbyte_loop_e: B[P1++] = R0;
68 sti R3;
69 RTS;
diff --git a/arch/blackfin/lib/lshrdi3.c b/arch/blackfin/lib/lshrdi3.c
new file mode 100644
index 000000000000..84b9c5592220
--- /dev/null
+++ b/arch/blackfin/lib/lshrdi3.c
@@ -0,0 +1,72 @@
1/*
2 * File: arch/blackfin/lib/lshrdi3.c
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#define BITS_PER_UNIT 8
31
32typedef int SItype __attribute__ ((mode(SI)));
33typedef unsigned int USItype __attribute__ ((mode(SI)));
34typedef int DItype __attribute__ ((mode(DI)));
35typedef int word_type __attribute__ ((mode(__word__)));
36
37struct DIstruct {
38 SItype high, low;
39};
40
41typedef union {
42 struct DIstruct s;
43 DItype ll;
44} DIunion;
45
46#ifdef CONFIG_ARITHMETIC_OPS_L1
47DItype __lshrdi3(DItype u, word_type b)__attribute__((l1_text));
48#endif
49
50DItype __lshrdi3(DItype u, word_type b)
51{
52 DIunion w;
53 word_type bm;
54 DIunion uu;
55
56 if (b == 0)
57 return u;
58
59 uu.ll = u;
60
61 bm = (sizeof(SItype) * BITS_PER_UNIT) - b;
62 if (bm <= 0) {
63 w.s.high = 0;
64 w.s.low = (USItype) uu.s.high >> -bm;
65 } else {
66 USItype carries = (USItype) uu.s.high << bm;
67 w.s.high = (USItype) uu.s.high >> b;
68 w.s.low = ((USItype) uu.s.low >> b) | carries;
69 }
70
71 return w.ll;
72}
diff --git a/arch/blackfin/lib/memchr.S b/arch/blackfin/lib/memchr.S
new file mode 100644
index 000000000000..498122250d07
--- /dev/null
+++ b/arch/blackfin/lib/memchr.S
@@ -0,0 +1,70 @@
1/*
2 * File: arch/blackfin/lib/memchr.S
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/linkage.h>
31
32/* void *memchr(const void *s, int c, size_t n);
33 * R0 = address (s)
34 * R1 = sought byte (c)
35 * R2 = count (n)
36 *
37 * Returns pointer to located character.
38 */
39
40.text
41
42.align 2
43
44ENTRY(_memchr)
45 P0 = R0; /* P0 = address */
46 P2 = R2; /* P2 = count */
47 R1 = R1.B(Z);
48 CC = R2 == 0;
49 IF CC JUMP .Lfailed;
50
51.Lbytes:
52 LSETUP (.Lbyte_loop_s, .Lbyte_loop_e) LC0=P2;
53
54.Lbyte_loop_s:
55 R3 = B[P0++](Z);
56 CC = R3 == R1;
57 IF CC JUMP .Lfound;
58.Lbyte_loop_e:
59 NOP;
60
61.Lfailed:
62 R0=0;
63 RTS;
64
65.Lfound:
66 R0 = P0;
67 R0 += -1;
68 RTS;
69
70.size _memchr,.-_memchr
diff --git a/arch/blackfin/lib/memcmp.S b/arch/blackfin/lib/memcmp.S
new file mode 100644
index 000000000000..5b9502368fc6
--- /dev/null
+++ b/arch/blackfin/lib/memcmp.S
@@ -0,0 +1,110 @@
1/*
2 * File: arch/blackfin/lib/memcmp.S
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/linkage.h>
31
32/* int memcmp(const void *s1, const void *s2, size_t n);
33 * R0 = First Address (s1)
34 * R1 = Second Address (s2)
35 * R2 = count (n)
36 *
37 * Favours word aligned data.
38 */
39
40.text
41
42.align 2
43
44ENTRY(_memcmp)
45 I1 = P3;
46 P0 = R0; /* P0 = s1 address */
47 P3 = R1; /* P3 = s2 Address */
48 P2 = R2 ; /* P2 = count */
49 CC = R2 <= 7(IU);
50 IF CC JUMP .Ltoo_small;
51 I0 = R1; /* s2 */
52 R1 = R1 | R0; /* OR addresses together */
53 R1 <<= 30; /* check bottom two bits */
54 CC = AZ; /* AZ set if zero. */
55 IF !CC JUMP .Lbytes ; /* Jump if addrs not aligned. */
56
57 P1 = P2 >> 2; /* count = n/4 */
58 R3 = 3;
59 R2 = R2 & R3; /* remainder */
60 P2 = R2; /* set remainder */
61
62 LSETUP (.Lquad_loop_s, .Lquad_loop_e) LC0=P1;
63.Lquad_loop_s:
64 MNOP || R0 = [P0++] || R1 = [I0++];
65 CC = R0 == R1;
66 IF !CC JUMP .Lquad_different;
67.Lquad_loop_e:
68 NOP;
69
70 P3 = I0; /* s2 */
71.Ltoo_small:
72 CC = P2 == 0; /* Check zero count*/
73 IF CC JUMP .Lfinished; /* very unlikely*/
74
75.Lbytes:
76 LSETUP (.Lbyte_loop_s, .Lbyte_loop_e) LC0=P2;
77.Lbyte_loop_s:
78 R1 = B[P3++](Z); /* *s2 */
79 R0 = B[P0++](Z); /* *s1 */
80 CC = R0 == R1;
81 IF !CC JUMP .Ldifferent;
82.Lbyte_loop_e:
83 NOP;
84
85.Ldifferent:
86 R0 = R0 - R1;
87 P3 = I1;
88 RTS;
89
90.Lquad_different:
91 /* We've read two quads which don't match.
92 * Can't just compare them, because we're
93 * a little-endian machine, so the MSBs of
94 * the regs occur at later addresses in the
95 * string.
96 * Arrange to re-read those two quads again,
97 * byte-by-byte.
98 */
99 P0 += -4; /* back up to the start of the */
100 P3 = I0; /* quads, and increase the*/
101 P2 += 4; /* remainder count*/
102 P3 += -4;
103 JUMP .Lbytes;
104
105.Lfinished:
106 R0 = 0;
107 P3 = I1;
108 RTS;
109
110.size _memcmp,.-_memcmp
diff --git a/arch/blackfin/lib/memcpy.S b/arch/blackfin/lib/memcpy.S
new file mode 100644
index 000000000000..c1e00eff541c
--- /dev/null
+++ b/arch/blackfin/lib/memcpy.S
@@ -0,0 +1,142 @@
1/*
2 * File: arch/blackfin/lib/memcpy.S
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description: internal version of memcpy(), issued by the compiler
8 * to copy blocks of data around.
9 * This is really memmove() - it has to be able to deal with
10 * possible overlaps, because that ambiguity is when the compiler
11 * gives up and calls a function. We have our own, internal version
12 * so that we get something we trust, even if the user has redefined
13 * the normal symbol.
14 *
15 * Modified:
16 * Copyright 2004-2006 Analog Devices Inc.
17 *
18 * Bugs: Enter bugs at http://blackfin.uclinux.org/
19 *
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, see the file COPYING, or write
32 * to the Free Software Foundation, Inc.,
33 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
34 */
35
36#include <linux/linkage.h>
37
38/* void *memcpy(void *dest, const void *src, size_t n);
39 * R0 = To Address (dest) (leave unchanged to form result)
40 * R1 = From Address (src)
41 * R2 = count
42 *
43 * Note: Favours word alignment
44 */
45
46#ifdef CONFIG_MEMCPY_L1
47.section .l1.text
48#else
49.text
50#endif
51
52.align 2
53
54ENTRY(_memcpy)
55 CC = R2 <= 0; /* length not positive? */
56 IF CC JUMP .L_P1L2147483647; /* Nothing to do */
57
58 P0 = R0 ; /* dst*/
59 P1 = R1 ; /* src*/
60 P2 = R2 ; /* length */
61
62 /* check for overlapping data */
63 CC = R1 < R0; /* src < dst */
64 IF !CC JUMP .Lno_overlap;
65 R3 = R1 + R2;
66 CC = R0 < R3; /* and dst < src+len */
67 IF CC JUMP .Lhas_overlap;
68
69.Lno_overlap:
70 /* Check for aligned data.*/
71
72 R3 = R1 | R0;
73 R0 = 0x3;
74 R3 = R3 & R0;
75 CC = R3; /* low bits set on either address? */
76 IF CC JUMP .Lnot_aligned;
77
78 /* Both addresses are word-aligned, so we can copy
79 at least part of the data using word copies.*/
80 P2 = P2 >> 2;
81 CC = P2 <= 2;
82 IF !CC JUMP .Lmore_than_seven;
83 /* less than eight bytes... */
84 P2 = R2;
85 LSETUP(.Lthree_start, .Lthree_end) LC0=P2;
86 R0 = R1; /* setup src address for return */
87.Lthree_start:
88 R3 = B[P1++] (X);
89.Lthree_end:
90 B[P0++] = R3;
91
92 RTS;
93
94.Lmore_than_seven:
95 /* There's at least eight bytes to copy. */
96 P2 += -1; /* because we unroll one iteration */
97 LSETUP(.Lword_loop, .Lword_loop) LC0=P2;
98 R0 = R1;
99 I1 = P1;
100 R3 = [I1++];
101.Lword_loop:
102 MNOP || [P0++] = R3 || R3 = [I1++];
103
104 [P0++] = R3;
105 /* Any remaining bytes to copy? */
106 R3 = 0x3;
107 R3 = R2 & R3;
108 CC = R3 == 0;
109 P1 = I1; /* in case there's something left, */
110 IF !CC JUMP .Lbytes_left;
111 RTS;
112.Lbytes_left: P2 = R3;
113.Lnot_aligned:
114 /* From here, we're copying byte-by-byte. */
115 LSETUP (.Lbyte_start, .Lbyte_end) LC0=P2;
116 R0 = R1; /* Save src address for return */
117.Lbyte_start:
118 R1 = B[P1++] (X);
119.Lbyte_end:
120 B[P0++] = R1;
121
122.L_P1L2147483647:
123 RTS;
124
125.Lhas_overlap:
126 /* Need to reverse the copying, because the
127 * dst would clobber the src.
128 * Don't bother to work out alignment for
129 * the reverse case.
130 */
131 R0 = R1; /* save src for later. */
132 P0 = P0 + P2;
133 P0 += -1;
134 P1 = P1 + P2;
135 P1 += -1;
136 LSETUP(.Lover_start, .Lover_end) LC0=P2;
137.Lover_start:
138 R1 = B[P1--] (X);
139.Lover_end:
140 B[P0--] = R1;
141
142 RTS;
diff --git a/arch/blackfin/lib/memmove.S b/arch/blackfin/lib/memmove.S
new file mode 100644
index 000000000000..2e5fb7f8df13
--- /dev/null
+++ b/arch/blackfin/lib/memmove.S
@@ -0,0 +1,103 @@
1/*
2 * File: arch/blackfin/lib/memmove.S
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/linkage.h>
31
32.align 2
33
34/*
35 * C Library function MEMMOVE
36 * R0 = To Address (leave unchanged to form result)
37 * R1 = From Address
38 * R2 = count
39 * Data may overlap
40 */
41
42ENTRY(_memmove)
43 I1 = P3;
44 P0 = R0; /* P0 = To address */
45 P3 = R1; /* P3 = From Address */
46 P2 = R2; /* P2 = count */
47 CC = P2 == 0; /* Check zero count*/
48 IF CC JUMP .Lfinished; /* very unlikely */
49
50 CC = R1 < R0 (IU); /* From < To */
51 IF !CC JUMP .Lno_overlap;
52 R3 = R1 + R2;
53 CC = R0 <= R3 (IU); /* (From+len) >= To */
54 IF CC JUMP .Loverlap;
55.Lno_overlap:
56 R3 = 11;
57 CC = R2 <= R3;
58 IF CC JUMP .Lbytes;
59 R3 = R1 | R0; /* OR addresses together */
60 R3 <<= 30; /* check bottom two bits */
61 CC = AZ; /* AZ set if zero.*/
62 IF !CC JUMP .Lbytes; /* Jump if addrs not aligned.*/
63
64 I0 = P3;
65 P1 = P2 >> 2; /* count = n/4 */
66 P1 += -1;
67 R3 = 3;
68 R2 = R2 & R3; /* remainder */
69 P2 = R2; /* set remainder */
70 R1 = [I0++];
71
72 LSETUP (.Lquad_loop, .Lquad_loop) LC0=P1;
73.Lquad_loop: MNOP || [P0++] = R1 || R1 = [I0++];
74 [P0++] = R1;
75
76 CC = P2 == 0; /* any remaining bytes? */
77 P3 = I0; /* Ammend P3 to updated ptr. */
78 IF !CC JUMP .Lbytes;
79 P3 = I1;
80 RTS;
81
82.Lbytes: LSETUP (.Lbyte2_s, .Lbyte2_e) LC0=P2;
83.Lbyte2_s: R1 = B[P3++](Z);
84.Lbyte2_e: B[P0++] = R1;
85
86.Lfinished: P3 = I1;
87 RTS;
88
89.Loverlap:
90 P2 += -1;
91 P0 = P0 + P2;
92 P3 = P3 + P2;
93 R1 = B[P3--] (Z);
94 CC = P2 == 0;
95 IF CC JUMP .Lno_loop;
96 LSETUP (.Lol_s, .Lol_e) LC0 = P2;
97.Lol_s: B[P0--] = R1;
98.Lol_e: R1 = B[P3--] (Z);
99.Lno_loop: B[P0] = R1;
100 P3 = I1;
101 RTS;
102
103.size _memmove,.-_memmove
diff --git a/arch/blackfin/lib/memset.S b/arch/blackfin/lib/memset.S
new file mode 100644
index 000000000000..ba6d047568dd
--- /dev/null
+++ b/arch/blackfin/lib/memset.S
@@ -0,0 +1,109 @@
1/*
2 * File: arch/blackfin/lib/memset.S
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/linkage.h>
31
32.align 2
33
34#ifdef CONFIG_MEMSET_L1
35.section .l1.text
36#else
37.text
38#endif
39
40/*
41 * C Library function MEMSET
42 * R0 = address (leave unchanged to form result)
43 * R1 = filler byte
44 * R2 = count
45 * Favours word aligned data.
46 */
47
48ENTRY(_memset)
49 P0 = R0 ; /* P0 = address */
50 P2 = R2 ; /* P2 = count */
51 R3 = R0 + R2; /* end */
52 CC = R2 <= 7(IU);
53 IF CC JUMP .Ltoo_small;
54 R1 = R1.B (Z); /* R1 = fill char */
55 R2 = 3;
56 R2 = R0 & R2; /* addr bottom two bits */
57 CC = R2 == 0; /* AZ set if zero. */
58 IF !CC JUMP .Lforce_align ; /* Jump if addr not aligned. */
59
60.Laligned:
61 P1 = P2 >> 2; /* count = n/4 */
62 R2 = R1 << 8; /* create quad filler */
63 R2.L = R2.L + R1.L(NS);
64 R2.H = R2.L + R1.H(NS);
65 P2 = R3;
66
67 LSETUP (.Lquad_loop , .Lquad_loop) LC0=P1;
68.Lquad_loop:
69 [P0++] = R2;
70
71 CC = P0 == P2;
72 IF !CC JUMP .Lbytes_left;
73 RTS;
74
75.Lbytes_left:
76 R2 = R3; /* end point */
77 R3 = P0; /* current position */
78 R2 = R2 - R3; /* bytes left */
79 P2 = R2;
80
81.Ltoo_small:
82 CC = P2 == 0; /* Check zero count */
83 IF CC JUMP .Lfinished; /* Unusual */
84
85.Lbytes:
86 LSETUP (.Lbyte_loop , .Lbyte_loop) LC0=P2;
87.Lbyte_loop:
88 B[P0++] = R1;
89
90.Lfinished:
91 RTS;
92
93.Lforce_align:
94 CC = BITTST (R0, 0); /* odd byte */
95 R0 = 4;
96 R0 = R0 - R2;
97 P1 = R0;
98 R0 = P0; /* Recover return address */
99 IF !CC JUMP .Lskip1;
100 B[P0++] = R1;
101.Lskip1:
102 CC = R2 <= 2; /* 2 bytes */
103 P2 -= P1; /* reduce count */
104 IF !CC JUMP .Laligned;
105 B[P0++] = R1;
106 B[P0++] = R1;
107 JUMP .Laligned;
108
109.size _memset,.-_memset
diff --git a/arch/blackfin/lib/modsi3.S b/arch/blackfin/lib/modsi3.S
new file mode 100644
index 000000000000..528b8b1ccb34
--- /dev/null
+++ b/arch/blackfin/lib/modsi3.S
@@ -0,0 +1,79 @@
1/*
2 * File: arch/blackfin/lib/modsi3.S
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description: This program computes 32 bit signed remainder. It calls div32 function
8 * for quotient estimation.
9 *
10 * Registers used :
11 * Numerator/ Denominator in R0, R1
12 * R0 - returns remainder.
13 * R2-R7
14 *
15 * Modified:
16 * Copyright 2004-2006 Analog Devices Inc.
17 *
18 * Bugs: Enter bugs at http://blackfin.uclinux.org/
19 *
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, see the file COPYING, or write
32 * to the Free Software Foundation, Inc.,
33 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
34 */
35
36.global ___modsi3;
37.type ___modsi3, STT_FUNC;
38.extern ___divsi3;
39.type ___divsi3, STT_FUNC;
40
41#ifdef CONFIG_ARITHMETIC_OPS_L1
42.section .l1.text
43#else
44.text
45#endif
46
47___modsi3:
48
49 CC=R0==0;
50 IF CC JUMP .LRETURN_R0; /* Return 0, if numerator == 0 */
51 CC=R1==0;
52 IF CC JUMP .LRETURN_ZERO; /* Return 0, if denominator == 0 */
53 CC=R0==R1;
54 IF CC JUMP .LRETURN_ZERO; /* Return 0, if numerator == denominator */
55 CC = R1 == 1;
56 IF CC JUMP .LRETURN_ZERO; /* Return 0, if denominator == 1 */
57 CC = R1 == -1;
58 IF CC JUMP .LRETURN_ZERO; /* Return 0, if denominator == -1 */
59
60 /* Valid input. Use __divsi3() to compute the quotient, and then
61 * derive the remainder from that. */
62
63 [--SP] = (R7:6); /* Push R7 and R6 */
64 [--SP] = RETS; /* and return address */
65 R7 = R0; /* Copy of R0 */
66 R6 = R1; /* Save for later */
67 SP += -12; /* Should always provide this space */
68 CALL ___divsi3; /* Compute signed quotient using ___divsi3()*/
69 SP += 12;
70 R0 *= R6; /* Quotient * divisor */
71 R0 = R7 - R0; /* Dividend - (quotient * divisor) */
72 RETS = [SP++]; /* Get back return address */
73 (R7:6) = [SP++]; /* Pop registers R7 and R4 */
74 RTS; /* Store remainder */
75
76.LRETURN_ZERO:
77 R0 = 0;
78.LRETURN_R0:
79 RTS;
diff --git a/arch/blackfin/lib/muldi3.c b/arch/blackfin/lib/muldi3.c
new file mode 100644
index 000000000000..303d0c6a6dba
--- /dev/null
+++ b/arch/blackfin/lib/muldi3.c
@@ -0,0 +1,99 @@
1/*
2 * File: arch/blackfin/lib/muldi3.c
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#ifndef SI_TYPE_SIZE
31#define SI_TYPE_SIZE 32
32#endif
33#define __ll_b (1L << (SI_TYPE_SIZE / 2))
34#define __ll_lowpart(t) ((usitype) (t) % __ll_b)
35#define __ll_highpart(t) ((usitype) (t) / __ll_b)
36#define BITS_PER_UNIT 8
37
38#if !defined(umul_ppmm)
39#define umul_ppmm(w1, w0, u, v) \
40 do { \
41 usitype __x0, __x1, __x2, __x3; \
42 usitype __ul, __vl, __uh, __vh; \
43 \
44 __ul = __ll_lowpart (u); \
45 __uh = __ll_highpart (u); \
46 __vl = __ll_lowpart (v); \
47 __vh = __ll_highpart (v); \
48 \
49 __x0 = (usitype) __ul * __vl; \
50 __x1 = (usitype) __ul * __vh; \
51 __x2 = (usitype) __uh * __vl; \
52 __x3 = (usitype) __uh * __vh; \
53 \
54 __x1 += __ll_highpart (__x0);/* this can't give carry */ \
55 __x1 += __x2; /* but this indeed can */ \
56 if (__x1 < __x2) /* did we get it? */ \
57 __x3 += __ll_b; /* yes, add it in the proper pos. */ \
58 \
59 (w1) = __x3 + __ll_highpart (__x1); \
60 (w0) = __ll_lowpart (__x1) * __ll_b + __ll_lowpart (__x0); \
61 } while (0)
62#endif
63
64#if !defined(__umulsidi3)
65#define __umulsidi3(u, v) \
66 ({diunion __w; \
67 umul_ppmm (__w.s.high, __w.s.low, u, v); \
68 __w.ll; })
69#endif
70
71typedef unsigned int usitype __attribute__ ((mode(SI)));
72typedef int sitype __attribute__ ((mode(SI)));
73typedef int ditype __attribute__ ((mode(DI)));
74typedef int word_type __attribute__ ((mode(__word__)));
75
76struct distruct {
77 sitype low, high;
78};
79typedef union {
80 struct distruct s;
81 ditype ll;
82} diunion;
83
84#ifdef CONFIG_ARITHMETIC_OPS_L1
85ditype __muldi3(ditype u, ditype v)__attribute__((l1_text));
86#endif
87
88ditype __muldi3(ditype u, ditype v)
89{
90 diunion w;
91 diunion uu, vv;
92
93 uu.ll = u, vv.ll = v;
94 w.ll = __umulsidi3(uu.s.low, vv.s.low);
95 w.s.high += ((usitype) uu.s.low * (usitype) vv.s.high
96 + (usitype) uu.s.high * (usitype) vv.s.low);
97
98 return w.ll;
99}
diff --git a/arch/blackfin/lib/outs.S b/arch/blackfin/lib/outs.S
new file mode 100644
index 000000000000..f8c876fe8930
--- /dev/null
+++ b/arch/blackfin/lib/outs.S
@@ -0,0 +1,62 @@
1/*
2 * File: arch/blackfin/lib/outs.S
3 * Based on:
4 * Author: Bas Vermeulen <bas@buyways.nl>
5 *
6 * Created: Tue Mar 22 15:27:24 CEST 2005
7 * Description: Implementation of outs{bwl} for BlackFin processors using zero overhead loops.
8 *
9 * Modified: Copyright (C) 2005 Bas Vermeulen, BuyWays BV <bas@buyways.nl>
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/linkage.h>
31
32.align 2
33
34ENTRY(_outsl)
35 P0 = R0; /* P0 = port */
36 P1 = R1; /* P1 = address */
37 P2 = R2; /* P2 = count */
38
39 LSETUP( .Llong_loop_s, .Llong_loop_e) LC0 = P2;
40.Llong_loop_s: R0 = [P1++];
41.Llong_loop_e: [P0] = R0;
42 RTS;
43
44ENTRY(_outsw)
45 P0 = R0; /* P0 = port */
46 P1 = R1; /* P1 = address */
47 P2 = R2; /* P2 = count */
48
49 LSETUP( .Lword_loop_s, .Lword_loop_e) LC0 = P2;
50.Lword_loop_s: R0 = W[P1++];
51.Lword_loop_e: W[P0] = R0;
52 RTS;
53
54ENTRY(_outsb)
55 P0 = R0; /* P0 = port */
56 P1 = R1; /* P1 = address */
57 P2 = R2; /* P2 = count */
58
59 LSETUP( .Lbyte_loop_s, .Lbyte_loop_e) LC0 = P2;
60.Lbyte_loop_s: R0 = B[P1++];
61.Lbyte_loop_e: B[P0] = R0;
62 RTS;
diff --git a/arch/blackfin/lib/smulsi3_highpart.S b/arch/blackfin/lib/smulsi3_highpart.S
new file mode 100644
index 000000000000..10b8f8da576f
--- /dev/null
+++ b/arch/blackfin/lib/smulsi3_highpart.S
@@ -0,0 +1,30 @@
1.align 2
2.global ___smulsi3_highpart;
3.type ___smulsi3_highpart, STT_FUNC;
4
5#ifdef CONFIG_ARITHMETIC_OPS_L1
6.section .l1.text
7#else
8.text
9#endif
10
11___smulsi3_highpart:
12 R2 = R1.L * R0.L (FU);
13 R3 = R1.H * R0.L (IS,M);
14 R0 = R0.H * R1.H, R1 = R0.H * R1.L (IS,M);
15
16 R1.L = R2.H + R1.L;
17 cc = ac0;
18 R2 = cc;
19
20 R1.L = R1.L + R3.L;
21 cc = ac0;
22 R1 >>>= 16;
23 R3 >>>= 16;
24 R1 = R1 + R3;
25 R1 = R1 + R2;
26 R2 = cc;
27 R1 = R1 + R2;
28
29 R0 = R0 + R1;
30 RTS;
diff --git a/arch/blackfin/lib/strcmp.c b/arch/blackfin/lib/strcmp.c
new file mode 100644
index 000000000000..2ad47c4254ba
--- /dev/null
+++ b/arch/blackfin/lib/strcmp.c
@@ -0,0 +1,11 @@
1#include <linux/types.h>
2
3#define strcmp __inline_strcmp
4#include <asm/string.h>
5#undef strcmp
6
7int strcmp(const char *dest, const char *src)
8{
9 return __inline_strcmp(dest, src);
10}
11
diff --git a/arch/blackfin/lib/strcpy.c b/arch/blackfin/lib/strcpy.c
new file mode 100644
index 000000000000..4dc835a8a19b
--- /dev/null
+++ b/arch/blackfin/lib/strcpy.c
@@ -0,0 +1,11 @@
1#include <linux/types.h>
2
3#define strcpy __inline_strcpy
4#include <asm/string.h>
5#undef strcpy
6
7char *strcpy(char *dest, const char *src)
8{
9 return __inline_strcpy(dest, src);
10}
11
diff --git a/arch/blackfin/lib/strncmp.c b/arch/blackfin/lib/strncmp.c
new file mode 100644
index 000000000000..947bcfe3f3bb
--- /dev/null
+++ b/arch/blackfin/lib/strncmp.c
@@ -0,0 +1,11 @@
1#include <linux/types.h>
2
3#define strncmp __inline_strncmp
4#include <asm/string.h>
5#undef strncmp
6
7int strncmp(const char *cs, const char *ct, size_t count)
8{
9 return __inline_strncmp(cs, ct, count);
10}
11
diff --git a/arch/blackfin/lib/strncpy.c b/arch/blackfin/lib/strncpy.c
new file mode 100644
index 000000000000..77a9b2e95097
--- /dev/null
+++ b/arch/blackfin/lib/strncpy.c
@@ -0,0 +1,11 @@
1#include <linux/types.h>
2
3#define strncpy __inline_strncpy
4#include <asm/string.h>
5#undef strncpy
6
7char *strncpy(char *dest, const char *src, size_t n)
8{
9 return __inline_strncpy(dest, src, n);
10}
11
diff --git a/arch/blackfin/lib/udivsi3.S b/arch/blackfin/lib/udivsi3.S
new file mode 100644
index 000000000000..d39a12916259
--- /dev/null
+++ b/arch/blackfin/lib/udivsi3.S
@@ -0,0 +1,298 @@
1/*
2 * File: arch/blackfin/lib/udivsi3.S
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/linkage.h>
31
32#define CARRY AC0
33
34#ifdef CONFIG_ARITHMETIC_OPS_L1
35.section .l1.text
36#else
37.text
38#endif
39
40
41ENTRY(___udivsi3)
42
43 CC = R0 < R1 (IU); /* If X < Y, always return 0 */
44 IF CC JUMP .Lreturn_ident;
45
46 R2 = R1 << 16;
47 CC = R2 <= R0 (IU);
48 IF CC JUMP .Lidents;
49
50 R2 = R0 >> 31; /* if X is a 31-bit number */
51 R3 = R1 >> 15; /* and Y is a 15-bit number */
52 R2 = R2 | R3; /* then it's okay to use the DIVQ builtins (fallthrough to fast)*/
53 CC = R2;
54 IF CC JUMP .Ly_16bit;
55
56/* METHOD 1: FAST DIVQ
57 We know we have a 31-bit dividend, and 15-bit divisor so we can use the
58 simple divq approach (first setting AQ to 0 - implying unsigned division,
59 then 16 DIVQ's).
60*/
61
62 AQ = CC; /* Clear AQ (CC==0) */
63
64/* ISR States: When dividing two integers (32.0/16.0) using divide primitives,
65 we need to shift the dividend one bit to the left.
66 We have already checked that we have a 31-bit number so we are safe to do
67 that.
68*/
69 R0 <<= 1;
70 DIVQ(R0, R1); // 1
71 DIVQ(R0, R1); // 2
72 DIVQ(R0, R1); // 3
73 DIVQ(R0, R1); // 4
74 DIVQ(R0, R1); // 5
75 DIVQ(R0, R1); // 6
76 DIVQ(R0, R1); // 7
77 DIVQ(R0, R1); // 8
78 DIVQ(R0, R1); // 9
79 DIVQ(R0, R1); // 10
80 DIVQ(R0, R1); // 11
81 DIVQ(R0, R1); // 12
82 DIVQ(R0, R1); // 13
83 DIVQ(R0, R1); // 14
84 DIVQ(R0, R1); // 15
85 DIVQ(R0, R1); // 16
86 R0 = R0.L (Z);
87 RTS;
88
89.Ly_16bit:
90 /* We know that the upper 17 bits of Y might have bits set,
91 ** or that the sign bit of X might have a bit. If Y is a
92 ** 16-bit number, but not bigger, then we can use the builtins
93 ** with a post-divide correction.
94 ** R3 currently holds Y>>15, which means R3's LSB is the
95 ** bit we're interested in.
96 */
97
98 /* According to the ISR, to use the Divide primitives for
99 ** unsigned integer divide, the useable range is 31 bits
100 */
101 CC = ! BITTST(R0, 31);
102
103 /* IF condition is true we can scale our inputs and use the divide primitives,
104 ** with some post-adjustment
105 */
106 R3 += -1; /* if so, Y is 0x00008nnn */
107 CC &= AZ;
108
109 /* If condition is true we can scale our inputs and use the divide primitives,
110 ** with some post-adjustment
111 */
112 R3 = R1 >> 1; /* Pre-scaled divisor for primitive case */
113 R2 = R0 >> 16;
114
115 R2 = R3 - R2; /* shifted divisor < upper 16 bits of dividend */
116 CC &= CARRY;
117 IF CC JUMP .Lshift_and_correct;
118
119 /* Fall through to the identities */
120
121/* METHOD 2: identities and manual calculation
122 We are not able to use the divide primites, but may still catch some special
123 cases.
124*/
125.Lidents:
126 /* Test for common identities. Value to be returned is placed in R2. */
127 CC = R0 == 0; /* 0/Y => 0 */
128 IF CC JUMP .Lreturn_r0;
129 CC = R0 == R1; /* X==Y => 1 */
130 IF CC JUMP .Lreturn_ident;
131 CC = R1 == 1; /* X/1 => X */
132 IF CC JUMP .Lreturn_ident;
133
134 R2.L = ONES R1;
135 R2 = R2.L (Z);
136 CC = R2 == 1;
137 IF CC JUMP .Lpower_of_two;
138
139 [--SP] = (R7:5); /* Push registers R5-R7 */
140
141 /* Idents don't match. Go for the full operation. */
142
143
144 R6 = 2; /* assume we'll shift two */
145 R3 = 1;
146
147 P2 = R1;
148 /* If either R0 or R1 have sign set, */
149 /* divide them by two, and note it's */
150 /* been done. */
151 CC = R1 < 0;
152 R2 = R1 >> 1;
153 IF CC R1 = R2; /* Possibly-shifted R1 */
154 IF !CC R6 = R3; /* R1 doesn't, so at most 1 shifted */
155
156 P0 = 0;
157 R3 = -R1;
158 [--SP] = R3;
159 R2 = R0 >> 1;
160 R2 = R0 >> 1;
161 CC = R0 < 0;
162 IF CC P0 = R6; /* Number of values divided */
163 IF !CC R2 = R0; /* Shifted R0 */
164
165 /* P0 is 0, 1 (NR/=2) or 2 (NR/=2, DR/=2) */
166
167 /* r2 holds Copy dividend */
168 R3 = 0; /* Clear partial remainder */
169 R7 = 0; /* Initialise quotient bit */
170
171 P1 = 32; /* Set loop counter */
172 LSETUP(.Lulst, .Lulend) LC0 = P1; /* Set loop counter */
173.Lulst: R6 = R2 >> 31; /* R6 = sign bit of R2, for carry */
174 R2 = R2 << 1; /* Shift 64 bit dividend up by 1 bit */
175 R3 = R3 << 1 || R5 = [SP];
176 R3 = R3 | R6; /* Include any carry */
177 CC = R7 < 0; /* Check quotient(AQ) */
178 /* If AQ==0, we'll sub divisor */
179 IF CC R5 = R1; /* and if AQ==1, we'll add it. */
180 R3 = R3 + R5; /* Add/sub divsor to partial remainder */
181 R7 = R3 ^ R1; /* Generate next quotient bit */
182
183 R5 = R7 >> 31; /* Get AQ */
184 BITTGL(R5, 0); /* Invert it, to get what we'll shift */
185.Lulend: R2 = R2 + R5; /* and "shift" it in. */
186
187 CC = P0 == 0; /* Check how many inputs we shifted */
188 IF CC JUMP .Lno_mult; /* if none... */
189 R6 = R2 << 1;
190 CC = P0 == 1;
191 IF CC R2 = R6; /* if 1, Q = Q*2 */
192 IF !CC R1 = P2; /* if 2, restore stored divisor */
193
194 R3 = R2; /* Copy of R2 */
195 R3 *= R1; /* Q * divisor */
196 R5 = R0 - R3; /* Z = (dividend - Q * divisor) */
197 CC = R1 <= R5 (IU); /* Check if divisor <= Z? */
198 R6 = CC; /* if yes, R6 = 1 */
199 R2 = R2 + R6; /* if yes, add one to quotient(Q) */
200.Lno_mult:
201 SP += 4;
202 (R7:5) = [SP++]; /* Pop registers R5-R7 */
203 R0 = R2; /* Store quotient */
204 RTS;
205
206.Lreturn_ident:
207 CC = R0 < R1 (IU); /* If X < Y, always return 0 */
208 R2 = 0;
209 IF CC JUMP .Ltrue_return_ident;
210 R2 = -1 (X); /* X/0 => 0xFFFFFFFF */
211 CC = R1 == 0;
212 IF CC JUMP .Ltrue_return_ident;
213 R2 = -R2; /* R2 now 1 */
214 CC = R0 == R1; /* X==Y => 1 */
215 IF CC JUMP .Ltrue_return_ident;
216 R2 = R0; /* X/1 => X */
217 /*FALLTHRU*/
218
219.Ltrue_return_ident:
220 R0 = R2;
221.Lreturn_r0:
222 RTS;
223
224.Lpower_of_two:
225 /* Y has a single bit set, which means it's a power of two.
226 ** That means we can perform the division just by shifting
227 ** X to the right the appropriate number of bits
228 */
229
230 /* signbits returns the number of sign bits, minus one.
231 ** 1=>30, 2=>29, ..., 0x40000000=>0. Which means we need
232 ** to shift right n-signbits spaces. It also means 0x80000000
233 ** is a special case, because that *also* gives a signbits of 0
234 */
235
236 R2 = R0 >> 31;
237 CC = R1 < 0;
238 IF CC JUMP .Ltrue_return_ident;
239
240 R1.l = SIGNBITS R1;
241 R1 = R1.L (Z);
242 R1 += -30;
243 R0 = LSHIFT R0 by R1.L;
244 RTS;
245
246/* METHOD 3: PRESCALE AND USE THE DIVIDE PRIMITIVES WITH SOME POST-CORRECTION
247 Two scaling operations are required to use the divide primitives with a
248 divisor > 0x7FFFF.
249 Firstly (as in method 1) we need to shift the dividend 1 to the left for
250 integer division.
251 Secondly we need to shift both the divisor and dividend 1 to the right so
252 both are in range for the primitives.
253 The left/right shift of the dividend does nothing so we can skip it.
254*/
255.Lshift_and_correct:
256 R2 = R0;
257 // R3 is already R1 >> 1
258 CC=!CC;
259 AQ = CC; /* Clear AQ, got here with CC = 0 */
260 DIVQ(R2, R3); // 1
261 DIVQ(R2, R3); // 2
262 DIVQ(R2, R3); // 3
263 DIVQ(R2, R3); // 4
264 DIVQ(R2, R3); // 5
265 DIVQ(R2, R3); // 6
266 DIVQ(R2, R3); // 7
267 DIVQ(R2, R3); // 8
268 DIVQ(R2, R3); // 9
269 DIVQ(R2, R3); // 10
270 DIVQ(R2, R3); // 11
271 DIVQ(R2, R3); // 12
272 DIVQ(R2, R3); // 13
273 DIVQ(R2, R3); // 14
274 DIVQ(R2, R3); // 15
275 DIVQ(R2, R3); // 16
276
277 /* According to the Instruction Set Reference:
278 To divide by a divisor > 0x7FFF,
279 1. prescale and perform divide to obtain quotient (Q) (done above),
280 2. multiply quotient by unscaled divisor (result M)
281 3. subtract the product from the divident to get an error (E = X - M)
282 4. if E < divisor (Y) subtract 1, if E > divisor (Y) add 1, else return quotient (Q)
283 */
284 R3 = R2.L (Z); /* Q = X' / Y' */
285 R2 = R3; /* Preserve Q */
286 R2 *= R1; /* M = Q * Y */
287 R2 = R0 - R2; /* E = X - M */
288 R0 = R3; /* Copy Q into result reg */
289
290/* Correction: If result of the multiply is negative, we overflowed
291 and need to correct the result by subtracting 1 from the result.*/
292 R3 = 0xFFFF (Z);
293 R2 = R2 >> 16; /* E >> 16 */
294 CC = R2 == R3;
295 R3 = 1 ;
296 R1 = R0 - R3;
297 IF CC R0 = R1;
298 RTS;
diff --git a/arch/blackfin/lib/umodsi3.S b/arch/blackfin/lib/umodsi3.S
new file mode 100644
index 000000000000..b55ce96ab89f
--- /dev/null
+++ b/arch/blackfin/lib/umodsi3.S
@@ -0,0 +1,66 @@
1/*
2 * File: arch/blackfin/lib/umodsi3.S
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description: libgcc1 routines for Blackfin 5xx
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#ifdef CONFIG_ARITHMETIC_OPS_L1
31.section .l1.text
32#else
33.text
34#endif
35
36.extern ___udivsi3;
37.globl ___umodsi3
38___umodsi3:
39
40 CC=R0==0;
41 IF CC JUMP .LRETURN_R0; /* Return 0, if NR == 0 */
42 CC= R1==0;
43 IF CC JUMP .LRETURN_ZERO_VAL; /* Return 0, if DR == 0 */
44 CC=R0==R1;
45 IF CC JUMP .LRETURN_ZERO_VAL; /* Return 0, if NR == DR */
46 CC = R1 == 1;
47 IF CC JUMP .LRETURN_ZERO_VAL; /* Return 0, if DR == 1 */
48 CC = R0<R1 (IU);
49 IF CC JUMP .LRETURN_R0; /* Return dividend (R0),IF NR<DR */
50
51 [--SP] = (R7:6); /* Push registers and */
52 [--SP] = RETS; /* Return address */
53 R7 = R0; /* Copy of R0 */
54 R6 = R1;
55 SP += -12; /* Should always provide this space */
56 CALL ___udivsi3; /* Compute unsigned quotient using ___udiv32()*/
57 SP += 12;
58 R0 *= R6; /* Quotient * divisor */
59 R0 = R7 - R0; /* Dividend - (quotient * divisor) */
60 RETS = [SP++]; /* Pop return address */
61 ( R7:6) = [SP++]; /* And registers */
62 RTS; /* Return remainder */
63.LRETURN_ZERO_VAL:
64 R0 = 0;
65.LRETURN_R0:
66 RTS;
diff --git a/arch/blackfin/lib/umulsi3_highpart.S b/arch/blackfin/lib/umulsi3_highpart.S
new file mode 100644
index 000000000000..aac8218fb258
--- /dev/null
+++ b/arch/blackfin/lib/umulsi3_highpart.S
@@ -0,0 +1,23 @@
1.align 2
2.global ___umulsi3_highpart;
3.type ___umulsi3_highpart, STT_FUNC;
4
5#ifdef CONFIG_ARITHMETIC_OPS_L1
6.section .l1.text
7#else
8.text
9#endif
10
11___umulsi3_highpart:
12 R2 = R1.H * R0.H, R3 = R1.L * R0.H (FU);
13 R0 = R1.L * R0.L, R1 = R1.H * R0.L (FU);
14 R0 >>= 16;
15 /* Unsigned multiplication has the nice property that we can
16 ignore carry on this first addition. */
17 R0 = R0 + R3;
18 R0 = R0 + R1;
19 cc = ac0;
20 R1 = cc;
21 R1 = PACK(R1.l,R0.h);
22 R0 = R1 + R2;
23 RTS;
diff --git a/arch/blackfin/mach-bf533/Kconfig b/arch/blackfin/mach-bf533/Kconfig
new file mode 100644
index 000000000000..14297b3ed5c3
--- /dev/null
+++ b/arch/blackfin/mach-bf533/Kconfig
@@ -0,0 +1,92 @@
1if (BF533 || BF532 || BF531)
2
3menu "BF533/2/1 Specific Configuration"
4
5comment "Interrupt Priority Assignment"
6menu "Priority"
7
8config UART_ERROR
9 int "UART ERROR"
10 default 7
11config SPORT0_ERROR
12 int "SPORT0 ERROR"
13 default 7
14config SPI_ERROR
15 int "SPI ERROR"
16 default 7
17config SPORT1_ERROR
18 int "SPORT1 ERROR"
19 default 7
20config PPI_ERROR
21 int "PPI ERROR"
22 default 7
23config DMA_ERROR
24 int "DMA ERROR"
25 default 7
26config PLLWAKE_ERROR
27 int "PLL WAKEUP ERROR"
28 default 7
29
30config RTC_ERROR
31 int "RTC ERROR"
32 default 8
33config DMA0_PPI
34 int "DMA0 PPI"
35 default 8
36
37config DMA1_SPORT0RX
38 int "DMA1 (SPORT0 RX)"
39 default 9
40config DMA2_SPORT0TX
41 int "DMA2 (SPORT0 TX)"
42 default 9
43config DMA3_SPORT1RX
44 int "DMA3 (SPORT1 RX)"
45 default 9
46config DMA4_SPORT1TX
47 int "DMA4 (SPORT1 TX)"
48 default 9
49config DMA5_SPI
50 int "DMA5 (SPI)"
51 default 10
52config DMA6_UARTRX
53 int "DMA6 (UART0 RX)"
54 default 10
55config DMA7_UARTTX
56 int "DMA7 (UART0 TX)"
57 default 10
58config TIMER0
59 int "TIMER0"
60 default 11
61config TIMER1
62 int "TIMER1"
63 default 11
64config TIMER2
65 int "TIMER2"
66 default 11
67config PFA
68 int "PF Interrupt A"
69 default 12
70config PFB
71 int "PF Interrupt B"
72 default 12
73config MEMDMA0
74 int "MEMORY DMA0"
75 default 13
76config MEMDMA1
77 int "MEMORY DMA1"
78 default 13
79config WDTIMER
80 int "WATCH DOG TIMER"
81 default 13
82
83 help
84 Enter the priority numbers between 7-13 ONLY. Others are Reserved.
85 This applies to all the above. It is not recommended to assign the
86 highest priority number 7 to UART or any other device.
87
88endmenu
89
90endmenu
91
92endif
diff --git a/arch/blackfin/mach-bf533/Makefile b/arch/blackfin/mach-bf533/Makefile
new file mode 100644
index 000000000000..76d2c2b8579a
--- /dev/null
+++ b/arch/blackfin/mach-bf533/Makefile
@@ -0,0 +1,9 @@
1#
2# arch/blackfin/mach-bf533/Makefile
3#
4
5extra-y := head.o
6
7obj-y := ints-priority.o
8
9obj-$(CONFIG_CPU_FREQ_BF533) += cpu.o
diff --git a/arch/blackfin/mach-bf533/boards/Makefile b/arch/blackfin/mach-bf533/boards/Makefile
new file mode 100644
index 000000000000..12a631ab389d
--- /dev/null
+++ b/arch/blackfin/mach-bf533/boards/Makefile
@@ -0,0 +1,8 @@
1#
2# arch/blackfin/mach-bf533/boards/Makefile
3#
4
5obj-$(CONFIG_GENERIC_BOARD) += generic_board.o
6obj-$(CONFIG_BFIN533_STAMP) += stamp.o
7obj-$(CONFIG_BFIN533_EZKIT) += ezkit.o
8obj-$(CONFIG_BFIN533_BLUETECHNIX_CM) += cm_bf533.o
diff --git a/arch/blackfin/mach-bf533/boards/cm_bf533.c b/arch/blackfin/mach-bf533/boards/cm_bf533.c
new file mode 100644
index 000000000000..23a7f607df3f
--- /dev/null
+++ b/arch/blackfin/mach-bf533/boards/cm_bf533.c
@@ -0,0 +1,267 @@
1/*
2 * File: arch/blackfin/mach-bf533/boards/cm_bf533.c
3 * Based on: arch/blackfin/mach-bf533/boards/ezkit.c
4 * Author: Aidan Williams <aidan@nicta.com.au> Copright 2005
5 *
6 * Created: 2005
7 * Description: Board description file
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/device.h>
31#include <linux/platform_device.h>
32#include <linux/mtd/mtd.h>
33#include <linux/mtd/partitions.h>
34#include <linux/spi/spi.h>
35#include <linux/spi/flash.h>
36#include <linux/usb_isp1362.h>
37#include <asm/irq.h>
38#include <asm/bfin5xx_spi.h>
39
40/*
41 * Name the Board for the /proc/cpuinfo
42 */
43char *bfin_board_name = "Bluetechnix CM BF533";
44
45#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
46/* all SPI peripherals info goes here */
47
48static struct mtd_partition bfin_spi_flash_partitions[] = {
49 {
50 .name = "bootloader",
51 .size = 0x00020000,
52 .offset = 0,
53 .mask_flags = MTD_CAP_ROM
54 },{
55 .name = "kernel",
56 .size = 0xe0000,
57 .offset = 0x20000
58 },{
59 .name = "file system",
60 .size = 0x700000,
61 .offset = 0x00100000,
62 }
63};
64
65static struct flash_platform_data bfin_spi_flash_data = {
66 .name = "m25p80",
67 .parts = bfin_spi_flash_partitions,
68 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
69 .type = "m25p64",
70};
71
72/* SPI flash chip (m25p64) */
73static struct bfin5xx_spi_chip spi_flash_chip_info = {
74 .enable_dma = 0, /* use dma transfer with this chip*/
75 .bits_per_word = 8,
76};
77
78/* SPI ADC chip */
79static struct bfin5xx_spi_chip spi_adc_chip_info = {
80 .enable_dma = 1, /* use dma transfer with this chip*/
81 .bits_per_word = 16,
82};
83
84#if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
85static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
86 .enable_dma = 0,
87 .bits_per_word = 16,
88};
89#endif
90
91static struct spi_board_info bfin_spi_board_info[] __initdata = {
92 {
93 /* the modalias must be the same as spi device driver name */
94 .modalias = "m25p80", /* Name of spi_driver for this device */
95 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
96 .bus_num = 1, /* Framework bus number */
97 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
98 .platform_data = &bfin_spi_flash_data,
99 .controller_data = &spi_flash_chip_info,
100 .mode = SPI_MODE_3,
101 },{
102 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
103 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
104 .bus_num = 1, /* Framework bus number */
105 .chip_select = 2, /* Framework chip select. */
106 .platform_data = NULL, /* No spi_driver specific config */
107 .controller_data = &spi_adc_chip_info,
108 },
109#if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
110 {
111 .modalias = "ad1836-spi",
112 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
113 .bus_num = 1,
114 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
115 .controller_data = &ad1836_spi_chip_info,
116 },
117#endif
118};
119
120/* SPI controller data */
121static struct bfin5xx_spi_master spi_bfin_master_info = {
122 .num_chipselect = 8,
123 .enable_dma = 1, /* master has the ability to do dma transfer */
124};
125
126static struct platform_device spi_bfin_master_device = {
127 .name = "bfin-spi-master",
128 .id = 1, /* Bus number */
129 .dev = {
130 .platform_data = &spi_bfin_master_info, /* Passed to driver */
131 },
132};
133#endif /* spi master and devices */
134
135#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
136static struct platform_device rtc_device = {
137 .name = "rtc-bfin",
138 .id = -1,
139};
140#endif
141
142#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
143static struct resource smc91x_resources[] = {
144 {
145 .start = 0x20200300,
146 .end = 0x20200300 + 16,
147 .flags = IORESOURCE_MEM,
148 },{
149 .start = IRQ_PF0,
150 .end = IRQ_PF0,
151 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
152 },
153};
154static struct platform_device smc91x_device = {
155 .name = "smc91x",
156 .id = 0,
157 .num_resources = ARRAY_SIZE(smc91x_resources),
158 .resource = smc91x_resources,
159};
160#endif
161
162#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
163static struct resource bfin_uart_resources[] = {
164 {
165 .start = 0xFFC00400,
166 .end = 0xFFC004FF,
167 .flags = IORESOURCE_MEM,
168 },
169};
170
171static struct platform_device bfin_uart_device = {
172 .name = "bfin-uart",
173 .id = 1,
174 .num_resources = ARRAY_SIZE(bfin_uart_resources),
175 .resource = bfin_uart_resources,
176};
177#endif
178
179#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
180static struct platform_device bfin_sport0_uart_device = {
181 .name = "bfin-sport-uart",
182 .id = 0,
183};
184
185static struct platform_device bfin_sport1_uart_device = {
186 .name = "bfin-sport-uart",
187 .id = 1,
188};
189#endif
190
191#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
192static struct resource isp1362_hcd_resources[] = {
193 {
194 .start = 0x20308000,
195 .end = 0x20308000,
196 .flags = IORESOURCE_MEM,
197 },{
198 .start = 0x20308004,
199 .end = 0x20308004,
200 .flags = IORESOURCE_MEM,
201 },{
202 .start = IRQ_PF4,
203 .end = IRQ_PF4,
204 .flags = IORESOURCE_IRQ,
205 },
206};
207
208static struct isp1362_platform_data isp1362_priv = {
209 .sel15Kres = 1,
210 .clknotstop = 0,
211 .oc_enable = 0,
212 .int_act_high = 0,
213 .int_edge_triggered = 0,
214 .remote_wakeup_connected = 0,
215 .no_power_switching = 1,
216 .power_switching_mode = 0,
217};
218
219static struct platform_device isp1362_hcd_device = {
220 .name = "isp1362-hcd",
221 .id = 0,
222 .dev = {
223 .platform_data = &isp1362_priv,
224 },
225 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
226 .resource = isp1362_hcd_resources,
227};
228#endif
229
230static struct platform_device *cm_bf533_devices[] __initdata = {
231#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
232 &bfin_uart_device,
233#endif
234
235#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
236 &bfin_sport0_uart_device,
237 &bfin_sport1_uart_device,
238#endif
239
240#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
241 &rtc_device,
242#endif
243
244#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
245 &isp1362_hcd_device,
246#endif
247
248#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
249 &smc91x_device,
250#endif
251
252#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
253 &spi_bfin_master_device,
254#endif
255};
256
257static int __init cm_bf533_init(void)
258{
259 printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
260 platform_add_devices(cm_bf533_devices, ARRAY_SIZE(cm_bf533_devices));
261#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
262 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
263#endif
264 return 0;
265}
266
267arch_initcall(cm_bf533_init);
diff --git a/arch/blackfin/mach-bf533/boards/ezkit.c b/arch/blackfin/mach-bf533/boards/ezkit.c
new file mode 100644
index 000000000000..747298ea907b
--- /dev/null
+++ b/arch/blackfin/mach-bf533/boards/ezkit.c
@@ -0,0 +1,224 @@
1/*
2 * File: arch/blackfin/mach-bf533/ezkit.c
3 * Based on: Orginal Work
4 * Author: Aidan Williams <aidan@nicta.com.au>
5 *
6 * Created: 2005
7 * Description:
8 *
9 * Modified: Robin Getz <rgetz@blackfin.uclinux.org> - Named the boards
10 * Copyright 2005 National ICT Australia (NICTA)
11 * Copyright 2004-2006 Analog Devices Inc.
12 *
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, see the file COPYING, or write
27 * to the Free Software Foundation, Inc.,
28 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 */
30
31#include <linux/device.h>
32#include <linux/platform_device.h>
33#include <linux/mtd/mtd.h>
34#include <linux/mtd/partitions.h>
35#include <linux/spi/spi.h>
36#include <linux/spi/flash.h>
37#include <linux/usb_isp1362.h>
38#include <asm/irq.h>
39#include <asm/bfin5xx_spi.h>
40
41/*
42 * Name the Board for the /proc/cpuinfo
43 */
44char *bfin_board_name = "ADDS-BF533-EZKIT";
45
46#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
47static struct platform_device rtc_device = {
48 .name = "rtc-bfin",
49 .id = -1,
50};
51#endif
52
53/*
54 * USB-LAN EzExtender board
55 * Driver needs to know address, irq and flag pin.
56 */
57#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
58static struct resource smc91x_resources[] = {
59 {
60 .name = "smc91x-regs",
61 .start = 0x20310300,
62 .end = 0x20310300 + 16,
63 .flags = IORESOURCE_MEM,
64 },{
65 .start = IRQ_PF9,
66 .end = IRQ_PF9,
67 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
68 },
69};
70static struct platform_device smc91x_device = {
71 .name = "smc91x",
72 .id = 0,
73 .num_resources = ARRAY_SIZE(smc91x_resources),
74 .resource = smc91x_resources,
75};
76#endif
77
78#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
79/* all SPI peripherals info goes here */
80
81#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
82static struct mtd_partition bfin_spi_flash_partitions[] = {
83 {
84 .name = "bootloader",
85 .size = 0x00020000,
86 .offset = 0,
87 .mask_flags = MTD_CAP_ROM
88 },{
89 .name = "kernel",
90 .size = 0xe0000,
91 .offset = 0x20000
92 },{
93 .name = "file system",
94 .size = 0x700000,
95 .offset = 0x00100000,
96 }
97};
98
99static struct flash_platform_data bfin_spi_flash_data = {
100 .name = "m25p80",
101 .parts = bfin_spi_flash_partitions,
102 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
103 .type = "m25p64",
104};
105
106/* SPI flash chip (m25p64) */
107static struct bfin5xx_spi_chip spi_flash_chip_info = {
108 .enable_dma = 0, /* use dma transfer with this chip*/
109 .bits_per_word = 8,
110};
111#endif
112
113#if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
114/* SPI ADC chip */
115static struct bfin5xx_spi_chip spi_adc_chip_info = {
116 .enable_dma = 1, /* use dma transfer with this chip*/
117 .bits_per_word = 16,
118};
119#endif
120
121#if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
122static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
123 .enable_dma = 0,
124 .bits_per_word = 16,
125};
126#endif
127
128static struct spi_board_info bfin_spi_board_info[] __initdata = {
129#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
130 {
131 /* the modalias must be the same as spi device driver name */
132 .modalias = "m25p80", /* Name of spi_driver for this device */
133 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
134 .bus_num = 1, /* Framework bus number */
135 .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
136 .platform_data = &bfin_spi_flash_data,
137 .controller_data = &spi_flash_chip_info,
138 .mode = SPI_MODE_3,
139 },
140#endif
141
142#if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
143 {
144 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
145 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
146 .bus_num = 1, /* Framework bus number */
147 .chip_select = 1, /* Framework chip select. */
148 .platform_data = NULL, /* No spi_driver specific config */
149 .controller_data = &spi_adc_chip_info,
150 },
151#endif
152
153#if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
154 {
155 .modalias = "ad1836-spi",
156 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
157 .bus_num = 1,
158 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
159 .controller_data = &ad1836_spi_chip_info,
160 },
161#endif
162};
163
164/* SPI controller data */
165static struct bfin5xx_spi_master spi_bfin_master_info = {
166 .num_chipselect = 8,
167 .enable_dma = 1, /* master has the ability to do dma transfer */
168};
169
170static struct platform_device spi_bfin_master_device = {
171 .name = "bfin-spi-master",
172 .id = 1, /* Bus number */
173 .dev = {
174 .platform_data = &spi_bfin_master_info, /* Passed to driver */
175 },
176};
177#endif /* spi master and devices */
178
179#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
180static struct resource bfin_uart_resources[] = {
181 {
182 .start = 0xFFC00400,
183 .end = 0xFFC004FF,
184 .flags = IORESOURCE_MEM,
185 },
186};
187
188static struct platform_device bfin_uart_device = {
189 .name = "bfin-uart",
190 .id = 1,
191 .num_resources = ARRAY_SIZE(bfin_uart_resources),
192 .resource = bfin_uart_resources,
193};
194#endif
195
196static struct platform_device *ezkit_devices[] __initdata = {
197#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
198 &smc91x_device,
199#endif
200
201#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
202 &spi_bfin_master_device,
203#endif
204
205#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
206 &rtc_device,
207#endif
208
209#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
210 &bfin_uart_device,
211#endif
212};
213
214static int __init ezkit_init(void)
215{
216 printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
217 platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
218#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
219 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
220#endif
221 return 0;
222}
223
224arch_initcall(ezkit_init);
diff --git a/arch/blackfin/mach-bf533/boards/generic_board.c b/arch/blackfin/mach-bf533/boards/generic_board.c
new file mode 100644
index 000000000000..c0f43ccfbfb5
--- /dev/null
+++ b/arch/blackfin/mach-bf533/boards/generic_board.c
@@ -0,0 +1,95 @@
1/*
2 * File: arch/blackfin/mach-bf533/generic_board.c
3 * Based on: arch/blackfin/mach-bf533/ezkit.c
4 * Author: Aidan Williams <aidan@nicta.com.au>
5 *
6 * Created: 2005
7 * Description:
8 *
9 * Modified:
10 * Copyright 2005 National ICT Australia (NICTA)
11 * Copyright 2004-2006 Analog Devices Inc.
12 *
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, see the file COPYING, or write
27 * to the Free Software Foundation, Inc.,
28 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 */
30
31#include <linux/device.h>
32#include <linux/platform_device.h>
33#include <asm/irq.h>
34
35/*
36 * Name the Board for the /proc/cpuinfo
37 */
38char *bfin_board_name = "UNKNOWN BOARD";
39
40#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
41static struct platform_device rtc_device = {
42 .name = "rtc-bfin",
43 .id = -1,
44};
45#endif
46
47/*
48 * Driver needs to know address, irq and flag pin.
49 */
50#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
51static struct resource smc91x_resources[] = {
52 {
53 .start = 0x20300300,
54 .end = 0x20300300 + 16,
55 .flags = IORESOURCE_MEM,
56 },{
57 .start = IRQ_PROG_INTB,
58 .end = IRQ_PROG_INTB,
59 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
60 },{
61 /*
62 * denotes the flag pin and is used directly if
63 * CONFIG_IRQCHIP_DEMUX_GPIO is defined.
64 */
65 .start = IRQ_PF7,
66 .end = IRQ_PF7,
67 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
68 },
69};
70
71static struct platform_device smc91x_device = {
72 .name = "smc91x",
73 .id = 0,
74 .num_resources = ARRAY_SIZE(smc91x_resources),
75 .resource = smc91x_resources,
76};
77#endif
78
79static struct platform_device *generic_board_devices[] __initdata = {
80#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
81 &rtc_device,
82#endif
83
84#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
85 &smc91x_device,
86#endif
87};
88
89static int __init generic_board_init(void)
90{
91 printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
92 return platform_add_devices(generic_board_devices, ARRAY_SIZE(generic_board_devices));
93}
94
95arch_initcall(generic_board_init);
diff --git a/arch/blackfin/mach-bf533/boards/stamp.c b/arch/blackfin/mach-bf533/boards/stamp.c
new file mode 100644
index 000000000000..d7b3a5d74e8c
--- /dev/null
+++ b/arch/blackfin/mach-bf533/boards/stamp.c
@@ -0,0 +1,321 @@
1/*
2 * File: arch/blackfin/mach-bf533/stamp.c
3 * Based on: arch/blackfin/mach-bf533/ezkit.c
4 * Author: Aidan Williams <aidan@nicta.com.au>
5 *
6 * Created: 2005
7 * Description: Board Info File for the BF533-STAMP
8 *
9 * Modified:
10 * Copyright 2005 National ICT Australia (NICTA)
11 * Copyright 2004-2006 Analog Devices Inc.
12 *
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, see the file COPYING, or write
27 * to the Free Software Foundation, Inc.,
28 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 */
30
31#include <linux/device.h>
32#include <linux/platform_device.h>
33#include <linux/mtd/mtd.h>
34#include <linux/mtd/partitions.h>
35#include <linux/spi/spi.h>
36#include <linux/spi/flash.h>
37#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
38#include <linux/usb_isp1362.h>
39#endif
40#include <asm/irq.h>
41#include <asm/bfin5xx_spi.h>
42
43/*
44 * Name the Board for the /proc/cpuinfo
45 */
46char *bfin_board_name = "ADDS-BF533-STAMP";
47
48#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
49static struct platform_device rtc_device = {
50 .name = "rtc-bfin",
51 .id = -1,
52};
53#endif
54
55/*
56 * Driver needs to know address, irq and flag pin.
57 */
58#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
59static struct resource smc91x_resources[] = {
60 {
61 .name = "smc91x-regs",
62 .start = 0x20300300,
63 .end = 0x20300300 + 16,
64 .flags = IORESOURCE_MEM,
65 },{
66 .start = IRQ_PF7,
67 .end = IRQ_PF7,
68 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
69 },
70};
71
72static struct platform_device smc91x_device = {
73 .name = "smc91x",
74 .id = 0,
75 .num_resources = ARRAY_SIZE(smc91x_resources),
76 .resource = smc91x_resources,
77};
78#endif
79
80#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
81static struct resource net2272_bfin_resources[] = {
82 {
83 .start = 0x20300000,
84 .end = 0x20300000 + 0x100,
85 .flags = IORESOURCE_MEM,
86 },{
87 .start = IRQ_PF10,
88 .end = IRQ_PF10,
89 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
90 },
91};
92
93static struct platform_device net2272_bfin_device = {
94 .name = "net2272",
95 .id = -1,
96 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
97 .resource = net2272_bfin_resources,
98};
99#endif
100
101#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
102/* all SPI peripherals info goes here */
103
104#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
105static struct mtd_partition bfin_spi_flash_partitions[] = {
106 {
107 .name = "bootloader",
108 .size = 0x00020000,
109 .offset = 0,
110 .mask_flags = MTD_CAP_ROM
111 },{
112 .name = "kernel",
113 .size = 0xe0000,
114 .offset = 0x20000
115 },{
116 .name = "file system",
117 .size = 0x700000,
118 .offset = 0x00100000,
119 }
120};
121
122static struct flash_platform_data bfin_spi_flash_data = {
123 .name = "m25p80",
124 .parts = bfin_spi_flash_partitions,
125 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
126 .type = "m25p64",
127};
128
129/* SPI flash chip (m25p64) */
130static struct bfin5xx_spi_chip spi_flash_chip_info = {
131 .enable_dma = 0, /* use dma transfer with this chip*/
132 .bits_per_word = 8,
133};
134#endif
135
136#if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
137/* SPI ADC chip */
138static struct bfin5xx_spi_chip spi_adc_chip_info = {
139 .enable_dma = 1, /* use dma transfer with this chip*/
140 .bits_per_word = 16,
141};
142#endif
143
144#if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
145static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
146 .enable_dma = 0,
147 .bits_per_word = 16,
148};
149#endif
150
151#if defined(CONFIG_PBX)
152static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
153 .ctl_reg = 0x4, /* send zero */
154 .enable_dma = 0,
155 .bits_per_word = 8,
156 .cs_change_per_word = 1,
157};
158#endif
159
160#if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
161static struct bfin5xx_spi_chip ad5304_chip_info = {
162 .enable_dma = 0,
163 .bits_per_word = 16,
164};
165#endif
166
167static struct spi_board_info bfin_spi_board_info[] __initdata = {
168#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
169 {
170 /* the modalias must be the same as spi device driver name */
171 .modalias = "m25p80", /* Name of spi_driver for this device */
172 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
173 .bus_num = 1, /* Framework bus number */
174 .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
175 .platform_data = &bfin_spi_flash_data,
176 .controller_data = &spi_flash_chip_info,
177 .mode = SPI_MODE_3,
178 },
179#endif
180
181#if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
182 {
183 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
184 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
185 .bus_num = 1, /* Framework bus number */
186 .chip_select = 1, /* Framework chip select. */
187 .platform_data = NULL, /* No spi_driver specific config */
188 .controller_data = &spi_adc_chip_info,
189 },
190#endif
191
192#if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
193 {
194 .modalias = "ad1836-spi",
195 .max_speed_hz = 31250000, /* max spi clock (SCK) speed in HZ */
196 .bus_num = 1,
197 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
198 .controller_data = &ad1836_spi_chip_info,
199 },
200#endif
201
202#if defined(CONFIG_PBX)
203 {
204 .modalias = "fxs-spi",
205 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
206 .bus_num = 1,
207 .chip_select = 3,
208 .controller_data= &spi_si3xxx_chip_info,
209 .mode = SPI_MODE_3,
210 },
211 {
212 .modalias = "fxo-spi",
213 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
214 .bus_num = 1,
215 .chip_select = 2,
216 .controller_data= &spi_si3xxx_chip_info,
217 .mode = SPI_MODE_3,
218 },
219#endif
220
221#if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
222 {
223 .modalias = "ad5304_spi",
224 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
225 .bus_num = 1,
226 .chip_select = 2,
227 .platform_data = NULL,
228 .controller_data = &ad5304_chip_info,
229 .mode = SPI_MODE_2,
230 },
231#endif
232};
233
234/* SPI controller data */
235static struct bfin5xx_spi_master spi_bfin_master_info = {
236 .num_chipselect = 8,
237 .enable_dma = 1, /* master has the ability to do dma transfer */
238};
239
240static struct platform_device spi_bfin_master_device = {
241 .name = "bfin-spi-master",
242 .id = 1, /* Bus number */
243 .dev = {
244 .platform_data = &spi_bfin_master_info, /* Passed to driver */
245 },
246};
247#endif /* spi master and devices */
248
249#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
250static struct platform_device bfin_fb_device = {
251 .name = "bf537-fb",
252};
253#endif
254
255#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
256static struct resource bfin_uart_resources[] = {
257 {
258 .start = 0xFFC00400,
259 .end = 0xFFC004FF,
260 .flags = IORESOURCE_MEM,
261 },
262};
263
264static struct platform_device bfin_uart_device = {
265 .name = "bfin-uart",
266 .id = 1,
267 .num_resources = ARRAY_SIZE(bfin_uart_resources),
268 .resource = bfin_uart_resources,
269};
270#endif
271
272#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
273static struct platform_device bfin_sport0_uart_device = {
274 .name = "bfin-sport-uart",
275 .id = 0,
276};
277
278static struct platform_device bfin_sport1_uart_device = {
279 .name = "bfin-sport-uart",
280 .id = 1,
281};
282#endif
283
284static struct platform_device *stamp_devices[] __initdata = {
285#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
286 &rtc_device,
287#endif
288
289#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
290 &smc91x_device,
291#endif
292
293#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
294 &net2272_bfin_device,
295#endif
296
297#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
298 &spi_bfin_master_device,
299#endif
300
301#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
302 &bfin_uart_device,
303#endif
304
305#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
306 &bfin_sport0_uart_device,
307 &bfin_sport1_uart_device,
308#endif
309};
310
311static int __init stamp_init(void)
312{
313 printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
314 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
315#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
316 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
317#endif
318 return 0;
319}
320
321arch_initcall(stamp_init);
diff --git a/arch/blackfin/mach-bf533/cpu.c b/arch/blackfin/mach-bf533/cpu.c
new file mode 100644
index 000000000000..99547c4c290e
--- /dev/null
+++ b/arch/blackfin/mach-bf533/cpu.c
@@ -0,0 +1,161 @@
1/*
2 * File: arch/blackfin/mach-bf533/cpu.c
3 * Based on:
4 * Author: michael.kang@analog.com
5 *
6 * Created:
7 * Description: clock scaling for the bf533
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/kernel.h>
31#include <linux/types.h>
32#include <linux/init.h>
33#include <linux/cpufreq.h>
34#include <asm/dpmc.h>
35#include <linux/fs.h>
36#include <asm/bfin-global.h>
37
38/* CONFIG_CLKIN_HZ=11059200 */
39#define VCO5 (CONFIG_CLKIN_HZ*45) /*497664000 */
40#define VCO4 (CONFIG_CLKIN_HZ*36) /*398131200 */
41#define VCO3 (CONFIG_CLKIN_HZ*27) /*298598400 */
42#define VCO2 (CONFIG_CLKIN_HZ*18) /*199065600 */
43#define VCO1 (CONFIG_CLKIN_HZ*9) /*99532800 */
44#define VCO(x) VCO##x
45
46#define FREQ(x) {VCO(x),VCO(x)/4},{VCO(x),VCO(x)/2},{VCO(x),VCO(x)}
47/* frequency */
48static struct cpufreq_frequency_table bf533_freq_table[] = {
49 FREQ(1),
50 FREQ(3),
51 {VCO4, VCO4 / 2}, {VCO4, VCO4},
52 FREQ(5),
53 {0, CPUFREQ_TABLE_END},
54};
55
56/*
57 * dpmc_fops->ioctl()
58 * static int dpmc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
59 */
60static int bf533_getfreq(unsigned int cpu)
61{
62 unsigned long cclk_mhz, vco_mhz;
63
64 /* The driver only support single cpu */
65 if (cpu == 0)
66 dpmc_fops.ioctl(NULL, NULL, IOCTL_GET_CORECLOCK, &cclk_mhz);
67 else
68 cclk_mhz = -1;
69 return cclk_mhz;
70}
71
72static int bf533_target(struct cpufreq_policy *policy,
73 unsigned int target_freq, unsigned int relation)
74{
75 unsigned long cclk_mhz;
76 unsigned long vco_mhz;
77 unsigned long flags;
78 unsigned int index, vco_index;
79 int i;
80
81 struct cpufreq_freqs freqs;
82 if (cpufreq_frequency_table_target
83 (policy, bf533_freq_table, target_freq, relation, &index))
84 return -EINVAL;
85 cclk_mhz = bf533_freq_table[index].frequency;
86 vco_mhz = bf533_freq_table[index].index;
87
88 dpmc_fops.ioctl(NULL, NULL, IOCTL_CHANGE_FREQUENCY, &vco_mhz);
89 freqs.old = bf533_getfreq(0);
90 freqs.new = cclk_mhz;
91 freqs.cpu = 0;
92
93 pr_debug("cclk begin change to cclk %d,vco=%d,index=%d,target=%d,oldfreq=%d\n",
94 cclk_mhz, vco_mhz, index, target_freq, freqs.old);
95
96 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
97 local_irq_save(flags);
98 dpmc_fops.ioctl(NULL, NULL, IOCTL_SET_CCLK, &cclk_mhz);
99 local_irq_restore(flags);
100 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
101
102 vco_mhz = get_vco();
103 cclk_mhz = get_cclk();
104 return 0;
105}
106
107/* make sure that only the "userspace" governor is run -- anything else wouldn't make sense on
108 * this platform, anyway.
109 */
110static int bf533_verify_speed(struct cpufreq_policy *policy)
111{
112 return cpufreq_frequency_table_verify(policy, &bf533_freq_table);
113}
114
115static int __init __bf533_cpu_init(struct cpufreq_policy *policy)
116{
117 int result;
118
119 if (policy->cpu != 0)
120 return -EINVAL;
121
122 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
123
124 policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
125 /*Now ,only support one cpu */
126 policy->cur = bf533_getfreq(0);
127 cpufreq_frequency_table_get_attr(bf533_freq_table, policy->cpu);
128 return cpufreq_frequency_table_cpuinfo(policy, bf533_freq_table);
129}
130
131static struct freq_attr *bf533_freq_attr[] = {
132 &cpufreq_freq_attr_scaling_available_freqs,
133 NULL,
134};
135
136static struct cpufreq_driver bf533_driver = {
137 .verify = bf533_verify_speed,
138 .target = bf533_target,
139 .get = bf533_getfreq,
140 .init = __bf533_cpu_init,
141 .name = "bf533",
142 .owner = THIS_MODULE,
143 .attr = bf533_freq_attr,
144};
145
146static int __init bf533_cpu_init(void)
147{
148 return cpufreq_register_driver(&bf533_driver);
149}
150
151static void __exit bf533_cpu_exit(void)
152{
153 cpufreq_unregister_driver(&bf533_driver);
154}
155
156MODULE_AUTHOR("Mickael Kang");
157MODULE_DESCRIPTION("cpufreq driver for BF533 CPU");
158MODULE_LICENSE("GPL");
159
160module_init(bf533_cpu_init);
161module_exit(bf533_cpu_exit);
diff --git a/arch/blackfin/mach-bf533/head.S b/arch/blackfin/mach-bf533/head.S
new file mode 100644
index 000000000000..4808edb0680f
--- /dev/null
+++ b/arch/blackfin/mach-bf533/head.S
@@ -0,0 +1,774 @@
1/*
2 * File: arch/blackfin/mach-bf533/head.S
3 * Based on:
4 * Author: Jeff Dionne <jeff@uclinux.org> COPYRIGHT 1998 D. Jeff Dionne
5 *
6 * Created: 1998
7 * Description: bf533 startup file
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/linkage.h>
31#include <asm/blackfin.h>
32#if CONFIG_BFIN_KERNEL_CLOCK
33#include <asm/mach/mem_init.h>
34#endif
35#if CONFIG_DEBUG_KERNEL_START
36#include <asm/mach-common/def_LPBlackfin.h>
37#endif
38
39.global __rambase
40.global __ramstart
41.global __ramend
42.extern ___bss_stop
43.extern ___bss_start
44.extern _bf53x_relocate_l1_mem
45
46#define INITIAL_STACK 0xFFB01000
47
48.text
49
50ENTRY(__start)
51ENTRY(__stext)
52 /* R0: argument of command line string, passed from uboot, save it */
53 R7 = R0;
54 /* Set the SYSCFG register */
55 R0 = 0x36;
56 /*Enable Cycle Counter and Nesting Of Interrupts(3rd Bit)*/
57 SYSCFG = R0;
58 R0 = 0;
59
60 /*Clear Out All the data and pointer Registers*/
61 R1 = R0;
62 R2 = R0;
63 R3 = R0;
64 R4 = R0;
65 R5 = R0;
66 R6 = R0;
67
68 P0 = R0;
69 P1 = R0;
70 P2 = R0;
71 P3 = R0;
72 P4 = R0;
73 P5 = R0;
74
75 LC0 = r0;
76 LC1 = r0;
77 L0 = r0;
78 L1 = r0;
79 L2 = r0;
80 L3 = r0;
81
82 /* Clear Out All the DAG Registers*/
83 B0 = r0;
84 B1 = r0;
85 B2 = r0;
86 B3 = r0;
87
88 I0 = r0;
89 I1 = r0;
90 I2 = r0;
91 I3 = r0;
92
93 M0 = r0;
94 M1 = r0;
95 M2 = r0;
96 M3 = r0;
97
98#if CONFIG_DEBUG_KERNEL_START
99
100/*
101 * Set up a temporary Event Vector Table, so if something bad happens before
102 * the kernel is fully started, it doesn't vector off into the bootloaders
103 * table
104 */
105 P0.l = lo(EVT2);
106 P0.h = hi(EVT2);
107 P1.l = lo(EVT15);
108 P1.h = hi(EVT15);
109 P2.l = debug_kernel_start_trap;
110 P2.h = debug_kernel_start_trap;
111
112 RTS = P2;
113 RTI = P2;
114 RTX = P2;
115 RTN = P2;
116 RTE = P2;
117
118.Lfill_temp_vector_table:
119 [P0++] = P2; /* Core Event Vector Table */
120 CC = P0 == P1;
121 if !CC JUMP .Lfill_temp_vector_table
122 P0 = r0;
123 P1 = r0;
124 P2 = r0;
125
126#endif
127
128 p0.h = hi(FIO_MASKA_C);
129 p0.l = lo(FIO_MASKA_C);
130 r0 = 0xFFFF(Z);
131 w[p0] = r0.L; /* Disable all interrupts */
132 ssync;
133
134 p0.h = hi(FIO_MASKB_C);
135 p0.l = lo(FIO_MASKB_C);
136 r0 = 0xFFFF(Z);
137 w[p0] = r0.L; /* Disable all interrupts */
138 ssync;
139
140 /* Turn off the icache */
141 p0.l = (IMEM_CONTROL & 0xFFFF);
142 p0.h = (IMEM_CONTROL >> 16);
143 R1 = [p0];
144 R0 = ~ENICPLB;
145 R0 = R0 & R1;
146
147 /* Anomaly 05000125 */
148#ifdef ANOMALY_05000125
149 CLI R2;
150 SSYNC;
151#endif
152 [p0] = R0;
153 SSYNC;
154#ifdef ANOMALY_05000125
155 STI R2;
156#endif
157
158 /* Turn off the dcache */
159 p0.l = (DMEM_CONTROL & 0xFFFF);
160 p0.h = (DMEM_CONTROL >> 16);
161 R1 = [p0];
162 R0 = ~ENDCPLB;
163 R0 = R0 & R1;
164
165 /* Anomaly 05000125 */
166#ifdef ANOMALY_05000125
167 CLI R2;
168 SSYNC;
169#endif
170 [p0] = R0;
171 SSYNC;
172#ifdef ANOMALY_05000125
173 STI R2;
174#endif
175
176 /* Initialise UART */
177 p0.h = hi(UART_LCR);
178 p0.l = lo(UART_LCR);
179 r0 = 0x0(Z);
180 w[p0] = r0.L; /* To enable DLL writes */
181 ssync;
182
183 p0.h = hi(UART_DLL);
184 p0.l = lo(UART_DLL);
185 r0 = 0x0(Z);
186 w[p0] = r0.L;
187 ssync;
188
189 p0.h = hi(UART_DLH);
190 p0.l = lo(UART_DLH);
191 r0 = 0x00(Z);
192 w[p0] = r0.L;
193 ssync;
194
195 p0.h = hi(UART_GCTL);
196 p0.l = lo(UART_GCTL);
197 r0 = 0x0(Z);
198 w[p0] = r0.L; /* To enable UART clock */
199 ssync;
200
201 /* Initialize stack pointer */
202 sp.l = lo(INITIAL_STACK);
203 sp.h = hi(INITIAL_STACK);
204 fp = sp;
205 usp = sp;
206
207 /* Put The Code for PLL Programming and SDRAM Programming in L1 ISRAM */
208 call _bf53x_relocate_l1_mem;
209#if CONFIG_BFIN_KERNEL_CLOCK
210 call _start_dma_code;
211#endif
212
213 /* Code for initializing Async memory banks */
214
215 p2.h = hi(EBIU_AMBCTL1);
216 p2.l = lo(EBIU_AMBCTL1);
217 r0.h = hi(AMBCTL1VAL);
218 r0.l = lo(AMBCTL1VAL);
219 [p2] = r0;
220 ssync;
221
222 p2.h = hi(EBIU_AMBCTL0);
223 p2.l = lo(EBIU_AMBCTL0);
224 r0.h = hi(AMBCTL0VAL);
225 r0.l = lo(AMBCTL0VAL);
226 [p2] = r0;
227 ssync;
228
229 p2.h = hi(EBIU_AMGCTL);
230 p2.l = lo(EBIU_AMGCTL);
231 r0 = AMGCTLVAL;
232 w[p2] = r0;
233 ssync;
234
235 /* This section keeps the processor in supervisor mode
236 * during kernel boot. Switches to user mode at end of boot.
237 * See page 3-9 of Hardware Reference manual for documentation.
238 */
239
240 /* EVT15 = _real_start */
241
242 p0.l = lo(EVT15);
243 p0.h = hi(EVT15);
244 p1.l = _real_start;
245 p1.h = _real_start;
246 [p0] = p1;
247 csync;
248
249 p0.l = lo(IMASK);
250 p0.h = hi(IMASK);
251 p1.l = IMASK_IVG15;
252 p1.h = 0x0;
253 [p0] = p1;
254 csync;
255
256 raise 15;
257 p0.l = .LWAIT_HERE;
258 p0.h = .LWAIT_HERE;
259 reti = p0;
260#if defined(ANOMALY_05000281)
261 nop; nop; nop;
262#endif
263 rti;
264
265.LWAIT_HERE:
266 jump .LWAIT_HERE;
267
268ENTRY(_real_start)
269 [ -- sp ] = reti;
270 p0.l = lo(WDOG_CTL);
271 p0.h = hi(WDOG_CTL);
272 r0 = 0xAD6(z);
273 w[p0] = r0; /* watchdog off for now */
274 ssync;
275
276 /* Code update for BSS size == 0
277 * Zero out the bss region.
278 */
279
280 p1.l = ___bss_start;
281 p1.h = ___bss_start;
282 p2.l = ___bss_stop;
283 p2.h = ___bss_stop;
284 r0 = 0;
285 p2 -= p1;
286 lsetup (.L_clear_bss, .L_clear_bss) lc0 = p2;
287.L_clear_bss:
288 B[p1++] = r0;
289
290 /* In case there is a NULL pointer reference
291 * Zero out region before stext
292 */
293
294 p1.l = 0x0;
295 p1.h = 0x0;
296 r0.l = __stext;
297 r0.h = __stext;
298 r0 = r0 >> 1;
299 p2 = r0;
300 r0 = 0;
301 lsetup (.L_clear_zero, .L_clear_zero) lc0 = p2;
302.L_clear_zero:
303 W[p1++] = r0;
304
305/* pass the uboot arguments to the global value command line */
306 R0 = R7;
307 call _cmdline_init;
308
309 p1.l = __rambase;
310 p1.h = __rambase;
311 r0.l = __sdata;
312 r0.h = __sdata;
313 [p1] = r0;
314
315 p1.l = __ramstart;
316 p1.h = __ramstart;
317 p3.l = ___bss_stop;
318 p3.h = ___bss_stop;
319
320 r1 = p3;
321 [p1] = r1;
322
323 /*
324 * load the current thread pointer and stack
325 */
326 r1.l = _init_thread_union;
327 r1.h = _init_thread_union;
328
329 r2.l = 0x2000;
330 r2.h = 0x0000;
331 r1 = r1 + r2;
332 sp = r1;
333 usp = sp;
334 fp = sp;
335 call _start_kernel;
336.L_exit:
337 jump.s .L_exit;
338
339.section .l1.text
340#if CONFIG_BFIN_KERNEL_CLOCK
341ENTRY(_start_dma_code)
342 p0.h = hi(SIC_IWR);
343 p0.l = lo(SIC_IWR);
344 r0.l = 0x1;
345 r0.h = 0x0;
346 [p0] = r0;
347 SSYNC;
348
349 /*
350 * Set PLL_CTL
351 * - [14:09] = MSEL[5:0] : CLKIN / VCO multiplication factors
352 * - [8] = BYPASS : BYPASS the PLL, run CLKIN into CCLK/SCLK
353 * - [7] = output delay (add 200ps of delay to mem signals)
354 * - [6] = input delay (add 200ps of input delay to mem signals)
355 * - [5] = PDWN : 1=All Clocks off
356 * - [3] = STOPCK : 1=Core Clock off
357 * - [1] = PLL_OFF : 1=Disable Power to PLL
358 * - [0] = DF : 1=Pass CLKIN/2 to PLL / 0=Pass CLKIN to PLL
359 * all other bits set to zero
360 */
361
362 p0.h = hi(PLL_LOCKCNT);
363 p0.l = lo(PLL_LOCKCNT);
364 r0 = 0x300(Z);
365 w[p0] = r0.l;
366 ssync;
367
368 P2.H = hi(EBIU_SDGCTL);
369 P2.L = lo(EBIU_SDGCTL);
370 R0 = [P2];
371 BITSET (R0, 24);
372 [P2] = R0;
373 SSYNC;
374
375 r0 = CONFIG_VCO_MULT & 63; /* Load the VCO multiplier */
376 r0 = r0 << 9; /* Shift it over, */
377 r1 = CLKIN_HALF; /* Do we need to divide CLKIN by 2?*/
378 r0 = r1 | r0;
379 r1 = PLL_BYPASS; /* Bypass the PLL? */
380 r1 = r1 << 8; /* Shift it over */
381 r0 = r1 | r0; /* add them all together */
382
383 p0.h = hi(PLL_CTL);
384 p0.l = lo(PLL_CTL); /* Load the address */
385 cli r2; /* Disable interrupts */
386 ssync;
387 w[p0] = r0.l; /* Set the value */
388 idle; /* Wait for the PLL to stablize */
389 sti r2; /* Enable interrupts */
390
391.Lcheck_again:
392 p0.h = hi(PLL_STAT);
393 p0.l = lo(PLL_STAT);
394 R0 = W[P0](Z);
395 CC = BITTST(R0,5);
396 if ! CC jump .Lcheck_again;
397
398 /* Configure SCLK & CCLK Dividers */
399 r0 = (CONFIG_CCLK_ACT_DIV | CONFIG_SCLK_DIV);
400 p0.h = hi(PLL_DIV);
401 p0.l = lo(PLL_DIV);
402 w[p0] = r0.l;
403 ssync;
404
405 p0.l = lo(EBIU_SDRRC);
406 p0.h = hi(EBIU_SDRRC);
407 r0 = mem_SDRRC;
408 w[p0] = r0.l;
409 ssync;
410
411 p0.l = (EBIU_SDBCTL & 0xFFFF);
412 p0.h = (EBIU_SDBCTL >> 16); /* SDRAM Memory Bank Control Register */
413 r0 = mem_SDBCTL;
414 w[p0] = r0.l;
415 ssync;
416
417 P2.H = hi(EBIU_SDGCTL);
418 P2.L = lo(EBIU_SDGCTL);
419 R0 = [P2];
420 BITCLR (R0, 24);
421 p0.h = hi(EBIU_SDSTAT);
422 p0.l = lo(EBIU_SDSTAT);
423 r2.l = w[p0];
424 cc = bittst(r2,3);
425 if !cc jump .Lskip;
426 NOP;
427 BITSET (R0, 23);
428.Lskip:
429 [P2] = R0;
430 SSYNC;
431
432 R0.L = lo(mem_SDGCTL);
433 R0.H = hi(mem_SDGCTL);
434 R1 = [p2];
435 R1 = R1 | R0;
436 [P2] = R1;
437 SSYNC;
438
439 p0.h = hi(SIC_IWR);
440 p0.l = lo(SIC_IWR);
441 r0.l = lo(IWR_ENABLE_ALL)
442 r0.h = hi(IWR_ENABLE_ALL)
443 [p0] = r0;
444 SSYNC;
445
446 RTS;
447#endif /* CONFIG_BFIN_KERNEL_CLOCK */
448
449ENTRY(_bfin_reset)
450 /* No more interrupts to be handled*/
451 CLI R6;
452 SSYNC;
453
454#if defined(CONFIG_BFIN_SHARED_FLASH_ENET)
455 p0.h = hi(FIO_INEN);
456 p0.l = lo(FIO_INEN);
457 r0.l = ~(1 << CONFIG_ENET_FLASH_PIN);
458 w[p0] = r0.l;
459
460 p0.h = hi(FIO_DIR);
461 p0.l = lo(FIO_DIR);
462 r0.l = (1 << CONFIG_ENET_FLASH_PIN);
463 w[p0] = r0.l;
464
465 p0.h = hi(FIO_FLAG_C);
466 p0.l = lo(FIO_FLAG_C);
467 r0.l = (1 << CONFIG_ENET_FLASH_PIN);
468 w[p0] = r0.l;
469#endif
470
471 /* Clear the bits 13-15 in SWRST if they werent cleared */
472 p0.h = hi(SWRST);
473 p0.l = lo(SWRST);
474 csync;
475 r0.l = w[p0];
476
477 /* Clear the IMASK register */
478 p0.h = hi(IMASK);
479 p0.l = lo(IMASK);
480 r0 = 0x0;
481 [p0] = r0;
482
483 /* Clear the ILAT register */
484 p0.h = hi(ILAT);
485 p0.l = lo(ILAT);
486 r0 = [p0];
487 [p0] = r0;
488 SSYNC;
489
490 /* Disable the WDOG TIMER */
491 p0.h = hi(WDOG_CTL);
492 p0.l = lo(WDOG_CTL);
493 r0.l = 0xAD6;
494 w[p0] = r0.l;
495 SSYNC;
496
497 /* Clear the sticky bit incase it is already set */
498 p0.h = hi(WDOG_CTL);
499 p0.l = lo(WDOG_CTL);
500 r0.l = 0x8AD6;
501 w[p0] = r0.l;
502 SSYNC;
503
504 /* Program the count value */
505 R0.l = 0x100;
506 R0.h = 0x0;
507 P0.h = hi(WDOG_CNT);
508 P0.l = lo(WDOG_CNT);
509 [P0] = R0;
510 SSYNC;
511
512 /* Program WDOG_STAT if necessary */
513 P0.h = hi(WDOG_CTL);
514 P0.l = lo(WDOG_CTL);
515 R0 = W[P0](Z);
516 CC = BITTST(R0,1);
517 if !CC JUMP .LWRITESTAT;
518 CC = BITTST(R0,2);
519 if !CC JUMP .LWRITESTAT;
520 JUMP .LSKIP_WRITE;
521
522.LWRITESTAT:
523 /* When watch dog timer is enabled, a write to STAT will load the contents of CNT to STAT */
524 R0 = 0x0000(z);
525 P0.h = hi(WDOG_STAT);
526 P0.l = lo(WDOG_STAT)
527 [P0] = R0;
528 SSYNC;
529
530.LSKIP_WRITE:
531 /* Enable the reset event */
532 P0.h = hi(WDOG_CTL);
533 P0.l = lo(WDOG_CTL);
534 R0 = W[P0](Z);
535 BITCLR(R0,1);
536 BITCLR(R0,2);
537 W[P0] = R0.L;
538 SSYNC;
539 NOP;
540
541 /* Enable the wdog counter */
542 R0 = W[P0](Z);
543 BITCLR(R0,4);
544 W[P0] = R0.L;
545 SSYNC;
546
547 IDLE;
548
549 RTS;
550
551#if CONFIG_DEBUG_KERNEL_START
552debug_kernel_start_trap:
553 /* Set up a temp stack in L1 - SDRAM might not be working */
554 P0.L = lo(L1_DATA_A_START + 0x100);
555 P0.H = hi(L1_DATA_A_START + 0x100);
556 SP = P0;
557
558 /* Make sure the Clocks are the way I think they should be */
559 r0 = CONFIG_VCO_MULT & 63; /* Load the VCO multiplier */
560 r0 = r0 << 9; /* Shift it over, */
561 r1 = CLKIN_HALF; /* Do we need to divide CLKIN by 2?*/
562 r0 = r1 | r0;
563 r1 = PLL_BYPASS; /* Bypass the PLL? */
564 r1 = r1 << 8; /* Shift it over */
565 r0 = r1 | r0; /* add them all together */
566
567 p0.h = hi(PLL_CTL);
568 p0.l = lo(PLL_CTL); /* Load the address */
569 cli r2; /* Disable interrupts */
570 ssync;
571 w[p0] = r0.l; /* Set the value */
572 idle; /* Wait for the PLL to stablize */
573 sti r2; /* Enable interrupts */
574
575.Lcheck_again1:
576 p0.h = hi(PLL_STAT);
577 p0.l = lo(PLL_STAT);
578 R0 = W[P0](Z);
579 CC = BITTST(R0,5);
580 if ! CC jump .Lcheck_again1;
581
582 /* Configure SCLK & CCLK Dividers */
583 r0 = (CONFIG_CCLK_ACT_DIV | CONFIG_SCLK_DIV);
584 p0.h = hi(PLL_DIV);
585 p0.l = lo(PLL_DIV);
586 w[p0] = r0.l;
587 ssync;
588
589 /* Make sure UART is enabled - you can never be sure */
590
591/*
592 * Setup for console. Argument comes from the menuconfig
593 */
594
595#ifdef CONFIG_BAUD_9600
596#define CONSOLE_BAUD_RATE 9600
597#elif CONFIG_BAUD_19200
598#define CONSOLE_BAUD_RATE 19200
599#elif CONFIG_BAUD_38400
600#define CONSOLE_BAUD_RATE 38400
601#elif CONFIG_BAUD_57600
602#define CONSOLE_BAUD_RATE 57600
603#elif CONFIG_BAUD_115200
604#define CONSOLE_BAUD_RATE 115200
605#endif
606
607 p0.h = hi(UART_GCTL);
608 p0.l = lo(UART_GCTL);
609 r0 = 0x00(Z);
610 w[p0] = r0.L; /* To Turn off UART clocks */
611 ssync;
612
613 p0.h = hi(UART_LCR);
614 p0.l = lo(UART_LCR);
615 r0 = 0x83(Z);
616 w[p0] = r0.L; /* To enable DLL writes */
617 ssync;
618
619 R1 = (((CONFIG_CLKIN_HZ * CONFIG_VCO_MULT) / CONFIG_SCLK_DIV) / (CONSOLE_BAUD_RATE * 16));
620
621 p0.h = hi(UART_DLL);
622 p0.l = lo(UART_DLL);
623 r0 = 0xFF(Z);
624 r0 = R1 & R0;
625 w[p0] = r0.L;
626 ssync;
627
628 p0.h = hi(UART_DLH);
629 p0.l = lo(UART_DLH);
630 r1 >>= 8 ;
631 w[p0] = r1.L;
632 ssync;
633
634 p0.h = hi(UART_GCTL);
635 p0.l = lo(UART_GCTL);
636 r0 = 0x0(Z);
637 w[p0] = r0.L; /* To enable UART clock */
638 ssync;
639
640 p0.h = hi(UART_LCR);
641 p0.l = lo(UART_LCR);
642 r0 = 0x03(Z);
643 w[p0] = r0.L; /* To Turn on UART */
644 ssync;
645
646 p0.h = hi(UART_GCTL);
647 p0.l = lo(UART_GCTL);
648 r0 = 0x01(Z);
649 w[p0] = r0.L; /* To Turn on UART Clocks */
650 ssync;
651
652 P0.h = hi(UART_THR);
653 P0.l = lo(UART_THR);
654 P1.h = hi(UART_LSR);
655 P1.l = lo(UART_LSR);
656
657 R0.L = 'K';
658 call .Lwait_char;
659 R0.L='e';
660 call .Lwait_char;
661 R0.L='r';
662 call .Lwait_char;
663 R0.L='n'
664 call .Lwait_char;
665 R0.L='e'
666 call .Lwait_char;
667 R0.L='l';
668 call .Lwait_char;
669 R0.L=' ';
670 call .Lwait_char;
671 R0.L='c';
672 call .Lwait_char;
673 R0.L='r';
674 call .Lwait_char;
675 R0.L='a';
676 call .Lwait_char;
677 R0.L='s';
678 call .Lwait_char;
679 R0.L='h';
680 call .Lwait_char;
681 R0.L='\r';
682 call .Lwait_char;
683 R0.L='\n';
684 call .Lwait_char;
685
686 R0.L='S';
687 call .Lwait_char;
688 R0.L='E';
689 call .Lwait_char;
690 R0.L='Q'
691 call .Lwait_char;
692 R0.L='S'
693 call .Lwait_char;
694 R0.L='T';
695 call .Lwait_char;
696 R0.L='A';
697 call .Lwait_char;
698 R0.L='T';
699 call .Lwait_char;
700 R0.L='=';
701 call .Lwait_char;
702 R2 = SEQSTAT;
703 call .Ldump_reg;
704
705 R0.L=' ';
706 call .Lwait_char;
707 R0.L='R';
708 call .Lwait_char;
709 R0.L='E'
710 call .Lwait_char;
711 R0.L='T'
712 call .Lwait_char;
713 R0.L='X';
714 call .Lwait_char;
715 R0.L='=';
716 call .Lwait_char;
717 R2 = RETX;
718 call .Ldump_reg;
719
720 R0.L='\r';
721 call .Lwait_char;
722 R0.L='\n';
723 call .Lwait_char;
724
725.Ldebug_kernel_start_trap_done:
726 JUMP .Ldebug_kernel_start_trap_done;
727.Ldump_reg:
728 R3 = 32;
729 R4 = 0x0F;
730 R5 = ':'; /* one past 9 */
731
732.Ldump_reg2:
733 R0 = R2;
734 R3 += -4;
735 R0 >>>= R3;
736 R0 = R0 & R4;
737 R0 += 0x30;
738 CC = R0 <= R5;
739 if CC JUMP .Ldump_reg1;
740 R0 += 7;
741
742.Ldump_reg1:
743 R1.l = W[P1];
744 CC = BITTST(R1, 5);
745 if !CC JUMP .Ldump_reg1;
746 W[P0] = r0;
747
748 CC = R3 == 0;
749 if !CC JUMP .Ldump_reg2
750 RTS;
751
752.Lwait_char:
753 R1.l = W[P1];
754 CC = BITTST(R1, 5);
755 if !CC JUMP .Lwait_char;
756 W[P0] = r0;
757 RTS;
758
759#endif /* CONFIG_DEBUG_KERNEL_START */
760
761.data
762
763/*
764 * Set up the usable of RAM stuff. Size of RAM is determined then
765 * an initial stack set up at the end.
766 */
767
768.align 4
769__rambase:
770.long 0
771__ramstart:
772.long 0
773__ramend:
774.long 0
diff --git a/arch/blackfin/mach-bf533/ints-priority.c b/arch/blackfin/mach-bf533/ints-priority.c
new file mode 100644
index 000000000000..36a693345204
--- /dev/null
+++ b/arch/blackfin/mach-bf533/ints-priority.c
@@ -0,0 +1,65 @@
1/*
2 * File: arch/blackfin/mach-bf533/ints-priority.c
3 * Based on:
4 * Author: Michael Hennerich
5 *
6 * Created: ?
7 * Description: Set up the interupt priorities
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/module.h>
31#include <asm/blackfin.h>
32#include <asm/irq.h>
33
34void program_IAR(void)
35{
36 /* Program the IAR0 Register with the configured priority */
37 bfin_write_SIC_IAR0(((CONFIG_PLLWAKE_ERROR - 7) << PLLWAKE_ERROR_POS) |
38 ((CONFIG_DMA_ERROR - 7) << DMA_ERROR_POS) |
39 ((CONFIG_PPI_ERROR - 7) << PPI_ERROR_POS) |
40 ((CONFIG_SPORT0_ERROR - 7) << SPORT0_ERROR_POS) |
41 ((CONFIG_SPI_ERROR - 7) << SPI_ERROR_POS) |
42 ((CONFIG_SPORT1_ERROR - 7) << SPORT1_ERROR_POS) |
43 ((CONFIG_UART_ERROR - 7) << UART_ERROR_POS) |
44 ((CONFIG_RTC_ERROR - 7) << RTC_ERROR_POS));
45
46 bfin_write_SIC_IAR1(((CONFIG_DMA0_PPI - 7) << DMA0_PPI_POS) |
47 ((CONFIG_DMA1_SPORT0RX - 7) << DMA1_SPORT0RX_POS) |
48 ((CONFIG_DMA2_SPORT0TX - 7) << DMA2_SPORT0TX_POS) |
49 ((CONFIG_DMA3_SPORT1RX - 7) << DMA3_SPORT1RX_POS) |
50 ((CONFIG_DMA4_SPORT1TX - 7) << DMA4_SPORT1TX_POS) |
51 ((CONFIG_DMA5_SPI - 7) << DMA5_SPI_POS) |
52 ((CONFIG_DMA6_UARTRX - 7) << DMA6_UARTRX_POS) |
53 ((CONFIG_DMA7_UARTTX - 7) << DMA7_UARTTX_POS));
54
55 bfin_write_SIC_IAR2(((CONFIG_TIMER0 - 7) << TIMER0_POS) |
56 ((CONFIG_TIMER1 - 7) << TIMER1_POS) |
57 ((CONFIG_TIMER2 - 7) << TIMER2_POS) |
58 ((CONFIG_PFA - 7) << PFA_POS) |
59 ((CONFIG_PFB - 7) << PFB_POS) |
60 ((CONFIG_MEMDMA0 - 7) << MEMDMA0_POS) |
61 ((CONFIG_MEMDMA1 - 7) << MEMDMA1_POS) |
62 ((CONFIG_WDTIMER - 7) << WDTIMER_POS));
63
64 SSYNC();
65}
diff --git a/arch/blackfin/mach-bf537/Kconfig b/arch/blackfin/mach-bf537/Kconfig
new file mode 100644
index 000000000000..cc9ae38a4dda
--- /dev/null
+++ b/arch/blackfin/mach-bf537/Kconfig
@@ -0,0 +1,141 @@
1if (BF537 || BF534 || BF536)
2
3menu "BF537 Specific Configuration"
4
5comment "PORT F/G Selection"
6choice
7 prompt "Select BF537/6/4 default GPIO PFx PORTx"
8 help
9 Quick Hack for BF537/6/4 default GPIO PFx PORTF.
10
11config BF537_PORT_F
12 bool "Select BF537/6/4 default GPIO PFx PORTF"
13 depends on (BF537 || BF536 || BF534)
14 help
15 Quick Hack for BF537/6/4 default GPIO PFx PORTF.
16
17config BF537_PORT_G
18 bool "Select BF537/6/4 default GPIO PFx PORTG"
19 depends on (BF537 || BF536 || BF534)
20 help
21 Quick Hack for BF537/6/4 default GPIO PFx PORTG.
22
23config BF537_PORT_H
24 bool "Select BF537/6/4 default GPIO PFx PORTH"
25 depends on (BF537 || BF536 || BF534)
26 help
27 Quick Hack for BF537/6/4 default GPIO PFx PORTH
28 Use only when Blackfin EMAC support is not required.
29
30endchoice
31
32comment "Interrupt Priority Assignment"
33menu "Priority"
34
35config IRQ_PLL_WAKEUP
36 int "IRQ_PLL_WAKEUP"
37 default 7
38config IRQ_DMA_ERROR
39 int "IRQ_DMA_ERROR Generic"
40 default 7
41config IRQ_ERROR
42 int "IRQ_ERROR: CAN MAC SPORT0 SPORT1 SPI UART0 UART1"
43 default 7
44config IRQ_RTC
45 int "IRQ_RTC"
46 default 8
47config IRQ_PPI
48 int "IRQ_PPI"
49 default 8
50config IRQ_SPORT0_RX
51 int "IRQ_SPORT0_RX"
52 default 9
53config IRQ_SPORT0_TX
54 int "IRQ_SPORT0_TX"
55 default 9
56config IRQ_SPORT1_RX
57 int "IRQ_SPORT1_RX"
58 default 9
59config IRQ_SPORT1_TX
60 int "IRQ_SPORT1_TX"
61 default 9
62config IRQ_TWI
63 int "IRQ_TWI"
64 default 10
65config IRQ_SPI
66 int "IRQ_SPI"
67 default 10
68config IRQ_UART0_RX
69 int "IRQ_UART0_RX"
70 default 10
71config IRQ_UART0_TX
72 int "IRQ_UART0_TX"
73 default 10
74config IRQ_UART1_RX
75 int "IRQ_UART1_RX"
76 default 10
77config IRQ_UART1_TX
78 int "IRQ_UART1_TX"
79 default 10
80config IRQ_CAN_RX
81 int "IRQ_CAN_RX"
82 default 11
83config IRQ_CAN_TX
84 int "IRQ_CAN_TX"
85 default 11
86config IRQ_MAC_RX
87 int "IRQ_MAC_RX"
88 default 11
89config IRQ_MAC_TX
90 int "IRQ_MAC_TX"
91 default 11
92config IRQ_TMR0
93 int "IRQ_TMR0"
94 default 12
95config IRQ_TMR1
96 int "IRQ_TMR1"
97 default 12
98config IRQ_TMR2
99 int "IRQ_TMR2"
100 default 12
101config IRQ_TMR3
102 int "IRQ_TMR3"
103 default 12
104config IRQ_TMR4
105 int "IRQ_TMR4"
106 default 12
107config IRQ_TMR5
108 int "IRQ_TMR5"
109 default 12
110config IRQ_TMR6
111 int "IRQ_TMR6"
112 default 12
113config IRQ_TMR7
114 int "IRQ_TMR7"
115 default 12
116config IRQ_PROG_INTA
117 int "IRQ_PROG_INTA"
118 default 12
119config IRQ_PORTG_INTB
120 int "IRQ_PORTG_INTB"
121 default 12
122config IRQ_MEM_DMA0
123 int "IRQ_MEM_DMA0"
124 default 13
125config IRQ_MEM_DMA1
126 int "IRQ_MEM_DMA1"
127 default 13
128config IRQ_WATCH
129 int "IRQ_WATCH"
130 default 13
131
132 help
133 Enter the priority numbers between 7-13 ONLY. Others are Reserved.
134 This applies to all the above. It is not recommended to assign the
135 highest priority number 7 to UART or any other device.
136
137endmenu
138
139endmenu
140
141endif
diff --git a/arch/blackfin/mach-bf537/Makefile b/arch/blackfin/mach-bf537/Makefile
new file mode 100644
index 000000000000..f32d44215bb7
--- /dev/null
+++ b/arch/blackfin/mach-bf537/Makefile
@@ -0,0 +1,9 @@
1#
2# arch/blackfin/mach-bf537/Makefile
3#
4
5extra-y := head.o
6
7obj-y := ints-priority.o
8
9obj-$(CONFIG_CPU_FREQ) += cpu.o
diff --git a/arch/blackfin/mach-bf537/boards/Makefile b/arch/blackfin/mach-bf537/boards/Makefile
new file mode 100644
index 000000000000..23323cacc3aa
--- /dev/null
+++ b/arch/blackfin/mach-bf537/boards/Makefile
@@ -0,0 +1,9 @@
1#
2# arch/blackfin/mach-bf537/boards/Makefile
3#
4
5obj-y += eth_mac.o
6obj-$(CONFIG_GENERIC_BOARD) += generic_board.o
7obj-$(CONFIG_BFIN537_STAMP) += stamp.o led.o
8obj-$(CONFIG_BFIN537_BLUETECHNIX_CM) += cm_bf537.o
9obj-$(CONFIG_PNAV10) += pnav10.o
diff --git a/arch/blackfin/mach-bf537/boards/cm_bf537.c b/arch/blackfin/mach-bf537/boards/cm_bf537.c
new file mode 100644
index 000000000000..6a60618a78ec
--- /dev/null
+++ b/arch/blackfin/mach-bf537/boards/cm_bf537.c
@@ -0,0 +1,364 @@
1/*
2 * File: arch/blackfin/mach-bf537/boards/cm_bf537.c
3 * Based on: arch/blackfin/mach-bf533/boards/ezkit.c
4 * Author: Aidan Williams <aidan@nicta.com.au>
5 *
6 * Created: 2005
7 * Description: Board description file
8 *
9 * Modified:
10 * Copyright 2005 National ICT Australia (NICTA)
11 * Copyright 2004-2006 Analog Devices Inc.
12 *
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, see the file COPYING, or write
27 * to the Free Software Foundation, Inc.,
28 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 */
30
31#include <linux/device.h>
32#include <linux/platform_device.h>
33#include <linux/mtd/mtd.h>
34#include <linux/mtd/partitions.h>
35#include <linux/spi/spi.h>
36#include <linux/spi/flash.h>
37#include <linux/usb_isp1362.h>
38#include <asm/irq.h>
39#include <asm/bfin5xx_spi.h>
40
41/*
42 * Name the Board for the /proc/cpuinfo
43 */
44char *bfin_board_name = "Bluetechnix CM BF537";
45
46#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
47/* all SPI peripherals info goes here */
48
49#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
50static struct mtd_partition bfin_spi_flash_partitions[] = {
51 {
52 .name = "bootloader",
53 .size = 0x00020000,
54 .offset = 0,
55 .mask_flags = MTD_CAP_ROM
56 },{
57 .name = "kernel",
58 .size = 0xe0000,
59 .offset = 0x20000
60 },{
61 .name = "file system",
62 .size = 0x700000,
63 .offset = 0x00100000,
64 }
65};
66
67static struct flash_platform_data bfin_spi_flash_data = {
68 .name = "m25p80",
69 .parts = bfin_spi_flash_partitions,
70 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
71 .type = "m25p64",
72};
73
74/* SPI flash chip (m25p64) */
75static struct bfin5xx_spi_chip spi_flash_chip_info = {
76 .enable_dma = 0, /* use dma transfer with this chip*/
77 .bits_per_word = 8,
78};
79#endif
80
81#if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
82/* SPI ADC chip */
83static struct bfin5xx_spi_chip spi_adc_chip_info = {
84 .enable_dma = 1, /* use dma transfer with this chip*/
85 .bits_per_word = 16,
86};
87#endif
88
89#if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
90static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
91 .enable_dma = 0,
92 .bits_per_word = 16,
93};
94#endif
95
96#if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
97static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
98 .enable_dma = 0,
99 .bits_per_word = 16,
100};
101#endif
102
103#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
104static struct bfin5xx_spi_chip spi_mmc_chip_info = {
105 .enable_dma = 1,
106 .bits_per_word = 8,
107};
108#endif
109
110static struct spi_board_info bfin_spi_board_info[] __initdata = {
111#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
112 {
113 /* the modalias must be the same as spi device driver name */
114 .modalias = "m25p80", /* Name of spi_driver for this device */
115 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
116 .bus_num = 1, /* Framework bus number */
117 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
118 .platform_data = &bfin_spi_flash_data,
119 .controller_data = &spi_flash_chip_info,
120 .mode = SPI_MODE_3,
121 },
122#endif
123
124#if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
125 {
126 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
127 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
128 .bus_num = 1, /* Framework bus number */
129 .chip_select = 1, /* Framework chip select. */
130 .platform_data = NULL, /* No spi_driver specific config */
131 .controller_data = &spi_adc_chip_info,
132 },
133#endif
134
135#if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
136 {
137 .modalias = "ad1836-spi",
138 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
139 .bus_num = 1,
140 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
141 .controller_data = &ad1836_spi_chip_info,
142 },
143#endif
144
145#if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
146 {
147 .modalias = "ad9960-spi",
148 .max_speed_hz = 10000000, /* max spi clock (SCK) speed in HZ */
149 .bus_num = 1,
150 .chip_select = 1,
151 .controller_data = &ad9960_spi_chip_info,
152 },
153#endif
154
155#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
156 {
157 .modalias = "spi_mmc_dummy",
158 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
159 .bus_num = 1,
160 .chip_select = 7,
161 .platform_data = NULL,
162 .controller_data = &spi_mmc_chip_info,
163 .mode = SPI_MODE_3,
164 },
165 {
166 .modalias = "spi_mmc",
167 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
168 .bus_num = 1,
169 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
170 .platform_data = NULL,
171 .controller_data = &spi_mmc_chip_info,
172 .mode = SPI_MODE_3,
173 },
174#endif
175};
176
177/* SPI controller data */
178static struct bfin5xx_spi_master spi_bfin_master_info = {
179 .num_chipselect = 8,
180 .enable_dma = 1, /* master has the ability to do dma transfer */
181};
182
183static struct platform_device spi_bfin_master_device = {
184 .name = "bfin-spi-master",
185 .id = 1, /* Bus number */
186 .dev = {
187 .platform_data = &spi_bfin_master_info, /* Passed to driver */
188 },
189};
190#endif /* spi master and devices */
191
192#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
193static struct platform_device rtc_device = {
194 .name = "rtc-bfin",
195 .id = -1,
196};
197#endif
198
199#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
200static struct resource smc91x_resources[] = {
201 {
202 .start = 0x20200300,
203 .end = 0x20200300 + 16,
204 .flags = IORESOURCE_MEM,
205 },{
206 .start = IRQ_PF14,
207 .end = IRQ_PF14,
208 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
209 },
210};
211
212static struct platform_device smc91x_device = {
213 .name = "smc91x",
214 .id = 0,
215 .num_resources = ARRAY_SIZE(smc91x_resources),
216 .resource = smc91x_resources,
217};
218#endif
219
220#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
221static struct resource isp1362_hcd_resources[] = {
222 {
223 .start = 0x20308000,
224 .end = 0x20308000,
225 .flags = IORESOURCE_MEM,
226 },{
227 .start = 0x20308004,
228 .end = 0x20308004,
229 .flags = IORESOURCE_MEM,
230 },{
231 .start = IRQ_PG15,
232 .end = IRQ_PG15,
233 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
234 },
235};
236
237static struct isp1362_platform_data isp1362_priv = {
238 .sel15Kres = 1,
239 .clknotstop = 0,
240 .oc_enable = 0,
241 .int_act_high = 0,
242 .int_edge_triggered = 0,
243 .remote_wakeup_connected = 0,
244 .no_power_switching = 1,
245 .power_switching_mode = 0,
246};
247
248static struct platform_device isp1362_hcd_device = {
249 .name = "isp1362-hcd",
250 .id = 0,
251 .dev = {
252 .platform_data = &isp1362_priv,
253 },
254 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
255 .resource = isp1362_hcd_resources,
256};
257#endif
258
259#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
260static struct resource net2272_bfin_resources[] = {
261 {
262 .start = 0x20200000,
263 .end = 0x20200000 + 0x100,
264 .flags = IORESOURCE_MEM,
265 },{
266 .start = IRQ_PF7,
267 .end = IRQ_PF7,
268 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
269 },
270};
271
272static struct platform_device net2272_bfin_device = {
273 .name = "net2272",
274 .id = -1,
275 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
276 .resource = net2272_bfin_resources,
277};
278#endif
279
280#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
281static struct resource bfin_uart_resources[] = {
282 {
283 .start = 0xFFC00400,
284 .end = 0xFFC004FF,
285 .flags = IORESOURCE_MEM,
286 },{
287 .start = 0xFFC02000,
288 .end = 0xFFC020FF,
289 .flags = IORESOURCE_MEM,
290 },
291};
292
293static struct platform_device bfin_uart_device = {
294 .name = "bfin-uart",
295 .id = 1,
296 .num_resources = ARRAY_SIZE(bfin_uart_resources),
297 .resource = bfin_uart_resources,
298};
299#endif
300
301#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
302static struct platform_device bfin_sport0_uart_device = {
303 .name = "bfin-sport-uart",
304 .id = 0,
305};
306
307static struct platform_device bfin_sport1_uart_device = {
308 .name = "bfin-sport-uart",
309 .id = 1,
310};
311#endif
312
313#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
314static struct platform_device bfin_mac_device = {
315 .name = "bfin_mac",
316};
317#endif
318
319static struct platform_device *cm_bf537_devices[] __initdata = {
320#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
321 &rtc_device,
322#endif
323
324#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
325 &bfin_uart_device,
326#endif
327
328#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
329 &bfin_sport0_uart_device,
330 &bfin_sport1_uart_device,
331#endif
332
333#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
334 &isp1362_hcd_device,
335#endif
336
337#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
338 &smc91x_device,
339#endif
340
341#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
342 &bfin_mac_device,
343#endif
344
345#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
346 &net2272_bfin_device,
347#endif
348
349#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
350 &spi_bfin_master_device,
351#endif
352};
353
354static int __init cm_bf537_init(void)
355{
356 printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
357 platform_add_devices(cm_bf537_devices, ARRAY_SIZE(cm_bf537_devices));
358#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
359 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
360#endif
361 return 0;
362}
363
364arch_initcall(cm_bf537_init);
diff --git a/arch/blackfin/mach-bf537/boards/eth_mac.c b/arch/blackfin/mach-bf537/boards/eth_mac.c
new file mode 100644
index 000000000000..e129a08d63de
--- /dev/null
+++ b/arch/blackfin/mach-bf537/boards/eth_mac.c
@@ -0,0 +1,51 @@
1/*
2 * arch/blackfin/mach-bf537/board/eth_mac.c
3 *
4 * Copyright (C) 2007 Analog Devices, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#include <linux/module.h>
21#include <asm/blackfin.h>
22
23#if defined(CONFIG_GENERIC_BOARD) \
24 || defined(CONFIG_BFIN537_STAMP)
25
26/*
27 * Currently the MAC address is saved in Flash by U-Boot
28 */
29#define FLASH_MAC 0x203f0000
30
31void get_bf537_ether_addr(char *addr)
32{
33 unsigned int flash_mac = (unsigned int) FLASH_MAC;
34 *(u32 *)(&(addr[0])) = bfin_read32(flash_mac);
35 flash_mac += 4;
36 *(u16 *)(&(addr[4])) = bfin_read16(flash_mac);
37}
38
39#else
40
41/*
42 * Provide MAC address function for other specific board setting
43 */
44void get_bf537_ether_addr(char *addr)
45{
46 printk(KERN_WARNING "%s: No valid Ethernet MAC address found\n",__FILE__);
47}
48
49#endif
50
51EXPORT_SYMBOL(get_bf537_ether_addr);
diff --git a/arch/blackfin/mach-bf537/boards/generic_board.c b/arch/blackfin/mach-bf537/boards/generic_board.c
new file mode 100644
index 000000000000..9019c0edbe7c
--- /dev/null
+++ b/arch/blackfin/mach-bf537/boards/generic_board.c
@@ -0,0 +1,445 @@
1/*
2 * File: arch/blackfin/mach-bf537/boards/generic_board.c
3 * Based on: arch/blackfin/mach-bf533/boards/ezkit.c
4 * Author: Aidan Williams <aidan@nicta.com.au>
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2005 National ICT Australia (NICTA)
11 * Copyright 2004-2006 Analog Devices Inc.
12 *
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, see the file COPYING, or write
27 * to the Free Software Foundation, Inc.,
28 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 */
30
31#include <linux/device.h>
32#include <linux/platform_device.h>
33#include <linux/mtd/mtd.h>
34#include <linux/mtd/partitions.h>
35#include <linux/spi/spi.h>
36#include <linux/spi/flash.h>
37#include <linux/usb_isp1362.h>
38#include <asm/irq.h>
39#include <asm/bfin5xx_spi.h>
40#include <linux/usb_sl811.h>
41
42/*
43 * Name the Board for the /proc/cpuinfo
44 */
45char *bfin_board_name = "UNKNOWN BOARD";
46
47/*
48 * Driver needs to know address, irq and flag pin.
49 */
50
51#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
52static struct resource bfin_pcmcia_cf_resources[] = {
53 {
54 .start = 0x20310000, /* IO PORT */
55 .end = 0x20312000,
56 .flags = IORESOURCE_MEM,
57 },{
58 .start = 0x20311000, /* Attribute Memeory */
59 .end = 0x20311FFF,
60 .flags = IORESOURCE_MEM,
61 },{
62 .start = IRQ_PROG_INTA,
63 .end = IRQ_PROG_INTA,
64 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
65 },{
66 .start = IRQ_PF4,
67 .end = IRQ_PF4,
68 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
69 },{
70 .start = 6, /* Card Detect PF6 */
71 .end = 6,
72 .flags = IORESOURCE_IRQ,
73 },
74};
75
76static struct platform_device bfin_pcmcia_cf_device = {
77 .name = "bfin_cf_pcmcia",
78 .id = -1,
79 .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
80 .resource = bfin_pcmcia_cf_resources,
81};
82#endif
83
84#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
85static struct platform_device rtc_device = {
86 .name = "rtc-bfin",
87 .id = -1,
88};
89#endif
90
91#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
92static struct resource smc91x_resources[] = {
93 {
94 .name = "smc91x-regs",
95 .start = 0x20300300,
96 .end = 0x20300300 + 16,
97 .flags = IORESOURCE_MEM,
98 },{
99 .start = IRQ_PROG_INTB,
100 .end = IRQ_PROG_INTB,
101 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
102 },{
103 /*
104 * denotes the flag pin and is used directly if
105 * CONFIG_IRQCHIP_DEMUX_GPIO is defined.
106 */
107 .start = IRQ_PF7,
108 .end = IRQ_PF7,
109 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
110 },
111};
112static struct platform_device smc91x_device = {
113 .name = "smc91x",
114 .id = 0,
115 .num_resources = ARRAY_SIZE(smc91x_resources),
116 .resource = smc91x_resources,
117};
118#endif
119
120#if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
121static struct resource sl811_hcd_resources[] = {
122 {
123 .start = 0x20340000,
124 .end = 0x20340000,
125 .flags = IORESOURCE_MEM,
126 },{
127 .start = 0x20340004,
128 .end = 0x20340004,
129 .flags = IORESOURCE_MEM,
130 },{
131 .start = IRQ_PROG_INTA,
132 .end = IRQ_PROG_INTA,
133 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
134 },{
135 .start = IRQ_PF0 + CONFIG_USB_SL811_BFIN_GPIO,
136 .end = IRQ_PF0 + CONFIG_USB_SL811_BFIN_GPIO,
137 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
138 },
139};
140
141#if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
142void sl811_port_power(struct device *dev, int is_on)
143{
144 unsigned short mask = (1<<CONFIG_USB_SL811_BFIN_GPIO_VBUS);
145
146 bfin_write_PORT_FER(bfin_read_PORT_FER() & ~mask);
147 bfin_write_FIO_DIR(bfin_read_FIO_DIR() | mask);
148
149 if (is_on)
150 bfin_write_FIO_FLAG_S(mask);
151 else
152 bfin_write_FIO_FLAG_C(mask);
153}
154#endif
155
156static struct sl811_platform_data sl811_priv = {
157 .potpg = 10,
158 .power = 250, /* == 500mA */
159#if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
160 .port_power = &sl811_port_power,
161#endif
162};
163
164static struct platform_device sl811_hcd_device = {
165 .name = "sl811-hcd",
166 .id = 0,
167 .dev = {
168 .platform_data = &sl811_priv,
169 },
170 .num_resources = ARRAY_SIZE(sl811_hcd_resources),
171 .resource = sl811_hcd_resources,
172};
173
174#endif
175
176#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
177static struct resource isp1362_hcd_resources[] = {
178 {
179 .start = 0x20360000,
180 .end = 0x20360000,
181 .flags = IORESOURCE_MEM,
182 },{
183 .start = 0x20360004,
184 .end = 0x20360004,
185 .flags = IORESOURCE_MEM,
186 },{
187 .start = IRQ_PROG_INTA,
188 .end = IRQ_PROG_INTA,
189 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
190 },{
191 .start = IRQ_PF0 + CONFIG_USB_ISP1362_BFIN_GPIO,
192 .end = IRQ_PF0 + CONFIG_USB_ISP1362_BFIN_GPIO,
193 .flags = IORESOURCE_IRQ,
194 },
195};
196
197static struct isp1362_platform_data isp1362_priv = {
198 .sel15Kres = 1,
199 .clknotstop = 0,
200 .oc_enable = 0,
201 .int_act_high = 0,
202 .int_edge_triggered = 0,
203 .remote_wakeup_connected = 0,
204 .no_power_switching = 1,
205 .power_switching_mode = 0,
206};
207
208static struct platform_device isp1362_hcd_device = {
209 .name = "isp1362-hcd",
210 .id = 0,
211 .dev = {
212 .platform_data = &isp1362_priv,
213 },
214 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
215 .resource = isp1362_hcd_resources,
216};
217#endif
218
219#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
220static struct platform_device bfin_mac_device = {
221 .name = "bfin_mac",
222};
223#endif
224
225#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
226static struct resource net2272_bfin_resources[] = {
227 {
228 .start = 0x20300000,
229 .end = 0x20300000 + 0x100,
230 .flags = IORESOURCE_MEM,
231 },{
232 .start = IRQ_PF7,
233 .end = IRQ_PF7,
234 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
235 },
236};
237
238static struct platform_device net2272_bfin_device = {
239 .name = "net2272",
240 .id = -1,
241 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
242 .resource = net2272_bfin_resources,
243};
244#endif
245
246#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
247/* all SPI peripherals info goes here */
248
249#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
250static struct mtd_partition bfin_spi_flash_partitions[] = {
251 {
252 .name = "bootloader",
253 .size = 0x00020000,
254 .offset = 0,
255 .mask_flags = MTD_CAP_ROM
256 },{
257 .name = "kernel",
258 .size = 0xe0000,
259 .offset = 0x20000
260 },{
261 .name = "file system",
262 .size = 0x700000,
263 .offset = 0x00100000,
264 }
265};
266
267static struct flash_platform_data bfin_spi_flash_data = {
268 .name = "m25p80",
269 .parts = bfin_spi_flash_partitions,
270 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
271 .type = "m25p64",
272};
273
274/* SPI flash chip (m25p64) */
275static struct bfin5xx_spi_chip spi_flash_chip_info = {
276 .enable_dma = 0, /* use dma transfer with this chip*/
277 .bits_per_word = 8,
278};
279#endif
280
281#if defined(CONFIG_SPI_ADC_BF533) \
282 || defined(CONFIG_SPI_ADC_BF533_MODULE)
283/* SPI ADC chip */
284static struct bfin5xx_spi_chip spi_adc_chip_info = {
285 .enable_dma = 1, /* use dma transfer with this chip*/
286 .bits_per_word = 16,
287};
288#endif
289
290#if defined(CONFIG_SND_BLACKFIN_AD1836) \
291 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
292static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
293 .enable_dma = 0,
294 .bits_per_word = 16,
295};
296#endif
297
298#if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
299static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
300 .enable_dma = 0,
301 .bits_per_word = 16,
302};
303#endif
304
305static struct spi_board_info bfin_spi_board_info[] __initdata = {
306#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
307 {
308 /* the modalias must be the same as spi device driver name */
309 .modalias = "m25p80", /* Name of spi_driver for this device */
310 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
311 .bus_num = 1, /* Framework bus number */
312 .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL1*/
313 .platform_data = &bfin_spi_flash_data,
314 .controller_data = &spi_flash_chip_info,
315 .mode = SPI_MODE_3,
316 },
317#endif
318
319#if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
320 {
321 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
322 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
323 .bus_num = 1, /* Framework bus number */
324 .chip_select = 1, /* Framework chip select. */
325 .platform_data = NULL, /* No spi_driver specific config */
326 .controller_data = &spi_adc_chip_info,
327 },
328#endif
329
330#if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
331 {
332 .modalias = "ad1836-spi",
333 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
334 .bus_num = 1,
335 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
336 .controller_data = &ad1836_spi_chip_info,
337 },
338#endif
339
340#if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
341 {
342 .modalias = "ad9960-spi",
343 .max_speed_hz = 10000000, /* max spi clock (SCK) speed in HZ */
344 .bus_num = 1,
345 .chip_select = 1,
346 .controller_data = &ad9960_spi_chip_info,
347 },
348#endif
349};
350
351/* SPI controller data */
352static struct bfin5xx_spi_master spi_bfin_master_info = {
353 .num_chipselect = 8,
354 .enable_dma = 1, /* master has the ability to do dma transfer */
355};
356
357static struct platform_device spi_bfin_master_device = {
358 .name = "bfin-spi-master",
359 .id = 1, /* Bus number */
360 .dev = {
361 .platform_data = &spi_bfin_master_info, /* Passed to driver */
362 },
363};
364#endif /* spi master and devices */
365
366#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
367static struct platform_device bfin_fb_device = {
368 .name = "bf537-fb",
369};
370#endif
371
372#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
373static struct resource bfin_uart_resources[] = {
374 {
375 .start = 0xFFC00400,
376 .end = 0xFFC004FF,
377 .flags = IORESOURCE_MEM,
378 },{
379 .start = 0xFFC02000,
380 .end = 0xFFC020FF,
381 .flags = IORESOURCE_MEM,
382 },
383};
384
385static struct platform_device bfin_uart_device = {
386 .name = "bfin-uart",
387 .id = 1,
388 .num_resources = ARRAY_SIZE(bfin_uart_resources),
389 .resource = bfin_uart_resources,
390};
391#endif
392
393static struct platform_device *stamp_devices[] __initdata = {
394#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
395 &rtc_device,
396#endif
397
398#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
399 &bfin_pcmcia_cf_device,
400#endif
401
402#if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
403 &sl811_hcd_device,
404#endif
405
406#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
407 &isp1362_hcd_device,
408#endif
409
410#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
411 &smc91x_device,
412#endif
413
414#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
415 &bfin_mac_device,
416#endif
417
418#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
419 &net2272_bfin_device,
420#endif
421
422#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
423 &spi_bfin_master_device,
424#endif
425
426#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
427 &bfin_fb_device,
428#endif
429
430#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
431 &bfin_uart_device,
432#endif
433};
434
435static int __init stamp_init(void)
436{
437 printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
438 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
439#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
440 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
441#endif
442 return 0;
443}
444
445arch_initcall(stamp_init);
diff --git a/arch/blackfin/mach-bf537/boards/led.S b/arch/blackfin/mach-bf537/boards/led.S
new file mode 100644
index 000000000000..4e9ea4283e5f
--- /dev/null
+++ b/arch/blackfin/mach-bf537/boards/led.S
@@ -0,0 +1,183 @@
1/****************************************************
2 * LED1 ---- PF6 LED2 ---- PF7 *
3 * LED3 ---- PF8 LED4 ---- PF9 *
4 * LED5 ---- PF10 LED6 ---- PF11 *
5 ****************************************************/
6
7#include <linux/linkage.h>
8#include <asm/blackfin.h>
9
10/* All functions in this file save the registers they uses.
11 So there is no need to save any registers before calling them. */
12
13 .text;
14
15/* Initialize LEDs. */
16
17ENTRY(_led_init)
18 LINK 12;
19 [--SP] = P0;
20 [--SP] = R0;
21 [--SP] = R1;
22 [--SP] = R2;
23 R1 = PF6|PF7|PF8|PF9|PF10|PF11 (Z);
24 R2 = ~R1;
25
26 P0.H = hi(PORTF_FER);
27 P0.L = lo(PORTF_FER);
28 R0 = W[P0](Z);
29 SSYNC;
30 R0 = R0 & R2;
31 W[P0] = R0.L;
32 SSYNC;
33
34 P0.H = hi(PORTFIO_DIR);
35 P0.L = lo(PORTFIO_DIR);
36 R0 = W[P0](Z);
37 SSYNC;
38 R0 = R0 | R1;
39 W[P0] = R0.L;
40 SSYNC;
41
42 P0.H = hi(PORTFIO_INEN);
43 P0.L = lo(PORTFIO_INEN);
44 R0 = W[P0](Z);
45 SSYNC;
46 R0 = R0 & R2;
47 W[P0] = R0.L;
48 SSYNC;
49
50 R2 = [SP++];
51 R1 = [SP++];
52 R0 = [SP++];
53 P0 = [SP++];
54 UNLINK;
55 RTS;
56 .size _led_init, .-_led_init
57
58/* Set one LED on. Leave other LEDs unchanged.
59 It expects the LED number passed through R0. */
60
61ENTRY(_led_on)
62 LINK 12;
63 [--SP] = P0;
64 [--SP] = R1;
65 CALL _led_init;
66 R1 = 1;
67 R0 += 5;
68 R1 <<= R0;
69 P0.H = hi(PORTFIO);
70 P0.L = lo(PORTFIO);
71 R0 = W[P0](Z);
72 SSYNC;
73 R0 = R0 | R1;
74 W[P0] = R0.L;
75 SSYNC;
76 R1 = [SP++];
77 P0 = [SP++];
78 UNLINK;
79 RTS;
80 .size _led_on, .-_led_on
81
82/* Set one LED off. Leave other LEDs unchanged. */
83
84ENTRY(_led_off)
85 LINK 12;
86 [--SP] = P0;
87 [--SP] = R1;
88 CALL _led_init;
89 R1 = 1;
90 R0 += 5;
91 R1 <<= R0;
92 R1 = ~R1;
93 P0.H = hi(PORTFIO);
94 P0.L = lo(PORTFIO);
95 R0 = W[P0](Z);
96 SSYNC;
97 R0 = R0 & R1;
98 W[P0] = R0.L;
99 SSYNC;
100 R1 = [SP++];
101 P0 = [SP++];
102 UNLINK;
103 RTS;
104 .size _led_off, .-_led_off
105
106/* Toggle one LED. Leave other LEDs unchanged. */
107
108ENTRY(_led_toggle)
109 LINK 12;
110 [--SP] = P0;
111 [--SP] = R1;
112 CALL _led_init;
113 R1 = 1;
114 R0 += 5;
115 R1 <<= R0;
116 P0.H = hi(PORTFIO);
117 P0.L = lo(PORTFIO);
118 R0 = W[P0](Z);
119 SSYNC;
120 R0 = R0 ^ R1;
121 W[P0] = R0.L;
122 SSYNC;
123 R1 = [SP++];
124 P0 = [SP++];
125 UNLINK;
126 RTS;
127 .size _led_toggle, .-_led_toggle
128
129/* Display the number using LEDs in binary format. */
130
131ENTRY(_led_disp_num)
132 LINK 12;
133 [--SP] = P0;
134 [--SP] = R1;
135 [--SP] = R2;
136 CALL _led_init;
137 R1 = 0x3f(X);
138 R0 = R0 & R1;
139 R2 = 6(X);
140 R0 <<= R2;
141 R1 <<= R2;
142 P0.H = hi(PORTFIO);
143 P0.L = lo(PORTFIO);
144 R2 = W[P0](Z);
145 SSYNC;
146 R1 = ~R1;
147 R2 = R2 & R1;
148 R2 = R2 | R0;
149 W[P0] = R2.L;
150 SSYNC;
151 R2 = [SP++];
152 R1 = [SP++];
153 P0 = [SP++];
154 UNLINK;
155 RTS;
156 .size _led_disp_num, .-_led_disp_num
157
158/* Toggle the number using LEDs in binary format. */
159
160ENTRY(_led_toggle_num)
161 LINK 12;
162 [--SP] = P0;
163 [--SP] = R1;
164 [--SP] = R2;
165 CALL _led_init;
166 R1 = 0x3f(X);
167 R0 = R0 & R1;
168 R1 = 6(X);
169 R0 <<= R1;
170 P0.H = hi(PORTFIO);
171 P0.L = lo(PORTFIO);
172 R1 = W[P0](Z);
173 SSYNC;
174 R1 = R1 ^ R0;
175 W[P0] = R1.L;
176 SSYNC;
177 R2 = [SP++];
178 R1 = [SP++];
179 P0 = [SP++];
180 UNLINK;
181 RTS;
182 .size _led_toggle_num, .-_led_toggle_num
183
diff --git a/arch/blackfin/mach-bf537/boards/pnav10.c b/arch/blackfin/mach-bf537/boards/pnav10.c
new file mode 100644
index 000000000000..40d3a1b70ee7
--- /dev/null
+++ b/arch/blackfin/mach-bf537/boards/pnav10.c
@@ -0,0 +1,523 @@
1/*
2 * File: arch/blackfin/mach-bf537/boards/stamp.c
3 * Based on: arch/blackfin/mach-bf533/boards/ezkit.c
4 * Author: Aidan Williams <aidan@nicta.com.au>
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2005 National ICT Australia (NICTA)
11 * Copyright 2004-2006 Analog Devices Inc.
12 *
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, see the file COPYING, or write
27 * to the Free Software Foundation, Inc.,
28 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 */
30
31#include <linux/device.h>
32#include <linux/platform_device.h>
33#include <linux/mtd/mtd.h>
34#include <linux/mtd/partitions.h>
35#include <linux/spi/spi.h>
36#include <linux/spi/flash.h>
37#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
38#include <linux/usb_isp1362.h>
39#endif
40#include <asm/irq.h>
41#include <asm/bfin5xx_spi.h>
42#include <linux/usb_sl811.h>
43
44#include <linux/spi/ad7877.h>
45
46/*
47 * Name the Board for the /proc/cpuinfo
48 */
49char *bfin_board_name = "PNAV-1.0";
50
51/*
52 * Driver needs to know address, irq and flag pin.
53 */
54
55#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
56static struct resource bfin_pcmcia_cf_resources[] = {
57 {
58 .start = 0x20310000, /* IO PORT */
59 .end = 0x20312000,
60 .flags = IORESOURCE_MEM,
61 },{
62 .start = 0x20311000, /* Attribute Memeory */
63 .end = 0x20311FFF,
64 .flags = IORESOURCE_MEM,
65 },{
66 .start = IRQ_PF4,
67 .end = IRQ_PF4,
68 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
69 },{
70 .start = 6, /* Card Detect PF6 */
71 .end = 6,
72 .flags = IORESOURCE_IRQ,
73 },
74};
75
76static struct platform_device bfin_pcmcia_cf_device = {
77 .name = "bfin_cf_pcmcia",
78 .id = -1,
79 .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
80 .resource = bfin_pcmcia_cf_resources,
81};
82#endif
83
84#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
85static struct platform_device rtc_device = {
86 .name = "rtc-bfin",
87 .id = -1,
88};
89#endif
90
91#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
92static struct resource smc91x_resources[] = {
93 {
94 .name = "smc91x-regs",
95 .start = 0x20300300,
96 .end = 0x20300300 + 16,
97 .flags = IORESOURCE_MEM,
98 },{
99
100 .start = IRQ_PF7,
101 .end = IRQ_PF7,
102 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
103 },
104};
105static struct platform_device smc91x_device = {
106 .name = "smc91x",
107 .id = 0,
108 .num_resources = ARRAY_SIZE(smc91x_resources),
109 .resource = smc91x_resources,
110};
111#endif
112
113#if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
114static struct resource sl811_hcd_resources[] = {
115 {
116 .start = 0x20340000,
117 .end = 0x20340000,
118 .flags = IORESOURCE_MEM,
119 },{
120 .start = 0x20340004,
121 .end = 0x20340004,
122 .flags = IORESOURCE_MEM,
123 },{
124 .start = CONFIG_USB_SL811_BFIN_IRQ,
125 .end = CONFIG_USB_SL811_BFIN_IRQ,
126 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
127 },
128};
129
130#if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
131void sl811_port_power(struct device *dev, int is_on)
132{
133 unsigned short mask = (1 << CONFIG_USB_SL811_BFIN_GPIO_VBUS);
134
135 bfin_write_PORT_FER(bfin_read_PORT_FER() & ~mask);
136 bfin_write_FIO_DIR(bfin_read_FIO_DIR() | mask);
137
138 if (is_on)
139 bfin_write_FIO_FLAG_S(mask);
140 else
141 bfin_write_FIO_FLAG_C(mask);
142}
143#endif
144
145static struct sl811_platform_data sl811_priv = {
146 .potpg = 10,
147 .power = 250, /* == 500mA */
148#if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
149 .port_power = &sl811_port_power,
150#endif
151};
152
153static struct platform_device sl811_hcd_device = {
154 .name = "sl811-hcd",
155 .id = 0,
156 .dev = {
157 .platform_data = &sl811_priv,
158 },
159 .num_resources = ARRAY_SIZE(sl811_hcd_resources),
160 .resource = sl811_hcd_resources,
161};
162#endif
163
164#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
165static struct resource isp1362_hcd_resources[] = {
166 {
167 .start = 0x20360000,
168 .end = 0x20360000,
169 .flags = IORESOURCE_MEM,
170 },{
171 .start = 0x20360004,
172 .end = 0x20360004,
173 .flags = IORESOURCE_MEM,
174 },{
175 .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
176 .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
177 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
178 },
179};
180
181static struct isp1362_platform_data isp1362_priv = {
182 .sel15Kres = 1,
183 .clknotstop = 0,
184 .oc_enable = 0,
185 .int_act_high = 0,
186 .int_edge_triggered = 0,
187 .remote_wakeup_connected = 0,
188 .no_power_switching = 1,
189 .power_switching_mode = 0,
190};
191
192static struct platform_device isp1362_hcd_device = {
193 .name = "isp1362-hcd",
194 .id = 0,
195 .dev = {
196 .platform_data = &isp1362_priv,
197 },
198 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
199 .resource = isp1362_hcd_resources,
200};
201#endif
202
203#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
204static struct platform_device bfin_mac_device = {
205 .name = "bfin_mac",
206};
207#endif
208
209#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
210static struct resource net2272_bfin_resources[] = {
211 {
212 .start = 0x20300000,
213 .end = 0x20300000 + 0x100,
214 .flags = IORESOURCE_MEM,
215 },{
216 .start = IRQ_PF7,
217 .end = IRQ_PF7,
218 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
219 },
220};
221
222static struct platform_device net2272_bfin_device = {
223 .name = "net2272",
224 .id = -1,
225 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
226 .resource = net2272_bfin_resources,
227};
228#endif
229
230#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
231/* all SPI peripherals info goes here */
232
233#if defined(CONFIG_MTD_M25P80) \
234 || defined(CONFIG_MTD_M25P80_MODULE)
235static struct mtd_partition bfin_spi_flash_partitions[] = {
236 {
237 .name = "bootloader",
238 .size = 0x00020000,
239 .offset = 0,
240 .mask_flags = MTD_CAP_ROM
241 },{
242 .name = "kernel",
243 .size = 0xe0000,
244 .offset = 0x20000
245 },{
246 .name = "file system",
247 .size = 0x700000,
248 .offset = 0x00100000,
249 }
250};
251
252static struct flash_platform_data bfin_spi_flash_data = {
253 .name = "m25p80",
254 .parts = bfin_spi_flash_partitions,
255 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
256 .type = "m25p64",
257};
258
259/* SPI flash chip (m25p64) */
260static struct bfin5xx_spi_chip spi_flash_chip_info = {
261 .enable_dma = 0, /* use dma transfer with this chip*/
262 .bits_per_word = 8,
263};
264#endif
265
266#if defined(CONFIG_SPI_ADC_BF533) \
267 || defined(CONFIG_SPI_ADC_BF533_MODULE)
268/* SPI ADC chip */
269static struct bfin5xx_spi_chip spi_adc_chip_info = {
270 .enable_dma = 1, /* use dma transfer with this chip*/
271 .bits_per_word = 16,
272};
273#endif
274
275#if defined(CONFIG_SND_BLACKFIN_AD1836) \
276 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
277static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
278 .enable_dma = 0,
279 .bits_per_word = 16,
280};
281#endif
282
283#if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
284static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
285 .enable_dma = 0,
286 .bits_per_word = 16,
287};
288#endif
289
290#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
291static struct bfin5xx_spi_chip spi_mmc_chip_info = {
292 .enable_dma = 1,
293 .bits_per_word = 8,
294};
295#endif
296
297#if defined(CONFIG_PBX)
298static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
299 .ctl_reg = 0x4, /* send zero */
300 .enable_dma = 0,
301 .bits_per_word = 8,
302 .cs_change_per_word = 1,
303};
304#endif
305
306
307#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
308static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
309 .cs_change_per_word = 1,
310 .enable_dma = 0,
311 .bits_per_word = 16,
312};
313
314static const struct ad7877_platform_data bfin_ad7877_ts_info = {
315 .model = 7877,
316 .vref_delay_usecs = 50, /* internal, no capacitor */
317 .x_plate_ohms = 419,
318 .y_plate_ohms = 486,
319 .pressure_max = 1000,
320 .pressure_min = 0,
321 .stopacq_polarity = 1,
322 .first_conversion_delay = 3,
323 .acquisition_time = 1,
324 .averaging = 1,
325 .pen_down_acc_interval = 1,
326};
327#endif
328
329static struct spi_board_info bfin_spi_board_info[] __initdata = {
330#if defined(CONFIG_MTD_M25P80) \
331 || defined(CONFIG_MTD_M25P80_MODULE)
332 {
333 /* the modalias must be the same as spi device driver name */
334 .modalias = "m25p80", /* Name of spi_driver for this device */
335 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
336 .bus_num = 1, /* Framework bus number */
337 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
338 .platform_data = &bfin_spi_flash_data,
339 .controller_data = &spi_flash_chip_info,
340 .mode = SPI_MODE_3,
341 },
342#endif
343
344#if defined(CONFIG_SPI_ADC_BF533) \
345 || defined(CONFIG_SPI_ADC_BF533_MODULE)
346 {
347 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
348 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
349 .bus_num = 1, /* Framework bus number */
350 .chip_select = 1, /* Framework chip select. */
351 .platform_data = NULL, /* No spi_driver specific config */
352 .controller_data = &spi_adc_chip_info,
353 },
354#endif
355
356#if defined(CONFIG_SND_BLACKFIN_AD1836) \
357 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
358 {
359 .modalias = "ad1836-spi",
360 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
361 .bus_num = 1,
362 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
363 .controller_data = &ad1836_spi_chip_info,
364 },
365#endif
366#if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
367 {
368 .modalias = "ad9960-spi",
369 .max_speed_hz = 10000000, /* max spi clock (SCK) speed in HZ */
370 .bus_num = 1,
371 .chip_select = 1,
372 .controller_data = &ad9960_spi_chip_info,
373 },
374#endif
375#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
376 {
377 .modalias = "spi_mmc_dummy",
378 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
379 .bus_num = 1,
380 .chip_select = 7,
381 .platform_data = NULL,
382 .controller_data = &spi_mmc_chip_info,
383 .mode = SPI_MODE_3,
384 },
385 {
386 .modalias = "spi_mmc",
387 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
388 .bus_num = 1,
389 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
390 .platform_data = NULL,
391 .controller_data = &spi_mmc_chip_info,
392 .mode = SPI_MODE_3,
393 },
394#endif
395#if defined(CONFIG_PBX)
396 {
397 .modalias = "fxs-spi",
398 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
399 .bus_num = 1,
400 .chip_select = 3,
401 .controller_data= &spi_si3xxx_chip_info,
402 .mode = SPI_MODE_3,
403 },
404 {
405 .modalias = "fxo-spi",
406 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
407 .bus_num = 1,
408 .chip_select = 2,
409 .controller_data= &spi_si3xxx_chip_info,
410 .mode = SPI_MODE_3,
411 },
412#endif
413#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
414{
415 .modalias = "ad7877",
416 .platform_data = &bfin_ad7877_ts_info,
417 .irq = IRQ_PF2,
418 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
419 .bus_num = 1,
420 .chip_select = 5,
421 .controller_data = &spi_ad7877_chip_info,
422},
423#endif
424
425};
426
427/* SPI controller data */
428static struct bfin5xx_spi_master spi_bfin_master_info = {
429 .num_chipselect = 8,
430 .enable_dma = 1, /* master has the ability to do dma transfer */
431};
432
433static struct platform_device spi_bfin_master_device = {
434 .name = "bfin-spi-master",
435 .id = 1, /* Bus number */
436 .dev = {
437 .platform_data = &spi_bfin_master_info, /* Passed to driver */
438 },
439};
440#endif /* spi master and devices */
441
442#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
443static struct platform_device bfin_fb_device = {
444 .name = "bf537-fb",
445};
446#endif
447
448#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
449static struct resource bfin_uart_resources[] = {
450 {
451 .start = 0xFFC00400,
452 .end = 0xFFC004FF,
453 .flags = IORESOURCE_MEM,
454 },{
455 .start = 0xFFC02000,
456 .end = 0xFFC020FF,
457 .flags = IORESOURCE_MEM,
458 },
459};
460
461static struct platform_device bfin_uart_device = {
462 .name = "bfin-uart",
463 .id = 1,
464 .num_resources = ARRAY_SIZE(bfin_uart_resources),
465 .resource = bfin_uart_resources,
466};
467#endif
468
469
470static struct platform_device *stamp_devices[] __initdata = {
471#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
472 &bfin_pcmcia_cf_device,
473#endif
474
475#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
476 &rtc_device,
477#endif
478
479#if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
480 &sl811_hcd_device,
481#endif
482
483#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
484 &isp1362_hcd_device,
485#endif
486
487#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
488 &smc91x_device,
489#endif
490
491#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
492 &bfin_mac_device,
493#endif
494
495#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
496 &net2272_bfin_device,
497#endif
498
499#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
500 &spi_bfin_master_device,
501#endif
502
503#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
504 &bfin_fb_device,
505#endif
506
507#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
508 &bfin_uart_device,
509#endif
510};
511
512static int __init stamp_init(void)
513{
514 printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
515 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
516#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
517 spi_register_board_info(bfin_spi_board_info,
518 ARRAY_SIZE(bfin_spi_board_info));
519#endif
520 return 0;
521}
522
523arch_initcall(stamp_init);
diff --git a/arch/blackfin/mach-bf537/boards/stamp.c b/arch/blackfin/mach-bf537/boards/stamp.c
new file mode 100644
index 000000000000..ba2f875a7f7d
--- /dev/null
+++ b/arch/blackfin/mach-bf537/boards/stamp.c
@@ -0,0 +1,615 @@
1/*
2 * File: arch/blackfin/mach-bf537/boards/stamp.c
3 * Based on: arch/blackfin/mach-bf533/boards/ezkit.c
4 * Author: Aidan Williams <aidan@nicta.com.au>
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2005 National ICT Australia (NICTA)
11 * Copyright 2004-2006 Analog Devices Inc.
12 *
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, see the file COPYING, or write
27 * to the Free Software Foundation, Inc.,
28 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 */
30
31#include <linux/device.h>
32#include <linux/platform_device.h>
33#include <linux/mtd/mtd.h>
34#include <linux/mtd/partitions.h>
35#include <linux/spi/spi.h>
36#include <linux/spi/flash.h>
37#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
38#include <linux/usb_isp1362.h>
39#endif
40#include <asm/irq.h>
41#include <linux/irq.h>
42#include <linux/interrupt.h>
43#include <asm/bfin5xx_spi.h>
44#include <linux/usb_sl811.h>
45
46#include <linux/spi/ad7877.h>
47
48/*
49 * Name the Board for the /proc/cpuinfo
50 */
51char *bfin_board_name = "ADDS-BF537-STAMP";
52
53/*
54 * Driver needs to know address, irq and flag pin.
55 */
56
57#define ISP1761_BASE 0x203C0000
58#define ISP1761_IRQ IRQ_PF7
59
60#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
61static struct resource bfin_isp1761_resources[] = {
62 [0] = {
63 .name = "isp1761-regs",
64 .start = ISP1761_BASE + 0x00000000,
65 .end = ISP1761_BASE + 0x000fffff,
66 .flags = IORESOURCE_MEM,
67 },
68 [1] = {
69 .start = ISP1761_IRQ,
70 .end = ISP1761_IRQ,
71 .flags = IORESOURCE_IRQ,
72 },
73};
74
75static struct platform_device bfin_isp1761_device = {
76 .name = "isp1761",
77 .id = 0,
78 .num_resources = ARRAY_SIZE(bfin_isp1761_resources),
79 .resource = bfin_isp1761_resources,
80};
81
82static struct platform_device *bfin_isp1761_devices[] = {
83 &bfin_isp1761_device,
84};
85
86int __init bfin_isp1761_init(void)
87{
88 unsigned int num_devices=ARRAY_SIZE(bfin_isp1761_devices);
89
90 printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
91 set_irq_type(ISP1761_IRQ, IRQF_TRIGGER_FALLING);
92
93 return platform_add_devices(bfin_isp1761_devices, num_devices);
94}
95
96void __exit bfin_isp1761_exit(void)
97{
98 platform_device_unregister(&bfin_isp1761_device);
99}
100
101arch_initcall(bfin_isp1761_init);
102#endif
103
104#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
105static struct resource bfin_pcmcia_cf_resources[] = {
106 {
107 .start = 0x20310000, /* IO PORT */
108 .end = 0x20312000,
109 .flags = IORESOURCE_MEM,
110 },{
111 .start = 0x20311000, /* Attribute Memeory */
112 .end = 0x20311FFF,
113 .flags = IORESOURCE_MEM,
114 },{
115 .start = IRQ_PF4,
116 .end = IRQ_PF4,
117 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
118 },{
119 .start = 6, /* Card Detect PF6 */
120 .end = 6,
121 .flags = IORESOURCE_IRQ,
122 },
123};
124
125static struct platform_device bfin_pcmcia_cf_device = {
126 .name = "bfin_cf_pcmcia",
127 .id = -1,
128 .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
129 .resource = bfin_pcmcia_cf_resources,
130};
131#endif
132
133#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
134static struct platform_device rtc_device = {
135 .name = "rtc-bfin",
136 .id = -1,
137};
138#endif
139
140#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
141static struct resource smc91x_resources[] = {
142 {
143 .name = "smc91x-regs",
144 .start = 0x20300300,
145 .end = 0x20300300 + 16,
146 .flags = IORESOURCE_MEM,
147 },{
148
149 .start = IRQ_PF7,
150 .end = IRQ_PF7,
151 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
152 },
153};
154static struct platform_device smc91x_device = {
155 .name = "smc91x",
156 .id = 0,
157 .num_resources = ARRAY_SIZE(smc91x_resources),
158 .resource = smc91x_resources,
159};
160#endif
161
162#if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
163static struct resource sl811_hcd_resources[] = {
164 {
165 .start = 0x20340000,
166 .end = 0x20340000,
167 .flags = IORESOURCE_MEM,
168 },{
169 .start = 0x20340004,
170 .end = 0x20340004,
171 .flags = IORESOURCE_MEM,
172 },{
173 .start = CONFIG_USB_SL811_BFIN_IRQ,
174 .end = CONFIG_USB_SL811_BFIN_IRQ,
175 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
176 },
177};
178
179#if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
180void sl811_port_power(struct device *dev, int is_on)
181{
182 unsigned short mask = (1 << CONFIG_USB_SL811_BFIN_GPIO_VBUS);
183
184 bfin_write_PORT_FER(bfin_read_PORT_FER() & ~mask);
185 bfin_write_FIO_DIR(bfin_read_FIO_DIR() | mask);
186
187 if (is_on)
188 bfin_write_FIO_FLAG_S(mask);
189 else
190 bfin_write_FIO_FLAG_C(mask);
191}
192#endif
193
194static struct sl811_platform_data sl811_priv = {
195 .potpg = 10,
196 .power = 250, /* == 500mA */
197#if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
198 .port_power = &sl811_port_power,
199#endif
200};
201
202static struct platform_device sl811_hcd_device = {
203 .name = "sl811-hcd",
204 .id = 0,
205 .dev = {
206 .platform_data = &sl811_priv,
207 },
208 .num_resources = ARRAY_SIZE(sl811_hcd_resources),
209 .resource = sl811_hcd_resources,
210};
211#endif
212
213#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
214static struct resource isp1362_hcd_resources[] = {
215 {
216 .start = 0x20360000,
217 .end = 0x20360000,
218 .flags = IORESOURCE_MEM,
219 },{
220 .start = 0x20360004,
221 .end = 0x20360004,
222 .flags = IORESOURCE_MEM,
223 },{
224 .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
225 .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
226 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
227 },
228};
229
230static struct isp1362_platform_data isp1362_priv = {
231 .sel15Kres = 1,
232 .clknotstop = 0,
233 .oc_enable = 0,
234 .int_act_high = 0,
235 .int_edge_triggered = 0,
236 .remote_wakeup_connected = 0,
237 .no_power_switching = 1,
238 .power_switching_mode = 0,
239};
240
241static struct platform_device isp1362_hcd_device = {
242 .name = "isp1362-hcd",
243 .id = 0,
244 .dev = {
245 .platform_data = &isp1362_priv,
246 },
247 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
248 .resource = isp1362_hcd_resources,
249};
250#endif
251
252#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
253static struct platform_device bfin_mac_device = {
254 .name = "bfin_mac",
255};
256#endif
257
258#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
259static struct resource net2272_bfin_resources[] = {
260 {
261 .start = 0x20300000,
262 .end = 0x20300000 + 0x100,
263 .flags = IORESOURCE_MEM,
264 },{
265 .start = IRQ_PF7,
266 .end = IRQ_PF7,
267 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
268 },
269};
270
271static struct platform_device net2272_bfin_device = {
272 .name = "net2272",
273 .id = -1,
274 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
275 .resource = net2272_bfin_resources,
276};
277#endif
278
279#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
280/* all SPI peripherals info goes here */
281
282#if defined(CONFIG_MTD_M25P80) \
283 || defined(CONFIG_MTD_M25P80_MODULE)
284static struct mtd_partition bfin_spi_flash_partitions[] = {
285 {
286 .name = "bootloader",
287 .size = 0x00020000,
288 .offset = 0,
289 .mask_flags = MTD_CAP_ROM
290 },{
291 .name = "kernel",
292 .size = 0xe0000,
293 .offset = 0x20000
294 },{
295 .name = "file system",
296 .size = 0x700000,
297 .offset = 0x00100000,
298 }
299};
300
301static struct flash_platform_data bfin_spi_flash_data = {
302 .name = "m25p80",
303 .parts = bfin_spi_flash_partitions,
304 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
305 .type = "m25p64",
306};
307
308/* SPI flash chip (m25p64) */
309static struct bfin5xx_spi_chip spi_flash_chip_info = {
310 .enable_dma = 0, /* use dma transfer with this chip*/
311 .bits_per_word = 8,
312};
313#endif
314
315#if defined(CONFIG_SPI_ADC_BF533) \
316 || defined(CONFIG_SPI_ADC_BF533_MODULE)
317/* SPI ADC chip */
318static struct bfin5xx_spi_chip spi_adc_chip_info = {
319 .enable_dma = 1, /* use dma transfer with this chip*/
320 .bits_per_word = 16,
321};
322#endif
323
324#if defined(CONFIG_SND_BLACKFIN_AD1836) \
325 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
326static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
327 .enable_dma = 0,
328 .bits_per_word = 16,
329};
330#endif
331
332#if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
333static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
334 .enable_dma = 0,
335 .bits_per_word = 16,
336};
337#endif
338
339#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
340static struct bfin5xx_spi_chip spi_mmc_chip_info = {
341 .enable_dma = 1,
342 .bits_per_word = 8,
343};
344#endif
345
346#if defined(CONFIG_PBX)
347static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
348 .ctl_reg = 0x4, /* send zero */
349 .enable_dma = 0,
350 .bits_per_word = 8,
351 .cs_change_per_word = 1,
352};
353#endif
354
355#if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
356static struct bfin5xx_spi_chip ad5304_chip_info = {
357 .enable_dma = 0,
358 .bits_per_word = 16,
359};
360#endif
361
362#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
363static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
364// .cs_change_per_word = 1,
365 .enable_dma = 0,
366 .bits_per_word = 16,
367};
368
369static const struct ad7877_platform_data bfin_ad7877_ts_info = {
370 .model = 7877,
371 .vref_delay_usecs = 50, /* internal, no capacitor */
372 .x_plate_ohms = 419,
373 .y_plate_ohms = 486,
374 .pressure_max = 1000,
375 .pressure_min = 0,
376 .stopacq_polarity = 1,
377 .first_conversion_delay = 3,
378 .acquisition_time = 1,
379 .averaging = 1,
380 .pen_down_acc_interval = 1,
381};
382#endif
383
384static struct spi_board_info bfin_spi_board_info[] __initdata = {
385#if defined(CONFIG_MTD_M25P80) \
386 || defined(CONFIG_MTD_M25P80_MODULE)
387 {
388 /* the modalias must be the same as spi device driver name */
389 .modalias = "m25p80", /* Name of spi_driver for this device */
390 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
391 .bus_num = 1, /* Framework bus number */
392 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
393 .platform_data = &bfin_spi_flash_data,
394 .controller_data = &spi_flash_chip_info,
395 .mode = SPI_MODE_3,
396 },
397#endif
398
399#if defined(CONFIG_SPI_ADC_BF533) \
400 || defined(CONFIG_SPI_ADC_BF533_MODULE)
401 {
402 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
403 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
404 .bus_num = 1, /* Framework bus number */
405 .chip_select = 1, /* Framework chip select. */
406 .platform_data = NULL, /* No spi_driver specific config */
407 .controller_data = &spi_adc_chip_info,
408 },
409#endif
410
411#if defined(CONFIG_SND_BLACKFIN_AD1836) \
412 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
413 {
414 .modalias = "ad1836-spi",
415 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
416 .bus_num = 1,
417 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
418 .controller_data = &ad1836_spi_chip_info,
419 },
420#endif
421#if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
422 {
423 .modalias = "ad9960-spi",
424 .max_speed_hz = 10000000, /* max spi clock (SCK) speed in HZ */
425 .bus_num = 1,
426 .chip_select = 1,
427 .controller_data = &ad9960_spi_chip_info,
428 },
429#endif
430#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
431 {
432 .modalias = "spi_mmc_dummy",
433 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
434 .bus_num = 1,
435 .chip_select = 0,
436 .platform_data = NULL,
437 .controller_data = &spi_mmc_chip_info,
438 .mode = SPI_MODE_3,
439 },
440 {
441 .modalias = "spi_mmc",
442 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
443 .bus_num = 1,
444 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
445 .platform_data = NULL,
446 .controller_data = &spi_mmc_chip_info,
447 .mode = SPI_MODE_3,
448 },
449#endif
450#if defined(CONFIG_PBX)
451 {
452 .modalias = "fxs-spi",
453 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
454 .bus_num = 1,
455 .chip_select = 3,
456 .controller_data= &spi_si3xxx_chip_info,
457 .mode = SPI_MODE_3,
458 },
459 {
460 .modalias = "fxo-spi",
461 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
462 .bus_num = 1,
463 .chip_select = 2,
464 .controller_data= &spi_si3xxx_chip_info,
465 .mode = SPI_MODE_3,
466 },
467#endif
468#if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
469 {
470 .modalias = "ad5304_spi",
471 .max_speed_hz = 1250000, /* max spi clock (SCK) speed in HZ */
472 .bus_num = 1,
473 .chip_select = 2,
474 .platform_data = NULL,
475 .controller_data = &ad5304_chip_info,
476 .mode = SPI_MODE_2,
477 },
478#endif
479#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
480 {
481 .modalias = "ad7877",
482 .platform_data = &bfin_ad7877_ts_info,
483 .irq = IRQ_PF6,
484 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
485 .bus_num = 1,
486 .chip_select = 1,
487 .controller_data = &spi_ad7877_chip_info,
488 },
489#endif
490};
491
492/* SPI controller data */
493static struct bfin5xx_spi_master spi_bfin_master_info = {
494 .num_chipselect = 8,
495 .enable_dma = 1, /* master has the ability to do dma transfer */
496};
497
498static struct platform_device spi_bfin_master_device = {
499 .name = "bfin-spi-master",
500 .id = 1, /* Bus number */
501 .dev = {
502 .platform_data = &spi_bfin_master_info, /* Passed to driver */
503 },
504};
505#endif /* spi master and devices */
506
507#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
508static struct platform_device bfin_fb_device = {
509 .name = "bf537-fb",
510};
511#endif
512
513#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
514static struct resource bfin_uart_resources[] = {
515 {
516 .start = 0xFFC00400,
517 .end = 0xFFC004FF,
518 .flags = IORESOURCE_MEM,
519 },{
520 .start = 0xFFC02000,
521 .end = 0xFFC020FF,
522 .flags = IORESOURCE_MEM,
523 },
524};
525
526static struct platform_device bfin_uart_device = {
527 .name = "bfin-uart",
528 .id = 1,
529 .num_resources = ARRAY_SIZE(bfin_uart_resources),
530 .resource = bfin_uart_resources,
531};
532#endif
533
534#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
535static struct platform_device i2c_bfin_twi_device = {
536 .name = "i2c-bfin-twi",
537 .id = 0,
538};
539#endif
540
541#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
542static struct platform_device bfin_sport0_uart_device = {
543 .name = "bfin-sport-uart",
544 .id = 0,
545};
546
547static struct platform_device bfin_sport1_uart_device = {
548 .name = "bfin-sport-uart",
549 .id = 1,
550};
551#endif
552
553static struct platform_device *stamp_devices[] __initdata = {
554#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
555 &bfin_pcmcia_cf_device,
556#endif
557
558#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
559 &rtc_device,
560#endif
561
562#if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
563 &sl811_hcd_device,
564#endif
565
566#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
567 &isp1362_hcd_device,
568#endif
569
570#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
571 &smc91x_device,
572#endif
573
574#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
575 &bfin_mac_device,
576#endif
577
578#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
579 &net2272_bfin_device,
580#endif
581
582#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
583 &spi_bfin_master_device,
584#endif
585
586#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
587 &bfin_fb_device,
588#endif
589
590#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
591 &bfin_uart_device,
592#endif
593
594#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
595 &i2c_bfin_twi_device,
596#endif
597
598#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
599 &bfin_sport0_uart_device,
600 &bfin_sport1_uart_device,
601#endif
602};
603
604static int __init stamp_init(void)
605{
606 printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
607 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
608#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
609 spi_register_board_info(bfin_spi_board_info,
610 ARRAY_SIZE(bfin_spi_board_info));
611#endif
612 return 0;
613}
614
615arch_initcall(stamp_init);
diff --git a/arch/blackfin/mach-bf537/cpu.c b/arch/blackfin/mach-bf537/cpu.c
new file mode 100644
index 000000000000..2d83b7e35469
--- /dev/null
+++ b/arch/blackfin/mach-bf537/cpu.c
@@ -0,0 +1,161 @@
1/*
2 * File: arch/blackfin/mach-bf537/cpu.c
3 * Based on:
4 * Author: michael.kang@analog.com
5 *
6 * Created:
7 * Description: clock scaling for the bf537
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/kernel.h>
31#include <linux/types.h>
32#include <linux/init.h>
33#include <linux/cpufreq.h>
34#include <asm/dpmc.h>
35#include <linux/fs.h>
36#include <asm/bfin-global.h>
37
38/* CONFIG_CLKIN_HZ=11059200 */
39#define VCO5 (CONFIG_CLKIN_HZ*45) /*497664000 */
40#define VCO4 (CONFIG_CLKIN_HZ*36) /*398131200 */
41#define VCO3 (CONFIG_CLKIN_HZ*27) /*298598400 */
42#define VCO2 (CONFIG_CLKIN_HZ*18) /*199065600 */
43#define VCO1 (CONFIG_CLKIN_HZ*9) /*99532800 */
44#define VCO(x) VCO##x
45
46#define FREQ(x) {VCO(x),VCO(x)/4},{VCO(x),VCO(x)/2},{VCO(x),VCO(x)}
47/* frequency */
48static struct cpufreq_frequency_table bf537_freq_table[] = {
49 FREQ(1),
50 FREQ(3),
51 {VCO4, VCO4 / 2}, {VCO4, VCO4},
52 FREQ(5),
53 {0, CPUFREQ_TABLE_END},
54};
55
56/*
57 * dpmc_fops->ioctl()
58 * static int dpmc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
59 */
60static int bf537_getfreq(unsigned int cpu)
61{
62 unsigned long cclk_mhz, vco_mhz;
63
64 /* The driver only support single cpu */
65 if (cpu == 0)
66 dpmc_fops.ioctl(NULL, NULL, IOCTL_GET_CORECLOCK, &cclk_mhz);
67 else
68 cclk_mhz = -1;
69 return cclk_mhz;
70}
71
72static int bf537_target(struct cpufreq_policy *policy,
73 unsigned int target_freq, unsigned int relation)
74{
75 unsigned long cclk_mhz;
76 unsigned long vco_mhz;
77 unsigned long flags;
78 unsigned int index, vco_index;
79 int i;
80
81 struct cpufreq_freqs freqs;
82 if (cpufreq_frequency_table_target
83 (policy, bf537_freq_table, target_freq, relation, &index))
84 return -EINVAL;
85 cclk_mhz = bf537_freq_table[index].frequency;
86 vco_mhz = bf537_freq_table[index].index;
87
88 dpmc_fops.ioctl(NULL, NULL, IOCTL_CHANGE_FREQUENCY, &vco_mhz);
89 freqs.old = bf537_getfreq(0);
90 freqs.new = cclk_mhz;
91 freqs.cpu = 0;
92
93 pr_debug("cclk begin change to cclk %d,vco=%d,index=%d,target=%d,oldfreq=%d\n",
94 cclk_mhz, vco_mhz, index, target_freq, freqs.old);
95
96 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
97 local_irq_save(flags);
98 dpmc_fops.ioctl(NULL, NULL, IOCTL_SET_CCLK, &cclk_mhz);
99 local_irq_restore(flags);
100 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
101
102 vco_mhz = get_vco();
103 cclk_mhz = get_cclk();
104 return 0;
105}
106
107/* make sure that only the "userspace" governor is run -- anything else wouldn't make sense on
108 * this platform, anyway.
109 */
110static int bf537_verify_speed(struct cpufreq_policy *policy)
111{
112 return cpufreq_frequency_table_verify(policy, &bf537_freq_table);
113}
114
115static int __init __bf537_cpu_init(struct cpufreq_policy *policy)
116{
117 int result;
118
119 if (policy->cpu != 0)
120 return -EINVAL;
121
122 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
123
124 policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
125 /*Now ,only support one cpu */
126 policy->cur = bf537_getfreq(0);
127 cpufreq_frequency_table_get_attr(bf537_freq_table, policy->cpu);
128 return cpufreq_frequency_table_cpuinfo(policy, bf537_freq_table);
129}
130
131static struct freq_attr *bf537_freq_attr[] = {
132 &cpufreq_freq_attr_scaling_available_freqs,
133 NULL,
134};
135
136static struct cpufreq_driver bf537_driver = {
137 .verify = bf537_verify_speed,
138 .target = bf537_target,
139 .get = bf537_getfreq,
140 .init = __bf537_cpu_init,
141 .name = "bf537",
142 .owner = THIS_MODULE,
143 .attr = bf537_freq_attr,
144};
145
146static int __init bf537_cpu_init(void)
147{
148 return cpufreq_register_driver(&bf537_driver);
149}
150
151static void __exit bf537_cpu_exit(void)
152{
153 cpufreq_unregister_driver(&bf537_driver);
154}
155
156MODULE_AUTHOR("Mickael Kang");
157MODULE_DESCRIPTION("cpufreq driver for BF537 CPU");
158MODULE_LICENSE("GPL");
159
160module_init(bf537_cpu_init);
161module_exit(bf537_cpu_exit);
diff --git a/arch/blackfin/mach-bf537/head.S b/arch/blackfin/mach-bf537/head.S
new file mode 100644
index 000000000000..d104e1d8e07a
--- /dev/null
+++ b/arch/blackfin/mach-bf537/head.S
@@ -0,0 +1,602 @@
1/*
2 * File: arch/blackfin/mach-bf537/head.S
3 * Based on: arch/blackfin/mach-bf533/head.S
4 * Author: Jeff Dionne <jeff@uclinux.org> COPYRIGHT 1998 D. Jeff Dionne
5 *
6 * Created: 1998
7 * Description: Startup code for Blackfin BF537
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/linkage.h>
31#include <asm/blackfin.h>
32#if CONFIG_BFIN_KERNEL_CLOCK
33#include <asm/mach/mem_init.h>
34#endif
35
36.global __rambase
37.global __ramstart
38.global __ramend
39.extern ___bss_stop
40.extern ___bss_start
41.extern _bf53x_relocate_l1_mem
42
43#define INITIAL_STACK 0xFFB01000
44
45.text
46
47ENTRY(__start)
48ENTRY(__stext)
49 /* R0: argument of command line string, passed from uboot, save it */
50 R7 = R0;
51 /* Set the SYSCFG register */
52 R0 = 0x36;
53 SYSCFG = R0; /*Enable Cycle Counter and Nesting Of Interrupts(3rd Bit)*/
54 R0 = 0;
55
56 /* Clear Out All the data and pointer Registers*/
57 R1 = R0;
58 R2 = R0;
59 R3 = R0;
60 R4 = R0;
61 R5 = R0;
62 R6 = R0;
63
64 P0 = R0;
65 P1 = R0;
66 P2 = R0;
67 P3 = R0;
68 P4 = R0;
69 P5 = R0;
70
71 LC0 = r0;
72 LC1 = r0;
73 L0 = r0;
74 L1 = r0;
75 L2 = r0;
76 L3 = r0;
77
78 /* Clear Out All the DAG Registers*/
79 B0 = r0;
80 B1 = r0;
81 B2 = r0;
82 B3 = r0;
83
84 I0 = r0;
85 I1 = r0;
86 I2 = r0;
87 I3 = r0;
88
89 M0 = r0;
90 M1 = r0;
91 M2 = r0;
92 M3 = r0;
93
94 /* Turn off the icache */
95 p0.l = (IMEM_CONTROL & 0xFFFF);
96 p0.h = (IMEM_CONTROL >> 16);
97 R1 = [p0];
98 R0 = ~ENICPLB;
99 R0 = R0 & R1;
100
101 /* Anomaly 05000125 */
102#ifdef ANOMALY_05000125
103 CLI R2;
104 SSYNC;
105#endif
106 [p0] = R0;
107 SSYNC;
108#ifdef ANOMALY_05000125
109 STI R2;
110#endif
111
112 /* Turn off the dcache */
113 p0.l = (DMEM_CONTROL & 0xFFFF);
114 p0.h = (DMEM_CONTROL >> 16);
115 R1 = [p0];
116 R0 = ~ENDCPLB;
117 R0 = R0 & R1;
118
119 /* Anomaly 05000125 */
120#ifdef ANOMALY_05000125
121 CLI R2;
122 SSYNC;
123#endif
124 [p0] = R0;
125 SSYNC;
126#ifdef ANOMALY_05000125
127 STI R2;
128#endif
129
130 /* Initialise General-Purpose I/O Modules on BF537 */
131 /* Rev 0.0 Anomaly 05000212 - PORTx_FER,
132 * PORT_MUX Registers Do Not accept "writes" correctly:
133 */
134 p0.h = hi(BFIN_PORT_MUX);
135 p0.l = lo(BFIN_PORT_MUX);
136#ifdef ANOMALY_05000212
137 R0.L = W[P0]; /* Read */
138 SSYNC;
139#endif
140 R0 = (PGDE_UART | PFTE_UART)(Z);
141#ifdef ANOMALY_05000212
142 W[P0] = R0.L; /* Write */
143 SSYNC;
144#endif
145 W[P0] = R0.L; /* Enable both UARTS */
146 SSYNC;
147
148 p0.h = hi(PORTF_FER);
149 p0.l = lo(PORTF_FER);
150#ifdef ANOMALY_05000212
151 R0.L = W[P0]; /* Read */
152 SSYNC;
153#endif
154 R0 = 0x000F(Z);
155#ifdef ANOMALY_05000212
156 W[P0] = R0.L; /* Write */
157 SSYNC;
158#endif
159 /* Enable peripheral function of PORTF for UART0 and UART1 */
160 W[P0] = R0.L;
161 SSYNC;
162
163#if !defined(CONFIG_BF534)
164 p0.h = hi(EMAC_SYSTAT);
165 p0.l = lo(EMAC_SYSTAT);
166 R0.h = 0xFFFF; /* Clear EMAC Interrupt Status bits */
167 R0.l = 0xFFFF;
168 [P0] = R0;
169 SSYNC;
170#endif
171
172#ifdef CONFIG_BF537_PORT_H
173 p0.h = hi(PORTH_FER);
174 p0.l = lo(PORTH_FER);
175 R0.L = W[P0]; /* Read */
176 SSYNC;
177 R0 = 0x0000;
178 W[P0] = R0.L; /* Write */
179 SSYNC;
180 W[P0] = R0.L; /* Disable peripheral function of PORTH */
181 SSYNC;
182#endif
183
184 /*Initialise UART*/
185 p0.h = hi(UART_LCR);
186 p0.l = lo(UART_LCR);
187 r0 = 0x0(Z);
188 w[p0] = r0.L; /* To enable DLL writes */
189 ssync;
190
191 p0.h = hi(UART_DLL);
192 p0.l = lo(UART_DLL);
193 r0 = 0x00(Z);
194 w[p0] = r0.L;
195 ssync;
196
197 p0.h = hi(UART_DLH);
198 p0.l = lo(UART_DLH);
199 r0 = 0x00(Z);
200 w[p0] = r0.L;
201 ssync;
202
203 p0.h = hi(UART_GCTL);
204 p0.l = lo(UART_GCTL);
205 r0 = 0x0(Z);
206 w[p0] = r0.L; /* To enable UART clock */
207 ssync;
208
209 /* Initialize stack pointer */
210 sp.l = lo(INITIAL_STACK);
211 sp.h = hi(INITIAL_STACK);
212 fp = sp;
213 usp = sp;
214
215 /* Put The Code for PLL Programming and SDRAM Programming in L1 ISRAM */
216 call _bf53x_relocate_l1_mem;
217#if CONFIG_BFIN_KERNEL_CLOCK
218 call _start_dma_code;
219#endif
220 /* Code for initializing Async memory banks */
221
222 p2.h = hi(EBIU_AMBCTL1);
223 p2.l = lo(EBIU_AMBCTL1);
224 r0.h = hi(AMBCTL1VAL);
225 r0.l = lo(AMBCTL1VAL);
226 [p2] = r0;
227 ssync;
228
229 p2.h = hi(EBIU_AMBCTL0);
230 p2.l = lo(EBIU_AMBCTL0);
231 r0.h = hi(AMBCTL0VAL);
232 r0.l = lo(AMBCTL0VAL);
233 [p2] = r0;
234 ssync;
235
236 p2.h = hi(EBIU_AMGCTL);
237 p2.l = lo(EBIU_AMGCTL);
238 r0 = AMGCTLVAL;
239 w[p2] = r0;
240 ssync;
241
242 /* This section keeps the processor in supervisor mode
243 * during kernel boot. Switches to user mode at end of boot.
244 * See page 3-9 of Hardware Reference manual for documentation.
245 */
246
247 /* EVT15 = _real_start */
248
249 p0.l = lo(EVT15);
250 p0.h = hi(EVT15);
251 p1.l = _real_start;
252 p1.h = _real_start;
253 [p0] = p1;
254 csync;
255
256 p0.l = lo(IMASK);
257 p0.h = hi(IMASK);
258 p1.l = IMASK_IVG15;
259 p1.h = 0x0;
260 [p0] = p1;
261 csync;
262
263 raise 15;
264 p0.l = .LWAIT_HERE;
265 p0.h = .LWAIT_HERE;
266 reti = p0;
267#if defined(ANOMALY_05000281)
268 nop; nop; nop;
269#endif
270 rti;
271
272.LWAIT_HERE:
273 jump .LWAIT_HERE;
274
275ENTRY(_real_start)
276 [ -- sp ] = reti;
277 p0.l = lo(WDOG_CTL);
278 p0.h = hi(WDOG_CTL);
279 r0 = 0xAD6(z);
280 w[p0] = r0; /* watchdog off for now */
281 ssync;
282
283 /* Code update for BSS size == 0
284 * Zero out the bss region.
285 */
286
287 p1.l = ___bss_start;
288 p1.h = ___bss_start;
289 p2.l = ___bss_stop;
290 p2.h = ___bss_stop;
291 r0 = 0;
292 p2 -= p1;
293 lsetup (.L_clear_bss, .L_clear_bss ) lc0 = p2;
294.L_clear_bss:
295 B[p1++] = r0;
296
297 /* In case there is a NULL pointer reference
298 * Zero out region before stext
299 */
300
301 p1.l = 0x0;
302 p1.h = 0x0;
303 r0.l = __stext;
304 r0.h = __stext;
305 r0 = r0 >> 1;
306 p2 = r0;
307 r0 = 0;
308 lsetup (.L_clear_zero, .L_clear_zero ) lc0 = p2;
309.L_clear_zero:
310 W[p1++] = r0;
311
312 /* pass the uboot arguments to the global value command line */
313 R0 = R7;
314 call _cmdline_init;
315
316 p1.l = __rambase;
317 p1.h = __rambase;
318 r0.l = __sdata;
319 r0.h = __sdata;
320 [p1] = r0;
321
322 p1.l = __ramstart;
323 p1.h = __ramstart;
324 p3.l = ___bss_stop;
325 p3.h = ___bss_stop;
326
327 r1 = p3;
328 [p1] = r1;
329
330
331 /*
332 * load the current thread pointer and stack
333 */
334 r1.l = _init_thread_union;
335 r1.h = _init_thread_union;
336
337 r2.l = 0x2000;
338 r2.h = 0x0000;
339 r1 = r1 + r2;
340 sp = r1;
341 usp = sp;
342 fp = sp;
343 call _start_kernel;
344.L_exit:
345 jump.s .L_exit;
346
347.section .l1.text
348#if CONFIG_BFIN_KERNEL_CLOCK
349ENTRY(_start_dma_code)
350
351 /* Enable PHY CLK buffer output */
352 p0.h = hi(VR_CTL);
353 p0.l = lo(VR_CTL);
354 r0.l = w[p0];
355 bitset(r0, 14);
356 w[p0] = r0.l;
357 ssync;
358
359 p0.h = hi(SIC_IWR);
360 p0.l = lo(SIC_IWR);
361 r0.l = 0x1;
362 r0.h = 0x0;
363 [p0] = r0;
364 SSYNC;
365
366 /*
367 * Set PLL_CTL
368 * - [14:09] = MSEL[5:0] : CLKIN / VCO multiplication factors
369 * - [8] = BYPASS : BYPASS the PLL, run CLKIN into CCLK/SCLK
370 * - [7] = output delay (add 200ps of delay to mem signals)
371 * - [6] = input delay (add 200ps of input delay to mem signals)
372 * - [5] = PDWN : 1=All Clocks off
373 * - [3] = STOPCK : 1=Core Clock off
374 * - [1] = PLL_OFF : 1=Disable Power to PLL
375 * - [0] = DF : 1=Pass CLKIN/2 to PLL / 0=Pass CLKIN to PLL
376 * all other bits set to zero
377 */
378
379 p0.h = hi(PLL_LOCKCNT);
380 p0.l = lo(PLL_LOCKCNT);
381 r0 = 0x300(Z);
382 w[p0] = r0.l;
383 ssync;
384
385 P2.H = hi(EBIU_SDGCTL);
386 P2.L = lo(EBIU_SDGCTL);
387 R0 = [P2];
388 BITSET (R0, 24);
389 [P2] = R0;
390 SSYNC;
391
392 r0 = CONFIG_VCO_MULT & 63; /* Load the VCO multiplier */
393 r0 = r0 << 9; /* Shift it over, */
394 r1 = CLKIN_HALF; /* Do we need to divide CLKIN by 2?*/
395 r0 = r1 | r0;
396 r1 = PLL_BYPASS; /* Bypass the PLL? */
397 r1 = r1 << 8; /* Shift it over */
398 r0 = r1 | r0; /* add them all together */
399
400 p0.h = hi(PLL_CTL);
401 p0.l = lo(PLL_CTL); /* Load the address */
402 cli r2; /* Disable interrupts */
403 ssync;
404 w[p0] = r0.l; /* Set the value */
405 idle; /* Wait for the PLL to stablize */
406 sti r2; /* Enable interrupts */
407
408.Lcheck_again:
409 p0.h = hi(PLL_STAT);
410 p0.l = lo(PLL_STAT);
411 R0 = W[P0](Z);
412 CC = BITTST(R0,5);
413 if ! CC jump .Lcheck_again;
414
415 /* Configure SCLK & CCLK Dividers */
416 r0 = (CONFIG_CCLK_ACT_DIV | CONFIG_SCLK_DIV);
417 p0.h = hi(PLL_DIV);
418 p0.l = lo(PLL_DIV);
419 w[p0] = r0.l;
420 ssync;
421
422 p0.l = lo(EBIU_SDRRC);
423 p0.h = hi(EBIU_SDRRC);
424 r0 = mem_SDRRC;
425 w[p0] = r0.l;
426 ssync;
427
428 p0.l = (EBIU_SDBCTL & 0xFFFF);
429 p0.h = (EBIU_SDBCTL >> 16); /* SDRAM Memory Bank Control Register */
430 r0 = mem_SDBCTL;
431 w[p0] = r0.l;
432 ssync;
433
434 P2.H = hi(EBIU_SDGCTL);
435 P2.L = lo(EBIU_SDGCTL);
436 R0 = [P2];
437 BITCLR (R0, 24);
438 p0.h = hi(EBIU_SDSTAT);
439 p0.l = lo(EBIU_SDSTAT);
440 r2.l = w[p0];
441 cc = bittst(r2,3);
442 if !cc jump .Lskip;
443 NOP;
444 BITSET (R0, 23);
445.Lskip:
446 [P2] = R0;
447 SSYNC;
448
449 R0.L = lo(mem_SDGCTL);
450 R0.H = hi(mem_SDGCTL);
451 R1 = [p2];
452 R1 = R1 | R0;
453 [P2] = R1;
454 SSYNC;
455
456 p0.h = hi(SIC_IWR);
457 p0.l = lo(SIC_IWR);
458 r0.l = lo(IWR_ENABLE_ALL);
459 r0.h = hi(IWR_ENABLE_ALL);
460 [p0] = r0;
461 SSYNC;
462
463 RTS;
464#endif /* CONFIG_BFIN_KERNEL_CLOCK */
465
466ENTRY(_bfin_reset)
467 /* No more interrupts to be handled*/
468 CLI R6;
469 SSYNC;
470
471#if defined(CONFIG_MTD_M25P80)
472/*
473 * The following code fix the SPI flash reboot issue,
474 * /CS signal of the chip which is using PF10 return to GPIO mode
475 */
476 p0.h = hi(PORTF_FER);
477 p0.l = lo(PORTF_FER);
478 r0.l = 0x0000;
479 w[p0] = r0.l;
480 SSYNC;
481
482/* /CS return to high */
483 p0.h = hi(PORTFIO);
484 p0.l = lo(PORTFIO);
485 r0.l = 0xFFFF;
486 w[p0] = r0.l;
487 SSYNC;
488
489/* Delay some time, This is necessary */
490 r1.h = 0;
491 r1.l = 0x400;
492 p1 = r1;
493 lsetup (_delay_lab1,_delay_lab1_end ) lc1 = p1;
494_delay_lab1:
495 r0.h = 0;
496 r0.l = 0x8000;
497 p0 = r0;
498 lsetup (_delay_lab0,_delay_lab0_end ) lc0 = p0;
499_delay_lab0:
500 nop;
501_delay_lab0_end:
502 nop;
503_delay_lab1_end:
504 nop;
505#endif
506
507 /* Clear the bits 13-15 in SWRST if they werent cleared */
508 p0.h = hi(SWRST);
509 p0.l = lo(SWRST);
510 csync;
511 r0.l = w[p0];
512
513 /* Clear the IMASK register */
514 p0.h = hi(IMASK);
515 p0.l = lo(IMASK);
516 r0 = 0x0;
517 [p0] = r0;
518
519 /* Clear the ILAT register */
520 p0.h = hi(ILAT);
521 p0.l = lo(ILAT);
522 r0 = [p0];
523 [p0] = r0;
524 SSYNC;
525
526 /* Disable the WDOG TIMER */
527 p0.h = hi(WDOG_CTL);
528 p0.l = lo(WDOG_CTL);
529 r0.l = 0xAD6;
530 w[p0] = r0.l;
531 SSYNC;
532
533 /* Clear the sticky bit incase it is already set */
534 p0.h = hi(WDOG_CTL);
535 p0.l = lo(WDOG_CTL);
536 r0.l = 0x8AD6;
537 w[p0] = r0.l;
538 SSYNC;
539
540 /* Program the count value */
541 R0.l = 0x100;
542 R0.h = 0x0;
543 P0.h = hi(WDOG_CNT);
544 P0.l = lo(WDOG_CNT);
545 [P0] = R0;
546 SSYNC;
547
548 /* Program WDOG_STAT if necessary */
549 P0.h = hi(WDOG_CTL);
550 P0.l = lo(WDOG_CTL);
551 R0 = W[P0](Z);
552 CC = BITTST(R0,1);
553 if !CC JUMP .LWRITESTAT;
554 CC = BITTST(R0,2);
555 if !CC JUMP .LWRITESTAT;
556 JUMP .LSKIP_WRITE;
557
558.LWRITESTAT:
559 /* When watch dog timer is enabled,
560 * a write to STAT will load the contents of CNT to STAT
561 */
562 R0 = 0x0000(z);
563 P0.h = hi(WDOG_STAT);
564 P0.l = lo(WDOG_STAT)
565 [P0] = R0;
566 SSYNC;
567
568.LSKIP_WRITE:
569 /* Enable the reset event */
570 P0.h = hi(WDOG_CTL);
571 P0.l = lo(WDOG_CTL);
572 R0 = W[P0](Z);
573 BITCLR(R0,1);
574 BITCLR(R0,2);
575 W[P0] = R0.L;
576 SSYNC;
577 NOP;
578
579 /* Enable the wdog counter */
580 R0 = W[P0](Z);
581 BITCLR(R0,4);
582 W[P0] = R0.L;
583 SSYNC;
584
585 IDLE;
586
587 RTS;
588
589.data
590
591/*
592 * Set up the usable of RAM stuff. Size of RAM is determined then
593 * an initial stack set up at the end.
594 */
595
596.align 4
597__rambase:
598.long 0
599__ramstart:
600.long 0
601__ramend:
602.long 0
diff --git a/arch/blackfin/mach-bf537/ints-priority.c b/arch/blackfin/mach-bf537/ints-priority.c
new file mode 100644
index 000000000000..fd6308eccbe6
--- /dev/null
+++ b/arch/blackfin/mach-bf537/ints-priority.c
@@ -0,0 +1,74 @@
1/*
2 * File: arch/blackfin/mach-bf537/ints-priority.c
3 * Based on: arch/blackfin/mach-bf533/ints-priority.c
4 * Author: Michael Hennerich
5 *
6 * Created:
7 * Description: Set up the interupt priorities
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/module.h>
31#include <asm/blackfin.h>
32#include <asm/irq.h>
33
34void program_IAR(void)
35{
36 /* Program the IAR0 Register with the configured priority */
37 bfin_write_SIC_IAR0(((CONFIG_IRQ_PLL_WAKEUP - 7) << IRQ_PLL_WAKEUP_POS) |
38 ((CONFIG_IRQ_DMA_ERROR - 7) << IRQ_DMA_ERROR_POS) |
39 ((CONFIG_IRQ_ERROR - 7) << IRQ_ERROR_POS) |
40 ((CONFIG_IRQ_RTC - 7) << IRQ_RTC_POS) |
41 ((CONFIG_IRQ_PPI - 7) << IRQ_PPI_POS) |
42 ((CONFIG_IRQ_SPORT0_RX - 7) << IRQ_SPORT0_RX_POS) |
43 ((CONFIG_IRQ_SPORT0_TX - 7) << IRQ_SPORT0_TX_POS) |
44 ((CONFIG_IRQ_SPORT1_RX - 7) << IRQ_SPORT1_RX_POS));
45
46 bfin_write_SIC_IAR1(((CONFIG_IRQ_SPORT1_TX - 7) << IRQ_SPORT1_TX_POS) |
47 ((CONFIG_IRQ_TWI - 7) << IRQ_TWI_POS) |
48 ((CONFIG_IRQ_SPI - 7) << IRQ_SPI_POS) |
49 ((CONFIG_IRQ_UART0_RX - 7) << IRQ_UART0_RX_POS) |
50 ((CONFIG_IRQ_UART0_TX - 7) << IRQ_UART0_TX_POS) |
51 ((CONFIG_IRQ_UART1_RX - 7) << IRQ_UART1_RX_POS) |
52 ((CONFIG_IRQ_UART1_TX - 7) << IRQ_UART1_TX_POS) |
53 ((CONFIG_IRQ_CAN_RX - 7) << IRQ_CAN_RX_POS));
54
55 bfin_write_SIC_IAR2(((CONFIG_IRQ_CAN_TX - 7) << IRQ_CAN_TX_POS) |
56 ((CONFIG_IRQ_MAC_RX - 7) << IRQ_MAC_RX_POS) |
57 ((CONFIG_IRQ_MAC_TX - 7) << IRQ_MAC_TX_POS) |
58 ((CONFIG_IRQ_TMR0 - 7) << IRQ_TMR0_POS) |
59 ((CONFIG_IRQ_TMR1 - 7) << IRQ_TMR1_POS) |
60 ((CONFIG_IRQ_TMR2 - 7) << IRQ_TMR2_POS) |
61 ((CONFIG_IRQ_TMR3 - 7) << IRQ_TMR3_POS) |
62 ((CONFIG_IRQ_TMR4 - 7) << IRQ_TMR4_POS));
63
64 bfin_write_SIC_IAR3(((CONFIG_IRQ_TMR5 - 7) << IRQ_TMR5_POS) |
65 ((CONFIG_IRQ_TMR6 - 7) << IRQ_TMR6_POS) |
66 ((CONFIG_IRQ_TMR7 - 7) << IRQ_TMR7_POS) |
67 ((CONFIG_IRQ_PROG_INTA - 7) << IRQ_PROG_INTA_POS) |
68 ((CONFIG_IRQ_PORTG_INTB - 7) << IRQ_PORTG_INTB_POS) |
69 ((CONFIG_IRQ_MEM_DMA0 - 7) << IRQ_MEM_DMA0_POS) |
70 ((CONFIG_IRQ_MEM_DMA1 - 7) << IRQ_MEM_DMA1_POS) |
71 ((CONFIG_IRQ_WATCH - 7) << IRQ_WATCH_POS));
72
73 SSYNC();
74}
diff --git a/arch/blackfin/mach-bf561/Kconfig b/arch/blackfin/mach-bf561/Kconfig
new file mode 100644
index 000000000000..0a17c4cf0059
--- /dev/null
+++ b/arch/blackfin/mach-bf561/Kconfig
@@ -0,0 +1,222 @@
1if BF561
2
3menu "BF561 Specific Configuration"
4
5comment "Core B Support"
6
7menu "Core B Support"
8
9config BF561_COREB
10 bool "Enable Core B support"
11 default y
12
13config BF561_COREB_RESET
14 bool "Enable Core B reset support"
15 default n
16 help
17 This requires code in the application that is loaded
18 into Core B. In order to reset, the application needs
19 to install an interrupt handler for Supplemental
20 Interrupt 0, that sets RETI to 0xff600000 and writes
21 bit 11 of SICB_SYSCR when bit 5 of SICA_SYSCR is 0.
22 This causes Core B to stall when Supplemental Interrupt
23 0 is set, and will reset PC to 0xff600000 when
24 COREB_SRAM_INIT is cleared.
25
26endmenu
27
28comment "Interrupt Priority Assignment"
29
30menu "Priority"
31
32config IRQ_PLL_WAKEUP
33 int "PLL Wakeup Interrupt"
34 default 7
35config IRQ_DMA1_ERROR
36 int "DMA1 Error (generic)"
37 default 7
38config IRQ_DMA2_ERROR
39 int "DMA2 Error (generic)"
40 default 7
41config IRQ_IMDMA_ERROR
42 int "IMDMA Error (generic)"
43 default 7
44config IRQ_PPI0_ERROR
45 int "PPI0 Error Interrupt"
46 default 7
47config IRQ_PPI1_ERROR
48 int "PPI1 Error Interrupt"
49 default 7
50config IRQ_SPORT0_ERROR
51 int "SPORT0 Error Interrupt"
52 default 7
53config IRQ_SPORT1_ERROR
54 int "SPORT1 Error Interrupt"
55 default 7
56config IRQ_SPI_ERROR
57 int "SPI Error Interrupt"
58 default 7
59config IRQ_UART_ERROR
60 int "UART Error Interrupt"
61 default 7
62config IRQ_RESERVED_ERROR
63 int "Reserved Interrupt"
64 default 7
65config IRQ_DMA1_0
66 int "DMA1 0 Interrupt(PPI1)"
67 default 8
68config IRQ_DMA1_1
69 int "DMA1 1 Interrupt(PPI2)"
70 default 8
71config IRQ_DMA1_2
72 int "DMA1 2 Interrupt"
73 default 8
74config IRQ_DMA1_3
75 int "DMA1 3 Interrupt"
76 default 8
77config IRQ_DMA1_4
78 int "DMA1 4 Interrupt"
79 default 8
80config IRQ_DMA1_5
81 int "DMA1 5 Interrupt"
82 default 8
83config IRQ_DMA1_6
84 int "DMA1 6 Interrupt"
85 default 8
86config IRQ_DMA1_7
87 int "DMA1 7 Interrupt"
88 default 8
89config IRQ_DMA1_8
90 int "DMA1 8 Interrupt"
91 default 8
92config IRQ_DMA1_9
93 int "DMA1 9 Interrupt"
94 default 8
95config IRQ_DMA1_10
96 int "DMA1 10 Interrupt"
97 default 8
98config IRQ_DMA1_11
99 int "DMA1 11 Interrupt"
100 default 8
101config IRQ_DMA2_0
102 int "DMA2 0 (SPORT0 RX)"
103 default 9
104config IRQ_DMA2_1
105 int "DMA2 1 (SPORT0 TX)"
106 default 9
107config IRQ_DMA2_2
108 int "DMA2 2 (SPORT1 RX)"
109 default 9
110config IRQ_DMA2_3
111 int "DMA2 3 (SPORT2 TX)"
112 default 9
113config IRQ_DMA2_4
114 int "DMA2 4 (SPI)"
115 default 9
116config IRQ_DMA2_5
117 int "DMA2 5 (UART RX)"
118 default 9
119config IRQ_DMA2_6
120 int "DMA2 6 (UART TX)"
121 default 9
122config IRQ_DMA2_7
123 int "DMA2 7 Interrupt"
124 default 9
125config IRQ_DMA2_8
126 int "DMA2 8 Interrupt"
127 default 9
128config IRQ_DMA2_9
129 int "DMA2 9 Interrupt"
130 default 9
131config IRQ_DMA2_10
132 int "DMA2 10 Interrupt"
133 default 9
134config IRQ_DMA2_11
135 int "DMA2 11 Interrupt"
136 default 9
137config IRQ_TIMER0
138 int "TIMER 0 Interrupt"
139 default 10
140config IRQ_TIMER1
141 int "TIMER 1 Interrupt"
142 default 10
143config IRQ_TIMER2
144 int "TIMER 2 Interrupt"
145 default 10
146config IRQ_TIMER3
147 int "TIMER 3 Interrupt"
148 default 10
149config IRQ_TIMER4
150 int "TIMER 4 Interrupt"
151 default 10
152config IRQ_TIMER5
153 int "TIMER 5 Interrupt"
154 default 10
155config IRQ_TIMER6
156 int "TIMER 6 Interrupt"
157 default 10
158config IRQ_TIMER7
159 int "TIMER 7 Interrupt"
160 default 10
161config IRQ_TIMER8
162 int "TIMER 8 Interrupt"
163 default 10
164config IRQ_TIMER9
165 int "TIMER 9 Interrupt"
166 default 10
167config IRQ_TIMER10
168 int "TIMER 10 Interrupt"
169 default 10
170config IRQ_TIMER11
171 int "TIMER 11 Interrupt"
172 default 10
173config IRQ_PROG0_INTA
174 int "Programmable Flags0 A (8)"
175 default 11
176config IRQ_PROG0_INTB
177 int "Programmable Flags0 B (8)"
178 default 11
179config IRQ_PROG1_INTA
180 int "Programmable Flags1 A (8)"
181 default 11
182config IRQ_PROG1_INTB
183 int "Programmable Flags1 B (8)"
184 default 11
185config IRQ_PROG2_INTA
186 int "Programmable Flags2 A (8)"
187 default 11
188config IRQ_PROG2_INTB
189 int "Programmable Flags2 B (8)"
190 default 11
191config IRQ_DMA1_WRRD0
192 int "MDMA1 0 write/read INT"
193 default 8
194config IRQ_DMA1_WRRD1
195 int "MDMA1 1 write/read INT"
196 default 8
197config IRQ_DMA2_WRRD0
198 int "MDMA2 0 write/read INT"
199 default 9
200config IRQ_DMA2_WRRD1
201 int "MDMA2 1 write/read INT"
202 default 9
203config IRQ_IMDMA_WRRD0
204 int "IMDMA 0 write/read INT"
205 default 12
206config IRQ_IMDMA_WRRD1
207 int "IMDMA 1 write/read INT"
208 default 12
209config IRQ_WDTIMER
210 int "Watch Dog Timer"
211 default 13
212
213 help
214 Enter the priority numbers between 7-13 ONLY. Others are Reserved.
215 This applies to all the above. It is not recommended to assign the
216 highest priority number 7 to UART or any other device.
217
218endmenu
219
220endmenu
221
222endif
diff --git a/arch/blackfin/mach-bf561/Makefile b/arch/blackfin/mach-bf561/Makefile
new file mode 100644
index 000000000000..57f475a55161
--- /dev/null
+++ b/arch/blackfin/mach-bf561/Makefile
@@ -0,0 +1,9 @@
1#
2# arch/blackfin/mach-bf561/Makefile
3#
4
5extra-y := head.o
6
7obj-y := ints-priority.o
8
9obj-$(CONFIG_BF561_COREB) += coreb.o
diff --git a/arch/blackfin/mach-bf561/boards/Makefile b/arch/blackfin/mach-bf561/boards/Makefile
new file mode 100644
index 000000000000..886edc739ab4
--- /dev/null
+++ b/arch/blackfin/mach-bf561/boards/Makefile
@@ -0,0 +1,7 @@
1#
2# arch/blackfin/mach-bf561/boards/Makefile
3#
4
5obj-$(CONFIG_GENERIC_BOARD) += generic_board.o
6obj-$(CONFIG_BFIN561_EZKIT) += ezkit.o
7obj-$(CONFIG_BFIN561_BLUETECHNIX_CM) += cm_bf561.o
diff --git a/arch/blackfin/mach-bf561/boards/cm_bf561.c b/arch/blackfin/mach-bf561/boards/cm_bf561.c
new file mode 100644
index 000000000000..6824e956d153
--- /dev/null
+++ b/arch/blackfin/mach-bf561/boards/cm_bf561.c
@@ -0,0 +1,289 @@
1/*
2 * File: arch/blackfin/mach-bf533/boards/cm_bf561.c
3 * Based on: arch/blackfin/mach-bf533/boards/ezkit.c
4 * Author: Aidan Williams <aidan@nicta.com.au> Copright 2005
5 *
6 * Created: 2006
7 * Description: Board description file
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/device.h>
31#include <linux/platform_device.h>
32#include <linux/mtd/mtd.h>
33#include <linux/mtd/partitions.h>
34#include <linux/spi/spi.h>
35#include <linux/spi/flash.h>
36#include <linux/usb_isp1362.h>
37#include <asm/irq.h>
38#include <asm/bfin5xx_spi.h>
39
40/*
41 * Name the Board for the /proc/cpuinfo
42 */
43char *bfin_board_name = "Bluetechnix CM BF561";
44
45#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
46/* all SPI perpherals info goes here */
47
48#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
49static struct mtd_partition bfin_spi_flash_partitions[] = {
50 {
51 .name = "bootloader",
52 .size = 0x00020000,
53 .offset = 0,
54 .mask_flags = MTD_CAP_ROM
55 },{
56 .name = "kernel",
57 .size = 0xe0000,
58 .offset = 0x20000
59 },{
60 .name = "file system",
61 .size = 0x700000,
62 .offset = 0x00100000,
63 }
64};
65
66static struct flash_platform_data bfin_spi_flash_data = {
67 .name = "m25p80",
68 .parts = bfin_spi_flash_partitions,
69 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
70 .type = "m25p64",
71};
72
73/* SPI flash chip (m25p64) */
74static struct bfin5xx_spi_chip spi_flash_chip_info = {
75 .enable_dma = 0, /* use dma transfer with this chip*/
76 .bits_per_word = 8,
77};
78#endif
79
80#if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
81/* SPI ADC chip */
82static struct bfin5xx_spi_chip spi_adc_chip_info = {
83 .enable_dma = 1, /* use dma transfer with this chip*/
84 .bits_per_word = 16,
85};
86#endif
87
88#if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
89static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
90 .enable_dma = 0,
91 .bits_per_word = 16,
92};
93#endif
94
95#if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
96static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
97 .enable_dma = 0,
98 .bits_per_word = 16,
99};
100#endif
101
102#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
103static struct bfin5xx_spi_chip spi_mmc_chip_info = {
104 .enable_dma = 1,
105 .bits_per_word = 8,
106};
107#endif
108
109static struct spi_board_info bfin_spi_board_info[] __initdata = {
110#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
111 {
112 /* the modalias must be the same as spi device driver name */
113 .modalias = "m25p80", /* Name of spi_driver for this device */
114 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
115 .bus_num = 1, /* Framework bus number */
116 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
117 .platform_data = &bfin_spi_flash_data,
118 .controller_data = &spi_flash_chip_info,
119 .mode = SPI_MODE_3,
120 },
121#endif
122
123#if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
124 {
125 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
126 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
127 .bus_num = 1, /* Framework bus number */
128 .chip_select = 1, /* Framework chip select. */
129 .platform_data = NULL, /* No spi_driver specific config */
130 .controller_data = &spi_adc_chip_info,
131 },
132#endif
133
134#if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
135 {
136 .modalias = "ad1836-spi",
137 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
138 .bus_num = 1,
139 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
140 .controller_data = &ad1836_spi_chip_info,
141 },
142#endif
143#if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
144 {
145 .modalias = "ad9960-spi",
146 .max_speed_hz = 10000000, /* max spi clock (SCK) speed in HZ */
147 .bus_num = 1,
148 .chip_select = 1,
149 .controller_data = &ad9960_spi_chip_info,
150 },
151#endif
152#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
153 {
154 .modalias = "spi_mmc",
155 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
156 .bus_num = 1,
157 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
158 .platform_data = NULL,
159 .controller_data = &spi_mmc_chip_info,
160 .mode = SPI_MODE_3,
161 },
162#endif
163};
164
165/* SPI controller data */
166static struct bfin5xx_spi_master spi_bfin_master_info = {
167 .num_chipselect = 8,
168 .enable_dma = 1, /* master has the ability to do dma transfer */
169};
170
171static struct platform_device spi_bfin_master_device = {
172 .name = "bfin-spi-master",
173 .id = 1, /* Bus number */
174 .dev = {
175 .platform_data = &spi_bfin_master_info, /* Passed to driver */
176 },
177};
178#endif /* spi master and devices */
179
180
181#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
182
183static struct resource smc91x_resources[] = {
184 {
185 .name = "smc91x-regs",
186 .start = 0x28000300,
187 .end = 0x28000300 + 16,
188 .flags = IORESOURCE_MEM,
189 },{
190 .start = IRQ_PF0,
191 .end = IRQ_PF0,
192 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
193 },
194};
195static struct platform_device smc91x_device = {
196 .name = "smc91x",
197 .id = 0,
198 .num_resources = ARRAY_SIZE(smc91x_resources),
199 .resource = smc91x_resources,
200};
201#endif
202
203#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
204static struct resource isp1362_hcd_resources[] = {
205 {
206 .start = 0x24008000,
207 .end = 0x24008000,
208 .flags = IORESOURCE_MEM,
209 },{
210 .start = 0x24008004,
211 .end = 0x24008004,
212 .flags = IORESOURCE_MEM,
213 },{
214 .start = IRQ_PF47,
215 .end = IRQ_PF47,
216 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
217 },
218};
219
220static struct isp1362_platform_data isp1362_priv = {
221 .sel15Kres = 1,
222 .clknotstop = 0,
223 .oc_enable = 0,
224 .int_act_high = 0,
225 .int_edge_triggered = 0,
226 .remote_wakeup_connected = 0,
227 .no_power_switching = 1,
228 .power_switching_mode = 0,
229};
230
231static struct platform_device isp1362_hcd_device = {
232 .name = "isp1362-hcd",
233 .id = 0,
234 .dev = {
235 .platform_data = &isp1362_priv,
236 },
237 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
238 .resource = isp1362_hcd_resources,
239};
240#endif
241
242#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
243static struct resource bfin_uart_resources[] = {
244 {
245 .start = 0xFFC00400,
246 .end = 0xFFC004FF,
247 .flags = IORESOURCE_MEM,
248 },
249};
250
251static struct platform_device bfin_uart_device = {
252 .name = "bfin-uart",
253 .id = 1,
254 .num_resources = ARRAY_SIZE(bfin_uart_resources),
255 .resource = bfin_uart_resources,
256};
257#endif
258
259static struct platform_device *cm_bf561_devices[] __initdata = {
260
261#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
262 &bfin_uart_device,
263#endif
264
265#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
266 &isp1362_hcd_device,
267#endif
268
269#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
270 &smc91x_device,
271#endif
272
273#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
274 &spi_bfin_master_device,
275#endif
276
277};
278
279static int __init cm_bf561_init(void)
280{
281 printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
282 platform_add_devices(cm_bf561_devices, ARRAY_SIZE(cm_bf561_devices));
283#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
284 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
285#endif
286 return 0;
287}
288
289arch_initcall(cm_bf561_init);
diff --git a/arch/blackfin/mach-bf561/boards/ezkit.c b/arch/blackfin/mach-bf561/boards/ezkit.c
new file mode 100644
index 000000000000..14eb4f9a68ea
--- /dev/null
+++ b/arch/blackfin/mach-bf561/boards/ezkit.c
@@ -0,0 +1,147 @@
1/*
2 * File: arch/blackfin/mach-bf561/ezkit.c
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/device.h>
31#include <linux/platform_device.h>
32#include <linux/spi/spi.h>
33#include <asm/irq.h>
34#include <asm/bfin5xx_spi.h>
35
36/*
37 * Name the Board for the /proc/cpuinfo
38 */
39char *bfin_board_name = "ADDS-BF561-EZKIT";
40
41/*
42 * USB-LAN EzExtender board
43 * Driver needs to know address, irq and flag pin.
44 */
45#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
46static struct resource smc91x_resources[] = {
47 {
48 .name = "smc91x-regs",
49 .start = 0x2C010300,
50 .end = 0x2C010300 + 16,
51 .flags = IORESOURCE_MEM,
52 },{
53
54 .start = IRQ_PF9,
55 .end = IRQ_PF9,
56 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
57 },
58};
59
60static struct platform_device smc91x_device = {
61 .name = "smc91x",
62 .id = 0,
63 .num_resources = ARRAY_SIZE(smc91x_resources),
64 .resource = smc91x_resources,
65};
66#endif
67
68#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
69static struct resource bfin_uart_resources[] = {
70 {
71 .start = 0xFFC00400,
72 .end = 0xFFC004FF,
73 .flags = IORESOURCE_MEM,
74 },
75};
76
77static struct platform_device bfin_uart_device = {
78 .name = "bfin-uart",
79 .id = 1,
80 .num_resources = ARRAY_SIZE(bfin_uart_resources),
81 .resource = bfin_uart_resources,
82};
83#endif
84
85#ifdef CONFIG_SPI_BFIN
86#if defined(CONFIG_SND_BLACKFIN_AD1836) \
87 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
88static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
89 .enable_dma = 0,
90 .bits_per_word = 16,
91};
92#endif
93#endif
94
95/* SPI controller data */
96static struct bfin5xx_spi_master spi_bfin_master_info = {
97 .num_chipselect = 8,
98 .enable_dma = 1, /* master has the ability to do dma transfer */
99};
100
101static struct platform_device spi_bfin_master_device = {
102 .name = "bfin-spi-master",
103 .id = 1, /* Bus number */
104 .dev = {
105 .platform_data = &spi_bfin_master_info, /* Passed to driver */
106 },
107};
108
109static struct spi_board_info bfin_spi_board_info[] __initdata = {
110#if defined(CONFIG_SND_BLACKFIN_AD1836) \
111 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
112 {
113 .modalias = "ad1836-spi",
114 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
115 .bus_num = 1,
116 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
117 .controller_data = &ad1836_spi_chip_info,
118 },
119#endif
120};
121
122static struct platform_device *ezkit_devices[] __initdata = {
123#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
124 &smc91x_device,
125#endif
126#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
127 &spi_bfin_master_device,
128#endif
129#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
130 &bfin_uart_device,
131#endif
132};
133
134static int __init ezkit_init(void)
135{
136 int ret;
137
138 printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
139 ret = platform_add_devices(ezkit_devices,
140 ARRAY_SIZE(ezkit_devices));
141 if (ret < 0)
142 return ret;
143 return spi_register_board_info(bfin_spi_board_info,
144 ARRAY_SIZE(bfin_spi_board_info));
145}
146
147arch_initcall(ezkit_init);
diff --git a/arch/blackfin/mach-bf561/boards/generic_board.c b/arch/blackfin/mach-bf561/boards/generic_board.c
new file mode 100644
index 000000000000..585ecdd2f6a5
--- /dev/null
+++ b/arch/blackfin/mach-bf561/boards/generic_board.c
@@ -0,0 +1,82 @@
1/*
2 * File: arch/blackfin/mach-bf561/generic_board.c
3 * Based on: arch/blackfin/mach-bf533/ezkit.c
4 * Author: Aidan Williams <aidan@nicta.com.au>
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2005 National ICT Australia (NICTA)
11 * Copyright 2004-2006 Analog Devices Inc.
12 *
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, see the file COPYING, or write
27 * to the Free Software Foundation, Inc.,
28 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 */
30
31#include <linux/device.h>
32#include <linux/platform_device.h>
33#include <asm/irq.h>
34
35char *bfin_board_name = "UNKNOWN BOARD";
36
37/*
38 * Driver needs to know address, irq and flag pin.
39 */
40#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
41static struct resource smc91x_resources[] = {
42 {
43 .start = 0x2C010300,
44 .end = 0x2C010300 + 16,
45 .flags = IORESOURCE_MEM,
46 },{
47 .start = IRQ_PROG_INTB,
48 .end = IRQ_PROG_INTB,
49 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
50 },{
51 /*
52 * denotes the flag pin and is used directly if
53 * CONFIG_IRQCHIP_DEMUX_GPIO is defined.
54 */
55 .start = IRQ_PF9,
56 .end = IRQ_PF9,
57 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
58 },
59};
60
61static struct platform_device smc91x_device = {
62 .name = "smc91x",
63 .id = 0,
64 .num_resources = ARRAY_SIZE(smc91x_resources),
65 .resource = smc91x_resources,
66};
67#endif
68
69static struct platform_device *generic_board_devices[] __initdata = {
70#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
71 &smc91x_device,
72#endif
73};
74
75static int __init generic_board_init(void)
76{
77 printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
78 return platform_add_devices(generic_board_devices,
79 ARRAY_SIZE(generic_board_devices));
80}
81
82arch_initcall(generic_board_init);
diff --git a/arch/blackfin/mach-bf561/coreb.c b/arch/blackfin/mach-bf561/coreb.c
new file mode 100644
index 000000000000..b28582fe083c
--- /dev/null
+++ b/arch/blackfin/mach-bf561/coreb.c
@@ -0,0 +1,402 @@
1/*
2 * File: arch/blackfin/mach-bf561/coreb.c
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description: Handle CoreB on a BF561
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/mm.h>
31#include <linux/miscdevice.h>
32#include <linux/device.h>
33#include <linux/ioport.h>
34#include <linux/module.h>
35#include <asm/dma.h>
36#include <asm/uaccess.h>
37
38#define MODULE_VER "v0.1"
39
40static spinlock_t coreb_lock;
41static wait_queue_head_t coreb_dma_wait;
42
43#define COREB_IS_OPEN 0x00000001
44#define COREB_IS_RUNNING 0x00000010
45
46#define CMD_COREB_INDEX 1
47#define CMD_COREB_START 2
48#define CMD_COREB_STOP 3
49#define CMD_COREB_RESET 4
50
51#define COREB_MINOR 229
52
53static unsigned long coreb_status = 0;
54static unsigned long coreb_base = 0xff600000;
55static unsigned long coreb_size = 0x4000;
56int coreb_dma_done;
57
58static loff_t coreb_lseek(struct file *file, loff_t offset, int origin);
59static ssize_t coreb_read(struct file *file, char *buf, size_t count,
60 loff_t * ppos);
61static ssize_t coreb_write(struct file *file, const char *buf, size_t count,
62 loff_t * ppos);
63static int coreb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
64 unsigned long arg);
65static int coreb_open(struct inode *inode, struct file *file);
66static int coreb_release(struct inode *inode, struct file *file);
67
68static irqreturn_t coreb_dma_interrupt(int irq, void *dev_id)
69{
70 clear_dma_irqstat(CH_MEM_STREAM2_DEST);
71 coreb_dma_done = 1;
72 wake_up_interruptible(&coreb_dma_wait);
73 return IRQ_HANDLED;
74}
75
76static ssize_t coreb_write(struct file *file, const char *buf, size_t count,
77 loff_t * ppos)
78{
79 unsigned long p = *ppos;
80 ssize_t wrote = 0;
81
82 if (p + count > coreb_size)
83 return -EFAULT;
84
85 while (count > 0) {
86 int len = count;
87
88 if (len > PAGE_SIZE)
89 len = PAGE_SIZE;
90
91 coreb_dma_done = 0;
92
93 /* Source Channel */
94 set_dma_start_addr(CH_MEM_STREAM2_SRC, (unsigned long)buf);
95 set_dma_x_count(CH_MEM_STREAM2_SRC, len);
96 set_dma_x_modify(CH_MEM_STREAM2_SRC, sizeof(char));
97 set_dma_config(CH_MEM_STREAM2_SRC, RESTART);
98 /* Destination Channel */
99 set_dma_start_addr(CH_MEM_STREAM2_DEST, coreb_base + p);
100 set_dma_x_count(CH_MEM_STREAM2_DEST, len);
101 set_dma_x_modify(CH_MEM_STREAM2_DEST, sizeof(char));
102 set_dma_config(CH_MEM_STREAM2_DEST, WNR | RESTART | DI_EN);
103
104 enable_dma(CH_MEM_STREAM2_SRC);
105 enable_dma(CH_MEM_STREAM2_DEST);
106
107 wait_event_interruptible(coreb_dma_wait, coreb_dma_done);
108
109 disable_dma(CH_MEM_STREAM2_SRC);
110 disable_dma(CH_MEM_STREAM2_DEST);
111
112 count -= len;
113 wrote += len;
114 buf += len;
115 p += len;
116 }
117 *ppos = p;
118 return wrote;
119}
120
121static ssize_t coreb_read(struct file *file, char *buf, size_t count,
122 loff_t * ppos)
123{
124 unsigned long p = *ppos;
125 ssize_t read = 0;
126
127 if ((p + count) > coreb_size)
128 return -EFAULT;
129
130 while (count > 0) {
131 int len = count;
132
133 if (len > PAGE_SIZE)
134 len = PAGE_SIZE;
135
136 coreb_dma_done = 0;
137
138 /* Source Channel */
139 set_dma_start_addr(CH_MEM_STREAM2_SRC, coreb_base + p);
140 set_dma_x_count(CH_MEM_STREAM2_SRC, len);
141 set_dma_x_modify(CH_MEM_STREAM2_SRC, sizeof(char));
142 set_dma_config(CH_MEM_STREAM2_SRC, RESTART);
143 /* Destination Channel */
144 set_dma_start_addr(CH_MEM_STREAM2_DEST, (unsigned long)buf);
145 set_dma_x_count(CH_MEM_STREAM2_DEST, len);
146 set_dma_x_modify(CH_MEM_STREAM2_DEST, sizeof(char));
147 set_dma_config(CH_MEM_STREAM2_DEST, WNR | RESTART | DI_EN);
148
149 enable_dma(CH_MEM_STREAM2_SRC);
150 enable_dma(CH_MEM_STREAM2_DEST);
151
152 wait_event_interruptible(coreb_dma_wait, coreb_dma_done);
153
154 disable_dma(CH_MEM_STREAM2_SRC);
155 disable_dma(CH_MEM_STREAM2_DEST);
156
157 count -= len;
158 read += len;
159 buf += len;
160 p += len;
161 }
162
163 return read;
164}
165
166static loff_t coreb_lseek(struct file *file, loff_t offset, int origin)
167{
168 loff_t ret;
169
170 mutex_lock(&file->f_dentry->d_inode->i_mutex);
171
172 switch (origin) {
173 case 0 /* SEEK_SET */ :
174 if (offset < coreb_size) {
175 file->f_pos = offset;
176 ret = file->f_pos;
177 } else
178 ret = -EINVAL;
179 break;
180 case 1 /* SEEK_CUR */ :
181 if ((offset + file->f_pos) < coreb_size) {
182 file->f_pos += offset;
183 ret = file->f_pos;
184 } else
185 ret = -EINVAL;
186 default:
187 ret = -EINVAL;
188 }
189 mutex_unlock(&file->f_dentry->d_inode->i_mutex);
190 return ret;
191}
192
193static int coreb_open(struct inode *inode, struct file *file)
194{
195 spin_lock_irq(&coreb_lock);
196
197 if (coreb_status & COREB_IS_OPEN)
198 goto out_busy;
199
200 coreb_status |= COREB_IS_OPEN;
201
202 spin_unlock_irq(&coreb_lock);
203 return 0;
204
205 out_busy:
206 spin_unlock_irq(&coreb_lock);
207 return -EBUSY;
208}
209
210static int coreb_release(struct inode *inode, struct file *file)
211{
212 spin_lock_irq(&coreb_lock);
213 coreb_status &= ~COREB_IS_OPEN;
214 spin_unlock_irq(&coreb_lock);
215 return 0;
216}
217
218static int coreb_ioctl(struct inode *inode, struct file *file,
219 unsigned int cmd, unsigned long arg)
220{
221 int retval = 0;
222 int coreb_index = 0;
223
224 switch (cmd) {
225 case CMD_COREB_INDEX:
226 if (copy_from_user(&coreb_index, (int *)arg, sizeof(int))) {
227 retval = -EFAULT;
228 break;
229 }
230
231 spin_lock_irq(&coreb_lock);
232 switch (coreb_index) {
233 case 0:
234 coreb_base = 0xff600000;
235 coreb_size = 0x4000;
236 break;
237 case 1:
238 coreb_base = 0xff610000;
239 coreb_size = 0x4000;
240 break;
241 case 2:
242 coreb_base = 0xff500000;
243 coreb_size = 0x8000;
244 break;
245 case 3:
246 coreb_base = 0xff400000;
247 coreb_size = 0x8000;
248 break;
249 default:
250 retval = -EINVAL;
251 break;
252 }
253 spin_unlock_irq(&coreb_lock);
254
255 mutex_lock(&file->f_dentry->d_inode->i_mutex);
256 file->f_pos = 0;
257 mutex_unlock(&file->f_dentry->d_inode->i_mutex);
258 break;
259 case CMD_COREB_START:
260 spin_lock_irq(&coreb_lock);
261 if (coreb_status & COREB_IS_RUNNING) {
262 retval = -EBUSY;
263 break;
264 }
265 printk(KERN_INFO "Starting Core B\n");
266 coreb_status |= COREB_IS_RUNNING;
267 bfin_write_SICA_SYSCR(bfin_read_SICA_SYSCR() & ~0x0020);
268 SSYNC();
269 spin_lock_irq(&coreb_lock);
270 break;
271#if defined(CONFIG_BF561_COREB_RESET)
272 case CMD_COREB_STOP:
273 spin_lock_irq(&coreb_lock);
274 printk(KERN_INFO "Stopping Core B\n");
275 bfin_write_SICA_SYSCR(bfin_read_SICA_SYSCR() | 0x0020);
276 bfin_write_SICB_SYSCR(bfin_read_SICB_SYSCR() | 0x0080);
277 coreb_status &= ~COREB_IS_RUNNING;
278 spin_lock_irq(&coreb_lock);
279 break;
280 case CMD_COREB_RESET:
281 printk(KERN_INFO "Resetting Core B\n");
282 bfin_write_SICB_SYSCR(bfin_read_SICB_SYSCR() | 0x0080);
283 break;
284#endif
285 }
286
287 return retval;
288}
289
290static struct file_operations coreb_fops = {
291 .owner = THIS_MODULE,
292 .llseek = coreb_lseek,
293 .read = coreb_read,
294 .write = coreb_write,
295 .ioctl = coreb_ioctl,
296 .open = coreb_open,
297 .release = coreb_release
298};
299
300static struct miscdevice coreb_dev = {
301 COREB_MINOR,
302 "coreb",
303 &coreb_fops
304};
305
306static ssize_t coreb_show_status(struct device *dev, struct device_attribute *attr, char *buf)
307{
308 return sprintf(buf,
309 "Base Address:\t0x%08lx\n"
310 "Core B is %s\n"
311 "SICA_SYSCR:\t%04x\n"
312 "SICB_SYSCR:\t%04x\n"
313 "\n"
314 "IRQ Status:\tCore A\t\tCore B\n"
315 "ISR0:\t\t%08x\t\t%08x\n"
316 "ISR1:\t\t%08x\t\t%08x\n"
317 "IMASK0:\t\t%08x\t\t%08x\n"
318 "IMASK1:\t\t%08x\t\t%08x\n",
319 coreb_base,
320 coreb_status & COREB_IS_RUNNING ? "running" : "stalled",
321 bfin_read_SICA_SYSCR(), bfin_read_SICB_SYSCR(),
322 bfin_read_SICA_ISR0(), bfin_read_SICB_ISR0(),
323 bfin_read_SICA_ISR1(), bfin_read_SICB_ISR0(),
324 bfin_read_SICA_IMASK0(), bfin_read_SICB_IMASK0(),
325 bfin_read_SICA_IMASK1(), bfin_read_SICB_IMASK1());
326}
327
328static DEVICE_ATTR(coreb_status, S_IRUGO, coreb_show_status, NULL);
329
330int __init bf561_coreb_init(void)
331{
332 init_waitqueue_head(&coreb_dma_wait);
333
334 spin_lock_init(&coreb_lock);
335 /* Request the core memory regions for Core B */
336 if (request_mem_region(0xff600000, 0x4000,
337 "Core B - Instruction SRAM") == NULL)
338 goto exit;
339
340 if (request_mem_region(0xFF610000, 0x4000,
341 "Core B - Instruction SRAM") == NULL)
342 goto release_instruction_a_sram;
343
344 if (request_mem_region(0xFF500000, 0x8000,
345 "Core B - Data Bank B SRAM") == NULL)
346 goto release_instruction_b_sram;
347
348 if (request_mem_region(0xff400000, 0x8000,
349 "Core B - Data Bank A SRAM") == NULL)
350 goto release_data_b_sram;
351
352 if (request_dma(CH_MEM_STREAM2_DEST, "Core B - DMA Destination") < 0)
353 goto release_data_a_sram;
354
355 if (request_dma(CH_MEM_STREAM2_SRC, "Core B - DMA Source") < 0)
356 goto release_dma_dest;
357
358 set_dma_callback(CH_MEM_STREAM2_DEST, coreb_dma_interrupt, NULL);
359
360 misc_register(&coreb_dev);
361
362 if (device_create_file(coreb_dev.this_device, &dev_attr_coreb_status))
363 goto release_dma_src;
364
365 printk(KERN_INFO "BF561 Core B driver %s initialized.\n", MODULE_VER);
366 return 0;
367
368 release_dma_src:
369 free_dma(CH_MEM_STREAM2_SRC);
370 release_dma_dest:
371 free_dma(CH_MEM_STREAM2_DEST);
372 release_data_a_sram:
373 release_mem_region(0xff400000, 0x8000);
374 release_data_b_sram:
375 release_mem_region(0xff500000, 0x8000);
376 release_instruction_b_sram:
377 release_mem_region(0xff610000, 0x4000);
378 release_instruction_a_sram:
379 release_mem_region(0xff600000, 0x4000);
380 exit:
381 return -ENOMEM;
382}
383
384void __exit bf561_coreb_exit(void)
385{
386 device_remove_file(coreb_dev.this_device, &dev_attr_coreb_status);
387 misc_deregister(&coreb_dev);
388
389 release_mem_region(0xff610000, 0x4000);
390 release_mem_region(0xff600000, 0x4000);
391 release_mem_region(0xff500000, 0x8000);
392 release_mem_region(0xff400000, 0x8000);
393
394 free_dma(CH_MEM_STREAM2_DEST);
395 free_dma(CH_MEM_STREAM2_SRC);
396}
397
398module_init(bf561_coreb_init);
399module_exit(bf561_coreb_exit);
400
401MODULE_AUTHOR("Bas Vermeulen <bvermeul@blackstar.xs4all.nl>");
402MODULE_DESCRIPTION("BF561 Core B Support");
diff --git a/arch/blackfin/mach-bf561/head.S b/arch/blackfin/mach-bf561/head.S
new file mode 100644
index 000000000000..7bca478526b9
--- /dev/null
+++ b/arch/blackfin/mach-bf561/head.S
@@ -0,0 +1,512 @@
1/*
2 * File: arch/blackfin/mach-bf561/head.S
3 * Based on: arch/blackfin/mach-bf533/head.S
4 * Author:
5 *
6 * Created:
7 * Description: BF561 startup file
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/linkage.h>
31#include <asm/blackfin.h>
32#if CONFIG_BFIN_KERNEL_CLOCK
33#include <asm/mach/mem_init.h>
34#endif
35
36.global __rambase
37.global __ramstart
38.global __ramend
39.extern ___bss_stop
40.extern ___bss_start
41.extern _bf53x_relocate_l1_mem
42
43#define INITIAL_STACK 0xFFB01000
44
45.text
46
47ENTRY(__start)
48ENTRY(__stext)
49 /* R0: argument of command line string, passed from uboot, save it */
50 R7 = R0;
51 /* Set the SYSCFG register */
52 R0 = 0x36;
53 SYSCFG = R0; /*Enable Cycle Counter and Nesting Of Interrupts(3rd Bit)*/
54 R0 = 0;
55
56 /*Clear Out All the data and pointer Registers*/
57 R1 = R0;
58 R2 = R0;
59 R3 = R0;
60 R4 = R0;
61 R5 = R0;
62 R6 = R0;
63
64 P0 = R0;
65 P1 = R0;
66 P2 = R0;
67 P3 = R0;
68 P4 = R0;
69 P5 = R0;
70
71 LC0 = r0;
72 LC1 = r0;
73 L0 = r0;
74 L1 = r0;
75 L2 = r0;
76 L3 = r0;
77
78 /* Clear Out All the DAG Registers*/
79 B0 = r0;
80 B1 = r0;
81 B2 = r0;
82 B3 = r0;
83
84 I0 = r0;
85 I1 = r0;
86 I2 = r0;
87 I3 = r0;
88
89 M0 = r0;
90 M1 = r0;
91 M2 = r0;
92 M3 = r0;
93
94 /* Turn off the icache */
95 p0.l = (IMEM_CONTROL & 0xFFFF);
96 p0.h = (IMEM_CONTROL >> 16);
97 R1 = [p0];
98 R0 = ~ENICPLB;
99 R0 = R0 & R1;
100
101 /* Anomaly 05000125 */
102#ifdef ANOMALY_05000125
103 CLI R2;
104 SSYNC;
105#endif
106 [p0] = R0;
107 SSYNC;
108#ifdef ANOMALY_05000125
109 STI R2;
110#endif
111
112 /* Turn off the dcache */
113 p0.l = (DMEM_CONTROL & 0xFFFF);
114 p0.h = (DMEM_CONTROL >> 16);
115 R1 = [p0];
116 R0 = ~ENDCPLB;
117 R0 = R0 & R1;
118
119 /* Anomaly 05000125 */
120#ifdef ANOMALY_05000125
121 CLI R2;
122 SSYNC;
123#endif
124 [p0] = R0;
125 SSYNC;
126#ifdef ANOMALY_05000125
127 STI R2;
128#endif
129
130 /* Initialise UART*/
131 p0.h = hi(UART_LCR);
132 p0.l = lo(UART_LCR);
133 r0 = 0x0(Z);
134 w[p0] = r0.L; /* To enable DLL writes */
135 ssync;
136
137 p0.h = hi(UART_DLL);
138 p0.l = lo(UART_DLL);
139 r0 = 0x0(Z);
140 w[p0] = r0.L;
141 ssync;
142
143 p0.h = hi(UART_DLH);
144 p0.l = lo(UART_DLH);
145 r0 = 0x00(Z);
146 w[p0] = r0.L;
147 ssync;
148
149 p0.h = hi(UART_GCTL);
150 p0.l = lo(UART_GCTL);
151 r0 = 0x0(Z);
152 w[p0] = r0.L; /* To enable UART clock */
153 ssync;
154
155 /* Initialize stack pointer */
156 sp.l = lo(INITIAL_STACK);
157 sp.h = hi(INITIAL_STACK);
158 fp = sp;
159 usp = sp;
160
161 /* Put The Code for PLL Programming and SDRAM Programming in L1 ISRAM */
162 call _bf53x_relocate_l1_mem;
163#if CONFIG_BFIN_KERNEL_CLOCK
164 call _start_dma_code;
165#endif
166
167 /* Code for initializing Async memory banks */
168
169 p2.h = hi(EBIU_AMBCTL1);
170 p2.l = lo(EBIU_AMBCTL1);
171 r0.h = hi(AMBCTL1VAL);
172 r0.l = lo(AMBCTL1VAL);
173 [p2] = r0;
174 ssync;
175
176 p2.h = hi(EBIU_AMBCTL0);
177 p2.l = lo(EBIU_AMBCTL0);
178 r0.h = hi(AMBCTL0VAL);
179 r0.l = lo(AMBCTL0VAL);
180 [p2] = r0;
181 ssync;
182
183 p2.h = hi(EBIU_AMGCTL);
184 p2.l = lo(EBIU_AMGCTL);
185 r0 = AMGCTLVAL;
186 w[p2] = r0;
187 ssync;
188
189 /* This section keeps the processor in supervisor mode
190 * during kernel boot. Switches to user mode at end of boot.
191 * See page 3-9 of Hardware Reference manual for documentation.
192 */
193
194 /* EVT15 = _real_start */
195
196 p0.l = lo(EVT15);
197 p0.h = hi(EVT15);
198 p1.l = _real_start;
199 p1.h = _real_start;
200 [p0] = p1;
201 csync;
202
203 p0.l = lo(IMASK);
204 p0.h = hi(IMASK);
205 p1.l = IMASK_IVG15;
206 p1.h = 0x0;
207 [p0] = p1;
208 csync;
209
210 raise 15;
211 p0.l = .LWAIT_HERE;
212 p0.h = .LWAIT_HERE;
213 reti = p0;
214#if defined(ANOMALY_05000281)
215 nop; nop; nop;
216#endif
217 rti;
218
219.LWAIT_HERE:
220 jump .LWAIT_HERE;
221
222ENTRY(_real_start)
223 [ -- sp ] = reti;
224 p0.l = lo(WDOGA_CTL);
225 p0.h = hi(WDOGA_CTL);
226 r0 = 0xAD6(z);
227 w[p0] = r0; /* watchdog off for now */
228 ssync;
229
230 /* Code update for BSS size == 0
231 * Zero out the bss region.
232 */
233
234 p1.l = ___bss_start;
235 p1.h = ___bss_start;
236 p2.l = ___bss_stop;
237 p2.h = ___bss_stop;
238 r0 = 0;
239 p2 -= p1;
240 lsetup (.L_clear_bss, .L_clear_bss ) lc0 = p2;
241.L_clear_bss:
242 B[p1++] = r0;
243
244 /* In case there is a NULL pointer reference
245 * Zero out region before stext
246 */
247
248 p1.l = 0x0;
249 p1.h = 0x0;
250 r0.l = __stext;
251 r0.h = __stext;
252 r0 = r0 >> 1;
253 p2 = r0;
254 r0 = 0;
255 lsetup (.L_clear_zero, .L_clear_zero ) lc0 = p2;
256.L_clear_zero:
257 W[p1++] = r0;
258
259/* pass the uboot arguments to the global value command line */
260 R0 = R7;
261 call _cmdline_init;
262
263 p1.l = __rambase;
264 p1.h = __rambase;
265 r0.l = __sdata;
266 r0.h = __sdata;
267 [p1] = r0;
268
269 p1.l = __ramstart;
270 p1.h = __ramstart;
271 p3.l = ___bss_stop;
272 p3.h = ___bss_stop;
273
274 r1 = p3;
275 [p1] = r1;
276
277 /*
278 * load the current thread pointer and stack
279 */
280 r1.l = _init_thread_union;
281 r1.h = _init_thread_union;
282
283 r2.l = 0x2000;
284 r2.h = 0x0000;
285 r1 = r1 + r2;
286 sp = r1;
287 usp = sp;
288 fp = sp;
289 call _start_kernel;
290.L_exit:
291 jump.s .L_exit;
292
293.section .l1.text
294#if CONFIG_BFIN_KERNEL_CLOCK
295ENTRY(_start_dma_code)
296 p0.h = hi(SICA_IWR0);
297 p0.l = lo(SICA_IWR0);
298 r0.l = 0x1;
299 [p0] = r0;
300 SSYNC;
301
302 /*
303 * Set PLL_CTL
304 * - [14:09] = MSEL[5:0] : CLKIN / VCO multiplication factors
305 * - [8] = BYPASS : BYPASS the PLL, run CLKIN into CCLK/SCLK
306 * - [7] = output delay (add 200ps of delay to mem signals)
307 * - [6] = input delay (add 200ps of input delay to mem signals)
308 * - [5] = PDWN : 1=All Clocks off
309 * - [3] = STOPCK : 1=Core Clock off
310 * - [1] = PLL_OFF : 1=Disable Power to PLL
311 * - [0] = DF : 1=Pass CLKIN/2 to PLL / 0=Pass CLKIN to PLL
312 * all other bits set to zero
313 */
314
315 p0.h = hi(PLL_LOCKCNT);
316 p0.l = lo(PLL_LOCKCNT);
317 r0 = 0x300(Z);
318 w[p0] = r0.l;
319 ssync;
320
321 P2.H = hi(EBIU_SDGCTL);
322 P2.L = lo(EBIU_SDGCTL);
323 R0 = [P2];
324 BITSET (R0, 24);
325 [P2] = R0;
326 SSYNC;
327
328 r0 = CONFIG_VCO_MULT & 63; /* Load the VCO multiplier */
329 r0 = r0 << 9; /* Shift it over, */
330 r1 = CLKIN_HALF; /* Do we need to divide CLKIN by 2?*/
331 r0 = r1 | r0;
332 r1 = PLL_BYPASS; /* Bypass the PLL? */
333 r1 = r1 << 8; /* Shift it over */
334 r0 = r1 | r0; /* add them all together */
335
336 p0.h = hi(PLL_CTL);
337 p0.l = lo(PLL_CTL); /* Load the address */
338 cli r2; /* Disable interrupts */
339 ssync;
340 w[p0] = r0.l; /* Set the value */
341 idle; /* Wait for the PLL to stablize */
342 sti r2; /* Enable interrupts */
343
344.Lcheck_again:
345 p0.h = hi(PLL_STAT);
346 p0.l = lo(PLL_STAT);
347 R0 = W[P0](Z);
348 CC = BITTST(R0,5);
349 if ! CC jump .Lcheck_again;
350
351 /* Configure SCLK & CCLK Dividers */
352 r0 = (CONFIG_CCLK_ACT_DIV | CONFIG_SCLK_DIV);
353 p0.h = hi(PLL_DIV);
354 p0.l = lo(PLL_DIV);
355 w[p0] = r0.l;
356 ssync;
357
358 p0.l = lo(EBIU_SDRRC);
359 p0.h = hi(EBIU_SDRRC);
360 r0 = mem_SDRRC;
361 w[p0] = r0.l;
362 ssync;
363
364 p0.l = (EBIU_SDBCTL & 0xFFFF);
365 p0.h = (EBIU_SDBCTL >> 16); /* SDRAM Memory Bank Control Register */
366 r0 = mem_SDBCTL;
367 w[p0] = r0.l;
368 ssync;
369
370 P2.H = hi(EBIU_SDGCTL);
371 P2.L = lo(EBIU_SDGCTL);
372 R0 = [P2];
373 BITCLR (R0, 24);
374 p0.h = hi(EBIU_SDSTAT);
375 p0.l = lo(EBIU_SDSTAT);
376 r2.l = w[p0];
377 cc = bittst(r2,3);
378 if !cc jump .Lskip;
379 NOP;
380 BITSET (R0, 23);
381.Lskip:
382 [P2] = R0;
383 SSYNC;
384
385 R0.L = lo(mem_SDGCTL);
386 R0.H = hi(mem_SDGCTL);
387 R1 = [p2];
388 R1 = R1 | R0;
389 [P2] = R1;
390 SSYNC;
391
392 RTS;
393#endif /* CONFIG_BFIN_KERNEL_CLOCK */
394
395ENTRY(_bfin_reset)
396 /* No more interrupts to be handled*/
397 CLI R6;
398 SSYNC;
399
400#if defined(CONFIG_BFIN_SHARED_FLASH_ENET)
401 p0.h = hi(FIO_INEN);
402 p0.l = lo(FIO_INEN);
403 r0.l = ~(PF1 | PF0);
404 w[p0] = r0.l;
405
406 p0.h = hi(FIO_DIR);
407 p0.l = lo(FIO_DIR);
408 r0.l = (PF1 | PF0);
409 w[p0] = r0.l;
410
411 p0.h = hi(FIO_FLAG_C);
412 p0.l = lo(FIO_FLAG_C);
413 r0.l = (PF1 | PF0);
414 w[p0] = r0.l;
415#endif
416
417 /* Clear the bits 13-15 in SWRST if they werent cleared */
418 p0.h = hi(SICA_SWRST);
419 p0.l = lo(SICA_SWRST);
420 csync;
421 r0.l = w[p0];
422
423 /* Clear the IMASK register */
424 p0.h = hi(IMASK);
425 p0.l = lo(IMASK);
426 r0 = 0x0;
427 [p0] = r0;
428
429 /* Clear the ILAT register */
430 p0.h = hi(ILAT);
431 p0.l = lo(ILAT);
432 r0 = [p0];
433 [p0] = r0;
434 SSYNC;
435
436 /* Disable the WDOG TIMER */
437 p0.h = hi(WDOGA_CTL);
438 p0.l = lo(WDOGA_CTL);
439 r0.l = 0xAD6;
440 w[p0] = r0.l;
441 SSYNC;
442
443 /* Clear the sticky bit incase it is already set */
444 p0.h = hi(WDOGA_CTL);
445 p0.l = lo(WDOGA_CTL);
446 r0.l = 0x8AD6;
447 w[p0] = r0.l;
448 SSYNC;
449
450 /* Program the count value */
451 R0.l = 0x100;
452 R0.h = 0x0;
453 P0.h = hi(WDOGA_CNT);
454 P0.l = lo(WDOGA_CNT);
455 [P0] = R0;
456 SSYNC;
457
458 /* Program WDOG_STAT if necessary */
459 P0.h = hi(WDOGA_CTL);
460 P0.l = lo(WDOGA_CTL);
461 R0 = W[P0](Z);
462 CC = BITTST(R0,1);
463 if !CC JUMP .LWRITESTAT;
464 CC = BITTST(R0,2);
465 if !CC JUMP .LWRITESTAT;
466 JUMP .LSKIP_WRITE;
467
468.LWRITESTAT:
469 /* When watch dog timer is enabled,
470 * a write to STAT will load the contents of CNT to STAT
471 */
472 R0 = 0x0000(z);
473 P0.h = hi(WDOGA_STAT);
474 P0.l = lo(WDOGA_STAT)
475 [P0] = R0;
476 SSYNC;
477
478.LSKIP_WRITE:
479 /* Enable the reset event */
480 P0.h = hi(WDOGA_CTL);
481 P0.l = lo(WDOGA_CTL);
482 R0 = W[P0](Z);
483 BITCLR(R0,1);
484 BITCLR(R0,2);
485 W[P0] = R0.L;
486 SSYNC;
487 NOP;
488
489 /* Enable the wdog counter */
490 R0 = W[P0](Z);
491 BITCLR(R0,4);
492 W[P0] = R0.L;
493 SSYNC;
494
495 IDLE;
496
497 RTS;
498
499.data
500
501/*
502 * Set up the usable of RAM stuff. Size of RAM is determined then
503 * an initial stack set up at the end.
504 */
505
506.align 4
507__rambase:
508.long 0
509__ramstart:
510.long 0
511__ramend:
512.long 0
diff --git a/arch/blackfin/mach-bf561/ints-priority.c b/arch/blackfin/mach-bf561/ints-priority.c
new file mode 100644
index 000000000000..89c52ff95b27
--- /dev/null
+++ b/arch/blackfin/mach-bf561/ints-priority.c
@@ -0,0 +1,108 @@
1/*
2 * File: arch/blackfin/mach-bf561/ints-priority.c
3 * Based on: arch/blackfin/mach-bf537/ints-priority.c
4 * Author: Michael Hennerich
5 *
6 * Created:
7 * Description: Set up the interupt priorities
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/module.h>
31#include <asm/blackfin.h>
32#include <asm/irq.h>
33
34void program_IAR(void)
35{
36 /* Program the IAR0 Register with the configured priority */
37 bfin_write_SICA_IAR0(((CONFIG_IRQ_PLL_WAKEUP - 7) << IRQ_PLL_WAKEUP_POS) |
38 ((CONFIG_IRQ_DMA1_ERROR - 7) << IRQ_DMA1_ERROR_POS) |
39 ((CONFIG_IRQ_DMA2_ERROR - 7) << IRQ_DMA2_ERROR_POS) |
40 ((CONFIG_IRQ_IMDMA_ERROR - 7) << IRQ_IMDMA_ERROR_POS) |
41 ((CONFIG_IRQ_PPI0_ERROR - 7) << IRQ_PPI0_ERROR_POS) |
42 ((CONFIG_IRQ_PPI1_ERROR - 7) << IRQ_PPI1_ERROR_POS) |
43 ((CONFIG_IRQ_SPORT0_ERROR - 7) << IRQ_SPORT0_ERROR_POS) |
44 ((CONFIG_IRQ_SPORT1_ERROR - 7) << IRQ_SPORT1_ERROR_POS));
45
46 bfin_write_SICA_IAR1(((CONFIG_IRQ_SPI_ERROR - 7) << IRQ_SPI_ERROR_POS) |
47 ((CONFIG_IRQ_UART_ERROR - 7) << IRQ_UART_ERROR_POS) |
48 ((CONFIG_IRQ_RESERVED_ERROR - 7) << IRQ_RESERVED_ERROR_POS) |
49 ((CONFIG_IRQ_DMA1_0 - 7) << IRQ_DMA1_0_POS) |
50 ((CONFIG_IRQ_DMA1_1 - 7) << IRQ_DMA1_1_POS) |
51 ((CONFIG_IRQ_DMA1_2 - 7) << IRQ_DMA1_2_POS) |
52 ((CONFIG_IRQ_DMA1_3 - 7) << IRQ_DMA1_3_POS) |
53 ((CONFIG_IRQ_DMA1_4 - 7) << IRQ_DMA1_4_POS));
54
55 bfin_write_SICA_IAR2(((CONFIG_IRQ_DMA1_5 - 7) << IRQ_DMA1_5_POS) |
56 ((CONFIG_IRQ_DMA1_6 - 7) << IRQ_DMA1_6_POS) |
57 ((CONFIG_IRQ_DMA1_7 - 7) << IRQ_DMA1_7_POS) |
58 ((CONFIG_IRQ_DMA1_8 - 7) << IRQ_DMA1_8_POS) |
59 ((CONFIG_IRQ_DMA1_9 - 7) << IRQ_DMA1_9_POS) |
60 ((CONFIG_IRQ_DMA1_10 - 7) << IRQ_DMA1_10_POS) |
61 ((CONFIG_IRQ_DMA1_11 - 7) << IRQ_DMA1_11_POS) |
62 ((CONFIG_IRQ_DMA2_0 - 7) << IRQ_DMA2_0_POS));
63
64 bfin_write_SICA_IAR3(((CONFIG_IRQ_DMA2_1 - 7) << IRQ_DMA2_1_POS) |
65 ((CONFIG_IRQ_DMA2_2 - 7) << IRQ_DMA2_2_POS) |
66 ((CONFIG_IRQ_DMA2_3 - 7) << IRQ_DMA2_3_POS) |
67 ((CONFIG_IRQ_DMA2_4 - 7) << IRQ_DMA2_4_POS) |
68 ((CONFIG_IRQ_DMA2_5 - 7) << IRQ_DMA2_5_POS) |
69 ((CONFIG_IRQ_DMA2_6 - 7) << IRQ_DMA2_6_POS) |
70 ((CONFIG_IRQ_DMA2_7 - 7) << IRQ_DMA2_7_POS) |
71 ((CONFIG_IRQ_DMA2_8 - 7) << IRQ_DMA2_8_POS));
72
73 bfin_write_SICA_IAR4(((CONFIG_IRQ_DMA2_9 - 7) << IRQ_DMA2_9_POS) |
74 ((CONFIG_IRQ_DMA2_10 - 7) << IRQ_DMA2_10_POS) |
75 ((CONFIG_IRQ_DMA2_11 - 7) << IRQ_DMA2_11_POS) |
76 ((CONFIG_IRQ_TIMER0 - 7) << IRQ_TIMER0_POS) |
77 ((CONFIG_IRQ_TIMER1 - 7) << IRQ_TIMER1_POS) |
78 ((CONFIG_IRQ_TIMER2 - 7) << IRQ_TIMER2_POS) |
79 ((CONFIG_IRQ_TIMER3 - 7) << IRQ_TIMER3_POS) |
80 ((CONFIG_IRQ_TIMER4 - 7) << IRQ_TIMER4_POS));
81
82 bfin_write_SICA_IAR5(((CONFIG_IRQ_TIMER5 - 7) << IRQ_TIMER5_POS) |
83 ((CONFIG_IRQ_TIMER6 - 7) << IRQ_TIMER6_POS) |
84 ((CONFIG_IRQ_TIMER7 - 7) << IRQ_TIMER7_POS) |
85 ((CONFIG_IRQ_TIMER8 - 7) << IRQ_TIMER8_POS) |
86 ((CONFIG_IRQ_TIMER9 - 7) << IRQ_TIMER9_POS) |
87 ((CONFIG_IRQ_TIMER10 - 7) << IRQ_TIMER10_POS) |
88 ((CONFIG_IRQ_TIMER11 - 7) << IRQ_TIMER11_POS) |
89 ((CONFIG_IRQ_PROG0_INTA - 7) << IRQ_PROG0_INTA_POS));
90
91 bfin_write_SICA_IAR6(((CONFIG_IRQ_PROG0_INTB - 7) << IRQ_PROG0_INTB_POS) |
92 ((CONFIG_IRQ_PROG1_INTA - 7) << IRQ_PROG1_INTA_POS) |
93 ((CONFIG_IRQ_PROG1_INTB - 7) << IRQ_PROG1_INTB_POS) |
94 ((CONFIG_IRQ_PROG2_INTA - 7) << IRQ_PROG2_INTA_POS) |
95 ((CONFIG_IRQ_PROG2_INTB - 7) << IRQ_PROG2_INTB_POS) |
96 ((CONFIG_IRQ_DMA1_WRRD0 - 7) << IRQ_DMA1_WRRD0_POS) |
97 ((CONFIG_IRQ_DMA1_WRRD1 - 7) << IRQ_DMA1_WRRD1_POS) |
98 ((CONFIG_IRQ_DMA2_WRRD0 - 7) << IRQ_DMA2_WRRD0_POS));
99
100 bfin_write_SICA_IAR7(((CONFIG_IRQ_DMA2_WRRD1 - 7) << IRQ_DMA2_WRRD1_POS) |
101 ((CONFIG_IRQ_IMDMA_WRRD0 - 7) << IRQ_IMDMA_WRRD0_POS) |
102 ((CONFIG_IRQ_IMDMA_WRRD1 - 7) << IRQ_IMDMA_WRRD1_POS) |
103 ((CONFIG_IRQ_WDTIMER - 7) << IRQ_WDTIMER_POS) |
104 (0 << IRQ_RESERVED_1_POS) | (0 << IRQ_RESERVED_2_POS) |
105 (0 << IRQ_SUPPLE_0_POS) | (0 << IRQ_SUPPLE_1_POS));
106
107 SSYNC();
108}
diff --git a/arch/blackfin/mach-common/Makefile b/arch/blackfin/mach-common/Makefile
new file mode 100644
index 000000000000..d3a49073d196
--- /dev/null
+++ b/arch/blackfin/mach-common/Makefile
@@ -0,0 +1,12 @@
1#
2# arch/blackfin/mach-common/Makefile
3#
4
5obj-y := \
6 cache.o cacheinit.o cplbhdlr.o cplbmgr.o entry.o \
7 interrupt.o lock.o dpmc.o irqpanic.o
8
9obj-$(CONFIG_CPLB_INFO) += cplbinfo.o
10obj-$(CONFIG_BFIN_SINGLE_CORE) += ints-priority-sc.o
11obj-$(CONFIG_BFIN_DUAL_CORE) += ints-priority-dc.o
12obj-$(CONFIG_PM) += pm.o
diff --git a/arch/blackfin/mach-common/cache.S b/arch/blackfin/mach-common/cache.S
new file mode 100644
index 000000000000..bb9446ef66ef
--- /dev/null
+++ b/arch/blackfin/mach-common/cache.S
@@ -0,0 +1,253 @@
1/*
2 * File: arch/blackfin/mach-common/cache.S
3 * Based on:
4 * Author: LG Soft India
5 *
6 * Created:
7 * Description: cache control support
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/linkage.h>
31#include <asm/cplb.h>
32#include <asm/entry.h>
33#include <asm/blackfin.h>
34#include <asm/cache.h>
35
36.text
37.align 2
38ENTRY(_cache_invalidate)
39
40 /*
41 * Icache or DcacheA or DcacheB Invalidation
42 * or any combination thereof
43 * R0 has bits
44 * CPLB_ENABLE_ICACHE_P,CPLB_ENABLE_DCACHE_P,CPLB_ENABLE_DCACHE2_P
45 * set as required
46 */
47 [--SP] = R7;
48
49 R7 = R0;
50 CC = BITTST(R7,CPLB_ENABLE_ICACHE_P);
51 IF !CC JUMP .Lno_icache;
52 [--SP] = RETS;
53 CALL _icache_invalidate;
54 RETS = [SP++];
55.Lno_icache:
56 CC = BITTST(R7,CPLB_ENABLE_DCACHE_P);
57 IF !CC JUMP .Lno_dcache_a;
58 R0 = 0; /* specifies bank A */
59 [--SP] = RETS;
60 CALL _dcache_invalidate;
61 RETS = [SP++];
62.Lno_dcache_a:
63 CC = BITTST(R7,CPLB_ENABLE_DCACHE2_P);
64 IF !CC JUMP .Lno_dcache_b;
65 R0 = 0;
66 BITSET(R0, 23); /* specifies bank B */
67 [--SP] = RETS;
68 CALL _dcache_invalidate;
69 RETS = [SP++];
70.Lno_dcache_b:
71 R7 = [SP++];
72 RTS;
73
74/* Invalidate the Entire Instruction cache by
75 * disabling IMC bit
76 */
77ENTRY(_icache_invalidate)
78ENTRY(_invalidate_entire_icache)
79 [--SP] = ( R7:5);
80
81 P0.L = (IMEM_CONTROL & 0xFFFF);
82 P0.H = (IMEM_CONTROL >> 16);
83 R7 = [P0];
84
85 /* Clear the IMC bit , All valid bits in the instruction
86 * cache are set to the invalid state
87 */
88 BITCLR(R7,IMC_P);
89 CLI R6;
90 SSYNC; /* SSYNC required before invalidating cache. */
91 .align 8;
92 [P0] = R7;
93 SSYNC;
94 STI R6;
95
96 /* Configures the instruction cache agian */
97 R6 = (IMC | ENICPLB);
98 R7 = R7 | R6;
99
100 CLI R6;
101 SSYNC; /* SSYNC required before writing to IMEM_CONTROL. */
102 .align 8;
103 [P0] = R7;
104 SSYNC;
105 STI R6;
106
107 ( R7:5) = [SP++];
108 RTS;
109
110/*
111 * blackfin_cache_flush_range(start, end)
112 * Invalidate all cache lines assocoiated with this
113 * area of memory.
114 *
115 * start: Start address
116 * end: End address
117 */
118ENTRY(_blackfin_icache_flush_range)
119 R2 = -L1_CACHE_BYTES;
120 R2 = R0 & R2;
121 P0 = R2;
122 P1 = R1;
123 CSYNC;
124 IFLUSH [P0];
1251:
126 IFLUSH [P0++];
127 CC = P0 < P1 (iu);
128 IF CC JUMP 1b (bp);
129 IFLUSH [P0];
130 SSYNC;
131 RTS;
132
133/*
134 * blackfin_icache_dcache_flush_range(start, end)
135 * FLUSH all cache lines assocoiated with this
136 * area of memory.
137 *
138 * start: Start address
139 * end: End address
140 */
141
142ENTRY(_blackfin_icache_dcache_flush_range)
143 R2 = -L1_CACHE_BYTES;
144 R2 = R0 & R2;
145 P0 = R2;
146 P1 = R1;
147 CSYNC;
148 IFLUSH [P0];
1491:
150 FLUSH [P0];
151 IFLUSH [P0++];
152 CC = P0 < P1 (iu);
153 IF CC JUMP 1b (bp);
154 IFLUSH [P0];
155 FLUSH [P0];
156 SSYNC;
157 RTS;
158
159/* Throw away all D-cached data in specified region without any obligation to
160 * write them back. However, we must clean the D-cached entries around the
161 * boundaries of the start and/or end address is not cache aligned.
162 *
163 * Start: start address,
164 * end : end address.
165 */
166
167ENTRY(_blackfin_dcache_invalidate_range)
168 R2 = -L1_CACHE_BYTES;
169 R2 = R0 & R2;
170 P0 = R2;
171 P1 = R1;
172 CSYNC;
173 FLUSHINV[P0];
1741:
175 FLUSHINV[P0++];
176 CC = P0 < P1 (iu);
177 IF CC JUMP 1b (bp);
178
179 /* If the data crosses a cache line, then we'll be pointing to
180 * the last cache line, but won't have flushed/invalidated it yet,
181 * so do one more.
182 */
183 FLUSHINV[P0];
184 SSYNC;
185 RTS;
186
187/* Invalidate the Entire Data cache by
188 * clearing DMC[1:0] bits
189 */
190ENTRY(_invalidate_entire_dcache)
191ENTRY(_dcache_invalidate)
192 [--SP] = ( R7:6);
193
194 P0.L = (DMEM_CONTROL & 0xFFFF);
195 P0.H = (DMEM_CONTROL >> 16);
196 R7 = [P0];
197
198 /* Clear the DMC[1:0] bits, All valid bits in the data
199 * cache are set to the invalid state
200 */
201 BITCLR(R7,DMC0_P);
202 BITCLR(R7,DMC1_P);
203 CLI R6;
204 SSYNC; /* SSYNC required before writing to DMEM_CONTROL. */
205 .align 8;
206 [P0] = R7;
207 SSYNC;
208 STI R6;
209
210 /* Configures the data cache again */
211
212 R6 = DMEM_CNTR;
213 R7 = R7 | R6;
214
215 CLI R6;
216 SSYNC; /* SSYNC required before writing to DMEM_CONTROL. */
217 .align 8;
218 [P0] = R7;
219 SSYNC;
220 STI R6;
221
222 ( R7:6) = [SP++];
223 RTS;
224
225ENTRY(_blackfin_dcache_flush_range)
226 R2 = -L1_CACHE_BYTES;
227 R2 = R0 & R2;
228 P0 = R2;
229 P1 = R1;
230 CSYNC;
231 FLUSH[P0];
2321:
233 FLUSH[P0++];
234 CC = P0 < P1 (iu);
235 IF CC JUMP 1b (bp);
236
237 /* If the data crosses a cache line, then we'll be pointing to
238 * the last cache line, but won't have flushed it yet, so do
239 * one more.
240 */
241 FLUSH[P0];
242 SSYNC;
243 RTS;
244
245ENTRY(_blackfin_dflush_page)
246 P1 = 1 << (PAGE_SHIFT - L1_CACHE_SHIFT);
247 P0 = R0;
248 CSYNC;
249 FLUSH[P0];
250 LSETUP (.Lfl1, .Lfl1) LC0 = P1;
251.Lfl1: FLUSH [P0++];
252 SSYNC;
253 RTS;
diff --git a/arch/blackfin/mach-common/cacheinit.S b/arch/blackfin/mach-common/cacheinit.S
new file mode 100644
index 000000000000..8c17f099e5eb
--- /dev/null
+++ b/arch/blackfin/mach-common/cacheinit.S
@@ -0,0 +1,137 @@
1/*
2 * File: arch/blackfin/mach-common/cacheinit.S
3 * Based on:
4 * Author: LG Soft India
5 *
6 * Created: ?
7 * Description: cache initialization
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30/* This function sets up the data and instruction cache. The
31 * tables like icplb table, dcplb table and Page Descriptor table
32 * are defined in cplbtab.h. You can configure those tables for
33 * your suitable requirements
34 */
35
36#include <linux/linkage.h>
37#include <asm/blackfin.h>
38
39.text
40
41#if defined(CONFIG_BLKFIN_CACHE)
42ENTRY(_bfin_icache_init)
43
44 /* Initialize Instruction CPLBS */
45
46 I0.L = (ICPLB_ADDR0 & 0xFFFF);
47 I0.H = (ICPLB_ADDR0 >> 16);
48
49 I1.L = (ICPLB_DATA0 & 0xFFFF);
50 I1.H = (ICPLB_DATA0 >> 16);
51
52 I2.L = _icplb_table;
53 I2.H = _icplb_table;
54
55 r1 = -1; /* end point comparison */
56 r3 = 15; /* max counter */
57
58/* read entries from table */
59
60.Lread_iaddr:
61 R0 = [I2++];
62 CC = R0 == R1;
63 IF CC JUMP .Lidone;
64 [I0++] = R0;
65
66.Lread_idata:
67 R2 = [I2++];
68 [I1++] = R2;
69 R3 = R3 + R1;
70 CC = R3 == R1;
71 IF !CC JUMP .Lread_iaddr;
72
73.Lidone:
74 /* Enable Instruction Cache */
75 P0.l = (IMEM_CONTROL & 0xFFFF);
76 P0.h = (IMEM_CONTROL >> 16);
77 R1 = [P0];
78 R0 = (IMC | ENICPLB);
79 R0 = R0 | R1;
80
81 /* Anomaly 05000125 */
82 CLI R2;
83 SSYNC; /* SSYNC required before writing to IMEM_CONTROL. */
84 .align 8;
85 [P0] = R0;
86 SSYNC;
87 STI R2;
88 RTS;
89#endif
90
91#if defined(CONFIG_BLKFIN_DCACHE)
92ENTRY(_bfin_dcache_init)
93
94 /* Initialize Data CPLBS */
95
96 I0.L = (DCPLB_ADDR0 & 0xFFFF);
97 I0.H = (DCPLB_ADDR0 >> 16);
98
99 I1.L = (DCPLB_DATA0 & 0xFFFF);
100 I1.H = (DCPLB_DATA0 >> 16);
101
102 I2.L = _dcplb_table;
103 I2.H = _dcplb_table;
104
105 R1 = -1; /* end point comparison */
106 R3 = 15; /* max counter */
107
108 /* read entries from table */
109.Lread_daddr:
110 R0 = [I2++];
111 cc = R0 == R1;
112 IF CC JUMP .Lddone;
113 [I0++] = R0;
114
115.Lread_ddata:
116 R2 = [I2++];
117 [I1++] = R2;
118 R3 = R3 + R1;
119 CC = R3 == R1;
120 IF !CC JUMP .Lread_daddr;
121.Lddone:
122 P0.L = (DMEM_CONTROL & 0xFFFF);
123 P0.H = (DMEM_CONTROL >> 16);
124 R1 = [P0];
125
126 R0 = DMEM_CNTR;
127
128 R0 = R0 | R1;
129 /* Anomaly 05000125 */
130 CLI R2;
131 SSYNC; /* SSYNC required before writing to DMEM_CONTROL. */
132 .align 8;
133 [P0] = R0;
134 SSYNC;
135 STI R2;
136 RTS;
137#endif
diff --git a/arch/blackfin/mach-common/cplbhdlr.S b/arch/blackfin/mach-common/cplbhdlr.S
new file mode 100644
index 000000000000..b979067c49ef
--- /dev/null
+++ b/arch/blackfin/mach-common/cplbhdlr.S
@@ -0,0 +1,130 @@
1/*
2 * File: arch/blackfin/mach-common/cplbhdlr.S
3 * Based on:
4 * Author: LG Soft India
5 *
6 * Created: ?
7 * Description: CPLB exception handler
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/linkage.h>
31#include <asm/cplb.h>
32#include <asm/entry.h>
33
34#ifdef CONFIG_EXCPT_IRQ_SYSC_L1
35.section .l1.text
36#else
37.text
38#endif
39
40.type _cplb_mgr, STT_FUNC;
41.type _panic_cplb_error, STT_FUNC;
42
43.align 2
44
45.global __cplb_hdr;
46.type __cplb_hdr, STT_FUNC;
47ENTRY(__cplb_hdr)
48 R2 = SEQSTAT;
49
50 /* Mask the contents of SEQSTAT and leave only EXCAUSE in R2 */
51 R2 <<= 26;
52 R2 >>= 26;
53
54 R1 = 0x23; /* Data access CPLB protection violation */
55 CC = R2 == R1;
56 IF !CC JUMP .Lnot_data_write;
57 R0 = 2; /* is a write to data space*/
58 JUMP .Lis_icplb_miss;
59
60.Lnot_data_write:
61 R1 = 0x2C; /* CPLB miss on an instruction fetch */
62 CC = R2 == R1;
63 R0 = 0; /* is_data_miss == False*/
64 IF CC JUMP .Lis_icplb_miss;
65
66 R1 = 0x26;
67 CC = R2 == R1;
68 IF !CC JUMP .Lunknown;
69
70 R0 = 1; /* is_data_miss == True*/
71
72.Lis_icplb_miss:
73
74#if defined(CONFIG_BLKFIN_CACHE) || defined(CONFIG_BLKFIN_DCACHE)
75# if defined(CONFIG_BLKFIN_CACHE) && !defined(CONFIG_BLKFIN_DCACHE)
76 R1 = CPLB_ENABLE_ICACHE;
77# endif
78# if !defined(CONFIG_BLKFIN_CACHE) && defined(CONFIG_BLKFIN_DCACHE)
79 R1 = CPLB_ENABLE_DCACHE;
80# endif
81# if defined(CONFIG_BLKFIN_CACHE) && defined(CONFIG_BLKFIN_DCACHE)
82 R1 = CPLB_ENABLE_DCACHE | CPLB_ENABLE_ICACHE;
83# endif
84#else
85 R1 = 0;
86#endif
87
88 [--SP] = RETS;
89 CALL _cplb_mgr;
90 RETS = [SP++];
91 CC = R0 == 0;
92 IF !CC JUMP .Lnot_replaced;
93 RTS;
94
95/*
96 * Diagnostic exception handlers
97 */
98.Lunknown:
99 R0 = CPLB_UNKNOWN_ERR;
100 JUMP .Lcplb_error;
101
102.Lnot_replaced:
103 CC = R0 == CPLB_NO_UNLOCKED;
104 IF !CC JUMP .Lnext_check;
105 R0 = CPLB_NO_UNLOCKED;
106 JUMP .Lcplb_error;
107
108.Lnext_check:
109 CC = R0 == CPLB_NO_ADDR_MATCH;
110 IF !CC JUMP .Lnext_check2;
111 R0 = CPLB_NO_ADDR_MATCH;
112 JUMP .Lcplb_error;
113
114.Lnext_check2:
115 CC = R0 == CPLB_PROT_VIOL;
116 IF !CC JUMP .Lstrange_return_from_cplb_mgr;
117 R0 = CPLB_PROT_VIOL;
118 JUMP .Lcplb_error;
119
120.Lstrange_return_from_cplb_mgr:
121 IDLE;
122 CSYNC;
123 JUMP .Lstrange_return_from_cplb_mgr;
124
125.Lcplb_error:
126 R1 = sp;
127 SP += -12;
128 call _panic_cplb_error;
129 SP += 12;
130 JUMP _handle_bad_cplb;
diff --git a/arch/blackfin/mach-common/cplbinfo.c b/arch/blackfin/mach-common/cplbinfo.c
new file mode 100644
index 000000000000..d65fac39d1bf
--- /dev/null
+++ b/arch/blackfin/mach-common/cplbinfo.c
@@ -0,0 +1,211 @@
1/*
2 * File: arch/blackfin/mach-common/cplbinfo.c
3 * Based on:
4 * Author: Sonic Zhang <sonic.zhang@analog.com>
5 *
6 * Created: Jan. 2005
7 * Description: Display CPLB status
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/module.h>
31#include <linux/kernel.h>
32#include <linux/init.h>
33#include <linux/proc_fs.h>
34
35#include <asm/current.h>
36#include <asm/uaccess.h>
37#include <asm/system.h>
38
39#include <asm/cplb.h>
40#include <asm/blackfin.h>
41
42#define CPLB_I 1
43#define CPLB_D 2
44
45#define SYNC_SYS SSYNC()
46#define SYNC_CORE CSYNC()
47
48#define CPLB_BIT_PAGESIZE 0x30000
49
50static int page_size_table[4] = {
51 0x00000400, /* 1K */
52 0x00001000, /* 4K */
53 0x00100000, /* 1M */
54 0x00400000 /* 4M */
55};
56
57static char page_size_string_table[][4] = { "1K", "4K", "1M", "4M" };
58
59static int cplb_find_entry(unsigned long *cplb_addr,
60 unsigned long *cplb_data, unsigned long addr,
61 unsigned long data)
62{
63 int ii;
64
65 for (ii = 0; ii < 16; ii++)
66 if (addr >= cplb_addr[ii] && addr < cplb_addr[ii] +
67 page_size_table[(cplb_data[ii] & CPLB_BIT_PAGESIZE) >> 16]
68 && (cplb_data[ii] == data))
69 return ii;
70
71 return -1;
72}
73
74static char *cplb_print_entry(char *buf, int type)
75{
76 unsigned long *p_addr = dpdt_table;
77 unsigned long *p_data = dpdt_table + 1;
78 unsigned long *p_icount = dpdt_swapcount_table;
79 unsigned long *p_ocount = dpdt_swapcount_table + 1;
80 unsigned long *cplb_addr = (unsigned long *)DCPLB_ADDR0;
81 unsigned long *cplb_data = (unsigned long *)DCPLB_DATA0;
82 int entry = 0, used_cplb = 0;
83
84 if (type == CPLB_I) {
85 buf += sprintf(buf, "Instrction CPLB entry:\n");
86 p_addr = ipdt_table;
87 p_data = ipdt_table + 1;
88 p_icount = ipdt_swapcount_table;
89 p_ocount = ipdt_swapcount_table + 1;
90 cplb_addr = (unsigned long *)ICPLB_ADDR0;
91 cplb_data = (unsigned long *)ICPLB_DATA0;
92 } else
93 buf += sprintf(buf, "Data CPLB entry:\n");
94
95 buf += sprintf(buf, "Address\t\tData\tSize\tValid\tLocked\tSwapin\
96\tiCount\toCount\n");
97
98 while (*p_addr != 0xffffffff) {
99 entry = cplb_find_entry(cplb_addr, cplb_data, *p_addr, *p_data);
100 if (entry >= 0)
101 used_cplb |= 1 << entry;
102
103 buf +=
104 sprintf(buf,
105 "0x%08lx\t0x%05lx\t%s\t%c\t%c\t%2d\t%ld\t%ld\n",
106 *p_addr, *p_data,
107 page_size_string_table[(*p_data & 0x30000) >> 16],
108 (*p_data & CPLB_VALID) ? 'Y' : 'N',
109 (*p_data & CPLB_LOCK) ? 'Y' : 'N', entry, *p_icount,
110 *p_ocount);
111
112 p_addr += 2;
113 p_data += 2;
114 p_icount += 2;
115 p_ocount += 2;
116 }
117
118 if (used_cplb != 0xffff) {
119 buf += sprintf(buf, "Unused/mismatched CPLBs:\n");
120
121 for (entry = 0; entry < 16; entry++)
122 if (0 == ((1 << entry) & used_cplb)) {
123 int flags = cplb_data[entry];
124 buf +=
125 sprintf(buf,
126 "%2d: 0x%08lx\t0x%05x\t%s\t%c\t%c\n",
127 entry, cplb_addr[entry], flags,
128 page_size_string_table[(flags &
129 0x30000) >>
130 16],
131 (flags & CPLB_VALID) ? 'Y' : 'N',
132 (flags & CPLB_LOCK) ? 'Y' : 'N');
133 }
134 }
135
136 buf += sprintf(buf, "\n");
137
138 return buf;
139}
140
141static int cplbinfo_proc_output(char *buf)
142{
143 char *p;
144
145 p = buf;
146
147 p += sprintf(p,
148 "------------------ CPLB Information ------------------\n\n");
149
150 if (bfin_read_IMEM_CONTROL() & ENICPLB)
151 p = cplb_print_entry(p, CPLB_I);
152 else
153 p += sprintf(p, "Instruction CPLB is disabled.\n\n");
154
155 if (bfin_read_DMEM_CONTROL() & ENDCPLB)
156 p = cplb_print_entry(p, CPLB_D);
157 else
158 p += sprintf(p, "Data CPLB is disabled.\n");
159
160 return p - buf;
161}
162
163static int cplbinfo_read_proc(char *page, char **start, off_t off,
164 int count, int *eof, void *data)
165{
166 int len;
167
168 len = cplbinfo_proc_output(page);
169 if (len <= off + count)
170 *eof = 1;
171 *start = page + off;
172 len -= off;
173 if (len > count)
174 len = count;
175 if (len < 0)
176 len = 0;
177 return len;
178}
179
180static int cplbinfo_write_proc(struct file *file, const char __user *buffer,
181 unsigned long count, void *data)
182{
183 printk(KERN_INFO "Reset the CPLB swap in/out counts.\n");
184 memset(ipdt_swapcount_table, 0, MAX_SWITCH_I_CPLBS * sizeof(unsigned long));
185 memset(dpdt_swapcount_table, 0, MAX_SWITCH_D_CPLBS * sizeof(unsigned long));
186
187 return count;
188}
189
190static int __init cplbinfo_init(void)
191{
192 struct proc_dir_entry *entry;
193
194 if ((entry = create_proc_entry("cplbinfo", 0, NULL)) == NULL) {
195 return -ENOMEM;
196 }
197
198 entry->read_proc = cplbinfo_read_proc;
199 entry->write_proc = cplbinfo_write_proc;
200 entry->data = NULL;
201
202 return 0;
203}
204
205static void __exit cplbinfo_exit(void)
206{
207 remove_proc_entry("cplbinfo", NULL);
208}
209
210module_init(cplbinfo_init);
211module_exit(cplbinfo_exit);
diff --git a/arch/blackfin/mach-common/cplbmgr.S b/arch/blackfin/mach-common/cplbmgr.S
new file mode 100644
index 000000000000..f5efc4bc65e6
--- /dev/null
+++ b/arch/blackfin/mach-common/cplbmgr.S
@@ -0,0 +1,607 @@
1/*
2 * File: arch/blackfin/mach-common/cplbmgtr.S
3 * Based on:
4 * Author: LG Soft India
5 *
6 * Created: ?
7 * Description: CPLB replacement routine for CPLB mismatch
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30/* Usage: int _cplb_mgr(is_data_miss,int enable_cache)
31 * is_data_miss==2 => Mark as Dirty, write to the clean data page
32 * is_data_miss==1 => Replace a data CPLB.
33 * is_data_miss==0 => Replace an instruction CPLB.
34 *
35 * Returns:
36 * CPLB_RELOADED => Successfully updated CPLB table.
37 * CPLB_NO_UNLOCKED => All CPLBs are locked, so cannot be evicted.
38 * This indicates that the CPLBs in the configuration
39 * tablei are badly configured, as this should never
40 * occur.
41 * CPLB_NO_ADDR_MATCH => The address being accessed, that triggered the
42 * exception, is not covered by any of the CPLBs in
43 * the configuration table. The application is
44 * presumably misbehaving.
45 * CPLB_PROT_VIOL => The address being accessed, that triggered the
46 * exception, was not a first-write to a clean Write
47 * Back Data page, and so presumably is a genuine
48 * violation of the page's protection attributes.
49 * The application is misbehaving.
50 */
51
52#include <linux/linkage.h>
53#include <asm/blackfin.h>
54#include <asm/cplb.h>
55
56#ifdef CONFIG_EXCPT_IRQ_SYSC_L1
57.section .l1.text
58#else
59.text
60#endif
61
62.align 2;
63ENTRY(_cplb_mgr)
64
65 [--SP]=( R7:4,P5:3 );
66
67 CC = R0 == 2;
68 IF CC JUMP .Ldcplb_write;
69
70 CC = R0 == 0;
71 IF !CC JUMP .Ldcplb_miss_compare;
72
73 /* ICPLB Miss Exception. We need to choose one of the
74 * currently-installed CPLBs, and replace it with one
75 * from the configuration table.
76 */
77
78 P4.L = (ICPLB_FAULT_ADDR & 0xFFFF);
79 P4.H = (ICPLB_FAULT_ADDR >> 16);
80
81 P1 = 16;
82 P5.L = _page_size_table;
83 P5.H = _page_size_table;
84
85 P0.L = (ICPLB_DATA0 & 0xFFFF);
86 P0.H = (ICPLB_DATA0 >> 16);
87 R4 = [P4]; /* Get faulting address*/
88 R6 = 64; /* Advance past the fault address, which*/
89 R6 = R6 + R4; /* we'll use if we find a match*/
90 R3 = ((16 << 8) | 2); /* Extract mask, bits 16 and 17.*/
91
92 R5 = 0;
93.Lisearch:
94
95 R1 = [P0-0x100]; /* Address for this CPLB */
96
97 R0 = [P0++]; /* Info for this CPLB*/
98 CC = BITTST(R0,0); /* Is the CPLB valid?*/
99 IF !CC JUMP .Lnomatch; /* Skip it, if not.*/
100 CC = R4 < R1(IU); /* If fault address less than page start*/
101 IF CC JUMP .Lnomatch; /* then skip this one.*/
102 R2 = EXTRACT(R0,R3.L) (Z); /* Get page size*/
103 P1 = R2;
104 P1 = P5 + (P1<<2); /* index into page-size table*/
105 R2 = [P1]; /* Get the page size*/
106 R1 = R1 + R2; /* and add to page start, to get page end*/
107 CC = R4 < R1(IU); /* and see whether fault addr is in page.*/
108 IF !CC R4 = R6; /* If so, advance the address and finish loop.*/
109 IF !CC JUMP .Lisearch_done;
110.Lnomatch:
111 /* Go around again*/
112 R5 += 1;
113 CC = BITTST(R5, 4); /* i.e CC = R5 >= 16*/
114 IF !CC JUMP .Lisearch;
115
116.Lisearch_done:
117 I0 = R4; /* Fault address we'll search for*/
118
119 /* set up pointers */
120 P0.L = (ICPLB_DATA0 & 0xFFFF);
121 P0.H = (ICPLB_DATA0 >> 16);
122
123 /* The replacement procedure for ICPLBs */
124
125 P4.L = (IMEM_CONTROL & 0xFFFF);
126 P4.H = (IMEM_CONTROL >> 16);
127
128 /* disable cplbs */
129 R5 = [P4]; /* Control Register*/
130 BITCLR(R5,ENICPLB_P);
131 CLI R1;
132 SSYNC; /* SSYNC required before writing to IMEM_CONTROL. */
133 .align 8;
134 [P4] = R5;
135 SSYNC;
136 STI R1;
137
138 R1 = -1; /* end point comparison */
139 R3 = 16; /* counter */
140
141 /* Search through CPLBs for first non-locked entry */
142 /* Overwrite it by moving everyone else up by 1 */
143.Licheck_lock:
144 R0 = [P0++];
145 R3 = R3 + R1;
146 CC = R3 == R1;
147 IF CC JUMP .Lall_locked;
148 CC = BITTST(R0, 0); /* an invalid entry is good */
149 IF !CC JUMP .Lifound_victim;
150 CC = BITTST(R0,1); /* but a locked entry isn't */
151 IF CC JUMP .Licheck_lock;
152
153.Lifound_victim:
154#ifdef CONFIG_CPLB_INFO
155 R7 = [P0 - 0x104];
156 P2.L = _ipdt_table;
157 P2.H = _ipdt_table;
158 P3.L = _ipdt_swapcount_table;
159 P3.H = _ipdt_swapcount_table;
160 P3 += -4;
161.Licount:
162 R2 = [P2]; /* address from config table */
163 P2 += 8;
164 P3 += 8;
165 CC = R2==-1;
166 IF CC JUMP .Licount_done;
167 CC = R7==R2;
168 IF !CC JUMP .Licount;
169 R7 = [P3];
170 R7 += 1;
171 [P3] = R7;
172 CSYNC;
173.Licount_done:
174#endif
175 LC0=R3;
176 LSETUP(.Lis_move,.Lie_move) LC0;
177.Lis_move:
178 R0 = [P0];
179 [P0 - 4] = R0;
180 R0 = [P0 - 0x100];
181 [P0-0x104] = R0;
182.Lie_move:P0+=4;
183
184 /* We've made space in the ICPLB table, so that ICPLB15
185 * is now free to be overwritten. Next, we have to determine
186 * which CPLB we need to install, from the configuration
187 * table. This is a matter of getting the start-of-page
188 * addresses and page-lengths from the config table, and
189 * determining whether the fault address falls within that
190 * range.
191 */
192
193 P2.L = _ipdt_table;
194 P2.H = _ipdt_table;
195#ifdef CONFIG_CPLB_INFO
196 P3.L = _ipdt_swapcount_table;
197 P3.H = _ipdt_swapcount_table;
198 P3 += -8;
199#endif
200 P0.L = _page_size_table;
201 P0.H = _page_size_table;
202
203 /* Retrieve our fault address (which may have been advanced
204 * because the faulting instruction crossed a page boundary).
205 */
206
207 R0 = I0;
208
209 /* An extraction pattern, to get the page-size bits from
210 * the CPLB data entry. Bits 16-17, so two bits at posn 16.
211 */
212
213 R1 = ((16<<8)|2);
214.Linext: R4 = [P2++]; /* address from config table */
215 R2 = [P2++]; /* data from config table */
216#ifdef CONFIG_CPLB_INFO
217 P3 += 8;
218#endif
219
220 CC = R4 == -1; /* End of config table*/
221 IF CC JUMP .Lno_page_in_table;
222
223 /* See if failed address > start address */
224 CC = R4 <= R0(IU);
225 IF !CC JUMP .Linext;
226
227 /* extract page size (17:16)*/
228 R3 = EXTRACT(R2, R1.L) (Z);
229
230 /* add page size to addr to get range */
231
232 P5 = R3;
233 P5 = P0 + (P5 << 2); /* scaled, for int access*/
234 R3 = [P5];
235 R3 = R3 + R4;
236
237 /* See if failed address < (start address + page size) */
238 CC = R0 < R3(IU);
239 IF !CC JUMP .Linext;
240
241 /* We've found a CPLB in the config table that covers
242 * the faulting address, so install this CPLB into the
243 * last entry of the table.
244 */
245
246 P1.L = (ICPLB_DATA15 & 0xFFFF); /* ICPLB_DATA15 */
247 P1.H = (ICPLB_DATA15 >> 16);
248 [P1] = R2;
249 [P1-0x100] = R4;
250#ifdef CONFIG_CPLB_INFO
251 R3 = [P3];
252 R3 += 1;
253 [P3] = R3;
254#endif
255
256 /* P4 points to IMEM_CONTROL, and R5 contains its old
257 * value, after we disabled ICPLBS. Re-enable them.
258 */
259
260 BITSET(R5,ENICPLB_P);
261 CLI R2;
262 SSYNC; /* SSYNC required before writing to IMEM_CONTROL. */
263 .align 8;
264 [P4] = R5;
265 SSYNC;
266 STI R2;
267
268 ( R7:4,P5:3 ) = [SP++];
269 R0 = CPLB_RELOADED;
270 RTS;
271
272/* FAILED CASES*/
273.Lno_page_in_table:
274 ( R7:4,P5:3 ) = [SP++];
275 R0 = CPLB_NO_ADDR_MATCH;
276 RTS;
277.Lall_locked:
278 ( R7:4,P5:3 ) = [SP++];
279 R0 = CPLB_NO_UNLOCKED;
280 RTS;
281.Lprot_violation:
282 ( R7:4,P5:3 ) = [SP++];
283 R0 = CPLB_PROT_VIOL;
284 RTS;
285
286.Ldcplb_write:
287
288 /* if a DCPLB is marked as write-back (CPLB_WT==0), and
289 * it is clean (CPLB_DIRTY==0), then a write to the
290 * CPLB's page triggers a protection violation. We have to
291 * mark the CPLB as dirty, to indicate that there are
292 * pending writes associated with the CPLB.
293 */
294
295 P4.L = (DCPLB_STATUS & 0xFFFF);
296 P4.H = (DCPLB_STATUS >> 16);
297 P3.L = (DCPLB_DATA0 & 0xFFFF);
298 P3.H = (DCPLB_DATA0 >> 16);
299 R5 = [P4];
300
301 /* A protection violation can be caused by more than just writes
302 * to a clean WB page, so we have to ensure that:
303 * - It's a write
304 * - to a clean WB page
305 * - and is allowed in the mode the access occurred.
306 */
307
308 CC = BITTST(R5, 16); /* ensure it was a write*/
309 IF !CC JUMP .Lprot_violation;
310
311 /* to check the rest, we have to retrieve the DCPLB.*/
312
313 /* The low half of DCPLB_STATUS is a bit mask*/
314
315 R2 = R5.L (Z); /* indicating which CPLB triggered the event.*/
316 R3 = 30; /* so we can use this to determine the offset*/
317 R2.L = SIGNBITS R2;
318 R2 = R2.L (Z); /* into the DCPLB table.*/
319 R3 = R3 - R2;
320 P4 = R3;
321 P3 = P3 + (P4<<2);
322 R3 = [P3]; /* Retrieve the CPLB*/
323
324 /* Now we can check whether it's a clean WB page*/
325
326 CC = BITTST(R3, 14); /* 0==WB, 1==WT*/
327 IF CC JUMP .Lprot_violation;
328 CC = BITTST(R3, 7); /* 0 == clean, 1 == dirty*/
329 IF CC JUMP .Lprot_violation;
330
331 /* Check whether the write is allowed in the mode that was active.*/
332
333 R2 = 1<<3; /* checking write in user mode*/
334 CC = BITTST(R5, 17); /* 0==was user, 1==was super*/
335 R5 = CC;
336 R2 <<= R5; /* if was super, check write in super mode*/
337 R2 = R3 & R2;
338 CC = R2 == 0;
339 IF CC JUMP .Lprot_violation;
340
341 /* It's a genuine write-to-clean-page.*/
342
343 BITSET(R3, 7); /* mark as dirty*/
344 [P3] = R3; /* and write back.*/
345 NOP;
346 CSYNC;
347 ( R7:4,P5:3 ) = [SP++];
348 R0 = CPLB_RELOADED;
349 RTS;
350
351.Ldcplb_miss_compare:
352
353 /* Data CPLB Miss event. We need to choose a CPLB to
354 * evict, and then locate a new CPLB to install from the
355 * config table, that covers the faulting address.
356 */
357
358 P1.L = (DCPLB_DATA15 & 0xFFFF);
359 P1.H = (DCPLB_DATA15 >> 16);
360
361 P4.L = (DCPLB_FAULT_ADDR & 0xFFFF);
362 P4.H = (DCPLB_FAULT_ADDR >> 16);
363 R4 = [P4];
364 I0 = R4;
365
366 /* The replacement procedure for DCPLBs*/
367
368 R6 = R1; /* Save for later*/
369
370 /* Turn off CPLBs while we work.*/
371 P4.L = (DMEM_CONTROL & 0xFFFF);
372 P4.H = (DMEM_CONTROL >> 16);
373 R5 = [P4];
374 BITCLR(R5,ENDCPLB_P);
375 CLI R0;
376 SSYNC; /* SSYNC required before writing to DMEM_CONTROL. */
377 .align 8;
378 [P4] = R5;
379 SSYNC;
380 STI R0;
381
382 /* Start looking for a CPLB to evict. Our order of preference
383 * is: invalid CPLBs, clean CPLBs, dirty CPLBs. Locked CPLBs
384 * are no good.
385 */
386
387 I1.L = (DCPLB_DATA0 & 0xFFFF);
388 I1.H = (DCPLB_DATA0 >> 16);
389 P1 = 2;
390 P2 = 16;
391 I2.L = _dcplb_preference;
392 I2.H = _dcplb_preference;
393 LSETUP(.Lsdsearch1, .Ledsearch1) LC0 = P1;
394.Lsdsearch1:
395 R0 = [I2++]; /* Get the bits we're interested in*/
396 P0 = I1; /* Go back to start of table*/
397 LSETUP (.Lsdsearch2, .Ledsearch2) LC1 = P2;
398.Lsdsearch2:
399 R1 = [P0++]; /* Fetch each installed CPLB in turn*/
400 R2 = R1 & R0; /* and test for interesting bits.*/
401 CC = R2 == 0; /* If none are set, it'll do.*/
402 IF !CC JUMP .Lskip_stack_check;
403
404 R2 = [P0 - 0x104]; /* R2 - PageStart */
405 P3.L = _page_size_table; /* retrieve end address */
406 P3.H = _page_size_table; /* retrieve end address */
407 R3 = 0x1002; /* 16th - position, 2 bits -length */
408#ifdef ANOMALY_05000209
409 nop; /* Anomaly 05000209 */
410#endif
411 R7 = EXTRACT(R1,R3.l);
412 R7 = R7 << 2; /* Page size index offset */
413 P5 = R7;
414 P3 = P3 + P5;
415 R7 = [P3]; /* page size in bytes */
416
417 R7 = R2 + R7; /* R7 - PageEnd */
418 R4 = SP; /* Test SP is in range */
419
420 CC = R7 < R4; /* if PageEnd < SP */
421 IF CC JUMP .Ldfound_victim;
422 R3 = 0x284; /* stack length from start of trap till
423 * the point.
424 * 20 stack locations for future modifications
425 */
426 R4 = R4 + R3;
427 CC = R4 < R2; /* if SP + stacklen < PageStart */
428 IF CC JUMP .Ldfound_victim;
429.Lskip_stack_check:
430
431.Ledsearch2: NOP;
432.Ledsearch1: NOP;
433
434 /* If we got here, we didn't find a DCPLB we considered
435 * replacable, which means all of them were locked.
436 */
437
438 JUMP .Lall_locked;
439.Ldfound_victim:
440
441#ifdef CONFIG_CPLB_INFO
442 R7 = [P0 - 0x104];
443 P2.L = _dpdt_table;
444 P2.H = _dpdt_table;
445 P3.L = _dpdt_swapcount_table;
446 P3.H = _dpdt_swapcount_table;
447 P3 += -4;
448.Ldicount:
449 R2 = [P2];
450 P2 += 8;
451 P3 += 8;
452 CC = R2==-1;
453 IF CC JUMP .Ldicount_done;
454 CC = R7==R2;
455 IF !CC JUMP .Ldicount;
456 R7 = [P3];
457 R7 += 1;
458 [P3] = R7;
459.Ldicount_done:
460#endif
461
462 /* Clean down the hardware loops*/
463 R2 = 0;
464 LC1 = R2;
465 LC0 = R2;
466
467 /* There's a suitable victim in [P0-4] (because we've
468 * advanced already).
469 */
470
471.LDdoverwrite:
472
473 /* [P0-4] is a suitable victim CPLB, so we want to
474 * overwrite it by moving all the following CPLBs
475 * one space closer to the start.
476 */
477
478 R1.L = (DCPLB_DATA16 & 0xFFFF); /* DCPLB_DATA15 + 4 */
479 R1.H = (DCPLB_DATA16 >> 16);
480 R0 = P0;
481
482 /* If the victim happens to be in DCPLB15,
483 * we don't need to move anything.
484 */
485
486 CC = R1 == R0;
487 IF CC JUMP .Lde_moved;
488 R1 = R1 - R0;
489 R1 >>= 2;
490 P1 = R1;
491 LSETUP(.Lds_move, .Lde_move) LC0=P1;
492.Lds_move:
493 R0 = [P0++]; /* move data */
494 [P0 - 8] = R0;
495 R0 = [P0-0x104] /* move address */
496.Lde_move: [P0-0x108] = R0;
497
498 /* We've now made space in DCPLB15 for the new CPLB to be
499 * installed. The next stage is to locate a CPLB in the
500 * config table that covers the faulting address.
501 */
502
503.Lde_moved:NOP;
504 R0 = I0; /* Our faulting address */
505
506 P2.L = _dpdt_table;
507 P2.H = _dpdt_table;
508#ifdef CONFIG_CPLB_INFO
509 P3.L = _dpdt_swapcount_table;
510 P3.H = _dpdt_swapcount_table;
511 P3 += -8;
512#endif
513
514 P1.L = _page_size_table;
515 P1.H = _page_size_table;
516
517 /* An extraction pattern, to retrieve bits 17:16.*/
518
519 R1 = (16<<8)|2;
520.Ldnext: R4 = [P2++]; /* address */
521 R2 = [P2++]; /* data */
522#ifdef CONFIG_CPLB_INFO
523 P3 += 8;
524#endif
525
526 CC = R4 == -1;
527 IF CC JUMP .Lno_page_in_table;
528
529 /* See if failed address > start address */
530 CC = R4 <= R0(IU);
531 IF !CC JUMP .Ldnext;
532
533 /* extract page size (17:16)*/
534 R3 = EXTRACT(R2, R1.L) (Z);
535
536 /* add page size to addr to get range */
537
538 P5 = R3;
539 P5 = P1 + (P5 << 2);
540 R3 = [P5];
541 R3 = R3 + R4;
542
543 /* See if failed address < (start address + page size) */
544 CC = R0 < R3(IU);
545 IF !CC JUMP .Ldnext;
546
547 /* We've found the CPLB that should be installed, so
548 * write it into CPLB15, masking off any caching bits
549 * if necessary.
550 */
551
552 P1.L = (DCPLB_DATA15 & 0xFFFF);
553 P1.H = (DCPLB_DATA15 >> 16);
554
555 /* If the DCPLB has cache bits set, but caching hasn't
556 * been enabled, then we want to mask off the cache-in-L1
557 * bit before installing. Moreover, if caching is off, we
558 * also want to ensure that the DCPLB has WT mode set, rather
559 * than WB, since WB pages still trigger first-write exceptions
560 * even when not caching is off, and the page isn't marked as
561 * cachable. Finally, we could mark the page as clean, not dirty,
562 * but we choose to leave that decision to the user; if the user
563 * chooses to have a CPLB pre-defined as dirty, then they always
564 * pay the cost of flushing during eviction, but don't pay the
565 * cost of first-write exceptions to mark the page as dirty.
566 */
567
568#ifdef CONFIG_BLKFIN_WT
569 BITSET(R6, 14); /* Set WT*/
570#endif
571
572 [P1] = R2;
573 [P1-0x100] = R4;
574#ifdef CONFIG_CPLB_INFO
575 R3 = [P3];
576 R3 += 1;
577 [P3] = R3;
578#endif
579
580 /* We've installed the CPLB, so re-enable CPLBs. P4
581 * points to DMEM_CONTROL, and R5 is the value we
582 * last wrote to it, when we were disabling CPLBs.
583 */
584
585 BITSET(R5,ENDCPLB_P);
586 CLI R2;
587 .align 8;
588 [P4] = R5;
589 SSYNC;
590 STI R2;
591
592 ( R7:4,P5:3 ) = [SP++];
593 R0 = CPLB_RELOADED;
594 RTS;
595
596.data
597.align 4;
598_page_size_table:
599.byte4 0x00000400; /* 1K */
600.byte4 0x00001000; /* 4K */
601.byte4 0x00100000; /* 1M */
602.byte4 0x00400000; /* 4M */
603
604.align 4;
605_dcplb_preference:
606.byte4 0x00000001; /* valid bit */
607.byte4 0x00000002; /* lock bit */
diff --git a/arch/blackfin/mach-common/dpmc.S b/arch/blackfin/mach-common/dpmc.S
new file mode 100644
index 000000000000..97cdcd6a00d4
--- /dev/null
+++ b/arch/blackfin/mach-common/dpmc.S
@@ -0,0 +1,418 @@
1/*
2 * File: arch/blackfin/mach-common/dpmc.S
3 * Based on:
4 * Author: LG Soft India
5 *
6 * Created: ?
7 * Description: Watchdog Timer APIs
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/linkage.h>
31#include <asm/blackfin.h>
32#include <asm/mach/irq.h>
33
34.text
35
36ENTRY(_unmask_wdog_wakeup_evt)
37 [--SP] = ( R7:0, P5:0 );
38#if defined(CONFIG_BF561)
39 P0.H = hi(SICA_IWR1);
40 P0.L = lo(SICA_IWR1);
41#else
42 P0.h = (SIC_IWR >> 16);
43 P0.l = (SIC_IWR & 0xFFFF);
44#endif
45 R7 = [P0];
46#if defined(CONFIG_BF561)
47 BITSET(R7, 27);
48#else
49 BITSET(R7,(IRQ_WATCH - IVG7));
50#endif
51 [P0] = R7;
52 SSYNC;
53
54 ( R7:0, P5:0 ) = [SP++];
55 RTS;
56
57.LWRITE_TO_STAT:
58 /* When watch dog timer is enabled, a write to STAT will load the
59 * contents of CNT to STAT
60 */
61 R7 = 0x0000(z);
62#if defined(CONFIG_BF561)
63 P0.h = (WDOGA_STAT >> 16);
64 P0.l = (WDOGA_STAT & 0xFFFF);
65#else
66 P0.h = (WDOG_STAT >> 16);
67 P0.l = (WDOG_STAT & 0xFFFF);
68#endif
69 [P0] = R7;
70 SSYNC;
71 JUMP .LSKIP_WRITE_TO_STAT;
72
73ENTRY(_program_wdog_timer)
74 [--SP] = ( R7:0, P5:0 );
75#if defined(CONFIG_BF561)
76 P0.h = (WDOGA_CNT >> 16);
77 P0.l = (WDOGA_CNT & 0xFFFF);
78#else
79 P0.h = (WDOG_CNT >> 16);
80 P0.l = (WDOG_CNT & 0xFFFF);
81#endif
82 [P0] = R0;
83 SSYNC;
84
85#if defined(CONFIG_BF561)
86 P0.h = (WDOGA_CTL >> 16);
87 P0.l = (WDOGA_CTL & 0xFFFF);
88#else
89 P0.h = (WDOG_CTL >> 16);
90 P0.l = (WDOG_CTL & 0xFFFF);
91#endif
92 R7 = W[P0](Z);
93 CC = BITTST(R7,1);
94 if !CC JUMP .LWRITE_TO_STAT;
95 CC = BITTST(R7,2);
96 if !CC JUMP .LWRITE_TO_STAT;
97
98.LSKIP_WRITE_TO_STAT:
99#if defined(CONFIG_BF561)
100 P0.h = (WDOGA_CTL >> 16);
101 P0.l = (WDOGA_CTL & 0xFFFF);
102#else
103 P0.h = (WDOG_CTL >> 16);
104 P0.l = (WDOG_CTL & 0xFFFF);
105#endif
106 R7 = W[P0](Z);
107 BITCLR(R7,1); /* Enable GP event */
108 BITSET(R7,2);
109 W[P0] = R7.L;
110 SSYNC;
111 NOP;
112
113 R7 = W[P0](Z);
114 BITCLR(R7,4); /* Enable the wdog counter */
115 W[P0] = R7.L;
116 SSYNC;
117
118 ( R7:0, P5:0 ) = [SP++];
119 RTS;
120
121ENTRY(_clear_wdog_wakeup_evt)
122 [--SP] = ( R7:0, P5:0 );
123
124#if defined(CONFIG_BF561)
125 P0.h = (WDOGA_CTL >> 16);
126 P0.l = (WDOGA_CTL & 0xFFFF);
127#else
128 P0.h = (WDOG_CTL >> 16);
129 P0.l = (WDOG_CTL & 0xFFFF);
130#endif
131 R7 = 0x0AD6(Z);
132 W[P0] = R7.L;
133 SSYNC;
134
135 R7 = W[P0](Z);
136 BITSET(R7,15);
137 W[P0] = R7.L;
138 SSYNC;
139
140 R7 = W[P0](Z);
141 BITSET(R7,1);
142 BITSET(R7,2);
143 W[P0] = R7.L;
144 SSYNC;
145
146 ( R7:0, P5:0 ) = [SP++];
147 RTS;
148
149ENTRY(_disable_wdog_timer)
150 [--SP] = ( R7:0, P5:0 );
151#if defined(CONFIG_BF561)
152 P0.h = (WDOGA_CTL >> 16);
153 P0.l = (WDOGA_CTL & 0xFFFF);
154#else
155 P0.h = (WDOG_CTL >> 16);
156 P0.l = (WDOG_CTL & 0xFFFF);
157#endif
158 R7 = 0xAD6(Z);
159 W[P0] = R7.L;
160 SSYNC;
161 ( R7:0, P5:0 ) = [SP++];
162 RTS;
163
164#if !defined(CONFIG_BF561)
165
166.section .l1.text
167
168ENTRY(_sleep_mode)
169 [--SP] = ( R7:0, P5:0 );
170 [--SP] = RETS;
171
172 call _set_sic_iwr;
173
174 R0 = 0xFFFF (Z);
175 call _set_rtc_istat
176
177 P0.H = hi(PLL_CTL);
178 P0.L = lo(PLL_CTL);
179 R1 = W[P0](z);
180 BITSET (R1, 3);
181 W[P0] = R1.L;
182
183 CLI R2;
184 SSYNC;
185 IDLE;
186 STI R2;
187
188 call _test_pll_locked;
189
190 R0 = IWR_ENABLE(0);
191 call _set_sic_iwr;
192
193 P0.H = hi(PLL_CTL);
194 P0.L = lo(PLL_CTL);
195 R7 = w[p0](z);
196 BITCLR (R7, 3);
197 BITCLR (R7, 5);
198 w[p0] = R7.L;
199 IDLE;
200 call _test_pll_locked;
201
202 RETS = [SP++];
203 ( R7:0, P5:0 ) = [SP++];
204 RTS;
205
206ENTRY(_hibernate_mode)
207 [--SP] = ( R7:0, P5:0 );
208 [--SP] = RETS;
209
210 call _set_sic_iwr;
211
212 R0 = 0xFFFF (Z);
213 call _set_rtc_istat
214
215 P0.H = hi(VR_CTL);
216 P0.L = lo(VR_CTL);
217 R1 = W[P0](z);
218 BITSET (R1, 8);
219 BITCLR (R1, 0);
220 BITCLR (R1, 1);
221 W[P0] = R1.L;
222 SSYNC;
223
224 CLI R2;
225 IDLE;
226
227 /* Actually, adding anything may not be necessary...SDRAM contents
228 * are lost
229 */
230
231ENTRY(_deep_sleep)
232 [--SP] = ( R7:0, P5:0 );
233 [--SP] = RETS;
234
235 CLI R4;
236
237 call _set_sic_iwr;
238
239 call _set_sdram_srfs;
240
241 /* Clear all the interrupts,bits sticky */
242 R0 = 0xFFFF (Z);
243 call _set_rtc_istat
244
245 P0.H = hi(PLL_CTL);
246 P0.L = lo(PLL_CTL);
247 R0 = W[P0](z);
248 BITSET (R0, 5);
249 W[P0] = R0.L;
250
251 call _test_pll_locked;
252
253 SSYNC;
254 IDLE;
255
256 call _unset_sdram_srfs;
257
258 call _test_pll_locked;
259
260 R0 = IWR_ENABLE(0);
261 call _set_sic_iwr;
262
263 P0.H = hi(PLL_CTL);
264 P0.L = lo(PLL_CTL);
265 R0 = w[p0](z);
266 BITCLR (R0, 3);
267 BITCLR (R0, 5);
268 BITCLR (R0, 8);
269 w[p0] = R0;
270 IDLE;
271 call _test_pll_locked;
272
273 STI R4;
274
275 RETS = [SP++];
276 ( R7:0, P5:0 ) = [SP++];
277 RTS;
278
279ENTRY(_sleep_deeper)
280 [--SP] = ( R7:0, P5:0 );
281 [--SP] = RETS;
282
283 CLI R4;
284
285 P3 = R0;
286 R0 = IWR_ENABLE(0);
287 call _set_sic_iwr;
288 call _set_sdram_srfs;
289
290 /* Clear all the interrupts,bits sticky */
291 R0 = 0xFFFF (Z);
292 call _set_rtc_istat
293
294 P0.H = hi(PLL_DIV);
295 P0.L = lo(PLL_DIV);
296 R6 = W[P0](z);
297 R0.L = 0xF;
298 W[P0] = R0.l;
299
300 P0.H = hi(PLL_CTL);
301 P0.L = lo(PLL_CTL);
302 R5 = W[P0](z);
303 R0.L = (MIN_VC/CONFIG_CLKIN_HZ) << 9;
304 W[P0] = R0.l;
305
306 SSYNC;
307 IDLE;
308
309 call _test_pll_locked;
310
311 P0.H = hi(VR_CTL);
312 P0.L = lo(VR_CTL);
313 R7 = W[P0](z);
314 R1 = 0x6;
315 R1 <<= 16;
316 R2 = 0x0404(Z);
317 R1 = R1|R2;
318
319 R2 = DEPOSIT(R7, R1);
320 W[P0] = R2;
321
322 SSYNC;
323 IDLE;
324
325 call _test_pll_locked;
326
327 P0.H = hi(PLL_CTL);
328 P0.L = lo(PLL_CTL);
329 R0 = W[P0](z);
330 BITSET (R0, 3);
331 W[P0] = R0.L;
332
333 R0 = P3;
334 call _set_sic_iwr;
335
336 SSYNC;
337 IDLE;
338
339 call _test_pll_locked;
340
341 R0 = IWR_ENABLE(0);
342 call _set_sic_iwr;
343
344 P0.H = hi(VR_CTL);
345 P0.L = lo(VR_CTL);
346 W[P0]= R7;
347
348 SSYNC;
349 IDLE;
350
351 call _test_pll_locked;
352
353 P0.H = hi(PLL_DIV);
354 P0.L = lo(PLL_DIV);
355 W[P0]= R6;
356
357 P0.H = hi(PLL_CTL);
358 P0.L = lo(PLL_CTL);
359 w[p0] = R5;
360 IDLE;
361 call _test_pll_locked;
362
363 call _unset_sdram_srfs;
364
365 STI R4;
366
367 RETS = [SP++];
368 ( R7:0, P5:0 ) = [SP++];
369 RTS;
370
371ENTRY(_set_sdram_srfs)
372 /* set the sdram to self refresh mode */
373 P0.H = hi(EBIU_SDGCTL);
374 P0.L = lo(EBIU_SDGCTL);
375 R2 = [P0];
376 R3.H = hi(SRFS);
377 R3.L = lo(SRFS);
378 R2 = R2|R3;
379 [P0] = R2;
380 ssync;
381 RTS;
382
383ENTRY(_unset_sdram_srfs)
384 /* set the sdram out of self refresh mode */
385 P0.H = hi(EBIU_SDGCTL);
386 P0.L = lo(EBIU_SDGCTL);
387 R2 = [P0];
388 R3.H = hi(SRFS);
389 R3.L = lo(SRFS);
390 R3 = ~R3;
391 R2 = R2&R3;
392 [P0] = R2;
393 ssync;
394 RTS;
395
396ENTRY(_set_sic_iwr)
397 P0.H = hi(SIC_IWR);
398 P0.L = lo(SIC_IWR);
399 [P0] = R0;
400 SSYNC;
401 RTS;
402
403ENTRY(_set_rtc_istat)
404 P0.H = hi(RTC_ISTAT);
405 P0.L = lo(RTC_ISTAT);
406 w[P0] = R0.L;
407 SSYNC;
408 RTS;
409
410ENTRY(_test_pll_locked)
411 P0.H = hi(PLL_STAT);
412 P0.L = lo(PLL_STAT);
4131:
414 R0 = W[P0] (Z);
415 CC = BITTST(R0,5);
416 IF !CC JUMP 1b;
417 RTS;
418#endif
diff --git a/arch/blackfin/mach-common/entry.S b/arch/blackfin/mach-common/entry.S
new file mode 100644
index 000000000000..8eb0a9023482
--- /dev/null
+++ b/arch/blackfin/mach-common/entry.S
@@ -0,0 +1,1207 @@
1/*
2 * File: arch/blackfin/mach-common/entry.S
3 * Based on:
4 * Author: Linus Torvalds
5 *
6 * Created: ?
7 * Description: contains the system-call and fault low-level handling routines.
8 * This also contains the timer-interrupt handler, as well as all
9 * interrupts and faults that can result in a task-switch.
10 *
11 * Modified:
12 * Copyright 2004-2006 Analog Devices Inc.
13 *
14 * Bugs: Enter bugs at http://blackfin.uclinux.org/
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, see the file COPYING, or write
28 * to the Free Software Foundation, Inc.,
29 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 */
31
32/*
33 * 25-Dec-2004 - LG Soft India
34 * 1. Fix in return_from_int, to make sure any pending
35 * system call in ILAT for this process to get
36 * executed, otherwise in case context switch happens,
37 * system call of first process (i.e in ILAT) will be
38 * carried forward to the switched process.
39 * 2. Removed Constant references for the following
40 * a. IPEND
41 * b. EXCAUSE mask
42 * c. PAGE Mask
43 */
44
45/*
46 * NOTE: This code handles signal-recognition, which happens every time
47 * after a timer-interrupt and after each system call.
48 */
49
50
51#include <linux/linkage.h>
52#include <asm/blackfin.h>
53#include <asm/unistd.h>
54#include <asm/errno.h>
55#include <asm/thread_info.h> /* TIF_NEED_RESCHED */
56#include <asm/asm-offsets.h>
57
58#include <asm/mach-common/context.S>
59
60#ifdef CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE
61 /*
62 * TODO: this should be proper save/restore, but for now
63 * we'll just cheat and use 0x1/0x13
64 */
65# define DEBUG_START_HWTRACE \
66 P5.l = LO(TBUFCTL); \
67 P5.h = HI(TBUFCTL); \
68 R7 = 0x13; \
69 [P5] = R7;
70# define DEBUG_STOP_HWTRACE \
71 P5.l = LO(TBUFCTL); \
72 P5.h = HI(TBUFCTL); \
73 R7 = 0x01; \
74 [P5] = R7;
75#else
76# define DEBUG_START_HWTRACE
77# define DEBUG_STOP_HWTRACE
78#endif
79
80#ifdef CONFIG_EXCPT_IRQ_SYSC_L1
81.section .l1.text
82#else
83.text
84#endif
85
86/* Slightly simplified and streamlined entry point for CPLB misses.
87 * This one does not lower the level to IRQ5, and thus can be used to
88 * patch up CPLB misses on the kernel stack.
89 */
90ENTRY(_ex_dcplb)
91#if defined(ANOMALY_05000261)
92 /*
93 * Work around an anomaly: if we see a new DCPLB fault, return
94 * without doing anything. Then, if we get the same fault again,
95 * handle it.
96 */
97 p5.l = _last_cplb_fault_retx;
98 p5.h = _last_cplb_fault_retx;
99 r7 = [p5];
100 r6 = retx;
101 [p5] = r6;
102 cc = r6 == r7;
103 if !cc jump _return_from_exception;
104 /* fall through */
105#endif
106
107ENTRY(_ex_icplb)
108 (R7:6,P5:4) = [sp++];
109 ASTAT = [sp++];
110 SAVE_ALL_SYS
111 call __cplb_hdr;
112 DEBUG_START_HWTRACE
113 RESTORE_ALL_SYS
114 SP = RETN;
115 rtx;
116
117ENTRY(_ex_spinlock)
118 /* Transform this into a syscall - twiddle the syscall vector. */
119 p5.l = lo(EVT15);
120 p5.h = hi(EVT15);
121 r7.l = _spinlock_bh;
122 r7.h = _spinlock_bh;
123 [p5] = r7;
124 csync;
125 /* Fall through. */
126
127ENTRY(_ex_syscall)
128 DEBUG_START_HWTRACE
129 (R7:6,P5:4) = [sp++];
130 ASTAT = [sp++];
131 raise 15; /* invoked by TRAP #0, for sys call */
132 sp = retn;
133 rtx
134
135ENTRY(_spinlock_bh)
136 SAVE_ALL_SYS
137 /* To end up here, vector 15 was changed - so we have to change it
138 * back.
139 */
140 p0.l = lo(EVT15);
141 p0.h = hi(EVT15);
142 p1.l = _evt_system_call;
143 p1.h = _evt_system_call;
144 [p0] = p1;
145 csync;
146 r0 = [sp + PT_R0];
147 sp += -12;
148 call _sys_bfin_spinlock;
149 sp += 12;
150 [SP + PT_R0] = R0;
151 RESTORE_ALL_SYS
152 rti;
153
154ENTRY(_ex_soft_bp)
155 r7 = retx;
156 r7 += -2;
157 retx = r7;
158 jump.s _ex_trap_c;
159
160ENTRY(_ex_single_step)
161 r7 = retx;
162 r6 = reti;
163 cc = r7 == r6;
164 if cc jump _return_from_exception
165 r7 = syscfg;
166 bitclr (r7, 0);
167 syscfg = R7;
168
169 p5.l = lo(IPEND);
170 p5.h = hi(IPEND);
171 r6 = [p5];
172 cc = bittst(r6, 5);
173 if !cc jump _ex_trap_c;
174 p4.l = lo(EVT5);
175 p4.h = hi(EVT5);
176 r6.h = _exception_to_level5;
177 r6.l = _exception_to_level5;
178 r7 = [p4];
179 cc = r6 == r7;
180 if !cc jump _ex_trap_c;
181
182_return_from_exception:
183 DEBUG_START_HWTRACE
184 (R7:6,P5:4) = [sp++];
185 ASTAT = [sp++];
186 sp = retn;
187 rtx;
188
189ENTRY(_handle_bad_cplb)
190 /* To get here, we just tried and failed to change a CPLB
191 * so, handle things in trap_c (C code), by lowering to
192 * IRQ5, just like we normally do. Since this is not a
193 * "normal" return path, we have a do alot of stuff to
194 * the stack to get ready so, we can fall through - we
195 * need to make a CPLB exception look like a normal exception
196 */
197
198 DEBUG_START_HWTRACE
199 RESTORE_ALL_SYS
200 [--sp] = ASTAT;
201 [--sp] = (R7:6, P5:4);
202
203ENTRY(_ex_trap_c)
204 /* Call C code (trap_c) to handle the exception, which most
205 * likely involves sending a signal to the current process.
206 * To avoid double faults, lower our priority to IRQ5 first.
207 */
208 P5.h = _exception_to_level5;
209 P5.l = _exception_to_level5;
210 p4.l = lo(EVT5);
211 p4.h = hi(EVT5);
212 [p4] = p5;
213 csync;
214
215 /* Disable all interrupts, but make sure level 5 is enabled so
216 * we can switch to that level. Save the old mask. */
217 cli r6;
218 p4.l = _excpt_saved_imask;
219 p4.h = _excpt_saved_imask;
220 [p4] = r6;
221 r6 = 0x3f;
222 sti r6;
223
224 /* Save the excause into a circular buffer, in case the instruction
225 * which caused this excecptions causes others.
226 */
227 P5.l = _in_ptr_excause;
228 P5.h = _in_ptr_excause;
229 R7 = [P5];
230 R7 += 4;
231 R6 = 0xF;
232 R7 = R7 & R6;
233 [P5] = R7;
234 R6.l = _excause_circ_buf;
235 R6.h = _excause_circ_buf;
236 R7 = R7 + R6;
237 p5 = R7;
238 R6 = SEQSTAT;
239 [P5] = R6;
240
241 DEBUG_START_HWTRACE
242 (R7:6,P5:4) = [sp++];
243 ASTAT = [sp++];
244 SP = RETN;
245 raise 5;
246 rtx;
247
248ENTRY(_exception_to_level5)
249 SAVE_ALL_SYS
250
251 /* Restore interrupt mask. We haven't pushed RETI, so this
252 * doesn't enable interrupts until we return from this handler. */
253 p4.l = _excpt_saved_imask;
254 p4.h = _excpt_saved_imask;
255 r6 = [p4];
256 sti r6;
257
258 /* Restore the hardware error vector. */
259 P5.h = _evt_ivhw;
260 P5.l = _evt_ivhw;
261 p4.l = lo(EVT5);
262 p4.h = hi(EVT5);
263 [p4] = p5;
264 csync;
265
266 p2.l = lo(IPEND);
267 p2.h = hi(IPEND);
268 csync;
269 r0 = [p2]; /* Read current IPEND */
270 [sp + PT_IPEND] = r0; /* Store IPEND */
271
272 /* Pop the excause from the circular buffer and push it on the stack
273 * (in the right place - if you change the location of SEQSTAT, you
274 * must change this offset.
275 */
276.L_excep_to_5_again:
277 P5.l = _out_ptr_excause;
278 P5.h = _out_ptr_excause;
279 R7 = [P5];
280 R7 += 4;
281 R6 = 0xF;
282 R7 = R7 & R6;
283 [P5] = R7;
284 R6.l = _excause_circ_buf;
285 R6.h = _excause_circ_buf;
286 R7 = R7 + R6;
287 P5 = R7;
288 R1 = [P5];
289 [SP + 8] = r1;
290
291 r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
292 SP += -12;
293 call _trap_c;
294 SP += 12;
295
296 /* See if anything else is in the exception buffer
297 * if there is, process it
298 */
299 P5.l = _out_ptr_excause;
300 P5.h = _out_ptr_excause;
301 P4.l = _in_ptr_excause;
302 P4.h = _in_ptr_excause;
303 R6 = [P5];
304 R7 = [P4];
305 CC = R6 == R7;
306 if ! CC JUMP .L_excep_to_5_again
307
308 call _ret_from_exception;
309 RESTORE_ALL_SYS
310 rti;
311
312ENTRY(_trap) /* Exception: 4th entry into system event table(supervisor mode)*/
313 /* Since the kernel stack can be anywhere, it's not guaranteed to be
314 * covered by a CPLB. Switch to an exception stack; use RETN as a
315 * scratch register (for want of a better option).
316 */
317 retn = sp;
318 sp.l = _exception_stack_top;
319 sp.h = _exception_stack_top;
320 /* Try to deal with syscalls quickly. */
321 [--sp] = ASTAT;
322 [--sp] = (R7:6, P5:4);
323 DEBUG_STOP_HWTRACE
324 r7 = SEQSTAT; /* reason code is in bit 5:0 */
325 r6.l = lo(SEQSTAT_EXCAUSE);
326 r6.h = hi(SEQSTAT_EXCAUSE);
327 r7 = r7 & r6;
328 p5.h = _extable;
329 p5.l = _extable;
330 p4 = r7;
331 p5 = p5 + (p4 << 2);
332 p4 = [p5];
333 jump (p4);
334
335.Lbadsys:
336 r7 = -ENOSYS; /* signextending enough */
337 [sp + PT_R0] = r7; /* return value from system call */
338 jump .Lsyscall_really_exit;
339
340ENTRY(_kernel_execve)
341 link SIZEOF_PTREGS;
342 p0 = sp;
343 r3 = SIZEOF_PTREGS / 4;
344 r4 = 0(x);
3450:
346 [p0++] = r4;
347 r3 += -1;
348 cc = r3 == 0;
349 if !cc jump 0b (bp);
350
351 p0 = sp;
352 sp += -16;
353 [sp + 12] = p0;
354 call _do_execve;
355 SP += 16;
356 cc = r0 == 0;
357 if ! cc jump 1f;
358 /* Success. Copy our temporary pt_regs to the top of the kernel
359 * stack and do a normal exception return.
360 */
361 r1 = sp;
362 r0 = (-KERNEL_STACK_SIZE) (x);
363 r1 = r1 & r0;
364 p2 = r1;
365 p3 = [p2];
366 r0 = KERNEL_STACK_SIZE - 4 (z);
367 p1 = r0;
368 p1 = p1 + p2;
369
370 p0 = fp;
371 r4 = [p0--];
372 r3 = SIZEOF_PTREGS / 4;
3730:
374 r4 = [p0--];
375 [p1--] = r4;
376 r3 += -1;
377 cc = r3 == 0;
378 if ! cc jump 0b (bp);
379
380 r0 = (KERNEL_STACK_SIZE - SIZEOF_PTREGS) (z);
381 p1 = r0;
382 p1 = p1 + p2;
383 sp = p1;
384 r0 = syscfg;
385 [SP + PT_SYSCFG] = r0;
386 [p3 + (TASK_THREAD + THREAD_KSP)] = sp;
387
388 RESTORE_CONTEXT;
389 rti;
3901:
391 unlink;
392 rts;
393
394ENTRY(_system_call)
395 /* Store IPEND */
396 p2.l = lo(IPEND);
397 p2.h = hi(IPEND);
398 csync;
399 r0 = [p2];
400 [sp + PT_IPEND] = r0;
401
402 /* Store RETS for now */
403 r0 = rets;
404 [sp + PT_RESERVED] = r0;
405 /* Set the stack for the current process */
406 r7 = sp;
407 r6.l = lo(ALIGN_PAGE_MASK);
408 r6.h = hi(ALIGN_PAGE_MASK);
409 r7 = r7 & r6; /* thread_info */
410 p2 = r7;
411 p2 = [p2];
412
413 [p2+(TASK_THREAD+THREAD_KSP)] = sp;
414
415 /* Check the System Call */
416 r7 = __NR_syscall;
417 /* System call number is passed in P0 */
418 r6 = p0;
419 cc = r6 < r7;
420 if ! cc jump .Lbadsys;
421
422 /* are we tracing syscalls?*/
423 r7 = sp;
424 r6.l = lo(ALIGN_PAGE_MASK);
425 r6.h = hi(ALIGN_PAGE_MASK);
426 r7 = r7 & r6;
427 p2 = r7;
428 r7 = [p2+TI_FLAGS];
429 CC = BITTST(r7,TIF_SYSCALL_TRACE);
430 if CC JUMP _sys_trace;
431
432 /* Execute the appropriate system call */
433
434 p4 = p0;
435 p5.l = _sys_call_table;
436 p5.h = _sys_call_table;
437 p5 = p5 + (p4 << 2);
438 r0 = [sp + PT_R0];
439 r1 = [sp + PT_R1];
440 r2 = [sp + PT_R2];
441 p5 = [p5];
442
443 [--sp] = r5;
444 [--sp] = r4;
445 [--sp] = r3;
446 SP += -12;
447 call (p5);
448 SP += 24;
449 [sp + PT_R0] = r0;
450
451.Lresume_userspace:
452 r7 = sp;
453 r4.l = lo(ALIGN_PAGE_MASK);
454 r4.h = hi(ALIGN_PAGE_MASK);
455 r7 = r7 & r4; /* thread_info->flags */
456 p5 = r7;
457.Lresume_userspace_1:
458 /* Disable interrupts. */
459 [--sp] = reti;
460 reti = [sp++];
461
462 r7 = [p5 + TI_FLAGS];
463 r4.l = lo(_TIF_WORK_MASK);
464 r4.h = hi(_TIF_WORK_MASK);
465 r7 = r7 & r4;
466
467.Lsyscall_resched:
468 cc = BITTST(r7, TIF_NEED_RESCHED);
469 if !cc jump .Lsyscall_sigpending;
470
471 /* Reenable interrupts. */
472 [--sp] = reti;
473 r0 = [sp++];
474
475 SP += -12;
476 call _schedule;
477 SP += 12;
478
479 jump .Lresume_userspace_1;
480
481.Lsyscall_sigpending:
482 cc = BITTST(r7, TIF_RESTORE_SIGMASK);
483 if cc jump .Lsyscall_do_signals;
484 cc = BITTST(r7, TIF_SIGPENDING);
485 if !cc jump .Lsyscall_really_exit;
486.Lsyscall_do_signals:
487 /* Reenable interrupts. */
488 [--sp] = reti;
489 r0 = [sp++];
490
491 r0 = sp;
492 SP += -12;
493 call _do_signal;
494 SP += 12;
495
496.Lsyscall_really_exit:
497 r5 = [sp + PT_RESERVED];
498 rets = r5;
499 rts;
500
501_sys_trace:
502 call _syscall_trace;
503
504 /* Execute the appropriate system call */
505
506 p4 = [SP + PT_P0];
507 p5.l = _sys_call_table;
508 p5.h = _sys_call_table;
509 p5 = p5 + (p4 << 2);
510 r0 = [sp + PT_R0];
511 r1 = [sp + PT_R1];
512 r2 = [sp + PT_R2];
513 r3 = [sp + PT_R3];
514 r4 = [sp + PT_R4];
515 r5 = [sp + PT_R5];
516 p5 = [p5];
517
518 [--sp] = r5;
519 [--sp] = r4;
520 [--sp] = r3;
521 SP += -12;
522 call (p5);
523 SP += 24;
524 [sp + PT_R0] = r0;
525
526 call _syscall_trace;
527 jump .Lresume_userspace;
528
529ENTRY(_resume)
530 /*
531 * Beware - when entering resume, prev (the current task) is
532 * in r0, next (the new task) is in r1.
533 */
534 p0 = r0;
535 p1 = r1;
536 [--sp] = rets;
537 [--sp] = fp;
538 [--sp] = (r7:4, p5:3);
539
540 /* save usp */
541 p2 = usp;
542 [p0+(TASK_THREAD+THREAD_USP)] = p2;
543
544 /* save current kernel stack pointer */
545 [p0+(TASK_THREAD+THREAD_KSP)] = sp;
546
547 /* save program counter */
548 r1.l = _new_old_task;
549 r1.h = _new_old_task;
550 [p0+(TASK_THREAD+THREAD_PC)] = r1;
551
552 /* restore the kernel stack pointer */
553 sp = [p1+(TASK_THREAD+THREAD_KSP)];
554
555 /* restore user stack pointer */
556 p0 = [p1+(TASK_THREAD+THREAD_USP)];
557 usp = p0;
558
559 /* restore pc */
560 p0 = [p1+(TASK_THREAD+THREAD_PC)];
561 jump (p0);
562
563 /*
564 * Following code actually lands up in a new (old) task.
565 */
566
567_new_old_task:
568 (r7:4, p5:3) = [sp++];
569 fp = [sp++];
570 rets = [sp++];
571
572 /*
573 * When we come out of resume, r0 carries "old" task, becuase we are
574 * in "new" task.
575 */
576 rts;
577
578ENTRY(_ret_from_exception)
579 p2.l = lo(IPEND);
580 p2.h = hi(IPEND);
581
582 csync;
583 r0 = [p2];
584 [sp + PT_IPEND] = r0;
585
5861:
587 r1 = 0x37(Z);
588 r2 = ~r1;
589 r2.h = 0;
590 r0 = r2 & r0;
591 cc = r0 == 0;
592 if !cc jump 4f; /* if not return to user mode, get out */
593
594 /* Make sure any pending system call or deferred exception
595 * return in ILAT for this process to get executed, otherwise
596 * in case context switch happens, system call of
597 * first process (i.e in ILAT) will be carried
598 * forward to the switched process
599 */
600
601 p2.l = lo(ILAT);
602 p2.h = hi(ILAT);
603 r0 = [p2];
604 r1 = (EVT_IVG14 | EVT_IVG15) (z);
605 r0 = r0 & r1;
606 cc = r0 == 0;
607 if !cc jump 5f;
608
609 /* Set the stack for the current process */
610 r7 = sp;
611 r4.l = lo(ALIGN_PAGE_MASK);
612 r4.h = hi(ALIGN_PAGE_MASK);
613 r7 = r7 & r4; /* thread_info->flags */
614 p5 = r7;
615 r7 = [p5 + TI_FLAGS];
616 r4.l = lo(_TIF_WORK_MASK);
617 r4.h = hi(_TIF_WORK_MASK);
618 r7 = r7 & r4;
619 cc = r7 == 0;
620 if cc jump 4f;
621
622 p0.l = lo(EVT15);
623 p0.h = hi(EVT15);
624 p1.l = _schedule_and_signal;
625 p1.h = _schedule_and_signal;
626 [p0] = p1;
627 csync;
628 raise 15; /* raise evt14 to do signal or reschedule */
6294:
630 r0 = syscfg;
631 bitclr(r0, 0);
632 syscfg = r0;
6335:
634 rts;
635
636ENTRY(_return_from_int)
637 /* If someone else already raised IRQ 15, do nothing. */
638 csync;
639 p2.l = lo(ILAT);
640 p2.h = hi(ILAT);
641 r0 = [p2];
642 cc = bittst (r0, EVT_IVG15_P);
643 if cc jump 2f;
644
645 /* if not return to user mode, get out */
646 p2.l = lo(IPEND);
647 p2.h = hi(IPEND);
648 r0 = [p2];
649 r1 = 0x17(Z);
650 r2 = ~r1;
651 r2.h = 0;
652 r0 = r2 & r0;
653 r1 = 1;
654 r1 = r0 - r1;
655 r2 = r0 & r1;
656 cc = r2 == 0;
657 if !cc jump 2f;
658
659 /* Lower the interrupt level to 15. */
660 p0.l = lo(EVT15);
661 p0.h = hi(EVT15);
662 p1.l = _schedule_and_signal_from_int;
663 p1.h = _schedule_and_signal_from_int;
664 [p0] = p1;
665 csync;
666#if defined(ANOMALY_05000281)
667 r0.l = lo(CONFIG_BOOT_LOAD);
668 r0.h = hi(CONFIG_BOOT_LOAD);
669 reti = r0;
670#endif
671 r0 = 0x801f (z);
672 STI r0;
673 raise 15; /* raise evt15 to do signal or reschedule */
674 rti;
6752:
676 rts;
677
678ENTRY(_lower_to_irq14)
679#if defined(ANOMALY_05000281)
680 r0.l = lo(CONFIG_BOOT_LOAD);
681 r0.h = hi(CONFIG_BOOT_LOAD);
682 reti = r0;
683#endif
684 r0 = 0x401f;
685 sti r0;
686 raise 14;
687 rti;
688ENTRY(_evt14_softirq)
689#ifdef CONFIG_DEBUG_HWERR
690 r0 = 0x3f;
691 sti r0;
692#else
693 cli r0;
694#endif
695 [--sp] = RETI;
696 SP += 4;
697 rts;
698
699_schedule_and_signal_from_int:
700 /* To end up here, vector 15 was changed - so we have to change it
701 * back.
702 */
703 p0.l = lo(EVT15);
704 p0.h = hi(EVT15);
705 p1.l = _evt_system_call;
706 p1.h = _evt_system_call;
707 [p0] = p1;
708 csync;
709 p1 = rets;
710 [sp + PT_RESERVED] = p1;
711
712 p0.l = _irq_flags;
713 p0.h = _irq_flags;
714 r0 = [p0];
715 sti r0;
716
717 jump.s .Lresume_userspace;
718
719_schedule_and_signal:
720 SAVE_CONTEXT_SYSCALL
721 /* To end up here, vector 15 was changed - so we have to change it
722 * back.
723 */
724 p0.l = lo(EVT15);
725 p0.h = hi(EVT15);
726 p1.l = _evt_system_call;
727 p1.h = _evt_system_call;
728 [p0] = p1;
729 csync;
730 p0.l = 1f;
731 p0.h = 1f;
732 [sp + PT_RESERVED] = P0;
733 call .Lresume_userspace;
7341:
735 RESTORE_CONTEXT
736 rti;
737
738/* Make sure when we start, that the circular buffer is initialized properly
739 * R0 and P0 are call clobbered, so we can use them here.
740 */
741ENTRY(_init_exception_buff)
742 r0 = 0;
743 p0.h = _in_ptr_excause;
744 p0.l = _in_ptr_excause;
745 [p0] = r0;
746 p0.h = _out_ptr_excause;
747 p0.l = _out_ptr_excause;
748 [p0] = r0;
749 rts;
750
751/*
752 * Put these in the kernel data section - that should always be covered by
753 * a CPLB. This is needed to ensure we don't get double fault conditions
754 */
755
756#ifdef CONFIG_SYSCALL_TAB_L1
757.section .l1.data
758#else
759.data
760#endif
761ALIGN
762_extable:
763 /* entry for each EXCAUSE[5:0]
764 * This table bmust be in sync with the table in ./kernel/traps.c
765 * EXCPT instruction can provide 4 bits of EXCAUSE, allowing 16 to be user defined
766 */
767 .long _ex_syscall; /* 0x00 - User Defined - Linux Syscall */
768 .long _ex_soft_bp /* 0x01 - User Defined - Software breakpoint */
769 .long _ex_trap_c /* 0x02 - User Defined */
770 .long _ex_trap_c /* 0x03 - User Defined - Atomic test and set service */
771 .long _ex_spinlock /* 0x04 - User Defined */
772 .long _ex_trap_c /* 0x05 - User Defined */
773 .long _ex_trap_c /* 0x06 - User Defined */
774 .long _ex_trap_c /* 0x07 - User Defined */
775 .long _ex_trap_c /* 0x08 - User Defined */
776 .long _ex_trap_c /* 0x09 - User Defined */
777 .long _ex_trap_c /* 0x0A - User Defined */
778 .long _ex_trap_c /* 0x0B - User Defined */
779 .long _ex_trap_c /* 0x0C - User Defined */
780 .long _ex_trap_c /* 0x0D - User Defined */
781 .long _ex_trap_c /* 0x0E - User Defined */
782 .long _ex_trap_c /* 0x0F - User Defined */
783 .long _ex_single_step /* 0x10 - HW Single step */
784 .long _ex_trap_c /* 0x11 - Trace Buffer Full */
785 .long _ex_trap_c /* 0x12 - Reserved */
786 .long _ex_trap_c /* 0x13 - Reserved */
787 .long _ex_trap_c /* 0x14 - Reserved */
788 .long _ex_trap_c /* 0x15 - Reserved */
789 .long _ex_trap_c /* 0x16 - Reserved */
790 .long _ex_trap_c /* 0x17 - Reserved */
791 .long _ex_trap_c /* 0x18 - Reserved */
792 .long _ex_trap_c /* 0x19 - Reserved */
793 .long _ex_trap_c /* 0x1A - Reserved */
794 .long _ex_trap_c /* 0x1B - Reserved */
795 .long _ex_trap_c /* 0x1C - Reserved */
796 .long _ex_trap_c /* 0x1D - Reserved */
797 .long _ex_trap_c /* 0x1E - Reserved */
798 .long _ex_trap_c /* 0x1F - Reserved */
799 .long _ex_trap_c /* 0x20 - Reserved */
800 .long _ex_trap_c /* 0x21 - Undefined Instruction */
801 .long _ex_trap_c /* 0x22 - Illegal Instruction Combination */
802 .long _ex_dcplb /* 0x23 - Data CPLB Protection Violation */
803 .long _ex_trap_c /* 0x24 - Data access misaligned */
804 .long _ex_trap_c /* 0x25 - Unrecoverable Event */
805 .long _ex_dcplb /* 0x26 - Data CPLB Miss */
806 .long _ex_trap_c /* 0x27 - Data CPLB Multiple Hits - Linux Trap Zero */
807 .long _ex_trap_c /* 0x28 - Emulation Watchpoint */
808 .long _ex_trap_c /* 0x29 - Instruction fetch access error (535 only) */
809 .long _ex_trap_c /* 0x2A - Instruction fetch misaligned */
810 .long _ex_icplb /* 0x2B - Instruction CPLB protection Violation */
811 .long _ex_icplb /* 0x2C - Instruction CPLB miss */
812 .long _ex_trap_c /* 0x2D - Instruction CPLB Multiple Hits */
813 .long _ex_trap_c /* 0x2E - Illegal use of Supervisor Resource */
814 .long _ex_trap_c /* 0x2E - Illegal use of Supervisor Resource */
815 .long _ex_trap_c /* 0x2F - Reserved */
816 .long _ex_trap_c /* 0x30 - Reserved */
817 .long _ex_trap_c /* 0x31 - Reserved */
818 .long _ex_trap_c /* 0x32 - Reserved */
819 .long _ex_trap_c /* 0x33 - Reserved */
820 .long _ex_trap_c /* 0x34 - Reserved */
821 .long _ex_trap_c /* 0x35 - Reserved */
822 .long _ex_trap_c /* 0x36 - Reserved */
823 .long _ex_trap_c /* 0x37 - Reserved */
824 .long _ex_trap_c /* 0x38 - Reserved */
825 .long _ex_trap_c /* 0x39 - Reserved */
826 .long _ex_trap_c /* 0x3A - Reserved */
827 .long _ex_trap_c /* 0x3B - Reserved */
828 .long _ex_trap_c /* 0x3C - Reserved */
829 .long _ex_trap_c /* 0x3D - Reserved */
830 .long _ex_trap_c /* 0x3E - Reserved */
831 .long _ex_trap_c /* 0x3F - Reserved */
832
833ALIGN
834ENTRY(_sys_call_table)
835 .long _sys_ni_syscall /* 0 - old "setup()" system call*/
836 .long _sys_exit
837 .long _sys_fork
838 .long _sys_read
839 .long _sys_write
840 .long _sys_open /* 5 */
841 .long _sys_close
842 .long _sys_ni_syscall /* old waitpid */
843 .long _sys_creat
844 .long _sys_link
845 .long _sys_unlink /* 10 */
846 .long _sys_execve
847 .long _sys_chdir
848 .long _sys_time
849 .long _sys_mknod
850 .long _sys_chmod /* 15 */
851 .long _sys_chown /* chown16 */
852 .long _sys_ni_syscall /* old break syscall holder */
853 .long _sys_ni_syscall /* old stat */
854 .long _sys_lseek
855 .long _sys_getpid /* 20 */
856 .long _sys_mount
857 .long _sys_ni_syscall /* old umount */
858 .long _sys_setuid
859 .long _sys_getuid
860 .long _sys_stime /* 25 */
861 .long _sys_ptrace
862 .long _sys_alarm
863 .long _sys_ni_syscall /* old fstat */
864 .long _sys_pause
865 .long _sys_ni_syscall /* old utime */ /* 30 */
866 .long _sys_ni_syscall /* old stty syscall holder */
867 .long _sys_ni_syscall /* old gtty syscall holder */
868 .long _sys_access
869 .long _sys_nice
870 .long _sys_ni_syscall /* 35 */ /* old ftime syscall holder */
871 .long _sys_sync
872 .long _sys_kill
873 .long _sys_rename
874 .long _sys_mkdir
875 .long _sys_rmdir /* 40 */
876 .long _sys_dup
877 .long _sys_pipe
878 .long _sys_times
879 .long _sys_ni_syscall /* old prof syscall holder */
880 .long _sys_brk /* 45 */
881 .long _sys_setgid
882 .long _sys_getgid
883 .long _sys_ni_syscall /* old sys_signal */
884 .long _sys_geteuid /* geteuid16 */
885 .long _sys_getegid /* getegid16 */ /* 50 */
886 .long _sys_acct
887 .long _sys_umount /* recycled never used phys() */
888 .long _sys_ni_syscall /* old lock syscall holder */
889 .long _sys_ioctl
890 .long _sys_fcntl /* 55 */
891 .long _sys_ni_syscall /* old mpx syscall holder */
892 .long _sys_setpgid
893 .long _sys_ni_syscall /* old ulimit syscall holder */
894 .long _sys_ni_syscall /* old old uname */
895 .long _sys_umask /* 60 */
896 .long _sys_chroot
897 .long _sys_ustat
898 .long _sys_dup2
899 .long _sys_getppid
900 .long _sys_getpgrp /* 65 */
901 .long _sys_setsid
902 .long _sys_ni_syscall /* old sys_sigaction */
903 .long _sys_sgetmask
904 .long _sys_ssetmask
905 .long _sys_setreuid /* setreuid16 */ /* 70 */
906 .long _sys_setregid /* setregid16 */
907 .long _sys_ni_syscall /* old sys_sigsuspend */
908 .long _sys_ni_syscall /* old sys_sigpending */
909 .long _sys_sethostname
910 .long _sys_setrlimit /* 75 */
911 .long _sys_ni_syscall /* old getrlimit */
912 .long _sys_getrusage
913 .long _sys_gettimeofday
914 .long _sys_settimeofday
915 .long _sys_getgroups /* getgroups16 */ /* 80 */
916 .long _sys_setgroups /* setgroups16 */
917 .long _sys_ni_syscall /* old_select */
918 .long _sys_symlink
919 .long _sys_ni_syscall /* old lstat */
920 .long _sys_readlink /* 85 */
921 .long _sys_uselib
922 .long _sys_ni_syscall /* sys_swapon */
923 .long _sys_reboot
924 .long _sys_ni_syscall /* old_readdir */
925 .long _sys_ni_syscall /* sys_mmap */ /* 90 */
926 .long _sys_munmap
927 .long _sys_truncate
928 .long _sys_ftruncate
929 .long _sys_fchmod
930 .long _sys_fchown /* fchown16 */ /* 95 */
931 .long _sys_getpriority
932 .long _sys_setpriority
933 .long _sys_ni_syscall /* old profil syscall holder */
934 .long _sys_statfs
935 .long _sys_fstatfs /* 100 */
936 .long _sys_ni_syscall
937 .long _sys_ni_syscall /* old sys_socketcall */
938 .long _sys_syslog
939 .long _sys_setitimer
940 .long _sys_getitimer /* 105 */
941 .long _sys_newstat
942 .long _sys_newlstat
943 .long _sys_newfstat
944 .long _sys_ni_syscall /* old uname */
945 .long _sys_ni_syscall /* iopl for i386 */ /* 110 */
946 .long _sys_vhangup
947 .long _sys_ni_syscall /* obsolete idle() syscall */
948 .long _sys_ni_syscall /* vm86old for i386 */
949 .long _sys_wait4
950 .long _sys_ni_syscall /* 115 */ /* sys_swapoff */
951 .long _sys_sysinfo
952 .long _sys_ni_syscall /* old sys_ipc */
953 .long _sys_fsync
954 .long _sys_ni_syscall /* old sys_sigreturn */
955 .long _sys_clone /* 120 */
956 .long _sys_setdomainname
957 .long _sys_newuname
958 .long _sys_ni_syscall /* old sys_modify_ldt */
959 .long _sys_adjtimex
960 .long _sys_ni_syscall /* 125 */ /* sys_mprotect */
961 .long _sys_ni_syscall /* old sys_sigprocmask */
962 .long _sys_ni_syscall /* old "creat_module" */
963 .long _sys_init_module
964 .long _sys_delete_module
965 .long _sys_ni_syscall /* 130: old "get_kernel_syms" */
966 .long _sys_quotactl
967 .long _sys_getpgid
968 .long _sys_fchdir
969 .long _sys_bdflush
970 .long _sys_ni_syscall /* 135 */ /* sys_sysfs */
971 .long _sys_personality
972 .long _sys_ni_syscall /* for afs_syscall */
973 .long _sys_setfsuid /* setfsuid16 */
974 .long _sys_setfsgid /* setfsgid16 */
975 .long _sys_llseek /* 140 */
976 .long _sys_getdents
977 .long _sys_ni_syscall /* sys_select */
978 .long _sys_flock
979 .long _sys_ni_syscall /* sys_msync */
980 .long _sys_readv /* 145 */
981 .long _sys_writev
982 .long _sys_getsid
983 .long _sys_fdatasync
984 .long _sys_sysctl
985 .long _sys_ni_syscall /* 150 */ /* sys_mlock */
986 .long _sys_ni_syscall /* sys_munlock */
987 .long _sys_ni_syscall /* sys_mlockall */
988 .long _sys_ni_syscall /* sys_munlockall */
989 .long _sys_sched_setparam
990 .long _sys_sched_getparam /* 155 */
991 .long _sys_sched_setscheduler
992 .long _sys_sched_getscheduler
993 .long _sys_sched_yield
994 .long _sys_sched_get_priority_max
995 .long _sys_sched_get_priority_min /* 160 */
996 .long _sys_sched_rr_get_interval
997 .long _sys_nanosleep
998 .long _sys_ni_syscall /* sys_mremap */
999 .long _sys_setresuid /* setresuid16 */
1000 .long _sys_getresuid /* getresuid16 */ /* 165 */
1001 .long _sys_ni_syscall /* for vm86 */
1002 .long _sys_ni_syscall /* old "query_module" */
1003 .long _sys_ni_syscall /* sys_poll */
1004 .long _sys_ni_syscall /* sys_nfsservctl */
1005 .long _sys_setresgid /* setresgid16 */ /* 170 */
1006 .long _sys_getresgid /* getresgid16 */
1007 .long _sys_prctl
1008 .long _sys_rt_sigreturn
1009 .long _sys_rt_sigaction
1010 .long _sys_rt_sigprocmask /* 175 */
1011 .long _sys_rt_sigpending
1012 .long _sys_rt_sigtimedwait
1013 .long _sys_rt_sigqueueinfo
1014 .long _sys_rt_sigsuspend
1015 .long _sys_pread64 /* 180 */
1016 .long _sys_pwrite64
1017 .long _sys_lchown /* lchown16 */
1018 .long _sys_getcwd
1019 .long _sys_capget
1020 .long _sys_capset /* 185 */
1021 .long _sys_sigaltstack
1022 .long _sys_sendfile
1023 .long _sys_ni_syscall /* streams1 */
1024 .long _sys_ni_syscall /* streams2 */
1025 .long _sys_vfork /* 190 */
1026 .long _sys_getrlimit
1027 .long _sys_mmap2
1028 .long _sys_truncate64
1029 .long _sys_ftruncate64
1030 .long _sys_stat64 /* 195 */
1031 .long _sys_lstat64
1032 .long _sys_fstat64
1033 .long _sys_chown
1034 .long _sys_getuid
1035 .long _sys_getgid /* 200 */
1036 .long _sys_geteuid
1037 .long _sys_getegid
1038 .long _sys_setreuid
1039 .long _sys_setregid
1040 .long _sys_getgroups /* 205 */
1041 .long _sys_setgroups
1042 .long _sys_fchown
1043 .long _sys_setresuid
1044 .long _sys_getresuid
1045 .long _sys_setresgid /* 210 */
1046 .long _sys_getresgid
1047 .long _sys_lchown
1048 .long _sys_setuid
1049 .long _sys_setgid
1050 .long _sys_setfsuid /* 215 */
1051 .long _sys_setfsgid
1052 .long _sys_pivot_root
1053 .long _sys_ni_syscall /* sys_mincore */
1054 .long _sys_ni_syscall /* sys_madvise */
1055 .long _sys_getdents64 /* 220 */
1056 .long _sys_fcntl64
1057 .long _sys_ni_syscall /* reserved for TUX */
1058 .long _sys_ni_syscall
1059 .long _sys_gettid
1060 .long _sys_ni_syscall /* 225 */ /* sys_readahead */
1061 .long _sys_setxattr
1062 .long _sys_lsetxattr
1063 .long _sys_fsetxattr
1064 .long _sys_getxattr
1065 .long _sys_lgetxattr /* 230 */
1066 .long _sys_fgetxattr
1067 .long _sys_listxattr
1068 .long _sys_llistxattr
1069 .long _sys_flistxattr
1070 .long _sys_removexattr /* 235 */
1071 .long _sys_lremovexattr
1072 .long _sys_fremovexattr
1073 .long _sys_tkill
1074 .long _sys_sendfile64
1075 .long _sys_futex /* 240 */
1076 .long _sys_sched_setaffinity
1077 .long _sys_sched_getaffinity
1078 .long _sys_ni_syscall /* sys_set_thread_area */
1079 .long _sys_ni_syscall /* sys_get_thread_area */
1080 .long _sys_io_setup /* 245 */
1081 .long _sys_io_destroy
1082 .long _sys_io_getevents
1083 .long _sys_io_submit
1084 .long _sys_io_cancel
1085 .long _sys_ni_syscall /* 250 */ /* sys_alloc_hugepages */
1086 .long _sys_ni_syscall /* sys_freec_hugepages */
1087 .long _sys_exit_group
1088 .long _sys_lookup_dcookie
1089 .long _sys_bfin_spinlock
1090 .long _sys_epoll_create /* 255 */
1091 .long _sys_epoll_ctl
1092 .long _sys_epoll_wait
1093 .long _sys_ni_syscall /* remap_file_pages */
1094 .long _sys_set_tid_address
1095 .long _sys_timer_create /* 260 */
1096 .long _sys_timer_settime
1097 .long _sys_timer_gettime
1098 .long _sys_timer_getoverrun
1099 .long _sys_timer_delete
1100 .long _sys_clock_settime /* 265 */
1101 .long _sys_clock_gettime
1102 .long _sys_clock_getres
1103 .long _sys_clock_nanosleep
1104 .long _sys_statfs64
1105 .long _sys_fstatfs64 /* 270 */
1106 .long _sys_tgkill
1107 .long _sys_utimes
1108 .long _sys_fadvise64_64
1109 .long _sys_ni_syscall /* vserver */
1110 .long _sys_ni_syscall /* 275, mbind */
1111 .long _sys_ni_syscall /* get_mempolicy */
1112 .long _sys_ni_syscall /* set_mempolicy */
1113 .long _sys_mq_open
1114 .long _sys_mq_unlink
1115 .long _sys_mq_timedsend /* 280 */
1116 .long _sys_mq_timedreceive
1117 .long _sys_mq_notify
1118 .long _sys_mq_getsetattr
1119 .long _sys_ni_syscall /* kexec_load */
1120 .long _sys_waitid /* 285 */
1121 .long _sys_add_key
1122 .long _sys_request_key
1123 .long _sys_keyctl
1124 .long _sys_ioprio_set
1125 .long _sys_ioprio_get /* 290 */
1126 .long _sys_inotify_init
1127 .long _sys_inotify_add_watch
1128 .long _sys_inotify_rm_watch
1129 .long _sys_ni_syscall /* migrate_pages */
1130 .long _sys_openat /* 295 */
1131 .long _sys_mkdirat
1132 .long _sys_mknodat
1133 .long _sys_fchownat
1134 .long _sys_futimesat
1135 .long _sys_fstatat64 /* 300 */
1136 .long _sys_unlinkat
1137 .long _sys_renameat
1138 .long _sys_linkat
1139 .long _sys_symlinkat
1140 .long _sys_readlinkat /* 305 */
1141 .long _sys_fchmodat
1142 .long _sys_faccessat
1143 .long _sys_pselect6
1144 .long _sys_ppoll
1145 .long _sys_unshare /* 310 */
1146 .long _sys_sram_alloc
1147 .long _sys_sram_free
1148 .long _sys_dma_memcpy
1149 .long _sys_accept
1150 .long _sys_bind /* 315 */
1151 .long _sys_connect
1152 .long _sys_getpeername
1153 .long _sys_getsockname
1154 .long _sys_getsockopt
1155 .long _sys_listen /* 320 */
1156 .long _sys_recv
1157 .long _sys_recvfrom
1158 .long _sys_recvmsg
1159 .long _sys_send
1160 .long _sys_sendmsg /* 325 */
1161 .long _sys_sendto
1162 .long _sys_setsockopt
1163 .long _sys_shutdown
1164 .long _sys_socket
1165 .long _sys_socketpair /* 330 */
1166 .long _sys_semctl
1167 .long _sys_semget
1168 .long _sys_semop
1169 .long _sys_msgctl
1170 .long _sys_msgget /* 335 */
1171 .long _sys_msgrcv
1172 .long _sys_msgsnd
1173 .long _sys_shmat
1174 .long _sys_shmctl
1175 .long _sys_shmdt /* 340 */
1176 .long _sys_shmget
1177 .rept NR_syscalls-(.-_sys_call_table)/4
1178 .long _sys_ni_syscall
1179 .endr
1180_excpt_saved_imask:
1181 .long 0;
1182
1183_exception_stack:
1184 .rept 1024
1185 .long 0;
1186 .endr
1187_exception_stack_top:
1188
1189#if defined(ANOMALY_05000261)
1190/* Used by the assembly entry point to work around an anomaly. */
1191_last_cplb_fault_retx:
1192 .long 0;
1193#endif
1194/*
1195 * Single instructions can have multiple faults, which need to be
1196 * handled by traps.c, in irq5. We store the exception cause to ensure
1197 * we don't miss a double fault condition
1198 */
1199ENTRY(_in_ptr_excause)
1200 .long 0;
1201ENTRY(_out_ptr_excause)
1202 .long 0;
1203ALIGN
1204ENTRY(_excause_circ_buf)
1205 .rept 4
1206 .long 0
1207 .endr
diff --git a/arch/blackfin/mach-common/interrupt.S b/arch/blackfin/mach-common/interrupt.S
new file mode 100644
index 000000000000..dd45664f0d02
--- /dev/null
+++ b/arch/blackfin/mach-common/interrupt.S
@@ -0,0 +1,253 @@
1/*
2 * File: arch/blackfin/mach-common/interrupt.S
3 * Based on:
4 * Author: D. Jeff Dionne <jeff@ryeham.ee.ryerson.ca>
5 * Kenneth Albanowski <kjahds@kjahds.com>
6 *
7 * Created: ?
8 * Description: Interrupt Entries
9 *
10 * Modified:
11 * Copyright 2004-2006 Analog Devices Inc.
12 *
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, see the file COPYING, or write
27 * to the Free Software Foundation, Inc.,
28 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 */
30
31#include <asm/blackfin.h>
32#include <asm/mach/irq.h>
33#include <linux/autoconf.h>
34#include <linux/linkage.h>
35#include <asm/entry.h>
36#include <asm/asm-offsets.h>
37
38#include <asm/mach-common/context.S>
39
40#ifdef CONFIG_I_ENTRY_L1
41.section .l1.text
42#else
43.text
44#endif
45
46.align 4 /* just in case */
47
48/*
49 * initial interrupt handlers
50 */
51
52#ifndef CONFIG_KGDB
53 /* interrupt routine for emulation - 0 */
54 /* Currently used only if GDB stub is not in - invalid */
55 /* gdb-stub set the evt itself */
56 /* save registers for post-mortem only */
57ENTRY(_evt_emulation)
58 SAVE_ALL_SYS
59#ifdef CONFIG_FRAME_POINTER
60 fp = 0;
61#endif
62 r0 = IRQ_EMU;
63 r1 = sp;
64 SP += -12;
65 call _irq_panic;
66 SP += 12;
67 /* - GDB stub fills this in by itself (if defined) */
68 rte;
69#endif
70
71/* Common interrupt entry code. First we do CLI, then push
72 * RETI, to keep interrupts disabled, but to allow this state to be changed
73 * by local_bh_enable.
74 * R0 contains the interrupt number, while R1 may contain the value of IPEND,
75 * or garbage if IPEND won't be needed by the ISR. */
76__common_int_entry:
77 [--sp] = fp;
78 [--sp] = usp;
79
80 [--sp] = i0;
81 [--sp] = i1;
82 [--sp] = i2;
83 [--sp] = i3;
84
85 [--sp] = m0;
86 [--sp] = m1;
87 [--sp] = m2;
88 [--sp] = m3;
89
90 [--sp] = l0;
91 [--sp] = l1;
92 [--sp] = l2;
93 [--sp] = l3;
94
95 [--sp] = b0;
96 [--sp] = b1;
97 [--sp] = b2;
98 [--sp] = b3;
99 [--sp] = a0.x;
100 [--sp] = a0.w;
101 [--sp] = a1.x;
102 [--sp] = a1.w;
103
104 [--sp] = LC0;
105 [--sp] = LC1;
106 [--sp] = LT0;
107 [--sp] = LT1;
108 [--sp] = LB0;
109 [--sp] = LB1;
110
111 [--sp] = ASTAT;
112
113 [--sp] = r0; /* Skip reserved */
114 [--sp] = RETS;
115 r2 = RETI;
116 [--sp] = r2;
117 [--sp] = RETX;
118 [--sp] = RETN;
119 [--sp] = RETE;
120 [--sp] = SEQSTAT;
121 [--sp] = r1; /* IPEND - R1 may or may not be set up before jumping here. */
122
123 /* Switch to other method of keeping interrupts disabled. */
124#ifdef CONFIG_DEBUG_HWERR
125 r1 = 0x3f;
126 sti r1;
127#else
128 cli r1;
129#endif
130 [--sp] = RETI; /* orig_pc */
131 /* Clear all L registers. */
132 r1 = 0 (x);
133 l0 = r1;
134 l1 = r1;
135 l2 = r1;
136 l3 = r1;
137#ifdef CONFIG_FRAME_POINTER
138 fp = 0;
139#endif
140
141#ifdef ANOMALY_05000283
142 cc = r7 == r7;
143 p5.h = 0xffc0;
144 p5.l = 0x0014;
145 if cc jump 1f;
146 r7.l = W[p5];
1471:
148#endif
149 r1 = sp;
150 SP += -12;
151 call _do_irq;
152 SP += 12;
153 call _return_from_int;
154.Lcommon_restore_context:
155 RESTORE_CONTEXT
156 rti;
157
158/* interrupt routine for ivhw - 5 */
159ENTRY(_evt_ivhw)
160 SAVE_CONTEXT
161#ifdef CONFIG_FRAME_POINTER
162 fp = 0;
163#endif
164#ifdef ANOMALY_05000283
165 cc = r7 == r7;
166 p5.h = 0xffc0;
167 p5.l = 0x0014;
168 if cc jump 1f;
169 r7.l = W[p5];
1701:
171#endif
172 p0.l = lo(TBUFCTL);
173 p0.h = hi(TBUFCTL);
174 r0 = 1;
175 [p0] = r0;
176 r0 = IRQ_HWERR;
177 r1 = sp;
178
179#ifdef CONFIG_HARDWARE_PM
180 r7 = SEQSTAT;
181 r7 = r7 >>> 0xe;
182 r6 = 0x1F;
183 r7 = r7 & r6;
184 r5 = 0x12;
185 cc = r7 == r5;
186 if cc jump .Lcall_do_ovf; /* deal with performance counter overflow */
187#endif
188
189 SP += -12;
190 call _irq_panic;
191 SP += 12;
192 rti;
193#ifdef CONFIG_HARDWARE_PM
194.Lcall_do_ovf:
195
196 SP += -12;
197 call _pm_overflow;
198 SP += 12;
199
200 jump .Lcommon_restore_context;
201#endif
202
203/* interrupt routine for evt2 - 2. This is NMI. */
204ENTRY(_evt_evt2)
205 SAVE_CONTEXT
206#ifdef CONFIG_FRAME_POINTER
207 fp = 0;
208#endif
209#ifdef ANOMALY_05000283
210 cc = r7 == r7;
211 p5.h = 0xffc0;
212 p5.l = 0x0014;
213 if cc jump 1f;
214 r7.l = W[p5];
2151:
216#endif
217 r0 = IRQ_NMI;
218 r1 = sp;
219 SP += -12;
220 call _asm_do_IRQ;
221 SP += 12;
222 RESTORE_CONTEXT
223 rtn;
224
225/* interrupt routine for core timer - 6 */
226ENTRY(_evt_timer)
227 TIMER_INTERRUPT_ENTRY(EVT_IVTMR_P)
228
229/* interrupt routine for evt7 - 7 */
230ENTRY(_evt_evt7)
231 INTERRUPT_ENTRY(EVT_IVG7_P)
232ENTRY(_evt_evt8)
233 INTERRUPT_ENTRY(EVT_IVG8_P)
234ENTRY(_evt_evt9)
235 INTERRUPT_ENTRY(EVT_IVG9_P)
236ENTRY(_evt_evt10)
237 INTERRUPT_ENTRY(EVT_IVG10_P)
238ENTRY(_evt_evt11)
239 INTERRUPT_ENTRY(EVT_IVG11_P)
240ENTRY(_evt_evt12)
241 INTERRUPT_ENTRY(EVT_IVG12_P)
242ENTRY(_evt_evt13)
243 INTERRUPT_ENTRY(EVT_IVG13_P)
244
245
246 /* interrupt routine for system_call - 15 */
247ENTRY(_evt_system_call)
248 SAVE_CONTEXT_SYSCALL
249#ifdef CONFIG_FRAME_POINTER
250 fp = 0;
251#endif
252 call _system_call;
253 jump .Lcommon_restore_context;
diff --git a/arch/blackfin/mach-common/ints-priority-dc.c b/arch/blackfin/mach-common/ints-priority-dc.c
new file mode 100644
index 000000000000..f3cf07036c2a
--- /dev/null
+++ b/arch/blackfin/mach-common/ints-priority-dc.c
@@ -0,0 +1,476 @@
1/*
2 * File: arch/blackfin/mach-common/ints-priority-dc.c
3 * Based on:
4 * Author:
5 *
6 * Created: ?
7 * Description: Set up the interupt priorities
8 *
9 * Modified:
10 * 1996 Roman Zippel
11 * 1999 D. Jeff Dionne <jeff@uclinux.org>
12 * 2000-2001 Lineo, Inc. D. Jefff Dionne <jeff@lineo.ca>
13 * 2002 Arcturus Networks Inc. MaTed <mated@sympatico.ca>
14 * 2003 Metrowerks/Motorola
15 * 2003 Bas Vermeulen <bas@buyways.nl>
16 * Copyright 2004-2006 Analog Devices Inc.
17 *
18 * Bugs: Enter bugs at http://blackfin.uclinux.org/
19 *
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, see the file COPYING, or write
32 * to the Free Software Foundation, Inc.,
33 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
34 */
35
36#include <linux/module.h>
37#include <linux/kernel_stat.h>
38#include <linux/seq_file.h>
39#include <linux/irq.h>
40#ifdef CONFIG_KGDB
41#include <linux/kgdb.h>
42#endif
43#include <asm/traps.h>
44#include <asm/blackfin.h>
45#include <asm/gpio.h>
46#include <asm/irq_handler.h>
47
48/*
49 * NOTES:
50 * - we have separated the physical Hardware interrupt from the
51 * levels that the LINUX kernel sees (see the description in irq.h)
52 * -
53 */
54
55unsigned long irq_flags = 0;
56
57/* The number of spurious interrupts */
58atomic_t num_spurious;
59
60struct ivgx {
61 /* irq number for request_irq, available in mach-bf561/irq.h */
62 int irqno;
63 /* corresponding bit in the SICA_ISR0 register */
64 int isrflag0;
65 /* corresponding bit in the SICA_ISR1 register */
66 int isrflag1;
67} ivg_table[NR_PERI_INTS];
68
69struct ivg_slice {
70 /* position of first irq in ivg_table for given ivg */
71 struct ivgx *ifirst;
72 struct ivgx *istop;
73} ivg7_13[IVG13 - IVG7 + 1];
74
75static void search_IAR(void);
76
77/*
78 * Search SIC_IAR and fill tables with the irqvalues
79 * and their positions in the SIC_ISR register.
80 */
81static void __init search_IAR(void)
82{
83 unsigned ivg, irq_pos = 0;
84 for (ivg = 0; ivg <= IVG13 - IVG7; ivg++) {
85 int irqn;
86
87 ivg7_13[ivg].istop = ivg7_13[ivg].ifirst = &ivg_table[irq_pos];
88
89 for (irqn = 0; irqn < NR_PERI_INTS; irqn++) {
90 int iar_shift = (irqn & 7) * 4;
91 if (ivg ==
92 (0xf &
93 bfin_read32((unsigned long *)SICA_IAR0 +
94 (irqn >> 3)) >> iar_shift)) {
95 ivg_table[irq_pos].irqno = IVG7 + irqn;
96 ivg_table[irq_pos].isrflag0 =
97 (irqn < 32 ? (1 << irqn) : 0);
98 ivg_table[irq_pos].isrflag1 =
99 (irqn < 32 ? 0 : (1 << (irqn - 32)));
100 ivg7_13[ivg].istop++;
101 irq_pos++;
102 }
103 }
104 }
105}
106
107/*
108 * This is for BF561 internal IRQs
109 */
110
111static void ack_noop(unsigned int irq)
112{
113 /* Dummy function. */
114}
115
116static void bf561_core_mask_irq(unsigned int irq)
117{
118 irq_flags &= ~(1 << irq);
119 if (!irqs_disabled())
120 local_irq_enable();
121}
122
123static void bf561_core_unmask_irq(unsigned int irq)
124{
125 irq_flags |= 1 << irq;
126 /*
127 * If interrupts are enabled, IMASK must contain the same value
128 * as irq_flags. Make sure that invariant holds. If interrupts
129 * are currently disabled we need not do anything; one of the
130 * callers will take care of setting IMASK to the proper value
131 * when reenabling interrupts.
132 * local_irq_enable just does "STI irq_flags", so it's exactly
133 * what we need.
134 */
135 if (!irqs_disabled())
136 local_irq_enable();
137 return;
138}
139
140static void bf561_internal_mask_irq(unsigned int irq)
141{
142 unsigned long irq_mask;
143 if ((irq - (IRQ_CORETMR + 1)) < 32) {
144 irq_mask = (1 << (irq - (IRQ_CORETMR + 1)));
145 bfin_write_SICA_IMASK0(bfin_read_SICA_IMASK0() & ~irq_mask);
146 } else {
147 irq_mask = (1 << (irq - (IRQ_CORETMR + 1) - 32));
148 bfin_write_SICA_IMASK1(bfin_read_SICA_IMASK1() & ~irq_mask);
149 }
150}
151
152static void bf561_internal_unmask_irq(unsigned int irq)
153{
154 unsigned long irq_mask;
155
156 if ((irq - (IRQ_CORETMR + 1)) < 32) {
157 irq_mask = (1 << (irq - (IRQ_CORETMR + 1)));
158 bfin_write_SICA_IMASK0(bfin_read_SICA_IMASK0() | irq_mask);
159 } else {
160 irq_mask = (1 << (irq - (IRQ_CORETMR + 1) - 32));
161 bfin_write_SICA_IMASK1(bfin_read_SICA_IMASK1() | irq_mask);
162 }
163 SSYNC();
164}
165
166static struct irq_chip bf561_core_irqchip = {
167 .ack = ack_noop,
168 .mask = bf561_core_mask_irq,
169 .unmask = bf561_core_unmask_irq,
170};
171
172static struct irq_chip bf561_internal_irqchip = {
173 .ack = ack_noop,
174 .mask = bf561_internal_mask_irq,
175 .unmask = bf561_internal_unmask_irq,
176};
177
178#ifdef CONFIG_IRQCHIP_DEMUX_GPIO
179static unsigned short gpio_enabled[gpio_bank(MAX_BLACKFIN_GPIOS)];
180static unsigned short gpio_edge_triggered[gpio_bank(MAX_BLACKFIN_GPIOS)];
181
182static void bf561_gpio_ack_irq(unsigned int irq)
183{
184 u16 gpionr = irq - IRQ_PF0;
185
186 if(gpio_edge_triggered[gpio_bank(gpionr)] & gpio_bit(gpionr)) {
187 set_gpio_data(gpionr, 0);
188 SSYNC();
189 }
190}
191
192static void bf561_gpio_mask_ack_irq(unsigned int irq)
193{
194 u16 gpionr = irq - IRQ_PF0;
195
196 if(gpio_edge_triggered[gpio_bank(gpionr)] & gpio_bit(gpionr)) {
197 set_gpio_data(gpionr, 0);
198 SSYNC();
199 }
200
201 set_gpio_maska(gpionr, 0);
202 SSYNC();
203}
204
205static void bf561_gpio_mask_irq(unsigned int irq)
206{
207 set_gpio_maska(irq - IRQ_PF0, 0);
208 SSYNC();
209}
210
211static void bf561_gpio_unmask_irq(unsigned int irq)
212{
213 set_gpio_maska(irq - IRQ_PF0, 1);
214 SSYNC();
215}
216
217static unsigned int bf561_gpio_irq_startup(unsigned int irq)
218{
219 unsigned int ret;
220 u16 gpionr = irq - IRQ_PF0;
221
222 if (!(gpio_enabled[gpio_bank(gpionr)] & gpio_bit(gpionr))) {
223
224 ret = gpio_request(gpionr, NULL);
225 if(ret)
226 return ret;
227
228 }
229
230 gpio_enabled[gpio_bank(gpionr)] |= gpio_bit(gpionr);
231 bf561_gpio_unmask_irq(irq);
232
233 return ret;
234
235}
236
237static void bf561_gpio_irq_shutdown(unsigned int irq)
238{
239 bf561_gpio_mask_irq(irq);
240 gpio_free(irq - IRQ_PF0);
241 gpio_enabled[gpio_bank(irq - IRQ_PF0)] &= ~gpio_bit(irq - IRQ_PF0);
242}
243
244static int bf561_gpio_irq_type(unsigned int irq, unsigned int type)
245{
246
247 unsigned int ret;
248 u16 gpionr = irq - IRQ_PF0;
249
250
251 if (type == IRQ_TYPE_PROBE) {
252 /* only probe unenabled GPIO interrupt lines */
253 if (gpio_enabled[gpio_bank(gpionr)] & gpio_bit(gpionr))
254 return 0;
255 type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING;
256
257 }
258
259 if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING |
260 IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) {
261
262 if (!(gpio_enabled[gpio_bank(gpionr)] & gpio_bit(gpionr))) {
263
264 ret = gpio_request(gpionr, NULL);
265 if(ret)
266 return ret;
267
268 }
269
270 gpio_enabled[gpio_bank(gpionr)] |= gpio_bit(gpionr);
271 } else {
272 gpio_enabled[gpio_bank(gpionr)] &= ~gpio_bit(gpionr);
273 return 0;
274 }
275
276
277 set_gpio_dir(gpionr, 0);
278 set_gpio_inen(gpionr, 1);
279
280
281 if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) {
282 gpio_edge_triggered[gpio_bank(gpionr)] |= gpio_bit(gpionr);
283 set_gpio_edge(gpionr, 1);
284 } else {
285 set_gpio_edge(gpionr, 0);
286 gpio_edge_triggered[gpio_bank(gpionr)] &= ~gpio_bit(gpionr);
287 }
288
289 if ((type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING))
290 == (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING))
291 set_gpio_both(gpionr, 1);
292 else
293 set_gpio_both(gpionr, 0);
294
295 if ((type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_LEVEL_LOW)))
296 set_gpio_polar(gpionr, 1); /* low or falling edge denoted by one */
297 else
298 set_gpio_polar(gpionr, 0); /* high or rising edge denoted by zero */
299
300 SSYNC();
301
302 if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING))
303 set_irq_handler(irq, handle_edge_irq);
304 else
305 set_irq_handler(irq, handle_level_irq);
306
307 return 0;
308}
309
310static struct irq_chip bf561_gpio_irqchip = {
311 .ack = bf561_gpio_ack_irq,
312 .mask = bf561_gpio_mask_irq,
313 .mask_ack = bf561_gpio_mask_ack_irq,
314 .unmask = bf561_gpio_unmask_irq,
315 .set_type = bf561_gpio_irq_type,
316 .startup = bf561_gpio_irq_startup,
317 .shutdown = bf561_gpio_irq_shutdown
318};
319
320static void bf561_demux_gpio_irq(unsigned int inta_irq,
321 struct irq_desc *intb_desc)
322{
323 int irq, flag_d, mask;
324 u16 gpio;
325
326 switch (inta_irq) {
327 case IRQ_PROG0_INTA:
328 irq = IRQ_PF0;
329 break;
330 case IRQ_PROG1_INTA:
331 irq = IRQ_PF16;
332 break;
333 case IRQ_PROG2_INTA:
334 irq = IRQ_PF32;
335 break;
336 default:
337 dump_stack();
338 return;
339 }
340
341 gpio = irq - IRQ_PF0;
342
343 flag_d = get_gpiop_data(gpio);
344 mask = flag_d & (gpio_enabled[gpio_bank(gpio)] &
345 get_gpiop_maska(gpio));
346
347 do {
348 if (mask & 1) {
349 struct irq_desc *desc = irq_desc + irq;
350 desc->handle_irq(irq, desc);
351 }
352 irq++;
353 mask >>= 1;
354 } while (mask);
355
356
357}
358
359#endif /* CONFIG_IRQCHIP_DEMUX_GPIO */
360
361/*
362 * This function should be called during kernel startup to initialize
363 * the BFin IRQ handling routines.
364 */
365int __init init_arch_irq(void)
366{
367 int irq;
368 unsigned long ilat = 0;
369 /* Disable all the peripheral intrs - page 4-29 HW Ref manual */
370 bfin_write_SICA_IMASK0(SIC_UNMASK_ALL);
371 bfin_write_SICA_IMASK1(SIC_UNMASK_ALL);
372 SSYNC();
373
374 local_irq_disable();
375
376 init_exception_buff();
377
378#ifndef CONFIG_KGDB
379 bfin_write_EVT0(evt_emulation);
380#endif
381 bfin_write_EVT2(evt_evt2);
382 bfin_write_EVT3(trap);
383 bfin_write_EVT5(evt_ivhw);
384 bfin_write_EVT6(evt_timer);
385 bfin_write_EVT7(evt_evt7);
386 bfin_write_EVT8(evt_evt8);
387 bfin_write_EVT9(evt_evt9);
388 bfin_write_EVT10(evt_evt10);
389 bfin_write_EVT11(evt_evt11);
390 bfin_write_EVT12(evt_evt12);
391 bfin_write_EVT13(evt_evt13);
392 bfin_write_EVT14(evt14_softirq);
393 bfin_write_EVT15(evt_system_call);
394 CSYNC();
395
396 for (irq = 0; irq < SYS_IRQS; irq++) {
397 if (irq <= IRQ_CORETMR)
398 set_irq_chip(irq, &bf561_core_irqchip);
399 else
400 set_irq_chip(irq, &bf561_internal_irqchip);
401#ifdef CONFIG_IRQCHIP_DEMUX_GPIO
402 if ((irq != IRQ_PROG0_INTA) &&
403 (irq != IRQ_PROG1_INTA) && (irq != IRQ_PROG2_INTA)) {
404#endif
405 set_irq_handler(irq, handle_simple_irq);
406#ifdef CONFIG_IRQCHIP_DEMUX_GPIO
407 } else {
408 set_irq_chained_handler(irq, bf561_demux_gpio_irq);
409 }
410#endif
411
412 }
413
414#ifdef CONFIG_IRQCHIP_DEMUX_GPIO
415 for (irq = IRQ_PF0; irq <= IRQ_PF47; irq++) {
416 set_irq_chip(irq, &bf561_gpio_irqchip);
417 /* if configured as edge, then will be changed to do_edge_IRQ */
418 set_irq_handler(irq, handle_level_irq);
419 }
420#endif
421 bfin_write_IMASK(0);
422 CSYNC();
423 ilat = bfin_read_ILAT();
424 CSYNC();
425 bfin_write_ILAT(ilat);
426 CSYNC();
427
428 printk(KERN_INFO "Configuring Blackfin Priority Driven Interrupts\n");
429 /* IMASK=xxx is equivalent to STI xx or irq_flags=xx,
430 * local_irq_enable()
431 */
432 program_IAR();
433 /* Therefore it's better to setup IARs before interrupts enabled */
434 search_IAR();
435
436 /* Enable interrupts IVG7-15 */
437 irq_flags = irq_flags | IMASK_IVG15 |
438 IMASK_IVG14 | IMASK_IVG13 | IMASK_IVG12 | IMASK_IVG11 |
439 IMASK_IVG10 | IMASK_IVG9 | IMASK_IVG8 | IMASK_IVG7 | IMASK_IVGHW;
440
441 return 0;
442}
443
444#ifdef CONFIG_DO_IRQ_L1
445void do_irq(int vec, struct pt_regs *fp)__attribute__((l1_text));
446#endif
447
448void do_irq(int vec, struct pt_regs *fp)
449{
450 if (vec == EVT_IVTMR_P) {
451 vec = IRQ_CORETMR;
452 } else {
453 struct ivgx *ivg = ivg7_13[vec - IVG7].ifirst;
454 struct ivgx *ivg_stop = ivg7_13[vec - IVG7].istop;
455 unsigned long sic_status0, sic_status1;
456
457 SSYNC();
458 sic_status0 = bfin_read_SICA_IMASK0() & bfin_read_SICA_ISR0();
459 sic_status1 = bfin_read_SICA_IMASK1() & bfin_read_SICA_ISR1();
460
461 for (;; ivg++) {
462 if (ivg >= ivg_stop) {
463 atomic_inc(&num_spurious);
464 return;
465 } else if ((sic_status0 & ivg->isrflag0) ||
466 (sic_status1 & ivg->isrflag1))
467 break;
468 }
469 vec = ivg->irqno;
470 }
471 asm_do_IRQ(vec, fp);
472
473#ifdef CONFIG_KGDB
474 kgdb_process_breakpoint();
475#endif
476}
diff --git a/arch/blackfin/mach-common/ints-priority-sc.c b/arch/blackfin/mach-common/ints-priority-sc.c
new file mode 100644
index 000000000000..34b62288ec3c
--- /dev/null
+++ b/arch/blackfin/mach-common/ints-priority-sc.c
@@ -0,0 +1,577 @@
1/*
2 * File: arch/blackfin/mach-common/ints-priority-sc.c
3 * Based on:
4 * Author:
5 *
6 * Created: ?
7 * Description: Set up the interupt priorities
8 *
9 * Modified:
10 * 1996 Roman Zippel
11 * 1999 D. Jeff Dionne <jeff@uclinux.org>
12 * 2000-2001 Lineo, Inc. D. Jefff Dionne <jeff@lineo.ca>
13 * 2002 Arcturus Networks Inc. MaTed <mated@sympatico.ca>
14 * 2003 Metrowerks/Motorola
15 * 2003 Bas Vermeulen <bas@buyways.nl>
16 * Copyright 2004-2006 Analog Devices Inc.
17 *
18 * Bugs: Enter bugs at http://blackfin.uclinux.org/
19 *
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, see the file COPYING, or write
32 * to the Free Software Foundation, Inc.,
33 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
34 */
35
36#include <linux/module.h>
37#include <linux/kernel_stat.h>
38#include <linux/seq_file.h>
39#include <linux/irq.h>
40#ifdef CONFIG_KGDB
41#include <linux/kgdb.h>
42#endif
43#include <asm/traps.h>
44#include <asm/blackfin.h>
45#include <asm/gpio.h>
46#include <asm/irq_handler.h>
47
48#ifdef BF537_FAMILY
49# define BF537_GENERIC_ERROR_INT_DEMUX
50#else
51# undef BF537_GENERIC_ERROR_INT_DEMUX
52#endif
53
54/*
55 * NOTES:
56 * - we have separated the physical Hardware interrupt from the
57 * levels that the LINUX kernel sees (see the description in irq.h)
58 * -
59 */
60
61unsigned long irq_flags = 0;
62
63/* The number of spurious interrupts */
64atomic_t num_spurious;
65
66struct ivgx {
67 /* irq number for request_irq, available in mach-bf533/irq.h */
68 int irqno;
69 /* corresponding bit in the SIC_ISR register */
70 int isrflag;
71} ivg_table[NR_PERI_INTS];
72
73struct ivg_slice {
74 /* position of first irq in ivg_table for given ivg */
75 struct ivgx *ifirst;
76 struct ivgx *istop;
77} ivg7_13[IVG13 - IVG7 + 1];
78
79static void search_IAR(void);
80
81/*
82 * Search SIC_IAR and fill tables with the irqvalues
83 * and their positions in the SIC_ISR register.
84 */
85static void __init search_IAR(void)
86{
87 unsigned ivg, irq_pos = 0;
88 for (ivg = 0; ivg <= IVG13 - IVG7; ivg++) {
89 int irqn;
90
91 ivg7_13[ivg].istop = ivg7_13[ivg].ifirst =
92 &ivg_table[irq_pos];
93
94 for (irqn = 0; irqn < NR_PERI_INTS; irqn++) {
95 int iar_shift = (irqn & 7) * 4;
96 if (ivg ==
97 (0xf &
98 bfin_read32((unsigned long *) SIC_IAR0 +
99 (irqn >> 3)) >> iar_shift)) {
100 ivg_table[irq_pos].irqno = IVG7 + irqn;
101 ivg_table[irq_pos].isrflag = 1 << irqn;
102 ivg7_13[ivg].istop++;
103 irq_pos++;
104 }
105 }
106 }
107}
108
109/*
110 * This is for BF533 internal IRQs
111 */
112
113static void ack_noop(unsigned int irq)
114{
115 /* Dummy function. */
116}
117
118static void bfin_core_mask_irq(unsigned int irq)
119{
120 irq_flags &= ~(1 << irq);
121 if (!irqs_disabled())
122 local_irq_enable();
123}
124
125static void bfin_core_unmask_irq(unsigned int irq)
126{
127 irq_flags |= 1 << irq;
128 /*
129 * If interrupts are enabled, IMASK must contain the same value
130 * as irq_flags. Make sure that invariant holds. If interrupts
131 * are currently disabled we need not do anything; one of the
132 * callers will take care of setting IMASK to the proper value
133 * when reenabling interrupts.
134 * local_irq_enable just does "STI irq_flags", so it's exactly
135 * what we need.
136 */
137 if (!irqs_disabled())
138 local_irq_enable();
139 return;
140}
141
142static void bfin_internal_mask_irq(unsigned int irq)
143{
144 bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() &
145 ~(1 << (irq - (IRQ_CORETMR + 1))));
146 SSYNC();
147}
148
149static void bfin_internal_unmask_irq(unsigned int irq)
150{
151 bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() |
152 (1 << (irq - (IRQ_CORETMR + 1))));
153 SSYNC();
154}
155
156static struct irq_chip bfin_core_irqchip = {
157 .ack = ack_noop,
158 .mask = bfin_core_mask_irq,
159 .unmask = bfin_core_unmask_irq,
160};
161
162static struct irq_chip bfin_internal_irqchip = {
163 .ack = ack_noop,
164 .mask = bfin_internal_mask_irq,
165 .unmask = bfin_internal_unmask_irq,
166};
167
168#ifdef BF537_GENERIC_ERROR_INT_DEMUX
169static int error_int_mask;
170
171static void bfin_generic_error_ack_irq(unsigned int irq)
172{
173
174}
175
176static void bfin_generic_error_mask_irq(unsigned int irq)
177{
178 error_int_mask &= ~(1L << (irq - IRQ_PPI_ERROR));
179
180 if (!error_int_mask) {
181 local_irq_disable();
182 bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() &
183 ~(1 <<
184 (IRQ_GENERIC_ERROR -
185 (IRQ_CORETMR + 1))));
186 SSYNC();
187 local_irq_enable();
188 }
189}
190
191static void bfin_generic_error_unmask_irq(unsigned int irq)
192{
193 local_irq_disable();
194 bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() | 1 <<
195 (IRQ_GENERIC_ERROR - (IRQ_CORETMR + 1)));
196 SSYNC();
197 local_irq_enable();
198
199 error_int_mask |= 1L << (irq - IRQ_PPI_ERROR);
200}
201
202static struct irq_chip bfin_generic_error_irqchip = {
203 .ack = bfin_generic_error_ack_irq,
204 .mask = bfin_generic_error_mask_irq,
205 .unmask = bfin_generic_error_unmask_irq,
206};
207
208static void bfin_demux_error_irq(unsigned int int_err_irq,
209 struct irq_desc *intb_desc)
210{
211 int irq = 0;
212
213 SSYNC();
214
215#if (defined(CONFIG_BF537) || defined(CONFIG_BF536))
216 if (bfin_read_EMAC_SYSTAT() & EMAC_ERR_MASK)
217 irq = IRQ_MAC_ERROR;
218 else
219#endif
220 if (bfin_read_SPORT0_STAT() & SPORT_ERR_MASK)
221 irq = IRQ_SPORT0_ERROR;
222 else if (bfin_read_SPORT1_STAT() & SPORT_ERR_MASK)
223 irq = IRQ_SPORT1_ERROR;
224 else if (bfin_read_PPI_STATUS() & PPI_ERR_MASK)
225 irq = IRQ_PPI_ERROR;
226 else if (bfin_read_CAN_GIF() & CAN_ERR_MASK)
227 irq = IRQ_CAN_ERROR;
228 else if (bfin_read_SPI_STAT() & SPI_ERR_MASK)
229 irq = IRQ_SPI_ERROR;
230 else if ((bfin_read_UART0_IIR() & UART_ERR_MASK_STAT1) &&
231 (bfin_read_UART0_IIR() & UART_ERR_MASK_STAT0))
232 irq = IRQ_UART0_ERROR;
233 else if ((bfin_read_UART1_IIR() & UART_ERR_MASK_STAT1) &&
234 (bfin_read_UART1_IIR() & UART_ERR_MASK_STAT0))
235 irq = IRQ_UART1_ERROR;
236
237 if (irq) {
238 if (error_int_mask & (1L << (irq - IRQ_PPI_ERROR))) {
239 struct irq_desc *desc = irq_desc + irq;
240 desc->handle_irq(irq, desc);
241 } else {
242
243 switch (irq) {
244 case IRQ_PPI_ERROR:
245 bfin_write_PPI_STATUS(PPI_ERR_MASK);
246 break;
247#if (defined(CONFIG_BF537) || defined(CONFIG_BF536))
248 case IRQ_MAC_ERROR:
249 bfin_write_EMAC_SYSTAT(EMAC_ERR_MASK);
250 break;
251#endif
252 case IRQ_SPORT0_ERROR:
253 bfin_write_SPORT0_STAT(SPORT_ERR_MASK);
254 break;
255
256 case IRQ_SPORT1_ERROR:
257 bfin_write_SPORT1_STAT(SPORT_ERR_MASK);
258 break;
259
260 case IRQ_CAN_ERROR:
261 bfin_write_CAN_GIS(CAN_ERR_MASK);
262 break;
263
264 case IRQ_SPI_ERROR:
265 bfin_write_SPI_STAT(SPI_ERR_MASK);
266 break;
267
268 default:
269 break;
270 }
271
272 pr_debug("IRQ %d:"
273 " MASKED PERIPHERAL ERROR INTERRUPT ASSERTED\n",
274 irq);
275 }
276 } else
277 printk(KERN_ERR
278 "%s : %s : LINE %d :\nIRQ ?: PERIPHERAL ERROR"
279 " INTERRUPT ASSERTED BUT NO SOURCE FOUND\n",
280 __FUNCTION__, __FILE__, __LINE__);
281
282
283}
284#endif /* BF537_GENERIC_ERROR_INT_DEMUX */
285
286#ifdef CONFIG_IRQCHIP_DEMUX_GPIO
287
288static unsigned short gpio_enabled[gpio_bank(MAX_BLACKFIN_GPIOS)];
289static unsigned short gpio_edge_triggered[gpio_bank(MAX_BLACKFIN_GPIOS)];
290
291static void bfin_gpio_ack_irq(unsigned int irq)
292{
293 u16 gpionr = irq - IRQ_PF0;
294
295 if (gpio_edge_triggered[gpio_bank(gpionr)] & gpio_bit(gpionr)) {
296 set_gpio_data(gpionr, 0);
297 SSYNC();
298 }
299}
300
301static void bfin_gpio_mask_ack_irq(unsigned int irq)
302{
303 u16 gpionr = irq - IRQ_PF0;
304
305 if (gpio_edge_triggered[gpio_bank(gpionr)] & gpio_bit(gpionr)) {
306 set_gpio_data(gpionr, 0);
307 SSYNC();
308 }
309
310 set_gpio_maska(gpionr, 0);
311 SSYNC();
312}
313
314static void bfin_gpio_mask_irq(unsigned int irq)
315{
316 set_gpio_maska(irq - IRQ_PF0, 0);
317 SSYNC();
318}
319
320static void bfin_gpio_unmask_irq(unsigned int irq)
321{
322 set_gpio_maska(irq - IRQ_PF0, 1);
323 SSYNC();
324}
325
326static unsigned int bfin_gpio_irq_startup(unsigned int irq)
327{
328 unsigned int ret;
329 u16 gpionr = irq - IRQ_PF0;
330
331 if (!(gpio_enabled[gpio_bank(gpionr)] & gpio_bit(gpionr))) {
332 ret = gpio_request(gpionr, NULL);
333 if (ret)
334 return ret;
335 }
336
337 gpio_enabled[gpio_bank(gpionr)] |= gpio_bit(gpionr);
338 bfin_gpio_unmask_irq(irq);
339
340 return ret;
341}
342
343static void bfin_gpio_irq_shutdown(unsigned int irq)
344{
345 bfin_gpio_mask_irq(irq);
346 gpio_free(irq - IRQ_PF0);
347 gpio_enabled[gpio_bank(irq - IRQ_PF0)] &= ~gpio_bit(irq - IRQ_PF0);
348}
349
350static int bfin_gpio_irq_type(unsigned int irq, unsigned int type)
351{
352
353 unsigned int ret;
354 u16 gpionr = irq - IRQ_PF0;
355
356 if (type == IRQ_TYPE_PROBE) {
357 /* only probe unenabled GPIO interrupt lines */
358 if (gpio_enabled[gpio_bank(gpionr)] & gpio_bit(gpionr))
359 return 0;
360 type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING;
361 }
362
363 if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING |
364 IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW))
365 {
366 if (!(gpio_enabled[gpio_bank(gpionr)] & gpio_bit(gpionr))) {
367 ret = gpio_request(gpionr, NULL);
368 if (ret)
369 return ret;
370 }
371
372 gpio_enabled[gpio_bank(gpionr)] |= gpio_bit(gpionr);
373 } else {
374 gpio_enabled[gpio_bank(gpionr)] &= ~gpio_bit(gpionr);
375 return 0;
376 }
377
378 set_gpio_dir(gpionr, 0);
379 set_gpio_inen(gpionr, 1);
380
381 if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) {
382 gpio_edge_triggered[gpio_bank(gpionr)] |= gpio_bit(gpionr);
383 set_gpio_edge(gpionr, 1);
384 } else {
385 set_gpio_edge(gpionr, 0);
386 gpio_edge_triggered[gpio_bank(gpionr)] &= ~gpio_bit(gpionr);
387 }
388
389 if ((type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING))
390 == (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING))
391 set_gpio_both(gpionr, 1);
392 else
393 set_gpio_both(gpionr, 0);
394
395 if ((type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_LEVEL_LOW)))
396 set_gpio_polar(gpionr, 1); /* low or falling edge denoted by one */
397 else
398 set_gpio_polar(gpionr, 0); /* high or rising edge denoted by zero */
399
400 SSYNC();
401
402 if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING))
403 set_irq_handler(irq, handle_edge_irq);
404 else
405 set_irq_handler(irq, handle_level_irq);
406
407 return 0;
408}
409
410
411static struct irq_chip bfin_gpio_irqchip = {
412 .ack = bfin_gpio_ack_irq,
413 .mask = bfin_gpio_mask_irq,
414 .mask_ack = bfin_gpio_mask_ack_irq,
415 .unmask = bfin_gpio_unmask_irq,
416 .set_type = bfin_gpio_irq_type,
417 .startup = bfin_gpio_irq_startup,
418 .shutdown = bfin_gpio_irq_shutdown
419};
420
421static void bfin_demux_gpio_irq(unsigned int intb_irq,
422 struct irq_desc *intb_desc)
423{
424 u16 i;
425
426 for (i = 0; i < MAX_BLACKFIN_GPIOS; i+=16) {
427 int irq = IRQ_PF0 + i;
428 int flag_d = get_gpiop_data(i);
429 int mask =
430 flag_d & (gpio_enabled[gpio_bank(i)] &
431 get_gpiop_maska(i));
432
433 while (mask) {
434 if (mask & 1) {
435 struct irq_desc *desc = irq_desc + irq;
436 desc->handle_irq(irq, desc);
437 }
438 irq++;
439 mask >>= 1;
440 }
441 }
442}
443
444#endif /* CONFIG_IRQCHIP_DEMUX_GPIO */
445
446/*
447 * This function should be called during kernel startup to initialize
448 * the BFin IRQ handling routines.
449 */
450int __init init_arch_irq(void)
451{
452 int irq;
453 unsigned long ilat = 0;
454 /* Disable all the peripheral intrs - page 4-29 HW Ref manual */
455 bfin_write_SIC_IMASK(SIC_UNMASK_ALL);
456 SSYNC();
457
458 local_irq_disable();
459
460#ifndef CONFIG_KGDB
461 bfin_write_EVT0(evt_emulation);
462#endif
463 bfin_write_EVT2(evt_evt2);
464 bfin_write_EVT3(trap);
465 bfin_write_EVT5(evt_ivhw);
466 bfin_write_EVT6(evt_timer);
467 bfin_write_EVT7(evt_evt7);
468 bfin_write_EVT8(evt_evt8);
469 bfin_write_EVT9(evt_evt9);
470 bfin_write_EVT10(evt_evt10);
471 bfin_write_EVT11(evt_evt11);
472 bfin_write_EVT12(evt_evt12);
473 bfin_write_EVT13(evt_evt13);
474 bfin_write_EVT14(evt14_softirq);
475 bfin_write_EVT15(evt_system_call);
476 CSYNC();
477
478 for (irq = 0; irq < SYS_IRQS; irq++) {
479 if (irq <= IRQ_CORETMR)
480 set_irq_chip(irq, &bfin_core_irqchip);
481 else
482 set_irq_chip(irq, &bfin_internal_irqchip);
483#ifdef BF537_GENERIC_ERROR_INT_DEMUX
484 if (irq != IRQ_GENERIC_ERROR) {
485#endif
486
487#ifdef CONFIG_IRQCHIP_DEMUX_GPIO
488 if ((irq != IRQ_PROG_INTA) /*PORT F & G MASK_A Interrupt*/
489# if defined(BF537_FAMILY) && !(defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE))
490 && (irq != IRQ_MAC_RX) /*PORT H MASK_A Interrupt*/
491# endif
492 ) {
493#endif
494 set_irq_handler(irq, handle_simple_irq);
495#ifdef CONFIG_IRQCHIP_DEMUX_GPIO
496 } else {
497 set_irq_chained_handler(irq,
498 bfin_demux_gpio_irq);
499 }
500#endif
501
502#ifdef BF537_GENERIC_ERROR_INT_DEMUX
503 } else {
504 set_irq_handler(irq, bfin_demux_error_irq);
505 }
506#endif
507 }
508#ifdef BF537_GENERIC_ERROR_INT_DEMUX
509 for (irq = IRQ_PPI_ERROR; irq <= IRQ_UART1_ERROR; irq++) {
510 set_irq_chip(irq, &bfin_generic_error_irqchip);
511 set_irq_handler(irq, handle_level_irq);
512 }
513#endif
514
515#ifdef CONFIG_IRQCHIP_DEMUX_GPIO
516 for (irq = IRQ_PF0; irq < NR_IRQS; irq++) {
517 set_irq_chip(irq, &bfin_gpio_irqchip);
518 /* if configured as edge, then will be changed to do_edge_IRQ */
519 set_irq_handler(irq, handle_level_irq);
520 }
521#endif
522 bfin_write_IMASK(0);
523 CSYNC();
524 ilat = bfin_read_ILAT();
525 CSYNC();
526 bfin_write_ILAT(ilat);
527 CSYNC();
528
529 printk(KERN_INFO
530 "Configuring Blackfin Priority Driven Interrupts\n");
531 /* IMASK=xxx is equivalent to STI xx or irq_flags=xx,
532 * local_irq_enable()
533 */
534 program_IAR();
535 /* Therefore it's better to setup IARs before interrupts enabled */
536 search_IAR();
537
538 /* Enable interrupts IVG7-15 */
539 irq_flags = irq_flags | IMASK_IVG15 |
540 IMASK_IVG14 | IMASK_IVG13 | IMASK_IVG12 | IMASK_IVG11 |
541 IMASK_IVG10 | IMASK_IVG9 | IMASK_IVG8 | IMASK_IVG7 |
542 IMASK_IVGHW;
543
544 return 0;
545}
546
547#ifdef CONFIG_DO_IRQ_L1
548void do_irq(int vec, struct pt_regs *fp)__attribute__((l1_text));
549#endif
550
551void do_irq(int vec, struct pt_regs *fp)
552{
553 if (vec == EVT_IVTMR_P) {
554 vec = IRQ_CORETMR;
555 } else {
556 struct ivgx *ivg = ivg7_13[vec - IVG7].ifirst;
557 struct ivgx *ivg_stop = ivg7_13[vec - IVG7].istop;
558 unsigned long sic_status;
559
560 SSYNC();
561 sic_status = bfin_read_SIC_IMASK() & bfin_read_SIC_ISR();
562
563 for (;; ivg++) {
564 if (ivg >= ivg_stop) {
565 atomic_inc(&num_spurious);
566 return;
567 } else if (sic_status & ivg->isrflag)
568 break;
569 }
570 vec = ivg->irqno;
571 }
572 asm_do_IRQ(vec, fp);
573
574#ifdef CONFIG_KGDB
575 kgdb_process_breakpoint();
576#endif
577}
diff --git a/arch/blackfin/mach-common/irqpanic.c b/arch/blackfin/mach-common/irqpanic.c
new file mode 100644
index 000000000000..f05e3dadaf33
--- /dev/null
+++ b/arch/blackfin/mach-common/irqpanic.c
@@ -0,0 +1,194 @@
1/*
2 * File: arch/blackfin/mach-common/irqpanic.c
3 * Based on:
4 * Author:
5 *
6 * Created: ?
7 * Description: panic kernel with dump information
8 *
9 * Modified: rgetz - added cache checking code 14Feb06
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/module.h>
31#include <linux/kernel_stat.h>
32#include <linux/sched.h>
33#include <asm/traps.h>
34#include <asm/blackfin.h>
35
36#include "../oprofile/op_blackfin.h"
37
38#ifdef CONFIG_DEBUG_ICACHE_CHECK
39#define L1_ICACHE_START 0xffa10000
40#define L1_ICACHE_END 0xffa13fff
41void irq_panic(int reason, struct pt_regs *regs) __attribute__ ((l1_text));
42#endif
43
44/*
45 * irq_panic - calls panic with string setup
46 */
47asmlinkage void irq_panic(int reason, struct pt_regs *regs)
48{
49 int sig = 0;
50 siginfo_t info;
51
52#ifdef CONFIG_DEBUG_ICACHE_CHECK
53 unsigned int cmd, tag, ca, cache_hi, cache_lo, *pa;
54 unsigned short i, j, die;
55 unsigned int bad[10][6];
56
57 /* check entire cache for coherency
58 * Since printk is in cacheable memory,
59 * don't call it until you have checked everything
60 */
61
62 die = 0;
63 i = 0;
64
65 /* check icache */
66
67 for (ca = L1_ICACHE_START; ca <= L1_ICACHE_END && i < 10; ca += 32) {
68
69 /* Grab various address bits for the itest_cmd fields */
70 cmd = (((ca & 0x3000) << 4) | /* ca[13:12] for SBNK[1:0] */
71 ((ca & 0x0c00) << 16) | /* ca[11:10] for WAYSEL[1:0] */
72 ((ca & 0x3f8)) | /* ca[09:03] for SET[4:0] and DW[1:0] */
73 0); /* Access Tag, Read access */
74
75 SSYNC();
76 bfin_write_ITEST_COMMAND(cmd);
77 SSYNC();
78 tag = bfin_read_ITEST_DATA0();
79 SSYNC();
80
81 /* if tag is marked as valid, check it */
82 if (tag & 1) {
83 /* The icache is arranged in 4 groups of 64-bits */
84 for (j = 0; j < 32; j += 8) {
85 cmd = ((((ca + j) & 0x3000) << 4) | /* ca[13:12] for SBNK[1:0] */
86 (((ca + j) & 0x0c00) << 16) | /* ca[11:10] for WAYSEL[1:0] */
87 (((ca + j) & 0x3f8)) | /* ca[09:03] for SET[4:0] and DW[1:0] */
88 4); /* Access Data, Read access */
89
90 SSYNC();
91 bfin_write_ITEST_COMMAND(cmd);
92 SSYNC();
93
94 cache_hi = bfin_read_ITEST_DATA1();
95 cache_lo = bfin_read_ITEST_DATA0();
96
97 pa = ((unsigned int *)((tag & 0xffffcc00) |
98 ((ca + j) & ~(0xffffcc00))));
99
100 /*
101 * Debugging this, enable
102 *
103 * printk("addr: %08x %08x%08x | %08x%08x\n",
104 * ((unsigned int *)((tag & 0xffffcc00) | ((ca+j) & ~(0xffffcc00)))),
105 * cache_hi, cache_lo, *(pa+1), *pa);
106 */
107
108 if (cache_hi != *(pa + 1) || cache_lo != *pa) {
109 /* Since icache is not working, stay out of it, by not printing */
110 die = 1;
111 bad[i][0] = (ca + j);
112 bad[i][1] = cache_hi;
113 bad[i][2] = cache_lo;
114 bad[i][3] = ((tag & 0xffffcc00) |
115 ((ca + j) & ~(0xffffcc00)));
116 bad[i][4] = *(pa + 1);
117 bad[i][5] = *(pa);
118 i++;
119 }
120 }
121 }
122 }
123 if (die) {
124 printk(KERN_EMERG "icache coherency error\n");
125 for (j = 0; j <= i; j++) {
126 printk(KERN_EMERG
127 "cache address : %08x cache value : %08x%08x\n",
128 bad[j][0], bad[j][1], bad[j][2]);
129 printk(KERN_EMERG
130 "physical address: %08x SDRAM value : %08x%08x\n",
131 bad[j][3], bad[j][4], bad[j][5]);
132 }
133 panic("icache coherency error");
134 } else {
135 printk(KERN_EMERG "icache checked, and OK\n");
136 }
137#endif
138
139 printk(KERN_EMERG "\n");
140 printk(KERN_EMERG "Exception: IRQ 0x%x entered\n", reason);
141 printk(KERN_EMERG " code=[0x%08lx], stack frame=0x%08lx, "
142 " bad PC=0x%08lx\n",
143 (unsigned long)regs->seqstat,
144 (unsigned long)regs,
145 (unsigned long)regs->pc);
146 if (reason == 0x5) {
147 printk(KERN_EMERG "----------- HARDWARE ERROR -----------\n");
148
149 /* There is only need to check for Hardware Errors, since other
150 * EXCEPTIONS are handled in TRAPS.c (MH)
151 */
152 switch (regs->seqstat & SEQSTAT_HWERRCAUSE) {
153 case (SEQSTAT_HWERRCAUSE_SYSTEM_MMR): /* System MMR Error */
154 info.si_code = BUS_ADRALN;
155 sig = SIGBUS;
156 printk(KERN_EMERG HWC_x2);
157 break;
158 case (SEQSTAT_HWERRCAUSE_EXTERN_ADDR): /* External Memory Addressing Error */
159 info.si_code = BUS_ADRERR;
160 sig = SIGBUS;
161 printk(KERN_EMERG HWC_x3);
162 break;
163 case (SEQSTAT_HWERRCAUSE_PERF_FLOW): /* Performance Monitor Overflow */
164 printk(KERN_EMERG HWC_x12);
165 break;
166 case (SEQSTAT_HWERRCAUSE_RAISE_5): /* RAISE 5 instruction */
167 printk(KERN_EMERG HWC_x18);
168 break;
169 default: /* Reserved */
170 printk(KERN_EMERG HWC_default);
171 break;
172 }
173 }
174
175 regs->ipend = bfin_read_IPEND();
176 dump_bfin_regs(regs, (void *)regs->pc);
177 if (0 == (info.si_signo = sig) || 0 == user_mode(regs)) /* in kernelspace */
178 panic("Unhandled IRQ or exceptions!\n");
179 else { /* in userspace */
180 info.si_errno = 0;
181 info.si_addr = (void *)regs->pc;
182 force_sig_info(sig, &info, current);
183 }
184}
185
186#ifdef CONFIG_HARDWARE_PM
187/*
188 * call the handler of Performance overflow
189 */
190asmlinkage void pm_overflow(int irq, struct pt_regs *regs)
191{
192 pm_overflow_handler(irq, regs);
193}
194#endif
diff --git a/arch/blackfin/mach-common/lock.S b/arch/blackfin/mach-common/lock.S
new file mode 100644
index 000000000000..2cbb15b33925
--- /dev/null
+++ b/arch/blackfin/mach-common/lock.S
@@ -0,0 +1,204 @@
1/*
2 * File: arch/blackfin/mach-common/lock.S
3 * Based on:
4 * Author: LG Soft India
5 *
6 * Created: ?
7 * Description: kernel locks
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/linkage.h>
31#include <asm/cplb.h>
32#include <asm/blackfin.h>
33
34.text
35
36#ifdef CONFIG_BLKFIN_CACHE_LOCK
37
38/* When you come here, it is assumed that
39 * R0 - Which way to be locked
40 */
41
42ENTRY(_cache_grab_lock)
43
44 [--SP]=( R7:0,P5:0 );
45
46 P1.H = (IMEM_CONTROL >> 16);
47 P1.L = (IMEM_CONTROL & 0xFFFF);
48 P5.H = (ICPLB_ADDR0 >> 16);
49 P5.L = (ICPLB_ADDR0 & 0xFFFF);
50 P4.H = (ICPLB_DATA0 >> 16);
51 P4.L = (ICPLB_DATA0 & 0xFFFF);
52 R7 = R0;
53
54 /* If the code of interest already resides in the cache
55 * invalidate the entire cache itself.
56 * invalidate_entire_icache;
57 */
58
59 SP += -12;
60 [--SP] = RETS;
61 CALL _invalidate_entire_icache;
62 RETS = [SP++];
63 SP += 12;
64
65 /* Disable the Interrupts*/
66
67 CLI R3;
68
69.LLOCK_WAY:
70
71 /* Way0 - 0xFFA133E0
72 * Way1 - 0xFFA137E0
73 * Way2 - 0xFFA13BE0 Total Way Size = 4K
74 * Way3 - 0xFFA13FE0
75 */
76
77 /* Procedure Ex. -Set the locks for other ways by setting ILOC[3:1]
78 * Only Way0 of the instruction cache can now be
79 * replaced by a new code
80 */
81
82 R5 = R7;
83 CC = BITTST(R7,0);
84 IF CC JUMP .LCLEAR1;
85 R7 = 0;
86 BITSET(R7,0);
87 JUMP .LDONE1;
88
89.LCLEAR1:
90 R7 = 0;
91 BITCLR(R7,0);
92.LDONE1: R4 = R7 << 3;
93 R7 = [P1];
94 R7 = R7 | R4;
95 SSYNC; /* SSYNC required writing to IMEM_CONTROL. */
96 .align 8;
97 [P1] = R7;
98 SSYNC;
99
100 R7 = R5;
101 CC = BITTST(R7,1);
102 IF CC JUMP .LCLEAR2;
103 R7 = 0;
104 BITSET(R7,1);
105 JUMP .LDONE2;
106
107.LCLEAR2:
108 R7 = 0;
109 BITCLR(R7,1);
110.LDONE2: R4 = R7 << 3;
111 R7 = [P1];
112 R7 = R7 | R4;
113 SSYNC; /* SSYNC required writing to IMEM_CONTROL. */
114 .align 8;
115 [P1] = R7;
116 SSYNC;
117
118 R7 = R5;
119 CC = BITTST(R7,2);
120 IF CC JUMP .LCLEAR3;
121 R7 = 0;
122 BITSET(R7,2);
123 JUMP .LDONE3;
124.LCLEAR3:
125 R7 = 0;
126 BITCLR(R7,2);
127.LDONE3: R4 = R7 << 3;
128 R7 = [P1];
129 R7 = R7 | R4;
130 SSYNC; /* SSYNC required writing to IMEM_CONTROL. */
131 .align 8;
132 [P1] = R7;
133 SSYNC;
134
135
136 R7 = R5;
137 CC = BITTST(R7,3);
138 IF CC JUMP .LCLEAR4;
139 R7 = 0;
140 BITSET(R7,3);
141 JUMP .LDONE4;
142.LCLEAR4:
143 R7 = 0;
144 BITCLR(R7,3);
145.LDONE4: R4 = R7 << 3;
146 R7 = [P1];
147 R7 = R7 | R4;
148 SSYNC; /* SSYNC required writing to IMEM_CONTROL. */
149 .align 8;
150 [P1] = R7;
151 SSYNC;
152
153 STI R3;
154
155 ( R7:0,P5:0 ) = [SP++];
156
157 RTS;
158
159/* After the execution of critical code, the code is now locked into
160 * the cache way. Now we need to set ILOC.
161 *
162 * R0 - Which way to be locked
163 */
164
165ENTRY(_cache_lock)
166
167 [--SP]=( R7:0,P5:0 );
168
169 P1.H = (IMEM_CONTROL >> 16);
170 P1.L = (IMEM_CONTROL & 0xFFFF);
171
172 /* Disable the Interrupts*/
173 CLI R3;
174
175 R7 = [P1];
176 R2 = 0xFFFFFF87 (X);
177 R7 = R7 & R2;
178 R0 = R0 << 3;
179 R7 = R0 | R7;
180 SSYNC; /* SSYNC required writing to IMEM_CONTROL. */
181 .align 8;
182 [P1] = R7;
183 SSYNC;
184 /* Renable the Interrupts */
185 STI R3;
186
187 ( R7:0,P5:0 ) = [SP++];
188 RTS;
189
190#endif /* BLKFIN_CACHE_LOCK */
191
192/* Return the ILOC bits of IMEM_CONTROL
193 */
194
195ENTRY(_read_iloc)
196
197 P1.H = (IMEM_CONTROL >> 16);
198 P1.L = (IMEM_CONTROL & 0xFFFF);
199 R1 = 0xF;
200 R0 = [P1];
201 R0 = R0 >> 3;
202 R0 = R0 & R1;
203
204 RTS;
diff --git a/arch/blackfin/mach-common/pm.c b/arch/blackfin/mach-common/pm.c
new file mode 100644
index 000000000000..deb27272c658
--- /dev/null
+++ b/arch/blackfin/mach-common/pm.c
@@ -0,0 +1,181 @@
1/*
2 * File: arch/blackfin/mach-common/pm.c
3 * Based on: arm/mach-omap/pm.c
4 * Author: Cliff Brake <cbrake@accelent.com> Copyright (c) 2001
5 *
6 * Created: 2001
7 * Description: Power management for the bfin
8 *
9 * Modified: Nicolas Pitre - PXA250 support
10 * Copyright (c) 2002 Monta Vista Software, Inc.
11 * David Singleton - OMAP1510
12 * Copyright (c) 2002 Monta Vista Software, Inc.
13 * Dirk Behme <dirk.behme@de.bosch.com> - OMAP1510/1610
14 * Copyright 2004
15 * Copyright 2004-2006 Analog Devices Inc.
16 *
17 * Bugs: Enter bugs at http://blackfin.uclinux.org/
18 *
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, see the file COPYING, or write
31 * to the Free Software Foundation, Inc.,
32 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33 */
34
35#include <linux/pm.h>
36#include <linux/sched.h>
37#include <linux/proc_fs.h>
38
39#include <asm/io.h>
40#include <asm/dpmc.h>
41#include <asm/irq.h>
42
43
44#ifdef CONFIG_PM_WAKEUP_GPIO_POLAR_H
45#define WAKEUP_TYPE PM_WAKE_HIGH
46#endif
47
48#ifdef CONFIG_PM_WAKEUP_GPIO_POLAR_L
49#define WAKEUP_TYPE PM_WAKE_LOW
50#endif
51
52#ifdef CONFIG_PM_WAKEUP_GPIO_POLAR_EDGE_F
53#define WAKEUP_TYPE PM_WAKE_FALLING
54#endif
55
56#ifdef CONFIG_PM_WAKEUP_GPIO_POLAR_EDGE_R
57#define WAKEUP_TYPE PM_WAKE_RISING
58#endif
59
60#ifdef CONFIG_PM_WAKEUP_GPIO_POLAR_EDGE_B
61#define WAKEUP_TYPE PM_WAKE_BOTH_EDGES
62#endif
63
64void bfin_pm_suspend_standby_enter(void)
65{
66#ifdef CONFIG_PM_WAKEUP_BY_GPIO
67 gpio_pm_wakeup_request(CONFIG_PM_WAKEUP_GPIO_NUMBER, WAKEUP_TYPE);
68#endif
69
70#if defined(CONFIG_PM_WAKEUP_BY_GPIO) || defined(CONFIG_PM_WAKEUP_GPIO_API)
71 {
72 u32 flags;
73
74 local_irq_save(flags);
75
76 sleep_deeper(gpio_pm_setup()); /*Goto Sleep*/
77
78 gpio_pm_restore();
79
80 bfin_write_SIC_IWR(IWR_ENABLE_ALL);
81
82 local_irq_restore(flags);
83 }
84#endif
85
86#if defined(CONFIG_PM_WAKEUP_GPIO_BY_SIC_IWR)
87 sleep_deeper(CONFIG_PM_WAKEUP_SIC_IWR);
88 bfin_write_SIC_IWR(IWR_ENABLE_ALL);
89#endif /* CONFIG_PM_WAKEUP_GPIO_BY_SIC_IWR */
90}
91
92
93/*
94 * bfin_pm_prepare - Do preliminary suspend work.
95 * @state: suspend state we're entering.
96 *
97 */
98static int bfin_pm_prepare(suspend_state_t state)
99{
100 int error = 0;
101
102 switch (state) {
103 case PM_SUSPEND_STANDBY:
104 break;
105 case PM_SUSPEND_MEM:
106 return -ENOTSUPP;
107
108 case PM_SUSPEND_DISK:
109 return -ENOTSUPP;
110
111 default:
112 return -EINVAL;
113 }
114
115 return error;
116}
117
118/*
119 * bfin_pm_enter - Actually enter a sleep state.
120 * @state: State we're entering.
121 *
122 */
123static int bfin_pm_enter(suspend_state_t state)
124{
125 switch (state) {
126 case PM_SUSPEND_STANDBY:
127 bfin_pm_suspend_standby_enter();
128 break;
129 case PM_SUSPEND_MEM:
130 return -ENOTSUPP;
131
132 case PM_SUSPEND_DISK:
133 return -ENOTSUPP;
134
135 default:
136 return -EINVAL;
137 }
138
139 return 0;
140}
141
142/*
143 * bfin_pm_finish - Finish up suspend sequence.
144 * @state: State we're coming out of.
145 *
146 * This is called after we wake back up (or if entering the sleep state
147 * failed).
148 */
149static int bfin_pm_finish(suspend_state_t state)
150{
151 switch (state) {
152 case PM_SUSPEND_STANDBY:
153 break;
154
155 case PM_SUSPEND_MEM:
156 return -ENOTSUPP;
157
158 case PM_SUSPEND_DISK:
159 return -ENOTSUPP;
160
161 default:
162 return -EINVAL;
163 }
164
165 return 0;
166}
167
168struct pm_ops bfin_pm_ops = {
169 .pm_disk_mode = PM_DISK_PLATFORM,
170 .prepare = bfin_pm_prepare,
171 .enter = bfin_pm_enter,
172 .finish = bfin_pm_finish,
173};
174
175static int __init bfin_pm_init(void)
176{
177 pm_set_ops(&bfin_pm_ops);
178 return 0;
179}
180
181__initcall(bfin_pm_init);
diff --git a/arch/blackfin/mm/Makefile b/arch/blackfin/mm/Makefile
new file mode 100644
index 000000000000..2a7202ce01fd
--- /dev/null
+++ b/arch/blackfin/mm/Makefile
@@ -0,0 +1,5 @@
1#
2# arch/blackfin/mm/Makefile
3#
4
5obj-y := blackfin_sram.o init.o
diff --git a/arch/blackfin/mm/blackfin_sram.c b/arch/blackfin/mm/blackfin_sram.c
new file mode 100644
index 000000000000..dd0c6501c424
--- /dev/null
+++ b/arch/blackfin/mm/blackfin_sram.c
@@ -0,0 +1,540 @@
1/*
2 * File: arch/blackfin/mm/blackfin_sram.c
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description: SRAM driver for Blackfin ADSP-BF5xx
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/autoconf.h>
31#include <linux/module.h>
32#include <linux/kernel.h>
33#include <linux/types.h>
34#include <linux/miscdevice.h>
35#include <linux/ioport.h>
36#include <linux/fcntl.h>
37#include <linux/init.h>
38#include <linux/poll.h>
39#include <linux/proc_fs.h>
40#include <linux/spinlock.h>
41#include <linux/rtc.h>
42#include <asm/blackfin.h>
43#include "blackfin_sram.h"
44
45spinlock_t l1sram_lock, l1_data_sram_lock, l1_inst_sram_lock;
46
47#if CONFIG_L1_MAX_PIECE < 16
48#undef CONFIG_L1_MAX_PIECE
49#define CONFIG_L1_MAX_PIECE 16
50#endif
51
52#if CONFIG_L1_MAX_PIECE > 1024
53#undef CONFIG_L1_MAX_PIECE
54#define CONFIG_L1_MAX_PIECE 1024
55#endif
56
57#define SRAM_SLT_NULL 0
58#define SRAM_SLT_FREE 1
59#define SRAM_SLT_ALLOCATED 2
60
61/* the data structure for L1 scratchpad and DATA SRAM */
62struct l1_sram_piece {
63 void *paddr;
64 int size;
65 int flag;
66};
67
68static struct l1_sram_piece l1_ssram[CONFIG_L1_MAX_PIECE];
69
70#if L1_DATA_A_LENGTH != 0
71static struct l1_sram_piece l1_data_A_sram[CONFIG_L1_MAX_PIECE];
72#endif
73
74#if L1_DATA_B_LENGTH != 0
75static struct l1_sram_piece l1_data_B_sram[CONFIG_L1_MAX_PIECE];
76#endif
77
78#if L1_CODE_LENGTH != 0
79static struct l1_sram_piece l1_inst_sram[CONFIG_L1_MAX_PIECE];
80#endif
81
82/* L1 Scratchpad SRAM initialization function */
83void l1sram_init(void)
84{
85 printk(KERN_INFO "Blackfin Scratchpad data SRAM: %d KB\n",
86 L1_SCRATCH_LENGTH >> 10);
87
88 memset(&l1_ssram, 0x00, sizeof(l1_ssram));
89 l1_ssram[0].paddr = (void*)L1_SCRATCH_START;
90 l1_ssram[0].size = L1_SCRATCH_LENGTH;
91 l1_ssram[0].flag = SRAM_SLT_FREE;
92
93 /* mutex initialize */
94 spin_lock_init(&l1sram_lock);
95}
96
97void l1_data_sram_init(void)
98{
99#if L1_DATA_A_LENGTH != 0
100 printk(KERN_INFO "Blackfin DATA_A SRAM: %d KB\n",
101 L1_DATA_A_LENGTH >> 10);
102
103 memset(&l1_data_A_sram, 0x00, sizeof(l1_data_A_sram));
104 l1_data_A_sram[0].paddr = (void*)L1_DATA_A_START +
105 (_ebss_l1 - _sdata_l1);
106 l1_data_A_sram[0].size = L1_DATA_A_LENGTH - (_ebss_l1 - _sdata_l1);
107 l1_data_A_sram[0].flag = SRAM_SLT_FREE;
108#endif
109#if L1_DATA_B_LENGTH != 0
110 printk(KERN_INFO "Blackfin DATA_B SRAM: %d KB\n",
111 L1_DATA_B_LENGTH >> 10);
112
113 memset(&l1_data_B_sram, 0x00, sizeof(l1_data_B_sram));
114 l1_data_B_sram[0].paddr = (void*)L1_DATA_B_START;
115 l1_data_B_sram[0].size = L1_DATA_B_LENGTH;
116 l1_data_B_sram[0].flag = SRAM_SLT_FREE;
117#endif
118
119 /* mutex initialize */
120 spin_lock_init(&l1_data_sram_lock);
121}
122
123void l1_inst_sram_init(void)
124{
125#if L1_CODE_LENGTH != 0
126 printk(KERN_INFO "Blackfin Instruction SRAM: %d KB\n",
127 L1_CODE_LENGTH >> 10);
128
129 memset(&l1_inst_sram, 0x00, sizeof(l1_inst_sram));
130 l1_inst_sram[0].paddr = (void*)L1_CODE_START + (_etext_l1 - _stext_l1);
131 l1_inst_sram[0].size = L1_CODE_LENGTH - (_etext_l1 - _stext_l1);
132 l1_inst_sram[0].flag = SRAM_SLT_FREE;
133#endif
134
135 /* mutex initialize */
136 spin_lock_init(&l1_inst_sram_lock);
137}
138
139/* L1 memory allocate function */
140static void *_l1_sram_alloc(size_t size, struct l1_sram_piece *pfree, int count)
141{
142 int i, index = 0;
143 void *addr = NULL;
144
145 if (size <= 0)
146 return NULL;
147
148 /* Align the size */
149 size = (size + 3) & ~3;
150
151 /* not use the good method to match the best slot !!! */
152 /* search an available memeory slot */
153 for (i = 0; i < count; i++) {
154 if ((pfree[i].flag == SRAM_SLT_FREE)
155 && (pfree[i].size >= size)) {
156 addr = pfree[i].paddr;
157 pfree[i].flag = SRAM_SLT_ALLOCATED;
158 index = i;
159 break;
160 }
161 }
162 if (i >= count)
163 return NULL;
164
165 /* updated the NULL memeory slot !!! */
166 if (pfree[i].size > size) {
167 for (i = 0; i < count; i++) {
168 if (pfree[i].flag == SRAM_SLT_NULL) {
169 pfree[i].flag = SRAM_SLT_FREE;
170 pfree[i].paddr = addr + size;
171 pfree[i].size = pfree[index].size - size;
172 pfree[index].size = size;
173 break;
174 }
175 }
176 }
177
178 return addr;
179}
180
181/* Allocate the largest available block. */
182static void *_l1_sram_alloc_max(struct l1_sram_piece *pfree, int count,
183 unsigned long *psize)
184{
185 unsigned long best = 0;
186 int i, index = -1;
187 void *addr = NULL;
188
189 /* search an available memeory slot */
190 for (i = 0; i < count; i++) {
191 if (pfree[i].flag == SRAM_SLT_FREE && pfree[i].size > best) {
192 addr = pfree[i].paddr;
193 index = i;
194 best = pfree[i].size;
195 }
196 }
197 if (index < 0)
198 return NULL;
199 *psize = best;
200
201 pfree[index].flag = SRAM_SLT_ALLOCATED;
202 return addr;
203}
204
205/* L1 memory free function */
206static int _l1_sram_free(const void *addr,
207 struct l1_sram_piece *pfree, int count)
208{
209 int i, index = 0;
210
211 /* search the relevant memory slot */
212 for (i = 0; i < count; i++) {
213 if (pfree[i].paddr == addr) {
214 if (pfree[i].flag != SRAM_SLT_ALLOCATED) {
215 /* error log */
216 return -1;
217 }
218 index = i;
219 break;
220 }
221 }
222 if (i >= count)
223 return -1;
224
225 pfree[index].flag = SRAM_SLT_FREE;
226
227 /* link the next address slot */
228 for (i = 0; i < count; i++) {
229 if (((pfree[index].paddr + pfree[index].size) == pfree[i].paddr)
230 && (pfree[i].flag == SRAM_SLT_FREE)) {
231 pfree[i].flag = SRAM_SLT_NULL;
232 pfree[index].size += pfree[i].size;
233 pfree[index].flag = SRAM_SLT_FREE;
234 break;
235 }
236 }
237
238 /* link the last address slot */
239 for (i = 0; i < count; i++) {
240 if (((pfree[i].paddr + pfree[i].size) == pfree[index].paddr) &&
241 (pfree[i].flag == SRAM_SLT_FREE)) {
242 pfree[index].flag = SRAM_SLT_NULL;
243 pfree[i].size += pfree[index].size;
244 break;
245 }
246 }
247
248 return 0;
249}
250
251int sram_free(const void *addr)
252{
253 if (0) {}
254#if L1_CODE_LENGTH != 0
255 else if (addr >= (void *)L1_CODE_START
256 && addr < (void *)(L1_CODE_START + L1_CODE_LENGTH))
257 return l1_inst_sram_free(addr);
258#endif
259#if L1_DATA_A_LENGTH != 0
260 else if (addr >= (void *)L1_DATA_A_START
261 && addr < (void *)(L1_DATA_A_START + L1_DATA_A_LENGTH))
262 return l1_data_A_sram_free(addr);
263#endif
264#if L1_DATA_B_LENGTH != 0
265 else if (addr >= (void *)L1_DATA_B_START
266 && addr < (void *)(L1_DATA_B_START + L1_DATA_B_LENGTH))
267 return l1_data_B_sram_free(addr);
268#endif
269 else
270 return -1;
271}
272EXPORT_SYMBOL(sram_free);
273
274void *l1_data_A_sram_alloc(size_t size)
275{
276 unsigned flags;
277 void *addr = NULL;
278
279 /* add mutex operation */
280 spin_lock_irqsave(&l1_data_sram_lock, flags);
281
282#if L1_DATA_A_LENGTH != 0
283 addr = _l1_sram_alloc(size, l1_data_A_sram, ARRAY_SIZE(l1_data_A_sram));
284#endif
285
286 /* add mutex operation */
287 spin_unlock_irqrestore(&l1_data_sram_lock, flags);
288
289 pr_debug("Allocated address in l1_data_A_sram_alloc is 0x%lx+0x%lx\n",
290 (long unsigned int)addr, size);
291
292 return addr;
293}
294EXPORT_SYMBOL(l1_data_A_sram_alloc);
295
296int l1_data_A_sram_free(const void *addr)
297{
298 unsigned flags;
299 int ret;
300
301 /* add mutex operation */
302 spin_lock_irqsave(&l1_data_sram_lock, flags);
303
304#if L1_DATA_A_LENGTH != 0
305 ret = _l1_sram_free(addr,
306 l1_data_A_sram, ARRAY_SIZE(l1_data_A_sram));
307#else
308 ret = -1;
309#endif
310
311 /* add mutex operation */
312 spin_unlock_irqrestore(&l1_data_sram_lock, flags);
313
314 return ret;
315}
316EXPORT_SYMBOL(l1_data_A_sram_free);
317
318void *l1_data_B_sram_alloc(size_t size)
319{
320#if L1_DATA_B_LENGTH != 0
321 unsigned flags;
322 void *addr;
323
324 /* add mutex operation */
325 spin_lock_irqsave(&l1_data_sram_lock, flags);
326
327 addr = _l1_sram_alloc(size, l1_data_B_sram, ARRAY_SIZE(l1_data_B_sram));
328
329 /* add mutex operation */
330 spin_unlock_irqrestore(&l1_data_sram_lock, flags);
331
332 pr_debug("Allocated address in l1_data_B_sram_alloc is 0x%lx+0x%lx\n",
333 (long unsigned int)addr, size);
334
335 return addr;
336#else
337 return NULL;
338#endif
339}
340EXPORT_SYMBOL(l1_data_B_sram_alloc);
341
342int l1_data_B_sram_free(const void *addr)
343{
344#if L1_DATA_B_LENGTH != 0
345 unsigned flags;
346 int ret;
347
348 /* add mutex operation */
349 spin_lock_irqsave(&l1_data_sram_lock, flags);
350
351 ret = _l1_sram_free(addr, l1_data_B_sram, ARRAY_SIZE(l1_data_B_sram));
352
353 /* add mutex operation */
354 spin_unlock_irqrestore(&l1_data_sram_lock, flags);
355
356 return ret;
357#else
358 return -1;
359#endif
360}
361EXPORT_SYMBOL(l1_data_B_sram_free);
362
363void *l1_data_sram_alloc(size_t size)
364{
365 void *addr = l1_data_A_sram_alloc(size);
366
367 if (!addr)
368 addr = l1_data_B_sram_alloc(size);
369
370 return addr;
371}
372EXPORT_SYMBOL(l1_data_sram_alloc);
373
374void *l1_data_sram_zalloc(size_t size)
375{
376 void *addr = l1_data_sram_alloc(size);
377
378 if (addr)
379 memset(addr, 0x00, size);
380
381 return addr;
382}
383EXPORT_SYMBOL(l1_data_sram_zalloc);
384
385int l1_data_sram_free(const void *addr)
386{
387 int ret;
388 ret = l1_data_A_sram_free(addr);
389 if (ret == -1)
390 ret = l1_data_B_sram_free(addr);
391 return ret;
392}
393EXPORT_SYMBOL(l1_data_sram_free);
394
395void *l1_inst_sram_alloc(size_t size)
396{
397#if L1_DATA_A_LENGTH != 0
398 unsigned flags;
399 void *addr;
400
401 /* add mutex operation */
402 spin_lock_irqsave(&l1_inst_sram_lock, flags);
403
404 addr = _l1_sram_alloc(size, l1_inst_sram, ARRAY_SIZE(l1_inst_sram));
405
406 /* add mutex operation */
407 spin_unlock_irqrestore(&l1_inst_sram_lock, flags);
408
409 pr_debug("Allocated address in l1_inst_sram_alloc is 0x%lx+0x%lx\n",
410 (long unsigned int)addr, size);
411
412 return addr;
413#else
414 return NULL;
415#endif
416}
417EXPORT_SYMBOL(l1_inst_sram_alloc);
418
419int l1_inst_sram_free(const void *addr)
420{
421#if L1_CODE_LENGTH != 0
422 unsigned flags;
423 int ret;
424
425 /* add mutex operation */
426 spin_lock_irqsave(&l1_inst_sram_lock, flags);
427
428 ret = _l1_sram_free(addr, l1_inst_sram, ARRAY_SIZE(l1_inst_sram));
429
430 /* add mutex operation */
431 spin_unlock_irqrestore(&l1_inst_sram_lock, flags);
432
433 return ret;
434#else
435 return -1;
436#endif
437}
438EXPORT_SYMBOL(l1_inst_sram_free);
439
440/* L1 Scratchpad memory allocate function */
441void *l1sram_alloc(size_t size)
442{
443 unsigned flags;
444 void *addr;
445
446 /* add mutex operation */
447 spin_lock_irqsave(&l1sram_lock, flags);
448
449 addr = _l1_sram_alloc(size, l1_ssram, ARRAY_SIZE(l1_ssram));
450
451 /* add mutex operation */
452 spin_unlock_irqrestore(&l1sram_lock, flags);
453
454 return addr;
455}
456
457/* L1 Scratchpad memory allocate function */
458void *l1sram_alloc_max(size_t *psize)
459{
460 unsigned flags;
461 void *addr;
462
463 /* add mutex operation */
464 spin_lock_irqsave(&l1sram_lock, flags);
465
466 addr = _l1_sram_alloc_max(l1_ssram, ARRAY_SIZE(l1_ssram), psize);
467
468 /* add mutex operation */
469 spin_unlock_irqrestore(&l1sram_lock, flags);
470
471 return addr;
472}
473
474/* L1 Scratchpad memory free function */
475int l1sram_free(const void *addr)
476{
477 unsigned flags;
478 int ret;
479
480 /* add mutex operation */
481 spin_lock_irqsave(&l1sram_lock, flags);
482
483 ret = _l1_sram_free(addr, l1_ssram, ARRAY_SIZE(l1_ssram));
484
485 /* add mutex operation */
486 spin_unlock_irqrestore(&l1sram_lock, flags);
487
488 return ret;
489}
490
491int sram_free_with_lsl(const void *addr)
492{
493 struct sram_list_struct *lsl, **tmp;
494 struct mm_struct *mm = current->mm;
495
496 for (tmp = &mm->context.sram_list; *tmp; tmp = &(*tmp)->next)
497 if ((*tmp)->addr == addr)
498 goto found;
499 return -1;
500found:
501 lsl = *tmp;
502 sram_free(addr);
503 *tmp = lsl->next;
504 kfree(lsl);
505
506 return 0;
507}
508EXPORT_SYMBOL(sram_free_with_lsl);
509
510void *sram_alloc_with_lsl(size_t size, unsigned long flags)
511{
512 void *addr = NULL;
513 struct sram_list_struct *lsl = NULL;
514 struct mm_struct *mm = current->mm;
515
516 lsl = kmalloc(sizeof(struct sram_list_struct), GFP_KERNEL);
517 if (!lsl)
518 return NULL;
519 memset(lsl, 0, sizeof(*lsl));
520
521 if (flags & L1_INST_SRAM)
522 addr = l1_inst_sram_alloc(size);
523
524 if (addr == NULL && (flags & L1_DATA_A_SRAM))
525 addr = l1_data_A_sram_alloc(size);
526
527 if (addr == NULL && (flags & L1_DATA_B_SRAM))
528 addr = l1_data_B_sram_alloc(size);
529
530 if (addr == NULL) {
531 kfree(lsl);
532 return NULL;
533 }
534 lsl->addr = addr;
535 lsl->length = size;
536 lsl->next = mm->context.sram_list;
537 mm->context.sram_list = lsl;
538 return addr;
539}
540EXPORT_SYMBOL(sram_alloc_with_lsl);
diff --git a/arch/blackfin/mm/blackfin_sram.h b/arch/blackfin/mm/blackfin_sram.h
new file mode 100644
index 000000000000..0fb73b78dd60
--- /dev/null
+++ b/arch/blackfin/mm/blackfin_sram.h
@@ -0,0 +1,38 @@
1/*
2 * File: arch/blackfin/mm/blackfin_sram.h
3 * Based on: arch/blackfin/mm/blackfin_sram.c
4 * Author: Mike Frysinger
5 *
6 * Created: Aug 2006
7 * Description: Local prototypes meant for internal use only
8 *
9 * Modified:
10 * Copyright 2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#ifndef __BLACKFIN_SRAM_H__
31#define __BLACKFIN_SRAM_H__
32
33extern void l1sram_init(void);
34extern void l1_inst_sram_init(void);
35extern void l1_data_sram_init(void);
36extern void *l1sram_alloc(size_t);
37
38#endif
diff --git a/arch/blackfin/mm/init.c b/arch/blackfin/mm/init.c
new file mode 100644
index 000000000000..73f72abed432
--- /dev/null
+++ b/arch/blackfin/mm/init.c
@@ -0,0 +1,208 @@
1/*
2 * File: arch/blackfin/mm/init.c
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/swap.h>
31#include <linux/bootmem.h>
32#include <asm/bfin-global.h>
33#include <asm/uaccess.h>
34#include <asm/l1layout.h>
35#include "blackfin_sram.h"
36
37/*
38 * BAD_PAGE is the page that is used for page faults when linux
39 * is out-of-memory. Older versions of linux just did a
40 * do_exit(), but using this instead means there is less risk
41 * for a process dying in kernel mode, possibly leaving a inode
42 * unused etc..
43 *
44 * BAD_PAGETABLE is the accompanying page-table: it is initialized
45 * to point to BAD_PAGE entries.
46 *
47 * ZERO_PAGE is a special page that is used for zero-initialized
48 * data and COW.
49 */
50static unsigned long empty_bad_page_table;
51
52static unsigned long empty_bad_page;
53
54unsigned long empty_zero_page;
55
56void show_mem(void)
57{
58 unsigned long i;
59 int free = 0, total = 0, reserved = 0, shared = 0;
60
61 int cached = 0;
62 printk(KERN_INFO "Mem-info:\n");
63 show_free_areas();
64 i = max_mapnr;
65 while (i-- > 0) {
66 total++;
67 if (PageReserved(mem_map + i))
68 reserved++;
69 else if (PageSwapCache(mem_map + i))
70 cached++;
71 else if (!page_count(mem_map + i))
72 free++;
73 else
74 shared += page_count(mem_map + i) - 1;
75 }
76 printk(KERN_INFO "%d pages of RAM\n", total);
77 printk(KERN_INFO "%d free pages\n", free);
78 printk(KERN_INFO "%d reserved pages\n", reserved);
79 printk(KERN_INFO "%d pages shared\n", shared);
80 printk(KERN_INFO "%d pages swap cached\n", cached);
81}
82
83/*
84 * paging_init() continues the virtual memory environment setup which
85 * was begun by the code in arch/head.S.
86 * The parameters are pointers to where to stick the starting and ending
87 * addresses of available kernel virtual memory.
88 */
89void paging_init(void)
90{
91 /*
92 * make sure start_mem is page aligned, otherwise bootmem and
93 * page_alloc get different views og the world
94 */
95 unsigned long end_mem = memory_end & PAGE_MASK;
96
97 pr_debug("start_mem is %#lx virtual_end is %#lx\n", PAGE_ALIGN(memory_start), end_mem);
98
99 /*
100 * initialize the bad page table and bad page to point
101 * to a couple of allocated pages
102 */
103 empty_bad_page_table = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
104 empty_bad_page = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
105 empty_zero_page = (unsigned long)alloc_bootmem_pages(PAGE_SIZE);
106 memset((void *)empty_zero_page, 0, PAGE_SIZE);
107
108 /*
109 * Set up SFC/DFC registers (user data space)
110 */
111 set_fs(KERNEL_DS);
112
113 pr_debug("free_area_init -> start_mem is %#lx virtual_end is %#lx\n",
114 PAGE_ALIGN(memory_start), end_mem);
115
116 {
117 unsigned long zones_size[MAX_NR_ZONES] = { 0, };
118
119 zones_size[ZONE_NORMAL] = (end_mem - PAGE_OFFSET) >> PAGE_SHIFT;
120#ifdef CONFIG_HIGHMEM
121 zones_size[ZONE_HIGHMEM] = 0;
122#endif
123 free_area_init(zones_size);
124 }
125}
126
127void mem_init(void)
128{
129 unsigned int codek = 0, datak = 0, initk = 0;
130 unsigned long tmp;
131 unsigned int len = _ramend - _rambase;
132 unsigned long start_mem = memory_start;
133 unsigned long end_mem = memory_end;
134
135 end_mem &= PAGE_MASK;
136 high_memory = (void *)end_mem;
137
138 start_mem = PAGE_ALIGN(start_mem);
139 max_mapnr = num_physpages = MAP_NR(high_memory);
140 printk(KERN_INFO "Physical pages: %lx\n", num_physpages);
141
142 /* This will put all memory onto the freelists. */
143 totalram_pages = free_all_bootmem();
144
145 codek = (_etext - _stext) >> 10;
146 datak = (__bss_stop - __bss_start) >> 10;
147 initk = (__init_end - __init_begin) >> 10;
148
149 tmp = nr_free_pages() << PAGE_SHIFT;
150 printk(KERN_INFO
151 "Memory available: %luk/%uk RAM, (%uk init code, %uk kernel code, %uk data, %uk dma)\n",
152 tmp >> 10, len >> 10, initk, codek, datak, DMA_UNCACHED_REGION >> 10);
153
154 /* Initialize the blackfin L1 Memory. */
155 l1sram_init();
156 l1_data_sram_init();
157 l1_inst_sram_init();
158
159 /* Allocate this once; never free it. We assume this gives us a
160 pointer to the start of L1 scratchpad memory; panic if it
161 doesn't. */
162 tmp = (unsigned long)l1sram_alloc(sizeof(struct l1_scratch_task_info));
163 if (tmp != (unsigned long)L1_SCRATCH_TASK_INFO) {
164 printk(KERN_EMERG "mem_init(): Did not get the right address from l1sram_alloc: %08lx != %08lx\n",
165 tmp, (unsigned long)L1_SCRATCH_TASK_INFO);
166 panic("No L1, time to give up\n");
167 }
168}
169
170#ifdef CONFIG_BLK_DEV_INITRD
171void free_initrd_mem(unsigned long start, unsigned long end)
172{
173 int pages = 0;
174 for (; start < end; start += PAGE_SIZE) {
175 ClearPageReserved(virt_to_page(start));
176 init_page_count(virt_to_page(start));
177 free_page(start);
178 totalram_pages++;
179 pages++;
180 }
181 printk(KERN_NOTICE "Freeing initrd memory: %dk freed\n", pages);
182}
183#endif
184
185void free_initmem(void)
186{
187#ifdef CONFIG_RAMKERNEL
188 unsigned long addr;
189/*
190 * the following code should be cool even if these sections
191 * are not page aligned.
192 */
193 addr = PAGE_ALIGN((unsigned long)(__init_begin));
194 /* next to check that the page we free is not a partial page */
195 for (; addr + PAGE_SIZE < (unsigned long)(__init_end);
196 addr += PAGE_SIZE) {
197 ClearPageReserved(virt_to_page(addr));
198 init_page_count(virt_to_page(addr));
199 free_page(addr);
200 totalram_pages++;
201 }
202 printk(KERN_NOTICE
203 "Freeing unused kernel memory: %ldk freed (0x%x - 0x%x)\n",
204 (addr - PAGE_ALIGN((long)__init_begin)) >> 10,
205 (int)(PAGE_ALIGN((unsigned long)(__init_begin))),
206 (int)(addr - PAGE_SIZE));
207#endif
208}
diff --git a/arch/blackfin/oprofile/Kconfig b/arch/blackfin/oprofile/Kconfig
new file mode 100644
index 000000000000..0a2fd999c941
--- /dev/null
+++ b/arch/blackfin/oprofile/Kconfig
@@ -0,0 +1,29 @@
1menu "Profiling support"
2depends on EXPERIMENTAL
3
4config PROFILING
5 bool "Profiling support (EXPERIMENTAL)"
6 help
7 Say Y here to enable the extended profiling support mechanisms used
8 by profilers such as OProfile.
9
10config OPROFILE
11 tristate "OProfile system profiling (EXPERIMENTAL)"
12 depends on PROFILING
13 help
14 OProfile is a profiling system capable of profiling the
15 whole system, include the kernel, kernel modules, libraries,
16 and applications.
17
18 If unsure, say N.
19
20config HARDWARE_PM
21 tristate "Hardware Performance Monitor Profiling"
22 depends on PROFILING
23 help
24 take use of hardware performance monitor to profiling the kernel
25 and application.
26
27 If unsure, say N.
28
29endmenu
diff --git a/arch/blackfin/oprofile/Makefile b/arch/blackfin/oprofile/Makefile
new file mode 100644
index 000000000000..634e300d67e2
--- /dev/null
+++ b/arch/blackfin/oprofile/Makefile
@@ -0,0 +1,14 @@
1#
2# arch/blackfin/oprofile/Makefile
3#
4
5obj-$(CONFIG_OPROFILE) += oprofile.o
6
7DRIVER_OBJS := $(addprefix ../../../drivers/oprofile/, \
8 oprof.o cpu_buffer.o buffer_sync.o \
9 event_buffer.o oprofile_files.o \
10 oprofilefs.o oprofile_stats.o \
11 timer_int.o )
12
13oprofile-y := $(DRIVER_OBJS) common.o
14oprofile-$(CONFIG_HARDWARE_PM) += op_model_bf533.o
diff --git a/arch/blackfin/oprofile/common.c b/arch/blackfin/oprofile/common.c
new file mode 100644
index 000000000000..009a1700c854
--- /dev/null
+++ b/arch/blackfin/oprofile/common.c
@@ -0,0 +1,168 @@
1/*
2 * File: arch/blackfin/oprofile/common.c
3 * Based on: arch/alpha/oprofile/common.c
4 * Author: Anton Blanchard <anton@au.ibm.com>
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright (C) 2004 Anton Blanchard <anton@au.ibm.com>, IBM
11 * Copyright 2004-2006 Analog Devices Inc.
12 *
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, see the file COPYING, or write
27 * to the Free Software Foundation, Inc.,
28 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 */
30
31#include <linux/oprofile.h>
32#include <linux/init.h>
33#include <linux/smp.h>
34#include <linux/errno.h>
35#include <linux/mutex.h>
36
37#include <asm/ptrace.h>
38#include <asm/system.h>
39#include <asm/blackfin.h>
40#include <asm/irq.h>
41#include <asm/io.h>
42
43#include "op_blackfin.h"
44
45#define BFIN_533_ID 0xE5040003
46#define BFIN_537_ID 0xE5040002
47
48static int pfmon_enabled;
49static struct mutex pfmon_lock;
50
51struct op_bfin533_model *model;
52
53struct op_counter_config ctr[OP_MAX_COUNTER];
54
55static int op_bfin_setup(void)
56{
57 int ret;
58
59 /* Pre-compute the values to stuff in the hardware registers. */
60 spin_lock(&oprofilefs_lock);
61 ret = model->reg_setup(ctr);
62 spin_unlock(&oprofilefs_lock);
63
64 return ret;
65}
66
67static void op_bfin_shutdown(void)
68{
69#if 0
70 /* what is the difference between shutdown and stop? */
71#endif
72}
73
74static int op_bfin_start(void)
75{
76 int ret = -EBUSY;
77
78 printk(KERN_INFO "KSDBG:in %s\n", __FUNCTION__);
79 mutex_lock(&pfmon_lock);
80 if (!pfmon_enabled) {
81 ret = model->start(ctr);
82 pfmon_enabled = !ret;
83 }
84 mutex_unlock(&pfmon_lock);
85
86 return ret;
87}
88
89static void op_bfin_stop(void)
90{
91 mutex_lock(&pfmon_lock);
92 if (pfmon_enabled) {
93 model->stop();
94 pfmon_enabled = 0;
95 }
96 mutex_unlock(&pfmon_lock);
97}
98
99static int op_bfin_create_files(struct super_block *sb, struct dentry *root)
100{
101 int i;
102
103 for (i = 0; i < model->num_counters; ++i) {
104 struct dentry *dir;
105 char buf[3];
106 printk(KERN_INFO "Oprofile: creating files... \n");
107
108 snprintf(buf, sizeof buf, "%d", i);
109 dir = oprofilefs_mkdir(sb, root, buf);
110
111 oprofilefs_create_ulong(sb, dir, "enabled", &ctr[i].enabled);
112 oprofilefs_create_ulong(sb, dir, "event", &ctr[i].event);
113 oprofilefs_create_ulong(sb, dir, "count", &ctr[i].count);
114 /*
115 * We dont support per counter user/kernel selection, but
116 * we leave the entries because userspace expects them
117 */
118 oprofilefs_create_ulong(sb, dir, "kernel", &ctr[i].kernel);
119 oprofilefs_create_ulong(sb, dir, "user", &ctr[i].user);
120 oprofilefs_create_ulong(sb, dir, "unit_mask",
121 &ctr[i].unit_mask);
122 }
123
124 return 0;
125}
126int __init oprofile_arch_init(struct oprofile_operations *ops)
127{
128#ifdef CONFIG_HARDWARE_PM
129 unsigned int dspid;
130
131 mutex_init(&pfmon_lock);
132
133 dspid = bfin_read_DSPID();
134
135 printk(KERN_INFO "Oprofile got the cpu id is 0x%x. \n", dspid);
136
137 switch (dspid) {
138 case BFIN_533_ID:
139 model = &op_model_bfin533;
140 model->num_counters = 2;
141 break;
142 case BFIN_537_ID:
143 model = &op_model_bfin533;
144 model->num_counters = 2;
145 break;
146 default:
147 return -ENODEV;
148 }
149
150 ops->cpu_type = model->name;
151 ops->create_files = op_bfin_create_files;
152 ops->setup = op_bfin_setup;
153 ops->shutdown = op_bfin_shutdown;
154 ops->start = op_bfin_start;
155 ops->stop = op_bfin_stop;
156
157 printk(KERN_INFO "oprofile: using %s performance monitoring.\n",
158 ops->cpu_type);
159
160 return 0;
161#else
162 return -1;
163#endif
164}
165
166void oprofile_arch_exit(void)
167{
168}
diff --git a/arch/blackfin/oprofile/op_blackfin.h b/arch/blackfin/oprofile/op_blackfin.h
new file mode 100644
index 000000000000..f88f446c814f
--- /dev/null
+++ b/arch/blackfin/oprofile/op_blackfin.h
@@ -0,0 +1,98 @@
1/*
2 * File: arch/blackfin/oprofile/op_blackfin.h
3 * Based on:
4 * Author: Anton Blanchard <anton@au.ibm.com>
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright (C) 2004 Anton Blanchard <anton@au.ibm.com>, IBM
11 * Copyright 2004-2006 Analog Devices Inc.
12 *
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, see the file COPYING, or write
27 * to the Free Software Foundation, Inc.,
28 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 */
30
31#ifndef OP_BLACKFIN_H
32#define OP_BLACKFIN_H 1
33
34#define OP_MAX_COUNTER 2
35
36#include <asm/blackfin.h>
37
38/* Per-counter configuration as set via oprofilefs. */
39struct op_counter_config {
40 unsigned long valid;
41 unsigned long enabled;
42 unsigned long event;
43 unsigned long count;
44 unsigned long kernel;
45 unsigned long user;
46 unsigned long unit_mask;
47};
48
49/* System-wide configuration as set via oprofilefs. */
50struct op_system_config {
51 unsigned long enable_kernel;
52 unsigned long enable_user;
53};
54
55/* Per-arch configuration */
56struct op_bfin533_model {
57 int (*reg_setup) (struct op_counter_config *);
58 int (*start) (struct op_counter_config *);
59 void (*stop) (void);
60 int num_counters;
61 char *name;
62};
63
64extern struct op_bfin533_model op_model_bfin533;
65
66static inline unsigned int ctr_read(void)
67{
68 unsigned int tmp;
69
70 tmp = bfin_read_PFCTL();
71 __builtin_bfin_csync();
72
73 return tmp;
74}
75
76static inline void ctr_write(unsigned int val)
77{
78 bfin_write_PFCTL(val);
79 __builtin_bfin_csync();
80}
81
82static inline void count_read(unsigned int *count)
83{
84 count[0] = bfin_read_PFCNTR0();
85 count[1] = bfin_read_PFCNTR1();
86 __builtin_bfin_csync();
87}
88
89static inline void count_write(unsigned int *count)
90{
91 bfin_write_PFCNTR0(count[0]);
92 bfin_write_PFCNTR1(count[1]);
93 __builtin_bfin_csync();
94}
95
96extern int pm_overflow_handler(int irq, struct pt_regs *regs);
97
98#endif
diff --git a/arch/blackfin/oprofile/op_model_bf533.c b/arch/blackfin/oprofile/op_model_bf533.c
new file mode 100644
index 000000000000..b7a20a006b49
--- /dev/null
+++ b/arch/blackfin/oprofile/op_model_bf533.c
@@ -0,0 +1,161 @@
1/*
2 * File: arch/blackfin/oprofile/op_model_bf533.c
3 * Based on:
4 * Author: Anton Blanchard <anton@au.ibm.com>
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright (C) 2004 Anton Blanchard <anton@au.ibm.com>, IBM
11 * Copyright 2004-2006 Analog Devices Inc.
12 *
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, see the file COPYING, or write
27 * to the Free Software Foundation, Inc.,
28 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 */
30
31#include <linux/oprofile.h>
32#include <linux/init.h>
33#include <linux/smp.h>
34#include <linux/interrupt.h>
35#include <asm/ptrace.h>
36#include <asm/system.h>
37#include <asm/processor.h>
38#include <asm/blackfin.h>
39#include <asm/irq.h>
40#include <asm/io.h>
41
42#include "op_blackfin.h"
43
44#define PM_ENABLE 0x01;
45#define PM_CTL1_ENABLE 0x18
46#define PM_CTL0_ENABLE 0xC000
47#define COUNT_EDGE_ONLY 0x3000000
48
49static int oprofile_running;
50
51static unsigned curr_pfctl, curr_count[2];
52
53static int bfin533_reg_setup(struct op_counter_config *ctr)
54{
55 unsigned int pfctl = ctr_read();
56 unsigned int count[2];
57
58 /* set Blackfin perf monitor regs with ctr */
59 if (ctr[0].enabled) {
60 pfctl |= (PM_CTL0_ENABLE | ((char)ctr[0].event << 5));
61 count[0] = 0xFFFFFFFF - ctr[0].count;
62 curr_count[0] = count[0];
63 }
64 if (ctr[1].enabled) {
65 pfctl |= (PM_CTL1_ENABLE | ((char)ctr[1].event << 16));
66 count[1] = 0xFFFFFFFF - ctr[1].count;
67 curr_count[1] = count[1];
68 }
69
70 pr_debug("ctr[0].enabled=%d,ctr[1].enabled=%d,ctr[0].event<<5=0x%x,ctr[1].event<<16=0x%x\n", ctr[0].enabled, ctr[1].enabled, ctr[0].event << 5, ctr[1].event << 16);
71 pfctl |= COUNT_EDGE_ONLY;
72 curr_pfctl = pfctl;
73
74 pr_debug("write 0x%x to pfctl\n", pfctl);
75 ctr_write(pfctl);
76 count_write(count);
77
78 return 0;
79}
80
81static int bfin533_start(struct op_counter_config *ctr)
82{
83 unsigned int pfctl = ctr_read();
84
85 pfctl |= PM_ENABLE;
86 curr_pfctl = pfctl;
87
88 ctr_write(pfctl);
89
90 oprofile_running = 1;
91 pr_debug("start oprofile counter \n");
92
93 return 0;
94}
95
96static void bfin533_stop(void)
97{
98 int pfctl;
99
100 pfctl = ctr_read();
101 pfctl &= ~PM_ENABLE;
102 /* freeze counters */
103 ctr_write(pfctl);
104
105 oprofile_running = 0;
106 pr_debug("stop oprofile counter \n");
107}
108
109static int get_kernel(void)
110{
111 int ipend, is_kernel;
112
113 ipend = bfin_read_IPEND();
114
115 /* test bit 15 */
116 is_kernel = ((ipend & 0x8000) != 0);
117
118 return is_kernel;
119}
120
121int pm_overflow_handler(int irq, struct pt_regs *regs)
122{
123 int is_kernel;
124 int i, cpu;
125 unsigned int pc, pfctl;
126 unsigned int count[2];
127
128 pr_debug("get interrupt in %s\n", __FUNCTION__);
129 if (oprofile_running == 0) {
130 pr_debug("error: entering interrupt when oprofile is stopped.\n\r");
131 return -1;
132 }
133
134 is_kernel = get_kernel();
135 cpu = smp_processor_id();
136 pc = regs->pc;
137 pfctl = ctr_read();
138
139 /* read the two event counter regs */
140 count_read(count);
141
142 /* if the counter overflows, add sample to oprofile buffer */
143 for (i = 0; i < 2; ++i) {
144 if (oprofile_running) {
145 oprofile_add_sample(regs, i);
146 }
147 }
148
149 /* reset the perfmon counter */
150 ctr_write(curr_pfctl);
151 count_write(curr_count);
152 return 0;
153}
154
155struct op_bfin533_model op_model_bfin533 = {
156 .reg_setup = bfin533_reg_setup,
157 .start = bfin533_start,
158 .stop = bfin533_stop,
159 .num_counters = 2,
160 .name = "blackfin/bf533"
161};
diff --git a/arch/blackfin/oprofile/timer_int.c b/arch/blackfin/oprofile/timer_int.c
new file mode 100644
index 000000000000..8fba16c846c9
--- /dev/null
+++ b/arch/blackfin/oprofile/timer_int.c
@@ -0,0 +1,74 @@
1/*
2 * File: arch/blackfin/oprofile/timer_int.c
3 * Based on:
4 * Author: Michael Kang
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30#include <linux/init.h>
31#include <linux/smp.h>
32#include <linux/irq.h>
33#include <linux/oprofile.h>
34
35#include <asm/ptrace.h>
36
37static void enable_sys_timer0()
38{
39}
40static void disable_sys_timer0()
41{
42}
43
44static irqreturn_t sys_timer0_int_handler(int irq, void *dev_id,
45 struct pt_regs *regs)
46{
47 oprofile_add_sample(regs, 0);
48 return IRQ_HANDLED;
49}
50
51static int sys_timer0_start(void)
52{
53 enable_sys_timer0();
54 return request_irq(IVG11, sys_timer0_int_handler, 0, "sys_timer0", NULL);
55}
56
57static void sys_timer0_stop(void)
58{
59 disable_sys_timer();
60}
61
62int __init sys_timer0_init(struct oprofile_operations *ops)
63{
64 extern int nmi_active;
65
66 if (nmi_active <= 0)
67 return -ENODEV;
68
69 ops->start = timer_start;
70 ops->stop = timer_stop;
71 ops->cpu_type = "timer";
72 printk(KERN_INFO "oprofile: using NMI timer interrupt.\n");
73 return 0;
74}