Ejemplo n.º 1
0
//this module just init for creat files to show which version
static int prjVersion_read_proc(struct file *file, char __user *buf, 
		size_t count,loff_t *off)
{
	char page[256] = {0};
	int len = 0;
	
	#if 0
	unsigned char operator_version;

	operator_version = get_Operator_Version();
	if(is_project(OPPO_14005)){
		if(operator_version == 3)
			len = sprintf(page,"%d",14006);
		else 
			len = sprintf(page,"%d",14005);
    }
	else if(is_project(OPPO_14023)){
		if(operator_version == 3)
			len = sprintf(page,"%d",14023);
		else 
			len = sprintf(page,"%d",14023);
    }
	else if(is_project(OPPO_14045)){
        //#ifdef VENDOR_EDIT
        //[email protected], 2014-08-07 add for EXP to mark 14085
		if(operator_version == 3 || 5 == operator_version || 6 == operator_version || 7 == operator_version)
        //#endif VENDOR_EDIT
			len = sprintf(page,"%d",14046);
		else if(operator_version == 4)
			len = sprintf(page,"%d",14047);
		else 
			len = sprintf(page,"%d",14045);
    }
	else
	{
		len = sprintf(page,"%d",get_project());
	}
	#else
	len = sprintf(page,"%d",get_project());
	#endif

	if(len > *off)
		len -= *off;
	else
		len = 0;
	
	if(copy_to_user(buf,page,(len < count ? len : count))){
		return -EFAULT;
	}
	*off += len < count ? len : count;
	return (len < count ? len : count);
}
Ejemplo n.º 2
0
sql_rel *
rel_partition(mvc *sql, sql_rel *rel) 
{
	(void)sql;
	if (rel->op == op_basetable) {
		rel->flag = REL_PARTITION;
	} else if ((rel->op == op_topn || rel->op == op_sample || rel->op == op_select) && rel->l) {
		rel_partition(sql, rel->l);
	} else if (is_modify(rel->op) && rel->card <= CARD_AGGR) {
		if (rel->r)
			rel_partition(sql, rel->r);
	} else if (is_project(rel->op) && rel->l) {
		rel_partition(sql, rel->l);
	} else if (rel->op == op_semi && rel->l && rel->r) {
		rel_partition(sql, rel->l);
		rel_partition(sql, rel->r);
	} else if (rel->op == op_anti && rel->l && rel->r) {
		rel_partition(sql, rel->l);
		rel_partition(sql, rel->r);
	} else if (is_join(rel->op)) {
		if (has_groupby(rel->l) || has_groupby(rel->r)) {
			rel_partition(sql, rel->l);
			rel_partition(sql, rel->r);
		}
		else
			_rel_partition(sql, rel);
	}
	return rel;
}
Ejemplo n.º 3
0
static int 
has_groupby(sql_rel *rel)
{
	if (rel->op == op_groupby) 
		return 1;
	if (is_join(rel->op)) 
		return has_groupby(rel->l) || has_groupby(rel->r);
	if ((is_select(rel->op) || is_project(rel->op)) && rel->l) 
		return has_groupby(rel->l);
	return 0;
}
Ejemplo n.º 4
0
int qpnp_power_get_property_mains(struct power_supply *psy,
				  enum power_supply_property prop,
				  union power_supply_propval *val)
{
	struct opchg_charger *chip = container_of(psy, struct opchg_charger,
								dc_psy);

	switch (prop) 
	{
	
	case POWER_SUPPLY_PROP_PRESENT:
	case POWER_SUPPLY_PROP_ONLINE:

		if (chip->charging_disabled)
			return 0;
		if( is_project(OPPO_14005))
		{
			if((opchg_get_prop_fast_chg_started(chip) == true)
				|| (opchg_get_prop_fast_switch_to_normal(chip) == true)
				|| (opchg_get_fast_normal_to_warm(chip) == true)) {
				val->intval = 1;
			} else {
				if(qpnp_charger_type_get(chip) == POWER_SUPPLY_TYPE_USB_DCP)
					val->intval = 1;
				else
					val->intval = 0;
			}
		}
		else
		{
			/* [email protected], 2014/02/11  Modify for when no battery gauge present */
			if(qpnp_charger_type_get(chip) == POWER_SUPPLY_TYPE_USB_DCP)
				val->intval = 1;
			else
				val->intval = 0;
		}
		#ifdef OPCHARGER_DEBUG_ENABLE
		pr_debug("oppo_debug dc charging and fast charging sign = %d\n",val->intval);
		#endif
		break;
		
	case POWER_SUPPLY_PROP_CURRENT_MAX:
		val->intval = chip->fastchg_current_max_ma * 1000;//chip->maxinput_dc_ma * 1000;
		break;
	
	default:
		return -EINVAL;
	}
	return 0;
}
Ejemplo n.º 5
0
sql_exp *
rel_find_exp( sql_rel *rel, sql_exp *e)
{
	sql_exp *ne = rel_find_exp_(rel, e);
	if (!ne) {
		switch(rel->op) {
		case op_left:
		case op_right:
		case op_full:
		case op_join:
			ne = rel_find_exp(rel->l, e);
			if (!ne) 
				ne = rel_find_exp(rel->r, e);
			break;
		case op_table:
			if (rel->exps && e->type == e_column && e->l && exps_bind_column2(rel->exps, e->l, e->r)) 
				ne = e;
			break;
		case op_union:
		case op_except:
		case op_inter:
		{
			if (rel->l)
				ne = rel_find_exp(rel->l, e);
			else if (rel->exps && e->l)
				ne = exps_bind_column2(rel->exps, e->l, e->r);
			else if (rel->exps)
				ne = exps_bind_column(rel->exps, e->r, NULL);
		}
		break;
		case op_basetable: 
			if (rel->exps && e->type == e_column && e->l) 
				ne = exps_bind_column2(rel->exps, e->l, e->r);
			break;
		default:
			if (!is_project(rel->op) && rel->l)
				ne = rel_find_exp(rel->l, e);
		}
	}
	return ne;
}
Ejemplo n.º 6
0
static sql_exp *
rel_find_exp_( sql_rel *rel, sql_exp *e) 
{
	sql_exp *ne = NULL;

	switch(e->type) {
	case e_column:
		if (rel->exps && (is_project(rel->op) || is_base(rel->op))) {
			if (e->l) {
				ne = exps_bind_column2(rel->exps, e->l, e->r);
			} else {
				ne = exps_bind_column(rel->exps, e->r, NULL);
			}
		}
		return ne;
	case e_convert:
		return rel_find_exp_(rel, e->l);
	case e_aggr:
	case e_func: 
		if (e->l) {
			list *l = e->l;
			node *n = l->h;
	
			ne = n->data;
			while (ne != NULL && n != NULL) {
				ne = rel_find_exp_(rel, n->data);
				n = n->next;
			}
			return ne;
		}
	case e_cmp:	
	case e_psm:	
		return NULL;
	case e_atom:
		return e;
	}
	return ne;
}
Ejemplo n.º 7
0
int
is_identity( sql_exp *e, sql_rel *r)
{
	switch(e->type) {
	case e_column:
		if (r && is_project(r->op)) {
			sql_exp *re = NULL;
			if (e->l)
				re = exps_bind_column2(r->exps, e->l, e->r);
			if (!re && ((char*)e->r)[0] == 'L')
				re = exps_bind_column(r->exps, e->r, NULL);
			if (re)
				return is_identity(re, r->l);
		}
		return 0;
	case e_func: {
		sql_subfunc *f = e->f;
		return (strcmp(f->func->base.name, "identity") == 0);
	}
	default:
		return 0;
	}
}
/*
 * mdss_check_dsi_ctrl_status() - Check MDP5 DSI controller status periodically.
 * @work     : dsi controller status data
 * @interval : duration in milliseconds to schedule work queue
 *
 * This function calls check_status API on DSI controller to send the BTA
 * command. If DSI controller fails to acknowledge the BTA command, it sends
 * the PANEL_ALIVE=0 status to HAL layer.
 */
void mdss_check_dsi_ctrl_status(struct work_struct *work, uint32_t interval)
{
	struct dsi_status_data *pstatus_data = NULL;
	struct mdss_panel_data *pdata = NULL;
	struct mipi_panel_info *mipi = NULL;
	struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
	struct mdss_overlay_private *mdp5_data = NULL;
	struct mdss_mdp_ctl *ctl = NULL;
	int ret = 0;
#ifdef VENDOR_EDIT
/* Xiaori.Yuan@Mobile Phone Software Dept.Driver, 2015/01/09  Add for 14045 TP and LCD ESD */
	int tp_ret=-1;
#endif /*VENDOR_EDIT*/

	pstatus_data = container_of(to_delayed_work(work),
		struct dsi_status_data, check_status);
	if (!pstatus_data || !(pstatus_data->mfd)) {
		pr_err("%s: mfd not available\n", __func__);
		return;
	}

	pdata = dev_get_platdata(&pstatus_data->mfd->pdev->dev);
	if (!pdata) {
		pr_err("%s: Panel data not available\n", __func__);
		return;
	}
	mipi = &pdata->panel_info.mipi;

	ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
							panel_data);
	if (!ctrl_pdata || !ctrl_pdata->check_status) {
		pr_err("%s: DSI ctrl or status_check callback not available\n",
								__func__);
		return;
	}

	mdp5_data = mfd_to_mdp5_data(pstatus_data->mfd);
	ctl = mfd_to_ctl(pstatus_data->mfd);

	if (!ctl) {
		pr_err("%s: Display is off\n", __func__);
		return;
	}

	if (!ctl->power_on) {
		schedule_delayed_work(&pstatus_data->check_status,
			msecs_to_jiffies(interval));
		pr_err("%s: ctl not powered on\n", __func__);
		return;
	}

	/*
	 * TODO: Because mdss_dsi_cmd_mdp_busy has made sure DMA to
	 * be idle in mdss_dsi_cmdlist_commit, it is not necessary
	 * to acquire ov_lock in case of video mode. Removing this
	 * lock to fix issues so that ESD thread could block other
	 * overlay operations. Need refine this lock for command mode
	 */
	if (mipi->mode == DSI_CMD_MODE)
		mutex_lock(&mdp5_data->ov_lock);

	if (pstatus_data->mfd->shutdown_pending ||
		!pstatus_data->mfd->panel_power_on) {
		if (mipi->mode == DSI_CMD_MODE)
			mutex_unlock(&mdp5_data->ov_lock);
		pr_err("%s: DSI turning off, avoiding panel status check\n",
							__func__);
		return;
	}

	/*
	 * For the command mode panels, we return pan display
	 * IOCTL on vsync interrupt. So, after vsync interrupt comes
	 * and when DMA_P is in progress, if the panel stops responding
	 * and if we trigger BTA before DMA_P finishes, then the DSI
	 * FIFO will not be cleared since the DSI data bus control
	 * doesn't come back to the host after BTA. This may cause the
	 * display reset not to be proper. Hence, wait for DMA_P done
	 * for command mode panels before triggering BTA.
	 */
	if (ctl->wait_pingpong)
		ctl->wait_pingpong(ctl, NULL);

	pr_debug("%s: DSI ctrl wait for ping pong done\n", __func__);

	mdss_mdp_clk_ctrl(MDP_BLOCK_POWER_ON, false);
	ret = ctrl_pdata->check_status(ctrl_pdata);
	mdss_mdp_clk_ctrl(MDP_BLOCK_POWER_OFF, false);

	if (mipi->mode == DSI_CMD_MODE)
		mutex_unlock(&mdp5_data->ov_lock);
	
#ifdef VENDOR_EDIT
/* Xiaori.Yuan@Mobile Phone Software Dept.Driver, 2015/01/09  Add for 14045 TP and LCD ESD  */
	if(is_project(OPPO_14045) && tp_esd_check_fn!=NULL)
	{
		tp_ret = tp_esd_check_fn();
	}else{
		tp_ret = 1;
	}
#endif /*VENDOR_EDIT*/
	
	if ((pstatus_data->mfd->panel_power_on)) {
		/* VENDOR_EDIT Xiaori.Yuan@Mobile Phone Software Dept.Driver, 2015/01/09  Modified  for 14045 TP and LCD ESD  */
		//if (ret > 0) {
		if ((ret > 0) && (tp_ret >= 0)) {
		/*VENDOR_EDIT Modified end*/
			schedule_delayed_work(&pstatus_data->check_status,
				msecs_to_jiffies(interval));
		} else {
			char *envp[2] = {"PANEL_ALIVE=0", NULL};
			pdata->panel_info.panel_dead = true;
			ret = kobject_uevent_env(
				&pstatus_data->mfd->fbi->dev->kobj,
							KOBJ_CHANGE, envp);
			pr_err("%s: Panel has gone bad, sending uevent - %s\n",
							__func__, envp[0]);
		}
	}
}
int smb358_chg_uv(struct opchg_charger *chip, u8 status)
{
	int rc = 0;

	if(chip->chg_present && (status == 0)){
		pr_err("%s chg has plugged in,return\n",__func__);
		return 0;
	}
	
	opchg_inout_charge_parameters(chip);
	//opchg_switch_to_usbin(chip,!status);

    if (status == 0) {
        chip->g_chg_in = 1;
		if(chip->g_is_wakeup == 0){ //if awake not be lock,lock it here else do nothing
            __pm_stay_awake(&chip->source);
            chip->g_is_wakeup= 1;
        }		
    }
    else {
        chip->g_chg_in = 0;
        schedule_delayed_work(&chip->opchg_delayed_wakeup_work,
                            round_jiffies_relative(msecs_to_jiffies(2000)));
    }
    
    /* use this to detect USB insertion only if !apsd */
    if (chip->disable_apsd && status == 0) {
        chip->chg_present = true;
        dev_dbg(chip->dev, "%s updating usb_psy present=%d", __func__, chip->chg_present);
        power_supply_set_supply_type(chip->usb_psy, POWER_SUPPLY_TYPE_USB);
        power_supply_set_present(chip->usb_psy, chip->chg_present);	
	}
	
    if (status != 0) {
        chip->chg_present = false;
        dev_dbg(chip->dev, "%s updating usb_psy present=%d", __func__, chip->chg_present);
        /* we can't set usb_psy as UNKNOWN so early, it'll lead USERSPACE issue */
        power_supply_set_present(chip->usb_psy, chip->chg_present);

		if (chip->bms_controlled_charging){
			/*
			* Disable SOC based USB suspend to enable charging on
			* USB insertion.
			*/
			rc = smb358_charging_disable(chip, SOC, false);
			if (rc < 0)
				dev_err(chip->dev,"Couldn't disable usb suspend rc = %d\n",rc);
		}
    }
	
    //chip->BMT_status.charger_exist = chip->chg_present;
	
    power_supply_changed(chip->usb_psy);
	
	if(is_project(OPPO_15005)){
		schedule_work(&chip->opchg_modify_tp_param_work);
	}
    dev_dbg(chip->dev, "chip->chg_present = %d\n", chip->chg_present);
    
    return 0;
}
Ejemplo n.º 10
0
int opchg_battery_get_property(struct power_supply *psy,
                            enum power_supply_property prop,
                            union power_supply_propval *val)
{
    struct opchg_charger *chip = container_of(psy,
                        struct opchg_charger, batt_psy);
                        
    switch (prop) {
		case POWER_SUPPLY_PROP_AUTHENTICATE:
		    val->intval = 1;
			break; 
		case POWER_SUPPLY_PROP_PRESENT:
			val->intval = chip->bat_exist;
			break;
		case POWER_SUPPLY_PROP_TECHNOLOGY:
	        val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
	        break;	

		case POWER_SUPPLY_PROP_CHARGE_NOW:
	        val->intval = chip->charger_vol;
			//val->intval = opchg_get_prop_charger_voltage_now(chip);
	        break;    
		case POWER_SUPPLY_PROP_VOLTAGE_NOW:
	        val->intval = chip->bat_instant_vol;
	        //val->intval = opchg_get_prop_battery_voltage_now(chip);
	        break;
		case POWER_SUPPLY_PROP_TEMP:
	        val->intval = chip->temperature;
	        //val->intval = opchg_get_prop_batt_temp(chip);
	        break;
		case 	POWER_SUPPLY_PROP_TEMP_STATU:
	        val->intval = chip->charging_opchg_temp_statu;
	        break;
		case POWER_SUPPLY_PROP_CURRENT_NOW:
	        val->intval = chip->charging_current;
	        //val->intval = opchg_get_prop_current_now(chip);
	        break;
	    case POWER_SUPPLY_PROP_CAPACITY:
			if(chip->bat_volt_check_point > 100)
			{
				val->intval = 100;
			}
			else
			{
				val->intval =chip->bat_volt_check_point;
			}
	        break;	
        
	    case POWER_SUPPLY_PROP_CHARGE_TIMEOUT:
	        val->intval = (int)chip->charging_time_out;
	        break;
	    case POWER_SUPPLY_PROP_HEALTH:
			#if 0
			if(is_project(OPPO_14005)) {
				if(chip->bat_temp_status ==POWER_SUPPLY_HEALTH_WARM)
				{
					val->intval = POWER_SUPPLY_HEALTH_GOOD;
				}
				else
				{
					val->intval = chip->bat_temp_status;
				}
			}
			else
			{
		        val->intval = chip->bat_temp_status;
			}
			#else
			val->intval = chip->bat_temp_status;
			#endif
	        break;
    
        case POWER_SUPPLY_PROP_ONLINE:
			// set usb charging sign
			if((chip->chg_present) && (qpnp_charger_type_get(chip) == POWER_SUPPLY_TYPE_USB_DCP))
			{
				val->intval = 0;
			}
			else
			{
	        	val->intval = chip->chg_present;
			}
			#ifdef OPCHARGER_DEBUG_ENABLE
			pr_debug("oppo_debug usb charging sign = %d\n",val->intval);
			#endif
	        break;
    	case POWER_SUPPLY_PROP_CHARGING_ENABLED:
	        if( is_project(OPPO_14005)) {
	            if(opchg_get_prop_fast_chg_started(chip) == true) {
	                val->intval = 1;
	            }
	            else {
	                val->intval = chip->is_charging;
	            }
	        }
	        else {
	            val->intval = chip->is_charging;
	        }
	        break;
	    case POWER_SUPPLY_PROP_STATUS:
			if( is_project(OPPO_14005)) {
				if(opchg_get_prop_fast_chg_started(chip) == true) {
					val->intval = POWER_SUPPLY_STATUS_CHARGING;
				}
				else {
					if((opchg_get_prop_fast_switch_to_normal(chip) == true)&&(chip->g_is_vooc_changed == false))
					{
						val->intval = POWER_SUPPLY_STATUS_CHARGING;
					}
					else
					{
						val->intval = chip->bat_status;
					}
				}
			}
			else {
				val->intval = chip->bat_status;
			}
			#ifdef OPCHARGER_DEBUG_ENABLE
			pr_debug("oppo_debug  bat_status= %d vooc_start_step= %d\r\n",val->intval,vooc_start_step);
			#endif
	        break;
	    case POWER_SUPPLY_PROP_CHARGE_TYPE:
			if( is_project(OPPO_14005)) {
			    if(opchg_get_prop_fast_chg_started(chip) == true) {	// in fast charging
			        val->intval = POWER_SUPPLY_CHARGE_TYPE_FAST;
			    }
			    else {										// in normal  charging
				    val->intval = chip->bat_charging_state;
				}
			}
			else {
			    val->intval = chip->bat_charging_state;
			}
	        break; 
			
	    case POWER_SUPPLY_PROP_MODEL_NAME:
	        val->strval = "OPCHARGER";//"SMB358";
	        break;

		
		case POWER_SUPPLY_PROP_FAST_CHARGE://wangjc add for fast charger
			#ifdef OPPO_USE_FAST_CHARGER /* OPPO 2013-12-22 wangjc add for fastchg*/
			if( is_project(OPPO_14005))
			{
				chip->fastcharger =opchg_get_prop_fast_chg_started(chip);
				if(chip->fastcharger == 0) {
					//if(chip->batt_full == true)
					if((chip->bat_status == POWER_SUPPLY_STATUS_FULL)|| (chip->batt_hot == true)|| (chip->batt_cold == true) 
						|| (chip->batt_voltage_over == true)||(chip->charger_ov_status == true) || (chip->charging_time_out == true))
					{
						chip->fastcharger = 0;
					}
					else if((opchg_get_prop_fast_switch_to_normal(chip) == true) || 
						(opchg_get_prop_fast_normal_to_warm(chip) == true) || 
						(opchg_get_fast_low_temp_full(chip) == true)) {
						chip->fastcharger = 1;
					}
				}
			}
			else
			{
				chip->fastcharger =0;
			}
			#else
			chip->fastcharger =0;
			#endif
			val->intval = chip->fastcharger;
			break;
		case POWER_SUPPLY_PROP_FAST_CHARGE_PROJECT://wangjc add for fast charger project sign
			val->intval = chip->fast_charge_project;
			break;
			
		case POWER_SUPPLY_PROP_BATTERY_FCC:			//dengnw add for battery fcc
			if( is_project(OPPO_14005))
			{
				if(bq27541_di == NULL)
				{
					val->intval = 100;
				}
				else
				{
					//val->intval = bq27541_di->full_charge_soc;
					val->intval = bq27541_di->fcc_pre;
				}
			}
			else
			{
				val->intval = 100;
			}
			break;
		case POWER_SUPPLY_PROP_BATTERY_SOH:			//dengnw add for battery soh
			if( is_project(OPPO_14005))
			{
				if(bq27541_di == NULL)
				{
					val->intval = 100;
				}
				else
				{
					//val->intval = bq27541_di->state_of_health;
					val->intval = bq27541_di->soh_pre;
				}
			}
			else
			{
				val->intval = 100;
			}
			break;
		case POWER_SUPPLY_PROP_BATTERY_CC:			//dengnw add for battery cc
			if( is_project(OPPO_14005))
			{
				if(bq27541_di == NULL)
				{
					val->intval = 100;
				}
				else
				{
					//val->intval = bq27541_di->state_of_health;
					val->intval = bq27541_di->cc_pre;
				}
			}
			else
			{
				val->intval = 100;
			}
			break;
		case POWER_SUPPLY_PROP_BATTERY_CHARGER_ENABLE:
			val->intval = chip->is_factory_mode;
			break;
		
		case POWER_SUPPLY_PROP_BATTERY_NOTIFY:
			val->intval = chip->batterynotify;
			#ifdef OPCHARGER_DEBUG_ENABLE
			pr_debug("oppo_debug  batterynotify = 0x%x\r\n",chip->batterynotify);
			#endif
			break;

		case POWER_SUPPLY_PROP_POWER_OFF:
			
				val->intval = 0;
			
			break;

		case POWER_SUPPLY_PROP_SHIPPING_MODE:
			val->intval = chip->shipping_mode;
			break;
			
	    default:
	        return -EINVAL;
	}
	return 0;
}
Ejemplo n.º 11
0
int opchg_battery_set_property(struct power_supply *psy,
                            enum power_supply_property prop,
                            const union power_supply_propval *val)
{
    struct opchg_charger *chip = container_of(psy,
                            struct opchg_charger, batt_psy);
                            
    switch (prop) {
	case POWER_SUPPLY_PROP_STATUS:
		if (!chip->bms_controlled_charging)
				return -EINVAL;
		switch (val->intval) {
		case POWER_SUPPLY_STATUS_FULL:
	
	            chip->batt_full = true;
	            dev_dbg(chip->dev, "status = FULL, batt_full = %d\n",chip->batt_full);

				break;
		case POWER_SUPPLY_STATUS_DISCHARGING:
				chip->batt_full = false;
				power_supply_changed(&chip->batt_psy);
				dev_dbg(chip->dev, "status = DISCHARGING, batt_full = %d\n",chip->batt_full);
				break;
		case POWER_SUPPLY_STATUS_CHARGING:
				
				chip->batt_full = false;
				dev_dbg(chip->dev, "status = CHARGING, batt_full = %d\n",chip->batt_full);
				
				break;
		default:
				return -EINVAL;
		}
		break;	
    case POWER_SUPPLY_PROP_CHARGING_ENABLED:
        opchg_config_charging_disable(chip, USER_DISABLE, !val->intval);//smb358_charging(chip, val->intval);
        break;
        
    case POWER_SUPPLY_PROP_CAPACITY:
        chip->fake_battery_soc = val->intval;
        power_supply_changed(&chip->batt_psy);
        break;
		
    case POWER_SUPPLY_PROP_BATTERY_CHARGER_ENABLE:
		chip->is_factory_mode= val->intval;
		if(chip->is_factory_mode == true)
		{
		/*[email protected] add for clone 15085*/
			if(is_project(OPPO_14005))
			{
				opchg_config_charging_disable(chip, FACTORY_MODE_DISABLE, 0);
			}
		}
		else
		{
		/*[email protected] add for clone 15085*/

			if( is_project(OPPO_14005))
			{
				opchg_config_charging_disable(chip, FACTORY_MODE_DISABLE, 1);
			}
		}
        break; 

	case POWER_SUPPLY_PROP_SHIPPING_MODE:
		chip->shipping_mode = !!val->intval;
		break;
		
    default:
        return -EINVAL;
    }
    
    return 0;
}
Ejemplo n.º 12
0
/* SET variable = value and set (variable1, .., variableN) = (query) */
static sql_exp *
psm_set_exp(mvc *sql, dnode *n)
{
	symbol *val = n->next->data.sym;
	sql_exp *e = NULL;
	int level = 0, is_last = 0;
	sql_subtype *tpe = NULL;
	sql_rel *rel = NULL;
	sql_exp *res = NULL;
	int single = (n->type == type_string);


	if (single) {
		exp_kind ek = {type_value, card_value, FALSE};
		const char *name = n->data.sval;
		/* name can be 
			'parameter of the function' (ie in the param list)
			or a local or global variable, declared earlier
		*/

		/* check if variable is known from the stack */
		if (!stack_find_var(sql, name)) {
			sql_arg *a = sql_bind_param(sql, name);

			if (!a) /* not parameter, ie local var ? */
				return sql_error(sql, 01, SQLSTATE(42000) "Variable %s unknown", name);
			tpe = &a->type;
		} else { 
			tpe = stack_find_type(sql, name);
		}

		e = rel_value_exp2(sql, &rel, val, sql_sel, ek, &is_last);
		if (!e || (rel && e->card > CARD_AGGR))
			return NULL;

		level = stack_find_frame(sql, name);
		e = rel_check_type(sql, tpe, e, type_cast); 
		if (!e)
			return NULL;
		if (rel) {
			sql_exp *er = exp_rel(sql, rel);
			list *b = sa_list(sql->sa);

			append(b, er);
			append(b, exp_set(sql->sa, name, e, level));
			res = exp_rel(sql, rel_psm_block(sql->sa, b));
		} else {
			res = exp_set(sql->sa, name, e, level);
		}
	} else { /* multi assignment */
		exp_kind ek = {type_value, (single)?card_column:card_relation, FALSE};
		sql_rel *rel_val = rel_subquery(sql, NULL, val, ek, APPLY_JOIN);
		dlist *vars = n->data.lval;
		dnode *m;
		node *n;
		list *b;

		if (!rel_val || !is_project(rel_val->op) ||
			    dlist_length(vars) != list_length(rel_val->exps)) {
			return sql_error(sql, 02, SQLSTATE(42000) "SET: Number of variables not equal to number of supplied values");
		}

	       	b = sa_list(sql->sa);
		if (rel_val) {
			sql_exp *er = exp_rel(sql, rel_val);

			append(b, er);
		}

		for(m = vars->h, n = rel_val->exps->h; n && m; n = n->next, m = m->next) {
			char *vname = m->data.sval;
			sql_exp *v = n->data;

			if (!stack_find_var(sql, vname)) {
				sql_arg *a = sql_bind_param(sql, vname);

				if (!a) /* not parameter, ie local var ? */
					return sql_error(sql, 01, SQLSTATE(42000) "Variable %s unknown", vname);
				tpe = &a->type;
			} else { 
				tpe = stack_find_type(sql, vname);
			}

			if (!exp_name(v))
				exp_label(sql->sa, v, ++sql->label);
			v = exp_column(sql->sa, exp_relname(v), exp_name(v), exp_subtype(v), v->card, has_nil(v), is_intern(v));

			level = stack_find_frame(sql, vname);
			v = rel_check_type(sql, tpe, v, type_cast); 
			if (!v)
				return NULL;
			if (v->card > CARD_AGGR) {
				sql_subaggr *zero_or_one = sql_bind_aggr(sql->sa, sql->session->schema, "zero_or_one", exp_subtype(v));
				assert(zero_or_one);
				v = exp_aggr1(sql->sa, v, zero_or_one, 0, 0, CARD_ATOM, 0);
			}
			append(b, exp_set(sql->sa, vname, v, level));
		}
		res = exp_rel(sql, rel_psm_block(sql->sa, b));
	}
	return res;
}
Ejemplo n.º 13
0
int qpnp_power_get_property_mains(struct power_supply *psy,
                                  enum power_supply_property prop,
                                  union power_supply_propval *val)
{
    struct opchg_charger *chip = container_of(psy, struct opchg_charger,
                                 dc_psy);

    switch (prop)
    {

    case POWER_SUPPLY_PROP_PRESENT:
    case POWER_SUPPLY_PROP_ONLINE:

        if (chip->charging_disabled)
            return 0;
#if 1
        if(is_project(OPPO_14005)||is_project(OPPO_14023)||is_project(OPPO_15011)||is_project(OPPO_15018))
        {
            if((opchg_get_prop_fast_chg_started(chip) == true)
                    || (opchg_get_prop_fast_switch_to_normal(chip) == true)
                    || (opchg_get_fast_normal_to_warm(chip) == true)) {
                val->intval = 1;
            } else {
                if(qpnp_charger_type_get(chip) == POWER_SUPPLY_TYPE_USB_DCP)
                    val->intval = 1;
                else
                    val->intval = 0;
            }
        }
        else
        {
            /* [email protected], 2014/02/11  Modify for when no battery gauge present */
            if(qpnp_charger_type_get(chip) == POWER_SUPPLY_TYPE_USB_DCP)
                val->intval = 1;
            else
                val->intval = 0;
        }
#ifdef OPCHARGER_DEBUG_ENABLE
        pr_debug("oppo_debug dc charging and fast charging sign = %d\n",val->intval);
#endif
#else
        if(is_project(OPPO_14005)||is_project(OPPO_14023)||is_project(OPPO_15011))
        {
            if(opchg_get_prop_fast_chg_started(chip) == true) { // in fast charging
                val->intval = 1;
                //pr_debug("usb_online= %d,00000 usb_check_inout = %d,vooc_start_step= %d\r\n",val->intval,chip->chg_present,vooc_start_step);
            }
            else if(vooc_start_step < OPCHG_VOOC_TO_STANDARD) { // out of fast charging
                val->intval = 1;
                //pr_debug("usb_online= %d,1111 usb_check_inout = %d,vooc_start_step= %d\r\n",val->intval,chip->chg_present,vooc_start_step);
            }
            else
            {
                if(qpnp_charger_type_get(chip) == POWER_SUPPLY_TYPE_USB_DCP)
                    val->intval = 1;
                else
                    val->intval = 0;
                //pr_debug("usb_online= %d,2222 usb_check_inout = %d,vooc_start_step= %d\r\n",val->intval,chip->chg_present,vooc_start_step);
            }
        }
        else
        {
            /* [email protected], 2014/02/11  Modify for when no battery gauge present */
            if(qpnp_charger_type_get(chip) == POWER_SUPPLY_TYPE_USB_DCP)
                val->intval = 1;
            else
                val->intval = 0;
        }
#endif /*CONFIG_BATTERY_BQ27541*/
        break;

    case POWER_SUPPLY_PROP_CURRENT_MAX:
        val->intval = chip->fastchg_current_max_ma * 1000;//chip->maxinput_dc_ma * 1000;
        break;

    default:
        return -EINVAL;
    }
    return 0;
}
Ejemplo n.º 14
0
static void opchg_external_power_changed(struct power_supply *psy)
{
    struct opchg_charger *chip = container_of(psy, struct opchg_charger, batt_psy);
    union power_supply_propval prop = {0,};
    int rc, current_limit = 0, online = 0;

    if (chip->bms_psy_name) {
        chip->bms_psy = power_supply_get_by_name((char *)chip->bms_psy_name);
    }

    rc = chip->usb_psy->get_property(chip->usb_psy, POWER_SUPPLY_PROP_ONLINE, &prop);
    if (rc) {
        dev_err(chip->dev, "Couldn't read USB online property, rc=%d\n", rc);
    }
    else {
        online = prop.intval;
    }

    rc = chip->usb_psy->get_property(chip->usb_psy, POWER_SUPPLY_PROP_CURRENT_MAX, &prop);
    if (rc) {
        dev_err(chip->dev, "Couldn't read USB current_max property, rc=%d\n", rc);
    }
    else {
        current_limit = prop.intval / 1000;
    }

    if(current_limit > chip->limit_current_max_ma) {
        current_limit = chip->limit_current_max_ma;
    }

    //lfc add for charger_ovp
    chip->charger_vol = opchg_get_prop_charger_voltage_now(chip);
    opchg_get_charger_ov_status(chip);
    if(chip->charger_ov_status == true) {
        dev_err(chip->dev,"%s charger-ovp,return \n",__func__);
        return ;
    }

    opchg_set_enable_volatile_writes(chip);
    opchg_config_input_chg_current(chip, INPUT_CURRENT_LCD, chip->limit_current_max_ma);
    opchg_config_input_chg_current(chip, INPUT_CURRENT_CAMERA, chip->limit_current_max_ma);
    opchg_config_input_chg_current(chip, INPUT_CURRENT_BY_POWER, current_limit);
    if(is_project(OPPO_14043) || is_project(OPPO_14051)
            || is_project(OPPO_15005) || is_project(OPPO_15057) || is_project(OPPO_15025))
        opchg_set_input_chg_current(chip, chip->max_input_current[INPUT_CURRENT_BY_POWER], false);
    else
        opchg_set_input_chg_current(chip, chip->max_input_current[INPUT_CURRENT_MIN], false);

    if ((chip->multiple_test == 1) && (current_limit >= 500)) {
        opchg_config_suspend_enable(chip, FACTORY_ENABLE, 1);
    }

    opchg_config_over_time(chip, current_limit);//opchg_set_complete_charge_timeout(chip);
    dev_dbg(chip->dev, "%s set charger input current=%d,online = %d, current_limit = %d\n", __func__,chip->max_input_current[INPUT_CURRENT_MIN], online, current_limit);

    opchg_check_status(chip);
    power_supply_changed(&chip->batt_psy);

    if(is_project(OPPO_14043) || is_project(OPPO_15005) || is_project(OPPO_15025)) {
        if(qpnp_charger_type_get(chip) == POWER_SUPPLY_TYPE_USB_DCP) {
            if(!chip->check_stat_again && (current_limit >= 500) && (chip->charging_current > -250)) {
                msleep(550);
                opchg_check_status(chip);
                chip->check_stat_again = true;
                power_supply_changed(&chip->batt_psy);
            }
        }
    }
}
Ejemplo n.º 15
0
int opchg_battery_set_property(struct power_supply *psy,
                               enum power_supply_property prop,
                               const union power_supply_propval *val)
{
    int rc;
    struct opchg_charger *chip = container_of(psy,
                                 struct opchg_charger, batt_psy);

    switch (prop) {
    case POWER_SUPPLY_PROP_STATUS:
        if (!chip->bms_controlled_charging)
            return -EINVAL;
        switch (val->intval) {
        case POWER_SUPPLY_STATUS_FULL:
            rc = smb358_charging_disable(chip, SOC, true);
            if (rc < 0) {
                dev_err(chip->dev,"Couldn't set charging disable rc = %d\n",rc);
            } else {
                chip->batt_full = true;
                dev_dbg(chip->dev, "status = FULL, batt_full = %d\n",chip->batt_full);
            }
            break;
        case POWER_SUPPLY_STATUS_DISCHARGING:
            chip->batt_full = false;
            power_supply_changed(&chip->batt_psy);
            dev_dbg(chip->dev, "status = DISCHARGING, batt_full = %d\n",chip->batt_full);
            break;
        case POWER_SUPPLY_STATUS_CHARGING:
            rc = smb358_charging_disable(chip, SOC, false);
            if (rc < 0) {
                dev_err(chip->dev,"Couldn't set charging disable rc = %d\n",rc);
            } else {
                chip->batt_full = false;
                dev_dbg(chip->dev, "status = CHARGING, batt_full = %d\n",chip->batt_full);
            }
            break;
        default:
            return -EINVAL;
        }
        break;
    case POWER_SUPPLY_PROP_CHARGING_ENABLED:
        opchg_config_charging_disable(chip, USER_DISABLE, !val->intval);//smb358_charging(chip, val->intval);
        break;

    case POWER_SUPPLY_PROP_CAPACITY:
        chip->fake_battery_soc = val->intval;
        power_supply_changed(&chip->batt_psy);
        break;

    case POWER_SUPPLY_PROP_BATTERY_CHARGER_ENABLE:
        chip->is_factory_mode= val->intval;
        if(chip->is_factory_mode == true)
        {
            if(is_project(OPPO_15011)||is_project(OPPO_14045)||is_project(OPPO_15005) || is_project(OPPO_15025))
            {
                opchg_config_charging_disable(chip, FACTORY_MODE_DISABLE, 0);
            }
        }
        else
        {
            if(is_project(OPPO_15011)||is_project(OPPO_14045)||is_project(OPPO_15005) || is_project(OPPO_15025))
            {
                opchg_config_charging_disable(chip, FACTORY_MODE_DISABLE, 1);
            }
        }
        break;

    default:
        return -EINVAL;
    }

    return 0;
}