]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
Merge branches 'acorn', 'ebsa110' and 'sa11x0' into platforms
authorRussell King <rmk+kernel@arm.linux.org.uk>
Sun, 25 Mar 2012 22:57:55 +0000 (23:57 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Sun, 25 Mar 2012 22:57:55 +0000 (23:57 +0100)
22 files changed:
arch/arm/Kconfig
arch/arm/common/Kconfig
arch/arm/common/Makefile
arch/arm/common/time-acorn.c [deleted file]
arch/arm/kernel/Makefile
arch/arm/kernel/ecard.c [deleted file]
arch/arm/kernel/ecard.h [deleted file]
arch/arm/mach-ebsa110/core.c
arch/arm/mach-ebsa110/core.h [new file with mode: 0644]
arch/arm/mach-ebsa110/include/mach/hardware.h
arch/arm/mach-ebsa110/io.c
arch/arm/mach-ebsa110/leds.c
arch/arm/mach-rpc/Makefile
arch/arm/mach-rpc/ecard.c [new file with mode: 0644]
arch/arm/mach-rpc/ecard.h [new file with mode: 0644]
arch/arm/mach-rpc/include/mach/irqs.h
arch/arm/mach-rpc/riscpc.c
arch/arm/mach-rpc/time.c [new file with mode: 0644]
drivers/input/serio/rpckbd.c
drivers/scsi/arm/arxescsi.c
drivers/scsi/arm/fas216.c
drivers/scsi/arm/fas216.h

index 34aed718faed9348f6d5e264169de83405b9e652..4ade2d83734e03364a4228ec7215d5303e244317 100644 (file)
@@ -731,7 +731,6 @@ config ARCH_RPC
        bool "RiscPC"
        select ARCH_ACORN
        select FIQ
-       select TIMER_ACORN
        select ARCH_MAY_HAVE_PC_FDC
        select HAVE_PATA_PLATFORM
        select ISA_DMA_API
index 81a933eb0903bf446c4722bd645aa2ec0573bf47..3bb1d7589bd9ec52a864487145cd88a428296253 100644 (file)
@@ -35,9 +35,6 @@ config DMABOUNCE
        bool
        select ZONE_DMA
 
-config TIMER_ACORN
-       bool
-
 config SHARP_LOCOMO
        bool
 
index 6ea9b6f3607af35121e2e117e1580b1d841b520d..69feafe7286c152f8eed73b998f2fe2e70347de9 100644 (file)
@@ -9,7 +9,6 @@ obj-$(CONFIG_PL330)             += pl330.o
 obj-$(CONFIG_SA1111)           += sa1111.o
 obj-$(CONFIG_PCI_HOST_VIA82C505) += via82c505.o
 obj-$(CONFIG_DMABOUNCE)                += dmabounce.o
-obj-$(CONFIG_TIMER_ACORN)      += time-acorn.o
 obj-$(CONFIG_SHARP_LOCOMO)     += locomo.o
 obj-$(CONFIG_SHARP_PARAM)      += sharpsl_param.o
 obj-$(CONFIG_SHARP_SCOOP)      += scoop.o
diff --git a/arch/arm/common/time-acorn.c b/arch/arm/common/time-acorn.c
deleted file mode 100644 (file)
index deeed56..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- *  linux/arch/arm/common/time-acorn.c
- *
- *  Copyright (c) 1996-2000 Russell King.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- *  Changelog:
- *   24-Sep-1996       RMK     Created
- *   10-Oct-1996       RMK     Brought up to date with arch-sa110eval
- *   04-Dec-1997       RMK     Updated for new arch/arm/time.c
- *   13=Jun-2004       DS      Moved to arch/arm/common b/c shared w/CLPS7500
- */
-#include <linux/timex.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/irq.h>
-#include <linux/io.h>
-
-#include <mach/hardware.h>
-#include <asm/hardware/ioc.h>
-
-#include <asm/mach/time.h>
-
-unsigned long ioc_timer_gettimeoffset(void)
-{
-       unsigned int count1, count2, status;
-       long offset;
-
-       ioc_writeb (0, IOC_T0LATCH);
-       barrier ();
-       count1 = ioc_readb(IOC_T0CNTL) | (ioc_readb(IOC_T0CNTH) << 8);
-       barrier ();
-       status = ioc_readb(IOC_IRQREQA);
-       barrier ();
-       ioc_writeb (0, IOC_T0LATCH);
-       barrier ();
-       count2 = ioc_readb(IOC_T0CNTL) | (ioc_readb(IOC_T0CNTH) << 8);
-
-       offset = count2;
-       if (count2 < count1) {
-               /*
-                * We have not had an interrupt between reading count1
-                * and count2.
-                */
-               if (status & (1 << 5))
-                       offset -= LATCH;
-       } else if (count2 > count1) {
-               /*
-                * We have just had another interrupt between reading
-                * count1 and count2.
-                */
-               offset -= LATCH;
-       }
-
-       offset = (LATCH - offset) * (tick_nsec / 1000);
-       return (offset + LATCH/2) / LATCH;
-}
-
-void __init ioctime_init(void)
-{
-       ioc_writeb(LATCH & 255, IOC_T0LTCHL);
-       ioc_writeb(LATCH >> 8, IOC_T0LTCHH);
-       ioc_writeb(0, IOC_T0GO);
-}
-
-static irqreturn_t
-ioc_timer_interrupt(int irq, void *dev_id)
-{
-       timer_tick();
-       return IRQ_HANDLED;
-}
-
-static struct irqaction ioc_timer_irq = {
-       .name           = "timer",
-       .flags          = IRQF_DISABLED,
-       .handler        = ioc_timer_interrupt
-};
-
-/*
- * Set up timer interrupt.
- */
-static void __init ioc_timer_init(void)
-{
-       ioctime_init();
-       setup_irq(IRQ_TIMER, &ioc_timer_irq);
-}
-
-struct sys_timer ioc_timer = {
-       .init           = ioc_timer_init,
-       .offset         = ioc_timer_gettimeoffset,
-};
-
index 43b740d0e3744ab65b3c6036f342d734753b97de..17663c63f7a1de95fd7462ded2c0f505828f7761 100644 (file)
@@ -23,7 +23,6 @@ obj-$(CONFIG_LEDS)            += leds.o
 obj-$(CONFIG_OC_ETM)           += etm.o
 
 obj-$(CONFIG_ISA_DMA_API)      += dma.o
-obj-$(CONFIG_ARCH_ACORN)       += ecard.o 
 obj-$(CONFIG_FIQ)              += fiq.o fiqasm.o
 obj-$(CONFIG_MODULES)          += armksyms.o module.o
 obj-$(CONFIG_ARTHUR)           += arthur.o
diff --git a/arch/arm/kernel/ecard.c b/arch/arm/kernel/ecard.c
deleted file mode 100644 (file)
index 4dd0eda..0000000
+++ /dev/null
@@ -1,1231 +0,0 @@
-/*
- *  linux/arch/arm/kernel/ecard.c
- *
- *  Copyright 1995-2001 Russell King
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- *  Find all installed expansion cards, and handle interrupts from them.
- *
- *  Created from information from Acorns RiscOS3 PRMs
- *
- *  08-Dec-1996        RMK     Added code for the 9'th expansion card - the ether
- *                     podule slot.
- *  06-May-1997        RMK     Added blacklist for cards whose loader doesn't work.
- *  12-Sep-1997        RMK     Created new handling of interrupt enables/disables
- *                     - cards can now register their own routine to control
- *                     interrupts (recommended).
- *  29-Sep-1997        RMK     Expansion card interrupt hardware not being re-enabled
- *                     on reset from Linux. (Caused cards not to respond
- *                     under RiscOS without hard reset).
- *  15-Feb-1998        RMK     Added DMA support
- *  12-Sep-1998        RMK     Added EASI support
- *  10-Jan-1999        RMK     Run loaders in a simulated RISC OS environment.
- *  17-Apr-1999        RMK     Support for EASI Type C cycles.
- */
-#define ECARD_C
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/sched.h>
-#include <linux/interrupt.h>
-#include <linux/completion.h>
-#include <linux/reboot.h>
-#include <linux/mm.h>
-#include <linux/slab.h>
-#include <linux/proc_fs.h>
-#include <linux/seq_file.h>
-#include <linux/device.h>
-#include <linux/init.h>
-#include <linux/mutex.h>
-#include <linux/kthread.h>
-#include <linux/io.h>
-
-#include <asm/dma.h>
-#include <asm/ecard.h>
-#include <mach/hardware.h>
-#include <asm/irq.h>
-#include <asm/mmu_context.h>
-#include <asm/mach/irq.h>
-#include <asm/tlbflush.h>
-
-#include "ecard.h"
-
-#ifndef CONFIG_ARCH_RPC
-#define HAVE_EXPMASK
-#endif
-
-struct ecard_request {
-       void            (*fn)(struct ecard_request *);
-       ecard_t         *ec;
-       unsigned int    address;
-       unsigned int    length;
-       unsigned int    use_loader;
-       void            *buffer;
-       struct completion *complete;
-};
-
-struct expcard_blacklist {
-       unsigned short   manufacturer;
-       unsigned short   product;
-       const char      *type;
-};
-
-static ecard_t *cards;
-static ecard_t *slot_to_expcard[MAX_ECARDS];
-static unsigned int ectcr;
-#ifdef HAS_EXPMASK
-static unsigned int have_expmask;
-#endif
-
-/* List of descriptions of cards which don't have an extended
- * identification, or chunk directories containing a description.
- */
-static struct expcard_blacklist __initdata blacklist[] = {
-       { MANU_ACORN, PROD_ACORN_ETHER1, "Acorn Ether1" }
-};
-
-asmlinkage extern int
-ecard_loader_reset(unsigned long base, loader_t loader);
-asmlinkage extern int
-ecard_loader_read(int off, unsigned long base, loader_t loader);
-
-static inline unsigned short ecard_getu16(unsigned char *v)
-{
-       return v[0] | v[1] << 8;
-}
-
-static inline signed long ecard_gets24(unsigned char *v)
-{
-       return v[0] | v[1] << 8 | v[2] << 16 | ((v[2] & 0x80) ? 0xff000000 : 0);
-}
-
-static inline ecard_t *slot_to_ecard(unsigned int slot)
-{
-       return slot < MAX_ECARDS ? slot_to_expcard[slot] : NULL;
-}
-
-/* ===================== Expansion card daemon ======================== */
-/*
- * Since the loader programs on the expansion cards need to be run
- * in a specific environment, create a separate task with this
- * environment up, and pass requests to this task as and when we
- * need to.
- *
- * This should allow 99% of loaders to be called from Linux.
- *
- * From a security standpoint, we trust the card vendors.  This
- * may be a misplaced trust.
- */
-static void ecard_task_reset(struct ecard_request *req)
-{
-       struct expansion_card *ec = req->ec;
-       struct resource *res;
-
-       res = ec->slot_no == 8
-               ? &ec->resource[ECARD_RES_MEMC]
-               : ec->easi
-                 ? &ec->resource[ECARD_RES_EASI]
-                 : &ec->resource[ECARD_RES_IOCSYNC];
-
-       ecard_loader_reset(res->start, ec->loader);
-}
-
-static void ecard_task_readbytes(struct ecard_request *req)
-{
-       struct expansion_card *ec = req->ec;
-       unsigned char *buf = req->buffer;
-       unsigned int len = req->length;
-       unsigned int off = req->address;
-
-       if (ec->slot_no == 8) {
-               void __iomem *base = (void __iomem *)
-                               ec->resource[ECARD_RES_MEMC].start;
-
-               /*
-                * The card maintains an index which increments the address
-                * into a 4096-byte page on each access.  We need to keep
-                * track of the counter.
-                */
-               static unsigned int index;
-               unsigned int page;
-
-               page = (off >> 12) * 4;
-               if (page > 256 * 4)
-                       return;
-
-               off &= 4095;
-
-               /*
-                * If we are reading offset 0, or our current index is
-                * greater than the offset, reset the hardware index counter.
-                */
-               if (off == 0 || index > off) {
-                       writeb(0, base);
-                       index = 0;
-               }
-
-               /*
-                * Increment the hardware index counter until we get to the
-                * required offset.  The read bytes are discarded.
-                */
-               while (index < off) {
-                       readb(base + page);
-                       index += 1;
-               }
-
-               while (len--) {
-                       *buf++ = readb(base + page);
-                       index += 1;
-               }
-       } else {
-               unsigned long base = (ec->easi
-                        ? &ec->resource[ECARD_RES_EASI]
-                        : &ec->resource[ECARD_RES_IOCSYNC])->start;
-               void __iomem *pbase = (void __iomem *)base;
-
-               if (!req->use_loader || !ec->loader) {
-                       off *= 4;
-                       while (len--) {
-                               *buf++ = readb(pbase + off);
-                               off += 4;
-                       }
-               } else {
-                       while(len--) {
-                               /*
-                                * The following is required by some
-                                * expansion card loader programs.
-                                */
-                               *(unsigned long *)0x108 = 0;
-                               *buf++ = ecard_loader_read(off++, base,
-                                                          ec->loader);
-                       }
-               }
-       }
-
-}
-
-static DECLARE_WAIT_QUEUE_HEAD(ecard_wait);
-static struct ecard_request *ecard_req;
-static DEFINE_MUTEX(ecard_mutex);
-
-/*
- * Set up the expansion card daemon's page tables.
- */
-static void ecard_init_pgtables(struct mm_struct *mm)
-{
-       struct vm_area_struct vma;
-
-       /* We want to set up the page tables for the following mapping:
-        *  Virtual     Physical
-        *  0x03000000  0x03000000
-        *  0x03010000  unmapped
-        *  0x03210000  0x03210000
-        *  0x03400000  unmapped
-        *  0x08000000  0x08000000
-        *  0x10000000  unmapped
-        *
-        * FIXME: we don't follow this 100% yet.
-        */
-       pgd_t *src_pgd, *dst_pgd;
-
-       src_pgd = pgd_offset(mm, (unsigned long)IO_BASE);
-       dst_pgd = pgd_offset(mm, IO_START);
-
-       memcpy(dst_pgd, src_pgd, sizeof(pgd_t) * (IO_SIZE / PGDIR_SIZE));
-
-       src_pgd = pgd_offset(mm, (unsigned long)EASI_BASE);
-       dst_pgd = pgd_offset(mm, EASI_START);
-
-       memcpy(dst_pgd, src_pgd, sizeof(pgd_t) * (EASI_SIZE / PGDIR_SIZE));
-
-       vma.vm_mm = mm;
-
-       flush_tlb_range(&vma, IO_START, IO_START + IO_SIZE);
-       flush_tlb_range(&vma, EASI_START, EASI_START + EASI_SIZE);
-}
-
-static int ecard_init_mm(void)
-{
-       struct mm_struct * mm = mm_alloc();
-       struct mm_struct *active_mm = current->active_mm;
-
-       if (!mm)
-               return -ENOMEM;
-
-       current->mm = mm;
-       current->active_mm = mm;
-       activate_mm(active_mm, mm);
-       mmdrop(active_mm);
-       ecard_init_pgtables(mm);
-       return 0;
-}
-
-static int
-ecard_task(void * unused)
-{
-       /*
-        * Allocate a mm.  We're not a lazy-TLB kernel task since we need
-        * to set page table entries where the user space would be.  Note
-        * that this also creates the page tables.  Failure is not an
-        * option here.
-        */
-       if (ecard_init_mm())
-               panic("kecardd: unable to alloc mm\n");
-
-       while (1) {
-               struct ecard_request *req;
-
-               wait_event_interruptible(ecard_wait, ecard_req != NULL);
-
-               req = xchg(&ecard_req, NULL);
-               if (req != NULL) {
-                       req->fn(req);
-                       complete(req->complete);
-               }
-       }
-}
-
-/*
- * Wake the expansion card daemon to action our request.
- *
- * FIXME: The test here is not sufficient to detect if the
- * kcardd is running.
- */
-static void ecard_call(struct ecard_request *req)
-{
-       DECLARE_COMPLETION_ONSTACK(completion);
-
-       req->complete = &completion;
-
-       mutex_lock(&ecard_mutex);
-       ecard_req = req;
-       wake_up(&ecard_wait);
-
-       /*
-        * Now wait for kecardd to run.
-        */
-       wait_for_completion(&completion);
-       mutex_unlock(&ecard_mutex);
-}
-
-/* ======================= Mid-level card control ===================== */
-
-static void
-ecard_readbytes(void *addr, ecard_t *ec, int off, int len, int useld)
-{
-       struct ecard_request req;
-
-       req.fn          = ecard_task_readbytes;
-       req.ec          = ec;
-       req.address     = off;
-       req.length      = len;
-       req.use_loader  = useld;
-       req.buffer      = addr;
-
-       ecard_call(&req);
-}
-
-int ecard_readchunk(struct in_chunk_dir *cd, ecard_t *ec, int id, int num)
-{
-       struct ex_chunk_dir excd;
-       int index = 16;
-       int useld = 0;
-
-       if (!ec->cid.cd)
-               return 0;
-
-       while(1) {
-               ecard_readbytes(&excd, ec, index, 8, useld);
-               index += 8;
-               if (c_id(&excd) == 0) {
-                       if (!useld && ec->loader) {
-                               useld = 1;
-                               index = 0;
-                               continue;
-                       }
-                       return 0;
-               }
-               if (c_id(&excd) == 0xf0) { /* link */
-                       index = c_start(&excd);
-                       continue;
-               }
-               if (c_id(&excd) == 0x80) { /* loader */
-                       if (!ec->loader) {
-                               ec->loader = kmalloc(c_len(&excd),
-                                                              GFP_KERNEL);
-                               if (ec->loader)
-                                       ecard_readbytes(ec->loader, ec,
-                                                       (int)c_start(&excd),
-                                                       c_len(&excd), useld);
-                               else
-                                       return 0;
-                       }
-                       continue;
-               }
-               if (c_id(&excd) == id && num-- == 0)
-                       break;
-       }
-
-       if (c_id(&excd) & 0x80) {
-               switch (c_id(&excd) & 0x70) {
-               case 0x70:
-                       ecard_readbytes((unsigned char *)excd.d.string, ec,
-                                       (int)c_start(&excd), c_len(&excd),
-                                       useld);
-                       break;
-               case 0x00:
-                       break;
-               }
-       }
-       cd->start_offset = c_start(&excd);
-       memcpy(cd->d.string, excd.d.string, 256);
-       return 1;
-}
-
-/* ======================= Interrupt control ============================ */
-
-static void ecard_def_irq_enable(ecard_t *ec, int irqnr)
-{
-#ifdef HAS_EXPMASK
-       if (irqnr < 4 && have_expmask) {
-               have_expmask |= 1 << irqnr;
-               __raw_writeb(have_expmask, EXPMASK_ENABLE);
-       }
-#endif
-}
-
-static void ecard_def_irq_disable(ecard_t *ec, int irqnr)
-{
-#ifdef HAS_EXPMASK
-       if (irqnr < 4 && have_expmask) {
-               have_expmask &= ~(1 << irqnr);
-               __raw_writeb(have_expmask, EXPMASK_ENABLE);
-       }
-#endif
-}
-
-static int ecard_def_irq_pending(ecard_t *ec)
-{
-       return !ec->irqmask || readb(ec->irqaddr) & ec->irqmask;
-}
-
-static void ecard_def_fiq_enable(ecard_t *ec, int fiqnr)
-{
-       panic("ecard_def_fiq_enable called - impossible");
-}
-
-static void ecard_def_fiq_disable(ecard_t *ec, int fiqnr)
-{
-       panic("ecard_def_fiq_disable called - impossible");
-}
-
-static int ecard_def_fiq_pending(ecard_t *ec)
-{
-       return !ec->fiqmask || readb(ec->fiqaddr) & ec->fiqmask;
-}
-
-static expansioncard_ops_t ecard_default_ops = {
-       ecard_def_irq_enable,
-       ecard_def_irq_disable,
-       ecard_def_irq_pending,
-       ecard_def_fiq_enable,
-       ecard_def_fiq_disable,
-       ecard_def_fiq_pending
-};
-
-/*
- * Enable and disable interrupts from expansion cards.
- * (interrupts are disabled for these functions).
- *
- * They are not meant to be called directly, but via enable/disable_irq.
- */
-static void ecard_irq_unmask(struct irq_data *d)
-{
-       ecard_t *ec = slot_to_ecard(d->irq - 32);
-
-       if (ec) {
-               if (!ec->ops)
-                       ec->ops = &ecard_default_ops;
-
-               if (ec->claimed && ec->ops->irqenable)
-                       ec->ops->irqenable(ec, d->irq);
-               else
-                       printk(KERN_ERR "ecard: rejecting request to "
-                               "enable IRQs for %d\n", d->irq);
-       }
-}
-
-static void ecard_irq_mask(struct irq_data *d)
-{
-       ecard_t *ec = slot_to_ecard(d->irq - 32);
-
-       if (ec) {
-               if (!ec->ops)
-                       ec->ops = &ecard_default_ops;
-
-               if (ec->ops && ec->ops->irqdisable)
-                       ec->ops->irqdisable(ec, d->irq);
-       }
-}
-
-static struct irq_chip ecard_chip = {
-       .name           = "ECARD",
-       .irq_ack        = ecard_irq_mask,
-       .irq_mask       = ecard_irq_mask,
-       .irq_unmask     = ecard_irq_unmask,
-};
-
-void ecard_enablefiq(unsigned int fiqnr)
-{
-       ecard_t *ec = slot_to_ecard(fiqnr);
-
-       if (ec) {
-               if (!ec->ops)
-                       ec->ops = &ecard_default_ops;
-
-               if (ec->claimed && ec->ops->fiqenable)
-                       ec->ops->fiqenable(ec, fiqnr);
-               else
-                       printk(KERN_ERR "ecard: rejecting request to "
-                               "enable FIQs for %d\n", fiqnr);
-       }
-}
-
-void ecard_disablefiq(unsigned int fiqnr)
-{
-       ecard_t *ec = slot_to_ecard(fiqnr);
-
-       if (ec) {
-               if (!ec->ops)
-                       ec->ops = &ecard_default_ops;
-
-               if (ec->ops->fiqdisable)
-                       ec->ops->fiqdisable(ec, fiqnr);
-       }
-}
-
-static void ecard_dump_irq_state(void)
-{
-       ecard_t *ec;
-
-       printk("Expansion card IRQ state:\n");
-
-       for (ec = cards; ec; ec = ec->next) {
-               if (ec->slot_no == 8)
-                       continue;
-
-               printk("  %d: %sclaimed, ",
-                      ec->slot_no, ec->claimed ? "" : "not ");
-
-               if (ec->ops && ec->ops->irqpending &&
-                   ec->ops != &ecard_default_ops)
-                       printk("irq %spending\n",
-                              ec->ops->irqpending(ec) ? "" : "not ");
-               else
-                       printk("irqaddr %p, mask = %02X, status = %02X\n",
-                              ec->irqaddr, ec->irqmask, readb(ec->irqaddr));
-       }
-}
-
-static void ecard_check_lockup(struct irq_desc *desc)
-{
-       static unsigned long last;
-       static int lockup;
-
-       /*
-        * If the timer interrupt has not run since the last million
-        * unrecognised expansion card interrupts, then there is
-        * something seriously wrong.  Disable the expansion card
-        * interrupts so at least we can continue.
-        *
-        * Maybe we ought to start a timer to re-enable them some time
-        * later?
-        */
-       if (last == jiffies) {
-               lockup += 1;
-               if (lockup > 1000000) {
-                       printk(KERN_ERR "\nInterrupt lockup detected - "
-                              "disabling all expansion card interrupts\n");
-
-                       desc->irq_data.chip->irq_mask(&desc->irq_data);
-                       ecard_dump_irq_state();
-               }
-       } else
-               lockup = 0;
-
-       /*
-        * If we did not recognise the source of this interrupt,
-        * warn the user, but don't flood the user with these messages.
-        */
-       if (!last || time_after(jiffies, last + 5*HZ)) {
-               last = jiffies;
-               printk(KERN_WARNING "Unrecognised interrupt from backplane\n");
-               ecard_dump_irq_state();
-       }
-}
-
-static void
-ecard_irq_handler(unsigned int irq, struct irq_desc *desc)
-{
-       ecard_t *ec;
-       int called = 0;
-
-       desc->irq_data.chip->irq_mask(&desc->irq_data);
-       for (ec = cards; ec; ec = ec->next) {
-               int pending;
-
-               if (!ec->claimed || ec->irq == NO_IRQ || ec->slot_no == 8)
-                       continue;
-
-               if (ec->ops && ec->ops->irqpending)
-                       pending = ec->ops->irqpending(ec);
-               else
-                       pending = ecard_default_ops.irqpending(ec);
-
-               if (pending) {
-                       generic_handle_irq(ec->irq);
-                       called ++;
-               }
-       }
-       desc->irq_data.chip->irq_unmask(&desc->irq_data);
-
-       if (called == 0)
-               ecard_check_lockup(desc);
-}
-
-#ifdef HAS_EXPMASK
-static unsigned char priority_masks[] =
-{
-       0xf0, 0xf1, 0xf3, 0xf7, 0xff, 0xff, 0xff, 0xff
-};
-
-static unsigned char first_set[] =
-{
-       0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00,
-       0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00
-};
-
-static void
-ecard_irqexp_handler(unsigned int irq, struct irq_desc *desc)
-{
-       const unsigned int statusmask = 15;
-       unsigned int status;
-
-       status = __raw_readb(EXPMASK_STATUS) & statusmask;
-       if (status) {
-               unsigned int slot = first_set[status];
-               ecard_t *ec = slot_to_ecard(slot);
-
-               if (ec->claimed) {
-                       /*
-                        * this ugly code is so that we can operate a
-                        * prioritorising system:
-                        *
-                        * Card 0       highest priority
-                        * Card 1
-                        * Card 2
-                        * Card 3       lowest priority
-                        *
-                        * Serial cards should go in 0/1, ethernet/scsi in 2/3
-                        * otherwise you will lose serial data at high speeds!
-                        */
-                       generic_handle_irq(ec->irq);
-               } else {
-                       printk(KERN_WARNING "card%d: interrupt from unclaimed "
-                              "card???\n", slot);
-                       have_expmask &= ~(1 << slot);
-                       __raw_writeb(have_expmask, EXPMASK_ENABLE);
-               }
-       } else
-               printk(KERN_WARNING "Wild interrupt from backplane (masks)\n");
-}
-
-static int __init ecard_probeirqhw(void)
-{
-       ecard_t *ec;
-       int found;
-
-       __raw_writeb(0x00, EXPMASK_ENABLE);
-       __raw_writeb(0xff, EXPMASK_STATUS);
-       found = (__raw_readb(EXPMASK_STATUS) & 15) == 0;
-       __raw_writeb(0xff, EXPMASK_ENABLE);
-
-       if (found) {
-               printk(KERN_DEBUG "Expansion card interrupt "
-                      "management hardware found\n");
-
-               /* for each card present, set a bit to '1' */
-               have_expmask = 0x80000000;
-
-               for (ec = cards; ec; ec = ec->next)
-                       have_expmask |= 1 << ec->slot_no;
-
-               __raw_writeb(have_expmask, EXPMASK_ENABLE);
-       }
-
-       return found;
-}
-#else
-#define ecard_irqexp_handler NULL
-#define ecard_probeirqhw() (0)
-#endif
-
-static void __iomem *__ecard_address(ecard_t *ec, card_type_t type, card_speed_t speed)
-{
-       void __iomem *address = NULL;
-       int slot = ec->slot_no;
-
-       if (ec->slot_no == 8)
-               return ECARD_MEMC8_BASE;
-
-       ectcr &= ~(1 << slot);
-
-       switch (type) {
-       case ECARD_MEMC:
-               if (slot < 4)
-                       address = ECARD_MEMC_BASE + (slot << 14);
-               break;
-
-       case ECARD_IOC:
-               if (slot < 4)
-                       address = ECARD_IOC_BASE + (slot << 14);
-               else
-                       address = ECARD_IOC4_BASE + ((slot - 4) << 14);
-               if (address)
-                       address += speed << 19;
-               break;
-
-       case ECARD_EASI:
-               address = ECARD_EASI_BASE + (slot << 24);
-               if (speed == ECARD_FAST)
-                       ectcr |= 1 << slot;
-               break;
-
-       default:
-               break;
-       }
-
-#ifdef IOMD_ECTCR
-       iomd_writeb(ectcr, IOMD_ECTCR);
-#endif
-       return address;
-}
-
-static int ecard_prints(struct seq_file *m, ecard_t *ec)
-{
-       seq_printf(m, "  %d: %s ", ec->slot_no, ec->easi ? "EASI" : "    ");
-
-       if (ec->cid.id == 0) {
-               struct in_chunk_dir incd;
-
-               seq_printf(m, "[%04X:%04X] ",
-                       ec->cid.manufacturer, ec->cid.product);
-
-               if (!ec->card_desc && ec->cid.cd &&
-                   ecard_readchunk(&incd, ec, 0xf5, 0)) {
-                       ec->card_desc = kmalloc(strlen(incd.d.string)+1, GFP_KERNEL);
-
-                       if (ec->card_desc)
-                               strcpy((char *)ec->card_desc, incd.d.string);
-               }
-
-               seq_printf(m, "%s\n", ec->card_desc ? ec->card_desc : "*unknown*");
-       } else
-               seq_printf(m, "Simple card %d\n", ec->cid.id);
-
-       return 0;
-}
-
-static int ecard_devices_proc_show(struct seq_file *m, void *v)
-{
-       ecard_t *ec = cards;
-
-       while (ec) {
-               ecard_prints(m, ec);
-               ec = ec->next;
-       }
-       return 0;
-}
-
-static int ecard_devices_proc_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, ecard_devices_proc_show, NULL);
-}
-
-static const struct file_operations bus_ecard_proc_fops = {
-       .owner          = THIS_MODULE,
-       .open           = ecard_devices_proc_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
-
-static struct proc_dir_entry *proc_bus_ecard_dir = NULL;
-
-static void ecard_proc_init(void)
-{
-       proc_bus_ecard_dir = proc_mkdir("bus/ecard", NULL);
-       proc_create("devices", 0, proc_bus_ecard_dir, &bus_ecard_proc_fops);
-}
-
-#define ec_set_resource(ec,nr,st,sz)                           \
-       do {                                                    \
-               (ec)->resource[nr].name = dev_name(&ec->dev);   \
-               (ec)->resource[nr].start = st;                  \
-               (ec)->resource[nr].end = (st) + (sz) - 1;       \
-               (ec)->resource[nr].flags = IORESOURCE_MEM;      \
-       } while (0)
-
-static void __init ecard_free_card(struct expansion_card *ec)
-{
-       int i;
-
-       for (i = 0; i < ECARD_NUM_RESOURCES; i++)
-               if (ec->resource[i].flags)
-                       release_resource(&ec->resource[i]);
-
-       kfree(ec);
-}
-
-static struct expansion_card *__init ecard_alloc_card(int type, int slot)
-{
-       struct expansion_card *ec;
-       unsigned long base;
-       int i;
-
-       ec = kzalloc(sizeof(ecard_t), GFP_KERNEL);
-       if (!ec) {
-               ec = ERR_PTR(-ENOMEM);
-               goto nomem;
-       }
-
-       ec->slot_no = slot;
-       ec->easi = type == ECARD_EASI;
-       ec->irq = NO_IRQ;
-       ec->fiq = NO_IRQ;
-       ec->dma = NO_DMA;
-       ec->ops = &ecard_default_ops;
-
-       dev_set_name(&ec->dev, "ecard%d", slot);
-       ec->dev.parent = NULL;
-       ec->dev.bus = &ecard_bus_type;
-       ec->dev.dma_mask = &ec->dma_mask;
-       ec->dma_mask = (u64)0xffffffff;
-       ec->dev.coherent_dma_mask = ec->dma_mask;
-
-       if (slot < 4) {
-               ec_set_resource(ec, ECARD_RES_MEMC,
-                               PODSLOT_MEMC_BASE + (slot << 14),
-                               PODSLOT_MEMC_SIZE);
-               base = PODSLOT_IOC0_BASE + (slot << 14);
-       } else
-               base = PODSLOT_IOC4_BASE + ((slot - 4) << 14);
-
-#ifdef CONFIG_ARCH_RPC
-       if (slot < 8) {
-               ec_set_resource(ec, ECARD_RES_EASI,
-                               PODSLOT_EASI_BASE + (slot << 24),
-                               PODSLOT_EASI_SIZE);
-       }
-
-       if (slot == 8) {
-               ec_set_resource(ec, ECARD_RES_MEMC, NETSLOT_BASE, NETSLOT_SIZE);
-       } else
-#endif
-
-       for (i = 0; i <= ECARD_RES_IOCSYNC - ECARD_RES_IOCSLOW; i++)
-               ec_set_resource(ec, i + ECARD_RES_IOCSLOW,
-                               base + (i << 19), PODSLOT_IOC_SIZE);
-
-       for (i = 0; i < ECARD_NUM_RESOURCES; i++) {
-               if (ec->resource[i].flags &&
-                   request_resource(&iomem_resource, &ec->resource[i])) {
-                       dev_err(&ec->dev, "resource(s) not available\n");
-                       ec->resource[i].end -= ec->resource[i].start;
-                       ec->resource[i].start = 0;
-                       ec->resource[i].flags = 0;
-               }
-       }
-
- nomem:
-       return ec;
-}
-
-static ssize_t ecard_show_irq(struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct expansion_card *ec = ECARD_DEV(dev);
-       return sprintf(buf, "%u\n", ec->irq);
-}
-
-static ssize_t ecard_show_dma(struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct expansion_card *ec = ECARD_DEV(dev);
-       return sprintf(buf, "%u\n", ec->dma);
-}
-
-static ssize_t ecard_show_resources(struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct expansion_card *ec = ECARD_DEV(dev);
-       char *str = buf;
-       int i;
-
-       for (i = 0; i < ECARD_NUM_RESOURCES; i++)
-               str += sprintf(str, "%08x %08x %08lx\n",
-                               ec->resource[i].start,
-                               ec->resource[i].end,
-                               ec->resource[i].flags);
-
-       return str - buf;
-}
-
-static ssize_t ecard_show_vendor(struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct expansion_card *ec = ECARD_DEV(dev);
-       return sprintf(buf, "%u\n", ec->cid.manufacturer);
-}
-
-static ssize_t ecard_show_device(struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct expansion_card *ec = ECARD_DEV(dev);
-       return sprintf(buf, "%u\n", ec->cid.product);
-}
-
-static ssize_t ecard_show_type(struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct expansion_card *ec = ECARD_DEV(dev);
-       return sprintf(buf, "%s\n", ec->easi ? "EASI" : "IOC");
-}
-
-static struct device_attribute ecard_dev_attrs[] = {
-       __ATTR(device,   S_IRUGO, ecard_show_device,    NULL),
-       __ATTR(dma,      S_IRUGO, ecard_show_dma,       NULL),
-       __ATTR(irq,      S_IRUGO, ecard_show_irq,       NULL),
-       __ATTR(resource, S_IRUGO, ecard_show_resources, NULL),
-       __ATTR(type,     S_IRUGO, ecard_show_type,      NULL),
-       __ATTR(vendor,   S_IRUGO, ecard_show_vendor,    NULL),
-       __ATTR_NULL,
-};
-
-
-int ecard_request_resources(struct expansion_card *ec)
-{
-       int i, err = 0;
-
-       for (i = 0; i < ECARD_NUM_RESOURCES; i++) {
-               if (ecard_resource_end(ec, i) &&
-                   !request_mem_region(ecard_resource_start(ec, i),
-                                       ecard_resource_len(ec, i),
-                                       ec->dev.driver->name)) {
-                       err = -EBUSY;
-                       break;
-               }
-       }
-
-       if (err) {
-               while (i--)
-                       if (ecard_resource_end(ec, i))
-                               release_mem_region(ecard_resource_start(ec, i),
-                                                  ecard_resource_len(ec, i));
-       }
-       return err;
-}
-EXPORT_SYMBOL(ecard_request_resources);
-
-void ecard_release_resources(struct expansion_card *ec)
-{
-       int i;
-
-       for (i = 0; i < ECARD_NUM_RESOURCES; i++)
-               if (ecard_resource_end(ec, i))
-                       release_mem_region(ecard_resource_start(ec, i),
-                                          ecard_resource_len(ec, i));
-}
-EXPORT_SYMBOL(ecard_release_resources);
-
-void ecard_setirq(struct expansion_card *ec, const struct expansion_card_ops *ops, void *irq_data)
-{
-       ec->irq_data = irq_data;
-       barrier();
-       ec->ops = ops;
-}
-EXPORT_SYMBOL(ecard_setirq);
-
-void __iomem *ecardm_iomap(struct expansion_card *ec, unsigned int res,
-                          unsigned long offset, unsigned long maxsize)
-{
-       unsigned long start = ecard_resource_start(ec, res);
-       unsigned long end = ecard_resource_end(ec, res);
-
-       if (offset > (end - start))
-               return NULL;
-
-       start += offset;
-       if (maxsize && end - start > maxsize)
-               end = start + maxsize;
-       
-       return devm_ioremap(&ec->dev, start, end - start);
-}
-EXPORT_SYMBOL(ecardm_iomap);
-
-/*
- * Probe for an expansion card.
- *
- * If bit 1 of the first byte of the card is set, then the
- * card does not exist.
- */
-static int __init
-ecard_probe(int slot, card_type_t type)
-{
-       ecard_t **ecp;
-       ecard_t *ec;
-       struct ex_ecid cid;
-       void __iomem *addr;
-       int i, rc;
-
-       ec = ecard_alloc_card(type, slot);
-       if (IS_ERR(ec)) {
-               rc = PTR_ERR(ec);
-               goto nomem;
-       }
-
-       rc = -ENODEV;
-       if ((addr = __ecard_address(ec, type, ECARD_SYNC)) == NULL)
-               goto nodev;
-
-       cid.r_zero = 1;
-       ecard_readbytes(&cid, ec, 0, 16, 0);
-       if (cid.r_zero)
-               goto nodev;
-
-       ec->cid.id      = cid.r_id;
-       ec->cid.cd      = cid.r_cd;
-       ec->cid.is      = cid.r_is;
-       ec->cid.w       = cid.r_w;
-       ec->cid.manufacturer = ecard_getu16(cid.r_manu);
-       ec->cid.product = ecard_getu16(cid.r_prod);
-       ec->cid.country = cid.r_country;
-       ec->cid.irqmask = cid.r_irqmask;
-       ec->cid.irqoff  = ecard_gets24(cid.r_irqoff);
-       ec->cid.fiqmask = cid.r_fiqmask;
-       ec->cid.fiqoff  = ecard_gets24(cid.r_fiqoff);
-       ec->fiqaddr     =
-       ec->irqaddr     = addr;
-
-       if (ec->cid.is) {
-               ec->irqmask = ec->cid.irqmask;
-               ec->irqaddr += ec->cid.irqoff;
-               ec->fiqmask = ec->cid.fiqmask;
-               ec->fiqaddr += ec->cid.fiqoff;
-       } else {
-               ec->irqmask = 1;
-               ec->fiqmask = 4;
-       }
-
-       for (i = 0; i < ARRAY_SIZE(blacklist); i++)
-               if (blacklist[i].manufacturer == ec->cid.manufacturer &&
-                   blacklist[i].product == ec->cid.product) {
-                       ec->card_desc = blacklist[i].type;
-                       break;
-               }
-
-       /*
-        * hook the interrupt handlers
-        */
-       if (slot < 8) {
-               ec->irq = 32 + slot;
-               irq_set_chip_and_handler(ec->irq, &ecard_chip,
-                                        handle_level_irq);
-               set_irq_flags(ec->irq, IRQF_VALID);
-       }
-
-       if (slot == 8)
-               ec->irq = 11;
-#ifdef CONFIG_ARCH_RPC
-       /* On RiscPC, only first two slots have DMA capability */
-       if (slot < 2)
-               ec->dma = 2 + slot;
-#endif
-
-       for (ecp = &cards; *ecp; ecp = &(*ecp)->next);
-
-       *ecp = ec;
-       slot_to_expcard[slot] = ec;
-
-       device_register(&ec->dev);
-
-       return 0;
-
- nodev:
-       ecard_free_card(ec);
- nomem:
-       return rc;
-}
-
-/*
- * Initialise the expansion card system.
- * Locate all hardware - interrupt management and
- * actual cards.
- */
-static int __init ecard_init(void)
-{
-       struct task_struct *task;
-       int slot, irqhw;
-
-       task = kthread_run(ecard_task, NULL, "kecardd");
-       if (IS_ERR(task)) {
-               printk(KERN_ERR "Ecard: unable to create kernel thread: %ld\n",
-                      PTR_ERR(task));
-               return PTR_ERR(task);
-       }
-
-       printk("Probing expansion cards\n");
-
-       for (slot = 0; slot < 8; slot ++) {
-               if (ecard_probe(slot, ECARD_EASI) == -ENODEV)
-                       ecard_probe(slot, ECARD_IOC);
-       }
-
-       ecard_probe(8, ECARD_IOC);
-
-       irqhw = ecard_probeirqhw();
-
-       irq_set_chained_handler(IRQ_EXPANSIONCARD,
-                               irqhw ? ecard_irqexp_handler : ecard_irq_handler);
-
-       ecard_proc_init();
-
-       return 0;
-}
-
-subsys_initcall(ecard_init);
-
-/*
- *     ECARD "bus"
- */
-static const struct ecard_id *
-ecard_match_device(const struct ecard_id *ids, struct expansion_card *ec)
-{
-       int i;
-
-       for (i = 0; ids[i].manufacturer != 65535; i++)
-               if (ec->cid.manufacturer == ids[i].manufacturer &&
-                   ec->cid.product == ids[i].product)
-                       return ids + i;
-
-       return NULL;
-}
-
-static int ecard_drv_probe(struct device *dev)
-{
-       struct expansion_card *ec = ECARD_DEV(dev);
-       struct ecard_driver *drv = ECARD_DRV(dev->driver);
-       const struct ecard_id *id;
-       int ret;
-
-       id = ecard_match_device(drv->id_table, ec);
-
-       ec->claimed = 1;
-       ret = drv->probe(ec, id);
-       if (ret)
-               ec->claimed = 0;
-       return ret;
-}
-
-static int ecard_drv_remove(struct device *dev)
-{
-       struct expansion_card *ec = ECARD_DEV(dev);
-       struct ecard_driver *drv = ECARD_DRV(dev->driver);
-
-       drv->remove(ec);
-       ec->claimed = 0;
-
-       /*
-        * Restore the default operations.  We ensure that the
-        * ops are set before we change the data.
-        */
-       ec->ops = &ecard_default_ops;
-       barrier();
-       ec->irq_data = NULL;
-
-       return 0;
-}
-
-/*
- * Before rebooting, we must make sure that the expansion card is in a
- * sensible state, so it can be re-detected.  This means that the first
- * page of the ROM must be visible.  We call the expansion cards reset
- * handler, if any.
- */
-static void ecard_drv_shutdown(struct device *dev)
-{
-       struct expansion_card *ec = ECARD_DEV(dev);
-       struct ecard_driver *drv = ECARD_DRV(dev->driver);
-       struct ecard_request req;
-
-       if (dev->driver) {
-               if (drv->shutdown)
-                       drv->shutdown(ec);
-               ec->claimed = 0;
-       }
-
-       /*
-        * If this card has a loader, call the reset handler.
-        */
-       if (ec->loader) {
-               req.fn = ecard_task_reset;
-               req.ec = ec;
-               ecard_call(&req);
-       }
-}
-
-int ecard_register_driver(struct ecard_driver *drv)
-{
-       drv->drv.bus = &ecard_bus_type;
-
-       return driver_register(&drv->drv);
-}
-
-void ecard_remove_driver(struct ecard_driver *drv)
-{
-       driver_unregister(&drv->drv);
-}
-
-static int ecard_match(struct device *_dev, struct device_driver *_drv)
-{
-       struct expansion_card *ec = ECARD_DEV(_dev);
-       struct ecard_driver *drv = ECARD_DRV(_drv);
-       int ret;
-
-       if (drv->id_table) {
-               ret = ecard_match_device(drv->id_table, ec) != NULL;
-       } else {
-               ret = ec->cid.id == drv->id;
-       }
-
-       return ret;
-}
-
-struct bus_type ecard_bus_type = {
-       .name           = "ecard",
-       .dev_attrs      = ecard_dev_attrs,
-       .match          = ecard_match,
-       .probe          = ecard_drv_probe,
-       .remove         = ecard_drv_remove,
-       .shutdown       = ecard_drv_shutdown,
-};
-
-static int ecard_bus_init(void)
-{
-       return bus_register(&ecard_bus_type);
-}
-
-postcore_initcall(ecard_bus_init);
-
-EXPORT_SYMBOL(ecard_readchunk);
-EXPORT_SYMBOL(ecard_register_driver);
-EXPORT_SYMBOL(ecard_remove_driver);
-EXPORT_SYMBOL(ecard_bus_type);
diff --git a/arch/arm/kernel/ecard.h b/arch/arm/kernel/ecard.h
deleted file mode 100644 (file)
index 4642d43..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- *  ecard.h
- *
- *  Copyright 2007 Russell King
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-/* Definitions internal to ecard.c - for it's use only!!
- *
- * External expansion card header as read from the card
- */
-struct ex_ecid {
-       unsigned char   r_irq:1;
-       unsigned char   r_zero:1;
-       unsigned char   r_fiq:1;
-       unsigned char   r_id:4;
-       unsigned char   r_a:1;
-
-       unsigned char   r_cd:1;
-       unsigned char   r_is:1;
-       unsigned char   r_w:2;
-       unsigned char   r_r1:4;
-
-       unsigned char   r_r2:8;
-
-       unsigned char   r_prod[2];
-
-       unsigned char   r_manu[2];
-
-       unsigned char   r_country;
-
-       unsigned char   r_fiqmask;
-       unsigned char   r_fiqoff[3];
-
-       unsigned char   r_irqmask;
-       unsigned char   r_irqoff[3];
-};
-
-/*
- * Chunk directory entry as read from the card
- */
-struct ex_chunk_dir {
-       unsigned char r_id;
-       unsigned char r_len[3];
-       unsigned long r_start;
-       union {
-               char string[256];
-               char data[1];
-       } d;
-#define c_id(x)                ((x)->r_id)
-#define c_len(x)       ((x)->r_len[0]|((x)->r_len[1]<<8)|((x)->r_len[2]<<16))
-#define c_start(x)     ((x)->r_start)
-};
-
-typedef enum ecard_type {              /* Cards address space          */
-       ECARD_IOC,
-       ECARD_MEMC,
-       ECARD_EASI
-} card_type_t;
-
-typedef enum {                         /* Speed for ECARD_IOC space    */
-       ECARD_SLOW       = 0,
-       ECARD_MEDIUM     = 1,
-       ECARD_FAST       = 2,
-       ECARD_SYNC       = 3
-} card_speed_t;
index 294aad07f7a05eaabcfe9b6fb7ac8d48ca1cfe10..6235efb0ccd43d044747924eefb4f461299958cc 100644 (file)
 
 #include <asm/mach/time.h>
 
-#define IRQ_MASK               0xfe000000      /* read */
-#define IRQ_MSET               0xfe000000      /* write */
-#define IRQ_STAT               0xff000000      /* read */
-#define IRQ_MCLR               0xff000000      /* write */
+#include "core.h"
 
 static void ebsa110_mask_irq(struct irq_data *d)
 {
@@ -79,22 +76,22 @@ static struct map_desc ebsa110_io_desc[] __initdata = {
        {       /* IRQ_STAT/IRQ_MCLR */
                .virtual        = IRQ_STAT,
                .pfn            = __phys_to_pfn(TRICK4_PHYS),
-               .length         = PGDIR_SIZE,
+               .length         = TRICK4_SIZE,
                .type           = MT_DEVICE
        }, {    /* IRQ_MASK/IRQ_MSET */
                .virtual        = IRQ_MASK,
                .pfn            = __phys_to_pfn(TRICK3_PHYS),
-               .length         = PGDIR_SIZE,
+               .length         = TRICK3_SIZE,
                .type           = MT_DEVICE
        }, {    /* SOFT_BASE */
                .virtual        = SOFT_BASE,
                .pfn            = __phys_to_pfn(TRICK1_PHYS),
-               .length         = PGDIR_SIZE,
+               .length         = TRICK1_SIZE,
                .type           = MT_DEVICE
        }, {    /* PIT_BASE */
                .virtual        = PIT_BASE,
                .pfn            = __phys_to_pfn(TRICK0_PHYS),
-               .length         = PGDIR_SIZE,
+               .length         = TRICK0_SIZE,
                .type           = MT_DEVICE
        },
 
diff --git a/arch/arm/mach-ebsa110/core.h b/arch/arm/mach-ebsa110/core.h
new file mode 100644 (file)
index 0000000..c93c9e4
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ *  Copyright (C) 1996-2000 Russell King.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This file contains the core hardware definitions of the EBSA-110.
+ */
+#ifndef CORE_H
+#define CORE_H
+
+/* Physical addresses/sizes */
+#define ISAMEM_PHYS            0xe0000000
+#define ISAMEM_SIZE            0x10000000
+
+#define ISAIO_PHYS             0xf0000000
+#define ISAIO_SIZE             PGDIR_SIZE
+
+#define TRICK0_PHYS            0xf2000000
+#define TRICK0_SIZE            PGDIR_SIZE
+#define TRICK1_PHYS            0xf2400000
+#define TRICK1_SIZE            PGDIR_SIZE
+#define TRICK2_PHYS            0xf2800000
+#define TRICK3_PHYS            0xf2c00000
+#define TRICK3_SIZE            PGDIR_SIZE
+#define TRICK4_PHYS            0xf3000000
+#define TRICK4_SIZE            PGDIR_SIZE
+#define TRICK5_PHYS            0xf3400000
+#define TRICK6_PHYS            0xf3800000
+#define TRICK7_PHYS            0xf3c00000
+
+/* Virtual addresses */
+#define PIT_BASE               0xfc000000      /* trick 0 */
+#define SOFT_BASE              0xfd000000      /* trick 1 */
+#define IRQ_MASK               0xfe000000      /* trick 3 - read */
+#define IRQ_MSET               0xfe000000      /* trick 3 - write */
+#define IRQ_STAT               0xff000000      /* trick 4 - read */
+#define IRQ_MCLR               0xff000000      /* trick 4 - write */
+
+#endif
index 4b2fb7743909793e125c7836e84bd215488f04a0..f4e5407bd004ae960965bdd73e332500b1fe1f6f 100644 (file)
 #ifndef __ASM_ARCH_HARDWARE_H
 #define __ASM_ARCH_HARDWARE_H
 
-/*
- * The EBSA110 has a weird "ISA IO" region:
- *
- * Region 0 (addr = 0xf0000000 + io << 2)
- * --------------------------------------------------------
- * Physical region     IO region
- * f0000fe0 - f0000ffc 3f8 - 3ff  ttyS0
- * f0000e60 - f0000e64 398 - 399
- * f0000de0 - f0000dfc 378 - 37f  lp0
- * f0000be0 - f0000bfc 2f8 - 2ff  ttyS1
- *
- * Region 1 (addr = 0xf0000000 + (io & ~1) << 1 + (io & 1))
- * --------------------------------------------------------
- * Physical region     IO region
- * f00014f1             a79        pnp write data
- * f00007c0 - f00007c1 3e0 - 3e1  pcmcia
- * f00004f1            279        pnp address
- * f0000440 - f000046c  220 - 236  eth0
- * f0000405            203        pnp read data
- */
-
-#define ISAMEM_PHYS            0xe0000000
-#define ISAMEM_SIZE            0x10000000
-
-#define ISAIO_PHYS             0xf0000000
-#define ISAIO_SIZE             PGDIR_SIZE
-
-#define TRICK0_PHYS            0xf2000000
-#define TRICK1_PHYS            0xf2400000
-#define TRICK2_PHYS            0xf2800000
-#define TRICK3_PHYS            0xf2c00000
-#define TRICK4_PHYS            0xf3000000
-#define TRICK5_PHYS            0xf3400000
-#define TRICK6_PHYS            0xf3800000
-#define TRICK7_PHYS            0xf3c00000
-
 #define ISAMEM_BASE            0xe0000000
 #define ISAIO_BASE             0xf0000000
 
-#define PIT_BASE               0xfc000000
-#define SOFT_BASE              0xfd000000
-
 /*
  * RAM definitions
  */
index c52e3047a7eb7ccc32a4094c1a1de8498ad37cbd..756cc377a73dcd8d4ad33ecc8f6e7ed30ac825dd 100644 (file)
@@ -177,6 +177,26 @@ void writesl(void __iomem *addr, const void *data, int len)
 }
 EXPORT_SYMBOL(writesl);
 
+/*
+ * The EBSA110 has a weird "ISA IO" region:
+ *
+ * Region 0 (addr = 0xf0000000 + io << 2)
+ * --------------------------------------------------------
+ * Physical region     IO region
+ * f0000fe0 - f0000ffc 3f8 - 3ff  ttyS0
+ * f0000e60 - f0000e64 398 - 399
+ * f0000de0 - f0000dfc 378 - 37f  lp0
+ * f0000be0 - f0000bfc 2f8 - 2ff  ttyS1
+ *
+ * Region 1 (addr = 0xf0000000 + (io & ~1) << 1 + (io & 1))
+ * --------------------------------------------------------
+ * Physical region     IO region
+ * f00014f1             a79        pnp write data
+ * f00007c0 - f00007c1 3e0 - 3e1  pcmcia
+ * f00004f1            279        pnp address
+ * f0000440 - f000046c  220 - 236  eth0
+ * f0000405            203        pnp read data
+ */
 #define SUPERIO_PORT(p) \
        (((p) >> 3) == (0x3f8 >> 3) || \
         ((p) >> 3) == (0x2f8 >> 3) || \
index 6a6ea57c2a4e9a79700b45c45d3893e723c20c3a..d43121a30aa783065e52dd7f87a5f09cbcc277a9 100644 (file)
@@ -20,6 +20,8 @@
 #include <asm/system.h>
 #include <asm/mach-types.h>
 
+#include "core.h"
+
 static spinlock_t leds_lock;
 
 static void ebsa110_leds_event(led_event_t ledevt)
index aa77bc9efbbbe0e9ee71cea36b6e3730c99b9d89..f89320739b09d7b605b835cbb4e0b1ca9e0e3188 100644 (file)
@@ -4,7 +4,7 @@
 
 # Object file lists.
 
-obj-y                  := dma.o irq.o riscpc.o
+obj-y                  := dma.o ecard.o irq.o riscpc.o time.o
 obj-m                  :=
 obj-n                  :=
 obj-                   :=
diff --git a/arch/arm/mach-rpc/ecard.c b/arch/arm/mach-rpc/ecard.c
new file mode 100644 (file)
index 0000000..0c01567
--- /dev/null
@@ -0,0 +1,1137 @@
+/*
+ *  linux/arch/arm/kernel/ecard.c
+ *
+ *  Copyright 1995-2001 Russell King
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ *  Find all installed expansion cards, and handle interrupts from them.
+ *
+ *  Created from information from Acorns RiscOS3 PRMs
+ *
+ *  08-Dec-1996        RMK     Added code for the 9'th expansion card - the ether
+ *                     podule slot.
+ *  06-May-1997        RMK     Added blacklist for cards whose loader doesn't work.
+ *  12-Sep-1997        RMK     Created new handling of interrupt enables/disables
+ *                     - cards can now register their own routine to control
+ *                     interrupts (recommended).
+ *  29-Sep-1997        RMK     Expansion card interrupt hardware not being re-enabled
+ *                     on reset from Linux. (Caused cards not to respond
+ *                     under RiscOS without hard reset).
+ *  15-Feb-1998        RMK     Added DMA support
+ *  12-Sep-1998        RMK     Added EASI support
+ *  10-Jan-1999        RMK     Run loaders in a simulated RISC OS environment.
+ *  17-Apr-1999        RMK     Support for EASI Type C cycles.
+ */
+#define ECARD_C
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <linux/completion.h>
+#include <linux/reboot.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+#include <linux/device.h>
+#include <linux/init.h>
+#include <linux/mutex.h>
+#include <linux/kthread.h>
+#include <linux/irq.h>
+#include <linux/io.h>
+
+#include <asm/dma.h>
+#include <asm/ecard.h>
+#include <mach/hardware.h>
+#include <asm/irq.h>
+#include <asm/mmu_context.h>
+#include <asm/mach/irq.h>
+#include <asm/tlbflush.h>
+
+#include "ecard.h"
+
+struct ecard_request {
+       void            (*fn)(struct ecard_request *);
+       ecard_t         *ec;
+       unsigned int    address;
+       unsigned int    length;
+       unsigned int    use_loader;
+       void            *buffer;
+       struct completion *complete;
+};
+
+struct expcard_blacklist {
+       unsigned short   manufacturer;
+       unsigned short   product;
+       const char      *type;
+};
+
+static ecard_t *cards;
+static ecard_t *slot_to_expcard[MAX_ECARDS];
+static unsigned int ectcr;
+
+/* List of descriptions of cards which don't have an extended
+ * identification, or chunk directories containing a description.
+ */
+static struct expcard_blacklist __initdata blacklist[] = {
+       { MANU_ACORN, PROD_ACORN_ETHER1, "Acorn Ether1" }
+};
+
+asmlinkage extern int
+ecard_loader_reset(unsigned long base, loader_t loader);
+asmlinkage extern int
+ecard_loader_read(int off, unsigned long base, loader_t loader);
+
+static inline unsigned short ecard_getu16(unsigned char *v)
+{
+       return v[0] | v[1] << 8;
+}
+
+static inline signed long ecard_gets24(unsigned char *v)
+{
+       return v[0] | v[1] << 8 | v[2] << 16 | ((v[2] & 0x80) ? 0xff000000 : 0);
+}
+
+static inline ecard_t *slot_to_ecard(unsigned int slot)
+{
+       return slot < MAX_ECARDS ? slot_to_expcard[slot] : NULL;
+}
+
+/* ===================== Expansion card daemon ======================== */
+/*
+ * Since the loader programs on the expansion cards need to be run
+ * in a specific environment, create a separate task with this
+ * environment up, and pass requests to this task as and when we
+ * need to.
+ *
+ * This should allow 99% of loaders to be called from Linux.
+ *
+ * From a security standpoint, we trust the card vendors.  This
+ * may be a misplaced trust.
+ */
+static void ecard_task_reset(struct ecard_request *req)
+{
+       struct expansion_card *ec = req->ec;
+       struct resource *res;
+
+       res = ec->slot_no == 8
+               ? &ec->resource[ECARD_RES_MEMC]
+               : ec->easi
+                 ? &ec->resource[ECARD_RES_EASI]
+                 : &ec->resource[ECARD_RES_IOCSYNC];
+
+       ecard_loader_reset(res->start, ec->loader);
+}
+
+static void ecard_task_readbytes(struct ecard_request *req)
+{
+       struct expansion_card *ec = req->ec;
+       unsigned char *buf = req->buffer;
+       unsigned int len = req->length;
+       unsigned int off = req->address;
+
+       if (ec->slot_no == 8) {
+               void __iomem *base = (void __iomem *)
+                               ec->resource[ECARD_RES_MEMC].start;
+
+               /*
+                * The card maintains an index which increments the address
+                * into a 4096-byte page on each access.  We need to keep
+                * track of the counter.
+                */
+               static unsigned int index;
+               unsigned int page;
+
+               page = (off >> 12) * 4;
+               if (page > 256 * 4)
+                       return;
+
+               off &= 4095;
+
+               /*
+                * If we are reading offset 0, or our current index is
+                * greater than the offset, reset the hardware index counter.
+                */
+               if (off == 0 || index > off) {
+                       writeb(0, base);
+                       index = 0;
+               }
+
+               /*
+                * Increment the hardware index counter until we get to the
+                * required offset.  The read bytes are discarded.
+                */
+               while (index < off) {
+                       readb(base + page);
+                       index += 1;
+               }
+
+               while (len--) {
+                       *buf++ = readb(base + page);
+                       index += 1;
+               }
+       } else {
+               unsigned long base = (ec->easi
+                        ? &ec->resource[ECARD_RES_EASI]
+                        : &ec->resource[ECARD_RES_IOCSYNC])->start;
+               void __iomem *pbase = (void __iomem *)base;
+
+               if (!req->use_loader || !ec->loader) {
+                       off *= 4;
+                       while (len--) {
+                               *buf++ = readb(pbase + off);
+                               off += 4;
+                       }
+               } else {
+                       while(len--) {
+                               /*
+                                * The following is required by some
+                                * expansion card loader programs.
+                                */
+                               *(unsigned long *)0x108 = 0;
+                               *buf++ = ecard_loader_read(off++, base,
+                                                          ec->loader);
+                       }
+               }
+       }
+
+}
+
+static DECLARE_WAIT_QUEUE_HEAD(ecard_wait);
+static struct ecard_request *ecard_req;
+static DEFINE_MUTEX(ecard_mutex);
+
+/*
+ * Set up the expansion card daemon's page tables.
+ */
+static void ecard_init_pgtables(struct mm_struct *mm)
+{
+       struct vm_area_struct vma;
+
+       /* We want to set up the page tables for the following mapping:
+        *  Virtual     Physical
+        *  0x03000000  0x03000000
+        *  0x03010000  unmapped
+        *  0x03210000  0x03210000
+        *  0x03400000  unmapped
+        *  0x08000000  0x08000000
+        *  0x10000000  unmapped
+        *
+        * FIXME: we don't follow this 100% yet.
+        */
+       pgd_t *src_pgd, *dst_pgd;
+
+       src_pgd = pgd_offset(mm, (unsigned long)IO_BASE);
+       dst_pgd = pgd_offset(mm, IO_START);
+
+       memcpy(dst_pgd, src_pgd, sizeof(pgd_t) * (IO_SIZE / PGDIR_SIZE));
+
+       src_pgd = pgd_offset(mm, (unsigned long)EASI_BASE);
+       dst_pgd = pgd_offset(mm, EASI_START);
+
+       memcpy(dst_pgd, src_pgd, sizeof(pgd_t) * (EASI_SIZE / PGDIR_SIZE));
+
+       vma.vm_mm = mm;
+
+       flush_tlb_range(&vma, IO_START, IO_START + IO_SIZE);
+       flush_tlb_range(&vma, EASI_START, EASI_START + EASI_SIZE);
+}
+
+static int ecard_init_mm(void)
+{
+       struct mm_struct * mm = mm_alloc();
+       struct mm_struct *active_mm = current->active_mm;
+
+       if (!mm)
+               return -ENOMEM;
+
+       current->mm = mm;
+       current->active_mm = mm;
+       activate_mm(active_mm, mm);
+       mmdrop(active_mm);
+       ecard_init_pgtables(mm);
+       return 0;
+}
+
+static int
+ecard_task(void * unused)
+{
+       /*
+        * Allocate a mm.  We're not a lazy-TLB kernel task since we need
+        * to set page table entries where the user space would be.  Note
+        * that this also creates the page tables.  Failure is not an
+        * option here.
+        */
+       if (ecard_init_mm())
+               panic("kecardd: unable to alloc mm\n");
+
+       while (1) {
+               struct ecard_request *req;
+
+               wait_event_interruptible(ecard_wait, ecard_req != NULL);
+
+               req = xchg(&ecard_req, NULL);
+               if (req != NULL) {
+                       req->fn(req);
+                       complete(req->complete);
+               }
+       }
+}
+
+/*
+ * Wake the expansion card daemon to action our request.
+ *
+ * FIXME: The test here is not sufficient to detect if the
+ * kcardd is running.
+ */
+static void ecard_call(struct ecard_request *req)
+{
+       DECLARE_COMPLETION_ONSTACK(completion);
+
+       req->complete = &completion;
+
+       mutex_lock(&ecard_mutex);
+       ecard_req = req;
+       wake_up(&ecard_wait);
+
+       /*
+        * Now wait for kecardd to run.
+        */
+       wait_for_completion(&completion);
+       mutex_unlock(&ecard_mutex);
+}
+
+/* ======================= Mid-level card control ===================== */
+
+static void
+ecard_readbytes(void *addr, ecard_t *ec, int off, int len, int useld)
+{
+       struct ecard_request req;
+
+       req.fn          = ecard_task_readbytes;
+       req.ec          = ec;
+       req.address     = off;
+       req.length      = len;
+       req.use_loader  = useld;
+       req.buffer      = addr;
+
+       ecard_call(&req);
+}
+
+int ecard_readchunk(struct in_chunk_dir *cd, ecard_t *ec, int id, int num)
+{
+       struct ex_chunk_dir excd;
+       int index = 16;
+       int useld = 0;
+
+       if (!ec->cid.cd)
+               return 0;
+
+       while(1) {
+               ecard_readbytes(&excd, ec, index, 8, useld);
+               index += 8;
+               if (c_id(&excd) == 0) {
+                       if (!useld && ec->loader) {
+                               useld = 1;
+                               index = 0;
+                               continue;
+                       }
+                       return 0;
+               }
+               if (c_id(&excd) == 0xf0) { /* link */
+                       index = c_start(&excd);
+                       continue;
+               }
+               if (c_id(&excd) == 0x80) { /* loader */
+                       if (!ec->loader) {
+                               ec->loader = kmalloc(c_len(&excd),
+                                                              GFP_KERNEL);
+                               if (ec->loader)
+                                       ecard_readbytes(ec->loader, ec,
+                                                       (int)c_start(&excd),
+                                                       c_len(&excd), useld);
+                               else
+                                       return 0;
+                       }
+                       continue;
+               }
+               if (c_id(&excd) == id && num-- == 0)
+                       break;
+       }
+
+       if (c_id(&excd) & 0x80) {
+               switch (c_id(&excd) & 0x70) {
+               case 0x70:
+                       ecard_readbytes((unsigned char *)excd.d.string, ec,
+                                       (int)c_start(&excd), c_len(&excd),
+                                       useld);
+                       break;
+               case 0x00:
+                       break;
+               }
+       }
+       cd->start_offset = c_start(&excd);
+       memcpy(cd->d.string, excd.d.string, 256);
+       return 1;
+}
+
+/* ======================= Interrupt control ============================ */
+
+static void ecard_def_irq_enable(ecard_t *ec, int irqnr)
+{
+}
+
+static void ecard_def_irq_disable(ecard_t *ec, int irqnr)
+{
+}
+
+static int ecard_def_irq_pending(ecard_t *ec)
+{
+       return !ec->irqmask || readb(ec->irqaddr) & ec->irqmask;
+}
+
+static void ecard_def_fiq_enable(ecard_t *ec, int fiqnr)
+{
+       panic("ecard_def_fiq_enable called - impossible");
+}
+
+static void ecard_def_fiq_disable(ecard_t *ec, int fiqnr)
+{
+       panic("ecard_def_fiq_disable called - impossible");
+}
+
+static int ecard_def_fiq_pending(ecard_t *ec)
+{
+       return !ec->fiqmask || readb(ec->fiqaddr) & ec->fiqmask;
+}
+
+static expansioncard_ops_t ecard_default_ops = {
+       ecard_def_irq_enable,
+       ecard_def_irq_disable,
+       ecard_def_irq_pending,
+       ecard_def_fiq_enable,
+       ecard_def_fiq_disable,
+       ecard_def_fiq_pending
+};
+
+/*
+ * Enable and disable interrupts from expansion cards.
+ * (interrupts are disabled for these functions).
+ *
+ * They are not meant to be called directly, but via enable/disable_irq.
+ */
+static void ecard_irq_unmask(struct irq_data *d)
+{
+       ecard_t *ec = irq_data_get_irq_chip_data(d);
+
+       if (ec) {
+               if (!ec->ops)
+                       ec->ops = &ecard_default_ops;
+
+               if (ec->claimed && ec->ops->irqenable)
+                       ec->ops->irqenable(ec, d->irq);
+               else
+                       printk(KERN_ERR "ecard: rejecting request to "
+                               "enable IRQs for %d\n", d->irq);
+       }
+}
+
+static void ecard_irq_mask(struct irq_data *d)
+{
+       ecard_t *ec = irq_data_get_irq_chip_data(d);
+
+       if (ec) {
+               if (!ec->ops)
+                       ec->ops = &ecard_default_ops;
+
+               if (ec->ops && ec->ops->irqdisable)
+                       ec->ops->irqdisable(ec, d->irq);
+       }
+}
+
+static struct irq_chip ecard_chip = {
+       .name           = "ECARD",
+       .irq_ack        = ecard_irq_mask,
+       .irq_mask       = ecard_irq_mask,
+       .irq_unmask     = ecard_irq_unmask,
+};
+
+void ecard_enablefiq(unsigned int fiqnr)
+{
+       ecard_t *ec = slot_to_ecard(fiqnr);
+
+       if (ec) {
+               if (!ec->ops)
+                       ec->ops = &ecard_default_ops;
+
+               if (ec->claimed && ec->ops->fiqenable)
+                       ec->ops->fiqenable(ec, fiqnr);
+               else
+                       printk(KERN_ERR "ecard: rejecting request to "
+                               "enable FIQs for %d\n", fiqnr);
+       }
+}
+
+void ecard_disablefiq(unsigned int fiqnr)
+{
+       ecard_t *ec = slot_to_ecard(fiqnr);
+
+       if (ec) {
+               if (!ec->ops)
+                       ec->ops = &ecard_default_ops;
+
+               if (ec->ops->fiqdisable)
+                       ec->ops->fiqdisable(ec, fiqnr);
+       }
+}
+
+static void ecard_dump_irq_state(void)
+{
+       ecard_t *ec;
+
+       printk("Expansion card IRQ state:\n");
+
+       for (ec = cards; ec; ec = ec->next) {
+               if (ec->slot_no == 8)
+                       continue;
+
+               printk("  %d: %sclaimed, ",
+                      ec->slot_no, ec->claimed ? "" : "not ");
+
+               if (ec->ops && ec->ops->irqpending &&
+                   ec->ops != &ecard_default_ops)
+                       printk("irq %spending\n",
+                              ec->ops->irqpending(ec) ? "" : "not ");
+               else
+                       printk("irqaddr %p, mask = %02X, status = %02X\n",
+                              ec->irqaddr, ec->irqmask, readb(ec->irqaddr));
+       }
+}
+
+static void ecard_check_lockup(struct irq_desc *desc)
+{
+       static unsigned long last;
+       static int lockup;
+
+       /*
+        * If the timer interrupt has not run since the last million
+        * unrecognised expansion card interrupts, then there is
+        * something seriously wrong.  Disable the expansion card
+        * interrupts so at least we can continue.
+        *
+        * Maybe we ought to start a timer to re-enable them some time
+        * later?
+        */
+       if (last == jiffies) {
+               lockup += 1;
+               if (lockup > 1000000) {
+                       printk(KERN_ERR "\nInterrupt lockup detected - "
+                              "disabling all expansion card interrupts\n");
+
+                       desc->irq_data.chip->irq_mask(&desc->irq_data);
+                       ecard_dump_irq_state();
+               }
+       } else
+               lockup = 0;
+
+       /*
+        * If we did not recognise the source of this interrupt,
+        * warn the user, but don't flood the user with these messages.
+        */
+       if (!last || time_after(jiffies, last + 5*HZ)) {
+               last = jiffies;
+               printk(KERN_WARNING "Unrecognised interrupt from backplane\n");
+               ecard_dump_irq_state();
+       }
+}
+
+static void
+ecard_irq_handler(unsigned int irq, struct irq_desc *desc)
+{
+       ecard_t *ec;
+       int called = 0;
+
+       desc->irq_data.chip->irq_mask(&desc->irq_data);
+       for (ec = cards; ec; ec = ec->next) {
+               int pending;
+
+               if (!ec->claimed || !ec->irq || ec->slot_no == 8)
+                       continue;
+
+               if (ec->ops && ec->ops->irqpending)
+                       pending = ec->ops->irqpending(ec);
+               else
+                       pending = ecard_default_ops.irqpending(ec);
+
+               if (pending) {
+                       generic_handle_irq(ec->irq);
+                       called ++;
+               }
+       }
+       desc->irq_data.chip->irq_unmask(&desc->irq_data);
+
+       if (called == 0)
+               ecard_check_lockup(desc);
+}
+
+static void __iomem *__ecard_address(ecard_t *ec, card_type_t type, card_speed_t speed)
+{
+       void __iomem *address = NULL;
+       int slot = ec->slot_no;
+
+       if (ec->slot_no == 8)
+               return ECARD_MEMC8_BASE;
+
+       ectcr &= ~(1 << slot);
+
+       switch (type) {
+       case ECARD_MEMC:
+               if (slot < 4)
+                       address = ECARD_MEMC_BASE + (slot << 14);
+               break;
+
+       case ECARD_IOC:
+               if (slot < 4)
+                       address = ECARD_IOC_BASE + (slot << 14);
+               else
+                       address = ECARD_IOC4_BASE + ((slot - 4) << 14);
+               if (address)
+                       address += speed << 19;
+               break;
+
+       case ECARD_EASI:
+               address = ECARD_EASI_BASE + (slot << 24);
+               if (speed == ECARD_FAST)
+                       ectcr |= 1 << slot;
+               break;
+
+       default:
+               break;
+       }
+
+#ifdef IOMD_ECTCR
+       iomd_writeb(ectcr, IOMD_ECTCR);
+#endif
+       return address;
+}
+
+static int ecard_prints(struct seq_file *m, ecard_t *ec)
+{
+       seq_printf(m, "  %d: %s ", ec->slot_no, ec->easi ? "EASI" : "    ");
+
+       if (ec->cid.id == 0) {
+               struct in_chunk_dir incd;
+
+               seq_printf(m, "[%04X:%04X] ",
+                       ec->cid.manufacturer, ec->cid.product);
+
+               if (!ec->card_desc && ec->cid.cd &&
+                   ecard_readchunk(&incd, ec, 0xf5, 0)) {
+                       ec->card_desc = kmalloc(strlen(incd.d.string)+1, GFP_KERNEL);
+
+                       if (ec->card_desc)
+                               strcpy((char *)ec->card_desc, incd.d.string);
+               }
+
+               seq_printf(m, "%s\n", ec->card_desc ? ec->card_desc : "*unknown*");
+       } else
+               seq_printf(m, "Simple card %d\n", ec->cid.id);
+
+       return 0;
+}
+
+static int ecard_devices_proc_show(struct seq_file *m, void *v)
+{
+       ecard_t *ec = cards;
+
+       while (ec) {
+               ecard_prints(m, ec);
+               ec = ec->next;
+       }
+       return 0;
+}
+
+static int ecard_devices_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, ecard_devices_proc_show, NULL);
+}
+
+static const struct file_operations bus_ecard_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = ecard_devices_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static struct proc_dir_entry *proc_bus_ecard_dir = NULL;
+
+static void ecard_proc_init(void)
+{
+       proc_bus_ecard_dir = proc_mkdir("bus/ecard", NULL);
+       proc_create("devices", 0, proc_bus_ecard_dir, &bus_ecard_proc_fops);
+}
+
+#define ec_set_resource(ec,nr,st,sz)                           \
+       do {                                                    \
+               (ec)->resource[nr].name = dev_name(&ec->dev);   \
+               (ec)->resource[nr].start = st;                  \
+               (ec)->resource[nr].end = (st) + (sz) - 1;       \
+               (ec)->resource[nr].flags = IORESOURCE_MEM;      \
+       } while (0)
+
+static void __init ecard_free_card(struct expansion_card *ec)
+{
+       int i;
+
+       for (i = 0; i < ECARD_NUM_RESOURCES; i++)
+               if (ec->resource[i].flags)
+                       release_resource(&ec->resource[i]);
+
+       kfree(ec);
+}
+
+static struct expansion_card *__init ecard_alloc_card(int type, int slot)
+{
+       struct expansion_card *ec;
+       unsigned long base;
+       int i;
+
+       ec = kzalloc(sizeof(ecard_t), GFP_KERNEL);
+       if (!ec) {
+               ec = ERR_PTR(-ENOMEM);
+               goto nomem;
+       }
+
+       ec->slot_no = slot;
+       ec->easi = type == ECARD_EASI;
+       ec->irq = 0;
+       ec->fiq = 0;
+       ec->dma = NO_DMA;
+       ec->ops = &ecard_default_ops;
+
+       dev_set_name(&ec->dev, "ecard%d", slot);
+       ec->dev.parent = NULL;
+       ec->dev.bus = &ecard_bus_type;
+       ec->dev.dma_mask = &ec->dma_mask;
+       ec->dma_mask = (u64)0xffffffff;
+       ec->dev.coherent_dma_mask = ec->dma_mask;
+
+       if (slot < 4) {
+               ec_set_resource(ec, ECARD_RES_MEMC,
+                               PODSLOT_MEMC_BASE + (slot << 14),
+                               PODSLOT_MEMC_SIZE);
+               base = PODSLOT_IOC0_BASE + (slot << 14);
+       } else
+               base = PODSLOT_IOC4_BASE + ((slot - 4) << 14);
+
+#ifdef CONFIG_ARCH_RPC
+       if (slot < 8) {
+               ec_set_resource(ec, ECARD_RES_EASI,
+                               PODSLOT_EASI_BASE + (slot << 24),
+                               PODSLOT_EASI_SIZE);
+       }
+
+       if (slot == 8) {
+               ec_set_resource(ec, ECARD_RES_MEMC, NETSLOT_BASE, NETSLOT_SIZE);
+       } else
+#endif
+
+       for (i = 0; i <= ECARD_RES_IOCSYNC - ECARD_RES_IOCSLOW; i++)
+               ec_set_resource(ec, i + ECARD_RES_IOCSLOW,
+                               base + (i << 19), PODSLOT_IOC_SIZE);
+
+       for (i = 0; i < ECARD_NUM_RESOURCES; i++) {
+               if (ec->resource[i].flags &&
+                   request_resource(&iomem_resource, &ec->resource[i])) {
+                       dev_err(&ec->dev, "resource(s) not available\n");
+                       ec->resource[i].end -= ec->resource[i].start;
+                       ec->resource[i].start = 0;
+                       ec->resource[i].flags = 0;
+               }
+       }
+
+ nomem:
+       return ec;
+}
+
+static ssize_t ecard_show_irq(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct expansion_card *ec = ECARD_DEV(dev);
+       return sprintf(buf, "%u\n", ec->irq);
+}
+
+static ssize_t ecard_show_dma(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct expansion_card *ec = ECARD_DEV(dev);
+       return sprintf(buf, "%u\n", ec->dma);
+}
+
+static ssize_t ecard_show_resources(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct expansion_card *ec = ECARD_DEV(dev);
+       char *str = buf;
+       int i;
+
+       for (i = 0; i < ECARD_NUM_RESOURCES; i++)
+               str += sprintf(str, "%08x %08x %08lx\n",
+                               ec->resource[i].start,
+                               ec->resource[i].end,
+                               ec->resource[i].flags);
+
+       return str - buf;
+}
+
+static ssize_t ecard_show_vendor(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct expansion_card *ec = ECARD_DEV(dev);
+       return sprintf(buf, "%u\n", ec->cid.manufacturer);
+}
+
+static ssize_t ecard_show_device(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct expansion_card *ec = ECARD_DEV(dev);
+       return sprintf(buf, "%u\n", ec->cid.product);
+}
+
+static ssize_t ecard_show_type(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct expansion_card *ec = ECARD_DEV(dev);
+       return sprintf(buf, "%s\n", ec->easi ? "EASI" : "IOC");
+}
+
+static struct device_attribute ecard_dev_attrs[] = {
+       __ATTR(device,   S_IRUGO, ecard_show_device,    NULL),
+       __ATTR(dma,      S_IRUGO, ecard_show_dma,       NULL),
+       __ATTR(irq,      S_IRUGO, ecard_show_irq,       NULL),
+       __ATTR(resource, S_IRUGO, ecard_show_resources, NULL),
+       __ATTR(type,     S_IRUGO, ecard_show_type,      NULL),
+       __ATTR(vendor,   S_IRUGO, ecard_show_vendor,    NULL),
+       __ATTR_NULL,
+};
+
+
+int ecard_request_resources(struct expansion_card *ec)
+{
+       int i, err = 0;
+
+       for (i = 0; i < ECARD_NUM_RESOURCES; i++) {
+               if (ecard_resource_end(ec, i) &&
+                   !request_mem_region(ecard_resource_start(ec, i),
+                                       ecard_resource_len(ec, i),
+                                       ec->dev.driver->name)) {
+                       err = -EBUSY;
+                       break;
+               }
+       }
+
+       if (err) {
+               while (i--)
+                       if (ecard_resource_end(ec, i))
+                               release_mem_region(ecard_resource_start(ec, i),
+                                                  ecard_resource_len(ec, i));
+       }
+       return err;
+}
+EXPORT_SYMBOL(ecard_request_resources);
+
+void ecard_release_resources(struct expansion_card *ec)
+{
+       int i;
+
+       for (i = 0; i < ECARD_NUM_RESOURCES; i++)
+               if (ecard_resource_end(ec, i))
+                       release_mem_region(ecard_resource_start(ec, i),
+                                          ecard_resource_len(ec, i));
+}
+EXPORT_SYMBOL(ecard_release_resources);
+
+void ecard_setirq(struct expansion_card *ec, const struct expansion_card_ops *ops, void *irq_data)
+{
+       ec->irq_data = irq_data;
+       barrier();
+       ec->ops = ops;
+}
+EXPORT_SYMBOL(ecard_setirq);
+
+void __iomem *ecardm_iomap(struct expansion_card *ec, unsigned int res,
+                          unsigned long offset, unsigned long maxsize)
+{
+       unsigned long start = ecard_resource_start(ec, res);
+       unsigned long end = ecard_resource_end(ec, res);
+
+       if (offset > (end - start))
+               return NULL;
+
+       start += offset;
+       if (maxsize && end - start > maxsize)
+               end = start + maxsize;
+       
+       return devm_ioremap(&ec->dev, start, end - start);
+}
+EXPORT_SYMBOL(ecardm_iomap);
+
+/*
+ * Probe for an expansion card.
+ *
+ * If bit 1 of the first byte of the card is set, then the
+ * card does not exist.
+ */
+static int __init ecard_probe(int slot, unsigned irq, card_type_t type)
+{
+       ecard_t **ecp;
+       ecard_t *ec;
+       struct ex_ecid cid;
+       void __iomem *addr;
+       int i, rc;
+
+       ec = ecard_alloc_card(type, slot);
+       if (IS_ERR(ec)) {
+               rc = PTR_ERR(ec);
+               goto nomem;
+       }
+
+       rc = -ENODEV;
+       if ((addr = __ecard_address(ec, type, ECARD_SYNC)) == NULL)
+               goto nodev;
+
+       cid.r_zero = 1;
+       ecard_readbytes(&cid, ec, 0, 16, 0);
+       if (cid.r_zero)
+               goto nodev;
+
+       ec->cid.id      = cid.r_id;
+       ec->cid.cd      = cid.r_cd;
+       ec->cid.is      = cid.r_is;
+       ec->cid.w       = cid.r_w;
+       ec->cid.manufacturer = ecard_getu16(cid.r_manu);
+       ec->cid.product = ecard_getu16(cid.r_prod);
+       ec->cid.country = cid.r_country;
+       ec->cid.irqmask = cid.r_irqmask;
+       ec->cid.irqoff  = ecard_gets24(cid.r_irqoff);
+       ec->cid.fiqmask = cid.r_fiqmask;
+       ec->cid.fiqoff  = ecard_gets24(cid.r_fiqoff);
+       ec->fiqaddr     =
+       ec->irqaddr     = addr;
+
+       if (ec->cid.is) {
+               ec->irqmask = ec->cid.irqmask;
+               ec->irqaddr += ec->cid.irqoff;
+               ec->fiqmask = ec->cid.fiqmask;
+               ec->fiqaddr += ec->cid.fiqoff;
+       } else {
+               ec->irqmask = 1;
+               ec->fiqmask = 4;
+       }
+
+       for (i = 0; i < ARRAY_SIZE(blacklist); i++)
+               if (blacklist[i].manufacturer == ec->cid.manufacturer &&
+                   blacklist[i].product == ec->cid.product) {
+                       ec->card_desc = blacklist[i].type;
+                       break;
+               }
+
+       ec->irq = irq;
+
+       /*
+        * hook the interrupt handlers
+        */
+       if (slot < 8) {
+               irq_set_chip_and_handler(ec->irq, &ecard_chip,
+                                        handle_level_irq);
+               irq_set_chip_data(ec->irq, ec);
+               set_irq_flags(ec->irq, IRQF_VALID);
+       }
+
+#ifdef CONFIG_ARCH_RPC
+       /* On RiscPC, only first two slots have DMA capability */
+       if (slot < 2)
+               ec->dma = 2 + slot;
+#endif
+
+       for (ecp = &cards; *ecp; ecp = &(*ecp)->next);
+
+       *ecp = ec;
+       slot_to_expcard[slot] = ec;
+
+       device_register(&ec->dev);
+
+       return 0;
+
+ nodev:
+       ecard_free_card(ec);
+ nomem:
+       return rc;
+}
+
+/*
+ * Initialise the expansion card system.
+ * Locate all hardware - interrupt management and
+ * actual cards.
+ */
+static int __init ecard_init(void)
+{
+       struct task_struct *task;
+       int slot, irqbase;
+
+       irqbase = irq_alloc_descs(-1, 0, 8, -1);
+       if (irqbase < 0)
+               return irqbase;
+
+       task = kthread_run(ecard_task, NULL, "kecardd");
+       if (IS_ERR(task)) {
+               printk(KERN_ERR "Ecard: unable to create kernel thread: %ld\n",
+                      PTR_ERR(task));
+               irq_free_descs(irqbase, 8);
+               return PTR_ERR(task);
+       }
+
+       printk("Probing expansion cards\n");
+
+       for (slot = 0; slot < 8; slot ++) {
+               if (ecard_probe(slot, irqbase + slot, ECARD_EASI) == -ENODEV)
+                       ecard_probe(slot, irqbase + slot, ECARD_IOC);
+       }
+
+       ecard_probe(8, 11, ECARD_IOC);
+
+       irq_set_chained_handler(IRQ_EXPANSIONCARD, ecard_irq_handler);
+
+       ecard_proc_init();
+
+       return 0;
+}
+
+subsys_initcall(ecard_init);
+
+/*
+ *     ECARD "bus"
+ */
+static const struct ecard_id *
+ecard_match_device(const struct ecard_id *ids, struct expansion_card *ec)
+{
+       int i;
+
+       for (i = 0; ids[i].manufacturer != 65535; i++)
+               if (ec->cid.manufacturer == ids[i].manufacturer &&
+                   ec->cid.product == ids[i].product)
+                       return ids + i;
+
+       return NULL;
+}
+
+static int ecard_drv_probe(struct device *dev)
+{
+       struct expansion_card *ec = ECARD_DEV(dev);
+       struct ecard_driver *drv = ECARD_DRV(dev->driver);
+       const struct ecard_id *id;
+       int ret;
+
+       id = ecard_match_device(drv->id_table, ec);
+
+       ec->claimed = 1;
+       ret = drv->probe(ec, id);
+       if (ret)
+               ec->claimed = 0;
+       return ret;
+}
+
+static int ecard_drv_remove(struct device *dev)
+{
+       struct expansion_card *ec = ECARD_DEV(dev);
+       struct ecard_driver *drv = ECARD_DRV(dev->driver);
+
+       drv->remove(ec);
+       ec->claimed = 0;
+
+       /*
+        * Restore the default operations.  We ensure that the
+        * ops are set before we change the data.
+        */
+       ec->ops = &ecard_default_ops;
+       barrier();
+       ec->irq_data = NULL;
+
+       return 0;
+}
+
+/*
+ * Before rebooting, we must make sure that the expansion card is in a
+ * sensible state, so it can be re-detected.  This means that the first
+ * page of the ROM must be visible.  We call the expansion cards reset
+ * handler, if any.
+ */
+static void ecard_drv_shutdown(struct device *dev)
+{
+       struct expansion_card *ec = ECARD_DEV(dev);
+       struct ecard_driver *drv = ECARD_DRV(dev->driver);
+       struct ecard_request req;
+
+       if (dev->driver) {
+               if (drv->shutdown)
+                       drv->shutdown(ec);
+               ec->claimed = 0;
+       }
+
+       /*
+        * If this card has a loader, call the reset handler.
+        */
+       if (ec->loader) {
+               req.fn = ecard_task_reset;
+               req.ec = ec;
+               ecard_call(&req);
+       }
+}
+
+int ecard_register_driver(struct ecard_driver *drv)
+{
+       drv->drv.bus = &ecard_bus_type;
+
+       return driver_register(&drv->drv);
+}
+
+void ecard_remove_driver(struct ecard_driver *drv)
+{
+       driver_unregister(&drv->drv);
+}
+
+static int ecard_match(struct device *_dev, struct device_driver *_drv)
+{
+       struct expansion_card *ec = ECARD_DEV(_dev);
+       struct ecard_driver *drv = ECARD_DRV(_drv);
+       int ret;
+
+       if (drv->id_table) {
+               ret = ecard_match_device(drv->id_table, ec) != NULL;
+       } else {
+               ret = ec->cid.id == drv->id;
+       }
+
+       return ret;
+}
+
+struct bus_type ecard_bus_type = {
+       .name           = "ecard",
+       .dev_attrs      = ecard_dev_attrs,
+       .match          = ecard_match,
+       .probe          = ecard_drv_probe,
+       .remove         = ecard_drv_remove,
+       .shutdown       = ecard_drv_shutdown,
+};
+
+static int ecard_bus_init(void)
+{
+       return bus_register(&ecard_bus_type);
+}
+
+postcore_initcall(ecard_bus_init);
+
+EXPORT_SYMBOL(ecard_readchunk);
+EXPORT_SYMBOL(ecard_register_driver);
+EXPORT_SYMBOL(ecard_remove_driver);
+EXPORT_SYMBOL(ecard_bus_type);
diff --git a/arch/arm/mach-rpc/ecard.h b/arch/arm/mach-rpc/ecard.h
new file mode 100644 (file)
index 0000000..4642d43
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ *  ecard.h
+ *
+ *  Copyright 2007 Russell King
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/* Definitions internal to ecard.c - for it's use only!!
+ *
+ * External expansion card header as read from the card
+ */
+struct ex_ecid {
+       unsigned char   r_irq:1;
+       unsigned char   r_zero:1;
+       unsigned char   r_fiq:1;
+       unsigned char   r_id:4;
+       unsigned char   r_a:1;
+
+       unsigned char   r_cd:1;
+       unsigned char   r_is:1;
+       unsigned char   r_w:2;
+       unsigned char   r_r1:4;
+
+       unsigned char   r_r2:8;
+
+       unsigned char   r_prod[2];
+
+       unsigned char   r_manu[2];
+
+       unsigned char   r_country;
+
+       unsigned char   r_fiqmask;
+       unsigned char   r_fiqoff[3];
+
+       unsigned char   r_irqmask;
+       unsigned char   r_irqoff[3];
+};
+
+/*
+ * Chunk directory entry as read from the card
+ */
+struct ex_chunk_dir {
+       unsigned char r_id;
+       unsigned char r_len[3];
+       unsigned long r_start;
+       union {
+               char string[256];
+               char data[1];
+       } d;
+#define c_id(x)                ((x)->r_id)
+#define c_len(x)       ((x)->r_len[0]|((x)->r_len[1]<<8)|((x)->r_len[2]<<16))
+#define c_start(x)     ((x)->r_start)
+};
+
+typedef enum ecard_type {              /* Cards address space          */
+       ECARD_IOC,
+       ECARD_MEMC,
+       ECARD_EASI
+} card_type_t;
+
+typedef enum {                         /* Speed for ECARD_IOC space    */
+       ECARD_SLOW       = 0,
+       ECARD_MEDIUM     = 1,
+       ECARD_FAST       = 2,
+       ECARD_SYNC       = 3
+} card_speed_t;
index 3d2037496e38cd4955f29ecb9ca1f09e715e7608..6868e178274d93893983874e076730aa753e6f06 100644 (file)
@@ -42,6 +42,4 @@
  */
 #define FIQ_START              64
 
-#define IRQ_TIMER              IRQ_TIMER0
-
 #define NR_IRQS                        128
index 3d44a59fc0df38e10bcf492f987c274e17c5da1e..731552d68adfe76a5a8b2f2d1235c0a90c03c350 100644 (file)
@@ -98,15 +98,9 @@ static void __init rpc_map_io(void)
 }
 
 static struct resource acornfb_resources[] = {
-       {       /* VIDC */
-               .start          = 0x03400000,
-               .end            = 0x035fffff,
-               .flags          = IORESOURCE_MEM,
-       }, {
-               .start          = IRQ_VSYNCPULSE,
-               .end            = IRQ_VSYNCPULSE,
-               .flags          = IORESOURCE_IRQ,
-       },
+       /* VIDC */
+       DEFINE_RES_MEM(0x03400000, 0x00200000),
+       DEFINE_RES_IRQ(IRQ_VSYNCPULSE),
 };
 
 static struct platform_device acornfb_device = {
@@ -120,11 +114,7 @@ static struct platform_device acornfb_device = {
 };
 
 static struct resource iomd_resources[] = {
-       {
-               .start          = 0x03200000,
-               .end            = 0x0320ffff,
-               .flags          = IORESOURCE_MEM,
-       },
+       DEFINE_RES_MEM(0x03200000, 0x10000),
 };
 
 static struct platform_device iomd_device = {
@@ -134,18 +124,25 @@ static struct platform_device iomd_device = {
        .resource               = iomd_resources,
 };
 
+static struct resource iomd_kart_resources[] = {
+       DEFINE_RES_IRQ(IRQ_KEYBOARDRX),
+       DEFINE_RES_IRQ(IRQ_KEYBOARDTX),
+};
+
 static struct platform_device kbd_device = {
        .name                   = "kart",
        .id                     = -1,
        .dev                    = {
                .parent         = &iomd_device.dev,
        },
+       .num_resources          = ARRAY_SIZE(iomd_kart_resources),
+       .resource               = iomd_kart_resources,
 };
 
 static struct plat_serial8250_port serial_platform_data[] = {
        {
                .mapbase        = 0x03010fe0,
-               .irq            = 10,
+               .irq            = IRQ_SERIALPORT,
                .uartclk        = 1843200,
                .regshift       = 2,
                .iotype         = UPIO_MEM,
@@ -167,21 +164,9 @@ static struct pata_platform_info pata_platform_data = {
 };
 
 static struct resource pata_resources[] = {
-       [0] = {
-               .start          = 0x030107c0,
-               .end            = 0x030107df,
-               .flags          = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start          = 0x03010fd8,
-               .end            = 0x03010fdb,
-               .flags          = IORESOURCE_MEM,
-       },
-       [2] = {
-               .start          = IRQ_HARDDISK,
-               .end            = IRQ_HARDDISK,
-               .flags          = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0x030107c0, 0x20),
+       DEFINE_RES_MEM(0x03010fd8, 0x04),
+       DEFINE_RES_IRQ(IRQ_HARDDISK),
 };
 
 static struct platform_device pata_device = {
diff --git a/arch/arm/mach-rpc/time.c b/arch/arm/mach-rpc/time.c
new file mode 100644 (file)
index 0000000..581fca9
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ *  linux/arch/arm/common/time-acorn.c
+ *
+ *  Copyright (c) 1996-2000 Russell King.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ *  Changelog:
+ *   24-Sep-1996       RMK     Created
+ *   10-Oct-1996       RMK     Brought up to date with arch-sa110eval
+ *   04-Dec-1997       RMK     Updated for new arch/arm/time.c
+ *   13=Jun-2004       DS      Moved to arch/arm/common b/c shared w/CLPS7500
+ */
+#include <linux/timex.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/io.h>
+
+#include <mach/hardware.h>
+#include <asm/hardware/ioc.h>
+
+#include <asm/mach/time.h>
+
+unsigned long ioc_timer_gettimeoffset(void)
+{
+       unsigned int count1, count2, status;
+       long offset;
+
+       ioc_writeb (0, IOC_T0LATCH);
+       barrier ();
+       count1 = ioc_readb(IOC_T0CNTL) | (ioc_readb(IOC_T0CNTH) << 8);
+       barrier ();
+       status = ioc_readb(IOC_IRQREQA);
+       barrier ();
+       ioc_writeb (0, IOC_T0LATCH);
+       barrier ();
+       count2 = ioc_readb(IOC_T0CNTL) | (ioc_readb(IOC_T0CNTH) << 8);
+
+       offset = count2;
+       if (count2 < count1) {
+               /*
+                * We have not had an interrupt between reading count1
+                * and count2.
+                */
+               if (status & (1 << 5))
+                       offset -= LATCH;
+       } else if (count2 > count1) {
+               /*
+                * We have just had another interrupt between reading
+                * count1 and count2.
+                */
+               offset -= LATCH;
+       }
+
+       offset = (LATCH - offset) * (tick_nsec / 1000);
+       return (offset + LATCH/2) / LATCH;
+}
+
+void __init ioctime_init(void)
+{
+       ioc_writeb(LATCH & 255, IOC_T0LTCHL);
+       ioc_writeb(LATCH >> 8, IOC_T0LTCHH);
+       ioc_writeb(0, IOC_T0GO);
+}
+
+static irqreturn_t
+ioc_timer_interrupt(int irq, void *dev_id)
+{
+       timer_tick();
+       return IRQ_HANDLED;
+}
+
+static struct irqaction ioc_timer_irq = {
+       .name           = "timer",
+       .flags          = IRQF_DISABLED,
+       .handler        = ioc_timer_interrupt
+};
+
+/*
+ * Set up timer interrupt.
+ */
+static void __init ioc_timer_init(void)
+{
+       ioctime_init();
+       setup_irq(IRQ_TIMER0, &ioc_timer_irq);
+}
+
+struct sys_timer ioc_timer = {
+       .init           = ioc_timer_init,
+       .offset         = ioc_timer_gettimeoffset,
+};
+
index 8b44ddc8041ce4c1cf410435585caeb8f379193a..58b224498b35ad7d3fc6c2b034780f67921f7f9f 100644 (file)
@@ -36,7 +36,6 @@
 #include <linux/io.h>
 #include <linux/slab.h>
 
-#include <asm/irq.h>
 #include <mach/hardware.h>
 #include <asm/hardware/iomd.h>
 #include <asm/system.h>
@@ -46,6 +45,11 @@ MODULE_DESCRIPTION("Acorn RiscPC PS/2 keyboard controller driver");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("platform:kart");
 
+struct rpckbd_data {
+       int tx_irq;
+       int rx_irq;
+};
+
 static int rpckbd_write(struct serio *port, unsigned char val)
 {
        while (!(iomd_readb(IOMD_KCTRL) & (1 << 7)))
@@ -78,19 +82,21 @@ static irqreturn_t rpckbd_tx(int irq, void *dev_id)
 
 static int rpckbd_open(struct serio *port)
 {
+       struct rpckbd_data *rpckbd = port->port_data;
+
        /* Reset the keyboard state machine. */
        iomd_writeb(0, IOMD_KCTRL);
        iomd_writeb(8, IOMD_KCTRL);
        iomd_readb(IOMD_KARTRX);
 
-       if (request_irq(IRQ_KEYBOARDRX, rpckbd_rx, 0, "rpckbd", port) != 0) {
+       if (request_irq(rpckbd->rx_irq, rpckbd_rx, 0, "rpckbd", port) != 0) {
                printk(KERN_ERR "rpckbd.c: Could not allocate keyboard receive IRQ\n");
                return -EBUSY;
        }
 
-       if (request_irq(IRQ_KEYBOARDTX, rpckbd_tx, 0, "rpckbd", port) != 0) {
+       if (request_irq(rpckbd->tx_irq, rpckbd_tx, 0, "rpckbd", port) != 0) {
                printk(KERN_ERR "rpckbd.c: Could not allocate keyboard transmit IRQ\n");
-               free_irq(IRQ_KEYBOARDRX, port);
+               free_irq(rpckbd->rx_irq, port);
                return -EBUSY;
        }
 
@@ -99,8 +105,10 @@ static int rpckbd_open(struct serio *port)
 
 static void rpckbd_close(struct serio *port)
 {
-       free_irq(IRQ_KEYBOARDRX, port);
-       free_irq(IRQ_KEYBOARDTX, port);
+       struct rpckbd_data *rpckbd = port->port_data;
+
+       free_irq(rpckbd->rx_irq, port);
+       free_irq(rpckbd->tx_irq, port);
 }
 
 /*
@@ -109,17 +117,35 @@ static void rpckbd_close(struct serio *port)
  */
 static int __devinit rpckbd_probe(struct platform_device *dev)
 {
+       struct rpckbd_data *rpckbd;
        struct serio *serio;
+       int tx_irq, rx_irq;
+
+       rx_irq = platform_get_irq(dev, 0);
+       if (rx_irq <= 0)
+               return rx_irq < 0 ? rx_irq : -ENXIO;
+
+       tx_irq = platform_get_irq(dev, 1);
+       if (tx_irq <= 0)
+               return tx_irq < 0 ? tx_irq : -ENXIO;
 
        serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
-       if (!serio)
+       rpckbd = kzalloc(sizeof(*rpckbd), GFP_KERNEL);
+       if (!serio || !rpckbd) {
+               kfree(rpckbd);
+               kfree(serio);
                return -ENOMEM;
+       }
+
+       rpckbd->rx_irq = rx_irq;
+       rpckbd->tx_irq = tx_irq;
 
        serio->id.type          = SERIO_8042;
        serio->write            = rpckbd_write;
        serio->open             = rpckbd_open;
        serio->close            = rpckbd_close;
        serio->dev.parent       = &dev->dev;
+       serio->port_data        = rpckbd;
        strlcpy(serio->name, "RiscPC PS/2 kbd port", sizeof(serio->name));
        strlcpy(serio->phys, "rpckbd/serio0", sizeof(serio->phys));
 
@@ -131,7 +157,11 @@ static int __devinit rpckbd_probe(struct platform_device *dev)
 static int __devexit rpckbd_remove(struct platform_device *dev)
 {
        struct serio *serio = platform_get_drvdata(dev);
+       struct rpckbd_data *rpckbd = serio->port_data;
+
        serio_unregister_port(serio);
+       kfree(rpckbd);
+
        return 0;
 }
 
index a750aa72b8ef27249a8925e49feee8cf5baf1811..2a28b4ad1975b8f66bb846f41f5928bfdaf880d3 100644 (file)
@@ -305,7 +305,7 @@ arxescsi_probe(struct expansion_card *ec, const struct ecard_id *id)
        info->base = base;
 
        info->info.scsi.io_base         = base + 0x2000;
-       info->info.scsi.irq             = NO_IRQ;
+       info->info.scsi.irq             = 0;
        info->info.scsi.dma             = NO_DMA;
        info->info.scsi.io_shift        = 5;
        info->info.ifcfg.clockrate      = 24; /* MHz */
index e85c40b6e19b162bdff9a20c203af426b746cf41..6206a666a8ec6d76a5ecba29f5069d77be339b61 100644 (file)
@@ -2176,7 +2176,7 @@ static void fas216_done(FAS216_Info *info, unsigned int result)
        fn = (void (*)(FAS216_Info *, struct scsi_cmnd *, unsigned int))SCpnt->host_scribble;
        fn(info, SCpnt, result);
 
-       if (info->scsi.irq != NO_IRQ) {
+       if (info->scsi.irq) {
                spin_lock_irqsave(&info->host_lock, flags);
                if (info->scsi.phase == PHASE_IDLE)
                        fas216_kick(info);
@@ -2276,7 +2276,7 @@ static int fas216_noqueue_command_lck(struct scsi_cmnd *SCpnt,
         * We should only be using this if we don't have an interrupt.
         * Provide some "incentive" to use the queueing code.
         */
-       BUG_ON(info->scsi.irq != NO_IRQ);
+       BUG_ON(info->scsi.irq);
 
        info->internal_done = 0;
        fas216_queue_command_lck(SCpnt, fas216_internal_done);
index 84b7127c01212409a97f793d6f87a8bdb0a17c80..df2e1b3ddfe230da9aef38355d7a3014cd8c7e0e 100644 (file)
 #ifndef FAS216_H
 #define FAS216_H
 
-#ifndef NO_IRQ
-#define NO_IRQ 255
-#endif
-
 #include <scsi/scsi_eh.h>
 
 #include "queue.h"