/* tspi_4fx.c David Rowe 30 August 2006 Linux device driver for Blackfin that implements unit tests for the 4fx daughter board. Tested on a Blackfin BF533 STAMP with a 4fx daughter board attached. See below for running instructions. See also the hardware-x.y tarball cpld/README to explain how the CPLD works on the 4fx board. */ /* Copyright (C) 2006 David Rowe This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include #include #include #include #include #include #include /* Need to do include bfsi module this way due to kbuild restrictions. I would rather have it as seperately compiled module but I couldn't work out how to specify the path I wanted */ #include "../../src/bfsi.c" #define NCS_A 3 #define NCS_B 2 #define TESTS 100 /*----------------------- TEST PARAMETERS -----------------------------*/ static int baud = 4; /* gives max for sys clock = 100 MHz for Si3050 */ static int tests = 1; static int select = 5; /* LED register */ static int data = 1; /* LED1 = red */ /*------------------------MODULE INIT FUNCTION --------------------------*/ /* The test can be controlled by command line parameters when the module is installed. The test runs by simply installing the module using insmod, to run again rmmod the module and insmod again. For example: 1/ Make LED1 light red. root:~> insmod tspi.ko 2/ Make LED1 light green. root:~> insmod tspi.ko data=0x2 3/ Send the value 0x55 100 times to the SPI device on nCS3: root:~> insmod tspi.ko tests=100 select=0x3 data=0x2 4/ Make all LEDs red: root:~> insmod tspi.ko data=0x55 5/ Make all LEDs green: root:~> insmod tspi.ko data=0xaa 5/ Make all LEDs RGRG: root:~> insmod tspi.ko data=0x66 Notes: + All these examples assume the 4fx board "address" as set by JMP10 & JMP11 is 00 (no shorting links on jumpers). + Using baud=0xffff is useful to slow down tests so you can see continous signals for a while (especially if you don'thave a storage scope :-) ) */ static int __init tspi_4fx_init_module (void) { int i; printk("initializing module\n"); bfsi_spi_init(baud, (1<