Esempio n. 1
0
void ft6x06_report_dsm_erro(struct ft6x06_ts_data * ft6x06_data, struct dsm_client * dsm_client, 
                                                                int type, int err_num)
{
    if(!dsm_client)
    {
        tp_log_err("%s %d: dsm_client is null!\n", __func__, __LINE__);
        return;
    }

    if(dsm_client_ocuppy(dsm_client))
    {
        tp_log_err("%s %d: dsm buffer is busy!\n", __func__, __LINE__);
        return;
    }

    switch(type)
    {
        case DSM_TP_I2C_RW_ERROR_NO:
            dsm_client_record(dsm_client,"%s %d: i2c_trans_erro, rc = %d\n", __func__,__LINE__, err_num); 
            break;
        case DSM_TP_FW_ERROR_NO:
            dsm_client_record(dsm_client,"%s %d: firmware upgrade erro!\n", __func__,__LINE__); 
            break;
        default:
            break;
    }

    ft6x06_dsm_record_basic_info(ft6x06_data, dsm_client);
    dsm_client_notify(dsm_client, type);

    return;
}
static void dsm_gpio_key_timer_func(unsigned long data)
{
	int key_press_error_found = -1;

	if (!dsm_client_ocuppy(key_dclient)) {
		key_press_error_found++;
	}

	/* judge the press count */
	if ((!key_press_error_found) && (volume_up_press_count > MAX_PRESS_KEY_COUNT)) {
		key_press_error_found++;
		dsm_client_record(key_dclient, "volume up key trigger on the abnormal style.\n");
	} else if ((!key_press_error_found) && (volume_down_press_count > MAX_PRESS_KEY_COUNT)) {
		key_press_error_found++;
		dsm_client_record(key_dclient, "volume down key trigger on the abnormal style.\n");
	}

	if (key_press_error_found > 0) {
		dsm_client_notify(key_dclient, DSM_KEY_ERROR_NO);
	} else if (!key_press_error_found) {
		dsm_client_unocuppy(key_dclient);
	} else {
		/* key_dclient preempt failed, we have nothing to do */
	}

	/* reset the statistic variable */
	volume_up_press_count = 0;
	volume_down_press_count = 0;
	mod_timer(&dsm_gpio_key_timer, jiffies + STATISTIC_INTERVAL * HZ);

	return;
}
/*add power status error judge,avoid red screen*/
void lcd_dcm_pwr_status_handler(unsigned long data)
{
	/*Not in factory mode will report this dsm log*/
	if( !is_runmode_factory() ) {
	/*optimize 20110 report strategy for device monitor.*/
		if((lcd_pwr_status.lcd_dcm_pwr_status != LCD_PWR_STAT_GOOD)&&(lcd_pwr_status.lcd_dcm_pwr_status != LCD_PWR_STAT_IS_GOOD))
		{
			dsm_client_record(lcd_dclient, "lcd power status wrong, value :%x\n",lcd_pwr_status.lcd_dcm_pwr_status);
			
			dsm_client_record(lcd_dclient, "lcd power status :bit 0  do unblank\n");
			dsm_client_record(lcd_dclient, "lcd power status :bit 1  lcd on\n");
			dsm_client_record(lcd_dclient, "lcd power status :bit 2  set frame\n");
			dsm_client_record(lcd_dclient, "lcd power status :bit 3  set backlgiht\n");
			
			dsm_client_record(lcd_dclient, "lcd power status :if did the operation the bit will be set to 1 or the bit is 0\n");
			dsm_client_record(lcd_dclient,"unblank at [%d-%d-%d]%d:%d:%d:%d\n",lcd_pwr_status.tm_unblank.tm_year + 1900,lcd_pwr_status.tm_unblank.tm_mon+1,
							lcd_pwr_status.tm_unblank.tm_mday,lcd_pwr_status.tm_unblank.tm_hour,lcd_pwr_status.tm_unblank.tm_min,lcd_pwr_status.tm_unblank.tm_sec,lcd_pwr_status.tvl_unblank.tv_usec%1000);
			dsm_client_record(lcd_dclient,"lcd on at [%d-%d-%d]%d:%d:%d:%d\n",lcd_pwr_status.tm_lcd_on.tm_year + 1900,lcd_pwr_status.tm_lcd_on.tm_mon+1,
							lcd_pwr_status.tm_lcd_on.tm_mday,lcd_pwr_status.tm_lcd_on.tm_hour,lcd_pwr_status.tm_lcd_on.tm_min,lcd_pwr_status.tm_lcd_on.tm_sec,lcd_pwr_status.tvl_lcd_on.tv_usec%1000);
			dsm_client_record(lcd_dclient,"set frame at [%d-%d-%d]%d:%d:%d:%d\n",lcd_pwr_status.tm_set_frame.tm_year + 1900,lcd_pwr_status.tm_set_frame.tm_mon+1,
							lcd_pwr_status.tm_set_frame.tm_mday,lcd_pwr_status.tm_set_frame.tm_hour,lcd_pwr_status.tm_set_frame.tm_min,lcd_pwr_status.tm_set_frame.tm_sec,lcd_pwr_status.tvl_set_frame.tv_usec%1000);
			dsm_client_record(lcd_dclient,"set backlight at [%d-%d-%d]%d:%d:%d:%d\n",lcd_pwr_status.tm_backlight.tm_year + 1900,lcd_pwr_status.tm_backlight.tm_mon+1,
							lcd_pwr_status.tm_backlight.tm_mday,lcd_pwr_status.tm_backlight.tm_hour,lcd_pwr_status.tm_backlight.tm_min,lcd_pwr_status.tm_backlight.tm_sec,lcd_pwr_status.tvl_backlight.tv_usec%1000);
			
			dsm_client_notify(lcd_dclient, DSM_LCD_POWER_STATUS_ERROR_NO);

			show_state_filter(TASK_UNINTERRUPTIBLE);
		}
	} else {
		/*in factory mode do not report this dsm log,just print a log for locate*/
		LCD_LOG_INFO("[%s] in factory mode ignore log of 20110\n",__func__);
	}
	lcd_pwr_status.lcd_dcm_pwr_status = 0;
}
struct hisi_hi6421v300_coul_battery_data* get_battery_data(unsigned int id_voltage)
{
    int i;
    int dsm_error_found = -1;
    int dsm_error_offset = 0;

    if (!bat_param_status)
    {
        hwlog_err("battery param is invalid\n");
        return NULL;
    }
    if(!dsm_client_ocuppy(battery_detect_dclient))
    {
        dsm_error_found++;
    }
    for(i = 0; i < hisi_bat_data_size; i++)
    {
        if((id_voltage > p_data[i]->id_identify_min) && (id_voltage <= p_data[i]->id_identify_max))
        {
            if ((id_voltage < p_data[i]->id_voltage_min) || (id_voltage > p_data[i]->id_voltage_max))
            {
                dsm_error_found++;
                dsm_error_offset = 0;
                dsm_client_record(battery_detect_dclient, "Battery id voltage:%d is out of normal range:[%d~%d],identify range:[%d~%d]!\n",id_voltage,
                    p_data[i]->id_voltage_min,p_data[i]->id_voltage_max,p_data[i]->id_identify_min,p_data[i]->id_identify_max);
            }
            break;
        }
    }
    if(i == hisi_bat_data_size)
    {
        i = 0;
        dsm_error_found++;
        dsm_error_offset = 1;
        dsm_client_record(battery_detect_dclient, "Battery id voltage:%d is invalid. Use the default battery params!\n",id_voltage);
    }
    if(dsm_error_found > 0)
    {
        dsm_client_notify(battery_detect_dclient, DSM_BATTERY_DETECT_ERROR_NO + dsm_error_offset);
    }
    else if(!dsm_error_found)
    {
        dsm_client_unocuppy(battery_detect_dclient);
    }
    else
    {
        hwlog_err("dsm battery_detect_dclient ocuppy failed!\n");
    }
    hwlog_info("current battery name is %s\n", p_data[i]->batt_brand);
    return p_data[i];
}
static void hi6401_check_pll(struct hi6401_irq *irq)
{
	unsigned long flags = 0;
	u32 ret = 0;
	u32 val = 0;

	mutex_lock(&irq->sr_mutex);
	spin_lock_irqsave(&irq->rw_lock, flags);
	writel(1, irq->reg_base_addr + (HI6401_PAGE_SELECT_REG << 2));
	udelay(1);
	ret = readl(irq->reg_base_addr + ((HI6401_PLL_PD_REG & HI6401_PAGE_OFFSET_MASK) << 2));
	udelay(1);
	if (0 == (ret & 1)) { /* HI6401_PLL_PD_BIT */
		/* pll power on */
		val = readl(irq->reg_base_addr + ((HI6401_PLL_EN_REG & HI6401_PAGE_OFFSET_MASK) << 2));
		udelay(1);
		if (0 != (val & (1 << HI6401_PLL_EN_BIT))) {
			/* pll enable */
			ret = readl(irq->reg_base_addr + ((HI6401_PLL_STATUS_REG & HI6401_PAGE_OFFSET_MASK) << 2));
			udelay(1);
			if (0 == (ret & (1 << HI6401_PLL_STATUS_BIT))) {
				pr_err("%s,line:%d reset pll.\n", __FUNCTION__, __LINE__);
				/* pll unlocked */
				hi6401_codec_dump(irq);
				if ((1 == pll_unlock_flag) && !dsm_client_ocuppy(hi6401_client)) {
					dsm_client_record(hi6401_client, "DSM_HI6401_PLL_UNLOCK ret=%d,codec=%s\n", ret, (g_dump_buf ? g_dump_buf : "null"));
					dsm_client_notify(hi6401_client, DSM_HI6401_PLL_UNLOCK);
				}
				pll_unlock_flag++;
				val &= ~(1 << HI6401_PLL_EN_BIT);
				writel(val, irq->reg_base_addr + ((HI6401_PLL_EN_REG & HI6401_PAGE_OFFSET_MASK) << 2));
				udelay(2);
				val |= (1 << HI6401_PLL_EN_BIT);
				writel(val, irq->reg_base_addr + ((HI6401_PLL_EN_REG & HI6401_PAGE_OFFSET_MASK) << 2));
				udelay(1);
			} else {
				pll_unlock_flag = 0;
				if(g_dump_buf)
					memset(g_dump_buf, 0, Hi6401_SIZE_MAX);
			}
		}
	} else {
		if (!dsm_client_ocuppy(hi6401_client)) {
			dsm_client_record(hi6401_client, "HI6401_PLL_PD_REG ret=%d\n", ret);
			dsm_client_notify(hi6401_client, DSM_HI6401_PLL_PD);
		}
	}
	spin_unlock_irqrestore(&irq->rw_lock, flags);
	mutex_unlock(&irq->sr_mutex);
}
/**
 * func - report basic info.
 * 		after read power, i2c gpio status,x,y,z value, important registers value,
 *		and report info to dsm server.
 */
static ssize_t lis_gsensor_dsm_record_basic_err_info( struct lis3dh_acc_data  *acceld, bool auto_report_flag)
{
	struct lis_gsensor_test_excep *excep = &acceld->lis_gs_exception;

	ssize_t size = 0;
	ssize_t total_size = 0;

	/* read important registers' value and x,y,z value  and report them	*/
	lis_gsensor_read_register_info(acceld,auto_report_flag);

	memset(acceld->dsm_buf,0, PAGE_SIZE);
	snprintf(acceld->dsm_buf, PAGE_SIZE,"CTRL1 = 0x%2x,CTRL2 = 0x%2x ,"
				"CTRL3 = 0x%2x,CTRL4 = 0x%2x,CTRL4 = 0x%2x,CTRL5 = 0x%2x  \n"\
				"excep_x = %d,excep_y = %d,excep_z = %d\n"
				,excep->reg_buf[0],excep->reg_buf[1],excep->reg_buf[2]
				,excep->reg_buf[3],excep->reg_buf[4],excep->reg_buf[5]
				,excep->cur_err_x,excep->cur_err_y,excep->cur_err_z);
	size = dsm_client_record(lis3dh_gs_dclient,acceld->dsm_buf);

	total_size += size;

	/* read power and i2c scl/sda gpio value  and report them	*/
	size = lis_gsensor_dsm_record_i2c_err_info(acceld);

	total_size += size;

	return total_size;

}
static void cpu_buck_work(struct work_struct *work)
{
    int i = 0;
    struct cpu_buck_sample* cbs = g_cbs;
    bool already_notified = false;

    if (!fault_happened)
        return;
    while(cbs)
    {
        for (i = 0; i < cbs->info_size; ++i)
        {
            if ((cbs->cbi[i].error_mask & cbs->reg[cbs->cbi[i].reg_number]) == cbs->cbi[i].error_mask)
            {
                if (!dsm_client_ocuppy(cpu_buck_client))
                {
                    already_notified = true;
                    hwlog_info("cpu_buck record and notify: %s\n", cbs->cbi[i].error_info);
                    dsm_client_record(cpu_buck_client, "cpu_buck %s happened!\n", cbs->cbi[i].error_info);
                    dsm_client_notify(cpu_buck_client, ERROR_NO_CPU_BUCK_BASE + cbs->cbi[i].err_no);
                    break;
                }
            }
        }
        if (already_notified)
        {
            break;
        }
        cbs = cbs->cbs;
    }
}
static void RFC_PrintIeStatus(CSMI_InformationElements *ie)
{
	if (ie->coreUnsprtdMsg || ie->coreDataTxCol || ie->coreReconfigObjection || ie->coreExError) {
		SLIMBUS_DEV_LIMIT_INFO("Core: UNSPRTD_MSG:%X DATA_TX_COL:%X RECONFIG_OBJECTION:%X EX_ERROR:%X \n",
			ie->coreUnsprtdMsg, ie->coreDataTxCol, ie->coreReconfigObjection, ie->coreExError);
	}
	if (ie->interfaceMcTxCol || ie->interfaceLostFs || ie->interfaceLostSfs || ie->interfaceLostMs || ie->interfaceDataSlotOverlap) {
		SLIMBUS_DEV_LIMIT_INFO("Interface: MC_TX_COL:%X LOST_FS:%X LOST_SFS:%X LOST_MS:%X DATA_SLOT_OVERLAP:%X\n",
			ie->interfaceMcTxCol, ie->interfaceLostFs, ie->interfaceLostSfs, ie->interfaceLostMs, ie->interfaceDataSlotOverlap);
	}
	if (ie->managerActiveManager) {
		SLIMBUS_DEV_LIMIT_INFO("Manager: ACTIVE_MANAGER:%X\n", ie->managerActiveManager);
	}
	if (ie->framerQuality || ie->framerGcTxCol || ie->framerFiTxCol || ie->framerFsTxCol || ie->framerActiveFramer) {
		SLIMBUS_DEV_LIMIT_INFO("Framer: QUALITY:%X GC_TX_COL:%X FI_TX_COL:%X FS_TX_COL:%X ACTIVE_FRAMER:%X\n",
			ie->framerQuality, ie->framerGcTxCol, ie->framerFiTxCol, ie->framerFsTxCol, ie->framerActiveFramer);
	}

	if (ie->interfaceLostFs || ie->interfaceLostSfs || ie->interfaceLostMs) {
		if (dsm_notify_limit == SLIMBUS_LOSTMS_COUNT) {
			slimbus_dump_state(SLIMBUS_DUMP_LOSTMS);
			if (!dsm_client_ocuppy(dsm_audio_client)) {
				dsm_client_record(dsm_audio_client, "DSM_HI6402_SLIMBUS_LOST_MS\n");
				dsm_client_notify(dsm_audio_client, DSM_HI6402_SLIMBUS_LOST_MS);
			}
		}
		dsm_notify_limit++;
	}
}
static void gpio_keydown_timer(unsigned long data)
{
        int keydown_value;
        struct hisi_gpio_key *gpio_key = (struct hisi_gpio_key *)data;

        keydown_value = gpio_get_value((unsigned int)gpio_key->gpio_down);
        /*judge key is pressed or released.*/
        if (keydown_value == GPIO_LOW_VOLTAGE){
                wake_lock(&volume_down_key_lock);

#if defined (CONFIG_HUAWEI_DSM)
            if ((jiffies - volume_down_last_press_time) < msecs_to_jiffies(PRESS_KEY_INTERVAL)) {
                if (!dsm_client_ocuppy(key_dclient)) {
                    dsm_client_record(key_dclient, "volume down key trigger on the abnormal style.\n");
                    dsm_client_notify(key_dclient, DSM_KEY_ERROR_NO);
                }
            }
            volume_down_last_press_time = jiffies;
 #endif
	}

	schedule_delayed_work(&(gpio_key->gpio_keydown_work), 0);

	return;
}
int audio_dsm_report_num(int error_no, unsigned int mesg_no)
{
    int err = 0;

    if(NULL == audio_dclient)
    {
        printk("%s: audio_dclient did not register!\n", __func__);
        return -1;
    }

    err = dsm_client_ocuppy(audio_dclient);
    if(0 != err)
    {
        printk("%s: user buffer is busy!\n", __func__);
        return -1;
    }

    printk("%s: after dsm_client_ocuppy, error_no=0x%x, mesg_no=0x%x!\n",
        __func__, error_no, mesg_no);
    
    err = dsm_client_record(audio_dclient, "Message code = 0x%x.\n", mesg_no);

    dsm_client_notify(audio_dclient, error_no);

    return 0;
}
/* fw err infomation: err number */
ssize_t cyttsp5_dsm_record_fw_err_info( int err_numb )
{

	ssize_t size = 0;
	ssize_t total_size = 0;

	tp_log_err("%s: entry!\n", __func__);

	/* err number */
	size = dsm_client_record(tp_cyp_dclient, "fw update result:failed, retval is %d\n", err_numb);
	total_size += size;

	/* fw err status */
	size = dsm_client_record(tp_cyp_dclient, "updata status is %d\n", g_tp_dsm_info.constraints_UPDATE_status);
	total_size += size;

	return total_size;
}
Esempio n. 12
0
ssize_t synaptics_dsm_record_esd_err_info( int err_num )
{

	ssize_t size = 0;
	struct dsm_client *tp_dclient = tp_dsm_get_client();

	/* esd err number */
	size =dsm_client_record(tp_dclient, "esd err number:%d\n", err_num);

	return size;
}
static void inputhub_mcu_send_complete(rproc_msg_t *ack_buffer,
				rproc_msg_len_t ack_buffer_len,
				int error,
				void *data)
{
    complete(&send_complete);
    	
    if ((-ETIMEOUT) == error) {
        hwlog_err("send failed timeout\n");
	        if(!dsm_client_ocuppy(shb_dclient)){
                    dsm_client_record(shb_dclient, "IOM3RSTSTAT: 0x%x\n", read_reg32(IOM3RSTSTAT_ADDR));
                    dsm_client_record(shb_dclient, "PERRSTSTAT4: 0x%x\n", read_reg32(PERRSTSTAT4_ADDR));
                    dsm_client_record(shb_dclient, "PERSTAT5: 0x%x\n", read_reg32(PERSTAT5_ADDR));
                    dsm_client_record(shb_dclient, "IOM3CLKEN: 0x%x\n", read_reg32(IOM3CLKEN_ADDR));
                    dsm_client_notify(shb_dclient, DSM_SHB_ERR_IPC_TIMEOUT);
            }
    }else{
    hwlog_debug("send success\n");
    }	
    return;
}
/*delete mdss_mdp_get_clk_rate() to avoid panic*/
void mdp_underrun_dsm_report(unsigned long num,unsigned long underrun_cnt)
{
	/* try to get permission to use the buffer */
	if(dsm_client_ocuppy(lcd_dclient))
	{
		/* buffer is busy */
		LCD_LOG_ERR("%s: buffer is busy!\n", __func__);
		return;
	}
	dsm_client_record(lcd_dclient, "Lcd underrun detected for ctl=%d,count=%d\n",num,underrun_cnt);
	dsm_client_notify(lcd_dclient, DSM_LCD_MDSS_UNDERRUN_ERROR_NO);
}
Esempio n. 15
0
size_t ft6x06_dsm_record_basic_info(struct ft6x06_ts_data * ft6x06_data, struct dsm_client * dsm_client)
{
    ssize_t size = 0;
    ssize_t total_size = 0; 

    if(!ft6x06_data)
    {
        tp_log_err("%s %d: ft6x06_data is null!\n", __func__, __LINE__);
        return -1;
    }

    if(!dsm_client)
    {
        tp_log_err("%s %d: dsm_client is null!\n", __func__, __LINE__);
        return -1;
    }

    /* power status: mode, enable, voltage*/ 
    size = dsm_client_record(dsm_client,
                "[vbus power] mode:%d, enable:%d, vol:%d\n"
                "[vdd power]  mode:%d, enable:%d, vol:%d\n",
                regulator_get_mode(vbus_focaltech), 
                regulator_is_enabled(vbus_focaltech),
                regulator_get_voltage(vbus_focaltech),
                regulator_get_mode(vdd_focaltech),
                regulator_is_enabled(vdd_focaltech),
                regulator_get_voltage(vdd_focaltech));
    total_size += size;

    /* gpio status: irq, reset*/
    size =dsm_client_record(dsm_client, 
                "[irq gpio]   num:%d, irq gpio status:%d\n"
                "[reset gpio] num:%d, reset gpio status:%d\n",
                ft6x06_data->pdata->irq, gpio_get_value(ft6x06_data->pdata->reset),
                ft6x06_data->pdata->reset, gpio_get_value(ft6x06_data->pdata->reset));
    total_size += size;

    return total_size;
}
/* i2c error infomation: err number, register infomation */
ssize_t cyttsp5_dsm_record_i2c_err_info( int err_numb )
{

	ssize_t size = 0;
	ssize_t total_size = 0;

	tp_log_err("%s: entry!\n", __func__);

	/* err number */
	size = dsm_client_record(tp_cyp_dclient, "i2c err number:%d\n", err_numb );
	total_size += size;

	return total_size;
}
int mdss_record_dsm_err(u32 *dsi_status)
{
	if( NULL == lcd_dclient )
	{
		LCD_LOG_ERR("%s: there is no lcd_dclient!\n", __func__);
		return -1;
	}

	/* try to get permission to use the buffer */
	if(dsm_client_ocuppy(lcd_dclient))
	{
		/* buffer is busy */
		LCD_LOG_ERR("%s: buffer is busy!\n", __func__);
		return -1;
	}

	LCD_LOG_INFO("%s: entry!\n", __func__);
	if (dsi_status[0])
		dsm_client_record(lcd_dclient, "DSI_ACK_ERR_STATUS is wrong ,err number :%x\n", dsi_status[0]);

	if (dsi_status[1] & 0x0111)
		dsm_client_record(lcd_dclient, "DSI_TIMEOUT_STATUS is wrong ,err number :%x\n", dsi_status[1]);

	if (dsi_status[2] & 0x011111)
		dsm_client_record(lcd_dclient, "DSI_DLN0_PHY_ERR is wrong ,err number :%x\n", dsi_status[2]);

	if (dsi_status[3] & 0xcccc4489) 
		dsm_client_record(lcd_dclient, "DSI_FIFO_STATUS is wrong ,err number :%x\n", dsi_status[3]);

	if (dsi_status[4] & 0x80000000) 
		dsm_client_record(lcd_dclient, "DSI_STATUS is wrong ,err number :%x\n", dsi_status[4]);

	dsm_client_notify(lcd_dclient, DSM_LCD_MDSS_DSI_ISR_ERROR_NO);

	return 0;
}
static void powerkey_timer_func(unsigned long data)
{
	if (powerkey_press_count > MAX_PRESS_KEY_COUNT) {
		if(!dsm_client_ocuppy(power_key_dclient)) {
			dsm_client_record(power_key_dclient, "powerkey trigger on the abnormal style.\n");
			dsm_client_notify(power_key_dclient, DSM_POWER_KEY_ERROR_NO);
		}
	}

	/* reset the statistic variable */
	powerkey_press_count = 0;
	mod_timer(&dsm_powerkey_timer, jiffies + STATISTIC_INTERVAL * HZ);

	return;
}
Esempio n. 19
0
/*****************************************************************************
 函 数 名  : pastar_dsm_work_func
 功能描述  : 上报异常信息
 输入参数  : @work - work结构体
 输出参数  : 无
 返 回 值  : 无
*****************************************************************************/
void pastar_dsm_work_func(struct work_struct *work)
{
    pastar_print_info("Execuing ...");

    /* notify exception */
    if (!dsm_client_ocuppy(pastar_dclient)) 
    {
        /* record message */
		dsm_client_record(pastar_dclient, "PAStar 0x21 reg 0x%x, 0x6A reg 0x%x\n", reg_val[0], reg_val[1]);

        /* notify */
		dsm_client_notify(pastar_dclient, 30000);
	}

    return;
}
static void hisi_pmic_record_events(PMIC_MNTN_DESC *pmic_mntn)
{
    int index;

#if defined (CONFIG_HUAWEI_DSM)
    int pmic_record_error_offset = 0;
    int i = 0;
#endif

    snprintf(pmic_mntn->init_log_show, PMIC_PRINT_BUF_SIZE, "\nPMIC REGISTER DUMP\n");
    snprintf(pmic_mntn->init_log_show + strlen(pmic_mntn->init_log_show), PMIC_PRINT_BUF_SIZE, "  addr     data \n");

    for (index = 0; index < pmic_mntn->record_reg_n; index++) {
        pmic_mntn->record_event_buff[index] = hisi_pmic_reg_read(pmic_mntn->record_regs[index]);

#if defined (CONFIG_HUAWEI_DSM)
		pmic_record_error_offset = pmic_mntn->data_width * index;
		if (pmic_mntn->record_event_buff[index] & HISI_PMIC_DSM_MASK_STATE) {
			for (i = 0; i < pmic_mntn->data_width; i++) {
				if ((pmic_mntn->record_event_buff[index] & BIT(i)) \
					&& (pmic_mntn->dsm_record_regs_mask[index] & BIT(i)) \
					&& (pmic_mntn->dsm_ocp_reset_mask[index] & BIT(i))) {
					if (dsm_client_ocuppy(pmic_dsm_dclient)) {
						pr_err("pmic_dsm_dclient dsm_client_ocuppy failed\n");
					} else {
						pr_err("pmic %s happened, please pay attention!\n",
							pmic_mntn->record_exch_desc[index].event_bit_name[i]);
						dsm_client_record(pmic_dsm_dclient, "pmic %s_ocp happened, please pay attention!\n",
							pmic_mntn->record_exch_desc[index].event_bit_name[i]);
						dsm_client_notify(pmic_dsm_dclient, DSM_PMU_OCP_ERROR_NO_BASE + pmic_record_error_offset);
					}
				}
				pmic_record_error_offset++;
			}
		}
#endif

        hisi_pmic_reg_write(pmic_mntn->record_regs[index], pmic_mntn->record_event_buff[index]);
        snprintf(pmic_mntn->init_log_show + strlen(pmic_mntn->init_log_show), PMIC_PRINT_BUF_SIZE,
            "  0x%0x    0x%0x \n", pmic_mntn->record_regs[index], pmic_mntn->record_event_buff[index]);
    }
    clear_uv_mntn_resered_reg_bit();

    pr_err("%s", pmic_mntn->init_log_show);

    return;
}
void hw_wifi_dsm_client_notify(int dsm_id, const char *fmt, ...) {
    char buf[LOG_BUF_SIZE] = {0};
    va_list ap;

    va_start(ap, fmt);
    if(wifi_dsm_client && !dsm_client_ocuppy(wifi_dsm_client)) {
        if(fmt) {
            vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
            dsm_client_record(wifi_dsm_client, buf);
        }
        dsm_client_notify(wifi_dsm_client, dsm_id);
        HW_PRINT_HI("wifi dsm_client_notify success\n");
    } else {
        HW_PRINT_HI("wifi dsm_client_notify failed\n");
    }
    va_end(ap);
}
static irqreturn_t ivp_dwaxi_irq_handler(int irq, void *dev_id)
{
    ivp_warn("=======================DWAXI IRQ Trigger============================");
    ivp_warn("dwaxi triggled!SMMU maybe in reset status");
    //clear dwaxi irq
    ivp_gic_reg_write(GIC_REG_OFF_GICD_ICENABLERn, 0x80000);
    ivp_parse_dwaxi_info();
    ivp_warn("=======================DWAXI IRQ LEAVE==============================");

    if(!dsm_client_ocuppy(client_ivp))
    {
         dsm_client_record(client_ivp, "ivp\n");
         dsm_client_notify(client_ivp, DSM_IVP_DWAXI_ERROR_NO);
         ivp_info("[I/DSM] %s dsm_client_ivp_dwaxi", client_ivp->client_name);
    }

    return IRQ_HANDLED;
}
static irqreturn_t ivp_wdg_irq_handler(int irq, void *dev_id)
{
    struct ivp_device *pdev = (struct ivp_device *) dev_id;;
    ivp_warn("=======================WDG IRQ Trigger============================");
    //Clear IRQ
    ivp_hw_clr_wdg_irq();

    up(&pdev->wdg_sem);
    ivp_warn("=======================WDG IRQ LEAVE==============================");

    if(!dsm_client_ocuppy(client_ivp))
    {
        dsm_client_record(client_ivp, "ivp\n");
        dsm_client_notify(client_ivp, DSM_IVP_WATCH_ERROR_NO);
        ivp_info("[I/DSM] %s dsm_client_ivp_watach dog", client_ivp->client_name);
    }

    return IRQ_HANDLED;
}
/**
 * func - after read sda/scl, vdd/vddio value, and report info to dsm server.
 * NOTE:
 */
static ssize_t lis_gsensor_dsm_record_i2c_err_info(struct lis3dh_acc_data  *acceld)
{
	struct lis_gsensor_test_excep *excep = &acceld->lis_gs_exception;

	ssize_t size = 0;
	ssize_t total_size = 0;

	/* read power and i2c scl/sda gpio value  and report them	*/
	lis_gsensor_read_i2c_err_info(acceld);

	memset(acceld->dsm_buf,0, DSM_SENSOR_BUF_COM);
	snprintf(acceld->dsm_buf, PAGE_SIZE,"i2c_scl_val=%d,i2c_sda_val=%d,vdd = %d, vddio=%d,i2c_errno=%d\n",
					excep->i2c_scl_val,excep->i2c_sda_val,
					excep->vdd_mv,excep->vddio_mv,excep->i2c_err_num);
	size = dsm_client_record(lis3dh_gs_dclient,acceld->dsm_buf);

	total_size += size;

	return total_size;
}
int audio_dsm_report_info(int error_no, char *fmt, ...)
{
    int err = 0;
    int ret = 0;
    char dsm_report_buffer[DSM_REPORT_BUF_SIZE] = {0};
    va_list args;

    if(NULL == audio_dclient)
    {
        printk("%s: audio_dclient did not register!\n", __func__);
        return -1;
    }

    if(error_no < DSM_AUDIO_ERROR_NUM)
    {
        printk("%s: input error_no err!\n", __func__);
        return -1;
    }

    va_start(args, fmt);
    ret = vsnprintf(dsm_report_buffer, DSM_REPORT_BUF_SIZE, fmt, args);
    va_end(args);
    
    err = dsm_client_ocuppy(audio_dclient);
    if(0 != err)
    {
        printk("%s: user buffer is busy!\n", __func__);
        return -1;
    }

    printk("%s: after dsm_client_ocuppy, dsm_error_no = %d, %s\n",
            __func__, error_no, dsm_report_buffer);

    dsm_client_record(audio_dclient, "%s\n", dsm_report_buffer);
    
    dsm_client_notify(audio_dclient, error_no);
    
    return 0;
    
}
static irqreturn_t hi6402_pll_unlock_handler(int irq, void *data)
{
	struct hi6402_mbhc_platform_data *pdata =
			(struct hi6402_mbhc_platform_data *)data;

	BUG_ON(NULL == pdata);

	unsigned int i = 0;

	mutex_lock(&pdata->p_irq->pll_mutex);

	if (0 != (hi6402_irq_read(pdata->p_irq, HI6402_PLL_PD_FLAG_REG) & PLL_PD_VALUE) || 0 != (hi6402_irq_read(pdata->p_irq, HI6402_PLL_LOCK_FLAG_REG) & PLL_LOCK_VALUE)){
		pr_info("%s(%u): pll pd, ignore pll unlock irq! \n", __FUNCTION__, __LINE__);
		/* mask pll unlock irq */
		mutex_lock(&pdata->p_irq->irq_lock);
		hi6402_reg_set_bit(pdata->p_irq, HI6402_MASK_IRQ_REG_2, HI6402_MASK_PLL_UNLOCK_BIT);
		pdata->p_irq->mask2 |= 0x10;
		mutex_unlock(&pdata->p_irq->irq_lock);
	} else {
		pr_info("%s(%u): pll unlock irq! \n", __FUNCTION__, __LINE__);

		if (!dsm_client_ocuppy(dsm_audio_client)) {
			dsm_client_record(dsm_audio_client, "DSM_HI6402_PLL_UNLOCK\n");
			dsm_client_notify(dsm_audio_client, DSM_HI6402_PLL_UNLOCK);
		}

		for (i = PLL_UNLOCK_REG_START; i<= PLL_UNLOCK_REG_END; i++) {
			pr_err("%s(%u): %x is %x \n", __FUNCTION__, __LINE__, i, hi6402_irq_read(pdata->p_irq, i));
		}

		pdata->p_irq->pll_status = HI6402_PLL_RST;
		hi6402_irq_set_pll_mode(pdata->p_irq);
	}

	mutex_unlock(&pdata->p_irq->pll_mutex);

	return IRQ_HANDLED;
}
int inputhub_mcu_send(const char *buf, unsigned long length)
{
    struct hisi_mbox_task *tx_task = NULL;
    mbox_msg_t *tx_buffer = NULL;
    mbox_msg_len_t len=0;
    int i = 0;
    int ret = -1;

    if(NULL==mbox)
        inputhub_mcu_connect();
    if(NULL==mbox)
        return ret;

    len = (length + sizeof(mbox_msg_t) - 1) / (sizeof(mbox_msg_t));
    //todo:send 256 bytes max one time, and repeat until buf was sent.
    tx_buffer = (mbox_msg_t *)kmalloc(sizeof(mbox_msg_t)*len, GFP_KERNEL);
    if (!tx_buffer)
        return ret;

    memcpy(tx_buffer, buf, length);
    pr_debug("inputhub_mcu_send------------->length = %d, len = %d\n", (int)length, (int)len);
    for (i = 0; i < len; i++)
        pr_debug("tx_buffer[%d] = 0x%x\n", i, tx_buffer[i]);

    tx_task = hisi_mbox_task_alloc(mbox,
                HISI_MAILBOX_RP_IOM3,
                tx_buffer,
                len,
                0,
                inputhub_mcu_send_complete,
                NULL);

    if (!tx_task) {
        kfree((void *)tx_buffer);
        return ret;
    }

    INIT_COMPLETION(send_complete);
    ret=hisi_mbox_msg_send_async(mbox,tx_task);
    if(ret)
    {
        hwlog_err("hisi_mbox_msg_send_async return %d.\n", ret);
        if (tx_task->tx_buffer)
            kfree((void *)tx_task->tx_buffer);
        tx_task->tx_buffer = NULL;
        hisi_mbox_task_free(&tx_task);
        return -1;
    }

    wait_for_completion(&send_complete);
    if ((-ETIMEOUT) == tx_task->tx_error) {
        hwlog_err("send failed timeout\n");
        if(!dsm_client_ocuppy(shb_dclient)){
            dsm_client_record(shb_dclient, "IOM3RSTSTAT: 0x%x\n", read_reg32(IOM3RSTSTAT_ADDR));
            dsm_client_record(shb_dclient, "PERRSTSTAT4: 0x%x\n", read_reg32(PERRSTSTAT4_ADDR));
            dsm_client_record(shb_dclient, "PERSTAT5: 0x%x\n", read_reg32(PERSTAT5_ADDR));
            dsm_client_record(shb_dclient, "IOM3CLKEN: 0x%x\n", read_reg32(IOM3CLKEN_ADDR));
            dsm_client_notify(shb_dclient, DSM_SHB_ERR_IPC_TIMEOUT);
        }
        ret = -1;
    }else{
        hwlog_debug("send success\n");
        ret = 0;
    }

    kfree((void *)tx_task->tx_buffer);
    tx_task->tx_buffer = NULL;
    hisi_mbox_task_free(&tx_task);
    return ret;
}
static int tps65132_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
	int retval = 0;
	int nRet = 0;
	int vpos_target = 0;
	int vneg_target = 0;
	struct device_node *np = NULL;
	struct tps65132_device_info *di = NULL;

	np = of_find_compatible_node(NULL, NULL, DTS_COMP_TPS65132);
	if (!np) {
		pr_err("NOT FOUND device node %s!\n", DTS_COMP_TPS65132);
		retval = -ENODEV;
		goto failed_1;
	}

	gpio_vsp_enable = of_get_named_gpio(np, "gpios", 0);
	gpio_vsn_enable = of_get_named_gpio(np, "gpios", 1);

	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
		pr_err("[%s,%d]: need I2C_FUNC_I2C\n",__FUNCTION__,__LINE__);
		retval = -ENODEV;
		goto failed_1;
	}

	di = kzalloc(sizeof(*di), GFP_KERNEL);
	if (!di) {
		dev_err(&client->dev, "failed to allocate device info data\n");
		retval = -ENOMEM;
		goto failed_1;
	}

	i2c_set_clientdata(client, di);
	di->dev = &client->dev;
	di->client = client;

	if (!fastboot_display_enable) {
		tps65132_start_setting();
	}

	tps65132_get_target_voltage(&vpos_target, &vneg_target);

	nRet = tps65132_reg_inited(di->client, (u8)vpos_target, (u8)vneg_target);
	if (nRet > 0) {
		pr_info("tps65132 inited needn't reset value\n");
	} else if (nRet < 0) {
		pr_err("tps65132 I2C read fail\n");
		retval = -ENODEV;
#if defined (CONFIG_HUAWEI_DSM)
		if (!dsm_client_ocuppy(lcd_dclient)) {
			dsm_client_record(lcd_dclient, "tps65132 I2C read fail\n");
			dsm_client_notify(lcd_dclient, DSM_LCD_POWER_STATUS_ERROR_NO);
		}
#endif
		goto failed_2;
	} else {
		nRet = tps65132_reg_init(di->client, (u8)vpos_target, (u8)vneg_target);
		if (nRet) {
			pr_err("tps65132_reg_init failed\n");
			retval = -ENODEV;
#if defined (CONFIG_HUAWEI_DSM)
			if (!dsm_client_ocuppy(lcd_dclient)) {
				dsm_client_record(lcd_dclient, "tps65132_reg_init failed\n");
				dsm_client_notify(lcd_dclient, DSM_LCD_POWER_STATUS_ERROR_NO);
			}
#endif
			goto failed_2;
		}
		pr_info("tps65132 inited succeed\n");
	}

	#ifdef CONFIG_HUAWEI_HW_DEV_DCT
		/* detect current device successful, set the flag as present */
		set_hw_dev_flag(DEV_I2C_DC_DC);
	#endif

failed_2:
	if (!fastboot_display_enable) {
		tps65132_finish_setting();
	}

	if (di)
		kfree(di);

failed_1:
	return retval;
}
Esempio n. 29
0
int bq_get_error_info(struct bq_bci_device_info *di)
{
    static int pre_bat_err =0, archive_state = 1;
    static unsigned long timeout_jiffies = 0;
    static int first_in = 1;
    static int pre_uf_capacity = 0;
    static int pre_capacity = 0;
    static int capacity_stay_count = 0;
    static int online_delay_count = 0;
    int bat_uf_capacity = 0;
    int curr_by_coultype = 1;
	int dsm_bci_battery_err_offset = 0;

    if (COUL_HISI_HI6421V300 == hisi_coulometer_type())
        curr_by_coultype = -1;

    di->bat_err = 0;

    if(!is_hisi_battery_exist())
        di->bat_err |= ERROR_BATT_NOT_EXIST;

    if(hisi_battery_temperature()< BQ2419x_COLD_BATTERY_THRESHOLD
           || hisi_battery_temperature()>= BQ2419x_HOT_BATTERY_THRESHOLD)
    {
        if(di->charge_status == POWER_SUPPLY_STATUS_NOT_CHARGING)
            di->bat_err |= ERROR_BATT_TEMP_STOP;
        if(di->charge_status == POWER_SUPPLY_STATUS_CHARGING)
            di->bat_err |= ERROR_BATT_TEMP_CHARGE;

        di->bat_err |= ERROR_BATT_TEMP_OUT;
        dev_info(di->dev,"batt temp = %d\n ", hisi_battery_temperature());
    }

    if(di->charge_status == POWER_SUPPLY_STATUS_NOT_CHARGING
        && !(bq2419x_get_factory_flag())) {
        if(di->power_supply_status == POWER_SUPPLY_HEALTH_OVERVOLTAGE)
            di->bat_err |= ERROR_VBUS_OVERVOLTAGE;
        if(hisi_battery_voltage() > BATT_OVERVOLTAGE_THRES)
            di->bat_err |= ERROR_BATT_OVERVOLTAGE;

        di->bat_err |= ERROR_BATT_NOT_CHARGING;
    } else {
        if(hisi_battery_voltage() > BATT_OVERVOLTAGE_THRES
           || hisi_battery_voltage() < BATT_LOWVOLTAGE_THRES) {
            di->bat_err |= ERROR_BATT_VOLTAGE;
            dev_info(di->dev,"batt volt = %d\n ", hisi_battery_voltage());
        }
    }

    if(di->chargedone_stat && hisi_battery_capacity() <= CHG_CANT_FULL_THRESHOLD){
        di->bat_err |= ERROR_PRE_CHARGEDONE;
        dev_info(di->dev,"batt capacity = %d\n ", hisi_battery_capacity());
    }

    if(di->charge_status == POWER_SUPPLY_STATUS_CHARGING
       && hisi_battery_current_avg() <= 50
       && hisi_battery_current_avg() >= 10
       && (curr_by_coultype*hisi_battery_current()) <= 50
       && (curr_by_coultype*hisi_battery_current()) >= 10
       && di->capacity == 100) {
        di->bat_err |= ERROR_NO_CHARGEDONE;
        dev_info(di->dev,"batt curr = %d batt curr_avg = %d\n ",
                         (curr_by_coultype*hisi_battery_current()), hisi_battery_current_avg());
    }

    if((!di->usb_online) && (!di->ac_online)){
        if((-hisi_battery_current() > 0) && (online_delay_count++ == 1)){
             di->bat_err |= ERROR_BAD_CURR_SENSOR;
             online_delay_count = 0;
             dev_info(di->dev,"batt curr = %d\n ", (-hisi_battery_current()));
        }
    } else {
        online_delay_count = 0;
    }

    bat_uf_capacity = hisi_battery_unfiltered_capacity();
    if(first_in){
        pre_uf_capacity = bat_uf_capacity;
        pre_capacity = di->capacity;
        first_in = 0;
    } else {
        if (abs(pre_uf_capacity - bat_uf_capacity) >= 3) {
            if (100 != bat_uf_capacity) {
                di->bat_err |= ERROR_UFCAPCITY_DEBOUNCE_OTHER;
            }
            else {
                if (abs(pre_uf_capacity - bat_uf_capacity) > 10)
                    di->bat_err |= ERROR_UFCAPCITY_DEBOUNCE_100;
            }
            hisi_hi6421v300_print_cc_reg(2); //debug
        }
        pre_uf_capacity = bat_uf_capacity;
    }

    if(di->charge_status == POWER_SUPPLY_STATUS_NOT_CHARGING
       || di->charge_status == POWER_SUPPLY_STATUS_DISCHARGING) {
        if(pre_capacity > 0 && di->capacity != pre_capacity) {
            if(di->capacity > REACH_FULL_RESAMPLE_THRESHOLD) {
                if(capacity_stay_count <= 2) {
                    di->bat_err |= ERROR_CAPACITY_CHANGE_FAST;
                    capacity_stay_count = 0;
                }
            } else if (di->capacity < REACH_EMPTY_RESAMPLE_THRESHOLD) {
                if(capacity_stay_count <= 12) {
                    di->bat_err |= ERROR_CAPACITY_CHANGE_FAST;
                    capacity_stay_count = 0;
                }
            } else {
                if(capacity_stay_count <= 6) {
                    di->bat_err |= ERROR_CAPACITY_CHANGE_FAST;
                    capacity_stay_count = 0;
                }
            }
            capacity_stay_count = 0;
        } else {
            capacity_stay_count++;
        }
    }
    pre_capacity = di->capacity;

    if (is_hisi_hi6421v300_fcc_debounce()) {
        di->bat_err |= ERROR_FCC_DEBOUNCE;
    }

    if(di->bat_err != pre_bat_err && archive_state == 1){
        timeout_jiffies = jiffies + msecs_to_jiffies(LOG_ARCH_DELAY_TIME);
        archive_state = 0;
        dev_info(di->dev,"(%s) BATT ERR = %x\n", hisi_battery_brand(), di->bat_err);
    }
    pre_bat_err = di->bat_err;

    if(time_is_before_jiffies(timeout_jiffies) &&  di->bat_err != 0x0 && archive_state == 0){
        //bq_log_exception_archive(di->bat_err);
		if (dsm_client_ocuppy(battery_dclient)) {
			dsm_client_record(battery_dclient, "battery error = %x.\n", di->bat_err);
			dsm_bci_battery_err_offset = get_bit(di->bat_err);
			dsm_client_notify(battery_dclient, DSM_BATTERY_ERROR_NO + dsm_bci_battery_err_offset);
		}
		archive_state = 1;
    }

    return di->bat_err;
}
static irqreturn_t hisi_powerkey_handler(int irq, void *data)
{
	struct hisi_powerkey_info *info = (struct hisi_powerkey_info *)data;

	wake_lock_timeout(&info->pwr_wake_lock, HZ);

	if (info->irq[0] == irq) {
			pr_info("[%s]response press interrupt!\n", __FUNCTION__);
			power_key_ps=true;

#if defined (CONFIG_HUAWEI_DSM)
			powerkey_press_count++;
                    if ((jiffies - powerkey_last_press_time) < msecs_to_jiffies(PRESS_KEY_INTERVAL)) {
                        if (!dsm_client_ocuppy(power_key_dclient)) {
                            dsm_client_record(power_key_dclient, "power key trigger on the abnormal style.\n");
                            dsm_client_notify(power_key_dclient, DSM_POWER_KEY_ERROR_NO);
                        }
                    }
                     powerkey_last_press_time = jiffies;
#endif
                    /* modify by songliangliang for dmd_log> */
			#if defined (CONFIG_FB_HI6220_CLCD)
			lcd_dcm_pwr_add_timer();
			#endif
			input_report_key(info->idev, KEY_POWER, POWER_KEY_PRESS);
			input_sync(info->idev);
	} else if (info->irq[1] == irq) {
			pr_info("[%s]response release interrupt!\n", __FUNCTION__);
			#if defined(CONFIG_HISILICON_PLATFORM_MAINTAIN)
                        #ifdef CONFIG_ARCH_HI6XXX
			if (check_himntn(HIMNTN_PRESS_KEY_TO_FASTBOOT)) {
				if ((VOL_UPDOWN_PRESS & gpio_key_vol_updown_press_get()) == VOL_UPDOWN_PRESS) {
					gpio_key_vol_updown_press_set_zero();
					if(is_gpio_key_vol_updown_pressed()) {
						systemError(0x25, EXCH_S_LOGDUMP, 0,0,0);
					}
				}
			}
			#elif defined(CONFIG_HISI_3635)
				if(is_fastboot_dumpmem_enable())
					if ((VOL_UPDOWN_PRESS & gpio_key_vol_updown_press_get()) == VOL_UPDOWN_PRESS) {
						gpio_key_vol_updown_press_set_zero();
						if(is_gpio_key_vol_updown_pressed()) {
							pr_info("[%s]Powerkey+VolUp_key+VolDn_key\n", __FUNCTION__);
							#ifdef CONFIG_HISI_REBOOT_TYPE
							set_watchdog_resetflag();
							#endif
							emergency_restart();
					}
				}
 			#endif
                        #endif
			input_report_key(info->idev, KEY_POWER, POWER_KEY_RELEASE);
			input_sync(info->idev);
	} else if (info->irq[2] == irq) {
			pr_info("[%s]response long press 1s interrupt!\n", __FUNCTION__);
			input_report_key(info->idev, KEY_POWER, POWER_KEY_PRESS);
			input_sync(info->idev);
	} else if (irq == info->irq[3]) {
		pr_info("[%s]response long press 8s interrupt!\n", __FUNCTION__);
	} else if (irq == info->irq[4]) {
		pr_info("[%s]response long press 10s interrupt!\n", __FUNCTION__);
	} else {
			pr_err("[%s]invalid irq %d!\n", __FUNCTION__, irq);
	}

	return IRQ_HANDLED;
}