mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 03:40:35 +09:00
rk31:pmu:rt5025:support AC & usb charger
This commit is contained in:
@@ -424,8 +424,8 @@ static u8 jeita_scalar[8] = { 0x30, 0x2B, 0x25, 0x20, 0x15, 0x10, 0x10, 0x0D };
|
||||
//cc unit: xxx mA
|
||||
static int jeita_temp_cc[][5] = {{ 500, 500, 500, 500, 500}, // not plugin
|
||||
{ 0 , 500, 500, 500, 0}, // normal USB
|
||||
{ 0, 500, 1000, 500, 0}, // USB charger
|
||||
{ 0, 500, 1000, 500, 0}}; // AC Adapter
|
||||
{ 0, 1000, 2000, 1000, 0}, // USB charger
|
||||
{ 0, 1000, 2000, 1000, 0}}; // AC Adapter
|
||||
//cv unit: xxx mV
|
||||
static int jeita_temp_cv[][5] = {{ 4200, 4200, 4200, 4200, 4200}, // not plugin
|
||||
{ 4200, 4200, 4200, 4200, 4200}, // normal USB
|
||||
|
||||
@@ -95,7 +95,7 @@ static void rt5025_work_func(struct work_struct *work)
|
||||
chg_event = irq_stat[0]<<16 | irq_stat[1]<<8 | irq_stat[2];
|
||||
pwr_event = irq_stat[3]<<8 | irq_stat[4];
|
||||
#ifdef CONFIG_POWER_RT5025
|
||||
if ((chg_event & CHARGER_DETECT_MASK) && ii->chip->power_info->otg_en == 0)
|
||||
if ((chg_event & CHARGER_DETECT_MASK))
|
||||
{
|
||||
if (chg_event & CHG_EVENT_CHTERMI)
|
||||
{
|
||||
|
||||
22
drivers/power/rt5025-power.c
Executable file → Normal file
22
drivers/power/rt5025-power.c
Executable file → Normal file
@@ -226,19 +226,33 @@ int rt5025_power_charge_detect(struct rt5025_power_info *info)
|
||||
chgstatval = ret;
|
||||
RTINFO("chgstat = 0x%02x\n", chgstatval);
|
||||
|
||||
if (info->otg_en)
|
||||
{
|
||||
ret = rt5025_set_bits(info->i2c, RT5025_REG_CHGCTL2, RT5025_CHGBUCKEN_MASK);
|
||||
msleep(100);
|
||||
}
|
||||
|
||||
new_acval = (chgstatval&RT5025_CHG_ACONLINE)>>RT5025_CHG_ACSHIFT;
|
||||
if (old_acval != new_acval)
|
||||
{
|
||||
info->ac_online = new_acval;
|
||||
power_supply_changed(&info->ac);
|
||||
}
|
||||
new_usbval = (chgstatval&RT5025_CHG_USBONLINE)>>RT5025_CHG_USBSHIFT;
|
||||
|
||||
new_usbval = (info->otg_en? \
|
||||
0:(chgstatval&RT5025_CHG_USBONLINE)>>RT5025_CHG_USBSHIFT);
|
||||
if (old_usbval != new_usbval)
|
||||
{
|
||||
info->usb_online = new_usbval;
|
||||
power_supply_changed(&info->usb);
|
||||
}
|
||||
|
||||
if (info->otg_en && new_acval == 0)
|
||||
{
|
||||
ret = rt5025_clr_bits(info->i2c, RT5025_REG_CHGCTL2, RT5025_CHGBUCKEN_MASK);
|
||||
msleep(100);
|
||||
}
|
||||
|
||||
if (old_acval != new_acval || old_usbval != new_usbval)
|
||||
schedule_delayed_work(&info->usb_detect_work, 0); //no delay
|
||||
|
||||
@@ -308,7 +322,7 @@ static void usb_detect_work_func(struct work_struct *work)
|
||||
mutex_lock(&pi->var_lock);
|
||||
if (pi->ac_online)
|
||||
{
|
||||
rt5025_set_charging_current(pi->i2c, 1000);
|
||||
rt5025_set_charging_current(pi->i2c, 2000);
|
||||
rt5025_notify_charging_cable(pi->chip->jeita_info, JEITA_AC_ADAPTER);
|
||||
pi->usb_cnt = 0;
|
||||
}
|
||||
@@ -318,13 +332,13 @@ static void usb_detect_work_func(struct work_struct *work)
|
||||
switch(dwc_vbus_status())
|
||||
{
|
||||
case 2: // USB Wall charger
|
||||
rt5025_set_charging_current(pi->i2c, 1000);
|
||||
rt5025_set_charging_current(pi->i2c, 2000);
|
||||
rt5025_notify_charging_cable(pi->chip->jeita_info, JEITA_USB_TA);
|
||||
RTINFO("rt5025: detect usb wall charger\n");
|
||||
break;
|
||||
case 1: //normal USB
|
||||
default:
|
||||
rt5025_set_charging_current(pi->i2c, 500);
|
||||
rt5025_set_charging_current(pi->i2c, 2000);
|
||||
rt5025_notify_charging_cable(pi->chip->jeita_info, JEITA_NORMAL_USB);
|
||||
RTINFO("rt5025: detect normal usb\n");
|
||||
break;
|
||||
|
||||
@@ -349,7 +349,7 @@ static void thermal_reg_work_func(struct work_struct *work)
|
||||
swji->dec_current = 300;
|
||||
break;
|
||||
case 2:
|
||||
swji->dec_current = 1000;
|
||||
swji->dec_current = 800;
|
||||
break;
|
||||
}
|
||||
swji->cur_therm_region = therm_region;
|
||||
@@ -430,10 +430,10 @@ static int __devexit rt5025_swjeita_remove(struct platform_device *pdev)
|
||||
static int rt5025_swjeita_suspend(struct platform_device *pdev, pm_message_t state)
|
||||
{
|
||||
struct rt5025_swjeita_info *swji = platform_get_drvdata(pdev);
|
||||
swji->cur_therm_region = swji->dec_current = 0;
|
||||
rt5025_notify_charging_cable(swji, swji->cur_cable);
|
||||
swji->suspend = 1;
|
||||
cancel_delayed_work_sync(&swji->thermal_reg_work);
|
||||
swji->cur_therm_region = swji->dec_current = 0;
|
||||
rt5025_notify_charging_cable(swji, swji->cur_cable);
|
||||
RTINFO("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <linux/android_alarm.h>
|
||||
|
||||
#define RT5025_DEVICE_NAME "RT5025"
|
||||
#define RT5025_DRV_VER "1.0.4_R"
|
||||
#define RT5025_DRV_VER "1.0.5_R"
|
||||
|
||||
enum {
|
||||
RT5025_RSTDELAY1_100MS,
|
||||
|
||||
@@ -31,9 +31,16 @@
|
||||
#define RT5025_CHGSTAT_SHIFT 4
|
||||
#define RT5025_CHGSTAT_UNKNOWN 0x04
|
||||
|
||||
#ifdef CONFIG_RT5025_SUPPORT_ACUSB_DUALIN
|
||||
#define RT5025_CHG_ACONLINE 0x02
|
||||
#define RT5025_CHG_ACSHIFT 1
|
||||
#define RT5025_CHG_USBONLINE 0x01
|
||||
#define RT5025_CHG_USBSHIFT 0
|
||||
#else
|
||||
#define RT5025_CHG_ACONLINE 0x01
|
||||
#define RT5025_CHG_ACSHIFT 0
|
||||
#define RT5025_CHG_USBONLINE 0x02
|
||||
#define RT5025_CHG_USBSHIFT 1
|
||||
#endif /* CONFIG_RT5025_SUPPORT_ACUSB_DUALIN */
|
||||
|
||||
#endif /* #ifndef __LINUX_RT5025_POWER_H */
|
||||
|
||||
Reference in New Issue
Block a user