From: 张晴 Date: Thu, 2 May 2013 07:52:58 +0000 (+0800) Subject: ricoh619:modify charge limit current X-Git-Tag: firefly_0821_release~7181 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ea2cbec05d9962feaca81b8f9030637a6436aba2;p=firefly-linux-kernel-4.4.55.git ricoh619:modify charge limit current --- diff --git a/drivers/mfd/ricoh619.c b/drivers/mfd/ricoh619.c index 70a1ef08b6fb..d7481a72fa7a 100644 --- a/drivers/mfd/ricoh619.c +++ b/drivers/mfd/ricoh619.c @@ -800,6 +800,11 @@ static int ricoh619_i2c_resume(struct i2c_client *client) __ricoh619_write(client, RICOH619_INT_IR_SYS, 0x0); //Clear PWR_KEY IRQ } + __ricoh619_write(client, RICOH619_INT_IR_CHGCTR, 0); + __ricoh619_write(client, RICOH619_INT_IR_CHGSTS1, 0); + __ricoh619_write(client, RICOH619_INT_IR_ADCL, 0); + __ricoh619_write(client, RICOH619_INT_IR_ADCH, 0); + enable_irq(client->irq); return 0; } diff --git a/drivers/power/ricoh619-battery.c b/drivers/power/ricoh619-battery.c old mode 100644 new mode 100755 index 0124ca53c36a..c511acd86a4b --- a/drivers/power/ricoh619-battery.c +++ b/drivers/power/ricoh619-battery.c @@ -1370,6 +1370,21 @@ static void low_battery_irq_work(struct work_struct *work) } #endif +extern int dwc_vbus_status(void); +static void ricoh619_usb_charge_det(void) +{ + struct ricoh619 *ricoh619 = g_ricoh619; + ricoh619_set_bits(ricoh619->dev,REGISET2_REG,(1 << 7)); //set usb limit current when SDP or other mode + if(2 == dwc_vbus_status()){ + ricoh619_write(ricoh619->dev,REGISET2_REG,0x13); //set usb limit current 2A + ricoh619_write(ricoh619->dev,CHGISET_REG,0x13); //set charge current 2A + } + else if(1 == dwc_vbus_status()){ + ricoh619_write(ricoh619->dev,REGISET2_REG,0x04); //set usb limit current 500ma + ricoh619_write(ricoh619->dev,CHGISET_REG,0x04); //set charge current 500ma + } +} + static void usb_det_irq_work(struct work_struct *work) { struct ricoh619_battery_info *info = container_of(work, @@ -1400,6 +1415,12 @@ static void usb_det_irq_work(struct work_struct *work) sts &= 0x02; if (sts) { + time = 60; + do { + ricoh619_usb_charge_det(); + time --; + mdelay(1000); + }while(time >0); } else { /*********************/ @@ -1414,11 +1435,27 @@ extern void rk28_send_wakeup_key(void); static irqreturn_t charger_in_isr(int irq, void *battery_info) { struct ricoh619_battery_info *info = battery_info; - printk("PMU:%s\n", __func__); + struct ricoh619 *ricoh619 = g_ricoh619; + uint8_t reg_val; + int ret; + printk("PMU:%s\n", __func__); info->chg_stat1 |= 0x01; queue_work(info->workqueue, &info->irq_work); - rk28_send_wakeup_key(); + rk28_send_wakeup_key(); + + ricoh619_read(ricoh619->dev, 0xbd, ®_val); + if ( reg_val & 0x40) + { + /* set adp limit current 2A */ + ricoh619_write(ricoh619->dev, 0xb6, 0x13); + /* set charge current 2A */ + ricoh619_write(ricoh619->dev, 0xb8, 0x13); + } + else if (reg_val & 0x80) + { + queue_work(info->usb_workqueue, &info->usb_irq_work); + } return IRQ_HANDLED; } @@ -1439,9 +1476,9 @@ static irqreturn_t charger_usb_isr(int irq, void *battery_info) printk("PMU:%s\n", __func__); info->chg_ctr |= 0x02; - queue_work(info->usb_workqueue, &info->usb_irq_work); - rk28_send_wakeup_key(); - +// queue_work(info->usb_workqueue, &info->usb_irq_work); + rk28_send_wakeup_key(); + if (RICOH619_SOCA_UNSTABLE == info->soca->status || RICOH619_SOCA_FG_RESET == info->soca->status) info->soca->stable_count = 11; @@ -1457,16 +1494,14 @@ static irqreturn_t charger_adp_isr(int irq, void *battery_info) info->chg_ctr |= 0x01; queue_work(info->workqueue, &info->irq_work); - rk28_send_wakeup_key(); /* clr usb det irq */ ricoh619_clr_bits(ricoh619->dev, RICOH619_INT_IR_CHGCTR, info->chg_ctr); - /* set adp limit current 2A */ - ricoh619_write(ricoh619->dev, 0xb6, 0x13); +// ricoh619_write(ricoh619->dev, 0xb6, 0x13); /* set charge current 2A */ - ricoh619_write(ricoh619->dev, 0xb8, 0x13); - +// ricoh619_write(ricoh619->dev, 0xb8, 0x13); + rk28_send_wakeup_key(); if (RICOH619_SOCA_UNSTABLE == info->soca->status || RICOH619_SOCA_FG_RESET == info->soca->status) info->soca->stable_count = 11;