imx233: fix usb_detect() to be consistent with vbus detection

The STMP3700 has unreliable vbusvalid irq so we need to use
vdd5gtvddio. Therefore, using the vbusvalid bit produces
inconsistent results between events and detect. Fix that
by making power handle all the usb detect stuff.

Change-Id: Ic521b2f6677602e184fe46352c5359f4b4ba8d56
This commit is contained in:
Amaury Pouly 2013-10-20 22:39:39 +02:00
parent 187017bad1
commit 46416c619d
3 changed files with 11 additions and 1 deletions

View file

@ -84,6 +84,15 @@ static struct current_step_bit_t g_4p2_charge_limit_bits[] =
#define USE_VBUSVALID #define USE_VBUSVALID
#endif #endif
bool imx233_power_usb_detect(void)
{
#ifdef USE_VBUSVALID
return BF_RD(POWER_STS, VBUSVALID);
#else
return BF_RD(POWER_STS, VDD5V_GT_VDDIO);
#endif
}
void INT_VDD5V(void) void INT_VDD5V(void)
{ {
#ifdef USE_VBUSVALID #ifdef USE_VBUSVALID

View file

@ -82,6 +82,7 @@ void imx233_power_init(void);
void imx233_power_set_charge_current(unsigned current); /* in mA */ void imx233_power_set_charge_current(unsigned current); /* in mA */
void imx233_power_set_stop_current(unsigned current); /* in mA */ void imx233_power_set_stop_current(unsigned current); /* in mA */
void imx233_power_enable_batadj(bool enable); void imx233_power_enable_batadj(bool enable);
bool imx233_power_usb_detect(void);
enum imx233_regulator_t enum imx233_regulator_t
{ {

View file

@ -61,7 +61,7 @@ void usb_init_device(void)
int usb_detect(void) int usb_detect(void)
{ {
return BF_RD(POWER_STS, VBUSVALID) ? USB_INSERTED : USB_EXTRACTED; return imx233_power_usb_detect() ? USB_INSERTED : USB_EXTRACTED;
} }
void usb_enable(bool on) void usb_enable(bool on)