00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 #include <linux/autoconf.h>
00061
00062 #include <linux/module.h>
00063 #include <linux/sched.h>
00064 #include <linux/slab.h>
00065 #include <linux/ioport.h>
00066 #include <linux/errno.h>
00067 #include <linux/kernel.h>
00068 #include <linux/fs.h>
00069 #include <linux/string.h>
00070
00071 #include <linux/init.h>
00072
00073
00074
00075
00076
00077
00078
00079
00080 #include <asm/arch/hwregs/reg_map.h>
00081 #include <asm/arch/hwregs/reg_rdwr.h>
00082 #include <asm/arch/hwregs/gio_defs.h>
00083 #include <asm/arch/hwregs/intr_vect_defs.h>
00084 #include <asm/arch/hwregs/pinmux_defs.h>
00085
00086
00087 #include <asm/io.h>
00088 #include <asm/system.h>
00089 #include <asm/irq.h>
00090
00091 #include <asm/elphel/fpgactrl.h>
00092
00093
00094 #include <asm/delay.h>
00095 #include <asm/uaccess.h>
00096
00097 #include "fpgactrl.h"
00098 #include "x3x3.h"
00099
00100
00101
00102
00103
00104
00105
00106 #define D(x)
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 #define FPGAJTAG_TDO_BIT 0
00121 #define FPGAJTAG_TDI_BIT 1
00122 #define FPGAJTAG_TMS_BIT 2
00123 #define FPGAJTAG_TCK_BIT 3
00124 #define FPGAJTAG_DONE_BIT 5
00125 #define FPGAJTAG_RSTBTN_BIT 6
00126 #define FPGAJTAG_PGM_BIT 7
00127
00128
00129 #ifndef XC2S300E_BITSIZE
00130 #define XC3S1000_BITSIZE 3223488
00131 #define XC3S1200E_BITSIZE 3841189
00132 #define XC3S1200E_BOUNDARY_SIZE 772
00133
00134 #define FJTAG_BUF_SIZE 0x77000
00135 #define FJTAG_MAX_HEAD 0x1000
00136 #define FJTAG_RAW_WSIZE 0x40000 // shared with bitstream buffer
00137 #define FJTAG_RAW_RSIZE 0x30000 // shared with bitstream buffer
00138 #define FJTAG_IDSIZE 0x40 // bits - ID and User
00139
00140 #endif
00141
00142
00143 #define FPGA_JTAG_MAJOR 132
00144 #define FPGA_JTAG_DRIVER_NAME "Elphel (R) model 353 FPGA (Xilinx (R) XC3S1200E) configuration driver"
00145 #define FPGA_JTAG_MAXMINOR 10
00146 #define FPGA_JTAG_RESET_MINOR 0 // just close open files
00147 #define FPGA_JTAG_RAW_MINOR 0 // just close open files
00148 #define FPGA_JTAG_MINOR 1
00149 #define FPGA_SJTAG_MINOR 2
00150 #define FPGA_AJTAG_MINOR 3
00151
00152 #define FPGA_JTAG_BOUNDARY_MINOR 5 // read/write boundary pins of the main FPGA
00153 #define FPGA_SJTAG_BOUNDARY_MINOR 6 // read/write boundary pins of the sensor board FPGA
00154 #define FPGA_AJTAG_BOUNDARY_MINOR 7 // read/write boundary pins of the aux board FPGA
00155
00156 #define JTAG_RAW 0 // raw JTAG access to any FPGA
00157 #define JTAG_MAIN_FPGA 1 // main board FPGA access (10353)
00158 #define JTAG_SENSOR_FPGA 2 // sensor board FPGA access (10347, 10359)
00159 #define JTAG_AUX_FPGA 3 //
00160 #define JTAG_NCHANNELS 4
00161
00162 #define JTAG_MODE_CLOSED 0 // JTAG channel is closed
00163 #define JTAG_MODE_RDID 1 // JTAG channel read ID
00164 #define JTAG_MODE_PGM 2 // JTAG channel PROGRAM
00165 #define JTAG_MODE_BOUNDARY 3 // JTAG channel boundary scan (just opened, will become one of the 2:JTAG_MODE_SAMPLE, JTAG_MODE_EXTEST
00166 #define JTAG_MODE_SAMPLE 4 // JTAG channel boundary scan - sample (the first operation after open is read)
00167 #define JTAG_MODE_EXTEST 5 // JTAG channel boundary scan - EXTEST (the first operation after open is read)
00168 #define JTAG_MODE_RAW 6 // JTAG raw command mode
00169
00170
00171 struct JTAG_channel_t {
00172 int mode;
00173 unsigned char * dbuf;
00174 int sizew;
00175 int sizer;
00176 int bitsw;
00177 int bitsr;
00178 int wp;
00179 int rp;
00180 int wdirty;
00181 };
00182 static unsigned char bitstream_data[FJTAG_BUF_SIZE];
00183
00184 static unsigned char *raw_fifo_w= &bitstream_data[0];
00185 static unsigned char *raw_fifo_r= &bitstream_data[FJTAG_RAW_WSIZE];
00186 static struct JTAG_channel_t JTAG_channels[JTAG_NCHANNELS];
00187
00188 static int data_modified=0;
00189
00190 static reg_gio_rw_pc_dout pc_dout;
00191 #define PC_DOUT_INITIAL 0
00192
00193
00194
00195
00196
00197
00198
00199
00200 static const char fpga_jtag_name[] = "fpga_jtag_loader";
00201 static int minors[FPGA_JTAG_MAXMINOR+1];
00202
00203 static int fpga_jtag_open (struct inode *inode, struct file *filp);
00204 static int fpga_jtag_release(struct inode *inode, struct file *filp);
00205 static ssize_t fpga_jtag_write (struct file * file, const char * buf, size_t count, loff_t *off);
00206 static loff_t fpga_jtag_lseek (struct file * file, loff_t offset, int orig);
00207 static ssize_t fpga_jtag_read (struct file * file, char * buf, size_t count, loff_t *off);
00208 static int __init fpga_jtag_init(void);
00209
00210 static struct file_operations fpga_jtag_fops = {
00211 owner: THIS_MODULE,
00212 open: fpga_jtag_open,
00213 release: fpga_jtag_release,
00214 llseek: fpga_jtag_lseek,
00215 read: fpga_jtag_read,
00216 write: fpga_jtag_write
00217 };
00218
00219
00220
00221
00222 loff_t fjtag_bitsize (int minor);
00223 loff_t fjtag_bytesize (int minor);
00224 int JTAG_channel(int minor);
00225 void initPortC(void);
00226 void set_pgm_mode (int chn, int en);
00227 void set_pgm (int chn, int pgmon);
00228 int read_done (int chn);
00229 int jtag_send (int chn, int tms, int len, int d);
00230 int jtag_write_bits (int chn,
00231 unsigned char *buf,
00232 int len,
00233 int check,
00234 int last,
00235 int prev[2]);
00236 int JTAG_configure (int chn, unsigned char * buf, int len);
00237 int JTAG_readID (int chn, unsigned char * buf);
00238 int JTAG_openChannel (int chn);
00239 int JTAG_resetChannel (int chn);
00240 int JTAG_CAPTURE (int chn, unsigned char * buf, int len);
00241 int JTAG_EXTEST (int chn, unsigned char * buf, int len);
00242
00243 void JTAG_push_raw (int b);
00244 int JTAG_process_raw(void);
00245
00246
00247 int JTAG_channel(int minor) {
00248 switch (minor) {
00249 case FPGA_JTAG_RESET_MINOR :
00250 return JTAG_RAW;
00251 case FPGA_JTAG_MINOR:
00252 case FPGA_JTAG_BOUNDARY_MINOR:
00253 return JTAG_MAIN_FPGA;
00254 case FPGA_SJTAG_MINOR:
00255 case FPGA_SJTAG_BOUNDARY_MINOR:
00256 return JTAG_SENSOR_FPGA;
00257 case FPGA_AJTAG_MINOR:
00258 case FPGA_AJTAG_BOUNDARY_MINOR:
00259 return JTAG_AUX_FPGA;
00260 }
00261 return 0;
00262 }
00263 static int raw_fifo_w_wp;
00264 static int raw_fifo_w_rp;
00265 static int raw_fifo_r_wp;
00266 static int raw_fifo_r_rp;
00267 static int raw_chn;
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284 #define JTAG_RAW_SEND 0x10
00285 #define JTAG_RAW_SETCHN 0x20
00286 #define JTAG_RAW_DEACT 0x22
00287 #define JTAG_RAW_ACT 0x23
00288 #define JTAG_RAW_PGMOFF 0x24
00289 #define JTAG_RAW_PGMON 0x25
00290 #define JTAG_RAW_WAIT 0x80
00291
00292 void JTAG_push_raw (int b) {
00293 raw_fifo_r[raw_fifo_r_wp++]=b;
00294 if (raw_fifo_r_wp > FJTAG_RAW_RSIZE) raw_fifo_r_wp-=FJTAG_RAW_RSIZE;
00295 }
00296 int JTAG_process_raw(void) {
00297 unsigned char b0, b1;
00298 while (raw_fifo_w_rp != (raw_fifo_w_wp & ~1)) {
00299 b0=raw_fifo_w[raw_fifo_w_rp++];
00300 b1=raw_fifo_w[raw_fifo_w_rp++];
00301 if (raw_fifo_w_rp > FJTAG_RAW_WSIZE) raw_fifo_w_rp-=FJTAG_RAW_WSIZE;
00302 if (b1 == JTAG_RAW_SETCHN) {
00303 raw_chn = b0;
00304 if (raw_chn>=JTAG_NCHANNELS) raw_chn=0;
00305 JTAG_push_raw (raw_chn);
00306 } else if (raw_chn) {
00307 if ((b1 & 0xf0) == JTAG_RAW_SEND) {
00308 JTAG_push_raw (jtag_send(raw_chn, (b1 >> 3) & 1, b1 & 7, (int) b0 ));
00309 } else if ((b1 & 0x80) == JTAG_RAW_WAIT) {
00310 udelay(((b1 & 0x7f) <<8) + b0);
00311 JTAG_push_raw (0x80);
00312 } else switch (b1) {
00313 case JTAG_RAW_DEACT:
00314 set_pgm_mode (raw_chn, 0);
00315 JTAG_push_raw (0x0);
00316 break;
00317 case JTAG_RAW_ACT:
00318 set_pgm_mode (raw_chn, 1);
00319 JTAG_push_raw (0x0);
00320 break;
00321 case JTAG_RAW_PGMOFF:
00322 set_pgm (raw_chn, 0);
00323 JTAG_push_raw (read_done(raw_chn));
00324 case JTAG_RAW_PGMON:
00325 set_pgm (raw_chn, 1);
00326 JTAG_push_raw (0xf0);
00327 break;
00328 default:
00329 JTAG_push_raw (0xff);
00330 }
00331 } else {
00332 JTAG_push_raw (0xf0);
00333 }
00334 }
00335 return 0;
00336 }
00337
00338
00339
00340 int JTAG_whatopen(void) {
00341 int i,r=0;
00342 for (i=0;i<JTAG_NCHANNELS;i++) r |= 1 << JTAG_channels[i].mode;
00343 return r;
00344 }
00345
00346
00347
00348 static int fpga_jtag_open(struct inode *inode, struct file *filp) {
00349 int i;
00350
00351 int p = MINOR(inode->i_rdev);
00352 int chn= JTAG_channel(p);
00353 reg_intr_vect_rw_mask intr_mask;
00354 D(printk("fpga_open: minor=%x, channel=%x, buf=%p\r\n",p,chn,bitstream_data ));
00355 switch ( p ) {
00356 case FPGA_JTAG_RESET_MINOR :
00357 for (i=1; i<JTAG_NCHANNELS; i++) JTAG_channels[i].mode=JTAG_MODE_CLOSED;
00358 JTAG_channels[chn].mode=JTAG_MODE_RAW;
00359 JTAG_channels[chn].sizew = FJTAG_RAW_WSIZE;
00360 JTAG_channels[chn].sizer = FJTAG_RAW_RSIZE;
00361 JTAG_channels[chn].wp = 0;
00362 JTAG_channels[chn].rp = 0;
00363 raw_fifo_w_wp=0;
00364 raw_fifo_w_rp=0;
00365 raw_fifo_r_wp=0;
00366 raw_fifo_r_rp=0;
00367 raw_chn=0;
00368 break;
00369 case FPGA_JTAG_MINOR :
00370 if ( JTAG_whatopen() & 0x7e) return -EACCES;
00371
00372
00373
00374
00375
00376
00377 fpga_state &= ~FPGA_STATE_LOADED;
00378 fpga_state &= ~FPGA_STATE_SDRAM_INIT;
00379
00380
00381 intr_mask = REG_RD(intr_vect, regi_irq, rw_mask);
00382 intr_mask.ext = 0;
00383 REG_WR(intr_vect, regi_irq, rw_mask, intr_mask);
00384
00385
00386
00387 case FPGA_SJTAG_MINOR :
00388 case FPGA_AJTAG_MINOR :
00389 if ( JTAG_whatopen() & 0x7e) return -EACCES;
00390 JTAG_channels[chn].mode = JTAG_MODE_PGM;
00391 JTAG_channels[chn].dbuf = &bitstream_data[0];
00392 JTAG_channels[chn].sizew = FJTAG_BUF_SIZE;
00393 JTAG_channels[chn].sizer = FJTAG_IDSIZE >> 3;
00394 JTAG_channels[chn].wp = 0;
00395 JTAG_channels[chn].rp = 0;
00396 JTAG_channels[chn].bitsw = XC3S1200E_BITSIZE;
00397 JTAG_channels[chn].bitsr= FJTAG_IDSIZE;
00398 JTAG_openChannel (chn);
00399 break;
00400 case FPGA_JTAG_BOUNDARY_MINOR :
00401 case FPGA_SJTAG_BOUNDARY_MINOR :
00402 case FPGA_AJTAG_BOUNDARY_MINOR :
00403 if ( JTAG_whatopen() & 0x46) return -EACCES;
00404 if ( JTAG_channels[chn].mode != JTAG_MODE_CLOSED) return -EACCES;
00405 JTAG_channels[chn].mode = JTAG_MODE_BOUNDARY;
00406 JTAG_channels[chn].sizew = (XC3S1200E_BOUNDARY_SIZE+7) >> 3;
00407 JTAG_channels[chn].sizer = (XC3S1200E_BOUNDARY_SIZE+7) >> 3;
00408 JTAG_channels[chn].dbuf = &bitstream_data[JTAG_channels[chn].sizew * chn];
00409 JTAG_channels[chn].wp = 0;
00410 JTAG_channels[chn].rp = 0;
00411 JTAG_channels[chn].bitsw = XC3S1200E_BOUNDARY_SIZE;
00412 JTAG_channels[chn].bitsr= XC3S1200E_BOUNDARY_SIZE;
00413 JTAG_openChannel (chn);
00414 break;
00415 default: return -EINVAL;
00416 }
00417 D(printk("fpga_open: chn=%x, JTAG_channels[chn].sizew=%x, JTAG_channels[chn].sizer=%x\r\n", chn,JTAG_channels[chn].sizew, JTAG_channels[chn].sizer) );
00418 D(printk("fpga_open: chn=%x, JTAG_channels[chn].bitsw=%x, JTAG_channels[chn].bitsr=%x\r\n", chn,JTAG_channels[chn].bitsw, JTAG_channels[chn].bitsr) );
00419 JTAG_channels[chn].wdirty=0;
00420
00421 inode->i_size=JTAG_channels[chn].sizer;
00422 minors[p]=p;
00423 filp->private_data = &minors[p];
00424 D(printk("fpga_open: inode->i_size=%x, chn=%x\r\n", (int) inode->i_size, chn) );
00425 return 0;
00426 }
00427
00428
00429
00430 static int fpga_jtag_release(struct inode *inode, struct file *filp) {
00431 int res=0;
00432 int p = MINOR(inode->i_rdev);
00433 int chn= JTAG_channel(p);
00434
00435 D(printk("fpga_jtag_release: p=%x,chn=%x, wp=0x%x, rp=0x%x\r\n",p,chn, JTAG_channels[chn].wp, JTAG_channels[chn].rp));
00436 switch ( p ) {
00437 case FPGA_JTAG_RESET_MINOR :
00438 break;
00439 case FPGA_JTAG_MINOR :
00440 case FPGA_SJTAG_MINOR :
00441 case FPGA_AJTAG_MINOR :
00442 if (JTAG_channels[chn].wp > 0) {
00443 res=JTAG_configure (chn, JTAG_channels[chn].dbuf, JTAG_channels[chn].wp);
00444 if ((res >=0) & (chn == JTAG_MAIN_FPGA)) fpga_state|=1;
00445 }
00446
00447 if (chn == JTAG_MAIN_FPGA) fpga_state &=~FPGA_STATE_INITIALIZED;
00448 JTAG_resetChannel (chn);
00449
00450 break;
00451 case FPGA_JTAG_BOUNDARY_MINOR :
00452 case FPGA_SJTAG_BOUNDARY_MINOR :
00453 case FPGA_AJTAG_BOUNDARY_MINOR :
00454
00455 if (JTAG_channels[chn].wp >0) JTAG_EXTEST (chn, JTAG_channels[chn].dbuf, JTAG_channels[chn].bitsw);
00456 JTAG_resetChannel (chn);
00457 break;
00458 default: return -EINVAL;
00459 }
00460 minors[p]=0;
00461 JTAG_channels[chn].mode=JTAG_MODE_CLOSED;
00462 D(printk("fpga_jtag_release: done\r\n"));
00463 return (res<0)?res:0;
00464 }
00465
00466
00467
00468
00469
00470 static ssize_t fpga_jtag_write(struct file * file, const char * buf, size_t count, loff_t *off) {
00471 int p = ((int *)file->private_data)[0];
00472 int chn= JTAG_channel(p);
00473 size_t size = JTAG_channels[chn].sizew;
00474 D(printk("fpga_jtag_write: p=%x,chn=%x, buf address=%lx count=%lx *offs=%lx, wp=%lx,size=0x%x\r\n",p,chn,(long) buf, (long) count, (long) *off, (long)JTAG_channels[chn].wp, (int) size));
00475
00476 switch (p) {
00477 case FPGA_JTAG_RESET_MINOR :
00478 if (count > size) count= size;
00479 if ((raw_fifo_w_wp+count) > size) {
00480 if (copy_from_user(&raw_fifo_w[raw_fifo_w_wp],buf,size-raw_fifo_w_wp)) return -EFAULT;
00481 if (copy_from_user(&raw_fifo_w[0],&buf[size-raw_fifo_w_wp],count+raw_fifo_w_wp-size)) return -EFAULT;
00482 } else {
00483 if (copy_from_user(&raw_fifo_w[raw_fifo_w_wp],buf,count)) return -EFAULT;
00484 }
00485 raw_fifo_w_wp+=count;
00486 if (raw_fifo_w_wp > size) raw_fifo_w_wp -= size;
00487 JTAG_process_raw();
00488 break;
00489 case FPGA_JTAG_MINOR :
00490 case FPGA_SJTAG_MINOR :
00491 case FPGA_AJTAG_MINOR :
00492 if (*off > size) return -EFAULT;
00493 if ((*off + count) > size) count= (size - *off);
00494 if (copy_from_user(&(JTAG_channels[chn].dbuf[*off]),buf,count)) return -EFAULT;
00495 *off+=count;
00496 if (*off > JTAG_channels[chn].wp) JTAG_channels[chn].wp= *off;
00497 break;
00498 case FPGA_JTAG_BOUNDARY_MINOR :
00499 case FPGA_SJTAG_BOUNDARY_MINOR :
00500 case FPGA_AJTAG_BOUNDARY_MINOR :
00501 if (*off > size) return -EFAULT;
00502 if ((*off + count) > size) count= (size - *off);
00503
00504 if (*off < JTAG_channels[chn].wp) {
00505 JTAG_EXTEST (chn, JTAG_channels[chn].dbuf, JTAG_channels[chn].bitsw);
00506 JTAG_channels[chn].wdirty=0;
00507 }
00508 if (copy_from_user(&(JTAG_channels[chn].dbuf[*off]),buf,count)) return -EFAULT;
00509 *off+=count;
00510 JTAG_channels[chn].wp= *off;
00511 if (*off >= size) {
00512 *off=0;
00513 }
00514 JTAG_channels[chn].mode=JTAG_MODE_EXTEST;
00515 JTAG_channels[chn].wdirty=1;
00516 break;
00517 default: return -EINVAL;
00518 }
00519 D(printk("fpga_jtag_write end: p=%x,chn=%x, buf address=%lx count=%lx *offs=%lx, wp=%lx,size=0x%x\r\n",p,chn,(long) buf, (long) count, (long) *off, (long)JTAG_channels[chn].wp, (int) size));
00520 return count;
00521 }
00522
00523
00524
00525 ssize_t fpga_jtag_read(struct file * file, char * buf, size_t count, loff_t *off) {
00526 int p = ((int *)file->private_data)[0];
00527 int chn= JTAG_channel(p);
00528 size_t size = JTAG_channels[chn].sizer;
00529 int size_av;
00530
00531 D(printk("fpga_jtag_read: p=%x,chn=%x, buf address=%lx count=%lx *offs=%lx, rp=%lx,size=0x%x\r\n",p,chn,(long) buf, (long) count, (long) *off, (long)JTAG_channels[chn].rp, (int) size));
00532 switch (p) {
00533 case FPGA_JTAG_RESET_MINOR :
00534 size_av=(raw_fifo_r_wp >= raw_fifo_r_rp)?(raw_fifo_r_wp - raw_fifo_r_rp):(size+raw_fifo_r_wp - raw_fifo_r_rp);
00535 if (count > size_av) count= size_av;
00536 if ((raw_fifo_r_rp+count) > size) {
00537 if (copy_to_user(buf, &raw_fifo_r[raw_fifo_r_rp],size-raw_fifo_r_rp)) return -EFAULT;
00538 if (copy_to_user(&buf[size-raw_fifo_r_rp],&raw_fifo_r[0],count+raw_fifo_r_rp-size)) return -EFAULT;
00539 } else {
00540 if (copy_to_user(buf,&raw_fifo_w[raw_fifo_w_wp],count)) return -EFAULT;
00541 }
00542 raw_fifo_r_rp+=count;
00543 if (raw_fifo_r_rp > size) raw_fifo_r_rp -= size;
00544 break;
00545 case FPGA_JTAG_MINOR :
00546 case FPGA_SJTAG_MINOR :
00547 case FPGA_AJTAG_MINOR :
00548 if ((JTAG_channels[chn].wp==0) && (JTAG_channels[chn].rp==0)) {
00549 JTAG_channels[chn].mode=JTAG_MODE_RDID;
00550 JTAG_readID (chn, JTAG_channels[chn].dbuf);
00551 }
00552 if (*off > size) return -EFAULT;
00553 if ((*off + count) > size) count= (size - *off);
00554 D(printk("fpga_jtag_read_01: p=%x,chn=%x, buf address=%lx count=%lx *offs=%lx, rp=%lx,size=0x%x\r\n",p,chn,(long) buf, (long) count, (long) *off, (long)JTAG_channels[chn].rp, (int) size));
00555
00556 if (copy_to_user(buf,&(JTAG_channels[chn].dbuf[*off]),count)) return -EFAULT;
00557 *off+=count;
00558 JTAG_channels[chn].rp= *off;
00559 break;
00560 case FPGA_JTAG_BOUNDARY_MINOR :
00561 case FPGA_SJTAG_BOUNDARY_MINOR :
00562 case FPGA_AJTAG_BOUNDARY_MINOR :
00563 if ((JTAG_channels[chn].mode==JTAG_MODE_EXTEST) && (JTAG_channels[chn].wdirty || (*off < JTAG_channels[chn].rp))) {
00564 JTAG_EXTEST (chn, JTAG_channels[chn].dbuf, JTAG_channels[chn].bitsr);
00565 JTAG_channels[chn].wdirty=0;
00566 }
00567
00568 if ((JTAG_channels[chn].mode!=JTAG_MODE_EXTEST) && ((*off < JTAG_channels[chn].rp) || (JTAG_channels[chn].mode==JTAG_MODE_BOUNDARY))) {
00569 JTAG_CAPTURE (chn, JTAG_channels[chn].dbuf, JTAG_channels[chn].bitsr);
00570 }
00571 if (*off > size) return -EFAULT;
00572 if ((*off + count) > size) count= (size - *off);
00573 D(printk("fpga_jtag_read_01: p=%x,chn=%x, buf address=%lx count=%lx *offs=%lx, rp=%lx,size=0x%x\r\n",p,chn,(long) buf, (long) count, (long) *off, (long)JTAG_channels[chn].rp, (int) size));
00574
00575
00576
00577
00578 if (copy_to_user(buf,&(JTAG_channels[chn].dbuf[*off]),count)) return -EFAULT;
00579 *off+=count;
00580 JTAG_channels[chn].rp= *off;
00581 if (*off >= size) {
00582 *off=0;
00583 }
00584 if (JTAG_channels[chn].mode == JTAG_MODE_BOUNDARY) JTAG_channels[chn].mode=JTAG_MODE_SAMPLE;
00585 break;
00586 default: return -EINVAL;
00587 }
00588 D(printk("fpga_jtag_read_end: p=%x,chn=%x, buf address=%lx count=%lx *offs=%lx, rp=%lx,size=0x%x, mode=%x\r\n",p,chn,(long) buf, (long) count, (long) *off, (long)JTAG_channels[chn].rp, (int) size, JTAG_channels[chn].mode));
00589 return count;
00590 }
00591
00592
00593
00594 static loff_t fpga_jtag_lseek(struct file * file, loff_t offset, int orig) {
00595
00596
00597
00598
00599
00600 int p = ((int *)file->private_data)[0];
00601 int chn= JTAG_channel(p);
00602 size_t size;
00603 if (chn==JTAG_RAW) {
00604 size=raw_fifo_r_wp-raw_fifo_r_rp;
00605 if (size<0) size+=FJTAG_RAW_RSIZE;
00606 } else size = JTAG_channels[chn].sizew;
00607 if (JTAG_channels[chn].mode == JTAG_MODE_RDID) size = JTAG_channels[chn].sizer;
00608 D(printk("fpga_jtag_lseek, fsize= 0x%x\n", (int) size));
00609 switch (orig) {
00610 case 0:
00611 file->f_pos = offset;
00612 break;
00613 case 1:
00614 file->f_pos += offset;
00615 break;
00616 case 2:
00617 file->f_pos = size + offset;
00618 break;
00619 default:
00620 return -EINVAL;
00621 }
00622
00623 if (file->f_pos < 0) {
00624 file->f_pos = 0;
00625 return (-EOVERFLOW);
00626 }
00627
00628 if (file->f_pos > size) {
00629 file->f_pos = size;
00630 return (-EOVERFLOW);
00631 }
00632 D(printk("fpga_jtag_lseek, file->f_pos= 0x%x\n", (int) file->f_pos));
00633 return (file->f_pos);
00634 }
00635
00636
00637
00638
00639 void initPortC(void) {
00640
00641 unsigned long tmp;
00642 reg_pinmux_rw_pc_iop pinmux_c_iop;
00643 reg_pinmux_rw_pc_gio pinmux_c_gio;
00644 reg_gio_rw_pc_oe pc_oe;
00645
00646 pinmux_c_iop= REG_RD(pinmux, regi_pinmux, rw_pc_iop);
00647 tmp = REG_TYPE_CONV(unsigned long, reg_pinmux_rw_pc_iop, pinmux_c_iop);
00648 tmp &= ~0xff;
00649 pinmux_c_iop = REG_TYPE_CONV(reg_pinmux_rw_pc_iop, unsigned long, tmp);
00650 REG_WR(pinmux, regi_pinmux, rw_pc_iop, pinmux_c_iop);
00651
00652 pinmux_c_gio= REG_RD(pinmux, regi_pinmux, rw_pc_gio);
00653 tmp = REG_TYPE_CONV(unsigned long, reg_pinmux_rw_pc_gio, pinmux_c_gio);
00654 tmp |= 0xff;
00655 pinmux_c_gio = REG_TYPE_CONV(reg_pinmux_rw_pc_gio, unsigned long, tmp);
00656 REG_WR(pinmux, regi_pinmux, rw_pc_gio, pinmux_c_gio);
00657
00658
00659 pc_dout = REG_RD(gio, regi_gio, rw_pc_dout);
00660 pc_dout.data &= ~0xff;
00661 pc_dout.data |= PC_DOUT_INITIAL;
00662 REG_WR(gio, regi_gio, rw_pc_dout, pc_dout);
00663
00664
00665 pc_oe = REG_RD(gio, regi_gio, rw_pc_oe);
00666 pc_oe.oe &= ~( (1 << FPGAJTAG_TDO_BIT) |
00667 (1 << FPGAJTAG_DONE_BIT) |
00668 (1 << FPGAJTAG_RSTBTN_BIT));
00669 pc_oe.oe |= ( (1 << FPGAJTAG_TDI_BIT) |
00670 (1 << FPGAJTAG_TMS_BIT) |
00671 (1 << FPGAJTAG_TCK_BIT) |
00672 (1 << FPGAJTAG_PGM_BIT));
00673 REG_WR(gio, regi_gio, rw_pc_oe, pc_oe);
00674 }
00675
00676
00677
00678 void set_pgm_mode (int chn, int en) {
00679 D(printk ("set_pgm_mode (%d,%d)\n",chn,en));
00680
00681 switch (chn) {
00682 case JTAG_SENSOR_FPGA:
00683 port_csp0_addr[X313_WA_SENSFPGA] = (en ? (3 << SFPGA_PGMEN_BIT): (SFPGA_RD_SENSPGMPIN | (2 << SFPGA_PGMEN_BIT))) | (2 << SFPGA_TCK_BIT);
00684 break;
00685 }
00686 udelay (2);
00687 }
00688
00689 void set_pgm (int chn, int pgmon) {
00690 D(printk ("set_pgm (%d,%d)\n",chn,pgmon));
00691 switch (chn) {
00692 case JTAG_MAIN_FPGA:
00693 if (pgmon) pc_dout.data &= ~0x80;
00694 else pc_dout.data |= 0x80;
00695 REG_WR(gio, regi_gio, rw_pc_dout, pc_dout);
00696 break;
00697 case JTAG_SENSOR_FPGA:
00698 port_csp0_addr[X313_WA_SENSFPGA] = (2 | (pgmon & 1)) << SFPGA_PROG_BIT;
00699 break;
00700 case JTAG_AUX_FPGA:
00701 break;
00702 }
00703 udelay (2);
00704 }
00705
00706
00707 int read_done (int chn) {
00708 switch (chn) {
00709 case JTAG_MAIN_FPGA:
00710 return ((((REG_RD(gio, regi_gio, r_pc_din)).data & 0x20)==0) ? 0 : 1 );
00711 case JTAG_SENSOR_FPGA:
00712 port_csp0_addr[X313_WA_SENSFPGA] = SFPGA_RD_DONE;
00713 udelay (1);
00714 return (port_csp0_addr[X313__RA__SENSFPGA] >> SFPGA_RD_BIT) & 1 ;
00715 case JTAG_AUX_FPGA:
00716 return 0;
00717 }
00718 return 0;
00719 }
00720
00721
00722 int jtag_send (int chn, int tms, int len, int d) {
00723 int i;
00724 int r=0;
00725 int d0;
00726 i = len & 7;
00727 if (i==0) i=8;
00728 d &= 0xff;
00729 d0=d;
00730 D( printk("jtag_send(0x%x, 0x%x, 0x%x, 0x%x)\r\n", chn, tms,len,d));
00731 switch (chn) {
00732 case JTAG_MAIN_FPGA:
00733
00734 pc_dout.data &= ~0x0e;
00735 pc_dout.data |= (tms & 1) << FPGAJTAG_TMS_BIT;
00736 for (;i>0;i--){
00737 r= (r<<1)+ ((REG_RD(gio, regi_gio, r_pc_din)).data & 1);
00738 pc_dout.data = (pc_dout.data & ~0x0a) | (((d<<=1)>>7) & 2);
00739 REG_WR(gio, regi_gio, rw_pc_dout, pc_dout);
00740 pc_dout.data |= (1 << FPGAJTAG_TCK_BIT);
00741 REG_WR(gio, regi_gio, rw_pc_dout, pc_dout);
00742 pc_dout.data &= ~(1 << FPGAJTAG_TCK_BIT);
00743 REG_WR(gio, regi_gio, rw_pc_dout, pc_dout);
00744 }
00745 break;
00746 case JTAG_SENSOR_FPGA:
00747 port_csp0_addr[X313_WA_SENSFPGA] = SFPGA_RD_TDO;
00748 udelay (1);
00749 for (;i>0;i--){
00750 port_csp0_addr[X313_WA_SENSFPGA] = (2 << SFPGA_TCK_BIT);
00751 port_csp0_addr[X313_WA_SENSFPGA] = ((2 | (tms & 1)) << SFPGA_TMS_BIT) |
00752 (((((d<<=1)>>8) & 1) | 2) << SFPGA_TDI_BIT) |
00753 (2 << SFPGA_TCK_BIT) ;
00754 port_csp0_addr[X313_WA_SENSFPGA] = (2 << SFPGA_TCK_BIT);
00755 port_csp0_addr[X313_WA_SENSFPGA] = (3 << SFPGA_TCK_BIT);
00756 r= (r<<1)+ ((port_csp0_addr[X313__RA__SENSFPGA] >> SFPGA_RD_BIT) & 1);
00757 port_csp0_addr[X313_WA_SENSFPGA] = (2 << SFPGA_TCK_BIT);
00758
00759 }
00760 port_csp0_addr[X313_WA_SENSFPGA] = (2 << SFPGA_TCK_BIT);
00761 break;
00762 case JTAG_AUX_FPGA:
00763 break;
00764 }
00765 return r;
00766 }
00767
00768
00769
00770
00771
00772
00773
00774
00775 int jtag_write_bits (int chn,
00776 unsigned char *buf,
00777 int len,
00778 int check,
00779 int last,
00780 int prev[2])
00781 {
00782 int i,j;
00783 int r=0;
00784 int d,d0;
00785 D( printk("jtag_write_bits(0x%x, 0x%x, 0x%x, 0x%x, 0x%x)\r\n", (int) chn, (int) buf, len, check, last););
00786
00787 switch (chn) {
00788 case JTAG_MAIN_FPGA:
00789
00790 for (i=0; len>0;i++) {
00791 pc_dout.data &= ~0x0e;
00792 d0=(d=buf[i]);
00793 for (j=0;j<8;j++) {
00794
00795 if (len>0) {
00796 r= (r<<1)+ ((REG_RD(gio, regi_gio, r_pc_din)).data & 1);
00797 if ((len==1) && last) pc_dout.data = (pc_dout.data & ~0x0a) | (((d<<=1)>>7) & 2) | (1 << FPGAJTAG_TMS_BIT);
00798 else pc_dout.data = (pc_dout.data & ~0x0a) | (((d<<=1)>>7) & 2);
00799 REG_WR(gio, regi_gio, rw_pc_dout, pc_dout);
00800 pc_dout.data |= (1 << FPGAJTAG_TCK_BIT);
00801 REG_WR(gio, regi_gio, rw_pc_dout, pc_dout);
00802 pc_dout.data &= ~(1 << FPGAJTAG_TCK_BIT);
00803 REG_WR(gio, regi_gio, rw_pc_dout, pc_dout);
00804 } else r= (r<<1);
00805 len--;
00806
00807 }
00808 buf[i]=r;
00809 if (check && ((r ^ (prev[1] >> 24)) & 0xff)) {
00810 return -((r & 0xff) | ((i+1) << 8));
00811 }
00812 if (prev) {
00813
00814
00815 prev[1]= (prev[1]<<8) | ((prev[0]>>24) & 0xff);
00816 prev[0]= (prev[0]<<8) | (d0 & 0xff);
00817 }
00818 }
00819 break;
00820 case JTAG_SENSOR_FPGA:
00821 port_csp0_addr[X313_WA_SENSFPGA] = SFPGA_RD_TDO;
00822 udelay (1);
00823 for (i=0; len>0;i++) {
00824 d0=(d=buf[i]);
00825 for (j=0;j<8;j++) {
00826 port_csp0_addr[X313_WA_SENSFPGA] = (2 << SFPGA_TCK_BIT);
00827 if (len>0) {
00828 if ((len==1) && last) port_csp0_addr[X313_WA_SENSFPGA] =
00829 (3 << SFPGA_TMS_BIT) |
00830 (((((d<<=1)>>8) & 1) | 2) << SFPGA_TDI_BIT) |
00831 (2 << SFPGA_TMS_BIT) |
00832 (2 << SFPGA_TCK_BIT) ;
00833
00834 else port_csp0_addr[X313_WA_SENSFPGA] =
00835 (((((d<<=1)>>8) & 1) | 2) << SFPGA_TDI_BIT) |
00836 (2 << SFPGA_TMS_BIT) |
00837 (2 << SFPGA_TCK_BIT) ;
00838 port_csp0_addr[X313_WA_SENSFPGA] = (2 << SFPGA_TCK_BIT);
00839 port_csp0_addr[X313_WA_SENSFPGA] = (3 << SFPGA_TCK_BIT);
00840
00841 r= ((r<<1)+ ((port_csp0_addr[X313__RA__SENSFPGA] >> SFPGA_RD_BIT) & 1));
00842 port_csp0_addr[X313_WA_SENSFPGA] = (2 << SFPGA_TCK_BIT);
00843 } else r= (r<<1);
00844 len--;
00845 }
00846 buf[i]=r;
00847 if (check && ((r ^ (prev[1]>>24)) & 0xff)) {
00848 return -((r & 0xff) | ((i+1) << 8));
00849 }
00850 if (prev) {
00851
00852
00853 prev[1]= (prev[1]<<8) | ((prev[0]>>24) & 0xff);
00854 prev[0]= (prev[0]<<8) | (d0 & 0xff);
00855 }
00856
00857 }
00858 port_csp0_addr[X313_WA_SENSFPGA] = (2 << SFPGA_TCK_BIT);
00859 break;
00860 case JTAG_AUX_FPGA:
00861 break;
00862
00863 }
00864 return 0;
00865 }
00866
00867
00868 int JTAG_configure (int chn, unsigned char * buf, int len) {
00869 int datastart, i, j ,r;
00870
00871
00872 int prev[2];
00873 #ifdef JTAG_DISABLE_IRQ
00874 unsigned long flags;
00875 #endif
00876 const unsigned char sync[]={0xff,0xff,0xff,0xff,0xaa,0x99,0x55,0x66};
00877 int skipvfy=8;
00878
00879 D(printk("JTAG_configure: chn=%x, wp=0x%x, rp=0x%x, len=0x%x\r\n",chn, JTAG_channels[chn].wp, JTAG_channels[chn].rp, len));
00880
00881
00882
00883
00884 datastart=-1;
00885 for (i=0;i<(FJTAG_MAX_HEAD-8);i++) {
00886 j=0;
00887 while ((j<8) && (buf[i+j]==sync[j])) j++;
00888 if (j==8) {
00889 datastart=i;
00890 break;
00891 }
00892 }
00893 if (datastart<0) {
00894 printk("Bitstream not found - bad file\r\n");
00895 return -EFAULT;
00896 }
00897
00898 if ((len-datastart)!=(XC3S1200E_BITSIZE>>3)) {
00899 printk("Wrong bitstream size - XC3S1200E has bitstream of %d bits (%d bytes)\n",XC3S1200E_BITSIZE,XC3S1200E_BITSIZE>>3);
00900 printk ("header size - %d, data size - %d\r\n",datastart, len-datastart);
00901 return -EFAULT;
00902 }
00903
00904 set_pgm_mode(chn, 1);
00905
00906 set_pgm (chn, 1);
00907 udelay (1000);
00908 set_pgm (chn, 0);
00909
00910 udelay (2500);
00911
00912 D( udelay (100000);printk("JTAG_configure(): IRQ off!\r\n"); udelay (100000););
00913 #ifdef JTAG_DISABLE_IRQ
00914 local_irq_save(flags);
00915
00916 #endif
00917
00918 jtag_send(chn, 1, 5, 0 );
00919 jtag_send(chn, 0, 1, 0 );
00920 jtag_send(chn, 1, 2, 0 );
00921 jtag_send(chn, 0, 2, 0 );
00922 jtag_send(chn, 0, 5, 0xa0);
00923 jtag_send(chn, 1, 1, 0 );
00924 jtag_send(chn, 1, 2, 0 );
00925 jtag_send(chn, 0, 2, 0 );
00926
00927 jtag_write_bits (chn,
00928 &buf[datastart],
00929 skipvfy << 3,
00930 0,
00931 0,
00932 prev);
00933
00934 if ((r=jtag_write_bits (chn,
00935 &buf[datastart+skipvfy],
00936
00937 (len-(datastart+skipvfy)) << 3,
00938 1,
00939 1, prev))<0) {
00940 r= -r;
00941 i= (r>>8) -1 + (datastart+skipvfy);
00942 r &= 0xff;
00943 #ifdef JTAG_DISABLE_IRQ
00944 local_irq_restore(flags);
00945 #endif
00946 set_pgm (chn, 1);
00947 set_pgm (chn, 0);
00948
00949 set_pgm_mode(chn, 0);
00950 printk ("**** Configuration failed at byte # %d (%x)****\n", (i-datastart),(i-datastart));
00951 printk ("**** r= %x, prev64=%x prev32=%x****\n", r,prev[1], prev[0]);
00952 return -EFAULT;
00953 }
00954 jtag_send(chn, 1, 1, 0 );
00955 jtag_send(chn, 1, 2, 0 );
00956 jtag_send(chn, 0, 2, 0 );
00957 jtag_send(chn, 0, 5, 0x30);
00958 jtag_send(chn, 1, 1, 0 );
00959 jtag_send(chn, 1, 2, 0 );
00960 jtag_send(chn, 0, 0, 0 );
00961 jtag_send(chn, 0, 0, 0 );
00962 jtag_send(chn, 1, 2, 0 );
00963 jtag_send(chn, 0, 1, 0 );
00964 jtag_send(chn, 0, 0, 0 );
00965 jtag_send(chn, 0, 0, 0 );
00966
00967 #ifdef JTAG_DISABLE_IRQ
00968 local_irq_restore(flags);
00969 #endif
00970
00971 r=read_done(chn);
00972
00973 set_pgm_mode(chn, 0);
00974
00975 if (r==0) {
00976 printk("*** FPGA did not start after configuration ***\r\n");
00977 return -EFAULT;
00978 }
00979
00980 D( udelay (100000);printk("\nJTAG_configure() OK!\r\n"));
00981 return 0;
00982 }
00983
00984
00985
00986
00987
00988
00989 int JTAG_openChannel (int chn) {
00990 D(printk ("JTAG_openChannel (%d)\n",chn));
00991
00992 set_pgm_mode(chn, 1);
00993
00994 switch (chn) {
00995 case JTAG_SENSOR_FPGA:
00996
00997 set_pgm (chn, 1);
00998 set_pgm (chn, 0);
00999
01000 udelay (2500);
01001 break;
01002 }
01003 jtag_send(chn, 1, 5, 0 );
01004 jtag_send(chn, 0, 1, 0 );
01005 }
01006
01007 int JTAG_resetChannel (int chn) {
01008 D(printk ("JTAG_resetChannel (%d)\n",chn));
01009 jtag_send(chn, 1, 5, 0 );
01010
01011 set_pgm_mode(chn, 0);
01012 }
01013
01014 int JTAG_readID (int chn, unsigned char * buf) {
01015 int i;
01016 unsigned long d1,d2=0;
01017 unsigned long * dp;
01018 #ifdef JTAG_DISABLE_IRQ
01019 unsigned long flags;
01020 #endif
01021
01022
01023
01024 #ifdef JTAG_DISABLE_IRQ
01025 local_irq_save(flags);
01026
01027 #endif
01028
01029 jtag_send(chn, 1, 5, 0 );
01030 jtag_send(chn, 0, 1, 0 );
01031 jtag_send(chn, 1, 2, 0 );
01032 jtag_send(chn, 0, 2, 0 );
01033 jtag_send(chn, 0, 5, 0x90);
01034 jtag_send(chn, 1, 1, 0 );
01035 jtag_send(chn, 1, 2, 0 );
01036 jtag_send(chn, 0, 2, 0 );
01037 jtag_write_bits (chn,
01038 &buf[0],
01039 32,
01040 0,
01041 1, 0) ;
01042 jtag_send(chn, 1, 5, 0 );
01043 jtag_send(chn, 0, 1, 0 );
01044 jtag_send(chn, 1, 2, 0 );
01045 jtag_send(chn, 0, 2, 0 );
01046 jtag_send(chn, 0, 5, 0x10);
01047 jtag_send(chn, 1, 1, 0 );
01048 jtag_send(chn, 1, 2, 0 );
01049 jtag_send(chn, 0, 2, 0 );
01050 jtag_write_bits (chn,
01051 &buf[4],
01052 32,
01053 0,
01054 1,0) ;
01055 jtag_send(chn,1, 5, 0 );
01056 #ifdef JTAG_DISABLE_IRQ
01057 local_irq_restore(flags);
01058 #endif
01059
01060
01061 dp = (unsigned long *) &buf[0];
01062 d1= *dp;
01063 for (i=0;i<32;i++){
01064 d2 = (d2 << 1) | (d1 & 1);
01065 d1 >>= 1;
01066 }
01067 *dp=d2;
01068 dp = (unsigned long *) &buf[4];
01069 d1= *dp;
01070 for (i=0;i<32;i++){
01071 d2 = (d2 << 1) | (d1 & 1);
01072 d1 >>= 1;
01073 }
01074 *dp=d2;
01075 D(for (i=0; i<8;i++) {printk("%3x ",(int) buf[i]); if ((i & 0xf) == 0xf) printk ("\n");} );
01076 data_modified=0;
01077 return 0;
01078 }
01079
01080
01081
01082
01083
01084
01085 int JTAG_CAPTURE (int chn, unsigned char * buf, int len) {
01086
01087 #ifdef JTAG_DISABLE_IRQ
01088 unsigned long flags;
01089 #endif
01090 D(printk("buf=%p\n",buf));
01091
01092 #ifdef JTAG_DISABLE_IRQ
01093 local_irq_save(flags);
01094
01095 #endif
01096
01097
01098
01099 jtag_send(chn, 1, 2, 0 );
01100 jtag_send(chn, 0, 2, 0 );
01101 jtag_send(chn, 0, 5, 0x80);
01102 jtag_send(chn, 1, 1, 0 );
01103 jtag_send(chn, 1, 2, 0 );
01104 jtag_send(chn, 0, 2, 0 );
01105 jtag_write_bits (chn,
01106 buf,
01107 len,
01108 0,
01109 1,0) ;
01110
01111
01112 jtag_send(chn, 1, 1, 0 );
01113
01114
01115 #ifdef JTAG_DISABLE_IRQ
01116 local_irq_restore(flags);
01117 #endif
01118
01119 D(printk ("\n"); for (i=0; i<((len+7)>>3) ;i++) {printk("%3x ",(int) buf[i]); if ((i & 0xf) == 0xf) printk ("\n");}printk ("\n"); );
01120 data_modified=0;
01121 return 0;
01122
01123 }
01124
01125
01126
01127
01128
01129
01130
01131 int JTAG_EXTEST (int chn, unsigned char * buf, int len) {
01132 #ifdef JTAG_DISABLE_IRQ
01133 unsigned long flags;
01134 #endif
01135
01136 #ifdef JTAG_DISABLE_IRQ
01137 local_irq_save(flags);
01138
01139 #endif
01140 D(printk("EXTEST: buf=%p, len=0x%x\n",buf,len));
01141
01142
01143
01144 jtag_send(chn, 1, 2, 0 );
01145 jtag_send(chn, 0, 2, 0 );
01146 jtag_send(chn, 0, 5, 0xf0);
01147 jtag_send(chn, 1, 1, 0 );
01148 jtag_send(chn, 1, 2, 0 );
01149 jtag_send(chn, 0, 2, 0 );
01150
01151 jtag_write_bits (chn,
01152 buf,
01153 len,
01154 0,
01155 1,0);
01156 jtag_send(chn, 1, 1, 0 );
01157 #ifdef JTAG_DISABLE_IRQ
01158 local_irq_restore(flags);
01159 #endif
01160 D(printk ("\n"); for (i=0; i<((len+7)>>3) ;i++) {printk("%3x ",(int) buf[i]); if ((i & 0xf) == 0xf) printk ("\n");}printk ("\n"); );
01161
01162 return 0;
01163 }
01164
01165 static int __init fpga_jtag_init(void) {
01166 int i,res;
01167 res = register_chrdev(FPGA_JTAG_MAJOR, fpga_jtag_name, &fpga_jtag_fops);
01168 if(res < 0) {
01169 printk(KERN_ERR "fpga_jtag_init: couldn't get a major number.\n");
01170 return res;
01171 }
01172 printk(FPGA_JTAG_DRIVER_NAME"\r\n");
01173 for (i=0;i<=FPGA_JTAG_MAXMINOR;i++) minors[i]=0;
01174 initPortC();
01175 fpga_state&=~0xffff;
01176 return 0;
01177 }
01178
01179
01180
01181
01182
01183 module_init(fpga_jtag_init);
01184 MODULE_LICENSE("GPL");
01185 MODULE_AUTHOR("Andrey Filippov <andrey@elphel.com>.");
01186 MODULE_DESCRIPTION(FPGA_JTAG_DRIVER_NAME);
01187