From patchwork Wed Sep 27 17:53: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: 727049 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 1AFC014F69; Wed, 27 Sep 2023 17:57:35 +0000 (UTC) Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C836A1; Wed, 27 Sep 2023 10:57:31 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-533e7d127d4so9810578a12.3; Wed, 27 Sep 2023 10:57:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695837450; x=1696442250; 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=2TTTzseuuP8hjwAd/NiPB8IAcvjSSkCe6oGYFrHNmxU=; b=mN74+OMDMvxtjmHGZICS4GEBUV4eInqBngTcV070k5wK3M8+BgCIsD/FnEyv41qDy7 49zjCsEFsf4WnV/cbztZFXRlhCIMRx5yYT0IPz9euIFXLCfKYEjmnPhvyC2aSN+Xi8ss Vy2QB4s84nGGyi3apFUfKH3+nz+RVpzW2bCmu2ChVx4rBdxYVARxNcZpacRYYSqYQPBI mlIyKL534KcUE/K2LQnEBe0KJw3X+eOdbjI0cnZ0NGRChyPFQ7QJwhzTr9fczRLFtNoQ Dm/S3neRZ0dq3HZiXugjP5wth5X+7JGe1Zl0J13yrvwdgyP90dvom0xG5NQmL/GymACq OnRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695837450; x=1696442250; 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=2TTTzseuuP8hjwAd/NiPB8IAcvjSSkCe6oGYFrHNmxU=; b=olXhE2WNecjGHFDjsXwBuOPLRNSkSiiW1R1ivL+3MTiCYIJRkHjMTLKa2Oed+ZXeD0 F+NgrW1PKj92zX3Ng+7CaCqFWsVKWAUUm2nwiUNVsaxgOmy09BDA3NwbSQjBStIor+oO BZyJuVzFJYCzA0XgnVHoZT0NFMRSwcOubvnDz5Y03yLoxjpi4bAgRpiqFxjMBKI1VbfS 9jN/UryARWcjZmtnLKI4f8vy7QTOpNTUEeXM5oKUKnH2MXURXZQO6z2TjZtVy7PiSHOa 6bqwGvFThn18YvROMD7UCv0G0T65r5KZ0qzYru46hG6/8vE8w22WQry2lPRdc1QhKbGa fGNA== X-Gm-Message-State: AOJu0Yynxr4W1qv/P3vbmRyK0zv6TVYZy5GnLxM3lpFtEVPUca+HoNWA 5d37rm28XmmTwMWdehbRbbnGqKby7wVia7iTBo8= X-Google-Smtp-Source: AGHT+IFsBDydS1HVbzexalbvWNzbeH6PI6ko1Xyxu7X+wcbnVvoG/wV/q8NKkiI0SxAFDuzDmHP/Cg== X-Received: by 2002:a17:906:11d:b0:9ae:738b:86d0 with SMTP id 29-20020a170906011d00b009ae738b86d0mr2514961eje.66.1695837449995; Wed, 27 Sep 2023 10:57:29 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id d4-20020a170906370400b0099bd8c1f67esm9654593ejc.109.2023.09.27.10.57.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 10:57:29 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ryan.eleceng@gmail.com, robh+dt@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org, Abdel Alkuor Subject: [PATCH v7 01/14] dt-bindings: usb: tps6598x: Add tps25750 Date: Wed, 27 Sep 2023 13:53:35 -0400 Message-Id: <20230927175348.18041-2-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230927175348.18041-1-alkuor@gmail.com> References: <20230927175348.18041-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=-0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_PASS autolearn=no 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 --- Changes in v7: - Define reg at top-level - Remove description from reg-names Changes in v6: - Use reg property for patch address Changes in v5: - Add tps25750 bindings .../devicetree/bindings/usb/ti,tps6598x.yaml | 81 ++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml b/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml index 5497a60cddbc..9303d00b89de 100644 --- a/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml +++ b/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml @@ -20,8 +20,18 @@ properties: enum: - ti,tps6598x - apple,cd321x + - ti,tps25750 + reg: - maxItems: 1 + minItems: 1 + items: + - description: main PD controller address + - description: | + I2C slave address field in PBMs input data + which is used as the device address when writing the + patch for TPS25750. + The patch address can be any value except 0x00, 0x20, + 0x21, 0x22, and 0x23 wakeup-source: true @@ -32,10 +42,47 @@ 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 + required: - compatible - reg +allOf: + - if: + properties: + compatible: + contains: + const: ti,tps25750 + then: + properties: + reg: + maxItems: 2 + + reg-names: + items: + - const: main + - const: patch-address + + connector: + required: + - data-role + + required: + - connector + - reg-names + else: + properties: + reg: + maxItems: 1 + additionalProperties: true examples: @@ -68,4 +115,36 @@ examples: }; }; }; + + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + typec@21 { + compatible = "ti,tps25750"; + reg = <0x21>, <0x0f>; + reg-names = "main", "patch-address"; + + interrupt-parent = <&msmgpio>; + interrupts = <100 IRQ_TYPE_LEVEL_LOW>; + interrupt-names = "irq"; + firmware-name = "tps25750.bin"; + + pinctrl-names = "default"; + pinctrl-0 = <&typec_pins>; + + typec_con0: connector { + compatible = "usb-c-connector"; + label = "USB-C"; + data-role = "dual"; + port { + typec_ep0: endpoint { + remote-endpoint = <&otg_ep>; + }; + }; + }; + }; + }; ... From patchwork Wed Sep 27 17:53: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: 727048 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 319B83AC01; Wed, 27 Sep 2023 17:57:38 +0000 (UTC) Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6CF0F3; Wed, 27 Sep 2023 10:57:35 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2c012232792so200369041fa.0; Wed, 27 Sep 2023 10:57:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695837454; x=1696442254; 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=ZRvQEPSEiEBX2XgILYaykwXlkKwlukHcD1HvhPUf8VQ=; b=Kv6E/GLJshZwmJmVNkVcbOuxJ/yU57YGeaSWbvI1ETHXwfNaHx8IyLNCR9CO5nA4WC WFMLLRs5lXxtyc0zdSu0DA3WUm/CUSs01hnQ0LasOszLMgvXXkYRzN7mJJaTdLLDUj4N m+iyx6dBfmRs2ZYXtlH+2GVuDx8lFtmrABkCmVG8Q5Wg9uPAq0GXtAzSr21kA+Ufim8B p7a8faA91Kbcz5UM+7sBCR9Ho/y/xoOTEq35Tw5zQeLyTg/5Cbgfn+u8Tj07si3413P5 Po2oBtA6nrnSmWRmK5+2iHNOPrh/BZCO3t/tMPlv6jQ/pamAJX2KKl0o81fJDUJYD8Tu Bd1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695837454; x=1696442254; 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=ZRvQEPSEiEBX2XgILYaykwXlkKwlukHcD1HvhPUf8VQ=; b=oL4tcT/Pi84xSPmWS6U5g1QQxhzMjVZdph1NR3VMjDOEPy225u0tcHsc4EvuQdLkks MaozX5DPjJ4VQ1A4fWgv1TRJ8IzSODWHW1mG0YdMkg4Xkmm6M00ahfLXqpzPZyHYDHRv z2UgGatK7Smg4cCLwBf63/i9CfLPnrAGXPEKXhfJM+7pLhY0nrCIOxHQmIqIF9pCeh/W PxIxJPntUlbR3iSOg26FpcVzbIXtk5sn22JhVd/H/a7F7oPKsAUF6O9vYe14H5z9u3dN agte93HVbh+/yTMx/PB7vE2fFEUlmg+jxkQNKo2nOjP3nZQVWBSPVY0btvOrUM4dHtok Zyxw== X-Gm-Message-State: AOJu0YzMr1qH3z8qioL92m6zXxSl+PQNUAocxDNvzbDqQSEnDHDo94yW Pc8b3q21bAKAWw4nZkA61qc= X-Google-Smtp-Source: AGHT+IFbN9AL+Mtr7T7ESiWlo1UgMb1mrS8iwJl8n3UjfMto5Wb+debHnpMySSqgSMQgEhTCZIA3KQ== X-Received: by 2002:a2e:9616:0:b0:2bc:cc1a:139c with SMTP id v22-20020a2e9616000000b002bccc1a139cmr2557448ljh.11.1695837453861; Wed, 27 Sep 2023 10:57:33 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id d4-20020a170906370400b0099bd8c1f67esm9654593ejc.109.2023.09.27.10.57.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 10:57: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, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ryan.eleceng@gmail.com, robh+dt@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org, Abdel Alkuor Subject: [PATCH v7 03/14] USB: typec: tps6598x: Add patch mode to tps6598x Date: Wed, 27 Sep 2023 13:53:37 -0400 Message-Id: <20230927175348.18041-4-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230927175348.18041-1-alkuor@gmail.com> References: <20230927175348.18041-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=-0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_PASS autolearn=no 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 has a patch mode indicating the device requires a configuration to get the device into operational mode Signed-off-by: Abdel Alkuor --- Changes in v7: - Add driver name to commit subject Changes in v6: - Return current mode and check it directly Changes in v5: - Incorporating tps25750 into tps6598x driver drivers/usb/typec/tipd/core.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 32420c61660d..58679b1c0cfe 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" */ @@ -593,12 +595,15 @@ static int tps6598x_check_mode(struct tps6598x *tps) if (ret) return ret; - switch (match_string(modes, ARRAY_SIZE(modes), mode)) { + ret = match_string(modes, ARRAY_SIZE(modes), mode); + + switch (ret) { case TPS_MODE_APP: - return 0; + case TPS_MODE_PTCH: + return ret; case TPS_MODE_BOOT: dev_warn(tps->dev, "dead-battery condition\n"); - return 0; + return ret; case TPS_MODE_BIST: case TPS_MODE_DISC: default: @@ -765,7 +770,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); - if (ret) + if (ret < 0) return ret; ret = tps6598x_write64(tps, TPS_REG_INT_MASK1, mask1); From patchwork Wed Sep 27 17:53: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: 727047 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 3EFAD4B21B; Wed, 27 Sep 2023 17:57:44 +0000 (UTC) Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F48C12A; Wed, 27 Sep 2023 10:57:40 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2c124adf469so197985711fa.0; Wed, 27 Sep 2023 10:57:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695837458; x=1696442258; 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=08TTJK6jIdlF3YGQZqg/ueMGQffH5CXs2rT/Yy540NE=; b=Fo4aXa5bduEsfH0X1GG2XnvD/W23eQHGKXCgWHjFzeXd7R+FDite+0yC2qRE7dsh3M j3Gt5EzAie5+cJAiaE/BStwMQ7kg4RCH/MCyg3EXJP+xkPgLMJypTDDJ9H4hugp3697J QyVvVGDa5oxwa2w/XcZhVVw/RnB986hedkEuk6g5OwQxyOgTR6fxZEHLsU61HMbjpDrZ VFOx6GJUbES3yNe0vR2GyRXtPTBmZlwgmdbdeSZn1xDG9bW/hhez/qeNSl7nRvl9/klX FJpjfKaIYpvOE3R2fKf+wdIRupyVWmPYXeb1y7z1rkn2qO0fvTehMjMvIXM6+KDEITso yNTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695837458; x=1696442258; 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=08TTJK6jIdlF3YGQZqg/ueMGQffH5CXs2rT/Yy540NE=; b=moISAK70dRA6o6RzErHPK+rcjByX6wfaMPurDDM/aGH0KDaTQHnwu9HEQfuTpuSdOR xzmvZSjkSIXQ37TqFekHpW/dz0nDtrEhcNyD7wV8mNWoO4CIq1q+Ff8DnE0cB/wG1O8Y ZNhvEV/dAvqkdqL93FREz8SlGDWDdjm3LpX3n8H38X31oPtWm9OfvF/VmPDijg8mg8sS tRYueQrmAAA1ZCy4miMNEhmh9Z/CPjjzYFBKz9lVYPgwaLxGlDygCBBRGdIjxZ6ggn3Z uahUO8dCME1eFFypUirI956544PdQA3p3d8bA/+rCNfG0OlrqOnH4l4fV3vnNYem15/C AUpQ== X-Gm-Message-State: AOJu0YwrnGkzU+gs9cAGFfHpefUek6iMWTAD+yD1a2aYx62yJivEOjfW Lna/iif5t38WB5fJ4bJHjkM= X-Google-Smtp-Source: AGHT+IEyz3wuba9KzvLZVtTeMjdqegWWFZuYn6c0/tWcUr1gjEMr4JLFbSZrGFtELLYtczMFW9thAg== X-Received: by 2002:a2e:93cf:0:b0:2bd:1bca:ebee with SMTP id p15-20020a2e93cf000000b002bd1bcaebeemr2559253ljh.19.1695837458077; Wed, 27 Sep 2023 10:57:38 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id d4-20020a170906370400b0099bd8c1f67esm9654593ejc.109.2023.09.27.10.57.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 10:57:37 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ryan.eleceng@gmail.com, robh+dt@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org, Abdel Alkuor Subject: [PATCH v7 05/14] USB: typec: tps6598x: Check for EEPROM present Date: Wed, 27 Sep 2023 13:53:39 -0400 Message-Id: <20230927175348.18041-6-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230927175348.18041-1-alkuor@gmail.com> References: <20230927175348.18041-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=-0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_PASS autolearn=no 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 --- Changes in v7: - Add driver name to commit subject Changes in v6: - Update eeprom macro to use TPS instead Changes in v5: - Incorporating tps25750 into tps6598x driver 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 f96a9ff07fba..cd22635460d3 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 @@ -910,6 +911,17 @@ static int tps25750_apply_patch(struct tps6598x *tps) { int ret; unsigned long timeout; + 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 & TPS_BOOT_STATUS_I2C_EEPROM_PRESENT) + goto wait_for_app; ret = tps25750_start_patch_burst_mode(tps); if (ret) { @@ -921,6 +933,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..a80d0929f3ee 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 TPS_BOOT_STATUS_I2C_EEPROM_PRESENT BIT(3) + #endif /* __TPS6598X_H__ */ From patchwork Wed Sep 27 17:53:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 727046 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 C05454BDD1; Wed, 27 Sep 2023 17:57:45 +0000 (UTC) Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C4D110A; Wed, 27 Sep 2023 10:57:43 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-99c1c66876aso1501383566b.2; Wed, 27 Sep 2023 10:57:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695837462; x=1696442262; 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=JIF24z+W4xSOOiQxGgE0N6mbcOqb2K0f4VACmgBIH2A=; b=MY+7TXiGutqbrMEdSTizXRAzYD3SVcs5Ym61Bbszoqa4ClM9cQQ26CG1enRQauurGo UIlt85qCuJeAvkdsqSCM9u2mqF3Gj3/dek46VjOdRTTVf95dQIMzREwGwmI1/mEHpcXn 8o22Mcz5tfFnJoaX6/8NHHuh49pg3FuWaYXCKr5SS8p7VUbQk7AFyYxCZCIUcttorTZZ bFLkxvf4AqngexGgqz692kwIivARcf3fPcfsFTjjyvxomHS2wE9GbBMW38qbaHfVMYmr 5wfx38wn6i+Jr4IOUr8GPWLd9+CUghGxPtS9DEOfoPyAUB25OQWZUVK34t7ub/S+Aury cIGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695837462; x=1696442262; 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=JIF24z+W4xSOOiQxGgE0N6mbcOqb2K0f4VACmgBIH2A=; b=Xulmwa1KKYNe6NMCnbJjrHFFeBOvR44LKAn3eqkgQNl9JGmfyYxcQN5g45aeiQFN82 9R9/rtgLPGiZrilNHDsdyOvKdNXm/bkRYvh1vmnYu5WEJJ9/Mu1wwYnaz6Ols3VKz+1+ aGyTweifNvbIlKTg07do2yuTjv1slPodx5dOMMVfJC+nAa5nokoqC1GUHOtYYAleonyb Qm+HbpKYXQZli0dr9DyV/j8tqHf+yc4O4QXtlTVf8m3OJDQ1GbqxnBDA4R0mbwftAlxP rSl0WtHVUkzR0LrnzVfuC4NmMS5PFrYiZuCiSUBFIG9EZkah2L9ByTUcgIQ1sR0C9R9c p3+w== X-Gm-Message-State: AOJu0YyWO0BjClJGtgjw4nrxwOaqtN/IzuSBE7vlU1EoxJGVHdICGp4r NQtVdV5XaG4DArITmxwVn0g= X-Google-Smtp-Source: AGHT+IH1Q9tjD6rssGUuLjMyyepySAgaNFHRHoviVDMNRT4tI+seuCHDwQugbI51YIzArWGmR4TSxQ== X-Received: by 2002:a17:906:5c:b0:9ae:63bd:a7fe with SMTP id 28-20020a170906005c00b009ae63bda7femr2493309ejg.10.1695837461874; Wed, 27 Sep 2023 10:57:41 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id d4-20020a170906370400b0099bd8c1f67esm9654593ejc.109.2023.09.27.10.57.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 10:57:41 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ryan.eleceng@gmail.com, robh+dt@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org, Abdel Alkuor Subject: [PATCH v7 07/14] USB: typec: tps6598x: Apply patch again after power resume Date: Wed, 27 Sep 2023 13:53:41 -0400 Message-Id: <20230927175348.18041-8-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230927175348.18041-1-alkuor@gmail.com> References: <20230927175348.18041-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=-0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_PASS autolearn=no 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 --- Changes in v7: - Add driver name to commit subject Changes in v6: - Check tps25750 using is_compatiable device node Changes in v5: - Incorporating tps25750 into tps6598x driver 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 faeee2ffc99c..56ffffe225f2 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -1204,6 +1204,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); + struct device_node *np = client->dev.of_node; + int ret; + + ret = tps6598x_check_mode(tps); + if (ret < 0) + return ret; + + if (of_device_is_compatible(np, "ti,tps25750") && ret == TPS_MODE_PTCH) { + ret = tps25750_apply_patch(tps); + if (ret) + return ret; + } if (tps->wakeup) { disable_irq_wake(client->irq); From patchwork Wed Sep 27 17:53:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 727045 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 17BFB4A52F; Wed, 27 Sep 2023 17:57:52 +0000 (UTC) Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75A32CE6; Wed, 27 Sep 2023 10:57:47 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-991c786369cso1432820766b.1; Wed, 27 Sep 2023 10:57:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695837466; x=1696442266; 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=aDe7CzXud22Tg0X5E9wYPOoM/0EBNI8QuGXK8h/hMrw=; b=HeWBYA9RiV0tKbg6k7DcQdOIeZk2LYSZ9/l5N6oc2li9Q9cVGm4WUTxGJTOqps5+tL AM10zdvLGBxLt7HDBpGKG3clYX5WxyYmDjrjzi8lJfIfJ4golDh7/PAa8LM6TK8jDB9q hLNJPUbvlLbdsbp+uEldgLA+uKSXAoEwzSxFbc3fzZfTG4anAtJKAf42hBOYcUThwQa8 OBAZ/MjtgjMD5O4wga9B7cxfZ6bzcfGnVBuc6+2SrOz5uXq9opMqiz56f+Gz9p8GN35R CqS7lW+JVPJNoc2KkyVl9mP0mtvoG4xV8ptmDZQjw4Owh8zzDrXu5qAumUeMZy/60Uc/ FhIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695837466; x=1696442266; 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=aDe7CzXud22Tg0X5E9wYPOoM/0EBNI8QuGXK8h/hMrw=; b=tE7ir8JBEDgYeUNYXHfM2p7YDXcSKp2BUHRuhr9N9ToWoT19B8GcDfI5TQmnNjFtfd 4USDSkb8GWpVDK4hjLd5Nb1l5pcT4QTDZAVZ5uet8eIZuyuuZouomNggZtTIKop2mkND O6cZ22pDawa9EL305tLdvv0PX51xPlF72zbYd35PurJZFnut4XsuUWRcao27YEv9JYY9 CJ45tli+9fbjhUBa0ybQ0eAKySbym5wPNeRGdXp4uQNbpJK1BfiTdKrSQ40q2ySyocfi GsIdzQ/HQFrwGxMiENS0WDzuEM0EwFFiFXsT5Zy6eXiz1+DChyiB5eNy/y0rdOWIdC+Z 5/cA== X-Gm-Message-State: AOJu0YxLvZm4FUv8htsmJKgEKaOy4pX9iF9vX2TyG5SXvy8pxGwlQ7fG POJIwlLI5OIB9Kn4cQJZlXc= X-Google-Smtp-Source: AGHT+IGG5tYu/U9pD9f/rgporT80dWB5xuW3JZG+4pMt2lJfhsKLAEj4F1vsL3l0RxDuBT4xRcJ0ig== X-Received: by 2002:a17:906:3145:b0:9ad:ec25:825b with SMTP id e5-20020a170906314500b009adec25825bmr2247961eje.58.1695837465682; Wed, 27 Sep 2023 10:57:45 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id d4-20020a170906370400b0099bd8c1f67esm9654593ejc.109.2023.09.27.10.57.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 10:57:45 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ryan.eleceng@gmail.com, robh+dt@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org, Abdel Alkuor Subject: [PATCH v7 09/14] USB: typec: tps6598x: Refactor tps6598x port registration Date: Wed, 27 Sep 2023 13:53:43 -0400 Message-Id: <20230927175348.18041-10-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230927175348.18041-1-alkuor@gmail.com> References: <20230927175348.18041-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=-0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_PASS autolearn=no 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 --- Changes in v7: - Add driver name to commit subject Changes in v6: - No changes Changes in v5: - Incorporating tps25750 into tps6598x driver 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 8f6268535866..96fea423129d 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -1030,6 +1030,58 @@ 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 const struct tipd_data cd321x_data = { .irq_handler = cd321x_interrupt, }; @@ -1045,11 +1097,9 @@ static const struct tipd_data tps25750_data = { static int tps6598x_probe(struct i2c_client *client) { 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; @@ -1123,10 +1173,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. @@ -1144,50 +1190,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 Wed Sep 27 17:53:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 727044 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 216B24BDD0; Wed, 27 Sep 2023 17:57:59 +0000 (UTC) Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29F3610D3; Wed, 27 Sep 2023 10:57:50 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-51e28cac164so28000549a12.1; Wed, 27 Sep 2023 10:57:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695837469; x=1696442269; 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=Sf41GpttTXH9NGnzfB9RP8nxYb55p65KkNUeRtKNh+Y=; b=f96bWUp1nZ2mO97Ipql9NWSRIT8cFalcBDCVO2P/aDjQqW+8dNnqu8wMCiZukWXbvf 4ML9EjvFtsiA6ClhZsMSabgAkCpcCFiJbeZIqp45oMACwyLwIBrop/1+rZZWWTnIfG5b X/XG2w8ZDr+BkapFLYwrT9UBvZ7e6V6QqwRwb3ZXuoiWMIHWSaaaXeO0bB1jm74prO4N +C+/LhaiQMxXtEvIHIx+/+AarMfYY4du10OilEmfaxu9ikMyDr98ejJn6g92rjpM4LdM QrHezpu9EYbvwfewfxMOfK6+P0xsnTalZJdWkVYdXI+/pwvap9VVkbSowI1BEOIKBxcn cs8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695837469; x=1696442269; 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=Sf41GpttTXH9NGnzfB9RP8nxYb55p65KkNUeRtKNh+Y=; b=iNhnA+hsA4Q2zim3KkuyhhoteIf2PwN7VAVUM2+yCT8511tBic8gVQNE8oSVO2AqtD aPWKwvYXfwSj/UvPO373kAjlM1VxOicund3PRMfwzMvfq7VOmynsZ5jPFrt58NHXKfpp wWLyF/b3ESdbrna7wXmonc4jyHLU7QAm4fv9bGXT8Asm9DLDntgB6VLPIuWAtvKxP0xu Fv0jGun1CeETOs77wmcxIZlhKWPBONK0ZFfg8kNXtbO9oIp62qAtzSm46hJam1mUYPJP lbF6h4JIxVpv8mqA8knE7K5QD5MZ1HpeGvb0mAvYzgAxMLxJNzicMPlIi8Q+PfXXQHFx ytPw== X-Gm-Message-State: AOJu0YxKsHjyDevPCNwurXT9pRvEnywCOhlkUZQsQu3pjk7HXoizs8Si nZS9zndzfAM5PhgePTlFIRE= X-Google-Smtp-Source: AGHT+IF1z+E/tX9+OE8N+e3m465FBZrG3IcOsR5RiyKEcJBCUV2BCXitgk7UqFfApjWRsa2pyKx/Ew== X-Received: by 2002:a17:906:2a50:b0:9a1:8993:9532 with SMTP id k16-20020a1709062a5000b009a189939532mr7184555eje.30.1695837469366; Wed, 27 Sep 2023 10:57:49 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id d4-20020a170906370400b0099bd8c1f67esm9654593ejc.109.2023.09.27.10.57.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 10:57: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, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ryan.eleceng@gmail.com, robh+dt@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org, Abdel Alkuor Subject: [PATCH v7 11/14] USB: typec: tps6598x: Enable sleep mode for tps25750 Date: Wed, 27 Sep 2023 13:53:45 -0400 Message-Id: <20230927175348.18041-12-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230927175348.18041-1-alkuor@gmail.com> References: <20230927175348.18041-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=-0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_PASS autolearn=no 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 --- Changes in v7: - Add driver name to commit subject Changes in v6: - Use tps25750_init instead of tps25750_apply_patch in resume as it initializes sleep mode Changes in v5: - Incorporating tps25750 into tps6598x driver drivers/usb/typec/tipd/core.c | 23 +++++++++++++++++++++-- drivers/usb/typec/tipd/tps6598x.h | 3 +++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index e775c3c9bf64..19bb2105b5b2 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) @@ -1040,6 +1041,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) { @@ -1226,7 +1245,7 @@ static int tps6598x_probe(struct i2c_client *client) return ret; if (is_tps25750 && ret == TPS_MODE_PTCH) { - ret = tps25750_apply_patch(tps); + ret = tps25750_init(tps); if (ret) return ret; } @@ -1365,7 +1384,7 @@ static int __maybe_unused tps6598x_resume(struct device *dev) return ret; if (of_device_is_compatible(np, "ti,tps25750") && ret == 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 3a9a43394134..f86b5e96efba 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 Wed Sep 27 17:53:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 727043 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 779DF4BDDF; Wed, 27 Sep 2023 17:58:03 +0000 (UTC) Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCBB11B7; Wed, 27 Sep 2023 10:57:54 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-98377c5d53eso1443260366b.0; Wed, 27 Sep 2023 10:57:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695837473; x=1696442273; 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=voe1AQlyJ66tuR3HAig5V+hgG3HWnfF9e7gj5LZdSfU=; b=a1FlIBvM/6x5sT3UzeDHPHDXv3f8hkhuaTz1C6YKhY6SzdRTVXHfAQZ/mnZY82vQ29 t6ev6qo6H5kmjxunJNoMS1xsJoRwAFf29uEfCd562rAHGp2hs2YVkhiefi9Z+DgKwvFT H0TAH4w3Z6bTdfsEZhKfhCuZ/OW/rh8Tsx+gCCAqKVpf/Kbt+RvGsEP6GOPNX4CuFj97 NOFGEsgd1T+a1ez1Yfn/ypfASyqAx4uejtAZgA8UOI72/M5aIbTTIazn0/NCvKx15lTc M5s+r1k6TTOq7r7anI2374fIUrs2wQt5n82ATForzCFkfg6LfQeGT82+yuFDgH8oAQv2 YdVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695837473; x=1696442273; 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=voe1AQlyJ66tuR3HAig5V+hgG3HWnfF9e7gj5LZdSfU=; b=BZenB/wKrhv0CcF6bWZPVCifHEXWhixN/xPIXNuB9kLMhZkgldfULABHgXGSM7ck0z 9ICoPOaeBl2fYjH4lrfwWPXKPrjQBHQJgVJGqX/2TAqbVmHLmDXaDQFPTR3XdBd4nRR5 vH9+LEvrPEoA3lIx/y4j6goHZehcGvzskbMVgtZK64PHeQJhWZnaGt7cMnHLIy8JjgDG 5BJzjMMg3z2o0IuEpWeb8THRASM8EB+n8/ecLQBV7210KTNscMF3f+TemffGsQJpnW+a 1KX4KsPl+701lNn9F58+FaIpG07L2V4mEE7/iC/VlFADCMA/b5UKggi0i5EX1W8wrp6u DSgw== X-Gm-Message-State: AOJu0Yw2eoymZSxgit1rTDQx9DCi8ue5XUD8wQgYXSkY6Ztfgdf6h0BZ zZ175pIFQf+TNa92bQr+Kyc= X-Google-Smtp-Source: AGHT+IFBhh41IjhFHrPaLC372wAaeq1Wy7oOT23zUFkCcfy05iMPrbdUuVOYXKK76NL26y21nbHrfw== X-Received: by 2002:a17:907:75d6:b0:99e:f3b:2f78 with SMTP id jl22-20020a17090775d600b0099e0f3b2f78mr2249383ejc.67.1695837473153; Wed, 27 Sep 2023 10:57:53 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id d4-20020a170906370400b0099bd8c1f67esm9654593ejc.109.2023.09.27.10.57.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 10:57: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, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ryan.eleceng@gmail.com, robh+dt@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org, Abdel Alkuor Subject: [PATCH v7 13/14] USB: typec: tps6598x: Add power status trace for tps25750 Date: Wed, 27 Sep 2023 13:53:47 -0400 Message-Id: <20230927175348.18041-14-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230927175348.18041-1-alkuor@gmail.com> References: <20230927175348.18041-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=-0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_PASS autolearn=no 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 --- Changes in v7: - Add driver name to commit subject Changes in v6: - Add trace power status to tipd data factory Changes in v5: - Incorporating tps25750 into tps6598x driver drivers/usb/typec/tipd/core.c | 8 +++++++- drivers/usb/typec/tipd/tps6598x.h | 19 ++++++++++++++++++ drivers/usb/typec/tipd/trace.h | 33 +++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index deb2b756fec4..c9c30de6e77a 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -108,6 +108,7 @@ struct tps6598x; struct tipd_data { irq_handler_t irq_handler; int (*register_port)(struct tps6598x *tps, struct fwnode_handle *node); + void (*trace_power_status)(u16 status); }; struct tps6598x { @@ -498,7 +499,9 @@ static bool tps6598x_read_power_status(struct tps6598x *tps) return false; } tps->pwr_status = pwr_status; - trace_tps6598x_power_status(pwr_status); + + if (tps->cb.trace_power_status) + tps->cb.trace_power_status(pwr_status); return true; } @@ -1169,16 +1172,19 @@ tps25750_register_port(struct tps6598x *tps, struct fwnode_handle *fwnode) static const struct tipd_data cd321x_data = { .irq_handler = cd321x_interrupt, .register_port = tps6598x_register_port, + .trace_power_status = trace_tps6598x_power_status, }; static const struct tipd_data tps6598x_data = { .irq_handler = tps6598x_interrupt, .register_port = tps6598x_register_port, + .trace_power_status = trace_tps6598x_power_status, }; static const struct tipd_data tps25750_data = { .irq_handler = tps25750_interrupt, .register_port = tps25750_register_port, + .trace_power_status = trace_tps25750_power_status, }; static int tps6598x_probe(struct i2c_client *client) diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps6598x.h index f86b5e96efba..01609bf509e4 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),