xref: /utopia/UTPA2-700.0.x/projects/tools/gr/spi_load.c (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1 #include <fcntl.h>
2 #include <sys/ioctl.h>
3 #include <stdio.h>
4 #include "mdrv_system_io.h"
5 #include "mdrv_types.h"
6 #include "mdrv_system_st.h"
7 
8 
9 #define SYS_MODULE_KERNAL_NAME   "/dev/system"
10 #define SYS_PRINT(fmt, args...)  printf("[SYSTEM (user mode)][%05d] " fmt, __LINE__, ## args)
11 
12 static int SYS_fd = 0;
13 
14 
MAdp_SYS_Init(void)15 void MAdp_SYS_Init(void)
16 {
17     if (SYS_fd==0)   //First time open
18     {
19         SYS_fd = open(SYS_MODULE_KERNAL_NAME, O_RDWR);
20         SYS_PRINT("open System Kernal finish\n");
21     }
22     else
23     {
24         SYS_PRINT("Fail to open System Kernal Module\n");
25     }
26     //printf("\nStart T8 demo \n");
27     //Init Scaler
28     //printf("SYS_fd= %d\n",SYS_fd);
29     SYS_PRINT("Start to Init System\n");
30 }
31 
MAdp_SPI_Load(U32 start,U32 len,U8 * bin)32 void MAdp_SPI_Load(U32 start,U32 len,U8 *bin)
33 {
34 	IO_SYS_SPI_t spi;
35 	spi.u32Start=start;
36 	spi.u32Len=len;
37 	spi.u8data=bin;
38 
39         ioctl(SYS_fd,IOCTL_SYS_SPI_LOAD,&spi);
40 
41 //	printf("\nstart 0x%08x   , size %d bytes \n",spi.u32Start,spi.u32Len);
42 //	unsigned int i;
43 //	printf("\nMAdp_SYS_SPI_LOAD\n");
44 //	for (i=0;i<0x10;i++)	printf("0x%02x ",*(spi.u8data+i));
45 
46 }
47