os/linux-2.6-tag--devboard-R2_10-4/arch/cris/arch-v32/drivers/elphel/fpgajtag353.c File Reference

#include <linux/autoconf.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/ioport.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/string.h>
#include <linux/init.h>
#include <asm/arch/hwregs/reg_map.h>
#include <asm/arch/hwregs/reg_rdwr.h>
#include <asm/arch/hwregs/gio_defs.h>
#include <asm/arch/hwregs/intr_vect_defs.h>
#include <asm/arch/hwregs/pinmux_defs.h>
#include <asm/io.h>
#include <asm/system.h>
#include <asm/irq.h>
#include <asm/elphel/fpgactrl.h>
#include <asm/delay.h>
#include <asm/uaccess.h>
#include "fpgactrl.h"
#include "x3x3.h"

Include dependency graph for fpgajtag353.c:

Go to the source code of this file.

Data Structures

struct  JTAG_channel_t

Defines

#define D(x)
#define FPGAJTAG_TDO_BIT   0
#define FPGAJTAG_TDI_BIT   1
#define FPGAJTAG_TMS_BIT   2
#define FPGAJTAG_TCK_BIT   3
#define FPGAJTAG_DONE_BIT   5
#define FPGAJTAG_RSTBTN_BIT   6
#define FPGAJTAG_PGM_BIT   7
#define XC3S1000_BITSIZE   3223488
#define XC3S1200E_BITSIZE   3841189
#define XC3S1200E_BOUNDARY_SIZE   772
#define FJTAG_BUF_SIZE   0x77000
#define FJTAG_MAX_HEAD   0x1000
#define FJTAG_RAW_WSIZE   0x40000
#define FJTAG_RAW_RSIZE   0x30000
#define FJTAG_IDSIZE   0x40
#define FPGA_JTAG_MAJOR   132
#define FPGA_JTAG_DRIVER_NAME   "Elphel (R) model 353 FPGA (Xilinx (R) XC3S1200E) configuration driver"
#define FPGA_JTAG_MAXMINOR   10
#define FPGA_JTAG_RESET_MINOR   0
#define FPGA_JTAG_RAW_MINOR   0
#define FPGA_JTAG_MINOR   1
#define FPGA_SJTAG_MINOR   2
#define FPGA_AJTAG_MINOR   3
#define FPGA_JTAG_BOUNDARY_MINOR   5
#define FPGA_SJTAG_BOUNDARY_MINOR   6
#define FPGA_AJTAG_BOUNDARY_MINOR   7
#define JTAG_RAW   0
#define JTAG_MAIN_FPGA   1
#define JTAG_SENSOR_FPGA   2
#define JTAG_AUX_FPGA   3
#define JTAG_NCHANNELS   4
#define JTAG_MODE_CLOSED   0
#define JTAG_MODE_RDID   1
#define JTAG_MODE_PGM   2
#define JTAG_MODE_BOUNDARY   3
#define JTAG_MODE_SAMPLE   4
#define JTAG_MODE_EXTEST   5
#define JTAG_MODE_RAW   6
#define PC_DOUT_INITIAL   0
#define JTAG_RAW_SEND   0x10
#define JTAG_RAW_SETCHN   0x20
#define JTAG_RAW_DEACT   0x22
#define JTAG_RAW_ACT   0x23
#define JTAG_RAW_PGMOFF   0x24
#define JTAG_RAW_PGMON   0x25
#define JTAG_RAW_WAIT   0x80

Functions

static int fpga_jtag_open (struct inode *inode, struct file *filp)
static int fpga_jtag_release (struct inode *inode, struct file *filp)
static ssize_t fpga_jtag_write (struct file *file, const char *buf, size_t count, loff_t *off)
static loff_t fpga_jtag_lseek (struct file *file, loff_t offset, int orig)
static ssize_t fpga_jtag_read (struct file *file, char *buf, size_t count, loff_t *off)
static int __init fpga_jtag_init (void)
loff_t fjtag_bitsize (int minor)
loff_t fjtag_bytesize (int minor)
int JTAG_channel (int minor)
void initPortC (void)
void set_pgm_mode (int chn, int en)
void set_pgm (int chn, int pgmon)
int read_done (int chn)
int jtag_send (int chn, int tms, int len, int d)
int jtag_write_bits (int chn, unsigned char *buf, int len, int check, int last, int prev[2])
int JTAG_configure (int chn, unsigned char *buf, int len)
int JTAG_readID (int chn, unsigned char *buf)
int JTAG_openChannel (int chn)
int JTAG_resetChannel (int chn)
int JTAG_CAPTURE (int chn, unsigned char *buf, int len)
int JTAG_EXTEST (int chn, unsigned char *buf, int len)
void JTAG_push_raw (int b)
int JTAG_process_raw (void)
int JTAG_whatopen (void)
 module_init (fpga_jtag_init)
 MODULE_LICENSE ("GPL")
 MODULE_AUTHOR ("Andrey Filippov <andrey@elphel.com>.")
 MODULE_DESCRIPTION (FPGA_JTAG_DRIVER_NAME)

Variables

static unsigned char bitstream_data [FJTAG_BUF_SIZE]
static unsigned char * raw_fifo_w = &bitstream_data[0]
static unsigned char * raw_fifo_r = &bitstream_data[FJTAG_RAW_WSIZE]
static struct JTAG_channel_t JTAG_channels [JTAG_NCHANNELS]
static int data_modified = 0
static reg_gio_rw_pc_dout pc_dout
static const char fpga_jtag_name [] = "fpga_jtag_loader"
static int minors [FPGA_JTAG_MAXMINOR+1]
static struct file_operations fpga_jtag_fops
static int raw_fifo_w_wp
static int raw_fifo_w_rp
static int raw_fifo_r_wp
static int raw_fifo_r_rp
static int raw_chn


Define Documentation

#define D ( x   ) 

*************************************************************************** ! FILE NAME : fpgajtag353.c ! DESCRIPTION: TBD ! Copyright 2002-2007 (C) Elphel, Inc. ! -----------------------------------------------------------------------------** ! ! 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 3 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, see <http://www.gnu.org/licenses/>. ! -----------------------------------------------------------------------------** !

Log
fpgajtag353.c,v
! Revision 1.2 2008/04/11 23:16:51 elphel ! removed unneeded local_irq_disable() after local_irq_save_flags() ! ! Revision 1.1.1.1 2007/08/17 10:23:18 elphel ! This is a fresh tree based on elphel353-2.10 ! ! Revision 1.7 2007/08/17 10:23:18 spectr_rain ! switch to GPL3 license ! ! Revision 1.6 2007/07/20 10:17:46 spectr_rain ! *** empty log message *** ! ! Revision 1.5 2007/06/28 02:20:39 elphel ! Slowed down sensor FPGA programming while working with long cables. Problem was different, so maybe that change may be undone. ! ! Revision 1.4 2007/05/21 21:23:50 elphel ! remove compile-time warning ! ! Revision 1.3 2007/05/21 17:45:11 elphel ! boundary scan support, added 359/347 detection ! ! Revision 1.2 2007/03/25 10:14:23 elphel ! Accommodating 10359 board ! ! Revision 1.1.1.1 2007/02/23 10:11:48 elphel ! initial import into CVS ! ! Revision 1.2 2005/05/10 21:08:49 elphel ! *** empty log message *** !

TODO: replace static buffer (what a waste!) I suspect "somebody" is is playing with portA during JTAG configuration. To test that I'll use 256K static buffer, copy all the bitstream there, disable interrupts and do the programming. No debug with printk ...

Definition at line 106 of file fpgajtag353.c.

#define FJTAG_BUF_SIZE   0x77000

Definition at line 134 of file fpgajtag353.c.

#define FJTAG_IDSIZE   0x40

Definition at line 138 of file fpgajtag353.c.

#define FJTAG_MAX_HEAD   0x1000

Definition at line 135 of file fpgajtag353.c.

#define FJTAG_RAW_RSIZE   0x30000

Definition at line 137 of file fpgajtag353.c.

#define FJTAG_RAW_WSIZE   0x40000

Definition at line 136 of file fpgajtag353.c.

#define FPGA_AJTAG_BOUNDARY_MINOR   7

Definition at line 154 of file fpgajtag353.c.

#define FPGA_AJTAG_MINOR   3

Definition at line 150 of file fpgajtag353.c.

#define FPGA_JTAG_BOUNDARY_MINOR   5

Definition at line 152 of file fpgajtag353.c.

#define FPGA_JTAG_DRIVER_NAME   "Elphel (R) model 353 FPGA (Xilinx (R) XC3S1200E) configuration driver"

Definition at line 144 of file fpgajtag353.c.

#define FPGA_JTAG_MAJOR   132

Definition at line 143 of file fpgajtag353.c.

#define FPGA_JTAG_MAXMINOR   10

Definition at line 145 of file fpgajtag353.c.

#define FPGA_JTAG_MINOR   1

Definition at line 148 of file fpgajtag353.c.

#define FPGA_JTAG_RAW_MINOR   0

Definition at line 147 of file fpgajtag353.c.

#define FPGA_JTAG_RESET_MINOR   0

Definition at line 146 of file fpgajtag353.c.

#define FPGA_SJTAG_BOUNDARY_MINOR   6

Definition at line 153 of file fpgajtag353.c.

#define FPGA_SJTAG_MINOR   2

Definition at line 149 of file fpgajtag353.c.

#define FPGAJTAG_DONE_BIT   5

Definition at line 124 of file fpgajtag353.c.

#define FPGAJTAG_PGM_BIT   7

Definition at line 126 of file fpgajtag353.c.

#define FPGAJTAG_RSTBTN_BIT   6

Definition at line 125 of file fpgajtag353.c.

#define FPGAJTAG_TCK_BIT   3

Definition at line 123 of file fpgajtag353.c.

#define FPGAJTAG_TDI_BIT   1

Definition at line 121 of file fpgajtag353.c.

#define FPGAJTAG_TDO_BIT   0

Definition at line 120 of file fpgajtag353.c.

#define FPGAJTAG_TMS_BIT   2

Definition at line 122 of file fpgajtag353.c.

#define JTAG_AUX_FPGA   3

Definition at line 159 of file fpgajtag353.c.

#define JTAG_MAIN_FPGA   1

Definition at line 157 of file fpgajtag353.c.

#define JTAG_MODE_BOUNDARY   3

Definition at line 165 of file fpgajtag353.c.

#define JTAG_MODE_CLOSED   0

Definition at line 162 of file fpgajtag353.c.

#define JTAG_MODE_EXTEST   5

Definition at line 167 of file fpgajtag353.c.

#define JTAG_MODE_PGM   2

Definition at line 164 of file fpgajtag353.c.

#define JTAG_MODE_RAW   6

Definition at line 168 of file fpgajtag353.c.

#define JTAG_MODE_RDID   1

Definition at line 163 of file fpgajtag353.c.

#define JTAG_MODE_SAMPLE   4

Definition at line 166 of file fpgajtag353.c.

#define JTAG_NCHANNELS   4

Definition at line 160 of file fpgajtag353.c.

#define JTAG_RAW   0

Definition at line 156 of file fpgajtag353.c.

#define JTAG_RAW_ACT   0x23

Definition at line 287 of file fpgajtag353.c.

#define JTAG_RAW_DEACT   0x22

Definition at line 286 of file fpgajtag353.c.

#define JTAG_RAW_PGMOFF   0x24

Definition at line 288 of file fpgajtag353.c.

#define JTAG_RAW_PGMON   0x25

Definition at line 289 of file fpgajtag353.c.

#define JTAG_RAW_SEND   0x10

Definition at line 284 of file fpgajtag353.c.

#define JTAG_RAW_SETCHN   0x20

Definition at line 285 of file fpgajtag353.c.

#define JTAG_RAW_WAIT   0x80

Definition at line 290 of file fpgajtag353.c.

#define JTAG_SENSOR_FPGA   2

Definition at line 158 of file fpgajtag353.c.

#define PC_DOUT_INITIAL   0

Definition at line 191 of file fpgajtag353.c.

#define XC3S1000_BITSIZE   3223488

Definition at line 130 of file fpgajtag353.c.

#define XC3S1200E_BITSIZE   3841189

Definition at line 131 of file fpgajtag353.c.

#define XC3S1200E_BOUNDARY_SIZE   772

Definition at line 132 of file fpgajtag353.c.


Function Documentation

loff_t fjtag_bitsize ( int  minor  ) 

loff_t fjtag_bytesize ( int  minor  ) 

static int __init fpga_jtag_init ( void   )  [static]

Definition at line 1165 of file fpgajtag353.c.

References FPGA_JTAG_DRIVER_NAME, fpga_jtag_fops, FPGA_JTAG_MAJOR, FPGA_JTAG_MAXMINOR, fpga_jtag_name, fpga_state, initPortC(), KERN_ERR, minors, and printk.

static loff_t fpga_jtag_lseek ( struct file *  file,
loff_t  offset,
int  orig 
) [static]

Definition at line 594 of file fpgajtag353.c.

References D, FJTAG_RAW_RSIZE, JTAG_channel(), JTAG_channels, JTAG_MODE_RDID, JTAG_RAW, mode, printk, JTAG_channel_t::sizer, and JTAG_channel_t::sizew.

static int fpga_jtag_open ( struct inode *  inode,
struct file *  filp 
) [static]

Definition at line 348 of file fpgajtag353.c.

References JTAG_channel_t::bitsr, bitstream_data, JTAG_channel_t::bitsw, D, JTAG_channel_t::dbuf, FJTAG_BUF_SIZE, FJTAG_IDSIZE, FJTAG_RAW_RSIZE, FJTAG_RAW_WSIZE, FPGA_AJTAG_BOUNDARY_MINOR, FPGA_AJTAG_MINOR, FPGA_JTAG_BOUNDARY_MINOR, FPGA_JTAG_MINOR, FPGA_JTAG_RESET_MINOR, FPGA_SJTAG_BOUNDARY_MINOR, FPGA_SJTAG_MINOR, fpga_state, FPGA_STATE_LOADED, FPGA_STATE_SDRAM_INIT, JTAG_channel(), JTAG_channels, JTAG_MODE_BOUNDARY, JTAG_MODE_CLOSED, JTAG_MODE_PGM, JTAG_MODE_RAW, JTAG_NCHANNELS, JTAG_openChannel(), JTAG_whatopen(), minors, JTAG_channel_t::mode, mode, printk, JTAG_channel_t::rp, JTAG_channel_t::sizer, JTAG_channel_t::sizew, JTAG_channel_t::wdirty, JTAG_channel_t::wp, XC3S1200E_BITSIZE, and XC3S1200E_BOUNDARY_SIZE.

ssize_t fpga_jtag_read ( struct file *  file,
char *  buf,
size_t  count,
loff_t *  off 
) [static]

Definition at line 525 of file fpgajtag353.c.

References D, FPGA_AJTAG_BOUNDARY_MINOR, FPGA_AJTAG_MINOR, FPGA_JTAG_BOUNDARY_MINOR, FPGA_JTAG_MINOR, FPGA_JTAG_RESET_MINOR, FPGA_SJTAG_BOUNDARY_MINOR, FPGA_SJTAG_MINOR, JTAG_CAPTURE(), JTAG_channel(), JTAG_channels, JTAG_EXTEST(), JTAG_MODE_BOUNDARY, JTAG_MODE_EXTEST, JTAG_MODE_RDID, JTAG_MODE_SAMPLE, JTAG_readID(), mode, JTAG_channel_t::mode, printk, raw_fifo_r, raw_fifo_w, JTAG_channel_t::rp, rp, JTAG_channel_t::sizer, JTAG_channel_t::wdirty, and wp.

static int fpga_jtag_release ( struct inode *  inode,
struct file *  filp 
) [static]

Definition at line 430 of file fpgajtag353.c.

References D, FPGA_AJTAG_BOUNDARY_MINOR, FPGA_AJTAG_MINOR, FPGA_JTAG_BOUNDARY_MINOR, FPGA_JTAG_MINOR, FPGA_JTAG_RESET_MINOR, FPGA_SJTAG_BOUNDARY_MINOR, FPGA_SJTAG_MINOR, fpga_state, FPGA_STATE_INITIALIZED, JTAG_channel(), JTAG_channels, JTAG_configure(), JTAG_EXTEST(), JTAG_MAIN_FPGA, JTAG_MODE_CLOSED, JTAG_resetChannel(), minors, JTAG_channel_t::mode, printk, rp, and wp.

static ssize_t fpga_jtag_write ( struct file *  file,
const char *  buf,
size_t  count,
loff_t *  off 
) [static]

Definition at line 470 of file fpgajtag353.c.

References D, FPGA_AJTAG_BOUNDARY_MINOR, FPGA_AJTAG_MINOR, FPGA_JTAG_BOUNDARY_MINOR, FPGA_JTAG_MINOR, FPGA_JTAG_RESET_MINOR, FPGA_SJTAG_BOUNDARY_MINOR, FPGA_SJTAG_MINOR, JTAG_channel(), JTAG_channels, JTAG_EXTEST(), JTAG_MODE_EXTEST, JTAG_process_raw(), JTAG_channel_t::mode, printk, raw_fifo_w, JTAG_channel_t::sizew, JTAG_channel_t::wdirty, JTAG_channel_t::wp, and wp.

void initPortC ( void   ) 

int JTAG_CAPTURE ( int  chn,
unsigned char *  buf,
int  len 
)

int JTAG_channel ( int  minor  ) 

int JTAG_configure ( int  chn,
unsigned char *  buf,
int  len 
)

int JTAG_EXTEST ( int  chn,
unsigned char *  buf,
int  len 
)

int JTAG_openChannel ( int  chn  ) 

int JTAG_process_raw ( void   ) 

void JTAG_push_raw ( int  b  ) 

int JTAG_readID ( int  chn,
unsigned char *  buf 
)

int JTAG_resetChannel ( int  chn  ) 

int jtag_send ( int  chn,
int  tms,
int  len,
int  d 
)

int JTAG_whatopen ( void   ) 

Definition at line 340 of file fpgajtag353.c.

References JTAG_channels, JTAG_NCHANNELS, and mode.

int jtag_write_bits ( int  chn,
unsigned char *  buf,
int  len,
int  check,
int  last,
int  prev[2] 
)

MODULE_AUTHOR ( "Andrey Filippov <andrey@elphel.com>."   ) 

MODULE_DESCRIPTION ( FPGA_JTAG_DRIVER_NAME   ) 

module_init ( fpga_jtag_init   ) 

MODULE_LICENSE ( "GPL"   ) 

int read_done ( int  chn  ) 

void set_pgm ( int  chn,
int  pgmon 
)

void set_pgm_mode ( int  chn,
int  en 
)


Variable Documentation

unsigned char bitstream_data[FJTAG_BUF_SIZE] [static]

Definition at line 182 of file fpgajtag353.c.

int data_modified = 0 [static]

Definition at line 188 of file fpgajtag353.c.

struct file_operations fpga_jtag_fops [static]

Initial value:

Definition at line 210 of file fpgajtag353.c.

const char fpga_jtag_name[] = "fpga_jtag_loader" [static]

Definition at line 200 of file fpgajtag353.c.

struct JTAG_channel_t JTAG_channels[JTAG_NCHANNELS] [static]

Definition at line 186 of file fpgajtag353.c.

int minors[FPGA_JTAG_MAXMINOR+1] [static]

Definition at line 201 of file fpgajtag353.c.

reg_gio_rw_pc_dout pc_dout [static]

Definition at line 190 of file fpgajtag353.c.

int raw_chn [static]

Definition at line 267 of file fpgajtag353.c.

unsigned char* raw_fifo_r = &bitstream_data[FJTAG_RAW_WSIZE] [static]

Definition at line 185 of file fpgajtag353.c.

int raw_fifo_r_rp [static]

Definition at line 266 of file fpgajtag353.c.

int raw_fifo_r_wp [static]

Definition at line 265 of file fpgajtag353.c.

unsigned char* raw_fifo_w = &bitstream_data[0] [static]

Definition at line 184 of file fpgajtag353.c.

int raw_fifo_w_rp [static]

Definition at line 264 of file fpgajtag353.c.

int raw_fifo_w_wp [static]

Definition at line 263 of file fpgajtag353.c.


Generated on Thu Aug 7 16:20:32 2008 for elphel by  doxygen 1.5.1