Ejemplo n.º 1
0
unsigned *target_atag_devinfo_data(unsigned *ptr)
{
  int i = 0;
  *ptr++ = tag_size(tag_devinfo_data);
  *ptr++ = ATAG_DEVINFO_DATA;
  for (i=0;i<ATAG_DEVINFO_DATA_SIZE;i++){
    *ptr++ = get_devinfo_with_index(i);  
  }
  *ptr++ = ATAG_DEVINFO_DATA_SIZE;
  printf("SSSS:0x%x\n", get_devinfo_with_index(3));
  printf("SSSS:0x%x\n", get_devinfo_with_index(4));
  printf("SSSS:0x%x\n", get_devinfo_with_index(5));
  printf("SSSS:0x%x\n", get_devinfo_with_index(10));
  return ptr;
}
static int mtktscpu_read_cal(char *buf, char **start, off_t off, int count, int *eof, void *data)
{
	int len = 0;
	char *p = buf;
	p += sprintf(p, "mtktscpu cal:\nReg1=0x%x, Reg2=0x%x",
	                get_devinfo_with_index(15), get_devinfo_with_index(16));
		
	*start = buf + off;

	len = p - buf;
	if (len > off)
		len -= off;
	else
		len = 0;
        
	return len < count ? len  : count;
}
static void thermal_cal_prepare(void)
{
	kal_uint32 efuse_reg0, efuse_reg1;

	efuse_reg0 = get_devinfo_with_index(15);
	efuse_reg1 = get_devinfo_with_index(16);

	g_adc_oe = 		(efuse_reg1 & 0x000FFC00)>>10;
	g_adc_cali_en = (efuse_reg1 & 0x00100000)>>20;			
	g_adc_ge =		(efuse_reg1 & 0x000003FF);
	g_o_vtsabb =	(efuse_reg0 & 0x000001FF);	
	g_id=			(efuse_reg0 & 0x00000200)>>9;	
	g_degc_cali = 	(efuse_reg0 & 0x0000FC00)>>10;	
	g_o_slope_sign =(efuse_reg0 & 0x02000000)>>25;	
		
	if(g_id==0)
	{
		g_o_slope=0;
	}
	else
	{
		g_o_slope = (efuse_reg0 & 0xFC000000)>>26;
	}
	
	if(g_adc_cali_en == 0)
	{
		g_o_slope=0;
		g_adc_ge = 512;
		g_adc_oe = 512;
		g_degc_cali = 40;
		g_o_slope = 0;
		g_o_slope_sign = 0;
		g_o_vtsabb = 260;
	}
	printk("[Power/CPU_Thermal] [Thermal calibration] g_adc_ge = 0x%x, g_adc_oe = 0x%x, g_degc_cali = 0x%x, g_adc_cali_en = 0x%x, g_o_slope = 0x%x, g_o_slope_sign = 0x%x, g_id = 0x%x\n", 
		g_adc_ge, g_adc_oe, g_degc_cali, g_adc_cali_en, g_o_slope, g_o_slope_sign, g_id);
	printk("[Power/CPU_Thermal] [Thermal calibration] g_o_vtsabb = 0x%x \n",
		g_o_vtsabb);
}
Ejemplo n.º 4
0
static int fastboot_oem_key_chk(void)
{
    int ret = B_OK;
    u32 chip_code = 0x0;
    char serial_number[SERIAL_NUMBER_SIZE+1] = {0};
    u64 key;
    char cal_serial_number[SERIAL_NUMBER_SIZE+1] = {0};

    /* Check for the unlock key */
    if(UNLOCK_KEY_SIZE != strlen(fb_unlock_key_str))
    {
        //fastboot_fail("Unlock key length is incorrect!");
        ret = ERR_UNLOCK_KEY_WRONG_LENGTH;
        return ret;
    }

    /* Get the device serial number */
    key = get_devinfo_with_index(13);
    key = (key << 32) | get_devinfo_with_index(12);
    chip_code = DRV_Reg32(APHW_CODE);
    if (key != 0)
        get_serial(key, chip_code, serial_number);
    else
        memcpy(serial_number, DEFAULT_SERIAL_NUM, SERIAL_NUMBER_SIZE);

    /* Calculate the serial number from the unlock key */
    sec_get_serial_number_from_unlock_key((u8 *)fb_unlock_key_str, UNLOCK_KEY_SIZE, (u8 *)cal_serial_number, SERIAL_NUMBER_SIZE);

    /* Compare the results */
    if(0 != memcmp(serial_number, cal_serial_number, SERIAL_NUMBER_SIZE))
    {
        //fastboot_fail("Unlock key code is incorrect!");
        ret = ERR_UNLOCK_WRONG_KEY_CODE;
        return ret;
    }

    return ret;
}
Ejemplo n.º 5
0
static int modem_power_down_worker(void *data)
{
	unsigned int val;

	val = get_devinfo_with_index(4);
	if ((val & (0x1 << 1)) == 0)
		internal_md_power_down();
	else
		pr_debug("[ccci-off]md1 effused,no need power off\n");
	if ((val & (0x1 << 15)) == 0)
		internal_md2_power_down();
	else
		pr_debug("[ccci-off]md2 effused,no need power off\n");
	return 0;
}
Ejemplo n.º 6
0
/************************************************************************** 
*  DEV DRIVER IOCTL 
**************************************************************************/ 
static long dev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
    u32 index = 0;
    int err   = 0;
    int ret   = 0;
    u32 data_size = g_devinfo_data_size;
    u32 data_read = 0;

    /* ---------------------------------- */
    /* IOCTL                              */
    /* ---------------------------------- */
    if (_IOC_TYPE(cmd) != DEV_IOC_MAGIC)
        return -ENOTTY;
    if (_IOC_NR(cmd) > DEV_IOC_MAXNR)
        return -ENOTTY;
    if (_IOC_DIR(cmd) & _IOC_READ)
        err = !access_ok(VERIFY_WRITE, (void __user *)arg, _IOC_SIZE(cmd));
    if (_IOC_DIR(cmd) & _IOC_WRITE)
        err = !access_ok(VERIFY_READ, (void __user *)arg, _IOC_SIZE(cmd));
    if (err) return -EFAULT;
    
    switch (cmd) {

        /* ---------------------------------- */
        /* get dev info data                  */
        /* ---------------------------------- */
        case READ_DEV_DATA:
            //xlog_printk(ANDROID_LOG_INFO, DEVINFO_TAG ,"%s CMD - READ_DEV_DATA\n",MODULE_NAME);
            if(copy_from_user((void *)&index, (void __user *)arg, sizeof(u32)))
            {              
                return -EFAULT;            
            }
            //xlog_printk(ANDROID_LOG_INFO, DEVINFO_TAG ,"%s READ_DEV_DATA IDX:%d\n",MODULE_NAME, index);

            if (index < data_size){
                data_read = get_devinfo_with_index(index);
                ret = copy_to_user((void __user *)arg, (void *)&(data_read), sizeof(u32));
            }else{
                xlog_printk(ANDROID_LOG_ERROR, DEVINFO_TAG ,"%s Error! Data index larger than data size. index:%d, size:%d\n",MODULE_NAME, 
                    index, data_size);
                return -EFAULT;            
            }
        break;       
    }
    
    return 0;
}
Ejemplo n.º 7
0
/**************************************************************************
*  DEV DRIVER IOCTL
**************************************************************************/
static long devinfo_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	u32 index = 0;
	int err   = 0;
	int ret   = 0;
	u32 data_size = ARRAY_SIZE(g_devinfo_data);
	u32 data_read = 0;

	/* ---------------------------------- */
	/* IOCTL							  */
	/* ---------------------------------- */
	if (_IOC_TYPE(cmd) != DEV_IOC_MAGIC)
		return -ENOTTY;
	if (_IOC_NR(cmd) > DEV_IOC_MAXNR)
		return -ENOTTY;
	if (_IOC_DIR(cmd) & _IOC_READ)
		err = !access_ok(VERIFY_WRITE, (void __user *)arg, _IOC_SIZE(cmd));
	if (_IOC_DIR(cmd) & _IOC_WRITE)
		err = !access_ok(VERIFY_READ, (void __user *)arg, _IOC_SIZE(cmd));
	if (err)
		return -EFAULT;

	switch (cmd) {
	/* ---------------------------------- */
	/* get dev info data				  */
	/* ---------------------------------- */
	case READ_DEV_DATA:
		if (copy_from_user((void *)&index, (void __user *)arg, sizeof(u32)))
			return -1;
		if (index < data_size) {
			data_read = get_devinfo_with_index(index);
			ret = copy_to_user((void __user *)arg, (void *)&(data_read), sizeof(u32));
		} else {
			pr_warn("%s Error! Data index larger than data size. index:%d, size:%d\n", MODULE_NAME,
			index, data_size);
			return -2;
		}
		break;
	}

	return 0;
}
Ejemplo n.º 8
0
void usb_phy_recover(void){

    //4 1. turn on USB reference clock.
    usb_enable_clock(true);
    //4 2. wait 50 usec.
    udelay(50);

	#ifdef MTK_UART_USB_SWITCH
	if (!usb_phy_check_in_uart_mode()) {
    // clean PUPD_BIST_EN
    // PUPD_BIST_EN = 1'b0
    // PMIC will use it to detect charger type
    USBPHY_CLR8(0x1d, 0x10);

    //4 3. force_uart_en = 1'b0
    USBPHY_CLR8(0x6b, 0x04);
    //4 4. RG_UART_EN = 1'b0
    USBPHY_CLR8(0x6e, 0x1);
	//4 5. release force suspendm.
    USBPHY_CLR8(0x6a, 0x04);

	skipDisableUartMode = false;
	} else {
		if (!skipDisableUartMode)
			return;
	}
	#else
    // clean PUPD_BIST_EN
    // PUPD_BIST_EN = 1'b0
    // PMIC will use it to detect charger type
    USBPHY_CLR8(0x1d, 0x10);

    //4 3. force_uart_en = 1'b0
    USBPHY_CLR8(0x6b, 0x04);
    //4 4. RG_UART_EN = 1'b0
    USBPHY_CLR8(0x6e, 0x1);
    //4 5. force_uart_en = 1'b0
    USBPHY_CLR8(0x6a, 0x04);
	#endif

    //4 6. RG_DPPULLDOWN = 1'b0
    USBPHY_CLR8(0x68, 0x40);
    //4 7. RG_DMPULLDOWN = 1'b0
    USBPHY_CLR8(0x68, 0x80);
    //4 8. RG_XCVRSEL = 2'b00
    USBPHY_CLR8(0x68, 0x30);
    //4 9. RG_TERMSEL = 1'b0
    USBPHY_CLR8(0x68, 0x04);
    //4 10. RG_DATAIN[3:0] = 4'b0000
    USBPHY_CLR8(0x69, 0x3c);

   //4 11. force_dp_pulldown = 1b'0
    USBPHY_CLR8(0x6a, 0x10);
    //4 12. force_dm_pulldown = 1b'0
    USBPHY_CLR8(0x6a, 0x20);
    //4 13. force_xcversel = 1b'0
    USBPHY_CLR8(0x6a, 0x08);
    //4 14. force_termsel = 1b'0
    USBPHY_CLR8(0x6a, 0x02);
    //4 15. force_datain = 1b'0
    USBPHY_CLR8(0x6a, 0x80);

    //4 16. RG_USB20_BC11_SW_EN 1'b0
    USBPHY_CLR8(0x1a, 0x80);
    
	//RG_USB20_INTR_CAL[4:0]	5'b01101	Internal R selection
	if (get_devinfo_with_index(19) & (0xF80))
    {
    	//printk("USB HW reg: read RG_USB20_INTR_CAL 0x%x\n", USBPHY_READ8(0x06));
			USBPHY_WRITE8(0x06,((USBPHY_READ8(0x06)&0x7)|((get_devinfo_with_index(19)&0xF80)>>4)));
			printk("USB HW reg: write RG_USB20_INTR_CAL 0x%x\n", USBPHY_READ8(0x06));
		}
Ejemplo n.º 9
0
unsigned int __chip_wafer_big_ver(void)
{
    unsigned int val = get_devinfo_with_index(16) & 0x03000000; //[25:24]
    return (val >> 24);
}
Ejemplo n.º 10
0
unsigned int __chip_fab_code(void)
{
    unsigned int val = get_devinfo_with_index(25) & 0x70000000; //[30:28]    
    return (val >> 28);
}
Ejemplo n.º 11
0
unsigned int __chip_proj_code(void)
{
    unsigned int val = get_devinfo_with_index(24) & 0x00003FFF; //[13:0]        
    return (val);
}
Ejemplo n.º 12
0
unsigned int __chip_date_code(void)
{
    unsigned int val = get_devinfo_with_index(24) & 0x00FFC000; //[23:14]
    return (val >> 14);
}    
Ejemplo n.º 13
0
unsigned int __chip_func_code(void)
{
	unsigned int val = get_devinfo_with_index(47) & 0xFE000000;	/* [31:25] */

	return val >> 25;
}
Ejemplo n.º 14
0
void usb_phy_recover(){

  //turn on USB reference clock. 
  usb_enable_clock(true);
  
  if (usb_phy_check_in_uart_mode())
		return;
		
  //wait 50 usec.
  udelay(50);

	/* force_uart_en = 1'b0 */
	USBPHY_CLR8(0x6b, 0x04);
	/* RG_UART_EN = 1'b0 */
	USBPHY_CLR8(0x6e, 0x01);
	/* force_uart_en = 1'b0 */
	USBPHY_CLR8(0x6a, 0x04);
  /* RG_DPPULLDOWN./RG_DMPULLDOWN. */
  /* RG_XCVRSEL[1:0] = 2'b00 */
  /* RG_TERMSEL = 1'b0 */
	USBPHY_CLR8(0x68, 0xf4);
	/* RG_DATAIN[3:0] = 4'b0000 */
	USBPHY_CLR8(0x69, 0x3c);
	/*
	 * force_dp_pulldown, force_dm_pulldown, 
	 * force_xcversel, force_termsel.
	 */
	USBPHY_CLR8(0x6a, 0xba);

	/* RG_USB20_BC11_SW_EN = 1'b0 */
	USBPHY_CLR8(0x1a, 0x80);
	/* RG_USB20_OTG_VBUSSCMP_EN = 1'b1 */
	USBPHY_SET8(0x1a, 0x10);

	udelay(800);
    
// force enter device mode
	USBPHY_CLR8(0x6c, 0x10);
	USBPHY_SET8(0x6c, 0x2E);
	USBPHY_SET8(0x6d, 0x3E);
  
  hs_slew_rate_cal();
  
  //RG_USB20_VRT_VREF_SEL[2:0]=5 (ori:4) (0x11110804[14:12])
  USBPHY_SET8(0x05, 0x10);
  //RG_USB20_TERM_VREF_SEL[2:0]=5 (ori:4) (0x11110804[10:8])
  USBPHY_SET8(0x05, 0x01);
  

	printk("USB HW reg: index18=0x%x, index7=0x%x\n", get_devinfo_with_index(18), get_devinfo_with_index(7));  
  if (get_devinfo_with_index(18) & (0x01<<14))
	{
		USBPHY_CLR8(0x00, 0x20);
		printk("USB HW reg: write RG_USB20_INTR_EN 0x%x\n", USBPHY_READ8(0x00));
	}
	
	if (get_devinfo_with_index(7) & (0x07<<8))
	{
		//RG_USB20_VRT_VREF_SEL[2:0]=5 (ori:4) (0x11110804[14:12])
		USBPHY_CLR8(0x05, 0x70);
  	USBPHY_SET8(0x05, ((get_devinfo_with_index(7)>>8)<<4)&0x70);
  	printk("USB HW reg: overwrite RG_USB20_VRT_VREF_SEL 0x%x\n", USBPHY_READ8(0x05));
	}
Ejemplo n.º 15
0
unsigned int __chip_func_code(void)
{       
    unsigned int val = get_devinfo_with_index(24) & 0xFF000000; //[31:24]
    return (val >> 24);
}
Ejemplo n.º 16
0
static u32 check_need_univpll(void) {
	u32 devinfo = get_devinfo_with_index(3);
	return devinfo & 0x80000;
}
Ejemplo n.º 17
0
static int mjc_open(struct inode *pInode, struct file *pFile)
{
    unsigned long ulFlags;
    unsigned int u4efuse;
#ifdef CONFIG_MTK_SEGMENT_TEST	
	unsigned int u4TestValue;
#endif
    
    MJCDBG("mjc_open() pid = %d\n", current->pid);

#ifndef CONFIG_MTK_SEGMENT_TEST	
    u4efuse = get_devinfo_with_index(EFUSE_MJC_IDX);
     
    if ((u4efuse & EFUSE_MJC_BIT) != 0)
    {
    	  MJCMSG("[ERROR] mjc efuse no support %d\n", u4efuse);
        return -1;
    }
#endif	

    // Gary todo: enable clock 
    enable_clock(MT_CG_DISP0_SMI_COMMON, "mjc");
	enable_clock(MT_CG_DISP0_LARB4_AXI_ASIF_MM, "mjc");
	enable_clock(MT_CG_DISP0_LARB4_AXI_ASIF_MJC, "mjc");
    enable_clock(MT_CG_MJC_SMI_LARB, "mjc");
	enable_clock(MT_CG_MJC_TOP_GROUP0, "mjc");
	enable_clock(MT_CG_MJC_TOP_GROUP1, "mjc");
	enable_clock(MT_CG_MJC_TOP_GROUP2, "mjc");
	enable_clock(MT_CG_MJC_LARB4_AXI_ASIF, "mjc");	

#ifdef CONFIG_MTK_SEGMENT_TEST
    u4TestValue = MJC_Reg32((gulRegister+4));
	MJCDBG("Pre-Read: 0x%x\n", u4TestValue);
	MJC_WriteReg32((gulRegister+4), 0x123456);
    MJC_WriteReg32((gulRegister+4), 0x123456);
	u4TestValue = MJC_Reg32((gulRegister+4));
	MJCDBG("Read: 0x%x\n", u4TestValue);
	if (u4TestValue == 0x123456)
	{
	    MJCMSG("[MJC efuse] HW enable\n");
	}
	else
	{
	    MJCMSG("[MJC efuse] HW disable\n");
		return -1;
	}
#endif	

	spin_lock_irqsave(&ContextLock, ulFlags);
	grContext.rEvent.u4TimeoutMs = 0xFFFFFFFF;
	spin_unlock_irqrestore(&ContextLock, ulFlags);

	spin_lock_irqsave(&HWLock, ulFlags);
	grHWLockContext.rEvent.u4TimeoutMs = 0xFFFFFFFF;
	spin_unlock_irqrestore(&HWLock, ulFlags);

	_mjc_m4uConfigPort();

	m4u_register_fault_callback(M4U_PORT_MJC_MV_RD, mjc_m4u_fault_callback, (void *)0);
	m4u_register_fault_callback(M4U_PORT_MJC_MV_WR, mjc_m4u_fault_callback, (void *)0);
	m4u_register_fault_callback(M4U_PORT_MJC_DMA_RD, mjc_m4u_fault_callback, (void *)0);
	m4u_register_fault_callback(M4U_PORT_MJC_DMA_WR, mjc_m4u_fault_callback, (void *)0);

	MJCDBG("Mapping register: 0x%lx, PA:0x%lx, Size:0x%lx, Irq ID:%d\n", gulRegister, gu1PaReg, gu1PaSize, gi4IrqID);

	return 0;
}