From patchwork Fri Sep 29 14:30: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: 146681 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp4192864vqu; Fri, 29 Sep 2023 10:22:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHe9iGRqTogIDROWQhndP07N7b1q4zRfV9cOA9/1g8guLZHhHisqoatJFKTVEtvvU1kDvuW X-Received: by 2002:a17:902:7d88:b0:1c0:d17a:bfe9 with SMTP id a8-20020a1709027d8800b001c0d17abfe9mr4907920plm.46.1696008174701; Fri, 29 Sep 2023 10:22:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696008174; cv=none; d=google.com; s=arc-20160816; b=GW5FHBDt7SWnKwNNCeOtZ2USGX4QQQR5v4rpn3qJgngqnToFGvFg91Ua9nnvtUcTI0 XFEM/Cu2dINwKI/5WuayMJ+5sY2KPGIQy4oAT+2bPUsHtzEZJarvQwJffDRXXcU6Qyou /lOiQb34hbK1vGX8rh5zuolNIQvm82woV+iocPfII0BG/KuYPx2pHQ50Lb3BvPGoXv9t dPhYe0CSfGDAysVsgb0Ji9nKsic1ZZJCdD/tiEUR+wcLQ+VL6aY05JQJffRTzlptFvZM BTs/tgq8Lt1Zw+mIrlFVidx0LtVSAaD4ECuXISekv2t3Nuwvdkjr7SGr/4EYvRVnjMCR fIBw== 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=6gorcjYjN49NAZEdNmuGyOjw/6rU6U5kxJc+ErxPrr8=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=TN2YKctNg4PUtNxoVifuViPZAvv9ynFig8LSnrk01GuKG39MnRk5Hf1BTws7zmSlKw OtsB5IuhE6TnZRX3Zcurko90qGs0aiaIvASymLHXze+z6/AiMJj8jIckaucp81v2dv3D Fll3NjXVcujAflGR2Z9caPT1JH14wGfuxmtvW5YRuE9alVZoqyqDY4IBphnAMGS65Na2 ddbGym8dsaHpPPcpN6wzNbCRPLcij7CUDfCNChQx1UCT3/hsnNvbO2TjPPTUygKfymc/ B6c9yi7Nr/H6q2RNz6s2jSIOfm2pkeZQExsbFq3Sq8Fr5f1CuBDug7W+Mhr6HrpfF8WL uUwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=aUUKttNE; 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 d2-20020a170903230200b001c38c268dc1si22399880plh.455.2023.09.29.10.22.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 10:22:54 -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=aUUKttNE; 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 3E5BE8022585; Fri, 29 Sep 2023 07:32:28 -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 S233550AbjI2OcL (ORCPT + 20 others); Fri, 29 Sep 2023 10:32:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233584AbjI2OcD (ORCPT ); Fri, 29 Sep 2023 10:32:03 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACC6410D7; Fri, 29 Sep 2023 07:31:58 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-9ad810be221so1928424366b.2; Fri, 29 Sep 2023 07:31:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695997917; x=1696602717; 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=6gorcjYjN49NAZEdNmuGyOjw/6rU6U5kxJc+ErxPrr8=; b=aUUKttNEaTM6BKnYPWhs9R+S1ao+hVAJoWCkfOFSA2e4fssaBscRKR4r/sMGLSg0eZ 9LobkIyOpLFdupc3jeDv/URy8PfPshgRR+yijBMa1UrG4WP26vZtnIdR9w6jbCBaYITr Kwri954BX/2PiAQ4QCGbeoLzeaMFpgs35pwNDkEOo4uwtCNpWBBLrh665uieyrR4YGF8 6vC3A0e0jkTCKH/HDHA1SPv/Sc1S0sJNGnerYeqs8q1uknD8S7uBHhymQJauUoKSo+e0 0B0C3pQB+XJLMsjKzkmMU3VIvst6TX5L1Vpd9tV4JnreRLRXevewyVkaCmlmcd4GzQ/x fnGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695997917; x=1696602717; 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=6gorcjYjN49NAZEdNmuGyOjw/6rU6U5kxJc+ErxPrr8=; b=hp9aNYD5rDBu35xskEc5a+cUwRA1AyUcKUjMy/kgCiDCptECa+bKUrD/xZqFwROKcc 6CofK2FgLl7mpSLXeMc+GmK4zqCmJflkKIJ8TwCEX+w2pGtshlPzUX1WH5MoXBzzxj1a qFaaTACgvL/3RjtE9A7dPqArXhnokhJbu2ZlyF7NqaAB3u6GbQQDWkanKFDkmaFyfy5m i1ZRrQWyUeXCRKisma/vy257fvHNgBY6T1mn/Dj7anC1lnJXx2ag2vZYFv4CXxrkSWXt 6rq+SW3YTDem7GKisRkAHyf7mpjliAIiyZtQdHZYsj39Np8eBxeS6EfodWH459hX9fbV iTbw== X-Gm-Message-State: AOJu0Yx3c+1UlbibdDxrXdzSx17qauzHnvWNgO1RqMrGb3hfiQGIkwI9 GyWtCZUnjO/FkX5fS3Fm7L0= X-Received: by 2002:a17:906:51d8:b0:99b:627b:e96d with SMTP id v24-20020a17090651d800b0099b627be96dmr4061338ejk.44.1695997916718; Fri, 29 Sep 2023 07:31:56 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id a7-20020a170906670700b0099293cdbc98sm12660105ejp.145.2023.09.29.07.31.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 07:31:56 -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 v8 01/14] dt-bindings: usb: tps6598x: Add tps25750 Date: Fri, 29 Sep 2023 10:30:42 -0400 Message-Id: <20230929143055.31360-2-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230929143055.31360-1-alkuor@gmail.com> References: <20230929143055.31360-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]); Fri, 29 Sep 2023 07:32:28 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778393467875310028 X-GMAIL-MSGID: 1778393467875310028 From: Abdel Alkuor TPS25750 is USB TypeC PD controller which is a subset of TPS6598x. Signed-off-by: Abdel Alkuor Reviewed-by: Krzysztof Kozlowski --- Changes in v8: - Define reg-names at top-level 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..72ac534e6ed2 100644 --- a/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml +++ b/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml @@ -20,8 +20,23 @@ 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 + + reg-names: + items: + - const: main + - const: patch-address wakeup-source: true @@ -32,10 +47,42 @@ 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 + + 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 Fri Sep 29 14:30: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: 146774 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6f87:b0:13f:353d:d1ed with SMTP id tl7csp3552530rwb; Fri, 29 Sep 2023 14:01:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHptx6XZAQ4/ax9f961OawMy7Y4KYyYnehp6aC7bYDuUm+2VCgk2A+mGkseDdL39ujEUOpy X-Received: by 2002:a17:90b:1254:b0:268:2500:b17e with SMTP id gx20-20020a17090b125400b002682500b17emr5289563pjb.23.1696021309626; Fri, 29 Sep 2023 14:01:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696021309; cv=none; d=google.com; s=arc-20160816; b=lafR1iyY7lQ6eK9exqAV/pjwnqL2BE9jp4wYa/GV5f4T4W7VdPHf1Lrr80QAIFftUL 0fQOVw1U5lRa665ztrfkNWfv5ZS2Bzjo7xvM6MzB3blQEp+uQoFM41RiRi6qqpo8kr/B f3G8yikKWbjYnVm/z1jlPEw45YiUj/x4OclEebgQYTukJznnLxs25Op9kLpJ+DB31Df2 Or+p1tRtMoGsjS6vcUHyrTyv6CHsZC3NPWE21agQvYijoswImpspv6f6Dz1Hws3L/GjY 5BIpr1OpH3sqTYYIRyylgAsogtRBwFm1kIA/sbYJQIQFpnX3HvI650aRKbIkX+ijzDc3 AjHw== 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=iGIQpTQvObysL6Oo7cgMHdezro1zF1YMMi1C0CmxddE=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=HonB+RhZjY9eEMAbGRU9EMp2mEdj/z0qRQM1pU0bd3SPMJca5JCJYRrX+r/1ODDqXj XePkVRGUtyJqlljWnVdnOJUlp2r3U0237hHT01vOWbGx/xYABy3cK0W+pT/LiNRn25KT 9FN99jGZEAep/sYr8PPxD9VX+2vXGvRlzhgzW+MX5NrM/bwDR3qWHnLXp5km9/4lyiEF IVjXCvY13JhUuCabWi2U6lNH8YSbBdVD7W9W6Ij1Zndcqe/h/+hl0Fm1nZH8Wl3EEJfg tUZFBi7piM3t+/52jPek6XdPxpaiyGHmWYqTTR6tX0r3xbvzyVs9lPvcZw65YWJaOzQg iQEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=h4h32S1R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id cm14-20020a17090afa0e00b00276c2b21697si2170521pjb.72.2023.09.29.14.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 14:01:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=h4h32S1R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 43FE6817DD07; Fri, 29 Sep 2023 07:32:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233454AbjI2OcO (ORCPT + 20 others); Fri, 29 Sep 2023 10:32:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233520AbjI2OcG (ORCPT ); Fri, 29 Sep 2023 10:32:06 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D87610E3; Fri, 29 Sep 2023 07:32:00 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-533e7d127d4so13798352a12.3; Fri, 29 Sep 2023 07:32:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695997919; x=1696602719; 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=iGIQpTQvObysL6Oo7cgMHdezro1zF1YMMi1C0CmxddE=; b=h4h32S1Rap4pOQkBV1FUdUT4Rpuw5nKsBZh/MaQd3D4inrg2FUKKyF1M0efJM6pnRW +sx9BZ2Le8N3Kj2rgJ2F3A2FaUc9PHnood1R7Q/IAoowTYHroSW7Dp8faZ70E4F3a8ot +6d5xsAA1laPzuhfgO0pbrr2eTIT2DekAw92/Mryafgl+fmKbSuV+O0W7jHMkk+yijEC 0bl52kB9ckbS89Bi6E+jEI3J9NdMfoxK5/PxWKEuRnMbxwHY0jizx4cb+po+W+eObz1q ug3Dhq3+tZjISsYF7DK7F31jHZtCarZhAU2YvgB1dSN0Is453ExZ8+W94IEP6TbH6Fh1 OZmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695997919; x=1696602719; 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=iGIQpTQvObysL6Oo7cgMHdezro1zF1YMMi1C0CmxddE=; b=Ula2gjCGgn/ay+py+2rAginC9WiXFZ3ldXbysdBXLtRAw6YtgK3x9b/jJOPZS/pUPB mrWwENB259IC6qb/1HmLdsDPAi/cTlZ03vTgNAvgsbo8Dqjy011+UJ393gWH9sQ3cx/z RZcQ2knD4SkoVlcbPJ7Gk2GNeqxILrMypGACTeApV48FB5v/71WJEDBWYvKC6TYfO5iO 02akYiIcbx1ao4+ZXewuO2iUCrtws3RX9xJ+EBCNRgZVjZE+k44kZjRrpdY76yv/xuX5 LvmsWQwZgJ3b6iQa1L8zk+kMm7Mwv1aLgf/I66vfdFIUX3U5OFioVNydh+WOp8m3x3yw mDGA== X-Gm-Message-State: AOJu0YyP4+3M8NFx1z3M9Opob+ysoP5VVVhmloNtrKCJw/+OCz9IkNXc tk9B+bILcgzOc+8EN9lkmOE= X-Received: by 2002:a17:906:53d9:b0:9ae:7611:99bb with SMTP id p25-20020a17090653d900b009ae761199bbmr4368551ejo.59.1695997918627; Fri, 29 Sep 2023 07:31:58 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id a7-20020a170906670700b0099293cdbc98sm12660105ejp.145.2023.09.29.07.31.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 07:31:58 -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 v8 02/14] USB: typec: tsp6598x: Add cmd timeout and response delay Date: Fri, 29 Sep 2023 10:30:43 -0400 Message-Id: <20230929143055.31360-3-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230929143055.31360-1-alkuor@gmail.com> References: <20230929143055.31360-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 pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 29 Sep 2023 07:32:58 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778407240852575881 X-GMAIL-MSGID: 1778407240852575881 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 v8: - Add Reviewed-by 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 Fri Sep 29 14:30: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: 146856 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp161203vqb; Fri, 29 Sep 2023 19:42:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGboGQW32wDbxo6BarJgkcm/EC7zsg5m3gjAsERUd2oQAKL4k7I0lyqw1r2DGjmH40oydCY X-Received: by 2002:a17:90a:4ece:b0:25b:c454:a366 with SMTP id v14-20020a17090a4ece00b0025bc454a366mr5799693pjl.5.1696041776503; Fri, 29 Sep 2023 19:42:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696041776; cv=none; d=google.com; s=arc-20160816; b=iRyY9oaLkdeJa9LRmP66bG1QKmD0AnBpFtOo41mHDLyjhA1FAeSSp3Og1flcRCW0oD Mh4jFqSJxh1pqL40+kWYgrQNZiWUmaV6+bdie5ACpTNJzHkmg17gecju8TfLFvphIv9h w93SE0n0WQF+I4H3RnlT3S61XpmA/ti0BpJySw2t3QzvgprFBOnzOPsseV8d59w7dlCU osFoNRkFjKXWlcOFY1X94pDlmFgoozfv0UYZASvnUpDXDYlEPAbMQy+uLsAzMOUaPWoB 38vvUXZidiBMrYatC/vfsarWgteqF/od29pAWrtdHluj854T6HEM8qwFF8ut0L/8BnOi sCgg== 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=En/oFUq/81cLOHvLKqdr065XPAN22won0/p2LOHNjFo=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=L9iZgMaO9MhzscEJ8xdCKDeb+iB+nFTMXR59effjsJBiHeRA62Myyc6vh18exzg138 OuWk2cmKj0UqJCrOlS0/JbwgW5JEAkI59HFSQ0ZfCxLhIr415vHTbI/VpYbOpuKet9XI 1Q4oefNnofDPJZXid3doui9bvmsaHRz8G57kPYaTNPVfb3xmvaua/HVnk9L1jgTT4wxT axPASK13FcNxttouHNNnv/nttn/VhA3NJtGjTRrbvdKFP7OgCuQ/yYu1GJtsH59EjP96 56oRQbzwe9DW++wKBr6uWDLZx3ghHFg+P0JvN7/98F+w4fL7ToqqyBzhqzAaV5hWRaw5 Wxbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="IgN4X2H/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id c10-20020a17090a8d0a00b0027768e7a9aesi2557852pjo.120.2023.09.29.19.42.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 19:42:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="IgN4X2H/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 85CA282F9250; Fri, 29 Sep 2023 07:32:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233606AbjI2OcS (ORCPT + 20 others); Fri, 29 Sep 2023 10:32:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233525AbjI2OcI (ORCPT ); Fri, 29 Sep 2023 10:32:08 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 433F5CE7; Fri, 29 Sep 2023 07:32:02 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-5335725cf84so16995615a12.2; Fri, 29 Sep 2023 07:32:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695997920; x=1696602720; 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=En/oFUq/81cLOHvLKqdr065XPAN22won0/p2LOHNjFo=; b=IgN4X2H/oA7ny4yJRqfUCAtG7nqAjlAsDHlb9U7oqFDP/DCmaX/1ynjQI1hrAkGQHJ yWi4iAO0BNWozzViZo6ZC9Iyue9HRsZWeLIqlEy6SuuZx4ZD5ChiGhdEmGXHArltlf6M c7+A9BK+shntL7gHYaVxYP/hFpXTK/ZMe0NtGGs3mIj4A9FcTfaSQq1asGhmfLI8bBYG KPyz+WhrV/4/9ic/WXVnBnkQxG0FmyydgwYnM2HQdV1HbUww3lHuzzB2a3l8aLZJ3KEH i8dDgBqvsJNhBiwEWWN/UqhiyJojgBwgHuakn//D8DMNZp5qvSI3k/9j9pgOv5/xASpv aCgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695997920; x=1696602720; 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=En/oFUq/81cLOHvLKqdr065XPAN22won0/p2LOHNjFo=; b=MKvdDj4ubZ8ZdB453TXsRe4fOMX1Nt6Jfts9IlB3Kfg0awsjB91fD4OwUM5EBfsdPP 5ZCS+s9jsKtcMRbpvEEk7P5ziqsu8O78EkYVreAlqLxYsCt6dPppcEKFrDvXAec1G2K+ 3eUjxmwW/0xSD0ZIX/bX9c88RFQfkkGZIynTwK6wfz4iMvyIRMrnZq8cN0HTwa8yiZ1w FeSxi513GPfxp4t7VQZIBsW0za0iqW2QZaEXgfuCA0k561XTxpafNFvlSRe1QnRVTVVQ 4EXGtFK9pyDT5a9QYjIkZ9rkZoG9J+h9Ogkcxi3xyePf9CnXCMFHiPV2DpVRXlYpCMXw e8Og== X-Gm-Message-State: AOJu0YxP9kV4Gas3IH3UyNcO9Et3Vk7AfL6ayoNa9TqqEWplbPy+ngdP ZipSfymozKb0vV+0PMYU5mk= X-Received: by 2002:a17:906:1bb2:b0:9ae:7204:3656 with SMTP id r18-20020a1709061bb200b009ae72043656mr4232051ejg.60.1695997920584; Fri, 29 Sep 2023 07:32:00 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id a7-20020a170906670700b0099293cdbc98sm12660105ejp.145.2023.09.29.07.31.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 07:32:00 -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 v8 03/14] USB: typec: tps6598x: Add patch mode to tps6598x Date: Fri, 29 Sep 2023 10:30:44 -0400 Message-Id: <20230929143055.31360-4-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230929143055.31360-1-alkuor@gmail.com> References: <20230929143055.31360-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 (snail.vger.email [0.0.0.0]); Fri, 29 Sep 2023 07:32:41 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778428701981972872 X-GMAIL-MSGID: 1778428701981972872 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 v8: - Revert mode check return 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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 32420c61660d..c5bbf03cb74a 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" */ @@ -595,6 +597,7 @@ static int tps6598x_check_mode(struct tps6598x *tps) switch (match_string(modes, ARRAY_SIZE(modes), mode)) { case TPS_MODE_APP: + case TPS_MODE_PTCH: return 0; case TPS_MODE_BOOT: dev_warn(tps->dev, "dead-battery condition\n"); From patchwork Fri Sep 29 14:30: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: 146705 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp4225111vqu; Fri, 29 Sep 2023 11:20:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHsW26OIrsn+uxO71gSAnCZMmnUXOhSDXJYX1PWdbBlsDX/bMyKUQBVPMbpLtDS59ABxjnd X-Received: by 2002:a9d:6d98:0:b0:6b8:6785:ed0b with SMTP id x24-20020a9d6d98000000b006b86785ed0bmr4703265otp.30.1696011615107; Fri, 29 Sep 2023 11:20:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696011615; cv=none; d=google.com; s=arc-20160816; b=MWmOvXlohWfzI6XSK0sLkzDz4EH6hW96AZNDyvnjtRILu0lW7gJprtJtQa84sIYUnm duMqht3gb0DzfBpBtyZpRzgkR7HacXRS4lN4gCqs1BwG9P52+IafFRl3/DExqwm2Iwzw DZdAN2kk5uMZUfnGikGGTSFNxmkS61G+hwu875Zm1OelQPUNpIb+As4CnR1eDun6BgiY dmvYywmuXadaaTmLxcBk9lSBsTLy1PCKLrCtLSa9mLMnMb09jYluTLfKGLHhUu/7j8cz xncBldijgEsJGNXHVBF011HLF40KXDfr14paXS/hf5am8tvcrB+Iq/aJBYycRMVxveCa ADLA== 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=Rq9tzUXgeqKnSzI772mYD7hi8W3HZqTNCYQs8mjvCnw=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=PTKBob5p74Zw+juesqSi4crfQlPYI2cu/5+Wm/JGIJ5XbYWl5gD2QvsFdBQGMdIUhf wxdNRn7R7p9v98/KHbYqCCCWeC4B3yr27TlMh0TbB3E2cElh/MpgsEpHN0aVynjZNicE 62DWSGEBZ7th4MaHXXApINDXU0AZNnu5GbvRsROcpdZX6ruqN0/gZpHK0w1LKfISZX4H //U3Qpe/I4YCNMUV0nK4zPFyuREbSLIi3I4aPWIIy7LZz7kkCJ4wxfkALSkhIuGV7e6j 4WA8PRgfuBZYUjusFJ3SGYwvwc+OvulSyQzuIxIuB4PU+Knk9suzDRc4CuAa6s9b1GbC PbwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=JUX4vub9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id 64-20020a630043000000b005859a90c58csi2659200pga.772.2023.09.29.11.20.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 11:20:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=JUX4vub9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 4CDFE82F9258; Fri, 29 Sep 2023 07:32:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233685AbjI2Ocb (ORCPT + 20 others); Fri, 29 Sep 2023 10:32:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233585AbjI2OcM (ORCPT ); Fri, 29 Sep 2023 10:32:12 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEF241B2; Fri, 29 Sep 2023 07:32:04 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-99c1c66876aso1921424266b.2; Fri, 29 Sep 2023 07:32:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695997923; x=1696602723; 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=Rq9tzUXgeqKnSzI772mYD7hi8W3HZqTNCYQs8mjvCnw=; b=JUX4vub9mPGvBzDA5SZc6S3VE+tkalENtZFJrVtbOFaaQrFA2c0phF0iskzQRo7zvn gj16qkpe/qwwUj6YttDHd+y/JI+vevXsxs9tG4IYM9nn5p/xXCvrJJHfzb+Q82DHgY2V pXlNxtj2hCueB9xT1TPwRRUCl05rZQVKAmHCqzA4FTsWAUWRk+AYQgnQuKujQXibr1bM e4Ye83QoS8oFpecv/C1PKCWI2+HpomUyikm0UDJ3nUyFxSuaLP3aYv1t2jiaEmJXbKBa yr2kdcEU179VqJslviGVaiSRR/olis9NWwamLjcOC/iTXM/Os+ly1C9ZCOI4kLZRRyG5 oxxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695997923; x=1696602723; 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=Rq9tzUXgeqKnSzI772mYD7hi8W3HZqTNCYQs8mjvCnw=; b=my4/8OALs2scublhjh7AngxgvsUX3Yi5QwlaSVNIRTnZVRXAs5pNuVFbgkCo0goYAm UGSwswMofT0CcEk7ixu/JtnmqVYHhOQ9UgLioV5FAYJzOAizWjCwgoIKl1wWB0JPLHFj Bh9PMUgFW3FMCXFzlEzlYjUgL3yPhPeUJ/o6cncylknLZXFTKwrEZ70/Os0Adn66Gk8W Wfs6ibsat4Cdqa2+0BFBbiqd/8+0/n9hJLPvMnTNCbmu5BLN3IRwycTXQFM5bwuUIIMv 9dlMhqytBnIv11jorrSZow3swihO6luXnbkb5Vek7Paf5pBX0Tu6S6uG0RLY2cS1lBZ6 PvMA== X-Gm-Message-State: AOJu0YwM4l9vVTAebde8yKIcVhFkUBfhN+xGDjiS0cXnB/7yu/3mDl4S ySkFXw4Kv6DK4gTI3t8h8Ow= X-Received: by 2002:a17:906:9c9:b0:9ae:50e3:7e40 with SMTP id r9-20020a17090609c900b009ae50e37e40mr4068372eje.52.1695997922636; Fri, 29 Sep 2023 07:32:02 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id a7-20020a170906670700b0099293cdbc98sm12660105ejp.145.2023.09.29.07.32.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 07:32:02 -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 v8 04/14] USB: typec: tps6598x: Load TPS25750 patch bundle Date: Fri, 29 Sep 2023 10:30:45 -0400 Message-Id: <20230929143055.31360-5-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230929143055.31360-1-alkuor@gmail.com> References: <20230929143055.31360-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 (snail.vger.email [0.0.0.0]); Fri, 29 Sep 2023 07:32:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778397075323663271 X-GMAIL-MSGID: 1778397075323663271 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 v8: - Return mode when mode is checked - Use device_is_compatible instead of of_device_is_compatible 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 | 263 ++++++++++++++++++++++++++++++++-- 1 file changed, 255 insertions(+), 8 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index c5bbf03cb74a..2e7b9eafaf04 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, @@ -595,13 +613,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: case TPS_MODE_PTCH: - return 0; + 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: @@ -711,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; @@ -723,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) @@ -735,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 = device_is_compatible(tps->dev, "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 @@ -768,12 +999,18 @@ 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; + 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) @@ -893,6 +1130,10 @@ static int tps6598x_probe(struct i2c_client *client) fwnode_handle_put(fwnode); err_clear_mask: tps6598x_write64(tps, TPS_REG_INT_MASK1, 0); +err_reset_controller: + /* Reset PD controller to remove any applied patch */ + if (is_tps25750) + tps6598x_exec_cmd_tmo(tps, "GAID", 0, NULL, 0, NULL, 2000, 0); return ret; } @@ -903,9 +1144,14 @@ static void tps6598x_remove(struct i2c_client *client) if (!client->irq) cancel_delayed_work_sync(&tps->wq_poll); + devm_free_irq(tps->dev, client->irq, tps); tps6598x_disconnect(tps, 0); typec_unregister_port(tps->port); usb_role_switch_put(tps->role_sw); + + /* Reset PD controller to remove any applied patch */ + if (device_is_compatible(tps->dev, "ti,tps25750")) + tps6598x_exec_cmd_tmo(tps, "GAID", 0, NULL, 0, NULL, 2000, 0); } static int __maybe_unused tps6598x_suspend(struct device *dev) @@ -948,6 +1194,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 Fri Sep 29 14:30: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: 146690 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp4204667vqu; Fri, 29 Sep 2023 10:45:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEKtVr+T1iBeCxaXyy1qDz9t9/X+C6pi9Hy/hlP10IwCK65hSPbwxIbOrv989WR5MbdSY4F X-Received: by 2002:a05:6870:e313:b0:1b7:2edd:df6d with SMTP id z19-20020a056870e31300b001b72edddf6dmr5525111oad.10.1696009503638; Fri, 29 Sep 2023 10:45:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696009503; cv=none; d=google.com; s=arc-20160816; b=ol4Qmaq/ysDnsHHTRTFpj9cfbQpeQONIeiD1cx9Z0lxSAQqfSrBcRY4HX8S0AMn4wK TrHBVxYBIeHZfV2u0lIDyvDfu37QQ7CypE/ZK7RAWRQyZKoWzQJFW8uSLkQ3uQnx5Hud Hj4Gsmxkl7U5f7DnJnXynSZdJ6SRZEApyEA/Va12PWzv+2YAkJQowyDiYWGR/2er7Ff4 dlpKvd57PNBdjlMbwpiYjViftsUW9IfTOLzL72ppfH/dBUcldS7G8y9KT25/PApUMzoL zyW7v3sB90OA2Co6tgCxYw96qeDWvW5OHo8fadAQZ4vTvJQVg7xVIN1E/qBSciPj/ZIq 8WPg== 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=uBJa+cb8dyEAQp6tCGjW9jEwVET1F9T3nDrDaidKVoA=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=Ktayv9wOltx9nruLS3Mi+VDxOuV5/NOFY55Q4hRQZePryE4VEO3F9sKRhhqaLXdl+c 3FVBHRqz3+c0dnSzkDQgbXhmP4BsxEF7eziuIikSJ2R4MZXC4VnE1hisRbKxJVdsobEv 3IiXe4Vi/6VBeqlxMpeKca1X96piIPPAZoEONf6qY9AzRMZHblEO3HAA0MH745UYG6Sw KPX+qHrOIS4gVIq/F7aqEUY/OUw82EMQ0ENSMeccxxzT2ntOH/ecPG6y1LJbvTeRxryA /tSCIbD8oVVNcgiR0oDlqSHxNmERjmRyn6w01wEFxk0MH29B6zGcotjz2WeNi8nL+lp+ ZOgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=nrv21yMl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id d19-20020a637353000000b00573f9a427d9si1339008pgn.717.2023.09.29.10.45.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 10:45:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=nrv21yMl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 0D02080DF26B; Fri, 29 Sep 2023 07:32:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233526AbjI2Oc1 (ORCPT + 20 others); Fri, 29 Sep 2023 10:32:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233555AbjI2OcM (ORCPT ); Fri, 29 Sep 2023 10:32:12 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C00E1B7; Fri, 29 Sep 2023 07:32:06 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-530fa34ab80so1644689a12.0; Fri, 29 Sep 2023 07:32:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695997924; x=1696602724; 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=uBJa+cb8dyEAQp6tCGjW9jEwVET1F9T3nDrDaidKVoA=; b=nrv21yMlaN1PpwRLtiFYcA4mpXDsfAhOlmzc3IKC5PSawPInz4BvYFEBDtIw0tIQQv B10FSk86/s4J/CAI+ANDTpQZk5AIcVeRq84XGEadDftI59ouwUqNP7YzUWSvc+jNBCAu 80PAwkiog6LGBd+VEa87tI1mLz9jqwyC+QgEuYbTHbAEm2fLQGvJYG4Z19ZM3Gx3nazz 6NeTGJq7Dwcr/8oDxIVmn6OoZkMgLEQu/aI4d88RL50E8KCPNQbB4QsToj8HAROes+Rc UerEUvUbbKMkELjvbdJEacBh4d4ewbo0sCYDK3zm7XzA1LQrcn3k/k4Us5nszokdUpUe IR3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695997924; x=1696602724; 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=uBJa+cb8dyEAQp6tCGjW9jEwVET1F9T3nDrDaidKVoA=; b=VvE2gOmPpB2BOT9BT8uwPbKvwIA0hJ39DJBQAHMT0DqWMPq74ia4e82F4inKtqWNw4 +89QyNCMJwgPDLatnh+48HzK6D9pzDQA/Xe1k6/qeHlSG1uG7nIuCJK6kzQleSPMrsD6 FyxAA6QdWLsNmJpeq8HZ3bpiF5+V9oXIOKv0Z08G78fTm3Lm74Ba7YRK+Vzav1ZAp/Pw eMVAUBfTgM8HQkHqoHrJ70KjjZ6GdQyhwXy6it04Ow43knlWeyJaUFiZU7zO6D9SGvlK Knf3cZ9Y4kitYNEsqBX55kN6bbQGD0LQijSfmqimyLJ/Qhcj4IO3JOGtU8UvuZjG2Sfq RC1Q== X-Gm-Message-State: AOJu0YwSdZOVGctMBGd48XvvXvitDTSI32BAOf7brWB7Np2kzQZ+vKF+ TpQPJyHDjUrSYaP8nElXx4Y= X-Received: by 2002:a17:906:51c6:b0:9b2:b30f:deb with SMTP id v6-20020a17090651c600b009b2b30f0debmr4443817ejk.4.1695997924606; Fri, 29 Sep 2023 07:32:04 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id a7-20020a170906670700b0099293cdbc98sm12660105ejp.145.2023.09.29.07.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 07:32:04 -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 v8 05/14] USB: typec: tps6598x: Check for EEPROM present Date: Fri, 29 Sep 2023 10:30:46 -0400 Message-Id: <20230929143055.31360-6-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230929143055.31360-1-alkuor@gmail.com> References: <20230929143055.31360-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 (snail.vger.email [0.0.0.0]); Fri, 29 Sep 2023 07:32:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778394860934823212 X-GMAIL-MSGID: 1778394860934823212 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 v8: - No changes 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 2e7b9eafaf04..21b0ea2c9627 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 Fri Sep 29 14:30: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: 146711 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp4237299vqu; Fri, 29 Sep 2023 11:44:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH4nrxFOOoNfH6chne6G5pneI0EmzoJzNVEDsG6SQI2ECeuW3L/y/hNzirIFJ41FhJ0o3ET X-Received: by 2002:a05:6a20:9191:b0:14d:6309:fc96 with SMTP id v17-20020a056a20919100b0014d6309fc96mr5429389pzd.4.1696013053401; Fri, 29 Sep 2023 11:44:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696013053; cv=none; d=google.com; s=arc-20160816; b=rlsvT2NUIPk7pJUWwrJByPiFWBOEbuz0/yiSE3Ls6KlmqgfCJ84xorM+zj3Xyrwp7N s4+izueC45jb4qV7oaipZZVt7+PUTzXmJxuRk7DbOQ7OdNgbb1ORl510qGtYTh5Vrrg3 ZpHdc+gIrvKb7dHxaFAgD4gpmFuURV/cmo0NbhWIYSl54IqXYU5yTiPZPLdmKT0ky+TU 9b5Kq9Hq9DZgNraQjCAq3moh4uGkbE6fKBE5eyIUdUxfPVTTZwRiscKETEyp4lD0RXr/ F9jNizfpkJsFFi4LkwvbaNwJ8AfqOXETsCICXcH8KoEOsMyvU6vKO2I/Ug/Z2Tgm4Gpv hDsg== 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=joW/9QyjDlkWvegamdHCGKd/54h9KZHWwQxT23h72Lg=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=ce6DAAnOJq1SDMwrZ/MXOsLYA149oHG0Da+JFA3mZZoEuI9cp804EGFM2MjM/7SebL wC7z9j0xZX9jCnsLwYbfD+/ihHPIDzXqIMKuzVDdl9YFhjElmoj9FwwYZbeULei4es3U hTbSVBQGkfm7pcmlcG22a3GpbTD71BZXnx7ZYh+YQFBUikQ000Ez7rXrljpyiSJBKmvZ rnE3MkSTJ7gw81o6MYA2+30Mby7DQJYBGLRWi0PVOYrlUf9V0kfXD9TKrHmCibCRt5ty VQfUhbEqfJM5I52xaD/+oXEaz7+rQwcd7Lj21XP2ZqZKzhwVsKLzhmSqyDvfdRzY9MLz C0CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YfpXYnbY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id g16-20020a631110000000b00573f7ef60aesi21917215pgl.154.2023.09.29.11.44.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 11:44:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YfpXYnbY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 6F531819D22C; Fri, 29 Sep 2023 07:33:51 -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 S233732AbjI2Ocx (ORCPT + 20 others); Fri, 29 Sep 2023 10:32:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233602AbjI2OcO (ORCPT ); Fri, 29 Sep 2023 10:32:14 -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 86498CCB; Fri, 29 Sep 2023 07:32:08 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-9a645e54806so1851066466b.0; Fri, 29 Sep 2023 07:32:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695997927; x=1696602727; 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=joW/9QyjDlkWvegamdHCGKd/54h9KZHWwQxT23h72Lg=; b=YfpXYnbYjAdDZ1oP95tcnA0Lz2vZlBIWOy3+AuWbqhYSTBmp0452TK8fF90FMpqkK5 dRADwDVE16FRHsaYXrH0ooDTj5a8CAjC6rAeB2cnyfEwGYx9JPtdEZZAvX825kNM5tEs 4u+bd+SSdL1H7rACkOsQKf/lb4nu7TXdvjZFqy297z6tqCi8PWXtLC7/HT4hqT61q5Ky Gu6RtXE4B9JV+pgM7ciDsK4NWDW+hagQLRk1xbq6P4VUzLdWj9/awZq/w9tKfJH6+6gw 48xb9oaG/fe7cjISpbbM8HdU6gdAmHIWsphT7NmriQp3udN0pBuxoFFm6FBoF5rWDSBj EOGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695997927; x=1696602727; 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=joW/9QyjDlkWvegamdHCGKd/54h9KZHWwQxT23h72Lg=; b=TYRUXNwY5GxJjgPpYjLosGDpcyix/7AWfcOCnCxfPxVwAzT9GlyWVuyOId8JWKMuJ/ rC/eT1dQmlOenWlajk95avFhNSlO/aNJGImSO4FpNtbWYBOihX6oCGlaC/dkw9kBcLdn xupEAvJi4qbv+qrJ3bCIfrZN+lmQuYx0696ggIzoSMOu72dn+g1oe7cKFbII9XWXweH6 dzIP89FC24gbczaeLbUOynHgkKHCn5pFuArFPRsXfjlRUaGILa1Y7TdWcFXaGReRE/90 hL/Lj0UI444TiDWCpOpl5cgeDyKpNESzX7gXkPGsaxKf8lq71P6fMBwLIX3I7E+5dYWI w/jA== X-Gm-Message-State: AOJu0YzOgxSlzPZwCvwnFxEBzW05kj4Npb3ascc3JUIM/LDisRoeJHvp UjbRyn3U+nAJZtPaLp2sWbk= X-Received: by 2002:a17:906:454d:b0:9ae:4f64:6db with SMTP id s13-20020a170906454d00b009ae4f6406dbmr3950928ejq.55.1695997926631; Fri, 29 Sep 2023 07:32:06 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id a7-20020a170906670700b0099293cdbc98sm12660105ejp.145.2023.09.29.07.32.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 07:32:06 -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 v8 06/14] USB: typec: tps6598x: Clear dead battery flag Date: Fri, 29 Sep 2023 10:30:47 -0400 Message-Id: <20230929143055.31360-7-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230929143055.31360-1-alkuor@gmail.com> References: <20230929143055.31360-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]); Fri, 29 Sep 2023 07:33:51 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778398583379416003 X-GMAIL-MSGID: 1778398583379416003 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 v8: - No changes 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 21b0ea2c9627..2598433a69cf 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 Fri Sep 29 14:30: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: 146666 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp4149511vqu; Fri, 29 Sep 2023 09:14:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1TCYpAiILKxFXpSDC8SnULvyZCb2W30wMB9BElyCHFPPii/03pUsYikSyyIWpLFafzQvu X-Received: by 2002:a05:6870:eca7:b0:1bf:e522:7133 with SMTP id eo39-20020a056870eca700b001bfe5227133mr5506783oab.38.1696004086695; Fri, 29 Sep 2023 09:14:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696004086; cv=none; d=google.com; s=arc-20160816; b=YADGrtrvuc+72FJjHmKbnt2z1Yn1IDi7mnxfJHHjgRJPGN2aqfgbw7g7wlElc2bWvP QFKITGth6IRTJmwU/sOKN53iWFoMON5vREitqyN+xV1R0ACOplgOjqpZBu1BAA2X8abJ 1a3+l+Ngmwx8IrtoduGNtqE5BtGMtaMcmTb5TLLeKIt0vyL75A0HyFOdLXoF0XG57cZk bDiAceNaZIzQ34iyHwXWWLfUI0EZ6fWS4xhtPDJ16gTE3h5hOyC/9ADSofowzLNVZzrS qgcA8QAKyy7kwwLSoOFVIxcRJumnTfjCTmAZpdYTbxravBTSpDUVbUrYr15pEYmPf1js GRSQ== 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=lUbuI3ctZezGQFs9q+kb+yJaHuWgpsp3o/CvTzIwMrw=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=S5YCQjjoS92owTjessBfyD8AB4fA+nQOf9wd0gUpK3u49/mIiD8csC68e+oNhiHi0a 3XwJgQ28tT5GHaG+E4I/Mt0Mi+0RxFDItZFzdVSjaUlYgNZq15qte4AIYr84loiSlYLx Bvbtacl3HeSLYyESFfHBICJamWivBM61hoGgyR/ZPj3Zx+JsiecgIeSihk/zWaKtg9CT ON93wTmamN6njrGuAtb2+cPUSB7avKFmGX2T7FNsg6ja9uqqXrptjpzw5p7WQa1bnTzo 0g63Bw2HPNi71gAGri4NF9YUyIQWEr7roojdkRw6Ku4iZyv7D4dxc3EBYLH3f1KmrBUZ Ds2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=N2bZPpu9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id a73-20020a63904c000000b005859b1c086fsi2208988pge.532.2023.09.29.09.14.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 09:14:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=N2bZPpu9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id B5ED18311BE4; Fri, 29 Sep 2023 07:33:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233723AbjI2Ocv (ORCPT + 20 others); Fri, 29 Sep 2023 10:32:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233527AbjI2OcP (ORCPT ); Fri, 29 Sep 2023 10:32:15 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3948FCD0; Fri, 29 Sep 2023 07:32:10 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-9ae2cc4d17eso1916950666b.1; Fri, 29 Sep 2023 07:32:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695997928; x=1696602728; 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=lUbuI3ctZezGQFs9q+kb+yJaHuWgpsp3o/CvTzIwMrw=; b=N2bZPpu9a2XMFDBI30fcTHanBfPSyB3ToqqR62vLEiVf8kb0P7ZCMIeMEEB/+clFTz BhrXRVlDrs1r/CRGuAT4wGdB4VFiKf1t/1eufLNT0EtDU77ZpLoHBY2OMJAE3TL73VlY AMOMMjCeaZRttM0g44BtpwyWBldCiGozlrh85vzwOeKepnQ1s1SXUo6+j0TbmkOik1ic CDKvUqTsYz+8S5SgBYJevg09pInJdfV4F9uS2MyUSRjluzAz7rrj54NdE/5rcBQEqkie YSwrnB8HRaL7JUdHkqsc/Q60ZB020Pv1C1QciwQuLcDFfWEUSZ9nX2oZvhz5Z7t+fs0x yq9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695997928; x=1696602728; 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=lUbuI3ctZezGQFs9q+kb+yJaHuWgpsp3o/CvTzIwMrw=; b=vIEx4eMODIiJmBa8nvxFCnsJ8lP/PCm3cOcFUsnuAGxs+h+snwRJJzXN1iA+ztoC+I 45bOZhT0wOT/VlAkSNG8/N3eSVHvmhQatOXTRD8W7ek0DF+CX0Q5fgVWEDmPikb93BZ4 XkH9k8bTdvDk0ImdqIHv3+BMHZUOkqFoRmCINZ4CuGnSMbmjntLkF9OynDzS5MDw2Bc7 kr3Gx0Se+VLHK4N5IbFUPlCYFq8wfTOR1aTZMhJ4agUx/uissAEpU1/AYMZybxfogAeF 7E6JbTljAlTujK+jpnt/isEBfXid61cMzEmarOnGNTVK5vXDu3g+3QDS2tdoNqTIglmz 9vdg== X-Gm-Message-State: AOJu0YyAnqEKyix5df/uJE3fzj6a1bqCVfdRieTbk9OyW2KxxDp+DDwm ovLNIXppu4Kv78pGTvm3UJY= X-Received: by 2002:a17:906:a00f:b0:9b2:c2a9:357a with SMTP id p15-20020a170906a00f00b009b2c2a9357amr3980429ejy.68.1695997928566; Fri, 29 Sep 2023 07:32:08 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id a7-20020a170906670700b0099293cdbc98sm12660105ejp.145.2023.09.29.07.32.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 07:32:08 -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 v8 07/14] USB: typec: tps6598x: Apply patch again after power resume Date: Fri, 29 Sep 2023 10:30:48 -0400 Message-Id: <20230929143055.31360-8-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230929143055.31360-1-alkuor@gmail.com> References: <20230929143055.31360-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 (snail.vger.email [0.0.0.0]); Fri, 29 Sep 2023 07:33:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778389181025914277 X-GMAIL-MSGID: 1778389181025914277 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 v8: - Use device_is_compatible instead of of_device_is_compatible 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 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 2598433a69cf..32e42798688f 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -1203,6 +1203,17 @@ static int __maybe_unused tps6598x_resume(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct tps6598x *tps = i2c_get_clientdata(client); + int ret; + + ret = tps6598x_check_mode(tps); + if (ret < 0) + return ret; + + if (device_is_compatible(tps->dev, "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 Fri Sep 29 14:30:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 146677 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp4175484vqu; Fri, 29 Sep 2023 09:56:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH9JMmf0c9p8EM31HF4FEs85/IyYbCFlfXwF/rXQxeWISXi40XoKjjPILpdUVMzuRG+CRFH X-Received: by 2002:a17:90b:3b88:b0:274:116b:8f84 with SMTP id pc8-20020a17090b3b8800b00274116b8f84mr4851238pjb.34.1696006566190; Fri, 29 Sep 2023 09:56:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696006566; cv=none; d=google.com; s=arc-20160816; b=BbgzjUplmVIQSpo4lERet2XzPt4q8OYxxSkl2PhknA8iULi1dp0DgFKQNCBlFygRiX JkFw7g0uJHGGpvGJgEXuqqeNOJG4s7/5JGY4WZxNdUqsiuVNL6+s/N/clduhMPvgJLEB fTJVYgQvSp3ofmGdAvrDVF9ChY3+ShiOwBO9u5X3heSICqJMFhyfjIY5X2/CqHfhX8P6 uBmXrkBDD9y5/SqNNspFKbZ4EfKqH1TNYkuGmH6W6FpmgmzewDEzjxjqNAra7sFgLyLY IDaqetnd4GU8pt9cB7N6Dz5xFnSwIT22P2k9j1a/XI/MuSStRYfta82aP/Rwz8GMazNC m+Ow== 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=S6cndaHgXnb2S15BU3PnP0VkZgs3jUstsWRylsqE55Y=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=YXY3ciNRJNWUNHMDNY9gbUXcDCAr0VmrBV55A9ZFbb2Nh/Yo4FperLiXzEtR7YBGKA BG4kbhHuVL4mHt4M83R2pg9bkeQeiQdbd22neb01/OH+3jWyXBc+un928uOBz+4hll6O LjX2xM37Usvop1pJ8T0Y/fS3JHaZABfW0KZXKHXAH7ng6479ajEkGZ1VnYUGajgUTOMW IPhU/7jIzQQ6KwfOr0L6AIRQzhFl4pkrI7Ca/Qtb1Ayb9PmzOaZE6KuYJzTsMdk5FE5n qzJQ1Z53CRXzFlNiyn5N76HefNgV6yTiVoTyzNY5kArlH+JqeIYmI8/VzbJD1CYYFXIv 4m5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="gb/eaqJx"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id s6-20020a17090a6e4600b002777ccd05bcsi1901443pjm.25.2023.09.29.09.56.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 09:56:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="gb/eaqJx"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 9E17E82A9B95; Fri, 29 Sep 2023 07:35:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233664AbjI2Oce (ORCPT + 20 others); Fri, 29 Sep 2023 10:32:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233533AbjI2OcR (ORCPT ); Fri, 29 Sep 2023 10:32:17 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43167CDE; Fri, 29 Sep 2023 07:32:12 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-9ae2cc4d17eso1916958166b.1; Fri, 29 Sep 2023 07:32:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695997930; x=1696602730; 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=S6cndaHgXnb2S15BU3PnP0VkZgs3jUstsWRylsqE55Y=; b=gb/eaqJxf1i8qOi3rEB/hJ3f8t7J14QFJM7KjaicLnqbLwZyEYzny2tYt+vjD8aYuI bSO2s55ggbAzcsH/LPSrcTuRFUCHWKOqEyPpBzTKENG9SsBERlIXRyaKczXtuutfA9TR pqcd0fhH97hbcKWUbMrzMi0ej+p+6yxcNQjZztVwOfm4DDpOzFjMgbHoSd/mL3531M0F x23mtcvZcXPiZASzwlLGG1vAhKEdTQbGMBv7z8IgZLvvseEBfJvBUfLojTAHrK1+Bxcc KtmqxSudSJ3DloUuCHnRpDPw52FKovb/iq6CkIU8VE+XV0KbdMurVgpr1uhX2kcPDYaA qzXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695997930; x=1696602730; 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=S6cndaHgXnb2S15BU3PnP0VkZgs3jUstsWRylsqE55Y=; b=p/3LiZihfuM+iVM5KZoFGN/BlGs92l7LnS3ql7WGoWYqIP5IXKqSO1S8OF3JDxqFnK utkDWD2VpXoRvLb6cZqXrOExNlBhN/rjSKObD3TRnq0/FvmbArFBk0ZvBJhrMN6g2gDi vYul8vGCMEHKo0aU7moy7si8FSBU76ntJ2Sw15w2N5Vqn+H4C2Cpw5jgApq45k1seXux l4gyV4ahy696AXNpD6sttjnSGPLWcJ9e1KASS0i2kUaebIZMPz9cKx1Oey1imfB2bDLD F1ZowS/nfUo4T3VbF/KlzN07e7offvU08fvF3HggXZ2pb/n40W4f+L1D1WF7K+O7qApj yIIg== X-Gm-Message-State: AOJu0YwKoPb+sgphcYalbF24o3xsfg0tMHuov5HznK+CMuKuYmWN9ih7 E03T+m0EzHGOhPiqP3RH3yI= X-Received: by 2002:a17:906:319b:b0:99d:e617:abeb with SMTP id 27-20020a170906319b00b0099de617abebmr3885669ejy.23.1695997930537; Fri, 29 Sep 2023 07:32:10 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id a7-20020a170906670700b0099293cdbc98sm12660105ejp.145.2023.09.29.07.32.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 07:32:10 -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 v8 08/14] USB: typec: tps6598x: Add interrupt support for TPS25750 Date: Fri, 29 Sep 2023 10:30:49 -0400 Message-Id: <20230929143055.31360-9-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230929143055.31360-1-alkuor@gmail.com> References: <20230929143055.31360-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 pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 29 Sep 2023 07:35:29 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778391780993057679 X-GMAIL-MSGID: 1778391780993057679 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 - Add device data to of_device_id Signed-off-by: Abdel Alkuor --- Changes in v8: - Populate of_device_id with device data - Change tps->cb to tps->data - Assign matched data to tps data 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 | 109 +++++++++++++++++++++++++++++----- 1 file changed, 95 insertions(+), 14 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 32e42798688f..9dc4c3ae5c60 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "tps6598x.h" #include "trace.h" @@ -101,6 +102,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 +123,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; + + const struct tipd_data *data; }; static enum power_supply_property tps6598x_psy_props[] = { @@ -545,6 +552,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 +665,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->data->irq_handler(0, tps); queue_delayed_work(system_power_efficient_wq, &tps->wq_poll, msecs_to_jiffies(POLL_INTERVAL)); } @@ -967,13 +1032,33 @@ 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 const struct of_device_id tps6598x_of_match[] = { + { .compatible = "ti,tps6598x", &tps6598x_data}, + { .compatible = "apple,cd321x", &cd321x_data}, + { .compatible = "ti,tps25750", &tps25750_data}, + {} +}; +MODULE_DEVICE_TABLE(of, tps6598x_of_match); + static int tps6598x_probe(struct i2c_client *client) { - irq_handler_t irq_handler = tps6598x_interrupt; struct device_node *np = client->dev.of_node; struct typec_capability typec_cap = { }; struct tps6598x *tps; struct fwnode_handle *fwnode; + const struct of_device_id *match; u32 status; u32 conf; u32 vid; @@ -1017,7 +1102,6 @@ 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; } else { /* Enable power status, data status and plug event interrupts */ mask1 = TPS_REG_INT_POWER_STATUS_UPDATE | @@ -1025,7 +1109,12 @@ static int tps6598x_probe(struct i2c_client *client) TPS_REG_INT_PLUG_EVENT; } - tps->irq_handler = irq_handler; + match = of_match_device(tps6598x_of_match, tps->dev); + if (!match) + return -EINVAL; + + tps->data = match->data; + /* Make sure the controller has application firmware running */ ret = tps6598x_check_mode(tps); if (ret < 0) @@ -1125,7 +1214,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->data->irq_handler, IRQF_SHARED | IRQF_ONESHOT, dev_name(&client->dev), tps); } else { @@ -1231,14 +1320,6 @@ static const struct dev_pm_ops tps6598x_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(tps6598x_suspend, tps6598x_resume) }; -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); - static const struct i2c_device_id tps6598x_id[] = { { "tps6598x" }, { } From patchwork Fri Sep 29 14:30:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 146714 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp4240360vqu; Fri, 29 Sep 2023 11:50:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHGKPqdDlux2BWNukZ3Vm1tpBOVVSoIn5S1ORCzO8EKBeJyuej1uPqzlNm7W2NZjr/dUnkG X-Received: by 2002:a17:902:bd94:b0:1c4:2271:55c3 with SMTP id q20-20020a170902bd9400b001c4227155c3mr4890924pls.38.1696013440714; Fri, 29 Sep 2023 11:50:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696013440; cv=none; d=google.com; s=arc-20160816; b=zbEliJgXv3Yt9DNLvYB74oAFGuznIpM3sNxQO1p6m4nKr9u2mRUZ5Z1No5PklSj2km EVRQEQw1fpnTYpxyutku/mCS4SYLEQeDgiE18mvoLuNJWJIXjbtnBx7v7N6isaL1WgcP kFez3htzgHk39aiUR3YOyOP/cl3+znk0O72tch10T9N4jlK4pf5YW/767KmoxRmV+Fh4 nyNTVFDVZp5ONKp04Sycv+neNhnZB3tgtihK14EvUldSB7is4QQafMKVedafsaV83o4g f6CN6K6i0IFcdXI608+iA4w8mKIcfK6BSt5ZtzvlbS/W5jpnVQLc0IN091UNUR8fSJ5z cKDw== 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=SHnX5ViB2blcrR3noBsF7rZaPABwO4T0sI7Bvq4+gXM=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=Oyj5DhB8eIM167q+CPnmc9zNRSpMxrFKmsLM+Eu/tz28RJCOKF9+USsUIePZG1blRe Gi/5Q7POe8NcQ/UcvE7lixK3nhTUBP2MRC2BZeGlUq7hVXMYkY3V2+gNdIA18LgR/67a LPrRaTX5HqSE5/eMCVzOHHfbcRGNW6Vb2yf8o24ryNQzf1PsWBEa/0egXoIRJq36Td0J YQ2g7Tn0Vu7DVznXmm0dQEECnLe8enOYSyr6TzIujLXtWAD1jAWBzwwLuExlGzlg0Ere JIq40J9/cSZ7l6emrfT1Rgq/bedyPC0R/T9v6nRG64DzIVwHVvfpr0o0sysbnpDce8zz JGEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=dDjk+43P; 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 u17-20020a170902e5d100b001c60ec1e654si17170117plf.416.2023.09.29.11.50.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 11:50:40 -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=dDjk+43P; 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 52E9580A44DF; Fri, 29 Sep 2023 07:32:50 -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 S233648AbjI2Oci (ORCPT + 20 others); Fri, 29 Sep 2023 10:32:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233608AbjI2OcS (ORCPT ); Fri, 29 Sep 2023 10:32:18 -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 2CA27CE6; Fri, 29 Sep 2023 07:32:14 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-532c81b9adbso18449270a12.1; Fri, 29 Sep 2023 07:32:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695997932; x=1696602732; 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=SHnX5ViB2blcrR3noBsF7rZaPABwO4T0sI7Bvq4+gXM=; b=dDjk+43PhwSt4prA8hdqTOd6fExstgLu8BAJZyvfQd+hBcjzz8bnqQDD7ZwlT3mc95 LoR8//oOR3gePKotMWZ445a/yfFhvYANUb56ZdPd7KTqMSX081aNHjtKNz2S8JiO+nlg T7GI4ekY56CyGaJFDF0cfKyQHGXtTzQiEt46IKU8HyBXIBwUcrQ55HbLPlg9dJc2z7NJ 1rLbsGFg7LCLFKe9bvYoglGUADmsELg34j4X1PAgHQPAlkS5I8s7ibdqOMm9LNFzodKv 5bpM8hx2ikmALS1uyre9YffjE6ncfE0Tr78gA9auGQ5BALCGe3PJvWpMIUrrg3Nb4AeV W8lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695997932; x=1696602732; 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=SHnX5ViB2blcrR3noBsF7rZaPABwO4T0sI7Bvq4+gXM=; b=ieDKjowFQ+Ouxv1WwjPIyVd/krQwNIevmNHK8NWVZduFZ8KtV4d3r4wiJ0sSQrIEpf zMgYnF85E+CFqq7U9UCttSZ/n4nfXQoiT1XZDdmO1C8N1Q9GGQqgiAkLotHbbYGZha1n hmiSNvpHW2ydO0xyBXaVpeW3gAp6jcSTj4cFDiYU1/vpHMuHHJqKZD7MEDC7oVQqVdyq PtEwqKMbR6r2YUbKGjjfn9ZTIa5o0/CLiIyjyssiprXn+na2+NQFDnZyhr0RqEfb2FqE mz8L+KU3J9wr2tzbBtg1vhUeYDDqvOu4GNQ/+U+wd5l4lyL4p7yldK/Ynfu9+689JYic kIew== X-Gm-Message-State: AOJu0YwyR5PskRa2hsMz/prk1FlLIByn+NglzI/xpHR4tHz9OVa8JdJ0 EfldjCfDiQ5THW8YcS/TYhU= X-Received: by 2002:a17:906:225c:b0:9a1:cfd5:1f3a with SMTP id 28-20020a170906225c00b009a1cfd51f3amr4539743ejr.13.1695997932433; Fri, 29 Sep 2023 07:32:12 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id a7-20020a170906670700b0099293cdbc98sm12660105ejp.145.2023.09.29.07.32.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 07:32:12 -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 v8 09/14] USB: typec: tps6598x: Refactor tps6598x port registration Date: Fri, 29 Sep 2023 10:30:50 -0400 Message-Id: <20230929143055.31360-10-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230929143055.31360-1-alkuor@gmail.com> References: <20230929143055.31360-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]); Fri, 29 Sep 2023 07:32:50 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778398989582318326 X-GMAIL-MSGID: 1778398989582318326 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 v8: - No changes 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 9dc4c3ae5c60..580680986f66 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -1032,6 +1032,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, }; @@ -1055,12 +1107,10 @@ MODULE_DEVICE_TABLE(of, tps6598x_of_match); 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; const struct of_device_id *match; u32 status; - u32 conf; u32 vid; int ret; u64 mask1; @@ -1135,10 +1185,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. @@ -1156,50 +1202,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 Fri Sep 29 14:30:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 146632 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp4117711vqu; Fri, 29 Sep 2023 08:28:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGR3mcocLDVLUYrtnRA5eaZtl3k4FJcKMby49Ic8UfFOMk0KVksKaWgZ5YTIHNm3BZgSq5P X-Received: by 2002:a05:6808:493:b0:3ab:7adb:7b35 with SMTP id z19-20020a056808049300b003ab7adb7b35mr4470205oid.50.1696001312563; Fri, 29 Sep 2023 08:28:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696001312; cv=none; d=google.com; s=arc-20160816; b=KekNFfRCDMz9O+kM4ML0xTkr1G4PIAtQ16ZXTB2Mn0c7zavpGGnutDiBO5BWAZtRKw FEQvfqy+K9d74vhFqnqJyGkH+uXwPLDutRAR5K1kx3vyk8RU/VWjgm0GRvuFgL4Vw7yA BaYscdZeOkfm8g9qR9ZDidf6yS9RbMr10pUHy31HFatShRQdNVJdmfXUobPT1PC9vC4X 0ZC/jDccPFej+ckF2y0Gf3BVmdnEVYWmAYQxnU9N/L4ywddgFTGQTFlZxE4fSPfwwfVI YvWTxIoz0Og+AS5PM38UK0lOdiM+cOvDRFyKUPgmoKfIE/0qgCLYO4ogVrewVp3bHdRE GoHQ== 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=UTbK6qkYutHvyFXWyfDTAiatmpQU1PAd9FUpYTZg5YI=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=gI8Z58iamKUq53f1OJ8+BSDmVRNMMMeyb0fZlg98mOksLOmrk/B0SBnKTU/9a+gsPA ksXPyv2UxEmTSdRFzUxBwKCSJq3ieQA2fkKBE5wTxz2AmXSD0r6/3Ylf+dmRtxXsz1jP VW9jYm6XXiVBZtLt66UVjNBfDKFTeu3nbaDvTDEHXz6BZ/m3mnGnL/qoQcVGCSSEG/h+ 8NIYQQVHgoGZdt/i4YqYN+vOEMvqji51uHjBnNEtO11PBBw8IQm+oufLk/QLQmvouWZR KljbpIL8Hk9X/EfubexFWCome22VeLZYG9Jcmy7P1BnT5S7zJkjPiAV+/+4m6tpA7zvS nd9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=BrZD3Dnd; 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 d4-20020a655884000000b0056534e3aeeasi21059227pgu.474.2023.09.29.08.28.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 08:28:32 -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=BrZD3Dnd; 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 5E8278043D18; Fri, 29 Sep 2023 07:33:08 -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 S233598AbjI2Ocr (ORCPT + 20 others); Fri, 29 Sep 2023 10:32:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233631AbjI2OcU (ORCPT ); Fri, 29 Sep 2023 10:32:20 -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 2CB09CF5; Fri, 29 Sep 2023 07:32:16 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-9b2a3fd5764so944989966b.3; Fri, 29 Sep 2023 07:32:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695997934; x=1696602734; 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=UTbK6qkYutHvyFXWyfDTAiatmpQU1PAd9FUpYTZg5YI=; b=BrZD3Dnda2F8jjxRxst95DX2myvUGzLebpKUUPnXLpNdpcV9sfDgrsKkM13v5LbQ+m tXI8627AhaXaNhqzVke1CnJOCR9AANcXQdIRF2R6foohkudm+TNEKW9EY17tnexrvXnM mGnbtpClmc3pW+NFU6QY3xBl1cB3AqjyibDuBxg6y4s/IbiU9G2HBwKh7bf38Dnu/2Hg k+srCKX6akoA3gIde9FRE7uvE6cydJzqcv6lHljJTixhxIztzKfGOPGtqbqRcCvB4OL6 dl7vgCifcxlnYh9Oea2wMb/EQ9hUeswdVF9oFHcCGD7zs9oLe2uELX1HM6hsHv56Iiyf DPpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695997934; x=1696602734; 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=UTbK6qkYutHvyFXWyfDTAiatmpQU1PAd9FUpYTZg5YI=; b=CIEZhJzY8l/UkLsc5L5E+QCq3CWdtNpl+aJ4yzuizr6tClI32swyoN/XdF3IXMtX+b TuS6AKTIwuc6xruqHFsCXQ0kYnRB2rmXxzgQXFQvCeHlfuBWSuKQh8zRmbB8pZUhE+qe 761q58I2cM1pJmHoy8tyXHDrJJmZ2Ds7pets7ivnkvAVcq/LPE51G06v43HWUEw9tZe4 k36KVAqbOD/IkcteVoFXjHQNpeZeSmwNTxk1ed4HYniLrsGIlxOxa+X5uyc8xKmAuP1D uoPdM2YfJAyiO4hXMefuNObWmoXJY+aiwWI3PVm1w+o8NrDaaY117aA6u6NQzwm2eFqc CANw== X-Gm-Message-State: AOJu0YyFZVXroN3QMSW2sewDkDj7m8OSN5KUmG3bPQsN23yHFBrLM5IM x3HHMCCgyenhXVokXiJVY7SNadBg2oQtp/saK7o= X-Received: by 2002:a17:906:224c:b0:9b2:93c1:72dd with SMTP id 12-20020a170906224c00b009b293c172ddmr4402324ejr.36.1695997934318; Fri, 29 Sep 2023 07:32:14 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id a7-20020a170906670700b0099293cdbc98sm12660105ejp.145.2023.09.29.07.32.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 07:32:14 -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 v8 10/14] USB: typec: tps6598x: Add port registration for tps25750 Date: Fri, 29 Sep 2023 10:30:51 -0400 Message-Id: <20230929143055.31360-11-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230929143055.31360-1-alkuor@gmail.com> References: <20230929143055.31360-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]); Fri, 29 Sep 2023 07:33:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778386272234944429 X-GMAIL-MSGID: 1778386272234944429 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 v8: - Change tps->cb to tps->data 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 580680986f66..dd2ecbea8031 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -40,6 +40,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 @@ -102,8 +103,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 { @@ -208,6 +212,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)); @@ -1084,16 +1093,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 const struct of_device_id tps6598x_of_match[] = { @@ -1206,7 +1272,7 @@ static int tps6598x_probe(struct i2c_client *client) if (ret) goto err_role_put; - ret = tps6598x_register_port(tps, fwnode); + ret = tps->data->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 Fri Sep 29 14:30:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 146669 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp4156865vqu; Fri, 29 Sep 2023 09:25:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHdv+17jVYvg5UJAhsnFPNqkkY7uzpnu1WG2iPj3guXbcJvcjdZAbR1vn/UOf5BP3Pntf3w X-Received: by 2002:a17:903:25c2:b0:1c5:76b6:d4f7 with SMTP id jc2-20020a17090325c200b001c576b6d4f7mr3555863plb.36.1696004741218; Fri, 29 Sep 2023 09:25:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696004741; cv=none; d=google.com; s=arc-20160816; b=IeakHS6HbTl4u2uFGICuLxZmaCu8DKrqjLx5TUTE0gOrSFwkVHgj8UaD3a/Xoozvyi 3cUoss6expfuLJ/9fz9sYhi7lUHVzKR84qjoZ5uwgk6aDdRvFze3SVW1r3IR3lbJK6r7 g3c0lwubSxqRQ7BLXT6ucXJt89JNI7C+6QFQwNRs8UDbaAoecTE9mwfOqgqmYV3JypF9 VGUvZBxUb+/JJvm/pir9/Uzo/DolEG0k2EjuRiIkyfrSHh+TaLYquXk613L56GWCecaq u1N0fScL32qC8zPLWuKVlRaPB2SgA0IW47Bh0RGl8D4l8+IWuZffCTtxcNyOSudbOmm0 6rsg== 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=RAp+55201wmFdbMkBq6EDZPiYVA++xP36p4l1BsD1I0=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=zbJRhrCxs2vT4/prgJiyApoP1vDbKpn8Y1AbpPLSMpGbcPuH42F2thEeec417GF6h2 6KzpqVLeqyIR++lOumbPZCr/tMxuSIHnGVlxFr/RhDgiNny8wSUnWdkzz4qp5oWZdz83 PNZPDDHRgeDOQdh8fdZaH5IvX0lmEPnJ8iW6tBQAV8WnGvbcHT2k7yP6z7eZu/fWoVlK FsUuF9MZNUqq7YGKyXe1xOQFFUJWeTEHhcAUM9O/WnVKZ24TbnUxA5e4P7az1MU6HcAs 2UQ7UBb8M0zYkTgVk9x+qOm2RzAsa18PpZdRTytAYIJokI8X3qtecOek5r8d0PDp+5Wo zVew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=j0D3gFJM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id d10-20020a170902654a00b001b8af83d939si20880204pln.537.2023.09.29.09.25.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 09:25:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=j0D3gFJM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 7E383802375A; Fri, 29 Sep 2023 07:33:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233718AbjI2Oct (ORCPT + 20 others); Fri, 29 Sep 2023 10:32:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233657AbjI2OcY (ORCPT ); Fri, 29 Sep 2023 10:32:24 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB80710D7; Fri, 29 Sep 2023 07:32:17 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-9a9cd066db5so1980664066b.0; Fri, 29 Sep 2023 07:32:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695997936; x=1696602736; 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=RAp+55201wmFdbMkBq6EDZPiYVA++xP36p4l1BsD1I0=; b=j0D3gFJMwrx3TBoOdUeWS3AzBxoxCMVb3Gc4ous9WQXmeQfBqSsXl7/8j2mnLguO/v ZM28DvVCKQ2ecEju/6k/IZGiy13jqD9Qq1eo+KnBWKC5hrnyC+A4olYCdeS5VCut33DM J1SSfKjgWQ13ptcNI+xnoHIyLK9FeRgsK3Z1ZfQSKwmTszYj8axZ7OjGOXYZIa98QAPz UpaAX8eS5ePzAAHL6rcKXKAYCU1gDz1hwvnkMMcdZvdWagG8bpxrD2LBOolUAizPslyN /pZPxypzHoyUVR/P48AQ44pOIUGLYlOavjiphdO5rWLnMcgFWVEvpoXKOdAp3KLyKoYH Rzuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695997936; x=1696602736; 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=RAp+55201wmFdbMkBq6EDZPiYVA++xP36p4l1BsD1I0=; b=kiTb2TZ4NQ6XNq9j0gvMLL87tNaMt1/5FWkLoLzsVn6HmxHx0NratbX1wFiilwVI3T wH8BZN+5infi9CTH+YF/gkHk74usSQLFw/QcLEERPVDU6OhUvYDUoM/tQTA7PyjgGWKt 1zVGqd82DvQ+HG05FTaryQBGyvHvwD+pC8BqMsWdWVkIrVkM/EHuWMiRXxnYnMbyEmUM w1rtYKVmNXEl6SDEBIEh5F5iivR31fCWAFNljB2jHgyF/LKhhRbYMxS3KDKBTGqgJCN1 gRlYlchOIsZrhG0JtZDBCaIgUiYK/GNfsMsZ/9l9ZWYk/FhSOGRs3Gp9xQjUzPV28WIW yjmQ== X-Gm-Message-State: AOJu0YwfM2yrKJ/ReCJNLSH29fHxUIMEGRwbhXoIufCZVOsL2Z6MkKkq 4EJZtD8gChbktHGJf2nBnQU= X-Received: by 2002:a17:906:32cb:b0:9aa:e07:d421 with SMTP id k11-20020a17090632cb00b009aa0e07d421mr3750670ejk.43.1695997936147; Fri, 29 Sep 2023 07:32:16 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id a7-20020a170906670700b0099293cdbc98sm12660105ejp.145.2023.09.29.07.32.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 07:32:15 -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 v8 11/14] USB: typec: tps6598x: Enable sleep mode for tps25750 Date: Fri, 29 Sep 2023 10:30:52 -0400 Message-Id: <20230929143055.31360-12-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230929143055.31360-1-alkuor@gmail.com> References: <20230929143055.31360-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 pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 29 Sep 2023 07:33:28 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778389867631156656 X-GMAIL-MSGID: 1778389867631156656 From: Abdel Alkuor Allow controller to enter sleep mode after the device is idle for sleep time. Signed-off-by: Abdel Alkuor --- Changes in v8: - No changes 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 dd2ecbea8031..0955ee214eb0 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -43,6 +43,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) @@ -1041,6 +1042,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) { @@ -1237,7 +1256,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; } @@ -1374,7 +1393,7 @@ static int __maybe_unused tps6598x_resume(struct device *dev) return ret; if (device_is_compatible(tps->dev, "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 Fri Sep 29 14:30:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 146724 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp4246872vqu; Fri, 29 Sep 2023 12:02:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IElr/+t42rtgRD175DMGwx+IWAQ6wvc7Zh1PDUE3lmzyaCsIlcCiWReBFhFBlIAgyREfzQ5 X-Received: by 2002:a17:902:e992:b0:1c3:b1d8:41b7 with SMTP id f18-20020a170902e99200b001c3b1d841b7mr4382323plb.7.1696014160965; Fri, 29 Sep 2023 12:02:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696014160; cv=none; d=google.com; s=arc-20160816; b=gxhjDOGjJY0T+GcR9yodvBBicdEkRUHv1tn6VcRP2Hcn4oYxHQtOFXVOkTUNAIcmj+ yH0RDSBq5qH5KP3Smhv7O8MWSdI4+lUBb/YL9BGYlaSsA6DHspJkECPmBU6INuFhFlsw FjBXlGwgfLWh8K1f3H9FsFdbXzfnWDdR1BhqewHi8xWtG63UC6wPJAtXEV8SmhwWCa6J mhXcmfeYMGvMdhpHrCuEsaVUtXlefScOlhD69moYF19Lp6FO0aPjbuAJF954Zizq1nZa bIyCiSh+0zAUCGSzrvHazRHyeAkQi9U5A6amzQwnEtJYY4xitURC+gg6SXSmZ7yfEUyk UKbQ== 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=rZqo0QnMnwdkE02SOtYyzKU82ptFvmGy4+S5Awxqt5k=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=xEHOsw6FBQdNPiqcc+hnvnwcPlL1mhEQ7sNjYrrVSpa1xodqCVTOHMeZNQYEmA4cAd Q/Sj+OZxbvY4nIYXm51qwEVW2IqBjedX5onpCuD9+pPkp5Sk/rtInKd78oq/U/LcbtZj kExqTmDrkkMsqxChgjHhL4pIaGmjI2g8SqmryRmKyGjriT62Ibx+8FrPjRyHxMKZczdM r25WmxF3CJgiPOvqHRvmxvfrdb7UjFgf/ednOSTYNNBXdVorUbNvlwlO4C+ReEENjtfx W1JnEnBMMqLyyoqFKgRhKfDa8nOf97a2dr9lFGH8iA1B1ArDQSFDCyqt4xnAcPWwpxGp U+9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=doq8e3a+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id i1-20020a170902c94100b001ab089f7329si10615187pla.73.2023.09.29.12.02.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 12:02:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=doq8e3a+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 619D3831EDBA; Fri, 29 Sep 2023 07:33:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233708AbjI2Oc4 (ORCPT + 20 others); Fri, 29 Sep 2023 10:32:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233444AbjI2OcZ (ORCPT ); Fri, 29 Sep 2023 10:32:25 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBD3F10EA; Fri, 29 Sep 2023 07:32:19 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-9a9cd066db5so1980668166b.0; Fri, 29 Sep 2023 07:32:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695997938; x=1696602738; 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=rZqo0QnMnwdkE02SOtYyzKU82ptFvmGy4+S5Awxqt5k=; b=doq8e3a+mFtthrHpSNrMxzm9dsf0BJXXApRFy9dZqlKfi12eyDqa59IGlRxXsFG5VA 79oyrVkMiIrSLXnUvVmbo066cryXVmJsP9X+0FoxDY28pTfRbUU5eHNpWYAAZIGTbUkD 7ERTjk5aEvvnhV0yud54etcO+kbnZ/78VNJnn03t95kDfE0JtyMmvXV1G6V2BxEfAe35 RDIF/KKtjVNJGhahz4/X3YpMdtB4rnWgZFPKotdxnuj1Oarfjt+sx//Uc4Jo3JRAsMcz 6FG1Nopvl8MCo17li5lvbrRBbqoX4xIuk7Z8quawOhU5dCirWdcBfQliZOUTp689irar fh9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695997938; x=1696602738; 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=rZqo0QnMnwdkE02SOtYyzKU82ptFvmGy4+S5Awxqt5k=; b=f9uZTL5s7lvMvdHkP5TZTo3NqLu2h16GHXsm8b/MreGgiNIpod7T2S4g/ZBC+8wR/P uE/+G5HzY9qBNX9zbAHSdrD4gB0EcmfKoejbl4sot70a6Ci96MzeBwXHmnI2zCOiJc01 dRUFtHwzGX+YHyr6hNNaOfubeiGjv0MfOcrvCMm4eR7p1FDS5F2r0PVA/GzXVl0o17Q6 mou2ffqbTEk2fE28Jhn03oNd7myNokqFoM6K9wOJeZXi/xzJe0RrT+kiujY39xwGxjQ/ nEEDWaMvOfywB63N2ZayPHgf0C6HRL/hF7o32bmWFGWVuRYUu6Z9XUI0Ja7exJUXVF4J KxHg== X-Gm-Message-State: AOJu0Ywk6cEyZiFhSiVCpJ0SBPzIy7Zd66MOZ5QMppOLl7We9XVBNBcT YvODkaubhnYwIQvxrentSuxeOPXwZGquG+YcMa0= X-Received: by 2002:a17:906:104e:b0:9ad:ef08:1f32 with SMTP id j14-20020a170906104e00b009adef081f32mr4600317ejj.37.1695997937923; Fri, 29 Sep 2023 07:32:17 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id a7-20020a170906670700b0099293cdbc98sm12660105ejp.145.2023.09.29.07.32.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 07:32:17 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, 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 v8 12/14] USB: typec: tps6598x: Add trace for tps25750 irq Date: Fri, 29 Sep 2023 10:30:53 -0400 Message-Id: <20230929143055.31360-13-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230929143055.31360-1-alkuor@gmail.com> References: <20230929143055.31360-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_BLOCKED,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Fri, 29 Sep 2023 07:33:10 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778399744985164495 X-GMAIL-MSGID: 1778399744985164495 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 v8: - No changes 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 0955ee214eb0..9df8da8f5d4b 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -583,6 +583,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 Fri Sep 29 14:30:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 148939 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp438566vqb; Thu, 5 Oct 2023 10:03:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGGZ1mktACE4lG7SLWIJqr2cwGK2iNJKrbkZzt77fwGWpEZ4fsdCrFlFQr7anf0/YQk8O3J X-Received: by 2002:a17:903:11d2:b0:1c7:2697:ec0a with SMTP id q18-20020a17090311d200b001c72697ec0amr6040171plh.30.1696525412976; Thu, 05 Oct 2023 10:03:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696525412; cv=none; d=google.com; s=arc-20160816; b=MQnDIZ5X2BnCcUbdAu+4zm9s6bZpHXV+oLd+iP9onAbFFpCAnGkr3BPeZnE8LlLHW9 M41hOVF17qp4ZdQVjuRbRupF7DHOat8El+5U8fm87mE6p2fz4dB/uE4PU8h25lm8FxHL DwHIFQ56WqtyEBR5QKeu/IeYPjT0fOebWYUxZxnS7UXaSE+6K0cgXK6rMo0RZTwt1fzx R9QzDk9WEeoCWkl75F44s4wql/XmSezapyhSpij4UG2v5pvE3KauHZ0bTSvtc1QQGZiH 6dz9QlkEEqbfpcdglFkKrsUuaIDH5tEONnyb/BrimTwnNc6N2uK79pqt0jktWkCd5Xdy pdLA== 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=a4cA+mZWyPkCkV/BDJlpA7F0WPLb7gs/FrHfljohURs=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=z53E7w9yRMdLwbYG4mX8A8bXOiOKVV1kC3dbK0g/R8cjA0u0Zh3faht8dM/++X8DAy J5/gKCLocq4KMw/mh3NrY55h9Z6qTupqQ5nF3xGEotFWqrBXu+RQuNQucD68sMaGN5kI mdzlYxotXPWZ4yh+YrVcmcbEAS3w8s0RbUd/tPmziWfpv7X7EYdNmiiWiPRTXbGn61R0 rmvKZC7T3XwW60Ai2fNl6PT93/lx2nfj4LAXcuLtyCnJCrI86Z/Wrkb4Fk7txIYwQML2 vzR5uwyamHLJK+NYp6k+fHgiGZXvthcYK3maIuYUrCjePpzA6hcPGNTYZjC2yNht6cBw TVUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HY3sGX96; 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 o17-20020a170903301100b001c39b8b1d77si1721251pla.149.2023.10.05.10.03.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 10:03:32 -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=HY3sGX96; 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 DCBE58020D8C; Fri, 29 Sep 2023 07:33:45 -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 S233772AbjI2OdJ (ORCPT + 20 others); Fri, 29 Sep 2023 10:33:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233583AbjI2Oc0 (ORCPT ); Fri, 29 Sep 2023 10:32:26 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E870610FB; Fri, 29 Sep 2023 07:32:21 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-9ad8d47ef2fso1850782166b.1; Fri, 29 Sep 2023 07:32:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695997940; x=1696602740; 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=a4cA+mZWyPkCkV/BDJlpA7F0WPLb7gs/FrHfljohURs=; b=HY3sGX96P4QoQ4faJEt8f8sREXCBNcb6H5QDd4jkeCbRPGKC8e8gR+YKoszoSqkJdd 1NqhZsZk4rEGNQzhxPdRBmDTWZcgiRkXm2hPs8Bgkm+XY/VqB30yRzcMf1pqMy+qCGmK eVbuAjtP1+PJdU3h6W/Io6UtSQqpWxQ4aaVxz1XJDNwyM69bKFOIl2hHbZ0OEJQtomYJ zN7hTlV7zeyac3PbJ0YiSW7CmfTKDXMk1C5xY3fFrnJaK9Un4eImw3Vc5Zjihq1p0XAK ksGwULld/DgwyXewtD5vdDpoUUJdx+c9NTr2ykn10ASZ7z/NjWnLSXgVipOShyvWUQ0p 7gWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695997940; x=1696602740; 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=a4cA+mZWyPkCkV/BDJlpA7F0WPLb7gs/FrHfljohURs=; b=KBQ1nwwIY9Y9CmkPUbTM8uRJPYOjWrYKvhTZ1sMiejkJRd+RbJGNIyIaYOrFmH4w/k TcB2jkghbQO034Dpyxpvv+Fy/rvTfJJHHKCvpNrNcA/lFUZ8liKZjAdfyI35ZgnDkCDC aTjy1RENWhloh+VKK9hExznqjHSuMXElChHByQ1Xha5aGlE0BYgG6qSPDBCdlRbCBXDu zHYpU5sQPtGCXGKFoohU0V9BL1cDiu4WdoATJZkEKR3VXZEO9SOgxg7rHmOhnJJzvmla BytBQ6urxtxrNjZUlGnRBi0ZpkBIwpscWZDq+32RQF4hFuyPktbfr1qvnyTULgpVZM91 R3sw== X-Gm-Message-State: AOJu0Yx8B56DuEe4wSiPoXiLQjLRW+wwwL3qzznsZbS73IF9fzFr40Gi roFqxwDpRkVYzriJQIiApEI6E6OIx0gg3CbkPuM= X-Received: by 2002:a17:906:854b:b0:9ae:54c3:c627 with SMTP id h11-20020a170906854b00b009ae54c3c627mr3503943ejy.71.1695997940123; Fri, 29 Sep 2023 07:32:20 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id a7-20020a170906670700b0099293cdbc98sm12660105ejp.145.2023.09.29.07.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 07:32:19 -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 v8 13/14] USB: typec: tps6598x: Add power status trace for tps25750 Date: Fri, 29 Sep 2023 10:30:54 -0400 Message-Id: <20230929143055.31360-14-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230929143055.31360-1-alkuor@gmail.com> References: <20230929143055.31360-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]); Fri, 29 Sep 2023 07:33:45 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778935831438145614 X-GMAIL-MSGID: 1778935831438145614 From: Abdel Alkuor tps25750 power status register is a subset of tps6598x power status register. Signed-off-by: Abdel Alkuor --- Changes in v8: - Change tps->cb to tps->data 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 9df8da8f5d4b..c7bec4464b8e 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -109,6 +109,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 { @@ -499,7 +500,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->data->trace_power_status) + tps->data->trace_power_status(pwr_status); return true; } @@ -1170,16 +1173,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 const struct of_device_id tps6598x_of_match[] = { 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 Fri Sep 29 14:30:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 146710 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp4234231vqu; Fri, 29 Sep 2023 11:37:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFvoPlUSZKTF1Qstl68i2yPCoKWEwzm8JuhU7jpYsXB7k3MBXt1j7HG/wklLbpy1fImxrn X-Received: by 2002:a17:902:da86:b0:1be:f45c:bc38 with SMTP id j6-20020a170902da8600b001bef45cbc38mr5778794plx.2.1696012663570; Fri, 29 Sep 2023 11:37:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696012663; cv=none; d=google.com; s=arc-20160816; b=MNYkAKE19E/F8ABqpt5/1LUEC6NGTrDSVxnZmqmarrnYBAIhfey7QzQJinD8JQWiuL HnQKjrMFnob0nlZXq1r6uugEmD/RFdFbWMr3B1g57Z+AbZkHiDaAdvBKa/x1j2uWVuvq OKb0mPkb58y57325bTTZKz7kFr36GP+3XIE80zB0QVYXWZ0xV4V0c3mGBCH653zPsOAt ypPSEloymoUt4p5tIFklOkGRkufB5KZqJTRftL0LqzhoDEok8GGynhQwkecqROLeMKI6 bo7f2njoz5jUpVgW1gUWgzENmXGXQfXmNDxVX8Oea3I2W5HoxemMTd4VbTDKBynNZwLb /dDw== 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=vEjsMkQ9GIeWHBCsfRSsqMZ7Yk3v0h6W2BQ04LYGZ6U=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=IkGI2xsMphDRjcynFAzpYsAspT7+SX3bW1w8xIVAS1j748bBBKyzcUwd+SOZ6iUdZS z/TImVN3f3ad4w05/j7CfjNdReQgIM7NapknwKgL9qz/yPhx4hrV/g2T4L+DtssoF2PC jgBo7mPF4NkMX8aZkqZFCzu/yJH7GeQr2OhkHgilpSRGHitT8hXkLuzI6zAc8tZhKQZG gVXppV+pYr9BE5ICrxyOhiH+L/b0NNmDbc/yB8fE69tTYjksN6tZOQFao46QNKmHE/oI 4XlGHBMiQptOAh4AmMZgrwXXXeOFztmGPpKnZ/NEWtJ4gyXfU0JZh7pOb2NZ6xjFwh8d BzEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=B13FjOcg; 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 m19-20020a170902d19300b001c730c865f8si5315292plb.320.2023.09.29.11.37.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 11:37:43 -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=B13FjOcg; 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 2AFE082DFD2D; Fri, 29 Sep 2023 07:33:40 -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 S233599AbjI2OdO (ORCPT + 20 others); Fri, 29 Sep 2023 10:33:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233601AbjI2Oca (ORCPT ); Fri, 29 Sep 2023 10:32:30 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97C891708; Fri, 29 Sep 2023 07:32:23 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-5335725cf84so16996586a12.2; Fri, 29 Sep 2023 07:32:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695997942; x=1696602742; 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=vEjsMkQ9GIeWHBCsfRSsqMZ7Yk3v0h6W2BQ04LYGZ6U=; b=B13FjOcgWLIe914gsuQqqzPk7RYUj5r+tsUSzc6UFKdzil30dJQkFB/CWmZY1oofd6 m/vN/txwbWXjEMYb7wQjDI+QL06bJl7blD2m1QT92xAoXG8674OyaE1iyvAu9D9JfjDe duC53dFwKCN+4il8BIvNoiahLgfZ2LXKGlGe05HHl+zVntuRaDv9v1O6RQcgcasZORg9 p6+VNdXyOEqWmlgeBql1P6+KvVUbqoMDOU/3f4QantXsgUMu4ZEwm528onRt3LmviySL gKLKkZz7+/ZfI762pXiFP59qbi9pfH852y1hjDl89BpRDgiKY+zQIo1tW84+Xrh55N3R ZxAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695997942; x=1696602742; 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=vEjsMkQ9GIeWHBCsfRSsqMZ7Yk3v0h6W2BQ04LYGZ6U=; b=T8LJZA1BHgJeFDClQToret7YSfQD6Xhh/TaG9eLXmNDezLx+rUPeELuv8ofdMqBOqA j5QuulE7yPgOmOZLBxnDc362WRDKOuGQlFmJF5it1MovXLyqgnf+UsLdmNoy1PCatO3k Ysq5h/VU4DKfOUjImkW/thlmmbZmKatCXkTuyqOBcvRRb0uFJWHyYhtZO2A7Ig9SYfIC W/yr02RmB3B75SvMXm2s3+l8CkUF+VT1yoNf+XVfvGIfYPR0wA2guIO8J2VOZsko2IMk RluXFom7KG/lj7/EIcntnzDfHkMrpadRffKlaIHYfDGpz59GE9At/vb0uHKgaiIrQTK+ 8vwg== X-Gm-Message-State: AOJu0YxFFhF1P/AzTYD0ZxMA6IjpEI5FEpqviX/6DV3pIBun3gEoJH8i 6WEfjqzidHY6ZM4fRaFUmmA= X-Received: by 2002:a17:906:53ce:b0:9ae:614f:bcec with SMTP id p14-20020a17090653ce00b009ae614fbcecmr4134319ejo.70.1695997942013; Fri, 29 Sep 2023 07:32:22 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id a7-20020a170906670700b0099293cdbc98sm12660105ejp.145.2023.09.29.07.32.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 07:32:21 -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 v8 14/14] USB: typec: tps6598x: Add status trace for tps25750 Date: Fri, 29 Sep 2023 10:30:55 -0400 Message-Id: <20230929143055.31360-15-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230929143055.31360-1-alkuor@gmail.com> References: <20230929143055.31360-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]); Fri, 29 Sep 2023 07:33:40 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778398174488277545 X-GMAIL-MSGID: 1778398174488277545 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 v8: - Change tps->cb to tps->data 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 c7bec4464b8e..1afd598c6a1b 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -110,6 +110,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 { @@ -469,7 +470,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->data->trace_status) + tps->data->trace_status(*status); return true; } @@ -1174,18 +1177,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 const struct of_device_id tps6598x_of_match[] = { @@ -1272,10 +1278,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),