From patchwork Wed Aug 12 16:29:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 253893 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 B9501C433E1 for ; Wed, 12 Aug 2020 16:30:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9510520829 for ; Wed, 12 Aug 2020 16:30:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597249811; bh=5VABsIIOTga9jxbpTZ9xoI/0EbnuZPCPq7dvahWwSbw=; h=From:To:Subject:Date:In-Reply-To:References:List-ID:From; b=ePnDk1K8+9sVDYo/1KYBmb1tEo+6LZ0WvyNUkGHfY2iCpIVrv4UQUEBAoi6QrYE8h OwQKiKmgl/z2jLuUbIrL1elaHSyoprMUXabkc3Vh+vlgFEXHPSTyAuJoArm2rkluPq JJwyFjK8W/e42/wMu8kd53u5nH0F3r7sx4dephrg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726724AbgHLQaI (ORCPT ); Wed, 12 Aug 2020 12:30:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:48566 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725872AbgHLQaH (ORCPT ); Wed, 12 Aug 2020 12:30:07 -0400 Received: from localhost.localdomain (unknown [194.230.155.117]) (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 795AD20829; Wed, 12 Aug 2020 16:30:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597249807; bh=5VABsIIOTga9jxbpTZ9xoI/0EbnuZPCPq7dvahWwSbw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=NGwsw6qgrFncoA3JUoHci5WNkSQFa83YxK1ZIs/n5ayPTkBq9ZeDxz1ysyK73qEvQ PGS7KXmrF386lxMgSLzxZvftek4ZplsMApoke+PDrDur5Gyv/k7dYl/1jZz5qabDT+ oJelA5TB8Nk+hB5xFPNOfQU3TE/efKe5fCFEB+8Y= 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 02/11] dt-bindings: extcon: ptn5150: Use generic "interrupts" property Date: Wed, 12 Aug 2020 18:29:49 +0200 Message-Id: <20200812162958.6180-2-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200812162958.6180-1-krzk@kernel.org> References: <20200812162958.6180-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 Wed Aug 12 16:29:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 253892 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 CFE44C433DF for ; Wed, 12 Aug 2020 16:30:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B140520829 for ; Wed, 12 Aug 2020 16:30:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597249819; bh=3bfDu2rrgsQUUDMAmYFHILNOphrIGlyzCv66V1HnZQE=; h=From:To:Subject:Date:In-Reply-To:References:List-ID:From; b=0TVgcA/NzNUGgSekCiAC1aJACoJ9s/Rz4SWxVNz27VXSN7u4kbVqQw7XyDqiK723e G6u2Tdse964KV6/JC4P4BLcrGFdDvfC2GDbphOpFELHo8aLDp+gNYbSu1sZOk89b+a dSJlswGhlGRTs36MtdiwP5hh4q9jI184TcilNJzc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726831AbgHLQaQ (ORCPT ); Wed, 12 Aug 2020 12:30:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:48916 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726777AbgHLQaP (ORCPT ); Wed, 12 Aug 2020 12:30:15 -0400 Received: from localhost.localdomain (unknown [194.230.155.117]) (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 CEBBA207DA; Wed, 12 Aug 2020 16:30:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597249815; bh=3bfDu2rrgsQUUDMAmYFHILNOphrIGlyzCv66V1HnZQE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=zSfry3T7e/Ewv2iAWZrfjTEqQKBEqKo5VnEy1RiQCV/DpxJpREWSFaGh+LfG/LOt4 gSerohMHaTHilgLn1haHAiJAyFd3ZpnFwvocG04UHnypTpQdPx7F5H98i8gvELTXi3 qVy4IwPuGocLAr7jnCZH4Jswv9q6W3mTV2ZOX4sQ= 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 06/11] extcon: ptn5150: Simplify getting vbus-gpios with flags Date: Wed, 12 Aug 2020 18:29:53 +0200 Message-Id: <20200812162958.6180-6-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200812162958.6180-1-krzk@kernel.org> References: <20200812162958.6180-1-krzk@kernel.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Instead of obtaining GPIO as input and configuring it right after to output-low, just use proper GPIOD_OUT_LOW flag. Code is smaller and simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/extcon/extcon-ptn5150.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c index 12e52ddbd77e..3b99ad41b06e 100644 --- a/drivers/extcon/extcon-ptn5150.c +++ b/drivers/extcon/extcon-ptn5150.c @@ -239,16 +239,11 @@ static int ptn5150_i2c_probe(struct i2c_client *i2c, info->dev = &i2c->dev; info->i2c = i2c; - info->vbus_gpiod = devm_gpiod_get(&i2c->dev, "vbus", GPIOD_IN); + info->vbus_gpiod = devm_gpiod_get(&i2c->dev, "vbus", GPIOD_OUT_LOW); if (IS_ERR(info->vbus_gpiod)) { dev_err(dev, "failed to get VBUS GPIO\n"); return PTR_ERR(info->vbus_gpiod); } - ret = gpiod_direction_output(info->vbus_gpiod, 0); - if (ret) { - dev_err(dev, "failed to set VBUS GPIO direction\n"); - return -EINVAL; - } mutex_init(&info->mutex); From patchwork Wed Aug 12 16:29:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 253891 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 CDA4FC433E1 for ; Wed, 12 Aug 2020 16:30:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A30BF2076B for ; Wed, 12 Aug 2020 16:30:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597249823; bh=GuxKhABf5nd+bNmYO2713nFRWWYvL9bTfzoRfMGaMxU=; h=From:To:Subject:Date:In-Reply-To:References:List-ID:From; b=MIJPqYLuknwTx5+FlGTvY/aahLz1++teNm+pUQrGXl3EiHUh0eJtFHn/TDx3c1NqC N3Pz18QuqzU7GIRAivrgGlKNWQfqHqRCZC+Se55P/AIi6fFjwRKZ22UbhL4GPhS4Ku ya+BxySwDTJKsSvO1x5+A/tBsTxoONPOQntX3+KE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726515AbgHLQaV (ORCPT ); Wed, 12 Aug 2020 12:30:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:49128 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726856AbgHLQaV (ORCPT ); Wed, 12 Aug 2020 12:30:21 -0400 Received: from localhost.localdomain (unknown [194.230.155.117]) (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 4FD7E207DA; Wed, 12 Aug 2020 16:30:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597249820; bh=GuxKhABf5nd+bNmYO2713nFRWWYvL9bTfzoRfMGaMxU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=NqZWtyCG63Z1ErQExIZIMv4zoJObfsNVemqQHog5oEF4+hZgM1AtyEFc27+mUT5iU 8x6JcQ/M+jRkSQvCckE+tSw0YV7PqpHkV7tJveUECzA4DsX0q+LG5uvVBw78yJDcSx To4Keg+VxoasYxpPon+eNGwu8LatgQAkg4rwt3gQ= 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 08/11] extcon: ptn5150: Check current USB mode when probing Date: Wed, 12 Aug 2020 18:29:55 +0200 Message-Id: <20200812162958.6180-8-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200812162958.6180-1-krzk@kernel.org> References: <20200812162958.6180-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 --- drivers/extcon/extcon-ptn5150.c | 93 ++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 43 deletions(-) diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c index a57fef384a29..bbb185378e4b 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,50 @@ 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); + mutex_unlock(&info->mutex); + 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 +135,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 +148,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 +300,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 +340,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 Wed Aug 12 16:29:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 253889 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 48561C433DF for ; Wed, 12 Aug 2020 16:30:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 202A2207DA for ; Wed, 12 Aug 2020 16:30:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597249838; bh=bsQ15/usVZgLip99G+grCHhURaw6dBoohf5jYJRGiT0=; h=From:To:Subject:Date:In-Reply-To:References:List-ID:From; b=afhKa0GUtMhfOUnm1vX5KmueKzCbIxnZrWcuVBdFaKDOkhxBFDXEWvkE7pqkQDepU EoH8wKRsaoCBZpRPX0UBeOSoBFbRKxpscjcgEWHcwxTdA/1bYMoPUFYHK0szVtCN2q /TIQJ9xE5b8PqcqThByccCy8oCn1ebeoSrJJ1uG4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726945AbgHLQah (ORCPT ); Wed, 12 Aug 2020 12:30:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:49208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726901AbgHLQaX (ORCPT ); Wed, 12 Aug 2020 12:30:23 -0400 Received: from localhost.localdomain (unknown [194.230.155.117]) (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 B36DB20771; Wed, 12 Aug 2020 16:30:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597249822; bh=bsQ15/usVZgLip99G+grCHhURaw6dBoohf5jYJRGiT0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=tdYgQ5rDpTlLFIAq87wqjfr0pJWq/30I+UE9wPTaV5uTKswwQFFUSgZqWDTPq8+rr yi6YuZTUw20v0FUwpsq/bGGmimbi42IpY/2B7tVfBZ9uyektwEBpO3u7J8sQ9VqQyp hOV39uKtILK45i39Trpyy1NfMs3E7OvdeQGd0Sjc= 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 09/11] extcon: ptn5150: Make 'vbus-gpios' optional Date: Wed, 12 Aug 2020 18:29:56 +0200 Message-Id: <20200812162958.6180-9-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200812162958.6180-1-krzk@kernel.org> References: <20200812162958.6180-1-krzk@kernel.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The PTN5150 chip can be used in hardware designs with only reporting of USB Type-C connection, without the VBUS control. The driver however unconditionally expected 'vbus-gpios'. Since all uses of the VBUS GPIO descriptor are NULL safe, the code can accept missing GPIO and provide only extcon status reporting. Signed-off-by: Krzysztof Kozlowski --- drivers/extcon/extcon-ptn5150.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c index bbb185378e4b..9daf45118ffd 100644 --- a/drivers/extcon/extcon-ptn5150.c +++ b/drivers/extcon/extcon-ptn5150.c @@ -239,8 +239,14 @@ static int ptn5150_i2c_probe(struct i2c_client *i2c, info->i2c = i2c; info->vbus_gpiod = devm_gpiod_get(&i2c->dev, "vbus", GPIOD_OUT_LOW); if (IS_ERR(info->vbus_gpiod)) { - dev_err(dev, "failed to get VBUS GPIO\n"); - return PTR_ERR(info->vbus_gpiod); + ret = PTR_ERR(info->vbus_gpiod); + if (ret == -ENOENT) { + dev_info(dev, "No VBUS GPIO, ignoring VBUS control\n"); + info->vbus_gpiod = NULL; + } else { + dev_err(dev, "failed to get VBUS GPIO\n"); + return ret; + } } mutex_init(&info->mutex); From patchwork Wed Aug 12 16:29:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 253890 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 E7717C433E0 for ; Wed, 12 Aug 2020 16:30:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C85FB20771 for ; Wed, 12 Aug 2020 16:30:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597249834; bh=eX15NLAnHkr2JM14R4rf4yZMswB6aHIybQEwZQAk2ZA=; h=From:To:Subject:Date:In-Reply-To:References:List-ID:From; b=eAFoN44PIeuqbhsZwMwht2zrvOX7lp/XbhKfVTtbSxWvlobgzuRuQMooxyTsU1NM3 etrTmztPD/veAHVFLHEGsA7YWXMpJqro5laHMknd9tWewxrqzQ8bFEoLoRVr+ARSv4 udJPsH5uHBSOZ2P9zX1hWMSbJEUKnVBpfzpQSK5s= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726937AbgHLQa0 (ORCPT ); Wed, 12 Aug 2020 12:30:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:49346 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726809AbgHLQaZ (ORCPT ); Wed, 12 Aug 2020 12:30:25 -0400 Received: from localhost.localdomain (unknown [194.230.155.117]) (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 3C3C920829; Wed, 12 Aug 2020 16:30:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597249824; bh=eX15NLAnHkr2JM14R4rf4yZMswB6aHIybQEwZQAk2ZA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=fl7YEQ/YQSEEmnyYibmoqbo6vFzWQwTstwx/FHZmPW/iIDiJXmeoSHgtID1w62JTF cGqjWvU7KlqhOGBks7inBqAXRgf33tYo7BSrSJh7mq+J5mSjL00tCr3kRYZeyT0Of7 PEW/GwP598iIhFp+ou3BbEYYpmuNOmDnRw6KcUJA= 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 10/11] extcon: ptn5150: Reduce the amount of logs on deferred probe Date: Wed, 12 Aug 2020 18:29:57 +0200 Message-Id: <20200812162958.6180-10-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200812162958.6180-1-krzk@kernel.org> References: <20200812162958.6180-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 9daf45118ffd..fd9723f86d55 100644 --- a/drivers/extcon/extcon-ptn5150.c +++ b/drivers/extcon/extcon-ptn5150.c @@ -244,7 +244,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; } } @@ -256,8 +256,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; } @@ -266,8 +266,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 Wed Aug 12 16:50:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 253888 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 6DED1C433DF for ; Wed, 12 Aug 2020 16:50:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C39720656 for ; Wed, 12 Aug 2020 16:50:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597251033; bh=gVGb7sNLAIhYGstS5KXbZV0W+9i8eM/O/IElQDO4KD8=; h=From:To:Subject:Date:In-Reply-To:References:List-ID:From; b=l6IP/cz9ZadWTnqr0au9VSRkCNtsroxqXPahP1nJ9hUgWhTW2e682CZmeq8TzeGiO DBZTY4v8OiR8jbILJaFSQtqA1M+N8TUDLSexyHvlFUS5zr93EaVhLMWsGMQOfDyXVB 3tsFsl9ZNXeqM2OvdqNApzzHjbO2IzCm7ftd5x8s= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726856AbgHLQuc (ORCPT ); Wed, 12 Aug 2020 12:50:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:33672 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726773AbgHLQu1 (ORCPT ); Wed, 12 Aug 2020 12:50:27 -0400 Received: from localhost.localdomain (unknown [194.230.155.117]) (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 B669220656; Wed, 12 Aug 2020 16:50:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597251027; bh=gVGb7sNLAIhYGstS5KXbZV0W+9i8eM/O/IElQDO4KD8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=GmCsmViBy3cFQonjqfXChi01zLz8Q7zRvYeJNOWRoUtIiiYVFoVO0pDTXdb/IYEeE z13mHBrxwlr5IMeumXxeQMmPzHiLrPmtHeLP/OHB4qTZQACqE7y6/m0COztF7eVFcW SVJW7nMMEfPZdjExOC2qWhKpe5rYT//LSQDrtO3w= 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 13/13] extcon: ptn5150: Convert to .probe_new Date: Wed, 12 Aug 2020 18:50:13 +0200 Message-Id: <20200812165013.2699-2-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200812165013.2699-1-krzk@kernel.org> References: <20200812162958.6180-1-krzk@kernel.org> <20200812165013.2699-1-krzk@kernel.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The 'struct i2c_device_id' argument of probe function is not used, so convert the driver to simpler 'probe_new' interface. Signed-off-by: Krzysztof Kozlowski --- drivers/extcon/extcon-ptn5150.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c index 559e26214f48..e9585e870fe9 100644 --- a/drivers/extcon/extcon-ptn5150.c +++ b/drivers/extcon/extcon-ptn5150.c @@ -219,8 +219,7 @@ static int ptn5150_init_dev_type(struct ptn5150_info *info) return 0; } -static int ptn5150_i2c_probe(struct i2c_client *i2c, - const struct i2c_device_id *id) +static int ptn5150_i2c_probe(struct i2c_client *i2c) { struct device *dev = &i2c->dev; struct device_node *np = i2c->dev.of_node; @@ -335,7 +334,7 @@ static struct i2c_driver ptn5150_i2c_driver = { .name = "ptn5150", .of_match_table = ptn5150_dt_match, }, - .probe = ptn5150_i2c_probe, + .probe_new = ptn5150_i2c_probe, .id_table = ptn5150_i2c_id, }; module_i2c_driver(ptn5150_i2c_driver);