Esempio n. 1
0
 static ssize_t efuse_read( struct file *file, char __user *buf,
     size_t count, loff_t *ppos )
 {
     unsigned long contents[EFUSE_DWORDS];
         unsigned pos = *ppos;
     unsigned long *pdw;
     unsigned int dwsize = (count + 3)/4;

         if (pos >= EFUSE_BYTES)
                 return 0;

         if (count > EFUSE_BYTES - pos)
                 count = EFUSE_BYTES - pos;
         if (count > EFUSE_BYTES)
                 return -EFAULT;

     printk( KERN_INFO "efuse_read: f_pos: %lld, ppos: %lld\n", file->f_pos, *ppos);

     memset(contents, 0, sizeof(contents));

         for (pdw = contents; dwsize-- > 0 && pos < EFUSE_BYTES; pos += 4, ++pdw)
                 __efuse_read_dword(pos, pdw);

     if (copy_to_user(buf, contents, count))
         return -EFAULT;

     *ppos += count;
     return count;
 }
Esempio n. 2
0
 static ssize_t __efuse_read( char *buf,
     size_t count, loff_t *ppos )
 {
     unsigned long contents[EFUSE_DWORDS];
         unsigned pos = *ppos;
     unsigned long *pdw;
     unsigned int dwsize = (count + 3)/4;

         if (pos >= EFUSE_BYTES)
                 return 0;

         if (count > EFUSE_BYTES - pos)
                 count = EFUSE_BYTES - pos;
         if (count > EFUSE_BYTES)
                 return -EFAULT;

     memset(contents, 0, sizeof(contents));

         for (pdw = contents; dwsize-- > 0 && pos < EFUSE_BYTES; pos += 4, ++pdw)
                 __efuse_read_dword(pos, pdw);

     memcpy(buf, contents, count);

     *ppos += count;
     return count;
 }
Esempio n. 3
0
static unsigned int efuse_read_byte(unsigned long addr){
	efuse_init();
	unsigned int int_addr = addr;
	unsigned int off_addr = addr % 4;
	unsigned int r_data = 0;
	__efuse_read_dword(int_addr, &r_data);
	//serial_put_hex(r_data, 32);
	//serial_put_hex(((r_data >> (off_addr*8)) & 0xff), 8);
	return ((r_data >> (off_addr*8)) & 0xff);
}
Esempio n. 4
0
int efuse_read(char *buf, unsigned count, unsigned *ppos, int from)
{
    unsigned long contents[EFUSE_DWORDS];
	unsigned pos = *ppos;
    unsigned long *pdw;
    unsigned residunt = pos%4;
    unsigned int dwsize = (count+residunt+3)>>2;
    
	if (pos >= EFUSE_BYTES)
		return 0;
	if (count > EFUSE_BYTES - pos)
		count = EFUSE_BYTES - pos;
	if (count > EFUSE_BYTES)
		return -1;
	
	which = from;	
	efuse_init();

    memset(contents, 0, sizeof(contents));

 	// Enabel auto-read mode    
    WRITE_EFUSE_REG_BITS( efuse_reg_addr(EFUSE_CNTL1), CNTL1_AUTO_RD_ENABLE_ON,
             							CNTL1_AUTO_RD_ENABLE_BIT, CNTL1_AUTO_RD_ENABLE_SIZE ); 
    pos = (pos/4)*4;
    for (pdw = contents; dwsize-- > 0 && pos < EFUSE_BYTES; pos += 4, ++pdw)
		__efuse_read_dword(pos, pdw);	    

     // Disable auto-read mode    
    WRITE_EFUSE_REG_BITS( efuse_reg_addr(EFUSE_CNTL1), CNTL1_AUTO_RD_ENABLE_OFF,
             CNTL1_AUTO_RD_ENABLE_BIT, CNTL1_AUTO_RD_ENABLE_SIZE );
            
	memcpy(buf, (char*)contents+residunt, count);	
	
    *ppos += count;
    return 0;
}