summaryrefslogtreecommitdiffstats
path: root/drivers/zorro
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1998-08-25 09:12:35 +0000
committerRalf Baechle <ralf@linux-mips.org>1998-08-25 09:12:35 +0000
commitc7fc24dc4420057f103afe8fc64524ebc25c5d37 (patch)
tree3682407a599b8f9f03fc096298134cafba1c9b2f /drivers/zorro
parent1d793fade8b063fde3cf275bf1a5c2d381292cd9 (diff)
o Merge with Linux 2.1.116.
o New Newport console code. o New G364 console code.
Diffstat (limited to 'drivers/zorro')
-rw-r--r--drivers/zorro/.cvsignore2
-rw-r--r--drivers/zorro/Makefile32
-rw-r--r--drivers/zorro/proc.c167
-rw-r--r--drivers/zorro/zorro.c229
-rw-r--r--drivers/zorro/zorrosyms.c23
5 files changed, 453 insertions, 0 deletions
diff --git a/drivers/zorro/.cvsignore b/drivers/zorro/.cvsignore
new file mode 100644
index 000000000..857dd22e9
--- /dev/null
+++ b/drivers/zorro/.cvsignore
@@ -0,0 +1,2 @@
+.depend
+.*.flags
diff --git a/drivers/zorro/Makefile b/drivers/zorro/Makefile
new file mode 100644
index 000000000..9aa883932
--- /dev/null
+++ b/drivers/zorro/Makefile
@@ -0,0 +1,32 @@
+#
+# Makefile for the Zorro bus specific drivers.
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+# Note 2! The CFLAGS definition is now inherited from the
+# parent makefile.
+#
+
+SUB_DIRS :=
+MOD_SUB_DIRS := $(SUB_DIRS)
+ALL_SUB_DIRS := $(SUB_DIRS)
+
+L_TARGET := zorro.a
+
+# Nasty trick as nobody references zorrosyms.o, but we still want it linked.
+ifeq ($(CONFIG_MODULES),y)
+O_TARGET = zorro_syms.o
+OX_OBJS = zorrosyms.o
+O_OBJS = zorro.o
+L_OBJS := zorro_syms.o
+else
+L_OBJS := zorro.o
+endif
+
+ifdef CONFIG_PROC_FS
+L_OBJS += proc.o
+endif
+
+include $(TOPDIR)/Rules.make
diff --git a/drivers/zorro/proc.c b/drivers/zorro/proc.c
new file mode 100644
index 000000000..4f9243359
--- /dev/null
+++ b/drivers/zorro/proc.c
@@ -0,0 +1,167 @@
+/*
+ * $Id: proc.c,v 1.1.2.1 1998/06/07 23:21:01 geert Exp $
+ *
+ * Procfs interface for the Zorro bus.
+ *
+ * Copyright (C) 1998 Geert Uytterhoeven
+ *
+ * Heavily based on the procfs interface for the PCI bus, which is
+ *
+ * Copyright (C) 1997, 1998 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ */
+
+#include <linux/types.h>
+#include <linux/zorro.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <asm/uaccess.h>
+#include <asm/amigahw.h>
+#include <asm/setup.h>
+
+static loff_t
+proc_bus_zorro_lseek(struct file *file, loff_t off, int whence)
+{
+ loff_t new;
+
+ switch (whence) {
+ case 0:
+ new = off;
+ break;
+ case 1:
+ new = file->f_pos + off;
+ break;
+ case 2:
+ new = sizeof(struct ConfigDev) + off;
+ break;
+ default:
+ return -EINVAL;
+ }
+ if (new < 0 || new > sizeof(struct ConfigDev))
+ return -EINVAL;
+ return (file->f_pos = new);
+}
+
+static ssize_t
+proc_bus_zorro_read(struct file *file, char *buf, size_t nbytes, loff_t *ppos)
+{
+ struct inode *ino = file->f_dentry->d_inode;
+ struct proc_dir_entry *dp = ino->u.generic_ip;
+ struct ConfigDev *cd = dp->data;
+ int pos = *ppos;
+
+ if (pos >= sizeof(struct ConfigDev))
+ return 0;
+ if (nbytes >= sizeof(struct ConfigDev))
+ nbytes = sizeof(struct ConfigDev);
+ if (pos + nbytes > sizeof(struct ConfigDev))
+ nbytes = sizeof(struct ConfigDev) - pos;
+ if (copy_to_user(buf, cd, nbytes))
+ return -EFAULT;
+ *ppos += nbytes;
+
+ return nbytes;
+}
+
+static struct file_operations proc_bus_zorro_operations = {
+ proc_bus_zorro_lseek,
+ proc_bus_zorro_read,
+ NULL, /* write */
+ NULL, /* readdir */
+ NULL, /* poll */
+ NULL, /* ioctl */
+ NULL, /* mmap */
+ NULL, /* no special open code */
+ NULL, /* no special release code */
+ NULL /* can't fsync */
+};
+
+static struct inode_operations proc_bus_zorro_inode_operations = {
+ &proc_bus_zorro_operations, /* default base directory file-ops */
+ NULL, /* create */
+ NULL, /* lookup */
+ NULL, /* link */
+ NULL, /* unlink */
+ NULL, /* symlink */
+ NULL, /* mkdir */
+ NULL, /* rmdir */
+ NULL, /* mknod */
+ NULL, /* rename */
+ NULL, /* readlink */
+ NULL, /* follow_link */
+ NULL, /* readpage */
+ NULL, /* writepage */
+ NULL, /* bmap */
+ NULL, /* truncate */
+ NULL /* permission */
+};
+
+int
+get_zorro_dev_info(char *buf, char **start, off_t pos, int count, int wr)
+{
+ u_int slot;
+ off_t at = 0;
+ int len, cnt;
+
+ for (slot = cnt = 0; slot < zorro_num_autocon && count > cnt; slot++) {
+ struct ConfigDev *cd = &zorro_autocon[slot];
+ u16 manuf = cd->cd_Rom.er_Manufacturer;
+ u8 prod = cd->cd_Rom.er_Product;
+ u8 epc;
+ if (manuf == ZORRO_MANUF(ZORRO_PROD_GVP_EPC_BASE) &&
+ prod == ZORRO_PROD(ZORRO_PROD_GVP_EPC_BASE)) {
+ /* GVP quirk */
+ u32 addr = (u32)cd->cd_BoardAddr;
+ epc = (*(u16 *)ZTWO_VADDR(addr+0x8000)) & GVP_PRODMASK;
+ } else
+ epc = 0;
+ len = sprintf(buf, "%02x\t%04x%02x%02x\t%08x\t%08x\t%02x\n",
+ slot, manuf, prod, epc, (u32)cd->cd_BoardAddr,
+ cd->cd_BoardSize, cd->cd_Rom.er_Type);
+ at += len;
+ if (at >= pos) {
+ if (!*start) {
+ *start = buf + (pos - (at - len));
+ cnt = at - pos;
+ } else
+ cnt += len;
+ buf += len;
+ }
+ }
+ return (count > cnt) ? cnt : count;
+}
+
+static struct proc_dir_entry proc_zorro_devices = {
+ PROC_BUS_ZORRO_DEVICES, 7, "devices",
+ S_IFREG | S_IRUGO, 1, 0, 0,
+ 0, &proc_array_inode_operations,
+ get_zorro_dev_info
+};
+
+static struct proc_dir_entry *proc_bus_zorro_dir;
+
+__initfunc(static int zorro_proc_attach_device(u_int slot))
+{
+ struct proc_dir_entry *entry;
+ char name[4];
+
+ sprintf(name, "%02x", slot);
+ entry = create_proc_entry(name, S_IFREG | S_IRUGO, proc_bus_zorro_dir);
+ if (!entry)
+ return -ENOMEM;
+ entry->ops = &proc_bus_zorro_inode_operations;
+ entry->data = &zorro_autocon[slot];
+ entry->size = sizeof(struct ConfigDev);
+ return 0;
+}
+
+__initfunc(void zorro_proc_init(void))
+{
+ u_int slot;
+
+ if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(ZORRO))
+ return;
+ proc_bus_zorro_dir = create_proc_entry("zorro", S_IFDIR, proc_bus);
+ proc_register(proc_bus_zorro_dir, &proc_zorro_devices);
+ for (slot = 0; slot < zorro_num_autocon; slot++)
+ zorro_proc_attach_device(slot);
+}
diff --git a/drivers/zorro/zorro.c b/drivers/zorro/zorro.c
new file mode 100644
index 000000000..108bd6700
--- /dev/null
+++ b/drivers/zorro/zorro.c
@@ -0,0 +1,229 @@
+/*
+ * $Id: zorro.c,v 1.1.2.1 1998/06/07 23:21:02 geert Exp $
+ *
+ * Zorro Bus Services
+ *
+ * Copyright (C) 1995-1998 Geert Uytterhoeven
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file COPYING in the main directory of this archive
+ * for more details.
+ */
+
+
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/zorro.h>
+#include <asm/setup.h>
+#include <asm/bitops.h>
+#include <asm/amigahw.h>
+
+
+ /*
+ * Expansion Devices
+ */
+
+u_int zorro_num_autocon = 0;
+struct ConfigDev zorro_autocon[ZORRO_NUM_AUTO];
+static u32 zorro_autocon_parts[ZORRO_NUM_AUTO] = { 0, };
+
+
+ /*
+ * Find the key for the next unconfigured expansion device of a specific
+ * type.
+ *
+ * Part is a device specific number (0 <= part <= 31) to allow for the
+ * independent configuration of independent parts of an expansion board.
+ * Thanks to Jes Soerensen for this idea!
+ *
+ * Index is used to specify the first board in the autocon list
+ * to be tested. It was inserted in order to solve the problem
+ * with the GVP boards that use the same product code, but
+ * it should help if there are other companies which use the same
+ * method as GVP. Drivers for boards which are not using this
+ * method do not need to think of this - just set index = 0.
+ *
+ * Example:
+ *
+ * while ((key = zorro_find(ZORRO_PROD_MY_BOARD, MY_PART, 0))) {
+ * cd = zorro_get_board(key);
+ * initialise_this_board;
+ * zorro_config_board(key, MY_PART);
+ * }
+ */
+
+u_int zorro_find(zorro_id id, u_int part, u_int index)
+{
+ u16 manuf = ZORRO_MANUF(id);
+ u8 prod = ZORRO_PROD(id);
+ u8 epc = ZORRO_EPC(id);
+ u_int key;
+ const struct ConfigDev *cd;
+ u32 addr;
+
+ if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(ZORRO))
+ return 0;
+
+ if (part > 31) {
+ printk("zorro_find: bad part %d\n", part);
+ return 0;
+ }
+
+ for (key = index+1; key <= zorro_num_autocon; key++) {
+ cd = &zorro_autocon[key-1];
+ addr = (u32)cd->cd_BoardAddr;
+ if ((cd->cd_Rom.er_Manufacturer == manuf) &&
+ (cd->cd_Rom.er_Product == prod) &&
+ !(zorro_autocon_parts[key-1] & (1<<part)) &&
+ (manuf != ZORRO_MANUF(ZORRO_PROD_GVP_EPC_BASE) ||
+ prod != ZORRO_PROD(ZORRO_PROD_GVP_EPC_BASE) || /* GVP quirk */
+ (*(u16 *)ZTWO_VADDR(addr+0x8000) & GVP_PRODMASK) == epc))
+ return key;
+ }
+ return 0;
+}
+
+
+ /*
+ * Get the board corresponding to a specific key
+ */
+
+const struct ConfigDev *zorro_get_board(u_int key)
+{
+ if ((key < 1) || (key > zorro_num_autocon)) {
+ printk("zorro_get_board: bad key %d\n", key);
+ return NULL;
+ }
+ return &zorro_autocon[key-1];
+}
+
+
+ /*
+ * Mark a part of a board as configured
+ */
+
+void zorro_config_board(u_int key, u_int part)
+{
+ if ((key < 1) || (key > zorro_num_autocon))
+ printk("zorro_config_board: bad key %d\n", key);
+ else if (part > 31)
+ printk("zorro_config_board: bad part %d\n", part);
+ else if (zorro_autocon_parts[key-1] & (1<<part))
+ printk("zorro_config_board: key %d part %d is already configured\n",
+ key, part);
+ else
+ zorro_autocon_parts[key-1] |= 1<<part;
+}
+
+
+ /*
+ * Mark a part of a board as unconfigured
+ *
+ * This function is mainly intended for the unloading of LKMs
+ */
+
+void zorro_unconfig_board(u_int key, u_int part)
+{
+ if ((key < 1) || (key > zorro_num_autocon))
+ printk("zorro_unconfig_board: bad key %d\n", key);
+ else if (part > 31)
+ printk("zorro_unconfig_board: bad part %d\n", part);
+ else if (!(zorro_autocon_parts[key-1] & (1<<part)))
+ printk("zorro_config_board: key %d part %d is not yet configured\n",
+ key, part);
+ else
+ zorro_autocon_parts[key-1] &= ~(1<<part);
+}
+
+
+ /*
+ * Bitmask indicating portions of available Zorro II RAM that are unused
+ * by the system. Every bit represents a 64K chunk, for a maximum of 8MB
+ * (128 chunks, physical 0x00200000-0x009fffff).
+ *
+ * If you want to use (= allocate) portions of this RAM, you should clear
+ * the corresponding bits.
+ *
+ * Possible uses:
+ * - z2ram device
+ * - SCSI DMA bounce buffers
+ */
+
+u32 zorro_unused_z2ram[4] = { 0, 0, 0, 0 };
+
+
+__initfunc(static void mark_region(u32 addr, u_int size, int flag))
+{
+ u32 start, end;
+
+ if (flag) {
+ start = (addr+Z2RAM_CHUNKMASK) & ~Z2RAM_CHUNKMASK;
+ end = (addr+size) & ~Z2RAM_CHUNKMASK;
+ } else {
+ start = addr & ~Z2RAM_CHUNKMASK;
+ end = (addr+size+Z2RAM_CHUNKMASK) & ~Z2RAM_CHUNKMASK;
+ }
+ if (end <= Z2RAM_START || start >= Z2RAM_END)
+ return;
+ start = start < Z2RAM_START ? 0x00000000 : start-Z2RAM_START;
+ end = end > Z2RAM_END ? Z2RAM_SIZE : end-Z2RAM_START;
+ while (start < end) {
+ u32 chunk = start>>Z2RAM_CHUNKSHIFT;
+ if (flag)
+ set_bit(chunk, zorro_unused_z2ram);
+ else
+ clear_bit(chunk, zorro_unused_z2ram);
+ start += Z2RAM_CHUNKSIZE;
+ }
+}
+
+
+ /*
+ * Initialization
+ */
+
+__initfunc(void zorro_init(void))
+{
+ u_int i, j;
+ u32 disabled_z2mem = 0;
+
+ if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(ZORRO)) {
+ printk("Zorro: No Zorro bus detected\n");
+ return;
+ }
+
+ printk("Zorro: Probing AutoConfig expansion devices: %d device%s\n",
+ zorro_num_autocon, zorro_num_autocon == 1 ? "" : "s");
+
+ /* Mark all available Zorro II memory */
+ for (i = 0; i < zorro_num_autocon; i++) {
+ const struct ConfigDev *cd = &zorro_autocon[i];
+ if (cd->cd_Rom.er_Type & ERTF_MEMLIST)
+ mark_region((u32)cd->cd_BoardAddr, cd->cd_BoardSize, 1);
+ }
+
+ /* Unmark all used Zorro II memory */
+ for (i = 0; i < m68k_num_memory; i++)
+ if (m68k_memory[i].addr < 16*1024*1024) {
+ if (AMIGAHW_PRESENT(ZORRO3)) {
+ /* don't use Zorro II RAM as system memory on Zorro III */
+ /* capable machines */
+ if (i == 0) {
+ /* don't cut off the branch we're sitting on */
+ printk("Warning: kernel runs in Zorro II memory\n");
+ } else {
+ disabled_z2mem += m68k_memory[i].size;
+ m68k_num_memory--;
+ for (j = i; j < m68k_num_memory; j++)
+ m68k_memory[j] = m68k_memory[j+1];
+ i--;
+ continue;
+ }
+ }
+ mark_region(m68k_memory[i].addr, m68k_memory[i].size, 0);
+ }
+ if (disabled_z2mem)
+ printk("%dK of Zorro II memory will not be used as system memory\n",
+ disabled_z2mem>>10);
+}
diff --git a/drivers/zorro/zorrosyms.c b/drivers/zorro/zorrosyms.c
new file mode 100644
index 000000000..b08ab54df
--- /dev/null
+++ b/drivers/zorro/zorrosyms.c
@@ -0,0 +1,23 @@
+/*
+ * $Id: zorrosyms.c,v 1.1.2.1 1998/06/07 23:21:02 geert Exp $
+ *
+ * Zorro Bus Services -- Exported Symbols
+ *
+ * Copyright (C) 1998 Geert Uytterhoeven
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/zorro.h>
+
+ /* Board configuration */
+
+EXPORT_SYMBOL(zorro_find);
+EXPORT_SYMBOL(zorro_get_board);
+EXPORT_SYMBOL(zorro_config_board);
+EXPORT_SYMBOL(zorro_unconfig_board);
+
+ /* Z2 memory */
+
+EXPORT_SYMBOL(zorro_unused_z2ram);
+