diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-17 00:20:36 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-17 00:20:36 +0200 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/m68k/mvme16x | |
download | linux-1da177e4c3f41524e886b7f1b8a0c1fc7321cac2.tar.xz linux-1da177e4c3f41524e886b7f1b8a0c1fc7321cac2.zip |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/m68k/mvme16x')
-rw-r--r-- | arch/m68k/mvme16x/16xints.c | 149 | ||||
-rw-r--r-- | arch/m68k/mvme16x/Makefile | 5 | ||||
-rw-r--r-- | arch/m68k/mvme16x/config.c | 286 | ||||
-rw-r--r-- | arch/m68k/mvme16x/mvme16x_ksyms.c | 6 | ||||
-rw-r--r-- | arch/m68k/mvme16x/rtc.c | 172 |
5 files changed, 618 insertions, 0 deletions
diff --git a/arch/m68k/mvme16x/16xints.c b/arch/m68k/mvme16x/16xints.c new file mode 100644 index 000000000000..793ef735b59c --- /dev/null +++ b/arch/m68k/mvme16x/16xints.c @@ -0,0 +1,149 @@ +/* + * arch/m68k/mvme16x/16xints.c + * + * Copyright (C) 1995 Richard Hirst [richard@sleepie.demon.co.uk] + * + * based on amiints.c -- Amiga Linux interrupt handling code + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file README.legal in the main directory of this archive + * for more details. + * + */ + +#include <linux/types.h> +#include <linux/kernel.h> +#include <linux/errno.h> +#include <linux/seq_file.h> + +#include <asm/system.h> +#include <asm/ptrace.h> +#include <asm/irq.h> + +static irqreturn_t mvme16x_defhand (int irq, void *dev_id, struct pt_regs *fp); + +/* + * This should ideally be 4 elements only, for speed. + */ + +static struct { + irqreturn_t (*handler)(int, void *, struct pt_regs *); + unsigned long flags; + void *dev_id; + const char *devname; + unsigned count; +} irq_tab[192]; + +/* + * void mvme16x_init_IRQ (void) + * + * Parameters: None + * + * Returns: Nothing + * + * This function is called during kernel startup to initialize + * the mvme16x IRQ handling routines. Should probably ensure + * that the base vectors for the VMEChip2 and PCCChip2 are valid. + */ + +void mvme16x_init_IRQ (void) +{ + int i; + + for (i = 0; i < 192; i++) { + irq_tab[i].handler = mvme16x_defhand; + irq_tab[i].flags = IRQ_FLG_STD; + irq_tab[i].dev_id = NULL; + irq_tab[i].devname = NULL; + irq_tab[i].count = 0; + } +} + +int mvme16x_request_irq(unsigned int irq, + irqreturn_t (*handler)(int, void *, struct pt_regs *), + unsigned long flags, const char *devname, void *dev_id) +{ + if (irq < 64 || irq > 255) { + printk("%s: Incorrect IRQ %d from %s\n", __FUNCTION__, irq, devname); + return -ENXIO; + } + + if (!(irq_tab[irq-64].flags & IRQ_FLG_STD)) { + if (irq_tab[irq-64].flags & IRQ_FLG_LOCK) { + printk("%s: IRQ %d from %s is not replaceable\n", + __FUNCTION__, irq, irq_tab[irq-64].devname); + return -EBUSY; + } + if (flags & IRQ_FLG_REPLACE) { + printk("%s: %s can't replace IRQ %d from %s\n", + __FUNCTION__, devname, irq, irq_tab[irq-64].devname); + return -EBUSY; + } + } + irq_tab[irq-64].handler = handler; + irq_tab[irq-64].flags = flags; + irq_tab[irq-64].dev_id = dev_id; + irq_tab[irq-64].devname = devname; + return 0; +} + +void mvme16x_free_irq(unsigned int irq, void *dev_id) +{ + if (irq < 64 || irq > 255) { + printk("%s: Incorrect IRQ %d\n", __FUNCTION__, irq); + return; + } + + if (irq_tab[irq-64].dev_id != dev_id) + printk("%s: Removing probably wrong IRQ %d from %s\n", + __FUNCTION__, irq, irq_tab[irq-64].devname); + + irq_tab[irq-64].handler = mvme16x_defhand; + irq_tab[irq-64].flags = IRQ_FLG_STD; + irq_tab[irq-64].dev_id = NULL; + irq_tab[irq-64].devname = NULL; +} + +irqreturn_t mvme16x_process_int (unsigned long vec, struct pt_regs *fp) +{ + if (vec < 64 || vec > 255) { + printk ("mvme16x_process_int: Illegal vector %ld", vec); + return IRQ_NONE; + } else { + irq_tab[vec-64].count++; + irq_tab[vec-64].handler(vec, irq_tab[vec-64].dev_id, fp); + return IRQ_HANDLED; + } +} + +int show_mvme16x_interrupts (struct seq_file *p, void *v) +{ + int i; + + for (i = 0; i < 192; i++) { + if (irq_tab[i].count) + seq_printf(p, "Vec 0x%02x: %8d %s\n", + i+64, irq_tab[i].count, + irq_tab[i].devname ? irq_tab[i].devname : "free"); + } + return 0; +} + + +static irqreturn_t mvme16x_defhand (int irq, void *dev_id, struct pt_regs *fp) +{ + printk ("Unknown interrupt 0x%02x\n", irq); + return IRQ_NONE; +} + + +void mvme16x_enable_irq (unsigned int irq) +{ +} + + +void mvme16x_disable_irq (unsigned int irq) +{ +} + + diff --git a/arch/m68k/mvme16x/Makefile b/arch/m68k/mvme16x/Makefile new file mode 100644 index 000000000000..5129f56b64a3 --- /dev/null +++ b/arch/m68k/mvme16x/Makefile @@ -0,0 +1,5 @@ +# +# Makefile for Linux arch/m68k/mvme16x source directory +# + +obj-y := config.o 16xints.o rtc.o mvme16x_ksyms.o diff --git a/arch/m68k/mvme16x/config.c b/arch/m68k/mvme16x/config.c new file mode 100644 index 000000000000..26ce81c1337d --- /dev/null +++ b/arch/m68k/mvme16x/config.c @@ -0,0 +1,286 @@ +/* + * arch/m68k/mvme16x/config.c + * + * Copyright (C) 1995 Richard Hirst [richard@sleepie.demon.co.uk] + * + * Based on: + * + * linux/amiga/config.c + * + * Copyright (C) 1993 Hamish Macdonald + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file README.legal in the main directory of this archive + * for more details. + */ + +#include <linux/types.h> +#include <linux/kernel.h> +#include <linux/mm.h> +#include <linux/tty.h> +#include <linux/console.h> +#include <linux/linkage.h> +#include <linux/init.h> +#include <linux/major.h> +#include <linux/genhd.h> +#include <linux/rtc.h> +#include <linux/interrupt.h> + +#include <asm/bootinfo.h> +#include <asm/system.h> +#include <asm/pgtable.h> +#include <asm/setup.h> +#include <asm/irq.h> +#include <asm/traps.h> +#include <asm/rtc.h> +#include <asm/machdep.h> +#include <asm/mvme16xhw.h> + +extern t_bdid mvme_bdid; + +static MK48T08ptr_t volatile rtc = (MK48T08ptr_t)MVME_RTC_BASE; + +extern irqreturn_t mvme16x_process_int (int level, struct pt_regs *regs); +extern void mvme16x_init_IRQ (void); +extern void mvme16x_free_irq (unsigned int, void *); +extern int show_mvme16x_interrupts (struct seq_file *, void *); +extern void mvme16x_enable_irq (unsigned int); +extern void mvme16x_disable_irq (unsigned int); +static void mvme16x_get_model(char *model); +static int mvme16x_get_hardware_list(char *buffer); +extern int mvme16x_request_irq(unsigned int irq, irqreturn_t (*handler)(int, void *, struct pt_regs *), unsigned long flags, const char *devname, void *dev_id); +extern void mvme16x_sched_init(irqreturn_t (*handler)(int, void *, struct pt_regs *)); +extern unsigned long mvme16x_gettimeoffset (void); +extern int mvme16x_hwclk (int, struct rtc_time *); +extern int mvme16x_set_clock_mmss (unsigned long); +extern void mvme16x_reset (void); +extern void mvme16x_waitbut(void); + +int bcd2int (unsigned char b); + +/* Save tick handler routine pointer, will point to do_timer() in + * kernel/sched.c, called via mvme16x_process_int() */ + +static irqreturn_t (*tick_handler)(int, void *, struct pt_regs *); + + +unsigned short mvme16x_config; + + +int mvme16x_parse_bootinfo(const struct bi_record *bi) +{ + if (bi->tag == BI_VME_TYPE || bi->tag == BI_VME_BRDINFO) + return 0; + else + return 1; +} + +void mvme16x_reset(void) +{ + printk ("\r\n\nCalled mvme16x_reset\r\n" + "\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r"); + /* The string of returns is to delay the reset until the whole + * message is output. Assert reset bit in GCSR */ + *(volatile char *)0xfff40107 = 0x80; +} + +static void mvme16x_get_model(char *model) +{ + p_bdid p = &mvme_bdid; + char suf[4]; + + suf[1] = p->brdsuffix[0]; + suf[2] = p->brdsuffix[1]; + suf[3] = '\0'; + suf[0] = suf[1] ? '-' : '\0'; + + sprintf(model, "Motorola MVME%x%s", p->brdno, suf); +} + + +static int mvme16x_get_hardware_list(char *buffer) +{ + p_bdid p = &mvme_bdid; + int len = 0; + + if (p->brdno == 0x0162 || p->brdno == 0x0172) + { + unsigned char rev = *(unsigned char *)MVME162_VERSION_REG; + + len += sprintf (buffer+len, "VMEchip2 %spresent\n", + rev & MVME16x_CONFIG_NO_VMECHIP2 ? "NOT " : ""); + len += sprintf (buffer+len, "SCSI interface %spresent\n", + rev & MVME16x_CONFIG_NO_SCSICHIP ? "NOT " : ""); + len += sprintf (buffer+len, "Ethernet i/f %spresent\n", + rev & MVME16x_CONFIG_NO_ETHERNET ? "NOT " : ""); + } + else + *buffer = '\0'; + + return (len); +} + + +#define pcc2chip ((volatile u_char *)0xfff42000) +#define PccSCCMICR 0x1d +#define PccSCCTICR 0x1e +#define PccSCCRICR 0x1f + +void __init config_mvme16x(void) +{ + p_bdid p = &mvme_bdid; + char id[40]; + + mach_max_dma_address = 0xffffffff; + mach_sched_init = mvme16x_sched_init; + mach_init_IRQ = mvme16x_init_IRQ; + mach_gettimeoffset = mvme16x_gettimeoffset; + mach_hwclk = mvme16x_hwclk; + mach_set_clock_mmss = mvme16x_set_clock_mmss; + mach_reset = mvme16x_reset; + mach_free_irq = mvme16x_free_irq; + mach_process_int = mvme16x_process_int; + mach_get_irq_list = show_mvme16x_interrupts; + mach_request_irq = mvme16x_request_irq; + enable_irq = mvme16x_enable_irq; + disable_irq = mvme16x_disable_irq; + mach_get_model = mvme16x_get_model; + mach_get_hardware_list = mvme16x_get_hardware_list; + + /* Report board revision */ + + if (strncmp("BDID", p->bdid, 4)) + { + printk ("\n\nBug call .BRD_ID returned garbage - giving up\n\n"); + while (1) + ; + } + /* Board type is only set by newer versions of vmelilo/tftplilo */ + if (vme_brdtype == 0) + vme_brdtype = p->brdno; + + mvme16x_get_model(id); + printk ("\nBRD_ID: %s BUG %x.%x %02x/%02x/%02x\n", id, p->rev>>4, + p->rev&0xf, p->yr, p->mth, p->day); + if (p->brdno == 0x0162 || p->brdno == 0x172) + { + unsigned char rev = *(unsigned char *)MVME162_VERSION_REG; + + mvme16x_config = rev | MVME16x_CONFIG_GOT_SCCA; + + printk ("MVME%x Hardware status:\n", p->brdno); + printk (" CPU Type 68%s040\n", + rev & MVME16x_CONFIG_GOT_FPU ? "" : "LC"); + printk (" CPU clock %dMHz\n", + rev & MVME16x_CONFIG_SPEED_32 ? 32 : 25); + printk (" VMEchip2 %spresent\n", + rev & MVME16x_CONFIG_NO_VMECHIP2 ? "NOT " : ""); + printk (" SCSI interface %spresent\n", + rev & MVME16x_CONFIG_NO_SCSICHIP ? "NOT " : ""); + printk (" Ethernet interface %spresent\n", + rev & MVME16x_CONFIG_NO_ETHERNET ? "NOT " : ""); + } + else + { + mvme16x_config = MVME16x_CONFIG_GOT_LP | MVME16x_CONFIG_GOT_CD2401; + + /* Dont allow any interrupts from the CD2401 until the interrupt */ + /* handlers are installed */ + + pcc2chip[PccSCCMICR] = 0x10; + pcc2chip[PccSCCTICR] = 0x10; + pcc2chip[PccSCCRICR] = 0x10; + } +} + +static irqreturn_t mvme16x_abort_int (int irq, void *dev_id, struct pt_regs *fp) +{ + p_bdid p = &mvme_bdid; + unsigned long *new = (unsigned long *)vectors; + unsigned long *old = (unsigned long *)0xffe00000; + volatile unsigned char uc, *ucp; + + if (p->brdno == 0x0162 || p->brdno == 0x172) + { + ucp = (volatile unsigned char *)0xfff42043; + uc = *ucp | 8; + *ucp = uc; + } + else + { + *(volatile unsigned long *)0xfff40074 = 0x40000000; + } + *(new+4) = *(old+4); /* Illegal instruction */ + *(new+9) = *(old+9); /* Trace */ + *(new+47) = *(old+47); /* Trap #15 */ + + if (p->brdno == 0x0162 || p->brdno == 0x172) + *(new+0x5e) = *(old+0x5e); /* ABORT switch */ + else + *(new+0x6e) = *(old+0x6e); /* ABORT switch */ + return IRQ_HANDLED; +} + +static irqreturn_t mvme16x_timer_int (int irq, void *dev_id, struct pt_regs *fp) +{ + *(volatile unsigned char *)0xfff4201b |= 8; + return tick_handler(irq, dev_id, fp); +} + +void mvme16x_sched_init (irqreturn_t (*timer_routine)(int, void *, struct pt_regs *)) +{ + p_bdid p = &mvme_bdid; + int irq; + + tick_handler = timer_routine; + /* Using PCCchip2 or MC2 chip tick timer 1 */ + *(volatile unsigned long *)0xfff42008 = 0; + *(volatile unsigned long *)0xfff42004 = 10000; /* 10ms */ + *(volatile unsigned char *)0xfff42017 |= 3; + *(volatile unsigned char *)0xfff4201b = 0x16; + if (request_irq(MVME16x_IRQ_TIMER, mvme16x_timer_int, 0, + "timer", mvme16x_timer_int)) + panic ("Couldn't register timer int"); + + if (p->brdno == 0x0162 || p->brdno == 0x172) + irq = MVME162_IRQ_ABORT; + else + irq = MVME167_IRQ_ABORT; + if (request_irq(irq, mvme16x_abort_int, 0, + "abort", mvme16x_abort_int)) + panic ("Couldn't register abort int"); +} + + +/* This is always executed with interrupts disabled. */ +unsigned long mvme16x_gettimeoffset (void) +{ + return (*(volatile unsigned long *)0xfff42008); +} + +int bcd2int (unsigned char b) +{ + return ((b>>4)*10 + (b&15)); +} + +int mvme16x_hwclk(int op, struct rtc_time *t) +{ +#warning check me! + if (!op) { + rtc->ctrl = RTC_READ; + t->tm_year = bcd2int (rtc->bcd_year); + t->tm_mon = bcd2int (rtc->bcd_mth); + t->tm_mday = bcd2int (rtc->bcd_dom); + t->tm_hour = bcd2int (rtc->bcd_hr); + t->tm_min = bcd2int (rtc->bcd_min); + t->tm_sec = bcd2int (rtc->bcd_sec); + rtc->ctrl = 0; + } + return 0; +} + +int mvme16x_set_clock_mmss (unsigned long nowtime) +{ + return 0; +} + diff --git a/arch/m68k/mvme16x/mvme16x_ksyms.c b/arch/m68k/mvme16x/mvme16x_ksyms.c new file mode 100644 index 000000000000..4a8a3634bb47 --- /dev/null +++ b/arch/m68k/mvme16x/mvme16x_ksyms.c @@ -0,0 +1,6 @@ +#include <linux/module.h> +#include <linux/types.h> +#include <asm/ptrace.h> +#include <asm/mvme16xhw.h> + +EXPORT_SYMBOL(mvme16x_config); diff --git a/arch/m68k/mvme16x/rtc.c b/arch/m68k/mvme16x/rtc.c new file mode 100644 index 000000000000..8a2425069088 --- /dev/null +++ b/arch/m68k/mvme16x/rtc.c @@ -0,0 +1,172 @@ +/* + * Real Time Clock interface for Linux on the MVME16x + * + * Based on the PC driver by Paul Gortmaker. + */ + +#define RTC_VERSION "1.00" + +#include <linux/types.h> +#include <linux/errno.h> +#include <linux/miscdevice.h> +#include <linux/slab.h> +#include <linux/ioport.h> +#include <linux/fcntl.h> +#include <linux/init.h> +#include <linux/poll.h> +#include <linux/mc146818rtc.h> /* For struct rtc_time and ioctls, etc */ +#include <linux/smp_lock.h> +#include <asm/mvme16xhw.h> + +#include <asm/io.h> +#include <asm/uaccess.h> +#include <asm/system.h> +#include <asm/setup.h> + +/* + * We sponge a minor off of the misc major. No need slurping + * up another valuable major dev number for this. If you add + * an ioctl, make sure you don't conflict with SPARC's RTC + * ioctls. + */ + +#define BCD2BIN(val) (((val)&15) + ((val)>>4)*10) +#define BIN2BCD(val) ((((val)/10)<<4) + (val)%10) + +static const unsigned char days_in_mo[] = +{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + +static atomic_t rtc_ready = ATOMIC_INIT(1); + +static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, + unsigned long arg) +{ + volatile MK48T08ptr_t rtc = (MK48T08ptr_t)MVME_RTC_BASE; + unsigned long flags; + struct rtc_time wtime; + + switch (cmd) { + case RTC_RD_TIME: /* Read the time/date from RTC */ + { + local_irq_save(flags); + /* Ensure clock and real-time-mode-register are accessible */ + rtc->ctrl = RTC_READ; + memset(&wtime, 0, sizeof(struct rtc_time)); + wtime.tm_sec = BCD2BIN(rtc->bcd_sec); + wtime.tm_min = BCD2BIN(rtc->bcd_min); + wtime.tm_hour = BCD2BIN(rtc->bcd_hr); + wtime.tm_mday = BCD2BIN(rtc->bcd_dom); + wtime.tm_mon = BCD2BIN(rtc->bcd_mth)-1; + wtime.tm_year = BCD2BIN(rtc->bcd_year); + if (wtime.tm_year < 70) + wtime.tm_year += 100; + wtime.tm_wday = BCD2BIN(rtc->bcd_dow)-1; + rtc->ctrl = 0; + local_irq_restore(flags); + return copy_to_user((void *)arg, &wtime, sizeof wtime) ? + -EFAULT : 0; + } + case RTC_SET_TIME: /* Set the RTC */ + { + struct rtc_time rtc_tm; + unsigned char mon, day, hrs, min, sec, leap_yr; + unsigned int yrs; + + if (!capable(CAP_SYS_ADMIN)) + return -EACCES; + + if (copy_from_user(&rtc_tm, (struct rtc_time*)arg, + sizeof(struct rtc_time))) + return -EFAULT; + + yrs = rtc_tm.tm_year; + if (yrs < 1900) + yrs += 1900; + mon = rtc_tm.tm_mon + 1; /* tm_mon starts at zero */ + day = rtc_tm.tm_mday; + hrs = rtc_tm.tm_hour; + min = rtc_tm.tm_min; + sec = rtc_tm.tm_sec; + + leap_yr = ((!(yrs % 4) && (yrs % 100)) || !(yrs % 400)); + + if ((mon > 12) || (day == 0)) + return -EINVAL; + + if (day > (days_in_mo[mon] + ((mon == 2) && leap_yr))) + return -EINVAL; + + if ((hrs >= 24) || (min >= 60) || (sec >= 60)) + return -EINVAL; + + if (yrs >= 2070) + return -EINVAL; + + local_irq_save(flags); + rtc->ctrl = RTC_WRITE; + + rtc->bcd_sec = BIN2BCD(sec); + rtc->bcd_min = BIN2BCD(min); + rtc->bcd_hr = BIN2BCD(hrs); + rtc->bcd_dom = BIN2BCD(day); + rtc->bcd_mth = BIN2BCD(mon); + rtc->bcd_year = BIN2BCD(yrs%100); + + rtc->ctrl = 0; + local_irq_restore(flags); + return 0; + } + default: + return -EINVAL; + } +} + +/* + * We enforce only one user at a time here with the open/close. + * Also clear the previous interrupt data on an open, and clean + * up things on a close. + */ + +static int rtc_open(struct inode *inode, struct file *file) +{ + if( !atomic_dec_and_test(&rtc_ready) ) + { + atomic_inc( &rtc_ready ); + return -EBUSY; + } + + return 0; +} + +static int rtc_release(struct inode *inode, struct file *file) +{ + atomic_inc( &rtc_ready ); + return 0; +} + +/* + * The various file operations we support. + */ + +static struct file_operations rtc_fops = { + .ioctl = rtc_ioctl, + .open = rtc_open, + .release = rtc_release, +}; + +static struct miscdevice rtc_dev= +{ + .minor = RTC_MINOR, + .name = "rtc", + .fops = &rtc_fops +}; + +int __init rtc_MK48T08_init(void) +{ + if (!MACH_IS_MVME16x) + return -ENODEV; + + printk(KERN_INFO "MK48T08 Real Time Clock Driver v%s\n", RTC_VERSION); + return misc_register(&rtc_dev); +} + |