static kal_uint32 charging_get_charger_det_status(void *data)
 {
	   kal_uint32 status = STATUS_OK;
 
#if defined(CHRDET_SW_MODE_EN)
    kal_uint32 vchr_val=0;

    vchr_val = PMIC_IMM_GetOneChannelValue(4,5,1);
    vchr_val = (((330+39)*100*vchr_val)/39)/100;

    if( vchr_val > 4300 )
    {
        battery_xlog_printk(BAT_LOG_FULL, "[CHRDET_SW_WORKAROUND_EN] upmu_is_chr_det=Y (%d)\n", vchr_val);
        *(kal_uint32 *)data = KAL_TRUE;	
    }
    else
    {
        battery_xlog_printk(BAT_LOG_FULL, "[CHRDET_SW_WORKAROUND_EN] upmu_is_chr_det=N (%d)\n", vchr_val);
        *(kal_uint32 *)data = KAL_FALSE;
    }        
#else
	   *(kal_bool*)(data) = upmu_get_rgs_chrdet();
#endif
	   
       if( upmu_get_rgs_chrdet() == 0 )
           g_charger_type = CHARGER_UNKNOWN;
       
	   return status;
 }
 static kal_uint32 charging_get_charger_det_status(void *data)
 {
	   kal_uint32 status = STATUS_OK;
 
	   *(kal_bool*)(data) = upmu_get_rgs_chrdet();
	   
       if( upmu_get_rgs_chrdet() == 0 )
           g_charger_type = CHARGER_UNKNOWN;
       
	   return status;
 }
static kal_uint32 charging_get_charger_det_status(void *data)
{
	int online;
	int rc;

	if (upmu_get_rgs_chrdet() == 0) {
		*(kal_bool*)(data) = KAL_FALSE;
		g_charger_type = CHARGER_UNKNOWN;
#ifdef CONFIG_LGE_PM
		charging_type_det_retry = KAL_FALSE;
#endif
	} else {
		*(kal_bool*)(data) = KAL_TRUE;
		rc = get_property(POWER_SUPPLY_PROP_ONLINE, &online);
		if (rc) {
			/* error reading online status. use pmic value */
			battery_xlog_printk(BAT_LOG_CRTI, "[PowerSupply] cannot read online.\n");
			return STATUS_OK;
		}

		if (!online) {
			/* OVP detected in external charger */
			*(kal_bool*)(data) = KAL_FALSE;
			g_charger_type = CHARGER_UNKNOWN;
		}
	}

	battery_xlog_printk(BAT_LOG_FULL, "[PowerSupply] g_charger_type = %d\n", g_charger_type);

	return STATUS_OK;
}
 static kal_uint32 charging_get_charger_det_status(void *data)
 {
	   kal_uint32 status = STATUS_OK;
 
	   *(kal_bool*)(data) = upmu_get_rgs_chrdet();
	   
	   return status;
 }
Beispiel #5
0
bool usb_cable_connected(void)
{
#ifdef CONFIG_POWER_EXT
	CHARGER_TYPE chg_type = mt_charger_type_detection();
	os_printk(K_INFO, "%s ext-chrdet=%d type=%d\n", __func__, upmu_get_rgs_chrdet(), chg_type);
	if (upmu_get_rgs_chrdet() && (chg_type == STANDARD_HOST))
#else
	os_printk(K_INFO, "%s chrdet=%d\n", __func__, upmu_is_chr_det());
	if (upmu_is_chr_det())
#endif
	{
		return true;
	} else {
		return false;
	}
	return true;
}
/*
 * FUNCTION
 *		Internal_chr_control_handler
 *
 * DESCRIPTION
 *		 This function is called to set the charger hw
 *
 * CALLS
 *
 * PARAMETERS
 *		None
 *
 * RETURNS
 *
 *
 * GLOBALS AFFECTED
 *	   None
 */
kal_int32 chr_control_interface(CHARGING_CTRL_CMD cmd, void *data)
{
	kal_int32 status;
	int i;

	switch(cmd) {
	/* these commands does not need power_supply, so jump to do_cmd */
	case CHARGING_CMD_INIT:
	case CHARGING_CMD_RESET_WATCH_DOG_TIMER:
	case CHARGING_CMD_SET_HV_THRESHOLD:
	case CHARGING_CMD_GET_HV_STATUS:
	case CHARGING_CMD_GET_BATTERY_STATUS:
	case CHARGING_CMD_GET_IS_PCM_TIMER_TRIGGER:
	case CHARGING_CMD_SET_PLATFORM_RESET:
	case CHARGING_CMD_GET_PLATFORM_BOOT_MODE:
	case CHARGING_CMD_SET_POWER_OFF:
	case CHARGING_CMD_GET_POWER_SOURCE:
	case CHARGING_CMD_GET_CSDAC_FALL_FLAG:
	case CHARGING_CMD_SET_TA_CURRENT_PATTERN:
	case CHARGING_CMD_SET_ERROR_STATE:
		goto chr_control_interface_do_cmd;
		break;
	default:
		break;
	}

	if (!power_supply) {
		/* find charger */
		for (i = 0; i < ARRAY_SIZE(support_charger); i++) {
			power_supply = power_supply_get_by_name(support_charger[i]);
			if (power_supply)
				break;
		}

		/* if not found, cannot control charger */
		if (!power_supply) {
			battery_xlog_printk(BAT_LOG_CRTI, "[PowerSupply] failed to get power_supply.\n");
			return STATUS_UNSUPPORTED;
		}

		/* If power source is attached, assume that device is charing now */
		if (upmu_get_rgs_chrdet()) {
			g_charging_enabled = true;
		}
	}

chr_control_interface_do_cmd:
	status = charging_func[cmd](data);

	return status;
}