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: 13388580 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DA434A2D; Sun, 17 Sep 2023 15:27:22 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IFAlU2KLbwPivzOvNhDV1UMVme5WR2wh+T5rKnTHdLovV+gEmPLm0qVb+TxWDSQpUuCpFvRcw== 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> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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: 13388581 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B6715231; Sun, 17 Sep 2023 15:27:23 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IGko7b9aR5sWDMm6H18nBCRxP4mO2QkcpzdwsQ27qTAHPfZm8aZZ0pGm5eyyZXvPOzhlRjw+w== 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> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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: 13388582 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99AF2538F; Sun, 17 Sep 2023 15:27:26 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IEhCdOXPEWVKfUzjHWZyi9HFGsZVEbrsH6gbLnrQoi9K5ObS1JXY0QX0vLnLRbav0lv9Qb3sQ== 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> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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: 13388583 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF1F5185A; Sun, 17 Sep 2023 15:27:30 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IF8LX2946iuaQxzTBL1HoJ24ntB5XQx0fJycjJyOsBRfQ4bAhnK5GX/Clk4ybAAD8SzYysd9g== 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> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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: 13388584 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FC981848; Sun, 17 Sep 2023 15:27:32 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IE3hqlV60mQRZuntGz1aiQ3pEziwdFwgKsPg/H+OdE8LfUvrphwYVpAsnVYm8bFDXva1LHbaA== 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> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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: 13388585 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF599290B; Sun, 17 Sep 2023 15:27:34 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IHrv5TtM34LmV6LdzcIwq/lFHrevCPfCaGHWAlJA/NCVFP7bCafP4Q+vTdNNEFFZv9aerHxwg== 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> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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: 13388586 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D75823D3; Sun, 17 Sep 2023 15:27:37 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IHXg5bI6LiwY5neIQaMjC6xoDzCmTHWLh8hZoZeoHAxA0NwnWzPpBV+I/WJq0bGf0N2OD9Imw== 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> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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: 13388587 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 881D36FD0; Sun, 17 Sep 2023 15:27:40 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IEzHH309aK1MdqEVdMZK5QwworImmdO54o7bTeVFiV3eTQuv0wiAWiEeP7n2zNb9NGtwNRLpw== 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> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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: 13388588 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53DC46FD0; Sun, 17 Sep 2023 15:27:43 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IHhkqw+OHSOmFSTdEoq5773mUgp2STJiAqBe8b13HYPxJ4M4UUXZ8onuJKTHZGa1ibtNCLIcw== 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> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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: 13388590 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21F19748B; Sun, 17 Sep 2023 15:27:47 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IE2whKvpl5VAri2AnH12htURwwKvEYwF8MPrJNUKJ1cuni1fK0gHc0sI7GYpuTgXWiceWtWpw== 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> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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: 13388589 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8588F23BD; Sun, 17 Sep 2023 15:27:48 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IHuQ5GHCtgPrcqNGuZhnt2rN0nTJVYlNyOV4spivVTJO8b0FW1At9WsNKfWdsKfdMUrtQoKzw== 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> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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: 13388591 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A29A2F4F3; Sun, 17 Sep 2023 15:27:50 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IHXWCZ8jI7PFgKTCoQkRWS5l8yPSyq/E7aHyQ5ss2XXI5whWJl6SFa+YhYJ8AW892qiJxErNw== 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> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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: 13388592 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75813F4F3; Sun, 17 Sep 2023 15:27:53 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IGB+bA/4PQpZ/qUKlRuqi5qcjkbXqV8r79ypUwa1oouPfnlFZ7Sotpv7prtQEW8BMLAt+IYUw== 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> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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: 13388593 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4FE0FF9CA; Sun, 17 Sep 2023 15:27:56 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IHkShHz18zKi/aXxX7+Lx10bI9IqBtUuVptBljp1sNz+m3EcSRCzmtFJFgRBBd2X0z/D3WQgg== 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> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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), From patchwork Sun Sep 17 15:26:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 13388594 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1C1AF9CA; Sun, 17 Sep 2023 15:27:58 +0000 (UTC) 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 2B740120; Sun, 17 Sep 2023 08:27:57 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-403012f27e1so39450635e9.1; Sun, 17 Sep 2023 08:27:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694964475; x=1695569275; 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=LD+60v9C6UaRp0/siQLtHNIFl77ZDBkVdyJlYrRa+7Y=; b=Gv1GZU9pH77NwfVpQIXgURem5swR3VLvbLwVzgtCXu+IojZri9otJ54Gj/r1pGOz3Y fhffDw+HELJw0TRA+qf0+ZvJJB1AfUzpjXuBS6VFVTvqOIBo2D3894Fyt8AHc00JybyZ m+/P2IvvZCCS3/kQn0zW9FQN0+mZ6UeDQSTW/biqvtsBk2bwW4Ez3XhC2NX8NfaMOgFF 6S+hfweTp9sqY8Mbvb7Lm7RyMVpe8ooegY1DXeR+8wet3M8KTJlUFKyK9oMiZ+zoTwya nHxIwKmAIDzu4fbrwksD1Ty4cCLgLQXBYluCVU+XzGX7VGL0O8e0kMOF6xXAeR9W0ZpN 1QAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694964475; x=1695569275; 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=LD+60v9C6UaRp0/siQLtHNIFl77ZDBkVdyJlYrRa+7Y=; b=ilMMzHBwBBOIoWkSXW1zjcnJ/bKBcFGZ6LbS0koP5qniuSAkhmPoED9lxlCOYZfF1h xevSQt6ag8aISEkpEwQ4FYSqFM6B/qd8/YCcHcPzGu+56TOJLJJz4tR7Wz+/NrnRwkso uPNhEWYbt8l0u0sA+CRs69F93J8q1kYJZx/vElsI1jLhIogjDjiB/E9BkHwCAMPKLgow n6AasUzBxOHJ7pUZioNNPaw+lc4i+eH4BCfIN6zTZUUePIHJUyxbXYeiRvWvm3M4JHJl bumeSkXRGqTCQU3lfKSvJD3r+6hKayk/Fkp9WHP20FtB3hoCwyH+Igeo/b+5EHn6YH6P JArQ== X-Gm-Message-State: AOJu0Yyi9XihZt94z+d5nphykaprFW+O+bqJwzC71XI/LkycM/Nrup3V tRPAY7rdsUKGXuyQhU36U2g= X-Google-Smtp-Source: AGHT+IFMoEpnwQyNLknzPee617qhcmJR/O2NloQ0cpT0cp57T8tjIvz2LAXQD9gdl6ee6PnfvYX2lA== X-Received: by 2002:a7b:c40b:0:b0:401:be70:53b6 with SMTP id k11-20020a7bc40b000000b00401be7053b6mr6000332wmi.15.1694964475610; Sun, 17 Sep 2023 08:27:55 -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.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 08:27:55 -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 15/15] USB: typec: Do not check VID for tps25750 Date: Sun, 17 Sep 2023 11:26:39 -0400 Message-Id: <20230917152639.21443-16-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> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net From: Abdel Alkuor tps25750 doesn't have VID register, check VID for PD controllers other than tps25750 Signed-off-by: Abdel Alkuor --- drivers/usb/typec/tipd/core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 326c23bfa8e6..c1399e12a170 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -1142,10 +1142,6 @@ static int tps6598x_probe(struct i2c_client *client) if (IS_ERR(tps->regmap)) return PTR_ERR(tps->regmap); - ret = tps6598x_read32(tps, TPS_REG_VID, &vid); - if (ret < 0 || !vid) - return -ENODEV; - /* * Checking can the adapter handle SMBus protocol. If it can not, the * driver needs to take care of block reads separately. @@ -1176,6 +1172,12 @@ static int tps6598x_probe(struct i2c_client *client) tps->irq_handler = irq_handler; + if (!tps->is_tps25750) { + ret = tps6598x_read32(tps, TPS_REG_VID, &vid); + if (ret < 0 || !vid) + return -ENODEV; + } + /* Make sure the controller has application firmware running */ ret = tps6598x_check_mode(tps, &mode); if (ret)