modify change charge current

This commit is contained in:
hxy
2010-09-04 22:38:09 +08:00
parent 1ae4d3c9d7
commit 5229738139
3 changed files with 19 additions and 11 deletions

3
arch/arm/configs/rk2818_raho_defconfig Executable file → Normal file
View File

@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
# Linux kernel version: 2.6.32.9
# Fri Sep 3 20:53:52 2010
# Sat Sep 4 20:01:16 2010
#
CONFIG_ARM=y
CONFIG_SYS_SUPPORTS_APM_EMULATION=y
@@ -936,6 +936,7 @@ CONFIG_REGULATOR_DEBUG=y
# CONFIG_REGULATOR_LP3971 is not set
# CONFIG_REGULATOR_TPS65023 is not set
# CONFIG_REGULATOR_TPS6507X is not set
CONFIG_RK2818_REGULATOR_CHARGE=y
CONFIG_RK2818_REGULATOR_LP8725=y
CONFIG_MEDIA_SUPPORT=y

View File

@@ -100,6 +100,7 @@ int gBatVoltageLevel = VOLTAGE_MID_LEVEL;
int gBatUseStatus = BAT_LOADER_STATUS;
static struct regulator *pChargeregulator;
int gVbuscharge = 0;
extern int dwc_vbus_status(void);
extern int get_msc_connect_flag(void);
@@ -145,6 +146,7 @@ typedef enum {
static int rk2818_get_charge_status(void)
{
struct regulator * rdev = pChargeregulator;
//DBG("gAdcValue[CHN_USB_ADC]=%d\n",gAdcValue[CHN_USB_ADC]);
if(gAdcValue[CHN_USB_ADC] > 250) //about 0.5V
{
@@ -152,12 +154,23 @@ static int rk2818_get_charge_status(void)
}
else if((1 == dwc_vbus_status())&& (0 == get_msc_connect_flag()))
{
regulator_set_current_limit(pChargeregulator,0,1200000);
if(gVbuscharge !=1)
{
if(rdev== pChargeregulator )
regulator_set_current_limit(rdev,0,1200000);
}
gVbuscharge = 1;
return 1;
}
else
{
regulator_set_current_limit(pChargeregulator,0,475000);
if(gVbuscharge !=0 )
{
if(rdev== pChargeregulator )
regulator_set_current_limit(rdev,0,475000);
}
gVbuscharge = 0;
return 0;
}
}

View File

@@ -74,11 +74,10 @@ static int charge_get_current(struct regulator_dev *dev)
static int charge_set_current(struct regulator_dev *dev,
int min_uA, int max_uA)
{
printk("enter charge_set_current , max_uA = %d\n",max_uA);
DBG("enter charge_set_current , max_uA = %d\n",max_uA);
struct charge_platform_data *pdata = rdev_get_drvdata(dev);
const int *current_map = charge_current_map;
int max_mA = max_uA / 1000;
printk("charge_set_current:pdata->gpio_charge=%d\n",pdata->gpio_charge);
if ( max_mA == current_map[0] )
gpio_direction_output(pdata->gpio_charge, GPIO_HIGH);
else
@@ -110,14 +109,9 @@ static int __devinit charge_regulator_probe(struct platform_device *pdev)
struct charge_platform_data *pdata = pdev->dev.platform_data;
struct regulator_dev *rdev;
int ret ;
printk(KERN_INFO "enter charge regulator\n");
#if 0
rdev = regulator_register(&chargeregulator, &pdev->dev,
pdev->dev.platform_data, pdata);
#else
rdev = regulator_register(&chargeregulator, &pdev->dev,
pdata->init_data, pdata);
#endif
if (IS_ERR(rdev)) {
dev_dbg(&pdev->dev, "couldn't register regulator\n");
return PTR_ERR(rdev);