Skip to contentSkip to conversation

MCA sysfs part II - bus abstraction

PATCH New J.E.J. Bottomley 1 participant 1 message Nov 20, 2002

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MCA sysfs part II - bus abstraction

The attached patch applies on top of the previous MCA sysfs one.

This one introduces the new API for handling MCA devices and abstracts the actual MCA handling away from the hardware implementation (any raving lunatic want to try an RS6000 port?).

In order to do a SCSI driver test conversion, I'm going to need the dma_mask into struct device patch.

This is also available in a bitkeeper tree:

http://linux-voyager.bkbits.net/mca-sysfs-2.5

James

# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:
# ChangeSet 1.843 -> 1.844
# drivers/mca/mca-legacy.c 1.1 -> 1.2
# include/linux/mca.h 1.2 -> 1.3
# arch/i386/kernel/mca.c 1.10 -> 1.11

#	drivers/mca/Makefile	1.1     -> 1.2    
#	               (new)	        -> 1.1     include/asm-i386/mca.h
#	               (new)	        -> 1.1     drivers/mca/mca-device.c
#	               (new)	        -> 1.1     include/linux/mca-legacy.h

#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/11/20 jejb@mulgrave.(none) 1.844
# MCA sysfs Part II - abstract out the hw specific pieces #
# Just in case some raving lunatic wants to add other platform

# support for MCA (like RS6000)
# 
# Abstract the hardware pieces from the general MCA bus handling
# Make all bus and pos accesses go through special accessor registers
# add transform functions for multiple MCA bus machines
# --------------------------------------------
#
diff -Nru a/arch/i386/kernel/mca.c b/arch/i386/kernel/mca.c
--- a/arch/i386/kernel/mca.c	Wed Nov 20 13:31:07 2002
+++ b/arch/i386/kernel/mca.c	Wed Nov 20 13:31:07 2002
@@ -158,6 +158,86 @@
 	return found;
 }

+static unsigned char mca_pc_read_pos(struct mca_device *mca_dev, int reg) +{
+ unsigned char byte;
+ unsigned long flags;
+
+ if(reg < 0 || reg >= 8)
+ return 0;
+
+ spin_lock_irqsave(&mca_lock, flags);
+ if(mca_dev->pos_register) {
+ /* Disable adapter setup, enable motherboard setup */
+
+ outb_p(0, MCA_ADAPTER_SETUP_REG);
+ outb_p(mca_dev->pos_register, MCA_MOTHERBOARD_SETUP_REG);
+
+ byte = inb_p(MCA_POS_REG(reg));
+ outb_p(0xff, MCA_MOTHERBOARD_SETUP_REG);
+ } else {
+
+ /* Make sure motherboard setup is off */
+
+ outb_p(0xff, MCA_MOTHERBOARD_SETUP_REG);
+
+ /* Read the appropriate register */
+
+ outb_p(0x8|(mca_dev->slot & 0xf), MCA_ADAPTER_SETUP_REG);
+ byte = inb_p(MCA_POS_REG(reg));
+ outb_p(0, MCA_ADAPTER_SETUP_REG);
+ }
+ spin_unlock_irqrestore(&mca_lock, flags);
+
+ mca_dev->pos[reg] = byte;
+
+ return byte;
+}
+
+static void mca_pc_write_pos(struct mca_device *mca_dev, int reg,
+ unsigned char byte)
+{
+ unsigned long flags;
+
+ if(reg < 0 || reg >= 8)
+ return;
+
+ spin_lock_irqsave(&mca_lock, flags);
+
+ /* Make sure motherboard setup is off */
+
+ outb_p(0xff, MCA_MOTHERBOARD_SETUP_REG);
+
+ /* Read in the appropriate register */
+
+ outb_p(0x8|(mca_dev->slot&0xf), MCA_ADAPTER_SETUP_REG);
+ outb_p(byte, MCA_POS_REG(reg));
+ outb_p(0, MCA_ADAPTER_SETUP_REG);
+
+ spin_unlock_irqrestore(&mca_lock, flags);
+
+ /* Update the global register list, while we have the byte */
+
+ mca_dev->pos[reg] = byte;
+
+}
+
+/* for the primary MCA bus, we have identity transforms */
+static int mca_dummy_transform_irq(struct mca_device * mca_dev, int irq) +{
+ return irq;
+}
+
+static int mca_dummy_transform_ioport(struct mca_device * mca_dev, int port) +{
+ return port;
+}
+
+static void *mca_dummy_transform_memory(struct mca_device * mca_dev, void *mem) +{
+ return mem;
+}
+

static int __init mca_init(void)
{
@@ -189,6 +269,11 @@
/* All MCA systems have at least a primary bus */ bus = mca_attach_bus(MCA_PRIMARY_BUS); bus->default_dma_mask = 0xffffffffLL;
+ bus->f.mca_write_pos = mca_pc_write_pos;
+ bus->f.mca_read_pos = mca_pc_read_pos;
+ bus->f.mca_transform_irq = mca_dummy_transform_irq;
+ bus->f.mca_transform_ioport = mca_dummy_transform_ioport;
+ bus->f.mca_transform_memory = mca_dummy_transform_memory;

/* get the motherboard device */
mca_dev = kmalloc(sizeof(struct mca_device), GFP_KERNEL);

drivers/mca/Makefile +1 -1
diff -Nru a/drivers/mca/Makefile b/drivers/mca/Makefile
@@ -1,6 +1,6 @@
 # Makefile for the Linux MCA bus support
 
-obj-y	:= mca-bus.o mca-legacy.o
+obj-y	:= mca-bus.o mca-device.o mca-legacy.o
 
 obj-$(CONFIG_PROC_FS)	+= mca-proc.o
 
drivers/mca/mca-device.c new file +202 -0

202 lines not on this page · raw message

drivers/mca/mca-legacy.c +13 -62

135 lines not on this page · raw message

include/asm-i386/mca.h new file +46 -0

46 lines not on this page · raw message

include/linux/mca-legacy.h new file +81 -0

81 lines not on this page · raw message

include/linux/mca.h +38 -111

193 lines not on this page · raw message