| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
 | 2 |  *  linux/arch/arm26/kernel/latches.c | 
 | 3 |  * | 
 | 4 |  *  Copyright (C) David Alan Gilbert 1995/1996,2000 | 
 | 5 |  *  Copyright (C) Ian Molton 2003 | 
 | 6 |  * | 
 | 7 |  * This program is free software; you can redistribute it and/or modify | 
 | 8 |  * it under the terms of the GNU General Public License version 2 as | 
 | 9 |  * published by the Free Software Foundation. | 
 | 10 |  * | 
 | 11 |  *  Support for the latches on the old Archimedes which control the floppy, | 
 | 12 |  *  hard disc and printer | 
 | 13 |  */ | 
 | 14 | #include <linux/module.h> | 
 | 15 | #include <linux/kernel.h> | 
 | 16 | #include <linux/init.h> | 
 | 17 | #include <linux/sched.h> | 
 | 18 |  | 
 | 19 | #include <asm/io.h> | 
 | 20 | #include <asm/hardware.h> | 
 | 21 | #include <asm/mach-types.h> | 
 | 22 | #include <asm/oldlatches.h> | 
 | 23 |  | 
 | 24 | static unsigned char latch_a_copy; | 
 | 25 | static unsigned char latch_b_copy; | 
 | 26 |  | 
 | 27 | /* newval=(oldval & ~mask)|newdata */ | 
 | 28 | void oldlatch_aupdate(unsigned char mask,unsigned char newdata) | 
 | 29 | { | 
 | 30 | 	unsigned long flags; | 
 | 31 |  | 
 | 32 | 	BUG_ON(!machine_is_archimedes()); | 
 | 33 |  | 
 | 34 | 	local_irq_save(flags); //FIXME: was local_save_flags | 
 | 35 | 	latch_a_copy = (latch_a_copy & ~mask) | newdata; | 
 | 36 | 	__raw_writeb(latch_a_copy, LATCHA_BASE); | 
 | 37 | 	local_irq_restore(flags); | 
 | 38 |  | 
 | 39 | 	printk("Latch: A = 0x%02x\n", latch_a_copy); | 
 | 40 | } | 
 | 41 |  | 
 | 42 |  | 
 | 43 | /* newval=(oldval & ~mask)|newdata */ | 
 | 44 | void oldlatch_bupdate(unsigned char mask,unsigned char newdata) | 
 | 45 | { | 
 | 46 | 	unsigned long flags; | 
 | 47 |  | 
 | 48 | 	BUG_ON(!machine_is_archimedes()); | 
 | 49 |  | 
 | 50 |  | 
 | 51 | 	local_irq_save(flags);//FIXME: was local_save_flags | 
 | 52 | 	latch_b_copy = (latch_b_copy & ~mask) | newdata; | 
 | 53 | 	__raw_writeb(latch_b_copy, LATCHB_BASE); | 
 | 54 | 	local_irq_restore(flags); | 
 | 55 |  | 
 | 56 | 	printk("Latch: B = 0x%02x\n", latch_b_copy); | 
 | 57 | } | 
 | 58 |  | 
 | 59 | static int __init oldlatch_init(void) | 
 | 60 | { | 
 | 61 | 	if (machine_is_archimedes()) { | 
 | 62 | 		oldlatch_aupdate(0xff, 0xff); | 
 | 63 | 		/* Thats no FDC reset...*/ | 
 | 64 | 		oldlatch_bupdate(0xff, LATCHB_FDCRESET); | 
 | 65 | 	} | 
 | 66 | 	return 0; | 
 | 67 | } | 
 | 68 |  | 
 | 69 | arch_initcall(oldlatch_init); | 
 | 70 |  | 
 | 71 | EXPORT_SYMBOL(oldlatch_aupdate); | 
 | 72 | EXPORT_SYMBOL(oldlatch_bupdate); |