From: Laxman Dewangan <ldewangan@nvidia.com> To: <cw00.choi@samsung.com>, <myungjoo.ham@samsung.com> Cc: <devicetree-discuss@lists.ozlabs.org>, <rob@landley.net>, <linux-doc@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <kishon@ti.com>, <gg@slimlogic.co.uk>, Laxman Dewangan <ldewangan@nvidia.com> Subject: [PATCH V2 2/4] extcon: palmas: enable ID_GND and ID_FLOAT detection always Date: Wed, 10 Jul 2013 11:45:57 +0530 [thread overview] Message-ID: <1373436959-32444-3-git-send-email-ldewangan@nvidia.com> (raw) In-Reply-To: <1373436959-32444-1-git-send-email-ldewangan@nvidia.com> When integrating driver with Tegra platform, it is found that the ID pins get detected only once after booting system and further removal and re-insert does not detect the ID pin. Fixing this issue with enabling interrupt on ID_GND and ID_FLOAT always and clearing the status on LATCH register which actually occurred. Also if interrupt occurs with line status as zero then based on previous status, set the cable state. Add debug prints to display the cable state when any cable insertion/removal happen. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Acked-by: Graeme Gregory <gg@slimlogic.co.uk> --- Changes from V1: - Corrected the print message to have more meaningful. drivers/extcon/extcon-palmas.c | 24 +++++++++++------------- 1 files changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c index b752a0a..33254d9 100644 --- a/drivers/extcon/extcon-palmas.c +++ b/drivers/extcon/extcon-palmas.c @@ -57,6 +57,7 @@ static irqreturn_t palmas_vbus_irq_handler(int irq, void *_palmas_usb) if (palmas_usb->linkstat != PALMAS_USB_STATE_VBUS) { palmas_usb->linkstat = PALMAS_USB_STATE_VBUS; extcon_set_cable_state(&palmas_usb->edev, "USB", true); + dev_info(palmas_usb->dev, "USB cable is attached\n"); } else { dev_dbg(palmas_usb->dev, "Spurious connect event detected\n"); @@ -65,6 +66,7 @@ static irqreturn_t palmas_vbus_irq_handler(int irq, void *_palmas_usb) if (palmas_usb->linkstat == PALMAS_USB_STATE_VBUS) { palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT; extcon_set_cable_state(&palmas_usb->edev, "USB", false); + dev_info(palmas_usb->dev, "USB cable is detached\n"); } else { dev_dbg(palmas_usb->dev, "Spurious disconnect event detected\n"); @@ -84,28 +86,23 @@ static irqreturn_t palmas_id_irq_handler(int irq, void *_palmas_usb) if (set & PALMAS_USB_ID_INT_SRC_ID_GND) { palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, - PALMAS_USB_ID_INT_EN_HI_SET, - PALMAS_USB_ID_INT_EN_HI_SET_ID_FLOAT); - palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, - PALMAS_USB_ID_INT_EN_HI_CLR, - PALMAS_USB_ID_INT_EN_HI_CLR_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, "HOST cable is attached\n"); } else if (set & PALMAS_USB_ID_INT_SRC_ID_FLOAT) { palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, - PALMAS_USB_ID_INT_EN_HI_SET, - PALMAS_USB_ID_INT_EN_HI_SET_ID_GND); - palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, - PALMAS_USB_ID_INT_EN_HI_CLR, - PALMAS_USB_ID_INT_EN_HI_CLR_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); palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT; extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", false); + dev_info(palmas_usb->dev, "HOST cable is detached\n"); + } else if ((palmas_usb->linkstat == PALMAS_USB_STATE_ID) && + (!(set & PALMAS_USB_ID_INT_SRC_ID_GND))) { + palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT; + extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", false); + dev_info(palmas_usb->dev, "HOST cable is detached\n"); } return IRQ_HANDLED; @@ -122,7 +119,8 @@ static void palmas_enable_irq(struct palmas_usb *palmas_usb) palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, PALMAS_USB_ID_INT_EN_HI_SET, - PALMAS_USB_ID_INT_EN_HI_SET_ID_GND); + PALMAS_USB_ID_INT_EN_HI_SET_ID_GND | + PALMAS_USB_ID_INT_EN_HI_SET_ID_FLOAT); palmas_vbus_irq_handler(palmas_usb->vbus_irq, palmas_usb); -- 1.7.1.1
WARNING: multiple messages have this Message-ID (diff)
From: Laxman Dewangan <ldewangan@nvidia.com> To: cw00.choi@samsung.com, myungjoo.ham@samsung.com Cc: devicetree-discuss@lists.ozlabs.org, rob@landley.net, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kishon@ti.com, gg@slimlogic.co.uk, Laxman Dewangan <ldewangan@nvidia.com> Subject: [PATCH V2 2/4] extcon: palmas: enable ID_GND and ID_FLOAT detection always Date: Wed, 10 Jul 2013 11:45:57 +0530 [thread overview] Message-ID: <1373436959-32444-3-git-send-email-ldewangan@nvidia.com> (raw) In-Reply-To: <1373436959-32444-1-git-send-email-ldewangan@nvidia.com> When integrating driver with Tegra platform, it is found that the ID pins get detected only once after booting system and further removal and re-insert does not detect the ID pin. Fixing this issue with enabling interrupt on ID_GND and ID_FLOAT always and clearing the status on LATCH register which actually occurred. Also if interrupt occurs with line status as zero then based on previous status, set the cable state. Add debug prints to display the cable state when any cable insertion/removal happen. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Acked-by: Graeme Gregory <gg@slimlogic.co.uk> --- Changes from V1: - Corrected the print message to have more meaningful. drivers/extcon/extcon-palmas.c | 24 +++++++++++------------- 1 files changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c index b752a0a..33254d9 100644 --- a/drivers/extcon/extcon-palmas.c +++ b/drivers/extcon/extcon-palmas.c @@ -57,6 +57,7 @@ static irqreturn_t palmas_vbus_irq_handler(int irq, void *_palmas_usb) if (palmas_usb->linkstat != PALMAS_USB_STATE_VBUS) { palmas_usb->linkstat = PALMAS_USB_STATE_VBUS; extcon_set_cable_state(&palmas_usb->edev, "USB", true); + dev_info(palmas_usb->dev, "USB cable is attached\n"); } else { dev_dbg(palmas_usb->dev, "Spurious connect event detected\n"); @@ -65,6 +66,7 @@ static irqreturn_t palmas_vbus_irq_handler(int irq, void *_palmas_usb) if (palmas_usb->linkstat == PALMAS_USB_STATE_VBUS) { palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT; extcon_set_cable_state(&palmas_usb->edev, "USB", false); + dev_info(palmas_usb->dev, "USB cable is detached\n"); } else { dev_dbg(palmas_usb->dev, "Spurious disconnect event detected\n"); @@ -84,28 +86,23 @@ static irqreturn_t palmas_id_irq_handler(int irq, void *_palmas_usb) if (set & PALMAS_USB_ID_INT_SRC_ID_GND) { palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, - PALMAS_USB_ID_INT_EN_HI_SET, - PALMAS_USB_ID_INT_EN_HI_SET_ID_FLOAT); - palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, - PALMAS_USB_ID_INT_EN_HI_CLR, - PALMAS_USB_ID_INT_EN_HI_CLR_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, "HOST cable is attached\n"); } else if (set & PALMAS_USB_ID_INT_SRC_ID_FLOAT) { palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, - PALMAS_USB_ID_INT_EN_HI_SET, - PALMAS_USB_ID_INT_EN_HI_SET_ID_GND); - palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, - PALMAS_USB_ID_INT_EN_HI_CLR, - PALMAS_USB_ID_INT_EN_HI_CLR_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); palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT; extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", false); + dev_info(palmas_usb->dev, "HOST cable is detached\n"); + } else if ((palmas_usb->linkstat == PALMAS_USB_STATE_ID) && + (!(set & PALMAS_USB_ID_INT_SRC_ID_GND))) { + palmas_usb->linkstat = PALMAS_USB_STATE_DISCONNECT; + extcon_set_cable_state(&palmas_usb->edev, "USB-HOST", false); + dev_info(palmas_usb->dev, "HOST cable is detached\n"); } return IRQ_HANDLED; @@ -122,7 +119,8 @@ static void palmas_enable_irq(struct palmas_usb *palmas_usb) palmas_write(palmas_usb->palmas, PALMAS_USB_OTG_BASE, PALMAS_USB_ID_INT_EN_HI_SET, - PALMAS_USB_ID_INT_EN_HI_SET_ID_GND); + PALMAS_USB_ID_INT_EN_HI_SET_ID_GND | + PALMAS_USB_ID_INT_EN_HI_SET_ID_FLOAT); palmas_vbus_irq_handler(palmas_usb->vbus_irq, palmas_usb); -- 1.7.1.1
next prev parent reply other threads:[~2013-07-10 6:08 UTC|newest] Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-07-10 6:15 [PATCH V2 0/4] extcon: palmas: clean-up/fixes and suspend/resume susupport Laxman Dewangan 2013-07-10 6:15 ` Laxman Dewangan 2013-07-10 6:15 ` [PATCH V2 1/4] extcon: palmas: remove unused member from palams_usb structure Laxman Dewangan 2013-07-10 6:15 ` Laxman Dewangan 2013-07-10 6:15 ` Laxman Dewangan [this message] 2013-07-10 6:15 ` [PATCH V2 2/4] extcon: palmas: enable ID_GND and ID_FLOAT detection always Laxman Dewangan 2013-07-10 7:02 ` Chanwoo Choi 2013-07-10 7:16 ` Laxman Dewangan 2013-07-10 7:16 ` Laxman Dewangan 2013-07-10 6:15 ` [PATCH V2 3/4] extcon: palams: add support for suspend/resume Laxman Dewangan 2013-07-10 6:15 ` Laxman Dewangan 2013-07-10 6:15 ` [PATCH V2 4/4] extcon: palmas: Option to disable ID/VBUS detection based on platform Laxman Dewangan 2013-07-10 6:15 ` Laxman Dewangan 2013-07-10 6:55 ` Chanwoo Choi 2013-07-10 7:13 ` Laxman Dewangan 2013-07-10 7:13 ` Laxman Dewangan 2013-07-10 7:34 ` Chanwoo Choi 2013-07-10 7:34 ` Chanwoo Choi 2013-07-10 8:42 ` Laxman Dewangan 2013-07-10 8:42 ` Laxman Dewangan 2013-07-10 6:57 ` [PATCH V2 0/4] extcon: palmas: clean-up/fixes and suspend/resume susupport Chanwoo Choi 2013-07-10 7:14 ` Laxman Dewangan 2013-07-10 7:14 ` Laxman Dewangan
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1373436959-32444-3-git-send-email-ldewangan@nvidia.com \ --to=ldewangan@nvidia.com \ --cc=cw00.choi@samsung.com \ --cc=devicetree-discuss@lists.ozlabs.org \ --cc=gg@slimlogic.co.uk \ --cc=kishon@ti.com \ --cc=linux-doc@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=myungjoo.ham@samsung.com \ --cc=rob@landley.net \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.