diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-08 13:01:28 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-08 13:01:28 -0500 |
commit | 0cf975e16927fd70f34cee20d3856246c13bb4c8 (patch) | |
tree | bb955d50f28e5d98c198701798c8341d9763299a /arch/cris/arch-v10 | |
parent | 03054de1e0b90b33e9974107d84dabd2509f5898 (diff) | |
parent | bc10ac3f2fe44e65f787d6197fd5d17304bf7d83 (diff) |
Merge branch 'cris' of git://www.jni.nu/cris
* 'cris' of git://www.jni.nu/cris: (158 commits)
CRIS v32: Remove hwregs/timer_defs.h, it is now architecture specific.
CRIS v32: Change drivers/i2c.c locking.
CRIS v32: Rewrite ARTPEC-3 gpio driver to avoid volatiles and general cleanup.
CRIS: Add new timerfd syscall entries.
MAINTAINERS: Add my information for the CRIS port.
CRIS v32: Correct spelling of bandwidth in function name.
CRIS v32: Clean up nandflash.c for ARTPEC-3 and ETRAX FS.
CRIS v10: Cleanup of drivers/gpio.c
CRIS v10: drivers/net/cris/eth_v10.c rename LED defines to CRIS_LED to avoid name clash.
CRIS: Make io_pwm_set_period members unsigned in etraxgpio.h
CRIS: Move ETRAX_AXISFLASHMAP to common Kconfig file.
CRIS: Drop regs parameter from call to profile_tick in kernel/time.c
CRIS v32: Fix minor formatting issue in mach-a3/io.c
CRIS v32: Initialize GIO even if we're rambooting in kernel/head.S
CRIS v32: Remove kernel/arbiter.c, it now exists in machine dependent directory.
CRIS v32: Minor changes to avoid errors in asm-cris/arch-v32/hwregs/reg_rdwr.h
CRIS v32: arch-v32/hwregs/intr_vect_defs.h moved to machine dependent directory.
CRIS v32: Correct offset for TASK_pid in asm-cris/arch-v32/offset.h
CRIS v32: Move register map header to machine dependent directory.
CRIS v32: Let compiler know that memory is clobbered after a break op.
...
Diffstat (limited to 'arch/cris/arch-v10')
35 files changed, 2756 insertions, 2221 deletions
diff --git a/arch/cris/arch-v10/Kconfig b/arch/cris/arch-v10/Kconfig index 1d61faec77cd..adc164e99339 100644 --- a/arch/cris/arch-v10/Kconfig +++ b/arch/cris/arch-v10/Kconfig | |||
@@ -1,5 +1,7 @@ | |||
1 | if ETRAX_ARCH_V10 | 1 | if ETRAX_ARCH_V10 |
2 | 2 | ||
3 | menu "CRIS v10 options" | ||
4 | |||
3 | # ETRAX 100LX v1 has a MMU "feature" requiring a low mapping | 5 | # ETRAX 100LX v1 has a MMU "feature" requiring a low mapping |
4 | config CRIS_LOW_MAP | 6 | config CRIS_LOW_MAP |
5 | bool | 7 | bool |
@@ -228,69 +230,6 @@ config ETRAX_LED12R | |||
228 | For products with only one or two controllable LEDs, | 230 | For products with only one or two controllable LEDs, |
229 | set this to same as CONFIG_ETRAX_LED1G (normally 2). | 231 | set this to same as CONFIG_ETRAX_LED1G (normally 2). |
230 | 232 | ||
231 | choice | ||
232 | prompt "Product debug-port" | ||
233 | depends on ETRAX_ARCH_V10 | ||
234 | default ETRAX_DEBUG_PORT0 | ||
235 | |||
236 | config ETRAX_DEBUG_PORT0 | ||
237 | bool "Serial-0" | ||
238 | help | ||
239 | Choose a serial port for the ETRAX debug console. Default to | ||
240 | port 0. | ||
241 | |||
242 | config ETRAX_DEBUG_PORT1 | ||
243 | bool "Serial-1" | ||
244 | help | ||
245 | Use serial port 1 for the console. | ||
246 | |||
247 | config ETRAX_DEBUG_PORT2 | ||
248 | bool "Serial-2" | ||
249 | help | ||
250 | Use serial port 2 for the console. | ||
251 | |||
252 | config ETRAX_DEBUG_PORT3 | ||
253 | bool "Serial-3" | ||
254 | help | ||
255 | Use serial port 3 for the console. | ||
256 | |||
257 | config ETRAX_DEBUG_PORT_NULL | ||
258 | bool "disabled" | ||
259 | help | ||
260 | Disable serial-port debugging. | ||
261 | |||
262 | endchoice | ||
263 | |||
264 | choice | ||
265 | prompt "Kernel GDB port" | ||
266 | depends on ETRAX_KGDB | ||
267 | default ETRAX_KGDB_PORT0 | ||
268 | help | ||
269 | Choose a serial port for kernel debugging. NOTE: This port should | ||
270 | not be enabled under Drivers for built-in interfaces (as it has its | ||
271 | own initialization code) and should not be the same as the debug port. | ||
272 | |||
273 | config ETRAX_KGDB_PORT0 | ||
274 | bool "Serial-0" | ||
275 | help | ||
276 | Use serial port 0 for kernel debugging. | ||
277 | |||
278 | config ETRAX_KGDB_PORT1 | ||
279 | bool "Serial-1" | ||
280 | help | ||
281 | Use serial port 1 for kernel debugging. | ||
282 | |||
283 | config ETRAX_KGDB_PORT2 | ||
284 | bool "Serial-2" | ||
285 | help | ||
286 | Use serial port 2 for kernel debugging. | ||
287 | |||
288 | config ETRAX_KGDB_PORT3 | ||
289 | bool "Serial-3" | ||
290 | help | ||
291 | Use serial port 3 for kernel debugging. | ||
292 | |||
293 | endchoice | ||
294 | 233 | ||
295 | choice | 234 | choice |
296 | prompt "Product rescue-port" | 235 | prompt "Product rescue-port" |
@@ -454,4 +393,6 @@ config ETRAX_POWERBUTTON_BIT | |||
454 | help | 393 | help |
455 | Configure where power button is connected. | 394 | Configure where power button is connected. |
456 | 395 | ||
396 | endmenu | ||
397 | |||
457 | endif | 398 | endif |
diff --git a/arch/cris/arch-v10/boot/Makefile b/arch/cris/arch-v10/boot/Makefile index e5b105851108..20c83a53caf3 100644 --- a/arch/cris/arch-v10/boot/Makefile +++ b/arch/cris/arch-v10/boot/Makefile | |||
@@ -1,13 +1,21 @@ | |||
1 | # | 1 | # |
2 | # arch/cris/boot/Makefile | 2 | # arch/cris/arch-v10/boot/Makefile |
3 | # | 3 | # |
4 | target = $(target_boot_dir) | ||
5 | src = $(src_boot_dir) | ||
6 | 4 | ||
7 | zImage: compressed/vmlinuz | 5 | OBJCOPY = objcopy-cris |
6 | OBJCOPYFLAGS = -O binary --remove-section=.bss | ||
8 | 7 | ||
9 | compressed/vmlinuz: | 8 | subdir- := compressed rescue |
10 | @$(MAKE) -f $(src)/compressed/Makefile $(target_compressed_dir)/vmlinuz | 9 | targets := Image |
11 | 10 | ||
12 | clean: | 11 | $(obj)/Image: vmlinux FORCE |
13 | @$(MAKE) -f $(src)/compressed/Makefile clean | 12 | $(call if_changed,objcopy) |
13 | @echo ' Kernel: $@ is ready' | ||
14 | |||
15 | $(obj)/compressed/vmlinux: $(obj)/Image FORCE | ||
16 | $(Q)$(MAKE) $(build)=$(obj)/compressed $@ | ||
17 | $(Q)$(MAKE) $(build)=$(obj)/rescue $(obj)/rescue/rescue.bin | ||
18 | |||
19 | $(obj)/zImage: $(obj)/compressed/vmlinux | ||
20 | @cp $< $@ | ||
21 | @echo ' Kernel: $@ is ready' | ||
diff --git a/arch/cris/arch-v10/boot/compressed/Makefile b/arch/cris/arch-v10/boot/compressed/Makefile index 6584a44820f4..4a031cb27eb9 100644 --- a/arch/cris/arch-v10/boot/compressed/Makefile +++ b/arch/cris/arch-v10/boot/compressed/Makefile | |||
@@ -1,45 +1,35 @@ | |||
1 | # | 1 | # |
2 | # create a compressed vmlinuz image from the binary vmlinux.bin file | 2 | # arch/cris/arch-v10/boot/compressed/Makefile |
3 | # | 3 | # |
4 | target = $(target_compressed_dir) | ||
5 | src = $(src_compressed_dir) | ||
6 | 4 | ||
7 | CC = gcc-cris -melf $(LINUXINCLUDE) | 5 | CC = gcc-cris -melf $(LINUXINCLUDE) |
8 | CFLAGS = -O2 | 6 | ccflags-y += -O2 |
9 | LD = ld-cris | 7 | LD = ld-cris |
8 | ldflags-y += -T $(obj)/decompress.ld | ||
9 | OBJECTS = $(obj)/head.o $(obj)/misc.o | ||
10 | OBJCOPY = objcopy-cris | 10 | OBJCOPY = objcopy-cris |
11 | OBJCOPYFLAGS = -O binary --remove-section=.bss | 11 | OBJCOPYFLAGS = -O binary --remove-section=.bss |
12 | OBJECTS = $(target)/head.o $(target)/misc.o | ||
13 | 12 | ||
14 | # files to compress | 13 | quiet_cmd_image = BUILD $@ |
15 | SYSTEM = $(objtree)/vmlinux.bin | 14 | cmd_image = cat $(obj)/decompress.bin $(obj)/piggy.gz > $@ |
16 | 15 | ||
17 | all: $(target_compressed_dir)/vmlinuz | 16 | targets := vmlinux piggy.gz decompress.o decompress.bin |
18 | 17 | ||
19 | $(target)/decompress.bin: $(OBJECTS) | 18 | $(obj)/decompress.o: $(OBJECTS) FORCE |
20 | $(LD) -T $(src)/decompress.ld -o $(target)/decompress.o $(OBJECTS) | 19 | $(call if_changed,ld) |
21 | $(OBJCOPY) $(OBJCOPYFLAGS) $(target)/decompress.o $(target)/decompress.bin | ||
22 | 20 | ||
23 | # Create vmlinuz image in top-level build directory | 21 | $(obj)/decompress.bin: $(obj)/decompress.o FORCE |
24 | $(target_compressed_dir)/vmlinuz: $(target) piggy.img $(target)/decompress.bin | 22 | $(call if_changed,objcopy) |
25 | @echo " COMPR vmlinux.bin --> vmlinuz" | ||
26 | @cat $(target)/decompress.bin piggy.img > $(target_compressed_dir)/vmlinuz | ||
27 | @rm -f piggy.img | ||
28 | 23 | ||
29 | $(target)/head.o: $(src)/head.S | 24 | $(obj)/head.o: $(obj)/head.S .config |
30 | $(CC) -D__ASSEMBLY__ -traditional -c $< -o $@ | 25 | @$(CC) -D__ASSEMBLY__ -traditional -c $< -o $@ |
31 | 26 | ||
32 | $(target)/misc.o: $(src)/misc.c | 27 | $(obj)/misc.o: $(obj)/misc.c .config |
33 | $(CC) -D__KERNEL__ -c $< -o $@ | 28 | @$(CC) -D__KERNEL__ -c $< -o $@ |
34 | 29 | ||
35 | # gzip the kernel image | 30 | $(obj)/vmlinux: $(obj)/piggy.gz $(obj)/decompress.bin FORCE |
31 | $(call if_changed,image) | ||
36 | 32 | ||
37 | piggy.img: $(SYSTEM) | 33 | $(obj)/piggy.gz: $(obj)/../Image FORCE |
38 | @cat $(SYSTEM) | gzip -f -9 > piggy.img | 34 | $(call if_changed,gzip) |
39 | |||
40 | $(target): | ||
41 | mkdir -p $(target) | ||
42 | |||
43 | clean: | ||
44 | rm -f piggy.img $(objtree)/vmlinuz | ||
45 | 35 | ||
diff --git a/arch/cris/arch-v10/boot/compressed/misc.c b/arch/cris/arch-v10/boot/compressed/misc.c index e205d2e7e089..9a43ab19391e 100644 --- a/arch/cris/arch-v10/boot/compressed/misc.c +++ b/arch/cris/arch-v10/boot/compressed/misc.c | |||
@@ -1,15 +1,13 @@ | |||
1 | /* | 1 | /* |
2 | * misc.c | 2 | * misc.c |
3 | * | 3 | * |
4 | * $Id: misc.c,v 1.6 2003/10/27 08:04:31 starvik Exp $ | 4 | * This is a collection of several routines from gzip-1.0.3 |
5 | * | ||
6 | * This is a collection of several routines from gzip-1.0.3 | ||
7 | * adapted for Linux. | 5 | * adapted for Linux. |
8 | * | 6 | * |
9 | * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994 | 7 | * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994 |
10 | * puts by Nick Holloway 1993, better puts by Martin Mares 1995 | 8 | * puts by Nick Holloway 1993, better puts by Martin Mares 1995 |
11 | * adaptation for Linux/CRIS Axis Communications AB, 1999 | 9 | * adaptation for Linux/CRIS Axis Communications AB, 1999 |
12 | * | 10 | * |
13 | */ | 11 | */ |
14 | 12 | ||
15 | /* where the piggybacked kernel image expects itself to live. | 13 | /* where the piggybacked kernel image expects itself to live. |
diff --git a/arch/cris/arch-v10/boot/rescue/Makefile b/arch/cris/arch-v10/boot/rescue/Makefile index 8be9b3130312..2e5045b9e19c 100644 --- a/arch/cris/arch-v10/boot/rescue/Makefile +++ b/arch/cris/arch-v10/boot/rescue/Makefile | |||
@@ -1,56 +1,38 @@ | |||
1 | # | 1 | # |
2 | # Makefile for rescue code | 2 | # Makefile for rescue (bootstrap) code |
3 | # | 3 | # |
4 | target = $(target_rescue_dir) | ||
5 | src = $(src_rescue_dir) | ||
6 | 4 | ||
7 | CC = gcc-cris -mlinux $(LINUXINCLUDE) | 5 | CC = gcc-cris -mlinux $(LINUXINCLUDE) |
8 | CFLAGS = -O2 | 6 | ccflags-y += -O2 |
7 | asflags-y += -traditional | ||
9 | LD = gcc-cris -mlinux -nostdlib | 8 | LD = gcc-cris -mlinux -nostdlib |
9 | ldflags-y += -T $(obj)/rescue.ld | ||
10 | OBJCOPY = objcopy-cris | 10 | OBJCOPY = objcopy-cris |
11 | OBJCOPYFLAGS = -O binary --remove-section=.bss | 11 | OBJCOPYFLAGS = -O binary --remove-section=.bss |
12 | obj-$(CONFIG_ETRAX_AXISFLASHMAP) = head.o | ||
13 | OBJECT := $(obj)/head.o | ||
12 | 14 | ||
13 | all: $(target)/rescue.bin $(target)/testrescue.bin $(target)/kimagerescue.bin | 15 | targets := rescue.o rescue.bin |
14 | 16 | ||
15 | $(target)/rescue.bin: $(target) $(target)/head.o | 17 | $(obj)/rescue.o: $(OBJECT) FORCE |
16 | $(LD) -T $(src)/rescue.ld -o $(target)/rescue.o $(target)/head.o | 18 | $(call if_changed,ld) |
17 | $(OBJCOPY) $(OBJCOPYFLAGS) $(target)/rescue.o $(target)/rescue.bin | ||
18 | # Place a copy in top-level build directory | ||
19 | cp -p $(target)/rescue.bin $(objtree) | ||
20 | 19 | ||
21 | $(target)/testrescue.bin: $(target) $(target)/testrescue.o | 20 | $(obj)/rescue.bin: $(obj)/rescue.o FORCE |
22 | $(OBJCOPY) $(OBJCOPYFLAGS) $(target)/testrescue.o tr.bin | 21 | $(call if_changed,objcopy) |
22 | cp -p $(obj)/rescue.bin $(objtree) | ||
23 | |||
24 | $(obj)/testrescue.bin: $(obj)/testrescue.o | ||
25 | $(OBJCOPY) $(OBJCOPYFLAGS) $(obj)/testrescue.o tr.bin | ||
23 | # Pad it to 784 bytes | 26 | # Pad it to 784 bytes |
24 | dd if=/dev/zero of=tmp2423 bs=1 count=784 | 27 | dd if=/dev/zero of=tmp2423 bs=1 count=784 |
25 | cat tr.bin tmp2423 >testrescue_tmp.bin | 28 | cat tr.bin tmp2423 >testrescue_tmp.bin |
26 | dd if=testrescue_tmp.bin of=$(target)/testrescue.bin bs=1 count=784 | 29 | dd if=testrescue_tmp.bin of=$(obj)/testrescue.bin bs=1 count=784 |
27 | rm tr.bin tmp2423 testrescue_tmp.bin | 30 | rm tr.bin tmp2423 testrescue_tmp.bin |
28 | 31 | ||
29 | $(target)/kimagerescue.bin: $(target) $(target)/kimagerescue.o | 32 | $(obj)/kimagerescue.bin: $(obj)/kimagerescue.o |
30 | $(OBJCOPY) $(OBJCOPYFLAGS) $(target)/kimagerescue.o ktr.bin | 33 | $(OBJCOPY) $(OBJCOPYFLAGS) $(obj)/kimagerescue.o ktr.bin |
31 | # Pad it to 784 bytes, that's what the rescue loader expects | 34 | # Pad it to 784 bytes, that's what the rescue loader expects |
32 | dd if=/dev/zero of=tmp2423 bs=1 count=784 | 35 | dd if=/dev/zero of=tmp2423 bs=1 count=784 |
33 | cat ktr.bin tmp2423 >kimagerescue_tmp.bin | 36 | cat ktr.bin tmp2423 >kimagerescue_tmp.bin |
34 | dd if=kimagerescue_tmp.bin of=$(target)/kimagerescue.bin bs=1 count=784 | 37 | dd if=kimagerescue_tmp.bin of=$(obj)/kimagerescue.bin bs=1 count=784 |
35 | rm ktr.bin tmp2423 kimagerescue_tmp.bin | 38 | rm ktr.bin tmp2423 kimagerescue_tmp.bin |
36 | |||
37 | $(target): | ||
38 | mkdir -p $(target) | ||
39 | |||
40 | $(target)/head.o: $(src)/head.S | ||
41 | $(CC) -D__ASSEMBLY__ -traditional -c $< -o $*.o | ||
42 | |||
43 | $(target)/testrescue.o: $(src)/testrescue.S | ||
44 | $(CC) -D__ASSEMBLY__ -traditional -c $< -o $*.o | ||
45 | |||
46 | $(target)/kimagerescue.o: $(src)/kimagerescue.S | ||
47 | $(CC) -D__ASSEMBLY__ -traditional -c $< -o $*.o | ||
48 | |||
49 | clean: | ||
50 | rm -f $(target)/*.o $(target)/*.bin | ||
51 | |||
52 | fastdep: | ||
53 | |||
54 | modules: | ||
55 | |||
56 | modules-install: | ||
diff --git a/arch/cris/arch-v10/boot/rescue/head.S b/arch/cris/arch-v10/boot/rescue/head.S index f223cc0c00bb..6ba7be8ac4a0 100644 --- a/arch/cris/arch-v10/boot/rescue/head.S +++ b/arch/cris/arch-v10/boot/rescue/head.S | |||
@@ -1,5 +1,4 @@ | |||
1 | /* $Id: head.S,v 1.7 2005/03/07 12:11:06 starvik Exp $ | 1 | /* |
2 | * | ||
3 | * Rescue code, made to reside at the beginning of the | 2 | * Rescue code, made to reside at the beginning of the |
4 | * flash-memory. when it starts, it checks a partition | 3 | * flash-memory. when it starts, it checks a partition |
5 | * table at the first sector after the rescue sector. | 4 | * table at the first sector after the rescue sector. |
@@ -23,20 +22,20 @@ | |||
23 | * Partition table format: | 22 | * Partition table format: |
24 | * | 23 | * |
25 | * Code transparency: | 24 | * Code transparency: |
26 | * | 25 | * |
27 | * 2 bytes [opcode 'nop'] | 26 | * 2 bytes [opcode 'nop'] |
28 | * 2 bytes [opcode 'di'] | 27 | * 2 bytes [opcode 'di'] |
29 | * 4 bytes [opcode 'ba <offset>', 8-bit or 16-bit version] | 28 | * 4 bytes [opcode 'ba <offset>', 8-bit or 16-bit version] |
30 | * 2 bytes [opcode 'nop', delay slot] | 29 | * 2 bytes [opcode 'nop', delay slot] |
31 | * | 30 | * |
32 | * Table validation (at +10): | 31 | * Table validation (at +10): |
33 | * | 32 | * |
34 | * 2 bytes [magic/version word for partitiontable - 0xef, 0xbe] | 33 | * 2 bytes [magic/version word for partitiontable - 0xef, 0xbe] |
35 | * 2 bytes [length of all entries plus the end marker] | 34 | * 2 bytes [length of all entries plus the end marker] |
36 | * 4 bytes [checksum for the partitiontable itself] | 35 | * 4 bytes [checksum for the partitiontable itself] |
37 | * | 36 | * |
38 | * Entries, each with the following format, last has offset -1: | 37 | * Entries, each with the following format, last has offset -1: |
39 | * | 38 | * |
40 | * 4 bytes [offset in bytes, from start of flash] | 39 | * 4 bytes [offset in bytes, from start of flash] |
41 | * 4 bytes [length in bytes of partition] | 40 | * 4 bytes [length in bytes of partition] |
42 | * 4 bytes [checksum, simple longword sum] | 41 | * 4 bytes [checksum, simple longword sum] |
@@ -47,9 +46,9 @@ | |||
47 | * End marker | 46 | * End marker |
48 | * | 47 | * |
49 | * 4 bytes [-1] | 48 | * 4 bytes [-1] |
50 | * | 49 | * |
51 | * 10 bytes [0, padding] | 50 | * 10 bytes [0, padding] |
52 | * | 51 | * |
53 | * Bit 0 in flags signifies RW or RO. The rescue code only bothers | 52 | * Bit 0 in flags signifies RW or RO. The rescue code only bothers |
54 | * to check the checksum for RO partitions, since the others will | 53 | * to check the checksum for RO partitions, since the others will |
55 | * change their data without updating the checksums. A 1 in bit 0 | 54 | * change their data without updating the checksums. A 1 in bit 0 |
@@ -59,26 +58,29 @@ | |||
59 | * | 58 | * |
60 | * During the wait for serial input, the status LED will flash so the | 59 | * During the wait for serial input, the status LED will flash so the |
61 | * user knows something went wrong. | 60 | * user knows something went wrong. |
62 | * | 61 | * |
63 | * Copyright (C) 1999, 2000, 2001, 2002, 2003 Axis Communications AB | 62 | * Copyright (C) 1999-2007 Axis Communications AB |
64 | */ | 63 | */ |
65 | 64 | ||
65 | #ifdef CONFIG_ETRAX_AXISFLASHMAP | ||
66 | |||
66 | #define ASSEMBLER_MACROS_ONLY | 67 | #define ASSEMBLER_MACROS_ONLY |
67 | #include <asm/arch/sv_addr_ag.h> | 68 | #include <asm/arch/sv_addr_ag.h> |
68 | 69 | ||
69 | ;; The partitiontable is looked for at the first sector after the boot | 70 | ;; The partitiontable is looked for at the first sector after the boot |
70 | ;; sector. Sector size is 65536 bytes in all flashes we use. | 71 | ;; sector. Sector size is 65536 bytes in all flashes we use. |
71 | 72 | ||
72 | #define PTABLE_START CONFIG_ETRAX_PTABLE_SECTOR | 73 | #define PTABLE_START CONFIG_ETRAX_PTABLE_SECTOR |
73 | #define PTABLE_MAGIC 0xbeef | 74 | #define PTABLE_MAGIC 0xbeef |
74 | 75 | ||
75 | ;; The normal Etrax100 on-chip boot ROM does serial boot at 0x380000f0. | 76 | ;; The normal Etrax100 on-chip boot ROM does serial boot at 0x380000f0. |
76 | ;; That is not where we put our downloaded serial boot-code. The length is | 77 | ;; That is not where we put our downloaded serial boot-code. |
77 | ;; enough for downloading code that loads the rest of itself (after | 78 | ;; The length is enough for downloading code that loads the rest |
78 | ;; having setup the DRAM etc). It is the same length as the on-chip | 79 | ;; of itself (after having setup the DRAM etc). |
79 | ;; ROM loads, so the same host loader can be used to load a rescued | 80 | ;; It is the same length as the on-chip ROM loads, so the same |
80 | ;; product as well as one booted through the Etrax serial boot code. | 81 | ;; host loader can be used to load a rescued product as well as |
81 | 82 | ;; one booted through the Etrax serial boot code. | |
83 | |||
82 | #define CODE_START 0x40000000 | 84 | #define CODE_START 0x40000000 |
83 | #define CODE_LENGTH 784 | 85 | #define CODE_LENGTH 784 |
84 | 86 | ||
@@ -102,7 +104,7 @@ | |||
102 | #define SERRECC R_SERIAL2_REC_CTRL | 104 | #define SERRECC R_SERIAL2_REC_CTRL |
103 | #define SERRDAT R_SERIAL2_REC_DATA | 105 | #define SERRDAT R_SERIAL2_REC_DATA |
104 | #define SERSTAT R_SERIAL2_STATUS | 106 | #define SERSTAT R_SERIAL2_STATUS |
105 | #endif | 107 | #endif |
106 | #ifdef CONFIG_ETRAX_RESCUE_SER3 | 108 | #ifdef CONFIG_ETRAX_RESCUE_SER3 |
107 | #define SERXOFF R_SERIAL3_XOFF | 109 | #define SERXOFF R_SERIAL3_XOFF |
108 | #define SERBAUD R_SERIAL3_BAUD | 110 | #define SERBAUD R_SERIAL3_BAUD |
@@ -115,60 +117,61 @@ | |||
115 | #define RAM_INIT_MAGIC 0x56902387 | 117 | #define RAM_INIT_MAGIC 0x56902387 |
116 | 118 | ||
117 | .text | 119 | .text |
118 | 120 | ||
119 | ;; This is the entry point of the rescue code | 121 | ;; This is the entry point of the rescue code |
120 | ;; 0x80000000 if loaded in flash (as it should be) | 122 | ;; 0x80000000 if loaded in flash (as it should be) |
121 | ;; since etrax actually starts at address 2 when booting from flash, we | 123 | ;; Since etrax actually starts at address 2 when booting from flash, we |
122 | ;; put a nop (2 bytes) here first so we dont accidentally skip the di | 124 | ;; put a nop (2 bytes) here first so we dont accidentally skip the di |
123 | 125 | ||
124 | nop | 126 | nop |
125 | di | 127 | di |
126 | 128 | ||
127 | jump in_cache ; enter cached area instead | 129 | jump in_cache ; enter cached area instead |
128 | in_cache: | 130 | in_cache: |
129 | 131 | ||
130 | 132 | ||
131 | ;; first put a jump test to give a possibility of upgrading the rescue code | 133 | ;; First put a jump test to give a possibility of upgrading the |
132 | ;; without erasing/reflashing the sector. we put a longword of -1 here and if | 134 | ;; rescue code without erasing/reflashing the sector. |
133 | ;; it is not -1, we jump using the value as jump target. since we can always | 135 | ;; We put a longword of -1 here and if it is not -1, we jump using |
134 | ;; change 1's to 0's without erasing the sector, it is possible to add new | 136 | ;; the value as jump target. Since we can always change 1's to 0's |
137 | ;; without erasing the sector, it is possible to add new | ||
135 | ;; code after this and altering the jumptarget in an upgrade. | 138 | ;; code after this and altering the jumptarget in an upgrade. |
136 | 139 | ||
137 | jtcd: move.d [jumptarget], $r0 | 140 | jtcd: move.d [jumptarget], $r0 |
138 | cmp.d 0xffffffff, $r0 | 141 | cmp.d 0xffffffff, $r0 |
139 | beq no_newjump | 142 | beq no_newjump |
140 | nop | 143 | nop |
141 | 144 | ||
142 | jump [$r0] | 145 | jump [$r0] |
143 | 146 | ||
144 | jumptarget: | 147 | jumptarget: |
145 | .dword 0xffffffff ; can be overwritten later to insert new code | 148 | .dword 0xffffffff ; can be overwritten later to insert new code |
146 | 149 | ||
147 | no_newjump: | 150 | no_newjump: |
148 | #ifdef CONFIG_ETRAX_ETHERNET | 151 | #ifdef CONFIG_ETRAX_ETHERNET |
149 | ;; Start MII clock to make sure it is running when tranceiver is reset | 152 | ;; Start MII clock to make sure it is running when tranceiver is reset |
150 | move.d 0x3, $r0 ; enable = on, phy = mii_clk | 153 | move.d 0x3, $r0 ; enable = on, phy = mii_clk |
151 | move.d $r0, [R_NETWORK_GEN_CONFIG] | 154 | move.d $r0, [R_NETWORK_GEN_CONFIG] |
152 | #endif | 155 | #endif |
153 | 156 | ||
154 | ;; We need to setup the bus registers before we start using the DRAM | 157 | ;; We need to setup the bus registers before we start using the DRAM |
155 | #include "../../lib/dram_init.S" | 158 | #include "../../lib/dram_init.S" |
156 | 159 | ||
157 | ;; we now should go through the checksum-table and check the listed | 160 | ;; we now should go through the checksum-table and check the listed |
158 | ;; partitions for errors. | 161 | ;; partitions for errors. |
159 | 162 | ||
160 | move.d PTABLE_START, $r3 | 163 | move.d PTABLE_START, $r3 |
161 | move.d [$r3], $r0 | 164 | move.d [$r3], $r0 |
162 | cmp.d NOP_DI, $r0 ; make sure the nop/di is there... | 165 | cmp.d NOP_DI, $r0 ; make sure the nop/di is there... |
163 | bne do_rescue | 166 | bne do_rescue |
164 | nop | 167 | nop |
165 | 168 | ||
166 | ;; skip the code transparency block (10 bytes). | 169 | ;; skip the code transparency block (10 bytes). |
167 | 170 | ||
168 | addq 10, $r3 | 171 | addq 10, $r3 |
169 | 172 | ||
170 | ;; check for correct magic | 173 | ;; check for correct magic |
171 | 174 | ||
172 | move.w [$r3+], $r0 | 175 | move.w [$r3+], $r0 |
173 | cmp.w PTABLE_MAGIC, $r0 | 176 | cmp.w PTABLE_MAGIC, $r0 |
174 | bne do_rescue ; didn't recognize - trig rescue | 177 | bne do_rescue ; didn't recognize - trig rescue |
@@ -186,11 +189,11 @@ no_newjump: | |||
186 | cmp.d $r0, $r4 | 189 | cmp.d $r0, $r4 |
187 | bne do_rescue ; didn't match - trig rescue | 190 | bne do_rescue ; didn't match - trig rescue |
188 | nop | 191 | nop |
189 | 192 | ||
190 | ;; ptable is ok. validate each entry. | 193 | ;; ptable is ok. validate each entry. |
191 | 194 | ||
192 | moveq -1, $r7 | 195 | moveq -1, $r7 |
193 | 196 | ||
194 | ploop: move.d [$r3+], $r1 ; partition offset (from ptable start) | 197 | ploop: move.d [$r3+], $r1 ; partition offset (from ptable start) |
195 | bne notfirst ; check if it is the partition containing ptable | 198 | bne notfirst ; check if it is the partition containing ptable |
196 | nop ; yes.. | 199 | nop ; yes.. |
@@ -199,7 +202,7 @@ ploop: move.d [$r3+], $r1 ; partition offset (from ptable start) | |||
199 | sub.d $r8, $r2 ; minus the ptable length | 202 | sub.d $r8, $r2 ; minus the ptable length |
200 | ba bosse | 203 | ba bosse |
201 | nop | 204 | nop |
202 | notfirst: | 205 | notfirst: |
203 | cmp.d -1, $r1 ; the end of the ptable ? | 206 | cmp.d -1, $r1 ; the end of the ptable ? |
204 | beq flash_ok ; if so, the flash is validated | 207 | beq flash_ok ; if so, the flash is validated |
205 | move.d [$r3+], $r2 ; partition length | 208 | move.d [$r3+], $r2 ; partition length |
@@ -213,47 +216,46 @@ bosse: move.d [$r3+], $r5 ; checksum | |||
213 | bpl 1f | 216 | bpl 1f |
214 | nop | 217 | nop |
215 | move.d $r1, $r7 ; remember boot partition offset | 218 | move.d $r1, $r7 ; remember boot partition offset |
216 | 1: | 219 | 1: |
217 | |||
218 | add.d PTABLE_START, $r1 | 220 | add.d PTABLE_START, $r1 |
219 | 221 | ||
220 | jsr checksum ; checksum the partition | 222 | jsr checksum ; checksum the partition |
221 | 223 | ||
222 | cmp.d $r0, $r5 | 224 | cmp.d $r0, $r5 |
223 | beq ploop ; checksums matched, go to next entry | 225 | beq ploop ; checksums matched, go to next entry |
224 | nop | 226 | nop |
225 | 227 | ||
226 | ;; otherwise fall through to the rescue code. | 228 | ;; otherwise fall through to the rescue code. |
227 | 229 | ||
228 | do_rescue: | 230 | do_rescue: |
229 | ;; setup port PA and PB default initial directions and data | 231 | ;; setup port PA and PB default initial directions and data |
230 | ;; (so we can flash LEDs, and so that DTR and others are set) | 232 | ;; (so we can flash LEDs, and so that DTR and others are set) |
231 | 233 | ||
232 | move.b CONFIG_ETRAX_DEF_R_PORT_PA_DIR, $r0 | 234 | move.b CONFIG_ETRAX_DEF_R_PORT_PA_DIR, $r0 |
233 | move.b $r0, [R_PORT_PA_DIR] | 235 | move.b $r0, [R_PORT_PA_DIR] |
234 | move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r0 | 236 | move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r0 |
235 | move.b $r0, [R_PORT_PA_DATA] | 237 | move.b $r0, [R_PORT_PA_DATA] |
236 | 238 | ||
237 | move.b CONFIG_ETRAX_DEF_R_PORT_PB_DIR, $r0 | 239 | move.b CONFIG_ETRAX_DEF_R_PORT_PB_DIR, $r0 |
238 | move.b $r0, [R_PORT_PB_DIR] | 240 | move.b $r0, [R_PORT_PB_DIR] |
239 | move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r0 | 241 | move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r0 |
240 | move.b $r0, [R_PORT_PB_DATA] | 242 | move.b $r0, [R_PORT_PB_DATA] |
241 | 243 | ||
242 | ;; setup the serial port at 115200 baud | 244 | ;; setup the serial port at 115200 baud |
243 | 245 | ||
244 | moveq 0, $r0 | 246 | moveq 0, $r0 |
245 | move.d $r0, [SERXOFF] | 247 | move.d $r0, [SERXOFF] |
246 | 248 | ||
247 | move.b 0x99, $r0 | 249 | move.b 0x99, $r0 |
248 | move.b $r0, [SERBAUD] ; 115.2kbaud for both transmit and receive | 250 | move.b $r0, [SERBAUD] ; 115.2kbaud for both transmit and receive |
249 | 251 | ||
250 | move.b 0x40, $r0 ; rec enable | 252 | move.b 0x40, $r0 ; rec enable |
251 | move.b $r0, [SERRECC] | 253 | move.b $r0, [SERRECC] |
252 | 254 | ||
253 | moveq 0, $r1 ; "timer" to clock out a LED red flash | 255 | moveq 0, $r1 ; "timer" to clock out a LED red flash |
254 | move.d CODE_START, $r3 ; destination counter | 256 | move.d CODE_START, $r3 ; destination counter |
255 | movu.w CODE_LENGTH, $r4; length | 257 | movu.w CODE_LENGTH, $r4; length |
256 | 258 | ||
257 | wait_ser: | 259 | wait_ser: |
258 | addq 1, $r1 | 260 | addq 1, $r1 |
259 | #ifndef CONFIG_ETRAX_NO_LEDS | 261 | #ifndef CONFIG_ETRAX_NO_LEDS |
@@ -272,20 +274,20 @@ wait_ser: | |||
272 | nop | 274 | nop |
273 | 1: not $r0 ; clear bit | 275 | 1: not $r0 ; clear bit |
274 | and.d $r0, $r2 | 276 | and.d $r0, $r2 |
275 | 2: | 277 | 2: |
276 | #ifdef CONFIG_ETRAX_PA_LEDS | 278 | #ifdef CONFIG_ETRAX_PA_LEDS |
277 | move.b $r2, [R_PORT_PA_DATA] | 279 | move.b $r2, [R_PORT_PA_DATA] |
278 | #endif | 280 | #endif |
279 | #ifdef CONFIG_ETRAX_PB_LEDS | 281 | #ifdef CONFIG_ETRAX_PB_LEDS |
280 | move.b $r2, [R_PORT_PB_DATA] | 282 | move.b $r2, [R_PORT_PB_DATA] |
281 | #endif | 283 | #endif |
282 | #ifdef CONFIG_ETRAX_90000000_LEDS | 284 | #ifdef CONFIG_ETRAX_90000000_LEDS |
283 | move.b $r2, [0x90000000] | 285 | move.b $r2, [0x90000000] |
284 | #endif | 286 | #endif |
285 | #endif | 287 | #endif |
286 | 288 | ||
287 | ;; check if we got something on the serial port | 289 | ;; check if we got something on the serial port |
288 | 290 | ||
289 | move.b [SERSTAT], $r0 | 291 | move.b [SERSTAT], $r0 |
290 | btstq 0, $r0 ; data_avail | 292 | btstq 0, $r0 ; data_avail |
291 | bpl wait_ser | 293 | bpl wait_ser |
@@ -295,14 +297,15 @@ wait_ser: | |||
295 | 297 | ||
296 | move.b [SERRDAT], $r0 | 298 | move.b [SERRDAT], $r0 |
297 | move.b $r0, [$r3+] | 299 | move.b $r0, [$r3+] |
298 | 300 | ||
299 | subq 1, $r4 ; decrease length | 301 | subq 1, $r4 ; decrease length |
300 | bne wait_ser | 302 | bne wait_ser |
301 | nop | 303 | nop |
302 | 304 | ||
303 | ;; jump into downloaded code | 305 | ;; jump into downloaded code |
304 | 306 | ||
305 | move.d RAM_INIT_MAGIC, $r8 ; Tell next product that DRAM is initialized | 307 | move.d RAM_INIT_MAGIC, $r8 ; Tell next product that DRAM is |
308 | ; initialized | ||
306 | jump CODE_START | 309 | jump CODE_START |
307 | 310 | ||
308 | flash_ok: | 311 | flash_ok: |
@@ -313,7 +316,8 @@ flash_ok: | |||
313 | nop | 316 | nop |
314 | move.d PTABLE_START, $r7; otherwise use the ptable start | 317 | move.d PTABLE_START, $r7; otherwise use the ptable start |
315 | 1: | 318 | 1: |
316 | move.d RAM_INIT_MAGIC, $r8 ; Tell next product that DRAM is initialized | 319 | move.d RAM_INIT_MAGIC, $r8 ; Tell next product that DRAM is |
320 | ; initialized | ||
317 | jump $r7 ; boot! | 321 | jump $r7 ; boot! |
318 | 322 | ||
319 | 323 | ||
@@ -327,7 +331,8 @@ checksum: | |||
327 | moveq 0, $r0 | 331 | moveq 0, $r0 |
328 | moveq CONFIG_ETRAX_FLASH1_SIZE, $r6 | 332 | moveq CONFIG_ETRAX_FLASH1_SIZE, $r6 |
329 | 333 | ||
330 | ;; If the first physical flash memory is exceeded wrap to the second one. | 334 | ;; If the first physical flash memory is exceeded wrap to the |
335 | ;; second one | ||
331 | btstq 26, $r1 ; Are we addressing first flash? | 336 | btstq 26, $r1 ; Are we addressing first flash? |
332 | bpl 1f | 337 | bpl 1f |
333 | nop | 338 | nop |
@@ -351,3 +356,5 @@ checksum: | |||
351 | 3: move.d MEM_CSE1_START, $r1 ; wrap to second flash | 356 | 3: move.d MEM_CSE1_START, $r1 ; wrap to second flash |
352 | ba 2b | 357 | ba 2b |
353 | nop | 358 | nop |
359 | |||
360 | #endif | ||
diff --git a/arch/cris/arch-v10/boot/rescue/kimagerescue.S b/arch/cris/arch-v10/boot/rescue/kimagerescue.S index cbccd6316d39..55eeff8bb08e 100644 --- a/arch/cris/arch-v10/boot/rescue/kimagerescue.S +++ b/arch/cris/arch-v10/boot/rescue/kimagerescue.S | |||
@@ -1,5 +1,4 @@ | |||
1 | /* $Id: kimagerescue.S,v 1.1 2001/12/17 13:59:27 bjornw Exp $ | 1 | /* |
2 | * | ||
3 | * Rescue code to be prepended on a kimage and copied to the | 2 | * Rescue code to be prepended on a kimage and copied to the |
4 | * rescue serial port. | 3 | * rescue serial port. |
5 | * This is called from the rescue code, it will copy received data to | 4 | * This is called from the rescue code, it will copy received data to |
@@ -7,13 +6,13 @@ | |||
7 | */ | 6 | */ |
8 | 7 | ||
9 | #define ASSEMBLER_MACROS_ONLY | 8 | #define ASSEMBLER_MACROS_ONLY |
10 | #include <asm/sv_addr_ag.h> | 9 | #include <asm/arch/sv_addr_ag.h> |
11 | 10 | ||
12 | #define CODE_START 0x40004000 | 11 | #define CODE_START 0x40004000 |
13 | #define CODE_LENGTH 784 | 12 | #define CODE_LENGTH 784 |
14 | #define TIMEOUT_VALUE 1000 | 13 | #define TIMEOUT_VALUE 1000 |
15 | 14 | ||
16 | 15 | ||
17 | #ifdef CONFIG_ETRAX_RESCUE_SER0 | 16 | #ifdef CONFIG_ETRAX_RESCUE_SER0 |
18 | #define SERXOFF R_SERIAL0_XOFF | 17 | #define SERXOFF R_SERIAL0_XOFF |
19 | #define SERBAUD R_SERIAL0_BAUD | 18 | #define SERBAUD R_SERIAL0_BAUD |
@@ -34,7 +33,7 @@ | |||
34 | #define SERRECC R_SERIAL2_REC_CTRL | 33 | #define SERRECC R_SERIAL2_REC_CTRL |
35 | #define SERRDAT R_SERIAL2_REC_DATA | 34 | #define SERRDAT R_SERIAL2_REC_DATA |
36 | #define SERSTAT R_SERIAL2_STATUS | 35 | #define SERSTAT R_SERIAL2_STATUS |
37 | #endif | 36 | #endif |
38 | #ifdef CONFIG_ETRAX_RESCUE_SER3 | 37 | #ifdef CONFIG_ETRAX_RESCUE_SER3 |
39 | #define SERXOFF R_SERIAL3_XOFF | 38 | #define SERXOFF R_SERIAL3_XOFF |
40 | #define SERBAUD R_SERIAL3_BAUD | 39 | #define SERBAUD R_SERIAL3_BAUD |
@@ -48,54 +47,55 @@ | |||
48 | ;; 0x80000000 if loaded in flash (as it should be) | 47 | ;; 0x80000000 if loaded in flash (as it should be) |
49 | ;; since etrax actually starts at address 2 when booting from flash, we | 48 | ;; since etrax actually starts at address 2 when booting from flash, we |
50 | ;; put a nop (2 bytes) here first so we dont accidentally skip the di | 49 | ;; put a nop (2 bytes) here first so we dont accidentally skip the di |
51 | 50 | ||
52 | nop | 51 | nop |
53 | di | 52 | di |
54 | #ifndef CONFIG_SVINTO_SIM | 53 | #ifndef CONFIG_SVINTO_SIM |
55 | ;; setup port PA and PB default initial directions and data | 54 | ;; setup port PA and PB default initial directions and data |
56 | ;; (so we can flash LEDs, and so that DTR and others are set) | 55 | ;; (so we can flash LEDs, and so that DTR and others are set) |
57 | 56 | ||
58 | move.b CONFIG_ETRAX_DEF_R_PORT_PA_DIR, $r0 | 57 | move.b CONFIG_ETRAX_DEF_R_PORT_PA_DIR, $r0 |
59 | move.b $r0, [R_PORT_PA_DIR] | 58 | move.b $r0, [R_PORT_PA_DIR] |
60 | move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r0 | 59 | move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r0 |
61 | move.b $r0, [R_PORT_PA_DATA] | 60 | move.b $r0, [R_PORT_PA_DATA] |
62 | 61 | ||
63 | move.b CONFIG_ETRAX_DEF_R_PORT_PB_DIR, $r0 | 62 | move.b CONFIG_ETRAX_DEF_R_PORT_PB_DIR, $r0 |
64 | move.b $r0, [R_PORT_PB_DIR] | 63 | move.b $r0, [R_PORT_PB_DIR] |
65 | move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r0 | 64 | move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r0 |
66 | move.b $r0, [R_PORT_PB_DATA] | 65 | move.b $r0, [R_PORT_PB_DATA] |
67 | 66 | ||
68 | ;; We need to setup the bus registers before we start using the DRAM | 67 | ;; We need to setup the bus registers before we start using the DRAM |
69 | #include "../../lib/dram_init.S" | 68 | #include "../../lib/dram_init.S" |
70 | 69 | ||
71 | #endif | 70 | #endif |
72 | ;; Setup the stack to a suitably high address. | 71 | ;; Setup the stack to a suitably high address. |
73 | ;; We assume 8 MB is the minimum DRAM in an eLinux | 72 | ;; We assume 8 MB is the minimum DRAM in an eLinux |
74 | ;; product and put the sp at the top for now. | 73 | ;; product and put the sp at the top for now. |
75 | 74 | ||
76 | move.d 0x40800000, $sp | 75 | move.d 0x40800000, $sp |
77 | 76 | ||
78 | ;; setup the serial port at 115200 baud | 77 | ;; setup the serial port at 115200 baud |
79 | 78 | ||
80 | moveq 0, $r0 | 79 | moveq 0, $r0 |
81 | move.d $r0, [SERXOFF] | 80 | move.d $r0, [SERXOFF] |
82 | 81 | ||
83 | move.b 0x99, $r0 | 82 | move.b 0x99, $r0 |
84 | move.b $r0, [SERBAUD] ; 115.2kbaud for both transmit and receive | 83 | move.b $r0, [SERBAUD] ; 115.2kbaud for both transmit |
84 | ; and receive | ||
85 | 85 | ||
86 | move.b 0x40, $r0 ; rec enable | 86 | move.b 0x40, $r0 ; rec enable |
87 | move.b $r0, [SERRECC] | 87 | move.b $r0, [SERRECC] |
88 | 88 | ||
89 | 89 | ||
90 | moveq 0, $r1 ; "timer" to clock out a LED red flash | 90 | moveq 0, $r1 ; "timer" to clock out a LED red flash |
91 | move.d CODE_START, $r3 ; destination counter | 91 | move.d CODE_START, $r3 ; destination counter |
92 | move.d CODE_LENGTH, $r4 ; length | 92 | move.d CODE_LENGTH, $r4 ; length |
93 | move.d TIMEOUT_VALUE, $r5 ; "timeout" until jump | 93 | move.d TIMEOUT_VALUE, $r5 ; "timeout" until jump |
94 | 94 | ||
95 | wait_ser: | 95 | wait_ser: |
96 | addq 1, $r1 | 96 | addq 1, $r1 |
97 | subq 1, $r5 ; decrease timeout | 97 | subq 1, $r5 ; decrease timeout |
98 | beq jump_start ; timed out | 98 | beq jump_start ; timed out |
99 | nop | 99 | nop |
100 | #ifndef CONFIG_ETRAX_NO_LEDS | 100 | #ifndef CONFIG_ETRAX_NO_LEDS |
101 | #ifdef CONFIG_ETRAX_PA_LEDS | 101 | #ifdef CONFIG_ETRAX_PA_LEDS |
@@ -111,21 +111,21 @@ wait_ser: | |||
111 | or.d $r0, $r2 ; set bit | 111 | or.d $r0, $r2 ; set bit |
112 | ba 2f | 112 | ba 2f |
113 | nop | 113 | nop |
114 | 1: not $r0 ; clear bit | 114 | 1: not $r0 ; clear bit |
115 | and.d $r0, $r2 | 115 | and.d $r0, $r2 |
116 | 2: | 116 | 2: |
117 | #ifdef CONFIG_ETRAX_PA_LEDS | 117 | #ifdef CONFIG_ETRAX_PA_LEDS |
118 | move.b $r2, [R_PORT_PA_DATA] | 118 | move.b $r2, [R_PORT_PA_DATA] |
119 | #endif | 119 | #endif |
120 | #ifdef CONFIG_ETRAX_PB_LEDS | 120 | #ifdef CONFIG_ETRAX_PB_LEDS |
121 | move.b $r2, [R_PORT_PB_DATA] | 121 | move.b $r2, [R_PORT_PB_DATA] |
122 | #endif | 122 | #endif |
123 | #endif | 123 | #endif |
124 | 124 | ||
125 | ;; check if we got something on the serial port | 125 | ;; check if we got something on the serial port |
126 | 126 | ||
127 | move.b [SERSTAT], $r0 | 127 | move.b [SERSTAT], $r0 |
128 | btstq 0, $r0 ; data_avail | 128 | btstq 0, $r0 ; data_avail |
129 | bpl wait_ser | 129 | bpl wait_ser |
130 | nop | 130 | nop |
131 | 131 | ||
@@ -134,7 +134,7 @@ wait_ser: | |||
134 | move.b [SERRDAT], $r0 | 134 | move.b [SERRDAT], $r0 |
135 | move.b $r0, [$r3+] | 135 | move.b $r0, [$r3+] |
136 | move.d TIMEOUT_VALUE, $r5 ; reset "timeout" | 136 | move.d TIMEOUT_VALUE, $r5 ; reset "timeout" |
137 | subq 1, $r4 ; decrease length | 137 | subq 1, $r4 ; decrease length |
138 | bne wait_ser | 138 | bne wait_ser |
139 | nop | 139 | nop |
140 | jump_start: | 140 | jump_start: |
diff --git a/arch/cris/arch-v10/boot/rescue/testrescue.S b/arch/cris/arch-v10/boot/rescue/testrescue.S index 566a9f341254..2d937f9afe23 100644 --- a/arch/cris/arch-v10/boot/rescue/testrescue.S +++ b/arch/cris/arch-v10/boot/rescue/testrescue.S | |||
@@ -1,13 +1,12 @@ | |||
1 | /* $Id: testrescue.S,v 1.1 2001/12/17 13:59:27 bjornw Exp $ | 1 | /* |
2 | * | ||
3 | * Simple testcode to download by the rescue block. | 2 | * Simple testcode to download by the rescue block. |
4 | * Just lits some LEDs to show it was downloaded correctly. | 3 | * Just lights some LEDs to show it was downloaded correctly. |
5 | * | 4 | * |
6 | * Copyright (C) 1999 Axis Communications AB | 5 | * Copyright (C) 1999 Axis Communications AB |
7 | */ | 6 | */ |
8 | 7 | ||
9 | #define ASSEMBLER_MACROS_ONLY | 8 | #define ASSEMBLER_MACROS_ONLY |
10 | #include <asm/sv_addr_ag.h> | 9 | #include <asm/arch/sv_addr_ag.h> |
11 | 10 | ||
12 | .text | 11 | .text |
13 | 12 | ||
@@ -16,11 +15,10 @@ | |||
16 | moveq -1, $r2 | 15 | moveq -1, $r2 |
17 | move.b $r2, [R_PORT_PA_DIR] | 16 | move.b $r2, [R_PORT_PA_DIR] |
18 | moveq 0, $r2 | 17 | moveq 0, $r2 |
19 | move.b $r2, [R_PORT_PA_DATA] | 18 | move.b $r2, [R_PORT_PA_DATA] |
20 | 19 | ||
21 | endless: | 20 | endless: |
22 | nop | 21 | nop |
23 | ba endless | 22 | ba endless |
24 | nop | 23 | nop |
25 | 24 | ||
26 | |||
diff --git a/arch/cris/arch-v10/drivers/Kconfig b/arch/cris/arch-v10/drivers/Kconfig index 96740ef497d4..58f5864a6680 100644 --- a/arch/cris/arch-v10/drivers/Kconfig +++ b/arch/cris/arch-v10/drivers/Kconfig | |||
@@ -9,37 +9,6 @@ config ETRAX_ETHERNET | |||
9 | This option enables the ETRAX 100LX built-in 10/100Mbit Ethernet | 9 | This option enables the ETRAX 100LX built-in 10/100Mbit Ethernet |
10 | controller. | 10 | controller. |
11 | 11 | ||
12 | choice | ||
13 | prompt "Network LED behavior" | ||
14 | depends on ETRAX_ETHERNET | ||
15 | default ETRAX_NETWORK_LED_ON_WHEN_ACTIVITY | ||
16 | |||
17 | config ETRAX_NETWORK_LED_ON_WHEN_LINK | ||
18 | bool "LED_on_when_link" | ||
19 | help | ||
20 | Selecting LED_on_when_link will light the LED when there is a | ||
21 | connection and will flash off when there is activity. | ||
22 | |||
23 | Selecting LED_on_when_activity will light the LED only when | ||
24 | there is activity. | ||
25 | |||
26 | This setting will also affect the behaviour of other activity LEDs | ||
27 | e.g. Bluetooth. | ||
28 | |||
29 | config ETRAX_NETWORK_LED_ON_WHEN_ACTIVITY | ||
30 | bool "LED_on_when_activity" | ||
31 | help | ||
32 | Selecting LED_on_when_link will light the LED when there is a | ||
33 | connection and will flash off when there is activity. | ||
34 | |||
35 | Selecting LED_on_when_activity will light the LED only when | ||
36 | there is activity. | ||
37 | |||
38 | This setting will also affect the behaviour of other activity LEDs | ||
39 | e.g. Bluetooth. | ||
40 | |||
41 | endchoice | ||
42 | |||
43 | config ETRAX_SERIAL | 12 | config ETRAX_SERIAL |
44 | bool "Serial-port support" | 13 | bool "Serial-port support" |
45 | depends on ETRAX_ARCH_V10 | 14 | depends on ETRAX_ARCH_V10 |
@@ -84,32 +53,6 @@ config ETRAX_SERIAL_PORT0 | |||
84 | the same DMA channels. | 53 | the same DMA channels. |
85 | 54 | ||
86 | choice | 55 | choice |
87 | prompt "Ser0 DMA out assignment" | ||
88 | depends on ETRAX_SERIAL_PORT0 | ||
89 | default ETRAX_SERIAL_PORT0_DMA6_OUT | ||
90 | |||
91 | config ETRAX_SERIAL_PORT0_NO_DMA_OUT | ||
92 | bool "No DMA out" | ||
93 | |||
94 | config ETRAX_SERIAL_PORT0_DMA6_OUT | ||
95 | bool "DMA 6" | ||
96 | |||
97 | endchoice | ||
98 | |||
99 | choice | ||
100 | prompt "Ser0 DMA in assignment" | ||
101 | depends on ETRAX_SERIAL_PORT0 | ||
102 | default ETRAX_SERIAL_PORT0_DMA7_IN | ||
103 | |||
104 | config ETRAX_SERIAL_PORT0_NO_DMA_IN | ||
105 | bool "No DMA in" | ||
106 | |||
107 | config ETRAX_SERIAL_PORT0_DMA7_IN | ||
108 | bool "DMA 7" | ||
109 | |||
110 | endchoice | ||
111 | |||
112 | choice | ||
113 | prompt "Ser0 DTR, RI, DSR and CD assignment" | 56 | prompt "Ser0 DTR, RI, DSR and CD assignment" |
114 | depends on ETRAX_SERIAL_PORT0 | 57 | depends on ETRAX_SERIAL_PORT0 |
115 | default ETRAX_SER0_DTR_RI_DSR_CD_ON_NONE | 58 | default ETRAX_SER0_DTR_RI_DSR_CD_ON_NONE |
@@ -198,32 +141,6 @@ config ETRAX_SERIAL_PORT1 | |||
198 | Enables the ETRAX 100 serial driver for ser1 (ttyS1). | 141 | Enables the ETRAX 100 serial driver for ser1 (ttyS1). |
199 | 142 | ||
200 | choice | 143 | choice |
201 | prompt "Ser1 DMA out assignment" | ||
202 | depends on ETRAX_SERIAL_PORT1 | ||
203 | default ETRAX_SERIAL_PORT1_DMA8_OUT | ||
204 | |||
205 | config ETRAX_SERIAL_PORT1_NO_DMA_OUT | ||
206 | bool "No DMA out" | ||
207 | |||
208 | config ETRAX_SERIAL_PORT1_DMA8_OUT | ||
209 | bool "DMA 8" | ||
210 | |||
211 | endchoice | ||
212 | |||
213 | choice | ||
214 | prompt "Ser1 DMA in assignment" | ||
215 | depends on ETRAX_SERIAL_PORT1 | ||
216 | default ETRAX_SERIAL_PORT1_DMA9_IN | ||
217 | |||
218 | config ETRAX_SERIAL_PORT1_NO_DMA_IN | ||
219 | bool "No DMA in" | ||
220 | |||
221 | config ETRAX_SERIAL_PORT1_DMA9_IN | ||
222 | bool "DMA 9" | ||
223 | |||
224 | endchoice | ||
225 | |||
226 | choice | ||
227 | prompt "Ser1 DTR, RI, DSR and CD assignment" | 144 | prompt "Ser1 DTR, RI, DSR and CD assignment" |
228 | depends on ETRAX_SERIAL_PORT1 | 145 | depends on ETRAX_SERIAL_PORT1 |
229 | default ETRAX_SER1_DTR_RI_DSR_CD_ON_NONE | 146 | default ETRAX_SER1_DTR_RI_DSR_CD_ON_NONE |
@@ -315,32 +232,6 @@ config ETRAX_SERIAL_PORT2 | |||
315 | Enables the ETRAX 100 serial driver for ser2 (ttyS2). | 232 | Enables the ETRAX 100 serial driver for ser2 (ttyS2). |
316 | 233 | ||
317 | choice | 234 | choice |
318 | prompt "Ser2 DMA out assignment" | ||
319 | depends on ETRAX_SERIAL_PORT2 | ||
320 | default ETRAX_SERIAL_PORT2_DMA2_OUT | ||
321 | |||
322 | config ETRAX_SERIAL_PORT2_NO_DMA_OUT | ||
323 | bool "No DMA out" | ||
324 | |||
325 | config ETRAX_SERIAL_PORT2_DMA2_OUT | ||
326 | bool "DMA 2" | ||
327 | |||
328 | endchoice | ||
329 | |||
330 | choice | ||
331 | prompt "Ser2 DMA in assignment" | ||
332 | depends on ETRAX_SERIAL_PORT2 | ||
333 | default ETRAX_SERIAL_PORT2_DMA3_IN | ||
334 | |||
335 | config ETRAX_SERIAL_PORT2_NO_DMA_IN | ||
336 | bool "No DMA in" | ||
337 | |||
338 | config ETRAX_SERIAL_PORT2_DMA3_IN | ||
339 | bool "DMA 3" | ||
340 | |||
341 | endchoice | ||
342 | |||
343 | choice | ||
344 | prompt "Ser2 DTR, RI, DSR and CD assignment" | 235 | prompt "Ser2 DTR, RI, DSR and CD assignment" |
345 | depends on ETRAX_SERIAL_PORT2 | 236 | depends on ETRAX_SERIAL_PORT2 |
346 | default ETRAX_SER2_DTR_RI_DSR_CD_ON_NONE | 237 | default ETRAX_SER2_DTR_RI_DSR_CD_ON_NONE |
@@ -429,32 +320,6 @@ config ETRAX_SERIAL_PORT3 | |||
429 | Enables the ETRAX 100 serial driver for ser3 (ttyS3). | 320 | Enables the ETRAX 100 serial driver for ser3 (ttyS3). |
430 | 321 | ||
431 | choice | 322 | choice |
432 | prompt "Ser3 DMA out assignment" | ||
433 | depends on ETRAX_SERIAL_PORT3 | ||
434 | default ETRAX_SERIAL_PORT3_DMA4_OUT | ||
435 | |||
436 | config ETRAX_SERIAL_PORT3_NO_DMA_OUT | ||
437 | bool "No DMA out" | ||
438 | |||
439 | config ETRAX_SERIAL_PORT3_DMA4_OUT | ||
440 | bool "DMA 4" | ||
441 | |||
442 | endchoice | ||
443 | |||
444 | choice | ||
445 | prompt "Ser3 DMA in assignment" | ||
446 | depends on ETRAX_SERIAL_PORT3 | ||
447 | default ETRAX_SERIAL_PORT3_DMA5_IN | ||
448 | |||
449 | config ETRAX_SERIAL_PORT3_NO_DMA_IN | ||
450 | bool "No DMA in" | ||
451 | |||
452 | config ETRAX_SERIAL_PORT3_DMA5_IN | ||
453 | bool "DMA 5" | ||
454 | |||
455 | endchoice | ||
456 | |||
457 | choice | ||
458 | prompt "Ser3 DTR, RI, DSR and CD assignment" | 323 | prompt "Ser3 DTR, RI, DSR and CD assignment" |
459 | depends on ETRAX_SERIAL_PORT3 | 324 | depends on ETRAX_SERIAL_PORT3 |
460 | default ETRAX_SER3_DTR_RI_DSR_CD_ON_NONE | 325 | default ETRAX_SER3_DTR_RI_DSR_CD_ON_NONE |
@@ -563,21 +428,6 @@ config ETRAX_USB_HOST_PORT2 | |||
563 | depends on ETRAX_USB_HOST | 428 | depends on ETRAX_USB_HOST |
564 | default n | 429 | default n |
565 | 430 | ||
566 | config ETRAX_AXISFLASHMAP | ||
567 | bool "Axis flash-map support" | ||
568 | depends on ETRAX_ARCH_V10 | ||
569 | select MTD | ||
570 | select MTD_CFI | ||
571 | select MTD_CFI_AMDSTD | ||
572 | select MTD_CHAR | ||
573 | select MTD_BLOCK | ||
574 | select MTD_PARTITIONS | ||
575 | select MTD_CONCAT | ||
576 | select MTD_COMPLEX_MAPPINGS | ||
577 | help | ||
578 | This option enables MTD mapping of flash devices. Needed to use | ||
579 | flash memories. If unsure, say Y. | ||
580 | |||
581 | config ETRAX_PTABLE_SECTOR | 431 | config ETRAX_PTABLE_SECTOR |
582 | int "Byte-offset of partition table sector" | 432 | int "Byte-offset of partition table sector" |
583 | depends on ETRAX_AXISFLASHMAP | 433 | depends on ETRAX_AXISFLASHMAP |
@@ -731,37 +581,6 @@ config ETRAX_PB_CHANGEABLE_BITS | |||
731 | Bit set = changeable. | 581 | Bit set = changeable. |
732 | You probably want 00 here. | 582 | You probably want 00 here. |
733 | 583 | ||
734 | config ETRAX_RTC | ||
735 | bool "Real Time Clock support" | ||
736 | depends on ETRAX_ARCH_V10 | ||
737 | help | ||
738 | Enables drivers for the Real-Time Clock battery-backed chips on | ||
739 | some products. The kernel reads the time when booting, and | ||
740 | the date can be set using ioctl(fd, RTC_SET_TIME, &rt) with rt a | ||
741 | rtc_time struct (see <file:include/asm-cris/rtc.h>) on the /dev/rtc | ||
742 | device, major 121. You can check the time with cat /proc/rtc, but | ||
743 | normal time reading should be done using libc function time and | ||
744 | friends. | ||
745 | |||
746 | choice | ||
747 | prompt "RTC chip" | ||
748 | depends on ETRAX_RTC | ||
749 | default ETRAX_DS1302 | ||
750 | |||
751 | config ETRAX_DS1302 | ||
752 | bool "DS1302" | ||
753 | help | ||
754 | Enables the driver for the DS1302 Real-Time Clock battery-backed | ||
755 | chip on some products. | ||
756 | |||
757 | config ETRAX_PCF8563 | ||
758 | bool "PCF8563" | ||
759 | help | ||
760 | Enables the driver for the PCF8563 Real-Time Clock battery-backed | ||
761 | chip on some products. | ||
762 | |||
763 | endchoice | ||
764 | |||
765 | config ETRAX_DS1302_RST_ON_GENERIC_PORT | 584 | config ETRAX_DS1302_RST_ON_GENERIC_PORT |
766 | bool "DS1302 RST on Generic Port" | 585 | bool "DS1302 RST on Generic Port" |
767 | depends on ETRAX_DS1302 | 586 | depends on ETRAX_DS1302 |
diff --git a/arch/cris/arch-v10/drivers/Makefile b/arch/cris/arch-v10/drivers/Makefile index 20258e36f384..44bf2e88c26e 100644 --- a/arch/cris/arch-v10/drivers/Makefile +++ b/arch/cris/arch-v10/drivers/Makefile | |||
@@ -2,11 +2,11 @@ | |||
2 | # Makefile for Etrax-specific drivers | 2 | # Makefile for Etrax-specific drivers |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-$(CONFIG_ETRAX_AXISFLASHMAP) += axisflashmap.o | 5 | obj-$(CONFIG_ETRAX_AXISFLASHMAP) += axisflashmap.o |
6 | obj-$(CONFIG_ETRAX_I2C) += i2c.o | 6 | obj-$(CONFIG_ETRAX_I2C) += i2c.o |
7 | obj-$(CONFIG_ETRAX_I2C_EEPROM) += eeprom.o | 7 | obj-$(CONFIG_ETRAX_I2C_EEPROM) += eeprom.o |
8 | obj-$(CONFIG_ETRAX_GPIO) += gpio.o | 8 | obj-$(CONFIG_ETRAX_GPIO) += gpio.o |
9 | obj-$(CONFIG_ETRAX_DS1302) += ds1302.o | 9 | obj-$(CONFIG_ETRAX_DS1302) += ds1302.o |
10 | obj-$(CONFIG_ETRAX_PCF8563) += pcf8563.o | 10 | obj-$(CONFIG_ETRAX_PCF8563) += pcf8563.o |
11 | 11 | obj-$(CONFIG_ETRAX_SYNCHRONOUS_SERIAL) += sync_serial.o | |
12 | 12 | ||
diff --git a/arch/cris/arch-v10/drivers/axisflashmap.c b/arch/cris/arch-v10/drivers/axisflashmap.c index ea3cf2e39a14..b3bdda93ffef 100644 --- a/arch/cris/arch-v10/drivers/axisflashmap.c +++ b/arch/cris/arch-v10/drivers/axisflashmap.c | |||
@@ -10,129 +10,6 @@ | |||
10 | * tells us what other partitions to define. If there isn't, we use a default | 10 | * tells us what other partitions to define. If there isn't, we use a default |
11 | * partition split defined below. | 11 | * partition split defined below. |
12 | * | 12 | * |
13 | * $Log: axisflashmap.c,v $ | ||
14 | * Revision 1.11 2004/11/15 10:27:14 starvik | ||
15 | * Corrected typo (Thanks to Milton Miller <miltonm@bga.com>). | ||
16 | * | ||
17 | * Revision 1.10 2004/08/16 12:37:22 starvik | ||
18 | * Merge of Linux 2.6.8 | ||
19 | * | ||
20 | * Revision 1.8 2004/05/14 07:58:03 starvik | ||
21 | * Merge of changes from 2.4 | ||
22 | * | ||
23 | * Revision 1.6 2003/07/04 08:27:37 starvik | ||
24 | * Merge of Linux 2.5.74 | ||
25 | * | ||
26 | * Revision 1.5 2002/12/11 13:13:57 starvik | ||
27 | * Added arch/ to v10 specific includes | ||
28 | * Added fix from Linux 2.4 in serial.c (flush_to_flip_buffer) | ||
29 | * | ||
30 | * Revision 1.4 2002/11/20 11:56:10 starvik | ||
31 | * Merge of Linux 2.5.48 | ||
32 | * | ||
33 | * Revision 1.3 2002/11/13 14:54:13 starvik | ||
34 | * Copied from linux 2.4 | ||
35 | * | ||
36 | * Revision 1.28 2002/10/01 08:08:43 jonashg | ||
37 | * The first partition ends at the start of the partition table. | ||
38 | * | ||
39 | * Revision 1.27 2002/08/21 09:23:13 jonashg | ||
40 | * Speling. | ||
41 | * | ||
42 | * Revision 1.26 2002/08/21 08:35:20 jonashg | ||
43 | * Cosmetic change to printouts. | ||
44 | * | ||
45 | * Revision 1.25 2002/08/21 08:15:42 jonashg | ||
46 | * Made it compile even without CONFIG_MTD_CONCAT defined. | ||
47 | * | ||
48 | * Revision 1.24 2002/08/20 13:12:35 jonashg | ||
49 | * * New approach to probing. Probe cse0 and cse1 separately and (mtd)concat | ||
50 | * the results. | ||
51 | * * Removed compile time tests concerning how the mtdram driver has been | ||
52 | * configured. The user will know about the misconfiguration at runtime | ||
53 | * instead. (The old approach made it impossible to use mtdram for anything | ||
54 | * else than RAM boot). | ||
55 | * | ||
56 | * Revision 1.23 2002/05/13 12:12:28 johana | ||
57 | * Allow compile without CONFIG_MTD_MTDRAM but warn at compiletime and | ||
58 | * be informative at runtime. | ||
59 | * | ||
60 | * Revision 1.22 2002/05/13 10:24:44 johana | ||
61 | * Added #if checks on MTDRAM CONFIG | ||
62 | * | ||
63 | * Revision 1.21 2002/05/06 16:05:20 johana | ||
64 | * Removed debug printout. | ||
65 | * | ||
66 | * Revision 1.20 2002/05/06 16:03:00 johana | ||
67 | * No more cramfs as root hack in generic code. | ||
68 | * It's handled by axisflashmap using mtdram. | ||
69 | * | ||
70 | * Revision 1.19 2002/03/15 17:10:28 bjornw | ||
71 | * Changed comment about cached access since we changed this before | ||
72 | * | ||
73 | * Revision 1.18 2002/03/05 17:06:15 jonashg | ||
74 | * Try amd_flash probe before cfi_probe since amd_flash driver can handle two | ||
75 | * (or more) flash chips of different model and the cfi driver cannot. | ||
76 | * | ||
77 | * Revision 1.17 2001/11/12 19:42:38 pkj | ||
78 | * Fixed compiler warnings. | ||
79 | * | ||
80 | * Revision 1.16 2001/11/08 11:18:58 jonashg | ||
81 | * Always read from uncached address to avoid problems with flushing | ||
82 | * cachelines after write and MTD-erase. No performance loss have been | ||
83 | * seen yet. | ||
84 | * | ||
85 | * Revision 1.15 2001/10/19 12:41:04 jonashg | ||
86 | * Name of probe has changed in MTD. | ||
87 | * | ||
88 | * Revision 1.14 2001/09/21 07:14:10 jonashg | ||
89 | * Made root filesystem (cramfs) use mtdblock driver when booting from flash. | ||
90 | * | ||
91 | * Revision 1.13 2001/08/15 13:57:35 jonashg | ||
92 | * Entire MTD updated to the linux 2.4.7 version. | ||
93 | * | ||
94 | * Revision 1.12 2001/06/11 09:50:30 jonashg | ||
95 | * Oops, 2MB is 0x200000 bytes. | ||
96 | * | ||
97 | * Revision 1.11 2001/06/08 11:39:44 jonashg | ||
98 | * Changed sizes and offsets in axis_default_partitions to use | ||
99 | * CONFIG_ETRAX_PTABLE_SECTOR. | ||
100 | * | ||
101 | * Revision 1.10 2001/05/29 09:42:03 jonashg | ||
102 | * Use macro for end marker length instead of sizeof. | ||
103 | * | ||
104 | * Revision 1.9 2001/05/29 08:52:52 jonashg | ||
105 | * Gave names to the magic fours (size of the ptable end marker). | ||
106 | * | ||
107 | * Revision 1.8 2001/05/28 15:36:20 jonashg | ||
108 | * * Removed old comment about ptable location in flash (it's a CONFIG_ option). | ||
109 | * * Variable ptable was initialized twice to the same value. | ||
110 | * | ||
111 | * Revision 1.7 2001/04/05 13:41:46 markusl | ||
112 | * Updated according to review remarks | ||
113 | * | ||
114 | * Revision 1.6 2001/03/07 09:21:21 bjornw | ||
115 | * No need to waste .data | ||
116 | * | ||
117 | * Revision 1.5 2001/03/06 16:27:01 jonashg | ||
118 | * Probe the entire flash area for flash devices. | ||
119 | * | ||
120 | * Revision 1.4 2001/02/23 12:47:15 bjornw | ||
121 | * Uncached flash in LOW_MAP moved from 0xe to 0x8 | ||
122 | * | ||
123 | * Revision 1.3 2001/02/16 12:11:45 jonashg | ||
124 | * MTD driver amd_flash is now included in MTD CVS repository. | ||
125 | * (It's now in drivers/mtd). | ||
126 | * | ||
127 | * Revision 1.2 2001/02/09 11:12:22 jonashg | ||
128 | * Support for AMD compatible non-CFI flash chips. | ||
129 | * Only tested with Toshiba TC58FVT160 so far. | ||
130 | * | ||
131 | * Revision 1.1 2001/01/12 17:01:18 bjornw | ||
132 | * * Added axisflashmap.c, a physical mapping for MTD that reads and understands | ||
133 | * Axis partition-table format. | ||
134 | * | ||
135 | * | ||
136 | */ | 13 | */ |
137 | 14 | ||
138 | #include <linux/module.h> | 15 | #include <linux/module.h> |
@@ -235,7 +112,7 @@ static struct map_info map_cse1 = { | |||
235 | }; | 112 | }; |
236 | 113 | ||
237 | /* If no partition-table was found, we use this default-set. */ | 114 | /* If no partition-table was found, we use this default-set. */ |
238 | #define MAX_PARTITIONS 7 | 115 | #define MAX_PARTITIONS 7 |
239 | #define NUM_DEFAULT_PARTITIONS 3 | 116 | #define NUM_DEFAULT_PARTITIONS 3 |
240 | 117 | ||
241 | /* | 118 | /* |
@@ -300,6 +177,15 @@ static struct mtd_partition axis_partitions[MAX_PARTITIONS] = { | |||
300 | }, | 177 | }, |
301 | }; | 178 | }; |
302 | 179 | ||
180 | #ifdef CONFIG_ETRAX_AXISFLASHMAP_MTD0WHOLE | ||
181 | /* Main flash device */ | ||
182 | static struct mtd_partition main_partition = { | ||
183 | .name = "main", | ||
184 | .size = 0, | ||
185 | .offset = 0 | ||
186 | }; | ||
187 | #endif | ||
188 | |||
303 | /* | 189 | /* |
304 | * Probe a chip select for AMD-compatible (JEDEC) or CFI-compatible flash | 190 | * Probe a chip select for AMD-compatible (JEDEC) or CFI-compatible flash |
305 | * chips in that order (because the amd_flash-driver is faster). | 191 | * chips in that order (because the amd_flash-driver is faster). |
@@ -316,15 +202,14 @@ static struct mtd_info *probe_cs(struct map_info *map_cs) | |||
316 | mtd_cs = do_map_probe("cfi_probe", map_cs); | 202 | mtd_cs = do_map_probe("cfi_probe", map_cs); |
317 | #endif | 203 | #endif |
318 | #ifdef CONFIG_MTD_JEDECPROBE | 204 | #ifdef CONFIG_MTD_JEDECPROBE |
319 | if (!mtd_cs) { | 205 | if (!mtd_cs) |
320 | mtd_cs = do_map_probe("jedec_probe", map_cs); | 206 | mtd_cs = do_map_probe("jedec_probe", map_cs); |
321 | } | ||
322 | #endif | 207 | #endif |
323 | 208 | ||
324 | return mtd_cs; | 209 | return mtd_cs; |
325 | } | 210 | } |
326 | 211 | ||
327 | /* | 212 | /* |
328 | * Probe each chip select individually for flash chips. If there are chips on | 213 | * Probe each chip select individually for flash chips. If there are chips on |
329 | * both cse0 and cse1, the mtd_info structs will be concatenated to one struct | 214 | * both cse0 and cse1, the mtd_info structs will be concatenated to one struct |
330 | * so that MTD partitions can cross chip boundries. | 215 | * so that MTD partitions can cross chip boundries. |
@@ -351,7 +236,7 @@ static struct mtd_info *flash_probe(void) | |||
351 | if (mtd_cse0 && mtd_cse1) { | 236 | if (mtd_cse0 && mtd_cse1) { |
352 | #ifdef CONFIG_MTD_CONCAT | 237 | #ifdef CONFIG_MTD_CONCAT |
353 | struct mtd_info *mtds[] = { mtd_cse0, mtd_cse1 }; | 238 | struct mtd_info *mtds[] = { mtd_cse0, mtd_cse1 }; |
354 | 239 | ||
355 | /* Since the concatenation layer adds a small overhead we | 240 | /* Since the concatenation layer adds a small overhead we |
356 | * could try to figure out if the chips in cse0 and cse1 are | 241 | * could try to figure out if the chips in cse0 and cse1 are |
357 | * identical and reprobe the whole cse0+cse1 window. But since | 242 | * identical and reprobe the whole cse0+cse1 window. But since |
@@ -372,7 +257,7 @@ static struct mtd_info *flash_probe(void) | |||
372 | 257 | ||
373 | /* The best we can do now is to only use what we found | 258 | /* The best we can do now is to only use what we found |
374 | * at cse0. | 259 | * at cse0. |
375 | */ | 260 | */ |
376 | mtd_cse = mtd_cse0; | 261 | mtd_cse = mtd_cse0; |
377 | map_destroy(mtd_cse1); | 262 | map_destroy(mtd_cse1); |
378 | } | 263 | } |
@@ -395,7 +280,7 @@ static int __init init_axis_flash(void) | |||
395 | struct partitiontable_head *ptable_head = NULL; | 280 | struct partitiontable_head *ptable_head = NULL; |
396 | struct partitiontable_entry *ptable; | 281 | struct partitiontable_entry *ptable; |
397 | int use_default_ptable = 1; /* Until proven otherwise. */ | 282 | int use_default_ptable = 1; /* Until proven otherwise. */ |
398 | const char *pmsg = " /dev/flash%d at 0x%08x, size 0x%08x\n"; | 283 | const char pmsg[] = " /dev/flash%d at 0x%08x, size 0x%08x\n"; |
399 | 284 | ||
400 | if (!(mymtd = flash_probe())) { | 285 | if (!(mymtd = flash_probe())) { |
401 | /* There's no reason to use this module if no flash chip can | 286 | /* There's no reason to use this module if no flash chip can |
@@ -435,7 +320,7 @@ static int __init init_axis_flash(void) | |||
435 | unsigned long offset = CONFIG_ETRAX_PTABLE_SECTOR; | 320 | unsigned long offset = CONFIG_ETRAX_PTABLE_SECTOR; |
436 | unsigned char *p; | 321 | unsigned char *p; |
437 | unsigned long csum = 0; | 322 | unsigned long csum = 0; |
438 | 323 | ||
439 | ptable = (struct partitiontable_entry *) | 324 | ptable = (struct partitiontable_entry *) |
440 | ((unsigned long)ptable_head + sizeof(*ptable_head)); | 325 | ((unsigned long)ptable_head + sizeof(*ptable_head)); |
441 | 326 | ||
@@ -490,6 +375,16 @@ static int __init init_axis_flash(void) | |||
490 | pidx++; | 375 | pidx++; |
491 | } | 376 | } |
492 | 377 | ||
378 | #ifdef CONFIG_ETRAX_AXISFLASHMAP_MTD0WHOLE | ||
379 | if (mymtd) { | ||
380 | main_partition.size = mymtd->size; | ||
381 | err = add_mtd_partitions(mymtd, &main_partition, 1); | ||
382 | if (err) | ||
383 | panic("axisflashmap: Could not initialize " | ||
384 | "partition for whole main mtd device!\n"); | ||
385 | } | ||
386 | #endif | ||
387 | |||
493 | if (mymtd) { | 388 | if (mymtd) { |
494 | if (use_default_ptable) { | 389 | if (use_default_ptable) { |
495 | printk(KERN_INFO " Using default partition table.\n"); | 390 | printk(KERN_INFO " Using default partition table.\n"); |
@@ -499,9 +394,8 @@ static int __init init_axis_flash(void) | |||
499 | err = add_mtd_partitions(mymtd, axis_partitions, pidx); | 394 | err = add_mtd_partitions(mymtd, axis_partitions, pidx); |
500 | } | 395 | } |
501 | 396 | ||
502 | if (err) { | 397 | if (err) |
503 | panic("axisflashmap could not add MTD partitions!\n"); | 398 | panic("axisflashmap could not add MTD partitions!\n"); |
504 | } | ||
505 | } | 399 | } |
506 | 400 | ||
507 | if (!romfs_in_flash) { | 401 | if (!romfs_in_flash) { |
@@ -515,25 +409,24 @@ static int __init init_axis_flash(void) | |||
515 | #else | 409 | #else |
516 | struct mtd_info *mtd_ram; | 410 | struct mtd_info *mtd_ram; |
517 | 411 | ||
518 | mtd_ram = kmalloc(sizeof(struct mtd_info), | 412 | mtd_ram = kmalloc(sizeof(struct mtd_info), GFP_KERNEL); |
519 | GFP_KERNEL); | 413 | if (!mtd_ram) |
520 | if (!mtd_ram) { | ||
521 | panic("axisflashmap couldn't allocate memory for " | 414 | panic("axisflashmap couldn't allocate memory for " |
522 | "mtd_info!\n"); | 415 | "mtd_info!\n"); |
523 | } | ||
524 | 416 | ||
525 | printk(KERN_INFO " Adding RAM partition for romfs image:\n"); | 417 | printk(KERN_INFO " Adding RAM partition for romfs image:\n"); |
526 | printk(pmsg, pidx, romfs_start, romfs_length); | 418 | printk(pmsg, pidx, (unsigned)romfs_start, |
527 | 419 | (unsigned)romfs_length); | |
528 | err = mtdram_init_device(mtd_ram, (void*)romfs_start, | 420 | |
529 | romfs_length, "romfs"); | 421 | err = mtdram_init_device(mtd_ram, |
530 | if (err) { | 422 | (void *)romfs_start, |
423 | romfs_length, | ||
424 | "romfs"); | ||
425 | if (err) | ||
531 | panic("axisflashmap could not initialize MTD RAM " | 426 | panic("axisflashmap could not initialize MTD RAM " |
532 | "device!\n"); | 427 | "device!\n"); |
533 | } | ||
534 | #endif | 428 | #endif |
535 | } | 429 | } |
536 | |||
537 | return err; | 430 | return err; |
538 | } | 431 | } |
539 | 432 | ||
diff --git a/arch/cris/arch-v10/drivers/ds1302.c b/arch/cris/arch-v10/drivers/ds1302.c index 1d1936a18133..c9aa3904be05 100644 --- a/arch/cris/arch-v10/drivers/ds1302.c +++ b/arch/cris/arch-v10/drivers/ds1302.c | |||
@@ -333,7 +333,7 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
333 | ds1302_writereg(RTC_TRICKLECHARGER, tcs_val); | 333 | ds1302_writereg(RTC_TRICKLECHARGER, tcs_val); |
334 | return 0; | 334 | return 0; |
335 | } | 335 | } |
336 | case RTC_VLOW_RD: | 336 | case RTC_VL_READ: |
337 | { | 337 | { |
338 | /* TODO: | 338 | /* TODO: |
339 | * Implement voltage low detection support | 339 | * Implement voltage low detection support |
@@ -342,7 +342,7 @@ rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
342 | " is not supported\n"); | 342 | " is not supported\n"); |
343 | return 0; | 343 | return 0; |
344 | } | 344 | } |
345 | case RTC_VLOW_SET: | 345 | case RTC_VL_CLR: |
346 | { | 346 | { |
347 | /* TODO: | 347 | /* TODO: |
348 | * Nothing to do since Voltage Low detection is not supported | 348 | * Nothing to do since Voltage Low detection is not supported |
diff --git a/arch/cris/arch-v10/drivers/eeprom.c b/arch/cris/arch-v10/drivers/eeprom.c index be35a70798aa..f1cac9dc75b8 100644 --- a/arch/cris/arch-v10/drivers/eeprom.c +++ b/arch/cris/arch-v10/drivers/eeprom.c | |||
@@ -19,77 +19,6 @@ | |||
19 | *! Sep 03 1999 Edgar Iglesias Added bail-out stuff if we get interrupted | 19 | *! Sep 03 1999 Edgar Iglesias Added bail-out stuff if we get interrupted |
20 | *! in the spin-lock. | 20 | *! in the spin-lock. |
21 | *! | 21 | *! |
22 | *! $Log: eeprom.c,v $ | ||
23 | *! Revision 1.12 2005/06/19 17:06:46 starvik | ||
24 | *! Merge of Linux 2.6.12. | ||
25 | *! | ||
26 | *! Revision 1.11 2005/01/26 07:14:46 starvik | ||
27 | *! Applied diff from kernel janitors (Nish Aravamudan). | ||
28 | *! | ||
29 | *! Revision 1.10 2003/09/11 07:29:48 starvik | ||
30 | *! Merge of Linux 2.6.0-test5 | ||
31 | *! | ||
32 | *! Revision 1.9 2003/07/04 08:27:37 starvik | ||
33 | *! Merge of Linux 2.5.74 | ||
34 | *! | ||
35 | *! Revision 1.8 2003/04/09 05:20:47 starvik | ||
36 | *! Merge of Linux 2.5.67 | ||
37 | *! | ||
38 | *! Revision 1.6 2003/02/10 07:19:28 starvik | ||
39 | *! Removed misplaced ; | ||
40 | *! | ||
41 | *! Revision 1.5 2002/12/11 13:13:57 starvik | ||
42 | *! Added arch/ to v10 specific includes | ||
43 | *! Added fix from Linux 2.4 in serial.c (flush_to_flip_buffer) | ||
44 | *! | ||
45 | *! Revision 1.4 2002/11/20 11:56:10 starvik | ||
46 | *! Merge of Linux 2.5.48 | ||
47 | *! | ||
48 | *! Revision 1.3 2002/11/18 13:16:06 starvik | ||
49 | *! Linux 2.5 port of latest 2.4 drivers | ||
50 | *! | ||
51 | *! Revision 1.8 2001/06/15 13:24:29 jonashg | ||
52 | *! * Added verification of pointers from userspace in read and write. | ||
53 | *! * Made busy counter volatile. | ||
54 | *! * Added define for initial write delay. | ||
55 | *! * Removed warnings by using loff_t instead of unsigned long. | ||
56 | *! | ||
57 | *! Revision 1.7 2001/06/14 15:26:54 jonashg | ||
58 | *! Removed test because condition is always true. | ||
59 | *! | ||
60 | *! Revision 1.6 2001/06/14 15:18:20 jonashg | ||
61 | *! Kb -> kB (makes quite a difference if you don't know if you have 2k or 16k). | ||
62 | *! | ||
63 | *! Revision 1.5 2001/06/14 14:39:51 jonashg | ||
64 | *! Forgot to use name when registering the driver. | ||
65 | *! | ||
66 | *! Revision 1.4 2001/06/14 14:35:47 jonashg | ||
67 | *! * Gave driver a name and used it in printk's. | ||
68 | *! * Cleanup. | ||
69 | *! | ||
70 | *! Revision 1.3 2001/03/19 16:04:46 markusl | ||
71 | *! Fixed init of fops struct | ||
72 | *! | ||
73 | *! Revision 1.2 2001/03/19 10:35:07 markusl | ||
74 | *! 2.4 port of eeprom driver | ||
75 | *! | ||
76 | *! Revision 1.8 2000/05/18 10:42:25 edgar | ||
77 | *! Make sure to end write cycle on _every_ write | ||
78 | *! | ||
79 | *! Revision 1.7 2000/01/17 17:41:01 johana | ||
80 | *! Adjusted probing and return -ENOSPC when writing outside EEPROM | ||
81 | *! | ||
82 | *! Revision 1.6 2000/01/17 15:50:36 johana | ||
83 | *! Added adaptive timing adjustments and fixed autoprobing for 2k and 16k(?) | ||
84 | *! EEPROMs | ||
85 | *! | ||
86 | *! Revision 1.5 1999/09/03 15:07:37 edgar | ||
87 | *! Added bail-out check to the spinlock | ||
88 | *! | ||
89 | *! Revision 1.4 1999/09/03 12:11:17 bjornw | ||
90 | *! Proper atomicity (need to use spinlocks, not if's). users -> busy. | ||
91 | *! | ||
92 | *! | ||
93 | *! (c) 1999 Axis Communications AB, Lund, Sweden | 22 | *! (c) 1999 Axis Communications AB, Lund, Sweden |
94 | *!*****************************************************************************/ | 23 | *!*****************************************************************************/ |
95 | 24 | ||
@@ -103,10 +32,10 @@ | |||
103 | #include <asm/uaccess.h> | 32 | #include <asm/uaccess.h> |
104 | #include "i2c.h" | 33 | #include "i2c.h" |
105 | 34 | ||
106 | #define D(x) | 35 | #define D(x) |
107 | 36 | ||
108 | /* If we should use adaptive timing or not: */ | 37 | /* If we should use adaptive timing or not: */ |
109 | //#define EEPROM_ADAPTIVE_TIMING | 38 | /* #define EEPROM_ADAPTIVE_TIMING */ |
110 | 39 | ||
111 | #define EEPROM_MAJOR_NR 122 /* use a LOCAL/EXPERIMENTAL major for now */ | 40 | #define EEPROM_MAJOR_NR 122 /* use a LOCAL/EXPERIMENTAL major for now */ |
112 | #define EEPROM_MINOR_NR 0 | 41 | #define EEPROM_MINOR_NR 0 |
diff --git a/arch/cris/arch-v10/drivers/gpio.c b/arch/cris/arch-v10/drivers/gpio.c index 0d347a705835..68a998bd1069 100644 --- a/arch/cris/arch-v10/drivers/gpio.c +++ b/arch/cris/arch-v10/drivers/gpio.c | |||
@@ -1,138 +1,11 @@ | |||
1 | /* $Id: gpio.c,v 1.17 2005/06/19 17:06:46 starvik Exp $ | 1 | /* |
2 | * | ||
3 | * Etrax general port I/O device | 2 | * Etrax general port I/O device |
4 | * | 3 | * |
5 | * Copyright (c) 1999, 2000, 2001, 2002 Axis Communications AB | 4 | * Copyright (c) 1999-2007 Axis Communications AB |
6 | * | 5 | * |
7 | * Authors: Bjorn Wesen (initial version) | 6 | * Authors: Bjorn Wesen (initial version) |
8 | * Ola Knutsson (LED handling) | 7 | * Ola Knutsson (LED handling) |
9 | * Johan Adolfsson (read/set directions, write, port G) | 8 | * Johan Adolfsson (read/set directions, write, port G) |
10 | * | ||
11 | * $Log: gpio.c,v $ | ||
12 | * Revision 1.17 2005/06/19 17:06:46 starvik | ||
13 | * Merge of Linux 2.6.12. | ||
14 | * | ||
15 | * Revision 1.16 2005/03/07 13:02:29 starvik | ||
16 | * Protect driver global states with spinlock | ||
17 | * | ||
18 | * Revision 1.15 2005/01/05 06:08:55 starvik | ||
19 | * No need to do local_irq_disable after local_irq_save. | ||
20 | * | ||
21 | * Revision 1.14 2004/12/13 12:21:52 starvik | ||
22 | * Added I/O and DMA allocators from Linux 2.4 | ||
23 | * | ||
24 | * Revision 1.12 2004/08/24 07:19:59 starvik | ||
25 | * Whitespace cleanup | ||
26 | * | ||
27 | * Revision 1.11 2004/05/14 07:58:03 starvik | ||
28 | * Merge of changes from 2.4 | ||
29 | * | ||
30 | * Revision 1.9 2003/09/11 07:29:48 starvik | ||
31 | * Merge of Linux 2.6.0-test5 | ||
32 | * | ||
33 | * Revision 1.8 2003/07/04 08:27:37 starvik | ||
34 | * Merge of Linux 2.5.74 | ||
35 | * | ||
36 | * Revision 1.7 2003/01/10 07:44:07 starvik | ||
37 | * init_ioremap is now called by kernel before drivers are initialized | ||
38 | * | ||
39 | * Revision 1.6 2002/12/11 13:13:57 starvik | ||
40 | * Added arch/ to v10 specific includes | ||
41 | * Added fix from Linux 2.4 in serial.c (flush_to_flip_buffer) | ||
42 | * | ||
43 | * Revision 1.5 2002/11/20 11:56:11 starvik | ||
44 | * Merge of Linux 2.5.48 | ||
45 | * | ||
46 | * Revision 1.4 2002/11/18 10:10:05 starvik | ||
47 | * Linux 2.5 port of latest gpio.c from Linux 2.4 | ||
48 | * | ||
49 | * Revision 1.20 2002/10/16 21:16:24 johana | ||
50 | * Added support for PA high level interrupt. | ||
51 | * That gives 2ms response time with iodtest for high levels and 2-12 ms | ||
52 | * response time on low levels if the check is not made in | ||
53 | * process.c:cpu_idle() as well. | ||
54 | * | ||
55 | * Revision 1.19 2002/10/14 18:27:33 johana | ||
56 | * Implemented alarm handling so select() now works. | ||
57 | * Latency is around 6-9 ms with a etrax_gpio_wake_up_check() in | ||
58 | * cpu_idle(). | ||
59 | * Otherwise I get 15-18 ms (same as doing the poll in userspace - | ||
60 | * but less overhead). | ||
61 | * TODO? Perhaps we should add the check in IMMEDIATE_BH (or whatever it | ||
62 | * is in 2.4) as well? | ||
63 | * TODO? Perhaps call request_irq()/free_irq() only when needed? | ||
64 | * Increased version to 2.5 | ||
65 | * | ||
66 | * Revision 1.18 2002/10/11 15:02:00 johana | ||
67 | * Mask inverted 8 bit value in setget_input(). | ||
68 | * | ||
69 | * Revision 1.17 2002/06/17 15:53:01 johana | ||
70 | * Added IO_READ_INBITS, IO_READ_OUTBITS, IO_SETGET_INPUT and IO_SETGET_OUTPUT | ||
71 | * that take a pointer as argument and thus can handle 32 bit ports (G) | ||
72 | * correctly. | ||
73 | * These should be used instead of IO_READBITS, IO_SETINPUT and IO_SETOUTPUT. | ||
74 | * (especially if Port G bit 31 is used) | ||
75 | * | ||
76 | * Revision 1.16 2002/06/17 09:59:51 johana | ||
77 | * Returning 32 bit values in the ioctl return value doesn't work if bit | ||
78 | * 31 is set (could happen for port G), so mask it of with 0x7FFFFFFF. | ||
79 | * A new set of ioctl's will be added. | ||
80 | * | ||
81 | * Revision 1.15 2002/05/06 13:19:13 johana | ||
82 | * IO_SETINPUT returns mask with bit set = inputs for PA and PB as well. | ||
83 | * | ||
84 | * Revision 1.14 2002/04/12 12:01:53 johana | ||
85 | * Use global r_port_g_data_shadow. | ||
86 | * Moved gpio_init_port_g() closer to gpio_init() and marked it __init. | ||
87 | * | ||
88 | * Revision 1.13 2002/04/10 12:03:55 johana | ||
89 | * Added support for port G /dev/gpiog (minor 3). | ||
90 | * Changed indentation on switch cases. | ||
91 | * Fixed other spaces to tabs. | ||
92 | * | ||
93 | * Revision 1.12 2001/11/12 19:42:15 pkj | ||
94 | * * Corrected return values from gpio_leds_ioctl(). | ||
95 | * * Fixed compiler warnings. | ||
96 | * | ||
97 | * Revision 1.11 2001/10/30 14:39:12 johana | ||
98 | * Added D() around gpio_write printk. | ||
99 | * | ||
100 | * Revision 1.10 2001/10/25 10:24:42 johana | ||
101 | * Added IO_CFG_WRITE_MODE ioctl and write method that can do fast | ||
102 | * bittoggling in the kernel. (This speeds up programming an FPGA with 450kB | ||
103 | * from ~60 seconds to 4 seconds). | ||
104 | * Added save_flags/cli/restore_flags in ioctl. | ||
105 | * | ||
106 | * Revision 1.9 2001/05/04 14:16:07 matsfg | ||
107 | * Corrected spelling error | ||
108 | * | ||
109 | * Revision 1.8 2001/04/27 13:55:26 matsfg | ||
110 | * Moved initioremap. | ||
111 | * Turns off all LEDS on init. | ||
112 | * Added support for shutdown and powerbutton. | ||
113 | * | ||
114 | * Revision 1.7 2001/04/04 13:30:08 matsfg | ||
115 | * Added bitset and bitclear for leds. Calls init_ioremap to set up memmapping | ||
116 | * | ||
117 | * Revision 1.6 2001/03/26 16:03:06 bjornw | ||
118 | * Needs linux/config.h | ||
119 | * | ||
120 | * Revision 1.5 2001/03/26 14:22:03 bjornw | ||
121 | * Namechange of some config options | ||
122 | * | ||
123 | * Revision 1.4 2001/02/27 13:52:48 bjornw | ||
124 | * malloc.h -> slab.h | ||
125 | * | ||
126 | * Revision 1.3 2001/01/24 15:06:48 bjornw | ||
127 | * gpio_wq correct type | ||
128 | * | ||
129 | * Revision 1.2 2001/01/18 16:07:30 bjornw | ||
130 | * 2.4 port | ||
131 | * | ||
132 | * Revision 1.1 2001/01/18 15:55:16 bjornw | ||
133 | * Verbatim copy of etraxgpio.c from elinux 2.0 added | ||
134 | * | ||
135 | * | ||
136 | */ | 9 | */ |
137 | 10 | ||
138 | 11 | ||
@@ -165,7 +38,7 @@ static int dp_cnt; | |||
165 | #else | 38 | #else |
166 | #define DP(x) | 39 | #define DP(x) |
167 | #endif | 40 | #endif |
168 | 41 | ||
169 | static char gpio_name[] = "etrax gpio"; | 42 | static char gpio_name[] = "etrax gpio"; |
170 | 43 | ||
171 | #if 0 | 44 | #if 0 |
@@ -173,9 +46,9 @@ static wait_queue_head_t *gpio_wq; | |||
173 | #endif | 46 | #endif |
174 | 47 | ||
175 | static int gpio_ioctl(struct inode *inode, struct file *file, | 48 | static int gpio_ioctl(struct inode *inode, struct file *file, |
176 | unsigned int cmd, unsigned long arg); | 49 | unsigned int cmd, unsigned long arg); |
177 | static ssize_t gpio_write(struct file * file, const char * buf, size_t count, | 50 | static ssize_t gpio_write(struct file *file, const char __user *buf, |
178 | loff_t *off); | 51 | size_t count, loff_t *off); |
179 | static int gpio_open(struct inode *inode, struct file *filp); | 52 | static int gpio_open(struct inode *inode, struct file *filp); |
180 | static int gpio_release(struct inode *inode, struct file *filp); | 53 | static int gpio_release(struct inode *inode, struct file *filp); |
181 | static unsigned int gpio_poll(struct file *filp, struct poll_table_struct *wait); | 54 | static unsigned int gpio_poll(struct file *filp, struct poll_table_struct *wait); |
@@ -201,22 +74,22 @@ struct gpio_private { | |||
201 | 74 | ||
202 | /* linked list of alarms to check for */ | 75 | /* linked list of alarms to check for */ |
203 | 76 | ||
204 | static struct gpio_private *alarmlist = 0; | 77 | static struct gpio_private *alarmlist; |
205 | 78 | ||
206 | static int gpio_some_alarms = 0; /* Set if someone uses alarm */ | 79 | static int gpio_some_alarms; /* Set if someone uses alarm */ |
207 | static unsigned long gpio_pa_irq_enabled_mask = 0; | 80 | static unsigned long gpio_pa_irq_enabled_mask; |
208 | 81 | ||
209 | static DEFINE_SPINLOCK(gpio_lock); /* Protect directions etc */ | 82 | static DEFINE_SPINLOCK(gpio_lock); /* Protect directions etc */ |
210 | 83 | ||
211 | /* Port A and B use 8 bit access, but Port G is 32 bit */ | 84 | /* Port A and B use 8 bit access, but Port G is 32 bit */ |
212 | #define NUM_PORTS (GPIO_MINOR_B+1) | 85 | #define NUM_PORTS (GPIO_MINOR_B+1) |
213 | 86 | ||
214 | static volatile unsigned char *ports[NUM_PORTS] = { | 87 | static volatile unsigned char *ports[NUM_PORTS] = { |
215 | R_PORT_PA_DATA, | 88 | R_PORT_PA_DATA, |
216 | R_PORT_PB_DATA, | 89 | R_PORT_PB_DATA, |
217 | }; | 90 | }; |
218 | static volatile unsigned char *shads[NUM_PORTS] = { | 91 | static volatile unsigned char *shads[NUM_PORTS] = { |
219 | &port_pa_data_shadow, | 92 | &port_pa_data_shadow, |
220 | &port_pb_data_shadow | 93 | &port_pb_data_shadow |
221 | }; | 94 | }; |
222 | 95 | ||
@@ -236,29 +109,29 @@ static volatile unsigned char *shads[NUM_PORTS] = { | |||
236 | #endif | 109 | #endif |
237 | 110 | ||
238 | 111 | ||
239 | static unsigned char changeable_dir[NUM_PORTS] = { | 112 | static unsigned char changeable_dir[NUM_PORTS] = { |
240 | CONFIG_ETRAX_PA_CHANGEABLE_DIR, | 113 | CONFIG_ETRAX_PA_CHANGEABLE_DIR, |
241 | CONFIG_ETRAX_PB_CHANGEABLE_DIR | 114 | CONFIG_ETRAX_PB_CHANGEABLE_DIR |
242 | }; | 115 | }; |
243 | static unsigned char changeable_bits[NUM_PORTS] = { | 116 | static unsigned char changeable_bits[NUM_PORTS] = { |
244 | CONFIG_ETRAX_PA_CHANGEABLE_BITS, | 117 | CONFIG_ETRAX_PA_CHANGEABLE_BITS, |
245 | CONFIG_ETRAX_PB_CHANGEABLE_BITS | 118 | CONFIG_ETRAX_PB_CHANGEABLE_BITS |
246 | }; | 119 | }; |
247 | 120 | ||
248 | static volatile unsigned char *dir[NUM_PORTS] = { | 121 | static volatile unsigned char *dir[NUM_PORTS] = { |
249 | R_PORT_PA_DIR, | 122 | R_PORT_PA_DIR, |
250 | R_PORT_PB_DIR | 123 | R_PORT_PB_DIR |
251 | }; | 124 | }; |
252 | 125 | ||
253 | static volatile unsigned char *dir_shadow[NUM_PORTS] = { | 126 | static volatile unsigned char *dir_shadow[NUM_PORTS] = { |
254 | &port_pa_dir_shadow, | 127 | &port_pa_dir_shadow, |
255 | &port_pb_dir_shadow | 128 | &port_pb_dir_shadow |
256 | }; | 129 | }; |
257 | 130 | ||
258 | /* All bits in port g that can change dir. */ | 131 | /* All bits in port g that can change dir. */ |
259 | static const unsigned long int changeable_dir_g_mask = 0x01FFFF01; | 132 | static const unsigned long int changeable_dir_g_mask = 0x01FFFF01; |
260 | 133 | ||
261 | /* Port G is 32 bit, handle it special, some bits are both inputs | 134 | /* Port G is 32 bit, handle it special, some bits are both inputs |
262 | and outputs at the same time, only some of the bits can change direction | 135 | and outputs at the same time, only some of the bits can change direction |
263 | and some of them in groups of 8 bit. */ | 136 | and some of them in groups of 8 bit. */ |
264 | static unsigned long changeable_dir_g; | 137 | static unsigned long changeable_dir_g; |
@@ -269,18 +142,17 @@ static unsigned long dir_g_shadow; /* 1=output */ | |||
269 | #define USE_PORTS(priv) ((priv)->minor <= GPIO_MINOR_B) | 142 | #define USE_PORTS(priv) ((priv)->minor <= GPIO_MINOR_B) |
270 | 143 | ||
271 | 144 | ||
272 | 145 | static unsigned int gpio_poll(struct file *file, poll_table *wait) | |
273 | static unsigned int | ||
274 | gpio_poll(struct file *file, | ||
275 | poll_table *wait) | ||
276 | { | 146 | { |
277 | unsigned int mask = 0; | 147 | unsigned int mask = 0; |
278 | struct gpio_private *priv = (struct gpio_private *)file->private_data; | 148 | struct gpio_private *priv = file->private_data; |
279 | unsigned long data; | 149 | unsigned long data; |
280 | spin_lock(&gpio_lock); | 150 | unsigned long flags; |
151 | |||
152 | spin_lock_irqsave(&gpio_lock, flags); | ||
153 | |||
281 | poll_wait(file, &priv->alarm_wq, wait); | 154 | poll_wait(file, &priv->alarm_wq, wait); |
282 | if (priv->minor == GPIO_MINOR_A) { | 155 | if (priv->minor == GPIO_MINOR_A) { |
283 | unsigned long flags; | ||
284 | unsigned long tmp; | 156 | unsigned long tmp; |
285 | data = *R_PORT_PA_DATA; | 157 | data = *R_PORT_PA_DATA; |
286 | /* PA has support for high level interrupt - | 158 | /* PA has support for high level interrupt - |
@@ -288,27 +160,25 @@ gpio_poll(struct file *file, | |||
288 | */ | 160 | */ |
289 | tmp = ~data & priv->highalarm & 0xFF; | 161 | tmp = ~data & priv->highalarm & 0xFF; |
290 | tmp = (tmp << R_IRQ_MASK1_SET__pa0__BITNR); | 162 | tmp = (tmp << R_IRQ_MASK1_SET__pa0__BITNR); |
291 | local_irq_save(flags); | 163 | |
292 | gpio_pa_irq_enabled_mask |= tmp; | 164 | gpio_pa_irq_enabled_mask |= tmp; |
293 | *R_IRQ_MASK1_SET = tmp; | 165 | *R_IRQ_MASK1_SET = tmp; |
294 | local_irq_restore(flags); | ||
295 | |||
296 | } else if (priv->minor == GPIO_MINOR_B) | 166 | } else if (priv->minor == GPIO_MINOR_B) |
297 | data = *R_PORT_PB_DATA; | 167 | data = *R_PORT_PB_DATA; |
298 | else if (priv->minor == GPIO_MINOR_G) | 168 | else if (priv->minor == GPIO_MINOR_G) |
299 | data = *R_PORT_G_DATA; | 169 | data = *R_PORT_G_DATA; |
300 | else { | 170 | else { |
301 | spin_unlock(&gpio_lock); | 171 | mask = 0; |
302 | return 0; | 172 | goto out; |
303 | } | 173 | } |
304 | 174 | ||
305 | if ((data & priv->highalarm) || | 175 | if ((data & priv->highalarm) || |
306 | (~data & priv->lowalarm)) { | 176 | (~data & priv->lowalarm)) { |
307 | mask = POLLIN|POLLRDNORM; | 177 | mask = POLLIN|POLLRDNORM; |
308 | } | 178 | } |
309 | 179 | ||
310 | spin_unlock(&gpio_lock); | 180 | out: |
311 | 181 | spin_unlock_irqrestore(&gpio_lock, flags); | |
312 | DP(printk("gpio_poll ready: mask 0x%08X\n", mask)); | 182 | DP(printk("gpio_poll ready: mask 0x%08X\n", mask)); |
313 | 183 | ||
314 | return mask; | 184 | return mask; |
@@ -316,16 +186,19 @@ gpio_poll(struct file *file, | |||
316 | 186 | ||
317 | int etrax_gpio_wake_up_check(void) | 187 | int etrax_gpio_wake_up_check(void) |
318 | { | 188 | { |
319 | struct gpio_private *priv = alarmlist; | 189 | struct gpio_private *priv; |
320 | unsigned long data = 0; | 190 | unsigned long data = 0; |
321 | int ret = 0; | 191 | int ret = 0; |
322 | spin_lock(&gpio_lock); | 192 | unsigned long flags; |
193 | |||
194 | spin_lock_irqsave(&gpio_lock, flags); | ||
195 | priv = alarmlist; | ||
323 | while (priv) { | 196 | while (priv) { |
324 | if (USE_PORTS(priv)) { | 197 | if (USE_PORTS(priv)) |
325 | data = *priv->port; | 198 | data = *priv->port; |
326 | } else if (priv->minor == GPIO_MINOR_G) { | 199 | else if (priv->minor == GPIO_MINOR_G) |
327 | data = *R_PORT_G_DATA; | 200 | data = *R_PORT_G_DATA; |
328 | } | 201 | |
329 | if ((data & priv->highalarm) || | 202 | if ((data & priv->highalarm) || |
330 | (~data & priv->lowalarm)) { | 203 | (~data & priv->lowalarm)) { |
331 | DP(printk("etrax_gpio_wake_up_check %i\n",priv->minor)); | 204 | DP(printk("etrax_gpio_wake_up_check %i\n",priv->minor)); |
@@ -334,12 +207,12 @@ int etrax_gpio_wake_up_check(void) | |||
334 | } | 207 | } |
335 | priv = priv->next; | 208 | priv = priv->next; |
336 | } | 209 | } |
337 | spin_unlock(&gpio_lock); | 210 | spin_unlock_irqrestore(&gpio_lock, flags); |
338 | return ret; | 211 | return ret; |
339 | } | 212 | } |
340 | 213 | ||
341 | static irqreturn_t | 214 | static irqreturn_t |
342 | gpio_poll_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) | 215 | gpio_poll_timer_interrupt(int irq, void *dev_id) |
343 | { | 216 | { |
344 | if (gpio_some_alarms) { | 217 | if (gpio_some_alarms) { |
345 | etrax_gpio_wake_up_check(); | 218 | etrax_gpio_wake_up_check(); |
@@ -349,10 +222,13 @@ gpio_poll_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
349 | } | 222 | } |
350 | 223 | ||
351 | static irqreturn_t | 224 | static irqreturn_t |
352 | gpio_pa_interrupt(int irq, void *dev_id, struct pt_regs *regs) | 225 | gpio_interrupt(int irq, void *dev_id) |
353 | { | 226 | { |
354 | unsigned long tmp; | 227 | unsigned long tmp; |
355 | spin_lock(&gpio_lock); | 228 | unsigned long flags; |
229 | |||
230 | spin_lock_irqsave(&gpio_lock, flags); | ||
231 | |||
356 | /* Find what PA interrupts are active */ | 232 | /* Find what PA interrupts are active */ |
357 | tmp = (*R_IRQ_READ1); | 233 | tmp = (*R_IRQ_READ1); |
358 | 234 | ||
@@ -363,75 +239,70 @@ gpio_pa_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
363 | *R_IRQ_MASK1_CLR = tmp; | 239 | *R_IRQ_MASK1_CLR = tmp; |
364 | gpio_pa_irq_enabled_mask &= ~tmp; | 240 | gpio_pa_irq_enabled_mask &= ~tmp; |
365 | 241 | ||
366 | spin_unlock(&gpio_lock); | 242 | spin_unlock_irqrestore(&gpio_lock, flags); |
367 | 243 | ||
368 | if (gpio_some_alarms) { | 244 | if (gpio_some_alarms) |
369 | return IRQ_RETVAL(etrax_gpio_wake_up_check()); | 245 | return IRQ_RETVAL(etrax_gpio_wake_up_check()); |
370 | } | 246 | |
371 | return IRQ_NONE; | 247 | return IRQ_NONE; |
372 | } | 248 | } |
373 | 249 | ||
250 | static void gpio_write_bit(struct gpio_private *priv, | ||
251 | unsigned char data, int bit) | ||
252 | { | ||
253 | *priv->port = *priv->shadow &= ~(priv->clk_mask); | ||
254 | if (data & 1 << bit) | ||
255 | *priv->port = *priv->shadow |= priv->data_mask; | ||
256 | else | ||
257 | *priv->port = *priv->shadow &= ~(priv->data_mask); | ||
258 | |||
259 | /* For FPGA: min 5.0ns (DCC) before CCLK high */ | ||
260 | *priv->port = *priv->shadow |= priv->clk_mask; | ||
261 | } | ||
374 | 262 | ||
375 | static ssize_t gpio_write(struct file * file, const char * buf, size_t count, | 263 | static void gpio_write_byte(struct gpio_private *priv, unsigned char data) |
376 | loff_t *off) | ||
377 | { | 264 | { |
378 | struct gpio_private *priv = (struct gpio_private *)file->private_data; | 265 | int i; |
379 | unsigned char data, clk_mask, data_mask, write_msb; | ||
380 | unsigned long flags; | ||
381 | 266 | ||
382 | spin_lock(&gpio_lock); | 267 | if (priv->write_msb) |
268 | for (i = 7; i >= 0; i--) | ||
269 | gpio_write_bit(priv, data, i); | ||
270 | else | ||
271 | for (i = 0; i <= 7; i++) | ||
272 | gpio_write_bit(priv, data, i); | ||
273 | } | ||
383 | 274 | ||
275 | static ssize_t gpio_write(struct file *file, const char __user *buf, | ||
276 | size_t count, loff_t *off) | ||
277 | { | ||
278 | struct gpio_private *priv = file->private_data; | ||
279 | unsigned long flags; | ||
384 | ssize_t retval = count; | 280 | ssize_t retval = count; |
385 | if (priv->minor !=GPIO_MINOR_A && priv->minor != GPIO_MINOR_B) { | 281 | |
386 | retval = -EFAULT; | 282 | if (priv->minor != GPIO_MINOR_A && priv->minor != GPIO_MINOR_B) |
387 | goto out; | 283 | return -EFAULT; |
388 | } | 284 | |
389 | 285 | if (!access_ok(VERIFY_READ, buf, count)) | |
390 | if (!access_ok(VERIFY_READ, buf, count)) { | 286 | return -EFAULT; |
391 | retval = -EFAULT; | 287 | |
392 | goto out; | 288 | spin_lock_irqsave(&gpio_lock, flags); |
393 | } | 289 | |
394 | clk_mask = priv->clk_mask; | ||
395 | data_mask = priv->data_mask; | ||
396 | /* It must have been configured using the IO_CFG_WRITE_MODE */ | 290 | /* It must have been configured using the IO_CFG_WRITE_MODE */ |
397 | /* Perhaps a better error code? */ | 291 | /* Perhaps a better error code? */ |
398 | if (clk_mask == 0 || data_mask == 0) { | 292 | if (priv->clk_mask == 0 || priv->data_mask == 0) { |
399 | retval = -EPERM; | 293 | retval = -EPERM; |
400 | goto out; | 294 | goto out; |
401 | } | 295 | } |
402 | write_msb = priv->write_msb; | 296 | |
403 | D(printk("gpio_write: %lu to data 0x%02X clk 0x%02X msb: %i\n",count, data_mask, clk_mask, write_msb)); | 297 | D(printk(KERN_DEBUG "gpio_write: %02X to data 0x%02X " |
404 | while (count--) { | 298 | "clk 0x%02X msb: %i\n", |
405 | int i; | 299 | count, priv->data_mask, priv->clk_mask, priv->write_msb)); |
406 | data = *buf++; | 300 | |
407 | if (priv->write_msb) { | 301 | while (count--) |
408 | for (i = 7; i >= 0;i--) { | 302 | gpio_write_byte(priv, *buf++); |
409 | local_irq_save(flags); | 303 | |
410 | *priv->port = *priv->shadow &= ~clk_mask; | ||
411 | if (data & 1<<i) | ||
412 | *priv->port = *priv->shadow |= data_mask; | ||
413 | else | ||
414 | *priv->port = *priv->shadow &= ~data_mask; | ||
415 | /* For FPGA: min 5.0ns (DCC) before CCLK high */ | ||
416 | *priv->port = *priv->shadow |= clk_mask; | ||
417 | local_irq_restore(flags); | ||
418 | } | ||
419 | } else { | ||
420 | for (i = 0; i <= 7;i++) { | ||
421 | local_irq_save(flags); | ||
422 | *priv->port = *priv->shadow &= ~clk_mask; | ||
423 | if (data & 1<<i) | ||
424 | *priv->port = *priv->shadow |= data_mask; | ||
425 | else | ||
426 | *priv->port = *priv->shadow &= ~data_mask; | ||
427 | /* For FPGA: min 5.0ns (DCC) before CCLK high */ | ||
428 | *priv->port = *priv->shadow |= clk_mask; | ||
429 | local_irq_restore(flags); | ||
430 | } | ||
431 | } | ||
432 | } | ||
433 | out: | 304 | out: |
434 | spin_unlock(&gpio_lock); | 305 | spin_unlock_irqrestore(&gpio_lock, flags); |
435 | return retval; | 306 | return retval; |
436 | } | 307 | } |
437 | 308 | ||
@@ -442,22 +313,20 @@ gpio_open(struct inode *inode, struct file *filp) | |||
442 | { | 313 | { |
443 | struct gpio_private *priv; | 314 | struct gpio_private *priv; |
444 | int p = iminor(inode); | 315 | int p = iminor(inode); |
316 | unsigned long flags; | ||
445 | 317 | ||
446 | if (p > GPIO_MINOR_LAST) | 318 | if (p > GPIO_MINOR_LAST) |
447 | return -EINVAL; | 319 | return -EINVAL; |
448 | 320 | ||
449 | priv = kmalloc(sizeof(struct gpio_private), | 321 | priv = kzalloc(sizeof(struct gpio_private), GFP_KERNEL); |
450 | GFP_KERNEL); | ||
451 | 322 | ||
452 | if (!priv) | 323 | if (!priv) |
453 | return -ENOMEM; | 324 | return -ENOMEM; |
454 | 325 | ||
455 | priv->minor = p; | 326 | priv->minor = p; |
456 | 327 | ||
457 | /* initialize the io/alarm struct and link it into our alarmlist */ | 328 | /* initialize the io/alarm struct */ |
458 | 329 | ||
459 | priv->next = alarmlist; | ||
460 | alarmlist = priv; | ||
461 | if (USE_PORTS(priv)) { /* A and B */ | 330 | if (USE_PORTS(priv)) { /* A and B */ |
462 | priv->port = ports[p]; | 331 | priv->port = ports[p]; |
463 | priv->shadow = shads[p]; | 332 | priv->shadow = shads[p]; |
@@ -480,7 +349,13 @@ gpio_open(struct inode *inode, struct file *filp) | |||
480 | priv->data_mask = 0; | 349 | priv->data_mask = 0; |
481 | init_waitqueue_head(&priv->alarm_wq); | 350 | init_waitqueue_head(&priv->alarm_wq); |
482 | 351 | ||
483 | filp->private_data = (void *)priv; | 352 | filp->private_data = priv; |
353 | |||
354 | /* link it into our alarmlist */ | ||
355 | spin_lock_irqsave(&gpio_lock, flags); | ||
356 | priv->next = alarmlist; | ||
357 | alarmlist = priv; | ||
358 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
484 | 359 | ||
485 | return 0; | 360 | return 0; |
486 | } | 361 | } |
@@ -490,11 +365,12 @@ gpio_release(struct inode *inode, struct file *filp) | |||
490 | { | 365 | { |
491 | struct gpio_private *p; | 366 | struct gpio_private *p; |
492 | struct gpio_private *todel; | 367 | struct gpio_private *todel; |
368 | unsigned long flags; | ||
493 | 369 | ||
494 | spin_lock(&gpio_lock); | 370 | spin_lock_irqsave(&gpio_lock, flags); |
495 | 371 | ||
496 | p = alarmlist; | 372 | p = alarmlist; |
497 | todel = (struct gpio_private *)filp->private_data; | 373 | todel = filp->private_data; |
498 | 374 | ||
499 | /* unlink from alarmlist and free the private structure */ | 375 | /* unlink from alarmlist and free the private structure */ |
500 | 376 | ||
@@ -512,123 +388,114 @@ gpio_release(struct inode *inode, struct file *filp) | |||
512 | while (p) { | 388 | while (p) { |
513 | if (p->highalarm | p->lowalarm) { | 389 | if (p->highalarm | p->lowalarm) { |
514 | gpio_some_alarms = 1; | 390 | gpio_some_alarms = 1; |
515 | spin_unlock(&gpio_lock); | 391 | goto out; |
516 | return 0; | ||
517 | } | 392 | } |
518 | p = p->next; | 393 | p = p->next; |
519 | } | 394 | } |
520 | gpio_some_alarms = 0; | 395 | gpio_some_alarms = 0; |
521 | spin_unlock(&gpio_lock); | 396 | out: |
397 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
522 | return 0; | 398 | return 0; |
523 | } | 399 | } |
524 | 400 | ||
525 | /* Main device API. ioctl's to read/set/clear bits, as well as to | 401 | /* Main device API. ioctl's to read/set/clear bits, as well as to |
526 | * set alarms to wait for using a subsequent select(). | 402 | * set alarms to wait for using a subsequent select(). |
527 | */ | 403 | */ |
528 | |||
529 | unsigned long inline setget_input(struct gpio_private *priv, unsigned long arg) | 404 | unsigned long inline setget_input(struct gpio_private *priv, unsigned long arg) |
530 | { | 405 | { |
531 | /* Set direction 0=unchanged 1=input, | 406 | /* Set direction 0=unchanged 1=input, |
532 | * return mask with 1=input | 407 | * return mask with 1=input */ |
533 | */ | ||
534 | unsigned long flags; | ||
535 | if (USE_PORTS(priv)) { | 408 | if (USE_PORTS(priv)) { |
536 | local_irq_save(flags); | 409 | *priv->dir = *priv->dir_shadow &= |
537 | *priv->dir = *priv->dir_shadow &= | ||
538 | ~((unsigned char)arg & priv->changeable_dir); | 410 | ~((unsigned char)arg & priv->changeable_dir); |
539 | local_irq_restore(flags); | ||
540 | return ~(*priv->dir_shadow) & 0xFF; /* Only 8 bits */ | 411 | return ~(*priv->dir_shadow) & 0xFF; /* Only 8 bits */ |
541 | } else if (priv->minor == GPIO_MINOR_G) { | 412 | } |
542 | /* We must fiddle with R_GEN_CONFIG to change dir */ | 413 | |
543 | local_irq_save(flags); | 414 | if (priv->minor != GPIO_MINOR_G) |
544 | if (((arg & dir_g_in_bits) != arg) && | 415 | return 0; |
545 | (arg & changeable_dir_g)) { | 416 | |
546 | arg &= changeable_dir_g; | 417 | /* We must fiddle with R_GEN_CONFIG to change dir */ |
547 | /* Clear bits in genconfig to set to input */ | 418 | if (((arg & dir_g_in_bits) != arg) && |
548 | if (arg & (1<<0)) { | 419 | (arg & changeable_dir_g)) { |
549 | genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG,g0dir); | 420 | arg &= changeable_dir_g; |
550 | dir_g_in_bits |= (1<<0); | 421 | /* Clear bits in genconfig to set to input */ |
551 | dir_g_out_bits &= ~(1<<0); | 422 | if (arg & (1<<0)) { |
552 | } | 423 | genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG, g0dir); |
553 | if ((arg & 0x0000FF00) == 0x0000FF00) { | 424 | dir_g_in_bits |= (1<<0); |
554 | genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG,g8_15dir); | 425 | dir_g_out_bits &= ~(1<<0); |
555 | dir_g_in_bits |= 0x0000FF00; | ||
556 | dir_g_out_bits &= ~0x0000FF00; | ||
557 | } | ||
558 | if ((arg & 0x00FF0000) == 0x00FF0000) { | ||
559 | genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG,g16_23dir); | ||
560 | dir_g_in_bits |= 0x00FF0000; | ||
561 | dir_g_out_bits &= ~0x00FF0000; | ||
562 | } | ||
563 | if (arg & (1<<24)) { | ||
564 | genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG,g24dir); | ||
565 | dir_g_in_bits |= (1<<24); | ||
566 | dir_g_out_bits &= ~(1<<24); | ||
567 | } | ||
568 | D(printk(KERN_INFO "gpio: SETINPUT on port G set " | ||
569 | "genconfig to 0x%08lX " | ||
570 | "in_bits: 0x%08lX " | ||
571 | "out_bits: 0x%08lX\n", | ||
572 | (unsigned long)genconfig_shadow, | ||
573 | dir_g_in_bits, dir_g_out_bits)); | ||
574 | *R_GEN_CONFIG = genconfig_shadow; | ||
575 | /* Must be a >120 ns delay before writing this again */ | ||
576 | |||
577 | } | 426 | } |
578 | local_irq_restore(flags); | 427 | if ((arg & 0x0000FF00) == 0x0000FF00) { |
579 | return dir_g_in_bits; | 428 | genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG, g8_15dir); |
429 | dir_g_in_bits |= 0x0000FF00; | ||
430 | dir_g_out_bits &= ~0x0000FF00; | ||
431 | } | ||
432 | if ((arg & 0x00FF0000) == 0x00FF0000) { | ||
433 | genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG, g16_23dir); | ||
434 | dir_g_in_bits |= 0x00FF0000; | ||
435 | dir_g_out_bits &= ~0x00FF0000; | ||
436 | } | ||
437 | if (arg & (1<<24)) { | ||
438 | genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG, g24dir); | ||
439 | dir_g_in_bits |= (1<<24); | ||
440 | dir_g_out_bits &= ~(1<<24); | ||
441 | } | ||
442 | D(printk(KERN_DEBUG "gpio: SETINPUT on port G set " | ||
443 | "genconfig to 0x%08lX " | ||
444 | "in_bits: 0x%08lX " | ||
445 | "out_bits: 0x%08lX\n", | ||
446 | (unsigned long)genconfig_shadow, | ||
447 | dir_g_in_bits, dir_g_out_bits)); | ||
448 | *R_GEN_CONFIG = genconfig_shadow; | ||
449 | /* Must be a >120 ns delay before writing this again */ | ||
450 | |||
580 | } | 451 | } |
581 | return 0; | 452 | return dir_g_in_bits; |
582 | } /* setget_input */ | 453 | } /* setget_input */ |
583 | 454 | ||
584 | unsigned long inline setget_output(struct gpio_private *priv, unsigned long arg) | 455 | unsigned long inline setget_output(struct gpio_private *priv, unsigned long arg) |
585 | { | 456 | { |
586 | unsigned long flags; | ||
587 | if (USE_PORTS(priv)) { | 457 | if (USE_PORTS(priv)) { |
588 | local_irq_save(flags); | 458 | *priv->dir = *priv->dir_shadow |= |
589 | *priv->dir = *priv->dir_shadow |= | 459 | ((unsigned char)arg & priv->changeable_dir); |
590 | ((unsigned char)arg & priv->changeable_dir); | ||
591 | local_irq_restore(flags); | ||
592 | return *priv->dir_shadow; | 460 | return *priv->dir_shadow; |
593 | } else if (priv->minor == GPIO_MINOR_G) { | 461 | } |
594 | /* We must fiddle with R_GEN_CONFIG to change dir */ | 462 | if (priv->minor != GPIO_MINOR_G) |
595 | local_irq_save(flags); | 463 | return 0; |
596 | if (((arg & dir_g_out_bits) != arg) && | 464 | |
597 | (arg & changeable_dir_g)) { | 465 | /* We must fiddle with R_GEN_CONFIG to change dir */ |
598 | /* Set bits in genconfig to set to output */ | 466 | if (((arg & dir_g_out_bits) != arg) && |
599 | if (arg & (1<<0)) { | 467 | (arg & changeable_dir_g)) { |
600 | genconfig_shadow |= IO_MASK(R_GEN_CONFIG,g0dir); | 468 | /* Set bits in genconfig to set to output */ |
601 | dir_g_out_bits |= (1<<0); | 469 | if (arg & (1<<0)) { |
602 | dir_g_in_bits &= ~(1<<0); | 470 | genconfig_shadow |= IO_MASK(R_GEN_CONFIG, g0dir); |
603 | } | 471 | dir_g_out_bits |= (1<<0); |
604 | if ((arg & 0x0000FF00) == 0x0000FF00) { | 472 | dir_g_in_bits &= ~(1<<0); |
605 | genconfig_shadow |= IO_MASK(R_GEN_CONFIG,g8_15dir); | ||
606 | dir_g_out_bits |= 0x0000FF00; | ||
607 | dir_g_in_bits &= ~0x0000FF00; | ||
608 | } | ||
609 | if ((arg & 0x00FF0000) == 0x00FF0000) { | ||
610 | genconfig_shadow |= IO_MASK(R_GEN_CONFIG,g16_23dir); | ||
611 | dir_g_out_bits |= 0x00FF0000; | ||
612 | dir_g_in_bits &= ~0x00FF0000; | ||
613 | } | ||
614 | if (arg & (1<<24)) { | ||
615 | genconfig_shadow |= IO_MASK(R_GEN_CONFIG,g24dir); | ||
616 | dir_g_out_bits |= (1<<24); | ||
617 | dir_g_in_bits &= ~(1<<24); | ||
618 | } | ||
619 | D(printk(KERN_INFO "gpio: SETOUTPUT on port G set " | ||
620 | "genconfig to 0x%08lX " | ||
621 | "in_bits: 0x%08lX " | ||
622 | "out_bits: 0x%08lX\n", | ||
623 | (unsigned long)genconfig_shadow, | ||
624 | dir_g_in_bits, dir_g_out_bits)); | ||
625 | *R_GEN_CONFIG = genconfig_shadow; | ||
626 | /* Must be a >120 ns delay before writing this again */ | ||
627 | } | 473 | } |
628 | local_irq_restore(flags); | 474 | if ((arg & 0x0000FF00) == 0x0000FF00) { |
629 | return dir_g_out_bits & 0x7FFFFFFF; | 475 | genconfig_shadow |= IO_MASK(R_GEN_CONFIG, g8_15dir); |
476 | dir_g_out_bits |= 0x0000FF00; | ||
477 | dir_g_in_bits &= ~0x0000FF00; | ||
478 | } | ||
479 | if ((arg & 0x00FF0000) == 0x00FF0000) { | ||
480 | genconfig_shadow |= IO_MASK(R_GEN_CONFIG, g16_23dir); | ||
481 | dir_g_out_bits |= 0x00FF0000; | ||
482 | dir_g_in_bits &= ~0x00FF0000; | ||
483 | } | ||
484 | if (arg & (1<<24)) { | ||
485 | genconfig_shadow |= IO_MASK(R_GEN_CONFIG, g24dir); | ||
486 | dir_g_out_bits |= (1<<24); | ||
487 | dir_g_in_bits &= ~(1<<24); | ||
488 | } | ||
489 | D(printk(KERN_INFO "gpio: SETOUTPUT on port G set " | ||
490 | "genconfig to 0x%08lX " | ||
491 | "in_bits: 0x%08lX " | ||
492 | "out_bits: 0x%08lX\n", | ||
493 | (unsigned long)genconfig_shadow, | ||
494 | dir_g_in_bits, dir_g_out_bits)); | ||
495 | *R_GEN_CONFIG = genconfig_shadow; | ||
496 | /* Must be a >120 ns delay before writing this again */ | ||
630 | } | 497 | } |
631 | return 0; | 498 | return dir_g_out_bits & 0x7FFFFFFF; |
632 | } /* setget_output */ | 499 | } /* setget_output */ |
633 | 500 | ||
634 | static int | 501 | static int |
@@ -642,12 +509,11 @@ gpio_ioctl(struct inode *inode, struct file *file, | |||
642 | unsigned long val; | 509 | unsigned long val; |
643 | int ret = 0; | 510 | int ret = 0; |
644 | 511 | ||
645 | struct gpio_private *priv = (struct gpio_private *)file->private_data; | 512 | struct gpio_private *priv = file->private_data; |
646 | if (_IOC_TYPE(cmd) != ETRAXGPIO_IOCTYPE) { | 513 | if (_IOC_TYPE(cmd) != ETRAXGPIO_IOCTYPE) |
647 | return -EINVAL; | 514 | return -EINVAL; |
648 | } | ||
649 | 515 | ||
650 | spin_lock(&gpio_lock); | 516 | spin_lock_irqsave(&gpio_lock, flags); |
651 | 517 | ||
652 | switch (_IOC_NR(cmd)) { | 518 | switch (_IOC_NR(cmd)) { |
653 | case IO_READBITS: /* Use IO_READ_INBITS and IO_READ_OUTBITS instead */ | 519 | case IO_READBITS: /* Use IO_READ_INBITS and IO_READ_OUTBITS instead */ |
@@ -659,7 +525,6 @@ gpio_ioctl(struct inode *inode, struct file *file, | |||
659 | } | 525 | } |
660 | break; | 526 | break; |
661 | case IO_SETBITS: | 527 | case IO_SETBITS: |
662 | local_irq_save(flags); | ||
663 | // set changeable bits with a 1 in arg | 528 | // set changeable bits with a 1 in arg |
664 | if (USE_PORTS(priv)) { | 529 | if (USE_PORTS(priv)) { |
665 | *priv->port = *priv->shadow |= | 530 | *priv->port = *priv->shadow |= |
@@ -667,10 +532,8 @@ gpio_ioctl(struct inode *inode, struct file *file, | |||
667 | } else if (priv->minor == GPIO_MINOR_G) { | 532 | } else if (priv->minor == GPIO_MINOR_G) { |
668 | *R_PORT_G_DATA = port_g_data_shadow |= (arg & dir_g_out_bits); | 533 | *R_PORT_G_DATA = port_g_data_shadow |= (arg & dir_g_out_bits); |
669 | } | 534 | } |
670 | local_irq_restore(flags); | ||
671 | break; | 535 | break; |
672 | case IO_CLRBITS: | 536 | case IO_CLRBITS: |
673 | local_irq_save(flags); | ||
674 | // clear changeable bits with a 1 in arg | 537 | // clear changeable bits with a 1 in arg |
675 | if (USE_PORTS(priv)) { | 538 | if (USE_PORTS(priv)) { |
676 | *priv->port = *priv->shadow &= | 539 | *priv->port = *priv->shadow &= |
@@ -678,7 +541,6 @@ gpio_ioctl(struct inode *inode, struct file *file, | |||
678 | } else if (priv->minor == GPIO_MINOR_G) { | 541 | } else if (priv->minor == GPIO_MINOR_G) { |
679 | *R_PORT_G_DATA = port_g_data_shadow &= ~((unsigned long)arg & dir_g_out_bits); | 542 | *R_PORT_G_DATA = port_g_data_shadow &= ~((unsigned long)arg & dir_g_out_bits); |
680 | } | 543 | } |
681 | local_irq_restore(flags); | ||
682 | break; | 544 | break; |
683 | case IO_HIGHALARM: | 545 | case IO_HIGHALARM: |
684 | // set alarm when bits with 1 in arg go high | 546 | // set alarm when bits with 1 in arg go high |
@@ -698,6 +560,8 @@ gpio_ioctl(struct inode *inode, struct file *file, | |||
698 | /* Must update gpio_some_alarms */ | 560 | /* Must update gpio_some_alarms */ |
699 | struct gpio_private *p = alarmlist; | 561 | struct gpio_private *p = alarmlist; |
700 | int some_alarms; | 562 | int some_alarms; |
563 | spin_lock_irq(&gpio_lock); | ||
564 | p = alarmlist; | ||
701 | some_alarms = 0; | 565 | some_alarms = 0; |
702 | while (p) { | 566 | while (p) { |
703 | if (p->highalarm | p->lowalarm) { | 567 | if (p->highalarm | p->lowalarm) { |
@@ -707,6 +571,7 @@ gpio_ioctl(struct inode *inode, struct file *file, | |||
707 | p = p->next; | 571 | p = p->next; |
708 | } | 572 | } |
709 | gpio_some_alarms = some_alarms; | 573 | gpio_some_alarms = some_alarms; |
574 | spin_unlock_irq(&gpio_lock); | ||
710 | } | 575 | } |
711 | break; | 576 | break; |
712 | case IO_READDIR: /* Use IO_SETGET_INPUT/OUTPUT instead! */ | 577 | case IO_READDIR: /* Use IO_SETGET_INPUT/OUTPUT instead! */ |
@@ -766,7 +631,7 @@ gpio_ioctl(struct inode *inode, struct file *file, | |||
766 | } else if (priv->minor == GPIO_MINOR_G) { | 631 | } else if (priv->minor == GPIO_MINOR_G) { |
767 | val = *R_PORT_G_DATA; | 632 | val = *R_PORT_G_DATA; |
768 | } | 633 | } |
769 | if (copy_to_user((unsigned long*)arg, &val, sizeof(val))) | 634 | if (copy_to_user((void __user *)arg, &val, sizeof(val))) |
770 | ret = -EFAULT; | 635 | ret = -EFAULT; |
771 | break; | 636 | break; |
772 | case IO_READ_OUTBITS: | 637 | case IO_READ_OUTBITS: |
@@ -776,33 +641,32 @@ gpio_ioctl(struct inode *inode, struct file *file, | |||
776 | } else if (priv->minor == GPIO_MINOR_G) { | 641 | } else if (priv->minor == GPIO_MINOR_G) { |
777 | val = port_g_data_shadow; | 642 | val = port_g_data_shadow; |
778 | } | 643 | } |
779 | if (copy_to_user((unsigned long*)arg, &val, sizeof(val))) | 644 | if (copy_to_user((void __user *)arg, &val, sizeof(val))) |
780 | ret = -EFAULT; | 645 | ret = -EFAULT; |
781 | break; | 646 | break; |
782 | case IO_SETGET_INPUT: | 647 | case IO_SETGET_INPUT: |
783 | /* bits set in *arg is set to input, | 648 | /* bits set in *arg is set to input, |
784 | * *arg updated with current input pins. | 649 | * *arg updated with current input pins. |
785 | */ | 650 | */ |
786 | if (copy_from_user(&val, (unsigned long*)arg, sizeof(val))) | 651 | if (copy_from_user(&val, (void __user *)arg, sizeof(val))) |
787 | { | 652 | { |
788 | ret = -EFAULT; | 653 | ret = -EFAULT; |
789 | break; | 654 | break; |
790 | } | 655 | } |
791 | val = setget_input(priv, val); | 656 | val = setget_input(priv, val); |
792 | if (copy_to_user((unsigned long*)arg, &val, sizeof(val))) | 657 | if (copy_to_user((void __user *)arg, &val, sizeof(val))) |
793 | ret = -EFAULT; | 658 | ret = -EFAULT; |
794 | break; | 659 | break; |
795 | case IO_SETGET_OUTPUT: | 660 | case IO_SETGET_OUTPUT: |
796 | /* bits set in *arg is set to output, | 661 | /* bits set in *arg is set to output, |
797 | * *arg updated with current output pins. | 662 | * *arg updated with current output pins. |
798 | */ | 663 | */ |
799 | if (copy_from_user(&val, (unsigned long*)arg, sizeof(val))) | 664 | if (copy_from_user(&val, (void __user *)arg, sizeof(val))) { |
800 | { | ||
801 | ret = -EFAULT; | 665 | ret = -EFAULT; |
802 | break; | 666 | break; |
803 | } | 667 | } |
804 | val = setget_output(priv, val); | 668 | val = setget_output(priv, val); |
805 | if (copy_to_user((unsigned long*)arg, &val, sizeof(val))) | 669 | if (copy_to_user((void __user *)arg, &val, sizeof(val))) |
806 | ret = -EFAULT; | 670 | ret = -EFAULT; |
807 | break; | 671 | break; |
808 | default: | 672 | default: |
@@ -812,7 +676,7 @@ gpio_ioctl(struct inode *inode, struct file *file, | |||
812 | ret = -EINVAL; | 676 | ret = -EINVAL; |
813 | } /* switch */ | 677 | } /* switch */ |
814 | 678 | ||
815 | spin_unlock(&gpio_lock); | 679 | spin_unlock_irqrestore(&gpio_lock, flags); |
816 | return ret; | 680 | return ret; |
817 | } | 681 | } |
818 | 682 | ||
@@ -824,18 +688,18 @@ gpio_leds_ioctl(unsigned int cmd, unsigned long arg) | |||
824 | 688 | ||
825 | switch (_IOC_NR(cmd)) { | 689 | switch (_IOC_NR(cmd)) { |
826 | case IO_LEDACTIVE_SET: | 690 | case IO_LEDACTIVE_SET: |
827 | green = ((unsigned char) arg) & 1; | 691 | green = ((unsigned char)arg) & 1; |
828 | red = (((unsigned char) arg) >> 1) & 1; | 692 | red = (((unsigned char)arg) >> 1) & 1; |
829 | LED_ACTIVE_SET_G(green); | 693 | CRIS_LED_ACTIVE_SET_G(green); |
830 | LED_ACTIVE_SET_R(red); | 694 | CRIS_LED_ACTIVE_SET_R(red); |
831 | break; | 695 | break; |
832 | 696 | ||
833 | case IO_LED_SETBIT: | 697 | case IO_LED_SETBIT: |
834 | LED_BIT_SET(arg); | 698 | CRIS_LED_BIT_SET(arg); |
835 | break; | 699 | break; |
836 | 700 | ||
837 | case IO_LED_CLRBIT: | 701 | case IO_LED_CLRBIT: |
838 | LED_BIT_CLR(arg); | 702 | CRIS_LED_BIT_CLR(arg); |
839 | break; | 703 | break; |
840 | 704 | ||
841 | default: | 705 | default: |
@@ -845,7 +709,7 @@ gpio_leds_ioctl(unsigned int cmd, unsigned long arg) | |||
845 | return 0; | 709 | return 0; |
846 | } | 710 | } |
847 | 711 | ||
848 | const struct file_operations gpio_fops = { | 712 | static const struct file_operations gpio_fops = { |
849 | .owner = THIS_MODULE, | 713 | .owner = THIS_MODULE, |
850 | .poll = gpio_poll, | 714 | .poll = gpio_poll, |
851 | .ioctl = gpio_ioctl, | 715 | .ioctl = gpio_ioctl, |
@@ -854,16 +718,18 @@ const struct file_operations gpio_fops = { | |||
854 | .release = gpio_release, | 718 | .release = gpio_release, |
855 | }; | 719 | }; |
856 | 720 | ||
857 | 721 | static void ioif_watcher(const unsigned int gpio_in_available, | |
858 | void ioif_watcher(const unsigned int gpio_in_available, | 722 | const unsigned int gpio_out_available, |
859 | const unsigned int gpio_out_available, | 723 | const unsigned char pa_available, |
860 | const unsigned char pa_available, | 724 | const unsigned char pb_available) |
861 | const unsigned char pb_available) | ||
862 | { | 725 | { |
863 | unsigned long int flags; | 726 | unsigned long int flags; |
864 | D(printk("gpio.c: ioif_watcher called\n")); | 727 | |
865 | D(printk("gpio.c: G in: 0x%08x G out: 0x%08x PA: 0x%02x PB: 0x%02x\n", | 728 | D(printk(KERN_DEBUG "gpio.c: ioif_watcher called\n")); |
866 | gpio_in_available, gpio_out_available, pa_available, pb_available)); | 729 | D(printk(KERN_DEBUG "gpio.c: G in: 0x%08x G out: 0x%08x " |
730 | "PA: 0x%02x PB: 0x%02x\n", | ||
731 | gpio_in_available, gpio_out_available, | ||
732 | pa_available, pb_available)); | ||
867 | 733 | ||
868 | spin_lock_irqsave(&gpio_lock, flags); | 734 | spin_lock_irqsave(&gpio_lock, flags); |
869 | 735 | ||
@@ -872,7 +738,7 @@ void ioif_watcher(const unsigned int gpio_in_available, | |||
872 | 738 | ||
873 | /* Initialise the dir_g_shadow etc. depending on genconfig */ | 739 | /* Initialise the dir_g_shadow etc. depending on genconfig */ |
874 | /* 0=input 1=output */ | 740 | /* 0=input 1=output */ |
875 | if (genconfig_shadow & IO_STATE(R_GEN_CONFIG, g0dir, out)) | 741 | if (genconfig_shadow & IO_STATE(R_GEN_CONFIG, g0dir, out)) |
876 | dir_g_shadow |= (1 << 0); | 742 | dir_g_shadow |= (1 << 0); |
877 | if (genconfig_shadow & IO_STATE(R_GEN_CONFIG, g8_15dir, out)) | 743 | if (genconfig_shadow & IO_STATE(R_GEN_CONFIG, g8_15dir, out)) |
878 | dir_g_shadow |= 0x0000FF00; | 744 | dir_g_shadow |= 0x0000FF00; |
@@ -884,7 +750,8 @@ void ioif_watcher(const unsigned int gpio_in_available, | |||
884 | changeable_dir_g = changeable_dir_g_mask; | 750 | changeable_dir_g = changeable_dir_g_mask; |
885 | changeable_dir_g &= dir_g_out_bits; | 751 | changeable_dir_g &= dir_g_out_bits; |
886 | changeable_dir_g &= dir_g_in_bits; | 752 | changeable_dir_g &= dir_g_in_bits; |
887 | /* Correct the bits that can change direction */ | 753 | |
754 | /* Correct the bits that can change direction */ | ||
888 | dir_g_out_bits &= ~changeable_dir_g; | 755 | dir_g_out_bits &= ~changeable_dir_g; |
889 | dir_g_out_bits |= dir_g_shadow; | 756 | dir_g_out_bits |= dir_g_shadow; |
890 | dir_g_in_bits &= ~changeable_dir_g; | 757 | dir_g_in_bits &= ~changeable_dir_g; |
@@ -892,7 +759,8 @@ void ioif_watcher(const unsigned int gpio_in_available, | |||
892 | 759 | ||
893 | spin_unlock_irqrestore(&gpio_lock, flags); | 760 | spin_unlock_irqrestore(&gpio_lock, flags); |
894 | 761 | ||
895 | printk(KERN_INFO "GPIO port G: in_bits: 0x%08lX out_bits: 0x%08lX val: %08lX\n", | 762 | printk(KERN_INFO "GPIO port G: in_bits: 0x%08lX out_bits: 0x%08lX " |
763 | "val: %08lX\n", | ||
896 | dir_g_in_bits, dir_g_out_bits, (unsigned long)*R_PORT_G_DATA); | 764 | dir_g_in_bits, dir_g_out_bits, (unsigned long)*R_PORT_G_DATA); |
897 | printk(KERN_INFO "GPIO port G: dir: %08lX changeable: %08lX\n", | 765 | printk(KERN_INFO "GPIO port G: dir: %08lX changeable: %08lX\n", |
898 | dir_g_shadow, changeable_dir_g); | 766 | dir_g_shadow, changeable_dir_g); |
@@ -900,16 +768,12 @@ void ioif_watcher(const unsigned int gpio_in_available, | |||
900 | 768 | ||
901 | /* main driver initialization routine, called from mem.c */ | 769 | /* main driver initialization routine, called from mem.c */ |
902 | 770 | ||
903 | static __init int | 771 | static int __init gpio_init(void) |
904 | gpio_init(void) | ||
905 | { | 772 | { |
906 | int res; | 773 | int res; |
907 | #if defined (CONFIG_ETRAX_CSP0_LEDS) | 774 | #if defined (CONFIG_ETRAX_CSP0_LEDS) |
908 | int i; | 775 | int i; |
909 | #endif | 776 | #endif |
910 | printk("gpio init\n"); | ||
911 | |||
912 | /* do the formalities */ | ||
913 | 777 | ||
914 | res = register_chrdev(GPIO_MAJOR, gpio_name, &gpio_fops); | 778 | res = register_chrdev(GPIO_MAJOR, gpio_name, &gpio_fops); |
915 | if (res < 0) { | 779 | if (res < 0) { |
@@ -919,43 +783,45 @@ gpio_init(void) | |||
919 | 783 | ||
920 | /* Clear all leds */ | 784 | /* Clear all leds */ |
921 | #if defined (CONFIG_ETRAX_CSP0_LEDS) || defined (CONFIG_ETRAX_PA_LEDS) || defined (CONFIG_ETRAX_PB_LEDS) | 785 | #if defined (CONFIG_ETRAX_CSP0_LEDS) || defined (CONFIG_ETRAX_PA_LEDS) || defined (CONFIG_ETRAX_PB_LEDS) |
922 | LED_NETWORK_SET(0); | 786 | CRIS_LED_NETWORK_SET(0); |
923 | LED_ACTIVE_SET(0); | 787 | CRIS_LED_ACTIVE_SET(0); |
924 | LED_DISK_READ(0); | 788 | CRIS_LED_DISK_READ(0); |
925 | LED_DISK_WRITE(0); | 789 | CRIS_LED_DISK_WRITE(0); |
926 | 790 | ||
927 | #if defined (CONFIG_ETRAX_CSP0_LEDS) | 791 | #if defined (CONFIG_ETRAX_CSP0_LEDS) |
928 | for (i = 0; i < 32; i++) { | 792 | for (i = 0; i < 32; i++) |
929 | LED_BIT_SET(i); | 793 | CRIS_LED_BIT_SET(i); |
930 | } | ||
931 | #endif | 794 | #endif |
932 | 795 | ||
933 | #endif | 796 | #endif |
934 | /* The I/O interface allocation watcher will be called when | 797 | /* The I/O interface allocation watcher will be called when |
935 | * registering it. */ | 798 | * registering it. */ |
936 | if (cris_io_interface_register_watcher(ioif_watcher)){ | 799 | if (cris_io_interface_register_watcher(ioif_watcher)){ |
937 | printk(KERN_WARNING "gpio_init: Failed to install IO if allocator watcher\n"); | 800 | printk(KERN_WARNING "gpio_init: Failed to install IO " |
801 | "if allocator watcher\n"); | ||
938 | } | 802 | } |
939 | 803 | ||
940 | printk(KERN_INFO "ETRAX 100LX GPIO driver v2.5, (c) 2001, 2002, 2003, 2004 Axis Communications AB\n"); | 804 | printk(KERN_INFO "ETRAX 100LX GPIO driver v2.5, (c) 2001-2008 " |
805 | "Axis Communications AB\n"); | ||
941 | /* We call etrax_gpio_wake_up_check() from timer interrupt and | 806 | /* We call etrax_gpio_wake_up_check() from timer interrupt and |
942 | * from cpu_idle() in kernel/process.c | 807 | * from cpu_idle() in kernel/process.c |
943 | * The check in cpu_idle() reduces latency from ~15 ms to ~6 ms | 808 | * The check in cpu_idle() reduces latency from ~15 ms to ~6 ms |
944 | * in some tests. | 809 | * in some tests. |
945 | */ | 810 | */ |
946 | if (request_irq(TIMER0_IRQ_NBR, gpio_poll_timer_interrupt, | 811 | res = request_irq(TIMER0_IRQ_NBR, gpio_poll_timer_interrupt, |
947 | IRQF_SHARED | IRQF_DISABLED,"gpio poll", NULL)) { | 812 | IRQF_SHARED | IRQF_DISABLED, "gpio poll", gpio_name); |
813 | if (res) { | ||
948 | printk(KERN_CRIT "err: timer0 irq for gpio\n"); | 814 | printk(KERN_CRIT "err: timer0 irq for gpio\n"); |
815 | return res; | ||
949 | } | 816 | } |
950 | if (request_irq(PA_IRQ_NBR, gpio_pa_interrupt, | 817 | res = request_irq(PA_IRQ_NBR, gpio_interrupt, |
951 | IRQF_SHARED | IRQF_DISABLED,"gpio PA", NULL)) { | 818 | IRQF_SHARED | IRQF_DISABLED, "gpio PA", gpio_name); |
819 | if (res) | ||
952 | printk(KERN_CRIT "err: PA irq for gpio\n"); | 820 | printk(KERN_CRIT "err: PA irq for gpio\n"); |
953 | } | ||
954 | |||
955 | 821 | ||
956 | return res; | 822 | return res; |
957 | } | 823 | } |
958 | 824 | ||
959 | /* this makes sure that gpio_init is called during kernel boot */ | 825 | /* this makes sure that gpio_init is called during kernel boot */ |
960 | |||
961 | module_init(gpio_init); | 826 | module_init(gpio_init); |
827 | |||
diff --git a/arch/cris/arch-v10/drivers/i2c.c b/arch/cris/arch-v10/drivers/i2c.c index aca81ddaf60f..d6d22067d0c8 100644 --- a/arch/cris/arch-v10/drivers/i2c.c +++ b/arch/cris/arch-v10/drivers/i2c.c | |||
@@ -6,85 +6,9 @@ | |||
6 | *! kernel modules (i2c_writereg/readreg) and from userspace using | 6 | *! kernel modules (i2c_writereg/readreg) and from userspace using |
7 | *! ioctl()'s | 7 | *! ioctl()'s |
8 | *! | 8 | *! |
9 | *! Nov 30 1998 Torbjorn Eliasson Initial version. | 9 | *! (C) Copyright 1999-2007 Axis Communications AB, LUND, SWEDEN |
10 | *! Bjorn Wesen Elinux kernel version. | ||
11 | *! Jan 14 2000 Johan Adolfsson Fixed PB shadow register stuff - | ||
12 | *! don't use PB_I2C if DS1302 uses same bits, | ||
13 | *! use PB. | ||
14 | *! $Log: i2c.c,v $ | ||
15 | *! Revision 1.13 2005/03/07 13:13:07 starvik | ||
16 | *! Added spinlocks to protect states etc | ||
17 | *! | ||
18 | *! Revision 1.12 2005/01/05 06:11:22 starvik | ||
19 | *! No need to do local_irq_disable after local_irq_save. | ||
20 | *! | ||
21 | *! Revision 1.11 2004/12/13 12:21:52 starvik | ||
22 | *! Added I/O and DMA allocators from Linux 2.4 | ||
23 | *! | ||
24 | *! Revision 1.9 2004/08/24 06:49:14 starvik | ||
25 | *! Whitespace cleanup | ||
26 | *! | ||
27 | *! Revision 1.8 2004/06/08 08:48:26 starvik | ||
28 | *! Removed unused code | ||
29 | *! | ||
30 | *! Revision 1.7 2004/05/28 09:26:59 starvik | ||
31 | *! Modified I2C initialization to work in 2.6. | ||
32 | *! | ||
33 | *! Revision 1.6 2004/05/14 07:58:03 starvik | ||
34 | *! Merge of changes from 2.4 | ||
35 | *! | ||
36 | *! Revision 1.4 2002/12/11 13:13:57 starvik | ||
37 | *! Added arch/ to v10 specific includes | ||
38 | *! Added fix from Linux 2.4 in serial.c (flush_to_flip_buffer) | ||
39 | *! | ||
40 | *! Revision 1.3 2002/11/20 11:56:11 starvik | ||
41 | *! Merge of Linux 2.5.48 | ||
42 | *! | ||
43 | *! Revision 1.2 2002/11/18 13:16:06 starvik | ||
44 | *! Linux 2.5 port of latest 2.4 drivers | ||
45 | *! | ||
46 | *! Revision 1.9 2002/10/31 15:32:26 starvik | ||
47 | *! Update Port B register and shadow even when running with hardware support | ||
48 | *! to avoid glitches when reading bits | ||
49 | *! Never set direction to out in i2c_inbyte | ||
50 | *! Removed incorrect clock toggling at end of i2c_inbyte | ||
51 | *! | ||
52 | *! Revision 1.8 2002/08/13 06:31:53 starvik | ||
53 | *! Made SDA and SCL line configurable | ||
54 | *! Modified i2c_inbyte to work with PCF8563 | ||
55 | *! | ||
56 | *! Revision 1.7 2001/04/04 13:11:36 markusl | ||
57 | *! Updated according to review remarks | ||
58 | *! | ||
59 | *! Revision 1.6 2001/03/19 12:43:00 markusl | ||
60 | *! Made some symbols unstatic (used by the eeprom driver) | ||
61 | *! | ||
62 | *! Revision 1.5 2001/02/27 13:52:48 bjornw | ||
63 | *! malloc.h -> slab.h | ||
64 | *! | ||
65 | *! Revision 1.4 2001/02/15 07:17:40 starvik | ||
66 | *! Corrected usage if port_pb_i2c_shadow | ||
67 | *! | ||
68 | *! Revision 1.3 2001/01/26 17:55:13 bjornw | ||
69 | *! * Made I2C_USES_PB_NOT_PB_I2C a CONFIG option instead of assigning it | ||
70 | *! magically. Config.in needs to set it for the options that need it, like | ||
71 | *! Dallas 1302 support. Actually, it should be default since it screws up | ||
72 | *! the PB bits even if you don't use I2C.. | ||
73 | *! * Include linux/config.h to get the above | ||
74 | *! | ||
75 | *! Revision 1.2 2001/01/18 15:49:30 bjornw | ||
76 | *! 2.4 port of I2C including some cleanups (untested of course) | ||
77 | *! | ||
78 | *! Revision 1.1 2001/01/18 15:35:25 bjornw | ||
79 | *! Verbatim copy of the Etrax i2c driver, 2.0 elinux version | ||
80 | *! | ||
81 | *! | ||
82 | *! --------------------------------------------------------------------------- | ||
83 | *! | ||
84 | *! (C) Copyright 1999-2002 Axis Communications AB, LUND, SWEDEN | ||
85 | *! | 10 | *! |
86 | *!***************************************************************************/ | 11 | *!***************************************************************************/ |
87 | /* $Id: i2c.c,v 1.13 2005/03/07 13:13:07 starvik Exp $ */ | ||
88 | 12 | ||
89 | /****************** INCLUDE FILES SECTION ***********************************/ | 13 | /****************** INCLUDE FILES SECTION ***********************************/ |
90 | 14 | ||
@@ -622,7 +546,7 @@ i2c_readreg(unsigned char theSlave, unsigned char theReg) | |||
622 | * last received byte needs to be nacked | 546 | * last received byte needs to be nacked |
623 | * instead of acked | 547 | * instead of acked |
624 | */ | 548 | */ |
625 | i2c_sendack(); | 549 | i2c_sendnack(); |
626 | /* | 550 | /* |
627 | * end sequence | 551 | * end sequence |
628 | */ | 552 | */ |
@@ -708,6 +632,7 @@ i2c_init(void) | |||
708 | if (!first) { | 632 | if (!first) { |
709 | return res; | 633 | return res; |
710 | } | 634 | } |
635 | first = 0; | ||
711 | 636 | ||
712 | /* Setup and enable the Port B I2C interface */ | 637 | /* Setup and enable the Port B I2C interface */ |
713 | 638 | ||
diff --git a/arch/cris/arch-v10/drivers/pcf8563.c b/arch/cris/arch-v10/drivers/pcf8563.c index c263b8232dbc..52103d16dc6c 100644 --- a/arch/cris/arch-v10/drivers/pcf8563.c +++ b/arch/cris/arch-v10/drivers/pcf8563.c | |||
@@ -8,14 +8,13 @@ | |||
8 | * low detector are also provided. All address and data are transferred | 8 | * low detector are also provided. All address and data are transferred |
9 | * serially via two-line bidirectional I2C-bus. Maximum bus speed is | 9 | * serially via two-line bidirectional I2C-bus. Maximum bus speed is |
10 | * 400 kbits/s. The built-in word address register is incremented | 10 | * 400 kbits/s. The built-in word address register is incremented |
11 | * automatically after each written or read bute. | 11 | * automatically after each written or read byte. |
12 | * | 12 | * |
13 | * Copyright (c) 2002, Axis Communications AB | 13 | * Copyright (c) 2002-2007, Axis Communications AB |
14 | * All rights reserved. | 14 | * All rights reserved. |
15 | * | 15 | * |
16 | * Author: Tobias Anderberg <tobiasa@axis.com>. | 16 | * Author: Tobias Anderberg <tobiasa@axis.com>. |
17 | * | 17 | * |
18 | * $Id: pcf8563.c,v 1.11 2005/03/07 13:13:07 starvik Exp $ | ||
19 | */ | 18 | */ |
20 | 19 | ||
21 | #include <linux/module.h> | 20 | #include <linux/module.h> |
@@ -27,19 +26,19 @@ | |||
27 | #include <linux/ioctl.h> | 26 | #include <linux/ioctl.h> |
28 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
29 | #include <linux/bcd.h> | 28 | #include <linux/bcd.h> |
30 | #include <linux/capability.h> | 29 | #include <linux/mutex.h> |
31 | 30 | ||
32 | #include <asm/uaccess.h> | 31 | #include <asm/uaccess.h> |
33 | #include <asm/system.h> | 32 | #include <asm/system.h> |
34 | #include <asm/io.h> | 33 | #include <asm/io.h> |
35 | #include <asm/arch/svinto.h> | ||
36 | #include <asm/rtc.h> | 34 | #include <asm/rtc.h> |
35 | |||
37 | #include "i2c.h" | 36 | #include "i2c.h" |
38 | 37 | ||
39 | #define PCF8563_MAJOR 121 /* Local major number. */ | 38 | #define PCF8563_MAJOR 121 /* Local major number. */ |
40 | #define DEVICE_NAME "rtc" /* Name which is registered in /proc/devices. */ | 39 | #define DEVICE_NAME "rtc" /* Name which is registered in /proc/devices. */ |
41 | #define PCF8563_NAME "PCF8563" | 40 | #define PCF8563_NAME "PCF8563" |
42 | #define DRIVER_VERSION "$Revision: 1.11 $" | 41 | #define DRIVER_VERSION "$Revision: 1.24 $" |
43 | 42 | ||
44 | /* I2C bus slave registers. */ | 43 | /* I2C bus slave registers. */ |
45 | #define RTC_I2C_READ 0xa3 | 44 | #define RTC_I2C_READ 0xa3 |
@@ -49,71 +48,88 @@ | |||
49 | #define rtc_read(x) i2c_readreg(RTC_I2C_READ, x) | 48 | #define rtc_read(x) i2c_readreg(RTC_I2C_READ, x) |
50 | #define rtc_write(x,y) i2c_writereg(RTC_I2C_WRITE, x, y) | 49 | #define rtc_write(x,y) i2c_writereg(RTC_I2C_WRITE, x, y) |
51 | 50 | ||
52 | static DEFINE_SPINLOCK(rtc_lock); /* Protect state etc */ | 51 | static DEFINE_MUTEX(rtc_lock); /* Protect state etc */ |
53 | 52 | ||
54 | static const unsigned char days_in_month[] = | 53 | static const unsigned char days_in_month[] = |
55 | { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; | 54 | { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; |
56 | 55 | ||
57 | int pcf8563_ioctl(struct inode *, struct file *, unsigned int, unsigned long); | 56 | int pcf8563_ioctl(struct inode *, struct file *, unsigned int, unsigned long); |
58 | 57 | ||
58 | /* Cache VL bit value read at driver init since writing the RTC_SECOND | ||
59 | * register clears the VL status. | ||
60 | */ | ||
61 | static int voltage_low; | ||
62 | |||
59 | static const struct file_operations pcf8563_fops = { | 63 | static const struct file_operations pcf8563_fops = { |
60 | .owner = THIS_MODULE, | 64 | .owner = THIS_MODULE, |
61 | .ioctl = pcf8563_ioctl, | 65 | .ioctl = pcf8563_ioctl, |
62 | }; | 66 | }; |
63 | 67 | ||
64 | unsigned char | 68 | unsigned char |
65 | pcf8563_readreg(int reg) | 69 | pcf8563_readreg(int reg) |
66 | { | 70 | { |
67 | unsigned char res = i2c_readreg(RTC_I2C_READ, reg); | 71 | unsigned char res = rtc_read(reg); |
68 | 72 | ||
69 | /* The PCF8563 does not return 0 for unimplemented bits */ | 73 | /* The PCF8563 does not return 0 for unimplemented bits. */ |
70 | switch(reg) | 74 | switch (reg) { |
71 | { | 75 | case RTC_SECONDS: |
72 | case RTC_SECONDS: | 76 | case RTC_MINUTES: |
73 | case RTC_MINUTES: | 77 | res &= 0x7F; |
74 | res &= 0x7f; | 78 | break; |
75 | break; | 79 | case RTC_HOURS: |
76 | case RTC_HOURS: | 80 | case RTC_DAY_OF_MONTH: |
77 | case RTC_DAY_OF_MONTH: | 81 | res &= 0x3F; |
78 | res &= 0x3f; | 82 | break; |
79 | break; | 83 | case RTC_WEEKDAY: |
80 | case RTC_MONTH: | 84 | res &= 0x07; |
81 | res = (res & 0x1f) - 1; /* PCF8563 returns month in range 1-12 */ | 85 | break; |
82 | break; | 86 | case RTC_MONTH: |
87 | res &= 0x1F; | ||
88 | break; | ||
89 | case RTC_CONTROL1: | ||
90 | res &= 0xA8; | ||
91 | break; | ||
92 | case RTC_CONTROL2: | ||
93 | res &= 0x1F; | ||
94 | break; | ||
95 | case RTC_CLOCKOUT_FREQ: | ||
96 | case RTC_TIMER_CONTROL: | ||
97 | res &= 0x83; | ||
98 | break; | ||
83 | } | 99 | } |
84 | return res; | 100 | return res; |
85 | } | 101 | } |
86 | 102 | ||
87 | void | 103 | void |
88 | pcf8563_writereg(int reg, unsigned char val) | 104 | pcf8563_writereg(int reg, unsigned char val) |
89 | { | 105 | { |
90 | #ifdef CONFIG_ETRAX_RTC_READONLY | ||
91 | if (reg == RTC_CONTROL1 || (reg >= RTC_SECONDS && reg <= RTC_YEAR)) | ||
92 | return; | ||
93 | #endif | ||
94 | |||
95 | rtc_write(reg, val); | 106 | rtc_write(reg, val); |
96 | } | 107 | } |
97 | 108 | ||
98 | void | 109 | void |
99 | get_rtc_time(struct rtc_time *tm) | 110 | get_rtc_time(struct rtc_time *tm) |
100 | { | 111 | { |
101 | tm->tm_sec = rtc_read(RTC_SECONDS); | 112 | tm->tm_sec = rtc_read(RTC_SECONDS); |
102 | tm->tm_min = rtc_read(RTC_MINUTES); | 113 | tm->tm_min = rtc_read(RTC_MINUTES); |
103 | tm->tm_hour = rtc_read(RTC_HOURS); | 114 | tm->tm_hour = rtc_read(RTC_HOURS); |
104 | tm->tm_mday = rtc_read(RTC_DAY_OF_MONTH); | 115 | tm->tm_mday = rtc_read(RTC_DAY_OF_MONTH); |
105 | tm->tm_mon = rtc_read(RTC_MONTH); | 116 | tm->tm_wday = rtc_read(RTC_WEEKDAY); |
117 | tm->tm_mon = rtc_read(RTC_MONTH); | ||
106 | tm->tm_year = rtc_read(RTC_YEAR); | 118 | tm->tm_year = rtc_read(RTC_YEAR); |
107 | 119 | ||
108 | if (tm->tm_sec & 0x80) | 120 | if (tm->tm_sec & 0x80) { |
109 | printk(KERN_WARNING "%s: RTC Low Voltage - date/time is not reliable!\n", PCF8563_NAME); | 121 | printk(KERN_ERR "%s: RTC Voltage Low - reliable date/time " |
122 | "information is no longer guaranteed!\n", PCF8563_NAME); | ||
123 | } | ||
110 | 124 | ||
111 | tm->tm_year = BCD_TO_BIN(tm->tm_year) + ((tm->tm_mon & 0x80) ? 100 : 0); | 125 | tm->tm_year = BCD_TO_BIN(tm->tm_year) + |
112 | tm->tm_sec &= 0x7f; | 126 | ((tm->tm_mon & 0x80) ? 100 : 0); |
113 | tm->tm_min &= 0x7f; | 127 | tm->tm_sec &= 0x7F; |
114 | tm->tm_hour &= 0x3f; | 128 | tm->tm_min &= 0x7F; |
115 | tm->tm_mday &= 0x3f; | 129 | tm->tm_hour &= 0x3F; |
116 | tm->tm_mon &= 0x1f; | 130 | tm->tm_mday &= 0x3F; |
131 | tm->tm_wday &= 0x07; /* Not coded in BCD. */ | ||
132 | tm->tm_mon &= 0x1F; | ||
117 | 133 | ||
118 | BCD_TO_BIN(tm->tm_sec); | 134 | BCD_TO_BIN(tm->tm_sec); |
119 | BCD_TO_BIN(tm->tm_min); | 135 | BCD_TO_BIN(tm->tm_min); |
@@ -126,17 +142,24 @@ get_rtc_time(struct rtc_time *tm) | |||
126 | int __init | 142 | int __init |
127 | pcf8563_init(void) | 143 | pcf8563_init(void) |
128 | { | 144 | { |
129 | int ret; | 145 | static int res; |
130 | 146 | static int first = 1; | |
131 | if ((ret = i2c_init())) { | 147 | |
132 | printk(KERN_CRIT "pcf8563_init: failed to init i2c\n"); | 148 | if (!first) |
133 | return ret; | 149 | return res; |
150 | first = 0; | ||
151 | |||
152 | /* Initiate the i2c protocol. */ | ||
153 | res = i2c_init(); | ||
154 | if (res < 0) { | ||
155 | printk(KERN_CRIT "pcf8563_init: Failed to init i2c.\n"); | ||
156 | return res; | ||
134 | } | 157 | } |
135 | 158 | ||
136 | /* | 159 | /* |
137 | * First of all we need to reset the chip. This is done by | 160 | * First of all we need to reset the chip. This is done by |
138 | * clearing control1, control2 and clk freq, clear the | 161 | * clearing control1, control2 and clk freq and resetting |
139 | * Voltage Low bit, and resetting all alarms. | 162 | * all alarms. |
140 | */ | 163 | */ |
141 | if (rtc_write(RTC_CONTROL1, 0x00) < 0) | 164 | if (rtc_write(RTC_CONTROL1, 0x00) < 0) |
142 | goto err; | 165 | goto err; |
@@ -147,34 +170,36 @@ pcf8563_init(void) | |||
147 | if (rtc_write(RTC_CLOCKOUT_FREQ, 0x00) < 0) | 170 | if (rtc_write(RTC_CLOCKOUT_FREQ, 0x00) < 0) |
148 | goto err; | 171 | goto err; |
149 | 172 | ||
150 | /* Clear the VL bit in the seconds register. */ | 173 | if (rtc_write(RTC_TIMER_CONTROL, 0x03) < 0) |
151 | ret = rtc_read(RTC_SECONDS); | ||
152 | |||
153 | if (rtc_write(RTC_SECONDS, (ret & 0x7f)) < 0) | ||
154 | goto err; | 174 | goto err; |
155 | 175 | ||
156 | /* Reset the alarms. */ | 176 | /* Reset the alarms. */ |
157 | if (rtc_write(RTC_MINUTE_ALARM, 0x00) < 0) | 177 | if (rtc_write(RTC_MINUTE_ALARM, 0x80) < 0) |
158 | goto err; | 178 | goto err; |
159 | 179 | ||
160 | if (rtc_write(RTC_HOUR_ALARM, 0x00) < 0) | 180 | if (rtc_write(RTC_HOUR_ALARM, 0x80) < 0) |
161 | goto err; | 181 | goto err; |
162 | 182 | ||
163 | if (rtc_write(RTC_DAY_ALARM, 0x00) < 0) | 183 | if (rtc_write(RTC_DAY_ALARM, 0x80) < 0) |
164 | goto err; | 184 | goto err; |
165 | 185 | ||
166 | if (rtc_write(RTC_WEEKDAY_ALARM, 0x00) < 0) | 186 | if (rtc_write(RTC_WEEKDAY_ALARM, 0x80) < 0) |
167 | goto err; | 187 | goto err; |
168 | 188 | ||
169 | /* Check for low voltage, and warn about it.. */ | 189 | /* Check for low voltage, and warn about it. */ |
170 | if (rtc_read(RTC_SECONDS) & 0x80) | 190 | if (rtc_read(RTC_SECONDS) & 0x80) { |
171 | printk(KERN_WARNING "%s: RTC Low Voltage - date/time is not reliable!\n", PCF8563_NAME); | 191 | voltage_low = 1; |
172 | 192 | printk(KERN_WARNING "%s: RTC Voltage Low - reliable " | |
173 | return 0; | 193 | "date/time information is no longer guaranteed!\n", |
194 | PCF8563_NAME); | ||
195 | } | ||
196 | |||
197 | return res; | ||
174 | 198 | ||
175 | err: | 199 | err: |
176 | printk(KERN_INFO "%s: Error initializing chip.\n", PCF8563_NAME); | 200 | printk(KERN_INFO "%s: Error initializing chip.\n", PCF8563_NAME); |
177 | return -1; | 201 | res = -1; |
202 | return res; | ||
178 | } | 203 | } |
179 | 204 | ||
180 | void __exit | 205 | void __exit |
@@ -187,8 +212,8 @@ pcf8563_exit(void) | |||
187 | * ioctl calls for this driver. Why return -ENOTTY upon error? Because | 212 | * ioctl calls for this driver. Why return -ENOTTY upon error? Because |
188 | * POSIX says so! | 213 | * POSIX says so! |
189 | */ | 214 | */ |
190 | int | 215 | int pcf8563_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, |
191 | pcf8563_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) | 216 | unsigned long arg) |
192 | { | 217 | { |
193 | /* Some sanity checks. */ | 218 | /* Some sanity checks. */ |
194 | if (_IOC_TYPE(cmd) != RTC_MAGIC) | 219 | if (_IOC_TYPE(cmd) != RTC_MAGIC) |
@@ -198,124 +223,146 @@ pcf8563_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned | |||
198 | return -ENOTTY; | 223 | return -ENOTTY; |
199 | 224 | ||
200 | switch (cmd) { | 225 | switch (cmd) { |
201 | case RTC_RD_TIME: | 226 | case RTC_RD_TIME: |
202 | { | 227 | { |
203 | struct rtc_time tm; | 228 | struct rtc_time tm; |
204 | |||
205 | spin_lock(&rtc_lock); | ||
206 | get_rtc_time(&tm); | ||
207 | |||
208 | if (copy_to_user((struct rtc_time *) arg, &tm, sizeof(struct rtc_time))) { | ||
209 | spin_unlock(&rtc_lock); | ||
210 | return -EFAULT; | ||
211 | } | ||
212 | |||
213 | spin_unlock(&rtc_lock); | ||
214 | return 0; | ||
215 | } | ||
216 | break; | ||
217 | case RTC_SET_TIME: | ||
218 | { | ||
219 | #ifdef CONFIG_ETRAX_RTC_READONLY | ||
220 | return -EPERM; | ||
221 | #else | ||
222 | int leap; | ||
223 | int century; | ||
224 | struct rtc_time tm; | ||
225 | |||
226 | memset(&tm, 0, sizeof (struct rtc_time)); | ||
227 | if (!capable(CAP_SYS_TIME)) | ||
228 | return -EPERM; | ||
229 | |||
230 | if (copy_from_user(&tm, (struct rtc_time *) arg, sizeof(struct rtc_time))) | ||
231 | return -EFAULT; | ||
232 | |||
233 | /* Convert from struct tm to struct rtc_time. */ | ||
234 | tm.tm_year += 1900; | ||
235 | tm.tm_mon += 1; | ||
236 | |||
237 | leap = ((tm.tm_mon == 2) && ((tm.tm_year % 4) == 0)) ? 1 : 0; | ||
238 | |||
239 | /* Perform some sanity checks. */ | ||
240 | if ((tm.tm_year < 1970) || | ||
241 | (tm.tm_mon > 12) || | ||
242 | (tm.tm_mday == 0) || | ||
243 | (tm.tm_mday > days_in_month[tm.tm_mon] + leap) || | ||
244 | (tm.tm_hour >= 24) || | ||
245 | (tm.tm_min >= 60) || | ||
246 | (tm.tm_sec >= 60)) | ||
247 | return -EINVAL; | ||
248 | |||
249 | century = (tm.tm_year >= 2000) ? 0x80 : 0; | ||
250 | tm.tm_year = tm.tm_year % 100; | ||
251 | |||
252 | BIN_TO_BCD(tm.tm_year); | ||
253 | BIN_TO_BCD(tm.tm_mday); | ||
254 | BIN_TO_BCD(tm.tm_hour); | ||
255 | BIN_TO_BCD(tm.tm_min); | ||
256 | BIN_TO_BCD(tm.tm_sec); | ||
257 | tm.tm_mon |= century; | ||
258 | |||
259 | spin_lock(&rtc_lock); | ||
260 | |||
261 | rtc_write(RTC_YEAR, tm.tm_year); | ||
262 | rtc_write(RTC_MONTH, tm.tm_mon); | ||
263 | rtc_write(RTC_DAY_OF_MONTH, tm.tm_mday); | ||
264 | rtc_write(RTC_HOURS, tm.tm_hour); | ||
265 | rtc_write(RTC_MINUTES, tm.tm_min); | ||
266 | rtc_write(RTC_SECONDS, tm.tm_sec); | ||
267 | |||
268 | spin_unlock(&rtc_lock); | ||
269 | |||
270 | return 0; | ||
271 | #endif /* !CONFIG_ETRAX_RTC_READONLY */ | ||
272 | } | ||
273 | |||
274 | case RTC_VLOW_RD: | ||
275 | { | ||
276 | int vl_bit = 0; | ||
277 | |||
278 | if (rtc_read(RTC_SECONDS) & 0x80) { | ||
279 | vl_bit = 1; | ||
280 | printk(KERN_WARNING "%s: RTC Voltage Low - reliable " | ||
281 | "date/time information is no longer guaranteed!\n", | ||
282 | PCF8563_NAME); | ||
283 | } | ||
284 | if (copy_to_user((int *) arg, &vl_bit, sizeof(int))) | ||
285 | return -EFAULT; | ||
286 | |||
287 | return 0; | ||
288 | } | ||
289 | 229 | ||
290 | case RTC_VLOW_SET: | 230 | mutex_lock(&rtc_lock); |
291 | { | 231 | memset(&tm, 0, sizeof tm); |
292 | /* Clear the VL bit in the seconds register */ | 232 | get_rtc_time(&tm); |
293 | int ret = rtc_read(RTC_SECONDS); | ||
294 | 233 | ||
295 | rtc_write(RTC_SECONDS, (ret & 0x7F)); | 234 | if (copy_to_user((struct rtc_time *) arg, &tm, |
235 | sizeof tm)) { | ||
236 | spin_unlock(&rtc_lock); | ||
237 | return -EFAULT; | ||
238 | } | ||
239 | |||
240 | mutex_unlock(&rtc_lock); | ||
296 | 241 | ||
297 | return 0; | 242 | return 0; |
243 | } | ||
244 | case RTC_SET_TIME: | ||
245 | { | ||
246 | int leap; | ||
247 | int year; | ||
248 | int century; | ||
249 | struct rtc_time tm; | ||
250 | |||
251 | memset(&tm, 0, sizeof tm); | ||
252 | if (!capable(CAP_SYS_TIME)) | ||
253 | return -EPERM; | ||
254 | |||
255 | if (copy_from_user(&tm, (struct rtc_time *) arg, sizeof tm)) | ||
256 | return -EFAULT; | ||
257 | |||
258 | /* Convert from struct tm to struct rtc_time. */ | ||
259 | tm.tm_year += 1900; | ||
260 | tm.tm_mon += 1; | ||
261 | |||
262 | /* | ||
263 | * Check if tm.tm_year is a leap year. A year is a leap | ||
264 | * year if it is divisible by 4 but not 100, except | ||
265 | * that years divisible by 400 _are_ leap years. | ||
266 | */ | ||
267 | year = tm.tm_year; | ||
268 | leap = (tm.tm_mon == 2) && | ||
269 | ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0); | ||
270 | |||
271 | /* Perform some sanity checks. */ | ||
272 | if ((tm.tm_year < 1970) || | ||
273 | (tm.tm_mon > 12) || | ||
274 | (tm.tm_mday == 0) || | ||
275 | (tm.tm_mday > days_in_month[tm.tm_mon] + leap) || | ||
276 | (tm.tm_wday >= 7) || | ||
277 | (tm.tm_hour >= 24) || | ||
278 | (tm.tm_min >= 60) || | ||
279 | (tm.tm_sec >= 60)) | ||
280 | return -EINVAL; | ||
281 | |||
282 | century = (tm.tm_year >= 2000) ? 0x80 : 0; | ||
283 | tm.tm_year = tm.tm_year % 100; | ||
284 | |||
285 | BIN_TO_BCD(tm.tm_year); | ||
286 | BIN_TO_BCD(tm.tm_mon); | ||
287 | BIN_TO_BCD(tm.tm_mday); | ||
288 | BIN_TO_BCD(tm.tm_hour); | ||
289 | BIN_TO_BCD(tm.tm_min); | ||
290 | BIN_TO_BCD(tm.tm_sec); | ||
291 | tm.tm_mon |= century; | ||
292 | |||
293 | mutex_lock(&rtc_lock); | ||
294 | |||
295 | rtc_write(RTC_YEAR, tm.tm_year); | ||
296 | rtc_write(RTC_MONTH, tm.tm_mon); | ||
297 | rtc_write(RTC_WEEKDAY, tm.tm_wday); /* Not coded in BCD. */ | ||
298 | rtc_write(RTC_DAY_OF_MONTH, tm.tm_mday); | ||
299 | rtc_write(RTC_HOURS, tm.tm_hour); | ||
300 | rtc_write(RTC_MINUTES, tm.tm_min); | ||
301 | rtc_write(RTC_SECONDS, tm.tm_sec); | ||
302 | |||
303 | mutex_unlock(&rtc_lock); | ||
304 | |||
305 | return 0; | ||
306 | } | ||
307 | case RTC_VL_READ: | ||
308 | if (voltage_low) { | ||
309 | printk(KERN_ERR "%s: RTC Voltage Low - " | ||
310 | "reliable date/time information is no " | ||
311 | "longer guaranteed!\n", PCF8563_NAME); | ||
298 | } | 312 | } |
299 | 313 | ||
300 | default: | 314 | if (copy_to_user((int *) arg, &voltage_low, sizeof(int))) |
301 | return -ENOTTY; | 315 | return -EFAULT; |
316 | return 0; | ||
317 | |||
318 | case RTC_VL_CLR: | ||
319 | { | ||
320 | /* Clear the VL bit in the seconds register in case | ||
321 | * the time has not been set already (which would | ||
322 | * have cleared it). This does not really matter | ||
323 | * because of the cached voltage_low value but do it | ||
324 | * anyway for consistency. */ | ||
325 | |||
326 | int ret = rtc_read(RTC_SECONDS); | ||
327 | |||
328 | rtc_write(RTC_SECONDS, (ret & 0x7F)); | ||
329 | |||
330 | /* Clear the cached value. */ | ||
331 | voltage_low = 0; | ||
332 | |||
333 | return 0; | ||
334 | } | ||
335 | default: | ||
336 | return -ENOTTY; | ||
302 | } | 337 | } |
303 | 338 | ||
304 | return 0; | 339 | return 0; |
305 | } | 340 | } |
306 | 341 | ||
307 | static int __init | 342 | static int __init pcf8563_register(void) |
308 | pcf8563_register(void) | ||
309 | { | 343 | { |
310 | pcf8563_init(); | 344 | if (pcf8563_init() < 0) { |
345 | printk(KERN_INFO "%s: Unable to initialize Real-Time Clock " | ||
346 | "Driver, %s\n", PCF8563_NAME, DRIVER_VERSION); | ||
347 | return -1; | ||
348 | } | ||
349 | |||
311 | if (register_chrdev(PCF8563_MAJOR, DEVICE_NAME, &pcf8563_fops) < 0) { | 350 | if (register_chrdev(PCF8563_MAJOR, DEVICE_NAME, &pcf8563_fops) < 0) { |
312 | printk(KERN_INFO "%s: Unable to get major number %d for RTC device.\n", | 351 | printk(KERN_INFO "%s: Unable to get major number %d for RTC device.\n", |
313 | PCF8563_NAME, PCF8563_MAJOR); | 352 | PCF8563_NAME, PCF8563_MAJOR); |
314 | return -1; | 353 | return -1; |
315 | } | 354 | } |
316 | 355 | ||
317 | printk(KERN_INFO "%s Real-Time Clock Driver, %s\n", PCF8563_NAME, DRIVER_VERSION); | 356 | printk(KERN_INFO "%s Real-Time Clock Driver, %s\n", PCF8563_NAME, |
318 | return 0; | 357 | DRIVER_VERSION); |
358 | |||
359 | /* Check for low voltage, and warn about it. */ | ||
360 | if (voltage_low) { | ||
361 | printk(KERN_WARNING "%s: RTC Voltage Low - reliable date/time " | ||
362 | "information is no longer guaranteed!\n", PCF8563_NAME); | ||
363 | } | ||
364 | |||
365 | return 0; | ||
319 | } | 366 | } |
320 | 367 | ||
321 | module_init(pcf8563_register); | 368 | module_init(pcf8563_register); |
diff --git a/arch/cris/arch-v10/drivers/sync_serial.c b/arch/cris/arch-v10/drivers/sync_serial.c new file mode 100644 index 000000000000..069546e342c5 --- /dev/null +++ b/arch/cris/arch-v10/drivers/sync_serial.c | |||
@@ -0,0 +1,1441 @@ | |||
1 | /* | ||
2 | * Simple synchronous serial port driver for ETRAX 100LX. | ||
3 | * | ||
4 | * Synchronous serial ports are used for continuous streamed data like audio. | ||
5 | * The default setting for this driver is compatible with the STA 013 MP3 | ||
6 | * decoder. The driver can easily be tuned to fit other audio encoder/decoders | ||
7 | * and SPI | ||
8 | * | ||
9 | * Copyright (c) 2001-2008 Axis Communications AB | ||
10 | * | ||
11 | * Author: Mikael Starvik, Johan Adolfsson | ||
12 | * | ||
13 | */ | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/types.h> | ||
17 | #include <linux/errno.h> | ||
18 | #include <linux/major.h> | ||
19 | #include <linux/sched.h> | ||
20 | #include <linux/slab.h> | ||
21 | #include <linux/interrupt.h> | ||
22 | #include <linux/poll.h> | ||
23 | #include <linux/init.h> | ||
24 | #include <linux/timer.h> | ||
25 | #include <asm/irq.h> | ||
26 | #include <asm/dma.h> | ||
27 | #include <asm/io.h> | ||
28 | #include <asm/arch/svinto.h> | ||
29 | #include <asm/uaccess.h> | ||
30 | #include <asm/system.h> | ||
31 | #include <asm/sync_serial.h> | ||
32 | #include <asm/arch/io_interface_mux.h> | ||
33 | |||
34 | /* The receiver is a bit tricky beacuse of the continuous stream of data.*/ | ||
35 | /* */ | ||
36 | /* Three DMA descriptors are linked together. Each DMA descriptor is */ | ||
37 | /* responsible for port->bufchunk of a common buffer. */ | ||
38 | /* */ | ||
39 | /* +---------------------------------------------+ */ | ||
40 | /* | +----------+ +----------+ +----------+ | */ | ||
41 | /* +-> | Descr[0] |-->| Descr[1] |-->| Descr[2] |-+ */ | ||
42 | /* +----------+ +----------+ +----------+ */ | ||
43 | /* | | | */ | ||
44 | /* v v v */ | ||
45 | /* +-------------------------------------+ */ | ||
46 | /* | BUFFER | */ | ||
47 | /* +-------------------------------------+ */ | ||
48 | /* |<- data_avail ->| */ | ||
49 | /* readp writep */ | ||
50 | /* */ | ||
51 | /* If the application keeps up the pace readp will be right after writep.*/ | ||
52 | /* If the application can't keep the pace we have to throw away data. */ | ||
53 | /* The idea is that readp should be ready with the data pointed out by */ | ||
54 | /* Descr[i] when the DMA has filled in Descr[i+1]. */ | ||
55 | /* Otherwise we will discard */ | ||
56 | /* the rest of the data pointed out by Descr1 and set readp to the start */ | ||
57 | /* of Descr2 */ | ||
58 | |||
59 | #define SYNC_SERIAL_MAJOR 125 | ||
60 | |||
61 | /* IN_BUFFER_SIZE should be a multiple of 6 to make sure that 24 bit */ | ||
62 | /* words can be handled */ | ||
63 | #define IN_BUFFER_SIZE 12288 | ||
64 | #define IN_DESCR_SIZE 256 | ||
65 | #define NUM_IN_DESCR (IN_BUFFER_SIZE/IN_DESCR_SIZE) | ||
66 | #define OUT_BUFFER_SIZE 4096 | ||
67 | |||
68 | #define DEFAULT_FRAME_RATE 0 | ||
69 | #define DEFAULT_WORD_RATE 7 | ||
70 | |||
71 | /* NOTE: Enabling some debug will likely cause overrun or underrun, | ||
72 | * especially if manual mode is use. | ||
73 | */ | ||
74 | #define DEBUG(x) | ||
75 | #define DEBUGREAD(x) | ||
76 | #define DEBUGWRITE(x) | ||
77 | #define DEBUGPOLL(x) | ||
78 | #define DEBUGRXINT(x) | ||
79 | #define DEBUGTXINT(x) | ||
80 | |||
81 | /* Define some macros to access ETRAX 100 registers */ | ||
82 | #define SETF(var, reg, field, val) \ | ||
83 | do { \ | ||
84 | var = (var & ~IO_MASK_(reg##_, field##_)) | \ | ||
85 | IO_FIELD_(reg##_, field##_, val); \ | ||
86 | } while (0) | ||
87 | |||
88 | #define SETS(var, reg, field, val) \ | ||
89 | do { \ | ||
90 | var = (var & ~IO_MASK_(reg##_, field##_)) | \ | ||
91 | IO_STATE_(reg##_, field##_, _##val); \ | ||
92 | } while (0) | ||
93 | |||
94 | struct sync_port { | ||
95 | /* Etrax registers and bits*/ | ||
96 | const volatile unsigned *const status; | ||
97 | volatile unsigned *const ctrl_data; | ||
98 | volatile unsigned *const output_dma_first; | ||
99 | volatile unsigned char *const output_dma_cmd; | ||
100 | volatile unsigned char *const output_dma_clr_irq; | ||
101 | volatile unsigned *const input_dma_first; | ||
102 | volatile unsigned char *const input_dma_cmd; | ||
103 | volatile unsigned *const input_dma_descr; | ||
104 | /* 8*4 */ | ||
105 | volatile unsigned char *const input_dma_clr_irq; | ||
106 | volatile unsigned *const data_out; | ||
107 | const volatile unsigned *const data_in; | ||
108 | char data_avail_bit; /* In R_IRQ_MASK1_RD/SET/CLR */ | ||
109 | char transmitter_ready_bit; /* In R_IRQ_MASK1_RD/SET/CLR */ | ||
110 | char input_dma_descr_bit; /* In R_IRQ_MASK2_RD */ | ||
111 | |||
112 | char output_dma_bit; /* In R_IRQ_MASK2_RD */ | ||
113 | /* End of fields initialised in array */ | ||
114 | char started; /* 1 if port has been started */ | ||
115 | char port_nbr; /* Port 0 or 1 */ | ||
116 | char busy; /* 1 if port is busy */ | ||
117 | |||
118 | char enabled; /* 1 if port is enabled */ | ||
119 | char use_dma; /* 1 if port uses dma */ | ||
120 | char tr_running; | ||
121 | |||
122 | char init_irqs; | ||
123 | |||
124 | /* Register shadow */ | ||
125 | unsigned int ctrl_data_shadow; | ||
126 | /* Remaining bytes for current transfer */ | ||
127 | volatile unsigned int out_count; | ||
128 | /* Current position in out_buffer */ | ||
129 | unsigned char *outp; | ||
130 | /* 16*4 */ | ||
131 | /* Next byte to be read by application */ | ||
132 | volatile unsigned char *volatile readp; | ||
133 | /* Next byte to be written by etrax */ | ||
134 | volatile unsigned char *volatile writep; | ||
135 | |||
136 | unsigned int in_buffer_size; | ||
137 | unsigned int inbufchunk; | ||
138 | struct etrax_dma_descr out_descr __attribute__ ((aligned(32))); | ||
139 | struct etrax_dma_descr in_descr[NUM_IN_DESCR] __attribute__ ((aligned(32))); | ||
140 | unsigned char out_buffer[OUT_BUFFER_SIZE] __attribute__ ((aligned(32))); | ||
141 | unsigned char in_buffer[IN_BUFFER_SIZE]__attribute__ ((aligned(32))); | ||
142 | unsigned char flip[IN_BUFFER_SIZE] __attribute__ ((aligned(32))); | ||
143 | struct etrax_dma_descr *next_rx_desc; | ||
144 | struct etrax_dma_descr *prev_rx_desc; | ||
145 | int full; | ||
146 | |||
147 | wait_queue_head_t out_wait_q; | ||
148 | wait_queue_head_t in_wait_q; | ||
149 | }; | ||
150 | |||
151 | |||
152 | static int etrax_sync_serial_init(void); | ||
153 | static void initialize_port(int portnbr); | ||
154 | static inline int sync_data_avail(struct sync_port *port); | ||
155 | |||
156 | static int sync_serial_open(struct inode *inode, struct file *file); | ||
157 | static int sync_serial_release(struct inode *inode, struct file *file); | ||
158 | static unsigned int sync_serial_poll(struct file *filp, poll_table *wait); | ||
159 | |||
160 | static int sync_serial_ioctl(struct inode *inode, struct file *file, | ||
161 | unsigned int cmd, unsigned long arg); | ||
162 | static ssize_t sync_serial_write(struct file *file, const char *buf, | ||
163 | size_t count, loff_t *ppos); | ||
164 | static ssize_t sync_serial_read(struct file *file, char *buf, | ||
165 | size_t count, loff_t *ppos); | ||
166 | |||
167 | #if ((defined(CONFIG_ETRAX_SYNCHRONOUS_SERIAL_PORT0) && \ | ||
168 | defined(CONFIG_ETRAX_SYNCHRONOUS_SERIAL0_DMA)) || \ | ||
169 | (defined(CONFIG_ETRAX_SYNCHRONOUS_SERIAL_PORT1) && \ | ||
170 | defined(CONFIG_ETRAX_SYNCHRONOUS_SERIAL1_DMA))) | ||
171 | #define SYNC_SER_DMA | ||
172 | #endif | ||
173 | |||
174 | static void send_word(struct sync_port *port); | ||
175 | static void start_dma(struct sync_port *port, const char *data, int count); | ||
176 | static void start_dma_in(struct sync_port *port); | ||
177 | #ifdef SYNC_SER_DMA | ||
178 | static irqreturn_t tr_interrupt(int irq, void *dev_id); | ||
179 | static irqreturn_t rx_interrupt(int irq, void *dev_id); | ||
180 | #endif | ||
181 | #if ((defined(CONFIG_ETRAX_SYNCHRONOUS_SERIAL_PORT0) && \ | ||
182 | !defined(CONFIG_ETRAX_SYNCHRONOUS_SERIAL0_DMA)) || \ | ||
183 | (defined(CONFIG_ETRAX_SYNCHRONOUS_SERIAL_PORT1) && \ | ||
184 | !defined(CONFIG_ETRAX_SYNCHRONOUS_SERIAL1_DMA))) | ||
185 | #define SYNC_SER_MANUAL | ||
186 | #endif | ||
187 | #ifdef SYNC_SER_MANUAL | ||
188 | static irqreturn_t manual_interrupt(int irq, void *dev_id); | ||
189 | #endif | ||
190 | |||
191 | /* The ports */ | ||
192 | static struct sync_port ports[] = { | ||
193 | { | ||
194 | .status = R_SYNC_SERIAL1_STATUS, | ||
195 | .ctrl_data = R_SYNC_SERIAL1_CTRL, | ||
196 | .output_dma_first = R_DMA_CH8_FIRST, | ||
197 | .output_dma_cmd = R_DMA_CH8_CMD, | ||
198 | .output_dma_clr_irq = R_DMA_CH8_CLR_INTR, | ||
199 | .input_dma_first = R_DMA_CH9_FIRST, | ||
200 | .input_dma_cmd = R_DMA_CH9_CMD, | ||
201 | .input_dma_descr = R_DMA_CH9_DESCR, | ||
202 | .input_dma_clr_irq = R_DMA_CH9_CLR_INTR, | ||
203 | .data_out = R_SYNC_SERIAL1_TR_DATA, | ||
204 | .data_in = R_SYNC_SERIAL1_REC_DATA, | ||
205 | .data_avail_bit = IO_BITNR(R_IRQ_MASK1_RD, ser1_data), | ||
206 | .transmitter_ready_bit = IO_BITNR(R_IRQ_MASK1_RD, ser1_ready), | ||
207 | .input_dma_descr_bit = IO_BITNR(R_IRQ_MASK2_RD, dma9_descr), | ||
208 | .output_dma_bit = IO_BITNR(R_IRQ_MASK2_RD, dma8_eop), | ||
209 | .init_irqs = 1, | ||
210 | #if defined(CONFIG_ETRAX_SYNCHRONOUS_SERIAL0_DMA) | ||
211 | .use_dma = 1, | ||
212 | #else | ||
213 | .use_dma = 0, | ||
214 | #endif | ||
215 | }, | ||
216 | { | ||
217 | .status = R_SYNC_SERIAL3_STATUS, | ||
218 | .ctrl_data = R_SYNC_SERIAL3_CTRL, | ||
219 | .output_dma_first = R_DMA_CH4_FIRST, | ||
220 | .output_dma_cmd = R_DMA_CH4_CMD, | ||
221 | .output_dma_clr_irq = R_DMA_CH4_CLR_INTR, | ||
222 | .input_dma_first = R_DMA_CH5_FIRST, | ||
223 | .input_dma_cmd = R_DMA_CH5_CMD, | ||
224 | .input_dma_descr = R_DMA_CH5_DESCR, | ||
225 | .input_dma_clr_irq = R_DMA_CH5_CLR_INTR, | ||
226 | .data_out = R_SYNC_SERIAL3_TR_DATA, | ||
227 | .data_in = R_SYNC_SERIAL3_REC_DATA, | ||
228 | .data_avail_bit = IO_BITNR(R_IRQ_MASK1_RD, ser3_data), | ||
229 | .transmitter_ready_bit = IO_BITNR(R_IRQ_MASK1_RD, ser3_ready), | ||
230 | .input_dma_descr_bit = IO_BITNR(R_IRQ_MASK2_RD, dma5_descr), | ||
231 | .output_dma_bit = IO_BITNR(R_IRQ_MASK2_RD, dma4_eop), | ||
232 | .init_irqs = 1, | ||
233 | #if defined(CONFIG_ETRAX_SYNCHRONOUS_SERIAL1_DMA) | ||
234 | .use_dma = 1, | ||
235 | #else | ||
236 | .use_dma = 0, | ||
237 | #endif | ||
238 | } | ||
239 | }; | ||
240 | |||
241 | /* Register shadows */ | ||
242 | static unsigned sync_serial_prescale_shadow; | ||
243 | |||
244 | #define NUMBER_OF_PORTS 2 | ||
245 | |||
246 | static struct file_operations sync_serial_fops = { | ||
247 | .owner = THIS_MODULE, | ||
248 | .write = sync_serial_write, | ||
249 | .read = sync_serial_read, | ||
250 | .poll = sync_serial_poll, | ||
251 | .ioctl = sync_serial_ioctl, | ||
252 | .open = sync_serial_open, | ||
253 | .release = sync_serial_release | ||
254 | }; | ||
255 | |||
256 | static int __init etrax_sync_serial_init(void) | ||
257 | { | ||
258 | ports[0].enabled = 0; | ||
259 | ports[1].enabled = 0; | ||
260 | |||
261 | #if defined(CONFIG_ETRAX_SYNCHRONOUS_SERIAL_PORT0) | ||
262 | if (cris_request_io_interface(if_sync_serial_1, "sync_ser1")) { | ||
263 | printk(KERN_CRIT "ETRAX100LX sync_serial: " | ||
264 | "Could not allocate IO group for port %d\n", 0); | ||
265 | return -EBUSY; | ||
266 | } | ||
267 | #endif | ||
268 | #if defined(CONFIG_ETRAX_SYNCHRONOUS_SERIAL_PORT1) | ||
269 | if (cris_request_io_interface(if_sync_serial_3, "sync_ser3")) { | ||
270 | #if defined(CONFIG_ETRAX_SYNCHRONOUS_SERIAL_PORT0) | ||
271 | cris_free_io_interface(if_sync_serial_1); | ||
272 | #endif | ||
273 | printk(KERN_CRIT "ETRAX100LX sync_serial: " | ||
274 | "Could not allocate IO group for port %d\n", 1); | ||
275 | return -EBUSY; | ||
276 | } | ||
277 | #endif | ||
278 | |||
279 | if (register_chrdev(SYNC_SERIAL_MAJOR, "sync serial", | ||
280 | &sync_serial_fops) < 0) { | ||
281 | #if defined(CONFIG_ETRAX_SYNCHRONOUS_SERIAL_PORT1) | ||
282 | cris_free_io_interface(if_sync_serial_3); | ||
283 | #endif | ||
284 | #if defined(CONFIG_ETRAX_SYNCHRONOUS_SERIAL_PORT0) | ||
285 | cris_free_io_interface(if_sync_serial_1); | ||
286 | #endif | ||
287 | printk("unable to get major for synchronous serial port\n"); | ||
288 | return -EBUSY; | ||
289 | } | ||
290 | |||
291 | /* Deselect synchronous serial ports while configuring. */ | ||
292 | SETS(gen_config_ii_shadow, R_GEN_CONFIG_II, sermode1, async); | ||
293 | SETS(gen_config_ii_shadow, R_GEN_CONFIG_II, sermode3, async); | ||
294 | *R_GEN_CONFIG_II = gen_config_ii_shadow; | ||
295 | |||
296 | /* Initialize Ports */ | ||
297 | #if defined(CONFIG_ETRAX_SYNCHRONOUS_SERIAL_PORT0) | ||
298 | ports[0].enabled = 1; | ||
299 | SETS(port_pb_i2c_shadow, R_PORT_PB_I2C, syncser1, ss1extra); | ||
300 | SETS(gen_config_ii_shadow, R_GEN_CONFIG_II, sermode1, sync); | ||
301 | #if defined(CONFIG_ETRAX_SYNCHRONOUS_SERIAL0_DMA) | ||
302 | ports[0].use_dma = 1; | ||
303 | #else | ||
304 | ports[0].use_dma = 0; | ||
305 | #endif | ||
306 | initialize_port(0); | ||
307 | #endif | ||
308 | |||
309 | #if defined(CONFIG_ETRAX_SYNCHRONOUS_SERIAL_PORT1) | ||
310 | ports[1].enabled = 1; | ||
311 | SETS(port_pb_i2c_shadow, R_PORT_PB_I2C, syncser3, ss3extra); | ||
312 | SETS(gen_config_ii_shadow, R_GEN_CONFIG_II, sermode3, sync); | ||
313 | #if defined(CONFIG_ETRAX_SYNCHRONOUS_SERIAL1_DMA) | ||
314 | ports[1].use_dma = 1; | ||
315 | #else | ||
316 | ports[1].use_dma = 0; | ||
317 | #endif | ||
318 | initialize_port(1); | ||
319 | #endif | ||
320 | |||
321 | *R_PORT_PB_I2C = port_pb_i2c_shadow; /* Use PB4/PB7 */ | ||
322 | |||
323 | /* Set up timing */ | ||
324 | *R_SYNC_SERIAL_PRESCALE = sync_serial_prescale_shadow = ( | ||
325 | IO_STATE(R_SYNC_SERIAL_PRESCALE, clk_sel_u1, codec) | | ||
326 | IO_STATE(R_SYNC_SERIAL_PRESCALE, word_stb_sel_u1, external) | | ||
327 | IO_STATE(R_SYNC_SERIAL_PRESCALE, clk_sel_u3, codec) | | ||
328 | IO_STATE(R_SYNC_SERIAL_PRESCALE, word_stb_sel_u3, external) | | ||
329 | IO_STATE(R_SYNC_SERIAL_PRESCALE, prescaler, div4) | | ||
330 | IO_FIELD(R_SYNC_SERIAL_PRESCALE, frame_rate, | ||
331 | DEFAULT_FRAME_RATE) | | ||
332 | IO_FIELD(R_SYNC_SERIAL_PRESCALE, word_rate, DEFAULT_WORD_RATE) | | ||
333 | IO_STATE(R_SYNC_SERIAL_PRESCALE, warp_mode, normal)); | ||
334 | |||
335 | /* Select synchronous ports */ | ||
336 | *R_GEN_CONFIG_II = gen_config_ii_shadow; | ||
337 | |||
338 | printk(KERN_INFO "ETRAX 100LX synchronous serial port driver\n"); | ||
339 | return 0; | ||
340 | } | ||
341 | |||
342 | static void __init initialize_port(int portnbr) | ||
343 | { | ||
344 | struct sync_port *port = &ports[portnbr]; | ||
345 | |||
346 | DEBUG(printk(KERN_DEBUG "Init sync serial port %d\n", portnbr)); | ||
347 | |||
348 | port->started = 0; | ||
349 | port->port_nbr = portnbr; | ||
350 | port->busy = 0; | ||
351 | port->tr_running = 0; | ||
352 | |||
353 | port->out_count = 0; | ||
354 | port->outp = port->out_buffer; | ||
355 | |||
356 | port->readp = port->flip; | ||
357 | port->writep = port->flip; | ||
358 | port->in_buffer_size = IN_BUFFER_SIZE; | ||
359 | port->inbufchunk = IN_DESCR_SIZE; | ||
360 | port->next_rx_desc = &port->in_descr[0]; | ||
361 | port->prev_rx_desc = &port->in_descr[NUM_IN_DESCR-1]; | ||
362 | port->prev_rx_desc->ctrl = d_eol; | ||
363 | |||
364 | init_waitqueue_head(&port->out_wait_q); | ||
365 | init_waitqueue_head(&port->in_wait_q); | ||
366 | |||
367 | port->ctrl_data_shadow = | ||
368 | IO_STATE(R_SYNC_SERIAL1_CTRL, tr_baud, c115k2Hz) | | ||
369 | IO_STATE(R_SYNC_SERIAL1_CTRL, mode, master_output) | | ||
370 | IO_STATE(R_SYNC_SERIAL1_CTRL, error, ignore) | | ||
371 | IO_STATE(R_SYNC_SERIAL1_CTRL, rec_enable, disable) | | ||
372 | IO_STATE(R_SYNC_SERIAL1_CTRL, f_synctype, normal) | | ||
373 | IO_STATE(R_SYNC_SERIAL1_CTRL, f_syncsize, word) | | ||
374 | IO_STATE(R_SYNC_SERIAL1_CTRL, f_sync, on) | | ||
375 | IO_STATE(R_SYNC_SERIAL1_CTRL, clk_mode, normal) | | ||
376 | IO_STATE(R_SYNC_SERIAL1_CTRL, clk_halt, stopped) | | ||
377 | IO_STATE(R_SYNC_SERIAL1_CTRL, bitorder, msb) | | ||
378 | IO_STATE(R_SYNC_SERIAL1_CTRL, tr_enable, disable) | | ||
379 | IO_STATE(R_SYNC_SERIAL1_CTRL, wordsize, size8bit) | | ||
380 | IO_STATE(R_SYNC_SERIAL1_CTRL, buf_empty, lmt_8) | | ||
381 | IO_STATE(R_SYNC_SERIAL1_CTRL, buf_full, lmt_8) | | ||
382 | IO_STATE(R_SYNC_SERIAL1_CTRL, flow_ctrl, enabled) | | ||
383 | IO_STATE(R_SYNC_SERIAL1_CTRL, clk_polarity, neg) | | ||
384 | IO_STATE(R_SYNC_SERIAL1_CTRL, frame_polarity, normal)| | ||
385 | IO_STATE(R_SYNC_SERIAL1_CTRL, status_polarity, inverted)| | ||
386 | IO_STATE(R_SYNC_SERIAL1_CTRL, clk_driver, normal) | | ||
387 | IO_STATE(R_SYNC_SERIAL1_CTRL, frame_driver, normal) | | ||
388 | IO_STATE(R_SYNC_SERIAL1_CTRL, status_driver, normal)| | ||
389 | IO_STATE(R_SYNC_SERIAL1_CTRL, def_out0, high); | ||
390 | |||
391 | if (port->use_dma) | ||
392 | port->ctrl_data_shadow |= IO_STATE(R_SYNC_SERIAL1_CTRL, | ||
393 | dma_enable, on); | ||
394 | else | ||
395 | port->ctrl_data_shadow |= IO_STATE(R_SYNC_SERIAL1_CTRL, | ||
396 | dma_enable, off); | ||
397 | |||
398 | *port->ctrl_data = port->ctrl_data_shadow; | ||
399 | } | ||
400 | |||
401 | static inline int sync_data_avail(struct sync_port *port) | ||
402 | { | ||
403 | int avail; | ||
404 | unsigned char *start; | ||
405 | unsigned char *end; | ||
406 | |||
407 | start = (unsigned char *)port->readp; /* cast away volatile */ | ||
408 | end = (unsigned char *)port->writep; /* cast away volatile */ | ||
409 | /* 0123456789 0123456789 | ||
410 | * ----- - ----- | ||
411 | * ^rp ^wp ^wp ^rp | ||
412 | */ | ||
413 | if (end >= start) | ||
414 | avail = end - start; | ||
415 | else | ||
416 | avail = port->in_buffer_size - (start - end); | ||
417 | return avail; | ||
418 | } | ||
419 | |||
420 | static inline int sync_data_avail_to_end(struct sync_port *port) | ||
421 | { | ||
422 | int avail; | ||
423 | unsigned char *start; | ||
424 | unsigned char *end; | ||
425 | |||
426 | start = (unsigned char *)port->readp; /* cast away volatile */ | ||
427 | end = (unsigned char *)port->writep; /* cast away volatile */ | ||
428 | /* 0123456789 0123456789 | ||
429 | * ----- ----- | ||
430 | * ^rp ^wp ^wp ^rp | ||
431 | */ | ||
432 | |||
433 | if (end >= start) | ||
434 | avail = end - start; | ||
435 | else | ||
436 | avail = port->flip + port->in_buffer_size - start; | ||
437 | return avail; | ||
438 | } | ||
439 | |||
440 | |||
441 | static int sync_serial_open(struct inode *inode, struct file *file) | ||
442 | { | ||
443 | int dev = MINOR(inode->i_rdev); | ||
444 | struct sync_port *port; | ||
445 | int mode; | ||
446 | |||
447 | DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev)); | ||
448 | |||
449 | if (dev < 0 || dev >= NUMBER_OF_PORTS || !ports[dev].enabled) { | ||
450 | DEBUG(printk(KERN_DEBUG "Invalid minor %d\n", dev)); | ||
451 | return -ENODEV; | ||
452 | } | ||
453 | port = &ports[dev]; | ||
454 | /* Allow open this device twice (assuming one reader and one writer) */ | ||
455 | if (port->busy == 2) { | ||
456 | DEBUG(printk(KERN_DEBUG "Device is busy.. \n")); | ||
457 | return -EBUSY; | ||
458 | } | ||
459 | if (port->init_irqs) { | ||
460 | if (port->use_dma) { | ||
461 | if (port == &ports[0]) { | ||
462 | #ifdef SYNC_SER_DMA | ||
463 | if (request_irq(24, tr_interrupt, 0, | ||
464 | "synchronous serial 1 dma tr", | ||
465 | &ports[0])) { | ||
466 | printk(KERN_CRIT "Can't alloc " | ||
467 | "sync serial port 1 IRQ"); | ||
468 | return -EBUSY; | ||
469 | } else if (request_irq(25, rx_interrupt, 0, | ||
470 | "synchronous serial 1 dma rx", | ||
471 | &ports[0])) { | ||
472 | free_irq(24, &port[0]); | ||
473 | printk(KERN_CRIT "Can't alloc " | ||
474 | "sync serial port 1 IRQ"); | ||
475 | return -EBUSY; | ||
476 | } else if (cris_request_dma(8, | ||
477 | "synchronous serial 1 dma tr", | ||
478 | DMA_VERBOSE_ON_ERROR, | ||
479 | dma_ser1)) { | ||
480 | free_irq(24, &port[0]); | ||
481 | free_irq(25, &port[0]); | ||
482 | printk(KERN_CRIT "Can't alloc " | ||
483 | "sync serial port 1 " | ||
484 | "TX DMA channel"); | ||
485 | return -EBUSY; | ||
486 | } else if (cris_request_dma(9, | ||
487 | "synchronous serial 1 dma rec", | ||
488 | DMA_VERBOSE_ON_ERROR, | ||
489 | dma_ser1)) { | ||
490 | cris_free_dma(8, NULL); | ||
491 | free_irq(24, &port[0]); | ||
492 | free_irq(25, &port[0]); | ||
493 | printk(KERN_CRIT "Can't alloc " | ||
494 | "sync serial port 1 " | ||
495 | "RX DMA channel"); | ||
496 | return -EBUSY; | ||
497 | } | ||
498 | #endif | ||
499 | RESET_DMA(8); WAIT_DMA(8); | ||
500 | RESET_DMA(9); WAIT_DMA(9); | ||
501 | *R_DMA_CH8_CLR_INTR = | ||
502 | IO_STATE(R_DMA_CH8_CLR_INTR, clr_eop, | ||
503 | do) | | ||
504 | IO_STATE(R_DMA_CH8_CLR_INTR, clr_descr, | ||
505 | do); | ||
506 | *R_DMA_CH9_CLR_INTR = | ||
507 | IO_STATE(R_DMA_CH9_CLR_INTR, clr_eop, | ||
508 | do) | | ||
509 | IO_STATE(R_DMA_CH9_CLR_INTR, clr_descr, | ||
510 | do); | ||
511 | *R_IRQ_MASK2_SET = | ||
512 | IO_STATE(R_IRQ_MASK2_SET, dma8_eop, | ||
513 | set) | | ||
514 | IO_STATE(R_IRQ_MASK2_SET, dma9_descr, | ||
515 | set); | ||
516 | } else if (port == &ports[1]) { | ||
517 | #ifdef SYNC_SER_DMA | ||
518 | if (request_irq(20, tr_interrupt, 0, | ||
519 | "synchronous serial 3 dma tr", | ||
520 | &ports[1])) { | ||
521 | printk(KERN_CRIT "Can't alloc " | ||
522 | "sync serial port 3 IRQ"); | ||
523 | return -EBUSY; | ||
524 | } else if (request_irq(21, rx_interrupt, 0, | ||
525 | "synchronous serial 3 dma rx", | ||
526 | &ports[1])) { | ||
527 | free_irq(20, &ports[1]); | ||
528 | printk(KERN_CRIT "Can't alloc " | ||
529 | "sync serial port 3 IRQ"); | ||
530 | return -EBUSY; | ||
531 | } else if (cris_request_dma(4, | ||
532 | "synchronous serial 3 dma tr", | ||
533 | DMA_VERBOSE_ON_ERROR, | ||
534 | dma_ser3)) { | ||
535 | free_irq(21, &ports[1]); | ||
536 | free_irq(20, &ports[1]); | ||
537 | printk(KERN_CRIT "Can't alloc " | ||
538 | "sync serial port 3 " | ||
539 | "TX DMA channel"); | ||
540 | return -EBUSY; | ||
541 | } else if (cris_request_dma(5, | ||
542 | "synchronous serial 3 dma rec", | ||
543 | DMA_VERBOSE_ON_ERROR, | ||
544 | dma_ser3)) { | ||
545 | cris_free_dma(4, NULL); | ||
546 | free_irq(21, &ports[1]); | ||
547 | free_irq(20, &ports[1]); | ||
548 | printk(KERN_CRIT "Can't alloc " | ||
549 | "sync serial port 3 " | ||
550 | "RX DMA channel"); | ||
551 | return -EBUSY; | ||
552 | } | ||
553 | #endif | ||
554 | RESET_DMA(4); WAIT_DMA(4); | ||
555 | RESET_DMA(5); WAIT_DMA(5); | ||
556 | *R_DMA_CH4_CLR_INTR = | ||
557 | IO_STATE(R_DMA_CH4_CLR_INTR, clr_eop, | ||
558 | do) | | ||
559 | IO_STATE(R_DMA_CH4_CLR_INTR, clr_descr, | ||
560 | do); | ||
561 | *R_DMA_CH5_CLR_INTR = | ||
562 | IO_STATE(R_DMA_CH5_CLR_INTR, clr_eop, | ||
563 | do) | | ||
564 | IO_STATE(R_DMA_CH5_CLR_INTR, clr_descr, | ||
565 | do); | ||
566 | *R_IRQ_MASK2_SET = | ||
567 | IO_STATE(R_IRQ_MASK2_SET, dma4_eop, | ||
568 | set) | | ||
569 | IO_STATE(R_IRQ_MASK2_SET, dma5_descr, | ||
570 | set); | ||
571 | } | ||
572 | start_dma_in(port); | ||
573 | port->init_irqs = 0; | ||
574 | } else { /* !port->use_dma */ | ||
575 | #ifdef SYNC_SER_MANUAL | ||
576 | if (port == &ports[0]) { | ||
577 | if (request_irq(8, | ||
578 | manual_interrupt, | ||
579 | IRQF_SHARED | IRQF_DISABLED, | ||
580 | "synchronous serial manual irq", | ||
581 | &ports[0])) { | ||
582 | printk(KERN_CRIT "Can't alloc " | ||
583 | "sync serial manual irq"); | ||
584 | return -EBUSY; | ||
585 | } | ||
586 | } else if (port == &ports[1]) { | ||
587 | if (request_irq(8, | ||
588 | manual_interrupt, | ||
589 | IRQF_SHARED | IRQF_DISABLED, | ||
590 | "synchronous serial manual irq", | ||
591 | &ports[1])) { | ||
592 | printk(KERN_CRIT "Can't alloc " | ||
593 | "sync serial manual irq"); | ||
594 | return -EBUSY; | ||
595 | } | ||
596 | } | ||
597 | port->init_irqs = 0; | ||
598 | #else | ||
599 | panic("sync_serial: Manual mode not supported.\n"); | ||
600 | #endif /* SYNC_SER_MANUAL */ | ||
601 | } | ||
602 | } /* port->init_irqs */ | ||
603 | |||
604 | port->busy++; | ||
605 | /* Start port if we use it as input */ | ||
606 | mode = IO_EXTRACT(R_SYNC_SERIAL1_CTRL, mode, port->ctrl_data_shadow); | ||
607 | if (mode == IO_STATE_VALUE(R_SYNC_SERIAL1_CTRL, mode, master_input) || | ||
608 | mode == IO_STATE_VALUE(R_SYNC_SERIAL1_CTRL, mode, slave_input) || | ||
609 | mode == IO_STATE_VALUE(R_SYNC_SERIAL1_CTRL, mode, master_bidir) || | ||
610 | mode == IO_STATE_VALUE(R_SYNC_SERIAL1_CTRL, mode, slave_bidir)) { | ||
611 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, clk_halt, | ||
612 | running); | ||
613 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, tr_enable, | ||
614 | enable); | ||
615 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, rec_enable, | ||
616 | enable); | ||
617 | port->started = 1; | ||
618 | *port->ctrl_data = port->ctrl_data_shadow; | ||
619 | if (!port->use_dma) | ||
620 | *R_IRQ_MASK1_SET = 1 << port->data_avail_bit; | ||
621 | DEBUG(printk(KERN_DEBUG "sser%d rec started\n", dev)); | ||
622 | } | ||
623 | return 0; | ||
624 | } | ||
625 | |||
626 | static int sync_serial_release(struct inode *inode, struct file *file) | ||
627 | { | ||
628 | int dev = MINOR(inode->i_rdev); | ||
629 | struct sync_port *port; | ||
630 | |||
631 | if (dev < 0 || dev >= NUMBER_OF_PORTS || !ports[dev].enabled) { | ||
632 | DEBUG(printk(KERN_DEBUG "Invalid minor %d\n", dev)); | ||
633 | return -ENODEV; | ||
634 | } | ||
635 | port = &ports[dev]; | ||
636 | if (port->busy) | ||
637 | port->busy--; | ||
638 | if (!port->busy) | ||
639 | *R_IRQ_MASK1_CLR = ((1 << port->data_avail_bit) | | ||
640 | (1 << port->transmitter_ready_bit)); | ||
641 | |||
642 | return 0; | ||
643 | } | ||
644 | |||
645 | |||
646 | |||
647 | static unsigned int sync_serial_poll(struct file *file, poll_table *wait) | ||
648 | { | ||
649 | int dev = MINOR(file->f_dentry->d_inode->i_rdev); | ||
650 | unsigned int mask = 0; | ||
651 | struct sync_port *port; | ||
652 | DEBUGPOLL(static unsigned int prev_mask = 0); | ||
653 | |||
654 | port = &ports[dev]; | ||
655 | poll_wait(file, &port->out_wait_q, wait); | ||
656 | poll_wait(file, &port->in_wait_q, wait); | ||
657 | /* Some room to write */ | ||
658 | if (port->out_count < OUT_BUFFER_SIZE) | ||
659 | mask |= POLLOUT | POLLWRNORM; | ||
660 | /* At least an inbufchunk of data */ | ||
661 | if (sync_data_avail(port) >= port->inbufchunk) | ||
662 | mask |= POLLIN | POLLRDNORM; | ||
663 | |||
664 | DEBUGPOLL(if (mask != prev_mask) | ||
665 | printk(KERN_DEBUG "sync_serial_poll: mask 0x%08X %s %s\n", | ||
666 | mask, | ||
667 | mask & POLLOUT ? "POLLOUT" : "", | ||
668 | mask & POLLIN ? "POLLIN" : ""); | ||
669 | prev_mask = mask; | ||
670 | ); | ||
671 | return mask; | ||
672 | } | ||
673 | |||
674 | static int sync_serial_ioctl(struct inode *inode, struct file *file, | ||
675 | unsigned int cmd, unsigned long arg) | ||
676 | { | ||
677 | int return_val = 0; | ||
678 | unsigned long flags; | ||
679 | |||
680 | int dev = MINOR(file->f_dentry->d_inode->i_rdev); | ||
681 | struct sync_port *port; | ||
682 | |||
683 | if (dev < 0 || dev >= NUMBER_OF_PORTS || !ports[dev].enabled) { | ||
684 | DEBUG(printk(KERN_DEBUG "Invalid minor %d\n", dev)); | ||
685 | return -1; | ||
686 | } | ||
687 | port = &ports[dev]; | ||
688 | |||
689 | local_irq_save(flags); | ||
690 | /* Disable port while changing config */ | ||
691 | if (dev) { | ||
692 | if (port->use_dma) { | ||
693 | RESET_DMA(4); WAIT_DMA(4); | ||
694 | port->tr_running = 0; | ||
695 | port->out_count = 0; | ||
696 | port->outp = port->out_buffer; | ||
697 | *R_DMA_CH4_CLR_INTR = | ||
698 | IO_STATE(R_DMA_CH4_CLR_INTR, clr_eop, do) | | ||
699 | IO_STATE(R_DMA_CH4_CLR_INTR, clr_descr, do); | ||
700 | } | ||
701 | SETS(gen_config_ii_shadow, R_GEN_CONFIG_II, sermode3, async); | ||
702 | } else { | ||
703 | if (port->use_dma) { | ||
704 | RESET_DMA(8); WAIT_DMA(8); | ||
705 | port->tr_running = 0; | ||
706 | port->out_count = 0; | ||
707 | port->outp = port->out_buffer; | ||
708 | *R_DMA_CH8_CLR_INTR = | ||
709 | IO_STATE(R_DMA_CH8_CLR_INTR, clr_eop, do) | | ||
710 | IO_STATE(R_DMA_CH8_CLR_INTR, clr_descr, do); | ||
711 | } | ||
712 | SETS(gen_config_ii_shadow, R_GEN_CONFIG_II, sermode1, async); | ||
713 | } | ||
714 | *R_GEN_CONFIG_II = gen_config_ii_shadow; | ||
715 | local_irq_restore(flags); | ||
716 | |||
717 | switch (cmd) { | ||
718 | case SSP_SPEED: | ||
719 | if (GET_SPEED(arg) == CODEC) { | ||
720 | if (dev) | ||
721 | SETS(sync_serial_prescale_shadow, | ||
722 | R_SYNC_SERIAL_PRESCALE, clk_sel_u3, | ||
723 | codec); | ||
724 | else | ||
725 | SETS(sync_serial_prescale_shadow, | ||
726 | R_SYNC_SERIAL_PRESCALE, clk_sel_u1, | ||
727 | codec); | ||
728 | |||
729 | SETF(sync_serial_prescale_shadow, | ||
730 | R_SYNC_SERIAL_PRESCALE, prescaler, | ||
731 | GET_FREQ(arg)); | ||
732 | SETF(sync_serial_prescale_shadow, | ||
733 | R_SYNC_SERIAL_PRESCALE, frame_rate, | ||
734 | GET_FRAME_RATE(arg)); | ||
735 | SETF(sync_serial_prescale_shadow, | ||
736 | R_SYNC_SERIAL_PRESCALE, word_rate, | ||
737 | GET_WORD_RATE(arg)); | ||
738 | } else { | ||
739 | SETF(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
740 | tr_baud, GET_SPEED(arg)); | ||
741 | if (dev) | ||
742 | SETS(sync_serial_prescale_shadow, | ||
743 | R_SYNC_SERIAL_PRESCALE, clk_sel_u3, | ||
744 | baudrate); | ||
745 | else | ||
746 | SETS(sync_serial_prescale_shadow, | ||
747 | R_SYNC_SERIAL_PRESCALE, clk_sel_u1, | ||
748 | baudrate); | ||
749 | } | ||
750 | break; | ||
751 | case SSP_MODE: | ||
752 | if (arg > 5) | ||
753 | return -EINVAL; | ||
754 | if (arg == MASTER_OUTPUT || arg == SLAVE_OUTPUT) | ||
755 | *R_IRQ_MASK1_CLR = 1 << port->data_avail_bit; | ||
756 | else if (!port->use_dma) | ||
757 | *R_IRQ_MASK1_SET = 1 << port->data_avail_bit; | ||
758 | SETF(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, mode, arg); | ||
759 | break; | ||
760 | case SSP_FRAME_SYNC: | ||
761 | if (arg & NORMAL_SYNC) | ||
762 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
763 | f_synctype, normal); | ||
764 | else if (arg & EARLY_SYNC) | ||
765 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
766 | f_synctype, early); | ||
767 | |||
768 | if (arg & BIT_SYNC) | ||
769 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
770 | f_syncsize, bit); | ||
771 | else if (arg & WORD_SYNC) | ||
772 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
773 | f_syncsize, word); | ||
774 | else if (arg & EXTENDED_SYNC) | ||
775 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
776 | f_syncsize, extended); | ||
777 | |||
778 | if (arg & SYNC_ON) | ||
779 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
780 | f_sync, on); | ||
781 | else if (arg & SYNC_OFF) | ||
782 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
783 | f_sync, off); | ||
784 | |||
785 | if (arg & WORD_SIZE_8) | ||
786 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
787 | wordsize, size8bit); | ||
788 | else if (arg & WORD_SIZE_12) | ||
789 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
790 | wordsize, size12bit); | ||
791 | else if (arg & WORD_SIZE_16) | ||
792 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
793 | wordsize, size16bit); | ||
794 | else if (arg & WORD_SIZE_24) | ||
795 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
796 | wordsize, size24bit); | ||
797 | else if (arg & WORD_SIZE_32) | ||
798 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
799 | wordsize, size32bit); | ||
800 | |||
801 | if (arg & BIT_ORDER_MSB) | ||
802 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
803 | bitorder, msb); | ||
804 | else if (arg & BIT_ORDER_LSB) | ||
805 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
806 | bitorder, lsb); | ||
807 | |||
808 | if (arg & FLOW_CONTROL_ENABLE) | ||
809 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
810 | flow_ctrl, enabled); | ||
811 | else if (arg & FLOW_CONTROL_DISABLE) | ||
812 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
813 | flow_ctrl, disabled); | ||
814 | |||
815 | if (arg & CLOCK_NOT_GATED) | ||
816 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
817 | clk_mode, normal); | ||
818 | else if (arg & CLOCK_GATED) | ||
819 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
820 | clk_mode, gated); | ||
821 | |||
822 | break; | ||
823 | case SSP_IPOLARITY: | ||
824 | /* NOTE!! negedge is considered NORMAL */ | ||
825 | if (arg & CLOCK_NORMAL) | ||
826 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
827 | clk_polarity, neg); | ||
828 | else if (arg & CLOCK_INVERT) | ||
829 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
830 | clk_polarity, pos); | ||
831 | |||
832 | if (arg & FRAME_NORMAL) | ||
833 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
834 | frame_polarity, normal); | ||
835 | else if (arg & FRAME_INVERT) | ||
836 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
837 | frame_polarity, inverted); | ||
838 | |||
839 | if (arg & STATUS_NORMAL) | ||
840 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
841 | status_polarity, normal); | ||
842 | else if (arg & STATUS_INVERT) | ||
843 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
844 | status_polarity, inverted); | ||
845 | break; | ||
846 | case SSP_OPOLARITY: | ||
847 | if (arg & CLOCK_NORMAL) | ||
848 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
849 | clk_driver, normal); | ||
850 | else if (arg & CLOCK_INVERT) | ||
851 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
852 | clk_driver, inverted); | ||
853 | |||
854 | if (arg & FRAME_NORMAL) | ||
855 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
856 | frame_driver, normal); | ||
857 | else if (arg & FRAME_INVERT) | ||
858 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
859 | frame_driver, inverted); | ||
860 | |||
861 | if (arg & STATUS_NORMAL) | ||
862 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
863 | status_driver, normal); | ||
864 | else if (arg & STATUS_INVERT) | ||
865 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
866 | status_driver, inverted); | ||
867 | break; | ||
868 | case SSP_SPI: | ||
869 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, flow_ctrl, | ||
870 | disabled); | ||
871 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, bitorder, | ||
872 | msb); | ||
873 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, wordsize, | ||
874 | size8bit); | ||
875 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, f_sync, on); | ||
876 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, f_syncsize, | ||
877 | word); | ||
878 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, f_synctype, | ||
879 | normal); | ||
880 | if (arg & SPI_SLAVE) { | ||
881 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
882 | frame_polarity, inverted); | ||
883 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
884 | clk_polarity, neg); | ||
885 | SETF(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
886 | mode, SLAVE_INPUT); | ||
887 | } else { | ||
888 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
889 | frame_driver, inverted); | ||
890 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
891 | clk_driver, inverted); | ||
892 | SETF(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, | ||
893 | mode, MASTER_OUTPUT); | ||
894 | } | ||
895 | break; | ||
896 | case SSP_INBUFCHUNK: | ||
897 | #if 0 | ||
898 | if (arg > port->in_buffer_size/NUM_IN_DESCR) | ||
899 | return -EINVAL; | ||
900 | port->inbufchunk = arg; | ||
901 | /* Make sure in_buffer_size is a multiple of inbufchunk */ | ||
902 | port->in_buffer_size = | ||
903 | (port->in_buffer_size/port->inbufchunk) * | ||
904 | port->inbufchunk; | ||
905 | DEBUG(printk(KERN_DEBUG "inbufchunk %i in_buffer_size: %i\n", | ||
906 | port->inbufchunk, port->in_buffer_size)); | ||
907 | if (port->use_dma) { | ||
908 | if (port->port_nbr == 0) { | ||
909 | RESET_DMA(9); | ||
910 | WAIT_DMA(9); | ||
911 | } else { | ||
912 | RESET_DMA(5); | ||
913 | WAIT_DMA(5); | ||
914 | } | ||
915 | start_dma_in(port); | ||
916 | } | ||
917 | #endif | ||
918 | break; | ||
919 | default: | ||
920 | return_val = -1; | ||
921 | } | ||
922 | /* Make sure we write the config without interruption */ | ||
923 | local_irq_save(flags); | ||
924 | /* Set config and enable port */ | ||
925 | *port->ctrl_data = port->ctrl_data_shadow; | ||
926 | nop(); nop(); nop(); nop(); | ||
927 | *R_SYNC_SERIAL_PRESCALE = sync_serial_prescale_shadow; | ||
928 | nop(); nop(); nop(); nop(); | ||
929 | if (dev) | ||
930 | SETS(gen_config_ii_shadow, R_GEN_CONFIG_II, sermode3, sync); | ||
931 | else | ||
932 | SETS(gen_config_ii_shadow, R_GEN_CONFIG_II, sermode1, sync); | ||
933 | |||
934 | *R_GEN_CONFIG_II = gen_config_ii_shadow; | ||
935 | /* Reset DMA. At readout from serial port the data could be shifted | ||
936 | * one byte if not resetting DMA. | ||
937 | */ | ||
938 | if (port->use_dma) { | ||
939 | if (port->port_nbr == 0) { | ||
940 | RESET_DMA(9); | ||
941 | WAIT_DMA(9); | ||
942 | } else { | ||
943 | RESET_DMA(5); | ||
944 | WAIT_DMA(5); | ||
945 | } | ||
946 | start_dma_in(port); | ||
947 | } | ||
948 | local_irq_restore(flags); | ||
949 | return return_val; | ||
950 | } | ||
951 | |||
952 | |||
953 | static ssize_t sync_serial_write(struct file *file, const char *buf, | ||
954 | size_t count, loff_t *ppos) | ||
955 | { | ||
956 | int dev = MINOR(file->f_dentry->d_inode->i_rdev); | ||
957 | DECLARE_WAITQUEUE(wait, current); | ||
958 | struct sync_port *port; | ||
959 | unsigned long flags; | ||
960 | unsigned long c, c1; | ||
961 | unsigned long free_outp; | ||
962 | unsigned long outp; | ||
963 | unsigned long out_buffer; | ||
964 | |||
965 | if (dev < 0 || dev >= NUMBER_OF_PORTS || !ports[dev].enabled) { | ||
966 | DEBUG(printk(KERN_DEBUG "Invalid minor %d\n", dev)); | ||
967 | return -ENODEV; | ||
968 | } | ||
969 | port = &ports[dev]; | ||
970 | |||
971 | DEBUGWRITE(printk(KERN_DEBUG "W d%d c %lu (%d/%d)\n", | ||
972 | port->port_nbr, count, port->out_count, OUT_BUFFER_SIZE)); | ||
973 | /* Space to end of buffer */ | ||
974 | /* | ||
975 | * out_buffer <c1>012345<- c ->OUT_BUFFER_SIZE | ||
976 | * outp^ +out_count | ||
977 | * ^free_outp | ||
978 | * out_buffer 45<- c ->0123OUT_BUFFER_SIZE | ||
979 | * +out_count outp^ | ||
980 | * free_outp | ||
981 | * | ||
982 | */ | ||
983 | |||
984 | /* Read variables that may be updated by interrupts */ | ||
985 | local_irq_save(flags); | ||
986 | if (count > OUT_BUFFER_SIZE - port->out_count) | ||
987 | count = OUT_BUFFER_SIZE - port->out_count; | ||
988 | |||
989 | outp = (unsigned long)port->outp; | ||
990 | free_outp = outp + port->out_count; | ||
991 | local_irq_restore(flags); | ||
992 | out_buffer = (unsigned long)port->out_buffer; | ||
993 | |||
994 | /* Find out where and how much to write */ | ||
995 | if (free_outp >= out_buffer + OUT_BUFFER_SIZE) | ||
996 | free_outp -= OUT_BUFFER_SIZE; | ||
997 | if (free_outp >= outp) | ||
998 | c = out_buffer + OUT_BUFFER_SIZE - free_outp; | ||
999 | else | ||
1000 | c = outp - free_outp; | ||
1001 | if (c > count) | ||
1002 | c = count; | ||
1003 | |||
1004 | DEBUGWRITE(printk(KERN_DEBUG "w op %08lX fop %08lX c %lu\n", | ||
1005 | outp, free_outp, c)); | ||
1006 | if (copy_from_user((void *)free_outp, buf, c)) | ||
1007 | return -EFAULT; | ||
1008 | |||
1009 | if (c != count) { | ||
1010 | buf += c; | ||
1011 | c1 = count - c; | ||
1012 | DEBUGWRITE(printk(KERN_DEBUG "w2 fi %lu c %lu c1 %lu\n", | ||
1013 | free_outp-out_buffer, c, c1)); | ||
1014 | if (copy_from_user((void *)out_buffer, buf, c1)) | ||
1015 | return -EFAULT; | ||
1016 | } | ||
1017 | local_irq_save(flags); | ||
1018 | port->out_count += count; | ||
1019 | local_irq_restore(flags); | ||
1020 | |||
1021 | /* Make sure transmitter/receiver is running */ | ||
1022 | if (!port->started) { | ||
1023 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, clk_halt, | ||
1024 | running); | ||
1025 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, tr_enable, | ||
1026 | enable); | ||
1027 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, rec_enable, | ||
1028 | enable); | ||
1029 | port->started = 1; | ||
1030 | } | ||
1031 | |||
1032 | *port->ctrl_data = port->ctrl_data_shadow; | ||
1033 | |||
1034 | if (file->f_flags & O_NONBLOCK) { | ||
1035 | local_irq_save(flags); | ||
1036 | if (!port->tr_running) { | ||
1037 | if (!port->use_dma) { | ||
1038 | /* Start sender by writing data */ | ||
1039 | send_word(port); | ||
1040 | /* and enable transmitter ready IRQ */ | ||
1041 | *R_IRQ_MASK1_SET = 1 << | ||
1042 | port->transmitter_ready_bit; | ||
1043 | } else | ||
1044 | start_dma(port, | ||
1045 | (unsigned char *volatile)port->outp, c); | ||
1046 | } | ||
1047 | local_irq_restore(flags); | ||
1048 | DEBUGWRITE(printk(KERN_DEBUG "w d%d c %lu NB\n", | ||
1049 | port->port_nbr, count)); | ||
1050 | return count; | ||
1051 | } | ||
1052 | |||
1053 | /* Sleep until all sent */ | ||
1054 | add_wait_queue(&port->out_wait_q, &wait); | ||
1055 | set_current_state(TASK_INTERRUPTIBLE); | ||
1056 | local_irq_save(flags); | ||
1057 | if (!port->tr_running) { | ||
1058 | if (!port->use_dma) { | ||
1059 | /* Start sender by writing data */ | ||
1060 | send_word(port); | ||
1061 | /* and enable transmitter ready IRQ */ | ||
1062 | *R_IRQ_MASK1_SET = 1 << port->transmitter_ready_bit; | ||
1063 | } else | ||
1064 | start_dma(port, port->outp, c); | ||
1065 | } | ||
1066 | local_irq_restore(flags); | ||
1067 | schedule(); | ||
1068 | set_current_state(TASK_RUNNING); | ||
1069 | remove_wait_queue(&port->out_wait_q, &wait); | ||
1070 | if (signal_pending(current)) | ||
1071 | return -EINTR; | ||
1072 | |||
1073 | DEBUGWRITE(printk(KERN_DEBUG "w d%d c %lu\n", port->port_nbr, count)); | ||
1074 | return count; | ||
1075 | } | ||
1076 | |||
1077 | static ssize_t sync_serial_read(struct file *file, char *buf, | ||
1078 | size_t count, loff_t *ppos) | ||
1079 | { | ||
1080 | int dev = MINOR(file->f_dentry->d_inode->i_rdev); | ||
1081 | int avail; | ||
1082 | struct sync_port *port; | ||
1083 | unsigned char *start; | ||
1084 | unsigned char *end; | ||
1085 | unsigned long flags; | ||
1086 | |||
1087 | if (dev < 0 || dev >= NUMBER_OF_PORTS || !ports[dev].enabled) { | ||
1088 | DEBUG(printk(KERN_DEBUG "Invalid minor %d\n", dev)); | ||
1089 | return -ENODEV; | ||
1090 | } | ||
1091 | port = &ports[dev]; | ||
1092 | |||
1093 | DEBUGREAD(printk(KERN_DEBUG "R%d c %d ri %lu wi %lu /%lu\n", | ||
1094 | dev, count, port->readp - port->flip, | ||
1095 | port->writep - port->flip, port->in_buffer_size)); | ||
1096 | |||
1097 | if (!port->started) { | ||
1098 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, clk_halt, | ||
1099 | running); | ||
1100 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, tr_enable, | ||
1101 | enable); | ||
1102 | SETS(port->ctrl_data_shadow, R_SYNC_SERIAL1_CTRL, rec_enable, | ||
1103 | enable); | ||
1104 | port->started = 1; | ||
1105 | } | ||
1106 | *port->ctrl_data = port->ctrl_data_shadow; | ||
1107 | |||
1108 | /* Calculate number of available bytes */ | ||
1109 | /* Save pointers to avoid that they are modified by interrupt */ | ||
1110 | local_irq_save(flags); | ||
1111 | start = (unsigned char *)port->readp; /* cast away volatile */ | ||
1112 | end = (unsigned char *)port->writep; /* cast away volatile */ | ||
1113 | local_irq_restore(flags); | ||
1114 | while (start == end && !port->full) { | ||
1115 | /* No data */ | ||
1116 | if (file->f_flags & O_NONBLOCK) | ||
1117 | return -EAGAIN; | ||
1118 | |||
1119 | interruptible_sleep_on(&port->in_wait_q); | ||
1120 | if (signal_pending(current)) | ||
1121 | return -EINTR; | ||
1122 | |||
1123 | local_irq_save(flags); | ||
1124 | start = (unsigned char *)port->readp; /* cast away volatile */ | ||
1125 | end = (unsigned char *)port->writep; /* cast away volatile */ | ||
1126 | local_irq_restore(flags); | ||
1127 | } | ||
1128 | |||
1129 | /* Lazy read, never return wrapped data. */ | ||
1130 | if (port->full) | ||
1131 | avail = port->in_buffer_size; | ||
1132 | else if (end > start) | ||
1133 | avail = end - start; | ||
1134 | else | ||
1135 | avail = port->flip + port->in_buffer_size - start; | ||
1136 | |||
1137 | count = count > avail ? avail : count; | ||
1138 | if (copy_to_user(buf, start, count)) | ||
1139 | return -EFAULT; | ||
1140 | /* Disable interrupts while updating readp */ | ||
1141 | local_irq_save(flags); | ||
1142 | port->readp += count; | ||
1143 | if (port->readp >= port->flip + port->in_buffer_size) /* Wrap? */ | ||
1144 | port->readp = port->flip; | ||
1145 | port->full = 0; | ||
1146 | local_irq_restore(flags); | ||
1147 | DEBUGREAD(printk(KERN_DEBUG "r %d\n", count)); | ||
1148 | return count; | ||
1149 | } | ||
1150 | |||
1151 | static void send_word(struct sync_port *port) | ||
1152 | { | ||
1153 | switch (IO_EXTRACT(R_SYNC_SERIAL1_CTRL, wordsize, | ||
1154 | port->ctrl_data_shadow)) { | ||
1155 | case IO_STATE_VALUE(R_SYNC_SERIAL1_CTRL, wordsize, size8bit): | ||
1156 | port->out_count--; | ||
1157 | *port->data_out = *port->outp++; | ||
1158 | if (port->outp >= port->out_buffer + OUT_BUFFER_SIZE) | ||
1159 | port->outp = port->out_buffer; | ||
1160 | break; | ||
1161 | case IO_STATE_VALUE(R_SYNC_SERIAL1_CTRL, wordsize, size12bit): | ||
1162 | { | ||
1163 | int data = (*port->outp++) << 8; | ||
1164 | data |= *port->outp++; | ||
1165 | port->out_count -= 2; | ||
1166 | *port->data_out = data; | ||
1167 | if (port->outp >= port->out_buffer + OUT_BUFFER_SIZE) | ||
1168 | port->outp = port->out_buffer; | ||
1169 | break; | ||
1170 | } | ||
1171 | case IO_STATE_VALUE(R_SYNC_SERIAL1_CTRL, wordsize, size16bit): | ||
1172 | port->out_count -= 2; | ||
1173 | *port->data_out = *(unsigned short *)port->outp; | ||
1174 | port->outp += 2; | ||
1175 | if (port->outp >= port->out_buffer + OUT_BUFFER_SIZE) | ||
1176 | port->outp = port->out_buffer; | ||
1177 | break; | ||
1178 | case IO_STATE_VALUE(R_SYNC_SERIAL1_CTRL, wordsize, size24bit): | ||
1179 | port->out_count -= 3; | ||
1180 | *port->data_out = *(unsigned int *)port->outp; | ||
1181 | port->outp += 3; | ||
1182 | if (port->outp >= port->out_buffer + OUT_BUFFER_SIZE) | ||
1183 | port->outp = port->out_buffer; | ||
1184 | break; | ||
1185 | case IO_STATE_VALUE(R_SYNC_SERIAL1_CTRL, wordsize, size32bit): | ||
1186 | port->out_count -= 4; | ||
1187 | *port->data_out = *(unsigned int *)port->outp; | ||
1188 | port->outp += 4; | ||
1189 | if (port->outp >= port->out_buffer + OUT_BUFFER_SIZE) | ||
1190 | port->outp = port->out_buffer; | ||
1191 | break; | ||
1192 | } | ||
1193 | } | ||
1194 | |||
1195 | |||
1196 | static void start_dma(struct sync_port *port, const char *data, int count) | ||
1197 | { | ||
1198 | port->tr_running = 1; | ||
1199 | port->out_descr.hw_len = 0; | ||
1200 | port->out_descr.next = 0; | ||
1201 | port->out_descr.ctrl = d_eol | d_eop; /* No d_wait to avoid glitches */ | ||
1202 | port->out_descr.sw_len = count; | ||
1203 | port->out_descr.buf = virt_to_phys(data); | ||
1204 | port->out_descr.status = 0; | ||
1205 | |||
1206 | *port->output_dma_first = virt_to_phys(&port->out_descr); | ||
1207 | *port->output_dma_cmd = IO_STATE(R_DMA_CH0_CMD, cmd, start); | ||
1208 | DEBUGTXINT(printk(KERN_DEBUG "dma %08lX c %d\n", | ||
1209 | (unsigned long)data, count)); | ||
1210 | } | ||
1211 | |||
1212 | static void start_dma_in(struct sync_port *port) | ||
1213 | { | ||
1214 | int i; | ||
1215 | unsigned long buf; | ||
1216 | port->writep = port->flip; | ||
1217 | |||
1218 | if (port->writep > port->flip + port->in_buffer_size) { | ||
1219 | panic("Offset too large in sync serial driver\n"); | ||
1220 | return; | ||
1221 | } | ||
1222 | buf = virt_to_phys(port->in_buffer); | ||
1223 | for (i = 0; i < NUM_IN_DESCR; i++) { | ||
1224 | port->in_descr[i].sw_len = port->inbufchunk; | ||
1225 | port->in_descr[i].ctrl = d_int; | ||
1226 | port->in_descr[i].next = virt_to_phys(&port->in_descr[i+1]); | ||
1227 | port->in_descr[i].buf = buf; | ||
1228 | port->in_descr[i].hw_len = 0; | ||
1229 | port->in_descr[i].status = 0; | ||
1230 | port->in_descr[i].fifo_len = 0; | ||
1231 | buf += port->inbufchunk; | ||
1232 | prepare_rx_descriptor(&port->in_descr[i]); | ||
1233 | } | ||
1234 | /* Link the last descriptor to the first */ | ||
1235 | port->in_descr[i-1].next = virt_to_phys(&port->in_descr[0]); | ||
1236 | port->in_descr[i-1].ctrl |= d_eol; | ||
1237 | port->next_rx_desc = &port->in_descr[0]; | ||
1238 | port->prev_rx_desc = &port->in_descr[NUM_IN_DESCR - 1]; | ||
1239 | *port->input_dma_first = virt_to_phys(port->next_rx_desc); | ||
1240 | *port->input_dma_cmd = IO_STATE(R_DMA_CH0_CMD, cmd, start); | ||
1241 | } | ||
1242 | |||
1243 | #ifdef SYNC_SER_DMA | ||
1244 | static irqreturn_t tr_interrupt(int irq, void *dev_id) | ||
1245 | { | ||
1246 | unsigned long ireg = *R_IRQ_MASK2_RD; | ||
1247 | struct etrax_dma_descr *descr; | ||
1248 | unsigned int sentl; | ||
1249 | int handled = 0; | ||
1250 | int i; | ||
1251 | |||
1252 | for (i = 0; i < NUMBER_OF_PORTS; i++) { | ||
1253 | struct sync_port *port = &ports[i]; | ||
1254 | if (!port->enabled || !port->use_dma) | ||
1255 | continue; | ||
1256 | |||
1257 | /* IRQ active for the port? */ | ||
1258 | if (!(ireg & (1 << port->output_dma_bit))) | ||
1259 | continue; | ||
1260 | |||
1261 | handled = 1; | ||
1262 | |||
1263 | /* Clear IRQ */ | ||
1264 | *port->output_dma_clr_irq = | ||
1265 | IO_STATE(R_DMA_CH0_CLR_INTR, clr_eop, do) | | ||
1266 | IO_STATE(R_DMA_CH0_CLR_INTR, clr_descr, do); | ||
1267 | |||
1268 | descr = &port->out_descr; | ||
1269 | if (!(descr->status & d_stop)) | ||
1270 | sentl = descr->sw_len; | ||
1271 | else | ||
1272 | /* Otherwise find amount of data sent here */ | ||
1273 | sentl = descr->hw_len; | ||
1274 | |||
1275 | port->out_count -= sentl; | ||
1276 | port->outp += sentl; | ||
1277 | if (port->outp >= port->out_buffer + OUT_BUFFER_SIZE) | ||
1278 | port->outp = port->out_buffer; | ||
1279 | if (port->out_count) { | ||
1280 | int c = port->out_buffer + OUT_BUFFER_SIZE - port->outp; | ||
1281 | if (c > port->out_count) | ||
1282 | c = port->out_count; | ||
1283 | DEBUGTXINT(printk(KERN_DEBUG | ||
1284 | "tx_int DMAWRITE %i %i\n", sentl, c)); | ||
1285 | start_dma(port, port->outp, c); | ||
1286 | } else { | ||
1287 | DEBUGTXINT(printk(KERN_DEBUG | ||
1288 | "tx_int DMA stop %i\n", sentl)); | ||
1289 | port->tr_running = 0; | ||
1290 | } | ||
1291 | /* wake up the waiting process */ | ||
1292 | wake_up_interruptible(&port->out_wait_q); | ||
1293 | } | ||
1294 | return IRQ_RETVAL(handled); | ||
1295 | } /* tr_interrupt */ | ||
1296 | |||
1297 | static irqreturn_t rx_interrupt(int irq, void *dev_id) | ||
1298 | { | ||
1299 | unsigned long ireg = *R_IRQ_MASK2_RD; | ||
1300 | int i; | ||
1301 | int handled = 0; | ||
1302 | |||
1303 | for (i = 0; i < NUMBER_OF_PORTS; i++) { | ||
1304 | struct sync_port *port = &ports[i]; | ||
1305 | |||
1306 | if (!port->enabled || !port->use_dma) | ||
1307 | continue; | ||
1308 | |||
1309 | if (!(ireg & (1 << port->input_dma_descr_bit))) | ||
1310 | continue; | ||
1311 | |||
1312 | /* Descriptor interrupt */ | ||
1313 | handled = 1; | ||
1314 | while (*port->input_dma_descr != | ||
1315 | virt_to_phys(port->next_rx_desc)) { | ||
1316 | if (port->writep + port->inbufchunk > port->flip + | ||
1317 | port->in_buffer_size) { | ||
1318 | int first_size = port->flip + | ||
1319 | port->in_buffer_size - port->writep; | ||
1320 | memcpy(port->writep, | ||
1321 | phys_to_virt(port->next_rx_desc->buf), | ||
1322 | first_size); | ||
1323 | memcpy(port->flip, | ||
1324 | phys_to_virt(port->next_rx_desc->buf + | ||
1325 | first_size), | ||
1326 | port->inbufchunk - first_size); | ||
1327 | port->writep = port->flip + | ||
1328 | port->inbufchunk - first_size; | ||
1329 | } else { | ||
1330 | memcpy(port->writep, | ||
1331 | phys_to_virt(port->next_rx_desc->buf), | ||
1332 | port->inbufchunk); | ||
1333 | port->writep += port->inbufchunk; | ||
1334 | if (port->writep >= port->flip | ||
1335 | + port->in_buffer_size) | ||
1336 | port->writep = port->flip; | ||
1337 | } | ||
1338 | if (port->writep == port->readp) | ||
1339 | port->full = 1; | ||
1340 | prepare_rx_descriptor(port->next_rx_desc); | ||
1341 | port->next_rx_desc->ctrl |= d_eol; | ||
1342 | port->prev_rx_desc->ctrl &= ~d_eol; | ||
1343 | port->prev_rx_desc = phys_to_virt((unsigned) | ||
1344 | port->next_rx_desc); | ||
1345 | port->next_rx_desc = phys_to_virt((unsigned) | ||
1346 | port->next_rx_desc->next); | ||
1347 | /* Wake up the waiting process */ | ||
1348 | wake_up_interruptible(&port->in_wait_q); | ||
1349 | *port->input_dma_cmd = IO_STATE(R_DMA_CH1_CMD, | ||
1350 | cmd, restart); | ||
1351 | /* DMA has reached end of descriptor */ | ||
1352 | *port->input_dma_clr_irq = IO_STATE(R_DMA_CH0_CLR_INTR, | ||
1353 | clr_descr, do); | ||
1354 | } | ||
1355 | } | ||
1356 | return IRQ_RETVAL(handled); | ||
1357 | } /* rx_interrupt */ | ||
1358 | #endif /* SYNC_SER_DMA */ | ||
1359 | |||
1360 | #ifdef SYNC_SER_MANUAL | ||
1361 | static irqreturn_t manual_interrupt(int irq, void *dev_id) | ||
1362 | { | ||
1363 | int i; | ||
1364 | int handled = 0; | ||
1365 | |||
1366 | for (i = 0; i < NUMBER_OF_PORTS; i++) { | ||
1367 | struct sync_port *port = &ports[i]; | ||
1368 | |||
1369 | if (!port->enabled || port->use_dma) | ||
1370 | continue; | ||
1371 | |||
1372 | /* Data received? */ | ||
1373 | if (*R_IRQ_MASK1_RD & (1 << port->data_avail_bit)) { | ||
1374 | handled = 1; | ||
1375 | /* Read data */ | ||
1376 | switch (port->ctrl_data_shadow & | ||
1377 | IO_MASK(R_SYNC_SERIAL1_CTRL, wordsize)) { | ||
1378 | case IO_STATE(R_SYNC_SERIAL1_CTRL, wordsize, size8bit): | ||
1379 | *port->writep++ = | ||
1380 | *(volatile char *)port->data_in; | ||
1381 | break; | ||
1382 | case IO_STATE(R_SYNC_SERIAL1_CTRL, wordsize, size12bit): | ||
1383 | { | ||
1384 | int data = *(unsigned short *)port->data_in; | ||
1385 | *port->writep = (data & 0x0ff0) >> 4; | ||
1386 | *(port->writep + 1) = data & 0x0f; | ||
1387 | port->writep += 2; | ||
1388 | break; | ||
1389 | } | ||
1390 | case IO_STATE(R_SYNC_SERIAL1_CTRL, wordsize, size16bit): | ||
1391 | *(unsigned short *)port->writep = | ||
1392 | *(volatile unsigned short *)port->data_in; | ||
1393 | port->writep += 2; | ||
1394 | break; | ||
1395 | case IO_STATE(R_SYNC_SERIAL1_CTRL, wordsize, size24bit): | ||
1396 | *(unsigned int *)port->writep = *port->data_in; | ||
1397 | port->writep += 3; | ||
1398 | break; | ||
1399 | case IO_STATE(R_SYNC_SERIAL1_CTRL, wordsize, size32bit): | ||
1400 | *(unsigned int *)port->writep = *port->data_in; | ||
1401 | port->writep += 4; | ||
1402 | break; | ||
1403 | } | ||
1404 | |||
1405 | /* Wrap? */ | ||
1406 | if (port->writep >= port->flip + port->in_buffer_size) | ||
1407 | port->writep = port->flip; | ||
1408 | if (port->writep == port->readp) { | ||
1409 | /* Receive buffer overrun, discard oldest */ | ||
1410 | port->readp++; | ||
1411 | /* Wrap? */ | ||
1412 | if (port->readp >= port->flip + | ||
1413 | port->in_buffer_size) | ||
1414 | port->readp = port->flip; | ||
1415 | } | ||
1416 | if (sync_data_avail(port) >= port->inbufchunk) { | ||
1417 | /* Wake up application */ | ||
1418 | wake_up_interruptible(&port->in_wait_q); | ||
1419 | } | ||
1420 | } | ||
1421 | |||
1422 | /* Transmitter ready? */ | ||
1423 | if (*R_IRQ_MASK1_RD & (1 << port->transmitter_ready_bit)) { | ||
1424 | if (port->out_count > 0) { | ||
1425 | /* More data to send */ | ||
1426 | send_word(port); | ||
1427 | } else { | ||
1428 | /* Transmission finished */ | ||
1429 | /* Turn off IRQ */ | ||
1430 | *R_IRQ_MASK1_CLR = 1 << | ||
1431 | port->transmitter_ready_bit; | ||
1432 | /* Wake up application */ | ||
1433 | wake_up_interruptible(&port->out_wait_q); | ||
1434 | } | ||
1435 | } | ||
1436 | } | ||
1437 | return IRQ_RETVAL(handled); | ||
1438 | } | ||
1439 | #endif | ||
1440 | |||
1441 | module_init(etrax_sync_serial_init); | ||
diff --git a/arch/cris/arch-v10/kernel/debugport.c b/arch/cris/arch-v10/kernel/debugport.c index 93679a48c791..04d5eee2c90c 100644 --- a/arch/cris/arch-v10/kernel/debugport.c +++ b/arch/cris/arch-v10/kernel/debugport.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* Serialport functions for debugging | 1 | /* Serialport functions for debugging |
2 | * | 2 | * |
3 | * Copyright (c) 2000 Axis Communications AB | 3 | * Copyright (c) 2000-2007 Axis Communications AB |
4 | * | 4 | * |
5 | * Authors: Bjorn Wesen | 5 | * Authors: Bjorn Wesen |
6 | * | 6 | * |
@@ -11,96 +11,6 @@ | |||
11 | * enableDebugIRQ() | 11 | * enableDebugIRQ() |
12 | * init_etrax_debug() | 12 | * init_etrax_debug() |
13 | * | 13 | * |
14 | * $Log: debugport.c,v $ | ||
15 | * Revision 1.27 2005/06/10 10:34:14 starvik | ||
16 | * Real console support | ||
17 | * | ||
18 | * Revision 1.26 2005/06/07 07:06:07 starvik | ||
19 | * Added LF->CR translation to make ETRAX customers happy. | ||
20 | * | ||
21 | * Revision 1.25 2005/03/08 08:56:47 mikaelam | ||
22 | * Do only set index as port->index if port is defined, otherwise use the index from the command line | ||
23 | * | ||
24 | * Revision 1.24 2005/01/19 10:26:33 mikaelam | ||
25 | * Return the cris serial driver in console device driver callback function | ||
26 | * | ||
27 | * Revision 1.23 2005/01/14 10:12:17 starvik | ||
28 | * KGDB on separate port. | ||
29 | * Console fixes from 2.4. | ||
30 | * | ||
31 | * Revision 1.22 2005/01/11 16:06:13 starvik | ||
32 | * typo | ||
33 | * | ||
34 | * Revision 1.21 2005/01/11 13:49:14 starvik | ||
35 | * Added raw_printk to be used where we don't trust the console. | ||
36 | * | ||
37 | * Revision 1.20 2004/12/27 11:18:32 starvik | ||
38 | * Merge of Linux 2.6.10 (not functional yet). | ||
39 | * | ||
40 | * Revision 1.19 2004/10/21 07:26:16 starvik | ||
41 | * Made it possible to specify console settings on kernel command line. | ||
42 | * | ||
43 | * Revision 1.18 2004/10/19 13:07:37 starvik | ||
44 | * Merge of Linux 2.6.9 | ||
45 | * | ||
46 | * Revision 1.17 2004/09/29 10:33:46 starvik | ||
47 | * Resolved a dealock when printing debug from kernel. | ||
48 | * | ||
49 | * Revision 1.16 2004/08/24 06:12:19 starvik | ||
50 | * Whitespace cleanup | ||
51 | * | ||
52 | * Revision 1.15 2004/08/16 12:37:19 starvik | ||
53 | * Merge of Linux 2.6.8 | ||
54 | * | ||
55 | * Revision 1.14 2004/05/17 13:11:29 starvik | ||
56 | * Disable DMA until real serial driver is up | ||
57 | * | ||
58 | * Revision 1.13 2004/05/14 07:58:01 starvik | ||
59 | * Merge of changes from 2.4 | ||
60 | * | ||
61 | * Revision 1.12 2003/09/11 07:29:49 starvik | ||
62 | * Merge of Linux 2.6.0-test5 | ||
63 | * | ||
64 | * Revision 1.11 2003/07/07 09:53:36 starvik | ||
65 | * Revert all the 2.5.74 merge changes to make the console work again | ||
66 | * | ||
67 | * Revision 1.9 2003/02/17 17:07:23 starvik | ||
68 | * Solved the problem with corrupted debug output (from Linux 2.4) | ||
69 | * * Wait until DMA, FIFO and pipe is empty before and after transmissions | ||
70 | * * Buffer data until a FIFO flush can be triggered. | ||
71 | * | ||
72 | * Revision 1.8 2003/01/22 06:48:36 starvik | ||
73 | * Fixed warnings issued by GCC 3.2.1 | ||
74 | * | ||
75 | * Revision 1.7 2002/12/12 08:26:32 starvik | ||
76 | * Don't use C-comments inside CVS comments | ||
77 | * | ||
78 | * Revision 1.6 2002/12/11 15:42:02 starvik | ||
79 | * Extracted v10 (ETRAX 100LX) specific stuff from arch/cris/kernel/ | ||
80 | * | ||
81 | * Revision 1.5 2002/11/20 06:58:03 starvik | ||
82 | * Compiles with kgdb | ||
83 | * | ||
84 | * Revision 1.4 2002/11/19 14:35:24 starvik | ||
85 | * Changes from linux 2.4 | ||
86 | * Changed struct initializer syntax to the currently preferred notation | ||
87 | * | ||
88 | * Revision 1.3 2002/11/06 09:47:03 starvik | ||
89 | * Modified for new interrupt macros | ||
90 | * | ||
91 | * Revision 1.2 2002/01/21 15:21:50 bjornw | ||
92 | * Update for kdev_t changes | ||
93 | * | ||
94 | * Revision 1.6 2001/04/17 13:58:39 orjanf | ||
95 | * * Renamed CONFIG_KGDB to CONFIG_ETRAX_KGDB. | ||
96 | * | ||
97 | * Revision 1.5 2001/03/26 14:22:05 bjornw | ||
98 | * Namechange of some config options | ||
99 | * | ||
100 | * Revision 1.4 2000/10/06 12:37:26 bjornw | ||
101 | * Use physical addresses when talking to DMA | ||
102 | * | ||
103 | * | ||
104 | */ | 14 | */ |
105 | 15 | ||
106 | #include <linux/console.h> | 16 | #include <linux/console.h> |
@@ -112,6 +22,8 @@ | |||
112 | #include <asm/arch/svinto.h> | 22 | #include <asm/arch/svinto.h> |
113 | #include <asm/io.h> /* Get SIMCOUT. */ | 23 | #include <asm/io.h> /* Get SIMCOUT. */ |
114 | 24 | ||
25 | extern void reset_watchdog(void); | ||
26 | |||
115 | struct dbg_port | 27 | struct dbg_port |
116 | { | 28 | { |
117 | unsigned int index; | 29 | unsigned int index; |
@@ -188,7 +100,9 @@ struct dbg_port ports[]= | |||
188 | } | 100 | } |
189 | }; | 101 | }; |
190 | 102 | ||
103 | #ifdef CONFIG_ETRAX_SERIAL | ||
191 | extern struct tty_driver *serial_driver; | 104 | extern struct tty_driver *serial_driver; |
105 | #endif | ||
192 | 106 | ||
193 | struct dbg_port* port = | 107 | struct dbg_port* port = |
194 | #if defined(CONFIG_ETRAX_DEBUG_PORT0) | 108 | #if defined(CONFIG_ETRAX_DEBUG_PORT0) |
@@ -368,11 +282,12 @@ console_write_direct(struct console *co, const char *buf, unsigned int len) | |||
368 | { | 282 | { |
369 | int i; | 283 | int i; |
370 | unsigned long flags; | 284 | unsigned long flags; |
371 | local_irq_save(flags); | ||
372 | 285 | ||
373 | if (!port) | 286 | if (!port) |
374 | return; | 287 | return; |
375 | 288 | ||
289 | local_irq_save(flags); | ||
290 | |||
376 | /* Send data */ | 291 | /* Send data */ |
377 | for (i = 0; i < len; i++) { | 292 | for (i = 0; i < len; i++) { |
378 | /* LF -> CRLF */ | 293 | /* LF -> CRLF */ |
@@ -386,26 +301,16 @@ console_write_direct(struct console *co, const char *buf, unsigned int len) | |||
386 | ; | 301 | ; |
387 | *port->write = buf[i]; | 302 | *port->write = buf[i]; |
388 | } | 303 | } |
389 | local_irq_restore(flags); | ||
390 | } | ||
391 | 304 | ||
392 | int raw_printk(const char *fmt, ...) | 305 | /* |
393 | { | 306 | * Feed the watchdog, otherwise it will reset the chip during boot. |
394 | static char buf[1024]; | 307 | * The time to send an ordinary boot message line (10-90 chars) |
395 | int printed_len; | 308 | * varies between 1-8ms at 115200. What makes up for the additional |
396 | static int first = 1; | 309 | * 90ms that allows the watchdog to bite? |
397 | if (first) { | 310 | */ |
398 | /* Force reinitialization of the port to get manual mode. */ | 311 | reset_watchdog(); |
399 | port->started = 0; | 312 | |
400 | start_port(port); | 313 | local_irq_restore(flags); |
401 | first = 0; | ||
402 | } | ||
403 | va_list args; | ||
404 | va_start(args, fmt); | ||
405 | printed_len = vsnprintf(buf, sizeof(buf), fmt, args); | ||
406 | va_end(args); | ||
407 | console_write_direct(NULL, buf, strlen(buf)); | ||
408 | return printed_len; | ||
409 | } | 314 | } |
410 | 315 | ||
411 | static void | 316 | static void |
@@ -500,6 +405,7 @@ console_setup(struct console *co, char *options) | |||
500 | return 0; | 405 | return 0; |
501 | } | 406 | } |
502 | 407 | ||
408 | |||
503 | /* This is a dummy serial device that throws away anything written to it. | 409 | /* This is a dummy serial device that throws away anything written to it. |
504 | * This is used when no debug output is wanted. | 410 | * This is used when no debug output is wanted. |
505 | */ | 411 | */ |
@@ -555,7 +461,13 @@ etrax_console_device(struct console* co, int *index) | |||
555 | { | 461 | { |
556 | if (port) | 462 | if (port) |
557 | *index = port->index; | 463 | *index = port->index; |
464 | else | ||
465 | *index = 0; | ||
466 | #ifdef CONFIG_ETRAX_SERIAL | ||
558 | return port ? serial_driver : &dummy_driver; | 467 | return port ? serial_driver : &dummy_driver; |
468 | #else | ||
469 | return &dummy_driver; | ||
470 | #endif | ||
559 | } | 471 | } |
560 | 472 | ||
561 | static struct console sercons = { | 473 | static struct console sercons = { |
diff --git a/arch/cris/arch-v10/kernel/dma.c b/arch/cris/arch-v10/kernel/dma.c index e9a0311b141d..eb1fa0d2b49f 100644 --- a/arch/cris/arch-v10/kernel/dma.c +++ b/arch/cris/arch-v10/kernel/dma.c | |||
@@ -1,6 +1,5 @@ | |||
1 | /* Wrapper for DMA channel allocator that updates DMA client muxing. | 1 | /* Wrapper for DMA channel allocator that updates DMA client muxing. |
2 | * Copyright 2004, Axis Communications AB | 2 | * Copyright 2004-2007, Axis Communications AB |
3 | * $Id: dma.c,v 1.1 2004/12/13 12:21:51 starvik Exp $ | ||
4 | */ | 3 | */ |
5 | 4 | ||
6 | #include <linux/kernel.h> | 5 | #include <linux/kernel.h> |
diff --git a/arch/cris/arch-v10/kernel/entry.S b/arch/cris/arch-v10/kernel/entry.S index d1361dc119e2..3a65f322ae07 100644 --- a/arch/cris/arch-v10/kernel/entry.S +++ b/arch/cris/arch-v10/kernel/entry.S | |||
@@ -1,252 +1,9 @@ | |||
1 | /* $Id: entry.S,v 1.28 2005/06/20 05:06:30 starvik Exp $ | 1 | /* |
2 | * | ||
3 | * linux/arch/cris/entry.S | 2 | * linux/arch/cris/entry.S |
4 | * | 3 | * |
5 | * Copyright (C) 2000, 2001, 2002 Axis Communications AB | 4 | * Copyright (C) 2000, 2001, 2002 Axis Communications AB |
6 | * | 5 | * |
7 | * Authors: Bjorn Wesen (bjornw@axis.com) | 6 | * Authors: Bjorn Wesen (bjornw@axis.com) |
8 | * | ||
9 | * $Log: entry.S,v $ | ||
10 | * Revision 1.28 2005/06/20 05:06:30 starvik | ||
11 | * Remove unnecessary diff to kernel.org tree | ||
12 | * | ||
13 | * Revision 1.27 2005/03/04 08:16:16 starvik | ||
14 | * Merge of Linux 2.6.11. | ||
15 | * | ||
16 | * Revision 1.26 2005/01/11 13:49:47 starvik | ||
17 | * Added NMI handler. | ||
18 | * | ||
19 | * Revision 1.25 2004/12/27 11:18:32 starvik | ||
20 | * Merge of Linux 2.6.10 (not functional yet). | ||
21 | * | ||
22 | * Revision 1.24 2004/12/22 10:41:23 starvik | ||
23 | * Updates to make v10 compile with the latest SMP aware generic code (even | ||
24 | * though v10 will never have SMP). | ||
25 | * | ||
26 | * Revision 1.23 2004/10/19 13:07:37 starvik | ||
27 | * Merge of Linux 2.6.9 | ||
28 | * | ||
29 | * Revision 1.22 2004/06/21 10:29:55 starvik | ||
30 | * Merge of Linux 2.6.7 | ||
31 | * | ||
32 | * Revision 1.21 2004/06/09 05:30:27 starvik | ||
33 | * Clean up multiple interrupt handling. | ||
34 | * Prevent interrupts from interrupting each other. | ||
35 | * Handle all active interrupts. | ||
36 | * | ||
37 | * Revision 1.20 2004/06/08 08:55:32 starvik | ||
38 | * Removed unused code | ||
39 | * | ||
40 | * Revision 1.19 2004/06/04 11:56:15 starvik | ||
41 | * Implemented page table lookup for refills in assembler for improved performance. | ||
42 | * | ||
43 | * Revision 1.18 2004/05/11 12:28:25 starvik | ||
44 | * Merge of Linux 2.6.6 | ||
45 | * | ||
46 | * Revision 1.17 2003/09/11 07:29:49 starvik | ||
47 | * Merge of Linux 2.6.0-test5 | ||
48 | * | ||
49 | * Revision 1.16 2003/07/04 08:27:41 starvik | ||
50 | * Merge of Linux 2.5.74 | ||
51 | * | ||
52 | * Revision 1.15 2003/04/09 07:32:55 starvik | ||
53 | * resume should return task_struct, not thread_info | ||
54 | * | ||
55 | * Revision 1.14 2003/04/09 05:20:44 starvik | ||
56 | * Merge of Linux 2.5.67 | ||
57 | * | ||
58 | * Revision 1.13 2002/12/11 15:42:02 starvik | ||
59 | * Extracted v10 (ETRAX 100LX) specific stuff from arch/cris/kernel/*.c | ||
60 | * | ||
61 | * Revision 1.12 2002/12/10 09:00:10 starvik | ||
62 | * Merge of Linux 2.5.51 | ||
63 | * | ||
64 | * Revision 1.11 2002/12/05 07:53:10 starvik | ||
65 | * Corrected constants used with btstq | ||
66 | * | ||
67 | * Revision 1.10 2002/11/27 08:45:10 starvik | ||
68 | * pid is in task_struct, not thread_info | ||
69 | * | ||
70 | * Revision 1.9 2002/11/26 09:52:05 starvik | ||
71 | * Added preemptive kernel scheduling (if CONFIG_PREEMPT) | ||
72 | * | ||
73 | * Revision 1.8 2002/11/20 11:56:11 starvik | ||
74 | * Merge of Linux 2.5.48 | ||
75 | * | ||
76 | * Revision 1.7 2002/11/18 13:02:42 starvik | ||
77 | * Added fourth parameter to do_notify_resume | ||
78 | * Minor cleanup | ||
79 | * | ||
80 | * Revision 1.6 2002/11/11 10:37:50 starvik | ||
81 | * Use new asm-offset defines | ||
82 | * Modified for new location of current->work etc | ||
83 | * Removed SYMBOL_NAME from syscalls | ||
84 | * Added some new syscalls | ||
85 | * | ||
86 | * Revision 1.5 2002/11/05 06:45:11 starvik | ||
87 | * Merge of Linux 2.5.45 | ||
88 | * | ||
89 | * Revision 1.4 2002/02/05 15:41:31 bjornw | ||
90 | * Rewritten to conform better to current 2.5 code (similar to arch/i386) | ||
91 | * | ||
92 | * Revision 1.3 2002/01/21 15:22:20 bjornw | ||
93 | * NICE_DOGGY fix from 2.4 arch/cris | ||
94 | * | ||
95 | * Revision 1.37 2001/12/07 17:03:55 bjornw | ||
96 | * Call a c-hook called watchdog_bite_hook instead of show_registers directly | ||
97 | * | ||
98 | * Revision 1.36 2001/11/22 13:36:36 bjornw | ||
99 | * * In ret_from_intr, check regs->dccr for usermode reentrance instead of | ||
100 | * DCCR explicitly (because the latter might not reflect current reality) | ||
101 | * * In mmu_bus_fault, set $r9 _after_ calling the C-code instead of before | ||
102 | * since $r9 is call-clobbered and is potentially needed afterwards | ||
103 | * | ||
104 | * Revision 1.35 2001/10/30 17:10:15 bjornw | ||
105 | * Add some syscalls | ||
106 | * | ||
107 | * Revision 1.34 2001/10/01 14:45:03 bjornw | ||
108 | * Removed underscores and added register prefixes | ||
109 | * | ||
110 | * Revision 1.33 2001/08/21 13:48:01 jonashg | ||
111 | * Added fix by HP to avoid oops when doing a hard_reset_now. | ||
112 | * | ||
113 | * Revision 1.32 2001/08/14 04:32:02 hp | ||
114 | * In _resume, add comment why R9 is saved; don't sound like it's call-saved. | ||
115 | * | ||
116 | * Revision 1.31 2001/07/25 16:07:42 bjornw | ||
117 | * softirq_active/mask -> softirq_pending only | ||
118 | * | ||
119 | * Revision 1.30 2001/07/05 01:03:32 hp | ||
120 | * - include asm/errno.h to get ENOSYS. | ||
121 | * - Use ENOSYS, not local constant LENOSYS; tweak comments. | ||
122 | * - Explain why .include, not #include is used. | ||
123 | * - Make oops-register-dump if watchdog bits and it's not expected. | ||
124 | * - Don't jsr, use jump _hard_reset_now, and skip spurious nop. | ||
125 | * - Use correct section attribute for section .rodata. | ||
126 | * - Adjust sys_ni_syscall fill number. | ||
127 | * | ||
128 | * Revision 1.29 2001/06/25 14:07:00 hp | ||
129 | * Fix review comment. | ||
130 | * * head.S: Use IO_STATE, IO_FIELD and IO_MASK constructs instead of | ||
131 | * magic numbers. Add comment that -traditional must not be used. | ||
132 | * * entry.S (SYMBOL_NAME): Change redefinition to use ## concatenation. | ||
133 | * Correct and update comment. | ||
134 | * * Makefile (.S.o): Don't use -traditional. Add comment why the | ||
135 | * toplevel rule can't be used (now that there's a reason). | ||
136 | * | ||
137 | * Revision 1.28 2001/06/21 02:00:40 hp | ||
138 | * * entry.S: Include asm/unistd.h. | ||
139 | * (_sys_call_table): Use section .rodata, not .data. | ||
140 | * (_kernel_thread): Move from... | ||
141 | * * process.c: ... here. | ||
142 | * * entryoffsets.c (VAL): Break out from... | ||
143 | * (OF): Use VAL. | ||
144 | * (LCLONE_VM): New asmified value from CLONE_VM. | ||
145 | * | ||
146 | * Revision 1.27 2001/05/29 11:25:27 markusl | ||
147 | * In case of "spurious_interrupt", do hard_reset instead of hanging system in a loop... | ||
148 | * | ||
149 | * Revision 1.26 2001/05/15 15:46:03 bjornw | ||
150 | * Include config.h now that we use some CONFIG_ options | ||
151 | * | ||
152 | * Revision 1.25 2001/05/15 05:38:47 hp | ||
153 | * Tweaked code in _ret_from_sys_call | ||
154 | * | ||
155 | * Revision 1.24 2001/05/15 05:27:49 hp | ||
156 | * Save r9 in r1 over function call rather than on stack. | ||
157 | * | ||
158 | * Revision 1.23 2001/05/15 05:10:00 hp | ||
159 | * Generate entry.S structure offsets from C | ||
160 | * | ||
161 | * Revision 1.22 2001/04/17 13:58:39 orjanf | ||
162 | * * Renamed CONFIG_KGDB to CONFIG_ETRAX_KGDB. | ||
163 | * | ||
164 | * Revision 1.21 2001/04/17 11:33:29 orjanf | ||
165 | * Updated according to review: | ||
166 | * * Included asm/sv_addr_ag.h to get macro for internal register. | ||
167 | * * Corrected comment regarding system call argument passing. | ||
168 | * * Removed comment about instruction being in a delay slot. | ||
169 | * * Added comment about SYMBOL_NAME macro. | ||
170 | * | ||
171 | * Revision 1.20 2001/04/12 08:51:07 hp | ||
172 | * - Add entry for sys_fcntl64. In fact copy last piece from i386 including ... | ||
173 | * - .rept to fill table to safe state with sys_ni_syscall. | ||
174 | * | ||
175 | * Revision 1.19 2001/04/04 09:43:32 orjanf | ||
176 | * * Moved do_sigtrap from traps.c to entry.S. | ||
177 | * * LTASK_PID need not be global anymore. | ||
178 | * | ||
179 | * Revision 1.18 2001/03/26 09:25:02 markusl | ||
180 | * Updated after review, should now handle USB interrupts correctly. | ||
181 | * | ||
182 | * Revision 1.17 2001/03/21 16:12:55 bjornw | ||
183 | * * Always make room for the cpu status record in the frame, in order to | ||
184 | * use the same framelength and layout for both mmu busfaults and normal | ||
185 | * irqs. No need to check for the explicit CRIS_FRAME_FIXUP type anymore. | ||
186 | * * Fixed bug with using addq for popping the stack in the epilogue - it | ||
187 | * destroyed the flag register. Use instructions that don't affect the | ||
188 | * flag register instead. | ||
189 | * * Removed write to R_PORT_PA_DATA during spurious_interrupt | ||
190 | * | ||
191 | * Revision 1.16 2001/03/20 19:43:02 bjornw | ||
192 | * * Get rid of esp0 setting | ||
193 | * * Give a 7th argument to a systemcall - the stackframe | ||
194 | * | ||
195 | * Revision 1.15 2001/03/05 13:14:30 bjornw | ||
196 | * Spelling fix | ||
197 | * | ||
198 | * Revision 1.14 2001/02/23 08:36:36 perf | ||
199 | * New ABI; syscallnr=r9, arg5=mof, arg6=srp. | ||
200 | * Corrected tracesys call check. | ||
201 | * | ||
202 | * Revision 1.13 2001/02/15 08:40:55 perf | ||
203 | * H-P by way of perf; | ||
204 | * - (_system_call): Don't read system call function address into r1. | ||
205 | * - (RBFExit): There is no such thing as a null pop. Adjust sp by addq. | ||
206 | * - (_system_call): Don't use r10 and don't save and restore it. | ||
207 | * - (THREAD_ESP0): New constant. | ||
208 | * - (_system_call): Inline set_esp0. | ||
209 | * | ||
210 | * Revision 1.12 2001/01/31 17:56:25 orjanf | ||
211 | * Added definition of LTASK_PID and made it global. | ||
212 | * | ||
213 | * Revision 1.11 2001/01/10 21:13:29 bjornw | ||
214 | * SYMBOL_NAME is defined incorrectly for the compiler options we currently use | ||
215 | * | ||
216 | * Revision 1.10 2000/12/18 23:47:56 bjornw | ||
217 | * * Added syscall trace support (ptrace), completely untested of course | ||
218 | * * Removed redundant check for NULL entries in syscall_table | ||
219 | * | ||
220 | * Revision 1.9 2000/11/21 16:40:51 bjornw | ||
221 | * * New frame type used when an SBFS frame needs to be popped without | ||
222 | * actually restarting the instruction | ||
223 | * * Enable interrupts in signal_return (they did so in x86, I hope it's a good | ||
224 | * idea) | ||
225 | * | ||
226 | * Revision 1.8 2000/11/17 16:53:35 bjornw | ||
227 | * Added detection of frame-type in Rexit, so that mmu_bus_fault can | ||
228 | * use ret_from_intr in the return-path to check for signals (like SEGV) | ||
229 | * and other foul things that might have occurred during the fault. | ||
230 | * | ||
231 | * Revision 1.7 2000/10/06 15:04:28 bjornw | ||
232 | * Include mof in register savings | ||
233 | * | ||
234 | * Revision 1.6 2000/09/12 16:02:44 bjornw | ||
235 | * Linux-2.4.0-test7 derived updates | ||
236 | * | ||
237 | * Revision 1.5 2000/08/17 15:35:15 bjornw | ||
238 | * 2.4.0-test6 changed local_irq_count and friends API | ||
239 | * | ||
240 | * Revision 1.4 2000/08/02 13:59:30 bjornw | ||
241 | * Removed olduname and uname from the syscall list | ||
242 | * | ||
243 | * Revision 1.3 2000/07/31 13:32:58 bjornw | ||
244 | * * Export ret_from_intr | ||
245 | * * _resume updated (prev/last tjohejsan) | ||
246 | * * timer_interrupt obsolete | ||
247 | * * SIGSEGV detection in mmu_bus_fault temporarily disabled | ||
248 | * | ||
249 | * | ||
250 | */ | 7 | */ |
251 | 8 | ||
252 | /* | 9 | /* |
@@ -1167,9 +924,11 @@ sys_call_table: | |||
1167 | .long sys_epoll_pwait | 924 | .long sys_epoll_pwait |
1168 | .long sys_utimensat /* 320 */ | 925 | .long sys_utimensat /* 320 */ |
1169 | .long sys_signalfd | 926 | .long sys_signalfd |
1170 | .long sys_ni_syscall | 927 | .long sys_timerfd_create |
1171 | .long sys_eventfd | 928 | .long sys_eventfd |
1172 | .long sys_fallocate | 929 | .long sys_fallocate |
930 | .long sys_timerfd_settime /* 325 */ | ||
931 | .long sys_timerfd_gettime | ||
1173 | 932 | ||
1174 | /* | 933 | /* |
1175 | * NOTE!! This doesn't have to be exact - we just have | 934 | * NOTE!! This doesn't have to be exact - we just have |
diff --git a/arch/cris/arch-v10/kernel/fasttimer.c b/arch/cris/arch-v10/kernel/fasttimer.c index c1a3a2100ee7..31ff35cff02c 100644 --- a/arch/cris/arch-v10/kernel/fasttimer.c +++ b/arch/cris/arch-v10/kernel/fasttimer.c | |||
@@ -31,15 +31,12 @@ | |||
31 | 31 | ||
32 | #define DEBUG_LOG_INCLUDED | 32 | #define DEBUG_LOG_INCLUDED |
33 | #define FAST_TIMER_LOG | 33 | #define FAST_TIMER_LOG |
34 | //#define FAST_TIMER_TEST | 34 | /* #define FAST_TIMER_TEST */ |
35 | 35 | ||
36 | #define FAST_TIMER_SANITY_CHECKS | 36 | #define FAST_TIMER_SANITY_CHECKS |
37 | 37 | ||
38 | #ifdef FAST_TIMER_SANITY_CHECKS | 38 | #ifdef FAST_TIMER_SANITY_CHECKS |
39 | #define SANITYCHECK(x) x | ||
40 | static int sanity_failed; | 39 | static int sanity_failed; |
41 | #else | ||
42 | #define SANITYCHECK(x) | ||
43 | #endif | 40 | #endif |
44 | 41 | ||
45 | #define D1(x) | 42 | #define D1(x) |
@@ -226,23 +223,19 @@ void start_one_shot_timer(struct fast_timer *t, | |||
226 | do_gettimeofday_fast(&t->tv_set); | 223 | do_gettimeofday_fast(&t->tv_set); |
227 | tmp = fast_timer_list; | 224 | tmp = fast_timer_list; |
228 | 225 | ||
229 | SANITYCHECK({ /* Check so this is not in the list already... */ | 226 | #ifdef FAST_TIMER_SANITY_CHECKS |
230 | while (tmp != NULL) | 227 | /* Check so this is not in the list already... */ |
231 | { | 228 | while (tmp != NULL) { |
232 | if (tmp == t) | 229 | if (tmp == t) { |
233 | { | 230 | printk(KERN_WARNING "timer name: %s data: " |
234 | printk(KERN_WARNING | 231 | "0x%08lX already in list!\n", name, data); |
235 | "timer name: %s data: 0x%08lX already in list!\n", name, data); | 232 | sanity_failed++; |
236 | sanity_failed++; | 233 | goto done; |
237 | goto done; | 234 | } else |
238 | } | 235 | tmp = tmp->next; |
239 | else | 236 | } |
240 | { | 237 | tmp = fast_timer_list; |
241 | tmp = tmp->next; | 238 | #endif |
242 | } | ||
243 | } | ||
244 | tmp = fast_timer_list; | ||
245 | }); | ||
246 | 239 | ||
247 | t->delay_us = delay_us; | 240 | t->delay_us = delay_us; |
248 | t->function = function; | 241 | t->function = function; |
diff --git a/arch/cris/arch-v10/kernel/head.S b/arch/cris/arch-v10/kernel/head.S index d946d8b8d277..96344afc4ebc 100644 --- a/arch/cris/arch-v10/kernel/head.S +++ b/arch/cris/arch-v10/kernel/head.S | |||
@@ -1,186 +1,10 @@ | |||
1 | /* $Id: head.S,v 1.10 2005/06/20 05:12:54 starvik Exp $ | 1 | /* |
2 | * | ||
3 | * Head of the kernel - alter with care | 2 | * Head of the kernel - alter with care |
4 | * | 3 | * |
5 | * Copyright (C) 2000, 2001 Axis Communications AB | 4 | * Copyright (C) 2000, 2001 Axis Communications AB |
6 | * | 5 | * |
7 | * Authors: Bjorn Wesen (bjornw@axis.com) | 6 | * Authors: Bjorn Wesen (bjornw@axis.com) |
8 | * | 7 | * |
9 | * $Log: head.S,v $ | ||
10 | * Revision 1.10 2005/06/20 05:12:54 starvik | ||
11 | * Remove unnecessary diff to kernel.org tree | ||
12 | * | ||
13 | * Revision 1.9 2004/12/13 12:21:51 starvik | ||
14 | * Added I/O and DMA allocators from Linux 2.4 | ||
15 | * | ||
16 | * Revision 1.8 2004/11/22 11:41:14 starvik | ||
17 | * Kernel command line may be supplied to kernel. Not used by Axis but may | ||
18 | * be used by customers. | ||
19 | * | ||
20 | * Revision 1.7 2004/05/14 07:58:01 starvik | ||
21 | * Merge of changes from 2.4 | ||
22 | * | ||
23 | * Revision 1.6 2003/04/28 05:31:46 starvik | ||
24 | * Added section attributes | ||
25 | * | ||
26 | * Revision 1.5 2002/12/11 15:42:02 starvik | ||
27 | * Extracted v10 (ETRAX 100LX) specific stuff from arch/cris/kernel/*.c | ||
28 | * | ||
29 | * Revision 1.4 2002/11/07 09:00:44 starvik | ||
30 | * Names changed for init sections | ||
31 | * init_task_union -> init_thread_union | ||
32 | * | ||
33 | * Revision 1.3 2002/02/05 15:38:23 bjornw | ||
34 | * Oops.. non-CRAMFS_MAGIC should jump over the copying, not into it... | ||
35 | * | ||
36 | * Revision 1.2 2001/12/18 13:35:19 bjornw | ||
37 | * Applied the 2.4.13->2.4.16 CRIS patch to 2.5.1 (is a copy of 2.4.15). | ||
38 | * | ||
39 | * Revision 1.43 2001/11/08 15:09:43 starvik | ||
40 | * Only start MII clock if Ethernet is configured | ||
41 | * | ||
42 | * Revision 1.42 2001/11/08 14:37:34 starvik | ||
43 | * Start MII clock early to make sure that it is running at tranceiver reset | ||
44 | * | ||
45 | * Revision 1.41 2001/10/29 14:55:58 pkj | ||
46 | * Corrected pa$r0 to par0. | ||
47 | * | ||
48 | * Revision 1.40 2001/10/03 14:59:57 pkj | ||
49 | * Added support for resetting the Bluetooth hardware. | ||
50 | * | ||
51 | * Revision 1.39 2001/10/01 14:45:03 bjornw | ||
52 | * Removed underscores and added register prefixes | ||
53 | * | ||
54 | * Revision 1.38 2001/09/21 07:14:11 jonashg | ||
55 | * Made root filesystem (cramfs) use mtdblock driver when booting from flash. | ||
56 | * | ||
57 | * Revision 1.37 2001/09/11 13:44:29 orjanf | ||
58 | * Decouple usage of serial ports for debug and kgdb. | ||
59 | * | ||
60 | * Revision 1.36 2001/06/29 12:39:31 pkj | ||
61 | * Added support for mirroring the first flash to just below the | ||
62 | * second one, to make them look consecutive to cramfs. | ||
63 | * | ||
64 | * Revision 1.35 2001/06/25 14:07:00 hp | ||
65 | * Fix review comment. | ||
66 | * * head.S: Use IO_STATE, IO_FIELD and IO_MASK constructs instead of | ||
67 | * magic numbers. Add comment that -traditional must not be used. | ||
68 | * * entry.S (SYMBOL_NAME): Change redefinition to use ## concatenation. | ||
69 | * Correct and update comment. | ||
70 | * * Makefile (.S.o): Don't use -traditional. Add comment why the | ||
71 | * toplevel rule can't be used (now that there's a reason). | ||
72 | * | ||
73 | * Revision 1.34 2001/05/15 07:08:14 hp | ||
74 | * Tweak "notice" to reflect that both r8 r9 are used | ||
75 | * | ||
76 | * Revision 1.33 2001/05/15 06:40:05 hp | ||
77 | * Put bulk of code in .text.init, data in .data.init | ||
78 | * | ||
79 | * Revision 1.32 2001/05/15 06:18:56 hp | ||
80 | * Execute review comment: s/bcc/bhs/g; s/bcs/blo/g | ||
81 | * | ||
82 | * Revision 1.31 2001/05/15 06:08:40 hp | ||
83 | * Add sentence about autodetecting the bit31-MMU-bug | ||
84 | * | ||
85 | * Revision 1.30 2001/05/15 06:00:05 hp | ||
86 | * Update comment: LOW_MAP is not forced on xsim anymore. | ||
87 | * | ||
88 | * Revision 1.29 2001/04/18 12:51:59 orjanf | ||
89 | * * Reverted review change regarding the use of bcs/bcc. | ||
90 | * * Removed non-working LED-clearing code. | ||
91 | * | ||
92 | * Revision 1.28 2001/04/17 13:58:39 orjanf | ||
93 | * * Renamed CONFIG_KGDB to CONFIG_ETRAX_KGDB. | ||
94 | * | ||
95 | * Revision 1.27 2001/04/17 11:42:35 orjanf | ||
96 | * Changed according to review: | ||
97 | * * Added comment explaining memory map bug. | ||
98 | * * Changed bcs and bcc to blo and bhs, respectively. | ||
99 | * * Removed mentioning of Stallone and Olga boards. | ||
100 | * | ||
101 | * Revision 1.26 2001/04/06 12:31:07 jonashg | ||
102 | * Check for cramfs in flash before RAM instead of RAM before flash. | ||
103 | * | ||
104 | * Revision 1.25 2001/04/04 06:23:53 starvik | ||
105 | * Initialize DRAM if not already initialized | ||
106 | * | ||
107 | * Revision 1.24 2001/04/03 11:12:00 starvik | ||
108 | * Removed dram init (done by rescue or etrax100boot | ||
109 | * Corrected include | ||
110 | * | ||
111 | * Revision 1.23 2001/04/03 09:53:03 starvik | ||
112 | * Include hw_settings.S | ||
113 | * | ||
114 | * Revision 1.22 2001/03/26 14:23:26 bjornw | ||
115 | * Namechange of some config options | ||
116 | * | ||
117 | * Revision 1.21 2001/03/08 12:14:41 bjornw | ||
118 | * * Config name for ETRAX IDE was renamed | ||
119 | * * Removed G27 auto-setting when JULIETTE is chosen (need to make this | ||
120 | * a new config option later) | ||
121 | * | ||
122 | * Revision 1.20 2001/02/23 12:47:56 bjornw | ||
123 | * MMU regs during LOW_MAP updated to reflect a newer reality | ||
124 | * | ||
125 | * Revision 1.19 2001/02/19 11:12:07 bjornw | ||
126 | * Changed comment header format | ||
127 | * | ||
128 | * Revision 1.18 2001/02/15 07:25:38 starvik | ||
129 | * Added support for synchronous serial ports | ||
130 | * | ||
131 | * Revision 1.17 2001/02/08 15:53:13 starvik | ||
132 | * Last commit removed some important ifdefs | ||
133 | * | ||
134 | * Revision 1.16 2001/02/08 15:20:38 starvik | ||
135 | * Include dram_init.S as inline | ||
136 | * | ||
137 | * Revision 1.15 2001/01/29 18:12:01 bjornw | ||
138 | * Corrected some comments | ||
139 | * | ||
140 | * Revision 1.14 2001/01/29 13:11:29 starvik | ||
141 | * Include dram_init.S (with DRAM/SDRAM initialization) | ||
142 | * | ||
143 | * Revision 1.13 2001/01/23 14:54:57 markusl | ||
144 | * Updated for USB | ||
145 | * i.e. added r_gen_config settings | ||
146 | * | ||
147 | * Revision 1.12 2001/01/19 16:16:29 perf | ||
148 | * Added temporary mapping of 0x0c->0x0c to avoid flash loading confusion. | ||
149 | * Renamed serial options from ETRAX100 to ETRAX. | ||
150 | * | ||
151 | * Revision 1.11 2001/01/16 16:31:38 bjornw | ||
152 | * * Changed name and semantics of running_from_flash to romfs_in_flash, | ||
153 | * set by head.S to indicate to setup.c whether there is a cramfs image | ||
154 | * after the kernels BSS or not. Should work for all three boot-cases | ||
155 | * (DRAM with cramfs in DRAM, DRAM with cramfs in flash (compressed boot), | ||
156 | * and flash with cramfs in flash) | ||
157 | * | ||
158 | * Revision 1.10 2001/01/16 14:12:21 bjornw | ||
159 | * * Check for cramfs start passed in r9 from the decompressor, if all other | ||
160 | * cramfs options fail (if we boot from DRAM but don't find a cramfs image | ||
161 | * after the kernel in DRAM, it is probably still in the flash) | ||
162 | * * Check magic in cramfs detection when booting from flash directly | ||
163 | * | ||
164 | * Revision 1.9 2001/01/15 17:17:02 bjornw | ||
165 | * * Corrected the code that detects the cramfs lengths | ||
166 | * * Added a comment saying that the above does not work due to other | ||
167 | * reasons.. | ||
168 | * | ||
169 | * Revision 1.8 2001/01/15 16:27:51 jonashg | ||
170 | * Made boot after flashing work. | ||
171 | * * end destination is __vmlinux_end in RAM. | ||
172 | * * _romfs_start moved because of virtual memory. | ||
173 | * | ||
174 | * Revision 1.7 2000/11/21 13:55:29 bjornw | ||
175 | * Use CONFIG_CRIS_LOW_MAP for the low VM map instead of explicit CPU type | ||
176 | * | ||
177 | * Revision 1.6 2000/10/06 12:36:55 bjornw | ||
178 | * Forgot swapper_pg_dir when changing memory map.. | ||
179 | * | ||
180 | * Revision 1.5 2000/10/04 16:49:30 bjornw | ||
181 | * * Fixed memory mapping in LX | ||
182 | * * Check for cramfs instead of romfs | ||
183 | * | ||
184 | */ | 8 | */ |
185 | 9 | ||
186 | #define ASSEMBLER_MACROS_ONLY | 10 | #define ASSEMBLER_MACROS_ONLY |
@@ -595,11 +419,17 @@ no_command_line: | |||
595 | 419 | ||
596 | moveq 0,$r0 | 420 | moveq 0,$r0 |
597 | 421 | ||
422 | ;; Select or disable serial port 2 | ||
423 | #ifdef CONFIG_ETRAX_SERIAL_PORT2 | ||
424 | or.d IO_STATE (R_GEN_CONFIG, ser2, select),$r0 | ||
425 | #else | ||
426 | or.d IO_STATE (R_GEN_CONFIG, ser2, disable),$r0 | ||
427 | #endif | ||
428 | |||
598 | ;; Init interfaces (disable them). | 429 | ;; Init interfaces (disable them). |
599 | or.d IO_STATE (R_GEN_CONFIG, scsi0, disable) \ | 430 | or.d IO_STATE (R_GEN_CONFIG, scsi0, disable) \ |
600 | | IO_STATE (R_GEN_CONFIG, ata, disable) \ | 431 | | IO_STATE (R_GEN_CONFIG, ata, disable) \ |
601 | | IO_STATE (R_GEN_CONFIG, par0, disable) \ | 432 | | IO_STATE (R_GEN_CONFIG, par0, disable) \ |
602 | | IO_STATE (R_GEN_CONFIG, ser2, disable) \ | ||
603 | | IO_STATE (R_GEN_CONFIG, mio, disable) \ | 433 | | IO_STATE (R_GEN_CONFIG, mio, disable) \ |
604 | | IO_STATE (R_GEN_CONFIG, scsi1, disable) \ | 434 | | IO_STATE (R_GEN_CONFIG, scsi1, disable) \ |
605 | | IO_STATE (R_GEN_CONFIG, scsi0w, disable) \ | 435 | | IO_STATE (R_GEN_CONFIG, scsi0w, disable) \ |
@@ -801,6 +631,41 @@ no_command_line: | |||
801 | | IO_STATE (R_SERIAL1_TR_CTRL, tr_bitnr, tr_8bit),$r0 | 631 | | IO_STATE (R_SERIAL1_TR_CTRL, tr_bitnr, tr_8bit),$r0 |
802 | move.b $r0,[R_SERIAL1_TR_CTRL] | 632 | move.b $r0,[R_SERIAL1_TR_CTRL] |
803 | 633 | ||
634 | #ifdef CONFIG_ETRAX_SERIAL_PORT2 | ||
635 | ;; setup the serial port 2 at 115200 baud for debug purposes | ||
636 | |||
637 | moveq IO_STATE (R_SERIAL2_XOFF, tx_stop, enable) \ | ||
638 | | IO_STATE (R_SERIAL2_XOFF, auto_xoff, disable) \ | ||
639 | | IO_FIELD (R_SERIAL2_XOFF, xoff_char, 0),$r0 | ||
640 | move.d $r0,[R_SERIAL2_XOFF] | ||
641 | |||
642 | ; 115.2kbaud for both transmit and receive | ||
643 | move.b IO_STATE (R_SERIAL2_BAUD, tr_baud, c115k2Hz) \ | ||
644 | | IO_STATE (R_SERIAL2_BAUD, rec_baud, c115k2Hz),$r0 | ||
645 | move.b $r0,[R_SERIAL2_BAUD] | ||
646 | |||
647 | ; Set up and enable the serial2 receiver. | ||
648 | move.b IO_STATE (R_SERIAL2_REC_CTRL, dma_err, stop) \ | ||
649 | | IO_STATE (R_SERIAL2_REC_CTRL, rec_enable, enable) \ | ||
650 | | IO_STATE (R_SERIAL2_REC_CTRL, rts_, active) \ | ||
651 | | IO_STATE (R_SERIAL2_REC_CTRL, sampling, middle) \ | ||
652 | | IO_STATE (R_SERIAL2_REC_CTRL, rec_stick_par, normal) \ | ||
653 | | IO_STATE (R_SERIAL2_REC_CTRL, rec_par, even) \ | ||
654 | | IO_STATE (R_SERIAL2_REC_CTRL, rec_par_en, disable) \ | ||
655 | | IO_STATE (R_SERIAL2_REC_CTRL, rec_bitnr, rec_8bit),$r0 | ||
656 | move.b $r0,[R_SERIAL2_REC_CTRL] | ||
657 | |||
658 | ; Set up and enable the serial2 transmitter. | ||
659 | move.b IO_FIELD (R_SERIAL2_TR_CTRL, txd, 0) \ | ||
660 | | IO_STATE (R_SERIAL2_TR_CTRL, tr_enable, enable) \ | ||
661 | | IO_STATE (R_SERIAL2_TR_CTRL, auto_cts, disabled) \ | ||
662 | | IO_STATE (R_SERIAL2_TR_CTRL, stop_bits, one_bit) \ | ||
663 | | IO_STATE (R_SERIAL2_TR_CTRL, tr_stick_par, normal) \ | ||
664 | | IO_STATE (R_SERIAL2_TR_CTRL, tr_par, even) \ | ||
665 | | IO_STATE (R_SERIAL2_TR_CTRL, tr_par_en, disable) \ | ||
666 | | IO_STATE (R_SERIAL2_TR_CTRL, tr_bitnr, tr_8bit),$r0 | ||
667 | move.b $r0,[R_SERIAL2_TR_CTRL] | ||
668 | #endif | ||
804 | 669 | ||
805 | #ifdef CONFIG_ETRAX_SERIAL_PORT3 | 670 | #ifdef CONFIG_ETRAX_SERIAL_PORT3 |
806 | ;; setup the serial port 3 at 115200 baud for debug purposes | 671 | ;; setup the serial port 3 at 115200 baud for debug purposes |
diff --git a/arch/cris/arch-v10/kernel/io_interface_mux.c b/arch/cris/arch-v10/kernel/io_interface_mux.c index f3b327d4ed9c..add98e0941b5 100644 --- a/arch/cris/arch-v10/kernel/io_interface_mux.c +++ b/arch/cris/arch-v10/kernel/io_interface_mux.c | |||
@@ -1,10 +1,9 @@ | |||
1 | /* IO interface mux allocator for ETRAX100LX. | 1 | /* IO interface mux allocator for ETRAX100LX. |
2 | * Copyright 2004, Axis Communications AB | 2 | * Copyright 2004-2007, Axis Communications AB |
3 | * $Id: io_interface_mux.c,v 1.2 2004/12/21 12:08:38 starvik Exp $ | ||
4 | */ | 3 | */ |
5 | 4 | ||
6 | 5 | ||
7 | /* C.f. ETRAX100LX Designer's Reference 20.9 */ | 6 | /* C.f. ETRAX100LX Designer's Reference chapter 19.9 */ |
8 | 7 | ||
9 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
10 | #include <linux/slab.h> | 9 | #include <linux/slab.h> |
@@ -45,17 +44,39 @@ struct watcher | |||
45 | struct if_group | 44 | struct if_group |
46 | { | 45 | { |
47 | enum io_if_group group; | 46 | enum io_if_group group; |
48 | unsigned char used; | 47 | /* name - the name of the group 'A' to 'F' */ |
49 | enum cris_io_interface owner; | 48 | char *name; |
49 | /* used - a bit mask of all pins in the group in the order listed | ||
50 | * in the tables in 19.9.1 to 19.9.6. Note that no | ||
51 | * distinction is made between in, out and in/out pins. */ | ||
52 | unsigned int used; | ||
50 | }; | 53 | }; |
51 | 54 | ||
52 | 55 | ||
53 | struct interface | 56 | struct interface |
54 | { | 57 | { |
55 | enum cris_io_interface ioif; | 58 | enum cris_io_interface ioif; |
59 | /* name - the name of the interface */ | ||
60 | char *name; | ||
61 | /* groups - OR'ed together io_if_group flags describing what pin groups | ||
62 | * the interface uses pins in. */ | ||
56 | unsigned char groups; | 63 | unsigned char groups; |
64 | /* used - set when the interface is allocated. */ | ||
57 | unsigned char used; | 65 | unsigned char used; |
58 | char *owner; | 66 | char *owner; |
67 | /* group_a through group_f - bit masks describing what pins in the | ||
68 | * pin groups the interface uses. */ | ||
69 | unsigned int group_a; | ||
70 | unsigned int group_b; | ||
71 | unsigned int group_c; | ||
72 | unsigned int group_d; | ||
73 | unsigned int group_e; | ||
74 | unsigned int group_f; | ||
75 | |||
76 | /* gpio_g_in, gpio_g_out, gpio_b - bit masks telling what pins in the | ||
77 | * GPIO ports the interface uses. This could be reconstucted using | ||
78 | * the group_X masks and a table of what pins the GPIO ports use, | ||
79 | * but that would be messy. */ | ||
59 | unsigned int gpio_g_in; | 80 | unsigned int gpio_g_in; |
60 | unsigned int gpio_g_out; | 81 | unsigned int gpio_g_out; |
61 | unsigned char gpio_b; | 82 | unsigned char gpio_b; |
@@ -64,26 +85,32 @@ struct interface | |||
64 | static struct if_group if_groups[6] = { | 85 | static struct if_group if_groups[6] = { |
65 | { | 86 | { |
66 | .group = group_a, | 87 | .group = group_a, |
88 | .name = "A", | ||
67 | .used = 0, | 89 | .used = 0, |
68 | }, | 90 | }, |
69 | { | 91 | { |
70 | .group = group_b, | 92 | .group = group_b, |
93 | .name = "B", | ||
71 | .used = 0, | 94 | .used = 0, |
72 | }, | 95 | }, |
73 | { | 96 | { |
74 | .group = group_c, | 97 | .group = group_c, |
98 | .name = "C", | ||
75 | .used = 0, | 99 | .used = 0, |
76 | }, | 100 | }, |
77 | { | 101 | { |
78 | .group = group_d, | 102 | .group = group_d, |
103 | .name = "D", | ||
79 | .used = 0, | 104 | .used = 0, |
80 | }, | 105 | }, |
81 | { | 106 | { |
82 | .group = group_e, | 107 | .group = group_e, |
108 | .name = "E", | ||
83 | .used = 0, | 109 | .used = 0, |
84 | }, | 110 | }, |
85 | { | 111 | { |
86 | .group = group_f, | 112 | .group = group_f, |
113 | .name = "F", | ||
87 | .used = 0, | 114 | .used = 0, |
88 | } | 115 | } |
89 | }; | 116 | }; |
@@ -94,14 +121,32 @@ static struct interface interfaces[] = { | |||
94 | /* Begin Non-multiplexed interfaces */ | 121 | /* Begin Non-multiplexed interfaces */ |
95 | { | 122 | { |
96 | .ioif = if_eth, | 123 | .ioif = if_eth, |
124 | .name = "ethernet", | ||
97 | .groups = 0, | 125 | .groups = 0, |
126 | |||
127 | .group_a = 0, | ||
128 | .group_b = 0, | ||
129 | .group_c = 0, | ||
130 | .group_d = 0, | ||
131 | .group_e = 0, | ||
132 | .group_f = 0, | ||
133 | |||
98 | .gpio_g_in = 0, | 134 | .gpio_g_in = 0, |
99 | .gpio_g_out = 0, | 135 | .gpio_g_out = 0, |
100 | .gpio_b = 0 | 136 | .gpio_b = 0 |
101 | }, | 137 | }, |
102 | { | 138 | { |
103 | .ioif = if_serial_0, | 139 | .ioif = if_serial_0, |
140 | .name = "serial_0", | ||
104 | .groups = 0, | 141 | .groups = 0, |
142 | |||
143 | .group_a = 0, | ||
144 | .group_b = 0, | ||
145 | .group_c = 0, | ||
146 | .group_d = 0, | ||
147 | .group_e = 0, | ||
148 | .group_f = 0, | ||
149 | |||
105 | .gpio_g_in = 0, | 150 | .gpio_g_in = 0, |
106 | .gpio_g_out = 0, | 151 | .gpio_g_out = 0, |
107 | .gpio_b = 0 | 152 | .gpio_b = 0 |
@@ -109,172 +154,385 @@ static struct interface interfaces[] = { | |||
109 | /* End Non-multiplexed interfaces */ | 154 | /* End Non-multiplexed interfaces */ |
110 | { | 155 | { |
111 | .ioif = if_serial_1, | 156 | .ioif = if_serial_1, |
157 | .name = "serial_1", | ||
112 | .groups = group_e, | 158 | .groups = group_e, |
159 | |||
160 | .group_a = 0, | ||
161 | .group_b = 0, | ||
162 | .group_c = 0, | ||
163 | .group_d = 0, | ||
164 | .group_e = 0x0f, | ||
165 | .group_f = 0, | ||
166 | |||
113 | .gpio_g_in = 0x00000000, | 167 | .gpio_g_in = 0x00000000, |
114 | .gpio_g_out = 0x00000000, | 168 | .gpio_g_out = 0x00000000, |
115 | .gpio_b = 0x00 | 169 | .gpio_b = 0x00 |
116 | }, | 170 | }, |
117 | { | 171 | { |
118 | .ioif = if_serial_2, | 172 | .ioif = if_serial_2, |
173 | .name = "serial_2", | ||
119 | .groups = group_b, | 174 | .groups = group_b, |
175 | |||
176 | .group_a = 0, | ||
177 | .group_b = 0x0f, | ||
178 | .group_c = 0, | ||
179 | .group_d = 0, | ||
180 | .group_e = 0, | ||
181 | .group_f = 0, | ||
182 | |||
120 | .gpio_g_in = 0x000000c0, | 183 | .gpio_g_in = 0x000000c0, |
121 | .gpio_g_out = 0x000000c0, | 184 | .gpio_g_out = 0x000000c0, |
122 | .gpio_b = 0x00 | 185 | .gpio_b = 0x00 |
123 | }, | 186 | }, |
124 | { | 187 | { |
125 | .ioif = if_serial_3, | 188 | .ioif = if_serial_3, |
189 | .name = "serial_3", | ||
126 | .groups = group_c, | 190 | .groups = group_c, |
191 | |||
192 | .group_a = 0, | ||
193 | .group_b = 0, | ||
194 | .group_c = 0x0f, | ||
195 | .group_d = 0, | ||
196 | .group_e = 0, | ||
197 | .group_f = 0, | ||
198 | |||
127 | .gpio_g_in = 0xc0000000, | 199 | .gpio_g_in = 0xc0000000, |
128 | .gpio_g_out = 0xc0000000, | 200 | .gpio_g_out = 0xc0000000, |
129 | .gpio_b = 0x00 | 201 | .gpio_b = 0x00 |
130 | }, | 202 | }, |
131 | { | 203 | { |
132 | .ioif = if_sync_serial_1, | 204 | .ioif = if_sync_serial_1, |
133 | .groups = group_e | group_f, /* if_sync_serial_1 and if_sync_serial_3 | 205 | .name = "sync_serial_1", |
134 | can be used simultaneously */ | 206 | .groups = group_e | group_f, |
207 | |||
208 | .group_a = 0, | ||
209 | .group_b = 0, | ||
210 | .group_c = 0, | ||
211 | .group_d = 0, | ||
212 | .group_e = 0x0f, | ||
213 | .group_f = 0x10, | ||
214 | |||
135 | .gpio_g_in = 0x00000000, | 215 | .gpio_g_in = 0x00000000, |
136 | .gpio_g_out = 0x00000000, | 216 | .gpio_g_out = 0x00000000, |
137 | .gpio_b = 0x10 | 217 | .gpio_b = 0x10 |
138 | }, | 218 | }, |
139 | { | 219 | { |
140 | .ioif = if_sync_serial_3, | 220 | .ioif = if_sync_serial_3, |
221 | .name = "sync_serial_3", | ||
141 | .groups = group_c | group_f, | 222 | .groups = group_c | group_f, |
223 | |||
224 | .group_a = 0, | ||
225 | .group_b = 0, | ||
226 | .group_c = 0x0f, | ||
227 | .group_d = 0, | ||
228 | .group_e = 0, | ||
229 | .group_f = 0x80, | ||
230 | |||
142 | .gpio_g_in = 0xc0000000, | 231 | .gpio_g_in = 0xc0000000, |
143 | .gpio_g_out = 0xc0000000, | 232 | .gpio_g_out = 0xc0000000, |
144 | .gpio_b = 0x80 | 233 | .gpio_b = 0x80 |
145 | }, | 234 | }, |
146 | { | 235 | { |
147 | .ioif = if_shared_ram, | 236 | .ioif = if_shared_ram, |
237 | .name = "shared_ram", | ||
148 | .groups = group_a, | 238 | .groups = group_a, |
239 | |||
240 | .group_a = 0x7f8ff, | ||
241 | .group_b = 0, | ||
242 | .group_c = 0, | ||
243 | .group_d = 0, | ||
244 | .group_e = 0, | ||
245 | .group_f = 0, | ||
246 | |||
149 | .gpio_g_in = 0x0000ff3e, | 247 | .gpio_g_in = 0x0000ff3e, |
150 | .gpio_g_out = 0x0000ff38, | 248 | .gpio_g_out = 0x0000ff38, |
151 | .gpio_b = 0x00 | 249 | .gpio_b = 0x00 |
152 | }, | 250 | }, |
153 | { | 251 | { |
154 | .ioif = if_shared_ram_w, | 252 | .ioif = if_shared_ram_w, |
253 | .name = "shared_ram_w", | ||
155 | .groups = group_a | group_d, | 254 | .groups = group_a | group_d, |
255 | |||
256 | .group_a = 0x7f8ff, | ||
257 | .group_b = 0, | ||
258 | .group_c = 0, | ||
259 | .group_d = 0xff, | ||
260 | .group_e = 0, | ||
261 | .group_f = 0, | ||
262 | |||
156 | .gpio_g_in = 0x00ffff3e, | 263 | .gpio_g_in = 0x00ffff3e, |
157 | .gpio_g_out = 0x00ffff38, | 264 | .gpio_g_out = 0x00ffff38, |
158 | .gpio_b = 0x00 | 265 | .gpio_b = 0x00 |
159 | }, | 266 | }, |
160 | { | 267 | { |
161 | .ioif = if_par_0, | 268 | .ioif = if_par_0, |
269 | .name = "par_0", | ||
162 | .groups = group_a, | 270 | .groups = group_a, |
271 | |||
272 | .group_a = 0x7fbff, | ||
273 | .group_b = 0, | ||
274 | .group_c = 0, | ||
275 | .group_d = 0, | ||
276 | .group_e = 0, | ||
277 | .group_f = 0, | ||
278 | |||
163 | .gpio_g_in = 0x0000ff3e, | 279 | .gpio_g_in = 0x0000ff3e, |
164 | .gpio_g_out = 0x0000ff3e, | 280 | .gpio_g_out = 0x0000ff3e, |
165 | .gpio_b = 0x00 | 281 | .gpio_b = 0x00 |
166 | }, | 282 | }, |
167 | { | 283 | { |
168 | .ioif = if_par_1, | 284 | .ioif = if_par_1, |
285 | .name = "par_1", | ||
169 | .groups = group_d, | 286 | .groups = group_d, |
287 | |||
288 | .group_a = 0, | ||
289 | .group_b = 0, | ||
290 | .group_c = 0, | ||
291 | .group_d = 0x7feff, | ||
292 | .group_e = 0, | ||
293 | .group_f = 0, | ||
294 | |||
170 | .gpio_g_in = 0x3eff0000, | 295 | .gpio_g_in = 0x3eff0000, |
171 | .gpio_g_out = 0x3eff0000, | 296 | .gpio_g_out = 0x3eff0000, |
172 | .gpio_b = 0x00 | 297 | .gpio_b = 0x00 |
173 | }, | 298 | }, |
174 | { | 299 | { |
175 | .ioif = if_par_w, | 300 | .ioif = if_par_w, |
301 | .name = "par_w", | ||
176 | .groups = group_a | group_d, | 302 | .groups = group_a | group_d, |
303 | |||
304 | .group_a = 0x7fbff, | ||
305 | .group_b = 0, | ||
306 | .group_c = 0, | ||
307 | .group_d = 0xff, | ||
308 | .group_e = 0, | ||
309 | .group_f = 0, | ||
310 | |||
177 | .gpio_g_in = 0x00ffff3e, | 311 | .gpio_g_in = 0x00ffff3e, |
178 | .gpio_g_out = 0x00ffff3e, | 312 | .gpio_g_out = 0x00ffff3e, |
179 | .gpio_b = 0x00 | 313 | .gpio_b = 0x00 |
180 | }, | 314 | }, |
181 | { | 315 | { |
182 | .ioif = if_scsi8_0, | 316 | .ioif = if_scsi8_0, |
183 | .groups = group_a | group_b | group_f, /* if_scsi8_0 and if_scsi8_1 | 317 | .name = "scsi8_0", |
184 | can be used simultaneously */ | 318 | .groups = group_a | group_b | group_f, |
319 | |||
320 | .group_a = 0x7ffff, | ||
321 | .group_b = 0x0f, | ||
322 | .group_c = 0, | ||
323 | .group_d = 0, | ||
324 | .group_e = 0, | ||
325 | .group_f = 0x10, | ||
326 | |||
185 | .gpio_g_in = 0x0000ffff, | 327 | .gpio_g_in = 0x0000ffff, |
186 | .gpio_g_out = 0x0000ffff, | 328 | .gpio_g_out = 0x0000ffff, |
187 | .gpio_b = 0x10 | 329 | .gpio_b = 0x10 |
188 | }, | 330 | }, |
189 | { | 331 | { |
190 | .ioif = if_scsi8_1, | 332 | .ioif = if_scsi8_1, |
191 | .groups = group_c | group_d | group_f, /* if_scsi8_0 and if_scsi8_1 | 333 | .name = "scsi8_1", |
192 | can be used simultaneously */ | 334 | .groups = group_c | group_d | group_f, |
335 | |||
336 | .group_a = 0, | ||
337 | .group_b = 0, | ||
338 | .group_c = 0x0f, | ||
339 | .group_d = 0x7ffff, | ||
340 | .group_e = 0, | ||
341 | .group_f = 0x80, | ||
342 | |||
193 | .gpio_g_in = 0xffff0000, | 343 | .gpio_g_in = 0xffff0000, |
194 | .gpio_g_out = 0xffff0000, | 344 | .gpio_g_out = 0xffff0000, |
195 | .gpio_b = 0x80 | 345 | .gpio_b = 0x80 |
196 | }, | 346 | }, |
197 | { | 347 | { |
198 | .ioif = if_scsi_w, | 348 | .ioif = if_scsi_w, |
349 | .name = "scsi_w", | ||
199 | .groups = group_a | group_b | group_d | group_f, | 350 | .groups = group_a | group_b | group_d | group_f, |
351 | |||
352 | .group_a = 0x7ffff, | ||
353 | .group_b = 0x0f, | ||
354 | .group_c = 0, | ||
355 | .group_d = 0x601ff, | ||
356 | .group_e = 0, | ||
357 | .group_f = 0x90, | ||
358 | |||
200 | .gpio_g_in = 0x01ffffff, | 359 | .gpio_g_in = 0x01ffffff, |
201 | .gpio_g_out = 0x07ffffff, | 360 | .gpio_g_out = 0x07ffffff, |
202 | .gpio_b = 0x80 | 361 | .gpio_b = 0x80 |
203 | }, | 362 | }, |
204 | { | 363 | { |
205 | .ioif = if_ata, | 364 | .ioif = if_ata, |
365 | .name = "ata", | ||
206 | .groups = group_a | group_b | group_c | group_d, | 366 | .groups = group_a | group_b | group_c | group_d, |
367 | |||
368 | .group_a = 0x7ffff, | ||
369 | .group_b = 0x0f, | ||
370 | .group_c = 0x0f, | ||
371 | .group_d = 0x7cfff, | ||
372 | .group_e = 0, | ||
373 | .group_f = 0, | ||
374 | |||
207 | .gpio_g_in = 0xf9ffffff, | 375 | .gpio_g_in = 0xf9ffffff, |
208 | .gpio_g_out = 0xffffffff, | 376 | .gpio_g_out = 0xffffffff, |
209 | .gpio_b = 0x80 | 377 | .gpio_b = 0x80 |
210 | }, | 378 | }, |
211 | { | 379 | { |
212 | .ioif = if_csp, | 380 | .ioif = if_csp, |
213 | .groups = group_f, /* if_csp and if_i2c can be used simultaneously */ | 381 | .name = "csp", |
382 | .groups = group_f, | ||
383 | |||
384 | .group_a = 0, | ||
385 | .group_b = 0, | ||
386 | .group_c = 0, | ||
387 | .group_d = 0, | ||
388 | .group_e = 0, | ||
389 | .group_f = 0xfc, | ||
390 | |||
214 | .gpio_g_in = 0x00000000, | 391 | .gpio_g_in = 0x00000000, |
215 | .gpio_g_out = 0x00000000, | 392 | .gpio_g_out = 0x00000000, |
216 | .gpio_b = 0xfc | 393 | .gpio_b = 0xfc |
217 | }, | 394 | }, |
218 | { | 395 | { |
219 | .ioif = if_i2c, | 396 | .ioif = if_i2c, |
220 | .groups = group_f, /* if_csp and if_i2c can be used simultaneously */ | 397 | .name = "i2c", |
398 | .groups = group_f, | ||
399 | |||
400 | .group_a = 0, | ||
401 | .group_b = 0, | ||
402 | .group_c = 0, | ||
403 | .group_d = 0, | ||
404 | .group_e = 0, | ||
405 | .group_f = 0x03, | ||
406 | |||
221 | .gpio_g_in = 0x00000000, | 407 | .gpio_g_in = 0x00000000, |
222 | .gpio_g_out = 0x00000000, | 408 | .gpio_g_out = 0x00000000, |
223 | .gpio_b = 0x03 | 409 | .gpio_b = 0x03 |
224 | }, | 410 | }, |
225 | { | 411 | { |
226 | .ioif = if_usb_1, | 412 | .ioif = if_usb_1, |
413 | .name = "usb_1", | ||
227 | .groups = group_e | group_f, | 414 | .groups = group_e | group_f, |
415 | |||
416 | .group_a = 0, | ||
417 | .group_b = 0, | ||
418 | .group_c = 0, | ||
419 | .group_d = 0, | ||
420 | .group_e = 0x0f, | ||
421 | .group_f = 0x2c, | ||
422 | |||
228 | .gpio_g_in = 0x00000000, | 423 | .gpio_g_in = 0x00000000, |
229 | .gpio_g_out = 0x00000000, | 424 | .gpio_g_out = 0x00000000, |
230 | .gpio_b = 0x2c | 425 | .gpio_b = 0x2c |
231 | }, | 426 | }, |
232 | { | 427 | { |
233 | .ioif = if_usb_2, | 428 | .ioif = if_usb_2, |
429 | .name = "usb_2", | ||
234 | .groups = group_d, | 430 | .groups = group_d, |
235 | .gpio_g_in = 0x0e000000, | 431 | |
236 | .gpio_g_out = 0x3c000000, | 432 | .group_a = 0, |
433 | .group_b = 0, | ||
434 | .group_c = 0, | ||
435 | .group_d = 0, | ||
436 | .group_e = 0x33e00, | ||
437 | .group_f = 0, | ||
438 | |||
439 | .gpio_g_in = 0x3e000000, | ||
440 | .gpio_g_out = 0x0c000000, | ||
237 | .gpio_b = 0x00 | 441 | .gpio_b = 0x00 |
238 | }, | 442 | }, |
239 | /* GPIO pins */ | 443 | /* GPIO pins */ |
240 | { | 444 | { |
241 | .ioif = if_gpio_grp_a, | 445 | .ioif = if_gpio_grp_a, |
446 | .name = "gpio_a", | ||
242 | .groups = group_a, | 447 | .groups = group_a, |
448 | |||
449 | .group_a = 0, | ||
450 | .group_b = 0, | ||
451 | .group_c = 0, | ||
452 | .group_d = 0, | ||
453 | .group_e = 0, | ||
454 | .group_f = 0, | ||
455 | |||
243 | .gpio_g_in = 0x0000ff3f, | 456 | .gpio_g_in = 0x0000ff3f, |
244 | .gpio_g_out = 0x0000ff3f, | 457 | .gpio_g_out = 0x0000ff3f, |
245 | .gpio_b = 0x00 | 458 | .gpio_b = 0x00 |
246 | }, | 459 | }, |
247 | { | 460 | { |
248 | .ioif = if_gpio_grp_b, | 461 | .ioif = if_gpio_grp_b, |
462 | .name = "gpio_b", | ||
249 | .groups = group_b, | 463 | .groups = group_b, |
464 | |||
465 | .group_a = 0, | ||
466 | .group_b = 0, | ||
467 | .group_c = 0, | ||
468 | .group_d = 0, | ||
469 | .group_e = 0, | ||
470 | .group_f = 0, | ||
471 | |||
250 | .gpio_g_in = 0x000000c0, | 472 | .gpio_g_in = 0x000000c0, |
251 | .gpio_g_out = 0x000000c0, | 473 | .gpio_g_out = 0x000000c0, |
252 | .gpio_b = 0x00 | 474 | .gpio_b = 0x00 |
253 | }, | 475 | }, |
254 | { | 476 | { |
255 | .ioif = if_gpio_grp_c, | 477 | .ioif = if_gpio_grp_c, |
478 | .name = "gpio_c", | ||
256 | .groups = group_c, | 479 | .groups = group_c, |
480 | |||
481 | .group_a = 0, | ||
482 | .group_b = 0, | ||
483 | .group_c = 0, | ||
484 | .group_d = 0, | ||
485 | .group_e = 0, | ||
486 | .group_f = 0, | ||
487 | |||
257 | .gpio_g_in = 0xc0000000, | 488 | .gpio_g_in = 0xc0000000, |
258 | .gpio_g_out = 0xc0000000, | 489 | .gpio_g_out = 0xc0000000, |
259 | .gpio_b = 0x00 | 490 | .gpio_b = 0x00 |
260 | }, | 491 | }, |
261 | { | 492 | { |
262 | .ioif = if_gpio_grp_d, | 493 | .ioif = if_gpio_grp_d, |
494 | .name = "gpio_d", | ||
263 | .groups = group_d, | 495 | .groups = group_d, |
496 | |||
497 | .group_a = 0, | ||
498 | .group_b = 0, | ||
499 | .group_c = 0, | ||
500 | .group_d = 0, | ||
501 | .group_e = 0, | ||
502 | .group_f = 0, | ||
503 | |||
264 | .gpio_g_in = 0x3fff0000, | 504 | .gpio_g_in = 0x3fff0000, |
265 | .gpio_g_out = 0x3fff0000, | 505 | .gpio_g_out = 0x3fff0000, |
266 | .gpio_b = 0x00 | 506 | .gpio_b = 0x00 |
267 | }, | 507 | }, |
268 | { | 508 | { |
269 | .ioif = if_gpio_grp_e, | 509 | .ioif = if_gpio_grp_e, |
510 | .name = "gpio_e", | ||
270 | .groups = group_e, | 511 | .groups = group_e, |
512 | |||
513 | .group_a = 0, | ||
514 | .group_b = 0, | ||
515 | .group_c = 0, | ||
516 | .group_d = 0, | ||
517 | .group_e = 0, | ||
518 | .group_f = 0, | ||
519 | |||
271 | .gpio_g_in = 0x00000000, | 520 | .gpio_g_in = 0x00000000, |
272 | .gpio_g_out = 0x00000000, | 521 | .gpio_g_out = 0x00000000, |
273 | .gpio_b = 0x00 | 522 | .gpio_b = 0x00 |
274 | }, | 523 | }, |
275 | { | 524 | { |
276 | .ioif = if_gpio_grp_f, | 525 | .ioif = if_gpio_grp_f, |
526 | .name = "gpio_f", | ||
277 | .groups = group_f, | 527 | .groups = group_f, |
528 | |||
529 | .group_a = 0, | ||
530 | .group_b = 0, | ||
531 | .group_c = 0, | ||
532 | .group_d = 0, | ||
533 | .group_e = 0, | ||
534 | .group_f = 0, | ||
535 | |||
278 | .gpio_g_in = 0x00000000, | 536 | .gpio_g_in = 0x00000000, |
279 | .gpio_g_out = 0x00000000, | 537 | .gpio_g_out = 0x00000000, |
280 | .gpio_b = 0xff | 538 | .gpio_b = 0xff |
@@ -284,11 +542,13 @@ static struct interface interfaces[] = { | |||
284 | 542 | ||
285 | static struct watcher *watchers = NULL; | 543 | static struct watcher *watchers = NULL; |
286 | 544 | ||
545 | /* The pins that are free to use in the GPIO ports. */ | ||
287 | static unsigned int gpio_in_pins = 0xffffffff; | 546 | static unsigned int gpio_in_pins = 0xffffffff; |
288 | static unsigned int gpio_out_pins = 0xffffffff; | 547 | static unsigned int gpio_out_pins = 0xffffffff; |
289 | static unsigned char gpio_pb_pins = 0xff; | 548 | static unsigned char gpio_pb_pins = 0xff; |
290 | static unsigned char gpio_pa_pins = 0xff; | 549 | static unsigned char gpio_pa_pins = 0xff; |
291 | 550 | ||
551 | /* Identifiers for the owners of the GPIO pins. */ | ||
292 | static enum cris_io_interface gpio_pa_owners[8]; | 552 | static enum cris_io_interface gpio_pa_owners[8]; |
293 | static enum cris_io_interface gpio_pb_owners[8]; | 553 | static enum cris_io_interface gpio_pb_owners[8]; |
294 | static enum cris_io_interface gpio_pg_owners[32]; | 554 | static enum cris_io_interface gpio_pg_owners[32]; |
@@ -338,13 +598,15 @@ int cris_request_io_interface(enum cris_io_interface ioif, const char *device_id | |||
338 | struct if_group *grp; | 598 | struct if_group *grp; |
339 | unsigned char group_set; | 599 | unsigned char group_set; |
340 | unsigned long flags; | 600 | unsigned long flags; |
601 | int res = 0; | ||
341 | 602 | ||
342 | (void)cris_io_interface_init(); | 603 | (void)cris_io_interface_init(); |
343 | 604 | ||
344 | DBG(printk("cris_request_io_interface(%d, \"%s\")\n", ioif, device_id)); | 605 | DBG(printk("cris_request_io_interface(%d, \"%s\")\n", ioif, device_id)); |
345 | 606 | ||
346 | if ((ioif >= if_max_interfaces) || (ioif < 0)) { | 607 | if ((ioif >= if_max_interfaces) || (ioif < 0)) { |
347 | printk(KERN_CRIT "cris_request_io_interface: Bad interface %u submitted for %s\n", | 608 | printk(KERN_CRIT "cris_request_io_interface: Bad interface " |
609 | "%u submitted for %s\n", | ||
348 | ioif, | 610 | ioif, |
349 | device_id); | 611 | device_id); |
350 | return -EINVAL; | 612 | return -EINVAL; |
@@ -353,59 +615,69 @@ int cris_request_io_interface(enum cris_io_interface ioif, const char *device_id | |||
353 | local_irq_save(flags); | 615 | local_irq_save(flags); |
354 | 616 | ||
355 | if (interfaces[ioif].used) { | 617 | if (interfaces[ioif].used) { |
356 | local_irq_restore(flags); | 618 | printk(KERN_CRIT "cris_io_interface: Cannot allocate interface " |
357 | printk(KERN_CRIT "cris_io_interface: Cannot allocate interface for %s, in use by %s\n", | 619 | "%s for %s, in use by %s\n", |
620 | interfaces[ioif].name, | ||
358 | device_id, | 621 | device_id, |
359 | interfaces[ioif].owner); | 622 | interfaces[ioif].owner); |
360 | return -EBUSY; | 623 | res = -EBUSY; |
624 | goto exit; | ||
361 | } | 625 | } |
362 | 626 | ||
363 | /* Check that all required groups are free before allocating, */ | 627 | /* Check that all required pins in the used groups are free |
628 | * before allocating. */ | ||
364 | group_set = interfaces[ioif].groups; | 629 | group_set = interfaces[ioif].groups; |
365 | while (NULL != (grp = get_group(group_set))) { | 630 | while (NULL != (grp = get_group(group_set))) { |
366 | if (grp->used) { | 631 | unsigned int if_group_use = 0; |
367 | if (grp->group == group_f) { | 632 | |
368 | if ((if_sync_serial_1 == ioif) || | 633 | switch (grp->group) { |
369 | (if_sync_serial_3 == ioif)) { | 634 | case group_a: |
370 | if ((grp->owner != if_sync_serial_1) && | 635 | if_group_use = interfaces[ioif].group_a; |
371 | (grp->owner != if_sync_serial_3)) { | 636 | break; |
372 | local_irq_restore(flags); | 637 | case group_b: |
373 | return -EBUSY; | 638 | if_group_use = interfaces[ioif].group_b; |
374 | } | 639 | break; |
375 | } else if ((if_scsi8_0 == ioif) || | 640 | case group_c: |
376 | (if_scsi8_1 == ioif)) { | 641 | if_group_use = interfaces[ioif].group_c; |
377 | if ((grp->owner != if_scsi8_0) && | 642 | break; |
378 | (grp->owner != if_scsi8_1)) { | 643 | case group_d: |
379 | local_irq_restore(flags); | 644 | if_group_use = interfaces[ioif].group_d; |
380 | return -EBUSY; | 645 | break; |
381 | } | 646 | case group_e: |
382 | } | 647 | if_group_use = interfaces[ioif].group_e; |
383 | } else { | 648 | break; |
384 | local_irq_restore(flags); | 649 | case group_f: |
385 | return -EBUSY; | 650 | if_group_use = interfaces[ioif].group_f; |
386 | } | 651 | break; |
652 | default: | ||
653 | BUG_ON(1); | ||
387 | } | 654 | } |
655 | |||
656 | if (if_group_use & grp->used) { | ||
657 | printk(KERN_INFO "cris_request_io_interface: group " | ||
658 | "%s needed by %s not available\n", | ||
659 | grp->name, interfaces[ioif].name); | ||
660 | res = -EBUSY; | ||
661 | goto exit; | ||
662 | } | ||
663 | |||
388 | group_set = clear_group_from_set(group_set, grp); | 664 | group_set = clear_group_from_set(group_set, grp); |
389 | } | 665 | } |
390 | 666 | ||
391 | /* Are the required GPIO pins available too? */ | 667 | /* Are the required GPIO pins available too? */ |
392 | if (((interfaces[ioif].gpio_g_in & gpio_in_pins) != interfaces[ioif].gpio_g_in) || | 668 | if (((interfaces[ioif].gpio_g_in & gpio_in_pins) != |
393 | ((interfaces[ioif].gpio_g_out & gpio_out_pins) != interfaces[ioif].gpio_g_out) || | 669 | interfaces[ioif].gpio_g_in) || |
394 | ((interfaces[ioif].gpio_b & gpio_pb_pins) != interfaces[ioif].gpio_b)) { | 670 | ((interfaces[ioif].gpio_g_out & gpio_out_pins) != |
395 | local_irq_restore(flags); | 671 | interfaces[ioif].gpio_g_out) || |
396 | printk(KERN_CRIT "cris_request_io_interface: Could not get required pins for interface %u\n", | 672 | ((interfaces[ioif].gpio_b & gpio_pb_pins) != |
397 | ioif); | 673 | interfaces[ioif].gpio_b)) { |
398 | return -EBUSY; | 674 | printk(KERN_CRIT "cris_request_io_interface: Could not get " |
399 | } | 675 | "required pins for interface %u\n", ioif); |
400 | 676 | res = -EBUSY; | |
401 | /* All needed I/O pins and pin groups are free, allocate. */ | 677 | goto exit; |
402 | group_set = interfaces[ioif].groups; | ||
403 | while (NULL != (grp = get_group(group_set))) { | ||
404 | grp->used = 1; | ||
405 | grp->owner = ioif; | ||
406 | group_set = clear_group_from_set(group_set, grp); | ||
407 | } | 678 | } |
408 | 679 | ||
680 | /* Check which registers need to be reconfigured. */ | ||
409 | gens = genconfig_shadow; | 681 | gens = genconfig_shadow; |
410 | gens_ii = gen_config_ii_shadow; | 682 | gens_ii = gen_config_ii_shadow; |
411 | 683 | ||
@@ -495,9 +767,43 @@ int cris_request_io_interface(enum cris_io_interface ioif, const char *device_id | |||
495 | set_gen_config = 0; | 767 | set_gen_config = 0; |
496 | break; | 768 | break; |
497 | default: | 769 | default: |
498 | panic("cris_request_io_interface: Bad interface %u submitted for %s\n", | 770 | printk(KERN_INFO "cris_request_io_interface: Bad interface " |
499 | ioif, | 771 | "%u submitted for %s\n", |
500 | device_id); | 772 | ioif, device_id); |
773 | res = -EBUSY; | ||
774 | goto exit; | ||
775 | } | ||
776 | |||
777 | /* All needed I/O pins and pin groups are free, allocate. */ | ||
778 | group_set = interfaces[ioif].groups; | ||
779 | while (NULL != (grp = get_group(group_set))) { | ||
780 | unsigned int if_group_use = 0; | ||
781 | |||
782 | switch (grp->group) { | ||
783 | case group_a: | ||
784 | if_group_use = interfaces[ioif].group_a; | ||
785 | break; | ||
786 | case group_b: | ||
787 | if_group_use = interfaces[ioif].group_b; | ||
788 | break; | ||
789 | case group_c: | ||
790 | if_group_use = interfaces[ioif].group_c; | ||
791 | break; | ||
792 | case group_d: | ||
793 | if_group_use = interfaces[ioif].group_d; | ||
794 | break; | ||
795 | case group_e: | ||
796 | if_group_use = interfaces[ioif].group_e; | ||
797 | break; | ||
798 | case group_f: | ||
799 | if_group_use = interfaces[ioif].group_f; | ||
800 | break; | ||
801 | default: | ||
802 | BUG_ON(1); | ||
803 | } | ||
804 | grp->used |= if_group_use; | ||
805 | |||
806 | group_set = clear_group_from_set(group_set, grp); | ||
501 | } | 807 | } |
502 | 808 | ||
503 | interfaces[ioif].used = 1; | 809 | interfaces[ioif].used = 1; |
@@ -516,25 +822,28 @@ int cris_request_io_interface(enum cris_io_interface ioif, const char *device_id | |||
516 | *R_GEN_CONFIG_II = gen_config_ii_shadow; | 822 | *R_GEN_CONFIG_II = gen_config_ii_shadow; |
517 | } | 823 | } |
518 | 824 | ||
519 | DBG(printk("GPIO pins: available before: g_in=0x%08x g_out=0x%08x pb=0x%02x\n", | 825 | DBG(printk(KERN_DEBUG "GPIO pins: available before: " |
520 | gpio_in_pins, gpio_out_pins, gpio_pb_pins)); | 826 | "g_in=0x%08x g_out=0x%08x pb=0x%02x\n", |
521 | DBG(printk("grabbing pins: g_in=0x%08x g_out=0x%08x pb=0x%02x\n", | 827 | gpio_in_pins, gpio_out_pins, gpio_pb_pins)); |
522 | interfaces[ioif].gpio_g_in, | 828 | DBG(printk(KERN_DEBUG |
523 | interfaces[ioif].gpio_g_out, | 829 | "grabbing pins: g_in=0x%08x g_out=0x%08x pb=0x%02x\n", |
524 | interfaces[ioif].gpio_b)); | 830 | interfaces[ioif].gpio_g_in, |
831 | interfaces[ioif].gpio_g_out, | ||
832 | interfaces[ioif].gpio_b)); | ||
525 | 833 | ||
526 | gpio_in_pins &= ~interfaces[ioif].gpio_g_in; | 834 | gpio_in_pins &= ~interfaces[ioif].gpio_g_in; |
527 | gpio_out_pins &= ~interfaces[ioif].gpio_g_out; | 835 | gpio_out_pins &= ~interfaces[ioif].gpio_g_out; |
528 | gpio_pb_pins &= ~interfaces[ioif].gpio_b; | 836 | gpio_pb_pins &= ~interfaces[ioif].gpio_b; |
529 | 837 | ||
530 | DBG(printk("GPIO pins: available after: g_in=0x%08x g_out=0x%08x pb=0x%02x\n", | 838 | DBG(printk(KERN_DEBUG "GPIO pins: available after: " |
531 | gpio_in_pins, gpio_out_pins, gpio_pb_pins)); | 839 | "g_in=0x%08x g_out=0x%08x pb=0x%02x\n", |
840 | gpio_in_pins, gpio_out_pins, gpio_pb_pins)); | ||
532 | 841 | ||
842 | exit: | ||
533 | local_irq_restore(flags); | 843 | local_irq_restore(flags); |
534 | 844 | if (res == 0) | |
535 | notify_watchers(); | 845 | notify_watchers(); |
536 | 846 | return res; | |
537 | return 0; | ||
538 | } | 847 | } |
539 | 848 | ||
540 | 849 | ||
@@ -560,43 +869,35 @@ void cris_free_io_interface(enum cris_io_interface ioif) | |||
560 | } | 869 | } |
561 | group_set = interfaces[ioif].groups; | 870 | group_set = interfaces[ioif].groups; |
562 | while (NULL != (grp = get_group(group_set))) { | 871 | while (NULL != (grp = get_group(group_set))) { |
563 | if (grp->group == group_f) { | 872 | unsigned int if_group_use = 0; |
564 | switch (ioif) | 873 | |
565 | { | 874 | switch (grp->group) { |
566 | case if_sync_serial_1: | 875 | case group_a: |
567 | if ((grp->owner == if_sync_serial_1) && | 876 | if_group_use = interfaces[ioif].group_a; |
568 | interfaces[if_sync_serial_3].used) { | 877 | break; |
569 | grp->owner = if_sync_serial_3; | 878 | case group_b: |
570 | } else | 879 | if_group_use = interfaces[ioif].group_b; |
571 | grp->used = 0; | 880 | break; |
572 | break; | 881 | case group_c: |
573 | case if_sync_serial_3: | 882 | if_group_use = interfaces[ioif].group_c; |
574 | if ((grp->owner == if_sync_serial_3) && | 883 | break; |
575 | interfaces[if_sync_serial_1].used) { | 884 | case group_d: |
576 | grp->owner = if_sync_serial_1; | 885 | if_group_use = interfaces[ioif].group_d; |
577 | } else | 886 | break; |
578 | grp->used = 0; | 887 | case group_e: |
579 | break; | 888 | if_group_use = interfaces[ioif].group_e; |
580 | case if_scsi8_0: | 889 | break; |
581 | if ((grp->owner == if_scsi8_0) && | 890 | case group_f: |
582 | interfaces[if_scsi8_1].used) { | 891 | if_group_use = interfaces[ioif].group_f; |
583 | grp->owner = if_scsi8_1; | 892 | break; |
584 | } else | 893 | default: |
585 | grp->used = 0; | 894 | BUG_ON(1); |
586 | break; | ||
587 | case if_scsi8_1: | ||
588 | if ((grp->owner == if_scsi8_1) && | ||
589 | interfaces[if_scsi8_0].used) { | ||
590 | grp->owner = if_scsi8_0; | ||
591 | } else | ||
592 | grp->used = 0; | ||
593 | break; | ||
594 | default: | ||
595 | grp->used = 0; | ||
596 | } | ||
597 | } else { | ||
598 | grp->used = 0; | ||
599 | } | 895 | } |
896 | |||
897 | if ((grp->used & if_group_use) != if_group_use) | ||
898 | BUG_ON(1); | ||
899 | grp->used = grp->used & ~if_group_use; | ||
900 | |||
600 | group_set = clear_group_from_set(group_set, grp); | 901 | group_set = clear_group_from_set(group_set, grp); |
601 | } | 902 | } |
602 | interfaces[ioif].used = 0; | 903 | interfaces[ioif].used = 0; |
diff --git a/arch/cris/arch-v10/kernel/irq.c b/arch/cris/arch-v10/kernel/irq.c index e06ab0050d37..65ed803dae6f 100644 --- a/arch/cris/arch-v10/kernel/irq.c +++ b/arch/cris/arch-v10/kernel/irq.c | |||
@@ -1,5 +1,4 @@ | |||
1 | /* $Id: irq.c,v 1.4 2005/01/04 12:22:28 starvik Exp $ | 1 | /* |
2 | * | ||
3 | * linux/arch/cris/kernel/irq.c | 2 | * linux/arch/cris/kernel/irq.c |
4 | * | 3 | * |
5 | * Copyright (c) 2000-2002 Axis Communications AB | 4 | * Copyright (c) 2000-2002 Axis Communications AB |
@@ -18,10 +17,6 @@ | |||
18 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
19 | #include <linux/init.h> | 18 | #include <linux/init.h> |
20 | 19 | ||
21 | /* From kgdb.c. */ | ||
22 | extern void kgdb_init(void); | ||
23 | extern void breakpoint(void); | ||
24 | |||
25 | #define mask_irq(irq_nr) (*R_VECT_MASK_CLR = 1 << (irq_nr)); | 20 | #define mask_irq(irq_nr) (*R_VECT_MASK_CLR = 1 << (irq_nr)); |
26 | #define unmask_irq(irq_nr) (*R_VECT_MASK_SET = 1 << (irq_nr)); | 21 | #define unmask_irq(irq_nr) (*R_VECT_MASK_SET = 1 << (irq_nr)); |
27 | 22 | ||
diff --git a/arch/cris/arch-v10/kernel/kgdb.c b/arch/cris/arch-v10/kernel/kgdb.c index 77f4b1423725..a3ca55150745 100644 --- a/arch/cris/arch-v10/kernel/kgdb.c +++ b/arch/cris/arch-v10/kernel/kgdb.c | |||
@@ -17,66 +17,8 @@ | |||
17 | *! Jun 17 1999 Hendrik Ruijter Added gdb 4.18 support. 'X', 'qC' and 'qL'. | 17 | *! Jun 17 1999 Hendrik Ruijter Added gdb 4.18 support. 'X', 'qC' and 'qL'. |
18 | *! Jul 21 1999 Bjorn Wesen eLinux port | 18 | *! Jul 21 1999 Bjorn Wesen eLinux port |
19 | *! | 19 | *! |
20 | *! $Log: kgdb.c,v $ | ||
21 | *! Revision 1.6 2005/01/14 10:12:17 starvik | ||
22 | *! KGDB on separate port. | ||
23 | *! Console fixes from 2.4. | ||
24 | *! | ||
25 | *! Revision 1.5 2004/10/07 13:59:08 starvik | ||
26 | *! Corrected call to set_int_vector | ||
27 | *! | ||
28 | *! Revision 1.4 2003/04/09 05:20:44 starvik | ||
29 | *! Merge of Linux 2.5.67 | ||
30 | *! | ||
31 | *! Revision 1.3 2003/01/21 19:11:08 starvik | ||
32 | *! Modified include path for new dir layout | ||
33 | *! | ||
34 | *! Revision 1.2 2002/11/19 14:35:24 starvik | ||
35 | *! Changes from linux 2.4 | ||
36 | *! Changed struct initializer syntax to the currently preferred notation | ||
37 | *! | ||
38 | *! Revision 1.1 2001/12/17 13:59:27 bjornw | ||
39 | *! Initial revision | ||
40 | *! | ||
41 | *! Revision 1.6 2001/10/09 13:10:03 matsfg | ||
42 | *! Added $ on registers and removed some underscores | ||
43 | *! | ||
44 | *! Revision 1.5 2001/04/17 13:58:39 orjanf | ||
45 | *! * Renamed CONFIG_KGDB to CONFIG_ETRAX_KGDB. | ||
46 | *! | ||
47 | *! Revision 1.4 2001/02/23 13:45:19 bjornw | ||
48 | *! config.h check | ||
49 | *! | ||
50 | *! Revision 1.3 2001/01/31 18:08:23 orjanf | ||
51 | *! Removed kgdb_handle_breakpoint from being the break 8 handler. | ||
52 | *! | ||
53 | *! Revision 1.2 2001/01/12 14:22:25 orjanf | ||
54 | *! Updated kernel debugging support to work with ETRAX 100LX. | ||
55 | *! | ||
56 | *! Revision 1.1 2000/07/10 16:25:21 bjornw | ||
57 | *! Initial revision | ||
58 | *! | ||
59 | *! Revision 1.1.1.1 1999/12/03 14:57:31 bjornw | ||
60 | *! * Initial version of arch/cris, the latest CRIS architecture with an MMU. | ||
61 | *! Mostly copied from arch/etrax100 with appropriate renames of files. | ||
62 | *! The mm/ subdir is copied from arch/i386. | ||
63 | *! This does not compile yet at all. | ||
64 | *! | ||
65 | *! | ||
66 | *! Revision 1.4 1999/07/22 17:25:25 bjornw | ||
67 | *! Dont wait for + in putpacket if we havent hit the initial breakpoint yet. Added a kgdb_init function which sets up the break and irq vectors. | ||
68 | *! | ||
69 | *! Revision 1.3 1999/07/21 19:51:18 bjornw | ||
70 | *! Check if the interrupting char is a ctrl-C, ignore otherwise. | ||
71 | *! | ||
72 | *! Revision 1.2 1999/07/21 18:09:39 bjornw | ||
73 | *! Ported to eLinux architecture, and added some kgdb documentation. | ||
74 | *! | ||
75 | *! | ||
76 | *!--------------------------------------------------------------------------- | 20 | *!--------------------------------------------------------------------------- |
77 | *! | 21 | *! |
78 | *! $Id: kgdb.c,v 1.6 2005/01/14 10:12:17 starvik Exp $ | ||
79 | *! | ||
80 | *! (C) Copyright 1999, Axis Communications AB, LUND, SWEDEN | 22 | *! (C) Copyright 1999, Axis Communications AB, LUND, SWEDEN |
81 | *! | 23 | *! |
82 | *!**************************************************************************/ | 24 | *!**************************************************************************/ |
diff --git a/arch/cris/arch-v10/kernel/process.c b/arch/cris/arch-v10/kernel/process.c index 1a3760c94f85..53117f07cc1a 100644 --- a/arch/cris/arch-v10/kernel/process.c +++ b/arch/cris/arch-v10/kernel/process.c | |||
@@ -1,5 +1,4 @@ | |||
1 | /* $Id: process.c,v 1.12 2004/12/27 11:18:32 starvik Exp $ | 1 | /* |
2 | * | ||
3 | * linux/arch/cris/kernel/process.c | 2 | * linux/arch/cris/kernel/process.c |
4 | * | 3 | * |
5 | * Copyright (C) 1995 Linus Torvalds | 4 | * Copyright (C) 1995 Linus Torvalds |
diff --git a/arch/cris/arch-v10/kernel/ptrace.c b/arch/cris/arch-v10/kernel/ptrace.c index b570ae9b6cad..ee505b2eb4db 100644 --- a/arch/cris/arch-v10/kernel/ptrace.c +++ b/arch/cris/arch-v10/kernel/ptrace.c | |||
@@ -65,6 +65,7 @@ void | |||
65 | ptrace_disable(struct task_struct *child) | 65 | ptrace_disable(struct task_struct *child) |
66 | { | 66 | { |
67 | /* Todo - pending singlesteps? */ | 67 | /* Todo - pending singlesteps? */ |
68 | clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); | ||
68 | } | 69 | } |
69 | 70 | ||
70 | /* | 71 | /* |
diff --git a/arch/cris/arch-v10/kernel/shadows.c b/arch/cris/arch-v10/kernel/shadows.c index 326178aef6ee..2454a0b02f54 100644 --- a/arch/cris/arch-v10/kernel/shadows.c +++ b/arch/cris/arch-v10/kernel/shadows.c | |||
@@ -1,5 +1,4 @@ | |||
1 | /* $Id: shadows.c,v 1.2 2004/12/13 12:21:51 starvik Exp $ | 1 | /* |
2 | * | ||
3 | * Various shadow registers. Defines for these are in include/asm-etrax100/io.h | 2 | * Various shadow registers. Defines for these are in include/asm-etrax100/io.h |
4 | */ | 3 | */ |
5 | 4 | ||
diff --git a/arch/cris/arch-v10/kernel/traps.c b/arch/cris/arch-v10/kernel/traps.c index 4becc1bcced9..9eada5d8893b 100644 --- a/arch/cris/arch-v10/kernel/traps.c +++ b/arch/cris/arch-v10/kernel/traps.c | |||
@@ -1,13 +1,10 @@ | |||
1 | /* $Id: traps.c,v 1.4 2005/04/24 18:47:55 starvik Exp $ | 1 | /* |
2 | * Helper functions for trap handlers | ||
2 | * | 3 | * |
3 | * linux/arch/cris/arch-v10/traps.c | 4 | * Copyright (C) 2000-2007, Axis Communications AB. |
4 | * | 5 | * |
5 | * Heler functions for trap handlers | 6 | * Authors: Bjorn Wesen |
6 | * | 7 | * Hans-Peter Nilsson |
7 | * Copyright (C) 2000-2002 Axis Communications AB | ||
8 | * | ||
9 | * Authors: Bjorn Wesen | ||
10 | * Hans-Peter Nilsson | ||
11 | * | 8 | * |
12 | */ | 9 | */ |
13 | 10 | ||
@@ -15,124 +12,119 @@ | |||
15 | #include <asm/uaccess.h> | 12 | #include <asm/uaccess.h> |
16 | #include <asm/arch/sv_addr_ag.h> | 13 | #include <asm/arch/sv_addr_ag.h> |
17 | 14 | ||
18 | extern int raw_printk(const char *fmt, ...); | 15 | void |
19 | 16 | show_registers(struct pt_regs *regs) | |
20 | void | ||
21 | show_registers(struct pt_regs * regs) | ||
22 | { | 17 | { |
23 | /* We either use rdusp() - the USP register, which might not | 18 | /* |
24 | correspond to the current process for all cases we're called, | 19 | * It's possible to use either the USP register or current->thread.usp. |
25 | or we use the current->thread.usp, which is not up to date for | 20 | * USP might not correspond to the current process for all cases this |
26 | the current process. Experience shows we want the USP | 21 | * function is called, and current->thread.usp isn't up to date for the |
27 | register. */ | 22 | * current process. Experience shows that using USP is the way to go. |
23 | */ | ||
28 | unsigned long usp = rdusp(); | 24 | unsigned long usp = rdusp(); |
29 | 25 | ||
30 | raw_printk("IRP: %08lx SRP: %08lx DCCR: %08lx USP: %08lx MOF: %08lx\n", | 26 | printk("IRP: %08lx SRP: %08lx DCCR: %08lx USP: %08lx MOF: %08lx\n", |
31 | regs->irp, regs->srp, regs->dccr, usp, regs->mof ); | 27 | regs->irp, regs->srp, regs->dccr, usp, regs->mof); |
32 | raw_printk(" r0: %08lx r1: %08lx r2: %08lx r3: %08lx\n", | 28 | |
29 | printk(" r0: %08lx r1: %08lx r2: %08lx r3: %08lx\n", | ||
33 | regs->r0, regs->r1, regs->r2, regs->r3); | 30 | regs->r0, regs->r1, regs->r2, regs->r3); |
34 | raw_printk(" r4: %08lx r5: %08lx r6: %08lx r7: %08lx\n", | 31 | |
32 | printk(" r4: %08lx r5: %08lx r6: %08lx r7: %08lx\n", | ||
35 | regs->r4, regs->r5, regs->r6, regs->r7); | 33 | regs->r4, regs->r5, regs->r6, regs->r7); |
36 | raw_printk(" r8: %08lx r9: %08lx r10: %08lx r11: %08lx\n", | 34 | |
35 | printk(" r8: %08lx r9: %08lx r10: %08lx r11: %08lx\n", | ||
37 | regs->r8, regs->r9, regs->r10, regs->r11); | 36 | regs->r8, regs->r9, regs->r10, regs->r11); |
38 | raw_printk("r12: %08lx r13: %08lx oR10: %08lx sp: %08lx\n", | 37 | |
39 | regs->r12, regs->r13, regs->orig_r10, regs); | 38 | printk("r12: %08lx r13: %08lx oR10: %08lx sp: %08lx\n", |
40 | raw_printk("R_MMU_CAUSE: %08lx\n", (unsigned long)*R_MMU_CAUSE); | 39 | regs->r12, regs->r13, regs->orig_r10, (long unsigned)regs); |
41 | raw_printk("Process %s (pid: %d, stackpage=%08lx)\n", | 40 | |
41 | printk("R_MMU_CAUSE: %08lx\n", (unsigned long)*R_MMU_CAUSE); | ||
42 | |||
43 | printk("Process %s (pid: %d, stackpage=%08lx)\n", | ||
42 | current->comm, current->pid, (unsigned long)current); | 44 | current->comm, current->pid, (unsigned long)current); |
43 | 45 | ||
44 | /* | 46 | /* |
45 | * When in-kernel, we also print out the stack and code at the | 47 | * When in-kernel, we also print out the stack and code at the |
46 | * time of the fault.. | 48 | * time of the fault.. |
47 | */ | 49 | */ |
48 | if (! user_mode(regs)) { | 50 | if (!user_mode(regs)) { |
49 | int i; | 51 | int i; |
50 | 52 | ||
51 | show_stack(NULL, (unsigned long*)usp); | 53 | show_stack(NULL, (unsigned long *)usp); |
52 | 54 | ||
53 | /* Dump kernel stack if the previous dump wasn't one. */ | 55 | /* |
56 | * If the previous stack-dump wasn't a kernel one, dump the | ||
57 | * kernel stack now. | ||
58 | */ | ||
54 | if (usp != 0) | 59 | if (usp != 0) |
55 | show_stack (NULL, NULL); | 60 | show_stack(NULL, NULL); |
56 | 61 | ||
57 | raw_printk("\nCode: "); | 62 | printk("\nCode: "); |
58 | if(regs->irp < PAGE_OFFSET) | 63 | |
59 | goto bad; | 64 | if (regs->irp < PAGE_OFFSET) |
60 | 65 | goto bad_value; | |
61 | /* Often enough the value at regs->irp does not point to | 66 | |
62 | the interesting instruction, which is most often the | 67 | /* |
63 | _previous_ instruction. So we dump at an offset large | 68 | * Quite often the value at regs->irp doesn't point to the |
64 | enough that instruction decoding should be in sync at | 69 | * interesting instruction, which often is the previous |
65 | the interesting point, but small enough to fit on a row | 70 | * instruction. So dump at an offset large enough that the |
66 | (sort of). We point out the regs->irp location in a | 71 | * instruction decoding should be in sync at the interesting |
67 | ksymoops-friendly way by wrapping the byte for that | 72 | * point, but small enough to fit on a row. The regs->irp |
68 | address in parentheses. */ | 73 | * location is pointed out in a ksymoops-friendly way by |
69 | for(i = -12; i < 12; i++) | 74 | * wrapping the byte for that address in parenthesises. |
70 | { | 75 | */ |
71 | unsigned char c; | 76 | for (i = -12; i < 12; i++) { |
72 | if(__get_user(c, &((unsigned char*)regs->irp)[i])) { | 77 | unsigned char c; |
73 | bad: | 78 | |
74 | raw_printk(" Bad IP value."); | 79 | if (__get_user(c, &((unsigned char *)regs->irp)[i])) { |
75 | break; | 80 | bad_value: |
76 | } | 81 | printk(" Bad IP value."); |
82 | break; | ||
83 | } | ||
77 | 84 | ||
78 | if (i == 0) | 85 | if (i == 0) |
79 | raw_printk("(%02x) ", c); | 86 | printk("(%02x) ", c); |
80 | else | 87 | else |
81 | raw_printk("%02x ", c); | 88 | printk("%02x ", c); |
82 | } | 89 | } |
83 | raw_printk("\n"); | 90 | printk("\n"); |
84 | } | 91 | } |
85 | } | 92 | } |
86 | 93 | ||
87 | /* Called from entry.S when the watchdog has bitten | ||
88 | * We print out something resembling an oops dump, and if | ||
89 | * we have the nice doggy development flag set, we halt here | ||
90 | * instead of rebooting. | ||
91 | */ | ||
92 | |||
93 | extern void reset_watchdog(void); | ||
94 | extern void stop_watchdog(void); | ||
95 | |||
96 | |||
97 | void | 94 | void |
98 | watchdog_bite_hook(struct pt_regs *regs) | 95 | arch_enable_nmi(void) |
99 | { | 96 | { |
100 | #ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY | 97 | asm volatile ("setf m"); |
101 | local_irq_disable(); | ||
102 | stop_watchdog(); | ||
103 | show_registers(regs); | ||
104 | while(1) /* nothing */; | ||
105 | #else | ||
106 | show_registers(regs); | ||
107 | #endif | ||
108 | } | 98 | } |
109 | 99 | ||
110 | /* This is normally the 'Oops' routine */ | 100 | extern void (*nmi_handler)(struct pt_regs *); |
111 | void | 101 | void handle_nmi(struct pt_regs *regs) |
112 | die_if_kernel(const char * str, struct pt_regs * regs, long err) | ||
113 | { | 102 | { |
114 | if(user_mode(regs)) | 103 | if (nmi_handler) |
115 | return; | 104 | nmi_handler(regs); |
116 | 105 | ||
117 | #ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY | 106 | /* Wait until nmi is no longer active. (We enable NMI immediately after |
118 | /* This printout might take too long and trigger the | 107 | returning from this function, and we don't want it happening while |
119 | * watchdog normally. If we're in the nice doggy | 108 | exiting from the NMI interrupt handler.) */ |
120 | * development mode, stop the watchdog during printout. | 109 | while (*R_IRQ_MASK0_RD & IO_STATE(R_IRQ_MASK0_RD, nmi_pin, active)) |
121 | */ | 110 | ; |
122 | stop_watchdog(); | ||
123 | #endif | ||
124 | |||
125 | raw_printk("%s: %04lx\n", str, err & 0xffff); | ||
126 | |||
127 | show_registers(regs); | ||
128 | |||
129 | #ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY | ||
130 | reset_watchdog(); | ||
131 | #endif | ||
132 | do_exit(SIGSEGV); | ||
133 | } | 111 | } |
134 | 112 | ||
135 | void arch_enable_nmi(void) | 113 | #ifdef CONFIG_DEBUG_BUGVERBOSE |
114 | void | ||
115 | handle_BUG(struct pt_regs *regs) | ||
136 | { | 116 | { |
137 | asm volatile("setf m"); | 117 | struct bug_frame f; |
118 | unsigned char c; | ||
119 | unsigned long irp = regs->irp; | ||
120 | |||
121 | if (__copy_from_user(&f, (const void __user *)(irp - 8), sizeof f)) | ||
122 | return; | ||
123 | if (f.prefix != BUG_PREFIX || f.magic != BUG_MAGIC) | ||
124 | return; | ||
125 | if (__get_user(c, f.filename)) | ||
126 | f.filename = "<bad filename>"; | ||
127 | |||
128 | printk("kernel BUG at %s:%d!\n", f.filename, f.line); | ||
138 | } | 129 | } |
130 | #endif | ||
diff --git a/arch/cris/arch-v10/lib/checksum.S b/arch/cris/arch-v10/lib/checksum.S index 85c48f0a9ec2..7d552f4bd5ae 100644 --- a/arch/cris/arch-v10/lib/checksum.S +++ b/arch/cris/arch-v10/lib/checksum.S | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $Id: checksum.S,v 1.1 2001/12/17 13:59:27 bjornw Exp $ | 1 | /* |
2 | * A fast checksum routine using movem | 2 | * A fast checksum routine using movem |
3 | * Copyright (c) 1998-2001 Axis Communications AB | 3 | * Copyright (c) 1998-2001 Axis Communications AB |
4 | * | 4 | * |
@@ -61,8 +61,6 @@ _mloop: movem [$r10+],$r9 ; read 10 longwords | |||
61 | 61 | ||
62 | ax | 62 | ax |
63 | addq 0,$r12 | 63 | addq 0,$r12 |
64 | ax ; do it again, since we might have generated a carry | ||
65 | addq 0,$r12 | ||
66 | 64 | ||
67 | subq 10*4,$r11 | 65 | subq 10*4,$r11 |
68 | bge _mloop | 66 | bge _mloop |
@@ -88,10 +86,6 @@ _word_loop: | |||
88 | lsrq 16,$r13 ; r13 = checksum >> 16 | 86 | lsrq 16,$r13 ; r13 = checksum >> 16 |
89 | and.d $r9,$r12 ; checksum = checksum & 0xffff | 87 | and.d $r9,$r12 ; checksum = checksum & 0xffff |
90 | add.d $r13,$r12 ; checksum += r13 | 88 | add.d $r13,$r12 ; checksum += r13 |
91 | move.d $r12,$r13 ; do the same again, maybe we got a carry last add | ||
92 | lsrq 16,$r13 | ||
93 | and.d $r9,$r12 | ||
94 | add.d $r13,$r12 | ||
95 | 89 | ||
96 | _no_fold: | 90 | _no_fold: |
97 | cmpq 2,$r11 | 91 | cmpq 2,$r11 |
diff --git a/arch/cris/arch-v10/lib/checksumcopy.S b/arch/cris/arch-v10/lib/checksumcopy.S index 35cbffb306fd..540db8a5f849 100644 --- a/arch/cris/arch-v10/lib/checksumcopy.S +++ b/arch/cris/arch-v10/lib/checksumcopy.S | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $Id: checksumcopy.S,v 1.1 2001/12/17 13:59:27 bjornw Exp $ | 1 | /* |
2 | * A fast checksum+copy routine using movem | 2 | * A fast checksum+copy routine using movem |
3 | * Copyright (c) 1998, 2001 Axis Communications AB | 3 | * Copyright (c) 1998, 2001 Axis Communications AB |
4 | * | 4 | * |
@@ -67,8 +67,6 @@ _mloop: movem [$r10+],$r9 ; read 10 longwords | |||
67 | 67 | ||
68 | ax | 68 | ax |
69 | addq 0,$r13 | 69 | addq 0,$r13 |
70 | ax ; do it again, since we might have generated a carry | ||
71 | addq 0,$r13 | ||
72 | 70 | ||
73 | subq 10*4,$r12 | 71 | subq 10*4,$r12 |
74 | bge _mloop | 72 | bge _mloop |
@@ -91,10 +89,6 @@ _word_loop: | |||
91 | lsrq 16,$r9 ; r0 = checksum >> 16 | 89 | lsrq 16,$r9 ; r0 = checksum >> 16 |
92 | and.d 0xffff,$r13 ; checksum = checksum & 0xffff | 90 | and.d 0xffff,$r13 ; checksum = checksum & 0xffff |
93 | add.d $r9,$r13 ; checksum += r0 | 91 | add.d $r9,$r13 ; checksum += r0 |
94 | move.d $r13,$r9 ; do the same again, maybe we got a carry last add | ||
95 | lsrq 16,$r9 | ||
96 | and.d 0xffff,$r13 | ||
97 | add.d $r9,$r13 | ||
98 | 92 | ||
99 | _no_fold: | 93 | _no_fold: |
100 | cmpq 2,$r12 | 94 | cmpq 2,$r12 |
diff --git a/arch/cris/arch-v10/lib/dram_init.S b/arch/cris/arch-v10/lib/dram_init.S index 6a6bdfd6984d..b9190ff7d0a4 100644 --- a/arch/cris/arch-v10/lib/dram_init.S +++ b/arch/cris/arch-v10/lib/dram_init.S | |||
@@ -1,5 +1,4 @@ | |||
1 | /* $Id: dram_init.S,v 1.4 2003/09/22 09:21:59 starvik Exp $ | 1 | /* |
2 | * | ||
3 | * DRAM/SDRAM initialization - alter with care | 2 | * DRAM/SDRAM initialization - alter with care |
4 | * This file is intended to be included from other assembler files | 3 | * This file is intended to be included from other assembler files |
5 | * | 4 | * |
@@ -8,60 +7,7 @@ | |||
8 | * | 7 | * |
9 | * Copyright (C) 2000, 2001 Axis Communications AB | 8 | * Copyright (C) 2000, 2001 Axis Communications AB |
10 | * | 9 | * |
11 | * Authors: Mikael Starvik (starvik@axis.com) | 10 | * Authors: Mikael Starvik (starvik@axis.com) |
12 | * | ||
13 | * $Log: dram_init.S,v $ | ||
14 | * Revision 1.4 2003/09/22 09:21:59 starvik | ||
15 | * Decompresser is linked to 0x407xxxxx and sdram commands are at 0x000xxxxx | ||
16 | * so we need to mask off 12 bits. | ||
17 | * | ||
18 | * Revision 1.3 2003/03/31 09:38:37 starvik | ||
19 | * Corrected calculation of end of sdram init commands | ||
20 | * | ||
21 | * Revision 1.2 2002/11/19 13:33:29 starvik | ||
22 | * Changes from Linux 2.4 | ||
23 | * | ||
24 | * Revision 1.13 2002/10/30 07:42:28 starvik | ||
25 | * Always read SDRAM command sequence from flash | ||
26 | * | ||
27 | * Revision 1.12 2002/08/09 11:37:37 orjanf | ||
28 | * Added double initialization work-around for Samsung SDRAMs. | ||
29 | * | ||
30 | * Revision 1.11 2002/06/04 11:43:21 starvik | ||
31 | * Check if mrs_data is specified in kernelconfig (necessary for MCM) | ||
32 | * | ||
33 | * Revision 1.10 2001/10/04 12:00:21 martinnn | ||
34 | * Added missing underscores. | ||
35 | * | ||
36 | * Revision 1.9 2001/10/01 14:47:35 bjornw | ||
37 | * Added register prefixes and removed underscores | ||
38 | * | ||
39 | * Revision 1.8 2001/05/15 07:12:45 hp | ||
40 | * Copy warning from head.S about r8 and r9 | ||
41 | * | ||
42 | * Revision 1.7 2001/04/18 12:05:39 bjornw | ||
43 | * Fixed comments, and explicitly include config.h to be sure its there | ||
44 | * | ||
45 | * Revision 1.6 2001/04/10 06:20:16 starvik | ||
46 | * Delay should be 200us, not 200ns | ||
47 | * | ||
48 | * Revision 1.5 2001/04/09 06:01:13 starvik | ||
49 | * Added support for 100 MHz SDRAMs | ||
50 | * | ||
51 | * Revision 1.4 2001/03/26 14:24:01 bjornw | ||
52 | * Namechange of some config options | ||
53 | * | ||
54 | * Revision 1.3 2001/03/23 08:29:41 starvik | ||
55 | * Corrected calculation of mrs_data | ||
56 | * | ||
57 | * Revision 1.2 2001/02/08 15:20:00 starvik | ||
58 | * Corrected SDRAM initialization | ||
59 | * Should now be included as inline | ||
60 | * | ||
61 | * Revision 1.1 2001/01/29 13:08:02 starvik | ||
62 | * Initial version | ||
63 | * This file should be included from all assembler files that needs to | ||
64 | * initialize DRAM/SDRAM. | ||
65 | * | 11 | * |
66 | */ | 12 | */ |
67 | 13 | ||
diff --git a/arch/cris/arch-v10/lib/old_checksum.c b/arch/cris/arch-v10/lib/old_checksum.c index 497634a64829..1734b467efa6 100644 --- a/arch/cris/arch-v10/lib/old_checksum.c +++ b/arch/cris/arch-v10/lib/old_checksum.c | |||
@@ -1,5 +1,4 @@ | |||
1 | /* $Id: old_checksum.c,v 1.3 2003/10/27 08:04:32 starvik Exp $ | 1 | /* |
2 | * | ||
3 | * INET An implementation of the TCP/IP protocol suite for the LINUX | 2 | * INET An implementation of the TCP/IP protocol suite for the LINUX |
4 | * operating system. INET is implemented using the BSD Socket | 3 | * operating system. INET is implemented using the BSD Socket |
5 | * interface as the means of communication with the user level. | 4 | * interface as the means of communication with the user level. |
diff --git a/arch/cris/arch-v10/mm/fault.c b/arch/cris/arch-v10/mm/fault.c index fe2615022b97..65504fd80928 100644 --- a/arch/cris/arch-v10/mm/fault.c +++ b/arch/cris/arch-v10/mm/fault.c | |||
@@ -4,10 +4,10 @@ | |||
4 | * Low level bus fault handler | 4 | * Low level bus fault handler |
5 | * | 5 | * |
6 | * | 6 | * |
7 | * Copyright (C) 2000, 2001 Axis Communications AB | 7 | * Copyright (C) 2000-2007 Axis Communications AB |
8 | * | ||
9 | * Authors: Bjorn Wesen | ||
8 | * | 10 | * |
9 | * Authors: Bjorn Wesen | ||
10 | * | ||
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/mm.h> | 13 | #include <linux/mm.h> |
@@ -60,7 +60,7 @@ handle_mmu_bus_fault(struct pt_regs *regs) | |||
60 | #ifdef DEBUG | 60 | #ifdef DEBUG |
61 | page_id = IO_EXTRACT(R_MMU_CAUSE, page_id, cause); | 61 | page_id = IO_EXTRACT(R_MMU_CAUSE, page_id, cause); |
62 | acc = IO_EXTRACT(R_MMU_CAUSE, acc_excp, cause); | 62 | acc = IO_EXTRACT(R_MMU_CAUSE, acc_excp, cause); |
63 | inv = IO_EXTRACT(R_MMU_CAUSE, inv_excp, cause); | 63 | inv = IO_EXTRACT(R_MMU_CAUSE, inv_excp, cause); |
64 | index = IO_EXTRACT(R_TLB_SELECT, index, select); | 64 | index = IO_EXTRACT(R_TLB_SELECT, index, select); |
65 | #endif | 65 | #endif |
66 | miss = IO_EXTRACT(R_MMU_CAUSE, miss_excp, cause); | 66 | miss = IO_EXTRACT(R_MMU_CAUSE, miss_excp, cause); |
@@ -84,12 +84,13 @@ handle_mmu_bus_fault(struct pt_regs *regs) | |||
84 | local_irq_disable(); | 84 | local_irq_disable(); |
85 | pmd = (pmd_t *)(pgd + pgd_index(address)); | 85 | pmd = (pmd_t *)(pgd + pgd_index(address)); |
86 | if (pmd_none(*pmd)) | 86 | if (pmd_none(*pmd)) |
87 | return; | 87 | goto exit; |
88 | pte = *pte_offset_kernel(pmd, address); | 88 | pte = *pte_offset_kernel(pmd, address); |
89 | if (!pte_present(pte)) | 89 | if (!pte_present(pte)) |
90 | return; | 90 | goto exit; |
91 | *R_TLB_SELECT = select; | 91 | *R_TLB_SELECT = select; |
92 | *R_TLB_HI = cause; | 92 | *R_TLB_HI = cause; |
93 | *R_TLB_LO = pte_val(pte); | 93 | *R_TLB_LO = pte_val(pte); |
94 | exit: | ||
94 | local_irq_restore(flags); | 95 | local_irq_restore(flags); |
95 | } | 96 | } |
diff --git a/arch/cris/arch-v10/mm/tlb.c b/arch/cris/arch-v10/mm/tlb.c index 7d9fec88dee5..6baf5bd209e7 100644 --- a/arch/cris/arch-v10/mm/tlb.c +++ b/arch/cris/arch-v10/mm/tlb.c | |||
@@ -4,8 +4,8 @@ | |||
4 | * Low level TLB handling | 4 | * Low level TLB handling |
5 | * | 5 | * |
6 | * | 6 | * |
7 | * Copyright (C) 2000-2002 Axis Communications AB | 7 | * Copyright (C) 2000-2007 Axis Communications AB |
8 | * | 8 | * |
9 | * Authors: Bjorn Wesen (bjornw@axis.com) | 9 | * Authors: Bjorn Wesen (bjornw@axis.com) |
10 | * | 10 | * |
11 | */ | 11 | */ |
@@ -39,7 +39,7 @@ flush_tlb_all(void) | |||
39 | unsigned long flags; | 39 | unsigned long flags; |
40 | 40 | ||
41 | /* the vpn of i & 0xf is so we dont write similar TLB entries | 41 | /* the vpn of i & 0xf is so we dont write similar TLB entries |
42 | * in the same 4-way entry group. details.. | 42 | * in the same 4-way entry group. details... |
43 | */ | 43 | */ |
44 | 44 | ||
45 | local_irq_save(flags); | 45 | local_irq_save(flags); |
@@ -47,7 +47,7 @@ flush_tlb_all(void) | |||
47 | *R_TLB_SELECT = ( IO_FIELD(R_TLB_SELECT, index, i) ); | 47 | *R_TLB_SELECT = ( IO_FIELD(R_TLB_SELECT, index, i) ); |
48 | *R_TLB_HI = ( IO_FIELD(R_TLB_HI, page_id, INVALID_PAGEID ) | | 48 | *R_TLB_HI = ( IO_FIELD(R_TLB_HI, page_id, INVALID_PAGEID ) | |
49 | IO_FIELD(R_TLB_HI, vpn, i & 0xf ) ); | 49 | IO_FIELD(R_TLB_HI, vpn, i & 0xf ) ); |
50 | 50 | ||
51 | *R_TLB_LO = ( IO_STATE(R_TLB_LO, global,no ) | | 51 | *R_TLB_LO = ( IO_STATE(R_TLB_LO, global,no ) | |
52 | IO_STATE(R_TLB_LO, valid, no ) | | 52 | IO_STATE(R_TLB_LO, valid, no ) | |
53 | IO_STATE(R_TLB_LO, kernel,no ) | | 53 | IO_STATE(R_TLB_LO, kernel,no ) | |
@@ -71,10 +71,10 @@ flush_tlb_mm(struct mm_struct *mm) | |||
71 | 71 | ||
72 | if(page_id == NO_CONTEXT) | 72 | if(page_id == NO_CONTEXT) |
73 | return; | 73 | return; |
74 | 74 | ||
75 | /* mark the TLB entries that match the page_id as invalid. | 75 | /* mark the TLB entries that match the page_id as invalid. |
76 | * here we could also check the _PAGE_GLOBAL bit and NOT flush | 76 | * here we could also check the _PAGE_GLOBAL bit and NOT flush |
77 | * global pages. is it worth the extra I/O ? | 77 | * global pages. is it worth the extra I/O ? |
78 | */ | 78 | */ |
79 | 79 | ||
80 | local_irq_save(flags); | 80 | local_irq_save(flags); |
@@ -83,7 +83,7 @@ flush_tlb_mm(struct mm_struct *mm) | |||
83 | if (IO_EXTRACT(R_TLB_HI, page_id, *R_TLB_HI) == page_id) { | 83 | if (IO_EXTRACT(R_TLB_HI, page_id, *R_TLB_HI) == page_id) { |
84 | *R_TLB_HI = ( IO_FIELD(R_TLB_HI, page_id, INVALID_PAGEID ) | | 84 | *R_TLB_HI = ( IO_FIELD(R_TLB_HI, page_id, INVALID_PAGEID ) | |
85 | IO_FIELD(R_TLB_HI, vpn, i & 0xf ) ); | 85 | IO_FIELD(R_TLB_HI, vpn, i & 0xf ) ); |
86 | 86 | ||
87 | *R_TLB_LO = ( IO_STATE(R_TLB_LO, global,no ) | | 87 | *R_TLB_LO = ( IO_STATE(R_TLB_LO, global,no ) | |
88 | IO_STATE(R_TLB_LO, valid, no ) | | 88 | IO_STATE(R_TLB_LO, valid, no ) | |
89 | IO_STATE(R_TLB_LO, kernel,no ) | | 89 | IO_STATE(R_TLB_LO, kernel,no ) | |
@@ -96,9 +96,7 @@ flush_tlb_mm(struct mm_struct *mm) | |||
96 | 96 | ||
97 | /* invalidate a single page */ | 97 | /* invalidate a single page */ |
98 | 98 | ||
99 | void | 99 | void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr) |
100 | flush_tlb_page(struct vm_area_struct *vma, | ||
101 | unsigned long addr) | ||
102 | { | 100 | { |
103 | struct mm_struct *mm = vma->vm_mm; | 101 | struct mm_struct *mm = vma->vm_mm; |
104 | int page_id = mm->context.page_id; | 102 | int page_id = mm->context.page_id; |
@@ -113,7 +111,7 @@ flush_tlb_page(struct vm_area_struct *vma, | |||
113 | addr &= PAGE_MASK; /* perhaps not necessary */ | 111 | addr &= PAGE_MASK; /* perhaps not necessary */ |
114 | 112 | ||
115 | /* invalidate those TLB entries that match both the mm context | 113 | /* invalidate those TLB entries that match both the mm context |
116 | * and the virtual address requested | 114 | * and the virtual address requested |
117 | */ | 115 | */ |
118 | 116 | ||
119 | local_irq_save(flags); | 117 | local_irq_save(flags); |
@@ -125,7 +123,7 @@ flush_tlb_page(struct vm_area_struct *vma, | |||
125 | (tlb_hi & PAGE_MASK) == addr) { | 123 | (tlb_hi & PAGE_MASK) == addr) { |
126 | *R_TLB_HI = IO_FIELD(R_TLB_HI, page_id, INVALID_PAGEID ) | | 124 | *R_TLB_HI = IO_FIELD(R_TLB_HI, page_id, INVALID_PAGEID ) | |
127 | addr; /* same addr as before works. */ | 125 | addr; /* same addr as before works. */ |
128 | 126 | ||
129 | *R_TLB_LO = ( IO_STATE(R_TLB_LO, global,no ) | | 127 | *R_TLB_LO = ( IO_STATE(R_TLB_LO, global,no ) | |
130 | IO_STATE(R_TLB_LO, valid, no ) | | 128 | IO_STATE(R_TLB_LO, valid, no ) | |
131 | IO_STATE(R_TLB_LO, kernel,no ) | | 129 | IO_STATE(R_TLB_LO, kernel,no ) | |
@@ -144,7 +142,7 @@ dump_tlb_all(void) | |||
144 | { | 142 | { |
145 | int i; | 143 | int i; |
146 | unsigned long flags; | 144 | unsigned long flags; |
147 | 145 | ||
148 | printk("TLB dump. LO is: pfn | reserved | global | valid | kernel | we |\n"); | 146 | printk("TLB dump. LO is: pfn | reserved | global | valid | kernel | we |\n"); |
149 | 147 | ||
150 | local_save_flags(flags); | 148 | local_save_flags(flags); |
@@ -172,27 +170,29 @@ init_new_context(struct task_struct *tsk, struct mm_struct *mm) | |||
172 | 170 | ||
173 | /* called in schedule() just before actually doing the switch_to */ | 171 | /* called in schedule() just before actually doing the switch_to */ |
174 | 172 | ||
175 | void | 173 | void switch_mm(struct mm_struct *prev, struct mm_struct *next, |
176 | switch_mm(struct mm_struct *prev, struct mm_struct *next, | 174 | struct task_struct *tsk) |
177 | struct task_struct *tsk) | ||
178 | { | 175 | { |
179 | /* make sure we have a context */ | 176 | if (prev != next) { |
177 | /* make sure we have a context */ | ||
178 | get_mmu_context(next); | ||
180 | 179 | ||
181 | get_mmu_context(next); | 180 | /* remember the pgd for the fault handlers |
181 | * this is similar to the pgd register in some other CPU's. | ||
182 | * we need our own copy of it because current and active_mm | ||
183 | * might be invalid at points where we still need to derefer | ||
184 | * the pgd. | ||
185 | */ | ||
182 | 186 | ||
183 | /* remember the pgd for the fault handlers | 187 | per_cpu(current_pgd, smp_processor_id()) = next->pgd; |
184 | * this is similar to the pgd register in some other CPU's. | ||
185 | * we need our own copy of it because current and active_mm | ||
186 | * might be invalid at points where we still need to derefer | ||
187 | * the pgd. | ||
188 | */ | ||
189 | 188 | ||
190 | per_cpu(current_pgd, smp_processor_id()) = next->pgd; | 189 | /* switch context in the MMU */ |
191 | 190 | ||
192 | /* switch context in the MMU */ | 191 | D(printk(KERN_DEBUG "switching mmu_context to %d (%p)\n", |
193 | 192 | next->context, next)); | |
194 | D(printk("switching mmu_context to %d (%p)\n", next->context, next)); | ||
195 | 193 | ||
196 | *R_MMU_CONTEXT = IO_FIELD(R_MMU_CONTEXT, page_id, next->context.page_id); | 194 | *R_MMU_CONTEXT = IO_FIELD(R_MMU_CONTEXT, |
195 | page_id, next->context.page_id); | ||
196 | } | ||
197 | } | 197 | } |
198 | 198 | ||