diff options
Diffstat (limited to 'drivers')
108 files changed, 2526 insertions, 4669 deletions
diff --git a/drivers/acorn/README b/drivers/acorn/README deleted file mode 100644 index d399c09ca61..00000000000 --- a/drivers/acorn/README +++ /dev/null @@ -1 +0,0 @@ -Drivers for the ACORN "podule" ARM specific bus. diff --git a/drivers/acorn/block/Kconfig b/drivers/acorn/block/Kconfig deleted file mode 100644 index a0ff25ea439..00000000000 --- a/drivers/acorn/block/Kconfig +++ /dev/null @@ -1,36 +0,0 @@ -# -# Block device driver configuration -# - -menu "Acorn-specific block devices" - depends on ARCH_ARC || ARCH_A5K - -config BLK_DEV_FD1772 - tristate "Old Archimedes floppy (1772) support" - depends on ARCH_ARC || ARCH_A5K - help - Support the floppy drive on the Acorn Archimedes (A300, A4x0, A540, - R140 and R260) series of computers; it supports only 720K floppies - at the moment. If you don't have one of these machines just answer - N. - -config BLK_DEV_MFM - tristate "MFM harddisk support" - depends on ARCH_ARC || ARCH_A5K - help - Support the MFM hard drives on the Acorn Archimedes both - on-board the A4x0 motherboards and via the Acorn MFM podules. - Drives up to 64MB are supported. If you haven't got one of these - machines or drives just say N. - -config BLK_DEV_MFM_AUTODETECT - bool "Autodetect hard drive geometry" - depends on BLK_DEV_MFM - help - If you answer Y, the MFM code will attempt to automatically detect - the cylinders/heads/sectors count on your hard drive. WARNING: This - sometimes doesn't work and it also does some dodgy stuff which - potentially might damage your drive. - -endmenu - diff --git a/drivers/acorn/block/Makefile b/drivers/acorn/block/Makefile deleted file mode 100644 index 38a9afe8e03..00000000000 --- a/drivers/acorn/block/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# -# Makefile for the Acorn block device drivers. -# - -fd1772_mod-objs := fd1772.o fd1772dma.o -mfmhd_mod-objs := mfmhd.o mfm.o - -obj-$(CONFIG_BLK_DEV_FD1772) += fd1772_mod.o -obj-$(CONFIG_BLK_DEV_MFM) += mfmhd_mod.o diff --git a/drivers/acorn/block/fd1772.c b/drivers/acorn/block/fd1772.c deleted file mode 100644 index d7e18ce8dad..00000000000 --- a/drivers/acorn/block/fd1772.c +++ /dev/null @@ -1,1604 +0,0 @@ -/* - * linux/kernel/arch/arm/drivers/block/fd1772.c - * Based on ataflop.c in the m68k Linux - * Copyright (C) 1993 Greg Harp - * Atari Support by Bjoern Brauel, Roman Hodek - * Archimedes Support by Dave Gilbert (linux@treblig.org) - * - * Big cleanup Sep 11..14 1994 Roman Hodek: - * - Driver now works interrupt driven - * - Support for two drives; should work, but I cannot test that :-( - * - Reading is done in whole tracks and buffered to speed up things - * - Disk change detection and drive deselecting after motor-off - * similar to TOS - * - Autodetection of disk format (DD/HD); untested yet, because I - * don't have an HD drive :-( - * - * Fixes Nov 13 1994 Martin Schaller: - * - Autodetection works now - * - Support for 5 1/4" disks - * - Removed drive type (unknown on atari) - * - Do seeks with 8 Mhz - * - * Changes by Andreas Schwab: - * - After errors in multiple read mode try again reading single sectors - * (Feb 1995): - * - Clean up error handling - * - Set blk_size for proper size checking - * - Initialize track register when testing presence of floppy - * - Implement some ioctl's - * - * Changes by Torsten Lang: - * - When probing the floppies we should add the FDC1772CMDADD_H flag since - * the FDC1772 will otherwise wait forever when no disk is inserted... - * - * Things left to do: - * - Formatting - * - Maybe a better strategy for disk change detection (does anyone - * know one?) - * - There are some strange problems left: The strangest one is - * that, at least on my TT (4+4MB), the first 2 Bytes of the last - * page of the TT-Ram (!) change their contents (some bits get - * set) while a floppy DMA is going on. But there are no accesses - * to these memory locations from the kernel... (I tested that by - * making the page read-only). I cannot explain what's going on... - * - Sometimes the drive-change-detection stops to work. The - * function is still called, but the WP bit always reads as 0... - * Maybe a problem with the status reg mode or a timing problem. - * Note 10/12/94: The change detection now seems to work reliably. - * There is no proof, but I've seen no hang for a long time... - * - * ARCHIMEDES changes: (gilbertd@cs.man.ac.uk) - * 26/12/95 - Changed all names starting with FDC to FDC1772 - * Removed all references to clock speed of FDC - we're stuck with 8MHz - * Modified disk_type structure to remove HD formats - * - * 7/ 1/96 - Wrote FIQ code, removed most remaining atariisms - * - * 13/ 1/96 - Well I think its read a single sector; but there is a problem - * fd_rwsec_done which is called in FIQ mode starts another transfer - * off (in fd_rwsec) while still in FIQ mode. Because its still in - * FIQ mode it can't service the DMA and loses data. So need to - * heavily restructure. - * 14/ 1/96 - Found that the definitions of the register numbers of the - * FDC were multiplied by 2 in the header for the 16bit words - * of the atari so half the writes were going in the wrong place. - * Also realised that the FIQ entry didn't make any attempt to - * preserve registers or return correctly; now in assembler. - * - * 11/ 2/96 - Hmm - doesn't work on real machine. Auto detect doesn't - * and hacking that past seems to wait forever - check motor - * being turned on. - * - * 17/ 2/96 - still having problems - forcing track to -1 when selecting - * new drives seems to allow it to read first few sectors - * but then we get solid hangs at apparently random places - * which change depending what is happening. - * - * 9/ 3/96 - Fiddled a lot of stuff around to move to kernel 1.3.35 - * A lot of fiddling in DMA stuff. Having problems with it - * constnatly thinking its timeing out. Ah - its timeout - * was set to (6*HZ) rather than jiffies+(6*HZ). Now giving - * duff data! - * - * 5/ 4/96 - Made it use the new IOC_ macros rather than *ioc - * Hmm - giving unexpected FIQ and then timeouts - * 18/ 8/96 - Ran through indent -kr -i8 - * Some changes to disc change detect; don't know how well it - * works. - * 24/ 8/96 - Put all the track buffering code back in from the atari - * code - I wonder if it will still work... No :-) - * Still works if I turn off track buffering. - * 25/ 8/96 - Changed the timer expires that I'd added back to be - * jiffies + ....; and it all sprang to life! Got 2.8K/sec - * off a cp -r of a 679K disc (showed 94% cpu usage!) - * (PC gets 14.3K/sec - 0% CPU!) Hmm - hard drive corrupt! - * Also perhaps that compile was with cache off. - * changed cli in fd_readtrack_check to cliIF - * changed vmallocs to kmalloc (whats the difference!!) - * Removed the busy wait loop in do_fd_request and replaced - * by a routine on tq_immediate; only 11% cpu on a dd off the - * raw disc - but the speed is the same. - * 1/ 9/96 - Idea (failed!) - set the 'disable spin-up sequence' - * when we read the track if we know the motor is on; didn't - * help - perhaps we have to do it in stepping as well. - * Nope. Still doesn't help. - * Hmm - what seems to be happening is that fd_readtrack_check - * is never getting called. Its job is to terminate the read - * just after we think we should have got the data; otherwise - * the fdc takes 1 second to timeout; which is what's happening - * Now I can see 'readtrack_timer' being set (which should do the - * call); but it never seems to be called - hmm! - * OK - I've moved the check to my tq_immediate code - - * and it WORKS! 13.95K/second at 19% CPU. - * I wish I knew why that timer didn't work..... - * - * 16/11/96 - Fiddled and frigged for 2.0.18 - * - * DAG 30/01/99 - Started frobbing for 2.2.1 - * DAG 20/06/99 - A little more frobbing: - * Included include/asm/uaccess.h for get_user/put_user - * - * DAG 1/09/00 - Dusted off for 2.4.0-test7 - * MAX_SECTORS was name clashing so it is now FD1772_... - * Minor parameter, name layouts for 2.4.x differences - */ - -#include <linux/sched.h> -#include <linux/fs.h> -#include <linux/fcntl.h> -#include <linux/slab.h> -#include <linux/kernel.h> -#include <linux/interrupt.h> -#include <linux/timer.h> -#include <linux/workqueue.h> -#include <linux/fd.h> -#include <linux/fd1772.h> -#include <linux/errno.h> -#include <linux/types.h> -#include <linux/delay.h> -#include <linux/mm.h> -#include <linux/bitops.h> - -#include <asm/arch/oldlatches.h> -#include <asm/dma.h> -#include <asm/hardware.h> -#include <asm/hardware/ioc.h> -#include <asm/io.h> -#include <asm/irq.h> -#include <asm/mach-types.h> -#include <asm/pgtable.h> -#include <asm/system.h> -#include <asm/uaccess.h> - - -/* Note: FD_MAX_UNITS could be redefined to 2 for the Atari (with - * little additional rework in this file). But I'm not yet sure if - * some other code depends on the number of floppies... (It is defined - * in a public header!) - */ -#if 0 -#undef FD_MAX_UNITS -#define FD_MAX_UNITS 2 -#endif - -/* Ditto worries for Arc - DAG */ -#define FD_MAX_UNITS 4 -#define TRACKBUFFER 0 -/*#define DEBUG*/ - -#ifdef DEBUG -#define DPRINT(a) printk a -#else -#define DPRINT(a) -#endif - -static struct request_queue *floppy_queue; - -#define MAJOR_NR FLOPPY_MAJOR -#define FLOPPY_DMA 0 -#define DEVICE_NAME "floppy" -#define QUEUE (floppy_queue) -#define CURRENT elv_next_request(floppy_queue) - -/* Disk types: DD */ -static struct archy_disk_type { - const char *name; - unsigned spt; /* sectors per track */ - unsigned blocks; /* total number of blocks */ - unsigned stretch; /* track doubling ? */ -} disk_type[] = { - - { "d360", 9, 720, 0 }, /* 360kB diskette */ - { "D360", 9, 720, 1 }, /* 360kb in 720kb drive */ - { "D720", 9, 1440, 0 }, /* 720kb diskette (DD) */ - /*{ "D820", 10,1640, 0}, *//* DD disk with 82 tracks/10 sectors - - DAG - can't see how type detect can distinguish this - from 720K until it reads block 4 by which time its too late! */ -}; - -#define NUM_DISK_TYPES (sizeof(disk_type)/sizeof(*disk_type)) - -/* - * Maximum disk size (in kilobytes). This default is used whenever the - * current disk size is unknown. - */ -#define MAX_DISK_SIZE 720 - -static struct gendisk *disks[FD_MAX_UNIT]; - -/* current info on each unit */ -static struct archy_floppy_struct { - int connected; /* !=0 : drive is connected */ - int autoprobe; /* !=0 : do autoprobe */ - - struct archy_disk_type *disktype; /* current type of disk */ - - int track; /* current head position or -1 - * if unknown */ - unsigned int steprate; /* steprate setting */ - unsigned int wpstat; /* current state of WP signal - * (for disk change detection) */ -} unit[FD_MAX_UNITS]; - -/* DAG: On Arc we spin on a flag being cleared by fdc1772_comendhandler which - is an assembler routine */ -extern void fdc1772_comendhandler(void); /* Actually doens't have these parameters - see fd1772.S */ -extern volatile int fdc1772_comendstatus; -extern volatile int fdc1772_fdc_int_done; - -#define FDC1772BASE ((0x210000>>2)|0x80000000) - -#define FDC1772_READ(reg) inb(FDC1772BASE+(reg/2)) - -/* DAG: You wouldn't be silly to ask why FDC1772_WRITE is a function rather - than the #def below - well simple - the #def won't compile - and I - don't understand why (__outwc not defined) */ -/* NOTE: Reg is 0,2,4,6 as opposed to 0,1,2,3 or 0,4,8,12 to keep compatibility - with the ST version of fd1772.h */ -/*#define FDC1772_WRITE(reg,val) outw(val,(reg+FDC1772BASE)); */ -void FDC1772_WRITE(int reg, unsigned char val) -{ - if (reg == FDC1772REG_CMD) { - DPRINT(("FDC1772_WRITE new command 0x%x @ %d\n", val,jiffies)); - if (fdc1772_fdc_int_done) { - DPRINT(("FDC1772_WRITE: Hmm fdc1772_fdc_int_done true - resetting\n")); - fdc1772_fdc_int_done = 0; - }; - }; - outb(val, (reg / 2) + FDC1772BASE); -}; - -#define FD1772_MAX_SECTORS 22 - -unsigned char *DMABuffer; /* buffer for writes */ -/*static unsigned long PhysDMABuffer; *//* physical address */ -/* DAG: On Arc we just go straight for the DMA buffer */ -#define PhysDMABuffer DMABuffer - -#ifdef TRACKBUFFER -unsigned char *TrackBuffer; /* buffer for reads */ -#define PhysTrackBuffer TrackBuffer /* physical address */ -static int BufferDrive, BufferSide, BufferTrack; -static int read_track; /* non-zero if we are reading whole tracks */ - -#define SECTOR_BUFFER(sec) (TrackBuffer + ((sec)-1)*512) -#define IS_BUFFERED(drive,side,track) \ - (BufferDrive == (drive) && BufferSide == (side) && BufferTrack == (track)) -#endif - -/* - * These are global variables, as that's the easiest way to give - * information to interrupts. They are the data used for the current - * request. - */ -static int SelectedDrive = 0; -static int ReqCmd, ReqBlock; -static int ReqSide, ReqTrack, ReqSector, ReqCnt; -static int HeadSettleFlag = 0; -static unsigned char *ReqData, *ReqBuffer; -static int MotorOn = 0, MotorOffTrys; - -/* Synchronization of FDC1772 access. */ -static volatile int fdc_busy = 0; -static DECLARE_WAIT_QUEUE_HEAD(fdc_wait); - - -/* long req'd for set_bit --RR */ -static unsigned long changed_floppies = 0xff, fake_change = 0; -#define CHECK_CHANGE_DELAY HZ/2 - -/* DAG - increased to 30*HZ - not sure if this is the correct thing to do */ -#define FD_MOTOR_OFF_DELAY (10*HZ) -#define FD_MOTOR_OFF_MAXTRY (10*20) - -#define FLOPPY_TIMEOUT (6*HZ) -#define RECALIBRATE_ERRORS 4 /* After this many errors the drive - * will be recalibrated. */ -#define MAX_ERRORS 8 /* After this many errors the driver - * will give up. */ - -#define START_MOTOR_OFF_TIMER(delay) \ - do { \ - motor_off_timer.expires = jiffies + (delay); \ - add_timer( &motor_off_timer ); \ - MotorOffTrys = 0; \ - } while(0) - -#define START_CHECK_CHANGE_TIMER(delay) \ - do { \ - mod_timer(&fd_timer, jiffies + (delay)); \ - } while(0) - -#define START_TIMEOUT() \ - do { \ - mod_timer(&timeout_timer, jiffies+FLOPPY_TIMEOUT); \ - } while(0) - -#define STOP_TIMEOUT() \ - do { \ - del_timer( &timeout_timer ); \ - } while(0) - -#define ENABLE_IRQ() enable_irq(FIQ_FD1772+64); - -#define DISABLE_IRQ() disable_irq(FIQ_FD1772+64); - -static void fd1772_checkint(void); - -DECLARE_WORK(fd1772_tq, (void *)fd1772_checkint, NULL); -/* - * The driver is trying to determine the correct media format - * while Probing is set. fd_rwsec_done() clears it after a - * successful access. - */ -static int Probing = 0; - -/* This flag is set when a dummy seek is necessary to make the WP - * status bit accessible. - */ -static int NeedSeek = 0; - - -/***************************** Prototypes *****************************/ - -static void fd_select_side(int side); -static void fd_select_drive(int drive); -static void fd_deselect(void); -static void fd_motor_off_timer(unsigned long dummy); -static void check_change(unsigned long dummy); -static void floppy_irqconsequencehandler(void); -static void fd_error(void); -static void do_fd_action(int drive); -static void fd_calibrate(void); -static void fd_calibrate_done(int status); -static void fd_seek(void); -static void fd_seek_done(int status); -static void fd_rwsec(void); -#ifdef TRACKBUFFER -static void fd_readtrack_check( unsigned long dummy ); -#endif -static void fd_rwsec_done(int status); -static void fd_times_out(unsigned long dummy); -static void finish_fdc(void); -static void finish_fdc_done(int dummy); -static void floppy_off(unsigned int nr); -static void setup_req_params(int drive); -static void redo_fd_request(void); -static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int - cmd, unsigned long param); -static void fd_probe(int drive); -static int fd_test_drive_present(int drive); -static void config_types(void); -static int floppy_open(struct inode *inode, struct file *filp); -static int floppy_release(struct inode *inode, struct file *filp); -static void do_fd_request(struct request_queue *); - -/************************* End of Prototypes **************************/ - -static DEFINE_TIMER(motor_off_timer, fd_motor_off_timer, 0, 0); - -#ifdef TRACKBUFFER -static DEFINE_TIMER(readtrack_timer, fd_readtrack_check, 0, 0); -#endif - -static DEFINE_TIMER(timeout_timer, fd_times_out, 0, 0); - -static DEFINE_TIMER(fd_timer, check_change, 0, 0); - -/* DAG: Haven't got a clue what this is? */ -int stdma_islocked(void) -{ - return 0; -}; - -/* Select the side to use. */ - -static void fd_select_side(int side) -{ - oldlatch_aupdate(LATCHA_SIDESEL, side ? 0 : LATCHA_SIDESEL); -} - - -/* Select a drive, update the FDC1772's track register - */ - -static void fd_select_drive(int drive) -{ -#ifdef DEBUG - printk("fd_select_drive:%d\n", drive); -#endif - /* Hmm - nowhere do we seem to turn the motor on - I'm going to do it here! */ - oldlatch_aupdate(LATCHA_MOTOR | LATCHA_INUSE, 0); - - if (drive == SelectedDrive) - return; - - oldlatch_aupdate(LATCHA_FDSELALL, 0xf - (1 << drive)); - - /* restore track register to saved value */ - FDC1772_WRITE(FDC1772REG_TRACK, unit[drive].track); - udelay(25); - - SelectedDrive = drive; -} - - -/* Deselect both drives. */ - -static void fd_deselect(void) -{ - unsigned long flags; - - DPRINT(("fd_deselect\n")); - - oldlatch_aupdate(LATCHA_FDSELALL | LATCHA_MOTOR | LATCHA_INUSE, 0xf | LATCHA_MOTOR | LATCHA_INUSE); - - SelectedDrive = -1; -} - - -/* This timer function deselects the drives when the FDC1772 switched the - * motor off. The deselection cannot happen earlier because the FDC1772 - * counts the index signals, which arrive only if one drive is selected. - */ - -static void fd_motor_off_timer(unsigned long dummy) -{ - unsigned long flags; - unsigned char status; - int delay; - - del_timer(&motor_off_timer); - - if (SelectedDrive < 0) - /* no drive selected, needn't deselect anyone */ - return; - - save_flags(flags); - cli(); - - if (fdc_busy) /* was stdma_islocked */ - goto retry; - - status = FDC1772_READ(FDC1772REG_STATUS); - - if (!(status & 0x80)) { - /* - * motor already turned off by FDC1772 -> deselect drives - * In actual fact its this deselection which turns the motor - * off on the Arc, since the motor control is actually on - * Latch A - */ - DPRINT(("fdc1772: deselecting in fd_motor_off_timer\n")); - fd_deselect(); - MotorOn = 0; - restore_flags(flags); - return; - } - /* not yet off, try again */ - -retry: - restore_flags(flags); - /* Test again later; if tested too often, it seems there is no disk - * in the drive and the FDC1772 will leave the motor on forever (or, - * at least until a disk is inserted). So we'll test only twice - * per second from then on... - */ - delay = (MotorOffTrys < FD_MOTOR_OFF_MAXTRY) ? - (++MotorOffTrys, HZ / 20) : HZ / 2; - START_MOTOR_OFF_TIMER(delay); -} - - -/* This function is repeatedly called to detect disk changes (as good - * as possible) and keep track of the current state of the write protection. - */ - -static void check_change(unsigned long dummy) -{ - static int drive = 0; - - unsigned long flags; - int stat; - - if (fdc_busy) - return; /* Don't start poking about if the fdc is busy */ - - return; /* let's just forget it for the mo DAG */ - - if (++drive > 1 || !unit[drive].connected) - drive = 0; - - save_flags(flags); - cli(); - - if (!stdma_islocked()) { - stat = !!(FDC1772_READ(FDC1772REG_STATUS) & FDC1772STAT_WPROT); - - /* The idea here is that if the write protect line has changed then - the disc must have changed */ - if (stat != unit[drive].wpstat) { - DPRINT(("wpstat[%d] = %d\n", drive, stat)); - unit[drive].wpstat = stat; - set_bit(drive, &changed_floppies); - } - } - restore_flags(flags); - - START_CHECK_CHANGE_TIMER(CHECK_CHANGE_DELAY); -} - - -/* Handling of the Head Settling Flag: This flag should be set after each - * seek operation, because we don't use seeks with verify. - */ - -static inline void set_head_settle_flag(void) -{ - HeadSettleFlag = FDC1772CMDADD_E; -} - -static inline int get_head_settle_flag(void) -{ - int tmp = HeadSettleFlag; - HeadSettleFlag = 0; - return (tmp); -} - - - - -/* General Interrupt Handling */ - -static inline void copy_buffer(void *from, void *to) -{ - ulong *p1 = (ulong *) from, *p2 = (ulong *) to; - int cnt; - - for (cnt = 512 / 4; cnt; cnt--) - *p2++ = *p1++; -} - -static void (*FloppyIRQHandler) (int status) = NULL; - -static void floppy_irqconsequencehandler(void) -{ - unsigned char status; - void (*handler) (int); - - fdc1772_fdc_int_done = 0; - - handler = FloppyIRQHandler; - FloppyIRQHandler = NULL; - - if (handler) { - nop(); - status = (unsigned char) fdc1772_comendstatus; - DPRINT(("FDC1772 irq, status = %02x handler = %08lx\n", (unsigned int) status, (unsigned long) handler)); - handler(status); - } else { - DPRINT(("FDC1772 irq, no handler status=%02x\n", fdc1772_comendstatus)); - } - DPRINT(("FDC1772 irq: end of floppy_irq\n")); -} - - -/* Error handling: If some error happened, retry some times, then - * recalibrate, then try again, and fail after MAX_ERRORS. - */ - -static void fd_error(void) -{ - printk("FDC1772: fd_error\n"); - /*panic("fd1772: fd_error"); *//* DAG tmp */ - if (!CURRENT) - return; - CURRENT->errors++; - if (CURRENT->errors >= MAX_ERRORS) { - printk("fd%d: too many errors.\n", SelectedDrive); - end_request(CURRENT, 0); - } else if (CURRENT->errors == RECALIBRATE_ERRORS) { - printk("fd%d: recalibrating\n", SelectedDrive); - if (SelectedDrive != -1) - unit[SelectedDrive].track = -1; - } - redo_fd_request(); -} - - - -#define SET_IRQ_HANDLER(proc) do { FloppyIRQHandler = (proc); } while(0) - - -/* do_fd_action() is the general procedure for a fd request: All - * required parameter settings (drive select, side select, track - * position) are checked and set if needed. For each of these - * parameters and the actual reading or writing exist two functions: - * one that starts the setting (or skips it if possible) and one - * callback for the "done" interrupt. Each done func calls the next - * set function to propagate the request down to fd_rwsec_done(). - */ - -static void do_fd_action(int drive) -{ - struct request *req; - DPRINT(("do_fd_action unit[drive].track=%d\n", unit[drive].track)); - -#ifdef TRACKBUFFER -repeat: - - if (IS_BUFFERED( drive, ReqSide, ReqTrack )) { - req = CURRENT; - if (ReqCmd == READ) { - copy_buffer( SECTOR_BUFFER(ReqSector), ReqData ); - if (++ReqCnt < req->current_nr_sectors) { - /* read next sector */ - setup_req_params( drive ); - goto repeat; - } else { - /* all sectors finished */ - req->nr_sectors -= req->current_nr_sectors; - req->sector += req->current_nr_sectors; - end_request(req, 1); - redo_fd_request(); - return; - } - } else { - /* cmd == WRITE, pay attention to track buffer - * consistency! */ - copy_buffer( ReqData, SECTOR_BUFFER(ReqSector) ); - } - } -#endif - - if (SelectedDrive != drive) { - /*unit[drive].track = -1; DAG */ - fd_select_drive(drive); - }; - - - if (unit[drive].track == -1) - fd_calibrate(); - else if (unit[drive].track != ReqTrack << unit[drive].disktype->stretch) - fd_seek(); - else - fd_rwsec(); -} - - -/* Seek to track 0 if the current track is unknown */ - -static void fd_calibrate(void) -{ - DPRINT(("fd_calibrate\n")); - if (unit[SelectedDrive].track >= 0) { - fd_calibrate_done(0); - return; - } - DPRINT(("fd_calibrate (after track compare)\n")); - SET_IRQ_HANDLER(fd_calibrate_done); - /* we can't verify, since the speed may be incorrect */ - FDC1772_WRITE(FDC1772REG_CMD, FDC1772CMD_RESTORE | unit[SelectedDrive].steprate); - - NeedSeek = 1; - MotorOn = 1; - START_TIMEOUT(); - /* wait for IRQ */ -} - - -static void fd_calibrate_done(int status) -{ - DPRINT(("fd_calibrate_done()\n")); - STOP_TIMEOUT(); - - /* set the correct speed now */ - if (status & FDC1772STAT_RECNF) { - printk("fd%d: restore failed\n", SelectedDrive); - fd_error(); - } else { - unit[SelectedDrive].track = 0; - fd_seek(); - } -} - - -/* Seek the drive to the requested track. The drive must have been - * calibrated at some point before this. - */ - -static void fd_seek(void) -{ - unsigned long flags; - DPRINT(("fd_seek() to track %d (unit[SelectedDrive].track=%d)\n", ReqTrack, - unit[SelectedDrive].track)); - if (unit[SelectedDrive].track == ReqTrack << - unit[SelectedDrive].disktype->stretch) { - fd_seek_done(0); - return; - } - FDC1772_WRITE(FDC1772REG_DATA, ReqTrack << - unit[SelectedDrive].disktype->stretch); - udelay(25); - save_flags(flags); - clf(); - SET_IRQ_HANDLER(fd_seek_done); - FDC1772_WRITE(FDC1772REG_CMD, FDC1772CMD_SEEK | unit[SelectedDrive].steprate | - /* DAG */ - (MotorOn?FDC1772CMDADD_H:0)); - - restore_flags(flags); - MotorOn = 1; - set_head_settle_flag(); - START_TIMEOUT(); - /* wait for IRQ */ -} - - -static void fd_seek_done(int status) -{ - DPRINT(("fd_seek_done()\n")); - STOP_TIMEOUT(); - - /* set the correct speed */ - if (status & FDC1772STAT_RECNF) { - printk("fd%d: seek error (to track %d)\n", - SelectedDrive, ReqTrack); - /* we don't know exactly which track we are on now! */ - unit[SelectedDrive].track = -1; - fd_error(); - } else { - unit[SelectedDrive].track = ReqTrack << - unit[SelectedDrive].disktype->stretch; - NeedSeek = 0; - fd_rwsec(); - } -} - - -/* This does the actual reading/writing after positioning the head - * over the correct track. - */ - -#ifdef TRACKBUFFER -static int MultReadInProgress = 0; -#endif - - -static void fd_rwsec(void) -{ - unsigned long paddr, flags; - unsigned int rwflag, old_motoron; - unsigned int track; - - DPRINT(("fd_rwsec(), Sec=%d, Access=%c\n", ReqSector, ReqCmd == WRITE ? 'w' : 'r')); - if (ReqCmd == WRITE) { - /*cache_push( (unsigned long)ReqData, 512 ); */ - paddr = (unsigned long) ReqData; - rwflag = 0x100; - } else { - paddr = (unsigned long) PhysDMABuffer; -#ifdef TRACKBUFFER - if (read_track) - paddr = (unsigned long)PhysTrackBuffer; -#endif - rwflag = 0; - } - - DPRINT(("fd_rwsec() before sidesel rwflag=%d sec=%d trk=%d\n", rwflag, - ReqSector, FDC1772_READ(FDC1772REG_TRACK))); - fd_select_side(ReqSide); - - /*DPRINT(("fd_rwsec() before start sector \n")); */ - /* Start sector of this operation */ -#ifdef TRACKBUFFER - FDC1772_WRITE( FDC1772REG_SECTOR, !read_track ? ReqSector : 1 ); -#else - FDC1772_WRITE( FDC1772REG_SECTOR, ReqSector ); -#endif - - /* Cheat for track if stretch != 0 */ - if (unit[SelectedDrive].disktype->stretch) { - track = FDC1772_READ(FDC1772REG_TRACK); - FDC1772_WRITE(FDC1772REG_TRACK, track >> - unit[SelectedDrive].disktype->stretch); - } - udelay(25); - - DPRINT(("fd_rwsec() before setup DMA \n")); - /* Setup DMA - Heavily modified by DAG */ - save_flags(flags); - clf(); - disable_dma(FLOPPY_DMA); - set_dma_mode(FLOPPY_DMA, rwflag ? DMA_MODE_WRITE : DMA_MODE_READ); - set_dma_addr(FLOPPY_DMA, (long) paddr); /* DAG - changed from Atari specific */ -#ifdef TRACKBUFFER - set_dma_count(FLOPPY_DMA,(!read_track ? 1 : unit[SelectedDrive].disktype->spt)*512); -#else - set_dma_count(FLOPPY_DMA, 512); /* Block/sector size - going to have to change */ -#endif - SET_IRQ_HANDLER(fd_rwsec_done); - /* Turn on dma int */ - enable_dma(FLOPPY_DMA); - /* Now give it something to do */ - FDC1772_WRITE(FDC1772REG_CMD, (rwflag ? (FDC1772CMD_WRSEC | FDC1772CMDADD_P) : -#ifdef TRACKBUFFER - (FDC1772CMD_RDSEC | (read_track ? FDC1772CMDADD_M : 0) | - /* Hmm - the idea here is to stop the FDC spinning the disc - up when we know that we already still have it spinning */ - (MotorOn?FDC1772CMDADD_H:0)) -#else - FDC1772CMD_RDSEC -#endif - )); - - restore_flags(flags); - DPRINT(("fd_rwsec() after DMA setup flags=0x%08x\n", flags)); - /*sti(); *//* DAG - Hmm */ - /* Hmm - should do something DAG */ - old_motoron = MotorOn; - MotorOn = 1; - NeedSeek = 1; - - /* wait for interrupt */ - -#ifdef TRACKBUFFER - if (read_track) { - /* - * If reading a whole track, wait about one disk rotation and - * then check if all sectors are read. The FDC will even - * search for the first non-existant sector and need 1 sec to - * recognise that it isn't present :-( - */ - /* 1 rot. + 5 rot.s if motor was off */ - mod_timer(&readtrack_timer, jiffies + HZ/5 + (old_motoron ? 0 : HZ)); - DPRINT(("Setting readtrack_timer to %d @ %d\n", - readtrack_timer.expires,jiffies)); - MultReadInProgress = 1; - } -#endif - - /*DPRINT(("fd_rwsec() before START_TIMEOUT \n")); */ - START_TIMEOUT(); - /*DPRINT(("fd_rwsec() after START_TIMEOUT \n")); */ -} - - -#ifdef TRACKBUFFER - -static void fd_readtrack_check(unsigned long dummy) -{ - unsigned long flags, addr; - extern unsigned char *fdc1772_dataaddr; - - DPRINT(("fd_readtrack_check @ %d\n",jiffies)); - - save_flags(flags); - clf(); - - del_timer( &readtrack_timer ); - - if (!MultReadInProgress) { - /* This prevents a race condition that could arise if the - * interrupt is triggered while the calling of this timer - * callback function takes place. The IRQ function then has - * already cleared 'MultReadInProgress' when control flow - * gets here. - */ - restore_flags(flags); - return; - } - - /* get the current DMA address */ - addr=(unsigned long)fdc1772_dataaddr; /* DAG - ? */ - DPRINT(("fd_readtrack_check: addr=%x PhysTrackBuffer=%x\n",addr,PhysTrackBuffer)); - - if (addr >= (unsigned int)PhysTrackBuffer + unit[SelectedDrive].disktype->spt*512) { - /* already read enough data, force an FDC interrupt to stop - * the read operation - */ - SET_IRQ_HANDLER( NULL ); - restore_flags(flags); - DPRINT(("fd_readtrack_check(): done\n")); - FDC1772_WRITE( FDC1772REG_CMD, FDC1772CMD_FORCI ); - udelay(25); - - /* No error until now -- the FDC would have interrupted - * otherwise! - */ - fd_rwsec_done( 0 ); - } else { - /* not yet finished, wait another tenth rotation */ - restore_flags(flags); - DPRINT(("fd_readtrack_check(): not yet finished\n")); - readtrack_timer.expires = jiffies + HZ/5/10; - add_timer( &readtrack_timer ); - } -} - -#endif - -static void fd_rwsec_done(int status) -{ - unsigned int track; - - DPRINT(("fd_rwsec_done() status=%d @ %d\n", status,jiffies)); - -#ifdef TRACKBUFFER - if (read_track && !MultReadInProgress) - return; - - MultReadInProgress = 0; - - STOP_TIMEOUT(); - - if (read_track) - del_timer( &readtrack_timer ); -#endif - - - /* Correct the track if stretch != 0 */ - if (unit[SelectedDrive].disktype->stretch) { - track = FDC1772_READ(FDC1772REG_TRACK); - FDC1772_WRITE(FDC1772REG_TRACK, track << - unit[SelectedDrive].disktype->stretch); - } - if (ReqCmd == WRITE && (status & FDC1772STAT_WPROT)) { - printk("fd%d: is write protected\n", SelectedDrive); - goto err_end; - } - if ((status & FDC1772STAT_RECNF) -#ifdef TRACKBUFFER - /* RECNF is no error after a multiple read when the FDC - * searched for a non-existant sector! - */ - && !(read_track && - FDC1772_READ(FDC1772REG_SECTOR) > unit[SelectedDrive].disktype->spt) -#endif - ) { - if (Probing) { - if (unit[SelectedDrive].disktype > disk_type) { - /* try another disk type */ - unit[SelectedDrive].disktype--; - set_capacity(disks[SelectedDrive], - unit[SelectedDrive].disktype->blocks); - } else - Probing = 0; - } else { - /* record not found, but not probing. Maybe stretch wrong ? Restart probing */ - if (unit[SelectedDrive].autoprobe) { - unit[SelectedDrive].disktype = disk_type + NUM_DISK_TYPES - 1; - set_capacity(disks[SelectedDrive], - unit[SelectedDrive].disktype->blocks); - Probing = 1; - } - } - if (Probing) { - setup_req_params(SelectedDrive); -#ifdef TRACKBUFFER - BufferDrive = -1; -#endif - do_fd_action(SelectedDrive); - return; - } - printk("fd%d: sector %d not found (side %d, track %d)\n", - SelectedDrive, FDC1772_READ(FDC1772REG_SECTOR), ReqSide, ReqTrack); - goto err_end; - } - if (status & FDC1772STAT_CRC) { - printk("fd%d: CRC error (side %d, track %d, sector %d)\n", - SelectedDrive, ReqSide, ReqTrack, FDC1772_READ(FDC1772REG_SECTOR)); - goto err_end; - } - if (status & FDC1772STAT_LOST) { - printk("fd%d: lost data (side %d, track %d, sector %d)\n", - SelectedDrive, ReqSide, ReqTrack, FDC1772_READ(FDC1772REG_SECTOR)); - goto err_end; - } - Probing = 0; - - if (ReqCmd == READ) { -#ifdef TRACKBUFFER - if (!read_track) { - /*cache_clear (PhysDMABuffer, 512);*/ - copy_buffer (DMABuffer, ReqData); - } else { - /*cache_clear (PhysTrackBuffer, FD1772_MAX_SECTORS * 512);*/ - BufferDrive = SelectedDrive; - BufferSide = ReqSide; - BufferTrack = ReqTrack; - copy_buffer (SECTOR_BUFFER (ReqSector), ReqData); - } -#else - /*cache_clear( PhysDMABuffer, 512 ); */ - copy_buffer(DMABuffer, ReqData); -#endif - } - if (++ReqCnt < CURRENT->current_nr_sectors) { - /* read next sector */ - setup_req_params(SelectedDrive); - do_fd_action(SelectedDrive); - } else { - /* all sectors finished */ - CURRENT->nr_sectors -= CURRENT->current_nr_sectors; - CURRENT->sector += CURRENT->current_nr_sectors; - end_request(CURRENT, 1); - redo_fd_request(); - } - return; - -err_end: -#ifdef TRACKBUFFER - BufferDrive = -1; -#endif - - fd_error(); -} - - -static void fd_times_out(unsigned long dummy) -{ - SET_IRQ_HANDLER(NULL); - /* If the timeout occurred while the readtrack_check timer was - * active, we need to cancel it, else bad things will happen */ - del_timer( &readtrack_timer ); - FDC1772_WRITE(FDC1772REG_CMD, FDC1772CMD_FORCI); - udelay(25); - - printk("floppy timeout\n"); - STOP_TIMEOUT(); /* hmm - should we do this ? */ - fd_error(); -} - - -/* The (noop) seek operation here is needed to make the WP bit in the - * FDC1772 status register accessible for check_change. If the last disk - * operation would have been a RDSEC, this bit would always read as 0 - * no matter what :-( To save time, the seek goes to the track we're - * already on. - */ - -static void finish_fdc(void) -{ - /* DAG - just try without this dummy seek! */ - finish_fdc_done(0); - return; - - if (!NeedSeek) { - finish_fdc_done(0); - } else { - DPRINT(("finish_fdc: dummy seek started\n")); - FDC1772_WRITE(FDC1772REG_DATA, unit[SelectedDrive].track); - SET_IRQ_HANDLER(finish_fdc_done); - FDC1772_WRITE(FDC1772REG_CMD, FDC1772CMD_SEEK); - MotorOn = 1; - START_TIMEOUT(); - /* we must wait for the IRQ here, because the ST-DMA is - * released immediately afterwards and the interrupt may be - * delivered to the wrong driver. - */ - } -} - - -static void finish_fdc_done(int dummy) -{ - unsigned long flags; - - DPRINT(("finish_fdc_done entered\n")); - STOP_TIMEOUT(); - NeedSeek = 0; - - if (timer_pending(&fd_timer) && - time_after(jiffies + 5, fd_timer.expires)) - /* If the check for a disk change is done too early after this - * last seek command, the WP bit still reads wrong :-(( - */ - mod_timer(&fd_timer, jiffies + 5); - else { - /* START_CHECK_CHANGE_TIMER( CHECK_CHANGE_DELAY ); */ - }; - del_timer(&motor_off_timer); - START_MOTOR_OFF_TIMER(FD_MOTOR_OFF_DELAY); - - save_flags(flags); - cli(); - /* stdma_release(); - not sure if I should do something DAG */ - fdc_busy = 0; - wake_up(&fdc_wait); - restore_flags(flags); - - DPRINT(("finish_fdc() finished\n")); -} - - -/* Prevent "aliased" accesses. */ -static int fd_ref[4]; -static int fd_device[4]; - -/* dummy for blk.h */ -static void floppy_off(unsigned int nr) -{ -} - - -/* On the old arcs write protect depends on the particular model - of machine. On the A310, R140, and A440 there is a disc changed - detect, however on the A4x0/1 range there is not. There - is nothing to tell you which machine your on. - At the moment I'm just marking changed always. I've - left the Atari's 'change on write protect change' code in this - part (but nothing sets it). - RiscOS apparently checks the disc serial number etc. to detect changes - - but if it sees a disc change line go high (?) it flips to using - it. Well maybe I'll add that in the future (!?) -*/ -static int check_floppy_change(struct gendisk *disk) -{ - struct archy_floppy_struct *p = disk->private_data; - unsigned int drive = p - unit; - - if (test_bit(drive, &fake_change)) { - /* simulated change (e.g. after formatting) */ - return 1; - } - if (test_bit(drive, &changed_floppies)) { - /* surely changed (the WP signal changed at least once) */ - return 1; - } - if (p->wpstat) { - /* WP is on -> could be changed: to be sure, buffers should be - * invalidated... - */ - return 1; - } - return 1; /* DAG - was 0 */ -} - -static int floppy_revalidate(struct gendisk *disk) -{ - struct archy_floppy_struct *p = disk->private_data; - unsigned int drive = p - unit; - - if (test_bit(drive, &changed_floppies) || test_bit(drive, &fake_change) - || unit[drive].disktype == 0) { -#ifdef TRACKBUFFER - BufferDrive = -1; -#endif - clear_bit(drive, &fake_change); - clear_bit(drive, &changed_floppies); - p->disktype = 0; - } - return 0; -} - -/* This sets up the global variables describing the current request. */ - -static void setup_req_params(int drive) -{ - int block = ReqBlock + ReqCnt; - - ReqTrack = block / unit[drive].disktype->spt; - ReqSector = block - ReqTrack * unit[drive].disktype->spt + 1; - ReqSide = ReqTrack & 1; - ReqTrack >>= 1; - ReqData = ReqBuffer + 512 * ReqCnt; - -#ifdef TRACKBUFFER - read_track = (ReqCmd == READ && CURRENT->errors == 0); -#endif - - DPRINT(("Request params: Si=%d Tr=%d Se=%d Data=%08lx\n", ReqSide, - ReqTrack, ReqSector, (unsigned long) ReqData)); -} - - -static void redo_fd_request(void) -{ - int drive, type; - struct archy_floppy_struct *floppy; - - DPRINT(("redo_fd_request: CURRENT=%p dev=%s CURRENT->sector=%ld\n", - CURRENT, CURRENT ? CURRENT->rq_disk->disk_name : "", - CURRENT ? CURRENT->sector : 0)); - -repeat: - - if (!CURRENT) - goto the_end; - - floppy = CURRENT->rq_disk->private_data; - drive = floppy - unit; - type = fd_device[drive]; - - if (!floppy->connected) { - /* drive not connected */ - printk("Unknown Device: fd%d\n", drive); - end_request(CURRENT, 0); - goto repeat; - } - if (type == 0) { - if (!floppy->disktype) { - Probing = 1; - floppy->disktype = disk_type + NUM_DISK_TYPES - 1; - set_capacity(disks[drive], floppy->disktype->blocks); - floppy->autoprobe = 1; - } - } else { - /* user supplied disk type */ - --type; - if (type >= NUM_DISK_TYPES) { - printk("fd%d: invalid disk format", drive); - end_request(CURRENT, 0); - goto repeat; - } - floppy->disktype = &disk_type[type]; - set_capacity(disks[drive], floppy->disktype->blocks); - floppy->autoprobe = 0; - } - - if (CURRENT->sector + 1 > floppy->disktype->blocks) { - end_request(CURRENT, 0); - goto repeat; - } - /* stop deselect timer */ - del_timer(&motor_off_timer); - - ReqCnt = 0; - ReqCmd = rq_data_dir(CURRENT); - ReqBlock = CURRENT->sector; - ReqBuffer = CURRENT->buffer; - setup_req_params(drive); - do_fd_action(drive); - - return; - -the_end: - finish_fdc(); -} - -static void fd1772_checkint(void) -{ - extern int fdc1772_bytestogo; - - /*printk("fd1772_checkint %d\n",fdc1772_fdc_int_done);*/ - if (fdc1772_fdc_int_done) - floppy_irqconsequencehandler(); - if ((MultReadInProgress) && (fdc1772_bytestogo==0)) fd_readtrack_check(0); - if (fdc_busy) { - schedule_work(&fd1772_tq); - } -} - -static void do_fd_request(struct request_queue* q) -{ - unsigned long flags; - - DPRINT(("do_fd_request for pid %d\n", current->pid)); - if (fdc_busy) return; - save_flags(flags); - cli(); - wait_event(fdc_wait, !fdc_busy); - fdc_busy = 1; - ENABLE_IRQ(); - restore_flags(flags); - - fdc1772_fdc_int_done = 0; - - redo_fd_request(); - - schedule_work(&fd1772_tq); -} - - -static int invalidate_drive(struct block_device *bdev) -{ - struct archy_floppy_struct *p = bdev->bd_disk->private_data; - /* invalidate the buffer track to force a reread */ -#ifdef TRACKBUFFER - BufferDrive = -1; -#endif - - set_bit(p - unit, &fake_change); - return 0; -} - -static int fd_ioctl(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long param) -{ - struct block_device *bdev = inode->i_bdev; - - switch (cmd) { - case FDFMTEND: - case FDFLUSH: - invalidate_drive(bdev); - check_disk_change(bdev); - case FDFMTBEG: - return 0; - default: - return -EINVAL; - } -} - - -/* Initialize the 'unit' variable for drive 'drive' */ - -static void fd_probe(int drive) -{ - unit[drive].connected = 0; - unit[drive].disktype = NULL; - - if (!fd_test_drive_present(drive)) - return; - - unit[drive].connected = 1; - unit[drive].track = -1; /* If we put the auto detect back in this can go to 0 */ - unit[drive].steprate = FDC1772STEP_6; - MotorOn = 1; /* from probe restore operation! */ -} - - -/* This function tests the physical presence of a floppy drive (not - * whether a disk is inserted). This is done by issuing a restore - * command, waiting max. 2 seconds (that should be enough to move the - * head across the whole disk) and looking at the state of the "TR00" - * signal. This should now be raised if there is a drive connected - * (and there is no hardware failure :-) Otherwise, the drive is - * declared absent. - */ - -static int fd_test_drive_present(int drive) -{ - unsigned long timeout; - unsigned char status; - int ok; - - printk("fd_test_drive_present %d\n", drive); - if (drive > 1) - return (0); - return (1); /* Simple hack for the moment - the autodetect doesn't seem to work on arc */ - fd_select_drive(drive); - - /* disable interrupt temporarily */ - DISABLE_IRQ(); - FDC1772_WRITE(FDC1772REG_TRACK, 0x00); /* was ff00 why? */ - FDC1772_WRITE(FDC1772REG_CMD, FDC1772CMD_RESTORE | FDC1772CMDADD_H | FDC1772STEP_6); - - /*printk("fd_test_drive_present: Going into timeout loop\n"); */ - for (ok = 0, timeout = jiffies + 2 * HZ + HZ / 2; time_before(jiffies, timeout);) { - /* What does this piece of atariism do? - query for an interrupt? */ - /* if (!(mfp.par_dt_reg & 0x20)) - break; */ - /* Well this is my nearest guess - quit when we get an FDC interrupt */ - if (ioc_readb(IOC_FIQSTAT) & 2) - break; - } - - /*printk("fd_test_drive_present: Coming out of timeout loop\n"); */ - status = FDC1772_READ(FDC1772REG_STATUS); - ok = (status & FDC1772STAT_TR00) != 0; - - /*printk("fd_test_drive_present: ok=%d\n",ok); */ - /* force interrupt to abort restore operation (FDC1772 would try - * about 50 seconds!) */ - FDC1772_WRITE(FDC1772REG_CMD, FDC1772CMD_FORCI); - udelay(500); - status = FDC1772_READ(FDC1772REG_STATUS); - udelay(20); - /*printk("fd_test_drive_present: just before OK code %d\n",ok); */ - - if (ok) { - /* dummy seek command to make WP bit accessible */ - FDC1772_WRITE(FDC1772REG_DATA, 0); - FDC1772_WRITE(FDC1772REG_CMD, FDC1772CMD_SEEK); - printk("fd_test_drive_present: just before wait for int\n"); - /* DAG: Guess means wait for interrupt */ - while (!(ioc_readb(IOC_FIQSTAT) & 2)); - printk("fd_test_drive_present: just after wait for int\n"); - status = FDC1772_READ(FDC1772REG_STATUS); - } - printk("fd_test_drive_present: just before ENABLE_IRQ\n"); - ENABLE_IRQ(); - printk("fd_test_drive_present: about to return\n"); - return (ok); -} - - -/* Look how many and which kind of drives are connected. If there are - * floppies, additionally start the disk-change and motor-off timers. - */ - -static void config_types(void) -{ - int drive, cnt = 0; - - printk("Probing floppy drive(s):\n"); - for (drive = 0; drive < FD_MAX_UNITS; drive++) { - fd_probe(drive); - if (unit[drive].connected) { - printk("fd%d\n", drive); - ++cnt; - } - } - - if (FDC1772_READ(FDC1772REG_STATUS) & FDC1772STAT_BUSY) { - /* If FDC1772 is still busy from probing, give it another FORCI - * command to abort the operation. If this isn't done, the FDC1772 - * will interrupt later and its IRQ line stays low, because - * the status register isn't read. And this will block any - * interrupts on this IRQ line :-( - */ - FDC1772_WRITE(FDC1772REG_CMD, FDC1772CMD_FORCI); - udelay(500); - FDC1772_READ(FDC1772REG_STATUS); - udelay(20); - } - if (cnt > 0) { - START_MOTOR_OFF_TIMER(FD_MOTOR_OFF_DELAY); - if (cnt == 1) - fd_select_drive(0); - /*START_CHECK_CHANGE_TIMER( CHECK_CHANGE_DELAY ); */ - } -} - -/* - * floppy_open check for aliasing (/dev/fd0 can be the same as - * /dev/PS0 etc), and disallows simultaneous access to the same - * drive with different device numbers. - */ - -static int floppy_open(struct inode *inode, struct file *filp) -{ - int drive = iminor(inode) & 3; - int type = iminor(inode) >> 2; - int old_dev = fd_device[drive]; - - if (fd_ref[drive] && old_dev != type) - return -EBUSY; - - if (fd_ref[drive] == -1 || (fd_ref[drive] && filp->f_flags & O_EXCL)) - return -EBUSY; - - if (filp->f_flags & O_EXCL) - fd_ref[drive] = -1; - else - fd_ref[drive]++; - - fd_device[drive] = type; - - if (filp->f_flags & O_NDELAY) - return 0; - - if (filp->f_mode & 3) { - check_disk_change(inode->i_bdev); - if (filp->f_mode & 2) { - if (unit[drive].wpstat) { - floppy_release(inode, filp); - return -EROFS; - } - } - } - return 0; -} - - -static int floppy_release(struct inode *inode, struct file *filp) -{ - int drive = iminor(inode) & 3; - - if (fd_ref[drive] < 0) - fd_ref[drive] = 0; - else if (!fd_ref[drive]--) { - printk("floppy_release with fd_ref == 0"); - fd_ref[drive] = 0; - } - - return 0; -} - -static struct block_device_operations floppy_fops = -{ - .open = floppy_open, - .release = floppy_release, - .ioctl = fd_ioctl, - .media_changed = check_floppy_change, - .revalidate_disk= floppy_revalidate, -}; - -static struct kobject *floppy_find(dev_t dev, int *part, void *data) -{ - int drive = *part & 3; - if ((*part >> 2) > NUM_DISK_TYPES || drive >= FD_MAX_UNITS) - return NULL; - *part = 0; - return get_disk(disks[drive]); -} - -int fd1772_init(void) -{ - static DEFINE_SPINLOCK(lock); - int i, err = -ENOMEM; - - if (!machine_is_archimedes()) - return 0; - - for (i = 0; i < FD_MAX_UNITS; i++) { - disks[i] = alloc_disk(1); - if (!disks[i]) - goto err_disk; - } - - err = register_blkdev(MAJOR_NR, "fd"); - if (err) - goto err_disk; - - err = -EBUSY; - if (request_dma(FLOPPY_DMA, "fd1772")) { - printk("Unable to grab DMA%d for the floppy (1772) driver\n", FLOPPY_DMA); - goto err_blkdev; - }; - - if (request_dma(FIQ_FD1772, "fd1772 end")) { - printk("Unable to grab DMA%d for the floppy (1772) driver\n", FIQ_FD1772); - goto err_dma1; - }; - - /* initialize variables */ - SelectedDrive = -1; -#ifdef TRACKBUFFER - BufferDrive = BufferSide = BufferTrack = -1; - /* Atari uses 512 - I want to eventually cope with 1K sectors */ - DMABuffer = kmalloc((FD1772_MAX_SECTORS+1)*512,GFP_KERNEL); - TrackBuffer = DMABuffer + 512; -#else - /* Allocate memory for the DMAbuffer - on the Atari this takes it - out of some special memory... */ - DMABuffer = kmalloc(2048); /* Copes with pretty large sectors */ -#endif - err = -ENOMEM; - if (!DMAbuffer) - goto err_dma2; - - enable_dma(FIQ_FD1772); /* This inserts a call to our command end routine */ - - floppy_queue = blk_init_queue(do_fd_request, &lock); - if (!floppy_queue) - goto err_queue; - - for (i = 0; i < FD_MAX_UNITS; i++) { - unit[i].track = -1; - disks[i]->major = MAJOR_NR; - disks[i]->first_minor = 0; - disks[i]->fops = &floppy_fops; - sprintf(disks[i]->disk_name, "fd%d", i); - disks[i]->private_data = &unit[i]; - disks[i]->queue = floppy_queue; - set_capacity(disks[i], MAX_DISK_SIZE * 2); - } - blk_register_region(MKDEV(MAJOR_NR, 0), 256, THIS_MODULE, - floppy_find, NULL, NULL); - - for (i = 0; i < FD_MAX_UNITS; i++) - add_disk(disks[i]); - - config_types(); - - return 0; - - err_queue: - kfree(DMAbuffer); - err_dma2: - free_dma(FIQ_FD1772); - - err_dma1: - free_dma(FLOPPY_DMA); - - err_blkdev: - unregister_blkdev(MAJOR_NR, "fd"); - - err_disk: - while (i--) - put_disk(disks[i]); - return err; -} diff --git a/drivers/acorn/block/fd1772dma.S b/drivers/acorn/block/fd1772dma.S deleted file mode 100644 index 7964435443e..00000000000 --- a/drivers/acorn/block/fd1772dma.S +++ /dev/null @@ -1,100 +0,0 @@ -#include <asm/hardware.h> - -@ Code for DMA with the 1772 fdc -.text - - - .global fdc1772_dataaddr -fdc1772_fiqdata: -@ Number of bytes left to DMA - .global fdc1772_bytestogo -fdc1772_bytestogo: - .word 0 -@ Place to put/get data from in DMA - .global fdc1772_dataaddr -fdc1772_dataaddr: - .word 0 - - .global fdc1772_fdc_int_done -fdc1772_fdc_int_done: - .word 0 - .global fdc1772_comendstatus -fdc1772_comendstatus: - .word 0 - -@ We hang this off DMA channel 1 - .global fdc1772_comendhandler -fdc1772_comendhandler: - mov r8,#IOC_BASE - ldrb r9,[r8,#0x34] @ IOC FIQ status - tst r9,#2 - subeqs pc,r14,#4 @ should I leave a space here - orr r9,r8,#0x10000 @ FDC base - adr r8,fdc1772_fdc_int_done - ldrb r10,[r9,#0] @ FDC status - mov r9,#1 @ Got a FIQ flag - stmia r8,{r9,r10} - subs pc,r14,#4 - - - .global fdc1772_dma_read -fdc1772_dma_read: - mov r8,#IOC_BASE - ldrb r9,[r8,#0x34] @ IOC FIQ status - tst r9,#1 - beq fdc1772_dma_read_notours - orr r8,r8,#0x10000 @ FDC base - ldrb r10,[r8,#0xc] @ Read from FDC data reg (also clears interrupt) - ldmia r11,{r8,r9} - subs r8,r8,#1 @ One less byte to go - @ If there was somewhere for this data to go then store it and update pointers - strplb r10,[r9],#1 @ Store the data and increment the pointer - stmplia r11,{r8,r9} @ Update count/pointers - @ Handle any other interrupts if there are any -fdc1772_dma_read_notours: - @ Cant branch because this code has been copied down to the FIQ vector - ldr pc,[pc,#-4] - .word fdc1772_comendhandler - .global fdc1772_dma_read_end -fdc1772_dma_read_end: - - .global fdc1772_dma_write -fdc1772_dma_write: - mov r8,#IOC_BASE - ldrb r9,[r8,#0x34] @ IOC FIQ status - tst r9,#1 - beq fdc1772_dma_write_notours - orr r8,r8,#0x10000 @ FDC base - ldmia r11,{r9,r10} - subs r9,r9,#1 @ One less byte to go - @ If there really is some data then get it, store it and update count - ldrplb r12,[r10],#1 - strplb r12,[r8,#0xc] @ write it to FDC data reg - stmplia r11,{r9,r10} @ Update count and pointer - should clear interrupt - @ Handle any other interrupts -fdc1772_dma_write_notours: - @ Cant branch because this code has been copied down to the FIQ vector - ldr pc,[pc,#-4] - .word fdc1772_comendhandler - - .global fdc1772_dma_write_end -fdc1772_dma_write_end: - - -@ Setup the FIQ R11 to point to the data and store the count, address -@ for this dma -@ R0=count -@ R1=address - .global fdc1772_setupdma -fdc1772_setupdma: - @ The big job is flipping in and out of FIQ mode - adr r2,fdc1772_fiqdata @ This is what we really came here for - stmia r2,{r0,r1} - mov r3, pc - teqp pc,#0x0c000001 @ Disable FIQs, IRQs and switch to FIQ mode - mov r0,r0 @ NOP - mov r11,r2 - teqp r3,#0 @ Normal mode - mov r0,r0 @ NOP - mov pc,r14 - diff --git a/drivers/acorn/block/mfm.S b/drivers/acorn/block/mfm.S deleted file mode 100644 index c90cbd41ce2..00000000000 --- a/drivers/acorn/block/mfm.S +++ /dev/null @@ -1,162 +0,0 @@ -@ Read/Write DMA code for the ST506/MFM hard drive controllers on the A400 Acorn Archimedes -@ motherboard and on ST506 expansion podules. -@ (c) David Alan Gilbert (linux@treblig.org) 1996-1999 - -#include <asm/assembler.h> - -hdc63463_irqdata: -@ Controller base address - .global hdc63463_baseaddress -hdc63463_baseaddress: - .word 0 - - .global hdc63463_irqpolladdress -hdc63463_irqpolladdress: - .word 0 - - .global hdc63463_irqpollmask -hdc63463_irqpollmask: - .word 0 - -@ where to read/write data from the kernel data space - .global hdc63463_dataptr -hdc63463_dataptr: - .word 0 - -@ Number of bytes left to transfer - .global hdc63463_dataleft -hdc63463_dataleft: - .word 0 - -@ ------------------------------------------------------------------------- -@ hdc63463_writedma: DMA from host to controller -@ internal reg usage: r0=hdc base address, r1=irq poll address, r2=poll mask -@ r3=data ptr, r4=data left, r5,r6=temporary - .global hdc63463_writedma -hdc63463_writedma: - stmfd sp!,{r4-r7} - adr r5,hdc63463_irqdata - ldmia r5,{r0,r1,r2,r3,r4} - -writedma_again: - - @ test number of remaining bytes to transfer - cmp r4,#0 - beq writedma_end - bmi writedma_end - - @ Check the hdc is interrupting - ldrb r5,[r1,#0] - tst r5,r2 - beq writedma_end - - @ Transfer a block of upto 256 bytes - cmp r4,#256 - movlt r7,r4 - movge r7,#256 - - @ Check the hdc is still busy and command has not ended and no errors - ldr r5,[r0,#32] @ Status reg - 16 bit - its the top few bits which are status - @ think we should continue DMA until it drops busy - perhaps this was - @ the main problem with corrected errors causing a hang - @tst r5,#0x3c00 @ Test for things which should be off - @bne writedma_end - and r5,r5,#0x8000 @ This is test for things which should be on: Busy - cmp r5,#0x8000 - bne writedma_end - - @ Bytes remaining at end - sub r4,r4,r7 - - @ HDC Write register location - add r0,r0,#32+8 - -writedma_loop: - @ OK - pretty sure we should be doing this - - ldr r5,[r3],#4 @ Get a word to be written - @ get bottom half to be sent first - mov r6,r5,lsl#16 @ Separate the first 2 bytes - orr r2,r6,r6,lsr #16 @ Duplicate them in the bottom half of the word - @ now the top half - mov r6,r5,lsr#16 @ Get 2nd 2 bytes - orr r6,r6,r6,lsl#16 @ Duplicate - @str r6,[r0] @ to hdc - stmia r0,{r2,r6} - subs r7,r7,#4 @ Dec. number of bytes left - bne writedma_loop - - @ If we were too slow we had better go through again - DAG - took out with new interrupt routine - @ sub r0,r0,#32+8 - @ adr r2,hdc63463_irqdata - @ ldr r2,[r2,#8] - @ b writedma_again - -writedma_end: - adr r5,hdc63463_irqdata+12 - stmia r5,{r3,r4} - ldmfd sp!,{r4-r7} - RETINSTR(mov,pc,lr) - -@ ------------------------------------------------------------------------- -@ hdc63463_readdma: DMA from controller to host -@ internal reg usage: r0=hdc base address, r1=irq poll address, r2=poll mask -@ r3=data ptr, r4=data left, r5,r6=temporary - .global hdc63463_readdma -hdc63463_readdma: - stmfd sp!,{r4-r7} - adr r5,hdc63463_irqdata - ldmia r5,{r0,r1,r2,r3,r4} - -readdma_again: - @ test number of remaining bytes to transfer - cmp r4,#0 - beq readdma_end - bmi readdma_end - - @ Check the hdc is interrupting - ldrb r5,[r1,#0] - tst r5,r2 - beq readdma_end - - @ Check the hdc is still busy and command has not ended and no errors - ldr r5,[r0,#32] @ Status reg - 16 bit - its the top few bits which are status - @ think we should continue DMA until it drops busy - perhaps this was - @ the main problem with corrected errors causing a hang - @tst r5,#0x3c00 @ Test for things which should be off - @bne readdma_end - and r5,r5,#0x8000 @ This is test for things which should be on: Busy - cmp r5,#0x8000 - bne readdma_end - - @ Transfer a block of upto 256 bytes - cmp r4,#256 - movlt r7,r4 - movge r7,#256 - - @ Bytes remaining at end - sub r4,r4,r7 - - @ Set a pointer to the data register in the HDC - add r0,r0,#8 -readdma_loop: - @ OK - pretty sure we should be doing this - ldmia r0,{r5,r6} - mov r5,r5,lsl#16 - mov r6,r6,lsl#16 - orr r6,r6,r5,lsr #16 - str r6,[r3],#4 - subs r7,r7,#4 @ Decrement bytes to go - bne readdma_loop - - @ Try reading multiple blocks - if this was fast enough then I do not think - @ this should help - NO taken out DAG - new interrupt handler has - @ non-consecutive memory blocks - @ sub r0,r0,#8 - @ b readdma_again - -readdma_end: - adr r5,hdc63463_irqdata+12 - stmia r5,{r3,r4} - ldmfd sp!,{r4-r7} - RETINSTR(mov,pc,lr) diff --git a/drivers/acorn/block/mfmhd.c b/drivers/acorn/block/mfmhd.c deleted file mode 100644 index 74058db674d..00000000000 --- a/drivers/acorn/block/mfmhd.c +++ /dev/null @@ -1,1385 +0,0 @@ -/* - * linux/drivers/acorn/block/mfmhd.c - * - * Copyright (C) 1995, 1996 Russell King, Dave Alan Gilbert (gilbertd@cs.man.ac.uk) - * - * MFM hard drive code [experimental] - */ - -/* - * Change list: - * - * 3/2/96:DAG: Started a change list :-) - * Set the hardsect_size pointers up since we are running 256 byte - * sectors - * Added DMA code, put it into the rw_intr - * Moved RCAL out of generic interrupt code - don't want to do it - * while DMA'ing - its now in individual handlers. - * Took interrupt handlers off task queue lists and called - * directly - not sure of implications. - * - * 18/2/96:DAG: Well its reading OK I think, well enough for image file code - * to find the image file; but now I've discovered that I actually - * have to put some code in for image files. - * - * Added stuff for image files; seems to work, but I've not - * got a multisegment image file (I don't think!). - * Put in a hack (yep a real hack) for multiple cylinder reads. - * Not convinced its working. - * - * 5/4/96:DAG: Added asm/hardware.h and use IOC_ macros - * Rewrote dma code in mfm.S (again!) - now takes a word at a time - * from main RAM for speed; still doesn't feel speedy! - * - * 20/4/96:DAG: After rewriting mfm.S a heck of a lot of times and speeding - * things up, I've finally figured out why its so damn slow. - * Linux is only reading a block at a time, and so you never - * get more than 1K per disc revoloution ~=60K/second. - * - * 27/4/96:DAG: On Russell's advice I change ll_rw_blk.c to ask it to - * join adjacent blocks together. Everything falls flat on its - * face. - * Four hours of debugging later; I hadn't realised that - * ll_rw_blk would be so generous as to join blocks whose - * results aren't going into consecutive buffers. - * - * OK; severe rehacking of mfm_rw_interrupt; now end_request's - * as soon as its DMA'd each request. Odd thing is that - * we are sometimes getting interrupts where we are not transferring - * any data; why? Is that what happens when you miss? I doubt - * it; are we too fast? No - its just at command ends. Got 240K/s - * better than before, but RiscOS hits 480K/s - * - * 25/6/96:RMK: Fixed init code to allow the MFM podule to work. Increased the - * number of errors for my Miniscribe drive (8425). - * - * 30/6/96:DAG: Russell suggested that a check drive 0 might turn the LEDs off - * - so in request_done just before it clears Busy it sends a - * check drive 0 - and the LEDs go off!!!! - * - * Added test for mainboard controller. - Removes need for separate - * define. - * - * 13/7/96:DAG: Changed hardware sectore size to 512 in attempt to make - * IM drivers work. - * 21/7/96:DAG: Took out old image file stuff (accessing it now produces an IO - * error.) - * - * 17/8/96:DAG: Ran through indent -kr -i8; evil - all my nice 2 character indents - * gone :-( Hand modified afterwards. - * Took out last remains of the older image map system. - * - * 22/9/96:DAG: Changed mfm.S so it will carry on DMA'ing til; BSY is dropped - * Changed mfm_rw_intr so that it doesn't follow the error - * code until BSY is dropped. Nope - still broke. Problem - * may revolve around when it reads the results for the error - * number? - * - *16/11/96:DAG: Modified for 2.0.18; request_irq changed - * - *17/12/96:RMK: Various cleanups, reorganisation, and the changes for new IO system. - * Improved probe for onboard MFM chip - it was hanging on my A5k. - * Added autodetect CHS code such that we don't rely on the presence - * of an ADFS boot block. Added ioport resource manager calls so - * that we don't clash with already-running hardware (eg. RiscPC Ether - * card slots if someone tries this)! - * - * 17/1/97:RMK: Upgraded to 2.1 kernels. - * - * 4/3/98:RMK: Changed major number to 21. - * - * 27/6/98:RMK: Changed asm/delay.h to linux/delay.h for mdelay(). - */ - -/* - * Possible enhancements: - * Multi-thread the code so that it is possible that while one drive - * is seeking, the other one can be reading data/seeking as well. - * This would be a performance boost with dual drive systems. - */ - -#include <linux/module.h> -#include <linux/fs.h> -#include <linux/interrupt.h> -#include <linux/kernel.h> -#include <linux/timer.h> -#include <linux/mm.h> -#include <linux/errno.h> -#include <linux/genhd.h> -#include <linux/major.h> -#include <linux/ioport.h> -#include <linux/delay.h> -#include <linux/blkpg.h> - -#include <asm/system.h> -#include <asm/io.h> -#include <asm/irq.h> -#include <asm/uaccess.h> -#include <asm/dma.h> -#include <asm/hardware.h> -#include <asm/ecard.h> -#include <asm/hardware/ioc.h> - -static void (*do_mfm)(void) = NULL; -static struct request_queue *mfm_queue; -static DEFINE_SPINLOCK(mfm_lock); - -#define MAJOR_NR MFM_ACORN_MAJOR -#define QUEUE (mfm_queue) -#define CURRENT elv_next_request(mfm_queue) - -/* - * Configuration section - * - * This is the maximum number of drives that we accept - */ -#define MFM_MAXDRIVES 2 -/* - * Linux I/O address of onboard MFM controller or 0 to disable this - */ -#define ONBOARD_MFM_ADDRESS ((0x002d0000 >> 2) | 0x80000000) -/* - * Uncomment this to enable debugging in the MFM driver... - */ -#ifndef DEBUG -/*#define DEBUG */ -#endif -/* - * End of configuration - */ - - -/* - * This structure contains all information to do with a particular physical - * device. - */ -struct mfm_info { - unsigned char sectors; - unsigned char heads; - unsigned short cylinders; - unsigned short lowcurrent; - unsigned short precomp; -#define NO_TRACK -1 -#define NEED_1_RECAL -2 -#define NEED_2_RECAL -3 - int cylinder; - struct { - char recal; - char report; - char abort; - } errors; -} mfm_info[MFM_MAXDRIVES]; - -#define MFM_DRV_INFO mfm_info[raw_cmd.dev] - -/* Stuff from the assembly routines */ -extern unsigned int hdc63463_baseaddress; /* Controller base address */ -extern unsigned int hdc63463_irqpolladdress; /* Address to read to test for int */ -extern unsigned int hdc63463_irqpollmask; /* Mask for irq register */ -extern unsigned int hdc63463_dataptr; /* Pointer to kernel data space to DMA */ -extern int hdc63463_dataleft; /* Number of bytes left to transfer */ - - - - -static int lastspecifieddrive; -static unsigned Busy; - -static unsigned int PartFragRead; /* The number of sectors which have been read - during a partial read split over two - cylinders. If 0 it means a partial - read did not occur. */ - -static unsigned int PartFragRead_RestartBlock; /* Where to restart on a split access */ -static unsigned int PartFragRead_SectorsLeft; /* Where to restart on a split access */ - -static int Sectors256LeftInCurrent; /* i.e. 256 byte sectors left in current */ -static int SectorsLeftInRequest; /* i.e. blocks left in the thing mfm_request was called for */ -static int Copy_Sector; /* The 256 byte sector we are currently at - fragments need to know - where to take over */ -static char *Copy_buffer; - - -static void mfm_seek(void); -static void mfm_rerequest(void); -static void mfm_request(void); -static void mfm_specify (void); -static void issue_request(unsigned int block, unsigned int nsect, - struct request *req); - -static unsigned int mfm_addr; /* Controller address */ -static unsigned int mfm_IRQPollLoc; /* Address to read for IRQ information */ -static unsigned int mfm_irqenable; /* Podule IRQ enable location */ -static unsigned char mfm_irq; /* Interrupt number */ -static int mfm_drives = 0; /* drives available */ -static int mfm_status = 0; /* interrupt status */ -static int *errors; - -static struct rawcmd { - unsigned int dev; - unsigned int cylinder; - unsigned int head; - unsigned int sector; - unsigned int cmdtype; - unsigned int cmdcode; - unsigned char cmddata[16]; - unsigned int cmdlen; -} raw_cmd; - -static unsigned char result[16]; - -static struct cont { - void (*interrupt) (void); /* interrupt handler */ - void (*error) (void); /* error handler */ - void (*redo) (void); /* redo handler */ - void (*done) (int st); /* done handler */ -} *cont = NULL; - -#if 0 -static struct tq_struct mfm_tq = {0, 0, (void (*)(void *)) NULL, 0}; -#endif - -int number_mfm_drives = 1; - -/* ------------------------------------------------------------------------------------------ */ -/* - * From the HD63463 data sheet from Hitachi Ltd. - */ - -#define MFM_COMMAND (mfm_addr + 0) -#define MFM_DATAOUT (mfm_addr + 1) -#define MFM_STATUS (mfm_addr + 8) -#define MFM_DATAIN (mfm_addr + 9) - -#define CMD_ABT 0xF0 /* Abort */ -#define CMD_SPC 0xE8 /* Specify */ -#define CMD_TST 0xE0 /* Test */ -#define CMD_RCLB 0xC8 /* Recalibrate */ -#define CMD_SEK 0xC0 /* Seek */ -#define CMD_WFS 0xAB /* Write Format Skew */ -#define CMD_WFM 0xA3 /* Write Format */ -#define CMD_MTB 0x90 /* Memory to buffer */ -#define CMD_CMPD 0x88 /* Compare data */ -#define CMD_WD 0x87 /* Write data */ -#define CMD_RED 0x70 /* Read erroneous data */ -#define CMD_RIS 0x68 /* Read ID skew */ -#define CMD_FID 0x61 /* Find ID */ -#define CMD_RID 0x60 /* Read ID */ -#define CMD_BTM 0x50 /* Buffer to memory */ -#define CMD_CKD 0x48 /* Check data */ -#define CMD_RD 0x40 /* Read data */ -#define CMD_OPBW 0x38 /* Open buffer write */ -#define CMD_OPBR 0x30 /* Open buffer read */ -#define CMD_CKV 0x28 /* Check drive */ -#define CMD_CKE 0x20 /* Check ECC */ -#define CMD_POD 0x18 /* Polling disable */ -#define CMD_POL 0x10 /* Polling enable */ -#define CMD_RCAL 0x08 /* Recall */ - -#define STAT_BSY 0x8000 /* Busy */ -#define STAT_CPR 0x4000 /* Command Parameter Rejection */ -#define STAT_CED 0x2000 /* Command end */ -#define STAT_SED 0x1000 /* Seek end */ -#define STAT_DER 0x0800 /* Drive error */ -#define STAT_ABN 0x0400 /* Abnormal end */ -#define STAT_POL 0x0200 /* Polling */ - -/* ------------------------------------------------------------------------------------------ */ -#ifdef DEBUG -static void console_printf(const char *fmt,...) -{ - static char buffer[2048]; /* Arbitary! */ - extern void console_print(const char *); - unsigned long flags; - va_list ap; - - local_irq_save(flags); - - va_start(ap, fmt); - vsprintf(buffer, fmt, ap); - console_print(buffer); - va_end(fmt); - - local_irq_restore(flags); -}; /* console_printf */ - -#define DBG(x...) console_printf(x) -#else -#define DBG(x...) -#endif - -static void print_status(void) -{ - char *error; - static char *errors[] = { - "no error", - "command aborted", - "invalid command", - "parameter error", - "not initialised", - "rejected TEST", - "no useld", - "write fault", - "not ready", - "no scp", - "in seek", - "invalid NCA", - "invalid step rate", - "seek error", - "over run", - "invalid PHA", - "data field EEC error", - "data field CRC error", - "error corrected", - "data field fatal error", - "no data am", - "not hit", - "ID field CRC error", - "time over", - "no ID am", - "not writable" - }; - if (result[1] < 0x65) - error = errors[result[1] >> 2]; - else - error = "unknown"; - printk("("); - if (mfm_status & STAT_BSY) printk("BSY "); - if (mfm_status & STAT_CPR) printk("CPR "); - if (mfm_status & STAT_CED) printk("CED "); - if (mfm_status & STAT_SED) printk("SED "); - if (mfm_status & STAT_DER) printk("DER "); - if (mfm_status & STAT_ABN) printk("ABN "); - if (mfm_status & STAT_POL) printk("POL "); - printk(") SSB = %X (%s)\n", result[1], error); - -} - -/* ------------------------------------------------------------------------------------- */ - -static void issue_command(int command, unsigned char *cmdb, int len) -{ - int status; -#ifdef DEBUG - int i; - console_printf("issue_command: %02X: ", command); - for (i = 0; i < len; i++) - console_printf("%02X ", cmdb[i]); - console_printf("\n"); -#endif - - do { - status = inw(MFM_STATUS); - } while (status & (STAT_BSY | STAT_POL)); - DBG("issue_command: status after pol/bsy loop: %02X:\n ", status >> 8); - - if (status & (STAT_CPR | STAT_CED | STAT_SED | STAT_DER | STAT_ABN)) { - outw(CMD_RCAL, MFM_COMMAND); - while (inw(MFM_STATUS) & STAT_BSY); - } - status = inw(MFM_STATUS); - DBG("issue_command: status before parameter issue: %02X:\n ", status >> 8); - - while (len > 0) { - outw(cmdb[1] | (cmdb[0] << 8), MFM_DATAOUT); - len -= 2; - cmdb += 2; - } - status = inw(MFM_STATUS); - DBG("issue_command: status before command issue: %02X:\n ", status >> 8); - - outw(command, MFM_COMMAND); - status = inw(MFM_STATUS); - DBG("issue_command: status immediately after command issue: %02X:\n ", status >> 8); -} - -static void wait_for_completion(void) -{ - while ((mfm_status = inw(MFM_STATUS)) & STAT_BSY); -} - -static void wait_for_command_end(void) -{ - int i; - - while (!((mfm_status = inw(MFM_STATUS)) & STAT_CED)); - - for (i = 0; i < 16;) { - int in; - in = inw(MFM_DATAIN); - result[i++] = in >> 8; - result[i++] = in; - } - outw (CMD_RCAL, MFM_COMMAND); -} - -/* ------------------------------------------------------------------------------------- */ - -static void mfm_rw_intr(void) -{ - int old_status; /* Holds status on entry, we read to see if the command just finished */ -#ifdef DEBUG - console_printf("mfm_rw_intr...dataleft=%d\n", hdc63463_dataleft); - print_status(); -#endif - - /* Now don't handle the error until BSY drops */ - if ((mfm_status & (STAT_DER | STAT_ABN)) && ((mfm_status&STAT_BSY)==0)) { - /* Something has gone wrong - let's try that again */ - outw(CMD_RCAL, MFM_COMMAND); /* Clear interrupt condition */ - if (cont) { - DBG("mfm_rw_intr: DER/ABN err\n"); - cont->error(); - cont->redo(); - }; - return; - }; - - /* OK so what ever happened it's not an error, now I reckon we are left between - a choice of command end or some data which is ready to be collected */ - /* I think we have to transfer data while the interrupt line is on and its - not any other type of interrupt */ - if (rq_data_dir(CURRENT) == WRITE) { - extern void hdc63463_writedma(void); - if ((hdc63463_dataleft <= 0) && (!(mfm_status & STAT_CED))) { - printk("mfm_rw_intr: Apparent DMA write request when no more to DMA\n"); - if (cont) { - cont->error(); - cont->redo(); - }; - return; - }; - hdc63463_writedma(); - } else { - extern void hdc63463_readdma(void); - if ((hdc63463_dataleft <= 0) && (!(mfm_status & STAT_CED))) { - printk("mfm_rw_intr: Apparent DMA read request when no more to DMA\n"); - if (cont) { - cont->error(); - cont->redo(); - }; - return; - }; - DBG("Going to try read dma..............status=0x%x, buffer=%p\n", mfm_status, hdc63463_dataptr); - hdc63463_readdma(); - }; /* Read */ - - if (hdc63463_dataptr != ((unsigned int) Copy_buffer + 256)) { - /* If we didn't actually manage to get any data on this interrupt - but why? We got the interrupt */ - /* Ah - well looking at the status its just when we get command end; so no problem */ - /*console_printf("mfm: dataptr mismatch. dataptr=0x%08x Copy_buffer+256=0x%08p\n", - hdc63463_dataptr,Copy_buffer+256); - print_status(); */ - } else { - Sectors256LeftInCurrent--; - Copy_buffer += 256; - Copy_Sector++; - - /* We have come to the end of this request */ - if (!Sectors256LeftInCurrent) { - DBG("mfm: end_request for CURRENT=0x%p CURRENT(sector=%d current_nr_sectors=%d nr_sectors=%d)\n", - CURRENT, CURRENT->sector, CURRENT->current_nr_sectors, CURRENT->nr_sectors); - - CURRENT->nr_sectors -= CURRENT->current_nr_sectors; - CURRENT->sector += CURRENT->current_nr_sectors; - SectorsLeftInRequest -= CURRENT->current_nr_sectors; - - end_request(CURRENT, 1); - if (SectorsLeftInRequest) { - hdc63463_dataptr = (unsigned int) CURRENT->buffer; - Copy_buffer = CURRENT->buffer; - Sectors256LeftInCurrent = CURRENT->current_nr_sectors * 2; - errors = &(CURRENT->errors); - /* These should match the present calculations of the next logical sector - on the device - Copy_Sector=CURRENT->sector*2; */ - - if (Copy_Sector != CURRENT->sector * 2) -#ifdef DEBUG - /*console_printf*/printk("mfm: Copy_Sector mismatch. Copy_Sector=%d CURRENT->sector*2=%d\n", - Copy_Sector, CURRENT->sector * 2); -#else - printk("mfm: Copy_Sector mismatch! Eek!\n"); -#endif - }; /* CURRENT */ - }; /* Sectors256LeftInCurrent */ - }; - - old_status = mfm_status; - mfm_status = inw(MFM_STATUS); - if (mfm_status & (STAT_DER | STAT_ABN)) { - /* Something has gone wrong - let's try that again */ - if (cont) { - DBG("mfm_rw_intr: DER/ABN error\n"); - cont->error(); - cont->redo(); - }; - return; - }; - - /* If this code wasn't entered due to command_end but there is - now a command end we must read the command results out. If it was - entered like this then mfm_interrupt_handler would have done the - job. */ - if ((!((old_status & (STAT_CPR | STAT_BSY)) == STAT_CPR)) && - ((mfm_status & (STAT_CPR | STAT_BSY)) == STAT_CPR)) { - int len = 0; - while (len < 16) { - int in; - in = inw(MFM_DATAIN); - result[len++] = in >> 8; - result[len++] = in; - }; - }; /* Result read */ - - /*console_printf ("mfm_rw_intr nearexit [%02X]\n", __raw_readb(mfm_IRQPollLoc)); */ - - /* If end of command move on */ - if (mfm_status & (STAT_CED)) { - outw(CMD_RCAL, MFM_COMMAND); /* Clear interrupt condition */ - /* End of command - trigger the next command */ - if (cont) { - cont->done(1); - } - DBG("mfm_rw_intr: returned from cont->done\n"); - } else { - /* Its going to generate another interrupt */ - do_mfm = mfm_rw_intr; - }; -} - -static void mfm_setup_rw(void) -{ - DBG("setting up for rw...\n"); - - do_mfm = mfm_rw_intr; - issue_command(raw_cmd.cmdcode, raw_cmd.cmddata, raw_cmd.cmdlen); -} - -static void mfm_recal_intr(void) -{ -#ifdef DEBUG - console_printf("recal intr - status = "); - print_status(); -#endif - outw(CMD_RCAL, MFM_COMMAND); /* Clear interrupt condition */ - if (mfm_status & (STAT_DER | STAT_ABN)) { - printk("recal failed\n"); - MFM_DRV_INFO.cylinder = NEED_2_RECAL; - if (cont) { - cont->error(); - cont->redo(); - } - return; - } - /* Thats seek end - we are finished */ - if (mfm_status & STAT_SED) { - issue_command(CMD_POD, NULL, 0); - MFM_DRV_INFO.cylinder = 0; - mfm_seek(); - return; - } - /* Command end without seek end (see data sheet p.20) for parallel seek - - we have to send a POL command to wait for the seek */ - if (mfm_status & STAT_CED) { - do_mfm = mfm_recal_intr; - issue_command(CMD_POL, NULL, 0); - return; - } - printk("recal: unknown status\n"); -} - -static void mfm_seek_intr(void) -{ -#ifdef DEBUG - console_printf("seek intr - status = "); - print_status(); -#endif - outw(CMD_RCAL, MFM_COMMAND); /* Clear interrupt condition */ - if (mfm_status & (STAT_DER | STAT_ABN)) { - printk("seek failed\n"); - MFM_DRV_INFO.cylinder = NEED_2_RECAL; - if (cont) { - cont->error(); - cont->redo(); - } - return; - } - if (mfm_status & STAT_SED) { - issue_command(CMD_POD, NULL, 0); - MFM_DRV_INFO.cylinder = raw_cmd.cylinder; - mfm_seek(); - return; - } - if (mfm_status & STAT_CED) { - do_mfm = mfm_seek_intr; - issue_command(CMD_POL, NULL, 0); - return; - } - printk("seek: unknown status\n"); -} - -/* IDEA2 seems to work better - its what RiscOS sets my - * disc to - on its SECOND call to specify! - */ -#define IDEA2 -#ifndef IDEA2 -#define SPEC_SL 0x16 -#define SPEC_SH 0xa9 /* Step pulse high=21, Record Length=001 (256 bytes) */ -#else -#define SPEC_SL 0x00 /* OM2 - SL - step pulse low */ -#define SPEC_SH 0x21 /* Step pulse high=4, Record Length=001 (256 bytes) */ -#endif - -static void mfm_setupspecify (int drive, unsigned char *cmdb) -{ - cmdb[0] = 0x1f; /* OM0 - !SECT,!MOD,!DIF,PADP,ECD,CRCP,CRCI,ACOR */ - cmdb[1] = 0xc3; /* OM1 - DTM,BRST,!CEDM,!SEDM,!DERM,0,AMEX,PSK */ - cmdb[2] = SPEC_SL; /* OM2 - SL - step pulse low */ - cmdb[3] = (number_mfm_drives == 1) ? 0x02 : 0x06; /* 1 or 2 drives */ - cmdb[4] = 0xfc | ((mfm_info[drive].cylinders - 1) >> 8);/* RW time over/high part of number of cylinders */ - cmdb[5] = mfm_info[drive].cylinders - 1; /* low part of number of cylinders */ - cmdb[6] = mfm_info[drive].heads - 1; /* Number of heads */ - cmdb[7] = mfm_info[drive].sectors - 1; /* Number of sectors */ - cmdb[8] = SPEC_SH; - cmdb[9] = 0x0a; /* gap length 1 */ - cmdb[10] = 0x0d; /* gap length 2 */ - cmdb[11] = 0x0c; /* gap length 3 */ - cmdb[12] = (mfm_info[drive].precomp - 1) >> 8; /* pre comp cylinder */ - cmdb[13] = mfm_info[drive].precomp - 1; - cmdb[14] = (mfm_info[drive].lowcurrent - 1) >> 8; /* Low current cylinder */ - cmdb[15] = mfm_info[drive].lowcurrent - 1; -} - -static void mfm_specify (void) -{ - unsigned char cmdb[16]; - - DBG("specify...dev=%d lastspecified=%d\n", raw_cmd.dev, lastspecifieddrive); - mfm_setupspecify (raw_cmd.dev, cmdb); - - issue_command (CMD_SPC, cmdb, 16); - /* Ensure that we will do another specify if we move to the other drive */ - lastspecifieddrive = raw_cmd.dev; - wait_for_completion(); -} - -static void mfm_seek(void) -{ - unsigned char cmdb[4]; - - DBG("seeking...\n"); - if (MFM_DRV_INFO.cylinder < 0) { - do_mfm = mfm_recal_intr; - DBG("mfm_seek: about to call specify\n"); - mfm_specify (); /* DAG added this */ - - cmdb[0] = raw_cmd.dev + 1; - cmdb[1] = 0; - - issue_command(CMD_RCLB, cmdb, 2); - return; - } - if (MFM_DRV_INFO.cylinder != raw_cmd.cylinder) { - cmdb[0] = raw_cmd.dev + 1; - cmdb[1] = 0; /* raw_cmd.head; DAG: My data sheet says this should be 0 */ - cmdb[2] = raw_cmd.cylinder >> 8; - cmdb[3] = raw_cmd.cylinder; - - do_mfm = mfm_seek_intr; - issue_command(CMD_SEK, cmdb, 4); - } else - mfm_setup_rw(); -} - -static void mfm_initialise(void) -{ - DBG("init...\n"); - mfm_seek(); -} - -static void request_done(int uptodate) -{ - DBG("mfm:request_done\n"); - if (uptodate) { - unsigned char block[2] = {0, 0}; - - /* Apparently worked - let's check bytes left to DMA */ - if (hdc63463_dataleft != (PartFragRead_SectorsLeft * 256)) { - printk("mfm: request_done - dataleft=%d - should be %d - Eek!\n", hdc63463_dataleft, PartFragRead_SectorsLeft * 256); - end_request(CURRENT, 0); - Busy = 0; - }; - /* Potentially this means that we've done; but we might be doing - a partial access, (over two cylinders) or we may have a number - of fragments in an image file. First let's deal with partial accesss - */ - if (PartFragRead) { - /* Yep - a partial access */ - - /* and issue the remainder */ - issue_request(PartFragRead_RestartBlock, PartFragRead_SectorsLeft, CURRENT); - return; - } - - /* ah well - perhaps there is another fragment to go */ - - /* Increment pointers/counts to start of next fragment */ - if (SectorsLeftInRequest > 0) printk("mfm: SectorsLeftInRequest>0 - Eek! Shouldn't happen!\n"); - - /* No - its the end of the line */ - /* end_request's should have happened at the end of sector DMAs */ - /* Turns Drive LEDs off - may slow it down? */ - if (!elv_next_request(QUEUE)) - issue_command(CMD_CKV, block, 2); - - Busy = 0; - DBG("request_done: About to mfm_request\n"); - /* Next one please */ - mfm_request(); /* Moved from mfm_rw_intr */ - DBG("request_done: returned from mfm_request\n"); - } else { - printk("mfm:request_done: update=0\n"); - end_request(CURRENT, 0); - Busy = 0; - } -} - -static void error_handler(void) -{ - printk("error detected... status = "); - print_status(); - (*errors)++; - if (*errors > MFM_DRV_INFO.errors.abort) - cont->done(0); - if (*errors > MFM_DRV_INFO.errors.recal) - MFM_DRV_INFO.cylinder = NEED_2_RECAL; -} - -static void rw_interrupt(void) -{ - printk("rw_interrupt\n"); -} - -static struct cont rw_cont = -{ - rw_interrupt, - error_handler, - mfm_rerequest, - request_done -}; - -/* - * Actually gets round to issuing the request - note everything at this - * point is in 256 byte sectors not Linux 512 byte blocks - */ -static void issue_request(unsigned int block, unsigned int nsect, - struct request *req) -{ - struct gendisk *disk = req->rq_disk; - struct mfm_info *p = disk->private_data; - int track, start_head, start_sector; - int sectors_to_next_cyl; - dev = p - mfm_info; - - track = block / p->sectors; - start_sector = block % p->sectors; - start_head = track % p->heads; - - /* First get the number of whole tracks which are free before the next - track */ - sectors_to_next_cyl = (p->heads - (start_head + 1)) * p->sectors; - /* Then add in the number of sectors left on this track */ - sectors_to_next_cyl += (p->sectors - start_sector); - - DBG("issue_request: mfm_info[dev].sectors=%d track=%d\n", p->sectors, track); - - raw_cmd.dev = dev; - raw_cmd.sector = start_sector; - raw_cmd.head = start_head; - raw_cmd.cylinder = track / p->heads; - raw_cmd.cmdtype = CURRENT->cmd; - raw_cmd.cmdcode = rq_data_dir(CURRENT) == WRITE ? CMD_WD : CMD_RD; - raw_cmd.cmddata[0] = dev + 1; /* DAG: +1 to get US */ - raw_cmd.cmddata[1] = raw_cmd.head; - raw_cmd.cmddata[2] = raw_cmd.cylinder >> 8; - raw_cmd.cmddata[3] = raw_cmd.cylinder; - raw_cmd.cmddata[4] = raw_cmd.head; - raw_cmd.cmddata[5] = raw_cmd.sector; - - /* Was == and worked - how the heck??? */ - if (lastspecifieddrive != raw_cmd.dev) - mfm_specify (); - - if (nsect <= sectors_to_next_cyl) { - raw_cmd.cmddata[6] = nsect >> 8; - raw_cmd.cmddata[7] = nsect; - PartFragRead = 0; /* All in one */ - PartFragRead_SectorsLeft = 0; /* Must set this - used in DMA calcs */ - } else { - raw_cmd.cmddata[6] = sectors_to_next_cyl >> 8; - raw_cmd.cmddata[7] = sectors_to_next_cyl; - PartFragRead = sectors_to_next_cyl; /* only do this many this time */ - PartFragRead_RestartBlock = block + sectors_to_next_cyl; /* Where to restart from */ - PartFragRead_SectorsLeft = nsect - sectors_to_next_cyl; - } - raw_cmd.cmdlen = 8; - - /* Setup DMA pointers */ - hdc63463_dataptr = (unsigned int) Copy_buffer; - hdc63463_dataleft = nsect * 256; /* Better way? */ - - DBG("mfm%c: %sing: CHS=%d/%d/%d, sectors=%d, buffer=0x%08lx (%p)\n", - raw_cmd.dev + 'a', rq_data_dir(CURRENT) == READ ? "read" : "writ", - raw_cmd.cylinder, - raw_cmd.head, - raw_cmd.sector, nsect, (unsigned long) Copy_buffer, CURRENT); - - cont = &rw_cont; - errors = &(CURRENT->errors); -#if 0 - mfm_tq.routine = (void (*)(void *)) mfm_initialise; - queue_task(&mfm_tq, &tq_immediate); - mark_bh(IMMEDIATE_BH); -#else - mfm_initialise(); -#endif -} /* issue_request */ - -/* - * Called when an error has just happened - need to trick mfm_request - * into thinking we weren't busy - * - * Turn off ints - mfm_request expects them this way - */ -static void mfm_rerequest(void) -{ - DBG("mfm_rerequest\n"); - cli(); - Busy = 0; - mfm_request(); -} - -static struct gendisk *mfm_gendisk[2]; - -static void mfm_request(void) -{ - DBG("mfm_request CURRENT=%p Busy=%d\n", CURRENT, Busy); - - /* If we are still processing then return; we will get called again */ - if (Busy) { - /* Again seems to be common in 1.3.45 */ - /*DBG*/printk("mfm_request: Exiting due to busy\n"); - return; - } - Busy = 1; - - while (1) { - unsigned int block, nsect; - struct gendisk *disk; - - DBG("mfm_request: loop start\n"); - sti(); - - DBG("mfm_request: before !CURRENT\n"); - - if (!CURRENT) { - printk("mfm_request: Exiting due to empty queue (pre)\n"); - do_mfm = NULL; - Busy = 0; - return; - } - - DBG("mfm_request: before arg extraction\n"); - - disk = CURRENT->rq_disk; - block = CURRENT->sector; - nsect = CURRENT->nr_sectors; - if (block >= get_capacity(disk) || - block+nsect > get_capacity(disk)) { - printk("%s: bad access: block=%d, count=%d, nr_sects=%ld\n", - disk->disk_name, block, nsect, get_capacity(disk)); - printk("mfm: continue 1\n"); - end_request(CURRENT, 0); - Busy = 0; - continue; - } - - /* DAG: Linux doesn't cope with this - even though it has an array telling - it the hardware block size - silly */ - block <<= 1; /* Now in 256 byte sectors */ - nsect <<= 1; /* Ditto */ - - SectorsLeftInRequest = nsect >> 1; - Sectors256LeftInCurrent = CURRENT->current_nr_sectors * 2; - Copy_buffer = CURRENT->buffer; - Copy_Sector = CURRENT->sector << 1; - - DBG("mfm_request: block after offset=%d\n", block); - - issue_request(block, nsect, CURRENT); - - break; - } - DBG("mfm_request: Dropping out bottom\n"); -} - -static void do_mfm_request(struct request_queue *q) -{ - DBG("do_mfm_request: about to mfm_request\n"); - mfm_request(); -} - -static void mfm_interrupt_handler(int unused, void *dev_id) -{ - void (*handler) (void) = do_mfm; - - do_mfm = NULL; - - DBG("mfm_interrupt_handler (handler=0x%p)\n", handler); - - mfm_status = inw(MFM_STATUS); - - /* If CPR (Command Parameter Reject) and not busy it means that the command - has some return message to give us */ - if ((mfm_status & (STAT_CPR | STAT_BSY)) == STAT_CPR) { - int len = 0; - while (len < 16) { - int in; - in = inw(MFM_DATAIN); - result[len++] = in >> 8; - result[len++] = in; - } - } - if (handler) { - handler(); - return; - } - outw (CMD_RCAL, MFM_COMMAND); /* Clear interrupt condition */ - printk ("mfm: unexpected interrupt - status = "); - print_status (); - while (1); -} - - - - - -/* - * Tell the user about the drive if we decided it exists. - */ -static void mfm_geometry(int drive) -{ - struct mfm_info *p = mfm_info + drive; - struct gendisk *disk = mfm_gendisk[drive]; - disk->private_data = p; - if (p->cylinders) - printk ("%s: %dMB CHS=%d/%d/%d LCC=%d RECOMP=%d\n", - disk->disk_name, - p->cylinders * p->heads * p->sectors / 4096, - p->cylinders, p->heads, p->sectors, - p->lowcurrent, p->precomp); - set_capacity(disk, p->cylinders * p->heads * p->sectors / 2); -} - -#ifdef CONFIG_BLK_DEV_MFM_AUTODETECT -/* - * Attempt to detect a drive and find its geometry. The drive has already been - * specified... - * - * We first recalibrate the disk, then try to probe sectors, heads and then - * cylinders. NOTE! the cylinder probe may break drives. The xd disk driver - * does something along these lines, so I assume that most drives are up to - * this mistreatment... - */ -static int mfm_detectdrive (int drive) -{ - unsigned int mingeo[3], maxgeo[3]; - unsigned int attribute, need_recal = 1; - unsigned char cmdb[8]; - - memset (mingeo, 0, sizeof (mingeo)); - maxgeo[0] = mfm_info[drive].sectors; - maxgeo[1] = mfm_info[drive].heads; - maxgeo[2] = mfm_info[drive].cylinders; - - cmdb[0] = drive + 1; - cmdb[6] = 0; - cmdb[7] = 1; - for (attribute = 0; attribute < 3; attribute++) { - while (mingeo[attribute] != maxgeo[attribute]) { - unsigned int variable; - - variable = (maxgeo[attribute] + mingeo[attribute]) >> 1; - cmdb[1] = cmdb[2] = cmdb[3] = cmdb[4] = cmdb[5] = 0; - - if (need_recal) { - int tries = 5; - - do { - issue_command (CMD_RCLB, cmdb, 2); - wait_for_completion (); - wait_for_command_end (); - if (result[1] == 0x20) - break; - } while (result[1] && --tries); - if (result[1]) { - outw (CMD_RCAL, MFM_COMMAND); - return 0; - } - need_recal = 0; - } - - switch (attribute) { - case 0: - cmdb[5] = variable; - issue_command (CMD_CMPD, cmdb, 8); - break; - case 1: - cmdb[1] = variable; - cmdb[4] = variable; - issue_command (CMD_CMPD, cmdb, 8); - break; - case 2: - cmdb[2] = variable >> 8; - cmdb[3] = variable; - issue_command (CMD_SEK, cmdb, 4); - break; - } - wait_for_completion (); - wait_for_command_end (); - - switch (result[1]) { - case 0x00: - case 0x50: - mingeo[attribute] = variable + 1; - break; - - case 0x20: - outw (CMD_RCAL, MFM_COMMAND); - return 0; - - case 0x24: - need_recal = 1; - default: - maxgeo[attribute] = variable; - break; - } - } - } - mfm_info[drive].cylinders = mingeo[2]; - mfm_info[drive].lowcurrent = mingeo[2]; - mfm_info[drive].precomp = mingeo[2] / 2; - mfm_info[drive].heads = mingeo[1]; - mfm_info[drive].sectors = mingeo[0]; - outw (CMD_RCAL, MFM_COMMAND); - return 1; -} -#endif - -/* - * Initialise all drive information for this controller. - */ -static int mfm_initdrives(void) -{ - int drive; - - if (number_mfm_drives > MFM_MAXDRIVES) { - number_mfm_drives = MFM_MAXDRIVES; - printk("No. of ADFS MFM drives is greater than MFM_MAXDRIVES - you can't have that many!\n"); - } - - for (drive = 0; drive < number_mfm_drives; drive++) { - mfm_info[drive].lowcurrent = 1; - mfm_info[drive].precomp = 1; - mfm_info[drive].cylinder = -1; - mfm_info[drive].errors.recal = 0; - mfm_info[drive].errors.report = 0; - mfm_info[drive].errors.abort = 4; - -#ifdef CONFIG_BLK_DEV_MFM_AUTODETECT - mfm_info[drive].cylinders = 1024; - mfm_info[drive].heads = 8; - mfm_info[drive].sectors = 64; - { - unsigned char cmdb[16]; - - mfm_setupspecify (drive, cmdb); - cmdb[1] &= ~0x81; - issue_command (CMD_SPC, cmdb, 16); - wait_for_completion (); - if (!mfm_detectdrive (drive)) { - mfm_info[drive].cylinders = 0; - mfm_info[drive].heads = 0; - mfm_info[drive].sectors = 0; - } - cmdb[0] = cmdb[1] = 0; - issue_command (CMD_CKV, cmdb, 2); - } -#else - mfm_info[drive].cylinders = 1; /* its going to have to figure it out from the partition info */ - mfm_info[drive].heads = 4; - mfm_info[drive].sectors = 32; -#endif - } - return number_mfm_drives; -} - - - -/* - * The 'front' end of the mfm driver follows... - */ - -static int mfm_getgeo(struct block_device *bdev, struct hd_geometry *geo) -{ - struct mfm_info *p = bdev->bd_disk->private_data; - - geo->heads = p->heads; - geo->sectors = p->sectors; - geo->cylinders = p->cylinders; - return 0; -} - -/* - * This is to handle various kernel command line parameters - * specific to this driver. - */ -void mfm_setup(char *str, int *ints) -{ - return; -} - -/* - * Set the CHS from the ADFS boot block if it is present. This is not ideal - * since if there are any non-ADFS partitions on the disk, this won't work! - * Hence, I want to get rid of this... - */ -void xd_set_geometry(struct block_device *bdev, unsigned char secsptrack, - unsigned char heads, unsigned int secsize) -{ - struct mfm_info *p = bdev->bd_disk->private_data; - int drive = p - mfm_info; - unsigned long disksize = bdev->bd_inode->i_size; - - if (p->cylinders == 1) { - p->sectors = secsptrack; - p->heads = heads; - p->cylinders = discsize / (secsptrack * heads * secsize); - - if ((heads < 1) || (p->cylinders > 1024)) { - printk("%s: Insane disc shape! Setting to 512/4/32\n", - bdev->bd_disk->disk_name); - - /* These values are fairly arbitary, but are there so that if your - * lucky you can pick apart your disc to find out what is going on - - * I reckon these figures won't hurt MOST drives - */ - p->sectors = 32; - p->heads = 4; - p->cylinders = 512; - } - if (raw_cmd.dev == drive) - mfm_specify (); - mfm_geometry (drive); - } -} - -static struct block_device_operations mfm_fops = -{ - .owner = THIS_MODULE, - .getgeo = mfm_getgeo, -}; - -/* - * See if there is a controller at the address presently at mfm_addr - * - * We check to see if the controller is busy - if it is, we abort it first, - * and check that the chip is no longer busy after at least 180 clock cycles. - * We then issue a command and check that the BSY or CPR bits are set. - */ -static int mfm_probecontroller (unsigned int mfm_addr) -{ - if (inw (MFM_STATUS) & STAT_BSY) { - outw (CMD_ABT, MFM_COMMAND); - udelay (50); - if (inw (MFM_STATUS) & STAT_BSY) - return 0; - } - - if (inw (MFM_STATUS) & STAT_CED) - outw (CMD_RCAL, MFM_COMMAND); - - outw (CMD_SEK, MFM_COMMAND); - - if (inw (MFM_STATUS) & (STAT_BSY | STAT_CPR)) { - unsigned int count = 2000; - while (inw (MFM_STATUS) & STAT_BSY) { - udelay (500); - if (!--count) - return 0; - } - - outw (CMD_RCAL, MFM_COMMAND); - } - return 1; -} - -static int mfm_do_init(unsigned char irqmask) -{ - int i, ret; - - printk("mfm: found at address %08X, interrupt %d\n", mfm_addr, mfm_irq); - - ret = -EBUSY; - if (!request_region (mfm_addr, 10, "mfm")) - goto out1; - - ret = register_blkdev(MAJOR_NR, "mfm"); - if (ret) - goto out2; - - /* Stuff for the assembler routines to get to */ - hdc63463_baseaddress = ioaddr(mfm_addr); - hdc63463_irqpolladdress = mfm_IRQPollLoc; - hdc63463_irqpollmask = irqmask; - - mfm_queue = blk_init_queue(do_mfm_request, &mfm_lock); - if (!mfm_queue) - goto out2a; - - Busy = 0; - lastspecifieddrive = -1; - - mfm_drives = mfm_initdrives(); - if (!mfm_drives) { - ret = -ENODEV; - goto out3; - } - - for (i = 0; i < mfm_drives; i++) { - struct gendisk *disk = alloc_disk(64); - if (!disk) - goto Enomem; - disk->major = MAJOR_NR; - disk->first_minor = i << 6; - disk->fops = &mfm_fops; - sprintf(disk->disk_name, "mfm%c", 'a'+i); - mfm_gendisk[i] = disk; - } - - printk("mfm: detected %d hard drive%s\n", mfm_drives, - mfm_drives == 1 ? "" : "s"); - ret = request_irq(mfm_irq, mfm_interrupt_handler, IRQF_DISABLED, "MFM harddisk", NULL); - if (ret) { - printk("mfm: unable to get IRQ%d\n", mfm_irq); - goto out4; - } - - if (mfm_irqenable) - outw(0x80, mfm_irqenable); /* Required to enable IRQs from MFM podule */ - - for (i = 0; i < mfm_drives; i++) { - mfm_geometry(i); - mfm_gendisk[i]->queue = mfm_queue; - add_disk(mfm_gendisk[i]); - } - return 0; - -out4: - for (i = 0; i < mfm_drives; i++) - put_disk(mfm_gendisk[i]); -out3: - blk_cleanup_queue(mfm_queue); -out2a: - unregister_blkdev(MAJOR_NR, "mfm"); -out2: - release_region(mfm_addr, 10); -out1: - return ret; -Enomem: - while (i--) - put_disk(mfm_gendisk[i]); - goto out3; -} - -static void mfm_do_exit(void) -{ - int i; - - free_irq(mfm_irq, NULL); - for (i = 0; i < mfm_drives; i++) { - del_gendisk(mfm_gendisk[i]); - put_disk(mfm_gendisk[i]); - } - blk_cleanup_queue(mfm_queue); - unregister_blkdev(MAJOR_NR, "mfm"); - if (mfm_addr) - release_region(mfm_addr, 10); -} - -static int __devinit mfm_probe(struct expansion_card *ec, struct ecard_id *id) -{ - if (mfm_addr) - return -EBUSY; - - mfm_addr = ecard_address(ec, ECARD_IOC, ECARD_MEDIUM) + 0x800; - mfm_IRQPollLoc = ioaddr(mfm_addr + 0x400); - mfm_irqenable = mfm_IRQPollLoc; - mfm_irq = ec->irq; - - return mfm_do_init(0x08); -} - -static void __devexit mfm_remove(struct expansion_card *ec) -{ - outw (0, mfm_irqenable); /* Required to enable IRQs from MFM podule */ - mfm_do_exit(); -} - -static const struct ecard_id mfm_cids[] = { - { MANU_ACORN, PROD_ACORN_MFM }, - { 0xffff, 0xffff }, -}; - -static struct ecard_driver mfm_driver = { - .probe = mfm_probe, - .remove = __devexit(mfm_remove), - .id_table = mfm_cids, - .drv = { - .name = "mfm", - }, -}; - -/* - * Look for a MFM controller - first check the motherboard, then the podules - * The podules have an extra interrupt enable that needs to be played with - * - * The HDC is accessed at MEDIUM IOC speeds. - */ -static int __init mfm_init (void) -{ - unsigned char irqmask; - - if (mfm_probecontroller(ONBOARD_MFM_ADDRESS)) { - mfm_addr = ONBOARD_MFM_ADDRESS; - mfm_IRQPollLoc = IOC_IRQSTATB; - mfm_irqenable = 0; - mfm_irq = IRQ_HARDDISK; - return mfm_do_init(0x08); /* IL3 pin */ - } else { - return ecard_register_driver(&mfm_driver); - } -} - -static void __exit mfm_exit(void) -{ - if (mfm_addr == ONBOARD_MFM_ADDRESS) - mfm_do_exit(); - else - ecard_unregister_driver(&mfm_driver); -} - -module_init(mfm_init) -module_exit(mfm_exit) -MODULE_LICENSE("GPL"); diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 934d639b368..f1372de4ce7 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -68,14 +68,6 @@ config ACPI_PROCFS Say N to delete /proc/acpi/ files that have moved to /sys/ -config ACPI_PROCFS_SLEEP - bool "/proc/acpi/sleep (deprecated)" - depends on PM_SLEEP && ACPI_PROCFS - default n - ---help--- - Create /proc/acpi/sleep - Deprecated by /sys/power/state - config ACPI_AC tristate "AC Adapter" depends on X86 diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index fe7ef339414..40545071e3c 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -53,7 +53,7 @@ static ssize_t store_online(struct sys_device *dev, const char *buf, ret = count; return ret; } -static SYSDEV_ATTR(online, 0600, show_online, store_online); +static SYSDEV_ATTR(online, 0644, show_online, store_online); static void __devinit register_cpu_control(struct cpu *cpu) { diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 1be82d544dc..a11b2bd54bb 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -3227,12 +3227,15 @@ static int alloc_cciss_hba(void) for (i = 0; i < MAX_CTLR; i++) { if (!hba[i]) { ctlr_info_t *p; + p = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL); if (!p) goto Enomem; p->gendisk[0] = alloc_disk(1 << NWD_SHIFT); - if (!p->gendisk[0]) + if (!p->gendisk[0]) { + kfree(p); goto Enomem; + } hba[i] = p; return i; } diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c index 6005b522577..8d74b8745e6 100644 --- a/drivers/char/ip2/ip2main.c +++ b/drivers/char/ip2/ip2main.c @@ -500,7 +500,6 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize) { int i, j, box; int err = 0; - int status = 0; static int loaded; i2eBordStrPtr pB = NULL; int rc = -1; @@ -588,6 +587,8 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize) case PCI: #ifdef CONFIG_PCI { + int status; + pci_dev_i = pci_get_device(PCI_VENDOR_ID_COMPUTONE, PCI_DEVICE_ID_COMPUTONE_IP2EX, pci_dev_i); if (pci_dev_i != NULL) { diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index 4edfdda0cf9..96d2f9ee42d 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c @@ -2050,6 +2050,7 @@ static __devinit void try_init_dmi(struct dmi_ipmi_data *ipmi_data) info->si_type = SI_BT; break; default: + kfree(info); return; } diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c index 372a37e2562..bbb7f129266 100644 --- a/drivers/char/synclink_gt.c +++ b/drivers/char/synclink_gt.c @@ -1,5 +1,5 @@ /* - * $Id: synclink_gt.c,v 4.36 2006/08/28 20:47:14 paulkf Exp $ + * $Id: synclink_gt.c,v 4.50 2007/07/25 19:29:25 paulkf Exp $ * * Device driver for Microgate SyncLink GT serial adapters. * @@ -93,7 +93,7 @@ * module identification */ static char *driver_name = "SyncLink GT"; -static char *driver_version = "$Revision: 4.36 $"; +static char *driver_version = "$Revision: 4.50 $"; static char *tty_driver_name = "synclink_gt"; static char *tty_dev_prefix = "ttySLG"; MODULE_LICENSE("GPL"); @@ -477,6 +477,7 @@ static void tx_set_idle(struct slgt_info *info); static unsigned int free_tbuf_count(struct slgt_info *info); static void reset_tbufs(struct slgt_info *info); static void tdma_reset(struct slgt_info *info); +static void tdma_start(struct slgt_info *info); static void tx_load(struct slgt_info *info, const char *buf, unsigned int count); static void get_signals(struct slgt_info *info); @@ -904,6 +905,8 @@ start: spin_lock_irqsave(&info->lock,flags); if (!info->tx_active) tx_start(info); + else + tdma_start(info); spin_unlock_irqrestore(&info->lock,flags); } @@ -3871,44 +3874,58 @@ static void tx_start(struct slgt_info *info) slgt_irq_on(info, IRQ_TXUNDER + IRQ_TXIDLE); /* clear tx idle and underrun status bits */ wr_reg16(info, SSR, (unsigned short)(IRQ_TXIDLE + IRQ_TXUNDER)); - - if (!(rd_reg32(info, TDCSR) & BIT0)) { - /* tx DMA stopped, restart tx DMA */ - tdma_reset(info); - /* set 1st descriptor address */ - wr_reg32(info, TDDAR, info->tbufs[info->tbuf_start].pdesc); - switch(info->params.mode) { - case MGSL_MODE_RAW: - case MGSL_MODE_MONOSYNC: - case MGSL_MODE_BISYNC: - wr_reg32(info, TDCSR, BIT2 + BIT0); /* IRQ + DMA enable */ - break; - default: - wr_reg32(info, TDCSR, BIT0); /* DMA enable */ - } - } - if (info->params.mode == MGSL_MODE_HDLC) mod_timer(&info->tx_timer, jiffies + msecs_to_jiffies(5000)); } else { - tdma_reset(info); - /* set 1st descriptor address */ - wr_reg32(info, TDDAR, info->tbufs[info->tbuf_start].pdesc); - slgt_irq_off(info, IRQ_TXDATA); slgt_irq_on(info, IRQ_TXIDLE); /* clear tx idle status bit */ wr_reg16(info, SSR, IRQ_TXIDLE); - - /* enable tx DMA */ - wr_reg32(info, TDCSR, BIT0); } - + tdma_start(info); info->tx_active = 1; } } +/* + * start transmit DMA if inactive and there are unsent buffers + */ +static void tdma_start(struct slgt_info *info) +{ + unsigned int i; + + if (rd_reg32(info, TDCSR) & BIT0) + return; + + /* transmit DMA inactive, check for unsent buffers */ + i = info->tbuf_start; + while (!desc_count(info->tbufs[i])) { + if (++i == info->tbuf_count) + i = 0; + if (i == info->tbuf_current) + return; + } + info->tbuf_start = i; + + /* there are unsent buffers, start transmit DMA */ + + /* reset needed if previous error condition */ + tdma_reset(info); + + /* set 1st descriptor address */ + wr_reg32(info, TDDAR, info->tbufs[info->tbuf_start].pdesc); + switch(info->params.mode) { + case MGSL_MODE_RAW: + case MGSL_MODE_MONOSYNC: + case MGSL_MODE_BISYNC: + wr_reg32(info, TDCSR, BIT2 + BIT0); /* IRQ + DMA enable */ + break; + default: + wr_reg32(info, TDCSR, BIT0); /* DMA enable */ + } +} + static void tx_stop(struct slgt_info *info) { unsigned short val; @@ -4642,8 +4659,8 @@ static unsigned int free_tbuf_count(struct slgt_info *info) i=0; } while (i != info->tbuf_current); - /* last buffer with zero count may be in use, assume it is */ - if (count) + /* if tx DMA active, last zero count buffer is in use */ + if (count && (rd_reg32(info, TDCSR) & BIT0)) --count; return count; diff --git a/drivers/dma/iovlock.c b/drivers/dma/iovlock.c index d637555a833..e763d723e4c 100644 --- a/drivers/dma/iovlock.c +++ b/drivers/dma/iovlock.c @@ -143,29 +143,6 @@ void dma_unpin_iovec_pages(struct dma_pinned_list *pinned_list) kfree(pinned_list); } -static dma_cookie_t dma_memcpy_to_kernel_iovec(struct dma_chan *chan, struct - iovec *iov, unsigned char *kdata, size_t len) -{ - dma_cookie_t dma_cookie = 0; - - while (len > 0) { - if (iov->iov_len) { - int copy = min_t(unsigned int, iov->iov_len, len); - dma_cookie = dma_async_memcpy_buf_to_buf( - chan, - iov->iov_base, - kdata, - copy); - kdata += copy; - len -= copy; - iov->iov_len -= copy; - iov->iov_base += copy; - } - iov++; - } - - return dma_cookie; -} /* * We have already pinned down the pages we will be using in the iovecs. @@ -187,10 +164,6 @@ dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov, if (!chan) return memcpy_toiovec(iov, kdata, len); - /* -> kernel copies (e.g. smbfs) */ - if (!pinned_list) - return dma_memcpy_to_kernel_iovec(chan, iov, kdata, len); - iovec_idx = 0; while (iovec_idx < pinned_list->nr_iovecs) { struct dma_page_list *page_list; diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index dbdca6f10e4..192953b29b2 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -520,6 +520,16 @@ config SENSORS_SMSC47B397 This driver can also be built as a module. If so, the module will be called smsc47b397. +config SENSORS_THMC50 + tristate "Texas Instruments THMC50 / Analog Devices ADM1022" + depends on I2C && EXPERIMENTAL + help + If you say yes here you get support for Texas Instruments THMC50 + sensor chips and clones: the Analog Devices ADM1022. + + This driver can also be built as a module. If so, the module + will be called thmc50. + config SENSORS_VIA686A tristate "VIA686A" depends on PCI diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 59f81fae40a..d04f90031eb 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -56,6 +56,7 @@ obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o obj-$(CONFIG_SENSORS_SMSC47M192)+= smsc47m192.o +obj-$(CONFIG_SENSORS_THMC50) += thmc50.o obj-$(CONFIG_SENSORS_VIA686A) += via686a.o obj-$(CONFIG_SENSORS_VT1211) += vt1211.o obj-$(CONFIG_SENSORS_VT8231) += vt8231.o diff --git a/drivers/hwmon/abituguru3.c b/drivers/hwmon/abituguru3.c index a003d104ca4..cdd8b6dea16 100644 --- a/drivers/hwmon/abituguru3.c +++ b/drivers/hwmon/abituguru3.c @@ -691,8 +691,9 @@ static int abituguru3_read(struct abituguru3_data *data, u8 bank, u8 offset, /* Sensor settings are stored 1 byte per offset with the bytes placed add consecutive offsets. */ -int abituguru3_read_increment_offset(struct abituguru3_data *data, u8 bank, - u8 offset, u8 count, u8 *buf, int offset_count) +static int abituguru3_read_increment_offset(struct abituguru3_data *data, + u8 bank, u8 offset, u8 count, + u8 *buf, int offset_count) { int i, x; diff --git a/drivers/hwmon/ams/ams-core.c b/drivers/hwmon/ams/ams-core.c index 6db97373972..a112a03e8f2 100644 --- a/drivers/hwmon/ams/ams-core.c +++ b/drivers/hwmon/ams/ams-core.c @@ -23,7 +23,6 @@ #include <linux/types.h> #include <linux/errno.h> #include <linux/init.h> -#include <linux/module.h> #include <asm/pmac_pfunc.h> #include <asm/of_platform.h> diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c index fd1281f4220..941729a131f 100644 --- a/drivers/hwmon/applesmc.c +++ b/drivers/hwmon/applesmc.c @@ -79,11 +79,15 @@ /* * Temperature sensors keys (sp78 - 2 bytes). - * First set for Macbook(Pro), second for Macmini. */ static const char* temperature_sensors_sets[][13] = { +/* Set 0: Macbook Pro */ { "TA0P", "TB0T", "TC0D", "TC0P", "TG0H", "TG0P", "TG0T", "Th0H", "Th1H", "Tm0P", "Ts0P", "Ts1P", NULL }, +/* Set 1: Macbook set */ + { "TB0T", "TC0D", "TC0P", "TM0P", "TN0P", "TN1P", "Th0H", "Th0S", + "Th1H", "Ts0P", NULL }, +/* Set 2: Macmini set */ { "TC0D", "TC0P", NULL } }; @@ -1150,10 +1154,10 @@ static void applesmc_release_accelerometer(void) static __initdata struct dmi_match_data applesmc_dmi_data[] = { /* MacBook Pro: accelerometer, backlight and temperature set 0 */ { .accelerometer = 1, .light = 1, .temperature_set = 0 }, -/* MacBook: accelerometer and temperature set 0 */ - { .accelerometer = 1, .light = 0, .temperature_set = 0 }, -/* MacBook: temperature set 1 */ - { .accelerometer = 0, .light = 0, .temperature_set = 1 } +/* MacBook: accelerometer and temperature set 1 */ + { .accelerometer = 1, .light = 0, .temperature_set = 1 }, +/* MacMini: temperature set 2 */ + { .accelerometer = 0, .light = 0, .temperature_set = 2 }, }; /* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1". diff --git a/drivers/hwmon/dme1737.c b/drivers/hwmon/dme1737.c index be3aaa5d0b9..e9cbc727664 100644 --- a/drivers/hwmon/dme1737.c +++ b/drivers/hwmon/dme1737.c @@ -750,7 +750,7 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *attr, res = (data->alarms >> DME1737_BIT_ALARM_TEMP[ix]) & 0x01; break; case SYS_TEMP_FAULT: - res = (data->temp[ix] == 0x0800); + res = (((u16)data->temp[ix] & 0xff00) == 0x8000); break; default: res = 0; diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c index 19717752cfc..b34b546c68b 100644 --- a/drivers/hwmon/fscher.c +++ b/drivers/hwmon/fscher.c @@ -441,6 +441,8 @@ static struct fscher_data *fscher_update_device(struct device *dev) data->watchdog[2] = fscher_read_value(client, FSCHER_REG_WDOG_CONTROL); data->global_event = fscher_read_value(client, FSCHER_REG_EVENT_STATE); + data->global_control = fscher_read_value(client, + FSCHER_REG_CONTROL); data->last_updated = jiffies; data->valid = 1; @@ -599,7 +601,7 @@ static ssize_t set_control(struct i2c_client *client, struct fscher_data *data, unsigned long v = simple_strtoul(buf, NULL, 10) & 0x01; mutex_lock(&data->update_lock); - data->global_control &= ~v; + data->global_control = v; fscher_write_value(client, reg, v); mutex_unlock(&data->update_lock); return count; diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index eff6036e15c..d75dba9b810 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -252,7 +252,7 @@ struct it87_data { static int it87_probe(struct platform_device *pdev); -static int it87_remove(struct platform_device *pdev); +static int __devexit it87_remove(struct platform_device *pdev); static int it87_read_value(struct it87_data *data, u8 reg); static void it87_write_value(struct it87_data *data, u8 reg, u8 value); diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index 9fb572f03ba..565c4e679b8 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c @@ -864,7 +864,7 @@ static int __init lm78_isa_found(unsigned short address) /* Determine the chip type */ outb_p(LM78_REG_CHIPID, address + LM78_ADDR_REG_OFFSET); val = inb_p(address + LM78_DATA_REG_OFFSET); - if (val == 0x00 /* LM78 */ + if (val == 0x00 || val == 0x20 /* LM78 */ || val == 0x40 /* LM78-J */ || (val & 0xfe) == 0xc0) /* LM79 */ found = 1; diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 48833fff492..af541d67245 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c @@ -585,7 +585,7 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) * those of the man_id register. */ if (chip_id == man_id - && (address == 0x4F || address == 0x4D) + && (address == 0x4C || address == 0x4D) && (reg_config1 & 0x1F) == (man_id & 0x0F) && reg_convrate <= 0x09) { kind = max6657; diff --git a/drivers/hwmon/lm93.c b/drivers/hwmon/lm93.c index 23edf4fe422..d84f8bf6f28 100644 --- a/drivers/hwmon/lm93.c +++ b/drivers/hwmon/lm93.c @@ -234,7 +234,7 @@ struct lm93_data { struct { u8 min; u8 max; - } temp_lim[3]; + } temp_lim[4]; /* vin1 - vin16: low and high limits */ struct { diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index cb72526c346..f57c75d59a5 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c @@ -220,7 +220,7 @@ struct pc87360_data { */ static int pc87360_probe(struct platform_device *pdev); -static int pc87360_remove(struct platform_device *pdev); +static int __devexit pc87360_remove(struct platform_device *pdev); static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank, u8 reg); diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c index 83321b28cf0..92956eb3f3c 100644 --- a/drivers/hwmon/sis5595.c +++ b/drivers/hwmon/sis5595.c @@ -187,7 +187,7 @@ struct sis5595_data { static struct pci_dev *s_bridge; /* pointer to the (only) sis5595 */ static int sis5595_probe(struct platform_device *pdev); -static int sis5595_remove(struct platform_device *pdev); +static int __devexit sis5595_remove(struct platform_device *pdev); static int sis5595_read_value(struct sis5595_data *data, u8 reg); static void sis5595_write_value(struct sis5595_data *data, u8 reg, u8 value); diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c index 1de2f2be870..338ee4f5461 100644 --- a/drivers/hwmon/smsc47m1.c +++ b/drivers/hwmon/smsc47m1.c @@ -134,7 +134,7 @@ struct smsc47m1_sio_data { static int smsc47m1_probe(struct platform_device *pdev); -static int smsc47m1_remove(struct platform_device *pdev); +static int __devexit smsc47m1_remove(struct platform_device *pdev); static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, int init); diff --git a/drivers/hwmon/thmc50.c b/drivers/hwmon/thmc50.c new file mode 100644 index 00000000000..9395b52d9b9 --- /dev/null +++ b/drivers/hwmon/thmc50.c @@ -0,0 +1,440 @@ +/* + thmc50.c - Part of lm_sensors, Linux kernel modules for hardware + monitoring + Copyright (C) 2007 Krzysztof Helt <krzysztof.h1@wp.pl> + Based on 2.4 driver by Frodo Looijaard <frodol@dds.nl> and + Philip Edelbrock <phil@netroedge.com> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include <linux/module.h> +#include <linux/init.h> +#include <linux/slab.h> +#include <linux/i2c.h> +#include <linux/hwmon.h> +#include <linux/hwmon-sysfs.h> +#include <linux/err.h> +#include <linux/mutex.h> + +MODULE_LICENSE("GPL"); + +/* Addresses to scan */ +static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; + +/* Insmod parameters */ +I2C_CLIENT_INSMOD_2(thmc50, adm1022); +I2C_CLIENT_MODULE_PARM(adm1022_temp3, "List of adapter,address pairs " + "to enable 3rd temperature (ADM1022 only)"); + +/* Many THMC50 constants specified below */ + +/* The THMC50 registers */ +#define THMC50_REG_CONF 0x40 +#define THMC50_REG_COMPANY_ID 0x3E +#define THMC50_REG_DIE_CODE 0x3F +#define THMC50_REG_ANALOG_OUT 0x19 + +const static u8 THMC50_REG_TEMP[] = { 0x27, 0x26, 0x20 }; +const static u8 THMC50_REG_TEMP_MIN[] = { 0x3A, 0x38, 0x2C }; +const static u8 THMC50_REG_TEMP_MAX[] = { 0x39, 0x37, 0x2B }; + +#define THMC50_REG_CONF_nFANOFF 0x20 + +/* Each client has this additional data */ +struct thmc50_data { + struct i2c_client client; + struct class_device *class_dev; + + struct mutex update_lock; + enum chips type; + unsigned long last_updated; /* In jiffies */ + char has_temp3; /* !=0 if it is ADM1022 in temp3 mode */ + char valid; /* !=0 if following fields are valid */ + + /* Register values */ + s8 temp_input[3]; + s8 temp_max[3]; + s8 temp_min[3]; + u8 analog_out; +}; + +static int thmc50_attach_adapter(struct i2c_adapter *adapter); +static int thmc50_detach_client(struct i2c_client *client); +static void thmc50_init_client(struct i2c_client *client); +static struct thmc50_data *thmc50_update_device(struct device *dev); + +static struct i2c_driver thmc50_driver = { + .driver = { + .name = "thmc50", + }, + .attach_adapter = thmc50_attach_adapter, + .detach_client = thmc50_detach_client, +}; + +static ssize_t show_analog_out(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct thmc50_data *data = thmc50_update_device(dev); + return sprintf(buf, "%d\n", data->analog_out); +} + +static ssize_t set_analog_out(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct thmc50_data *data = i2c_get_clientdata(client); + int tmp = simple_strtoul(buf, NULL, 10); + int config; + + mutex_lock(&data->update_lock); + data->analog_out = SENSORS_LIMIT(tmp, 0, 255); + i2c_smbus_write_byte_data(client, THMC50_REG_ANALOG_OUT, + data->analog_out); + + config = i2c_smbus_read_byte_data(client, THMC50_REG_CONF); + if (data->analog_out == 0) + config &= ~THMC50_REG_CONF_nFANOFF; + else + config |= THMC50_REG_CONF_nFANOFF; + i2c_smbus_write_byte_data(client, THMC50_REG_CONF, config); + + mutex_unlock(&data->update_lock); + return count; +} + +/* There is only one PWM mode = DC */ +static ssize_t show_pwm_mode(struct device *dev, struct device_attribute *attr, + char *buf) +{ + return sprintf(buf, "0\n"); +} + +/* Temperatures */ +static ssize_t show_temp(struct device *dev, struct device_attribute *attr, + char *buf) +{ + int nr = to_sensor_dev_attr(attr)->index; + struct thmc50_data *data = thmc50_update_device(dev); + return sprintf(buf, "%d\n", data->temp_input[nr] * 1000); +} + +static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr, + char *buf) +{ + int nr = to_sensor_dev_attr(attr)->index; + struct thmc50_data *data = thmc50_update_device(dev); + return sprintf(buf, "%d\n", data->temp_min[nr] * 1000); +} + +static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + int nr = to_sensor_dev_attr(attr)->index; + struct i2c_client *client = to_i2c_client(dev); + struct thmc50_data *data = i2c_get_clientdata(client); + int val = simple_strtol(buf, NULL, 10); + + mutex_lock(&data->update_lock); + data->temp_min[nr] = SENSORS_LIMIT(val / 1000, -128, 127); + i2c_smbus_write_byte_data(client, THMC50_REG_TEMP_MIN[nr], + data->temp_min[nr]); + mutex_unlock(&data->update_lock); + return count; +} + +static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, + char *buf) +{ + int nr = to_sensor_dev_attr(attr)->index; + struct thmc50_data *data = thmc50_update_device(dev); + return sprintf(buf, "%d\n", data->temp_max[nr] * 1000); +} + +static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + int nr = to_sensor_dev_attr(attr)->index; + struct i2c_client *client = to_i2c_client(dev); + struct thmc50_data *data = i2c_get_clientdata(client); + int val = simple_strtol(buf, NULL, 10); + + mutex_lock(&data->update_lock); + data->temp_max[nr] = SENSORS_LIMIT(val / 1000, -128, 127); + i2c_smbus_write_byte_data(client, THMC50_REG_TEMP_MAX[nr], + data->temp_max[nr]); + mutex_unlock(&data->update_lock); + return count; +} + +#define temp_reg(offset) \ +static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp, \ + NULL, offset - 1); \ +static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ + show_temp_min, set_temp_min, offset - 1); \ +static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ + show_temp_max, set_temp_max, offset - 1); + +temp_reg(1); +temp_reg(2); +temp_reg(3); + +static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_analog_out, + set_analog_out, 0); +static SENSOR_DEVICE_ATTR(pwm1_mode, S_IRUGO, show_pwm_mode, NULL, 0); + +static struct attribute *thmc50_attributes[] = { + &sensor_dev_attr_temp1_max.dev_attr.attr, + &sensor_dev_attr_temp1_min.dev_attr.attr, + &sensor_dev_attr_temp1_input.dev_attr.attr, + &sensor_dev_attr_temp2_max.dev_attr.attr, + &sensor_dev_attr_temp2_min.dev_attr.attr, + &sensor_dev_attr_temp2_input.dev_attr.attr, + &sensor_dev_attr_pwm1.dev_attr.attr, + &sensor_dev_attr_pwm1_mode.dev_attr.attr, + NULL +}; + +static const struct attribute_group thmc50_group = { + .attrs = thmc50_attributes, +}; + +/* for ADM1022 3rd temperature mode */ +static struct attribute *adm1022_attributes[] = { + &sensor_dev_attr_temp3_max.dev_attr.attr, + &sensor_dev_attr_temp3_min.dev_attr.attr, + &sensor_dev_attr_temp3_input.dev_attr.attr, + NULL +}; + +static const struct attribute_group adm1022_group = { + .attrs = adm1022_attributes, +}; + +static int thmc50_detect(struct i2c_adapter *adapter, int address, int kind) +{ + unsigned company; + unsigned revision; + unsigned config; + struct i2c_client *client; + struct thmc50_data *data; + struct device *dev; + int err = 0; + const char *type_name = ""; + + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { + pr_debug("thmc50: detect failed, " + "smbus byte data not supported!\n"); + goto exit; + } + + /* OK. For now, we presume we have a valid client. We now create the + client structure, even though we cannot fill it completely yet. + But it allows us to access thmc50 registers. */ + if (!(data = kzalloc(sizeof(struct thmc50_data), GFP_KERNEL))) { + pr_debug("thmc50: detect failed, kzalloc failed!\n"); + err = -ENOMEM; + goto exit; + } + + client = &data->client; + i2c_set_clientdata(client, data); + client->addr = address; + client->adapter = adapter; + client->driver = &thmc50_driver; + dev = &client->dev; + + pr_debug("thmc50: Probing for THMC50 at 0x%2X on bus %d\n", + client->addr, i2c_adapter_id(client->adapter)); + + /* Now, we do the remaining detection. */ + company = i2c_smbus_read_byte_data(client, THMC50_REG_COMPANY_ID); + revision = i2c_smbus_read_byte_data(client, THMC50_REG_DIE_CODE); + config = i2c_smbus_read_byte_data(client, THMC50_REG_CONF); + + if (kind == 0) + kind = thmc50; + else if (kind < 0) { + err = -ENODEV; + if (revision >= 0xc0 && ((config & 0x10) == 0)) { + if (company == 0x49) { + kind = thmc50; + err = 0; + } else if (company == 0x41) { + kind = adm1022; + err = 0; + } + } + } + if (err == -ENODEV) { + pr_debug("thmc50: Detection of THMC50/ADM1022 failed\n"); + goto exit_free; + } + pr_debug("thmc50: Detected %s (version %x, revision %x)\n", + type_name, (revision >> 4) - 0xc, revision & 0xf); + data->type = kind; + + if (kind == thmc50) + type_name = "thmc50"; + else if (kind == adm1022) { + int id = i2c_adapter_id(client->adapter); + int i; + + type_name = "adm1022"; + data->has_temp3 = (config >> 7) & 1; /* config MSB */ + for (i = 0; i + 1 < adm1022_temp3_num; i += 2) + if (adm1022_temp3[i] == id && + adm1022_temp3[i + 1] == address) { + /* enable 2nd remote temp */ + data->has_temp3 = 1; + break; + } + } + + /* Fill in the remaining client fields & put it into the global list */ + strlcpy(client->name, type_name, I2C_NAME_SIZE); + mutex_init(&data->update_lock); + + /* Tell the I2C layer a new client has arrived */ + if ((err = i2c_attach_client(client))) + goto exit_free; + + thmc50_init_client(client); + + /* Register sysfs hooks */ + if ((err = sysfs_create_group(&client->dev.kobj, &thmc50_group))) + goto exit_detach; + + /* Register ADM1022 sysfs hooks */ + if (data->type == adm1022) + if ((err = sysfs_create_group(&client->dev.kobj, + &adm1022_group))) + goto exit_remove_sysfs_thmc50; + + /* Register a new directory entry with module sensors */ + data->class_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_remove_sysfs; + } + + return 0; + +exit_remove_sysfs: + if (data->type == adm1022) + sysfs_remove_group(&client->dev.kobj, &adm1022_group); +exit_remove_sysfs_thmc50: + sysfs_remove_group(&client->dev.kobj, &thmc50_group); +exit_detach: + i2c_detach_client(client); +exit_free: + kfree(data); +exit: + return err; +} + +static int thmc50_attach_adapter(struct i2c_adapter *adapter) +{ + if (!(adapter->class & I2C_CLASS_HWMON)) + return 0; + return i2c_probe(adapter, &addr_data, thmc50_detect); +} + +static int thmc50_detach_client(struct i2c_client *client) +{ + struct thmc50_data *data = i2c_get_clientdata(client); + int err; + + hwmon_device_unregister(data->class_dev); + sysfs_remove_group(&client->dev.kobj, &thmc50_group); + if (data->type == adm1022) + sysfs_remove_group(&client->dev.kobj, &adm1022_group); + + if ((err = i2c_detach_client(client))) + return err; + + kfree(data); + + return 0; +} + +static void thmc50_init_client(struct i2c_client *client) +{ + struct thmc50_data *data = i2c_get_clientdata(client); + int config; + + data->analog_out = i2c_smbus_read_byte_data(client, + THMC50_REG_ANALOG_OUT); + /* set up to at least 1 */ + if (data->analog_out == 0) { + data->analog_out = 1; + i2c_smbus_write_byte_data(client, THMC50_REG_ANALOG_OUT, + data->analog_out); + } + config = i2c_smbus_read_byte_data(client, THMC50_REG_CONF); + config |= 0x1; /* start the chip if it is in standby mode */ + if (data->has_temp3) + config |= 0x80; /* enable 2nd remote temp */ + i2c_smbus_write_byte_data(client, THMC50_REG_CONF, config); +} + +static struct thmc50_data *thmc50_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct thmc50_data *data = i2c_get_clientdata(client); + int timeout = HZ / 5 + (data->type == thmc50 ? HZ : 0); + + mutex_lock(&data->update_lock); + + if (time_after(jiffies, data->last_updated + timeout) + || !data->valid) { + + int temps = data->has_temp3 ? 3 : 2; + int i; + for (i = 0; i < temps; i++) { + data->temp_input[i] = i2c_smbus_read_byte_data(client, + THMC50_REG_TEMP[i]); + data->temp_max[i] = i2c_smbus_read_byte_data(client, + THMC50_REG_TEMP_MAX[i]); + data->temp_min[i] = i2c_smbus_read_byte_data(client, + THMC50_REG_TEMP_MIN[i]); + } + data->analog_out = + i2c_smbus_read_byte_data(client, THMC50_REG_ANALOG_OUT); + data->last_updated = jiffies; + data->valid = 1; + } + + mutex_unlock(&data->update_lock); + + return data; +} + +static int __init sm_thmc50_init(void) +{ + return i2c_add_driver(&thmc50_driver); +} + +static void __exit sm_thmc50_exit(void) +{ + i2c_del_driver(&thmc50_driver); +} + +MODULE_AUTHOR("Krzysztof Helt <krzysztof.h1@wp.pl>"); +MODULE_DESCRIPTION("THMC50 driver"); + +module_init(sm_thmc50_init); +module_exit(sm_thmc50_exit); diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c index 24a6851491d..696c8a2e537 100644 --- a/drivers/hwmon/via686a.c +++ b/drivers/hwmon/via686a.c @@ -314,7 +314,7 @@ struct via686a_data { static struct pci_dev *s_bridge; /* pointer to the (only) via686a */ static int via686a_probe(struct platform_device *pdev); -static int via686a_remove(struct platform_device *pdev); +static int __devexit via686a_remove(struct platform_device *pdev); static inline int via686a_read_value(struct via686a_data *data, u8 reg) { diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c index c604972f018..3e63eaf1904 100644 --- a/drivers/hwmon/vt8231.c +++ b/drivers/hwmon/vt8231.c @@ -167,7 +167,7 @@ struct vt8231_data { static struct pci_dev *s_bridge; static int vt8231_probe(struct platform_device *pdev); -static int vt8231_remove(struct platform_device *pdev); +static int __devexit vt8231_remove(struct platform_device *pdev); static struct vt8231_data *vt8231_update_device(struct device *dev); static void vt8231_init_device(struct vt8231_data *data); @@ -751,7 +751,7 @@ exit_release: return err; } -static int vt8231_remove(struct platform_device *pdev) +static int __devexit vt8231_remove(struct platform_device *pdev) { struct vt8231_data *data = platform_get_drvdata(pdev); int i; diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index 1ce78179b00..7a4a15f4bf8 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c @@ -387,7 +387,7 @@ struct w83627hf_sio_data { static int w83627hf_probe(struct platform_device *pdev); -static int w83627hf_remove(struct platform_device *pdev); +static int __devexit w83627hf_remove(struct platform_device *pdev); static int w83627hf_read_value(struct w83627hf_data *data, u16 reg); static int w83627hf_write_value(struct w83627hf_data *data, u16 reg, u16 value); diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index b1a9b81c211..e049f65bc3a 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig @@ -833,7 +833,7 @@ config BLK_DEV_IDE_AU1XXX_SEQTS_PER_RQ depends on BLK_DEV_IDE_AU1XXX config IDE_ARM - def_bool ARM && (ARCH_A5K || ARCH_CLPS7500 || ARCH_RPC || ARCH_SHARK) + def_bool ARM && (ARCH_CLPS7500 || ARCH_RPC || ARCH_SHARK) config BLK_DEV_IDE_ICSIDE tristate "ICS IDE interface support" diff --git a/drivers/ide/arm/ide_arm.c b/drivers/ide/arm/ide_arm.c index a3d6744e870..bce2bec8141 100644 --- a/drivers/ide/arm/ide_arm.c +++ b/drivers/ide/arm/ide_arm.c @@ -1,5 +1,5 @@ /* - * ARM/ARM26 default IDE host driver + * ARM default IDE host driver * * Copyright (C) 2004 Bartlomiej Zolnierkiewicz * Based on code by: Russell King, Ian Molton and Alexander Schulz. @@ -14,12 +14,6 @@ #include <asm/mach-types.h> #include <asm/irq.h> -#ifdef CONFIG_ARM26 -# define IDE_ARM_HOST (machine_is_a5k()) -#else -# define IDE_ARM_HOST (1) -#endif - #ifdef CONFIG_ARCH_CLPS7500 # include <asm/arch/hardware.h> # @@ -32,12 +26,10 @@ void __init ide_arm_init(void) { - if (IDE_ARM_HOST) { - hw_regs_t hw; + hw_regs_t hw; - memset(&hw, 0, sizeof(hw)); - ide_std_init_ports(&hw, IDE_ARM_IO, IDE_ARM_IO + 0x206); - hw.irq = IDE_ARM_IRQ; - ide_register_hw(&hw, 1, NULL); - } + memset(&hw, 0, sizeof(hw)); + ide_std_init_ports(&hw, IDE_ARM_IO, IDE_ARM_IO + 0x206); + hw.irq = IDE_ARM_IRQ; + ide_register_hw(&hw, 1, NULL); } diff --git a/drivers/infiniband/hw/ehca/ehca_irq.c b/drivers/infiniband/hw/ehca/ehca_irq.c index 71c0799b350..ee06d8bd739 100644 --- a/drivers/infiniband/hw/ehca/ehca_irq.c +++ b/drivers/infiniband/hw/ehca/ehca_irq.c @@ -116,7 +116,7 @@ static void print_error_data(struct ehca_shca *shca, void *data, } default: ehca_err(&shca->ib_device, - "Unknown errror type: %lx on %s.", + "Unknown error type: %lx on %s.", type, shca->ib_device.name); break; } diff --git a/drivers/isdn/divert/divert_procfs.c b/drivers/isdn/divert/divert_procfs.c index be77ee625bb..559a0d0244c 100644 --- a/drivers/isdn/divert/divert_procfs.c +++ b/drivers/isdn/divert/divert_procfs.c @@ -70,6 +70,8 @@ put_info_buffer(char *cp) wake_up_interruptible(&(rd_queue)); } /* put_info_buffer */ +#ifdef CONFIG_PROC_FS + /**********************************/ /* deflection device read routine */ /**********************************/ @@ -253,8 +255,6 @@ isdn_divert_ioctl(struct inode *inode, struct file *file, return copy_to_user((void __user *)arg, &dioctl, sizeof(dioctl)) ? -EFAULT : 0; } /* isdn_divert_ioctl */ - -#ifdef CONFIG_PROC_FS static const struct file_operations isdn_fops = { .owner = THIS_MODULE, diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index f730a144baf..4e53792aa52 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -917,6 +917,13 @@ static int make_request(struct request_queue *q, struct bio * bio) bio_list_add(&bl, mbio); } + if (unlikely(!atomic_read(&r10_bio->remaining))) { + /* the array is dead */ + md_write_end(mddev); + raid_end_bio_io(r10_bio); + return 0; + } + bitmap_startwrite(mddev->bitmap, bio->bi_sector, r10_bio->sectors, 0); spin_lock_irqsave(&conf->device_lock, flags); bio_list_merge(&conf->pending_bio_list, &bl); @@ -1557,7 +1564,6 @@ static void raid10d(mddev_t *mddev) bio = r10_bio->devs[r10_bio->read_slot].bio; r10_bio->devs[r10_bio->read_slot].bio = mddev->ro ? IO_BLOCKED : NULL; - bio_put(bio); mirror = read_balance(conf, r10_bio); if (mirror == -1) { printk(KERN_ALERT "raid10: %s: unrecoverable I/O" @@ -1565,8 +1571,10 @@ static void raid10d(mddev_t *mddev) bdevname(bio->bi_bdev,b), (unsigned long long)r10_bio->sector); raid_end_bio_io(r10_bio); + bio_put(bio); } else { const int do_sync = bio_sync(r10_bio->master_bio); + bio_put(bio); rdev = conf->mirrors[mirror].rdev; if (printk_ratelimit()) printk(KERN_ERR "raid10: %s: redirecting sector %llu to" diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c index 5e1c99f83ab..50b2c733441 100644 --- a/drivers/message/i2o/i2o_block.c +++ b/drivers/message/i2o/i2o_block.c @@ -744,7 +744,7 @@ static int i2o_block_transfer(struct request *req) { struct i2o_block_device *dev = req->rq_disk->private_data; struct i2o_controller *c; - int tid = dev->i2o_dev->lct_data.tid; + u32 tid = dev->i2o_dev->lct_data.tid; struct i2o_message *msg; u32 *mptr; struct i2o_block_request *ireq = req->special; diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c index 6deb20fc7a0..001c66dd3a9 100644 --- a/drivers/net/3c59x.c +++ b/drivers/net/3c59x.c @@ -2886,7 +2886,6 @@ static const struct ethtool_ops vortex_ethtool_ops = { .set_settings = vortex_set_settings, .get_link = ethtool_op_get_link, .nway_reset = vortex_nway_reset, - .get_perm_addr = ethtool_op_get_perm_addr, }; #ifdef CONFIG_PCI diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c index e970e64bf96..a79f28c7a10 100644 --- a/drivers/net/8139cp.c +++ b/drivers/net/8139cp.c @@ -1578,7 +1578,6 @@ static const struct ethtool_ops cp_ethtool_ops = { .set_wol = cp_set_wol, .get_strings = cp_get_strings, .get_ethtool_stats = cp_get_ethtool_stats, - .get_perm_addr = ethtool_op_get_perm_addr, .get_eeprom_len = cp_get_eeprom_len, .get_eeprom = cp_get_eeprom, .set_eeprom = cp_set_eeprom, diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c index 327eaa7b499..f4e4298d24b 100644 --- a/drivers/net/8139too.c +++ b/drivers/net/8139too.c @@ -2452,7 +2452,6 @@ static const struct ethtool_ops rtl8139_ethtool_ops = { .get_strings = rtl8139_get_strings, .get_stats_count = rtl8139_get_stats_count, .get_ethtool_stats = rtl8139_get_ethtool_stats, - .get_perm_addr = ethtool_op_get_perm_addr, }; static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index f8a602caabc..81ef81c9a58 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -2851,7 +2851,7 @@ config PPPOATM config PPPOL2TP tristate "PPP over L2TP (EXPERIMENTAL)" - depends on EXPERIMENTAL && PPP + depends on EXPERIMENTAL && PPP && INET help Support for PPP-over-L2TP socket family. L2TP is a protocol used by ISPs and enterprises to tunnel PPP traffic over UDP diff --git a/drivers/net/ax88796.c b/drivers/net/ax88796.c index e43e8047b90..83da1770baf 100644 --- a/drivers/net/ax88796.c +++ b/drivers/net/ax88796.c @@ -580,7 +580,6 @@ static const struct ethtool_ops ax_ethtool_ops = { .set_settings = ax_set_settings, .nway_reset = ax_nway_reset, .get_link = ax_get_link, - .get_perm_addr = ethtool_op_get_perm_addr, }; /* setup code */ diff --git a/drivers/net/b44.c b/drivers/net/b44.c index 37f1b6ff5c1..0795df23549 100644 --- a/drivers/net/b44.c +++ b/drivers/net/b44.c @@ -2033,7 +2033,6 @@ static const struct ethtool_ops b44_ethtool_ops = { .get_strings = b44_get_strings, .get_stats_count = b44_get_stats_count, .get_ethtool_stats = b44_get_ethtool_stats, - .get_perm_addr = ethtool_op_get_perm_addr, }; static int b44_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index a729da061bb..d53dfc5bbae 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c @@ -6269,7 +6269,6 @@ static const struct ethtool_ops bnx2_ethtool_ops = { .phys_id = bnx2_phys_id, .get_stats_count = bnx2_get_stats_count, .get_ethtool_stats = bnx2_get_ethtool_stats, - .get_perm_addr = ethtool_op_get_perm_addr, }; /* Called with rtnl_lock */ diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index cb9cb3013f4..070b78d959c 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -613,38 +613,20 @@ down: static int bond_update_speed_duplex(struct slave *slave) { struct net_device *slave_dev = slave->dev; - static int (* ioctl)(struct net_device *, struct ifreq *, int); - struct ifreq ifr; struct ethtool_cmd etool; + int res; /* Fake speed and duplex */ slave->speed = SPEED_100; slave->duplex = DUPLEX_FULL; - if (slave_dev->ethtool_ops) { - int res; - - if (!slave_dev->ethtool_ops->get_settings) { - return -1; - } - - res = slave_dev->ethtool_ops->get_settings(slave_dev, &etool); - if (res < 0) { - return -1; - } - - goto verify; - } + if (!slave_dev->ethtool_ops || !slave_dev->ethtool_ops->get_settings) + return -1; - ioctl = slave_dev->do_ioctl; - strncpy(ifr.ifr_name, slave_dev->name, IFNAMSIZ); - etool.cmd = ETHTOOL_GSET; - ifr.ifr_data = (char*)&etool; - if (!ioctl || (IOCTL(slave_dev, &ifr, SIOCETHTOOL) < 0)) { + res = slave_dev->ethtool_ops->get_settings(slave_dev, &etool); + if (res < 0) return -1; - } -verify: switch (etool.speed) { case SPEED_10: case SPEED_100: @@ -690,7 +672,6 @@ static int bond_check_dev_link(struct bonding *bond, struct net_device *slave_de static int (* ioctl)(struct net_device *, struct ifreq *, int); struct ifreq ifr; struct mii_ioctl_data *mii; - struct ethtool_value etool; if (bond->params.use_carrier) { return netif_carrier_ok(slave_dev) ? BMSR_LSTATUS : 0; @@ -721,9 +702,10 @@ static int bond_check_dev_link(struct bonding *bond, struct net_device *slave_de } } - /* try SIOCETHTOOL ioctl, some drivers cache ETHTOOL_GLINK */ - /* for a period of time so we attempt to get link status */ - /* from it last if the above MII ioctls fail... */ + /* + * Some drivers cache ETHTOOL_GLINK for a period of time so we only + * attempt to get link status from it if the above MII ioctls fail. + */ if (slave_dev->ethtool_ops) { if (slave_dev->ethtool_ops->get_link) { u32 link; @@ -734,23 +716,9 @@ static int bond_check_dev_link(struct bonding *bond, struct net_device *slave_de } } - if (ioctl) { - strncpy(ifr.ifr_name, slave_dev->name, IFNAMSIZ); - etool.cmd = ETHTOOL_GLINK; - ifr.ifr_data = (char*)&etool; - if (IOCTL(slave_dev, &ifr, SIOCETHTOOL) == 0) { - if (etool.data == 1) { - return BMSR_LSTATUS; - } else { - dprintk("SIOCETHTOOL shows link down\n"); - return 0; - } - } - } - /* * If reporting, report that either there's no dev->do_ioctl, - * or both SIOCGMIIREG and SIOCETHTOOL failed (meaning that we + * or both SIOCGMIIREG and get_link failed (meaning that we * cannot report link status). If not reporting, pretend * we're ok. */ diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c index 6fd1e524183..dc5d26988bb 100644 --- a/drivers/net/cxgb3/cxgb3_main.c +++ b/drivers/net/cxgb3/cxgb3_main.c @@ -1583,7 +1583,6 @@ static const struct ethtool_ops cxgb_ethtool_ops = { .get_wol = get_wol, .get_tso = ethtool_op_get_tso, .set_tso = ethtool_op_set_tso, - .get_perm_addr = ethtool_op_get_perm_addr }; static int in_range(int val, int lo, int hi) diff --git a/drivers/net/e100.c b/drivers/net/e100.c index 6b6401e9304..280313b9b06 100644 --- a/drivers/net/e100.c +++ b/drivers/net/e100.c @@ -2506,7 +2506,6 @@ static const struct ethtool_ops e100_ethtool_ops = { .phys_id = e100_phys_id, .get_stats_count = e100_get_stats_count, .get_ethtool_stats = e100_get_ethtool_stats, - .get_perm_addr = ethtool_op_get_perm_addr, }; static int e100_do_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c index bb08375b5f1..c90c92e72d2 100644 --- a/drivers/net/e1000/e1000_ethtool.c +++ b/drivers/net/e1000/e1000_ethtool.c @@ -1973,7 +1973,6 @@ static const struct ethtool_ops e1000_ethtool_ops = { .phys_id = e1000_phys_id, .get_stats_count = e1000_get_stats_count, .get_ethtool_stats = e1000_get_ethtool_stats, - .get_perm_addr = ethtool_op_get_perm_addr, }; void e1000_set_ethtool_ops(struct net_device *netdev) diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c index 51e1cb47273..69f5f365239 100644 --- a/drivers/net/forcedeth.c +++ b/drivers/net/forcedeth.c @@ -4707,7 +4707,6 @@ static const struct ethtool_ops ops = { .get_regs_len = nv_get_regs_len, .get_regs = nv_get_regs, .nway_reset = nv_nway_reset, - .get_perm_addr = ethtool_op_get_perm_addr, .get_tso = ethtool_op_get_tso, .set_tso = nv_set_tso, .get_ringparam = nv_get_ringparam, diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c index 656f2789c9b..cc0ee93669e 100644 --- a/drivers/net/hamradio/bpqether.c +++ b/drivers/net/hamradio/bpqether.c @@ -413,12 +413,12 @@ static void *bpq_seq_next(struct seq_file *seq, void *v, loff_t *pos) ++*pos; if (v == SEQ_START_TOKEN) - p = bpq_devices.next; + p = rcu_dereference(bpq_devices.next); else - p = ((struct bpqdev *)v)->bpq_list.next; + p = rcu_dereference(((struct bpqdev *)v)->bpq_list.next); return (p == &bpq_devices) ? NULL - : rcu_dereference(list_entry(p, struct bpqdev, bpq_list)); + : list_entry(p, struct bpqdev, bpq_list); } static void bpq_seq_stop(struct seq_file *seq, void *v) diff --git a/drivers/net/ixgb/ixgb_ethtool.c b/drivers/net/ixgb/ixgb_ethtool.c index afde84868be..0413cd95eda 100644 --- a/drivers/net/ixgb/ixgb_ethtool.c +++ b/drivers/net/ixgb/ixgb_ethtool.c @@ -724,7 +724,6 @@ static const struct ethtool_ops ixgb_ethtool_ops = { .phys_id = ixgb_phys_id, .get_stats_count = ixgb_get_stats_count, .get_ethtool_stats = ixgb_get_ethtool_stats, - .get_perm_addr = ethtool_op_get_perm_addr, }; void ixgb_set_ethtool_ops(struct net_device *netdev) diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index 6ba6ed2b480..5106c2328d1 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c @@ -229,7 +229,12 @@ struct net_device loopback_dev = { /* Setup and register the loopback device. */ static int __init loopback_init(void) { - return register_netdev(&loopback_dev); + int err = register_netdev(&loopback_dev); + + if (err) + panic("loopback: Failed to register netdevice: %d\n", err); + + return err; }; module_init(loopback_init); diff --git a/drivers/net/ne2k-pci.c b/drivers/net/ne2k-pci.c index cfdeaf7aa16..f81d9398d60 100644 --- a/drivers/net/ne2k-pci.c +++ b/drivers/net/ne2k-pci.c @@ -638,7 +638,6 @@ static const struct ethtool_ops ne2k_pci_ethtool_ops = { .get_drvinfo = ne2k_pci_get_drvinfo, .get_tx_csum = ethtool_op_get_tx_csum, .get_sg = ethtool_op_get_sg, - .get_perm_addr = ethtool_op_get_perm_addr, }; static void __devexit ne2k_pci_remove_one (struct pci_dev *pdev) diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c index 0175f6c353f..a6138b474b4 100644 --- a/drivers/net/netxen/netxen_nic_ethtool.c +++ b/drivers/net/netxen/netxen_nic_ethtool.c @@ -755,5 +755,4 @@ struct ethtool_ops netxen_nic_ethtool_ops = { .get_strings = netxen_nic_get_strings, .get_stats_count = netxen_nic_get_stats_count, .get_ethtool_stats = netxen_nic_get_ethtool_stats, - .get_perm_addr = ethtool_op_get_perm_addr, }; diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c index 465485a3fbc..e6a67531de9 100644 --- a/drivers/net/pcnet32.c +++ b/drivers/net/pcnet32.c @@ -1515,7 +1515,6 @@ static const struct ethtool_ops pcnet32_ethtool_ops = { .phys_id = pcnet32_phys_id, .get_regs_len = pcnet32_get_regs_len, .get_regs = pcnet32_get_regs, - .get_perm_addr = ethtool_op_get_perm_addr, }; /* only probes for non-PCI devices, the rest are handled by diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c index 6f98834e6ac..68631a5721a 100644 --- a/drivers/net/pppoe.c +++ b/drivers/net/pppoe.c @@ -108,19 +108,24 @@ static inline int cmp_addr(struct pppoe_addr *a, unsigned long sid, char *addr) (memcmp(a->remote,addr,ETH_ALEN) == 0)); } -static int hash_item(unsigned long sid, unsigned char *addr) +#if 8%PPPOE_HASH_BITS +#error 8 must be a multiple of PPPOE_HASH_BITS +#endif + +static int hash_item(unsigned int sid, unsigned char *addr) { - char hash = 0; - int i, j; + unsigned char hash = 0; + unsigned int i; - for (i = 0; i < ETH_ALEN ; ++i) { - for (j = 0; j < 8/PPPOE_HASH_BITS ; ++j) { - hash ^= addr[i] >> ( j * PPPOE_HASH_BITS ); - } + for (i = 0 ; i < ETH_ALEN ; i++) { + hash ^= addr[i]; + } + for (i = 0 ; i < sizeof(sid_t)*8 ; i += 8 ){ + hash ^= sid>>i; + } + for (i = 8 ; (i>>=1) >= PPPOE_HASH_BITS ; ) { + hash ^= hash>>i; } - - for (i = 0; i < (sizeof(unsigned long)*8) / PPPOE_HASH_BITS ; ++i) - hash ^= sid >> (i*PPPOE_HASH_BITS); return hash & ( PPPOE_HASH_SIZE - 1 ); } @@ -664,8 +669,8 @@ static int pppoe_ioctl(struct socket *sock, unsigned int cmd, { struct sock *sk = sock->sk; struct pppox_sock *po = pppox_sk(sk); - int val = 0; - int err = 0; + int val; + int err; switch (cmd) { case PPPIOCGMRU: @@ -754,8 +759,9 @@ static int pppoe_ioctl(struct socket *sock, unsigned int cmd, err = 0; break; - default:; - }; + default: + err = -ENOTTY; + } return err; } @@ -773,6 +779,7 @@ static int pppoe_sendmsg(struct kiocb *iocb, struct socket *sock, struct net_device *dev; char *start; + lock_sock(sk); if (sock_flag(sk, SOCK_DEAD) || !(sk->sk_state & PPPOX_CONNECTED)) { error = -ENOTCONN; goto end; @@ -783,8 +790,6 @@ static int pppoe_sendmsg(struct kiocb *iocb, struct socket *sock, hdr.code = 0; hdr.sid = po->num; - lock_sock(sk); - dev = po->pppoe_dev; error = -EMSGSIZE; diff --git a/drivers/net/pppox.c b/drivers/net/pppox.c index f3e47d0c2b3..25c52b55c38 100644 --- a/drivers/net/pppox.c +++ b/drivers/net/pppox.c @@ -73,7 +73,7 @@ int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) { struct sock *sk = sock->sk; struct pppox_sock *po = pppox_sk(sk); - int rc = 0; + int rc; lock_sock(sk); @@ -94,12 +94,9 @@ int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) break; } default: - if (pppox_protos[sk->sk_protocol]->ioctl) - rc = pppox_protos[sk->sk_protocol]->ioctl(sock, cmd, - arg); - - break; - }; + rc = pppox_protos[sk->sk_protocol]->ioctl ? + pppox_protos[sk->sk_protocol]->ioctl(sock, cmd, arg) : -ENOTTY; + } release_sock(sk); return rc; diff --git a/drivers/net/qla3xxx.c b/drivers/net/qla3xxx.c index 8be8be451ad..69da95b5ad0 100755 --- a/drivers/net/qla3xxx.c +++ b/drivers/net/qla3xxx.c @@ -1904,7 +1904,6 @@ static void ql_get_pauseparam(struct net_device *ndev, static const struct ethtool_ops ql3xxx_ethtool_ops = { .get_settings = ql_get_settings, .get_drvinfo = ql_get_drvinfo, - .get_perm_addr = ethtool_op_get_perm_addr, .get_link = ethtool_op_get_link, .get_msglevel = ql_get_msglevel, .set_msglevel = ql_set_msglevel, diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index bb6896ae315..c9333b9dd51 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c @@ -1066,7 +1066,6 @@ static const struct ethtool_ops rtl8169_ethtool_ops = { .get_strings = rtl8169_get_strings, .get_stats_count = rtl8169_get_stats_count, .get_ethtool_stats = rtl8169_get_ethtool_stats, - .get_perm_addr = ethtool_op_get_perm_addr, }; static void rtl8169_write_gmii_reg_bit(void __iomem *ioaddr, int reg, diff --git a/drivers/net/sc92031.c b/drivers/net/sc92031.c index 5b7284c955d..872cb1cc9c4 100644 --- a/drivers/net/sc92031.c +++ b/drivers/net/sc92031.c @@ -1402,7 +1402,6 @@ static struct ethtool_ops sc92031_ethtool_ops = { .get_strings = sc92031_ethtool_get_strings, .get_stats_count = sc92031_ethtool_get_stats_count, .get_ethtool_stats = sc92031_ethtool_get_ethtool_stats, - .get_perm_addr = ethtool_op_get_perm_addr, .get_ufo = ethtool_op_get_ufo, }; diff --git a/drivers/net/skfp/pmf.c b/drivers/net/skfp/pmf.c index efc639c013f..ea85de91823 100644 --- a/drivers/net/skfp/pmf.c +++ b/drivers/net/skfp/pmf.c @@ -575,7 +575,7 @@ void smt_add_para(struct s_smc *smc, struct s_pcon *pcon, u_short para, int sp_len ; /* - * skip if errror + * skip if error */ if (pcon->pc_err) return ; diff --git a/drivers/net/skge.c b/drivers/net/skge.c index 77669294656..e3d8520209b 100644 --- a/drivers/net/skge.c +++ b/drivers/net/skge.c @@ -821,7 +821,6 @@ static const struct ethtool_ops skge_ethtool_ops = { .phys_id = skge_phys_id, .get_stats_count = skge_get_stats_count, .get_ethtool_stats = skge_get_ethtool_stats, - .get_perm_addr = ethtool_op_get_perm_addr, }; /* diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 13f08a390e1..e7a2eadcc3b 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -3548,7 +3548,6 @@ static const struct ethtool_ops sky2_ethtool_ops = { .phys_id = sky2_phys_id, .get_stats_count = sky2_get_stats_count, .get_ethtool_stats = sky2_get_ethtool_stats, - .get_perm_addr = ethtool_op_get_perm_addr, }; #ifdef CONFIG_SKY2_DEBUG diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c index af0c9831074..a8f2af8f778 100644 --- a/drivers/net/sundance.c +++ b/drivers/net/sundance.c @@ -1586,7 +1586,6 @@ static const struct ethtool_ops ethtool_ops = { .get_link = get_link, .get_msglevel = get_msglevel, .set_msglevel = set_msglevel, - .get_perm_addr = ethtool_op_get_perm_addr, }; static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) diff --git a/drivers/net/sunlance.c b/drivers/net/sunlance.c index 053b7cb0d94..68e4f660367 100644 --- a/drivers/net/sunlance.c +++ b/drivers/net/sunlance.c @@ -99,8 +99,7 @@ static char lancestr[] = "LANCE"; #include <asm/byteorder.h> /* Used by the checksum routines */ #include <asm/idprom.h> #include <asm/sbus.h> -#include <asm/openprom.h> -#include <asm/oplib.h> +#include <asm/prom.h> #include <asm/auxio.h> /* For tpe-link-test? setting */ #include <asm/irq.h> @@ -1326,6 +1325,7 @@ static int __devinit sparc_lance_probe_one(struct sbus_dev *sdev, struct sbus_dev *lebuffer) { static unsigned version_printed; + struct device_node *dp = sdev->ofdev.node; struct net_device *dev; struct lance_private *lp; int i; @@ -1389,54 +1389,46 @@ static int __devinit sparc_lance_probe_one(struct sbus_dev *sdev, lp->rx = lance_rx_dvma; lp->tx = lance_tx_dvma; } - lp->busmaster_regval = prom_getintdefault(sdev->prom_node, - "busmaster-regval", - (LE_C3_BSWP | LE_C3_ACON | - LE_C3_BCON)); + lp->busmaster_regval = of_getintprop_default(dp, "busmaster-regval", + (LE_C3_BSWP | + LE_C3_ACON | + LE_C3_BCON)); lp->name = lancestr; lp->ledma = ledma; lp->burst_sizes = 0; if (lp->ledma) { - char prop[6]; + struct device_node *ledma_dp = ledma->sdev->ofdev.node; + const char *prop; unsigned int sbmask; u32 csr; /* Find burst-size property for ledma */ - lp->burst_sizes = prom_getintdefault(ledma->sdev->prom_node, - "burst-sizes", 0); + lp->burst_sizes = of_getintprop_default(ledma_dp, + "burst-sizes", 0); /* ledma may be capable of fast bursts, but sbus may not. */ - sbmask = prom_getintdefault(ledma->sdev->bus->prom_node, - "burst-sizes", DMA_BURSTBITS); + sbmask = of_getintprop_default(ledma_dp, "burst-sizes", + DMA_BURSTBITS); lp->burst_sizes &= sbmask; /* Get the cable-selection property */ - memset(prop, 0, sizeof(prop)); - prom_getstring(ledma->sdev->prom_node, "cable-selection", - prop, sizeof(prop)); - if (prop[0] == 0) { - int topnd, nd; + prop = of_get_property(ledma_dp, "cable-selection", NULL); + if (!prop || prop[0] == '\0') { + struct device_node *nd; - printk(KERN_INFO "SunLance: using auto-carrier-detection.\n"); + printk(KERN_INFO "SunLance: using " + "auto-carrier-detection.\n"); - /* Is this found at /options .attributes in all - * Prom versions? XXX - */ - topnd = prom_getchild(prom_root_node); - - nd = prom_searchsiblings(topnd, "options"); + nd = of_find_node_by_path("/options"); if (!nd) goto no_link_test; - if (!prom_node_has_property(nd, "tpe-link-test?")) + prop = of_get_property(nd, "tpe-link-test?", NULL); + if (!prop) goto no_link_test; - memset(prop, 0, sizeof(prop)); - prom_getstring(nd, "tpe-link-test?", prop, - sizeof(prop)); - if (strcmp(prop, "true")) { printk(KERN_NOTICE "SunLance: warning: overriding option " "'tpe-link-test?'\n"); diff --git a/drivers/net/sunvnet.c b/drivers/net/sunvnet.c index 61f98251fea..ff1028a597d 100644 --- a/drivers/net/sunvnet.c +++ b/drivers/net/sunvnet.c @@ -906,7 +906,6 @@ static const struct ethtool_ops vnet_ethtool_ops = { .get_msglevel = vnet_get_msglevel, .set_msglevel = vnet_set_msglevel, .get_link = ethtool_op_get_link, - .get_perm_addr = ethtool_op_get_perm_addr, }; static void vnet_port_free_tx_bufs(struct vnet_port *port) diff --git a/drivers/net/tc35815.c b/drivers/net/tc35815.c index 7f94ca93098..ec41469eee8 100644 --- a/drivers/net/tc35815.c +++ b/drivers/net/tc35815.c @@ -2198,7 +2198,6 @@ static const struct ethtool_ops tc35815_ethtool_ops = { .get_strings = tc35815_get_strings, .get_stats_count = tc35815_get_stats_count, .get_ethtool_stats = tc35815_get_ethtool_stats, - .get_perm_addr = ethtool_op_get_perm_addr, }; static int tc35815_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 887b9a5cfe4..dc41c055ebb 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c @@ -9294,7 +9294,6 @@ static const struct ethtool_ops tg3_ethtool_ops = { .get_ethtool_stats = tg3_get_ethtool_stats, .get_coalesce = tg3_get_coalesce, .set_coalesce = tg3_set_coalesce, - .get_perm_addr = ethtool_op_get_perm_addr, }; static void __devinit tg3_get_eeprom_size(struct tg3 *tp) diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c index f87d76981ab..eca984f89bb 100644 --- a/drivers/net/tulip/tulip_core.c +++ b/drivers/net/tulip/tulip_core.c @@ -1471,14 +1471,6 @@ static int __devinit tulip_init_one (struct pci_dev *pdev, sa_offset = 2; /* Grrr, damn Matrox boards. */ multiport_cnt = 4; } -#ifdef CONFIG_DDB5477 - if ((pdev->bus->number == 0) && (PCI_SLOT(pdev->devfn) == 4)) { - /* DDB5477 MAC address in first EEPROM locations. */ - sa_offset = 0; - /* No media table either */ - tp->flags &= ~HAS_MEDIA_TABLE; - } -#endif #ifdef CONFIG_MIPS_COBALT if ((pdev->bus->number == 0) && ((PCI_SLOT(pdev->devfn) == 7) || diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c index f51c2c138f1..c3fe230695a 100644 --- a/drivers/net/via-rhine.c +++ b/drivers/net/via-rhine.c @@ -1805,7 +1805,6 @@ static const struct ethtool_ops netdev_ethtool_ops = { .set_wol = rhine_set_wol, .get_sg = ethtool_op_get_sg, .get_tx_csum = ethtool_op_get_tx_csum, - .get_perm_addr = ethtool_op_get_perm_addr, }; static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c index f331843d110..93574add406 100644 --- a/drivers/net/via-velocity.c +++ b/drivers/net/via-velocity.c @@ -1613,7 +1613,7 @@ static void velocity_error(struct velocity_info *vptr, int status) if (status & ISR_TXSTLI) { struct mac_regs __iomem * regs = vptr->mac_regs; - printk(KERN_ERR "TD structure errror TDindex=%hx\n", readw(®s->TDIdx[0])); + printk(KERN_ERR "TD structure error TDindex=%hx\n", readw(®s->TDIdx[0])); BYTE_REG_BITS_ON(TXESR_TDSTR, ®s->TXESR); writew(TRDCSR_RUN, ®s->TDCSRClr); netif_stop_queue(vptr->dev); diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c index 5d58ad55d85..e2be8400110 100644 --- a/drivers/parport/parport_pc.c +++ b/drivers/parport/parport_pc.c @@ -3445,7 +3445,6 @@ static void __exit parport_pc_exit(void) pnp_unregister_driver (&parport_pc_pnp_driver); platform_driver_unregister(&parport_pc_platform_driver); - spin_lock(&ports_lock); while (!list_empty(&ports_list)) { struct parport_pc_private *priv; struct parport *port; @@ -3455,11 +3454,8 @@ static void __exit parport_pc_exit(void) if (port->dev && port->dev->bus == &platform_bus_type) platform_device_unregister( to_platform_device(port->dev)); - spin_unlock(&ports_lock); parport_pc_unregister_port(port); - spin_lock(&ports_lock); } - spin_unlock(&ports_lock); } MODULE_AUTHOR("Phil Blundell, Tim Waugh, others"); diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index 7c93a108f9b..f8b13f0270d 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -409,6 +409,9 @@ static void socket_shutdown(struct pcmcia_socket *s) #endif s->functions = 0; + /* give socket some time to power down */ + msleep(100); + s->ops->get_status(s, &status); if (status & SS_POWERON) { printk(KERN_ERR "PCMCIA: socket %p: *** DANGER *** unable to remove socket power\n", s); diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 9d8d40d5c8f..ff9e35cb308 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -2,15 +2,13 @@ # RTC class/drivers configuration # -menu "Real Time Clock" - depends on !S390 - config RTC_LIB tristate -config RTC_CLASS - tristate "RTC class" +menuconfig RTC_CLASS + tristate "Real Time Clock" default n + depends on !S390 select RTC_LIB help Generic RTC class support. If you say yes here, you will @@ -20,6 +18,8 @@ config RTC_CLASS This driver can also be built as a module. If so, the module will be called rtc-class. +if RTC_CLASS + config RTC_HCTOSYS bool "Set system time from RTC on startup and resume" depends on RTC_CLASS = y @@ -58,11 +58,10 @@ config RTC_DEBUG and individual RTC drivers. comment "RTC interfaces" - depends on RTC_CLASS config RTC_INTF_SYSFS boolean "/sys/class/rtc/rtcN (sysfs)" - depends on RTC_CLASS && SYSFS + depends on SYSFS default RTC_CLASS help Say yes here if you want to use your RTCs using sysfs interfaces, @@ -73,7 +72,7 @@ config RTC_INTF_SYSFS config RTC_INTF_PROC boolean "/proc/driver/rtc (procfs for rtc0)" - depends on RTC_CLASS && PROC_FS + depends on PROC_FS default RTC_CLASS help Say yes here if you want to use your first RTC through the proc @@ -85,7 +84,6 @@ config RTC_INTF_PROC config RTC_INTF_DEV boolean "/dev/rtcN (character devices)" - depends on RTC_CLASS default RTC_CLASS help Say yes here if you want to use your RTCs using the /dev @@ -107,7 +105,6 @@ config RTC_INTF_DEV_UIE_EMUL config RTC_DRV_TEST tristate "Test driver/device" - depends on RTC_CLASS help If you say yes here you get support for the RTC test driver. It's a software RTC which can be @@ -121,11 +118,12 @@ config RTC_DRV_TEST will be called rtc-test. comment "I2C RTC drivers" - depends on RTC_CLASS && I2C + depends on I2C + +if I2C config RTC_DRV_DS1307 tristate "Dallas/Maxim DS1307/37/38/39/40, ST M41T00" - depends on RTC_CLASS && I2C help If you say yes here you get support for various compatible RTC chips (often with battery backup) connected with I2C. This driver @@ -143,7 +141,6 @@ config RTC_DRV_DS1307 config RTC_DRV_DS1672 tristate "Dallas/Maxim DS1672" - depends on RTC_CLASS && I2C help If you say yes here you get support for the Dallas/Maxim DS1672 timekeeping chip. @@ -153,7 +150,6 @@ config RTC_DRV_DS1672 config RTC_DRV_MAX6900 tristate "Maxim 6900" - depends on RTC_CLASS && I2C help If you say yes here you will get support for the Maxim MAX6900 I2C RTC chip. @@ -163,7 +159,6 @@ config RTC_DRV_MAX6900 config RTC_DRV_RS5C372 tristate "Ricoh RS5C372A/B, RV5C386, RV5C387A" - depends on RTC_CLASS && I2C help If you say yes here you get support for the Ricoh RS5C372A, RS5C372B, RV5C386, and RV5C387A RTC chips. @@ -173,7 +168,6 @@ config RTC_DRV_RS5C372 config RTC_DRV_ISL1208 tristate "Intersil 1208" - depends on RTC_CLASS && I2C help If you say yes here you get support for the Intersil 1208 RTC chip. @@ -183,7 +177,6 @@ config RTC_DRV_ISL1208 config RTC_DRV_X1205 tristate "Xicor/Intersil X1205" - depends on RTC_CLASS && I2C help If you say yes here you get support for the Xicor/Intersil X1205 RTC chip. @@ -193,7 +186,6 @@ config RTC_DRV_X1205 config RTC_DRV_PCF8563 tristate "Philips PCF8563/Epson RTC8564" - depends on RTC_CLASS && I2C help If you say yes here you get support for the Philips PCF8563 RTC chip. The Epson RTC8564 @@ -204,7 +196,6 @@ config RTC_DRV_PCF8563 config RTC_DRV_PCF8583 tristate "Philips PCF8583" - depends on RTC_CLASS && I2C help If you say yes here you get support for the Philips PCF8583 RTC chip found on Acorn RiscPCs. This driver supports the @@ -217,7 +208,6 @@ config RTC_DRV_PCF8583 config RTC_DRV_M41T80 tristate "ST M41T80 series RTC" - depends on RTC_CLASS && I2C help If you say Y here you will get support for the ST M41T80 RTC chips series. Currently following chips are @@ -236,19 +226,21 @@ config RTC_DRV_M41T80_WDT config RTC_DRV_TWL92330 boolean "TI TWL92330/Menelaus" - depends on RTC_CLASS && I2C && MENELAUS + depends on MENELAUS help If you say yes here you get support for the RTC on the TWL92330 "Menelaus" power mangement chip, used with OMAP2 platforms. The support is integrated with the rest of the Menelaus driver; it's not separate module. +endif # I2C + comment "SPI RTC drivers" - depends on RTC_CLASS && SPI_MASTER + +if SPI_MASTER config RTC_DRV_RS5C348 tristate "Ricoh RS5C348A/B" - depends on RTC_CLASS && SPI_MASTER help If you say yes here you get support for the Ricoh RS5C348A and RS5C348B RTC chips. @@ -258,7 +250,6 @@ config RTC_DRV_RS5C348 config RTC_DRV_MAX6902 tristate "Maxim 6902" - depends on RTC_CLASS && SPI_MASTER help If you say yes here you will get support for the Maxim MAX6902 SPI RTC chip. @@ -266,8 +257,9 @@ config RTC_DRV_MAX6902 This driver can also be built as a module. If so, the module will be called rtc-max6902. +endif # SPI_MASTER + comment "Platform RTC drivers" - depends on RTC_CLASS # this 'CMOS' RTC driver is arch dependent because <asm-generic/rtc.h> # requires <asm/mc146818rtc.h> defining CMOS_READ/CMOS_WRITE, and a @@ -275,8 +267,7 @@ comment "Platform RTC drivers" config RTC_DRV_CMOS tristate "PC-style 'CMOS'" - depends on RTC_CLASS && (X86 || ALPHA || ARM26 || ARM \ - || M32R || ATARI || PPC || MIPS) + depends on X86 || ALPHA || ARM || M32R || ATARI || PPC || MIPS help Say "yes" here to get direct support for the real time clock found in every PC or ACPI-based system, and some other boards. @@ -294,13 +285,12 @@ config RTC_DRV_CMOS config RTC_DRV_DS1216 tristate "Dallas DS1216" - depends on RTC_CLASS && SNI_RM + depends on SNI_RM help If you say yes here you get support for the Dallas DS1216 RTC chips. config RTC_DRV_DS1553 tristate "Dallas DS1553" - depends on RTC_CLASS help If you say yes here you get support for the Dallas DS1553 timekeeping chip. @@ -320,7 +310,6 @@ config RTC_DRV_STK17TA8 config RTC_DRV_DS1742 tristate "Dallas DS1742/1743" - depends on RTC_CLASS help If you say yes here you get support for the Dallas DS1742/1743 timekeeping chip. @@ -330,7 +319,6 @@ config RTC_DRV_DS1742 config RTC_DRV_M48T86 tristate "ST M48T86/Dallas DS12887" - depends on RTC_CLASS help If you say Y here you will get support for the ST M48T86 and Dallas DS12887 RTC chips. @@ -340,7 +328,6 @@ config RTC_DRV_M48T86 config RTC_DRV_M48T59 tristate "ST M48T59" - depends on RTC_CLASS help If you say Y here you will get support for the ST M48T59 RTC chip. @@ -350,7 +337,6 @@ config RTC_DRV_M48T59 config RTC_DRV_V3020 tristate "EM Microelectronic V3020" - depends on RTC_CLASS help If you say yes here you will get support for the EM Microelectronic v3020 RTC chip. @@ -359,19 +345,17 @@ config RTC_DRV_V3020 will be called rtc-v3020. comment "on-CPU RTC drivers" - depends on RTC_CLASS config RTC_DRV_OMAP tristate "TI OMAP1" - depends on RTC_CLASS && ( \ - ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730 ) + depends on ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730 help Say "yes" here to support the real time clock on TI OMAP1 chips. This driver can also be built as a module called rtc-omap. config RTC_DRV_S3C tristate "Samsung S3C series SoC RTC" - depends on RTC_CLASS && ARCH_S3C2410 + depends on ARCH_S3C2410 help RTC (Realtime Clock) driver for the clock inbuilt into the Samsung S3C24XX series of SoCs. This can provide periodic @@ -387,7 +371,7 @@ config RTC_DRV_S3C config RTC_DRV_EP93XX tristate "Cirrus Logic EP93XX" - depends on RTC_CLASS && ARCH_EP93XX + depends on ARCH_EP93XX help If you say yes here you get support for the RTC embedded in the Cirrus Logic EP93XX processors. @@ -397,7 +381,7 @@ config RTC_DRV_EP93XX config RTC_DRV_SA1100 tristate "SA11x0/PXA2xx" - depends on RTC_CLASS && (ARCH_SA1100 || ARCH_PXA) + depends on ARCH_SA1100 || ARCH_PXA help If you say Y here you will get access to the real time clock built into your SA11x0 or PXA2xx CPU. @@ -407,7 +391,7 @@ config RTC_DRV_SA1100 config RTC_DRV_SH tristate "SuperH On-Chip RTC" - depends on RTC_CLASS && SUPERH && (CPU_SH3 || CPU_SH4) + depends on RTC_CLASS && (CPU_SH3 || CPU_SH4) help Say Y here to enable support for the on-chip RTC found in most SuperH processors. @@ -417,7 +401,7 @@ config RTC_DRV_SH config RTC_DRV_VR41XX tristate "NEC VR41XX" - depends on RTC_CLASS && CPU_VR41XX + depends on CPU_VR41XX help If you say Y here you will get access to the real time clock built into your NEC VR41XX CPU. @@ -427,7 +411,7 @@ config RTC_DRV_VR41XX config RTC_DRV_PL031 tristate "ARM AMBA PL031 RTC" - depends on RTC_CLASS && ARM_AMBA + depends on ARM_AMBA help If you say Y here you will get access to ARM AMBA PrimeCell PL031 RTC found on certain ARM SOCs. @@ -437,20 +421,20 @@ config RTC_DRV_PL031 config RTC_DRV_AT32AP700X tristate "AT32AP700X series RTC" - depends on RTC_CLASS && PLATFORM_AT32AP + depends on PLATFORM_AT32AP help Driver for the internal RTC (Realtime Clock) on Atmel AVR32 AT32AP700x family processors. config RTC_DRV_AT91RM9200 tristate "AT91RM9200" - depends on RTC_CLASS && ARCH_AT91RM9200 + depends on ARCH_AT91RM9200 help Driver for the Atmel AT91RM9200's internal RTC (Realtime Clock). config RTC_DRV_BFIN tristate "Blackfin On-Chip RTC" - depends on RTC_CLASS && BFIN + depends on BFIN help If you say yes here you will get support for the Blackfin On-Chip Real Time Clock. @@ -460,8 +444,8 @@ config RTC_DRV_BFIN config RTC_DRV_RS5C313 tristate "Ricoh RS5C313" - depends on RTC_CLASS && SH_LANDISK + depends on SH_LANDISK help If you say yes here you get support for the Ricoh RS5C313 RTC chips. -endmenu +endif # RTC_CLASS diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c index 304535942de..005fff3a350 100644 --- a/drivers/rtc/rtc-dev.c +++ b/drivers/rtc/rtc-dev.c @@ -348,6 +348,8 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file, case RTC_IRQP_SET: if (ops->irq_set_freq) err = rtc_irq_set_freq(rtc, rtc->irq_task, arg); + else + err = -ENOTTY; break; #if 0 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c index 33b752350ab..bf60d35f580 100644 --- a/drivers/rtc/rtc-m48t59.c +++ b/drivers/rtc/rtc-m48t59.c @@ -35,7 +35,7 @@ struct m48t59_private { void __iomem *ioaddr; unsigned int size; /* iomem size */ - unsigned int irq; + int irq; struct rtc_device *rtc; spinlock_t lock; /* serialize the NVRAM and RTC access */ }; diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index 54b61305346..8c1012b432b 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c @@ -29,7 +29,7 @@ #include <asm/mach/time.h> -#include <asm/arch/regs-rtc.h> +#include <asm/plat-s3c/regs-rtc.h> /* I have yet to find an S3C implementation with more than one * of these rtc blocks in */ diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c index 418b4e63a4f..ea63ba7828f 100644 --- a/drivers/s390/block/dasd_eckd.c +++ b/drivers/s390/block/dasd_eckd.c @@ -555,7 +555,7 @@ dasd_eckd_read_conf(struct dasd_device *device) if (conf_data == NULL) { MESSAGE(KERN_WARNING, "%s", "No configuration " "data retrieved"); - continue; /* no errror */ + continue; /* no error */ } if (conf_len != sizeof (struct dasd_eckd_confdata)) { MESSAGE(KERN_WARNING, @@ -564,7 +564,7 @@ dasd_eckd_read_conf(struct dasd_device *device) conf_len, sizeof (struct dasd_eckd_confdata)); kfree(conf_data); - continue; /* no errror */ + continue; /* no error */ } /* save first valid configuration data */ if (!conf_data_saved){ diff --git a/drivers/sbus/char/bbc_envctrl.c b/drivers/sbus/char/bbc_envctrl.c index e821a155b65..0bde26989a2 100644 --- a/drivers/sbus/char/bbc_envctrl.c +++ b/drivers/sbus/char/bbc_envctrl.c @@ -479,11 +479,12 @@ static int kenvctrld(void *__unused) static void attach_one_temp(struct linux_ebus_child *echild, int temp_idx) { - struct bbc_cpu_temperature *tp = kmalloc(sizeof(*tp), GFP_KERNEL); + struct bbc_cpu_temperature *tp; + tp = kzalloc(sizeof(*tp), GFP_KERNEL); if (!tp) return; - memset(tp, 0, sizeof(*tp)); + tp->client = bbc_i2c_attach(echild); if (!tp->client) { kfree(tp); @@ -525,11 +526,12 @@ static void attach_one_temp(struct linux_ebus_child *echild, int temp_idx) static void attach_one_fan(struct linux_ebus_child *echild, int fan_idx) { - struct bbc_fan_control *fp = kmalloc(sizeof(*fp), GFP_KERNEL); + struct bbc_fan_control *fp; + fp = kzalloc(sizeof(*fp), GFP_KERNEL); if (!fp) return; - memset(fp, 0, sizeof(*fp)); + fp->client = bbc_i2c_attach(echild); if (!fp->client) { kfree(fp); diff --git a/drivers/sbus/char/bbc_i2c.c b/drivers/sbus/char/bbc_i2c.c index fbadd4d761f..ac8ef2ce07f 100644 --- a/drivers/sbus/char/bbc_i2c.c +++ b/drivers/sbus/char/bbc_i2c.c @@ -357,13 +357,13 @@ static void __init reset_one_i2c(struct bbc_i2c_bus *bp) static int __init attach_one_i2c(struct linux_ebus_device *edev, int index) { - struct bbc_i2c_bus *bp = kmalloc(sizeof(*bp), GFP_KERNEL); + struct bbc_i2c_bus *bp; struct linux_ebus_child *echild; int entry; + bp = kzalloc(sizeof(*bp), GFP_KERNEL); if (!bp) return -ENOMEM; - memset(bp, 0, sizeof(*bp)); bp->i2c_control_regs = ioremap(edev->resource[0].start, 0x2); if (!bp->i2c_control_regs) diff --git a/drivers/sbus/char/vfc_dev.c b/drivers/sbus/char/vfc_dev.c index 26b1d2a17ed..9269f7fbd36 100644 --- a/drivers/sbus/char/vfc_dev.c +++ b/drivers/sbus/char/vfc_dev.c @@ -248,6 +248,7 @@ static int vfc_debug(struct vfc_dev *dev, int cmd, void __user *argp) buffer,inout.len); if (copy_to_user(argp,&inout,sizeof(inout))) { + vfc_unlock_device(dev); kfree(buffer); return -EFAULT; } diff --git a/drivers/scsi/arm/Kconfig b/drivers/scsi/arm/Kconfig index d006a8cb4a7..7236143941f 100644 --- a/drivers/scsi/arm/Kconfig +++ b/drivers/scsi/arm/Kconfig @@ -74,15 +74,6 @@ config SCSI_CUMANA_1 This enables support for the Cumana SCSI I card. If you have an Acorn system with one of these, say Y. If unsure, say N. -config SCSI_ECOSCSI - tristate "EcoScsi support (EXPERIMENTAL)" - depends on ARCH_ACORN && EXPERIMENTAL && (ARCH_ARC || ARCH_A5K) && SCSI - select SCSI_SPI_ATTRS - help - This enables support for the EcoSCSI card -- a small card that sits - in the Econet socket. If you have an Acorn system with one of these, - say Y. If unsure, say N. - config SCSI_OAK1 tristate "Oak SCSI support (EXPERIMENTAL)" depends on ARCH_ACORN && EXPERIMENTAL && SCSI diff --git a/drivers/scsi/arm/Makefile b/drivers/scsi/arm/Makefile index e8db17924c1..16c3e86a6b1 100644 --- a/drivers/scsi/arm/Makefile +++ b/drivers/scsi/arm/Makefile @@ -8,7 +8,6 @@ obj-$(CONFIG_SCSI_ACORNSCSI_3) += acornscsi_mod.o queue.o msgqueue.o obj-$(CONFIG_SCSI_ARXESCSI) += arxescsi.o fas216.o queue.o msgqueue.o obj-$(CONFIG_SCSI_CUMANA_1) += cumana_1.o obj-$(CONFIG_SCSI_CUMANA_2) += cumana_2.o fas216.o queue.o msgqueue.o -obj-$(CONFIG_SCSI_ECOSCSI) += ecoscsi.o obj-$(CONFIG_SCSI_OAK1) += oak.o obj-$(CONFIG_SCSI_POWERTECSCSI) += powertec.o fas216.o queue.o msgqueue.o obj-$(CONFIG_SCSI_EESOXSCSI) += eesox.o fas216.o queue.o msgqueue.o diff --git a/drivers/scsi/arm/ecoscsi.c b/drivers/scsi/arm/ecoscsi.c deleted file mode 100644 index 5265a988433..00000000000 --- a/drivers/scsi/arm/ecoscsi.c +++ /dev/null @@ -1,166 +0,0 @@ -#define AUTOSENSE -/* #define PSEUDO_DMA */ - -/* - * EcoSCSI Generic NCR5380 driver - * - * Copyright 1995, Russell King - * - * ALPHA RELEASE 1. - * - * For more information, please consult - * - * NCR 5380 Family - * SCSI Protocol Controller - * Databook - * - * NCR Microelectronics - * 1635 Aeroplaza Drive - * Colorado Springs, CO 80916 - * 1+ (719) 578-3400 - * 1+ (800) 334-5454 - */ - -#include <linux/module.h> -#include <linux/signal.h> -#include <linux/ioport.h> -#include <linux/delay.h> -#include <linux/init.h> -#include <linux/blkdev.h> - -#include <asm/io.h> -#include <asm/system.h> - -#include "../scsi.h" -#include <scsi/scsi_host.h> - -#define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata) - -#define NCR5380_local_declare() void __iomem *_base -#define NCR5380_setup(host) _base = priv(host)->base - -#define NCR5380_read(reg) ({ writeb(reg | 8, _base); readb(_base + 4); }) -#define NCR5380_write(reg, value) ({ writeb(reg | 8, _base); writeb(value, _base + 4); }) - -#define NCR5380_intr ecoscsi_intr -#define NCR5380_queue_command ecoscsi_queue_command -#define NCR5380_proc_info ecoscsi_proc_info - -#define NCR5380_implementation_fields \ - void __iomem *base - -#include "../NCR5380.h" - -#define ECOSCSI_PUBLIC_RELEASE 1 - -/* - * Function : ecoscsi_setup(char *str, int *ints) - * - * Purpose : LILO command line initialization of the overrides array, - * - * Inputs : str - unused, ints - array of integer parameters with ints[0] - * equal to the number of ints. - * - */ - -void ecoscsi_setup(char *str, int *ints) -{ -} - -const char * ecoscsi_info (struct Scsi_Host *spnt) -{ - return ""; -} - -#define BOARD_NORMAL 0 -#define BOARD_NCR53C400 1 - -#include "../NCR5380.c" - -static struct scsi_host_template ecoscsi_template = { - .module = THIS_MODULE, - .name = "Serial Port EcoSCSI NCR5380", - .proc_name = "ecoscsi", - .info = ecoscsi_info, - .queuecommand = ecoscsi_queue_command, - .eh_abort_handler = NCR5380_abort, - .eh_bus_reset_handler = NCR5380_bus_reset, - .can_queue = 16, - .this_id = 7, - .sg_tablesize = SG_ALL, - .cmd_per_lun = 2, - .use_clustering = DISABLE_CLUSTERING -}; - -static struct Scsi_Host *host; - -static int __init ecoscsi_init(void) -{ - void __iomem *_base; - int ret; - - if (!request_mem_region(0x33a0000, 4096, "ecoscsi")) { - ret = -EBUSY; - goto out; - } - - _base = ioremap(0x33a0000, 4096); - if (!_base) { - ret = -ENOMEM; - goto out_release; - } - - NCR5380_write(MODE_REG, 0x20); /* Is it really SCSI? */ - if (NCR5380_read(MODE_REG) != 0x20) /* Write to a reg. */ - goto out_unmap; - - NCR5380_write(MODE_REG, 0x00); /* it back. */ - if (NCR5380_read(MODE_REG) != 0x00) - goto out_unmap; - - host = scsi_host_alloc(tpnt, sizeof(struct NCR5380_hostdata)); - if (!host) { - ret = -ENOMEM; - goto out_unmap; - } - - priv(host)->base = _base; - host->irq = IRQ_NONE; - - NCR5380_init(host, 0); - - printk("scsi%d: at port 0x%08lx irqs disabled", host->host_no, host->io_port); - printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", - host->can_queue, host->cmd_per_lun, ECOSCSI_PUBLIC_RELEASE); - printk("\nscsi%d:", host->host_no); - NCR5380_print_options(host); - printk("\n"); - - scsi_add_host(host, NULL); /* XXX handle failure */ - scsi_scan_host(host); - return 0; - - out_unmap: - iounmap(_base); - out_release: - release_mem_region(0x33a0000, 4096); - out: - return ret; -} - -static void __exit ecoscsi_exit(void) -{ - scsi_remove_host(host); - NCR5380_exit(host); - scsi_host_put(host); - release_mem_region(0x33a0000, 4096); - return 0; -} - -module_init(ecoscsi_init); -module_exit(ecoscsi_exit); - -MODULE_AUTHOR("Russell King"); -MODULE_DESCRIPTION("Econet-SCSI driver for Acorn machines"); -MODULE_LICENSE("GPL"); - diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c index 6d7d616e9cc..5e485876f54 100644 --- a/drivers/serial/8250_pci.c +++ b/drivers/serial/8250_pci.c @@ -976,7 +976,6 @@ enum pci_board_num_t { pbn_oxsemi, pbn_intel_i960, pbn_sgi_ioc3, - pbn_nec_nile4, pbn_computone_4, pbn_computone_6, pbn_computone_8, @@ -1443,18 +1442,6 @@ static struct pciserial_board pci_boards[] __devinitdata = { }, /* - * NEC Vrc-5074 (Nile 4) builtin UART. - */ - [pbn_nec_nile4] = { - .flags = FL_BASE0, - .num_ports = 1, - .base_baud = 520833, - .uart_offset = 8 << 3, - .reg_shift = 3, - .first_offset = 0x300, - }, - - /* * Computone - uses IOMEM. */ [pbn_computone_4] = { @@ -2345,13 +2332,6 @@ static struct pci_device_id serial_pci_tbl[] = { PCI_ANY_ID, PCI_ANY_ID, 0, 0, pbn_b2_1_115200 }, - /* - * NEC Vrc-5074 (Nile 4) builtin UART. - */ - { PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_NILE4, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, - pbn_nec_nile4 }, - { PCI_VENDOR_ID_DCI, PCI_DEVICE_ID_DCI_PCCOM2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, pbn_b3_2_115200 }, diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 18f62970644..64ff6a5f6af 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -88,21 +88,17 @@ config SERIAL_8250_PCI depends on SERIAL_8250 && PCI default SERIAL_8250 help - Say Y here if you have PCI serial ports. - - To compile this driver as a module, choose M here: the module - will be called 8250_pci. + This builds standard PCI serial support. You may be able to + disable this feature if you only need legacy serial support. + Saves about 9K. config SERIAL_8250_PNP tristate "8250/16550 PNP device support" if EMBEDDED depends on SERIAL_8250 && PNP default SERIAL_8250 help - Say Y here if you have serial ports described by PNPBIOS or ACPI. - These are typically ports built into the system board. - - To compile this driver as a module, choose M here: the module - will be called 8250_pnp. + This builds standard PNP serial support. You may be able to + disable this feature if you only need legacy serial support. config SERIAL_8250_HP300 tristate @@ -1195,7 +1191,7 @@ config SERIAL_VR41XX config SERIAL_VR41XX_CONSOLE bool "Enable NEC VR4100 series Serial Interface Unit console" - depends on SERIAL_VR41XX + depends on SERIAL_VR41XX=y select SERIAL_CORE_CONSOLE help If you have a NEC VR4100 series processor and you want to use diff --git a/drivers/serial/mpsc.c b/drivers/serial/mpsc.c index 00924feaf62..4d643c92665 100644 --- a/drivers/serial/mpsc.c +++ b/drivers/serial/mpsc.c @@ -74,10 +74,6 @@ #include <asm/io.h> #include <asm/irq.h> -#if defined(CONFIG_SERIAL_MPSC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) -#define SUPPORT_SYSRQ -#endif - #define MPSC_NUM_CTLRS 2 /* @@ -97,9 +93,8 @@ #define MPSC_TXBE_SIZE dma_get_cache_alignment() #define MPSC_TXB_SIZE (MPSC_TXR_ENTRIES * MPSC_TXBE_SIZE) -#define MPSC_DMA_ALLOC_SIZE (MPSC_RXR_SIZE + MPSC_RXB_SIZE + \ - MPSC_TXR_SIZE + MPSC_TXB_SIZE + \ - dma_get_cache_alignment() /* for alignment */) +#define MPSC_DMA_ALLOC_SIZE (MPSC_RXR_SIZE + MPSC_RXB_SIZE + MPSC_TXR_SIZE \ + + MPSC_TXB_SIZE + dma_get_cache_alignment() /* for alignment */) /* Rx and Tx Ring entry descriptors -- assume entry size is <= cacheline size */ struct mpsc_rx_desc { @@ -270,8 +265,8 @@ struct mpsc_port_info *mpsc_device_remove(int index); #define SDMA_DESC_CMDSTAT_EI (1<<23) #define SDMA_DESC_CMDSTAT_O (1<<31) -#define SDMA_DESC_DFLT (SDMA_DESC_CMDSTAT_O | \ - SDMA_DESC_CMDSTAT_EI) +#define SDMA_DESC_DFLT (SDMA_DESC_CMDSTAT_O \ + | SDMA_DESC_CMDSTAT_EI) #define SDMA_SDC_RFT (1<<0) #define SDMA_SDC_SFM (1<<1) @@ -295,10 +290,10 @@ struct mpsc_port_info *mpsc_device_remove(int index); #define SDMA_1_CAUSE_TXBUF (1<<10) #define SDMA_1_CAUSE_TXEND (1<<11) -#define SDMA_CAUSE_RX_MASK (SDMA_0_CAUSE_RXBUF | SDMA_0_CAUSE_RXERR | \ - SDMA_1_CAUSE_RXBUF | SDMA_1_CAUSE_RXERR) -#define SDMA_CAUSE_TX_MASK (SDMA_0_CAUSE_TXBUF | SDMA_0_CAUSE_TXEND | \ - SDMA_1_CAUSE_TXBUF | SDMA_1_CAUSE_TXEND) +#define SDMA_CAUSE_RX_MASK (SDMA_0_CAUSE_RXBUF | SDMA_0_CAUSE_RXERR \ + | SDMA_1_CAUSE_RXBUF | SDMA_1_CAUSE_RXERR) +#define SDMA_CAUSE_TX_MASK (SDMA_0_CAUSE_TXBUF | SDMA_0_CAUSE_TXEND \ + | SDMA_1_CAUSE_TXBUF | SDMA_1_CAUSE_TXEND) /* SDMA Interrupt registers */ #define SDMA_INTR_CAUSE 0x0000 @@ -312,11 +307,11 @@ struct mpsc_port_info *mpsc_device_remove(int index); * Define how this driver is known to the outside (we've been assigned a * range on the "Low-density serial ports" major). */ -#define MPSC_MAJOR 204 -#define MPSC_MINOR_START 44 -#define MPSC_DRIVER_NAME "MPSC" -#define MPSC_DEV_NAME "ttyMM" -#define MPSC_VERSION "1.00" +#define MPSC_MAJOR 204 +#define MPSC_MINOR_START 44 +#define MPSC_DRIVER_NAME "MPSC" +#define MPSC_DEV_NAME "ttyMM" +#define MPSC_VERSION "1.00" static struct mpsc_port_info mpsc_ports[MPSC_NUM_CTLRS]; static struct mpsc_shared_regs mpsc_shared_regs; @@ -332,8 +327,7 @@ static void mpsc_release_port(struct uart_port *port); * ****************************************************************************** */ -static void -mpsc_brg_init(struct mpsc_port_info *pi, u32 clk_src) +static void mpsc_brg_init(struct mpsc_port_info *pi, u32 clk_src) { u32 v; @@ -349,11 +343,9 @@ mpsc_brg_init(struct mpsc_port_info *pi, u32 clk_src) writel(readl(pi->brg_base + BRG_BTR) & 0xffff0000, pi->brg_base + BRG_BTR); - return; } -static void -mpsc_brg_enable(struct mpsc_port_info *pi) +static void mpsc_brg_enable(struct mpsc_port_info *pi) { u32 v; @@ -363,11 +355,9 @@ mpsc_brg_enable(struct mpsc_port_info *pi) if (pi->mirror_regs) pi->BRG_BCR_m = v; writel(v, pi->brg_base + BRG_BCR); - return; } -static void -mpsc_brg_disable(struct mpsc_port_info *pi) +static void mpsc_brg_disable(struct mpsc_port_info *pi) { u32 v; @@ -377,21 +367,19 @@ mpsc_brg_disable(struct mpsc_port_info *pi) if (pi->mirror_regs) pi->BRG_BCR_m = v; writel(v, pi->brg_base + BRG_BCR); - return; } -static inline void -mpsc_set_baudrate(struct mpsc_port_info *pi, u32 baud) +/* + * To set the baud, we adjust the CDV field in the BRG_BCR reg. + * From manual: Baud = clk / ((CDV+1)*2) ==> CDV = (clk / (baud*2)) - 1. + * However, the input clock is divided by 16 in the MPSC b/c of how + * 'MPSC_MMCRH' was set up so we have to divide the 'clk' used in our + * calculation by 16 to account for that. So the real calculation + * that accounts for the way the mpsc is set up is: + * CDV = (clk / (baud*2*16)) - 1 ==> CDV = (clk / (baud << 5)) - 1. + */ +static void mpsc_set_baudrate(struct mpsc_port_info *pi, u32 baud) { - /* - * To set the baud, we adjust the CDV field in the BRG_BCR reg. - * From manual: Baud = clk / ((CDV+1)*2) ==> CDV = (clk / (baud*2)) - 1. - * However, the input clock is divided by 16 in the MPSC b/c of how - * 'MPSC_MMCRH' was set up so we have to divide the 'clk' used in our - * calculation by 16 to account for that. So the real calculation - * that accounts for the way the mpsc is set up is: - * CDV = (clk / (baud*2*16)) - 1 ==> CDV = (clk / (baud << 5)) - 1. - */ u32 cdv = (pi->port.uartclk / (baud << 5)) - 1; u32 v; @@ -403,8 +391,6 @@ mpsc_set_baudrate(struct mpsc_port_info *pi, u32 baud) pi->BRG_BCR_m = v; writel(v, pi->brg_base + BRG_BCR); mpsc_brg_enable(pi); - - return; } /* @@ -415,13 +401,12 @@ mpsc_set_baudrate(struct mpsc_port_info *pi, u32 baud) ****************************************************************************** */ -static void -mpsc_sdma_burstsize(struct mpsc_port_info *pi, u32 burst_size) +static void mpsc_sdma_burstsize(struct mpsc_port_info *pi, u32 burst_size) { u32 v; pr_debug("mpsc_sdma_burstsize[%d]: burst_size: %d\n", - pi->port.line, burst_size); + pi->port.line, burst_size); burst_size >>= 3; /* Divide by 8 b/c reg values are 8-byte chunks */ @@ -436,11 +421,9 @@ mpsc_sdma_burstsize(struct mpsc_port_info *pi, u32 burst_size) writel((readl(pi->sdma_base + SDMA_SDC) & (0x3 << 12)) | (v << 12), pi->sdma_base + SDMA_SDC); - return; } -static void -mpsc_sdma_init(struct mpsc_port_info *pi, u32 burst_size) +static void mpsc_sdma_init(struct mpsc_port_info *pi, u32 burst_size) { pr_debug("mpsc_sdma_init[%d]: burst_size: %d\n", pi->port.line, burst_size); @@ -448,11 +431,9 @@ mpsc_sdma_init(struct mpsc_port_info *pi, u32 burst_size) writel((readl(pi->sdma_base + SDMA_SDC) & 0x3ff) | 0x03f, pi->sdma_base + SDMA_SDC); mpsc_sdma_burstsize(pi, burst_size); - return; } -static inline u32 -mpsc_sdma_intr_mask(struct mpsc_port_info *pi, u32 mask) +static u32 mpsc_sdma_intr_mask(struct mpsc_port_info *pi, u32 mask) { u32 old, v; @@ -475,15 +456,14 @@ mpsc_sdma_intr_mask(struct mpsc_port_info *pi, u32 mask) return old & 0xf; } -static inline void -mpsc_sdma_intr_unmask(struct mpsc_port_info *pi, u32 mask) +static void mpsc_sdma_intr_unmask(struct mpsc_port_info *pi, u32 mask) { u32 v; pr_debug("mpsc_sdma_intr_unmask[%d]: mask: 0x%x\n", pi->port.line,mask); - v = (pi->mirror_regs) ? pi->shared_regs->SDMA_INTR_MASK_m : - readl(pi->shared_regs->sdma_intr_base + SDMA_INTR_MASK); + v = (pi->mirror_regs) ? pi->shared_regs->SDMA_INTR_MASK_m + : readl(pi->shared_regs->sdma_intr_base + SDMA_INTR_MASK); mask &= 0xf; if (pi->port.line) @@ -493,41 +473,35 @@ mpsc_sdma_intr_unmask(struct mpsc_port_info *pi, u32 mask) if (pi->mirror_regs) pi->shared_regs->SDMA_INTR_MASK_m = v; writel(v, pi->shared_regs->sdma_intr_base + SDMA_INTR_MASK); - return; } -static inline void -mpsc_sdma_intr_ack(struct mpsc_port_info *pi) +static void mpsc_sdma_intr_ack(struct mpsc_port_info *pi) { pr_debug("mpsc_sdma_intr_ack[%d]: Acknowledging IRQ\n", pi->port.line); if (pi->mirror_regs) pi->shared_regs->SDMA_INTR_CAUSE_m = 0; - writeb(0x00, pi->shared_regs->sdma_intr_base + SDMA_INTR_CAUSE + - pi->port.line); - return; + writeb(0x00, pi->shared_regs->sdma_intr_base + SDMA_INTR_CAUSE + + pi->port.line); } -static inline void -mpsc_sdma_set_rx_ring(struct mpsc_port_info *pi, struct mpsc_rx_desc *rxre_p) +static void mpsc_sdma_set_rx_ring(struct mpsc_port_info *pi, + struct mpsc_rx_desc *rxre_p) { pr_debug("mpsc_sdma_set_rx_ring[%d]: rxre_p: 0x%x\n", - pi->port.line, (u32) rxre_p); + pi->port.line, (u32)rxre_p); writel((u32)rxre_p, pi->sdma_base + SDMA_SCRDP); - return; } -static inline void -mpsc_sdma_set_tx_ring(struct mpsc_port_info *pi, struct mpsc_tx_desc *txre_p) +static void mpsc_sdma_set_tx_ring(struct mpsc_port_info *pi, + struct mpsc_tx_desc *txre_p) { writel((u32)txre_p, pi->sdma_base + SDMA_SFTDP); writel((u32)txre_p, pi->sdma_base + SDMA_SCTDP); - return; } -static inline void -mpsc_sdma_cmd(struct mpsc_port_info *pi, u32 val) +static void mpsc_sdma_cmd(struct mpsc_port_info *pi, u32 val) { u32 v; @@ -539,46 +513,40 @@ mpsc_sdma_cmd(struct mpsc_port_info *pi, u32 val) wmb(); writel(v, pi->sdma_base + SDMA_SDCM); wmb(); - return; } -static inline uint -mpsc_sdma_tx_active(struct mpsc_port_info *pi) +static uint mpsc_sdma_tx_active(struct mpsc_port_info *pi) { return readl(pi->sdma_base + SDMA_SDCM) & SDMA_SDCM_TXD; } -static inline void -mpsc_sdma_start_tx(struct mpsc_port_info *pi) +static void mpsc_sdma_start_tx(struct mpsc_port_info *pi) { struct mpsc_tx_desc *txre, *txre_p; /* If tx isn't running & there's a desc ready to go, start it */ if (!mpsc_sdma_tx_active(pi)) { - txre = (struct mpsc_tx_desc *)(pi->txr + - (pi->txr_tail * MPSC_TXRE_SIZE)); - dma_cache_sync(pi->port.dev, (void *) txre, MPSC_TXRE_SIZE, DMA_FROM_DEVICE); + txre = (struct mpsc_tx_desc *)(pi->txr + + (pi->txr_tail * MPSC_TXRE_SIZE)); + dma_cache_sync(pi->port.dev, (void *)txre, MPSC_TXRE_SIZE, + DMA_FROM_DEVICE); #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ invalidate_dcache_range((ulong)txre, - (ulong)txre + MPSC_TXRE_SIZE); + (ulong)txre + MPSC_TXRE_SIZE); #endif if (be32_to_cpu(txre->cmdstat) & SDMA_DESC_CMDSTAT_O) { - txre_p = (struct mpsc_tx_desc *)(pi->txr_p + - (pi->txr_tail * - MPSC_TXRE_SIZE)); + txre_p = (struct mpsc_tx_desc *) + (pi->txr_p + (pi->txr_tail * MPSC_TXRE_SIZE)); mpsc_sdma_set_tx_ring(pi, txre_p); mpsc_sdma_cmd(pi, SDMA_SDCM_STD | SDMA_SDCM_TXD); } } - - return; } -static inline void -mpsc_sdma_stop(struct mpsc_port_info *pi) +static void mpsc_sdma_stop(struct mpsc_port_info *pi) { pr_debug("mpsc_sdma_stop[%d]: Stopping SDMA\n", pi->port.line); @@ -593,8 +561,6 @@ mpsc_sdma_stop(struct mpsc_port_info *pi) /* Disable interrupts */ mpsc_sdma_intr_mask(pi, 0xf); mpsc_sdma_intr_ack(pi); - - return; } /* @@ -605,8 +571,7 @@ mpsc_sdma_stop(struct mpsc_port_info *pi) ****************************************************************************** */ -static void -mpsc_hw_init(struct mpsc_port_info *pi) +static void mpsc_hw_init(struct mpsc_port_info *pi) { u32 v; @@ -628,8 +593,7 @@ mpsc_hw_init(struct mpsc_port_info *pi) v = (v & ~0xf0f) | 0x100; pi->shared_regs->MPSC_TCRR_m = v; writel(v, pi->shared_regs->mpsc_routing_base + MPSC_TCRR); - } - else { + } else { v = readl(pi->shared_regs->mpsc_routing_base + MPSC_MRR); v &= ~0x1c7; writel(v, pi->shared_regs->mpsc_routing_base + MPSC_MRR); @@ -646,7 +610,7 @@ mpsc_hw_init(struct mpsc_port_info *pi) /* Put MPSC in UART mode & enabel Tx/Rx egines */ writel(0x000004c4, pi->mpsc_base + MPSC_MMCRL); - /* No preamble, 16x divider, low-latency, */ + /* No preamble, 16x divider, low-latency, */ writel(0x04400400, pi->mpsc_base + MPSC_MMCRH); if (pi->mirror_regs) { @@ -663,12 +627,9 @@ mpsc_hw_init(struct mpsc_port_info *pi) writel(0, pi->mpsc_base + MPSC_CHR_8); writel(0, pi->mpsc_base + MPSC_CHR_9); writel(0, pi->mpsc_base + MPSC_CHR_10); - - return; } -static inline void -mpsc_enter_hunt(struct mpsc_port_info *pi) +static void mpsc_enter_hunt(struct mpsc_port_info *pi) { pr_debug("mpsc_enter_hunt[%d]: Hunting...\n", pi->port.line); @@ -677,20 +638,16 @@ mpsc_enter_hunt(struct mpsc_port_info *pi) pi->mpsc_base + MPSC_CHR_2); /* Erratum prevents reading CHR_2 so just delay for a while */ udelay(100); - } - else { + } else { writel(readl(pi->mpsc_base + MPSC_CHR_2) | MPSC_CHR_2_EH, - pi->mpsc_base + MPSC_CHR_2); + pi->mpsc_base + MPSC_CHR_2); while (readl(pi->mpsc_base + MPSC_CHR_2) & MPSC_CHR_2_EH) udelay(10); } - - return; } -static inline void -mpsc_freeze(struct mpsc_port_info *pi) +static void mpsc_freeze(struct mpsc_port_info *pi) { u32 v; @@ -703,11 +660,9 @@ mpsc_freeze(struct mpsc_port_info *pi) if (pi->mirror_regs) pi->MPSC_MPCR_m = v; writel(v, pi->mpsc_base + MPSC_MPCR); - return; } -static inline void -mpsc_unfreeze(struct mpsc_port_info *pi) +static void mpsc_unfreeze(struct mpsc_port_info *pi) { u32 v; @@ -720,11 +675,9 @@ mpsc_unfreeze(struct mpsc_port_info *pi) writel(v, pi->mpsc_base + MPSC_MPCR); pr_debug("mpsc_unfreeze[%d]: Unfrozen\n", pi->port.line); - return; } -static inline void -mpsc_set_char_length(struct mpsc_port_info *pi, u32 len) +static void mpsc_set_char_length(struct mpsc_port_info *pi, u32 len) { u32 v; @@ -737,11 +690,9 @@ mpsc_set_char_length(struct mpsc_port_info *pi, u32 len) if (pi->mirror_regs) pi->MPSC_MPCR_m = v; writel(v, pi->mpsc_base + MPSC_MPCR); - return; } -static inline void -mpsc_set_stop_bit_length(struct mpsc_port_info *pi, u32 len) +static void mpsc_set_stop_bit_length(struct mpsc_port_info *pi, u32 len) { u32 v; @@ -756,11 +707,9 @@ mpsc_set_stop_bit_length(struct mpsc_port_info *pi, u32 len) if (pi->mirror_regs) pi->MPSC_MPCR_m = v; writel(v, pi->mpsc_base + MPSC_MPCR); - return; } -static inline void -mpsc_set_parity(struct mpsc_port_info *pi, u32 p) +static void mpsc_set_parity(struct mpsc_port_info *pi, u32 p) { u32 v; @@ -775,7 +724,6 @@ mpsc_set_parity(struct mpsc_port_info *pi, u32 p) if (pi->mirror_regs) pi->MPSC_CHR_2_m = v; writel(v, pi->mpsc_base + MPSC_CHR_2); - return; } /* @@ -786,8 +734,7 @@ mpsc_set_parity(struct mpsc_port_info *pi, u32 p) ****************************************************************************** */ -static void -mpsc_init_hw(struct mpsc_port_info *pi) +static void mpsc_init_hw(struct mpsc_port_info *pi) { pr_debug("mpsc_init_hw[%d]: Initializing\n", pi->port.line); @@ -796,12 +743,9 @@ mpsc_init_hw(struct mpsc_port_info *pi) mpsc_sdma_init(pi, dma_get_cache_alignment()); /* burst a cacheline */ mpsc_sdma_stop(pi); mpsc_hw_init(pi); - - return; } -static int -mpsc_alloc_ring_mem(struct mpsc_port_info *pi) +static int mpsc_alloc_ring_mem(struct mpsc_port_info *pi) { int rc = 0; @@ -812,11 +756,10 @@ mpsc_alloc_ring_mem(struct mpsc_port_info *pi) if (!dma_supported(pi->port.dev, 0xffffffff)) { printk(KERN_ERR "MPSC: Inadequate DMA support\n"); rc = -ENXIO; - } - else if ((pi->dma_region = dma_alloc_noncoherent(pi->port.dev, - MPSC_DMA_ALLOC_SIZE, &pi->dma_region_p, GFP_KERNEL)) - == NULL) { - + } else if ((pi->dma_region = dma_alloc_noncoherent(pi->port.dev, + MPSC_DMA_ALLOC_SIZE, + &pi->dma_region_p, GFP_KERNEL)) + == NULL) { printk(KERN_ERR "MPSC: Can't alloc Desc region\n"); rc = -ENOMEM; } @@ -825,23 +768,19 @@ mpsc_alloc_ring_mem(struct mpsc_port_info *pi) return rc; } -static void -mpsc_free_ring_mem(struct mpsc_port_info *pi) +static void mpsc_free_ring_mem(struct mpsc_port_info *pi) { pr_debug("mpsc_free_ring_mem[%d]: Freeing ring mem\n", pi->port.line); if (pi->dma_region) { dma_free_noncoherent(pi->port.dev, MPSC_DMA_ALLOC_SIZE, - pi->dma_region, pi->dma_region_p); + pi->dma_region, pi->dma_region_p); pi->dma_region = NULL; - pi->dma_region_p = (dma_addr_t) NULL; + pi->dma_region_p = (dma_addr_t)NULL; } - - return; } -static void -mpsc_init_rings(struct mpsc_port_info *pi) +static void mpsc_init_rings(struct mpsc_port_info *pi) { struct mpsc_rx_desc *rxre; struct mpsc_tx_desc *txre; @@ -859,8 +798,8 @@ mpsc_init_rings(struct mpsc_port_info *pi) * Descriptors & buffers are multiples of cacheline size and must be * cacheline aligned. */ - dp = ALIGN((u32) pi->dma_region, dma_get_cache_alignment()); - dp_p = ALIGN((u32) pi->dma_region_p, dma_get_cache_alignment()); + dp = ALIGN((u32)pi->dma_region, dma_get_cache_alignment()); + dp_p = ALIGN((u32)pi->dma_region_p, dma_get_cache_alignment()); /* * Partition dma region into rx ring descriptor, rx buffers, @@ -871,8 +810,8 @@ mpsc_init_rings(struct mpsc_port_info *pi) dp += MPSC_RXR_SIZE; dp_p += MPSC_RXR_SIZE; - pi->rxb = (u8 *) dp; - pi->rxb_p = (u8 *) dp_p; + pi->rxb = (u8 *)dp; + pi->rxb_p = (u8 *)dp_p; dp += MPSC_RXB_SIZE; dp_p += MPSC_RXB_SIZE; @@ -883,8 +822,8 @@ mpsc_init_rings(struct mpsc_port_info *pi) dp += MPSC_TXR_SIZE; dp_p += MPSC_TXR_SIZE; - pi->txb = (u8 *) dp; - pi->txb_p = (u8 *) dp_p; + pi->txb = (u8 *)dp; + pi->txb_p = (u8 *)dp_p; pi->txr_head = 0; pi->txr_tail = 0; @@ -900,10 +839,9 @@ mpsc_init_rings(struct mpsc_port_info *pi) rxre->bufsize = cpu_to_be16(MPSC_RXBE_SIZE); rxre->bytecnt = cpu_to_be16(0); - rxre->cmdstat = cpu_to_be32(SDMA_DESC_CMDSTAT_O | - SDMA_DESC_CMDSTAT_EI | - SDMA_DESC_CMDSTAT_F | - SDMA_DESC_CMDSTAT_L); + rxre->cmdstat = cpu_to_be32(SDMA_DESC_CMDSTAT_O + | SDMA_DESC_CMDSTAT_EI | SDMA_DESC_CMDSTAT_F + | SDMA_DESC_CMDSTAT_L); rxre->link = cpu_to_be32(dp_p + MPSC_RXRE_SIZE); rxre->buf_ptr = cpu_to_be32(bp_p); @@ -933,19 +871,19 @@ mpsc_init_rings(struct mpsc_port_info *pi) } txre->link = cpu_to_be32(pi->txr_p); /* Wrap last back to first */ - dma_cache_sync(pi->port.dev, (void *) pi->dma_region, MPSC_DMA_ALLOC_SIZE, - DMA_BIDIRECTIONAL); + dma_cache_sync(pi->port.dev, (void *)pi->dma_region, + MPSC_DMA_ALLOC_SIZE, DMA_BIDIRECTIONAL); #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ flush_dcache_range((ulong)pi->dma_region, - (ulong)pi->dma_region + MPSC_DMA_ALLOC_SIZE); + (ulong)pi->dma_region + + MPSC_DMA_ALLOC_SIZE); #endif return; } -static void -mpsc_uninit_rings(struct mpsc_port_info *pi) +static void mpsc_uninit_rings(struct mpsc_port_info *pi) { pr_debug("mpsc_uninit_rings[%d]: Uninitializing rings\n",pi->port.line); @@ -963,12 +901,9 @@ mpsc_uninit_rings(struct mpsc_port_info *pi) pi->txb_p = NULL; pi->txr_head = 0; pi->txr_tail = 0; - - return; } -static int -mpsc_make_ready(struct mpsc_port_info *pi) +static int mpsc_make_ready(struct mpsc_port_info *pi) { int rc; @@ -993,8 +928,7 @@ mpsc_make_ready(struct mpsc_port_info *pi) ****************************************************************************** */ -static inline int -mpsc_rx_intr(struct mpsc_port_info *pi) +static int mpsc_rx_intr(struct mpsc_port_info *pi) { struct mpsc_rx_desc *rxre; struct tty_struct *tty = pi->port.info->tty; @@ -1007,21 +941,24 @@ mpsc_rx_intr(struct mpsc_port_info *pi) rxre = (struct mpsc_rx_desc *)(pi->rxr + (pi->rxr_posn*MPSC_RXRE_SIZE)); - dma_cache_sync(pi->port.dev, (void *)rxre, MPSC_RXRE_SIZE, DMA_FROM_DEVICE); + dma_cache_sync(pi->port.dev, (void *)rxre, MPSC_RXRE_SIZE, + DMA_FROM_DEVICE); #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ invalidate_dcache_range((ulong)rxre, - (ulong)rxre + MPSC_RXRE_SIZE); + (ulong)rxre + MPSC_RXRE_SIZE); #endif /* * Loop through Rx descriptors handling ones that have been completed. */ - while (!((cmdstat = be32_to_cpu(rxre->cmdstat)) & SDMA_DESC_CMDSTAT_O)){ + while (!((cmdstat = be32_to_cpu(rxre->cmdstat)) + & SDMA_DESC_CMDSTAT_O)) { bytes_in = be16_to_cpu(rxre->bytecnt); /* Following use of tty struct directly is deprecated */ - if (unlikely(tty_buffer_request_room(tty, bytes_in) < bytes_in)) { + if (unlikely(tty_buffer_request_room(tty, bytes_in) + < bytes_in)) { if (tty->low_latency) tty_flip_buffer_push(tty); /* @@ -1031,11 +968,12 @@ mpsc_rx_intr(struct mpsc_port_info *pi) } bp = pi->rxb + (pi->rxr_posn * MPSC_RXBE_SIZE); - dma_cache_sync(pi->port.dev, (void *) bp, MPSC_RXBE_SIZE, DMA_FROM_DEVICE); + dma_cache_sync(pi->port.dev, (void *)bp, MPSC_RXBE_SIZE, + DMA_FROM_DEVICE); #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ invalidate_dcache_range((ulong)bp, - (ulong)bp + MPSC_RXBE_SIZE); + (ulong)bp + MPSC_RXBE_SIZE); #endif /* @@ -1046,8 +984,9 @@ mpsc_rx_intr(struct mpsc_port_info *pi) * we'll assume there is no data in the buffer. * If there is...it gets lost. */ - if (unlikely(cmdstat & (SDMA_DESC_CMDSTAT_BR | - SDMA_DESC_CMDSTAT_FR | SDMA_DESC_CMDSTAT_OR))) { + if (unlikely(cmdstat & (SDMA_DESC_CMDSTAT_BR + | SDMA_DESC_CMDSTAT_FR + | SDMA_DESC_CMDSTAT_OR))) { pi->port.icount.rx++; @@ -1056,11 +995,11 @@ mpsc_rx_intr(struct mpsc_port_info *pi) if (uart_handle_break(&pi->port)) goto next_frame; - } - else if (cmdstat & SDMA_DESC_CMDSTAT_FR)/* Framing */ + } else if (cmdstat & SDMA_DESC_CMDSTAT_FR) { pi->port.icount.frame++; - else if (cmdstat & SDMA_DESC_CMDSTAT_OR) /* Overrun */ + } else if (cmdstat & SDMA_DESC_CMDSTAT_OR) { pi->port.icount.overrun++; + } cmdstat &= pi->port.read_status_mask; @@ -1080,12 +1019,12 @@ mpsc_rx_intr(struct mpsc_port_info *pi) goto next_frame; } - if ((unlikely(cmdstat & (SDMA_DESC_CMDSTAT_BR | - SDMA_DESC_CMDSTAT_FR | SDMA_DESC_CMDSTAT_OR))) && - !(cmdstat & pi->port.ignore_status_mask)) - + if ((unlikely(cmdstat & (SDMA_DESC_CMDSTAT_BR + | SDMA_DESC_CMDSTAT_FR + | SDMA_DESC_CMDSTAT_OR))) + && !(cmdstat & pi->port.ignore_status_mask)) { tty_insert_flip_char(tty, *bp, flag); - else { + } else { for (i=0; i<bytes_in; i++) tty_insert_flip_char(tty, *bp++, TTY_NORMAL); @@ -1095,29 +1034,29 @@ mpsc_rx_intr(struct mpsc_port_info *pi) next_frame: rxre->bytecnt = cpu_to_be16(0); wmb(); - rxre->cmdstat = cpu_to_be32(SDMA_DESC_CMDSTAT_O | - SDMA_DESC_CMDSTAT_EI | - SDMA_DESC_CMDSTAT_F | - SDMA_DESC_CMDSTAT_L); + rxre->cmdstat = cpu_to_be32(SDMA_DESC_CMDSTAT_O + | SDMA_DESC_CMDSTAT_EI | SDMA_DESC_CMDSTAT_F + | SDMA_DESC_CMDSTAT_L); wmb(); - dma_cache_sync(pi->port.dev, (void *)rxre, MPSC_RXRE_SIZE, DMA_BIDIRECTIONAL); + dma_cache_sync(pi->port.dev, (void *)rxre, MPSC_RXRE_SIZE, + DMA_BIDIRECTIONAL); #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ flush_dcache_range((ulong)rxre, - (ulong)rxre + MPSC_RXRE_SIZE); + (ulong)rxre + MPSC_RXRE_SIZE); #endif /* Advance to next descriptor */ pi->rxr_posn = (pi->rxr_posn + 1) & (MPSC_RXR_ENTRIES - 1); - rxre = (struct mpsc_rx_desc *)(pi->rxr + - (pi->rxr_posn * MPSC_RXRE_SIZE)); - dma_cache_sync(pi->port.dev, (void *)rxre, MPSC_RXRE_SIZE, DMA_FROM_DEVICE); + rxre = (struct mpsc_rx_desc *) + (pi->rxr + (pi->rxr_posn * MPSC_RXRE_SIZE)); + dma_cache_sync(pi->port.dev, (void *)rxre, MPSC_RXRE_SIZE, + DMA_FROM_DEVICE); #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ invalidate_dcache_range((ulong)rxre, - (ulong)rxre + MPSC_RXRE_SIZE); + (ulong)rxre + MPSC_RXRE_SIZE); #endif - rc = 1; } @@ -1129,42 +1068,38 @@ next_frame: return rc; } -static inline void -mpsc_setup_tx_desc(struct mpsc_port_info *pi, u32 count, u32 intr) +static void mpsc_setup_tx_desc(struct mpsc_port_info *pi, u32 count, u32 intr) { struct mpsc_tx_desc *txre; - txre = (struct mpsc_tx_desc *)(pi->txr + - (pi->txr_head * MPSC_TXRE_SIZE)); + txre = (struct mpsc_tx_desc *)(pi->txr + + (pi->txr_head * MPSC_TXRE_SIZE)); txre->bytecnt = cpu_to_be16(count); txre->shadow = txre->bytecnt; wmb(); /* ensure cmdstat is last field updated */ - txre->cmdstat = cpu_to_be32(SDMA_DESC_CMDSTAT_O | SDMA_DESC_CMDSTAT_F | - SDMA_DESC_CMDSTAT_L | ((intr) ? - SDMA_DESC_CMDSTAT_EI - : 0)); + txre->cmdstat = cpu_to_be32(SDMA_DESC_CMDSTAT_O | SDMA_DESC_CMDSTAT_F + | SDMA_DESC_CMDSTAT_L + | ((intr) ? SDMA_DESC_CMDSTAT_EI : 0)); wmb(); - dma_cache_sync(pi->port.dev, (void *) txre, MPSC_TXRE_SIZE, DMA_BIDIRECTIONAL); + dma_cache_sync(pi->port.dev, (void *)txre, MPSC_TXRE_SIZE, + DMA_BIDIRECTIONAL); #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ flush_dcache_range((ulong)txre, - (ulong)txre + MPSC_TXRE_SIZE); + (ulong)txre + MPSC_TXRE_SIZE); #endif - - return; } -static inline void -mpsc_copy_tx_data(struct mpsc_port_info *pi) +static void mpsc_copy_tx_data(struct mpsc_port_info *pi) { struct circ_buf *xmit = &pi->port.info->xmit; u8 *bp; u32 i; /* Make sure the desc ring isn't full */ - while (CIRC_CNT(pi->txr_head, pi->txr_tail, MPSC_TXR_ENTRIES) < - (MPSC_TXR_ENTRIES - 1)) { + while (CIRC_CNT(pi->txr_head, pi->txr_tail, MPSC_TXR_ENTRIES) + < (MPSC_TXR_ENTRIES - 1)) { if (pi->port.x_char) { /* * Ideally, we should use the TCS field in @@ -1178,11 +1113,11 @@ mpsc_copy_tx_data(struct mpsc_port_info *pi) *bp = pi->port.x_char; pi->port.x_char = 0; i = 1; - } - else if (!uart_circ_empty(xmit) && !uart_tx_stopped(&pi->port)){ - i = min((u32) MPSC_TXBE_SIZE, - (u32) uart_circ_chars_pending(xmit)); - i = min(i, (u32) CIRC_CNT_TO_END(xmit->head, xmit->tail, + } else if (!uart_circ_empty(xmit) + && !uart_tx_stopped(&pi->port)) { + i = min((u32)MPSC_TXBE_SIZE, + (u32)uart_circ_chars_pending(xmit)); + i = min(i, (u32)CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE)); bp = pi->txb + (pi->txr_head * MPSC_TXBE_SIZE); memcpy(bp, &xmit->buf[xmit->tail], i); @@ -1190,27 +1125,25 @@ mpsc_copy_tx_data(struct mpsc_port_info *pi) if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) uart_write_wakeup(&pi->port); - } - else /* All tx data copied into ring bufs */ + } else { /* All tx data copied into ring bufs */ return; + } - dma_cache_sync(pi->port.dev, (void *) bp, MPSC_TXBE_SIZE, DMA_BIDIRECTIONAL); + dma_cache_sync(pi->port.dev, (void *)bp, MPSC_TXBE_SIZE, + DMA_BIDIRECTIONAL); #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ flush_dcache_range((ulong)bp, - (ulong)bp + MPSC_TXBE_SIZE); + (ulong)bp + MPSC_TXBE_SIZE); #endif mpsc_setup_tx_desc(pi, i, 1); /* Advance to next descriptor */ pi->txr_head = (pi->txr_head + 1) & (MPSC_TXR_ENTRIES - 1); } - - return; } -static inline int -mpsc_tx_intr(struct mpsc_port_info *pi) +static int mpsc_tx_intr(struct mpsc_port_info *pi) { struct mpsc_tx_desc *txre; int rc = 0; @@ -1219,14 +1152,15 @@ mpsc_tx_intr(struct mpsc_port_info *pi) spin_lock_irqsave(&pi->tx_lock, iflags); if (!mpsc_sdma_tx_active(pi)) { - txre = (struct mpsc_tx_desc *)(pi->txr + - (pi->txr_tail * MPSC_TXRE_SIZE)); + txre = (struct mpsc_tx_desc *)(pi->txr + + (pi->txr_tail * MPSC_TXRE_SIZE)); - dma_cache_sync(pi->port.dev, (void *) txre, MPSC_TXRE_SIZE, DMA_FROM_DEVICE); + dma_cache_sync(pi->port.dev, (void *)txre, MPSC_TXRE_SIZE, + DMA_FROM_DEVICE); #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ invalidate_dcache_range((ulong)txre, - (ulong)txre + MPSC_TXRE_SIZE); + (ulong)txre + MPSC_TXRE_SIZE); #endif while (!(be32_to_cpu(txre->cmdstat) & SDMA_DESC_CMDSTAT_O)) { @@ -1238,14 +1172,14 @@ mpsc_tx_intr(struct mpsc_port_info *pi) if (pi->txr_head == pi->txr_tail) break; - txre = (struct mpsc_tx_desc *)(pi->txr + - (pi->txr_tail * MPSC_TXRE_SIZE)); - dma_cache_sync(pi->port.dev, (void *) txre, MPSC_TXRE_SIZE, - DMA_FROM_DEVICE); + txre = (struct mpsc_tx_desc *)(pi->txr + + (pi->txr_tail * MPSC_TXRE_SIZE)); + dma_cache_sync(pi->port.dev, (void *)txre, + MPSC_TXRE_SIZE, DMA_FROM_DEVICE); #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ invalidate_dcache_range((ulong)txre, - (ulong)txre + MPSC_TXRE_SIZE); + (ulong)txre + MPSC_TXRE_SIZE); #endif } @@ -1262,8 +1196,7 @@ mpsc_tx_intr(struct mpsc_port_info *pi) * the interrupt, then handle any completed Rx/Tx descriptors. When done * handling those descriptors, we restart the Rx/Tx engines if they're stopped. */ -static irqreturn_t -mpsc_sdma_intr(int irq, void *dev_id) +static irqreturn_t mpsc_sdma_intr(int irq, void *dev_id) { struct mpsc_port_info *pi = dev_id; ulong iflags; @@ -1290,8 +1223,7 @@ mpsc_sdma_intr(int irq, void *dev_id) * ****************************************************************************** */ -static uint -mpsc_tx_empty(struct uart_port *port) +static uint mpsc_tx_empty(struct uart_port *port) { struct mpsc_port_info *pi = (struct mpsc_port_info *)port; ulong iflags; @@ -1304,21 +1236,18 @@ mpsc_tx_empty(struct uart_port *port) return rc; } -static void -mpsc_set_mctrl(struct uart_port *port, uint mctrl) +static void mpsc_set_mctrl(struct uart_port *port, uint mctrl) { /* Have no way to set modem control lines AFAICT */ - return; } -static uint -mpsc_get_mctrl(struct uart_port *port) +static uint mpsc_get_mctrl(struct uart_port *port) { struct mpsc_port_info *pi = (struct mpsc_port_info *)port; u32 mflags, status; - status = (pi->mirror_regs) ? pi->MPSC_CHR_10_m : - readl(pi->mpsc_base + MPSC_CHR_10); + status = (pi->mirror_regs) ? pi->MPSC_CHR_10_m + : readl(pi->mpsc_base + MPSC_CHR_10); mflags = 0; if (status & 0x1) @@ -1329,19 +1258,16 @@ mpsc_get_mctrl(struct uart_port *port) return mflags | TIOCM_DSR; /* No way to tell if DSR asserted */ } -static void -mpsc_stop_tx(struct uart_port *port) +static void mpsc_stop_tx(struct uart_port *port) { struct mpsc_port_info *pi = (struct mpsc_port_info *)port; pr_debug("mpsc_stop_tx[%d]\n", port->line); mpsc_freeze(pi); - return; } -static void -mpsc_start_tx(struct uart_port *port) +static void mpsc_start_tx(struct uart_port *port) { struct mpsc_port_info *pi = (struct mpsc_port_info *)port; unsigned long iflags; @@ -1355,42 +1281,45 @@ mpsc_start_tx(struct uart_port *port) spin_unlock_irqrestore(&pi->tx_lock, iflags); pr_debug("mpsc_start_tx[%d]\n", port->line); - return; } -static void -mpsc_start_rx(struct mpsc_port_info *pi) +static void mpsc_start_rx(struct mpsc_port_info *pi) { pr_debug("mpsc_start_rx[%d]: Starting...\n", pi->port.line); - /* Issue a Receive Abort to clear any receive errors */ - writel(MPSC_CHR_2_RA, pi->mpsc_base + MPSC_CHR_2); if (pi->rcv_data) { mpsc_enter_hunt(pi); mpsc_sdma_cmd(pi, SDMA_SDCM_ERD); } - return; } -static void -mpsc_stop_rx(struct uart_port *port) +static void mpsc_stop_rx(struct uart_port *port) { struct mpsc_port_info *pi = (struct mpsc_port_info *)port; pr_debug("mpsc_stop_rx[%d]: Stopping...\n", port->line); + if (pi->mirror_regs) { + writel(pi->MPSC_CHR_2_m | MPSC_CHR_2_RA, + pi->mpsc_base + MPSC_CHR_2); + /* Erratum prevents reading CHR_2 so just delay for a while */ + udelay(100); + } else { + writel(readl(pi->mpsc_base + MPSC_CHR_2) | MPSC_CHR_2_RA, + pi->mpsc_base + MPSC_CHR_2); + + while (readl(pi->mpsc_base + MPSC_CHR_2) & MPSC_CHR_2_RA) + udelay(10); + } + mpsc_sdma_cmd(pi, SDMA_SDCM_AR); - return; } -static void -mpsc_enable_ms(struct uart_port *port) +static void mpsc_enable_ms(struct uart_port *port) { - return; /* Not supported */ } -static void -mpsc_break_ctl(struct uart_port *port, int ctl) +static void mpsc_break_ctl(struct uart_port *port, int ctl) { struct mpsc_port_info *pi = (struct mpsc_port_info *)port; ulong flags; @@ -1403,12 +1332,9 @@ mpsc_break_ctl(struct uart_port *port, int ctl) pi->MPSC_CHR_1_m = v; writel(v, pi->mpsc_base + MPSC_CHR_1); spin_unlock_irqrestore(&pi->port.lock, flags); - - return; } -static int -mpsc_startup(struct uart_port *port) +static int mpsc_startup(struct uart_port *port) { struct mpsc_port_info *pi = (struct mpsc_port_info *)port; u32 flag = 0; @@ -1426,20 +1352,19 @@ mpsc_startup(struct uart_port *port) flag = IRQF_SHARED; if (request_irq(pi->port.irq, mpsc_sdma_intr, flag, - "mpsc-sdma", pi)) + "mpsc-sdma", pi)) printk(KERN_ERR "MPSC: Can't get SDMA IRQ %d\n", - pi->port.irq); + pi->port.irq); mpsc_sdma_intr_unmask(pi, 0xf); - mpsc_sdma_set_rx_ring(pi, (struct mpsc_rx_desc *)(pi->rxr_p + - (pi->rxr_posn * MPSC_RXRE_SIZE))); + mpsc_sdma_set_rx_ring(pi, (struct mpsc_rx_desc *)(pi->rxr_p + + (pi->rxr_posn * MPSC_RXRE_SIZE))); } return rc; } -static void -mpsc_shutdown(struct uart_port *port) +static void mpsc_shutdown(struct uart_port *port) { struct mpsc_port_info *pi = (struct mpsc_port_info *)port; @@ -1447,11 +1372,9 @@ mpsc_shutdown(struct uart_port *port) mpsc_sdma_stop(pi); free_irq(pi->port.irq, pi); - return; } -static void -mpsc_set_termios(struct uart_port *port, struct ktermios *termios, +static void mpsc_set_termios(struct uart_port *port, struct ktermios *termios, struct ktermios *old) { struct mpsc_port_info *pi = (struct mpsc_port_info *)port; @@ -1508,12 +1431,11 @@ mpsc_set_termios(struct uart_port *port, struct ktermios *termios, mpsc_set_baudrate(pi, baud); /* Characters/events to read */ - pi->rcv_data = 1; pi->port.read_status_mask = SDMA_DESC_CMDSTAT_OR; if (termios->c_iflag & INPCK) - pi->port.read_status_mask |= SDMA_DESC_CMDSTAT_PE | - SDMA_DESC_CMDSTAT_FR; + pi->port.read_status_mask |= SDMA_DESC_CMDSTAT_PE + | SDMA_DESC_CMDSTAT_FR; if (termios->c_iflag & (BRKINT | PARMRK)) pi->port.read_status_mask |= SDMA_DESC_CMDSTAT_BR; @@ -1522,8 +1444,8 @@ mpsc_set_termios(struct uart_port *port, struct ktermios *termios, pi->port.ignore_status_mask = 0; if (termios->c_iflag & IGNPAR) - pi->port.ignore_status_mask |= SDMA_DESC_CMDSTAT_PE | - SDMA_DESC_CMDSTAT_FR; + pi->port.ignore_status_mask |= SDMA_DESC_CMDSTAT_PE + | SDMA_DESC_CMDSTAT_FR; if (termios->c_iflag & IGNBRK) { pi->port.ignore_status_mask |= SDMA_DESC_CMDSTAT_BR; @@ -1532,32 +1454,32 @@ mpsc_set_termios(struct uart_port *port, struct ktermios *termios, pi->port.ignore_status_mask |= SDMA_DESC_CMDSTAT_OR; } - /* Ignore all chars if CREAD not set */ - if (!(termios->c_cflag & CREAD)) + if ((termios->c_cflag & CREAD)) { + if (!pi->rcv_data) { + pi->rcv_data = 1; + mpsc_start_rx(pi); + } + } else if (pi->rcv_data) { + mpsc_stop_rx(port); pi->rcv_data = 0; - else - mpsc_start_rx(pi); + } spin_unlock_irqrestore(&pi->port.lock, flags); - return; } -static const char * -mpsc_type(struct uart_port *port) +static const char *mpsc_type(struct uart_port *port) { pr_debug("mpsc_type[%d]: port type: %s\n", port->line,MPSC_DRIVER_NAME); return MPSC_DRIVER_NAME; } -static int -mpsc_request_port(struct uart_port *port) +static int mpsc_request_port(struct uart_port *port) { /* Should make chip/platform specific call */ return 0; } -static void -mpsc_release_port(struct uart_port *port) +static void mpsc_release_port(struct uart_port *port) { struct mpsc_port_info *pi = (struct mpsc_port_info *)port; @@ -1566,18 +1488,13 @@ mpsc_release_port(struct uart_port *port) mpsc_free_ring_mem(pi); pi->ready = 0; } - - return; } -static void -mpsc_config_port(struct uart_port *port, int flags) +static void mpsc_config_port(struct uart_port *port, int flags) { - return; } -static int -mpsc_verify_port(struct uart_port *port, struct serial_struct *ser) +static int mpsc_verify_port(struct uart_port *port, struct serial_struct *ser) { struct mpsc_port_info *pi = (struct mpsc_port_info *)port; int rc = 0; @@ -1603,22 +1520,22 @@ mpsc_verify_port(struct uart_port *port, struct serial_struct *ser) } static struct uart_ops mpsc_pops = { - .tx_empty = mpsc_tx_empty, - .set_mctrl = mpsc_set_mctrl, - .get_mctrl = mpsc_get_mctrl, - .stop_tx = mpsc_stop_tx, - .start_tx = mpsc_start_tx, - .stop_rx = mpsc_stop_rx, - .enable_ms = mpsc_enable_ms, - .break_ctl = mpsc_break_ctl, - .startup = mpsc_startup, - .shutdown = mpsc_shutdown, - .set_termios = mpsc_set_termios, - .type = mpsc_type, - .release_port = mpsc_release_port, - .request_port = mpsc_request_port, - .config_port = mpsc_config_port, - .verify_port = mpsc_verify_port, + .tx_empty = mpsc_tx_empty, + .set_mctrl = mpsc_set_mctrl, + .get_mctrl = mpsc_get_mctrl, + .stop_tx = mpsc_stop_tx, + .start_tx = mpsc_start_tx, + .stop_rx = mpsc_stop_rx, + .enable_ms = mpsc_enable_ms, + .break_ctl = mpsc_break_ctl, + .startup = mpsc_startup, + .shutdown = mpsc_shutdown, + .set_termios = mpsc_set_termios, + .type = mpsc_type, + .release_port = mpsc_release_port, + .request_port = mpsc_request_port, + .config_port = mpsc_config_port, + .verify_port = mpsc_verify_port, }; /* @@ -1630,8 +1547,7 @@ static struct uart_ops mpsc_pops = { */ #ifdef CONFIG_SERIAL_MPSC_CONSOLE -static void -mpsc_console_write(struct console *co, const char *s, uint count) +static void mpsc_console_write(struct console *co, const char *s, uint count) { struct mpsc_port_info *pi = &mpsc_ports[co->index]; u8 *bp, *dp, add_cr = 0; @@ -1660,8 +1576,7 @@ mpsc_console_write(struct console *co, const char *s, uint count) if (add_cr) { *(dp++) = '\r'; add_cr = 0; - } - else { + } else { *(dp++) = *s; if (*(s++) == '\n') { /* add '\r' after '\n' */ @@ -1673,11 +1588,12 @@ mpsc_console_write(struct console *co, const char *s, uint count) count--; } - dma_cache_sync(pi->port.dev, (void *) bp, MPSC_TXBE_SIZE, DMA_BIDIRECTIONAL); + dma_cache_sync(pi->port.dev, (void *)bp, MPSC_TXBE_SIZE, + DMA_BIDIRECTIONAL); #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ flush_dcache_range((ulong)bp, - (ulong)bp + MPSC_TXBE_SIZE); + (ulong)bp + MPSC_TXBE_SIZE); #endif mpsc_setup_tx_desc(pi, i, 0); pi->txr_head = (pi->txr_head + 1) & (MPSC_TXR_ENTRIES - 1); @@ -1690,11 +1606,9 @@ mpsc_console_write(struct console *co, const char *s, uint count) } spin_unlock_irqrestore(&pi->tx_lock, iflags); - return; } -static int __init -mpsc_console_setup(struct console *co, char *options) +static int __init mpsc_console_setup(struct console *co, char *options) { struct mpsc_port_info *pi; int baud, bits, parity, flow; @@ -1723,17 +1637,16 @@ mpsc_console_setup(struct console *co, char *options) } static struct console mpsc_console = { - .name = MPSC_DEV_NAME, - .write = mpsc_console_write, - .device = uart_console_device, - .setup = mpsc_console_setup, - .flags = CON_PRINTBUFFER, - .index = -1, - .data = &mpsc_reg, + .name = MPSC_DEV_NAME, + .write = mpsc_console_write, + .device = uart_console_device, + .setup = mpsc_console_setup, + .flags = CON_PRINTBUFFER, + .index = -1, + .data = &mpsc_reg, }; -static int __init -mpsc_late_console_init(void) +static int __init mpsc_late_console_init(void) { pr_debug("mpsc_late_console_init: Enter\n"); @@ -1755,43 +1668,40 @@ late_initcall(mpsc_late_console_init); * ****************************************************************************** */ -static void -mpsc_resource_err(char *s) +static void mpsc_resource_err(char *s) { printk(KERN_WARNING "MPSC: Platform device resource error in %s\n", s); - return; } -static int -mpsc_shared_map_regs(struct platform_device *pd) +static int mpsc_shared_map_regs(struct platform_device *pd) { struct resource *r; if ((r = platform_get_resource(pd, IORESOURCE_MEM, - MPSC_ROUTING_BASE_ORDER)) && request_mem_region(r->start, - MPSC_ROUTING_REG_BLOCK_SIZE, "mpsc_routing_regs")) { - + MPSC_ROUTING_BASE_ORDER)) + && request_mem_region(r->start, + MPSC_ROUTING_REG_BLOCK_SIZE, + "mpsc_routing_regs")) { mpsc_shared_regs.mpsc_routing_base = ioremap(r->start, - MPSC_ROUTING_REG_BLOCK_SIZE); + MPSC_ROUTING_REG_BLOCK_SIZE); mpsc_shared_regs.mpsc_routing_base_p = r->start; - } - else { + } else { mpsc_resource_err("MPSC routing base"); return -ENOMEM; } if ((r = platform_get_resource(pd, IORESOURCE_MEM, - MPSC_SDMA_INTR_BASE_ORDER)) && request_mem_region(r->start, - MPSC_SDMA_INTR_REG_BLOCK_SIZE, "sdma_intr_regs")) { - + MPSC_SDMA_INTR_BASE_ORDER)) + && request_mem_region(r->start, + MPSC_SDMA_INTR_REG_BLOCK_SIZE, + "sdma_intr_regs")) { mpsc_shared_regs.sdma_intr_base = ioremap(r->start, MPSC_SDMA_INTR_REG_BLOCK_SIZE); mpsc_shared_regs.sdma_intr_base_p = r->start; - } - else { + } else { iounmap(mpsc_shared_regs.mpsc_routing_base); release_mem_region(mpsc_shared_regs.mpsc_routing_base_p, - MPSC_ROUTING_REG_BLOCK_SIZE); + MPSC_ROUTING_REG_BLOCK_SIZE); mpsc_resource_err("SDMA intr base"); return -ENOMEM; } @@ -1799,18 +1709,17 @@ mpsc_shared_map_regs(struct platform_device *pd) return 0; } -static void -mpsc_shared_unmap_regs(void) +static void mpsc_shared_unmap_regs(void) { if (!mpsc_shared_regs.mpsc_routing_base) { iounmap(mpsc_shared_regs.mpsc_routing_base); release_mem_region(mpsc_shared_regs.mpsc_routing_base_p, - MPSC_ROUTING_REG_BLOCK_SIZE); + MPSC_ROUTING_REG_BLOCK_SIZE); } if (!mpsc_shared_regs.sdma_intr_base) { iounmap(mpsc_shared_regs.sdma_intr_base); release_mem_region(mpsc_shared_regs.sdma_intr_base_p, - MPSC_SDMA_INTR_REG_BLOCK_SIZE); + MPSC_SDMA_INTR_REG_BLOCK_SIZE); } mpsc_shared_regs.mpsc_routing_base = NULL; @@ -1818,19 +1727,17 @@ mpsc_shared_unmap_regs(void) mpsc_shared_regs.mpsc_routing_base_p = 0; mpsc_shared_regs.sdma_intr_base_p = 0; - - return; } -static int -mpsc_shared_drv_probe(struct platform_device *dev) +static int mpsc_shared_drv_probe(struct platform_device *dev) { struct mpsc_shared_pdata *pdata; int rc = -ENODEV; if (dev->id == 0) { - if (!(rc = mpsc_shared_map_regs(dev))) { - pdata = (struct mpsc_shared_pdata *)dev->dev.platform_data; + if (!(rc = mpsc_shared_map_regs(dev))) { + pdata = (struct mpsc_shared_pdata *) + dev->dev.platform_data; mpsc_shared_regs.MPSC_MRR_m = pdata->mrr_val; mpsc_shared_regs.MPSC_RCRR_m= pdata->rcrr_val; @@ -1847,8 +1754,7 @@ mpsc_shared_drv_probe(struct platform_device *dev) return rc; } -static int -mpsc_shared_drv_remove(struct platform_device *dev) +static int mpsc_shared_drv_remove(struct platform_device *dev) { int rc = -ENODEV; @@ -1869,7 +1775,7 @@ static struct platform_driver mpsc_shared_driver = { .probe = mpsc_shared_drv_probe, .remove = mpsc_shared_drv_remove, .driver = { - .name = MPSC_SHARED_NAME, + .name = MPSC_SHARED_NAME, }, }; @@ -1881,55 +1787,51 @@ static struct platform_driver mpsc_shared_driver = { ****************************************************************************** */ static struct uart_driver mpsc_reg = { - .owner = THIS_MODULE, - .driver_name = MPSC_DRIVER_NAME, - .dev_name = MPSC_DEV_NAME, - .major = MPSC_MAJOR, - .minor = MPSC_MINOR_START, - .nr = MPSC_NUM_CTLRS, - .cons = MPSC_CONSOLE, + .owner = THIS_MODULE, + .driver_name = MPSC_DRIVER_NAME, + .dev_name = MPSC_DEV_NAME, + .major = MPSC_MAJOR, + .minor = MPSC_MINOR_START, + .nr = MPSC_NUM_CTLRS, + .cons = MPSC_CONSOLE, }; -static int -mpsc_drv_map_regs(struct mpsc_port_info *pi, struct platform_device *pd) +static int mpsc_drv_map_regs(struct mpsc_port_info *pi, + struct platform_device *pd) { struct resource *r; - if ((r = platform_get_resource(pd, IORESOURCE_MEM, MPSC_BASE_ORDER)) && - request_mem_region(r->start, MPSC_REG_BLOCK_SIZE, "mpsc_regs")){ - + if ((r = platform_get_resource(pd, IORESOURCE_MEM, MPSC_BASE_ORDER)) + && request_mem_region(r->start, MPSC_REG_BLOCK_SIZE, + "mpsc_regs")) { pi->mpsc_base = ioremap(r->start, MPSC_REG_BLOCK_SIZE); pi->mpsc_base_p = r->start; - } - else { + } else { mpsc_resource_err("MPSC base"); - return -ENOMEM; + goto err; } if ((r = platform_get_resource(pd, IORESOURCE_MEM, - MPSC_SDMA_BASE_ORDER)) && request_mem_region(r->start, - MPSC_SDMA_REG_BLOCK_SIZE, "sdma_regs")) { - + MPSC_SDMA_BASE_ORDER)) + && request_mem_region(r->start, + MPSC_SDMA_REG_BLOCK_SIZE, "sdma_regs")) { pi->sdma_base = ioremap(r->start,MPSC_SDMA_REG_BLOCK_SIZE); pi->sdma_base_p = r->start; - } - else { + } else { mpsc_resource_err("SDMA base"); if (pi->mpsc_base) { iounmap(pi->mpsc_base); pi->mpsc_base = NULL; } - return -ENOMEM; + goto err; } if ((r = platform_get_resource(pd,IORESOURCE_MEM,MPSC_BRG_BASE_ORDER)) - && request_mem_region(r->start, MPSC_BRG_REG_BLOCK_SIZE, - "brg_regs")) { - + && request_mem_region(r->start, + MPSC_BRG_REG_BLOCK_SIZE, "brg_regs")) { pi->brg_base = ioremap(r->start, MPSC_BRG_REG_BLOCK_SIZE); pi->brg_base_p = r->start; - } - else { + } else { mpsc_resource_err("BRG base"); if (pi->mpsc_base) { iounmap(pi->mpsc_base); @@ -1939,14 +1841,15 @@ mpsc_drv_map_regs(struct mpsc_port_info *pi, struct platform_device *pd) iounmap(pi->sdma_base); pi->sdma_base = NULL; } - return -ENOMEM; + goto err; } - return 0; + +err: + return -ENOMEM; } -static void -mpsc_drv_unmap_regs(struct mpsc_port_info *pi) +static void mpsc_drv_unmap_regs(struct mpsc_port_info *pi) { if (!pi->mpsc_base) { iounmap(pi->mpsc_base); @@ -1968,13 +1871,10 @@ mpsc_drv_unmap_regs(struct mpsc_port_info *pi) pi->mpsc_base_p = 0; pi->sdma_base_p = 0; pi->brg_base_p = 0; - - return; } -static void -mpsc_drv_get_platform_data(struct mpsc_port_info *pi, - struct platform_device *pd, int num) +static void mpsc_drv_get_platform_data(struct mpsc_port_info *pi, + struct platform_device *pd, int num) { struct mpsc_pdata *pdata; @@ -2009,12 +1909,9 @@ mpsc_drv_get_platform_data(struct mpsc_port_info *pi, pi->shared_regs = &mpsc_shared_regs; pi->port.irq = platform_get_irq(pd, 0); - - return; } -static int -mpsc_drv_probe(struct platform_device *dev) +static int mpsc_drv_probe(struct platform_device *dev) { struct mpsc_port_info *pi; int rc = -ENODEV; @@ -2030,47 +1927,46 @@ mpsc_drv_probe(struct platform_device *dev) if (!(rc = mpsc_make_ready(pi))) { spin_lock_init(&pi->tx_lock); if (!(rc = uart_add_one_port(&mpsc_reg, - &pi->port))) + &pi->port))) { rc = 0; - else { - mpsc_release_port( - (struct uart_port *)pi); + } else { + mpsc_release_port((struct uart_port *) + pi); mpsc_drv_unmap_regs(pi); } - } - else + } else { mpsc_drv_unmap_regs(pi); + } } } return rc; } -static int -mpsc_drv_remove(struct platform_device *dev) +static int mpsc_drv_remove(struct platform_device *dev) { pr_debug("mpsc_drv_exit: Removing MPSC %d\n", dev->id); if (dev->id < MPSC_NUM_CTLRS) { uart_remove_one_port(&mpsc_reg, &mpsc_ports[dev->id].port); - mpsc_release_port((struct uart_port *)&mpsc_ports[dev->id].port); + mpsc_release_port((struct uart_port *) + &mpsc_ports[dev->id].port); mpsc_drv_unmap_regs(&mpsc_ports[dev->id]); return 0; - } - else + } else { return -ENODEV; + } } static struct platform_driver mpsc_driver = { .probe = mpsc_drv_probe, .remove = mpsc_drv_remove, .driver = { - .name = MPSC_CTLR_NAME, + .name = MPSC_CTLR_NAME, }, }; -static int __init -mpsc_drv_init(void) +static int __init mpsc_drv_init(void) { int rc; @@ -2085,24 +1981,21 @@ mpsc_drv_init(void) platform_driver_unregister(&mpsc_shared_driver); uart_unregister_driver(&mpsc_reg); } - } - else + } else { uart_unregister_driver(&mpsc_reg); + } } return rc; - } -static void __exit -mpsc_drv_exit(void) +static void __exit mpsc_drv_exit(void) { platform_driver_unregister(&mpsc_driver); platform_driver_unregister(&mpsc_shared_driver); uart_unregister_driver(&mpsc_reg); memset(mpsc_ports, 0, sizeof(mpsc_ports)); memset(&mpsc_shared_regs, 0, sizeof(mpsc_shared_regs)); - return; } module_init(mpsc_drv_init); diff --git a/drivers/serial/sb1250-duart.c b/drivers/serial/sb1250-duart.c index 1d9d7285172..20125375501 100644 --- a/drivers/serial/sb1250-duart.c +++ b/drivers/serial/sb1250-duart.c @@ -25,6 +25,7 @@ #define SUPPORT_SYSRQ #endif +#include <linux/compiler.h> #include <linux/console.h> #include <linux/delay.h> #include <linux/errno.h> @@ -103,8 +104,6 @@ struct sbd_duart { static struct sbd_duart sbd_duarts[DUART_MAX_CHIP]; -#define __unused __attribute__((__unused__)) - /* * Reading and writing SB1250 DUART registers. @@ -204,12 +203,12 @@ static int sbd_receive_drain(struct sbd_port *sport) return loops; } -static int __unused sbd_transmit_ready(struct sbd_port *sport) +static int __maybe_unused sbd_transmit_ready(struct sbd_port *sport) { return read_sbdchn(sport, R_DUART_STATUS) & M_DUART_TX_RDY; } -static int __unused sbd_transmit_drain(struct sbd_port *sport) +static int __maybe_unused sbd_transmit_drain(struct sbd_port *sport) { int loops = 10000; @@ -664,7 +663,7 @@ static void sbd_release_port(struct uart_port *uport) static int sbd_map_port(struct uart_port *uport) { - static const char *err = KERN_ERR "sbd: Cannot map MMIO\n"; + const char *err = KERN_ERR "sbd: Cannot map MMIO\n"; struct sbd_port *sport = to_sport(uport); struct sbd_duart *duart = sport->duart; @@ -691,8 +690,7 @@ static int sbd_map_port(struct uart_port *uport) static int sbd_request_port(struct uart_port *uport) { - static const char *err = KERN_ERR - "sbd: Unable to reserve MMIO resource\n"; + const char *err = KERN_ERR "sbd: Unable to reserve MMIO resource\n"; struct sbd_duart *duart = to_sport(uport)->duart; int map_guard; int ret = 0; @@ -755,7 +753,7 @@ static int sbd_verify_port(struct uart_port *uport, struct serial_struct *ser) } -static struct uart_ops sbd_ops = { +static const struct uart_ops sbd_ops = { .tx_empty = sbd_tx_empty, .set_mctrl = sbd_set_mctrl, .get_mctrl = sbd_get_mctrl, diff --git a/drivers/serial/serial_txx9.c b/drivers/serial/serial_txx9.c index 1deb5764326..b8f91e018b2 100644 --- a/drivers/serial/serial_txx9.c +++ b/drivers/serial/serial_txx9.c @@ -1043,8 +1043,9 @@ static int __devinit serial_txx9_probe(struct platform_device *dev) ret = serial_txx9_register_port(&port); if (ret < 0) { dev_err(&dev->dev, "unable to register port at index %d " - "(IO%x MEM%lx IRQ%d): %d\n", i, - p->iobase, p->mapbase, p->irq, ret); + "(IO%x MEM%llx IRQ%d): %d\n", i, + p->iobase, (unsigned long long)p->mapbase, + p->irq, ret); } } return 0; diff --git a/drivers/serial/vr41xx_siu.c b/drivers/serial/vr41xx_siu.c index 85309acb75f..6fd51b0022c 100644 --- a/drivers/serial/vr41xx_siu.c +++ b/drivers/serial/vr41xx_siu.c @@ -65,7 +65,9 @@ static struct uart_port siu_uart_ports[SIU_PORTS_MAX] = { }, }; +#ifdef CONFIG_SERIAL_VR41XX_CONSOLE static uint8_t lsr_break_flag[SIU_PORTS_MAX]; +#endif #define siu_read(port, offset) readb((port)->membase + (offset)) #define siu_write(port, offset, value) writeb((value), (port)->membase + (offset)) @@ -782,7 +784,7 @@ static void siu_console_write(struct console *con, const char *s, unsigned count siu_write(port, UART_IER, ier); } -static int siu_console_setup(struct console *con, char *options) +static int __init siu_console_setup(struct console *con, char *options) { struct uart_port *port; int baud = 9600; @@ -800,7 +802,8 @@ static int siu_console_setup(struct console *con, char *options) port->membase = ioremap(port->mapbase, siu_port_size(port)); } - vr41xx_select_siu_interface(SIU_INTERFACE_RS232C); + if (port->type == PORT_VR41XX_SIU) + vr41xx_select_siu_interface(SIU_INTERFACE_RS232C); if (options != NULL) uart_parse_options(options, &baud, &parity, &bits, &flow); diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index b05de30b5d9..e84d2159794 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -200,6 +200,8 @@ static DEFINE_MUTEX(board_lock); * platforms may not be able to use spi_register_board_info though, and * this is exported so that for example a USB or parport based adapter * driver could add devices (which it would learn about out-of-band). + * + * Returns the new device, or NULL. */ struct spi_device *spi_new_device(struct spi_master *master, struct spi_board_info *chip) @@ -208,7 +210,20 @@ struct spi_device *spi_new_device(struct spi_master *master, struct device *dev = master->cdev.dev; int status; - /* NOTE: caller did any chip->bus_num checks necessary */ + /* NOTE: caller did any chip->bus_num checks necessary. + * + * Also, unless we change the return value convention to use + * error-or-pointer (not NULL-or-pointer), troubleshootability + * suggests syslogged diagnostics are best here (ugh). + */ + + /* Chipselects are numbered 0..max; validate. */ + if (chip->chip_select >= master->num_chipselect) { + dev_err(dev, "cs%d > max %d\n", + chip->chip_select, + master->num_chipselect); + return NULL; + } if (!spi_master_get(master)) return NULL; @@ -236,10 +251,10 @@ struct spi_device *spi_new_device(struct spi_master *master, proxy->controller_state = NULL; proxy->dev.release = spidev_release; - /* drivers may modify this default i/o setup */ + /* drivers may modify this initial i/o setup */ status = master->setup(proxy); if (status < 0) { - dev_dbg(dev, "can't %s %s, status %d\n", + dev_err(dev, "can't %s %s, status %d\n", "setup", proxy->dev.bus_id, status); goto fail; } @@ -249,7 +264,7 @@ struct spi_device *spi_new_device(struct spi_master *master, */ status = device_register(&proxy->dev); if (status < 0) { - dev_dbg(dev, "can't %s %s, status %d\n", + dev_err(dev, "can't %s %s, status %d\n", "add", proxy->dev.bus_id, status); goto fail; } @@ -306,7 +321,6 @@ spi_register_board_info(struct spi_board_info const *info, unsigned n) static void scan_boardinfo(struct spi_master *master) { struct boardinfo *bi; - struct device *dev = master->cdev.dev; mutex_lock(&board_lock); list_for_each_entry(bi, &board_list, list) { @@ -316,17 +330,9 @@ static void scan_boardinfo(struct spi_master *master) for (n = bi->n_board_info; n > 0; n--, chip++) { if (chip->bus_num != master->bus_num) continue; - /* some controllers only have one chip, so they - * might not use chipselects. otherwise, the - * chipselects are numbered 0..max. + /* NOTE: this relies on spi_new_device to + * issue diagnostics when given bogus inputs */ - if (chip->chip_select >= master->num_chipselect - && master->num_chipselect) { - dev_dbg(dev, "cs%d > max %d\n", - chip->chip_select, - master->num_chipselect); - continue; - } (void) spi_new_device(master, chip); } } @@ -419,8 +425,17 @@ int spi_register_master(struct spi_master *master) if (!dev) return -ENODEV; + /* even if it's just one always-selected device, there must + * be at least one chipselect + */ + if (master->num_chipselect == 0) + return -EINVAL; + /* convention: dynamically assigned bus IDs count down from the max */ if (master->bus_num < 0) { + /* FIXME switch to an IDR based scheme, something like + * I2C now uses, so we can't run out of "dynamic" IDs + */ master->bus_num = atomic_dec_return(&dyn_bus_id); dynamic = 1; } diff --git a/drivers/spi/spi_mpc83xx.c b/drivers/spi/spi_mpc83xx.c index 3295cfcc9f2..0c16a2b39b4 100644 --- a/drivers/spi/spi_mpc83xx.c +++ b/drivers/spi/spi_mpc83xx.c @@ -39,6 +39,7 @@ struct mpc83xx_spi_reg { }; /* SPI Controller mode register definitions */ +#define SPMODE_LOOP (1 << 30) #define SPMODE_CI_INACTIVEHIGH (1 << 29) #define SPMODE_CP_BEGIN_EDGECLK (1 << 28) #define SPMODE_DIV16 (1 << 27) @@ -153,12 +154,18 @@ static void mpc83xx_spi_chipselect(struct spi_device *spi, int value) len = len - 1; /* mask out bits we are going to set */ - regval &= ~0x38ff0000; + regval &= ~(SPMODE_CP_BEGIN_EDGECLK | SPMODE_CI_INACTIVEHIGH + | SPMODE_LEN(0xF) | SPMODE_DIV16 + | SPMODE_PM(0xF) | SPMODE_REV | SPMODE_LOOP); if (spi->mode & SPI_CPHA) regval |= SPMODE_CP_BEGIN_EDGECLK; if (spi->mode & SPI_CPOL) regval |= SPMODE_CI_INACTIVEHIGH; + if (!(spi->mode & SPI_LSB_FIRST)) + regval |= SPMODE_REV; + if (spi->mode & SPI_LOOP) + regval |= SPMODE_LOOP; regval |= SPMODE_LEN(len); @@ -176,6 +183,8 @@ static void mpc83xx_spi_chipselect(struct spi_device *spi, int value) regval |= SPMODE_PM(pm); } + /* Turn off SPI unit prior changing mode */ + mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, 0); mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, regval); if (mpc83xx_spi->activate_cs) mpc83xx_spi->activate_cs(spi->chip_select, pol); @@ -231,6 +240,14 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t) } else return -EINVAL; + if (mpc83xx_spi->qe_mode && spi->mode & SPI_LSB_FIRST) { + mpc83xx_spi->tx_shift = 0; + if (bits_per_word <= 8) + mpc83xx_spi->rx_shift = 8; + else + mpc83xx_spi->rx_shift = 0; + } + /* nsecs = (clock period)/2 */ if (!hz) hz = spi->max_speed_hz; @@ -245,17 +262,22 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t) regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode); - /* Mask out bits_per_wordgth */ - regval &= 0xff0fffff; + /* mask out bits we are going to set */ + regval &= ~(SPMODE_LEN(0xF) | SPMODE_REV); regval |= SPMODE_LEN(bits_per_word); + if (!(spi->mode & SPI_LSB_FIRST)) + regval |= SPMODE_REV; + /* Turn off SPI unit prior changing mode */ + mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, 0); mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, regval); return 0; } /* the spi->mode bits understood by this driver: */ -#define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH) +#define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH \ + | SPI_LSB_FIRST | SPI_LOOP) static int mpc83xx_spi_setup(struct spi_device *spi) { diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index 38b60ad0eda..630f781aeb1 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c @@ -55,9 +55,16 @@ static unsigned long minors[N_SPI_MINORS / BITS_PER_LONG]; -/* Bit masks for spi_device.mode management */ -#define SPI_MODE_MASK (SPI_CPHA | SPI_CPOL) - +/* Bit masks for spi_device.mode management. Note that incorrect + * settings for CS_HIGH and 3WIRE can cause *lots* of trouble for other + * devices on a shared bus: CS_HIGH, because this device will be + * active when it shouldn't be; 3WIRE, because when active it won't + * behave as it should. + * + * REVISIT should changing those two modes be privileged? + */ +#define SPI_MODE_MASK (SPI_CPHA | SPI_CPOL | SPI_CS_HIGH \ + | SPI_LSB_FIRST | SPI_3WIRE | SPI_LOOP) struct spidev_data { struct device dev; diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index a7231d171bd..5216c11d4de 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -1645,18 +1645,6 @@ config FB_MAXINE DECstation series (Personal DECstation 5000/20, /25, /33, /50, Codename "Maxine"). -config FB_TX3912 - bool "TMPTX3912/PR31700 frame buffer support" - depends on (FB = y) && NINO - select FB_CFB_FILLRECT - select FB_CFB_COPYAREA - select FB_CFB_IMAGEBLIT - help - The TX3912 is a Toshiba RISC processor based on the MIPS 3900 core - see <http://www.toshiba.com/taec/components/Generic/risc/tx3912.htm>. - - Say Y here to enable kernel support for the on-board framebuffer. - config FB_G364 bool "G364 frame buffer support" depends on (FB = y) && (MIPS_MAGNUM_4000 || OLIVETTI_M700) diff --git a/drivers/video/Makefile b/drivers/video/Makefile index 518933d4905..06eec7b182b 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile @@ -103,7 +103,6 @@ obj-$(CONFIG_FB_PMAG_AA) += pmag-aa-fb.o obj-$(CONFIG_FB_PMAG_BA) += pmag-ba-fb.o obj-$(CONFIG_FB_PMAGB_B) += pmagb-b-fb.o obj-$(CONFIG_FB_MAXINE) += maxinefb.o -obj-$(CONFIG_FB_TX3912) += tx3912fb.o obj-$(CONFIG_FB_S1D13XXX) += s1d13xxxfb.o obj-$(CONFIG_FB_IMX) += imxfb.o obj-$(CONFIG_FB_S3C2410) += s3c2410fb.o diff --git a/drivers/video/acornfb.c b/drivers/video/acornfb.c index 61a8bf159cb..eedb8285e32 100644 --- a/drivers/video/acornfb.c +++ b/drivers/video/acornfb.c @@ -138,17 +138,6 @@ static struct pixclock arc_clocks[] = { { 41250, 42083, VIDC_CTRL_DIV1, VID_CTL_24MHz }, /* 24.000MHz */ }; -#ifdef CONFIG_ARCH_A5K -static struct pixclock a5k_clocks[] = { - { 117974, 120357, VIDC_CTRL_DIV3, VID_CTL_25MHz }, /* 8.392MHz */ - { 78649, 80238, VIDC_CTRL_DIV2, VID_CTL_25MHz }, /* 12.588MHz */ - { 58987, 60178, VIDC_CTRL_DIV1_5, VID_CTL_25MHz }, /* 16.588MHz */ - { 55000, 56111, VIDC_CTRL_DIV2, VID_CTL_36MHz }, /* 18.000MHz */ - { 39325, 40119, VIDC_CTRL_DIV1, VID_CTL_25MHz }, /* 25.175MHz */ - { 27500, 28055, VIDC_CTRL_DIV1, VID_CTL_36MHz }, /* 36.000MHz */ -}; -#endif - static struct pixclock * acornfb_valid_pixrate(struct fb_var_screeninfo *var) { @@ -163,15 +152,6 @@ acornfb_valid_pixrate(struct fb_var_screeninfo *var) pixclock < arc_clocks[i].max_clock) return arc_clocks + i; -#ifdef CONFIG_ARCH_A5K - if (machine_is_a5k()) { - for (i = 0; i < ARRAY_SIZE(a5k_clocks); i++) - if (pixclock > a5k_clocks[i].min_clock && - pixclock < a5k_clocks[i].max_clock) - return a5k_clocks + i; - } -#endif - return NULL; } diff --git a/drivers/video/console/fonts.c b/drivers/video/console/fonts.c index a6828d0a4c5..96979c37751 100644 --- a/drivers/video/console/fonts.c +++ b/drivers/video/console/fonts.c @@ -133,8 +133,8 @@ const struct font_desc *get_default_font(int xres, int yres, u32 font_w, if ((yres < 400) == (f->height <= 8)) c += 1000; - if (!(font_w & (1 << (f->width - 1))) || - !(font_w & (1 << (f->height - 1)))) + if ((font_w & (1 << (f->width - 1))) && + (font_h & (1 << (f->height - 1)))) c += 1000; if (c > cc) { diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c index 215ac579f90..07402720470 100644 --- a/drivers/video/fbmem.c +++ b/drivers/video/fbmem.c @@ -244,8 +244,17 @@ static void fb_set_logo(struct fb_info *info, u8 xor = (info->fix.visual == FB_VISUAL_MONO01) ? 0xff : 0; u8 fg = 1, d; - if (fb_get_color_depth(&info->var, &info->fix) == 3) + switch (fb_get_color_depth(&info->var, &info->fix)) { + case 1: + fg = 1; + break; + case 2: + fg = 3; + break; + default: fg = 7; + break; + } if (info->fix.visual == FB_VISUAL_MONO01 || info->fix.visual == FB_VISUAL_MONO10) @@ -564,21 +573,6 @@ int fb_prepare_logo(struct fb_info *info, int rotate) depth = 4; } - if (depth >= 8) { - switch (info->fix.visual) { - case FB_VISUAL_TRUECOLOR: - fb_logo.needs_truepalette = 1; - break; - case FB_VISUAL_DIRECTCOLOR: - fb_logo.needs_directpalette = 1; - fb_logo.needs_cmapreset = 1; - break; - case FB_VISUAL_PSEUDOCOLOR: - fb_logo.needs_cmapreset = 1; - break; - } - } - /* Return if no suitable logo was found */ fb_logo.logo = fb_find_logo(depth); @@ -604,6 +598,22 @@ int fb_prepare_logo(struct fb_info *info, int rotate) else fb_logo.depth = 1; + + if (fb_logo.depth > 4 && depth > 4) { + switch (info->fix.visual) { + case FB_VISUAL_TRUECOLOR: + fb_logo.needs_truepalette = 1; + break; + case FB_VISUAL_DIRECTCOLOR: + fb_logo.needs_directpalette = 1; + fb_logo.needs_cmapreset = 1; + break; + case FB_VISUAL_PSEUDOCOLOR: + fb_logo.needs_cmapreset = 1; + break; + } + } + return fb_prepare_extra_logos(info, fb_logo.logo->height, yres); } diff --git a/drivers/video/geode/Kconfig b/drivers/video/geode/Kconfig index a814b6c2605..7608429b394 100644 --- a/drivers/video/geode/Kconfig +++ b/drivers/video/geode/Kconfig @@ -8,6 +8,21 @@ config FB_GEODE Say 'Y' here to allow you to select framebuffer drivers for the AMD Geode family of processors. +config FB_GEODE_LX + tristate "AMD Geode LX framebuffer support (EXPERIMENTAL)" + depends on FB && FB_GEODE + select FB_CFB_FILLRECT + select FB_CFB_COPYAREA + select FB_CFB_IMAGEBLIT + ---help--- + Framebuffer driver for the display controller integrated into the + AMD Geode LX processors. + + To compile this driver as a module, choose M here: the module will + be called lxfb. + + If unsure, say N. + config FB_GEODE_GX tristate "AMD Geode GX framebuffer support (EXPERIMENTAL)" depends on FB && FB_GEODE && EXPERIMENTAL diff --git a/drivers/video/geode/Makefile b/drivers/video/geode/Makefile index f896565bc31..957304b45fb 100644 --- a/drivers/video/geode/Makefile +++ b/drivers/video/geode/Makefile @@ -2,6 +2,8 @@ obj-$(CONFIG_FB_GEODE_GX1) += gx1fb.o obj-$(CONFIG_FB_GEODE_GX) += gxfb.o +obj-$(CONFIG_FB_GEODE_LX) += lxfb.o gx1fb-objs := gx1fb_core.o display_gx1.o video_cs5530.o gxfb-objs := gxfb_core.o display_gx.o video_gx.o +lxfb-objs := lxfb_core.o lxfb_ops.o diff --git a/drivers/video/geode/lxfb.h b/drivers/video/geode/lxfb.h new file mode 100644 index 00000000000..6c227f9592a --- /dev/null +++ b/drivers/video/geode/lxfb.h @@ -0,0 +1,199 @@ +#ifndef _LXFB_H_ +#define _LXFB_H_ + +#include <linux/fb.h> + +#define OUTPUT_CRT 0x01 +#define OUTPUT_PANEL 0x02 + +struct lxfb_par { + int output; + int panel_width; + int panel_height; + + void __iomem *gp_regs; + void __iomem *dc_regs; + void __iomem *df_regs; +}; + +static inline unsigned int lx_get_pitch(unsigned int xres, int bpp) +{ + return (((xres * (bpp >> 3)) + 7) & ~7); +} + +void lx_set_mode(struct fb_info *); +void lx_get_gamma(struct fb_info *, unsigned int *, int); +void lx_set_gamma(struct fb_info *, unsigned int *, int); +unsigned int lx_framebuffer_size(void); +int lx_blank_display(struct fb_info *, int); +void lx_set_palette_reg(struct fb_info *, unsigned int, unsigned int, + unsigned int, unsigned int); + +/* MSRS */ + +#define MSR_LX_GLD_CONFIG 0x48002001 +#define MSR_LX_GLCP_DOTPLL 0x4c000015 +#define MSR_LX_DF_PADSEL 0x48000011 +#define MSR_LX_DC_SPARE 0x80000011 +#define MSR_LX_DF_GLCONFIG 0x48002001 + +#define MSR_LX_GLIU0_P2D_RO0 0x10000029 + +#define GLCP_DOTPLL_RESET (1 << 0) +#define GLCP_DOTPLL_BYPASS (1 << 15) +#define GLCP_DOTPLL_HALFPIX (1 << 24) +#define GLCP_DOTPLL_LOCK (1 << 25) + +#define DF_CONFIG_OUTPUT_MASK 0x38 +#define DF_OUTPUT_PANEL 0x08 +#define DF_OUTPUT_CRT 0x00 +#define DF_SIMULTANEOUS_CRT_AND_FP (1 << 15) + +#define DF_DEFAULT_TFT_PAD_SEL_LOW 0xDFFFFFFF +#define DF_DEFAULT_TFT_PAD_SEL_HIGH 0x0000003F + +#define DC_SPARE_DISABLE_CFIFO_HGO 0x00000800 +#define DC_SPARE_VFIFO_ARB_SELECT 0x00000400 +#define DC_SPARE_WM_LPEN_OVRD 0x00000200 +#define DC_SPARE_LOAD_WM_LPEN_MASK 0x00000100 +#define DC_SPARE_DISABLE_INIT_VID_PRI 0x00000080 +#define DC_SPARE_DISABLE_VFIFO_WM 0x00000040 +#define DC_SPARE_DISABLE_CWD_CHECK 0x00000020 +#define DC_SPARE_PIX8_PAN_FIX 0x00000010 +#define DC_SPARE_FIRST_REQ_MASK 0x00000002 + +/* Registers */ + +#define DC_UNLOCK 0x00 +#define DC_UNLOCK_CODE 0x4758 + +#define DC_GENERAL_CFG 0x04 +#define DC_GCFG_DFLE (1 << 0) +#define DC_GCFG_VIDE (1 << 3) +#define DC_GCFG_VGAE (1 << 7) +#define DC_GCFG_CMPE (1 << 5) +#define DC_GCFG_DECE (1 << 6) +#define DC_GCFG_FDTY (1 << 17) + +#define DC_DISPLAY_CFG 0x08 +#define DC_DCFG_TGEN (1 << 0) +#define DC_DCFG_GDEN (1 << 3) +#define DC_DCFG_VDEN (1 << 4) +#define DC_DCFG_TRUP (1 << 6) +#define DC_DCFG_DCEN (1 << 24) +#define DC_DCFG_PALB (1 << 25) +#define DC_DCFG_VISL (1 << 27) + +#define DC_DCFG_16BPP 0x0 + +#define DC_DCFG_DISP_MODE_MASK 0x00000300 +#define DC_DCFG_DISP_MODE_8BPP 0x00000000 +#define DC_DCFG_DISP_MODE_16BPP 0x00000100 +#define DC_DCFG_DISP_MODE_24BPP 0x00000200 +#define DC_DCFG_DISP_MODE_32BPP 0x00000300 + + +#define DC_ARB_CFG 0x0C + +#define DC_FB_START 0x10 +#define DC_CB_START 0x14 +#define DC_CURSOR_START 0x18 + +#define DC_DV_TOP 0x2C +#define DC_DV_TOP_ENABLE (1 << 0) + +#define DC_LINE_SIZE 0x30 +#define DC_GRAPHICS_PITCH 0x34 +#define DC_H_ACTIVE_TIMING 0x40 +#define DC_H_BLANK_TIMING 0x44 +#define DC_H_SYNC_TIMING 0x48 +#define DC_V_ACTIVE_TIMING 0x50 +#define DC_V_BLANK_TIMING 0x54 +#define DC_V_SYNC_TIMING 0x58 +#define DC_FB_ACTIVE 0x5C + +#define DC_PAL_ADDRESS 0x70 +#define DC_PAL_DATA 0x74 + +#define DC_PHY_MEM_OFFSET 0x84 + +#define DC_DV_CTL 0x88 +#define DC_DV_LINE_SIZE_MASK 0x00000C00 +#define DC_DV_LINE_SIZE_1024 0x00000000 +#define DC_DV_LINE_SIZE_2048 0x00000400 +#define DC_DV_LINE_SIZE_4096 0x00000800 +#define DC_DV_LINE_SIZE_8192 0x00000C00 + + +#define DC_GFX_SCALE 0x90 +#define DC_IRQ_FILT_CTL 0x94 + + +#define DC_IRQ 0xC8 +#define DC_IRQ_MASK (1 << 0) +#define DC_VSYNC_IRQ_MASK (1 << 1) +#define DC_IRQ_STATUS (1 << 20) +#define DC_VSYNC_IRQ_STATUS (1 << 21) + +#define DC_GENLCK_CTRL 0xD4 +#define DC_GENLCK_ENABLE (1 << 18) +#define DC_GC_ALPHA_FLICK_ENABLE (1 << 25) +#define DC_GC_FLICKER_FILTER_ENABLE (1 << 24) +#define DC_GC_FLICKER_FILTER_MASK (0x0F << 28) + +#define DC_COLOR_KEY 0xB8 +#define DC_CLR_KEY_ENABLE (1 << 24) + + +#define DC3_DV_LINE_SIZE_MASK 0x00000C00 +#define DC3_DV_LINE_SIZE_1024 0x00000000 +#define DC3_DV_LINE_SIZE_2048 0x00000400 +#define DC3_DV_LINE_SIZE_4096 0x00000800 +#define DC3_DV_LINE_SIZE_8192 0x00000C00 + +#define DF_VIDEO_CFG 0x0 +#define DF_VCFG_VID_EN (1 << 0) + +#define DF_DISPLAY_CFG 0x08 + +#define DF_DCFG_CRT_EN (1 << 0) +#define DF_DCFG_HSYNC_EN (1 << 1) +#define DF_DCFG_VSYNC_EN (1 << 2) +#define DF_DCFG_DAC_BL_EN (1 << 3) +#define DF_DCFG_CRT_HSYNC_POL (1 << 8) +#define DF_DCFG_CRT_VSYNC_POL (1 << 9) +#define DF_DCFG_GV_PAL_BYP (1 << 21) + +#define DF_DCFG_CRT_SYNC_SKW_INIT 0x10000 +#define DF_DCFG_CRT_SYNC_SKW_MASK 0x1c000 + +#define DF_DCFG_PWR_SEQ_DLY_INIT 0x80000 +#define DF_DCFG_PWR_SEQ_DLY_MASK 0xe0000 + +#define DF_MISC 0x50 + +#define DF_MISC_GAM_BYPASS (1 << 0) +#define DF_MISC_DAC_PWRDN (1 << 10) +#define DF_MISC_A_PWRDN (1 << 11) + +#define DF_PAR 0x38 +#define DF_PDR 0x40 +#define DF_ALPHA_CONTROL_1 0xD8 +#define DF_VIDEO_REQUEST 0x120 + +#define DF_PANEL_TIM1 0x400 +#define DF_DEFAULT_TFT_PMTIM1 0x0 + +#define DF_PANEL_TIM2 0x408 +#define DF_DEFAULT_TFT_PMTIM2 0x08000000 + +#define DF_FP_PM 0x410 +#define DF_FP_PM_P (1 << 24) + +#define DF_DITHER_CONTROL 0x418 +#define DF_DEFAULT_TFT_DITHCTL 0x00000070 +#define GP_BLT_STATUS 0x44 +#define GP_BS_BLT_BUSY (1 << 0) +#define GP_BS_CB_EMPTY (1 << 4) + +#endif diff --git a/drivers/video/geode/lxfb_core.c b/drivers/video/geode/lxfb_core.c new file mode 100644 index 00000000000..5e30b40c8c0 --- /dev/null +++ b/drivers/video/geode/lxfb_core.c @@ -0,0 +1,621 @@ +/* + * Geode LX framebuffer driver. + * + * Copyright (C) 2007 Advanced Micro Devices, Inc. + * Built from gxfb (which is Copyright (C) 2006 Arcom Control Systems Ltd.) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/errno.h> +#include <linux/string.h> +#include <linux/console.h> +#include <linux/mm.h> +#include <linux/slab.h> +#include <linux/delay.h> +#include <linux/fb.h> +#include <linux/init.h> +#include <linux/pci.h> +#include <linux/uaccess.h> + +#include "lxfb.h" + +static char *mode_option; +static int noclear, nopanel, nocrt; +static int fbsize; + +/* Most of these modes are sorted in ascending order, but + * since the first entry in this table is the "default" mode, + * we try to make it something sane - 640x480-60 is sane + */ + +const struct fb_videomode geode_modedb[] __initdata = { + /* 640x480-60 */ + { NULL, 60, 640, 480, 39682, 48, 8, 25, 2, 88, 2, + FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + FB_VMODE_NONINTERLACED, 0 }, + /* 640x400-70 */ + { NULL, 70, 640, 400, 39770, 40, 8, 28, 5, 96, 2, + FB_SYNC_HOR_HIGH_ACT, + FB_VMODE_NONINTERLACED, 0 }, + /* 640x480-70 */ + { NULL, 70, 640, 480, 35014, 88, 24, 15, 2, 64, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 640x480-72 */ + { NULL, 72, 640, 480, 32102, 120, 16, 20, 1, 40, 3, + FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + FB_VMODE_NONINTERLACED, 0 }, + /* 640x480-75 */ + { NULL, 75, 640, 480, 31746, 120, 16, 16, 1, 64, 3, + FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + FB_VMODE_NONINTERLACED, 0 }, + /* 640x480-85 */ + { NULL, 85, 640, 480, 27780, 80, 56, 25, 1, 56, 3, + FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + FB_VMODE_NONINTERLACED, 0 }, + /* 640x480-90 */ + { NULL, 90, 640, 480, 26392, 96, 32, 22, 1, 64, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 640x480-100 */ + { NULL, 100, 640, 480, 23167, 104, 40, 25, 1, 64, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 640x480-60 */ + { NULL, 60, 640, 480, 39682, 48, 16, 25, 10, 88, 2, + FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + FB_VMODE_NONINTERLACED, 0 }, + /* 800x600-56 */ + { NULL, 56, 800, 600, 27901, 128, 24, 22, 1, 72, 2, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 800x600-60 */ + { NULL, 60, 800, 600, 25131, 72, 32, 23, 1, 136, 4, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 800x600-70 */ + { NULL, 70, 800, 600, 21873, 120, 40, 21, 4, 80, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 800x600-72 */ + { NULL, 72, 800, 600, 20052, 64, 56, 23, 37, 120, 6, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 800x600-75 */ + { NULL, 75, 800, 600, 20202, 160, 16, 21, 1, 80, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 800x600-85 */ + { NULL, 85, 800, 600, 17790, 152, 32, 27, 1, 64, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 800x600-90 */ + { NULL, 90, 800, 600, 16648, 128, 40, 28, 1, 88, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 800x600-100 */ + { NULL, 100, 800, 600, 14667, 136, 48, 27, 1, 88, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 800x600-60 */ + { NULL, 60, 800, 600, 25131, 88, 40, 23, 1, 128, 4, + FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + FB_VMODE_NONINTERLACED, 0 }, + /* 1024x768-60 */ + { NULL, 60, 1024, 768, 15385, 160, 24, 29, 3, 136, 6, + FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + FB_VMODE_NONINTERLACED, 0 }, + /* 1024x768-70 */ + { NULL, 70, 1024, 768, 13346, 144, 24, 29, 3, 136, 6, + FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + FB_VMODE_NONINTERLACED, 0 }, + /* 1024x768-72 */ + { NULL, 72, 1024, 768, 12702, 168, 56, 29, 4, 112, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1024x768-75 */ + { NULL, 75, 1024, 768, 12703, 176, 16, 28, 1, 96, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1024x768-85 */ + { NULL, 85, 1024, 768, 10581, 208, 48, 36, 1, 96, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1024x768-90 */ + { NULL, 90, 1024, 768, 9981, 176, 64, 37, 1, 112, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1024x768-100 */ + { NULL, 100, 1024, 768, 8825, 184, 72, 42, 1, 112, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1024x768-60 */ + { NULL, 60, 1024, 768, 15385, 160, 24, 29, 3, 136, 6, + FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + FB_VMODE_NONINTERLACED, 0 }, + /* 1152x864-60 */ + { NULL, 60, 1152, 864, 12251, 184, 64, 27, 1, 120, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1152x864-70 */ + { NULL, 70, 1152, 864, 10254, 192, 72, 32, 8, 120, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1152x864-72 */ + { NULL, 72, 1152, 864, 9866, 200, 72, 33, 7, 128, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1152x864-75 */ + { NULL, 75, 1152, 864, 9259, 256, 64, 32, 1, 128, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1152x864-85 */ + { NULL, 85, 1152, 864, 8357, 200, 72, 37, 3, 128, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1152x864-90 */ + { NULL, 90, 1152, 864, 7719, 208, 80, 42, 9, 128, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1152x864-100 */ + { NULL, 100, 1152, 864, 6947, 208, 80, 48, 3, 128, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1152x864-60 */ + { NULL, 60, 1152, 864, 12251, 184, 64, 27, 1, 120, 3, + FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + FB_VMODE_NONINTERLACED, 0 }, + /* 1280x1024-60 */ + { NULL, 60, 1280, 1024, 9262, 248, 48, 38, 1, 112, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1280x1024-70 */ + { NULL, 70, 1280, 1024, 7719, 224, 88, 38, 6, 136, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1280x1024-72 */ + { NULL, 72, 1280, 1024, 7490, 224, 88, 39, 7, 136, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1280x1024-75 */ + { NULL, 75, 1280, 1024, 7409, 248, 16, 38, 1, 144, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1280x1024-85 */ + { NULL, 85, 1280, 1024, 6351, 224, 64, 44, 1, 160, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1280x1024-90 */ + { NULL, 90, 1280, 1024, 5791, 240, 96, 51, 12, 144, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1280x1024-100 */ + { NULL, 100, 1280, 1024, 5212, 240, 96, 57, 6, 144, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1280x1024-60 */ + { NULL, 60, 1280, 1024, 9262, 248, 48, 38, 1, 112, 3, + FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + FB_VMODE_NONINTERLACED, 0 }, + /* 1600x1200-60 */ + { NULL, 60, 1600, 1200, 6172, 304, 64, 46, 1, 192, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1600x1200-70 */ + { NULL, 70, 1600, 1200, 5291, 304, 64, 46, 1, 192, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1600x1200-72 */ + { NULL, 72, 1600, 1200, 5053, 288, 112, 47, 13, 176, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1600x1200-75 */ + { NULL, 75, 1600, 1200, 4938, 304, 64, 46, 1, 192, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1600x1200-85 */ + { NULL, 85, 1600, 1200, 4357, 304, 64, 46, 1, 192, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1600x1200-90 */ + { NULL, 90, 1600, 1200, 3981, 304, 128, 60, 1, 176, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1600x1200-100 */ + { NULL, 100, 1600, 1200, 3563, 304, 128, 67, 1, 176, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1600x1200-60 */ + { NULL, 60, 1600, 1200, 6172, 304, 64, 46, 1, 192, 3, + FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, + FB_VMODE_NONINTERLACED, 0 }, + /* 1920x1440-60 */ + { NULL, 60, 1920, 1440, 4273, 344, 128, 56, 1, 208, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1920x1440-70 */ + { NULL, 70, 1920, 1440, 3593, 360, 152, 55, 8, 208, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1920x1440-72 */ + { NULL, 72, 1920, 1440, 3472, 360, 152, 68, 4, 208, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1920x1440-75 */ + { NULL, 75, 1920, 1440, 3367, 352, 144, 56, 1, 224, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, + /* 1920x1440-85 */ + { NULL, 85, 1920, 1440, 2929, 368, 152, 68, 1, 216, 3, + 0, FB_VMODE_NONINTERLACED, 0 }, +}; + +static int lxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) +{ + if (var->xres > 1920 || var->yres > 1440) + return -EINVAL; + + if (var->bits_per_pixel == 32) { + var->red.offset = 16; var->red.length = 8; + var->green.offset = 8; var->green.length = 8; + var->blue.offset = 0; var->blue.length = 8; + } else if (var->bits_per_pixel == 16) { + var->red.offset = 11; var->red.length = 5; + var->green.offset = 5; var->green.length = 6; + var->blue.offset = 0; var->blue.length = 5; + } else if (var->bits_per_pixel == 8) { + var->red.offset = 0; var->red.length = 8; + var->green.offset = 0; var->green.length = 8; + var->blue.offset = 0; var->blue.length = 8; + } else + return -EINVAL; + + var->transp.offset = 0; var->transp.length = 0; + + /* Enough video memory? */ + if ((lx_get_pitch(var->xres, var->bits_per_pixel) * var->yres) + > info->fix.smem_len) + return -EINVAL; + + return 0; +} + +static int lxfb_set_par(struct fb_info *info) +{ + if (info->var.bits_per_pixel > 8) { + info->fix.visual = FB_VISUAL_TRUECOLOR; + fb_dealloc_cmap(&info->cmap); + } else { + info->fix.visual = FB_VISUAL_PSEUDOCOLOR; + fb_alloc_cmap(&info->cmap, 1<<info->var.bits_per_pixel, 0); + } + + info->fix.line_length = lx_get_pitch(info->var.xres, + info->var.bits_per_pixel); + + lx_set_mode(info); + return 0; +} + +static inline u_int chan_to_field(u_int chan, struct fb_bitfield *bf) +{ + chan &= 0xffff; + chan >>= 16 - bf->length; + return chan << bf->offset; +} + +static int lxfb_setcolreg(unsigned regno, unsigned red, unsigned green, + unsigned blue, unsigned transp, + struct fb_info *info) +{ + if (info->var.grayscale) { + /* grayscale = 0.30*R + 0.59*G + 0.11*B */ + red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8; + } + + /* Truecolor has hardware independent palette */ + if (info->fix.visual == FB_VISUAL_TRUECOLOR) { + u32 *pal = info->pseudo_palette; + u32 v; + + if (regno >= 16) + return -EINVAL; + + v = chan_to_field(red, &info->var.red); + v |= chan_to_field(green, &info->var.green); + v |= chan_to_field(blue, &info->var.blue); + + pal[regno] = v; + } else { + if (regno >= 256) + return -EINVAL; + + lx_set_palette_reg(info, regno, red, green, blue); + } + + return 0; +} + +static int lxfb_blank(int blank_mode, struct fb_info *info) +{ + return lx_blank_display(info, blank_mode); +} + + +static int __init lxfb_map_video_memory(struct fb_info *info, + struct pci_dev *dev) +{ + struct lxfb_par *par = info->par; + int ret; + + ret = pci_enable_device(dev); + + if (ret) + return ret; + + ret = pci_request_region(dev, 0, "lxfb-framebuffer"); + + if (ret) + return ret; + + ret = pci_request_region(dev, 1, "lxfb-gp"); + + if (ret) + return ret; + + ret = pci_request_region(dev, 2, "lxfb-vg"); + + if (ret) + return ret; + + ret = pci_request_region(dev, 3, "lxfb-vip"); + + if (ret) + return ret; + + info->fix.smem_start = pci_resource_start(dev, 0); + info->fix.smem_len = fbsize ? fbsize : lx_framebuffer_size(); + + info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len); + + ret = -ENOMEM; + + if (info->screen_base == NULL) + return ret; + + par->gp_regs = ioremap(pci_resource_start(dev, 1), + pci_resource_len(dev, 1)); + + if (par->gp_regs == NULL) + return ret; + + par->dc_regs = ioremap(pci_resource_start(dev, 2), + pci_resource_len(dev, 2)); + + if (par->dc_regs == NULL) + return ret; + + par->df_regs = ioremap(pci_resource_start(dev, 3), + pci_resource_len(dev, 3)); + + if (par->df_regs == NULL) + return ret; + + writel(DC_UNLOCK_CODE, par->dc_regs + DC_UNLOCK); + + writel(info->fix.smem_start & 0xFF000000, + par->dc_regs + DC_PHY_MEM_OFFSET); + + writel(0, par->dc_regs + DC_UNLOCK); + + dev_info(&dev->dev, "%d KB of video memory at 0x%lx\n", + info->fix.smem_len / 1024, info->fix.smem_start); + + return 0; +} + +static struct fb_ops lxfb_ops = { + .owner = THIS_MODULE, + .fb_check_var = lxfb_check_var, + .fb_set_par = lxfb_set_par, + .fb_setcolreg = lxfb_setcolreg, + .fb_blank = lxfb_blank, + /* No HW acceleration for now. */ + .fb_fillrect = cfb_fillrect, + .fb_copyarea = cfb_copyarea, + .fb_imageblit = cfb_imageblit, +}; + +static struct fb_info * __init lxfb_init_fbinfo(struct device *dev) +{ + struct lxfb_par *par; + struct fb_info *info; + + /* Alloc enough space for the pseudo palette. */ + info = framebuffer_alloc(sizeof(struct lxfb_par) + sizeof(u32) * 16, + dev); + if (!info) + return NULL; + + par = info->par; + + strcpy(info->fix.id, "Geode LX"); + + info->fix.type = FB_TYPE_PACKED_PIXELS; + info->fix.type_aux = 0; + info->fix.xpanstep = 0; + info->fix.ypanstep = 0; + info->fix.ywrapstep = 0; + info->fix.accel = FB_ACCEL_NONE; + + info->var.nonstd = 0; + info->var.activate = FB_ACTIVATE_NOW; + info->var.height = -1; + info->var.width = -1; + info->var.accel_flags = 0; + info->var.vmode = FB_VMODE_NONINTERLACED; + + info->fbops = &lxfb_ops; + info->flags = FBINFO_DEFAULT; + info->node = -1; + + info->pseudo_palette = (void *)par + sizeof(struct lxfb_par); + + info->var.grayscale = 0; + + return info; +} + +static int __init lxfb_probe(struct pci_dev *pdev, + const struct pci_device_id *id) +{ + struct lxfb_par *par; + struct fb_info *info; + int ret; + + struct fb_videomode *modedb_ptr; + int modedb_size; + + info = lxfb_init_fbinfo(&pdev->dev); + + if (info == NULL) + return -ENOMEM; + + par = info->par; + + ret = lxfb_map_video_memory(info, pdev); + + if (ret < 0) { + dev_err(&pdev->dev, + "failed to map frame buffer or controller registers\n"); + goto err; + } + + /* Set up the desired outputs */ + + par->output = 0; + par->output |= (nopanel) ? 0 : OUTPUT_PANEL; + par->output |= (nocrt) ? 0 : OUTPUT_CRT; + + /* Set up the mode database */ + + modedb_ptr = (struct fb_videomode *) geode_modedb; + modedb_size = ARRAY_SIZE(geode_modedb); + + ret = fb_find_mode(&info->var, info, mode_option, + modedb_ptr, modedb_size, NULL, 16); + + if (ret == 0 || ret == 4) { + dev_err(&pdev->dev, "could not find valid video mode\n"); + ret = -EINVAL; + goto err; + } + + /* Clear the screen of garbage, unless noclear was specified, + * in which case we assume the user knows what he is doing */ + + if (!noclear) + memset_io(info->screen_base, 0, info->fix.smem_len); + + /* Set the mode */ + + lxfb_check_var(&info->var, info); + lxfb_set_par(info); + + if (register_framebuffer(info) < 0) { + ret = -EINVAL; + goto err; + } + pci_set_drvdata(pdev, info); + printk(KERN_INFO "fb%d: %s frame buffer device\n", + info->node, info->fix.id); + + return 0; + +err: + if (info->screen_base) { + iounmap(info->screen_base); + pci_release_region(pdev, 0); + } + if (par->gp_regs) { + iounmap(par->gp_regs); + pci_release_region(pdev, 1); + } + if (par->dc_regs) { + iounmap(par->dc_regs); + pci_release_region(pdev, 2); + } + if (par->df_regs) { + iounmap(par->df_regs); + pci_release_region(pdev, 3); + } + + if (info) + framebuffer_release(info); + + return ret; +} + +static void lxfb_remove(struct pci_dev *pdev) +{ + struct fb_info *info = pci_get_drvdata(pdev); + struct lxfb_par *par = info->par; + + unregister_framebuffer(info); + + iounmap(info->screen_base); + pci_release_region(pdev, 0); + + iounmap(par->gp_regs); + pci_release_region(pdev, 1); + + iounmap(par->dc_regs); + pci_release_region(pdev, 2); + + iounmap(par->df_regs); + pci_release_region(pdev, 3); + + pci_set_drvdata(pdev, NULL); + framebuffer_release(info); +} + +static struct pci_device_id lxfb_id_table[] = { + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LX_VIDEO) }, + { 0, } +}; + +MODULE_DEVICE_TABLE(pci, lxfb_id_table); + +static struct pci_driver lxfb_driver = { + .name = "lxfb", + .id_table = lxfb_id_table, + .probe = lxfb_probe, + .remove = lxfb_remove, +}; + +#ifndef MODULE +static int __init lxfb_setup(char *options) +{ + char *opt; + + if (!options || !*options) + return 0; + + while (1) { + char *opt = strsep(&options, ","); + + if (opt == NULL) + break; + + if (!*opt) + continue; + + if (!strncmp(opt, "fbsize:", 7)) + fbsize = simple_strtoul(opt+7, NULL, 0); + else if (!strcmp(opt, "noclear")) + noclear = 1; + else if (!strcmp(opt, "nopanel")) + nopanel = 1; + else if (!strcmp(opt, "nocrt")) + nocrt = 1; + else + mode_option = opt; + } + + return 0; +} +#endif + +static int __init lxfb_init(void) +{ +#ifndef MODULE + char *option = NULL; + + if (fb_get_options("lxfb", &option)) + return -ENODEV; + + lxfb_setup(option); +#endif + return pci_register_driver(&lxfb_driver); +} +static void __exit lxfb_cleanup(void) +{ + pci_unregister_driver(&lxfb_driver); +} + +module_init(lxfb_init); +module_exit(lxfb_cleanup); + +module_param(mode_option, charp, 0); +MODULE_PARM_DESC(mode_option, "video mode (<x>x<y>[-<bpp>][@<refr>])"); + +module_param(fbsize, int, 0); +MODULE_PARM_DESC(fbsize, "video memory size"); + +MODULE_DESCRIPTION("Framebuffer driver for the AMD Geode LX"); +MODULE_LICENSE("GPL"); diff --git a/drivers/video/geode/lxfb_ops.c b/drivers/video/geode/lxfb_ops.c new file mode 100644 index 00000000000..4fbc99be96e --- /dev/null +++ b/drivers/video/geode/lxfb_ops.c @@ -0,0 +1,536 @@ +/* Geode LX framebuffer driver + * + * Copyright (C) 2006-2007, Advanced Micro Devices,Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include <linux/kernel.h> +#include <linux/errno.h> +#include <linux/fb.h> +#include <linux/uaccess.h> +#include <linux/delay.h> + +#include "lxfb.h" + +/* TODO + * Support panel scaling + * Add acceleration + * Add support for interlacing (TV out) + * Support compression + */ + +/* This is the complete list of PLL frequencies that we can set - + * we will choose the closest match to the incoming clock. + * freq is the frequency of the dotclock * 1000 (for example, + * 24823 = 24.983 Mhz). + * pllval is the corresponding PLL value +*/ + +static const struct { + unsigned int pllval; + unsigned int freq; +} pll_table[] = { + { 0x000031AC, 24923 }, + { 0x0000215D, 25175 }, + { 0x00001087, 27000 }, + { 0x0000216C, 28322 }, + { 0x0000218D, 28560 }, + { 0x000010C9, 31200 }, + { 0x00003147, 31500 }, + { 0x000010A7, 33032 }, + { 0x00002159, 35112 }, + { 0x00004249, 35500 }, + { 0x00000057, 36000 }, + { 0x0000219A, 37889 }, + { 0x00002158, 39168 }, + { 0x00000045, 40000 }, + { 0x00000089, 43163 }, + { 0x000010E7, 44900 }, + { 0x00002136, 45720 }, + { 0x00003207, 49500 }, + { 0x00002187, 50000 }, + { 0x00004286, 56250 }, + { 0x000010E5, 60065 }, + { 0x00004214, 65000 }, + { 0x00001105, 68179 }, + { 0x000031E4, 74250 }, + { 0x00003183, 75000 }, + { 0x00004284, 78750 }, + { 0x00001104, 81600 }, + { 0x00006363, 94500 }, + { 0x00005303, 97520 }, + { 0x00002183, 100187 }, + { 0x00002122, 101420 }, + { 0x00001081, 108000 }, + { 0x00006201, 113310 }, + { 0x00000041, 119650 }, + { 0x000041A1, 129600 }, + { 0x00002182, 133500 }, + { 0x000041B1, 135000 }, + { 0x00000051, 144000 }, + { 0x000041E1, 148500 }, + { 0x000062D1, 157500 }, + { 0x000031A1, 162000 }, + { 0x00000061, 169203 }, + { 0x00004231, 172800 }, + { 0x00002151, 175500 }, + { 0x000052E1, 189000 }, + { 0x00000071, 192000 }, + { 0x00003201, 198000 }, + { 0x00004291, 202500 }, + { 0x00001101, 204750 }, + { 0x00007481, 218250 }, + { 0x00004170, 229500 }, + { 0x00006210, 234000 }, + { 0x00003140, 251182 }, + { 0x00006250, 261000 }, + { 0x000041C0, 278400 }, + { 0x00005220, 280640 }, + { 0x00000050, 288000 }, + { 0x000041E0, 297000 }, + { 0x00002130, 320207 } +}; + + +static void lx_set_dotpll(u32 pllval) +{ + u32 dotpll_lo, dotpll_hi; + int i; + + rdmsr(MSR_LX_GLCP_DOTPLL, dotpll_lo, dotpll_hi); + + if ((dotpll_lo & GLCP_DOTPLL_LOCK) && (dotpll_hi == pllval)) + return; + + dotpll_hi = pllval; + dotpll_lo &= ~(GLCP_DOTPLL_BYPASS | GLCP_DOTPLL_HALFPIX); + dotpll_lo |= GLCP_DOTPLL_RESET; + + wrmsr(MSR_LX_GLCP_DOTPLL, dotpll_lo, dotpll_hi); + + /* Wait 100us for the PLL to lock */ + + udelay(100); + + /* Now, loop for the lock bit */ + + for (i = 0; i < 1000; i++) { + rdmsr(MSR_LX_GLCP_DOTPLL, dotpll_lo, dotpll_hi); + if (dotpll_lo & GLCP_DOTPLL_LOCK) + break; + } + + /* Clear the reset bit */ + + dotpll_lo &= ~GLCP_DOTPLL_RESET; + wrmsr(MSR_LX_GLCP_DOTPLL, dotpll_lo, dotpll_hi); +} + +/* Set the clock based on the frequency specified by the current mode */ + +static void lx_set_clock(struct fb_info *info) +{ + unsigned int diff, min, best = 0; + unsigned int freq, i; + + freq = (unsigned int) (0x3b9aca00 / info->var.pixclock); + + min = abs(pll_table[0].freq - freq); + + for (i = 0; i < ARRAY_SIZE(pll_table); i++) { + diff = abs(pll_table[i].freq - freq); + if (diff < min) { + min = diff; + best = i; + } + } + + lx_set_dotpll(pll_table[best].pllval & 0x7FFF); +} + +static void lx_graphics_disable(struct fb_info *info) +{ + struct lxfb_par *par = info->par; + unsigned int val, gcfg; + + /* Note: This assumes that the video is in a quitet state */ + + writel(0, par->df_regs + DF_ALPHA_CONTROL_1); + writel(0, par->df_regs + DF_ALPHA_CONTROL_1 + 32); + writel(0, par->df_regs + DF_ALPHA_CONTROL_1 + 64); + + /* Turn off the VGA and video enable */ + val = readl (par->dc_regs + DC_GENERAL_CFG) & + ~(DC_GCFG_VGAE | DC_GCFG_VIDE); + + writel(val, par->dc_regs + DC_GENERAL_CFG); + + val = readl(par->df_regs + DF_VIDEO_CFG) & ~DF_VCFG_VID_EN; + writel(val, par->df_regs + DF_VIDEO_CFG); + + writel( DC_IRQ_MASK | DC_VSYNC_IRQ_MASK | + DC_IRQ_STATUS | DC_VSYNC_IRQ_STATUS, + par->dc_regs + DC_IRQ); + + val = readl(par->dc_regs + DC_GENLCK_CTRL) & ~DC_GENLCK_ENABLE; + writel(val, par->dc_regs + DC_GENLCK_CTRL); + + val = readl(par->dc_regs + DC_COLOR_KEY) & ~DC_CLR_KEY_ENABLE; + writel(val & ~DC_CLR_KEY_ENABLE, par->dc_regs + DC_COLOR_KEY); + + /* We don't actually blank the panel, due to the long latency + involved with bringing it back */ + + val = readl(par->df_regs + DF_MISC) | DF_MISC_DAC_PWRDN; + writel(val, par->df_regs + DF_MISC); + + /* Turn off the display */ + + val = readl(par->df_regs + DF_DISPLAY_CFG); + writel(val & ~(DF_DCFG_CRT_EN | DF_DCFG_HSYNC_EN | DF_DCFG_VSYNC_EN | + DF_DCFG_DAC_BL_EN), par->df_regs + DF_DISPLAY_CFG); + + gcfg = readl(par->dc_regs + DC_GENERAL_CFG); + gcfg &= ~(DC_GCFG_CMPE | DC_GCFG_DECE); + writel(gcfg, par->dc_regs + DC_GENERAL_CFG); + + /* Turn off the TGEN */ + val = readl(par->dc_regs + DC_DISPLAY_CFG); + val &= ~DC_DCFG_TGEN; + writel(val, par->dc_regs + DC_DISPLAY_CFG); + + /* Wait 1000 usecs to ensure that the TGEN is clear */ + udelay(1000); + + /* Turn off the FIFO loader */ + + gcfg &= ~DC_GCFG_DFLE; + writel(gcfg, par->dc_regs + DC_GENERAL_CFG); + + /* Lastly, wait for the GP to go idle */ + + do { + val = readl(par->gp_regs + GP_BLT_STATUS); + } while ((val & GP_BS_BLT_BUSY) || !(val & GP_BS_CB_EMPTY)); +} + +static void lx_graphics_enable(struct fb_info *info) +{ + struct lxfb_par *par = info->par; + u32 temp, config; + + /* Set the video request register */ + writel(0, par->df_regs + DF_VIDEO_REQUEST); + + /* Set up the polarities */ + + config = readl(par->df_regs + DF_DISPLAY_CFG); + + config &= ~(DF_DCFG_CRT_SYNC_SKW_MASK | DF_DCFG_PWR_SEQ_DLY_MASK | + DF_DCFG_CRT_HSYNC_POL | DF_DCFG_CRT_VSYNC_POL); + + config |= (DF_DCFG_CRT_SYNC_SKW_INIT | DF_DCFG_PWR_SEQ_DLY_INIT | + DF_DCFG_GV_PAL_BYP); + + if (info->var.sync & FB_SYNC_HOR_HIGH_ACT) + config |= DF_DCFG_CRT_HSYNC_POL; + + if (info->var.sync & FB_SYNC_VERT_HIGH_ACT) + config |= DF_DCFG_CRT_VSYNC_POL; + + if (par->output & OUTPUT_PANEL) { + u32 msrlo, msrhi; + + writel(DF_DEFAULT_TFT_PMTIM1, + par->df_regs + DF_PANEL_TIM1); + writel(DF_DEFAULT_TFT_PMTIM2, + par->df_regs + DF_PANEL_TIM2); + writel(DF_DEFAULT_TFT_DITHCTL, + par->df_regs + DF_DITHER_CONTROL); + + msrlo = DF_DEFAULT_TFT_PAD_SEL_LOW; + msrhi = DF_DEFAULT_TFT_PAD_SEL_HIGH; + + wrmsr(MSR_LX_DF_PADSEL, msrlo, msrhi); + } + + if (par->output & OUTPUT_CRT) { + config |= DF_DCFG_CRT_EN | DF_DCFG_HSYNC_EN | + DF_DCFG_VSYNC_EN | DF_DCFG_DAC_BL_EN; + } + + writel(config, par->df_regs + DF_DISPLAY_CFG); + + /* Turn the CRT dacs back on */ + + if (par->output & OUTPUT_CRT) { + temp = readl(par->df_regs + DF_MISC); + temp &= ~(DF_MISC_DAC_PWRDN | DF_MISC_A_PWRDN); + writel(temp, par->df_regs + DF_MISC); + } + + /* Turn the panel on (if it isn't already) */ + + if (par->output & OUTPUT_PANEL) { + temp = readl(par->df_regs + DF_FP_PM); + + if (!(temp & 0x09)) + writel(temp | DF_FP_PM_P, par->df_regs + DF_FP_PM); + } + + temp = readl(par->df_regs + DF_MISC); + temp = readl(par->df_regs + DF_DISPLAY_CFG); +} + +unsigned int lx_framebuffer_size(void) +{ + unsigned int val; + + /* The frame buffer size is reported by a VSM in VSA II */ + /* Virtual Register Class = 0x02 */ + /* VG_MEM_SIZE (1MB units) = 0x00 */ + + outw(0xFC53, 0xAC1C); + outw(0x0200, 0xAC1C); + + val = (unsigned int)(inw(0xAC1E)) & 0xFE; + return (val << 20); +} + +void lx_set_mode(struct fb_info *info) +{ + struct lxfb_par *par = info->par; + u64 msrval; + + unsigned int max, dv, val, size; + + unsigned int gcfg, dcfg; + int hactive, hblankstart, hsyncstart, hsyncend, hblankend, htotal; + int vactive, vblankstart, vsyncstart, vsyncend, vblankend, vtotal; + + /* Unlock the DC registers */ + writel(DC_UNLOCK_CODE, par->dc_regs + DC_UNLOCK); + + lx_graphics_disable(info); + + lx_set_clock(info); + + /* Set output mode */ + + rdmsrl(MSR_LX_DF_GLCONFIG, msrval); + msrval &= ~DF_CONFIG_OUTPUT_MASK; + + if (par->output & OUTPUT_PANEL) { + msrval |= DF_OUTPUT_PANEL; + + if (par->output & OUTPUT_CRT) + msrval |= DF_SIMULTANEOUS_CRT_AND_FP; + else + msrval &= ~DF_SIMULTANEOUS_CRT_AND_FP; + } else { + msrval |= DF_OUTPUT_CRT; + } + + wrmsrl(MSR_LX_DF_GLCONFIG, msrval); + + /* Clear the various buffers */ + /* FIXME: Adjust for panning here */ + + writel(0, par->dc_regs + DC_FB_START); + writel(0, par->dc_regs + DC_CB_START); + writel(0, par->dc_regs + DC_CURSOR_START); + + /* FIXME: Add support for interlacing */ + /* FIXME: Add support for scaling */ + + val = readl(par->dc_regs + DC_GENLCK_CTRL); + val &= ~(DC_GC_ALPHA_FLICK_ENABLE | + DC_GC_FLICKER_FILTER_ENABLE | DC_GC_FLICKER_FILTER_MASK); + + /* Default scaling params */ + + writel((0x4000 << 16) | 0x4000, par->dc_regs + DC_GFX_SCALE); + writel(0, par->dc_regs + DC_IRQ_FILT_CTL); + writel(val, par->dc_regs + DC_GENLCK_CTRL); + + /* FIXME: Support compression */ + + if (info->fix.line_length > 4096) + dv = DC_DV_LINE_SIZE_8192; + else if (info->fix.line_length > 2048) + dv = DC_DV_LINE_SIZE_4096; + else if (info->fix.line_length > 1024) + dv = DC_DV_LINE_SIZE_2048; + else + dv = DC_DV_LINE_SIZE_1024; + + max = info->fix.line_length * info->var.yres; + max = (max + 0x3FF) & 0xFFFFFC00; + + writel(max | DC_DV_TOP_ENABLE, par->dc_regs + DC_DV_TOP); + + val = readl(par->dc_regs + DC_DV_CTL) & ~DC_DV_LINE_SIZE_MASK; + writel(val | dv, par->dc_regs + DC_DV_CTL); + + size = info->var.xres * (info->var.bits_per_pixel >> 3); + + writel(info->fix.line_length >> 3, par->dc_regs + DC_GRAPHICS_PITCH); + writel((size + 7) >> 3, par->dc_regs + DC_LINE_SIZE); + + /* Set default watermark values */ + + rdmsrl(MSR_LX_DC_SPARE, msrval); + + msrval &= ~(DC_SPARE_DISABLE_CFIFO_HGO | DC_SPARE_VFIFO_ARB_SELECT | + DC_SPARE_LOAD_WM_LPEN_MASK | DC_SPARE_WM_LPEN_OVRD | + DC_SPARE_DISABLE_INIT_VID_PRI | DC_SPARE_DISABLE_VFIFO_WM); + msrval |= DC_SPARE_DISABLE_VFIFO_WM | DC_SPARE_DISABLE_INIT_VID_PRI; + wrmsrl(MSR_LX_DC_SPARE, msrval); + + gcfg = DC_GCFG_DFLE; /* Display fifo enable */ + gcfg |= 0xB600; /* Set default priority */ + gcfg |= DC_GCFG_FDTY; /* Set the frame dirty mode */ + + dcfg = DC_DCFG_VDEN; /* Enable video data */ + dcfg |= DC_DCFG_GDEN; /* Enable graphics */ + dcfg |= DC_DCFG_TGEN; /* Turn on the timing generator */ + dcfg |= DC_DCFG_TRUP; /* Update timings immediately */ + dcfg |= DC_DCFG_PALB; /* Palette bypass in > 8 bpp modes */ + dcfg |= DC_DCFG_VISL; + dcfg |= DC_DCFG_DCEN; /* Always center the display */ + + /* Set the current BPP mode */ + + switch (info->var.bits_per_pixel) { + case 8: + dcfg |= DC_DCFG_DISP_MODE_8BPP; + break; + + case 16: + dcfg |= DC_DCFG_DISP_MODE_16BPP | DC_DCFG_16BPP; + break; + + case 32: + case 24: + dcfg |= DC_DCFG_DISP_MODE_24BPP; + break; + } + + /* Now - set up the timings */ + + hactive = info->var.xres; + hblankstart = hactive; + hsyncstart = hblankstart + info->var.right_margin; + hsyncend = hsyncstart + info->var.hsync_len; + hblankend = hsyncend + info->var.left_margin; + htotal = hblankend; + + vactive = info->var.yres; + vblankstart = vactive; + vsyncstart = vblankstart + info->var.lower_margin; + vsyncend = vsyncstart + info->var.vsync_len; + vblankend = vsyncend + info->var.upper_margin; + vtotal = vblankend; + + writel((hactive - 1) | ((htotal - 1) << 16), + par->dc_regs + DC_H_ACTIVE_TIMING); + writel((hblankstart - 1) | ((hblankend - 1) << 16), + par->dc_regs + DC_H_BLANK_TIMING); + writel((hsyncstart - 1) | ((hsyncend - 1) << 16), + par->dc_regs + DC_H_SYNC_TIMING); + + writel((vactive - 1) | ((vtotal - 1) << 16), + par->dc_regs + DC_V_ACTIVE_TIMING); + + writel((vblankstart - 1) | ((vblankend - 1) << 16), + par->dc_regs + DC_V_BLANK_TIMING); + + writel((vsyncstart - 1) | ((vsyncend - 1) << 16), + par->dc_regs + DC_V_SYNC_TIMING); + + writel( (info->var.xres - 1) << 16 | (info->var.yres - 1), + par->dc_regs + DC_FB_ACTIVE); + + /* And re-enable the graphics output */ + lx_graphics_enable(info); + + /* Write the two main configuration registers */ + writel(dcfg, par->dc_regs + DC_DISPLAY_CFG); + writel(0, par->dc_regs + DC_ARB_CFG); + writel(gcfg, par->dc_regs + DC_GENERAL_CFG); + + /* Lock the DC registers */ + writel(0, par->dc_regs + DC_UNLOCK); +} + +void lx_set_palette_reg(struct fb_info *info, unsigned regno, + unsigned red, unsigned green, unsigned blue) +{ + struct lxfb_par *par = info->par; + int val; + + /* Hardware palette is in RGB 8-8-8 format. */ + + val = (red << 8) & 0xff0000; + val |= (green) & 0x00ff00; + val |= (blue >> 8) & 0x0000ff; + + writel(regno, par->dc_regs + DC_PAL_ADDRESS); + writel(val, par->dc_regs + DC_PAL_DATA); +} + +int lx_blank_display(struct fb_info *info, int blank_mode) +{ + struct lxfb_par *par = info->par; + u32 dcfg, fp_pm; + int blank, hsync, vsync; + + /* CRT power saving modes. */ + switch (blank_mode) { + case FB_BLANK_UNBLANK: + blank = 0; hsync = 1; vsync = 1; + break; + case FB_BLANK_NORMAL: + blank = 1; hsync = 1; vsync = 1; + break; + case FB_BLANK_VSYNC_SUSPEND: + blank = 1; hsync = 1; vsync = 0; + break; + case FB_BLANK_HSYNC_SUSPEND: + blank = 1; hsync = 0; vsync = 1; + break; + case FB_BLANK_POWERDOWN: + blank = 1; hsync = 0; vsync = 0; + break; + default: + return -EINVAL; + } + + dcfg = readl(par->df_regs + DF_DISPLAY_CFG); + dcfg &= ~(DF_DCFG_DAC_BL_EN + | DF_DCFG_HSYNC_EN | DF_DCFG_VSYNC_EN); + if (!blank) + dcfg |= DF_DCFG_DAC_BL_EN; + if (hsync) + dcfg |= DF_DCFG_HSYNC_EN; + if (vsync) + dcfg |= DF_DCFG_VSYNC_EN; + writel(dcfg, par->df_regs + DF_DISPLAY_CFG); + + /* Power on/off flat panel */ + + if (par->output & OUTPUT_PANEL) { + fp_pm = readl(par->df_regs + DF_FP_PM); + if (blank_mode == FB_BLANK_POWERDOWN) + fp_pm &= ~DF_FP_PM_P; + else + fp_pm |= DF_FP_PM_P; + writel(fp_pm, par->df_regs + DF_FP_PM); + } + + return 0; +} diff --git a/drivers/video/s3c2410fb.c b/drivers/video/s3c2410fb.c index ed3426062a8..8a4c6470d79 100644 --- a/drivers/video/s3c2410fb.c +++ b/drivers/video/s3c2410fb.c @@ -474,6 +474,7 @@ static void schedule_palette_update(struct s3c2410fb_info *fbi, { unsigned long flags; unsigned long irqen; + void __iomem *regs = fbi->io; local_irq_save(flags); @@ -483,9 +484,9 @@ static void schedule_palette_update(struct s3c2410fb_info *fbi, fbi->palette_ready = 1; /* enable IRQ */ - irqen = readl(S3C2410_LCDINTMSK); + irqen = readl(regs + S3C2410_LCDINTMSK); irqen &= ~S3C2410_LCDINT_FRSYNC; - writel(irqen, S3C2410_LCDINTMSK); + writel(irqen, regs + S3C2410_LCDINTMSK); } local_irq_restore(flags); @@ -680,6 +681,7 @@ static inline void modify_gpio(void __iomem *reg, static int s3c2410fb_init_registers(struct s3c2410fb_info *fbi) { unsigned long flags; + void __iomem *regs = fbi->io; /* Initialise LCD with values from haret */ @@ -694,25 +696,25 @@ static int s3c2410fb_init_registers(struct s3c2410fb_info *fbi) local_irq_restore(flags); - writel(fbi->regs.lcdcon1, S3C2410_LCDCON1); - writel(fbi->regs.lcdcon2, S3C2410_LCDCON2); - writel(fbi->regs.lcdcon3, S3C2410_LCDCON3); - writel(fbi->regs.lcdcon4, S3C2410_LCDCON4); - writel(fbi->regs.lcdcon5, S3C2410_LCDCON5); + writel(fbi->regs.lcdcon1, regs + S3C2410_LCDCON1); + writel(fbi->regs.lcdcon2, regs + S3C2410_LCDCON2); + writel(fbi->regs.lcdcon3, regs + S3C2410_LCDCON3); + writel(fbi->regs.lcdcon4, regs + S3C2410_LCDCON4); + writel(fbi->regs.lcdcon5, regs + S3C2410_LCDCON5); s3c2410fb_set_lcdaddr(fbi); dprintk("LPCSEL = 0x%08lx\n", mach_info->lpcsel); - writel(mach_info->lpcsel, S3C2410_LPCSEL); + writel(mach_info->lpcsel, regs + S3C2410_LPCSEL); - dprintk("replacing TPAL %08x\n", readl(S3C2410_TPAL)); + dprintk("replacing TPAL %08x\n", readl(regs + S3C2410_TPAL)); /* ensure temporary palette disabled */ - writel(0x00, S3C2410_TPAL); + writel(0x00, regs + S3C2410_TPAL); /* Enable video by setting the ENVID bit to 1 */ fbi->regs.lcdcon1 |= S3C2410_LCDCON1_ENVID; - writel(fbi->regs.lcdcon1, S3C2410_LCDCON1); + writel(fbi->regs.lcdcon1, regs + S3C2410_LCDCON1); return 0; } @@ -720,6 +722,7 @@ static void s3c2410fb_write_palette(struct s3c2410fb_info *fbi) { unsigned int i; unsigned long ent; + void __iomem *regs = fbi->io; fbi->palette_ready = 0; @@ -727,14 +730,14 @@ static void s3c2410fb_write_palette(struct s3c2410fb_info *fbi) if ((ent = fbi->palette_buffer[i]) == PALETTE_BUFF_CLEAR) continue; - writel(ent, S3C2410_TFTPAL(i)); + writel(ent, regs + S3C2410_TFTPAL(i)); /* it seems the only way to know exactly * if the palette wrote ok, is to check * to see if the value verifies ok */ - if (readw(S3C2410_TFTPAL(i)) == ent) + if (readw(regs + S3C2410_TFTPAL(i)) == ent) fbi->palette_buffer[i] = PALETTE_BUFF_CLEAR; else fbi->palette_ready = 1; /* retry */ @@ -744,14 +747,15 @@ static void s3c2410fb_write_palette(struct s3c2410fb_info *fbi) static irqreturn_t s3c2410fb_irq(int irq, void *dev_id) { struct s3c2410fb_info *fbi = dev_id; - unsigned long lcdirq = readl(S3C2410_LCDINTPND); + void __iomem *regs = fbi->io; + unsigned long lcdirq = readl(regs + S3C2410_LCDINTPND); if (lcdirq & S3C2410_LCDINT_FRSYNC) { if (fbi->palette_ready) s3c2410fb_write_palette(fbi); - writel(S3C2410_LCDINT_FRSYNC, S3C2410_LCDINTPND); - writel(S3C2410_LCDINT_FRSYNC, S3C2410_LCDSRCPND); + writel(S3C2410_LCDINT_FRSYNC, regs + S3C2410_LCDINTPND); + writel(S3C2410_LCDINT_FRSYNC, regs + S3C2410_LCDSRCPND); } return IRQ_HANDLED; @@ -764,9 +768,11 @@ static int __init s3c2410fb_probe(struct platform_device *pdev) struct s3c2410fb_info *info; struct fb_info *fbinfo; struct s3c2410fb_hw *mregs; + struct resource *res; int ret; int irq; int i; + int size; u32 lcdcon1; mach_info = pdev->dev.platform_data; @@ -788,11 +794,32 @@ static int __init s3c2410fb_probe(struct platform_device *pdev) return -ENOMEM; } - info = fbinfo->par; info->fb = fbinfo; info->dev = &pdev->dev; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (res == NULL) { + dev_err(&pdev->dev, "failed to get memory registersn"); + ret = -ENXIO; + goto dealloc_fb; + } + + size = (res->end - res->start)+1; + info->mem = request_mem_region(res->start, size, pdev->name); + if (info->mem == NULL) { + dev_err(&pdev->dev, "failed to get memory region\n"); + ret = -ENOENT; + goto dealloc_fb; + } + + info->io = ioremap(res->start, size); + if (info->io == NULL) { + dev_err(&pdev->dev, "ioremap() of registers failed\n"); + ret = -ENXIO; + goto release_mem; + } + platform_set_drvdata(pdev, fbinfo); dprintk("devinit\n"); @@ -803,8 +830,8 @@ static int __init s3c2410fb_probe(struct platform_device *pdev) /* Stop the video and unset ENVID if set */ info->regs.lcdcon1 &= ~S3C2410_LCDCON1_ENVID; - lcdcon1 = readl(S3C2410_LCDCON1); - writel(lcdcon1 & ~S3C2410_LCDCON1_ENVID, S3C2410_LCDCON1); + lcdcon1 = readl(info->io + S3C2410_LCDCON1); + writel(lcdcon1 & ~S3C2410_LCDCON1_ENVID, info->io + S3C2410_LCDCON1); info->mach_info = pdev->dev.platform_data; @@ -855,19 +882,11 @@ static int __init s3c2410fb_probe(struct platform_device *pdev) for (i = 0; i < 256; i++) info->palette_buffer[i] = PALETTE_BUFF_CLEAR; - if (!request_mem_region((unsigned long)S3C24XX_VA_LCD, SZ_1M, "s3c2410-lcd")) { - ret = -EBUSY; - goto dealloc_fb; - } - - - dprintk("got LCD region\n"); - ret = request_irq(irq, s3c2410fb_irq, IRQF_DISABLED, pdev->name, info); if (ret) { dev_err(&pdev->dev, "cannot get irq %d - err %d\n", irq, ret); ret = -EBUSY; - goto release_mem; + goto release_regs; } info->clk = clk_get(NULL, "lcd"); @@ -889,6 +908,7 @@ static int __init s3c2410fb_probe(struct platform_device *pdev) ret = -ENOMEM; goto release_clock; } + dprintk("got video memory\n"); ret = s3c2410fb_init_registers(info); @@ -916,8 +936,11 @@ release_clock: clk_put(info->clk); release_irq: free_irq(irq,info); +release_regs: + iounmap(info->io); release_mem: - release_mem_region((unsigned long)S3C24XX_VA_LCD, S3C24XX_SZ_LCD); + release_resource(info->mem); + kfree(info->mem); dealloc_fb: framebuffer_release(fbinfo); return ret; @@ -935,7 +958,7 @@ static void s3c2410fb_stop_lcd(struct s3c2410fb_info *fbi) local_irq_save(flags); fbi->regs.lcdcon1 &= ~S3C2410_LCDCON1_ENVID; - writel(fbi->regs.lcdcon1, S3C2410_LCDCON1); + writel(fbi->regs.lcdcon1, fbi->io + S3C2410_LCDCON1); local_irq_restore(flags); } @@ -962,7 +985,10 @@ static int s3c2410fb_remove(struct platform_device *pdev) irq = platform_get_irq(pdev, 0); free_irq(irq,info); - release_mem_region((unsigned long)S3C24XX_VA_LCD, S3C24XX_SZ_LCD); + + release_resource(info->mem); + kfree(info->mem); + iounmap(info->io); unregister_framebuffer(fbinfo); return 0; diff --git a/drivers/video/s3c2410fb.h b/drivers/video/s3c2410fb.h index f3f8a8e1501..17c7915b7ac 100644 --- a/drivers/video/s3c2410fb.h +++ b/drivers/video/s3c2410fb.h @@ -30,6 +30,9 @@ struct s3c2410fb_info { struct device *dev; struct clk *clk; + struct resource *mem; + void __iomem *io; + struct s3c2410fb_mach_info *mach_info; /* raw memory addresses */ diff --git a/drivers/video/tx3912fb.c b/drivers/video/tx3912fb.c deleted file mode 100644 index e6f7c78da68..00000000000 --- a/drivers/video/tx3912fb.c +++ /dev/null @@ -1,326 +0,0 @@ -/* - * drivers/video/tx3912fb.c - * - * Copyright (C) 1999 Harald Koerfgen - * Copyright (C) 2001 Steven Hill (sjhill@realitydiluted.com) - * - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file COPYING in the main directory of this archive for - * more details. - * - * Framebuffer for LCD controller in TMPR3912/05 and PR31700 processors - */ -#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/errno.h> -#include <linux/string.h> -#include <linux/delay.h> -#include <linux/interrupt.h> -#include <linux/init.h> -#include <linux/pm.h> -#include <linux/fb.h> -#include <asm/io.h> -#include <asm/bootinfo.h> -#include <asm/uaccess.h> -#include <asm/tx3912.h> -#include <video/tx3912.h> - -/* - * Frame buffer, palette and console structures - */ -static struct fb_info fb_info; -static u32 cfb8[16]; - -static struct fb_fix_screeninfo tx3912fb_fix __initdata = { - .id = "tx3912fb", - .smem_len = ((240 * 320)/2), - .type = FB_TYPE_PACKED_PIXELS, - .visual = FB_VISUAL_TRUECOLOR, - .xpanstep = 1, - .ypanstep = 1, - .ywrapstep = 1, - .accel = FB_ACCEL_NONE, -}; - -static struct fb_var_screeninfo tx3912fb_var = { - .xres = 240, - .yres = 320, - .xres_virtual = 240, - .yres_virtual = 320, - .bits_per_pixel =4, - .red = { 0, 4, 0 }, /* ??? */ - .green = { 0, 4, 0 }, - .blue = { 0, 4, 0 }, - .activate = FB_ACTIVATE_NOW, - .width = -1, - .height = -1, - .pixclock = 20000, - .left_margin = 64, - .right_margin = 64, - .upper_margin = 32, - .lower_margin = 32, - .hsync_len = 64, - .vsync_len = 2, - .vmode = FB_VMODE_NONINTERLACED, -}; - -/* - * Interface used by the world - */ -int tx3912fb_init(void); - -static int tx3912fb_setcolreg(u_int regno, u_int red, u_int green, - u_int blue, u_int transp, - struct fb_info *info); - -/* - * Macros - */ -#define get_line_length(xres_virtual, bpp) \ - (u_long) (((int) xres_virtual * (int) bpp + 7) >> 3) - -/* - * Frame buffer operations structure used by console driver - */ -static struct fb_ops tx3912fb_ops = { - .owner = THIS_MODULE, - .fb_setcolreg = tx3912fb_setcolreg, - .fb_fillrect = cfb_fillrect, - .fb_copyarea = cfb_copyarea, - .fb_imageblit = cfb_imageblit, -}; - -static int tx3912fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) -{ - /* - * Memory limit - */ - line_length = - get_line_length(var->xres_virtual, var->bits_per_pixel); - if ((line_length * var->yres_virtual) > info->fix.smem_len) - return -ENOMEM; - - return 0; -} - -static int tx3912fb_set_par(struct fb_info *info) -{ - u_long tx3912fb_paddr = 0; - - /* Disable the video logic */ - outl(inl(TX3912_VIDEO_CTRL1) & - ~(TX3912_VIDEO_CTRL1_ENVID | TX3912_VIDEO_CTRL1_DISPON), - TX3912_VIDEO_CTRL1); - udelay(200); - - /* Set start address for DMA transfer */ - outl(tx3912fb_paddr, TX3912_VIDEO_CTRL3); - - /* Set end address for DMA transfer */ - outl((tx3912fb_paddr + tx3912fb_fix.smem_len + 1), TX3912_VIDEO_CTRL4); - - /* Set the pixel depth */ - switch (info->var.bits_per_pixel) { - case 1: - /* Monochrome */ - outl(inl(TX3912_VIDEO_CTRL1) & - ~TX3912_VIDEO_CTRL1_BITSEL_MASK, TX3912_VIDEO_CTRL1); - info->fix.visual = FB_VISUAL_MONO10; - break; - case 4: - /* 4-bit gray */ - outl(inl(TX3912_VIDEO_CTRL1) & - ~TX3912_VIDEO_CTRL1_BITSEL_MASK, TX3912_VIDEO_CTRL1); - outl(inl(TX3912_VIDEO_CTRL1) | - TX3912_VIDEO_CTRL1_BITSEL_4BIT_GRAY, - TX3912_VIDEO_CTRL1); - info->fix.visual = FB_VISUAL_TRUECOLOR; - break; - case 8: - /* 8-bit color */ - outl(inl(TX3912_VIDEO_CTRL1) & - ~TX3912_VIDEO_CTRL1_BITSEL_MASK, TX3912_VIDEO_CTRL1); - outl(inl(TX3912_VIDEO_CTRL1) | - TX3912_VIDEO_CTRL1_BITSEL_8BIT_COLOR, - TX3912_VIDEO_CTRL1); - info->fix.visual = FB_VISUAL_TRUECOLOR; - break; - case 2: - default: - /* 2-bit gray */ - outl(inl(TX3912_VIDEO_CTRL1) & - ~TX3912_VIDEO_CTRL1_BITSEL_MASK, TX3912_VIDEO_CTRL1); - outl(inl(TX3912_VIDEO_CTRL1) | - TX3912_VIDEO_CTRL1_BITSEL_2BIT_GRAY, - TX3912_VIDEO_CTRL1); - info->fix.visual = FB_VISUAL_PSEUDOCOLOR; - break; - } - - /* Enable the video clock */ - outl(inl(TX3912_CLK_CTRL) | TX3912_CLK_CTRL_ENVIDCLK, - TX3912_CLK_CTRL); - - /* Unfreeze video logic and enable DF toggle */ - outl(inl(TX3912_VIDEO_CTRL1) & - ~(TX3912_VIDEO_CTRL1_ENFREEZEFRAME | - TX3912_VIDEO_CTRL1_DFMODE) - , TX3912_VIDEO_CTRL1); - udelay(200); - - /* Enable the video logic */ - outl(inl(TX3912_VIDEO_CTRL1) | - (TX3912_VIDEO_CTRL1_ENVID | TX3912_VIDEO_CTRL1_DISPON), - TX3912_VIDEO_CTRL1); - - info->fix.line_length = get_line_length(var->xres_virtual, - var->bits_per_pixel); -} - -/* - * Set a single color register - */ -static int tx3912fb_setcolreg(u_int regno, u_int red, u_int green, - u_int blue, u_int transp, - struct fb_info *info) -{ - if (regno > 255) - return 1; - - if (regno < 16) - ((u32 *)(info->pseudo_palette))[regno] = ((red & 0xe000) >> 8) - | ((green & 0xe000) >> 11) - | ((blue & 0xc000) >> 14); - return 0; -} - -int __init tx3912fb_setup(char *options); - -/* - * Initialization of the framebuffer - */ -int __init tx3912fb_init(void) -{ - u_long tx3912fb_paddr = 0; - int size = (info->var.bits_per_pixel == 8) ? 256 : 16; - char *option = NULL; - - if (fb_get_options("tx3912fb", &option)) - return -ENODEV; - tx3912fb_setup(option); - - /* Disable the video logic */ - outl(inl(TX3912_VIDEO_CTRL1) & - ~(TX3912_VIDEO_CTRL1_ENVID | TX3912_VIDEO_CTRL1_DISPON), - TX3912_VIDEO_CTRL1); - udelay(200); - - /* Set start address for DMA transfer */ - outl(tx3912fb_paddr, TX3912_VIDEO_CTRL3); - - /* Set end address for DMA transfer */ - outl((tx3912fb_paddr + tx3912fb_fix.smem_len + 1), TX3912_VIDEO_CTRL4); - - /* Set the pixel depth */ - switch (tx3912fb_var.bits_per_pixel) { - case 1: - /* Monochrome */ - outl(inl(TX3912_VIDEO_CTRL1) & - ~TX3912_VIDEO_CTRL1_BITSEL_MASK, TX3912_VIDEO_CTRL1); - tx3912fb_fix.visual = FB_VISUAL_MONO10; - break; - case 4: - /* 4-bit gray */ - outl(inl(TX3912_VIDEO_CTRL1) & - ~TX3912_VIDEO_CTRL1_BITSEL_MASK, TX3912_VIDEO_CTRL1); - outl(inl(TX3912_VIDEO_CTRL1) | - TX3912_VIDEO_CTRL1_BITSEL_4BIT_GRAY, - TX3912_VIDEO_CTRL1); - tx3912fb_fix.visual = FB_VISUAL_TRUECOLOR; - tx3912fb_fix.grayscale = 1; - break; - case 8: - /* 8-bit color */ - outl(inl(TX3912_VIDEO_CTRL1) & - ~TX3912_VIDEO_CTRL1_BITSEL_MASK, TX3912_VIDEO_CTRL1); - outl(inl(TX3912_VIDEO_CTRL1) | - TX3912_VIDEO_CTRL1_BITSEL_8BIT_COLOR, - TX3912_VIDEO_CTRL1); - tx3912fb_fix.visual = FB_VISUAL_TRUECOLOR; - break; - case 2: - default: - /* 2-bit gray */ - outl(inl(TX3912_VIDEO_CTRL1) & - ~TX3912_VIDEO_CTRL1_BITSEL_MASK, TX3912_VIDEO_CTRL1); - outl(inl(TX3912_VIDEO_CTRL1) | - TX3912_VIDEO_CTRL1_BITSEL_2BIT_GRAY, - TX3912_VIDEO_CTRL1); - tx3912fb_fix.visual = FB_VISUAL_PSEUDOCOLOR; - tx3912fb_fix.grayscale = 1; - break; - } - - /* Enable the video clock */ - outl(inl(TX3912_CLK_CTRL) | TX3912_CLK_CTRL_ENVIDCLK, - TX3912_CLK_CTRL); - - /* Unfreeze video logic and enable DF toggle */ - outl(inl(TX3912_VIDEO_CTRL1) & - ~(TX3912_VIDEO_CTRL1_ENFREEZEFRAME | TX3912_VIDEO_CTRL1_DFMODE), - TX3912_VIDEO_CTRL1); - udelay(200); - - /* Clear the framebuffer */ - memset((void *) tx3912fb_fix.smem_start, 0xff, tx3912fb_fix.smem_len); - udelay(200); - - /* Enable the video logic */ - outl(inl(TX3912_VIDEO_CTRL1) | - (TX3912_VIDEO_CTRL1_ENVID | TX3912_VIDEO_CTRL1_DISPON), - TX3912_VIDEO_CTRL1); - - /* - * Memory limit - */ - tx3912fb_fix.line_length = - get_line_length(tx3912fb_var.xres_virtual, tx3912fb_var.bits_per_pixel); - if ((tx3912fb_fix.line_length * tx3912fb_var.yres_virtual) > tx3912fb_fix.smem_len) - return -ENOMEM; - - fb_info.fbops = &tx3912fb_ops; - fb_info.var = tx3912fb_var; - fb_info.fix = tx3912fb_fix; - fb_info.pseudo_palette = cfb8; - fb_info.flags = FBINFO_DEFAULT; - - /* Clear the framebuffer */ - memset((void *) fb_info.fix.smem_start, 0xff, fb_info.fix.smem_len); - udelay(200); - - fb_alloc_cmap(&info->cmap, size, 0); - - if (register_framebuffer(&fb_info) < 0) - return -1; - - printk(KERN_INFO "fb%d: TX3912 frame buffer using %uKB.\n", - fb_info.node, (u_int) (fb_info.fix.smem_len >> 10)); - return 0; -} - -int __init tx3912fb_setup(char *options) -{ - char *this_opt; - - if (!options || !*options) - return 0; - - while ((this_opt = strsep(&options, ","))) { - if (!strncmp(options, "bpp:", 4)) - tx3912fb_var.bits_per_pixel = simple_strtoul(options+4, NULL, 0); - } - return 0; -} - -module_init(tx3912fb_init); -MODULE_LICENSE("GPL"); diff --git a/drivers/video/xilinxfb.c b/drivers/video/xilinxfb.c index 1d29a89a86b..6ef9733a18d 100644 --- a/drivers/video/xilinxfb.c +++ b/drivers/video/xilinxfb.c @@ -79,7 +79,7 @@ /* * Here are the default fb_fix_screeninfo and fb_var_screeninfo structures */ -static struct fb_fix_screeninfo xilinx_fb_fix __initdata = { +static struct fb_fix_screeninfo xilinx_fb_fix = { .id = "Xilinx", .type = FB_TYPE_PACKED_PIXELS, .visual = FB_VISUAL_TRUECOLOR, @@ -88,7 +88,7 @@ static struct fb_fix_screeninfo xilinx_fb_fix __initdata = { .accel = FB_ACCEL_NONE }; -static struct fb_var_screeninfo xilinx_fb_var __initdata = { +static struct fb_var_screeninfo xilinx_fb_var = { .xres = XRES, .yres = YRES, .xres_virtual = XRES_VIRTUAL, @@ -212,11 +212,6 @@ xilinxfb_drv_probe(struct device *dev) pdev = to_platform_device(dev); pdata = pdev->dev.platform_data; - if (pdata == NULL) { - printk(KERN_ERR "Couldn't find platform data.\n"); - return -EFAULT; - } - drvdata = kzalloc(sizeof(*drvdata), GFP_KERNEL); if (!drvdata) { printk(KERN_ERR "Couldn't allocate device private record\n"); @@ -258,11 +253,9 @@ xilinxfb_drv_probe(struct device *dev) xilinx_fb_out_be32(drvdata, REG_FB_ADDR, drvdata->fb_phys); /* Turn on the display */ - if (pdata->rotate_screen) { - drvdata->reg_ctrl_default = REG_CTRL_ENABLE | REG_CTRL_ROTATE; - } else { - drvdata->reg_ctrl_default = REG_CTRL_ENABLE; - } + drvdata->reg_ctrl_default = REG_CTRL_ENABLE; + if (pdata && pdata->rotate_screen) + drvdata->reg_ctrl_default |= REG_CTRL_ROTATE; xilinx_fb_out_be32(drvdata, REG_CTRL, drvdata->reg_ctrl_default); /* Fill struct fb_info */ @@ -281,8 +274,10 @@ xilinxfb_drv_probe(struct device *dev) } drvdata->info.flags = FBINFO_DEFAULT; - xilinx_fb_var.height = pdata->screen_height_mm; - xilinx_fb_var.width = pdata->screen_width_mm; + if (pdata) { + xilinx_fb_var.height = pdata->screen_height_mm; + xilinx_fb_var.width = pdata->screen_width_mm; + } drvdata->info.var = xilinx_fb_var; /* Register new frame buffer */ |