int efuse_write(char *buf, unsigned count, unsigned *ppos, int from) { unsigned pos = *ppos; const char *pc; unsigned long contents[EFUSE_DWORDS]; if (pos >= EFUSE_BYTES) return 0; /* Past EOF */ if (count > EFUSE_BYTES - pos) count = EFUSE_BYTES - pos; if (count > EFUSE_BYTES) return -1; which=from; efuse_init(); int i; // checkout if have been written memset(contents, 0, EFUSE_DWORDS); pc = (char*)contents; efuse_read(pc, count, &pos, from); for(i=0; i<count; i++){ if(pc[i] != 0) return -1; } pos = *ppos; for (pc = buf; count--; ++pos, ++pc) __efuse_write_byte(pos, *pc); *ppos = pos; return 0; }
static ssize_t efuse_block_dump(struct device *dev, struct device_attribute *attr, char *buf) { int idx; char *p = buf; p += sprintf(p, "ddie efuse blocks dump:\n"); for (idx = 0; idx < EFUSE_BLOCK_MAX; idx++) { p += sprintf(p, "[%02d] %08x\n", idx, efuse_read(idx)); } return p - buf; }
int do_read_efuse(int ppos,int *flag,int *temp,int *TS_C, int print) { char buf[2]; int ret; int cpu = 0; char *cpu_str[] = {"M8", "M8M2", "M8Baby", "G9TV", "G9TVBaby"}; *flag=0; buf[0]=0; buf[1]=0; //read efuse tsc,flag efuse_init(); ret=efuse_read(buf,2,(loff_t *)&ppos); if (print) { printf("buf[0]=%x,buf[1]=%x\n",buf[0],buf[1]); } if (IS_MESON_M8_CPU) { *temp=buf[1]; *temp=(*temp<<8)|buf[0]; *TS_C=*temp&0xf; *flag=(*temp&0x8000)>>15; *temp=(*temp&0x7fff)>>4; cpu = 0; } else if (IS_MESON_M8M2_CPU) {
static int _key_query_secure_boot_set(char* keyname, unsigned int * keystate) { unsigned int pos = 0; unsigned int info_lis=0xffffffff; int nChkVal = 0, nChkAddr = 0; if(strcmp("secure_boot_set", keyname)){ printf("Err, key name (%s) is not secure_boot_set\n", keyname); return -__LINE__; } //Check if bit7 && bit 6 are both 1 //Attention: check this code to stay same with cmd[efuse secure_boot_set] efuse_read(&nChkVal,sizeof(nChkVal),(loff_t*)&nChkAddr); if(((nChkVal >> 7) & 1) && ((nChkVal >> 6) & 1)) { *keystate = KEY_BURNED; return __LINE__; } *keystate = KEY_NO_EXIST;//key not burned return 0; }