From patchwork Sun Sep 17 15:26:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 141212 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2339288vqi; Sun, 17 Sep 2023 16:15:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHvKVoyK0ShpY53UeZfHa9fAOAdUB+XY+7f63Qr+LHswBFsjl3dCSotYxPyQ3iIeOGwnv2I X-Received: by 2002:aa7:88d3:0:b0:68e:3616:604a with SMTP id k19-20020aa788d3000000b0068e3616604amr10694140pff.8.1694992526525; Sun, 17 Sep 2023 16:15:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694992526; cv=none; d=google.com; s=arc-20160816; b=dVbZZ8nDcEz1R49DxrgV5+4IwRf++o9WZ6++5lweuOsotyQYDZc6bFrGwVk17qHE5U lyK5h7hpnn+XVUw1h5Odm94WWvYRdVqnyK/RGcELbJHcN0w1EBShfN+5svp663OtH8px Lu26b5w09e+E5VQ6si8BsL2KDXs1ltYFDPRUs5KHEQ+EKTT4i0BbrW0enIUzx4FyvgRe yzKBlCiy81FdDmUyui4yWj+iZaPnfptE9PENPZxvqk7NsqwZvf2IXYwIPvbtP9urRy6t bHaX83zqio44L8R3Wk9ZQ+Ys5iJNCX6SCbqOTAO7ks7FovfIqGNBrrvYixgloFxsYune Z8Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sklpvAcj30UO+GX0DztQzCwJiBeqDyCx8hTAU0gXl9E=; fh=1TLHXZLxbVW/pzxFCwcQN1QIszWWCFgsgFdloZrlyPk=; b=APwMaPx+YX9PvrV0eyd4xo9jd02suZUlzfbikPYXm+69Y1VMyUOP9SNyzlvuTpSkRV hUuBgZ/mfM9/bhvTxALdjoC74xuC52mbfaKrKRNOmV5QkbGyNxc3M7rBtVVxWjIcnw7r rLmE7EHSKtTpxLlTp1yJADXKWT7aKV5CaDUbPFzt8hBxoRHD/B+UGGe0uan3N83aT0Gx cdzj2yI9YevXYRU/FgJNEOM+beRXqFi24NldnNHS55zmw2Adt79ttYpiFKa0vDkRj/jq 9CwPZvPy0FlHKqhsQLsSQZKrS+o7D9ys+DF2Yp0LXW6fCnx7HPQLF68obB/zbduTB/Cu x0eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CnZV3pJ+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id v3-20020a655c43000000b00565e386ff44si6855639pgr.702.2023.09.17.16.15.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 16:15:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CnZV3pJ+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 0537D822B2F8; Sun, 17 Sep 2023 08:28:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235066AbjIQP17 (ORCPT + 29 others); Sun, 17 Sep 2023 11:27:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229594AbjIQP10 (ORCPT ); Sun, 17 Sep 2023 11:27:26 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AC3C120; Sun, 17 Sep 2023 08:27:20 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-404773f2501so31256255e9.0; Sun, 17 Sep 2023 08:27:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694964438; x=1695569238; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sklpvAcj30UO+GX0DztQzCwJiBeqDyCx8hTAU0gXl9E=; b=CnZV3pJ+vnioTkacAboil4MdQW05qIZ2uyW41ygEsS7FUYKPfSwpHj7SjOcTLVbiNN cEbO0aamocdIeb8iqGi3Z+Q87NYrKxlARJG4Hv5OtH1zjtkKb2C3ycNdeLwUDRGgNE4l 8amL7CcK94vW4hs6S1XjgTkiBWtYx9ZrldnT/LYvqmceB5EMTzhCdohcOu/+NOym4dCA H8utNvJHD9Jzj24BQRX8sK9L4u4jmtqLJ75Sd4QvvSyKcKdIeys8eIv3FVjejPwH8fzR V2g2w9MauNyllCAi32k4/RVdiR6d1sG5iXR026fdKuvgDL37JkbHEtEYox0gMybT5Gk9 Zv0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694964438; x=1695569238; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sklpvAcj30UO+GX0DztQzCwJiBeqDyCx8hTAU0gXl9E=; b=v9UiwikzR+qwsi7F6SYviGCCyI9+0Tt+sOZpEsUYHv22yUll3OfPmGTezSThfuMrlO otcEW1X3lElvk5fSi+3JDetq9nR6/XjlfOlckCV/N/Pi3RC+oStkROeH/0r4t+HfEPrj u2+XXE2LEm9suJ3rB9lyjwavNhL3oqEINjTHvhaSaHUUkFXXNJjtMmp52IoXbAg85XSx a3ZYMBXP6xJ3gk4byTZaEcG/PJ2LuaZEfEmdQnERuDJsbdAM2xjFp55SR9Jnju63DVg4 zPHvh1WL89DjWr7+VdOWdDYm/2yzxRvlZEt9v+dE9CKP+IiaTX5XMr48z9ga3cMMEOST YARg== X-Gm-Message-State: AOJu0Yz5r4GZAsUSkMv3mWZT0KuETaCQo4ePGOnwPCvafLlfKZm736Bx jI+9XCsHlzV7iTkm9LekyUt7suV3f/OL37cDKWk= X-Received: by 2002:a1c:f717:0:b0:403:b86:f624 with SMTP id v23-20020a1cf717000000b004030b86f624mr5664827wmh.23.1694964438121; Sun, 17 Sep 2023 08:27:18 -0700 (PDT) Received: from localhost.localdomain ([5.45.134.53]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c489700b003fe15ac0934sm7388865wmp.1.2023.09.17.08.27.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 08:27:17 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, robh+dt@kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org, linux-kernel@vger.kernel.org, abdelalkuor@geotab.com Subject: [PATCH v5 01/15] dt-bindings: usb: tps6598x: Add tps25750 Date: Sun, 17 Sep 2023 11:26:25 -0400 Message-Id: <20230917152639.21443-2-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230917152639.21443-1-alkuor@gmail.com> References: <20230917152639.21443-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sun, 17 Sep 2023 08:28:51 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777318472683302531 X-GMAIL-MSGID: 1777328483363791708 From: Abdel Alkuor TPS25750 is USB TypeC PD controller which is a subset of TPS6598x. Signed-off-by: Abdel Alkuor --- .../devicetree/bindings/usb/ti,tps6598x.yaml | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml b/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml index 5497a60cddbc..e49bd92b5276 100644 --- a/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml +++ b/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml @@ -20,6 +20,8 @@ properties: enum: - ti,tps6598x - apple,cd321x + - ti,tps25750 + reg: maxItems: 1 @@ -32,10 +34,45 @@ properties: items: - const: irq + firmware-name: + description: | + Should contain the name of the default patch binary + file located on the firmware search path which is + used to switch the controller into APP mode. + This is used when tps25750 doesn't have an EEPROM + connected to it. + maxItems: 1 + + ti,patch-address: + description: | + One of PBMs command data field is I2C slave address + which is used when writing the patch for TPS25750. + The slave address can be any value except 0x00, 0x20, + 0x21, 0x22, and 0x23 + $ref: /schemas/types.yaml#/definitions/uint8 + minimum: 1 + maximum: 0x7e + required: - compatible - reg +allOf: + - if: + properties: + compatible: + contains: + const: ti,tps25750 + then: + required: + - ti,patch-address + - connector + + properties: + connector: + required: + - data-role + additionalProperties: true examples: @@ -68,4 +105,37 @@ examples: }; }; }; + + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + typec@21 { + compatible = "ti,tps25750"; + reg = <0x21>; + + interrupt-parent = <&msmgpio>; + interrupts = <100 IRQ_TYPE_LEVEL_LOW>; + interrupt-names = "irq"; + firmware-name = "tps25750.bin"; + + pinctrl-names = "default"; + pinctrl-0 = <&typec_pins>; + + ti,patch-address = /bits/ 8 <0x0f>; + + typec_con0: connector { + compatible = "usb-c-connector"; + label = "USB-C"; + data-role = "dual"; + port { + typec_ep0: endpoint { + remote-endpoint = <&otg_ep>; + }; + }; + }; + }; + }; ... From patchwork Sun Sep 17 15:26:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 141187 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2271936vqi; Sun, 17 Sep 2023 12:30:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGB0UdqGlpd65VoWDF04qM96BELd87ARqqFoKKTngX7/CoIVd/IgQZyI362lGFRN3kfQ4ZU X-Received: by 2002:a17:902:ec89:b0:1c0:9d6f:9d28 with SMTP id x9-20020a170902ec8900b001c09d6f9d28mr6403479plg.11.1694979034551; Sun, 17 Sep 2023 12:30:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694979034; cv=none; d=google.com; s=arc-20160816; b=KuTdseLLw+6XTGKd4HHdBpQYT79jOmBNFIDlXUxEqW9/Ei7GCtjU+KbAWzWOrdUDSR NU6YJZ+OqjTXC7pRRO/9rt0GhMibZON6d3u4EnXI6uwnvGzdo8oNU4NSc6IstrzTL7mc 80ApBe2tzEjzt/A0zyfOvDa7Qsq0OWeSnm7f+QFfBcAUAv+A0EuaikoqxTPthyqT03og wBKIIOWEFtpKIWU3Vtm728XpaOzEL3KAoQh336gCeNFobSUjqUEqF3ptZxmJ3eoZN0Vs ICbORgJd7bq9+zKEStq6L/zUqL4tvinEH/RWXtByAx3FddiGUO+8Mgr/40kfd9nrVdhi VN/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=V3y8c1achGK+WQ5g0X4obcawzUgKoXn6NXo4Tvawvo4=; fh=I0Lzq3m/LIxJ51N7jPTHUv8eE5jJdt/R03iLk7hWxA8=; b=MlMN8Xp7UyabvtpNryEZynr/a4bfnHeE1a3r8nr0u51b4ZKON2I2bIvo3FtTDC8vCm 1hK3GKuszSdV9SuoOnhs2AItz/YqMaYIljGvMaGiBytzGYShZTMaPdir53bBpPY8SpDQ 2n9wH+RfI6Qps5JI7wRyUFQZA22Spg5G4WMP+gLsNftyr5FeKQlNz99Sjf04wxlgyQ21 rbGjgxgANoeEOVZ8ee+npkoB4OkhtCEyOxqs238ffDrfxtunVirXto+/pszLLClCKYPM yXxTJxOoOBf5c3ut+CCzr/q/whdxs0tYH7a9pgCVRc5LazekYcVPErY2GxtQ+gG9+Y/m e3bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CctofdMv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id la4-20020a170902fa0400b001bf1d1d99ddsi6595848plb.295.2023.09.17.12.30.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 12:30:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CctofdMv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id D298981FD2AD; Sun, 17 Sep 2023 08:29:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235933AbjIQP2C (ORCPT + 29 others); Sun, 17 Sep 2023 11:28:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233257AbjIQP12 (ORCPT ); Sun, 17 Sep 2023 11:27:28 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F05A188; Sun, 17 Sep 2023 08:27:22 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-404573e6c8fso36714015e9.1; Sun, 17 Sep 2023 08:27:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694964441; x=1695569241; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=V3y8c1achGK+WQ5g0X4obcawzUgKoXn6NXo4Tvawvo4=; b=CctofdMvKInfUHMp8wksY8ygDmJKGvzGshQ4iLysJSoFvv9LXkexqJOjtoxBgffCNh RiYvgGNDlKl4AuiLWoTx0ZE9DH1uylh1phz2QAgTndpLybB9DQK8u09AlkRVc2SfmWAd 89b3QGg0U4oZXN13tHycrFDupTt4STrBEhC1X8VZhq9/YGJtvuFuw+MTquF1Ok5Ed6Ee WCs9a64eDFmMOLvHQ9W0cApg558aY6bKlxWEQ9Xt29JV++oCX75vAnK5pu3k0AjevBZT l/zQnGa2GM4lAtWpT9FBj4wqxVvjdh5Nv+yTCLarxquKagaFmdvaUeSNBxn0ipmI5IOH 02kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694964441; x=1695569241; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=V3y8c1achGK+WQ5g0X4obcawzUgKoXn6NXo4Tvawvo4=; b=QhnhpUryitCjJUfcmODxzt8PpWU61XNJfO27D57rqRnqJEKNnAw45qJVmfkMxtRs+e bfchqLK0KhuKpP9qpmXp5Y+DicShDo5MqoQ02++4HftI78q9b/GpSY2D7G2aB6LKYhc5 z4yT3LqVrfPYodMqJLmiCOPrY0R38riQCIkiFulv1o/399FVZFbnVSHDa+Yyt6DUDPGE 75Ki1CKlNoPedwBPpkmuYNjuDQKSoH0uoIjM25xMpgPe+E438Xs9s9SrXIkDeJVmtFOR 56mhkIT291Q3Uueqclkz07tkBX7+jSHMenjXCi265KOW988arSwjwR7svqBlUJ/e8MvP q9SA== X-Gm-Message-State: AOJu0YwUNotOW08KxsynRm8NNyCa+Amcp3q+mKM8zR7i0Q3Kw4YhrJ70 pDiazBDTszjMg42O3l1VSxA= X-Received: by 2002:a1c:ed10:0:b0:401:daf2:2737 with SMTP id l16-20020a1ced10000000b00401daf22737mr6521093wmh.30.1694964440875; Sun, 17 Sep 2023 08:27:20 -0700 (PDT) Received: from localhost.localdomain ([5.45.134.53]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c489700b003fe15ac0934sm7388865wmp.1.2023.09.17.08.27.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 08:27:20 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, robh+dt@kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org, linux-kernel@vger.kernel.org, abdelalkuor@geotab.com, Abdel Alkuor Subject: [PATCH v5 02/15] USB: typec: Add cmd timeout and response delay Date: Sun, 17 Sep 2023 11:26:26 -0400 Message-Id: <20230917152639.21443-3-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230917152639.21443-1-alkuor@gmail.com> References: <20230917152639.21443-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Sun, 17 Sep 2023 08:29:15 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777314335674518484 X-GMAIL-MSGID: 1777314335674518484 Some commands in tps25750 take longer than 1 second to complete, and some responses need some delay before the result becomes available. Signed-off-by: Abdel Alkuor --- drivers/usb/typec/tipd/core.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 37b56ce75f39..a8aee4e1aeba 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -284,7 +284,8 @@ static void tps6598x_disconnect(struct tps6598x *tps, u32 status) static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd, size_t in_len, u8 *in_data, - size_t out_len, u8 *out_data) + size_t out_len, u8 *out_data, + u32 cmd_timeout_ms, u32 res_delay_ms) { unsigned long timeout; u32 val; @@ -307,8 +308,7 @@ static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd, if (ret < 0) return ret; - /* XXX: Using 1s for now, but it may not be enough for every command. */ - timeout = jiffies + msecs_to_jiffies(1000); + timeout = jiffies + msecs_to_jiffies(cmd_timeout_ms); do { ret = tps6598x_read32(tps, TPS_REG_CMD1, &val); @@ -321,6 +321,9 @@ static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd, return -ETIMEDOUT; } while (val); + /* some commands require delay for the result to be available */ + mdelay(res_delay_ms); + if (out_len) { ret = tps6598x_block_read(tps, TPS_REG_DATA1, out_data, out_len); @@ -354,7 +357,7 @@ static int tps6598x_dr_set(struct typec_port *port, enum typec_data_role role) mutex_lock(&tps->lock); - ret = tps6598x_exec_cmd(tps, cmd, 0, NULL, 0, NULL); + ret = tps6598x_exec_cmd(tps, cmd, 0, NULL, 0, NULL, 1000, 0); if (ret) goto out_unlock; @@ -384,7 +387,7 @@ static int tps6598x_pr_set(struct typec_port *port, enum typec_role role) mutex_lock(&tps->lock); - ret = tps6598x_exec_cmd(tps, cmd, 0, NULL, 0, NULL); + ret = tps6598x_exec_cmd(tps, cmd, 0, NULL, 0, NULL, 1000, 0); if (ret) goto out_unlock; @@ -654,7 +657,10 @@ static int cd321x_switch_power_state(struct tps6598x *tps, u8 target_state) if (state == target_state) return 0; - ret = tps6598x_exec_cmd(tps, "SSPS", sizeof(u8), &target_state, 0, NULL); + ret = tps6598x_exec_cmd(tps, "SSPS", + sizeof(u8), &target_state, + 0, NULL, + 1000, 0); if (ret) return ret; From patchwork Sun Sep 17 15:26:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 141171 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2247892vqi; Sun, 17 Sep 2023 11:15:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFW3ky1Ejn88OeEBRwrDfvpW+GGKDOnhDM5ZusmoDslgy2sQsXCGOzsNpHrtFw6KyoawC76 X-Received: by 2002:a05:6a20:12c4:b0:148:3c72:4878 with SMTP id v4-20020a056a2012c400b001483c724878mr9441877pzg.50.1694974526426; Sun, 17 Sep 2023 11:15:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694974526; cv=none; d=google.com; s=arc-20160816; b=KSUJJ68XMKMdhgUVK+PTjJyTQdZsCw2OqcOeafSw64j05b+sgSXPezNm4m36O1mJH3 WcwqlXM2LE798TMe6guuZYfjlwOtYqC2Hs3lHqdm9e7VrU9SlWCwr0iCenR8psfZnmLd gM73FGnYSBLLCJ79G88ateLKnw/GQRBzdCF0byP1UeVCM/uO0CF+/X+0HP3nc9ItDPTN +T4cRYrNqNGIaZp7zSBKNZG38hFXS9kYa1HEwQwtBTnhawFbBkMaEjQxdMJ6qFDY2SVC d8bzTIdZNj6XMQVvK89kY4JJxCP9YMdPyxqLpCW2lxatWW4y4x+No40LWLTbkLBuW9t5 qM5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ca93iTqJpSx/plxX75j5Y8vcvCYToSV9JbO7YLCJdoA=; fh=I0Lzq3m/LIxJ51N7jPTHUv8eE5jJdt/R03iLk7hWxA8=; b=txkvqr7226CLoAQ74+OKxyjuWvNQARAWGxvn6YoLsbBltqHClCT9B99kfccdeABnAT BK9QNc49oPrHgC6PjLeY5oSa2j8NGz6tQxYcjwYWGgmIUGVFh7vr7lzKJUIzfiUEabp8 XITRKXnzyiqGcB3ynfPDoDYFciadg1kRQQZaFlzDofTAFv1wExd8M9wjxiWtKgvxRgnp d8UhiJ7eUz9SoTaDwxsDMzHmy+nuz6PD70dt5uAQeK1pVub6wU24+PK72QpieNXGm75X YiD2tmGUWU7k3S+T9+nEffI9K0zIUq3tpVOEbSacfyWAQ2dNczw7HT+pNQdRhHMdyV18 8sng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="C9/3hplK"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id w29-20020a63161d000000b005649d5fc097si4165309pgl.820.2023.09.17.11.15.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 11:15:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="C9/3hplK"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id C363C81F3785; Sun, 17 Sep 2023 08:29:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236190AbjIQP2E (ORCPT + 29 others); Sun, 17 Sep 2023 11:28:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233546AbjIQP1a (ORCPT ); Sun, 17 Sep 2023 11:27:30 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56E2418B; Sun, 17 Sep 2023 08:27:25 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-402c46c49f4so39994775e9.1; Sun, 17 Sep 2023 08:27:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694964444; x=1695569244; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ca93iTqJpSx/plxX75j5Y8vcvCYToSV9JbO7YLCJdoA=; b=C9/3hplKd8qlo2ppa8L+ohT4dtw+/PX2o77OEcce0LNqarToW3u4OTgl/N7QHhWpPA au5H/ON8jsfQ7H1Od4BCcMHIQn4ELczUAoLhejQjov76N2fUf4gwowcjpy6kAs2Ba8gy sxOsFqvutgEfzaeYDZxpOiwgYdKrwv89wNtnuhMSr+Akq5f3yHxkCG1p6ERmGY3dlAV/ ib95q445tg0zSBRaeBVgpO42zUzqXKZjOq6WXsFLw/TaeT6+V5GcaWwdRSYhzf+K/16q /w0Mq+B1Y9SnrQt5Lni5LAKsBwP3g+ay83e4bJm11JMYR8iqK5n9pmKsicBjCa8qnPx1 BEnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694964444; x=1695569244; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ca93iTqJpSx/plxX75j5Y8vcvCYToSV9JbO7YLCJdoA=; b=JAyxkcjSr/+kEKIF0sIn8rUFx5DcZn3ItICYDZPwhY/3aP3rRl4105NIcPCOrnbWDQ Zt97DocdZvIAPyIPGWyZyD62MgHgcUsaaihjOtTjiMfnCryLPu4jLEkLX437hSR2m/05 FxjlZcdXI8/K7xOXFCM2C2eLcSDASe4RDfiBiwe2h/mWPdsqiYnJVbRgZ93BBIfOj98b IRdAZHIa7b7HRRo92yejdJD/9tDnosaqW3uJ4SCjEfzZQsIT+wQVOrkBfQJAD6m8/xfH W24ooRotdtfzp4Nr1ZUUI2LoI/hF1DD9KJ8riuKOrkKY3KNvnbsQWz2Qk8w9+lU36AIJ m21g== X-Gm-Message-State: AOJu0YzlodmFNKaoSD/5BoitusjWkJ9jluOFQyBL5sJGJe1FXHDf+Cu+ OzMj6a/H1CKFdl4FNDv7j80= X-Received: by 2002:a7b:c40d:0:b0:402:cc5c:c98 with SMTP id k13-20020a7bc40d000000b00402cc5c0c98mr5999011wmi.13.1694964443723; Sun, 17 Sep 2023 08:27:23 -0700 (PDT) Received: from localhost.localdomain ([5.45.134.53]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c489700b003fe15ac0934sm7388865wmp.1.2023.09.17.08.27.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 08:27:23 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, robh+dt@kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org, linux-kernel@vger.kernel.org, abdelalkuor@geotab.com, Abdel Alkuor Subject: [PATCH v5 03/15] USB: typec: Add patch mode to tps6598x Date: Sun, 17 Sep 2023 11:26:27 -0400 Message-Id: <20230917152639.21443-4-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230917152639.21443-1-alkuor@gmail.com> References: <20230917152639.21443-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Sun, 17 Sep 2023 08:29:35 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777309608570720008 X-GMAIL-MSGID: 1777309608570720008 TPS25750 has a patch mode indicating the device requires a configuration to get the device into operational mode Signed-off-by: Abdel Alkuor --- drivers/usb/typec/tipd/core.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index a8aee4e1aeba..6d2151325fbb 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -68,6 +68,7 @@ enum { TPS_MODE_BOOT, TPS_MODE_BIST, TPS_MODE_DISC, + TPS_MODE_PTCH, }; static const char *const modes[] = { @@ -75,6 +76,7 @@ static const char *const modes[] = { [TPS_MODE_BOOT] = "BOOT", [TPS_MODE_BIST] = "BIST", [TPS_MODE_DISC] = "DISC", + [TPS_MODE_PTCH] = "PTCH", }; /* Unrecognized commands will be replaced with "!CMD" */ @@ -576,7 +578,7 @@ static void tps6598x_poll_work(struct work_struct *work) &tps->wq_poll, msecs_to_jiffies(POLL_INTERVAL)); } -static int tps6598x_check_mode(struct tps6598x *tps) +static int tps6598x_check_mode(struct tps6598x *tps, u8 *curr_mode) { char mode[5] = { }; int ret; @@ -585,8 +587,11 @@ static int tps6598x_check_mode(struct tps6598x *tps) if (ret) return ret; - switch (match_string(modes, ARRAY_SIZE(modes), mode)) { + *curr_mode = match_string(modes, ARRAY_SIZE(modes), mode); + + switch (*curr_mode) { case TPS_MODE_APP: + case TPS_MODE_PTCH: return 0; case TPS_MODE_BOOT: dev_warn(tps->dev, "dead-battery condition\n"); @@ -715,6 +720,7 @@ static int tps6598x_probe(struct i2c_client *client) u32 vid; int ret; u64 mask1; + u8 mode; tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); if (!tps) @@ -759,7 +765,7 @@ static int tps6598x_probe(struct i2c_client *client) tps->irq_handler = irq_handler; /* Make sure the controller has application firmware running */ - ret = tps6598x_check_mode(tps); + ret = tps6598x_check_mode(tps, &mode); if (ret) return ret; From patchwork Sun Sep 17 15:26:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 141180 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2260238vqi; Sun, 17 Sep 2023 11:56:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEu/2kd/a07px9FVSICjLPbjGza6Cjjpq/TOtYAPrhROFOkD2G0t9Wzye6W8dkeh0O0bK/X X-Received: by 2002:a17:90b:38ce:b0:274:96a:5007 with SMTP id nn14-20020a17090b38ce00b00274096a5007mr5244233pjb.1.1694976970128; Sun, 17 Sep 2023 11:56:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694976970; cv=none; d=google.com; s=arc-20160816; b=AAiNARqBX+bzT+gt1Q6tfMPYa2oqQ6uBQZoV82w6a539qsS+MAZCV4VGMp0fdPOVD/ 2WfZ3DQUef+3vI5kCsxqRnjqIiY4KDzhaMrWW2xqIhueSP5LYcC7Y5oYWXq1q6uqgqQI HRVupo2NZD5XI7iB5jwv6iL0C1udt0zrBR8VHuaIJfEtE9XRo/j5n4WJRP/FPLepptoK K5MyH0KJ2203szzW5JauDzxLP2viNn+fTqQjz7LqQtRhaTudJd7E351FSq2F7RbUh3St wn24SiqYn0CZAJfUH2fhSXv9EEhmY9uGHrrtzV4jH+1QWAS3ERsGHmXJXtbvdwIg+xq1 wlFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pDX0213p1fJnmoU0X5KIpHt/mm/mKTvDNuRIc09/tKA=; fh=1TLHXZLxbVW/pzxFCwcQN1QIszWWCFgsgFdloZrlyPk=; b=M2sQM3cMtgYM7dyzKu0JBOVdJsDoddBsRGrkjLud4xelxb8KCsg3+/R20ZkOXyIlH1 wizNK4v15LJmNvercZu2Q2jkztduReyGChmrC7ZCAL8H++b1rLIfJ5Rhz+qKLBYJFiMg H9MrqmXg/mIxBabi6xUhLvZXafV61xJCtnqr6GSlUB8GKjypUF0pcr7HEJ1NxcOZ4HCz GQ0kXGzrIMXrlZhNn2JgNOr8kpGe3WLmkiWFGRqwbVuqitIc+BdGnAyTKsXCvxo3deLz TpVIXIpIOMMSg7xvX65/OhlpIzeWirx2bOrIqdQVWx1s9JWEQIxP3gfS+bY1EXOKyQWz Sykg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="Vy/fSOi1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id t11-20020a17090a5d8b00b00263a923c189si6532788pji.100.2023.09.17.11.56.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 11:56:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="Vy/fSOi1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 99B48826631D; Sun, 17 Sep 2023 08:29:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236360AbjIQP2F (ORCPT + 29 others); Sun, 17 Sep 2023 11:28:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233585AbjIQP1e (ORCPT ); Sun, 17 Sep 2023 11:27:34 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54C7111F; Sun, 17 Sep 2023 08:27:28 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-401ec23be82so39548675e9.0; Sun, 17 Sep 2023 08:27:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694964447; x=1695569247; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pDX0213p1fJnmoU0X5KIpHt/mm/mKTvDNuRIc09/tKA=; b=Vy/fSOi1VNseJzHIzy6YdddWauJbJO1WSx7jND1grxlML7zCRQ+onCtkChBwqudwBF rMe7Eyng31Lth/7R6+qrTVauOuJhqd2BbutP9297J+uQt1EXgM3h1FbrfCPPVBRjrJkx iHhTe53gYYNZwWOPh4/dz2ebLTuJ7U5CoQ9qjSTYs4DyiC32HH1MYTkOk4ZjMMVlXQHZ 8K+jyu4OsVZlS+TOGnIa8HR/aBV9bEb3wDkGIyFn+YEVMbeCDu0jhZ6swVHOtBCeQuPu HVq/nJJqhXeSFtg6esuXRL7eGecZC51uF3SD95jMK4W3TblXlLb3gbokDXWCjBHOGjo+ yI1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694964447; x=1695569247; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pDX0213p1fJnmoU0X5KIpHt/mm/mKTvDNuRIc09/tKA=; b=HOeATL6HLXneOzfgqKGseR9dlIvJOx5Fv8eAqaZMpxvnrxFJ13ECW7Aa4m2KqWnYUE foxrN0zWnWAAD2zhssDwkrmdpxSJ2FN/hSvXwIyw3ZV17qWVGZqwaj7m8ojFnhFFCN4j rgaDxzlCoXkxFE/pien/hA5BVmNGAwSH+nYpXU/7qdN8bGd0UK5ILYI4z2YpyzyYy1Or K6YEillHf6sFhUt6GskOyHPtey5R5L9+ZSoQnAEEMoA3WqkrjeeEIV0PSGA03xRFlHK3 uZF3nU1on6nb3sbutHEREDCqY1byzZNB4bD8coSU7fh1jPbokBMcjr6gdVl5C2setdnX 0YoQ== X-Gm-Message-State: AOJu0YwpN1Zg/AFeL0cU8DY9byEpxXhGUhsTl16q1HPN0OnrxM+bc5YC UgcuaU/anTjNlmjI5YWeD067PbKi1hbTGNJbsls= X-Received: by 2002:a1c:4c07:0:b0:402:ee9e:ed98 with SMTP id z7-20020a1c4c07000000b00402ee9eed98mr5577774wmf.34.1694964446673; Sun, 17 Sep 2023 08:27:26 -0700 (PDT) Received: from localhost.localdomain ([5.45.134.53]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c489700b003fe15ac0934sm7388865wmp.1.2023.09.17.08.27.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 08:27:26 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, robh+dt@kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org, linux-kernel@vger.kernel.org, abdelalkuor@geotab.com Subject: [PATCH v5 04/15] USB: typec: Load TPS25750 patch bundle Date: Sun, 17 Sep 2023 11:26:28 -0400 Message-Id: <20230917152639.21443-5-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230917152639.21443-1-alkuor@gmail.com> References: <20230917152639.21443-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sun, 17 Sep 2023 08:29:53 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777312171133387576 X-GMAIL-MSGID: 1777312171133387576 From: Abdel Alkuor TPS25750 controller requires a binary to be loaded with a configuration binary by an EEPROM or a host. Appling a patch bundling using a host is implemented based on the flow diagram pg.62 in TPS25750 host interface manual. https://www.ti.com/lit/ug/slvuc05a/slvuc05a.pdf The flow diagram can be summarized as following: - Start the patch loading sequence with patch bundle information by executing PBMs - Write the whole patch at once - When writing the patch fails, execute PBMe which instructs the PD controller to end the patching process - After writing the patch successfully, execute PBMc which verifies the patch integrity and applies the patch internally - Wait for the device to switch into APP mode (normal operation) The execuation flow diagram polls the events register and then polls the corresponding register related to the event as well before advancing to the next state. Polling the events register is a redundant step, in this implementation only the corresponding register related to the event is polled. Signed-off-by: Abdel Alkuor --- drivers/usb/typec/tipd/core.c | 237 +++++++++++++++++++++++++++++++++- 1 file changed, 236 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 6d2151325fbb..fea139c72d6d 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "tps6598x.h" #include "trace.h" @@ -43,6 +44,23 @@ /* TPS_REG_SYSTEM_CONF bits */ #define TPS_SYSCONF_PORTINFO(c) ((c) & 7) +/* + * BPMs task timeout, recommended 5 seconds + * pg.48 TPS2575 Host Interface Technical Reference + * Manual (Rev. A) + * https://www.ti.com/lit/ug/slvuc05a/slvuc05a.pdf + */ +#define TPS_BUNDLE_TIMEOUT 0x32 + +/* BPMs return code */ +#define TPS_TASK_BPMS_INVALID_BUNDLE_SIZE 0x4 +#define TPS_TASK_BPMS_INVALID_SLAVE_ADDR 0x5 +#define TPS_TASK_BPMS_INVALID_TIMEOUT 0x6 + +/* PBMc data out */ +#define TPS_PBMC_RC 0 /* Return code */ +#define TPS_PBMC_DPCS 2 /* device patch complete status */ + enum { TPS_PORTINFO_SINK, TPS_PORTINFO_SINK_ACCESSORY, @@ -88,6 +106,8 @@ struct tps6598x { struct mutex lock; /* device lock */ u8 i2c_protocol:1; + u8 is_tps25750:1; + struct typec_port *port; struct typec_partner *partner; struct usb_pd_identity partner_identity; @@ -708,6 +728,203 @@ static int devm_tps6598_psy_register(struct tps6598x *tps) return PTR_ERR_OR_ZERO(tps->psy); } +static int +tps25750_write_firmware(struct tps6598x *tps, + u8 bpms_addr, const u8 *data, size_t len) +{ + struct i2c_client *client = to_i2c_client(tps->dev); + int ret; + u8 slave_addr; + int timeout; + + slave_addr = client->addr; + timeout = client->adapter->timeout; + + /* + * binary configuration size is around ~16Kbytes + * which might take some time to finish writing it + */ + client->adapter->timeout = msecs_to_jiffies(5000); + client->addr = bpms_addr; + + ret = regmap_raw_write(tps->regmap, data[0], &data[1], len - 1); + + client->addr = slave_addr; + client->adapter->timeout = timeout; + + return ret; +} + +static int +tps25750_exec_pbms(struct tps6598x *tps, u8 *in_data, size_t in_len) +{ + int ret; + u8 rc; + + ret = tps6598x_exec_cmd(tps, "PBMs", in_len, in_data, + sizeof(rc), &rc, 4000, 0); + if (ret) + return ret; + + switch (rc) { + case TPS_TASK_BPMS_INVALID_BUNDLE_SIZE: + dev_err(tps->dev, "%s: invalid fw size\n", __func__); + return -EINVAL; + case TPS_TASK_BPMS_INVALID_SLAVE_ADDR: + dev_err(tps->dev, "%s: invalid slave address\n", __func__); + return -EINVAL; + case TPS_TASK_BPMS_INVALID_TIMEOUT: + dev_err(tps->dev, "%s: timed out\n", __func__); + return -ETIMEDOUT; + default: + break; + } + + return 0; +} + +static int tps25750_abort_patch_process(struct tps6598x *tps) +{ + int ret; + u8 mode; + + ret = tps6598x_exec_cmd(tps, "PBMe", 0, NULL, 0, NULL, 1000, 0); + if (ret) + return ret; + + ret = tps6598x_check_mode(tps, &mode); + if (mode != TPS_MODE_PTCH) + dev_err(tps->dev, "failed to switch to \"PTCH\" mode\n"); + + return ret; +} + +static int tps25750_start_patch_burst_mode(struct tps6598x *tps) +{ + int ret; + const struct firmware *fw; + const char *firmware_name; + struct { + u32 fw_size; + u8 addr; + u8 timeout; + } __packed bpms_data; + + ret = device_property_read_string(tps->dev, "firmware-name", + &firmware_name); + if (ret) + return ret; + + ret = request_firmware(&fw, firmware_name, tps->dev); + if (ret) { + dev_err(tps->dev, "failed to retrieve \"%s\"\n", firmware_name); + return ret; + } + + if (fw->size == 0) { + ret = -EINVAL; + goto release_fw; + } + + ret = device_property_read_u8(tps->dev, "ti,patch-address", &bpms_data.addr); + if (ret) { + dev_err(tps->dev, "failed to get patch address\n"); + return ret; + } + + bpms_data.fw_size = fw->size; + bpms_data.timeout = TPS_BUNDLE_TIMEOUT; + + ret = tps25750_exec_pbms(tps, (u8 *)&bpms_data, sizeof(bpms_data)); + if (ret) + goto release_fw; + + ret = tps25750_write_firmware(tps, bpms_data.addr, fw->data, fw->size); + if (ret) { + dev_err(tps->dev, "Failed to write patch %s of %lu bytes\n", + firmware_name, fw->size); + goto release_fw; + } + + /* + * A delay of 500us is required after the firmware is written + * based on pg.62 in tps6598x Host Interface Technical + * Reference Manual + * https://www.ti.com/lit/ug/slvuc05a/slvuc05a.pdf + */ + udelay(500); + +release_fw: + release_firmware(fw); + + return ret; +} + +static int tps25750_complete_patch_process(struct tps6598x *tps) +{ + int ret; + u8 out_data[40]; + u8 dummy[2] = { }; + + /* + * Without writing something to DATA_IN, this command would + * return an error + */ + ret = tps6598x_exec_cmd(tps, "PBMc", sizeof(dummy), dummy, + sizeof(out_data), out_data, 2000, 20); + if (ret) + return ret; + + if (out_data[TPS_PBMC_RC]) { + dev_err(tps->dev, + "%s: pbmc failed: %u\n", __func__, + out_data[TPS_PBMC_RC]); + return -EIO; + } + + if (out_data[TPS_PBMC_DPCS]) { + dev_err(tps->dev, + "%s: failed device patch complete status: %u\n", + __func__, out_data[TPS_PBMC_DPCS]); + return -EIO; + } + + return 0; +} + +static int tps25750_apply_patch(struct tps6598x *tps) +{ + int ret; + unsigned long timeout; + u8 mode; + + ret = tps25750_start_patch_burst_mode(tps); + if (ret) { + tps25750_abort_patch_process(tps); + return ret; + } + + ret = tps25750_complete_patch_process(tps); + if (ret) + return ret; + + timeout = jiffies + msecs_to_jiffies(1000); + + do { + ret = tps6598x_check_mode(tps, &mode); + if (ret) + return ret; + + if (time_is_before_jiffies(timeout)) + return -ETIMEDOUT; + + } while (mode != TPS_MODE_APP); + + dev_info(tps->dev, "controller switched to \"APP\" mode\n"); + + return 0; +}; + static int tps6598x_probe(struct i2c_client *client) { irq_handler_t irq_handler = tps6598x_interrupt; @@ -757,6 +974,8 @@ static int tps6598x_probe(struct i2c_client *client) irq_handler = cd321x_interrupt; } else { + + tps->is_tps25750 = of_device_is_compatible(np, "ti,tps25750"); /* Enable power status, data status and plug event interrupts */ mask1 = TPS_REG_INT_POWER_STATUS_UPDATE | TPS_REG_INT_DATA_STATUS_UPDATE | @@ -769,9 +988,15 @@ static int tps6598x_probe(struct i2c_client *client) if (ret) return ret; + if (tps->is_tps25750 && mode == TPS_MODE_PTCH) { + ret = tps25750_apply_patch(tps); + if (ret) + return ret; + } + ret = tps6598x_write64(tps, TPS_REG_INT_MASK1, mask1); if (ret) - return ret; + goto err_reset_controller; ret = tps6598x_read32(tps, TPS_REG_STATUS, &status); if (ret < 0) @@ -891,6 +1116,10 @@ static int tps6598x_probe(struct i2c_client *client) fwnode_handle_put(fwnode); err_clear_mask: tps6598x_write64(tps, TPS_REG_INT_MASK1, 0); +err_reset_controller: + /* Reset PD controller to remove any applied patch */ + if (tps->is_tps25750) + tps6598x_exec_cmd(tps, "GAID", 0, NULL, 0, NULL, 2000, 0); return ret; } @@ -901,9 +1130,14 @@ static void tps6598x_remove(struct i2c_client *client) if (!client->irq) cancel_delayed_work_sync(&tps->wq_poll); + devm_free_irq(tps->dev, client->irq, tps); tps6598x_disconnect(tps, 0); typec_unregister_port(tps->port); usb_role_switch_put(tps->role_sw); + + /* Reset PD controller to remove any applied patch */ + if (tps->is_tps25750) + tps6598x_exec_cmd(tps, "GAID", 0, NULL, 0, NULL, 2000, 0); } static int __maybe_unused tps6598x_suspend(struct device *dev) @@ -946,6 +1180,7 @@ static const struct dev_pm_ops tps6598x_pm_ops = { static const struct of_device_id tps6598x_of_match[] = { { .compatible = "ti,tps6598x", }, { .compatible = "apple,cd321x", }, + { .compatible = "ti,tps25750", }, {} }; MODULE_DEVICE_TABLE(of, tps6598x_of_match); From patchwork Sun Sep 17 15:26:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 141161 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2209644vqi; Sun, 17 Sep 2023 09:28:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEfuDNsGfU3JR5/DSr5ISN5OlIJSFkjaz1rw3O5LGfIrBNN5w3lNo7hWS+3zq5MV67sZhh0 X-Received: by 2002:a05:6a00:24ca:b0:686:6e90:a99b with SMTP id d10-20020a056a0024ca00b006866e90a99bmr6721941pfv.25.1694968081773; Sun, 17 Sep 2023 09:28:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694968081; cv=none; d=google.com; s=arc-20160816; b=o3gWfRKTBoAp1LZ9hnukd+jRyWiqlHq57UVsEROq/XiYLcC7ftiXPHhuhppURT/XBH 580Bn5nmqsTzRaObtMvB86/+rpZajoLimPSZJNAknNXw9c0qWJHPs+p5q11AKH4KIXVN bws/VAqwTYOSHSeIP1xj/CrZjuc8KKgfjwgzzqaA4GUvWuBPR5F8bRB4Yw6c/zP5uZo+ M4RLyqj+leC5R3docZSWUY572xn1WzM4AddxdpSdLMVLt+0yz23jNFPZLnljmIi7gopD 9n32XIVCjvTf/VNUcHq6VOJHt5CKhcSsDUlceTg3RUyT2B5zcjATdYqaZeTBefLmzQmP 1h+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KkNrm9xtXH99tqSrPhCbYDtc/M1xV92D12c2YjQETGI=; fh=1TLHXZLxbVW/pzxFCwcQN1QIszWWCFgsgFdloZrlyPk=; b=ufHQ/Kpq9td7BvVjBtnFFkpTzDxqcXOxSI+z71w1pl37HkOEuE8aTb71D+95O9BdJC +M9MwVGdgJ0HB4dXnWFsUxTefGLxnmaXrOEb28l355mIJYUsclDl4hoiDatviY6eTsWN Idl98N3Duz2dUMpNfr0UhsGggVEcaRqzDYlWpvUl28JYh8TbCeM+jNt8sFoyrQeEePhx Gsd9UhfSb8CGgYAKIRg4CxuODZc3xBNP351xi/mjK8eq0rXD6j3BnmZqhmcpARIWPecb qFCMPKP5lCeEG2Qhw2KhGRrMSQA7hpoIdvoc3wvL+siPUe0EEz29qOd0j7Um+zois/O9 oFbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=aogjEkaB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id ca20-20020a056a02069400b00573f7e9d75asi7010818pgb.646.2023.09.17.09.28.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 09:28:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=aogjEkaB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 0758C80834B4; Sun, 17 Sep 2023 08:30:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236607AbjIQP2H (ORCPT + 29 others); Sun, 17 Sep 2023 11:28:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234517AbjIQP1g (ORCPT ); Sun, 17 Sep 2023 11:27:36 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C37DA185; Sun, 17 Sep 2023 08:27:30 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4018af103bcso23912895e9.1; Sun, 17 Sep 2023 08:27:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694964449; x=1695569249; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KkNrm9xtXH99tqSrPhCbYDtc/M1xV92D12c2YjQETGI=; b=aogjEkaBR8yLMPdyt4g8752HEughiOQ6K89G+PPV7D8jZfzNtXps1jGAuq8dAE4TZm u6wcbwaKV+icKf2Osy9D2qyPa3uAD+U7Q9eUSUreWcCV+Zc4Qa64K64TTG5AoFXBdLSX 0gz9zt/qp5b8fqLrXqfJgt/A4CbJjYEhBEjB2rq+OMKCXmpNZ8XpsCez63jWYGTBG6mW BFQyTYXBpLyuVmsFx+/QrK4dpC9ZAX7MekOVrO2qdNOZqnVB/DX4x2o6x1/IX1j9GyTz JlAGvJ8jweh/lQ0T6VJbI7cKQBjDVFGuUhO9240bp8nFGxM2TsGr0KCYmYerZ5PNiKc8 H0yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694964449; x=1695569249; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KkNrm9xtXH99tqSrPhCbYDtc/M1xV92D12c2YjQETGI=; b=lSKNEPnJlgDaqn7uPDZeb6kK5Y3rJob6h09h/IQPBv5IJqWK90Ymes5bcP8tWfhOQ7 u5/VoA1xXhGkHOztZnVYfcZNCjbfmke3/VXGtmzsax3qHRr+9bqCim2prTXRm8SjgwNr 9bv5Km+tatCw9c3UrczFH+LAx/fJuI0Z73CI95iWDAvPKJpmtqMWo1VgiYLiBk0vzDvR 63/hh6+MKqoURzOPdh/qWmpeSToC62ZbPIu6ygANVxjaKIbkcYjdctDlFHnxTTmhsDaT omEld1qstTOFPE91R3K47GtOUYrRgXtVvPNnx9pBi0dS7eyUudtyVqY0tLWUUTO3uKXQ H60g== X-Gm-Message-State: AOJu0Yz1P9tUqtesNdRcfp/9zDkz5XpOR9w2a2TPAAkgxY89ykPxkMpg pCE+pf2xuNfyTkl21VnXtx4= X-Received: by 2002:a05:600c:b4b:b0:401:c7ec:b930 with SMTP id k11-20020a05600c0b4b00b00401c7ecb930mr7025504wmr.10.1694964449178; Sun, 17 Sep 2023 08:27:29 -0700 (PDT) Received: from localhost.localdomain ([5.45.134.53]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c489700b003fe15ac0934sm7388865wmp.1.2023.09.17.08.27.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 08:27:28 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, robh+dt@kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org, linux-kernel@vger.kernel.org, abdelalkuor@geotab.com Subject: [PATCH v5 05/15] USB: typec: Check for EEPROM present Date: Sun, 17 Sep 2023 11:26:29 -0400 Message-Id: <20230917152639.21443-6-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230917152639.21443-1-alkuor@gmail.com> References: <20230917152639.21443-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Sun, 17 Sep 2023 08:30:50 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777302851399409336 X-GMAIL-MSGID: 1777302851399409336 From: Abdel Alkuor When an EEPROM is present, tps25750 loads the binary configuration from EEPROM. Hence, all we need to do is wait for the device to switch to APP mode Signed-off-by: Abdel Alkuor --- drivers/usb/typec/tipd/core.c | 13 +++++++++++++ drivers/usb/typec/tipd/tps6598x.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index fea139c72d6d..b3d4b2b5bf5f 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -37,6 +37,7 @@ #define TPS_REG_STATUS 0x1a #define TPS_REG_SYSTEM_CONF 0x28 #define TPS_REG_CTRL_CONF 0x29 +#define TPS_REG_BOOT_STATUS 0x2D #define TPS_REG_POWER_STATUS 0x3f #define TPS_REG_RX_IDENTITY_SOP 0x48 #define TPS_REG_DATA_STATUS 0x5f @@ -897,6 +898,17 @@ static int tps25750_apply_patch(struct tps6598x *tps) int ret; unsigned long timeout; u8 mode; + u64 status = 0; + + ret = tps6598x_block_read(tps, TPS_REG_BOOT_STATUS, &status, 5); + if (ret) + return ret; + /* + * Nothing to be done if the configuration + * is being loaded from EERPOM + */ + if (status & TPS25750_BOOT_STATUS_I2C_EEPROM_PRESENT) + goto wait_for_app; ret = tps25750_start_patch_burst_mode(tps); if (ret) { @@ -908,6 +920,7 @@ static int tps25750_apply_patch(struct tps6598x *tps) if (ret) return ret; +wait_for_app: timeout = jiffies + msecs_to_jiffies(1000); do { diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps6598x.h index 527857549d69..5e942c089c27 100644 --- a/drivers/usb/typec/tipd/tps6598x.h +++ b/drivers/usb/typec/tipd/tps6598x.h @@ -199,4 +199,7 @@ #define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_A BIT(2) #define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_B (BIT(2) | BIT(1)) +/* BOOT STATUS REG*/ +#define TPS25750_BOOT_STATUS_I2C_EEPROM_PRESENT BIT(3) + #endif /* __TPS6598X_H__ */ From patchwork Sun Sep 17 15:26:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 141198 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2296279vqi; Sun, 17 Sep 2023 13:55:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEzRbQNxjuJiXFr7fdyHsIy28sybgbWHOZXHv9I6eELEPHTdhDF0RWfrhmZWxG2etKYs3U4 X-Received: by 2002:a17:90a:ba88:b0:276:7683:70f6 with SMTP id t8-20020a17090aba8800b00276768370f6mr22270pjr.33.1694984125354; Sun, 17 Sep 2023 13:55:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694984125; cv=none; d=google.com; s=arc-20160816; b=elgHBNCT8QOEAjL3kabxODPQiMpaz7gDqZwvM7ia61luvZmlrNvJHyFFavaesBsmyM cZ7mVLXiecyzDITlGxMWdeNaATzrtK0Kpvo92/F3roJVdwZ+5Jw3T5aLUemAjV+eW7SO LAt0ekFXlNvnWv9l0eD4ng9rutYN889z944B4/uVV1DFAIrBc5l8hT0vrKbKBxvO7Lio BuVNzT983zHfSdIIUYNJb1nO3O1fP38TFERMp5zLyUtYBtT3AwjyUX2WdXyMDGANWBzo w7uAi8YDa0FOo/jtaj2QlhE7IRpClg909nFXsPsPNoLUvxjBuqRTnCHsJTqkIdyOEkZE y0gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6/OQx1tSDBSLV+D4ziu7/m5M5iv3V8DehxeIrYNTs6k=; fh=1TLHXZLxbVW/pzxFCwcQN1QIszWWCFgsgFdloZrlyPk=; b=NrAjBURyQ4SRgSVXNlbe+5Oqcb66+1uVh1El8rNH+Yuw4OyJG7MNDPSZVgQIvITAcR f+AG/VD8z2X8JRA5cV8WejPpAivvqniWqSl9C+a45tgALF6xbd9+9wS4P2FtFQVA2R25 p1DCbPkmmxz35KSbrtkCJwoBqkXyabBT+0URcq5iavd1IOjvcT+9bnla9BLRAnrnOkv9 OML8IjMkDf3uNLy/Hoq31MjDzWVGNmQ8OjLmNisVDBWAzvbJ1QwB5LaqcWHVJNu/Arha ojWlZfFB/JNSUjAn9xzse1xAACdAY6K+7tcpcicEsPMJEvYBjvgH70TyJYlRdogYk5u7 1KLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="Ytc/HWWA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id in19-20020a17090b439300b002613720fcd5si4512376pjb.35.2023.09.17.13.55.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 13:55:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="Ytc/HWWA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 27D0F80834BB; Sun, 17 Sep 2023 08:30:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236759AbjIQP2I (ORCPT + 29 others); Sun, 17 Sep 2023 11:28:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234619AbjIQP1i (ORCPT ); Sun, 17 Sep 2023 11:27:38 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FF4811F; Sun, 17 Sep 2023 08:27:33 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40472f9db24so36127975e9.2; Sun, 17 Sep 2023 08:27:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694964452; x=1695569252; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6/OQx1tSDBSLV+D4ziu7/m5M5iv3V8DehxeIrYNTs6k=; b=Ytc/HWWA3p5zxh6JakRudNaXgI+twkdnmUQq47NuopbX7bnclWdSso0UfyJhVlXs2p Edq+vcUSI9YguteMiK93br2XtFrNP+LPZaa5SJhDFFuNzav77ZTN+TK67qKTPF6j/BjE dUzj8uN+kf4vd5ByP0W0Ji/7/ugm4IdXWL2YcqOF2xK6UK16Ll9IQL7U8IrvcLvj9vAY 2n06uXoXLr5GDETTWdXZaJH9GaRcyF4eQjCtP+UcJrsXnoIhORfMg2lVUUrpBsN2rmnM TUoZFsoGrgyIpMNUCgEozlPT2BeRJD0V0vFhOUHsbdR5Nnvy53+jpyw2fuJ/P0XPSa92 hCcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694964452; x=1695569252; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6/OQx1tSDBSLV+D4ziu7/m5M5iv3V8DehxeIrYNTs6k=; b=SNEVZSYKMjyz01UmGZGoe9CBdDBt7R8jQc5TBam9vOoXdrH2ll3vx3dkHi/W1CbzQf 71PdwL+9SGifPdsFI07L0fAVPKO9Zv3I25sxaCuOVHjdY4hSo6UqTJ1tUzA61rEw0fJi 9X/X85RiVYO1s+ayRRl0W2ZDEQYSm2e0EMijtoei/sH5//QFMlZLk/oiciXSZh6AOi7D vfMTu/YP7wKiy0s89QzG0wkCzqcUBhzvqsZ7NFahBR8xzpjTL2BEQKiWwvo+vLToGcF/ JTdZcoGjCRPd0UsOTEiSy9a1OXTy0KPY2fUPAUF0SRd43hpS+dWtpdAw9DwhBKtvQwJz bDCA== X-Gm-Message-State: AOJu0Yy4m6dVF6M7ld1RaNUhtQWj/aW/K87wdTuK8ovyFFUtiH7eHfr7 3Ijfa/8CQt+FqBLL+jXkidQ= X-Received: by 2002:a7b:c44b:0:b0:401:b2c7:349d with SMTP id l11-20020a7bc44b000000b00401b2c7349dmr6696119wmi.29.1694964451804; Sun, 17 Sep 2023 08:27:31 -0700 (PDT) Received: from localhost.localdomain ([5.45.134.53]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c489700b003fe15ac0934sm7388865wmp.1.2023.09.17.08.27.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 08:27:31 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, robh+dt@kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org, linux-kernel@vger.kernel.org, abdelalkuor@geotab.com Subject: [PATCH v5 06/15] USB: typec: Clear dead battery flag Date: Sun, 17 Sep 2023 11:26:30 -0400 Message-Id: <20230917152639.21443-7-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230917152639.21443-1-alkuor@gmail.com> References: <20230917152639.21443-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Sun, 17 Sep 2023 08:30:56 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777319674083653680 X-GMAIL-MSGID: 1777319674083653680 From: Abdel Alkuor Dead battery flag must be cleared after switching tps25750 to APP mode so the PD controller becomes fully functional. Signed-off-by: Abdel Alkuor --- drivers/usb/typec/tipd/core.c | 16 ++++++++++++++++ drivers/usb/typec/tipd/tps6598x.h | 1 + 2 files changed, 17 insertions(+) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index b3d4b2b5bf5f..3ad8112c78b6 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -933,6 +933,22 @@ static int tps25750_apply_patch(struct tps6598x *tps) } while (mode != TPS_MODE_APP); + /* + * The dead battery flag may be triggered when the controller + * port is connected to a device that can source power and + * attempts to power up both the controller and the board it is on. + * To restore controller functionality, it is necessary to clear + * this flag + */ + if (status & TPS_BOOT_STATUS_DEAD_BATTERY_FLAG) { + ret = tps6598x_exec_cmd(tps, "DBfg", 0, NULL, 0, NULL, 1000, 0); + if (ret) { + dev_err(tps->dev, + "failed to clear dead battery %d\n", ret); + return ret; + } + } + dev_info(tps->dev, "controller switched to \"APP\" mode\n"); return 0; diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps6598x.h index 5e942c089c27..362e1eca53ad 100644 --- a/drivers/usb/typec/tipd/tps6598x.h +++ b/drivers/usb/typec/tipd/tps6598x.h @@ -200,6 +200,7 @@ #define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_B (BIT(2) | BIT(1)) /* BOOT STATUS REG*/ +#define TPS_BOOT_STATUS_DEAD_BATTERY_FLAG BIT(2) #define TPS25750_BOOT_STATUS_I2C_EEPROM_PRESENT BIT(3) #endif /* __TPS6598X_H__ */ From patchwork Sun Sep 17 15:26:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 141176 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2254609vqi; Sun, 17 Sep 2023 11:36:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IECmR5PBbkExh8KvvCs7FKMSwDKFgBLiF5o9AeR5N/7SHwv1MOlG2ioyrQGwaSmWHdlDUaL X-Received: by 2002:a17:90b:1e43:b0:276:66e8:f7fd with SMTP id pi3-20020a17090b1e4300b0027666e8f7fdmr927189pjb.22.1694975774837; Sun, 17 Sep 2023 11:36:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694975774; cv=none; d=google.com; s=arc-20160816; b=uDrZAGC6SEJCTAV16Gv4ShxEvpVJbZj3LXLoSqLb/3nYKQS5LqWXhKk6wh+PdXP6D+ xXkxwPrbBUrV7pVD8XtOK0UxyWVOw9+m2MPzROk6UuWp0gdIre1II0t6sxlUigSdP9ir jDB1Qv5okyNnBysNPb4ewSRUeWK5xhp+pzVPlY5UYxmK3cUCjWBZtovdumsWZWqHwVlD CBtjqUXZyFzy0cvsoJhQnvZPk4Tim0jaMeWmkM4cSXXlbvS16XpbOYtqXUOJYi27K3hn cqozXbTbJlE9xuEkHbO0P14WjMaED8mi8Ed2SUWi2/XhB37UWi13fbzkQ0jCz1pkSsN4 w9sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KQmw68BxoRUha7oPFqTU+EThuQkLbUrzB5b28thzr/w=; fh=1TLHXZLxbVW/pzxFCwcQN1QIszWWCFgsgFdloZrlyPk=; b=yhhqcK4Asli5mT2ym20mf8ZTXjYdK2Z8iS/5cbzvhJhBlcxYdrxshOGjwf5qwc+wd3 lI27+wyln9sgpnXDr4tj04KTzu3IE3zB/NMTWzY7SSWprtc9KWPKW1lLzjaa117Ai7Zu 0sJ2MAZimzTFF1C3OXvTZ4ptzpgL6oY8lvD9WfgiUjsjPlMZEPxXviN2cAqx6JXN5pb3 cjGG90jKCyiAPuUKTWx7ZeM8pjiFQU4MezIQmjDwkBg7kiieoqHt0idgXOlZ90JXf+rT C8GWw74jvmoR4ZRgTk9VfGEPDd+2YYWCDXvgkj9FOxe00PawJJTYg+XRHHju2GZXn3H4 /Ybw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="PNP/Km3+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id ng7-20020a17090b1a8700b0026376acd6fesi7172958pjb.22.2023.09.17.11.36.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 11:36:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="PNP/Km3+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id D81AA80C9A56; Sun, 17 Sep 2023 08:31:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236930AbjIQP2K (ORCPT + 29 others); Sun, 17 Sep 2023 11:28:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234667AbjIQP1l (ORCPT ); Sun, 17 Sep 2023 11:27:41 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AE5711F; Sun, 17 Sep 2023 08:27:36 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-40479f8325fso27476235e9.1; Sun, 17 Sep 2023 08:27:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694964454; x=1695569254; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KQmw68BxoRUha7oPFqTU+EThuQkLbUrzB5b28thzr/w=; b=PNP/Km3+QM9MWFoWr2JMVGrGbtl5kNIa9gKQ32lro2WIkUwF0xG16PV8r1zlAjF2fu 9L7EzM2+HHDLPnx2+3j7lBTIS5x6hHLDXMDtTeyJMxGLEM6e6iiYBYb4TEL/AHmbmLTn YGCVLKA7+3MiREH3UsYu1/C5C5y1RBbeQvSuUeCqr+MMnYSun70XznzRQPZGj0FIQ5uR eNcv/IFZfsEEcuhq5WReFmXW3T+GQ9iLdP6114eljbScokvEL85gua3wqwxzPKXOg7XS gUykcTRvuGGLMXBWLbTn+5DCo3gGupX666zRc30f6P24KJfjaAa1YJKgs/BKHVYPuClu aYgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694964454; x=1695569254; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KQmw68BxoRUha7oPFqTU+EThuQkLbUrzB5b28thzr/w=; b=GH9cT7K/lW3tnujngpPDTF1nG8hLL+rZ4TrDLi6G+O3Ho10sddAx77omGTP3wyOkYc APRp7Hh84HamemtFpELkpoxiIvHzZB7xek5rPed1BlLnmoCPfHabw3v67frtR117giqw GQpiIkJwe1XJFXdZeeJOzIsQBwAiCT0VXdjTuknGanWr0ILFE6MlfXmR5Js78AnF0aXY Q3LMVpFTsgnEr1nZKBgVYS+ZjJ8Gx0qGQgVy7vzRu3FY3JBUv7Q0EvVPAGL5oRS5gVTx TJHWeZGiy6uEQU3jBaDi0c4836ZtT4ppuos/8CuBqqgoNFQlZnJgvR9bg/Y5v6ote/Bf cOCw== X-Gm-Message-State: AOJu0Yw8XFq3aYxJ4X5RH6u6a2+rO/nGKvq+Hu4mRva4L1ZNzwkq7PFz kbU393D//5XgSrt9VS1U+vs= X-Received: by 2002:a7b:c415:0:b0:403:442:5421 with SMTP id k21-20020a7bc415000000b0040304425421mr5271816wmi.4.1694964454299; Sun, 17 Sep 2023 08:27:34 -0700 (PDT) Received: from localhost.localdomain ([5.45.134.53]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c489700b003fe15ac0934sm7388865wmp.1.2023.09.17.08.27.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 08:27:33 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, robh+dt@kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org, linux-kernel@vger.kernel.org, abdelalkuor@geotab.com Subject: [PATCH v5 07/15] USB: typec: Apply patch again after power resume Date: Sun, 17 Sep 2023 11:26:31 -0400 Message-Id: <20230917152639.21443-8-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230917152639.21443-1-alkuor@gmail.com> References: <20230917152639.21443-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Sun, 17 Sep 2023 08:31:14 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777310918129223141 X-GMAIL-MSGID: 1777310918129223141 From: Abdel Alkuor TPS25750 PD controller might be powered off externally at power suspend, after resuming PD controller power back, apply the patch again. Signed-off-by: Abdel Alkuor --- drivers/usb/typec/tipd/core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 3ad8112c78b6..bd5436fd88fd 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -1189,6 +1189,18 @@ static int __maybe_unused tps6598x_resume(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct tps6598x *tps = i2c_get_clientdata(client); + u8 mode; + int ret; + + ret = tps6598x_check_mode(tps, &mode); + if (ret) + return ret; + + if (mode == TPS_MODE_PTCH) { + ret = tps25750_apply_patch(tps); + if (ret) + return ret; + } if (tps->wakeup) { disable_irq_wake(client->irq); From patchwork Sun Sep 17 15:26:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 141162 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2212820vqi; Sun, 17 Sep 2023 09:35:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEfakA4AoTXzfgHUQzIBUUCjM3tOvZWCwML8UCw0SMOVulq6ifa8y/5aRO1wP5j8wwSarKU X-Received: by 2002:a05:6a20:4306:b0:14c:7b5d:1fe0 with SMTP id h6-20020a056a20430600b0014c7b5d1fe0mr9337709pzk.3.1694968550901; Sun, 17 Sep 2023 09:35:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694968550; cv=none; d=google.com; s=arc-20160816; b=rHQYXVLjMPrZsigdtSmwnlx126LZ1P84+8yRH5ZQH6nFI9SSsZBl+m6S9sgvha4qxR Jd+aFLJd7qb1c+mDpiz+W2aGshN40AF/qOyuSrSh7BJPVhwhsW6VMg5VhCLcsWZ+VyO7 nj5voKykGN9xPQ4zha618f5GYWY3W2FCwdQuvzwCoY1NN2eiRAJVRxOusqV7tpgeutUP SksfezWlKAYPLGKxw3lUdeTtTgERVmhtfbgS74bJp98WOqjUkHxef05+crGlUASBJ2NI WhU5O4QjwBdNe3azr4ryh5HoUc409KUVj3Un5qdCJCRV9BKh5zQSVEvT1qbC/8yTeOz0 v9aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6tQbjNBA0eBP8DdL0NmRWM+a5YA5TtpgDMffVlXzxR0=; fh=1TLHXZLxbVW/pzxFCwcQN1QIszWWCFgsgFdloZrlyPk=; b=KwHArW1PUIdHOH819Lq0OUN2HA+PMmHKFPcUNZ65dcGMZjlvlziipcWDtYzHfdcJAW cVHjmTy4CwxJv1Jj9fB+eFdsYqmpa4Hilb+oldZW2PJ6/fqph9XHWSEG3l6y+57k7tgy 4D346C2Y59RfJr4/MUVrMDQWCSJMUNVs+go/g7dE4Q21pyfKKvZjlEP8Wlcv/E2PHrvu wbi/IF1Zuc0Dp9G9U4t1nGr8EL+eHvHx/XvqKiLzXG5RaIz1Q0B/mTLwRvIKq3OeDZFD kEJ0F2ihUJcYcIC6LTWCg50nb4ptScNJ31puv7fe7ZIfSlIvqNVPVXGw8q6oQVjHXX2I Bsww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=LVAOd8qj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id f21-20020a056a00229500b0068e3e4f5b90si6941189pfe.10.2023.09.17.09.35.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 09:35:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=LVAOd8qj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 7FDD68087FE6; Sun, 17 Sep 2023 08:31:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237002AbjIQP2L (ORCPT + 29 others); Sun, 17 Sep 2023 11:28:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234679AbjIQP1o (ORCPT ); Sun, 17 Sep 2023 11:27:44 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2AEE187; Sun, 17 Sep 2023 08:27:38 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40472c3faadso35587655e9.2; Sun, 17 Sep 2023 08:27:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694964457; x=1695569257; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6tQbjNBA0eBP8DdL0NmRWM+a5YA5TtpgDMffVlXzxR0=; b=LVAOd8qjwniXU/6gVi88gXGJZWSjTWRpGnnDO21kBvYTpG20pMQFQtIG9j4LET9i8C Bu2vJqCa3Kyl6dWH7ds/ZyITW9zSVsnuDJSbjxYgafKPqyQ4uQNcfGtApAiCTzhgInAo ErlRHP0imguDxh0SDaCLJ6ShaYmsCXEaBJ+prPuvivp2AqKbIYo3hPhIlJNm7sSzj5NN lCIfh0NDiUMBGB8ZRqxI1M+ARUdEBj73mSRaknMLpw77fWTLoFjij1fHj3L1z2zfCIPs Zth+RMDurKJya37AUeHRxYXnJT7Qs08n3R15NHRHFOArHcQZjkNB/S/DWbWe1NhQPQhW k46A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694964457; x=1695569257; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6tQbjNBA0eBP8DdL0NmRWM+a5YA5TtpgDMffVlXzxR0=; b=MHmtSipM8is/pDhjVslD95Li27Rd6DP3f89HpGFM6GSklnd++G5/OYSHgNz5w6/2Bo v5FPPCA5pY/ce+ASg7LpMqqVf+YUq+fQu0j04fxl8DJy0mVxDAUAWgRu4vbo/wKVru6r fcAQHNoNgR+MDIC1XSYHUh2QVCyTH6ljfo7CPiWk7xMbThlcHCKBIfVVUC5qGKa/vo6/ wkEE2p+cCANbcQmnqTNOgDMpUXiV5OGnpoJiEbmzq4E1x4zfNQ1FmisxcplJhZFF1qzE PnZGDWn0MYJvXHR/lxais6czmLnwG0SG4hBPo+fakdsBCyZ9dn3jLSOEkPBBnRmUjMKO X5hg== X-Gm-Message-State: AOJu0YzP1/edZyfheOrxCGobklPPpA7C1Icma/qODkat/Uh/cnz0EF11 g7okfM00bVF+DcNgBdYBvDQ= X-Received: by 2002:a1c:4c0f:0:b0:402:fec4:fddc with SMTP id z15-20020a1c4c0f000000b00402fec4fddcmr5523275wmf.17.1694964457063; Sun, 17 Sep 2023 08:27:37 -0700 (PDT) Received: from localhost.localdomain ([5.45.134.53]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c489700b003fe15ac0934sm7388865wmp.1.2023.09.17.08.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 08:27:36 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, robh+dt@kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org, linux-kernel@vger.kernel.org, abdelalkuor@geotab.com Subject: [PATCH v5 08/15] USB: typec: Add interrupt support for TPS25750 Date: Sun, 17 Sep 2023 11:26:32 -0400 Message-Id: <20230917152639.21443-9-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230917152639.21443-1-alkuor@gmail.com> References: <20230917152639.21443-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sun, 17 Sep 2023 08:31:19 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777303342998746914 X-GMAIL-MSGID: 1777303342998746914 From: Abdel Alkuor Update tps6598x interrupt handler to accommodate tps25750 interrupt Signed-off-by: Abdel Alkuor --- drivers/usb/typec/tipd/core.c | 49 +++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index bd5436fd88fd..17b3bc480f97 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -120,6 +120,7 @@ struct tps6598x { enum power_supply_usb_type usb_type; int wakeup; + u32 status; /* status reg */ u16 pwr_status; struct delayed_work wq_poll; irq_handler_t irq_handler; @@ -539,50 +540,71 @@ static irqreturn_t cd321x_interrupt(int irq, void *data) return IRQ_NONE; } +static bool tps6598x_has_role_changed(struct tps6598x *tps, u32 status) +{ + status ^= tps->status; + + return status & (TPS_STATUS_PORTROLE | TPS_STATUS_DATAROLE); +} + static irqreturn_t tps6598x_interrupt(int irq, void *data) { struct tps6598x *tps = data; - u64 event1 = 0; - u64 event2 = 0; + u64 event[2] = { }; u32 status; int ret; mutex_lock(&tps->lock); - ret = tps6598x_read64(tps, TPS_REG_INT_EVENT1, &event1); - ret |= tps6598x_read64(tps, TPS_REG_INT_EVENT2, &event2); + if (tps->is_tps25750) { + ret = tps6598x_block_read(tps, TPS_REG_INT_EVENT1, event, 11); + } else { + ret = tps6598x_read64(tps, TPS_REG_INT_EVENT1, &event[0]); + ret |= tps6598x_read64(tps, TPS_REG_INT_EVENT2, &event[1]); + } + if (ret) { dev_err(tps->dev, "%s: failed to read events\n", __func__); goto err_unlock; } - trace_tps6598x_irq(event1, event2); + trace_tps6598x_irq(event[0], event[1]); - if (!(event1 | event2)) + if (!(event[0] | event[1])) goto err_unlock; if (!tps6598x_read_status(tps, &status)) goto err_clear_ints; - if ((event1 | event2) & TPS_REG_INT_POWER_STATUS_UPDATE) + if ((event[0] | event[1]) & TPS_REG_INT_POWER_STATUS_UPDATE) if (!tps6598x_read_power_status(tps)) goto err_clear_ints; - if ((event1 | event2) & TPS_REG_INT_DATA_STATUS_UPDATE) + if ((event[0] | event[1]) & TPS_REG_INT_DATA_STATUS_UPDATE) if (!tps6598x_read_data_status(tps)) goto err_clear_ints; - /* Handle plug insert or removal */ - if ((event1 | event2) & TPS_REG_INT_PLUG_EVENT) + /* + * data/port roles could be updated independently after + * a plug event. Therefore, we need to check + * for pr/dr status change to set TypeC dr/pr accordingly. + */ + if ((event[0] | event[1]) & TPS_REG_INT_PLUG_EVENT || + tps6598x_has_role_changed(tps, status)) tps6598x_handle_plug_event(tps, status); + tps->status = status; err_clear_ints: - tps6598x_write64(tps, TPS_REG_INT_CLEAR1, event1); - tps6598x_write64(tps, TPS_REG_INT_CLEAR2, event2); + if (tps->is_tps25750) { + tps6598x_block_write(tps, TPS_REG_INT_CLEAR1, event, 11); + } else { + tps6598x_write64(tps, TPS_REG_INT_CLEAR1, event[0]); + tps6598x_write64(tps, TPS_REG_INT_CLEAR2, event[1]); + } err_unlock: mutex_unlock(&tps->lock); - if (event1 | event2) + if (event[0] | event[1]) return IRQ_HANDLED; return IRQ_NONE; } @@ -1003,7 +1025,6 @@ static int tps6598x_probe(struct i2c_client *client) irq_handler = cd321x_interrupt; } else { - tps->is_tps25750 = of_device_is_compatible(np, "ti,tps25750"); /* Enable power status, data status and plug event interrupts */ mask1 = TPS_REG_INT_POWER_STATUS_UPDATE | From patchwork Sun Sep 17 15:26:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 141182 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2264321vqi; Sun, 17 Sep 2023 12:07:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFiP/wOYY9erBiSA/vf5EeLwyaLIxWfWnsg4/rcKic5Foq49YmEFqHUYXr+3Wbwv65OhrTo X-Received: by 2002:a05:6808:15a4:b0:3a7:56a5:4251 with SMTP id t36-20020a05680815a400b003a756a54251mr9979864oiw.16.1694977631846; Sun, 17 Sep 2023 12:07:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694977631; cv=none; d=google.com; s=arc-20160816; b=wMCCXCNt2+gurDHGBBAZcnoIS8A+m252i7ejOeWQs3Q3RAdQLTuLLFfe3Xai3jcBH2 G7xJBqu48fcp65I18Dvj8VgpyxZGZAX92MCTujrypQbjLeDV6SI4oNcv22DQElnAItqi lv+IpVga5Xn4zmzafe+/pW4rr2uXeWq7bzW07H+m07kvnLwL6uKqVzh0ad675BrTeuoe +kKeBsKdScRhpupApp90WR3eBxzzFAEwxnIacRlKGD8vpuIxS/YHUK/b7BgaWpC2I5AV t/9CxosRBgQZEulrqkucUGh3YQQE0NuxpieVgrVe8k2sb3OvP8IURFp6d8ENiloZ8XeB CYxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DBK+EuhlZqztM+Alma3nr5nA9Qm2t1d0t11jSRG7m0Q=; fh=1TLHXZLxbVW/pzxFCwcQN1QIszWWCFgsgFdloZrlyPk=; b=ZWp60fqVZmbY3mJRCDX4wVBs35YyonlO68Ek9MJRY9bjgZIZwg8UosElwJh50t2s6w ynYlOsfwMeQ1iuTFk0pli/cXMLLOjn6XDTN7vrdPWfnN0bqR7xqBR6Z0ESYTGHIbfc8e KHz0poM+ttbvuJ5utogm/4CQkq+K91TduFe2/EYDNuQL8J2Ach2it0cYDAAkP5huoVUb T+Idqm/TCRTY9mx6253L3GDGkLn648B/2F1qqtEpCQ+P+H7BZ4AX5K89Lmvz+4My5Uob z/g83kP2XaEJRD8a9AJ6dfQc8h8BhEGcGgTHJgO8PRZ5xuH7N7vRbxIwhCGevw4LZDfY ymfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cc1gvsdw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id a6-20020a656406000000b0056949ba3f3fsi6677799pgv.253.2023.09.17.12.07.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 12:07:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cc1gvsdw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 590BF80AC479; Sun, 17 Sep 2023 08:32:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237123AbjIQP2N (ORCPT + 29 others); Sun, 17 Sep 2023 11:28:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234782AbjIQP1r (ORCPT ); Sun, 17 Sep 2023 11:27:47 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8940211F; Sun, 17 Sep 2023 08:27:41 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-32003aae100so564774f8f.0; Sun, 17 Sep 2023 08:27:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694964460; x=1695569260; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DBK+EuhlZqztM+Alma3nr5nA9Qm2t1d0t11jSRG7m0Q=; b=cc1gvsdwENHqJp29Yvy07Smcane7fTY7Hu3q0f2pkmamlPuceshYhxFMCnrXodWFM+ pDNxuHdRu/Q0iaC2hBbgnN56hwMEZ9NtUgdnZc6l+crZ8SaFMCedxYkHOjqv+Em68ybU UXHG8TIkhU/su077BkjTi9nyMblAJrI1rz5e/gwJVLcq/FqdIYjLbvJx1NE+fEXy2c3n Fo21Q3JPl0xFCjJ90v597ZaYi96ZX8SNjUYxymwGMngDqBiKiul76ofMZ8eT8L9sAMXE qjeA+pGQiADzJuG92pee48Iq4HtLgh82RqZbnoMiPg53a0RHoJjbDzOo8TBZSkvFEbkG Jn8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694964460; x=1695569260; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DBK+EuhlZqztM+Alma3nr5nA9Qm2t1d0t11jSRG7m0Q=; b=JABQ70HbXajOFmBWEH2xJEcjT6AZHOlD8c5bW/VAxWiGfRFfKc8sm+sWutjZtTRVg3 /BXMho1yTo/Ty5HNH7xRsXSYuRIK5rq6fFpTEabRUwFdJ54rbOjFvPl8GJEtwF6Xg/2i 0YmrXacskhwC38I2QHS6UsWQuslm7cow4SKb21lQacSf0LOvJIb3uF/1lXYvi6vd1BGn 4xoPUKmHBuPKMr4smN4VK05xaFXzYHo20/rEV3Otg+71q8SDPOEG2H7k8etZA0/pBOdf 3HOlmblil76euD3tClP/I/GUg2x5k4fe9NUFZbEbpzYSRSA8hNxEYHa2WZZxcBIhMxRx hH+A== X-Gm-Message-State: AOJu0YxtBmHiek4Z4qW1i0jEI0OD5cjW6X0geePRZDrrR3Pv6Wutwlwh gS4bUywIaZvm/yT3cGe1MZI= X-Received: by 2002:adf:ea02:0:b0:317:dadc:4a63 with SMTP id q2-20020adfea02000000b00317dadc4a63mr7509736wrm.8.1694964459904; Sun, 17 Sep 2023 08:27:39 -0700 (PDT) Received: from localhost.localdomain ([5.45.134.53]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c489700b003fe15ac0934sm7388865wmp.1.2023.09.17.08.27.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 08:27:39 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, robh+dt@kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org, linux-kernel@vger.kernel.org, abdelalkuor@geotab.com Subject: [PATCH v5 09/15] USB: typec: Refactor tps6598x port registration Date: Sun, 17 Sep 2023 11:26:33 -0400 Message-Id: <20230917152639.21443-10-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230917152639.21443-1-alkuor@gmail.com> References: <20230917152639.21443-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Sun, 17 Sep 2023 08:32:00 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777312865551503979 X-GMAIL-MSGID: 1777312865551503979 From: Abdel Alkuor tps6598x and cd321x use TPS_REG_SYSTEM_CONF to get dr/pr roles where other similar devices don't have this register such as tps25750. Move tps6598x port registration to its own function Signed-off-by: Abdel Alkuor --- drivers/usb/typec/tipd/core.c | 99 +++++++++++++++++++---------------- 1 file changed, 54 insertions(+), 45 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 17b3bc480f97..8218d88a4a06 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -976,15 +976,65 @@ static int tps25750_apply_patch(struct tps6598x *tps) return 0; }; +static int +tps6598x_register_port(struct tps6598x *tps, struct fwnode_handle *fwnode) +{ + int ret; + u32 conf; + struct typec_capability typec_cap = { }; + + ret = tps6598x_read32(tps, TPS_REG_SYSTEM_CONF, &conf); + if (ret) + return ret; + + typec_cap.revision = USB_TYPEC_REV_1_2; + typec_cap.pd_revision = 0x200; + typec_cap.prefer_role = TYPEC_NO_PREFERRED_ROLE; + typec_cap.driver_data = tps; + typec_cap.ops = &tps6598x_ops; + typec_cap.fwnode = fwnode; + + switch (TPS_SYSCONF_PORTINFO(conf)) { + case TPS_PORTINFO_SINK_ACCESSORY: + case TPS_PORTINFO_SINK: + typec_cap.type = TYPEC_PORT_SNK; + typec_cap.data = TYPEC_PORT_UFP; + break; + case TPS_PORTINFO_DRP_UFP_DRD: + case TPS_PORTINFO_DRP_DFP_DRD: + typec_cap.type = TYPEC_PORT_DRP; + typec_cap.data = TYPEC_PORT_DRD; + break; + case TPS_PORTINFO_DRP_UFP: + typec_cap.type = TYPEC_PORT_DRP; + typec_cap.data = TYPEC_PORT_UFP; + break; + case TPS_PORTINFO_DRP_DFP: + typec_cap.type = TYPEC_PORT_DRP; + typec_cap.data = TYPEC_PORT_DFP; + break; + case TPS_PORTINFO_SOURCE: + typec_cap.type = TYPEC_PORT_SRC; + typec_cap.data = TYPEC_PORT_DFP; + break; + default: + return -ENODEV; + } + + tps->port = typec_register_port(tps->dev, &typec_cap); + if (IS_ERR(tps->port)) + return PTR_ERR(tps->port); + + return 0; +} + static int tps6598x_probe(struct i2c_client *client) { irq_handler_t irq_handler = tps6598x_interrupt; struct device_node *np = client->dev.of_node; - struct typec_capability typec_cap = { }; struct tps6598x *tps; struct fwnode_handle *fwnode; u32 status; - u32 conf; u32 vid; int ret; u64 mask1; @@ -1053,10 +1103,6 @@ static int tps6598x_probe(struct i2c_client *client) goto err_clear_mask; trace_tps6598x_status(status); - ret = tps6598x_read32(tps, TPS_REG_SYSTEM_CONF, &conf); - if (ret < 0) - goto err_clear_mask; - /* * This fwnode has a "compatible" property, but is never populated as a * struct device. Instead we simply parse it to read the properties. @@ -1074,50 +1120,13 @@ static int tps6598x_probe(struct i2c_client *client) goto err_fwnode_put; } - typec_cap.revision = USB_TYPEC_REV_1_2; - typec_cap.pd_revision = 0x200; - typec_cap.prefer_role = TYPEC_NO_PREFERRED_ROLE; - typec_cap.driver_data = tps; - typec_cap.ops = &tps6598x_ops; - typec_cap.fwnode = fwnode; - - switch (TPS_SYSCONF_PORTINFO(conf)) { - case TPS_PORTINFO_SINK_ACCESSORY: - case TPS_PORTINFO_SINK: - typec_cap.type = TYPEC_PORT_SNK; - typec_cap.data = TYPEC_PORT_UFP; - break; - case TPS_PORTINFO_DRP_UFP_DRD: - case TPS_PORTINFO_DRP_DFP_DRD: - typec_cap.type = TYPEC_PORT_DRP; - typec_cap.data = TYPEC_PORT_DRD; - break; - case TPS_PORTINFO_DRP_UFP: - typec_cap.type = TYPEC_PORT_DRP; - typec_cap.data = TYPEC_PORT_UFP; - break; - case TPS_PORTINFO_DRP_DFP: - typec_cap.type = TYPEC_PORT_DRP; - typec_cap.data = TYPEC_PORT_DFP; - break; - case TPS_PORTINFO_SOURCE: - typec_cap.type = TYPEC_PORT_SRC; - typec_cap.data = TYPEC_PORT_DFP; - break; - default: - ret = -ENODEV; - goto err_role_put; - } - ret = devm_tps6598_psy_register(tps); if (ret) goto err_role_put; - tps->port = typec_register_port(&client->dev, &typec_cap); - if (IS_ERR(tps->port)) { - ret = PTR_ERR(tps->port); + ret = tps6598x_register_port(tps, fwnode); + if (ret) goto err_role_put; - } if (status & TPS_STATUS_PLUG_PRESENT) { ret = tps6598x_read16(tps, TPS_REG_POWER_STATUS, &tps->pwr_status); From patchwork Sun Sep 17 15:26:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 141224 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2369634vqi; Sun, 17 Sep 2023 18:00:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGEzVq2Ph/XIznyhjwhssP37Jc8xQ4339X5oO9Ai7TYx5dXrK6vPJoxsRqhPSWJm3vLpij+ X-Received: by 2002:a05:6a20:430d:b0:154:a1e4:b676 with SMTP id h13-20020a056a20430d00b00154a1e4b676mr10686671pzk.4.1694998807314; Sun, 17 Sep 2023 18:00:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694998807; cv=none; d=google.com; s=arc-20160816; b=zOhw/WAVdErlN53Tf8LQNQrwIbccISPJI9Y1rg36+KmjEVtMUPfz53U2emMjihBIbG 34GEIDGQjBmtX42TYRKbRmzRXfLr1xRRSZzyVMuMtSPX7JsRy+WtCD3c5nP1mtlIBtR0 Pa0ApvbDC9XR6dl/dPWUCMd/CAtpi0ldkOnKmP0mdLGUw1WyEEWBPG73+YCmoQybLBX3 Q1BY5U4VVUxHM1UZNSiBXbfaRGKtCbt5fn4BV6zFvx1ArGmHM+6pzRhstqlaI0JjXev7 l1Fb4My8nqBg+e1otDVLy+micahfWpBfGOS3qRhnjiDW2ZUO7z7N5Xn9SlYSGuJ6Kr6T NrGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cxpfJhVV2ocOjrZiYJqyl63jEXCWOHPBdFU1UNBK2Hg=; fh=1TLHXZLxbVW/pzxFCwcQN1QIszWWCFgsgFdloZrlyPk=; b=A7JqVwkQsPr8CsA7ECyEGPUvfasoHqtzP3HMzQXYMp79mnaQgJvmSj4HXifHxrjt75 mXbJUsSbIlGvGrxG1UXsqK5b9REXWNTyZ1DMYuKsGHgh/EQ7qsW3ppqyh7ldD0KVKbGS DwIiL31NrhfwMSYrknKyJHGPZfVGmsf/5fmPeotFK11R1TwBhTUvaFIp4/QAqAWFDBOh mHb/2F0ob92akm2I4qnW7MxnaOYlFo40D71ilahtTsLgvqGEn4F4L2pz76vr1erQbZPf w97/pAxn16sOvrh2V5wVJQzqRjV0eWV6JQ8pDjRyx2N1ItdsjOWI4vCyANBitq4fcbLr s0mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gRNBpb9H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id bx29-20020a056a02051d00b005637e28270fsi7679226pgb.243.2023.09.17.18.00.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 18:00:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gRNBpb9H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 51D9E81AB52F; Sun, 17 Sep 2023 08:32:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237255AbjIQP2Q (ORCPT + 29 others); Sun, 17 Sep 2023 11:28:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234821AbjIQP1x (ORCPT ); Sun, 17 Sep 2023 11:27:53 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 103D2188; Sun, 17 Sep 2023 08:27:44 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-404573e6c8fso36715645e9.1; Sun, 17 Sep 2023 08:27:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694964462; x=1695569262; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cxpfJhVV2ocOjrZiYJqyl63jEXCWOHPBdFU1UNBK2Hg=; b=gRNBpb9HOtqxDzQhi4tad8dwDUm3yEPAnN2kMYMEeY0eDvamf27XQET8oInvCY85yR RL1B1/F0LyavWkcbVLTtVbzZDIBnSXNQUi17OR2p5e6BSQJCPZxQDmu4VKejfOQud3CQ ng6G8N5QDJNR8sB5dpIKhOqOk2LOncO+18Gc7Fbu4Iqm6PWaMU5vCWyexkv/PROjNCW3 mXo4T8jq28DAe4YEUc/S4fPht9yg6JnkpEBm2utYBMxJpb0Y6rm3rdzep+0uuVytqdEs HiCpw6ZLHgQwMBf3StqNQCldf1t51bqhAQdkP2ccSQBwVATaIulAM5yPeKKQbLL9rsSd D2Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694964462; x=1695569262; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cxpfJhVV2ocOjrZiYJqyl63jEXCWOHPBdFU1UNBK2Hg=; b=ewPDrh5p6E3rOKVLvK6zMd2KvCbYKe7EufRivWWZ1ZJY7Z9OeNFus9ExkqyU1lVu8E DxXvvXXAUpf/sG6okYlL9JUit4RF5F4/jvFvR5hkjv2BPcxXVVU7Amuf1LYlU/5CYhJO POVyna0KSpRu+YA0LR1cXQUhbC93cIAi9tEwi89VV5uepfLP37XGASR+qjpaKcjV4IdZ 0nWbTWnxQcvnHTJsHIVkkqZLeopKpkUudfKeitCThnlXeI3sHOhjGWjWzjMyirj8Wfqg i34W/o4SjXAcaTMnxFDeagMTci6RTptzv708cfICjYp6ADuLPoN/WMf6oz/gCISVIala 8rmQ== X-Gm-Message-State: AOJu0Yzniukqyza9UMLyQOiPlP6rpUDxZXdvpuSo41nNBGWIhRj5hfP9 aE4qC42+PTWeGZRunrtcJxU= X-Received: by 2002:a1c:7419:0:b0:402:feff:90d5 with SMTP id p25-20020a1c7419000000b00402feff90d5mr5647361wmc.5.1694964462453; Sun, 17 Sep 2023 08:27:42 -0700 (PDT) Received: from localhost.localdomain ([5.45.134.53]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c489700b003fe15ac0934sm7388865wmp.1.2023.09.17.08.27.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 08:27:42 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, robh+dt@kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org, linux-kernel@vger.kernel.org, abdelalkuor@geotab.com Subject: [PATCH v5 10/15] USB: typec: Add port registration for tps25750 Date: Sun, 17 Sep 2023 11:26:34 -0400 Message-Id: <20230917152639.21443-11-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230917152639.21443-1-alkuor@gmail.com> References: <20230917152639.21443-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 17 Sep 2023 08:32:31 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777335069172151764 X-GMAIL-MSGID: 1777335069172151764 From: Abdel Alkuor TPS25750 doesn't have system configuration register to get dr/pr of the current applied binary configuration. Get data role from the device node and power role from PD status register. Signed-off-by: Abdel Alkuor --- drivers/usb/typec/tipd/core.c | 61 ++++++++++++++++++++++++++++++- drivers/usb/typec/tipd/tps6598x.h | 10 +++++ 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 8218d88a4a06..a97fda68cb54 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -39,6 +39,7 @@ #define TPS_REG_CTRL_CONF 0x29 #define TPS_REG_BOOT_STATUS 0x2D #define TPS_REG_POWER_STATUS 0x3f +#define TPS_REG_PD_STATUS 0x40 #define TPS_REG_RX_IDENTITY_SOP 0x48 #define TPS_REG_DATA_STATUS 0x5f @@ -1028,6 +1029,60 @@ tps6598x_register_port(struct tps6598x *tps, struct fwnode_handle *fwnode) return 0; } +static int +tps25750_register_port(struct tps6598x *tps, struct fwnode_handle *fwnode) +{ + struct typec_capability typec_cap = { }; + const char *data_role; + u8 pd_status; + int ret; + + ret = tps6598x_read8(tps, TPS_REG_PD_STATUS, &pd_status); + if (ret) + return ret; + + ret = fwnode_property_read_string(fwnode, "data-role", &data_role); + if (ret) { + dev_err(tps->dev, "data-role not found: %d\n", ret); + return ret; + } + + ret = typec_find_port_data_role(data_role); + if (ret < 0) { + dev_err(tps->dev, "unknown data-role: %s\n", data_role); + return ret; + } + + typec_cap.data = ret; + typec_cap.revision = USB_TYPEC_REV_1_3; + typec_cap.pd_revision = 0x300; + typec_cap.driver_data = tps; + typec_cap.ops = &tps6598x_ops; + typec_cap.fwnode = fwnode; + typec_cap.prefer_role = TYPEC_NO_PREFERRED_ROLE; + + switch (TPS_PD_STATUS_PORT_TYPE(pd_status)) { + case TPS_PD_STATUS_PORT_TYPE_SINK_SOURCE: + case TPS_PD_STATUS_PORT_TYPE_SOURCE_SINK: + typec_cap.type = TYPEC_PORT_DRP; + break; + case TPS_PD_STATUS_PORT_TYPE_SINK: + typec_cap.type = TYPEC_PORT_SNK; + break; + case TPS_PD_STATUS_PORT_TYPE_SOURCE: + typec_cap.type = TYPEC_PORT_SRC; + break; + default: + return -ENODEV; + } + + tps->port = typec_register_port(tps->dev, &typec_cap); + if (IS_ERR(tps->port)) + return PTR_ERR(tps->port); + + return 0; +} + static int tps6598x_probe(struct i2c_client *client) { irq_handler_t irq_handler = tps6598x_interrupt; @@ -1124,7 +1179,11 @@ static int tps6598x_probe(struct i2c_client *client) if (ret) goto err_role_put; - ret = tps6598x_register_port(tps, fwnode); + if (np && of_device_is_compatible(np, "ti,tps25750")) + ret = tps25750_register_port(tps, fwnode); + else + ret = tps6598x_register_port(tps, fwnode); + if (ret) goto err_role_put; diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps6598x.h index 362e1eca53ad..d2c65387994f 100644 --- a/drivers/usb/typec/tipd/tps6598x.h +++ b/drivers/usb/typec/tipd/tps6598x.h @@ -203,4 +203,14 @@ #define TPS_BOOT_STATUS_DEAD_BATTERY_FLAG BIT(2) #define TPS25750_BOOT_STATUS_I2C_EEPROM_PRESENT BIT(3) +/* PD STATUS REG */ +#define TPS_REG_PD_STATUS_PORT_TYPE_MASK GENMASK(5, 4) +#define TPS_PD_STATUS_PORT_TYPE(x) \ + TPS_FIELD_GET(TPS_REG_PD_STATUS_PORT_TYPE_MASK, x) + +#define TPS_PD_STATUS_PORT_TYPE_SINK_SOURCE 0 +#define TPS_PD_STATUS_PORT_TYPE_SINK 1 +#define TPS_PD_STATUS_PORT_TYPE_SOURCE 2 +#define TPS_PD_STATUS_PORT_TYPE_SOURCE_SINK 3 + #endif /* __TPS6598X_H__ */ From patchwork Sun Sep 17 15:26:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 141174 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2249735vqi; Sun, 17 Sep 2023 11:20:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IENDLBe+7BXhAV/hLrswO1N5PULlXSg/s4GP8rOpv28U2K8ULYRBXkx93ogB1QVFkcpX3IE X-Received: by 2002:a05:6a00:804:b0:68e:4303:edb8 with SMTP id m4-20020a056a00080400b0068e4303edb8mr9341525pfk.30.1694974839958; Sun, 17 Sep 2023 11:20:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694974839; cv=none; d=google.com; s=arc-20160816; b=X87yEFfC4vMfZVq5Mv9WHrq93iw9ty3WjsQ1sJjE+kuWB00yRFpCBYbO/W+3J5Q6LH aCiW5O4FZH5aYFApOGFeujtWv8brM19QvdZpT2mVsFaoaqGq7kL1PEWNeVvV9UmxaPFg fl3r0xXjrgQv5x7L0mkm14BEZ4MNoYYjA32ZvV407BtOjNR9dGzQLZduuriuCQz/qmQL O/jyUldgj1ekAQM0KMv98JG0qFlIcsxh0XpwZa693fp1xbJn8wl5+me6eiwtnfBYMvXF uFrL/NbLNnjqmy4X2u67TrYam74yBD+/jY0kX7TuHvv75T4w9fqAD5d7jzvCWiTeEFmt DS8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0n50wlN15P0stenDju6p9cw+JcF6FZEojTnqcJ2Z8gE=; fh=1TLHXZLxbVW/pzxFCwcQN1QIszWWCFgsgFdloZrlyPk=; b=RCjtPz2PcawmV0TMnWXdLMRg3mGBsYSRBtlxDBuZs5Ovph2rhdj0yBylRHgPTNblf0 C4R8pxcndheR+nm2dw2oXPZKAkliVnzz0jCu7DSp2opRFDpAL5XjZnJ9oNP+SFn2JKvQ 1TwXLoeY0SRounDisjgdCQBSjiUtslHV3yes7WPC9R0OJf0C/wipasI6sOaAsUxjA8Vp IX+Atu6kQ56FZ0zS50dWRWSYby5BoMQ6KlWVOY1s3PCCDK45lz1pIg9pJ/ULMHVPKkZB QYiwNn9kf7J6RveLyxrP6qFwoAtOizVVBZLi7nfPu/ojCpMSfVzzSkEDnuWeIvyrIRAx rPPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=W8KEsmdh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id ct25-20020a056a000f9900b0065b4e2b52c5si6540917pfb.196.2023.09.17.11.20.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 11:20:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=W8KEsmdh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 095BE82296A8; Sun, 17 Sep 2023 08:32:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237336AbjIQP2S (ORCPT + 29 others); Sun, 17 Sep 2023 11:28:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234809AbjIQP1x (ORCPT ); Sun, 17 Sep 2023 11:27:53 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C04D18B; Sun, 17 Sep 2023 08:27:46 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-400a087b0bfso39937065e9.2; Sun, 17 Sep 2023 08:27:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694964465; x=1695569265; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0n50wlN15P0stenDju6p9cw+JcF6FZEojTnqcJ2Z8gE=; b=W8KEsmdhEB40oiznYrEJUK9vC6qo3/+yRo1nGuhgYhqifIw2euID4lAVgDue1/SeWw MWCUcwGJ/7LFoKrLdFF7+YigHj6rT/l1QUorc7z3wevj4/RxzhIhzWdlT/j1myANbPDb aahTNietBw2Jr/l7aJm3aWwKylEX3IcS9O6CAprGCtBZjdVbjAs4RJF9EAaE8J8QHHOU 0+T9f1nTjvMMV+WdzHbJXPaeCerei79x6OcIQSqUU3XM/c7T+zWvAtzjFp0YwQarNMpI CNBKKq4/tzCpCoUOay9/uTHudJ+aM1IBQbwY1cyOiiIiRLcnw88KAmEAG2VWIvMIMoAy /CIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694964465; x=1695569265; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0n50wlN15P0stenDju6p9cw+JcF6FZEojTnqcJ2Z8gE=; b=OCK83qDAYVFnbl3jEl7TbsxLaOa35f4PCmpQ2ZI7AfwsKM+ejvnuDVUGir24ouXek7 Ix6gLzyjAwxm/WGbJZX+4H/jdtyTcTfg/TQ26dg7+9DNjDD2TpG+ObcQt5O9uBrwdqby 1FIk5aCtvtd7L1PwJcF3E1VCAhAUUzPVUK5pPRwrMI9biEdHdyYQG5Yag1JSoY3BkWsT H0GbCC43w54mRMK9hNpa4rDovrRxXhyv7Fvujzyb9V73Xf+W1ylqZ3LndVmjZiDbELu+ gP/C7Ejnk9KUYyuIGBoYMiSUvIOaf6C6Cd+qeEVeqE9MdYV0mYv6mRs9J2WEIBpv3gJI vslA== X-Gm-Message-State: AOJu0YxqT4OmVQmKPsjgXOLVU6j1ilrVf7WcHiHpH6Qej69193KvReTd 2hqPcFOt6QQnBKnBmaZFY9U= X-Received: by 2002:a05:600c:2194:b0:3fe:ef11:d79f with SMTP id e20-20020a05600c219400b003feef11d79fmr6173540wme.36.1694964464977; Sun, 17 Sep 2023 08:27:44 -0700 (PDT) Received: from localhost.localdomain ([5.45.134.53]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c489700b003fe15ac0934sm7388865wmp.1.2023.09.17.08.27.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 08:27:44 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, robh+dt@kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org, linux-kernel@vger.kernel.org, abdelalkuor@geotab.com Subject: [PATCH v5 11/15] USB: typec: Enable sleep mode for tps25750 Date: Sun, 17 Sep 2023 11:26:35 -0400 Message-Id: <20230917152639.21443-12-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230917152639.21443-1-alkuor@gmail.com> References: <20230917152639.21443-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 17 Sep 2023 08:32:45 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777309937948311897 X-GMAIL-MSGID: 1777309937948311897 From: Abdel Alkuor Allow controller to enter sleep mode after the device is idle for sleep time. Signed-off-by: Abdel Alkuor --- drivers/usb/typec/tipd/core.c | 29 ++++++++++++++++++++++++++++- drivers/usb/typec/tipd/tps6598x.h | 3 +++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index a97fda68cb54..3d9877551160 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -42,6 +42,7 @@ #define TPS_REG_PD_STATUS 0x40 #define TPS_REG_RX_IDENTITY_SOP 0x48 #define TPS_REG_DATA_STATUS 0x5f +#define TPS_REG_SLEEP_CONF 0x70 /* TPS_REG_SYSTEM_CONF bits */ #define TPS_SYSCONF_PORTINFO(c) ((c) & 7) @@ -205,6 +206,11 @@ static inline int tps6598x_read64(struct tps6598x *tps, u8 reg, u64 *val) return tps6598x_block_read(tps, reg, val, sizeof(u64)); } +static inline int tps6598x_write8(struct tps6598x *tps, u8 reg, u8 val) +{ + return tps6598x_block_write(tps, reg, &val, sizeof(u8)); +} + static inline int tps6598x_write64(struct tps6598x *tps, u8 reg, u64 val) { return tps6598x_block_write(tps, reg, &val, sizeof(u64)); @@ -977,6 +983,24 @@ static int tps25750_apply_patch(struct tps6598x *tps) return 0; }; +static int tps25750_init(struct tps6598x *tps) +{ + int ret; + + ret = tps25750_apply_patch(tps); + if (ret) + return ret; + + ret = tps6598x_write8(tps, TPS_REG_SLEEP_CONF, + TPS_SLEEP_CONF_SLEEP_MODE_ALLOWED); + if (ret) + dev_warn(tps->dev, + "%s: failed to enable sleep mode: %d\n", + __func__, ret); + + return 0; +} + static int tps6598x_register_port(struct tps6598x *tps, struct fwnode_handle *fwnode) { @@ -1131,6 +1155,7 @@ static int tps6598x_probe(struct i2c_client *client) irq_handler = cd321x_interrupt; } else { tps->is_tps25750 = of_device_is_compatible(np, "ti,tps25750"); + /* Enable power status, data status and plug event interrupts */ mask1 = TPS_REG_INT_POWER_STATUS_UPDATE | TPS_REG_INT_DATA_STATUS_UPDATE | @@ -1138,6 +1163,7 @@ static int tps6598x_probe(struct i2c_client *client) } tps->irq_handler = irq_handler; + /* Make sure the controller has application firmware running */ ret = tps6598x_check_mode(tps, &mode); if (ret) @@ -1149,6 +1175,7 @@ static int tps6598x_probe(struct i2c_client *client) return ret; } + ret = tps6598x_write64(tps, TPS_REG_INT_MASK1, mask1); if (ret) goto err_reset_controller; @@ -1286,7 +1313,7 @@ static int __maybe_unused tps6598x_resume(struct device *dev) return ret; if (mode == TPS_MODE_PTCH) { - ret = tps25750_apply_patch(tps); + ret = tps25750_init(tps); if (ret) return ret; } diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps6598x.h index d2c65387994f..0344b65cd55a 100644 --- a/drivers/usb/typec/tipd/tps6598x.h +++ b/drivers/usb/typec/tipd/tps6598x.h @@ -213,4 +213,7 @@ #define TPS_PD_STATUS_PORT_TYPE_SOURCE 2 #define TPS_PD_STATUS_PORT_TYPE_SOURCE_SINK 3 +/* SLEEP CONF REG */ +#define TPS_SLEEP_CONF_SLEEP_MODE_ALLOWED BIT(0) + #endif /* __TPS6598X_H__ */ From patchwork Sun Sep 17 15:26:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 141170 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2240426vqi; Sun, 17 Sep 2023 10:55:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEWt+KLZpz4+qwYKLrYpSpk/o1pMo4ci6sszqOQAdgwwHvBlVqvRlxgTJWnZn9NQ7cTjNKh X-Received: by 2002:a05:6a00:22ce:b0:68e:2cf2:1613 with SMTP id f14-20020a056a0022ce00b0068e2cf21613mr7438057pfj.3.1694973350434; Sun, 17 Sep 2023 10:55:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694973350; cv=none; d=google.com; s=arc-20160816; b=m6jeT5K9AFh+V+NNDD6ppCDRvTuzBWWxuaIRiJIcKXeNfLEYgTK1Who9GRw7NgMD4h X0b1nbc1xcJzAVjVUjHXYd5CMKVdXReUsG4JtOgLOoV+e0Pr9dK34W/mb9N56Oq4O9OD y7822mZE2AbzgiQD73WP8jFxMfE7XbR3Zm3czdnTsw2yGi0deAPsAbP8TF7VLW6F2el0 BSRz1QddkoDsrPfhGnUjzY6HsK9qrCf5ma86XQMv5CgUGU14I/G7aKHvf2zkMKGfzIiG yPN7OQ708+xIc8NDy4kRp1qutoaAFJhKNkp8Z3swom8C4HKjejfY05EaGhkeFCZUfd5u 4lkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VPo77c2oAmmTJzlQbZh4cIjjJUw0euUNGNp5zx2Guyo=; fh=1TLHXZLxbVW/pzxFCwcQN1QIszWWCFgsgFdloZrlyPk=; b=bD5SF1YgYjFk/6NYbvVSn3pjCCms7fDU+2UjTe6WtpAkkbFPUKIbIE5zn/c4WdQSga btdNFFTMsXe+eLtCOZXCleqXSolfK4eSV6qItFxhYvfIy9WVEVOjKqEcjDcB2WuCALtr GTUFzAE4pHAjOK5cXDdAg+xAMfFLghJT3Bd/xSSKCL1djJw7r97P3A5Mpfvc5yDBWt1W m0HsBiQqaZAMATwCsmoASHYJSSOBZucRcA96E0brvOqMFr7GlMI4foxZdOI2+n+1R3hi gts1Ijs0t7xFV2WbjumuHsnb49PscPcWtiNZB3aMjN9ZQHoO0X5eBep9hYxi6FEK78f3 q3oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DwNFyewb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id m11-20020a056a00080b00b0068740bcd8d7si6852065pfk.362.2023.09.17.10.55.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 10:55:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DwNFyewb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id BE22880E6FE6; Sun, 17 Sep 2023 08:32:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237155AbjIQP2P (ORCPT + 29 others); Sun, 17 Sep 2023 11:28:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234990AbjIQP1y (ORCPT ); Sun, 17 Sep 2023 11:27:54 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D30F185; Sun, 17 Sep 2023 08:27:49 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-404732a0700so36519635e9.0; Sun, 17 Sep 2023 08:27:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694964468; x=1695569268; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VPo77c2oAmmTJzlQbZh4cIjjJUw0euUNGNp5zx2Guyo=; b=DwNFyewbEAUsVNZ3Shpcojh5UNbqHx98HcLkDyTPVJh33GOSDgon0EsGbbIy8RWi4h Ptk+14Nij89mp7Ck9Kl/PVWzZOW8q/7Bp+Asn5TFPu4pNjV5OFLUbROcneyT/hWtxhAq Oml00Oxsqsy3frwaYRLZ/PDDBxw+FXhT5ZbSdBkGgzdbNDbR9oTegwD57892ee0V0zDm hPsm4/MQ9YrkwHAuZ9SOt6WoGjXk+Arj52XMxkC/zwLBtwTh5A6zQxgx5N4etjmPlZ48 eCKnsyMnw1qgIhJ8DHPZ7zXK9ATD0Dt6Ew1f/6CgXn9rUGgQYMfp7SSipl+7gfLFaOJV U+NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694964468; x=1695569268; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VPo77c2oAmmTJzlQbZh4cIjjJUw0euUNGNp5zx2Guyo=; b=IEOUR9hHqxLBMja7fyMICTmVEy52tjPI3ulj8pVsCx3OY3qp+P80maZWe/p5kcUr4r zM9abkXCb+/m416PoYE4iZMPXd2psLuddpLoq0026Got7C7ODb+KOy7Zuum6HiO0Nzsg QiWSc4FhvyrAuO7rRKJy9VOY9up+7LIilRzbg7cQpFAKurWpDwUC5KGzaYfIj75p+x4v Kc0HZCu8KKWtawbmM0QFHRbxNleS+RoTFDc8GBnNyTnq6V2oiSeCswFIGkksMOaxZ6f6 8lvLz7RjtdVluReNGqDzYseGWf6QmMzodla/oJ6KyOYzUphDaJHBWwHVVrZXiq86IjOz KKwA== X-Gm-Message-State: AOJu0YynggPQa4mEpxtGYy7e2wOkupIvxvumqug6FEtFJIY64bqWN7x+ 8Y7pJzt6N5RQYgsYiAUn9D9QWo9ka+YlarPfY78= X-Received: by 2002:a7b:c4cb:0:b0:401:6800:703c with SMTP id g11-20020a7bc4cb000000b004016800703cmr6546902wmk.21.1694964467533; Sun, 17 Sep 2023 08:27:47 -0700 (PDT) Received: from localhost.localdomain ([5.45.134.53]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c489700b003fe15ac0934sm7388865wmp.1.2023.09.17.08.27.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 08:27:47 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, robh+dt@kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org, linux-kernel@vger.kernel.org, abdelalkuor@geotab.com Subject: [PATCH v5 12/15] USB: typec: Add trace for tps25750 irq Date: Sun, 17 Sep 2023 11:26:36 -0400 Message-Id: <20230917152639.21443-13-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230917152639.21443-1-alkuor@gmail.com> References: <20230917152639.21443-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Sun, 17 Sep 2023 08:32:07 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777308375982621903 X-GMAIL-MSGID: 1777308375982621903 From: Abdel Alkuor tps25750 event1 register doesn't have all bits in tps6598x event registers, only show the events that are masked Signed-off-by: Abdel Alkuor --- drivers/usb/typec/tipd/core.c | 6 +++++- drivers/usb/typec/tipd/trace.h | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 3d9877551160..8d6cb67898a5 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -574,7 +574,11 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data) dev_err(tps->dev, "%s: failed to read events\n", __func__); goto err_unlock; } - trace_tps6598x_irq(event[0], event[1]); + + if (tps->is_tps25750) + trace_tps25750_irq(event[0]); + else + trace_tps6598x_irq(event[0], event[1]); if (!(event[0] | event[1])) goto err_unlock; diff --git a/drivers/usb/typec/tipd/trace.h b/drivers/usb/typec/tipd/trace.h index 12cad1bde7cc..28725234a2d8 100644 --- a/drivers/usb/typec/tipd/trace.h +++ b/drivers/usb/typec/tipd/trace.h @@ -74,6 +74,13 @@ { APPLE_CD_REG_INT_DATA_STATUS_UPDATE, "DATA_STATUS_UPDATE" }, \ { APPLE_CD_REG_INT_STATUS_UPDATE, "STATUS_UPDATE" }) +#define show_tps25750_irq_flags(flags) \ + __print_flags_u64(flags, "|", \ + { TPS_REG_INT_PLUG_EVENT, "PLUG_EVENT" }, \ + { TPS_REG_INT_POWER_STATUS_UPDATE, "POWER_STATUS_UPDATE" }, \ + { TPS_REG_INT_STATUS_UPDATE, "STATUS_UPDATE" }, \ + { TPS_REG_INT_PD_STATUS_UPDATE, "PD_STATUS_UPDATE" }) + #define TPS6598X_STATUS_FLAGS_MASK (GENMASK(31, 0) ^ (TPS_STATUS_CONN_STATE_MASK | \ TPS_STATUS_PP_5V0_SWITCH_MASK | \ TPS_STATUS_PP_HV_SWITCH_MASK | \ @@ -230,6 +237,21 @@ TRACE_EVENT(cd321x_irq, show_cd321x_irq_flags(__entry->event)) ); +TRACE_EVENT(tps25750_irq, + TP_PROTO(u64 event), + TP_ARGS(event), + + TP_STRUCT__entry( + __field(u64, event) + ), + + TP_fast_assign( + __entry->event = event; + ), + + TP_printk("event=%s", show_tps25750_irq_flags(__entry->event)) +); + TRACE_EVENT(tps6598x_status, TP_PROTO(u32 status), TP_ARGS(status), From patchwork Sun Sep 17 15:26:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 141312 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2514856vqi; Mon, 18 Sep 2023 01:54:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHROJ3XrwBoFBW9Z6bxqmeTcGh32Wlmz+wND9LcX7LTgaQ1t4jJwNRba3hMOhJm5/Fa5CwC X-Received: by 2002:a05:6a20:6a1a:b0:13d:a903:88e6 with SMTP id p26-20020a056a206a1a00b0013da90388e6mr7815977pzk.48.1695027279303; Mon, 18 Sep 2023 01:54:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695027279; cv=none; d=google.com; s=arc-20160816; b=X9ytVPZmxX4Tl6Pt945QptFILjpVbdh3CgCGx8B+on8Xu9LvkBGFNJPl36rAHPzdRq SA1j+aCyXc5mTUCrpk1d6TV7dUyw6f4Aj9PsHPjI7hgJDoO/Zic3nhMb9UgrB47J6k1q 1P1LTFHSjMHhCLrQXdUGD18132/SaP7wWmVZv9fQZBb12qtKKdEMzmw+bstItpBnbECe 3L2FnsmcKz29qV+NubWLnZlYCDBUjbxcqfZ3td0cboUvYig8k0Z4JqG3V1k73D13yDvr 6Pq9JcDBm8gaAbrOsDP/cKW3Zb9Ln/w6oPsXUAqyZz4WFe+6L1kYxsYSAr8rnAOpLdSN zrNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=48igqbWoZ6rl5cAwQg8BttYETGq1bFuqrgNpEHB1dVg=; fh=1TLHXZLxbVW/pzxFCwcQN1QIszWWCFgsgFdloZrlyPk=; b=E8NL9N0bGLQsBQQ6L+QBee45CjZ9xBuikFhIP9eCoG+m7e8ydf1gRsMPD7t3JYg1JG oDgX36K4eEZ494k2cHqI7Ezv8Gh4uNMf0UK/shU26xU7z47YKd8QQOQrW/qmiX/gzPA+ 3Ate4DkNStfBeM5+uMPeCp1t+fk1Y42J797LDKlrCpINHOgTcqZwT4INS2gzQiVuXiQm oClcd4hxEPBHR5OEUudMLRUIVf7U3lAfXIgmYSYHWi8wCX7tMQZIpaTUSQZnIb4RpRC7 Jul0kan4HZ7IKtSY1EuFztqpuoSSJV2b7K33sxtPTeD4rjn+tDgNO+B0+3Y0z0RI4Tzj 3Eog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hh7O0bMG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id e19-20020a056a001a9300b0068fe9c452acsi7795458pfv.376.2023.09.18.01.54.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 01:54:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hh7O0bMG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 3033582296B1; Sun, 17 Sep 2023 08:32:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237459AbjIQP2T (ORCPT + 29 others); Sun, 17 Sep 2023 11:28:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235011AbjIQP15 (ORCPT ); Sun, 17 Sep 2023 11:27:57 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB079186; Sun, 17 Sep 2023 08:27:51 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-401da71b83cso42177515e9.2; Sun, 17 Sep 2023 08:27:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694964470; x=1695569270; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=48igqbWoZ6rl5cAwQg8BttYETGq1bFuqrgNpEHB1dVg=; b=hh7O0bMGsG7deqbwcqrweZ32uH7xxvfLtPuXaA1Ju+ViyXjwTOhDGbc6AcUCdyucIx 7b/bZFB0XRfK1SQusqoJgpzRehr7D6rGxVM7z+4dbGih1RChnDewY2yRV9UpZ+f1nNTH 2fdEHXB9PrZ+X4xZlZN20HdzcJodes17K+p1ghw1KzqBNRtT/f2JTjOHPFQ6Q7l5xGPC 44OmMeXNGumz1CUf4o0ExrlEVLwn67jKS46amBqhMhEAnOaM0yfS9E7ySryUNJZy+0R3 L5JJw88C3Mbd49eI45/BnqogbK6u0aHJHJcwUtmbE/IGudSV7KC84Nd9QSAyaUEq44V5 WkYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694964470; x=1695569270; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=48igqbWoZ6rl5cAwQg8BttYETGq1bFuqrgNpEHB1dVg=; b=RsEuClIP2GyX6XhHfiQ3Fp9eW3HPgzsNfkl9KLp49TaEdMxuB+C2XUdnqtPlqFZzVh 7QiC8fbiARNQ5nycFSYTD5mTlX4o+MiPc0c3GjNU/ASKLm4i8vTKZ60LBt4SEt6c2g95 8KL4kkY+/+o+E2hxL8+JEAumsMNAlI2IcF0teecrWPsOdyowQMo+2+URhnxm3i81HzX9 oDiXWlDQNeC4KxGGAxm4U3gfNqHQm7kAQ1OEUtEp8Y61BQUoAUkVzu26nvDgcqQ0panv GTFhg2QcjQr0W+BT6CIHZt9dVRJmELz24jiJm8+h4dx3VMK3a7p6mwNdu+yZHkz0dqZT zLUQ== X-Gm-Message-State: AOJu0Yy0pJkpLeLDJDwdv1JX4aHhHz74u25yZ9gbxdO4EIhEBjdPub4Z mVzb4q4MxUvCJZL7KuXCRJM= X-Received: by 2002:a05:600c:144:b0:401:b504:b6a0 with SMTP id w4-20020a05600c014400b00401b504b6a0mr6937162wmm.3.1694964470280; Sun, 17 Sep 2023 08:27:50 -0700 (PDT) Received: from localhost.localdomain ([5.45.134.53]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c489700b003fe15ac0934sm7388865wmp.1.2023.09.17.08.27.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 08:27:49 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, robh+dt@kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org, linux-kernel@vger.kernel.org, abdelalkuor@geotab.com Subject: [PATCH v5 13/15] USB: typec: Add power status trace for tps25750 Date: Sun, 17 Sep 2023 11:26:37 -0400 Message-Id: <20230917152639.21443-14-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230917152639.21443-1-alkuor@gmail.com> References: <20230917152639.21443-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 17 Sep 2023 08:32:54 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777364924338877393 X-GMAIL-MSGID: 1777364924338877393 From: Abdel Alkuor tps25750 power status register is a subset of tps6598x power status register. Signed-off-by: Abdel Alkuor --- drivers/usb/typec/tipd/core.c | 6 +++++- drivers/usb/typec/tipd/tps6598x.h | 19 ++++++++++++++++++ drivers/usb/typec/tipd/trace.h | 33 +++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 8d6cb67898a5..dd3c76b57aaa 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -484,7 +484,11 @@ static bool tps6598x_read_power_status(struct tps6598x *tps) return false; } tps->pwr_status = pwr_status; - trace_tps6598x_power_status(pwr_status); + + if (tps->is_tps25750) + trace_tps25750_power_status(pwr_status); + else + trace_tps6598x_power_status(pwr_status); return true; } diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps6598x.h index 0344b65cd55a..bab6b0f026fc 100644 --- a/drivers/usb/typec/tipd/tps6598x.h +++ b/drivers/usb/typec/tipd/tps6598x.h @@ -161,6 +161,25 @@ #define TPS_POWER_STATUS_BC12_STATUS_CDP 2 #define TPS_POWER_STATUS_BC12_STATUS_DCP 3 +/* TPS25750_REG_POWER_STATUS bits */ +#define TPS25750_POWER_STATUS_CHARGER_DETECT_STATUS_MASK GENMASK(7, 4) +#define TPS25750_POWER_STATUS_CHARGER_DETECT_STATUS(p) \ + TPS_FIELD_GET(TPS25750_POWER_STATUS_CHARGER_DETECT_STATUS_MASK, (p)) +#define TPS25750_POWER_STATUS_CHARGER_ADVERTISE_STATUS_MASK GENMASK(9, 8) +#define TPS25750_POWER_STATUS_CHARGER_ADVERTISE_STATUS(p) \ + TPS_FIELD_GET(TPS25750_POWER_STATUS_CHARGER_ADVERTISE_STATUS_MASK, (p)) + +#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_DISABLED 0 +#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_IN_PROGRESS 1 +#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_NONE 2 +#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_SPD 3 +#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_BC_1_2_CPD 4 +#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_BC_1_2_DPD 5 +#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_DIV_1_DCP 6 +#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_DIV_2_DCP 7 +#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_DIV_3_DCP 8 +#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_1_2V_DCP 9 + /* TPS_REG_DATA_STATUS bits */ #define TPS_DATA_STATUS_DATA_CONNECTION BIT(0) #define TPS_DATA_STATUS_UPSIDE_DOWN BIT(1) diff --git a/drivers/usb/typec/tipd/trace.h b/drivers/usb/typec/tipd/trace.h index 28725234a2d8..739b0a2a867d 100644 --- a/drivers/usb/typec/tipd/trace.h +++ b/drivers/usb/typec/tipd/trace.h @@ -166,6 +166,19 @@ { TPS_POWER_STATUS_BC12_STATUS_CDP, "cdp" }, \ { TPS_POWER_STATUS_BC12_STATUS_SDP, "sdp" }) +#define show_tps25750_power_status_charger_detect_status(power_status) \ + __print_symbolic(TPS25750_POWER_STATUS_CHARGER_DETECT_STATUS(power_status), \ + { TPS25750_POWER_STATUS_CHARGER_DET_STATUS_DISABLED, "disabled"}, \ + { TPS25750_POWER_STATUS_CHARGER_DET_STATUS_IN_PROGRESS, "in progress"}, \ + { TPS25750_POWER_STATUS_CHARGER_DET_STATUS_NONE, "none"}, \ + { TPS25750_POWER_STATUS_CHARGER_DET_STATUS_SPD, "spd"}, \ + { TPS25750_POWER_STATUS_CHARGER_DET_STATUS_BC_1_2_CPD, "cpd"}, \ + { TPS25750_POWER_STATUS_CHARGER_DET_STATUS_BC_1_2_DPD, "dpd"}, \ + { TPS25750_POWER_STATUS_CHARGER_DET_STATUS_DIV_1_DCP, "divider 1 dcp"}, \ + { TPS25750_POWER_STATUS_CHARGER_DET_STATUS_DIV_2_DCP, "divider 2 dcp"}, \ + { TPS25750_POWER_STATUS_CHARGER_DET_STATUS_DIV_3_DCP, "divider 3 dpc"}, \ + { TPS25750_POWER_STATUS_CHARGER_DET_STATUS_1_2V_DCP, "1.2V dpc"}) + #define TPS_DATA_STATUS_FLAGS_MASK (GENMASK(31, 0) ^ (TPS_DATA_STATUS_DP_PIN_ASSIGNMENT_MASK | \ TPS_DATA_STATUS_TBT_CABLE_SPEED_MASK | \ TPS_DATA_STATUS_TBT_CABLE_GEN_MASK)) @@ -299,6 +312,26 @@ TRACE_EVENT(tps6598x_power_status, ) ); +TRACE_EVENT(tps25750_power_status, + TP_PROTO(u16 power_status), + TP_ARGS(power_status), + + TP_STRUCT__entry( + __field(u16, power_status) + ), + + TP_fast_assign( + __entry->power_status = power_status; + ), + + TP_printk("conn: %d, pwr-role: %s, typec: %s, charger detect: %s", + !!TPS_POWER_STATUS_CONNECTION(__entry->power_status), + show_power_status_source_sink(__entry->power_status), + show_power_status_typec_status(__entry->power_status), + show_tps25750_power_status_charger_detect_status(__entry->power_status) + ) +); + TRACE_EVENT(tps6598x_data_status, TP_PROTO(u32 data_status), TP_ARGS(data_status), From patchwork Sun Sep 17 15:26:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 141213 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2339498vqi; Sun, 17 Sep 2023 16:16:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0uKVmPBdeGL6kpD4cTGv3KKUdn6NVzZZGf740kO3chJ/H13wXepFk+G98SZw1elmjYSOI X-Received: by 2002:a05:6a20:728b:b0:152:4615:cb9d with SMTP id o11-20020a056a20728b00b001524615cb9dmr14788378pzk.12.1694992569450; Sun, 17 Sep 2023 16:16:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694992569; cv=none; d=google.com; s=arc-20160816; b=Kr/wfQ/0Mhq4DQzeJHJuJ3YPeWd2p86TRMmB9p5jfdJAj/1PNNGMRhRI4zZg7L92W4 GMr9k9wrcb89SJqKszN29tGzKDYl7RIrH9PndsEbJRufqAC4BH0RHJrF3WvuBRBSPyFN CvUdbtB16TYzcKqBDlEKAS4yUT1Pb5nFlDukfdPv6e47r+tkPaPx5OjPjtVxhBCk6H/3 m/UaATnCLpuI8OBQepb1OL9lGZ/kKutMMj64SPB3/fuWzINMYzQ1eXLdQDrWNOzDlJfk t08o787qlMEekF77UFJuzlfENrCMhJlzT0L70K/bk+oJr/Fni47lTPpSFgp3EZRDg0HL s5jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tt+2C7H8Lp9GSUddurKydQcPQn4TRhG9Hz2u3xUiVI4=; fh=1TLHXZLxbVW/pzxFCwcQN1QIszWWCFgsgFdloZrlyPk=; b=EPfXnSJYXL8oEp7oqufuc2cvNq8SbeJMFsMW5lOyc6YxAYEfdyDqpCvzA26rLBVNKm dBRK6kN+F+/cWl7DB0f5YsUlbqYNh3US1rEwCtt0W57VVqrc+yPY8iIjfVXd5WdvbV7n 9WytpfXNXLTpKKAFFm4UGm4ufrVC93t4mw1o7e4vA+Hl8WEv+BsQT5rdD1JABLCmBgGd otc/XKPlUojRpxY37lzYeLNR32Ut8ByX2dqkALF3zmwz1TnB2v4CvGpQs+wHGQH2RVzW kmNAgPLT+N8JiQUGh5QW8ZeE2MADGhOJ+qQmtTqEsOxhT11nolEboyZomieHoV0HBkac mJ+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=FWaHQzU9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id bg26-20020a056a02011a00b00573f885c4easi6688492pgb.753.2023.09.17.16.16.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 16:16:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=FWaHQzU9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E08DA82296BC; Sun, 17 Sep 2023 08:33:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235011AbjIQP2c (ORCPT + 29 others); Sun, 17 Sep 2023 11:28:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235606AbjIQP2A (ORCPT ); Sun, 17 Sep 2023 11:28:00 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90D0111F; Sun, 17 Sep 2023 08:27:54 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-313e742a787so2320902f8f.1; Sun, 17 Sep 2023 08:27:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694964473; x=1695569273; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tt+2C7H8Lp9GSUddurKydQcPQn4TRhG9Hz2u3xUiVI4=; b=FWaHQzU9uco56v7WOUeq90gKntkqmDSyKs66uM6Kg/S2amqkPIUyIclhhS6GcDPsjz xP2LjMjD8YuKIb1Y8O70x/ibtbULSIqcY4C4MWoeehY1QxYgwk3HPouzPgOClX1tBYuh lb6pIco4+bCenG7e/7HEfQqc8SWSocq9q6H8EhN9okKV9NnNHpSG2YNyvSOjdWNMlBOi 3SbrCM9oqCF/iDIwJWD4S3VVzWOpwd3WE+Ru2V9jzrqeo8Y+9hMUH4aVcquWfWZxLV19 qnUMlujIdFe6E3cWJ/j/X8m5ex661ksIgMhtyUkdEJLhmHce3GODc+u0HwzW4gLyaIEJ d38A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694964473; x=1695569273; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tt+2C7H8Lp9GSUddurKydQcPQn4TRhG9Hz2u3xUiVI4=; b=xN8NDi+r7lZGxz4Lg6Lfrrqnw1vNi5Bu53uoTyK86HNXEppgmumUIEZPkndQH2/63N 9wqUxPkljDU91tgq8nk3tVb87VmxPiy+Gy5S9wlqmaoOyjBrqUt8QfAhLYe/4BqNNTM3 TszjSYR3VGoSo72wN8RwIZuG6ji6ftq6/qdMmSK0PFzozrRTPJmSju8pT6FqvThag20n 613p6jjJW6YrdG/QAbj8o79m+kf7Kg9MGNBjEKYSKHDYFFRl+d33wbWf/eVAhBobVCXq nqVZ3tsVhdUp3zHlJ/fEMEo91apoUgU92aicUrPJyDdxeh1reOMALw/QsRYtvmQ18Gam Y/zA== X-Gm-Message-State: AOJu0Yyq8VjNwlkj2/UtGcebjFDs7TQgVZ3Y6nmJZQJDow7ywmY6lZJ/ w17wn5iMlsmyv2LJ2cIhrDuMyT7+mKVFBJCTfFE= X-Received: by 2002:a5d:60cc:0:b0:31f:db54:317e with SMTP id x12-20020a5d60cc000000b0031fdb54317emr6996605wrt.14.1694964472989; Sun, 17 Sep 2023 08:27:52 -0700 (PDT) Received: from localhost.localdomain ([5.45.134.53]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c489700b003fe15ac0934sm7388865wmp.1.2023.09.17.08.27.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 08:27:52 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, robh+dt@kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org, linux-kernel@vger.kernel.org, abdelalkuor@geotab.com Subject: [PATCH v5 14/15] USB: typec: Add status trace for tps25750 Date: Sun, 17 Sep 2023 11:26:38 -0400 Message-Id: <20230917152639.21443-15-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230917152639.21443-1-alkuor@gmail.com> References: <20230917152639.21443-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 17 Sep 2023 08:33:17 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777328528755423988 X-GMAIL-MSGID: 1777328528755423988 From: Abdel Alkuor tps25750 status register is a subset of tps6598x status register, hence a trace for tps25750 status register is added. Signed-off-by: Abdel Alkuor --- drivers/usb/typec/tipd/core.c | 10 +++++---- drivers/usb/typec/tipd/trace.h | 37 ++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index dd3c76b57aaa..326c23bfa8e6 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -453,7 +453,11 @@ static bool tps6598x_read_status(struct tps6598x *tps, u32 *status) dev_err(tps->dev, "%s: failed to read status\n", __func__); return false; } - trace_tps6598x_status(*status); + + if (tps->is_tps25750) + trace_tps25750_status(*status); + else + trace_tps6598x_status(*status); return true; } @@ -1188,10 +1192,8 @@ static int tps6598x_probe(struct i2c_client *client) if (ret) goto err_reset_controller; - ret = tps6598x_read32(tps, TPS_REG_STATUS, &status); - if (ret < 0) + if (!tps6598x_read_status(tps, &status)) goto err_clear_mask; - trace_tps6598x_status(status); /* * This fwnode has a "compatible" property, but is never populated as a diff --git a/drivers/usb/typec/tipd/trace.h b/drivers/usb/typec/tipd/trace.h index 739b0a2a867d..afa0875a9de5 100644 --- a/drivers/usb/typec/tipd/trace.h +++ b/drivers/usb/typec/tipd/trace.h @@ -91,6 +91,14 @@ TPS_STATUS_USB_HOST_PRESENT_MASK | \ TPS_STATUS_LEGACY_MASK)) +#define TPS25750_STATUS_FLAGS_MASK (GENMASK(31, 0) ^ (TPS_STATUS_CONN_STATE_MASK | \ + GENMASK(19, 7) | \ + TPS_STATUS_VBUS_STATUS_MASK | \ + TPS_STATUS_USB_HOST_PRESENT_MASK | \ + TPS_STATUS_LEGACY_MASK | \ + BIT(26) | \ + GENMASK(31, 28))) + #define show_status_conn_state(status) \ __print_symbolic(TPS_STATUS_CONN_STATE((status)), \ { TPS_STATUS_CONN_STATE_CONN_WITH_R_A, "conn-Ra" }, \ @@ -148,6 +156,14 @@ { TPS_STATUS_HIGH_VOLAGE_WARNING, "HIGH_VOLAGE_WARNING" }, \ { TPS_STATUS_HIGH_LOW_VOLTAGE_WARNING, "HIGH_LOW_VOLTAGE_WARNING" }) +#define show_tps25750_status_flags(flags) \ + __print_flags((flags & TPS25750_STATUS_FLAGS_MASK), "|", \ + { TPS_STATUS_PLUG_PRESENT, "PLUG_PRESENT" }, \ + { TPS_STATUS_PLUG_UPSIDE_DOWN, "UPSIDE_DOWN" }, \ + { TPS_STATUS_PORTROLE, "PORTROLE" }, \ + { TPS_STATUS_DATAROLE, "DATAROLE" }, \ + { TPS_STATUS_BIST, "BIST" }) + #define show_power_status_source_sink(power_status) \ __print_symbolic(TPS_POWER_STATUS_SOURCESINK(power_status), \ { 1, "sink" }, \ @@ -292,6 +308,27 @@ TRACE_EVENT(tps6598x_status, ) ); +TRACE_EVENT(tps25750_status, + TP_PROTO(u32 status), + TP_ARGS(status), + + TP_STRUCT__entry( + __field(u32, status) + ), + + TP_fast_assign( + __entry->status = status; + ), + + TP_printk("conn: %s, vbus: %s, usb-host: %s, legacy: %s, flags: %s", + show_status_conn_state(__entry->status), + show_status_vbus_status(__entry->status), + show_status_usb_host_present(__entry->status), + show_status_legacy(__entry->status), + show_tps25750_status_flags(__entry->status) + ) +); + TRACE_EVENT(tps6598x_power_status, TP_PROTO(u16 power_status), TP_ARGS(power_status),