spi.c File Reference

#include <flash.h>

Include dependency graph for spi.c:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static struct flash_function
st25p65_flash_func 
__attribute__ ((section(".flash.init")))
static int __spiromsyscall1 (int type, unsigned long long addr, union commondata *mydata)
static int __spiromsyscall2 (int type, unsigned long long addr, union commondata *mydata)
int cmd_spi_init (int argc, char **argv)
static int cmd_spiroms (int argc, char **argv)
static int cmd_test_erase_spi_area (int argc, char **argv)
static int cmd_test_program_spi (int argc, char **argv)
void ls1f_spi_init (void *unused)
 mycmd_init (spi_init, cmd_spi_init,"spi_init","init spi")
 mycmd_init (spiroms, cmd_spiroms,"","select spi rom for read")
 mycmd_init (test_program_spi, cmd_test_program_spi,"","test program spi")
 mycmd_init (test_erase_spi_area, cmd_test_erase_spi_area,"","test erase spi")

Variables

static unsigned int code_erase_area_st25p64 []
static unsigned int code_erase_st25p64 []
static unsigned int code_program_st25p64 []
static int ls1f_spi_inited


Function Documentation

static struct flash_function st25p65_flash_func __attribute__ ( (section(".flash.init"))   )  [static, read]

static int __spiromsyscall1 ( int  type,
unsigned long long  addr,
union commondata *  mydata 
) [static]

Definition at line 49 of file spi.c.

References commondata.c, tgt_exec, ui_datamem, ui_fifomem, and uififo_waddr.

Referenced by cmd_spiroms().

00050 {
00051 uififo_waddr=0;
00052 ui_datamem[0] = addr;
00053 ui_datamem[1] = type;
00054 
00055 tgt_exec(\
00056 "1:mtc0    s0, $31;\n" 
00057 "li s0,0xff200000;\n"
00058 "sw v0,0x1fc(s0);\n"
00059 "sw v1,0x1fc(s0);\n"
00060 "sw ra,0x1fc(s0);\n"
00061 "sw t0,0x1fc(s0);\n"
00062 "li v0,0xbfe80000;\n" 
00063 "bal 102f;\n" /*wait sr */
00064 "nop;\n" 
00065 "li v1,1;\n"
00066 "sb v1,5(v0);\n" /*enable and low cs*/
00067 "li v1,3;\n"  /* read command */
00068 "bal 101f;\n" 
00069 "nop;\n" 
00070 "lw t0,0(s0);\n" /*addr*/
00071 "srl v1,t0,16;\n" /*addr*/
00072 "bal 101f;\n" 
00073 "nop;\n" 
00074 "srl v1,t0,8;\n" 
00075 "bal 101f;\n" 
00076 "nop;\n" 
00077 "move v1,t0;\n" 
00078 "bal 101f;\n" 
00079 "nop;\n" 
00080 "lw t0,4(s0);\n" /*count*/
00081 "2:bal 101f;\n" /*read 1 data*/ 
00082 "nop;\n" 
00083 "sb v1,0x1f8(s0);\n"
00084 "addiu t0,-1;\n"
00085 "bnez t0,2b;\n" 
00086 "nop;\n" \
00087 "li v1,0x11;\n"
00088 "sb v1,5(v0);\n" /*enable and high cs*/
00089 "li s0,0xff200000;\n"
00090 "lw t0,0x1fc(s0);\n"
00091 "lw ra,0x1fc(s0);\n"
00092 "lw v1,0x1fc(s0);\n"
00093 "lw v0,0x1fc(s0);\n"
00094 "mfc0    s0, $31;\n" 
00095 "b 1b;\n" 
00096 "nop;\n" 
00097 "101:sb v1,2(v0);\n" 
00098 "1:lb v1,1(v0);\n" 
00099 "andi v1,1;\n" 
00100 "bnez v1,1b;\n"
00101 "nop;\n"
00102 "lb v1,2(v0);\n" 
00103 "jr ra;\n" 
00104 "nop;" 
00105 "102:move t0,ra;\n" 
00106 "li v1,1;\n"
00107 "sb v1,5(v0);\n" /*enable and low cs*/
00108 "1:li v1,5;\n"  /*wait read sr*/
00109 "bal 101b;\n" 
00110 "nop;\n" 
00111 "andi v1,1;\n"
00112 "bnez v1,1b;\n"
00113 "nop;\n"
00114 "li v1,0x11;\n"
00115 "sb v1,5(v0);\n" /*enable and high cs*/
00116 "jr t0;\n"
00117 "nop;\n",
00118 0x8000
00119 );
00120 
00121 memcpy(mydata->c,ui_fifomem,type);
00122 return 0;
00123 }

static int __spiromsyscall2 ( int  type,
unsigned long long  addr,
union commondata *  mydata 
) [static]

Definition at line 125 of file spi.c.

Referenced by cmd_spiroms().

00126 {
00127 return -1;
00128 }

int cmd_spi_init ( int  argc,
char **  argv 
)

Definition at line 43 of file spi.c.

References ls1f_spi_init().

00044 {
00045         ls1f_spi_init(0);
00046 }

Here is the call graph for this function:

static int cmd_spiroms ( int  argc,
char **  argv 
) [static]

Definition at line 130 of file spi.c.

References __spiromsyscall1(), __spiromsyscall2(), cp0s_sel, ls1f_spi_init(), syscall1, syscall2, and syscall_addrwidth.

00131 {
00132 syscall1=__spiromsyscall1;
00133 syscall2=__spiromsyscall2;
00134 syscall_addrwidth=1;
00135 if(argc>1)cp0s_sel=strtoul(argv[1],0,0);
00136 else cp0s_sel=0;
00137 ls1f_spi_init(0);
00138 return 0;       
00139 }

Here is the call graph for this function:

static int cmd_test_erase_spi_area ( int  argc,
char **  argv 
) [static]

Definition at line 366 of file spi.c.

References code_erase_area_st25p64, context_reg, context_restore(), context_save(), dMIPS32_NUM_DEBUG_REGISTERS, fMIPS32_ExecuteDebugModule(), ls1f_spi_init(), and ui_datamem.

00367 {
00368         int context_reg[dMIPS32_NUM_DEBUG_REGISTERS];
00369         int i;
00370         ls1f_spi_init(0);
00371         context_save(context_reg);
00372         ls1f_spi_init(0);
00373         ui_datamem[0] = 0x00000;
00374         ui_datamem[1] = 0x7ffff;
00375         ui_datamem[2] = 0x10000;
00376         fMIPS32_ExecuteDebugModule(code_erase_area_st25p64,sizeof(code_erase_area_st25p64),1);
00377         context_restore(context_reg);
00378 }

Here is the call graph for this function:

static int cmd_test_program_spi ( int  argc,
char **  argv 
) [static]

Definition at line 353 of file spi.c.

References code_program_st25p64, context_reg, context_restore(), context_save(), dMIPS32_NUM_DEBUG_REGISTERS, fMIPS32_ExecuteDebugModule(), ls1f_spi_init(), and tgt_exec.

00354 {
00355         int context_reg[dMIPS32_NUM_DEBUG_REGISTERS];
00356         int i;
00357         ls1f_spi_init(0);
00358 //      for(i=0;i<256;i++)((char *)ui_datamem)[i]=i;
00359         context_save(context_reg);
00360         tgt_exec("1:li a0,0xa1000000;li a1,0x00000;li a2,0x60000;b 1b;nop",80);
00361         fMIPS32_ExecuteDebugModule(code_program_st25p64,sizeof(code_program_st25p64),1);
00362         context_restore(context_reg);
00363 }

Here is the call graph for this function:

void ls1f_spi_init ( void *  unused  ) 

Definition at line 5 of file spi.c.

References ls1f_spi_inited, and tgt_exec.

Referenced by cmd_spi_init(), cmd_spiroms(), cmd_test_erase_spi_area(), and cmd_test_program_spi().

00006 {
00007 
00008 if(ls1f_spi_inited) return;
00009 ls1f_spi_inited = 1;
00010 
00011 tgt_exec(
00012 "#define SPI_BASE 0xbfe80000 \n"
00013 "#define SPCR      0x0 \n"
00014 "#define SPSR      0x1 \n"
00015 "#define TXFIFO    0x2 \n"
00016 "#define SPER      0x3 \n"
00017 "#define PARAM     0x4 \n"
00018 "#define SOFTCS    0x5 \n"
00019 "#define PARAM2    0x6 \n"
00020 
00021 ".macro set_spi add,val\n"
00022 "li v1,\val;\n"
00023 "sb v1,\add(v0);\n"
00024 ".endm\n"
00025 
00026 "1:mtc0    v0, $31;\n" 
00027 "li    v0,0xff200000;\n" 
00028 "sw    v1,0x1fc(v0);\n" 
00029 "li        v0,SPI_BASE;\n" /*spi base*/
00030 "set_spi SPSR,0xc0;\n"
00031 "set_spi PARAM,0x40;\n"
00032 "set_spi SPER,0x5;\n"
00033 "set_spi PARAM2,1;\n"
00034 "set_spi SPCR,0x50;\n"
00035 "li    v0,0xff200000;\n" 
00036 "lw    v1,0x1fc(v0);\n" 
00037 "mfc0    v0, $31;\n" 
00038 "b 1b;\n" 
00039 "nop;" 
00040 ,0x8000);
00041 }

mycmd_init ( spi_init  ,
cmd_spi_init  ,
"spi_init"  ,
"init spi"   
)

mycmd_init ( spiroms  ,
cmd_spiroms  ,
""  ,
"select spi rom for read"   
)

mycmd_init ( test_program_spi  ,
cmd_test_program_spi  ,
""  ,
"test program spi"   
)

mycmd_init ( test_erase_spi_area  ,
cmd_test_erase_spi_area  ,
""  ,
"test erase spi"   
)


Variable Documentation

unsigned int code_erase_area_st25p64[] [static]

Definition at line 269 of file spi.c.

Referenced by cmd_test_erase_spi_area().

unsigned int code_erase_st25p64[] [static]

Definition at line 142 of file spi.c.

unsigned int code_program_st25p64[] [static]

Definition at line 201 of file spi.c.

Referenced by cmd_test_program_spi().

int ls1f_spi_inited [static]

Definition at line 3 of file spi.c.

Referenced by ls1f_spi_init().


Generated on Fri Nov 5 07:24:51 2010 for ejtag debug tools for loongson 232 cpu by  doxygen 1.5.6