Skip to contentSkip to conversation

external interrupts: IOC4 driver

PATCH New Brent Casavant 1 participant 1 message Jul 28, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/2 external interrupts: IOC4 driver

This patch implements a device driver for the external interrupt capabilities of the SGI IOC4 I/O controller chip. This driver depends upon the ioc4 driver and the extint abstraction layer (provided in the first patch of this series).

In addition to the base capabilities present in the abstracted external interrupt interface, this driver also provides a character special device to expose the user-mappable register capability of the IOC4. This allows a user application to mmap the device in order to directly poke at the external interrupt output control register, thereby reducing read/write system call overhead which is necessary when going through the abstraction layer class attribute files.

 Documentation/sgi-ioc4.txt      |  177 ++++++++
 arch/ia64/configs/sn2_defconfig |    1 
 arch/ia64/defconfig             |    1 
 drivers/char/Kconfig            |    9 
 drivers/char/Makefile           |    1 
 drivers/char/ioc4_extint.c      |  791 ++++++++++++++++++++++++++++++++++++++++
 include/linux/ioc4.h            |    1 
 7 files changed, 976 insertions(+), 5 deletions(-)
Documentation/sgi-ioc4.txt +172 -5
@@ -3,18 +3,19 @@ it are in order.
 
 First, even though the IOC4 performs multiple functions, such as an
 IDE controller, a serial controller, a PS/2 keyboard/mouse controller,
-and an external interrupt mechanism, it's not implemented as a
+and an external interrupt mechanism, it is not implemented as a
 multifunction device.  The consequence of this from a software
 standpoint is that all these functions share a single IRQ, and
 they can't all register to own the same PCI device ID.  To make
 matters a bit worse, some of the register blocks (and even registers
 themselves) present in IOC4 are mixed-purpose between these several
-functions, meaning that there's no clear "owning" device driver.
+functions, meaning that there's no clear "owning" device driver as
+far as PCI resources are concerned.
 
 The solution is to organize the IOC4 driver into several independent
-drivers, "ioc4", "sgiioc4", and "ioc4_serial".  Note that there is no
-PS/2 controller driver as this functionality has never been wired up
-on a shipping IO card.
+drivers, "ioc4", "sgiioc4", "ioc4_serial", and "ioc4_extint".  Note
+that there is no PS/2 controller driver as this functionality has never
+been wired up on a shipping IO card.
 
 ioc4
 ====
@@ -43,3 +44,169 @@ ioc4_serial
 This is the serial driver for IOC4.  There's not much to say about it
 other than it hooks up to the ioc4 driver via the appropriate registration,
 probe, and remove functions.
+
+ioc4_extint
+===========
+Since external interrupts may not be obvious in purpose from their
+name, here's a brief rundown.
+
+Sometimes it's useful to be able to react to an physical event totally
+outside the system, or generate such an event for another system or device
+to notice.  In particular, this is useful for realtime (both soft and hard)
+systems.  IOC4-based IO controller cards provide an electrical interface
+to the outside world which can be used to ingest and generate a simple
+signal for these purposes.
+
+On the output side, one of the jacks can provide a small selection
+of output modes (low, high, a single strobe, as well as toggling or
+pulses at a specified interval) that create a 0-5V electrical output.
+On the input side, one of the jacks will cause the IOC4 to generate
+a PCI interrupt on the transition edge of an electrical signal.
+
+For the most part this driver simply registers with the "extint"
+abstracted external interrupt driver, and lets it take care of
+the user-facing details.  You are directed the Documentation/extint.txt
+file for a description thereof.  However, there are some exceptions.
+The details of the driver interface follow.
+
+external interrupt output
+-------------------------
+The output section provides several modes of output.  Modes "low" and
+"high" sets the output to either logic low or logic high.  "strobe"
+sets the output to logic high for 3 ticks (see below), then returns
+to logic low.  "toggle" alternates the output between logic low and
+logic high as configured by the period setting (see below).  "pulse"
+sets the output to logic high for 3 ticks then returns to logic low
+for an interval configured by the period setting, then repeats.
+The mode should be configurable by the abstraction layer device's
+"mode" attribute, and available modes can be found from the abstraction
+layer device's "modelist" attribute.
+
+The period can be set to a range of values determined by the PCI
+clock speed of the IOC4 device.  For the "toggle" and "pulse"
+output modes, this period determines how often the toggle or
+pulse occurs.  The IOC4 hardware is designed to divide the PCI clock
+signal by 520, and use this as the "tick" length for external
+interrupt output.  The output period can be set only to a multiple
+of this length (rounding will occur automatically in the driver).
+The "pulse" and "strobe" output modes have an logic high pulsewidth
+equal to three ticks.  The period should be configurable by the
+abstraction layer device's "period" attribute, and the tick length
+can be found from the abstraction layer device's "quantum" attribute.
+
+For reference, on a 66MHz PCI bus, the tick length is 7.8 microseconds.
+On a 33MHz PCI bus, the tick length is 15.6 microseconds.  However,
+the IOC4 driver calibrates itself to a more precise value than these
+somewhat coarse numbers, depending on actual bus speed which may vary
+slightly from bus to bus or even reboot to reboot.  Note however, that
+IOC4 is only officially supported when running at 66MHz.
+
+One device file is provided, which can be memory mapped.  The first
+32-bit quantity in the mapped area is aliased to the hardware register
+which controls output.  Direct manipulation of the register, both for
+reading and writing, may be performed in order to avoid the kernel
+overhead which would be necessary if using the abstracted interfaces.
+Assuming the typical sysfs mount point, the device number files for
+these devices can be found at:
+
+	/sys/class/ioc4_intout/intout*/dev
+
+This capability is not abstracted into the external interrupt abstraction
+layer as it is critical for an application to know that this is an IOC4
+device in order to know the format of the mapped register.  The format
+of the register is:
+
+	Bits	Field	Reset	RW	Comment
+	-----	-----	-----	--	------------------------------------
+	15:0	COUNT	X	RW	This value is reloaded into the
+					counter each time it reaches 0x0.
+					The count period is actually
+					(COUNT+1).
+	18:16	MODE	000	RW	Sets the mode for INT_OUT control:
+					000: Load a '0' to INT_OUT
+					100: Load a '1' to INT_OUT
+					101: Pulse INT_OUT high for 3 ticks
+					110: Pulse INT_OUT for 3 ticks every
+					     COUNT
+					111: Toggle INTOUT for 3 ticks every
+					     COUNT
+					001, 010, 011: NOOP
+	29:19	reserved	RO	Read as '0', writes are ignored
+	30	DIAG	0	RW	Bypass clock base divider.
+	31	INT_OUT	0x0	RO	Current state of INT_OUT signal.
+
+Note that this register should always be read and written as a 32-bit word.
+Subword accesses will read the wrong end of the register.
+
+Physical interface
+..................
+All IOC4-based external interrupt implementations utilize female 1/8 inch
+audio jacks (i.e. identical to the jacks portable stereo headphones would
+plug into).  The wiring for the output jack is:
+
+	Tip: +5V output
+	Ring: Interrupt output, open collector (active low)
+	Sleeve: Chassis ground/cable shield
+
+A two conductor shielded cable should be used to connect external
+interrupt output and input, with the two cable conductors wired to the
++5V and interrupt conductors, and the sleeves connected to the cable
+shield at both ends to maintain EMI integrity.
+
+The internal driver circuit for the the output connector is as follows:
+
+	+5 ---/\/\/\-------- 	(output +5V connector)
+
+		+-----------	(output interrupt connector)
+		|	     	open collector driver
+		|
+	      |/
+	   ---|
+	      |\
+		v
+		|
+		=		(ground)
+
+external interrupt ingest
+-------------------------
+The ingest section provides one control, the source of interrupt
+signals.  The "external" source is a circuit connected to the external
+jack provided on IOC4-based IO controller cards.  The "loopback" source
+is the output of the IOC4's interrupt output section.  The source should
+be configurable by the abstraction layer device's "source" attribute,
+and available sources can be found from the abstraction layer device's
+"sourcelist" attribute.
+
+Physical interface
+..................
+All IOC4-based external interrupt implementations utilize female 1/8 inch
+audio jacks (i.e. identical to the jacks portable stereo headphones would
+plug into).  The wiring for the input jack is:
+
+	Tip: +5V input
+	Ring: Interrupt input (active low, optoisolated)
+	Sleeve: Chassis ground/cable shield
+
+The input signal passes through an opto-isolator that has a damping effect.
+The input signal must be of sufficient duration to drive the output of the
+opto-isolator low in order for the interrupt to be recognized by the
+receiving machine.  Current experimentation shows that the threshold is
+about 2.5 microseconds.  To be safe, the driver sets its default outgoing
+pulse width to 10 microseconds.  Any hardware not from Silicon Graphics that
+is driving this line should do the same.
+
+The internal receiver circuit for the input connector is as follows:
+
+		(input +5V connector)	--------+
+						|
+					       ---
+			optoisolator LED       \ /
+					       ---
+						|
+	  (input interrupt connector)	--------+
+
+An output connector can be wired directly to an input connector, taking
+care to connect the +5V output to the +5V input and the interrupt output
+to the interrupt input.  If some other device is used to drive the input,
+it must be a +5V source current limited with a 420 ohm resistor in series,
+to avoid damaging the optoisolator.
arch/ia64/configs/sn2_defconfig +1 -0
@@ -631,6 +631,7 @@ CONFIG_MMTIMER=y
 # Misc devices
 #
 CONFIG_EXTINT=m
+CONFIG_EXTINT_SGI_IOC4=m
 
 #
 # Multimedia devices
arch/ia64/defconfig +1 -0
@@ -718,6 +718,7 @@ CONFIG_MMTIMER=y
 # Misc devices
 #
 CONFIG_EXTINT=m
+CONFIG_EXTINT_SGI_IOC4=m
 
 #
 # Multimedia devices
drivers/char/Kconfig +9 -0
@@ -420,6 +420,15 @@ config EXTINT
 	  interrupt devices (such as SGI IOC3 and IOC4 IO controllers).
 	  If you have such a device, say Y. Otherwise, say N.
 
+config EXTINT_SGI_IOC4
+	tristate "Device driver for SGI IOC4 external interrupts"
+	depends on (IA64_GENERIC || IA64_SGI_SN2) && EXTINT && BLK_DEV_SGIIOC4
+	help
+	  This option enables support for the external interrupt ingest
+	  and generation capabilities of SGI IOC4 IO controllers.  If
+	  you have an SGI Altix with an IOC4 based IO card, say Y.
+	  Otherwise, say N.
+
 source "drivers/serial/Kconfig"
 
 config UNIX98_PTYS
drivers/char/Makefile +1 -0
@@ -83,6 +83,7 @@ obj-$(CONFIG_SCx200_GPIO) += scx200_gpio
 obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o
 obj-$(CONFIG_TANBAC_TB0219) += tb0219.o
 obj-$(CONFIG_EXTINT) += extint.o
+obj-$(CONFIG_EXTINT_SGI_IOC4) += ioc4_extint.o
 
 obj-$(CONFIG_WATCHDOG)	+= watchdog/
 obj-$(CONFIG_MWAVE) += mwave/
drivers/char/ioc4_extint.c new file +791 -0

791 lines not on this page · raw message

include/linux/ioc4.h +1 -0
@@ -156,6 +156,7 @@ struct ioc4_driver_data {
 	struct __iomem ioc4_misc_regs *idd_misc_regs;
 	unsigned long count_period;
 	void *idd_serial_data;
+	void *idd_extint_data;
 };
 
 /* One per submodule */
Signature · 3 lines
Brent Casavant                          If you had nothing to fear,
[email protected]                        how then could you be brave?
Silicon Graphics, Inc.                    -- Queen Dama, Source Wars