From patchwork Mon Aug 17 06:59:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 253711 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B2A4C433E3 for ; Mon, 17 Aug 2020 07:00:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 52FA62072D for ; Mon, 17 Aug 2020 07:00:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597647641; bh=5VABsIIOTga9jxbpTZ9xoI/0EbnuZPCPq7dvahWwSbw=; h=From:To:Subject:Date:In-Reply-To:References:List-ID:From; b=jwSDDjdcyb1ULbiuB/fIj8w/ktZrm9bShMeovV1M1aexBYrVEZ39c9JhdJvI/AgbZ 1LpGCXJcVDBSL6DZQdXKYThxQC9tMtajeSjZ+Kh/duOM4FtdBJisFZ0JpIzCxV8Ktf tFG/gH9Zv53Tbz0AbyPNrsF0nasNKxXATutTpNow= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726422AbgHQHAg (ORCPT ); Mon, 17 Aug 2020 03:00:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:41392 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726302AbgHQHAX (ORCPT ); Mon, 17 Aug 2020 03:00:23 -0400 Received: from localhost.localdomain (unknown [194.230.155.242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EC5782080D; Mon, 17 Aug 2020 07:00:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597647622; bh=5VABsIIOTga9jxbpTZ9xoI/0EbnuZPCPq7dvahWwSbw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=C4rOfHeCVb8g9+6DNe2dZcMKSyRMbORjqzPBWdTvo2H76cQb7H3HLZ63WjbP111dG EZyBYl/tFxxPC8x1D9R9gVVIBoLZXhqcrvQ3lAkeWLC9wWuwkEklLaB8gRc6w6P7bW zx1qbf1bx150JBOcmv3gO9I26XrXIDQDf5PUzDAA= From: Krzysztof Kozlowski To: MyungJoo Ham , Chanwoo Choi , Rob Herring , Krzysztof Kozlowski , Vijai Kumar K , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v2 02/13] dt-bindings: extcon: ptn5150: Use generic "interrupts" property Date: Mon, 17 Aug 2020 08:59:58 +0200 Message-Id: <20200817070009.4631-3-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200817070009.4631-1-krzk@kernel.org> References: <20200817070009.4631-1-krzk@kernel.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Interrupts do not have to be always GPIO based so instead of expecting "int-gpios" property and converting the GPIO to an interrupt, just accept any interrupt via generic "interrupts" property. Mark the old "int-gpios" as deprecated. Signed-off-by: Krzysztof Kozlowski --- .../devicetree/bindings/extcon/extcon-ptn5150.yaml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml b/Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml index f6316f12028b..1ddc97db3e61 100644 --- a/Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml +++ b/Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml @@ -19,8 +19,13 @@ properties: const: nxp,ptn5150 int-gpios: + deprecated: true description: GPIO pin (input) connected to the PTN5150's INTB pin. + Use "interrupts" instead. + + interrupts: + maxItems: 1 reg: maxItems: 1 @@ -31,7 +36,7 @@ properties: required: - compatible - - int-gpios + - interrupts - reg - vbus-gpios @@ -40,6 +45,7 @@ additionalProperties: false examples: - | #include + #include i2c { #address-cells = <1>; #size-cells = <0>; @@ -47,7 +53,8 @@ examples: ptn5150@1d { compatible = "nxp,ptn5150"; reg = <0x1d>; - int-gpios = <&msmgpio 78 GPIO_ACTIVE_HIGH>; + interrupt-parent = <&msmgpio>; + interrupts = <78 IRQ_TYPE_LEVEL_HIGH>; vbus-gpios = <&msmgpio 148 GPIO_ACTIVE_HIGH>; }; }; From patchwork Mon Aug 17 07:00:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 253704 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B0BAC433DF for ; Mon, 17 Aug 2020 07:03:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CB29D20772 for ; Mon, 17 Aug 2020 07:03:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597647811; bh=PYY8uXXlmytuiAxIl2R7A+XdZTSPkLshPeJXisdTWNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=osrArw3rN5uPzU5yyhlF19N5J47gSRT28lWNRvvcX8Y532pSO8wjISS1G4QiY09H2 gBs5hiuOYTakobVur13VQljLFUWMaGklX2h1XDa9ZmbAMuI0sO3qMYl+KODUR+BWvC 91HY1eq8S1IQDCVSNHCJciOBz/pMh6k8OfaLXSyU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726646AbgHQHDa (ORCPT ); Mon, 17 Aug 2020 03:03:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:41626 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726341AbgHQHA1 (ORCPT ); Mon, 17 Aug 2020 03:00:27 -0400 Received: from localhost.localdomain (unknown [194.230.155.242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EBC5F2072D; Mon, 17 Aug 2020 07:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597647626; bh=PYY8uXXlmytuiAxIl2R7A+XdZTSPkLshPeJXisdTWNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sNU0etOLQpWcb3qMjipDoDxDj9JLuaaIOnZ8yUNr38mQuFXWCJrdNvSYDcSIJ/7DV 3PgKsoksU/zqkRnRaB7roOJqpU7csaHTLwzLuZEUguwDtmCaTVBXAnLomgt7KWOTno Skka53gMXQxzddzNfZFRJWHtXluIukgyR62ZdCGk= From: Krzysztof Kozlowski To: MyungJoo Ham , Chanwoo Choi , Rob Herring , Krzysztof Kozlowski , Vijai Kumar K , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: stable@vger.kernel.org Subject: [PATCH v2 04/13] extcon: ptn5150: Fix usage of atomic GPIO with sleeping GPIO chips Date: Mon, 17 Aug 2020 09:00:00 +0200 Message-Id: <20200817070009.4631-5-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200817070009.4631-1-krzk@kernel.org> References: <20200817070009.4631-1-krzk@kernel.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The driver uses atomic version of gpiod_set_value() without any real reason. It is called in a workqueue under mutex so it could sleep there. Changing it to "can_sleep" flavor allows to use the driver with all GPIO chips. Fixes: 4ed754de2d66 ("extcon: Add support for ptn5150 extcon driver") Cc: Signed-off-by: Krzysztof Kozlowski --- drivers/extcon/extcon-ptn5150.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c index d1c997599390..5f5252752644 100644 --- a/drivers/extcon/extcon-ptn5150.c +++ b/drivers/extcon/extcon-ptn5150.c @@ -127,7 +127,7 @@ static void ptn5150_irq_work(struct work_struct *work) case PTN5150_DFP_ATTACHED: extcon_set_state_sync(info->edev, EXTCON_USB_HOST, false); - gpiod_set_value(info->vbus_gpiod, 0); + gpiod_set_value_cansleep(info->vbus_gpiod, 0); extcon_set_state_sync(info->edev, EXTCON_USB, true); break; @@ -138,9 +138,9 @@ static void ptn5150_irq_work(struct work_struct *work) PTN5150_REG_CC_VBUS_DETECTION_MASK) >> PTN5150_REG_CC_VBUS_DETECTION_SHIFT); if (vbus) - gpiod_set_value(info->vbus_gpiod, 0); + gpiod_set_value_cansleep(info->vbus_gpiod, 0); else - gpiod_set_value(info->vbus_gpiod, 1); + gpiod_set_value_cansleep(info->vbus_gpiod, 1); extcon_set_state_sync(info->edev, EXTCON_USB_HOST, true); @@ -156,7 +156,7 @@ static void ptn5150_irq_work(struct work_struct *work) EXTCON_USB_HOST, false); extcon_set_state_sync(info->edev, EXTCON_USB, false); - gpiod_set_value(info->vbus_gpiod, 0); + gpiod_set_value_cansleep(info->vbus_gpiod, 0); } } From patchwork Mon Aug 17 07:00:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 253705 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C3FBC433E3 for ; Mon, 17 Aug 2020 07:03:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E0D5D20758 for ; Mon, 17 Aug 2020 07:03:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597647810; bh=cZA9ZUARN+utcYkCJWoSAM3zaWPeBpxOmpgTjJgh5s8=; h=From:To:Subject:Date:In-Reply-To:References:List-ID:From; b=keVtJXaqdHr8f9To4B9xxUUj/vFrH48yDn5blELB64DNpXJHJMmab1j53E3DCXznE I4kocpXlRqx7ABmBVEJHCZbyGMwK/bVQo9YglGRiF8ENQxTf4lTjl9lXMYN17dWBGV vysC7AzUZ7/C/UHpnf+eKejBDJmRnvTbtlo1A2H4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726916AbgHQHDO (ORCPT ); Mon, 17 Aug 2020 03:03:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:41730 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726349AbgHQHA3 (ORCPT ); Mon, 17 Aug 2020 03:00:29 -0400 Received: from localhost.localdomain (unknown [194.230.155.242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 22A2A207FB; Mon, 17 Aug 2020 07:00:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597647628; bh=cZA9ZUARN+utcYkCJWoSAM3zaWPeBpxOmpgTjJgh5s8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=tD4Cr2JesNZLkoLInAuT7zRPnlGs2KbpxEfpPfVFYqhs8MJ/zpMI7culDGiYnTT6v XzNbsKqHjbMt39ifPAlL0qdmVqmakqTLQKo9wIHmw2kvf/k1PO/Ikbvf1OYBGb9eyW RIG5syYrs+k6kw+ToWuVQPRr3YuC42EM8Qlpy9X8= From: Krzysztof Kozlowski To: MyungJoo Ham , Chanwoo Choi , Rob Herring , Krzysztof Kozlowski , Vijai Kumar K , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v2 05/13] extcon: ptn5150: Use generic "interrupts" property Date: Mon, 17 Aug 2020 09:00:01 +0200 Message-Id: <20200817070009.4631-6-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200817070009.4631-1-krzk@kernel.org> References: <20200817070009.4631-1-krzk@kernel.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Interrupts do not have to be always GPIO based so instead of expecting "int-gpios" property and converting the GPIO to an interrupt, just accept any interrupt via generic "interrupts" property. Keep support for old "int-gpios" for backward compatibility. Signed-off-by: Krzysztof Kozlowski --- drivers/extcon/extcon-ptn5150.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c index 5f5252752644..12e52ddbd77e 100644 --- a/drivers/extcon/extcon-ptn5150.c +++ b/drivers/extcon/extcon-ptn5150.c @@ -239,11 +239,6 @@ static int ptn5150_i2c_probe(struct i2c_client *i2c, info->dev = &i2c->dev; info->i2c = i2c; - info->int_gpiod = devm_gpiod_get(&i2c->dev, "int", GPIOD_IN); - if (IS_ERR(info->int_gpiod)) { - dev_err(dev, "failed to get INT GPIO\n"); - return PTR_ERR(info->int_gpiod); - } info->vbus_gpiod = devm_gpiod_get(&i2c->dev, "vbus", GPIOD_IN); if (IS_ERR(info->vbus_gpiod)) { dev_err(dev, "failed to get VBUS GPIO\n"); @@ -267,22 +262,30 @@ static int ptn5150_i2c_probe(struct i2c_client *i2c, return ret; } - if (info->int_gpiod) { + if (i2c->irq > 0) { + info->irq = i2c->irq; + } else { + info->int_gpiod = devm_gpiod_get(&i2c->dev, "int", GPIOD_IN); + if (IS_ERR(info->int_gpiod)) { + dev_err(dev, "failed to get INT GPIO\n"); + return PTR_ERR(info->int_gpiod); + } + info->irq = gpiod_to_irq(info->int_gpiod); if (info->irq < 0) { dev_err(dev, "failed to get INTB IRQ\n"); return info->irq; } + } - ret = devm_request_threaded_irq(dev, info->irq, NULL, - ptn5150_irq_handler, - IRQF_TRIGGER_FALLING | - IRQF_ONESHOT, - i2c->name, info); - if (ret < 0) { - dev_err(dev, "failed to request handler for INTB IRQ\n"); - return ret; - } + ret = devm_request_threaded_irq(dev, info->irq, NULL, + ptn5150_irq_handler, + IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, + i2c->name, info); + if (ret < 0) { + dev_err(dev, "failed to request handler for INTB IRQ\n"); + return ret; } /* Allocate extcon device */ From patchwork Mon Aug 17 07:00:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 253706 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59CF6C433DF for ; Mon, 17 Aug 2020 07:03:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2EBFE2072D for ; Mon, 17 Aug 2020 07:03:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597647794; bh=sqhbsGHDKmGnWrxF7WKJvCjHIGno9ziu+Usjt7jxW2w=; h=From:To:Subject:Date:In-Reply-To:References:List-ID:From; b=dUA6dKOUTO/0ZgwHtiVw2z9yDuh1r20Hscm8MlLV9EKELgqQrghmRHZ2S2pqxXrF9 ccy+Dr/xlN4k6URTYHApjk2Og4ymPOV1Sv2q5OIXbR/M0hPRqh9vAbw5/+xLBmaaYA 1znNm0CX9hViAzk+7FXCiKWdBZ2wUEmQxkpT2pBM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726482AbgHQHDN (ORCPT ); Mon, 17 Aug 2020 03:03:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:42130 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726371AbgHQHAf (ORCPT ); Mon, 17 Aug 2020 03:00:35 -0400 Received: from localhost.localdomain (unknown [194.230.155.242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0E01320829; Mon, 17 Aug 2020 07:00:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597647634; bh=sqhbsGHDKmGnWrxF7WKJvCjHIGno9ziu+Usjt7jxW2w=; h=From:To:Subject:Date:In-Reply-To:References:From; b=DfTDouap3ZK0yLSxQoNUXtQkQNmpvBwpl2lPr8fHjIk6C/beSVXSs9iHDfzg5sgqE 3YCqACD62Bv3xUK09VpIcUkV2x3JjJteNT7p3BtpLUTK3HROZmc5i9Fee02oqq/fI0 t7ZOGNFHovGrjZl9mvu0dkHCKyu/N+DAtxghSsMs= From: Krzysztof Kozlowski To: MyungJoo Ham , Chanwoo Choi , Rob Herring , Krzysztof Kozlowski , Vijai Kumar K , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v2 08/13] extcon: ptn5150: Check current USB mode when probing Date: Mon, 17 Aug 2020 09:00:04 +0200 Message-Id: <20200817070009.4631-9-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200817070009.4631-1-krzk@kernel.org> References: <20200817070009.4631-1-krzk@kernel.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org When machine boots up, the USB could be already in OTG mode. In such case there will be no interrupt coming to ptn5150 device and driver will report default state of nothing connected. Detection of USB connection would happen on first unplug of the cable. Factor out code for checking current connection mode and call it right after probe so the existing USB mode will be properly reported. Signed-off-by: Krzysztof Kozlowski --- Changes since v1: 1. Remove copied mutex_unlock --- drivers/extcon/extcon-ptn5150.c | 92 ++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 43 deletions(-) diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c index a57fef384a29..342973726565 100644 --- a/drivers/extcon/extcon-ptn5150.c +++ b/drivers/extcon/extcon-ptn5150.c @@ -5,6 +5,7 @@ // Based on extcon-sm5502.c driver // Copyright (c) 2018-2019 by Vijai Kumar K // Author: Vijai Kumar K +// Copyright (c) 2020 Krzysztof Kozlowski #include #include @@ -83,12 +84,49 @@ static const struct regmap_config ptn5150_regmap_config = { .max_register = PTN5150_REG_END, }; +static void ptn5150_check_state(struct ptn5150_info *info) +{ + unsigned int port_status, reg_data, vbus; + int ret; + + ret = regmap_read(info->regmap, PTN5150_REG_CC_STATUS, ®_data); + if (ret) { + dev_err(info->dev, "failed to read CC STATUS %d\n", ret); + return; + } + + port_status = ((reg_data & + PTN5150_REG_CC_PORT_ATTACHMENT_MASK) >> + PTN5150_REG_CC_PORT_ATTACHMENT_SHIFT); + + switch (port_status) { + case PTN5150_DFP_ATTACHED: + extcon_set_state_sync(info->edev, EXTCON_USB_HOST, false); + gpiod_set_value_cansleep(info->vbus_gpiod, 0); + extcon_set_state_sync(info->edev, EXTCON_USB, true); + break; + case PTN5150_UFP_ATTACHED: + extcon_set_state_sync(info->edev, EXTCON_USB, false); + vbus = ((reg_data & PTN5150_REG_CC_VBUS_DETECTION_MASK) >> + PTN5150_REG_CC_VBUS_DETECTION_SHIFT); + if (vbus) + gpiod_set_value_cansleep(info->vbus_gpiod, 0); + else + gpiod_set_value_cansleep(info->vbus_gpiod, 1); + + extcon_set_state_sync(info->edev, EXTCON_USB_HOST, true); + break; + default: + dev_err(info->dev, "Unknown Port status : %x\n", port_status); + break; + } +} + static void ptn5150_irq_work(struct work_struct *work) { struct ptn5150_info *info = container_of(work, struct ptn5150_info, irq_work); int ret = 0; - unsigned int reg_data; unsigned int int_status; if (!info->edev) @@ -96,13 +134,6 @@ static void ptn5150_irq_work(struct work_struct *work) mutex_lock(&info->mutex); - ret = regmap_read(info->regmap, PTN5150_REG_CC_STATUS, ®_data); - if (ret) { - dev_err(info->dev, "failed to read CC STATUS %d\n", ret); - mutex_unlock(&info->mutex); - return; - } - /* Clear interrupt. Read would clear the register */ ret = regmap_read(info->regmap, PTN5150_REG_INT_STATUS, &int_status); if (ret) { @@ -116,41 +147,7 @@ static void ptn5150_irq_work(struct work_struct *work) cable_attach = int_status & PTN5150_REG_INT_CABLE_ATTACH_MASK; if (cable_attach) { - unsigned int port_status; - unsigned int vbus; - - port_status = ((reg_data & - PTN5150_REG_CC_PORT_ATTACHMENT_MASK) >> - PTN5150_REG_CC_PORT_ATTACHMENT_SHIFT); - - switch (port_status) { - case PTN5150_DFP_ATTACHED: - extcon_set_state_sync(info->edev, - EXTCON_USB_HOST, false); - gpiod_set_value_cansleep(info->vbus_gpiod, 0); - extcon_set_state_sync(info->edev, EXTCON_USB, - true); - break; - case PTN5150_UFP_ATTACHED: - extcon_set_state_sync(info->edev, EXTCON_USB, - false); - vbus = ((reg_data & - PTN5150_REG_CC_VBUS_DETECTION_MASK) >> - PTN5150_REG_CC_VBUS_DETECTION_SHIFT); - if (vbus) - gpiod_set_value_cansleep(info->vbus_gpiod, 0); - else - gpiod_set_value_cansleep(info->vbus_gpiod, 1); - - extcon_set_state_sync(info->edev, - EXTCON_USB_HOST, true); - break; - default: - dev_err(info->dev, - "Unknown Port status : %x\n", - port_status); - break; - } + ptn5150_check_state(info); } else { extcon_set_state_sync(info->edev, EXTCON_USB_HOST, false); @@ -302,6 +299,14 @@ static int ptn5150_i2c_probe(struct i2c_client *i2c, if (ret) return -EINVAL; + /* + * Update current extcon state if for example OTG connection was there + * before the probe + */ + mutex_lock(&info->mutex); + ptn5150_check_state(info); + mutex_unlock(&info->mutex); + return 0; } @@ -334,4 +339,5 @@ subsys_initcall(ptn5150_i2c_init); MODULE_DESCRIPTION("NXP PTN5150 CC logic Extcon driver"); MODULE_AUTHOR("Vijai Kumar K "); +MODULE_AUTHOR("Krzysztof Kozlowski "); MODULE_LICENSE("GPL v2"); From patchwork Mon Aug 17 07:00:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 253710 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E04ADC433DF for ; Mon, 17 Aug 2020 07:00:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B05692080D for ; Mon, 17 Aug 2020 07:00:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597647657; bh=VLk66Gcfw65cI8H3iqrAuNUGmvgQ8gBD623S8yCZ7BA=; h=From:To:Subject:Date:In-Reply-To:References:List-ID:From; b=gBCKAKHMbZ1SEMK/NMKvrIwoF+5RYUeh3ORt4t6BGNIqPGF3lBkA5AQArRN0ylybA G7MG+3We19hVKKQZa0SpKCRKvzxCqTjchovYG+brXA/4aKG3h3dToAEngFOmugNCC5 eRsd5VJw8fM18FaHI10c1MbtP4cR9Fo2qHVC63cU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726648AbgHQHAt (ORCPT ); Mon, 17 Aug 2020 03:00:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:42356 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726451AbgHQHAi (ORCPT ); Mon, 17 Aug 2020 03:00:38 -0400 Received: from localhost.localdomain (unknown [194.230.155.242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 04DC7207FF; Mon, 17 Aug 2020 07:00:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597647638; bh=VLk66Gcfw65cI8H3iqrAuNUGmvgQ8gBD623S8yCZ7BA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=TMsdTpZyCmmCaNBe5kUZzOG7Kl+Pj8ROVMSo8VBf6qpyWMlqG4P1H7rsk8AAH+w2M 77ax78tJsIjeuEmJnMlfcxjUvFz/iiew/dNqq/D6TxVynX4hVNfb5TbjVLyKbDW0gr IfbvwsLVyTmVEcROq9ZnEY33UvLmeXhLaqR/LgQA= From: Krzysztof Kozlowski To: MyungJoo Ham , Chanwoo Choi , Rob Herring , Krzysztof Kozlowski , Vijai Kumar K , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v2 10/13] extcon: ptn5150: Reduce the amount of logs on deferred probe Date: Mon, 17 Aug 2020 09:00:06 +0200 Message-Id: <20200817070009.4631-11-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200817070009.4631-1-krzk@kernel.org> References: <20200817070009.4631-1-krzk@kernel.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org There is no point to print deferred probe (and its failures to get resources) as an error. In case of multiple probe tries this would pollute the dmesg. Signed-off-by: Krzysztof Kozlowski --- drivers/extcon/extcon-ptn5150.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c index 008e664d8d56..c8611ff90990 100644 --- a/drivers/extcon/extcon-ptn5150.c +++ b/drivers/extcon/extcon-ptn5150.c @@ -243,7 +243,7 @@ static int ptn5150_i2c_probe(struct i2c_client *i2c, dev_info(dev, "No VBUS GPIO, ignoring VBUS control\n"); info->vbus_gpiod = NULL; } else { - dev_err(dev, "failed to get VBUS GPIO\n"); + dev_err_probe(dev, ret, "failed to get VBUS GPIO\n"); return ret; } } @@ -255,8 +255,8 @@ static int ptn5150_i2c_probe(struct i2c_client *i2c, info->regmap = devm_regmap_init_i2c(i2c, &ptn5150_regmap_config); if (IS_ERR(info->regmap)) { ret = PTR_ERR(info->regmap); - dev_err(info->dev, "failed to allocate register map: %d\n", - ret); + dev_err_probe(info->dev, ret, "failed to allocate register map: %d\n", + ret); return ret; } @@ -265,8 +265,9 @@ static int ptn5150_i2c_probe(struct i2c_client *i2c, } else { info->int_gpiod = devm_gpiod_get(&i2c->dev, "int", GPIOD_IN); if (IS_ERR(info->int_gpiod)) { - dev_err(dev, "failed to get INT GPIO\n"); - return PTR_ERR(info->int_gpiod); + ret = PTR_ERR(info->int_gpiod); + dev_err_probe(dev, ret, "failed to get INT GPIO\n"); + return ret; } info->irq = gpiod_to_irq(info->int_gpiod); From patchwork Mon Aug 17 07:00:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 253707 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1ED66C433E3 for ; Mon, 17 Aug 2020 07:02:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F11092072D for ; Mon, 17 Aug 2020 07:02:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597647758; bh=MQR05X2smn64mi3esQ9qgy+sb0U5n0XiH+PjMJuVSKg=; h=From:To:Subject:Date:In-Reply-To:References:List-ID:From; b=cqvm+bJD6ycs90CBEwrmHyTOjDA+Njqu2QsOjI+KZluttL9Ww8lSTWKHggmJ30FFk TSUJx2o15OPu2tkdyKp0tQv90ND/3G8PJq4IWNzBbAqWJm3nE9HjBhIWsoA77DWJ/G TSoavD0SW+hh7mx6VCEjh/IbPDMFR8AAaSLmqJYg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726688AbgHQHBK (ORCPT ); Mon, 17 Aug 2020 03:01:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:42246 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726585AbgHQHAo (ORCPT ); Mon, 17 Aug 2020 03:00:44 -0400 Received: from localhost.localdomain (unknown [194.230.155.242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 156B62072D; Mon, 17 Aug 2020 07:00:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597647644; bh=MQR05X2smn64mi3esQ9qgy+sb0U5n0XiH+PjMJuVSKg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=LCYRNU2N6oii4lu3CX3IZq+4mCtUScjFOVm2XaWM7Zo1ucjGtzXZVx+FmoiPFah1J QUfX7kGSHd5Q8KajAZjkEuQif+ezUjQJNUt3kPjeSjBNco65THnjlAVSGFZcRfviUe vea6Wx5pmQyoXDdcGx2o6hCFTmEaPFuGhrbGAJWA= From: Krzysztof Kozlowski To: MyungJoo Ham , Chanwoo Choi , Rob Herring , Krzysztof Kozlowski , Vijai Kumar K , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v2 13/13] MAINTAINERS: Add entry for NXP PTN5150A CC driver Date: Mon, 17 Aug 2020 09:00:09 +0200 Message-Id: <20200817070009.4631-14-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200817070009.4631-1-krzk@kernel.org> References: <20200817070009.4631-1-krzk@kernel.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add Krzysztof Kozlowski as maintainer of NXP PTN5150A CC/extcon driver to provide review, feedback and testing. Signed-off-by: Krzysztof Kozlowski --- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index f2eb17cd3953..48cb5162a94a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -12431,6 +12431,13 @@ F: drivers/iio/gyro/fxas21002c_core.c F: drivers/iio/gyro/fxas21002c_i2c.c F: drivers/iio/gyro/fxas21002c_spi.c +NXP PTN5150A CC LOGIC AND EXTCON DRIVER +M: Krzysztof Kozlowski +L: linux-kernel@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml +F: drivers/extcon/extcon-ptn5150.c + NXP SGTL5000 DRIVER M: Fabio Estevam L: alsa-devel@alsa-project.org (moderated for non-subscribers)