Notes for MPC8xx CPM SPI interface driver in Linux -------------------------------------------------- This driver is an interface for the SPI controller in MPC8xx. The driver is written to work with the microcode patches to correct the parameter ram problems. The driver supports basic init,open,close,read and write functions. The read and write are almost similar since the SPI reads and writes data simultaneously. But I've noticed that write takes place before read. The driver code may be modified and used to interface SPI to external devices. In my case, I am using the SPI to communicate with 3 uarts. The driver code was inspired by a previous I2C driver by Dan Malek. A custom SPI interface was also contributed by Tobias Otto-Adamczak. Please refer to Motorola documentation of microcode relocation patches to understand the relocation process. I would like to point you to once specific task required to make the microcode relocation work. The rbptr (pointer to rx buffer descriptor) and tbptr (pointer tx buffer descriptor) need to be initialized to rbase and rbase values. The MPC823 manual suggests not to touch the rbptr and tbptr values. But the documentation on microcode patches requires us to initialize these values. This is missing from the I2C driver by Dan. Without this initialization, the kernel justs hangs immediately after the transfer is started, which is done by setting the spcom to 0x80. There is a memdump function provided to view the tx and rx buffers before and after the data transfers which may be used for debugging purposes. Interrupts may be used to check for various SPI events like the completion of receive or transmit, or checking for multi-master error. The interrupt is generated by setting the SPI Mask register. For the SPI to generate interrupts to flag the end of transmit of receive, you need to set the interrupt bit in the status register of the tx and rx buffer descriptors. I have used them and it works just fine. But I dont use them in this driver. The tx ready and rx empty bits are reset once transmit and receive is completed, respectively. The interrupt can be used to check for other events like multi-master errors. INSTALLING THE DRIVER --------------------- Please note that the driver is not a loadable module. To install the driver, i) Copy the spi.c file to linux/arch/ppc/8xx_io directory for the source tree ii) In the Makefile of the same directory, add spi.o to O_OBJS iii) Declare the spi initialization function in linux/drivers/char/mem.c file void cpm_spi_init(void) iv) Call the init function in __initfunc() in linux/driver/char/mem.c file cpm_spi_init() v) Recompile the linux kernel and boot. The driver will register itself with a major number of 89 during the boot process. vi) Create a device with minor number=0 and major number=89 in the /dev directory of your file system. Navin Boppuri (nboppuri@trinetcommunication.com) Prashant Patel (pmpatel@trinetcommunication.com)