This document describes the installation procedure for the SPI driver.

You have two choices where to put the stuff:

1.) Keep it somewhere locally (like /usr/local/....) or
2.) Make it part of your kernel sources.

Both ways have their advantages and disadvantages. The first keeps upgrades
of your kernel clean and straightforward (no need to copy and modify files
again). But you must remember to explicitely install the module in the right
directory after you upgraded your kernel. The second method makes the driver
virtually a part of the kernel sources, although it did not come with the
kernel. This means that it appears as a configurable item in "make config"
and "make menuconfig" - convenient for those who tend to forget. But when
you upgrade your kernel you have to copy and modifiy some files. (The driver
MIGHT come with the kernel in the future, but this is beyond the influence of 
the author.)

First the description for the second method - make it part of the kernel
sources: (Tho other starts after a line with a lot of ************** )

* Copy or move the following files to the indicated location:
	spi.c 		--> /usr/src/linux/drivers/char/spi.c
	spi.h		--> /usr/src/linux/include/linux/spi.h
  (Or wherever your kernel drivers and headers are. The files must
  go to the same directories where lp.c and lp.h reside, respectively.)
	
* Edit the Makefile for the character devices to include the SPI driver.
  (The file to edit is the Makefile in the dir where spi.c is.
  Usually /usr/src/linux/drivers/char/Makefile.) Insert the following lines
  right after the respecive lines for the printer. (Look for CONFIG_PRINTER
  to find the section.)

  	ifeq ($(CONFIG_SPI),y)
  	L_OBJS += spi.o
  	else
  	  ifeq ($(CONFIG_SPI),m)
  	  M_OBJS += spi.o
  	  endif
  	endif
  
* Edit the configuration file for the character devices (usually
  /usr/src/linux/drivers/char/Config.in) and add the following line (again
  best after the lines for the printer):

  	tristate 'SPI bus on parallel port support' CONFIG_SPI  

  If you want to keep a reminder that you must make the printer driver a
  module to use the spi driver then add these lines, too:

  	if [ "$CONFIG_SPI" <> "n" ]; then
  	   if [ "CONFIG_PRINTER" = "y" ]; then
  	     comment 'You must make the printer support a module to use the spi bus'
  	   fi
  	fi
  
* If you want some help when you configure your kernel, add something like
  this to the file /usr/src/linux/Documentation/Configure.help
  
  SPI bus over parallel port support
  CONFIG_SPI
    The SPI bus is a serial synchronous bus that is used to communicate with
    a variety of chips, like ADCs, DACs, ports, EEROMs. This driver can talk
    the MicroWire protocol, too. If you do not know what this means at all,
    do not include the spi support as you never will need it ;-)
    
* Change to your source directory (/usr/src/linux in most cases), invoke
  "make config" or "make menuconfig" and make BOTH the spi driver and the
  printer driver a module.

* Recompile the kernel and the modules. Do not forget to install the
  modules afterwards. 
  (Usually: "make dep && make clean && make zlilo && make modules && make
   modules_install")

* If you already use local major numbers pick a free one. If you do not know
  what this is, choose 60 as the major number. Now issue the command:

	mknod /dev/spi c <major> 0

  with <major> being the major number from above, eg. 60
  
* Edit the file /etc/conf.modules (may be called /etc/modules.conf on your 
  machine) and add a line like this:
  
  	options spi spi_base=0x378 spi_major=60
  	
  The values of spi_base and spi_major must be changed for your system. The
  spi_major must be the major number of above. The spi_base must be set to
  the address of the parallel port to use. (0x378 is the first, 0x278 the
  second and 0x3bc that on the hercules graphics cards.)
	
* When you had to recompile the kernel (printer driver was NOT a module
  before) reboot the machine. 
  
* If your startup scripts do not do it for you, issue the command
	depmod -a
	
* If you do not run kerneld then you must load the module before you can use
  it: (every time, not just once for the installation)
  	insmod spi
  	
  To unload it: rmmod spi
  
How to use the spi device from then on is described in the file
spi-driver-interface.txt.

You can skip the rest of the file, as it describes the installation
procedure for the local method.

*********************** Local Method ***************************************  

So, you decided to keep it locally. Then you probably already have a
strategy to handle that - which directories will hold what files. 

* Make sure the printer support in your kernel is a module. To check and
  change this do a "make config" or "make menuconfig". If it was not a
  module, recompile the kernel and the modules and install them. Issue
  something like

  make dep && make clean && make zlilo && make modules && make modules_install

While the machine is rebuilding the kernel you can do something in parallel:
  
* Move the two files (spi.c and spi.h) to their destination(s).

* Compile the spi.c to a module. You can adapt the Makefile in this
  distribution for this and then simply do a "make".
  
* Put the spi.o to the directory where your modules are or modify the 
  MODPATH environment variable to include the directory where the spi.o
  resides. The kernel puts the modules in a directory in /lib/modules.
  The name of the directory is composed of the version and patchlevel of
  the kernel. 

* If you already use local major numbers pick a free one. If you do not know
  what this is, choose 60 as the major number. Now issue the command:

	mknod /dev/spi c <major> 0

  with <major> being the major number from above, eg. 60
  
* Edit the file /etc/conf.modules (may be called /etc/modules.conf on your 
  machine) and add a line like this:
  
  	options spi spi_base=0x378 spi_major=60
  	
  The values of spi_base and spi_major must be changed for your system. The
  spi_major must be the major number of above. The spi_base must be set to
  the address of the parallel port to use. (0x378 is the first, 0x278 the
  second and 0x3bc that on the hercules graphics cards.)

* When you had to recompile the kernel (printer driver was NOT a module
  before) reboot the machine. 
  
* If your startup scripts do not do it for you, issue the command
	depmod -a
	
* If you do not run kerneld then you must load the module before you can use
  it: (every time, not just once for the installation)
  	insmod spi
  	
  To unload it: rmmod spi
  
How to use the spi device from then on is described in the file
spi-driver-interface.txt.

