mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 12:42:02 +00:00
extcon: palmas: Handle ID interrupt properly using USB_ID_INT_SRC
Always cross check with the ID state and the source of interrupt. Also add a case in which ID Source is ID_GND but LATCH state is set wrongly. This uses the previous Link stat to determine the new state. Signed-off-by: George Cherian <george.cherian@ti.com> Acked-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
This commit is contained in:
parent
5fbc77d6eb
commit
b7d2d5be3c
@ -78,20 +78,24 @@ static irqreturn_t palmas_vbus_irq_handler(int irq, void *_palmas_usb)
|
||||
|
||||
static irqreturn_t palmas_id_irq_handler(int irq, void *_palmas_usb)
|
||||
{
|
||||
unsigned int set;
|
||||
unsigned int set, id_src;
|
||||
struct palmas_usb *palmas_usb = _palmas_usb;
|
||||
|
||||
palmas_read(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
|
||||
PALMAS_USB_ID_INT_LATCH_SET, &set);
|
||||
palmas_read(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
|
||||
PALMAS_USB_ID_INT_SRC, &id_src);
|
||||
|
||||
if (set & PALMAS_USB_ID_INT_SRC_ID_GND) {
|
||||
if ((set & PALMAS_USB_ID_INT_SRC_ID_GND) &&
|
||||
(id_src & PALMAS_USB_ID_INT_SRC_ID_GND)) {
|
||||
palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
|
||||
PALMAS_USB_ID_INT_LATCH_CLR,
|
||||
PALMAS_USB_ID_INT_EN_HI_CLR_ID_GND);
|
||||
palmas_usb->linkstat = PALMAS_USB_STATE_ID;
|
||||
extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", true);
|
||||
dev_info(palmas_usb->dev, "USB-HOST cable is attached\n");
|
||||
} else if (set & PALMAS_USB_ID_INT_SRC_ID_FLOAT) {
|
||||
} else if ((set & PALMAS_USB_ID_INT_SRC_ID_FLOAT) &&
|
||||
(id_src & PALMAS_USB_ID_INT_SRC_ID_FLOAT)) {
|
||||
palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE,
|
||||
PALMAS_USB_ID_INT_LATCH_CLR,
|
||||
PALMAS_USB_ID_INT_EN_HI_CLR_ID_FLOAT);
|
||||
@ -103,6 +107,11 @@ static irqreturn_t palmas_id_irq_handler(int irq, void *_palmas_usb)
|
||||
palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT;
|
||||
extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", false);
|
||||
dev_info(palmas_usb->dev, "USB-HOST cable is detached\n");
|
||||
} else if ((palmas_usb->linkstat == PALMAS_USB_STATE_DISCONNECT) &&
|
||||
(id_src & PALMAS_USB_ID_INT_SRC_ID_GND)) {
|
||||
palmas_usb->linkstat = PALMAS_USB_STATE_ID;
|
||||
extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", true);
|
||||
dev_info(palmas_usb->dev, " USB-HOST cable is attached\n");
|
||||
}
|
||||
|
||||
return IRQ_HANDLED;
|
||||
|
Loading…
Reference in New Issue
Block a user