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: 146080 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3277302vqu; Thu, 28 Sep 2023 05:34:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFLzZIPCbuqrrZt6eQYfUpfJhVyJcsiphJsjo4VyPKcrQUAfWpB8RveaRn8qnJcGr4Lm0L8 X-Received: by 2002:a05:6358:2606:b0:141:bfc:b11d with SMTP id l6-20020a056358260600b001410bfcb11dmr1131918rwc.16.1695904474332; Thu, 28 Sep 2023 05:34:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695904474; cv=none; d=google.com; s=arc-20160816; b=rhKbxYer0jJyDhzKidVKFZWYynT6JkKDtHG3sfY8TfnnoObQGciIsKhV2f+jalOCq0 AKqNLGAJKHa2NX//1spdOtWPG6APVXe0A1bZ9iPLGO/t43U+WXiOAWmmsGSP0BckIhhl MpQ6JXBN391i7xRkNOQPQfpVmLfDm2ot9P4UnacHDHMkvl361zLdvLSdIhxY6uGniraN y9+ALYHqieQYWWYs3Ac3NQVuo6zxlIrNhaC+C1pKKQ6/Hiq8PfQy9QnzC74TwlG4O8Bk 465RDk+9TdpDufEPg/wmkaLZVEffH4iuePb+9e9h0UqooVQyJTcOUnr/ui9yrdEo0iFG MaHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2TTTzseuuP8hjwAd/NiPB8IAcvjSSkCe6oGYFrHNmxU=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=ONpPneOb6iFXjvSBKwF0GMveJGEZ3ym6PuZzkAcwNYyFevlGstxt03i9WlpL9FJ6I3 6PBDJMvpcZnfwgB8GcL7kQgIQ8L0ilpnqUvsrQnonXyn+UStGE8ipCT1nW6BY6sU3+zm Ym/gnQfpA6km+8R5iBz4bdptElwddf4QhcFOW2i+UFchgjEKJmao3te825dAcMU4Ud2W 9FACoxIt6NHTs1QpWRBviJbaTxj99z9Bw003YTCICpApjndaxAIf/tVzS8tjZpPcduUL BzB2r6z3y20otQV9CX0qqawNwAwGU1tNRZndBfgtyRf2/l8ymn3iv6IZSYFDkSXZ8nmU Z15w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=mN74+OMD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id f16-20020a63e310000000b005740e906e46si14392668pgh.358.2023.09.28.05.34.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 05:34:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=mN74+OMD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 2C4B780576DC; Wed, 27 Sep 2023 10:57:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229670AbjI0R5g (ORCPT + 20 others); Wed, 27 Sep 2023 13:57:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229623AbjI0R5f (ORCPT ); Wed, 27 Sep 2023 13:57:35 -0400 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-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> 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 27 Sep 2023 10:57:44 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778268117736589147 X-GMAIL-MSGID: 1778284730046279239 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: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: 145662 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3003615vqu; Wed, 27 Sep 2023 18:17:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHSoxkaYPDfcY8xWqmAuikrtB/qrpw+yWgoXcGiX30k2InlgnFi20gBxZ+nCyVqDYfL8fCC X-Received: by 2002:a05:6a20:8e22:b0:15e:bb88:b76e with SMTP id y34-20020a056a208e2200b0015ebb88b76emr3546172pzj.14.1695863827877; Wed, 27 Sep 2023 18:17:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695863827; cv=none; d=google.com; s=arc-20160816; b=N/u6BQeY8wL5V4zBkeEC6F3MzKdEYBRXKeubjyn5kOHBfvZeu+ua3EaP+HeizUFFcb Mb6gZMZceIamBYWf/0DPQo7c6LOKJi4yt5K5PM2eBa1Cp7RHZH5WYpDpWQQbt+d5nTyv +l4GU+REQt0YYy2ZDABciKRWId773LC5CJUZ8NxXq13aeZLBFGU5Yhht5rUUbv7A/cdN mOW9xmgP4mpxtuIxpM+Ei8k1fqx/3NBe/eVdj9w/DZHFZ+VNr/IHQLIiXnSEUAMCzb/L hCM0ahOqTTK8QG9CrXMfNvbxUP/wFODkDSVmMrpfSsYrsIKvb6t8wKaTNQkeemevuKgF O5qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+aeRRLyveSp222PznPdG+n1sUIcY6jPHssGE/fPbHxM=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=uW1Gvq+lgbnxGVeKrgNP1Z77O3hFNCFQtgNByD/jf5ufvtewACqWXblxAbtZLh6lQI 7CM+WXFRd71eSwI2PVEsWCDnm/veS87bUB+NyiBnPIAAIwluySutbrIr/SNRAUVoqdpc rNAnamUFjwZYqi5DHKSSsKStgq0wGwA1NQ6w7V8m3TTzSNQcBniYGpr6B8LYGDRQ0jig 7QB2InIeBaNYZlmXGyXlzORFn0/ZgmfeB8xez0tHw2VHbsAPvZcluJcJy6G2Kpzo9OwU nZ6Wknh2lJP/cvGFYWj66vVtfjU9B6nGx/VN3/KR16n86s/l+oqN6QkBxGQRga3ec73A 6NoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=j7XdiMFn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id oj15-20020a17090b4d8f00b00252d84b7af0si19527043pjb.181.2023.09.27.18.17.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 18:17:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=j7XdiMFn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 0842A801C199; Wed, 27 Sep 2023 10:58:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229623AbjI0R5j (ORCPT + 20 others); Wed, 27 Sep 2023 13:57:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229662AbjI0R5f (ORCPT ); Wed, 27 Sep 2023 13:57:35 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72E3FF5; Wed, 27 Sep 2023 10:57:33 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-99c1c66876aso1501324066b.2; Wed, 27 Sep 2023 10:57:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695837452; x=1696442252; 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=+aeRRLyveSp222PznPdG+n1sUIcY6jPHssGE/fPbHxM=; b=j7XdiMFnQbHdP9NVQr8xjpKcXk2Rj7rx3mPmLkg7Gsz3HPSrQv6nLqF0wBnQCXACO8 WZvFKb6ru3TJgzHrExPfbuJ1zB/lgxVP0ZcRJ8KsafqjS+RD3u3U24xjTqUnaKaBEtwS ToETtqt270rPSTnXT0qeQlPubiVvLh7+dd7mWQhZZnVvUTV7EjYrCxOIHhJM1o5ziZXZ 2BsOBDXlZQzBnAg984wjzxzxVYEN5lW7nUD1h+BP53iXjROJuFvSKTKUaUWghB1oRMzf gcPG6MFu8fOV4/vbBLsjfQk36beJN3uMu/+dbQxKK01rUlHwDpmJ1OOgbLgLYhZLJTTy pzPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695837452; x=1696442252; 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=+aeRRLyveSp222PznPdG+n1sUIcY6jPHssGE/fPbHxM=; b=ctL/bmeDu+BjsvXY3fNDlXwWN0kFvLchSbgovF4+LaUJlXd5WUKtfCKF8u2C8vKx6S CdrRuVGNSmAr/TdBbxUtBRUkujyozf01haOco42vRw/VhVlWbVS+ww8H0h8Xt7nmeXCV /w/89SIzCjlE1P+LdSlM8N01j7EZmtA3c8vYSXiU97rD5IyHiN1hDu/C9KrsdjHH//vi PN24/+c6zK9z2P4Z+/I0auY+HGA+KnU9xACjhJUkiOX5PcGPeZnZQU7L/B3EORWVpA1o Re8My7HriZpbGJ7sEZKVkr3ECZYOliq7Py83nRBd46gZrRWTZ6vgfMotdRqOfd+ZIGwC 4XrQ== X-Gm-Message-State: AOJu0YzZ1TAPoUfKj6mXO5E8/YQC5mFCKe3Fq+9aP61hG2HmdRxKEXMj rgmiLihR00UJj1fH0/ceCEs= X-Received: by 2002:a17:907:9487:b0:9a5:c49e:7145 with SMTP id dm7-20020a170907948700b009a5c49e7145mr3180086ejc.69.1695837451882; Wed, 27 Sep 2023 10:57:31 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id d4-20020a170906370400b0099bd8c1f67esm9654593ejc.109.2023.09.27.10.57.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 10:57: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, 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 02/14] USB: typec: tsp6598x: Add cmd timeout and response delay Date: Wed, 27 Sep 2023 13:53:36 -0400 Message-Id: <20230927175348.18041-3-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> MIME-Version: 1.0 X-Spam-Status: No, score=0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 27 Sep 2023 10:58:10 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778242108940826465 X-GMAIL-MSGID: 1778242108940826465 From: Abdel Alkuor 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 Reviewed-by: Heikki Krogerus --- Changes in v7: - Add driver name to commit subject Changes in v6: - Use tps6598x_exec_cmd as a wrapper Changes in v5: - Incorporating tps25750 into tps6598x driver drivers/usb/typec/tipd/core.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 37b56ce75f39..32420c61660d 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -282,9 +282,10 @@ static void tps6598x_disconnect(struct tps6598x *tps, u32 status) power_supply_changed(tps->psy); } -static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd, +static int tps6598x_exec_cmd_tmo(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); @@ -345,6 +348,14 @@ static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd, return 0; } +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) +{ + return tps6598x_exec_cmd_tmo(tps, cmd, in_len, in_data, + out_len, out_data, 1000, 0); +} + static int tps6598x_dr_set(struct typec_port *port, enum typec_data_role role) { const char *cmd = (role == TYPEC_DEVICE) ? "SWUF" : "SWDF"; 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: 145727 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3053560vqu; Wed, 27 Sep 2023 20:50:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGzMhYJwncGhJmUIZBDNhog1LK+eHnTQ0xhnIz8UulDQ8wsiHeLhPHXdHPE8GaTZSAhCuF3 X-Received: by 2002:a17:90a:55c7:b0:274:4f21:deae with SMTP id o7-20020a17090a55c700b002744f21deaemr46179pjm.35.1695873013773; Wed, 27 Sep 2023 20:50:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695873013; cv=none; d=google.com; s=arc-20160816; b=GH6qG1sLFYBxkdj1ysBdJgOVkA6iokkIQGHhfRD86UHJ63yxUajm1CzuE1F9FQeQIo TIfZ8kH6HoFA5Fx0Mrka0y/+bX4F1J6oq+poW9s7VDzMZx1vxGtBG2aEbH6nxA8rVf85 mnxd9Ka0Fy4yvUeY6YexG3EpyGn7+k+is6hgLiLwHI8i5y81jrJBXS/bA38phbM1savW b3Eo3TTkms6lcIuJBdxBUUqCaaPXphXt1uQfRnDhJ58NdiNx+c4p86JT7N0xD0ndDKUX RxuS4QYIPi7bQdCvVZr1QVCcKlw6HhxTYx78K6cdHl4GnCZPxwgtewhzrrZljMCJnFtD +wVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZRvQEPSEiEBX2XgILYaykwXlkKwlukHcD1HvhPUf8VQ=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=TtX+9BTWQ8NJke3BZSCIt/B3HerSTc6zivd3U8olkeZ4J5XJFKImOOWWWlA8EnCB6u 40erd+ogQoUffkYWLs9PQx9spEZORJ2OyebxRZCFmjaZ1nFBbJkVTgVx84BdUaubclqk +2i0PO8VjvNgO1+xAOfvhorTUwX1a1Hf81uwk4bQeDLgtTLpf/BwqBNYUm7tc3WEom0+ 09TaZ4m2pWAn4VvjTF+Ttg8sJyyWSHVzNSimHu7SRw8EpqZ5rj0DWHaD7vPEAgddHaIy o1+TcepMiSDfnhAbsORhsleMB4wowrYjdZA4LT5UuqeA8i0b0PDowJtnAzbfgPOexd+X cdcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="Kv6E/GLJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id p1-20020a17090adf8100b0027540ebd2absi19241263pjv.187.2023.09.27.20.50.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 20:50:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="Kv6E/GLJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 560928060471; Wed, 27 Sep 2023 10:58:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229692AbjI0R5n (ORCPT + 20 others); Wed, 27 Sep 2023 13:57:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229668AbjI0R5i (ORCPT ); Wed, 27 Sep 2023 13:57:38 -0400 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-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> MIME-Version: 1.0 X-Spam-Status: No, score=0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 27 Sep 2023 10:58:05 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778251741094135421 X-GMAIL-MSGID: 1778251741094135421 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: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: 145564 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2861353vqu; Wed, 27 Sep 2023 12:43:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG+acZ4r/LEs1u62QjSqKrOFjOqH9eKYVD77q1/G2zb+YvV+EANOl81m2uyAcpllfMclVA1 X-Received: by 2002:a05:6a20:8e0b:b0:157:e4c6:766a with SMTP id y11-20020a056a208e0b00b00157e4c6766amr3489759pzj.41.1695843826020; Wed, 27 Sep 2023 12:43:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695843826; cv=none; d=google.com; s=arc-20160816; b=TwXpH87Fliy0cRVyVu9MP1/b1u5/mybgpVvRSmLSSHIJJHLOinUNBVhFDPOPU7yGdi D0iInuxaw72IMm+fD7fOhDmNYlExSPe6EIiyaVuqNqvmTDdeHJEuW7hhTJjYfNiAs9Mg byeQXeZ8K9zH2CZp482sh2nVObGy1x4W0vK9Kkqfh1Vm6uawBMGW0+9lABaYzS6v3cvY 3hDajpuF7khY6wQ2CD8WdbS4apon8juBN4SSHrAfybBP/RfWS8rpYrLY3lXXh+2WiShA w0I7lNsNlpHU747iTk3QXD2GrMw6vKNXARd8Xa+Vo+qSjZlUJOZrOr2MY8OP1UyQVkh7 tDnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zJcYqNpImLuQRg8Dy6zmjayVHVCVmOST2NVEJA6ZGhI=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=n25B1RYfCgserl5869cjIFrRFfPDHUQbOQv6Db9u0AmyL0lfD6XipOv8dpjK4OhzLZ ntXACHmX1dALp2JGqhjRCSGaAnO5ayTW9+EjASfO2946cOXJLqbLiDvRD9DEAmulB2xu 31D6YeFxiEf5aPIUgSAURoCZEKCfO6rh9O6goSAPWrqAnyFgzZWHIdip0L3wqBD+uG36 xnlkg3d48D81ncsdnze0Re/p9s3wsRQq1RVh9JaI36dEjGQSYqwkhkIWPV7RuKVA+K/Q YfJti9EBU9HPXxmXbhoOJ2lFQNUxNtiWBWRQDh4UR5SSCF3pGCFY2w5x/ODByk6qEtvl l64A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Di1ciBy+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id t5-20020a170902e1c500b001c60de17b50si9537443pla.182.2023.09.27.12.43.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 12:43:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Di1ciBy+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 0AEEC80B6334; Wed, 27 Sep 2023 10:57:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229672AbjI0R5r (ORCPT + 20 others); Wed, 27 Sep 2023 13:57:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229671AbjI0R5k (ORCPT ); Wed, 27 Sep 2023 13:57:40 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9472FFB; Wed, 27 Sep 2023 10:57:37 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-5230a22cfd1so14061987a12.1; Wed, 27 Sep 2023 10:57:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695837456; x=1696442256; 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=zJcYqNpImLuQRg8Dy6zmjayVHVCVmOST2NVEJA6ZGhI=; b=Di1ciBy+Ux/1tMzAYo9Hmh1Rb6pkL32toO/czYcukbOv6PCWYPFCvXytxviOLNb2Oo k1HLv43UOmRr398JpGoncrSRgBB1PvVyXC1vVlLinSSYJcYfUo2Q7BezY371q2lMnl+3 EUy2ce/SmEGB5aYJm1skI6GAPQHpd7cl31SjsKmLvFZdRQmUxxnDlkuXZXiDBPhUBrZp mk0fXdkroCpRWXKhcuRB9/pTHLJjFgi87KCNWTFanCJJm8G0ENNbsoeSBlPlhMrLoAid vOxBIT+6UI0oqpvu9fHxSj8WuusHNblEijHo5ecAffJd17+ucPGuOe7FEBSqCYFXkwBp xQRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695837456; x=1696442256; 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=zJcYqNpImLuQRg8Dy6zmjayVHVCVmOST2NVEJA6ZGhI=; b=RGibUmhIEuRyxnI6XPl9vp4vhEfEKIQYfXWzFb2ZkwQZ8/WLRdMLx+zY4ndMfEXGYH x2+aurrF27h7w5mP/XYviPxPU37Ez70PVqiEz/DdSHtID8x0mJ8p9jrpG3X/NjhPsrnu HeePj0+ikMaKXPMXBPUk+hU0JeKIchEuYYkAdS3hPt7+/UB22cIGXsIEX0cledLqI90K 476p1JlgUOph+ynNcq5bjVwj4eZ07Klqxs8cPz3ZBbWUa1UdHCTMCnI7I7owOiw6GX+s yEbi4dIJ++waNt0z3P7tSTvW7xy5ImRYZGLA+Y6YY9PqzJ0XVcCzAGakxP0LkD75dq+X 96lw== X-Gm-Message-State: AOJu0YzblUUkhxah48UFPKdxbgAGxASAMYC+5oQgbQuTP5epfgmTcwEF QZ0M26bh7qq+/E5lx1cJKdI= X-Received: by 2002:a17:906:3143:b0:9ae:7088:6e5d with SMTP id e3-20020a170906314300b009ae70886e5dmr2573182eje.3.1695837455980; Wed, 27 Sep 2023 10:57:35 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id d4-20020a170906370400b0099bd8c1f67esm9654593ejc.109.2023.09.27.10.57.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 10:57:35 -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 04/14] USB: typec: tps6598x: Load TPS25750 patch bundle Date: Wed, 27 Sep 2023 13:53:38 -0400 Message-Id: <20230927175348.18041-5-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> 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 27 Sep 2023 10:57:58 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778221135786268526 X-GMAIL-MSGID: 1778221135786268526 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 --- Changes in v7: - Add driver name to commit subject Changes in v6: - Don't check VID for tps25750 as the VID register doesn't exist - Remove is_tps25750 flag from tps6598x struct - Get patch address from reg property Changes in v5: - Incorporating tps25750 into tps6598x driver drivers/usb/typec/tipd/core.c | 254 +++++++++++++++++++++++++++++++++- 1 file changed, 250 insertions(+), 4 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 58679b1c0cfe..f96a9ff07fba 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, @@ -713,6 +731,213 @@ 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_tmo(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; + + ret = tps6598x_exec_cmd(tps, "PBMe", 0, NULL, 0, NULL); + if (ret) + return ret; + + ret = tps6598x_check_mode(tps); + if (ret != 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; + u32 addr; + struct device_node *np = tps->dev->of_node; + + 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 = of_property_match_string(np, "reg-names", "patch-address"); + if (ret < 0) { + dev_err(tps->dev, "failed to get patch-address %d\n", ret); + return ret; + } + + ret = of_property_read_u32_index(np, "reg", ret, &addr); + if (ret) + return ret; + + if (addr == 0 || (addr >= 0x20 && addr <= 0x23)) { + dev_err(tps->dev, "wrong patch address %u\n", addr); + return -EINVAL; + } + + bpms_data.addr = (u8)addr; + 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 %zu 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_tmo(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; + + 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); + if (ret < 0) + return ret; + + if (time_is_before_jiffies(timeout)) + return -ETIMEDOUT; + + } while (ret != 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; @@ -725,6 +950,7 @@ static int tps6598x_probe(struct i2c_client *client) u32 vid; int ret; u64 mask1; + bool is_tps25750; tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); if (!tps) @@ -737,9 +963,12 @@ 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; + is_tps25750 = of_device_is_compatible(np, "ti,tps25750"); + if (!is_tps25750) { + 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 @@ -773,9 +1002,15 @@ static int tps6598x_probe(struct i2c_client *client) if (ret < 0) return ret; + if (is_tps25750 && ret == 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) @@ -895,19 +1130,29 @@ 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 (is_tps25750) + tps6598x_exec_cmd_tmo(tps, "GAID", 0, NULL, 0, NULL, 2000, 0); return ret; } static void tps6598x_remove(struct i2c_client *client) { struct tps6598x *tps = i2c_get_clientdata(client); + struct device_node *np = client->dev.of_node; 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 (of_device_is_compatible(np, "ti,tps25750")) + tps6598x_exec_cmd_tmo(tps, "GAID", 0, NULL, 0, NULL, 2000, 0); } static int __maybe_unused tps6598x_suspend(struct device *dev) @@ -950,6 +1195,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 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: 145714 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3039100vqu; Wed, 27 Sep 2023 20:05:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFSaOJkIYJoZVFZymVhVCBRWpPEDghEdORW7jjGV2hf2KBUnZUI8lpuYwqeCrtmXR94CUJu X-Received: by 2002:a05:6a20:158b:b0:15c:b7ba:1671 with SMTP id h11-20020a056a20158b00b0015cb7ba1671mr13102pzj.2.1695870330073; Wed, 27 Sep 2023 20:05:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695870330; cv=none; d=google.com; s=arc-20160816; b=X5eTjesFQhiMptA6hzQa7x/t9MKCukOPRfqusMmlNwgZMpvicgaR4iXPEZCTkhk6hL FS1GBm2cQ+T63s/GHHi+vDBQd8SXcqFcox+WrnA3ukwQXuPCXK2Qn0aiDNBQY0DMaE+3 bgyv5nvVEIsdvxVPJm0/cI8QIXPKcxbLRiaKrGp7uioLxwU6uQGDCkQBZqmOhekSXVmT DwzLe9Z8xf3RjjMabhMf2Mu07zKNLJQkRI8rcxp0wdTqoevX1FPtFq207hSIDeYyaKCv fkvfklwyM/+omCugzRHomOB4D9K7l4x6ikroEV+iq139nnk5/ryx5DC4XrJBTPvScPJs j6AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=08TTJK6jIdlF3YGQZqg/ueMGQffH5CXs2rT/Yy540NE=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=j9Afgc3LIANajXuPPlW4DMz5+Ys3G5cPSu8GBZODO7l8R9k97pYAGNk0ICP3k/z8rn oC7jg8kx04yXmkE6DLoib9cCfmSzcIHPqtueczPMFv0ih/ZjB52b2LDTpqjjz4R1Zr7f yhB/b8bCTVs/IkKVGNlRpxj3RVfDohuUotepzMGfTuPyruKT2gjvk1icwPPxJNzD9qLs 7XeF2NzYSA/szsc/mo22us1ukg/KIg5ZtKcC7U1IO4W8dol9gThnB3wLZ2g9m+xOoZAs znTJWbhSEZzqu+RLZHwrKqURiCUetQZeECr1nNOFEttVOu/mIO+O9qRt5Vc3yE0r5+jV bGBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Fo4aXa5b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id b130-20020a633488000000b0056952b496efsi17417936pga.366.2023.09.27.20.05.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 20:05:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Fo4aXa5b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 47A8A80253BC; Wed, 27 Sep 2023 10:59:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229711AbjI0R5y (ORCPT + 20 others); Wed, 27 Sep 2023 13:57:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229665AbjI0R5p (ORCPT ); Wed, 27 Sep 2023 13:57:45 -0400 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-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> MIME-Version: 1.0 X-Spam-Status: No, score=0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 27 Sep 2023 10:59:41 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778248927504919935 X-GMAIL-MSGID: 1778248927504919935 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:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 145574 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2878260vqu; Wed, 27 Sep 2023 13:16:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFOJl90BC3ZF0PUWgyAA3ueRqtmaJ5wC8cWJDOxDkexxZVIxaCSsPAs9krlORkGQaf+1Kyj X-Received: by 2002:a0d:df45:0:b0:59b:ee58:67fb with SMTP id i66-20020a0ddf45000000b0059bee5867fbmr3180780ywe.10.1695845801124; Wed, 27 Sep 2023 13:16:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695845801; cv=none; d=google.com; s=arc-20160816; b=yEMI/vqnWjmXQRZk9ak7AeT4N9tnGSOdjV3EXNwLIiJruLCEm9z7bUlx7QGIQtcF9g R//7WiG5lj/czK4snTTKXPkTxldEl8S9PUJXmezSZCVCCuuZx5wIp3nNp+BZ3ax53cEB O49eY2b/OgKJHMw8E7341+VyeqtwKPhKYN15tOTiwG4iWlI06pcx35lqC8HxTqmxOVVD iMVfmRFWT+JHSFCbltjn69OJbX7HxQGIaqT30pZb7SHBnOTJBLs4tJKaUZ21KTvtLS01 5XF9ucv7+iiPeVw4XxXwJBWzNPmOBVaOuxp3gp79TXQHoXW/OvgoFZvvX84utkLyTg3Z eFEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Kt4gFv3KJ+4bysg0kbGW0jRlrPYOAsIxZD0k9Gm3Zgc=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=Ljewcw01qB0dWujuIivmoDP/7PLJ2Kc0FdQ4M7Vn+2mQILleJutiiA3CssJW7oBLH3 bSQATGQ1SF2FPjJB/4KxzciZf3y+SXUUdJxDOedJ3AoKfiP/YkpsjLbgGK1QLhjvxeRq dIchyzGxA1rTXJQ5fK/ptbec1hvK8YDn7k9Dv7UUrgULHXQua6il62zAkpSAmMkaUSFo zNe8v/IdUpDKYKwJViqUiP48bGTPz7BWxcuCFSyt7Va1Ajbd1Gq8+KiZjY1CPuFfFgmC i26GmeD5IWSR1yq7AUZ2UPYIvcz9lGdLHsvZGiEtvKcHhlSlaCdvA39iIk/NhZPYmPr9 +17g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=L47+YMJg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id s1-20020a63dc01000000b0056fed6fa634si16337511pgg.433.2023.09.27.13.16.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 13:16:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=L47+YMJg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 1741E826E5A6; Wed, 27 Sep 2023 10:58:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229671AbjI0R54 (ORCPT + 20 others); Wed, 27 Sep 2023 13:57:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229686AbjI0R5p (ORCPT ); Wed, 27 Sep 2023 13:57:45 -0400 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 F3B441B3; Wed, 27 Sep 2023 10:57:41 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-99c136ee106so1469866866b.1; Wed, 27 Sep 2023 10:57:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695837460; x=1696442260; 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=Kt4gFv3KJ+4bysg0kbGW0jRlrPYOAsIxZD0k9Gm3Zgc=; b=L47+YMJgKNE7vZMeQNISLszmVacKHxgmMnHbxRig+cpmo6ZOyf4IOBXvWXHnd3vXTp xATiPzo3OG0e7ivLxrNoX43dQerUmtsmzv55OD42kmjpuqlnTTpEwrWv4QFvQ8lMOooU SBd9sCwh4ywlubrnpWv0TCSdfCznenhQIuoYh7rr+eJ8nBQ2VOqIsuduCm3iKRN+VT2V e1cH77QjV30SSOyNeYK9VJypU3SyKcmatLIFNhNHSvpoNHLA3+OfhNo3MpnrjqEKkLIW 6bZU+Bnd32kKpRGZIYa60UAdtY06kTkVZALLu5CI9xptUe31n6BWDUIsU4/Fgesp3/g0 6fcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695837460; x=1696442260; 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=Kt4gFv3KJ+4bysg0kbGW0jRlrPYOAsIxZD0k9Gm3Zgc=; b=h2DlczQ8bx68JYAXyZsfvlC9ttm47rDKqihUEq0Vux6vpNUvvWBDukHAhlCZKgV5N4 2TExnMGjFtbCZduwRVnr5+RX4V9jdR2JJKrsUy5tOw0h9fyzVGEOikitcyZNDO3A5LqC L78nFXuo1/kNK0Vt6C26HUek1BKTizIOVQPzdr+hR40rFFBbWCyA2UrmXio+/FQiVi7R qTy1qEwdMaBgFHV22X31vV8cFu5/MC1FnxUgOotV59Lo4A8G63HzY83XPXwa+JUbVrQP /tGGpD1fH4RnXrW7/n6bPvFhVCFE8/J6QS26Y6Dm+zYCyWBU1VGS4yT3+C80AVRf0/p0 dHhQ== X-Gm-Message-State: AOJu0Yw5+8YRK/EhPuCIZvvwTw/AMFoLqJQ2MeVp8z14525k73XokABI J1tG015VCPELdrLGXZu6Hpo= X-Received: by 2002:a17:906:3187:b0:9a5:d657:47e1 with SMTP id 7-20020a170906318700b009a5d65747e1mr2600762ejy.43.1695837459952; Wed, 27 Sep 2023 10:57:39 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id d4-20020a170906370400b0099bd8c1f67esm9654593ejc.109.2023.09.27.10.57.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 10:57: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, 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 06/14] USB: typec: tps6598x: Clear dead battery flag Date: Wed, 27 Sep 2023 13:53:40 -0400 Message-Id: <20230927175348.18041-7-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> MIME-Version: 1.0 X-Spam-Status: No, score=0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 27 Sep 2023 10:58:13 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778223206710013445 X-GMAIL-MSGID: 1778223206710013445 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 --- 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 | 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 cd22635460d3..faeee2ffc99c 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -946,6 +946,22 @@ static int tps25750_apply_patch(struct tps6598x *tps) } while (ret != 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); + 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 a80d0929f3ee..c000170f4547 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 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: 145579 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2881758vqu; Wed, 27 Sep 2023 13:24:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGUBWgLDQZm4KsB7hepBC/uWsrEw/P9GHnmD5rDMYo6ffBnQ/06JY6wdd2eKVWXLhg4JEmM X-Received: by 2002:a17:902:c412:b0:1c3:b0c7:38bf with SMTP id k18-20020a170902c41200b001c3b0c738bfmr12322842plk.12.1695846258050; Wed, 27 Sep 2023 13:24:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695846258; cv=none; d=google.com; s=arc-20160816; b=uIu35ImsQj+HgSP982jAbMhOTf/piuMA6+Q5CZoaME8T75CBZ86cXhFqLz+3S2vjEH lzQwkULEzEL1xm7MKB9FuoE0bXpujRhY0ndMwCY7iZJZ5Ja0LmZ9lqcqtpIwhU9B3krg AIB3hSog8J13+byoxZQFxV13bkJkYoh/fW3NGfh2bMoWHU5hd91Rc/4OjjQJbjWWwTpA nvDQiMWo/fPe5637BFKNdvlogPdCArsADGvNYIlFrptKdOs3sg0GzjHSYZEhcmejR9t/ T/HUY3+vnBk7Pv3ncf1gOnK0OcdLGnVnjEFAG49LXoc6Hc5u9Hn531hC7QQsdldWSfew 2CoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JIF24z+W4xSOOiQxGgE0N6mbcOqb2K0f4VACmgBIH2A=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=uMiLlGB/vdPx1rdxLXgrUFKikIkzi9ijUntmc7/JLhMZFoqwCpNDf9reM+0irBhphv 1gXNULUGIEBS8NwkdOgGE/XmgVOY2N1qbBr+Vetyd5gt2fUpVe+UzXDvIuE1VGoU+7ft yNXXDUWEg2nsT4eUY0UA4VrVND0dU6VNEJoC5imZ6idwTu2zLKlbkpOA+4P7ujeK1mRE v6FD23/yIcvqLh+6DEfks4CFnJnkc6GLKbTQP0+mmqeXqpDnZKJP1eDjrW/MCvR6nsCm M5xowNdxop54UFZbdsJmAwRaj54pk9ChtEttVJX89+viWGKTQ/GjGTrRDiKgvvSltCpI ZBYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MY+7TXiG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id x12-20020a170902ec8c00b001c43ff69d93si17944406plg.324.2023.09.27.13.24.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 13:24:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MY+7TXiG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 9F709801BC95; Wed, 27 Sep 2023 10:58:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229499AbjI0R6A (ORCPT + 20 others); Wed, 27 Sep 2023 13:58:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229731AbjI0R5r (ORCPT ); Wed, 27 Sep 2023 13:57:47 -0400 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-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> MIME-Version: 1.0 X-Spam-Status: No, score=0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 27 Sep 2023 10:58:54 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778223685931324640 X-GMAIL-MSGID: 1778223685931324640 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:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 145641 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2974555vqu; Wed, 27 Sep 2023 17:02:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHayme6b6n+T1E4TNSwvIgthxS3zLA7sSKRkfJwipNTOfr4VAUQOoP7zC7eTQZ0h1XzzomJ X-Received: by 2002:a0d:ca08:0:b0:59b:fb60:fbb9 with SMTP id m8-20020a0dca08000000b0059bfb60fbb9mr4315532ywd.9.1695859326426; Wed, 27 Sep 2023 17:02:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695859326; cv=none; d=google.com; s=arc-20160816; b=CX3reCLO0n67NOhPLlUFBru7QV6QzcGffBQGcQaOxhLsLmj0s/Izc8dK4De5OhdWFR Af/rF6XIaSLcTvZRGJR/lh6xrSZbNUhcjZIxQLTy9wsG085AhShqb6BBSHyUzTI9vMWg RqCOfcBLrwn+hUu706sYdhGGxBmve4tmxAAtjz8I2cXlabQ8Ko0j+ImrQ+4FSz2t2lhN uYnx3OAmBrggAmpwB8Flvb7lhlaj/SmZNMjAF0/fBznezVpnBeuCLHritZJQ5tbpqyVk 4YYv3KHl+AhjMivCaob01T0Vx213Dr8uKydN9hanuwreG36hkFa0T/SGUzPb0IjrYGoP LdOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Bg1oWc/TwN4fGrhVhvQgxMm7Z4lMcGdoKvRf8Q8jP8s=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=O2fGVa9ecXptJW7V3azqVmePi5kqd1Wiezm0EUkJGs0dJ5+KLj2KtXR9HsNMNllwoB wx86OvkS2Rpl6XGC173/FvDtV/M5pcFU+YpaH0MpMzVNzbVR4ZtIB5n2BNsN+Cw6Ln1U TvRefOiaA5tpSqD/bd8QxDnD1TmlY1GjKb87QcsGGjAjXE/sYeFzFdS+EsoCstAmYGSe 5bdmvFISWtkLLmRB7p78JF1X5C/sT+l9gmx/Tqwk9FzPhgPSrZp2cBmXvKnhdZBK+044 MuLoL5mRVYrZ/Gt9YMqWzo91DGhQ6rG1gmxku1PdKJtHutR9BAVqtmudxjitnogqSP7s xL3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=IB8iXeGs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id a35-20020a631a63000000b00578ea9a0b93si17210817pgm.890.2023.09.27.17.02.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 17:02:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=IB8iXeGs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 10528826ED2C; Wed, 27 Sep 2023 10:58:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229854AbjI0R6J (ORCPT + 20 others); Wed, 27 Sep 2023 13:58:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229764AbjI0R5x (ORCPT ); Wed, 27 Sep 2023 13:57:53 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D809CD5; Wed, 27 Sep 2023 10:57:45 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-9ae75ece209so1319880166b.3; Wed, 27 Sep 2023 10:57:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695837464; x=1696442264; 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=Bg1oWc/TwN4fGrhVhvQgxMm7Z4lMcGdoKvRf8Q8jP8s=; b=IB8iXeGskq6V5MuWdPg/CZDjicdMtvi/hYZq5aZ5Ff4GtIWDIPmUP1KsCs6PVSsR/q 6bV8OljBjLmQnPwARVrnMhyMWU3rCONzmsn0AfUxO3go7RuxHjyTmixqDSfAaYPRExnW /KANMLtS4iJGMetpwTpTXZMYLgDJCcuesOGZutdZ358QTOWq+OejdTijCA8cbfaWGvKD UI/c5f3XxDVP6UJqWTNNxO1xxgwueHEUPkFh43WrqAwrmtExWezvPSGfHJMg62+DjP+S RCAHPkAwDKuZAJQ0xSa73/5K9TYRpZ0oV8sWUBB8gG5ELMGZbNyoxA01HDESQs8NWhjt AZ5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695837464; x=1696442264; 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=Bg1oWc/TwN4fGrhVhvQgxMm7Z4lMcGdoKvRf8Q8jP8s=; b=eg2lEPlWYB5urRGHvDciutw6NNzztNl43cKDobQZxvIXnMRBjo+e6X1U93oGQkKx+B pEI4/K44wgMtV12RHlSAsmFyl0C+S2PGJKg5Z73OsJkNOghp18Ir3hY+LQe8w8yWSr99 OdsFDTSHGEo+RA01GN+q3rcA/amb34FtAMwQFG0NE3DpqAsTQLnxDxOsfI65DCFy8GpS JS03xQ+rW3ULclpF2CDIOpZEdzPsCJ7rcjpBa5pc22VzbjOFblxmh+wJwIwmuMiNNUVj wthZJ5HgigIoLAvH5qQ+0KM4o1Yzo8mvp/YMt87r2Y1mZIXj9Pa8pTQRu8ejnFsBMSzQ o57g== X-Gm-Message-State: AOJu0YzOvqr9dJ47sotbToPP2i8B7xwHUQR5dImhQsmNv3s0knIrztrW l0pk3Wm9k9Azk59h4VMrYDc= X-Received: by 2002:a17:906:3299:b0:9a1:c44d:7056 with SMTP id 25-20020a170906329900b009a1c44d7056mr2573758ejw.26.1695837463842; Wed, 27 Sep 2023 10:57:43 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id d4-20020a170906370400b0099bd8c1f67esm9654593ejc.109.2023.09.27.10.57.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 10:57:43 -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 08/14] USB: typec: tps6598x: Add interrupt support for TPS25750 Date: Wed, 27 Sep 2023 13:53:42 -0400 Message-Id: <20230927175348.18041-9-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> MIME-Version: 1.0 X-Spam-Status: No, score=0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 27 Sep 2023 10:58:47 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778237389090653384 X-GMAIL-MSGID: 1778237389090653384 From: Abdel Alkuor tps25750 event registers structure is different than tps6598x's, tps25750 has 11 bytes of events which are read at once where tps6598x has two event registers of 8 bytes each which are read separately. Likewise MASK event registers. Also, not all events are supported in both devices. Create a new handler to accommodate tps25750 interrupt Signed-off-by: Abdel Alkuor --- Changes in v7: - Add driver name to commit subject - Create tps25750 interrupt handler Changes in v6: - Create tipd callbacks factory Changes in v5: - Incorporating tps25750 into tps6598x driver drivers/usb/typec/tipd/core.c | 90 ++++++++++++++++++++++++++++++++--- 1 file changed, 84 insertions(+), 6 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 56ffffe225f2..40a76826a44e 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -101,6 +101,10 @@ static const char *const modes[] = { /* Unrecognized commands will be replaced with "!CMD" */ #define INVALID_CMD(_cmd_) (_cmd_ == 0x444d4321) +struct tipd_data { + irq_handler_t irq_handler; +}; + struct tps6598x { struct device *dev; struct regmap *regmap; @@ -118,9 +122,11 @@ 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; + + struct tipd_data cb; }; static enum power_supply_property tps6598x_psy_props[] = { @@ -545,6 +551,64 @@ 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 tps25750_interrupt(int irq, void *data) +{ + struct tps6598x *tps = data; + u64 event[2] = { }; + u32 status; + int ret; + + mutex_lock(&tps->lock); + + ret = tps6598x_block_read(tps, TPS_REG_INT_EVENT1, event, 11); + if (ret) { + dev_err(tps->dev, "%s: failed to read events\n", __func__); + goto err_unlock; + } + + if (!(event[0] | event[1])) + goto err_unlock; + + if (!tps6598x_read_status(tps, &status)) + goto err_clear_ints; + + if ((event[0] | event[1]) & TPS_REG_INT_POWER_STATUS_UPDATE) + if (!tps6598x_read_power_status(tps)) + goto err_clear_ints; + + if ((event[0] | event[1]) & TPS_REG_INT_DATA_STATUS_UPDATE) + if (!tps6598x_read_data_status(tps)) + goto err_clear_ints; + + /* + * 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_block_write(tps, TPS_REG_INT_CLEAR1, event, 11); + +err_unlock: + mutex_unlock(&tps->lock); + + if (event[0] | event[1]) + return IRQ_HANDLED; + return IRQ_NONE; +} + static irqreturn_t tps6598x_interrupt(int irq, void *data) { struct tps6598x *tps = data; @@ -600,7 +664,7 @@ static void tps6598x_poll_work(struct work_struct *work) struct tps6598x *tps = container_of(to_delayed_work(work), struct tps6598x, wq_poll); - tps->irq_handler(0, tps); + tps->cb.irq_handler(0, tps); queue_delayed_work(system_power_efficient_wq, &tps->wq_poll, msecs_to_jiffies(POLL_INTERVAL)); } @@ -967,9 +1031,20 @@ static int tps25750_apply_patch(struct tps6598x *tps) return 0; }; +static const struct tipd_data cd321x_data = { + .irq_handler = cd321x_interrupt, +}; + +static const struct tipd_data tps6598x_data = { + .irq_handler = tps6598x_interrupt, +}; + +static const struct tipd_data tps25750_data = { + .irq_handler = tps25750_interrupt, +}; + 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; @@ -1017,15 +1092,18 @@ static int tps6598x_probe(struct i2c_client *client) APPLE_CD_REG_INT_DATA_STATUS_UPDATE | APPLE_CD_REG_INT_PLUG_EVENT; - irq_handler = cd321x_interrupt; + tps->cb = cd321x_data; } else { + if (is_tps25750) + tps->cb = tps25750_data; + else + tps->cb = tps6598x_data; /* Enable power status, data status and plug event interrupts */ mask1 = TPS_REG_INT_POWER_STATUS_UPDATE | TPS_REG_INT_DATA_STATUS_UPDATE | TPS_REG_INT_PLUG_EVENT; } - tps->irq_handler = irq_handler; /* Make sure the controller has application firmware running */ ret = tps6598x_check_mode(tps); if (ret < 0) @@ -1125,7 +1203,7 @@ static int tps6598x_probe(struct i2c_client *client) if (client->irq) { ret = devm_request_threaded_irq(&client->dev, client->irq, NULL, - irq_handler, + tps->cb.irq_handler, IRQF_SHARED | IRQF_ONESHOT, dev_name(&client->dev), tps); } else { 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: 145674 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3012046vqu; Wed, 27 Sep 2023 18:42:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF4Mxwc2E2+6HdCcxhw1P6Q+VPMV6Bnr/slXi7JS6dSH5hw/CQdU2kOaHVBhadLUX0ch/4J X-Received: by 2002:a05:6358:618c:b0:143:49f5:145d with SMTP id w12-20020a056358618c00b0014349f5145dmr3318686rww.20.1695865323850; Wed, 27 Sep 2023 18:42:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695865323; cv=none; d=google.com; s=arc-20160816; b=RAKaoquhElr13StqJ9vqml23Wn6nsf3ePl+XumPAZII8zlUVrCCzQh4Xqs5ShmQQSv iboa20wkIudGPEo+fkSU4wEbjiUTAl3aAzSDVnBXFkKHjtNBSILoDVdcqIric/n9nfeX 1Ntf0KA2HIJ22qhDVLdP4Q60PZkAvMedNzj2P9h3vaKfTRQszZRPRvF97rUD6XmXCakm EjqTSYiZO7+sdMaKLqhgysbDGB5A4n1DYVXZP7FBhc1cwxOrID3OI/Yipjs120xallIT iKh1e6Ldx6KXhCSOzmvFK0ElL3txiBTcdLiOo9utZ7dz67q6qdtr8NHQP6aXx6cq8jHM eTjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aDe7CzXud22Tg0X5E9wYPOoM/0EBNI8QuGXK8h/hMrw=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=EGRKhOxch1yTexsLkctRGKomlHHKdD0LtFB0yOQMuI8eNphPfn8iYtrryo1yqIkqeI BmODO/OFNbtyRzR4LLvHuxmzYuFLw+P1QZV40Ed63YJt255pu8lOLTmwPakrfi3qbnmI y5anm44ZFgYsltpWkluByNpRvra7D9HCa9f4SMgykG3mX2Seg9XICxZ8nQDKVwjO1WC7 N1eAQ+ig/sl41YL5e3cdnZFB4Y7cSM7NUk3ooqKyekF8CLigz2ctBjuxg7JgJE4AhSPa tkWtbqZmDJZShJiWAgWXUgJiM+tsOxa/9rhj2FYNm8+b3oldptp/CKJ88lmZ3a5sum/L oJNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HeWBYA9R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id y6-20020a63e246000000b00570505c5267si17948194pgj.262.2023.09.27.18.42.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 18:42:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HeWBYA9R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id EC607829151C; Wed, 27 Sep 2023 10:58:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229741AbjI0R6P (ORCPT + 20 others); Wed, 27 Sep 2023 13:58:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229783AbjI0R5z (ORCPT ); Wed, 27 Sep 2023 13:57:55 -0400 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-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> MIME-Version: 1.0 X-Spam-Status: No, score=0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 27 Sep 2023 10:58:30 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778243677678481038 X-GMAIL-MSGID: 1778243677678481038 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:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 145582 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2882636vqu; Wed, 27 Sep 2023 13:26:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF4EfKUYdfieihtsB86uo6NcGlOYnnAtH1mhT0A9laodnFtAyZsApz/b2yu1GE4WuOlyKxE X-Received: by 2002:a05:6a00:10c6:b0:692:b429:390 with SMTP id d6-20020a056a0010c600b00692b4290390mr3224530pfu.29.1695846386443; Wed, 27 Sep 2023 13:26:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695846386; cv=none; d=google.com; s=arc-20160816; b=nhY7wFeOYcwzTmvpbC3SnFgaPw+QTpf5X0IpNfv3TsNyqw+wGp+8b7TCAIh4mr1Bdz QAu18z9JHtyYHwzOAaD799pqeZiIc4ybCxy3tU/FW+dd43Q60UFfUYEqjyS+awAYca1D QP0J1Cd5Ypy8Sts9zb82fbvMgsUGcDYHHsljeocBZALbH7ZxVnaY9ONCY7ucWZovtJjQ ddGS8jKaoNxQkIZHqrMD2zWQRUG6gvcXz2GWyJofgvL1HtC6UykL8QDRhW/K2CY4MR82 Wwz62iKhgE35rl83SpyW0MfcKVJTFvgyuYbf463eD7a5P+6GBvfm3QoM72XgeY8Germc PCXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=P3vTTatxpTmSJDREvGgzvcF6cpLVGqrOuRB25FxTUfI=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=WowUW9ZrYl+v99dhTQKNLoaodT2weN081wPVlaXS9c0EMs3J+xGKXtdKwjXXeQ3Osv 3ZDPmerBCk5yg65ow0itNExHN4mAlayftiF7SKgcPYu1dQEV3+LMYz1mL6jlektkuqRa I1ab5qfHlmJ458P0CIJzx37g1It2ZeJUnvlvr5SrvClplrRgLL/fJZs/Bfv2r1zVjret /qwwGinD5yA2eDnoxvtPhhzr97wQgda6nAa2qlNJKHcSWEIKcFtb8R7MVYUAwiHgjeKP rC7D+J9aKAl+pJf7yVFYtbv+Q3hgh77pXUANl9hv3o4QczbXIkSwHjLArsb5Gkojiotx Drug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WBrXIyE8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id c192-20020a6335c9000000b00578a9192d90si17091423pga.140.2023.09.27.13.26.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 13:26:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WBrXIyE8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 92BA1826EE07; Wed, 27 Sep 2023 10:58:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229736AbjI0R6M (ORCPT + 20 others); Wed, 27 Sep 2023 13:58:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229672AbjI0R6C (ORCPT ); Wed, 27 Sep 2023 13:58:02 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBD9910C1; Wed, 27 Sep 2023 10:57:49 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-98377c5d53eso1443233866b.0; Wed, 27 Sep 2023 10:57:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695837467; x=1696442267; 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=P3vTTatxpTmSJDREvGgzvcF6cpLVGqrOuRB25FxTUfI=; b=WBrXIyE86mKyJiFTrIFftIataCa+m/CG/t6ZgkNOusstzhwT5TDfiFOe8EwxQAYzEN zgbmreHk9H4pc6bxH4I3YAlsCrikc1po4tok/JCUvQ6fkHAQK/Wjr7kOh0BQyVVBu94i 0zxp0rMs1y4oihsyQZwivd8zTusXDiQXSfhf1uFSlLPrBcZIB1gpsGqeLTR7pID3YG8y UrHPjhJs9RNJ18ruOBDQC68IZ6lNDTrCheWkXs/Gne2sKaq4KK1ZUwb+g5VLCDzH9uHZ YSoVUtiSas3voP71+38uPhK/LHfshP7lEYRdtxup1QQ3YWJ9uk0ypZsyyUzv5b4EZ/i4 R3iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695837467; x=1696442267; 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=P3vTTatxpTmSJDREvGgzvcF6cpLVGqrOuRB25FxTUfI=; b=RTswvHV23pD4SBM3JQWYMouM/7coItE2hNC/DWfRV55v8kUsKetJV1jv2cnoG8G4oc a6RFnAmfG8RanpoJT1qoEN3LgWgPAzlD3Yt//DyjFyHCyBrS3crZtUe3VIsjQTMInCOM zz+r4N/pN0J8UCx6m6e+D54txvjhbGs6mEJblCXRW6aPaB6xtpaRvJbRwFumBnd/3o6/ ErX5uF11obgVwphMqn4cT1aEJTMc900+pJsTZEKr7oJw2LHF8s846HceS0fuzG1W2hRg xu8926heLgaYPmptehGzMKLOWgJeKAi9hBWN3Rsw8QRzV9PTWI8YRUi483SFDQYvXDwo vP7g== X-Gm-Message-State: AOJu0Yz/+L24IFbp3rgXaOW7ClFaCpaHR9JyRLyDxJibiw1RKpAYRm59 Ggah9DIfd6uidBsGgOC3PXk= X-Received: by 2002:a17:906:297:b0:9ae:7d2d:f2b1 with SMTP id 23-20020a170906029700b009ae7d2df2b1mr2379262ejf.73.1695837467527; Wed, 27 Sep 2023 10:57:47 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id d4-20020a170906370400b0099bd8c1f67esm9654593ejc.109.2023.09.27.10.57.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 10:57: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, 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 10/14] USB: typec: tps6598x: Add port registration for tps25750 Date: Wed, 27 Sep 2023 13:53:44 -0400 Message-Id: <20230927175348.18041-11-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> MIME-Version: 1.0 X-Spam-Status: No, score=0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 27 Sep 2023 10:58:24 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778223820672278019 X-GMAIL-MSGID: 1778223820672278019 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 --- Changes in v7: - Add driver name to commit subject Changes in v6: - Add port registration to tipd data factory Changes in v5: - Incorporating tps25750 into tps6598x driver drivers/usb/typec/tipd/core.c | 68 ++++++++++++++++++++++++++++++- drivers/usb/typec/tipd/tps6598x.h | 10 +++++ 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index bd877e4cdb72..e775c3c9bf64 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 @@ -101,8 +102,11 @@ static const char *const modes[] = { /* Unrecognized commands will be replaced with "!CMD" */ #define INVALID_CMD(_cmd_) (_cmd_ == 0x444d4321) +struct tps6598x; + struct tipd_data { irq_handler_t irq_handler; + int (*register_port)(struct tps6598x *tps, struct fwnode_handle *node); }; struct tps6598x { @@ -207,6 +211,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)); @@ -1083,16 +1092,73 @@ 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 const struct tipd_data cd321x_data = { .irq_handler = cd321x_interrupt, + .register_port = tps6598x_register_port, }; static const struct tipd_data tps6598x_data = { .irq_handler = tps6598x_interrupt, + .register_port = tps6598x_register_port, }; static const struct tipd_data tps25750_data = { .irq_handler = tps25750_interrupt, + .register_port = tps25750_register_port, }; static int tps6598x_probe(struct i2c_client *client) @@ -1195,7 +1261,7 @@ static int tps6598x_probe(struct i2c_client *client) if (ret) goto err_role_put; - ret = tps6598x_register_port(tps, fwnode); + ret = tps->cb.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 c000170f4547..3a9a43394134 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 TPS_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 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: 145699 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3030488vqu; Wed, 27 Sep 2023 19:38:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF8/J5H6SSPk1z/OgDEJ97sEy1PGaSHzh+6/UGJcTHLUAkQjnJZQnKaCOSgkuHtPP//dl91 X-Received: by 2002:a05:620a:3195:b0:773:db7b:26e6 with SMTP id bi21-20020a05620a319500b00773db7b26e6mr3394370qkb.52.1695868687480; Wed, 27 Sep 2023 19:38:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695868687; cv=none; d=google.com; s=arc-20160816; b=vBo2QTERRQ2SKLTDdUYMg+zQD6rUMvjsyHgvmGR/i9nGFHpYZayxzfRwMrxXXnlzck 3E0YLiaUsn4mYdjQcrGNVpZ6pyAnEoNEdQ/HOHDdfr2myNqMxWVLmhz0FqiENIDgwXhA ytIeuytb1HCgdMfyn1xxSRKEohWabeTUYj3J29iVxz641CS6cyzGrXToLTQXmR3acHeN IWYbMeC+UoJnoa6mwYgMs8EUgXq0D1NvIVdhWkxvsG3OcoL7DGkH53VZjzwSAAD0sCcm 13noEZJ4d/tCuF3wlsvz+q2yIHs9H4P24Eos2Iq8OOiUaD3N12ZXDjQ+9S/QwKwbIpcx JmXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Sf41GpttTXH9NGnzfB9RP8nxYb55p65KkNUeRtKNh+Y=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=EwFcSRPuJXooADJ5aN5Z5NqSZe00NOtvfXzWAVzRbI6+IcsKBJa4jjmx6SFsF3NBD4 bc7EWkNpd1P0UT4vgm1l8qm2tleYSJoE8KuHYyl/1CoTO6Plm3OT6MDaOQoy31x7IbVN h4dhtPeBDl4+aFBxHqMlRPBz85VNYwteTyi+/rUa92FZdH/HV0AqlrJnWd1o891SEkoq FAjQw51nffkHmNH+1xZUK0TdQSZ23vGwAy3bkoWDbbfjfRVxfcFEJpx8A+PQaTIdRcUC qG8MuIGcUoyGGC1Mlv+32OlHvPYHRtH4iWIBYr5bZRNPU9kW29LzZXB0rrx3m7BxeKLV AJ+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=f96bWUp1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id c5-20020a6566c5000000b00565e6a5b065si6602562pgw.107.2023.09.27.19.38.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 19:38:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=f96bWUp1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 022B78291536; Wed, 27 Sep 2023 10:58:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229691AbjI0R6S (ORCPT + 20 others); Wed, 27 Sep 2023 13:58:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229825AbjI0R6E (ORCPT ); Wed, 27 Sep 2023 13:58:04 -0400 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-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> MIME-Version: 1.0 X-Spam-Status: No, score=0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 27 Sep 2023 10:58:50 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778247205004446756 X-GMAIL-MSGID: 1778247205004446756 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:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 145575 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2878452vqu; Wed, 27 Sep 2023 13:17:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXe5DkWTmhDMW62schDnY2p4J/1wWYrPklfqp3yuFeAo2DP8jJB1yrOeS5The6EpAHPzej X-Received: by 2002:a05:6358:91c:b0:129:d242:f782 with SMTP id r28-20020a056358091c00b00129d242f782mr3740666rwi.0.1695845823756; Wed, 27 Sep 2023 13:17:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695845823; cv=none; d=google.com; s=arc-20160816; b=heC/fIcIw+ed8ccE/m+BYw891rQeCqDOSCcw2MW4hRaHs/InDVa2TadYXTUS0uzFhL dHE2ox7oJBk07jZwDMyDlz/mcVbTSCg0rgcXITdugqWVl1OV+ji1/thf5bTF5Pm+GhJr BF1Xe3yH+SSDy+KfBrDGUjnZKblpXAnLhL6TtYM1BvNLNoP4UJsJx/z9pecncEwaiTFz Swr0dijqQ1nkv87wkgQ9h21EDM0TfBXAP/ktHvKm1kggQXR0Xoq/JKShcgWU156f+tvM LSy1rZQEP7/pAnzOUsDk29LTmPB/fegv9dCU1zEpY8mcB4dwKhGiX5doT2YhAuf6eSls lyBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0wXh/hi9rdCXT//s8PNBxmTKFVVUBiplEMbkFSyoXnA=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=yalzpHGtrlvdddxpqetrqlSW/Wzh4s0QDxXX+OI9UfM+ScSs44jon/+SoiQOWtYgYa ThfMIxIzz6qxwJpsBF2iQhMaQn2hRtaFNz7Pv1OcBMZ/lsEX/htpospvqCicUZlo45zN 1YhrUQF8pK4nSpTGduHmv/Sy6tLuVhdkLqFN6m13c6PkTLmpwutw7yoDctjUZSHyYwbi vbR7oisXHtyagodjz5jbgQOgeuI1VhNCSlC2DCdIzZG7UEc4LRjlC8jQKCAs4Oo2/Eui It9XhMx3H7uNdGVxyseiXNSL7wN2QiZBQjea5Ac6ETs1hUjyXo5T1goSRflq4BpXvC2e Mqsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NQ9RxLX2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id y72-20020a638a4b000000b00578e98deca3si16653028pgd.37.2023.09.27.13.17.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 13:17:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NQ9RxLX2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 492A6826EEA0; Wed, 27 Sep 2023 10:58:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229825AbjI0R6W (ORCPT + 20 others); Wed, 27 Sep 2023 13:58:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229765AbjI0R6I (ORCPT ); Wed, 27 Sep 2023 13:58:08 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15BB710F1; Wed, 27 Sep 2023 10:57:53 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-31427ddd3fbso10604157f8f.0; Wed, 27 Sep 2023 10:57:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695837471; x=1696442271; 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=0wXh/hi9rdCXT//s8PNBxmTKFVVUBiplEMbkFSyoXnA=; b=NQ9RxLX20HXei9p4kNWz42Q6HwqfdDofGH1uH6Umr0968az7VXE618UgrjDX+nTrUr GJUVbXyC3fVVJ4maEcgQH/07E7DJl/isd2VtzDQqP82gOzxvGIQa8+jadrpggGLDwh+M NgwlURiST6KGffkyxb8n4DUcy5tXsj4v+zPnfAi7WbvcO81c+nLWzEUU1dgzsRcxy7o2 iGt0iq7yVRtH/TGsm0SRoyg6MNFxYChmKS6/wr4RZHVz5klWv5gTVa9FY/OlQd2JNrZZ lLCZ/sw7xNMRVuPb62fqEjahViZYU5DOoj5AxulNBK3ic90hTXUbAhz7qJkK9HEaSouv j67w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695837471; x=1696442271; 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=0wXh/hi9rdCXT//s8PNBxmTKFVVUBiplEMbkFSyoXnA=; b=Uywn/B47GzSlx6SNqJokyX8PTt1mFC5lzaOLAbu+KmPKlnZxDNwsQGLBgO5Qu45uCH fh+llD+0Vg4WjYPRrfshYQnOZ6WO6bCUc8JQZLE0rmsJiKS87BmOyqeNcJaRok8+I4Fe OEm7hTHoPOiIZSDkpWfVQj6tFNs0GfKu5MpcuheKWXTTJjvYDsMhqw2lB4CCTtXjV5dq 9vIsB0GUPp0cEVCiFc5jkyaeb0ny3ubN6hlGdLGl0SJnv7IdttAIRPYbUIM075XKqQ97 dqw6TqFNfNjTfOtNaRN0n8Vi322mCqjS8HQJiAO50Pk6cHaSjYr2cOMwBW+sfOydaCxt 8hvA== X-Gm-Message-State: AOJu0Yzh7cZrcY3YJI7X/O7n+Lgm28cZLNP7XLVKwvi/b7/FNgLM0Ad5 PfNQ1/G8q8FwxcTORrhZkRs= X-Received: by 2002:adf:cd04:0:b0:31c:804b:5ec3 with SMTP id w4-20020adfcd04000000b0031c804b5ec3mr2393453wrm.67.1695837471218; Wed, 27 Sep 2023 10:57:51 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id d4-20020a170906370400b0099bd8c1f67esm9654593ejc.109.2023.09.27.10.57.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 10:57:50 -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 12/14] USB: typec: tps6598x: Add trace for tps25750 irq Date: Wed, 27 Sep 2023 13:53:46 -0400 Message-Id: <20230927175348.18041-13-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> MIME-Version: 1.0 X-Spam-Status: No, score=0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 27 Sep 2023 10:58:56 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778223230210050263 X-GMAIL-MSGID: 1778223230210050263 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 --- Changes in v7: - Add driver name to commit subject - Call trace_tps25750_irq directly from tps25750 interrupt handler Changes in v6: - Add trace irq to tipd callbacks factory Changes in v5: - Incorporating tps25750 into tps6598x driver drivers/usb/typec/tipd/core.c | 1 + drivers/usb/typec/tipd/trace.h | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 19bb2105b5b2..deb2b756fec4 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -582,6 +582,7 @@ static irqreturn_t tps25750_interrupt(int irq, void *data) dev_err(tps->dev, "%s: failed to read events\n", __func__); goto err_unlock; } + trace_tps25750_irq(event[0]); 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 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: 145544 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2842936vqu; Wed, 27 Sep 2023 12:09:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGKD3LIAKv79DXyPYnbgtNNLJn6Qsbchp999vjHpMF4an1CJNpjM3a4eo6w4Y88Nt/KMm0B X-Received: by 2002:a17:902:ab54:b0:1c6:2866:5aeb with SMTP id ij20-20020a170902ab5400b001c628665aebmr8083040plb.9.1695841771463; Wed, 27 Sep 2023 12:09:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695841771; cv=none; d=google.com; s=arc-20160816; b=tZwTY3+XNS783WoHZL9ffnBS3EjWcrvpFP83xp5EL14vtaWbHlRBLqysaL47NQzgCm RNIRBcxgiSeLu3menAASe4f3u/3QFgejIVPnYZpliUlbSXwWhu3roxVJ7XAm1+fjs1oA kH+6klev1217qI1+4a1oFuVDuVUwFuX1yx1us2e5Ynrh8DwZifAMjXYy550isJ2ykwTy WxLlzyWkOw4BuqrbeCTpMCA6gmv6L+MrEdyjR6g/sbceR0IVyRCyqpmwCf43lYaii8ac uvYZmV2Bb1YTZx5KF+HFowtPrvmO4LbLD/ijkoQ+7gKwPOUWegEQIli99eJjiAoaTOlw YpHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=voe1AQlyJ66tuR3HAig5V+hgG3HWnfF9e7gj5LZdSfU=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=n1ddyKlJepfcUbAACkpxtg3jaeluoWWxZqr+bA5LRPUtuleVzNN1xYjLP6TT/1jvUm DIwbmXh8Hp0KQu2O1eGVKlPNZPFgCjmh6l4JZhFipGkAOI2Ziz7PBCqjjMX5yQ7pIFi1 1kp3VS4hvp8/5DGpBuA4BAkOlrWhJFDWuz0XkHmpkqlf6cqX9viJsB0KLPdQkUdwsl1a bmhKt3gD/w/47fdSss6We6euJCYRQvQbjPZ4xrzVL/+AXH1Cmm2HEBrkoeUlt7PhK/k/ Q8niSAFiVmHjTS6BHKTfqqtxd9HUUNcjwNzPufDmkZL1j/gBrb8ds7TUEzrCcnY/mTXV 5eFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=a1FlIBvM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id x12-20020a1709028ecc00b001b87bd2f7b0si15217051plo.402.2023.09.27.12.09.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 12:09:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=a1FlIBvM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 174B280B6C2A; Wed, 27 Sep 2023 10:58:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229847AbjI0R6a (ORCPT + 20 others); Wed, 27 Sep 2023 13:58:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229842AbjI0R6J (ORCPT ); Wed, 27 Sep 2023 13:58:09 -0400 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-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> 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 27 Sep 2023 10:58:35 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778218980983912371 X-GMAIL-MSGID: 1778218980983912371 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), From patchwork Wed Sep 27 17:53:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 145730 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3058652vqu; Wed, 27 Sep 2023 21:05:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGi3rUAzsjJV1v0jCj9jhraTih8yZiiDPVDjMwSW9pLwxxRc2lf83tP2+iC8JppacHx7VL6 X-Received: by 2002:a05:6a20:2446:b0:15b:c800:48af with SMTP id t6-20020a056a20244600b0015bc80048afmr99008pzc.23.1695873901600; Wed, 27 Sep 2023 21:05:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695873901; cv=none; d=google.com; s=arc-20160816; b=ghEAPl3Z0cyjRIBnP8Km8u0Ixge0nG9kd9aQ36E9wkqb13oWeiSom5w+mSD59TW4sd feH50FH3QcVvz0Y+thn3Z312tQvMUmKv4R6DGAQnj9SdoQeyJBEfwP5pFo9EHoistSa0 nz+isvgGtZBiIlss/F1kWbFcFottJDOcwcijFVn4YxPFTPQUgnCXsTxWImP2h7825RDQ sWJ0H3WEwsPnMXq5vPCxdO7mrNdWj9XcRj3DPxvHnqRl/6O22FStH2+xg8/621CF/c1A qNHkGMZCrn7Qp2c6mmJWoOEGio9eu05y/rKPBAIC4QU9jMGfMZMV3FLuh/oM1EoP+Nza gIGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=p2109S4Uz2+NkDCuRu0GcYLAXs7x3Far7ylOe5EHoOY=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=XXAOkbJ2emQzZqxFJXgWVfXJ6J5LQGkCR1UqC9NGylzoJJXugurLlCY/OJr1eSmNmi VsnJ4HUBi5/ntEY3aHOONd2XZnZDa67KXJSITJhVDLbaTIVbsy5m1yxYxWi6q0tlDlcI 53JeUHNokgNV1qCtkhlWaYGdDTO/+drQy/qP9Ii6MrWyEDNbowtij0hF8jCnRFFq37o5 t+oKUP3S/aCgVSttT5eoaSMdTMXOtND9Xe/7iAbob7pFab9pCMd/GQGGqQV0b06M6lRv 5QYNIVtyENiXoHY8RgPm0USdx4r6zrZkQmge4UzUwizZ/wx3UmM7Dgcz8FQZm/hGZRFb In2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=m933ANgx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id kh8-20020a170903064800b001c6223e5675si7720024plb.188.2023.09.27.21.05.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 21:05:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=m933ANgx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id D3DFF80B6C2C; Wed, 27 Sep 2023 10:58:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229708AbjI0R6d (ORCPT + 20 others); Wed, 27 Sep 2023 13:58:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229848AbjI0R6J (ORCPT ); Wed, 27 Sep 2023 13:58:09 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3E2210F5; Wed, 27 Sep 2023 10:57:56 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-40572aeb6d0so82792905e9.1; Wed, 27 Sep 2023 10:57:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695837475; x=1696442275; 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=p2109S4Uz2+NkDCuRu0GcYLAXs7x3Far7ylOe5EHoOY=; b=m933ANgxGQiFXpCXC3/svDWVuqeg5IQTId42hA/fM0FJcK9KNZ61FcfSDHbJb89Dn9 +5toSYVtp+9KgbFbHoGzIJ/oFCQdPxQcgvD6vC0JeOjY2zTX89bnNUHeuL+5M294glb9 qZ6FjdvIdXc7J0B3fP62cUnVe5sQ8UmOnPOVUeSiGq7145azUXg2Hz64I668B6fsu9BF z2YG7Iqpmk5OfhkU1utDEyq3PclPNesQkTRjoaJgTY5y4dyv63xXfakARjZ/9LNQ+wqb SfG6GJHsWunODdlkhaevLNLBhzTVcstmS5OK/iM6r0PxPM1pGQQgZ9jowFV4CJ5WyhUw 2b8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695837475; x=1696442275; 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=p2109S4Uz2+NkDCuRu0GcYLAXs7x3Far7ylOe5EHoOY=; b=PSi/Q3434HFH/X+n3GSg00cEUh+TEMtTOZyOPLVxeuRmC/iYqeLgkgxAIh+OIBjkcs PMMXQ3Ee4x++E3zSK2YdO+LTnPGdbVB/AwFY32ns1XdGL4e5OQFA2enCWgSmQUA0DbVH 8htjeMeyIEBoAm3e9bOJU+Qvocz7yv66kjaYUL+VoRZckfYTiaZAS5ga5Nh8l2m/STCo ggmPWe+gpdEzW9tWIWBO9njOvltusubsutjyrWr6e6TOcqW6vMv0OEO/ch48fEB+yThe mC/wild8AluzP9qFFa2m+p+V3A6GLiZh17pzJIsmayDzPc5Gw2WjW1CqCw+nMJC0tTSL l1ow== X-Gm-Message-State: AOJu0YyrqZme5IcvZSmci1cSkFiJATTiiLSC5xLnlVDO8jRMwRcobqYw 5zu2a9DCLQvcFYwtcOq3zqzx3ytsnjrYTsiI4FI= X-Received: by 2002:a5d:6782:0:b0:31f:b79a:c4b7 with SMTP id v2-20020a5d6782000000b0031fb79ac4b7mr2420469wru.24.1695837475101; Wed, 27 Sep 2023 10:57:55 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id d4-20020a170906370400b0099bd8c1f67esm9654593ejc.109.2023.09.27.10.57.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 10:57:54 -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 14/14] USB: typec: tps6598x: Add status trace for tps25750 Date: Wed, 27 Sep 2023 13:53:48 -0400 Message-Id: <20230927175348.18041-15-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> 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 27 Sep 2023 10:58:48 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778252672694119790 X-GMAIL-MSGID: 1778252672694119790 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 --- Changes in v7: - Add driver name to commit subject Changes in v6: - Add trace status to tipd data factory Changes in v5: - Incorporating tps25750 into tps6598x driver drivers/usb/typec/tipd/core.c | 12 +++++++---- drivers/usb/typec/tipd/trace.h | 37 ++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index c9c30de6e77a..59a4ba797a2c 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -109,6 +109,7 @@ struct tipd_data { irq_handler_t irq_handler; int (*register_port)(struct tps6598x *tps, struct fwnode_handle *node); void (*trace_power_status)(u16 status); + void (*trace_status)(u32 status); }; struct tps6598x { @@ -468,7 +469,9 @@ 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->cb.trace_status) + tps->cb.trace_status(*status); return true; } @@ -1173,18 +1176,21 @@ static const struct tipd_data cd321x_data = { .irq_handler = cd321x_interrupt, .register_port = tps6598x_register_port, .trace_power_status = trace_tps6598x_power_status, + .trace_status = trace_tps6598x_status, }; static const struct tipd_data tps6598x_data = { .irq_handler = tps6598x_interrupt, .register_port = tps6598x_register_port, .trace_power_status = trace_tps6598x_power_status, + .trace_status = trace_tps6598x_status, }; static const struct tipd_data tps25750_data = { .irq_handler = tps25750_interrupt, .register_port = tps25750_register_port, .trace_power_status = trace_tps25750_power_status, + .trace_status = trace_tps25750_status, }; static int tps6598x_probe(struct i2c_client *client) @@ -1261,10 +1267,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..0669cca12ea1 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),