Example #1
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
int axp809_set_charge_control(void)
{
	u8 reg_value;
	//disable ts adc, enable all other adc
	if(axp_i2c_read(AXP809_ADDR, BOOT_POWER809_ADC_EN, &reg_value))
    {
        return -1;
    }
    reg_value |= 0xC0;
    if(axp_i2c_write(AXP809_ADDR, BOOT_POWER809_ADC_EN, reg_value))
    {
        return -1;
    }
    //enable charge
	if(axp_i2c_read(AXP809_ADDR, BOOT_POWER809_CHARGE1, &reg_value))
    {
        return -1;
    }
    reg_value |= 0x80;
    if(axp_i2c_write(AXP809_ADDR, BOOT_POWER809_CHARGE1, reg_value))
    {
        return -1;
    }

    return 0;
}
Example #2
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
static int axp20_set_dcdc2(int set_vol, int onoff)
{
 	u32 vol, tmp, i;
    u8  reg_addr, value;
	if(set_vol == -1)
	{
		set_vol = 1.4;
	}
    //PMU is AXP209
    reg_addr = BOOT_POWER20_DC2OUT_VOL;
    if(axp_i2c_read(AXP20_ADDR, reg_addr, &value))
    {
        return -1;
    }
    tmp     = value & 0x3f;
    vol     = tmp * 25 + 700;
    //如果电压过高,则调低
    while(vol > set_vol)
    {
        tmp -= 1;
        value &= ~0x3f;
        value |= tmp;
        reg_addr = BOOT_POWER20_DC2OUT_VOL;
        if(axp_i2c_write(AXP20_ADDR, reg_addr, &value))
        {
            return -1;
        }
        for(i=0;i<2000;i++);
        reg_addr = BOOT_POWER20_DC2OUT_VOL;
        if(axp_i2c_read(AXP20_ADDR, reg_addr, &value))
        {
            return -1;
        }
        tmp     = value & 0x3f;
        vol     = tmp * 25 + 700;
    }
    //如果电压过低,则调高,根据先调低再调高的过程,保证电压会大于等于用户设定电压
    while(vol < set_vol)
    {
        tmp += 1;
        value &= ~0x3f;
        value |= tmp;
        reg_addr = BOOT_POWER20_DC2OUT_VOL;
        if(axp_i2c_write(AXP20_ADDR, reg_addr, &value))
        {
            return -1;
        }
        for(i=0;i<2000;i++);
        reg_addr = BOOT_POWER20_DC2OUT_VOL;
        if(axp_i2c_read(AXP20_ADDR, reg_addr, &value))
        {
            return -1;
        }
        tmp     = value & 0x3f;
        vol     = tmp * 25 + 700;
    }
	printf("after set dcdc2,the value =%dmv\n",vol);
	
	return 0;
}
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
static int axp20_set_dcdc3(int set_vol, int onoff)
{
	s32 vol_value;
	s32 ret;
	u8  reg_addr;
	u8  reg_value;
	
	if(set_vol == -1)
	{
		if(!dcdc3_user_set)
		{
			ret = script_parser_fetch("target", "dcdc3_vol", &vol_value, 1);
			if(ret)
			{
				printf("boot power:unable to find dcdc3 set\n");
				return -1;
			}
			dcdc3_user_set = vol_value;
		}
		vol_value = dcdc3_user_set;
	}
	else
	{
		vol_value = set_vol;
	}

	if(!vol_value)
	{
		reg_addr = BOOT_POWER20_OUTPUT_CTL;
		if(!axp_i2c_read(AXP20_ADDR, reg_addr, &reg_value))
		{
			reg_value &= ~(1<<1);
			if(axp_i2c_write(AXP20_ADDR, reg_addr, reg_value))
			{
				printf("boot power:unable to close dcdc3\n");
				return -1;
			}
		}
	}
	else
	{
		reg_addr = BOOT_POWER20_DC3OUT_VOL;
		if(!axp_i2c_read(AXP20_ADDR, reg_addr, &reg_value))
		{
			if((vol_value >= 700) && (vol_value <= 3500))
			{
				reg_value &= 0x80;
				reg_value = ((vol_value - 700)/25);
				if(axp_i2c_write(AXP20_ADDR, reg_addr, reg_value))
				{
					printf("boot power:unable to set dcdc3\n");
					return -1;
				}
			}
		}
	}

	return 0;
}
/*
 ************************************************************************************************************
 *
 *                                             function
 *
 *    函数名称:
 *
 *    参数列表:
 *
 *    返回值  :
 *
 *    说明    :
 *
 *
 ************************************************************************************************************
 */
static int axp20_set_ldo2(int set_vol, int onoff)
{
    s32 vol_value;
        s32 ret;
        u8  reg_addr;
        u8  reg_value;

        if(set_vol == -1)
        {
            if(!ldo2_user_set)
            {
                ret = script_parser_fetch("target", "ldo2_vol", &vol_value, 1);
                    if(ret)
                    {
                        printf("boot power:unable to find ldo2 set\n");

                            return -1;
                    }
                ldo2_user_set = vol_value;
            }
            vol_value = ldo2_user_set;
        }
        else
        {
            vol_value = set_vol;
        }
    if(!vol_value)
    {
        reg_addr = BOOT_POWER20_OUTPUT_CTL;
        if(!axp_i2c_read(AXP20_ADDR, reg_addr, &reg_value))
        {
            reg_value &= ~(1<<2);
            if(axp_i2c_write(AXP20_ADDR, reg_addr, reg_value))
            {
                printf("boot power:unable to set ldo2\n");
                    return -1;
            }
        }
    }
    else
    {
        reg_addr  = BOOT_POWER20_LDO24OUT_VOL;
        if(!axp_i2c_read(AXP20_ADDR, reg_addr, &reg_value))
        {
            if((vol_value >= 1800) && (vol_value <= 3300))
            {
                reg_value &= 0x0f;
                reg_value |= (((vol_value - 1800)/100) << 4);
                if(axp_i2c_write(AXP20_ADDR, reg_addr, reg_value))
                {
                    printf("boot power:unable to set ldo2\n");
                        return -1;
                }
            }
        }
    }
    return 0;
}
Example #5
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
static int axp81X_set_eldo1(int set_vol, int onoff)
{
	u8 reg_value;

	if(set_vol > 0)
	{
		if(set_vol < 700)
		{
			set_vol = 700;
		}
		else if(set_vol > 1900)
		{
			set_vol = 1900;
		}
		if(axp_i2c_read(AXP81X_ADDR, BOOT_POWER81X_ELDO1_VOL, &reg_value))
	    {
	        return -1;
	    }
	    reg_value &= 0xE0;
      
        reg_value |= ((set_vol - 700)/50);
       
		
	    if(axp_i2c_write(AXP81X_ADDR, BOOT_POWER81X_ELDO1_VOL, reg_value))
	    {
	    	printf("sunxi pmu error : unable to set eldo1\n");

	        return -1;
	    }
	}

	if(onoff < 0)
	{
		return 0;
	}
	if(axp_i2c_read(AXP81X_ADDR, BOOT_POWER81X_OUTPUT_CTL2, &reg_value))
    {
		return -1;
    }
	if(onoff == 0)
	{
		reg_value &= ~(1 << 0);
	}
	else
	{
		reg_value |=  (1 << 0);
	}
    if(axp_i2c_write(AXP81X_ADDR, BOOT_POWER81X_OUTPUT_CTL2, reg_value))
	{
		printf("sunxi pmu error : unable to onoff eldo1\n");

		return -1;
	}

	return 0;
}
Example #6
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
static int axp809_set_dcdc5(int set_vol, int onoff)
{
    u8   reg_value;

	if(set_vol > 0)
	{
		if(set_vol < 1000)
		{
			set_vol = 1000;
		}
		else if(set_vol > 2550)
		{
			set_vol = 2550;
		}
		if(axp_i2c_read(AXP809_ADDR, BOOT_POWER809_DC5OUT_VOL, &reg_value))
	    {
	    	debug("%d\n", __LINE__);

	        return -1;
	    }
	    reg_value &= 0xC0;
		reg_value |= ((set_vol - 1000)/50);
		if(axp_i2c_write(AXP809_ADDR, BOOT_POWER809_DC5OUT_VOL, reg_value))
		{
			printf("sunxi pmu error : unable to set dcdc5\n");

			return -1;
		}
	}

	if(onoff < 0)
	{
		return 0;
	}
	if(axp_i2c_read(AXP809_ADDR, BOOT_POWER809_OUTPUT_CTL1, &reg_value))
    {
		return -1;
    }
	if(onoff == 0)
	{
		reg_value &= ~(1 << 5);
	}
	else
	{
		reg_value |=  (1 << 5);
	}
    if(axp_i2c_write(AXP809_ADDR, BOOT_POWER809_OUTPUT_CTL1, reg_value))
	{
		printf("sunxi pmu error : unable to onoff dcdc5\n");

		return -1;
	}

	return 0;
}
Example #7
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
static int axp809_set_dcdc1(int set_vol, int onoff)
{
    u8   reg_value;

	if(set_vol > 0)
	{
		if(set_vol < 1600)
		{
			set_vol = 1600;
		}
		else if(set_vol > 3400)
		{
			set_vol = 3400;
		}
		if(axp_i2c_read(AXP809_ADDR, BOOT_POWER809_DC1OUT_VOL, &reg_value))
	    {
			return -1;
	    }
	    reg_value &= 0xE0;
		reg_value |= ((set_vol - 1600)/100);

		if(axp_i2c_write(AXP809_ADDR, BOOT_POWER809_DC1OUT_VOL, reg_value))
		{
			printf("sunxi pmu error : unable to set dcdc1\n");

			return -1;
		}
		axp_i2c_read(AXP809_ADDR, BOOT_POWER809_DC1OUT_VOL, &reg_value);
	}

	if(onoff < 0)
	{
		return 0;
	}
	if(axp_i2c_read(AXP809_ADDR, BOOT_POWER809_OUTPUT_CTL1, &reg_value))
    {
		return -1;
    }
	if(onoff == 0)
	{
		reg_value &= ~(1 << 1);
	}
	else
	{
		reg_value |=  (1 << 1);
	}
    if(axp_i2c_write(AXP809_ADDR, BOOT_POWER809_OUTPUT_CTL1, reg_value))
	{
		printf("sunxi pmu error : unable to onoff dcdc1\n");

		return -1;
	}

	return 0;
}
Example #8
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
static int axp22_set_gpio1ldo(int set_vol, int onoff)
{
	u8 reg_value;

	if(set_vol > 0)
	{
		if(set_vol < 700)
		{
			set_vol = 700;
		}
		else if(set_vol > 3300)
		{
			set_vol = 3300;
		}
		if(axp_i2c_read(AXP22_ADDR, BOOT_POWER22_GPIO1_VOL, &reg_value))
	    {
	        return -1;
	    }
	    reg_value &= 0xE0;
		reg_value |= ((set_vol - 700)/100);
	    if(axp_i2c_write(AXP22_ADDR, BOOT_POWER22_GPIO1_VOL, reg_value))
	    {
	    	printf("sunxi pmu error : unable to set gpio1ldo\n");

	        return -1;
	    }
	}

	if(onoff < 0)
	{
		return 0;
	}
	if(axp_i2c_read(AXP22_ADDR, BOOT_POWER22_GPIO1_CTL, &reg_value))
    {
		return -1;
    }
	if(onoff == 0)
	{
		reg_value &= ~(7 << 0);
		reg_value |=  (3 << 0);
	}
	else
	{
		reg_value &= ~(7 << 0);
		reg_value |=  (2 << 0);
	}
    if(axp_i2c_write(AXP22_ADDR, BOOT_POWER22_GPIO1_CTL, reg_value))
	{
		printf("sunxi pmu error : unable to onoff gpio1ldo\n");

		return -1;
	}

	return 0;
}
Example #9
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
static int axp22_set_dcdc4(int set_vol, int onoff)
{
    u8   reg_value;

	if(set_vol > 0)
	{
		if(set_vol < 600)
		{
			set_vol = 600;
		}
		else if(set_vol > 1540)
		{
			set_vol = 1540;
		}
		if(axp_i2c_read(AXP22_ADDR, BOOT_POWER22_DC4OUT_VOL, &reg_value))
	    {
	    	debug("%d\n", __LINE__);

	        return -1;
	    }
		reg_value = ((set_vol - 600)/20);
		if(axp_i2c_write(AXP22_ADDR, BOOT_POWER22_DC4OUT_VOL, reg_value))
		{
			printf("sunxi pmu error : unable to set dcdc4\n");

			return -1;
		}
	}

	if(onoff < 0)
	{
		return 0;
	}
	if(axp_i2c_read(AXP22_ADDR, BOOT_POWER22_OUTPUT_CTL1, &reg_value))
    {
		return -1;
    }
	if(onoff == 0)
	{
		reg_value &= ~(1 << 4);
	}
	else
	{
		reg_value |=  (1 << 4);
	}
    if(axp_i2c_write(AXP22_ADDR, BOOT_POWER22_OUTPUT_CTL1, reg_value))
	{
		printf("sunxi pmu error : unable to onoff dcdc4\n");

		return -1;
	}

	return 0;
}
Example #10
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
static int axp809_set_aldo3(int set_vol, int onoff)
{
	u8 reg_value;

	if(set_vol > 0)
	{
		if(set_vol < 700)
		{
			set_vol = 700;
		}
		else if(set_vol > 3300)
		{
			set_vol = 3300;
		}
		if(axp_i2c_read(AXP809_ADDR, BOOT_POWER809_ALDO3OUT_VOL, &reg_value))
	    {
	        return -1;
	    }
	    reg_value &= 0xE0;
		reg_value |= ((set_vol - 700)/100);
	    if(axp_i2c_write(AXP809_ADDR, BOOT_POWER809_ALDO3OUT_VOL, reg_value))
	    {
	    	printf("sunxi pmu error : unable to set aldo3\n");

	        return -1;
	    }
	}

	if(onoff < 0)
	{
		return 0;
	}
	if(axp_i2c_read(AXP809_ADDR, BOOT_POWER809_OUTPUT_CTL2, &reg_value))
    {
		return -1;
    }
	if(onoff == 0)
	{
		reg_value &= ~(1 << 5);
	}
	else
	{
		reg_value |=  (1 << 5);
	}
    if(axp_i2c_write(AXP809_ADDR, BOOT_POWER809_OUTPUT_CTL2, reg_value))
	{
		printf("sunxi pmu error : unable to onoff aldo3\n");

		return -1;
	}

	return 0;
}
Example #11
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
static int axp22_set_dldo4(int set_vol, int onoff)
{
	u8 reg_value;

	if(set_vol > 0)
	{
		if(set_vol < 700)
		{
			set_vol = 700;
		}
		else if(set_vol > 3300)
		{
			set_vol = 3300;
		}
		if(axp_i2c_read(AXP22_ADDR, BOOT_POWER22_DLDO4_VOL, &reg_value))
	    {
	        return -1;
	    }
	    reg_value &= 0xE0;
		reg_value |= ((set_vol - 700)/100);
	    if(axp_i2c_write(AXP22_ADDR, BOOT_POWER22_DLDO4_VOL, reg_value))
	    {
	    	printf("sunxi pmu error : unable to set dldo4\n");

	        return -1;
	    }
	}

	if(onoff < 0)
	{
		return 0;
	}
	if(axp_i2c_read(AXP22_ADDR, BOOT_POWER22_OUTPUT_CTL2, &reg_value))
    {
		return -1;
    }
	if(onoff == 0)
	{
		reg_value &= ~(1 << 6);
	}
	else
	{
		reg_value |=  (1 << 6);
	}
    if(axp_i2c_write(AXP22_ADDR, BOOT_POWER22_OUTPUT_CTL2, reg_value))
	{
		printf("sunxi pmu error : unable to onoff dldo4\n");

		return -1;
	}

	return 0;
}
Example #12
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
static int axp809_set_dcdc2(int set_vol, int onoff)
{
    u8   reg_value;

	if(set_vol > 0)
	{
		if(set_vol < 600)
		{
			set_vol = 600;
		}
		else if(set_vol > 1540)
		{
			set_vol = 1540;
		}
		if(axp_i2c_read(AXP809_ADDR, BOOT_POWER809_DC2OUT_VOL, &reg_value))
	    {
	        return -1;
	    }
	    reg_value &= ~0x3f;
	    reg_value |= (set_vol - 600)/20;
	    if(axp_i2c_write(AXP809_ADDR, BOOT_POWER809_DC2OUT_VOL, reg_value))
	    {
	    	printf("sunxi pmu error : unable to set dcdc2\n");
	        return -1;
	    }
	}

	if(onoff < 0)
	{
		return 0;
	}
	if(axp_i2c_read(AXP809_ADDR, BOOT_POWER809_OUTPUT_CTL1, &reg_value))
    {
		return -1;
    }
	if(onoff == 0)
	{
		reg_value &= ~(1 << 2);
	}
	else
	{
		reg_value |=  (1 << 2);
	}
    if(axp_i2c_write(AXP809_ADDR, BOOT_POWER809_OUTPUT_CTL1, reg_value))
	{
		printf("sunxi pmu error : unable to onoff dcdc2\n");

		return -1;
	}

    return 0;
}
Example #13
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
static int axp809_set_dc1sw(int onoff)
{
    u8   reg_value;

	if(axp_i2c_read(AXP809_ADDR, BOOT_POWER809_OUTPUT_CTL2, &reg_value))
    {
		return -1;
    }
    if(onoff)
    {
		reg_value |= (1 << 7);
	}
	else
	{
		reg_value &= ~(1 << 7);
	}
	if(axp_i2c_write(AXP809_ADDR, BOOT_POWER809_OUTPUT_CTL2, reg_value))
	{
		printf("sunxi pmu error : unable to set dc1sw\n");

		return -1;
	}

	return 0;
}
Example #14
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
static int axp22_set_dc5ldo(int onoff)
{
    u8   reg_value;

	if(axp_i2c_read(AXP22_ADDR, BOOT_POWER22_OUTPUT_CTL1, &reg_value))
    {
		return -1;
    }
    if(onoff)
    {
		reg_value |= (1 << 0);
	}
	else
	{
		reg_value &= ~(1 << 0);
	}
	if(axp_i2c_write(AXP22_ADDR, BOOT_POWER22_OUTPUT_CTL1, reg_value))
	{
		printf("sunxi pmu error : unable to set dc5ldo\n");

		return -1;
	}

	return 0;
}
Example #15
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
int axp809_set_vbus_cur_limit(int current)
{
	uchar reg_value;

	//set bus current limit off
	if(axp_i2c_read(AXP809_ADDR, BOOT_POWER809_VBUS_SET, &reg_value))
    {
        return -1;
    }
    reg_value &= 0xfC;
	if(!current)
	{
	    reg_value |= 0x03;
	}
	else if(current <= 500)		//limit to 500
	{
		reg_value |= 0x01;
	}
	else						//limit to 900
	{
		reg_value |= 0;
	}
	if(axp_i2c_write(AXP809_ADDR, BOOT_POWER809_VBUS_SET, reg_value))
    {
        return -1;
    }

    return 0;
}
Example #16
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
int axp809_set_vbus_vol_limit(int vol)
{
	uchar reg_value;

	//set bus vol limit off
	if(axp_i2c_read(AXP809_ADDR, BOOT_POWER809_VBUS_SET, &reg_value))
    {
        return -1;
    }
    reg_value &= ~(7 << 3);
	if(!vol)
	{
	    reg_value &= ~(1 << 6);
	}
	else
	{
		if(vol < 4000)
		{
			vol = 4000;
		}
		else if(vol > 4700)
		{
			vol = 4700;
		}
		reg_value |= ((vol-4000)/100) << 3;
	}
	if(axp_i2c_write(AXP809_ADDR, BOOT_POWER809_VBUS_SET, reg_value))
    {
        return -1;
    }

    return 0;
}
Example #17
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
int axp81_set_charge_current(int current)
{
	u8   reg_value;
	int  step;

	if(axp_i2c_read(AXP81X_ADDR, BOOT_POWER81X_CHARGE1, &reg_value))
    {
        return -1;
    }
	reg_value &= ~0x0f;
	if(current > 2800)
	{
		current = 2800;
	}
	else if(current < 200)
	{
		current = 200;
	}
	step       = (current/200) - 1; //0-13 ---->200to 2800
	reg_value |= (step & 0x0f);

	if(axp_i2c_write(AXP81X_ADDR, BOOT_POWER81X_CHARGE1, reg_value))
    {
        return -1;
    }

	return 0;
}
Example #18
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
int axp809_set_charge_current(int current)
{
	u8   reg_value;
	int  step;

	if(axp_i2c_read(AXP809_ADDR, BOOT_POWER809_CHARGE1, &reg_value))
    {
        return -1;
    }
	reg_value &= ~0x0f;
	if(current > 2550)
	{
		current = 2550;
	}
	else if(current < 300)
	{
		current = 300;
	}
	step       = (current/150) - 2;
	reg_value |= (step & 0x0f);

	if(axp_i2c_write(AXP809_ADDR, BOOT_POWER809_CHARGE1, reg_value))
    {
        return -1;
    }

	return 0;
}
Example #19
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
int axp809_set_next_sys_mode(int data)
{
	if(axp_i2c_write(AXP809_ADDR, BOOT_POWER809_DATA_BUFFER11, (u8)data))
    {
        return -1;
    }

	return 0;
}
Example #20
0
int axp_close_LED(void)
{
        uchar led_status;

        axp_i2c_read(AXP81X_ADDR, 0x32, &led_status);
        led_status &= (~0x08);
        led_status &= 0xc7;
        axp_i2c_write(AXP81X_ADDR, 0x32, led_status);

        return 0;
}
Example #21
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
int axp_open_LED(void)
{
        uchar led_status;

        axp_i2c_read(AXP81X_ADDR, 0x32, &led_status);
        led_status &= (~0x08);
        led_status |= 0x30;
        axp_i2c_write(AXP81X_ADDR, 0x32, led_status);

        return 0;
}
Example #22
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
int axp809_set_int_enable(uchar *addr)
{
	int   i;
	uchar  int_reg = BOOT_POWER809_INTEN1;

	for(i=0;i<5;i++)
	{
		if(axp_i2c_write(AXP809_ADDR, int_reg, addr[i]))
	    {
	        return -1;
	    }
	    int_reg ++;
	}

	return 0;
}
Example #23
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
int axp809_set_power_off(void)
{
    u8 reg_value;

	if(axp_i2c_read(AXP809_ADDR, BOOT_POWER809_OFF_CTL, &reg_value))
    {
        return -1;
    }
    reg_value |= 1 << 7;
	if(axp_i2c_write(AXP809_ADDR, BOOT_POWER809_OFF_CTL, reg_value))
    {
        return -1;
    }

    return 0;
}
Example #24
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
int axp809_probe_key(void)
{
	u8  reg_value;

	if(axp_i2c_read(AXP809_ADDR, BOOT_POWER809_INTSTS5, &reg_value))
    {
        return -1;
    }
    reg_value &= (0x03<<3);
	if(reg_value)
	{
		if(axp_i2c_write(AXP809_ADDR, BOOT_POWER809_INTSTS5, reg_value))
	    {
	        return -1;
	    }
	}

	return (reg_value>>3)&3;
}
Example #25
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
int axp22_probe_key(void)
{
    u8  reg_value;

    if(axp_i2c_read(AXP22_ADDR, BOOT_POWER22_INTSTS3, &reg_value))
    {
        return -1;
    }
    reg_value &= 0x03;
    if(reg_value)
    {
        if(axp_i2c_write(AXP22_ADDR, BOOT_POWER22_INTSTS3, reg_value))
        {
            return -1;
        }
    }

    return reg_value;
}
Example #26
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
int axp809_set_coulombmeter_onoff(int onoff)
{
	u8 reg_value;

	if(axp_i2c_read(AXP809_ADDR,BOOT_POWER809_FUEL_GAUGE_CTL, &reg_value))
    {
        return -1;
    }
    if(!onoff)
    	reg_value &= ~(0x01 << 7);
    else
    	reg_value |= (0x01 << 7);

    if(axp_i2c_write(AXP809_ADDR,BOOT_POWER809_FUEL_GAUGE_CTL,reg_value))
    {
        return -1;
    }

    return 0;
}
Example #27
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
int axp22_set_coulombmeter_onoff(int onoff)
{
    u8 reg_value;

    if(axp_i2c_read(AXP22_ADDR,BOOT_POWER22_COULOMB_CTL, &reg_value))
    {
        return -1;
    }
    if(!onoff)
        reg_value &= ~(0x01 << 7);
    else
        reg_value |= (0x01 << 7);

    if(axp_i2c_write(AXP22_ADDR,BOOT_POWER22_COULOMB_CTL,reg_value))
    {
        return -1;
    }

    return 0;
}
Example #28
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
int axp809_probe_int_pending(uchar *addr)
{
	int   i;

	for(i=0;i<5;i++)
	{
	    if(axp_i2c_read(AXP809_ADDR, BOOT_POWER809_INTSTS1 + i, addr + i))
	    {
	        return -1;
	    }
	}

	for(i=0;i<5;i++)
	{
	    if(axp_i2c_write(AXP809_ADDR, BOOT_POWER809_INTSTS1 + i, 0xff))
	    {
	        return -1;
	    }
	}

	return 0;
}
Example #29
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
int axp809_set_power_onoff_vol(int set_vol, int stage)
{
	u8 reg_value;

	if(!set_vol)
	{
		if(!stage)
		{
			set_vol = 3300;
		}
		else
		{
			set_vol = 2900;
		}
	}
	if(axp_i2c_read(AXP809_ADDR, BOOT_POWER809_VOFF_SET, &reg_value))
    {
        return -1;
    }
	reg_value &= 0xf8;
	if(set_vol >= 2600 && set_vol <= 3300)
	{
		reg_value |= (set_vol - 2600)/100;
	}
	else if(set_vol <= 2600)
	{
		reg_value |= 0x00;
	}
	else
	{
		reg_value |= 0x07;
	}
	if(axp_i2c_write(AXP809_ADDR, BOOT_POWER809_VOFF_SET, reg_value))
    {
        return -1;
    }

	return 0;
}
Example #30
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
int axp81_set_vbus_cur_limit(int current)
{
	uchar reg_value;

	//set bus current limit off
	if(axp_i2c_read(AXP81X_ADDR, BOOT_POWER81X_VBUS_SET, &reg_value))
    {
        return -1;
    }
    reg_value &= 0xfC;
	if(!current)
	{
	    reg_value |= 0x03;
	}
	else if(current >= 2500) //limit to2500
	{
		reg_value |= 0x03;
	}
	else if(current >= 2000) //limit to 2000
	{
		reg_value |= 0x02;
	}
    else if(current >= 1500) //limit to 1500
	{
		reg_value |= 0x01;
	}
    else 				     //limit to 900
	{
		reg_value |= 0x00;
	}

	if(axp_i2c_write(AXP81X_ADDR, BOOT_POWER81X_VBUS_SET, reg_value))
    {
        return -1;
    }

    return 0;
}