ret = ricoh619_write(ricoh619->dev, RICOH619_INTC_INTEN, 0);
ret = ricoh619_clr_bits(ricoh619->dev,RICOH619_PWR_REP_CNT,(0x1<<0));//Not repeat power ON after power off(Power Off/N_OE)
- if(( charge_state == CHG_STATE_CHG_TRICKLE)||( charge_state == CHG_STATE_CHG_RAPID))
+ if(( charge_state == CHG_STATE_CHG_TRICKLE)||( charge_state == CHG_STATE_CHG_RAPID) ||(charge_state == CHG_STATE_CHG_COMPLETE))
ricoh619_set_bits(ricoh619->dev, RICOH619_PWR_REP_CNT,(0x1<<0));//Power OFF
ret = ricoh619_set_bits(ricoh619->dev, RICOH619_PWR_SLP_CNT,(0x1<<0));//Power OFF
if (ret < 0) {
printk("%s,line=%d ricoh619 power off his %08x\n", __func__,__LINE__,val);
*/
ricoh619_set_bits(ricoh619->dev, 0xae, (0x1 <<6));//enable alam_d
+ ricoh619_write(ricoh619->dev, 0x2f, 0x43);//slove ripple
+ ricoh619_write(ricoh619->dev, 0x05, 0x07);//enable clkout2
ricoh619_noe_init(ricoh619);
/***************set PKEY long press time 0sec*******/
if (ricoh619->dev->of_node)
pdata = ricoh619_parse_dt(ricoh619);
- if (gpio_is_valid(pdata->dc_det))
+ if (pdata->dc_det)
ricoh619->dc_det = pdata->dc_det;
/******************************set sleep vol & dcdc mode******************/
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-#define RICOH619_BATTERY_VERSION "RICOH619_BATTERY_VERSION: 2014.03.28"
+#define RICOH619_BATTERY_VERSION "RICOH619_BATTERY_VERSION: 2014.05.06"
#include <linux/kernel.h>
#define DISABLE_CHARGER_TIMER
/* #define ENABLE_FG_KEEP_ON_MODE */
/* #define ENABLE_OCV_TABLE_CALIB */
-
+//#define SUPPORT_USB_CONNECT_TO_ADP
/* FG setting */
#endif
- ret = ricoh619_write(info->dev->parent, VINDAC_REG, 0x01);
+ ret = ricoh619_write(info->dev->parent, VINDAC_REG, 0x03);
if (ret < 0) {
dev_err(info->dev, "Error in writing the control register\n");
return ret;
{
struct ricoh619_battery_info *info
= container_of(work, struct ricoh619_battery_info, irq_work);
- int ret = 0;
+ int ret = 0,i;
uint8_t reg_val;
RICOH_FG_DBG("PMU:%s In\n", __func__);
power_supply_changed(&powerac);
power_supply_changed(&powerusb);
-// mutex_lock(&info->lock);
+ mutex_lock(&info->lock);
if (info->chg_stat1 & 0x01) {
ricoh619_read(info->dev->parent, CHGSTATE_REG, ®_val);
if (reg_val & 0x40) { /* USE ADP */
+ #ifdef SUPPORT_USB_CONNECT_TO_ADP
+ for(i =0;i<60;i++){
+ RICOH_FG_DBG("PMU:%s usb det dwc_otg_check_dpdm =%d\n", __func__,dwc_otg_check_dpdm(0));
+ if(2 == dwc_otg_check_dpdm(0)){
+ /* set adp limit current 2A */
+ ricoh619_write(info->dev->parent, REGISET1_REG, 0x16);
+ /* set charge current 2A */
+ ricoh619_write(info->dev->parent, CHGISET_REG, 0xD3);
+ }
+ else {
+ /* set adp limit current 500ma */
+ ricoh619_write(info->dev->parent, REGISET1_REG, 0x04);
+ /* set charge current 500ma */
+ ricoh619_write(info->dev->parent, CHGISET_REG, 0xc4);
+ }
+ mdelay(10);
+ power_supply_changed(&powerac);
+ power_supply_changed(&powerusb);
+ }
+ #else //support adp and usb chag
if (gpio_is_valid(g_ricoh619->dc_det)){
ret = gpio_request(g_ricoh619->dc_det, "ricoh619_dc_det");
if (ret < 0) {
}
gpio_direction_input(g_ricoh619->dc_det);
ret = gpio_get_value(g_ricoh619->dc_det);
+
if (ret ==0){
/* set adp limit current 2A */
- ricoh619_write(info->dev->parent, REGISET1_REG, 0x13);
+ ricoh619_write(info->dev->parent, REGISET1_REG, 0x16);
/* set charge current 2A */
ricoh619_write(info->dev->parent, CHGISET_REG, 0xD3);
}
}
else{
/* set adp limit current 2A */
- ricoh619_write(info->dev->parent, REGISET1_REG, 0x13);
+ ricoh619_write(info->dev->parent, REGISET1_REG, 0x16);
/* set charge current 2A */
ricoh619_write(info->dev->parent, CHGISET_REG, 0xD3);
}
- }
+ #endif
+ }
else if (reg_val & 0x80) { /* USE USB */
queue_work(info->usb_workqueue, &info->usb_irq_work);
}
"%s(): Error in enable charger mask INT %d\n",
__func__, ret);
-// mutex_unlock(&info->lock);
+ mutex_unlock(&info->lock);
RICOH_FG_DBG("PMU:%s Out\n", __func__);
}
{
struct ricoh619 *ricoh619 = g_ricoh619;
ricoh619_set_bits(ricoh619->dev,REGISET2_REG,(1 << 7)); //set usb limit current when SDP or other mode
+ RICOH_FG_DBG("PMU:%s usb det dwc_otg_check_dpdm =%d\n", __func__,dwc_otg_check_dpdm(0));
if(2 == dwc_otg_check_dpdm(0)){
- ricoh619_write(ricoh619->dev,REGISET2_REG,0x13); //set usb limit current 2A
+ ricoh619_write(ricoh619->dev,REGISET2_REG,0x16); //set usb limit current 2A
ricoh619_write(ricoh619->dev,CHGISET_REG,0xD3); //set charge current 2A
}
else {
{
struct ricoh619_battery_info *info = container_of(work,
struct ricoh619_battery_info, usb_irq_work);
- int ret = 0;
+ int ret = 0,i;
uint8_t sts;
RICOH_FG_DBG("PMU:%s In\n", __func__);
sts &= 0x02;
if (sts) {
+ for(i =0;i<60;i++){
ricoh619_usb_charge_det();
+ mdelay(10);
+ }
} else {
/*********************/
/* No process ?? */
mutex_unlock(&info->lock);
return ret;
}
- if (psy->type == POWER_SUPPLY_TYPE_MAINS)
- val->intval = (status & 0x40 ? 1 : 0);
- else if (psy->type == POWER_SUPPLY_TYPE_USB)
- val->intval = (status & 0x80 ? 1 : 0);
+ #ifdef SUPPORT_USB_CONNECT_TO_ADP
+ if (psy->type == POWER_SUPPLY_TYPE_MAINS)
+ if((2 == dwc_otg_check_dpdm(0)) && (status & 0x40))
+ val->intval =1;
+ else
+ val->intval =0;
+ else if (psy->type == POWER_SUPPLY_TYPE_USB)
+ if((1 == dwc_otg_check_dpdm(0)) && (status & 0x40))
+ val->intval =1;
+ else
+ val->intval =0;
+ #else
+ if (psy->type == POWER_SUPPLY_TYPE_MAINS)
+ val->intval = (status & 0x40 ? 1 : 0);
+ else if (psy->type == POWER_SUPPLY_TYPE_USB)
+ val->intval = (status & 0x80 ? 1 : 0);
+ #endif
break;
/* this setting is same as battery driver of 584 */
case POWER_SUPPLY_PROP_STATUS: