From patchwork Sun Oct 1 08:11:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 147103 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp892878vqb; Sun, 1 Oct 2023 07:11:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGJv53JE+ze+pX6kgHTFZuOtHCX3idbF1645pkRAm+u87UNaFte3z6YBn7tLVFwfkLVWdaq X-Received: by 2002:a17:902:e74a:b0:1c3:9f2b:4d08 with SMTP id p10-20020a170902e74a00b001c39f2b4d08mr9421227plf.20.1696169517585; Sun, 01 Oct 2023 07:11:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696169517; cv=none; d=google.com; s=arc-20160816; b=Rip51WrRCppB/cZzEOZUfTZe3cedzqtHkEYgMu6E9vMY0+X+clPOehknlhaID0oqXh NBPXRdqE/nQ5CuGs8cTqX5/dSiPf+GgGM+ULqQ5dxnHv7FIkuEV7BFVRpELoSjDI9Qzv 9z+N75tSOg1Nv4Ggpa/yYJEfpEk/dnRzXj0JfgbC2who+Jb7Pw1IcwhA5cn9OSwLEGTg inJEbEJr2QQN2wV00uAU2kRZnJYmK86CA2j0D+Z0q839ZCo4Gs7SFgRAHxojIaMPJ0lH lhIF9tSsnMbC8KHwgAdwC6UFo70ymXnELTm0SyPcLsAF0ycw12Ow+2Xwu1oUHbBxflnt Q7TQ== 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=OGpDxcT5aeITQfH2zI83I7bXWv8lEzILwF0J/4qGo+Y=; fh=B7IWgJVc42wMIMsrVDZntNehKViVjDtT6uWLvo6Gxpo=; b=oIBeh/+kWmDiQqy3zCHoZXtx1R6LRgCe7o6ItSjxvqJZfd1NfhqcCIu2edDSUB3Lzd sEmH+aaEe+MV/yNNII+LzgjF+JpVl2w0fgmUk2WlUO/z+41Iy4n9zzaqEckN8ewCe895 M0GO0EIQQwZ8YK9BjrmLJM2r2nTmO6sR3iJ903ZpDAug/+Evkk5wHLh6TyqiHAAU60zo NamZtLUMP+RYYaurg2oW4sodbxl1aY8FjhtqNveiem4JzU03pCa73qvjDLQtwszygcff PhffIxUU1dnRb9E5bM5LoVaoHf431aSMQHK+AcuQgYlQpnE3YSrG/6qkKTmFF1cr58f4 rV7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KkOyL5ES; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id p17-20020a170902e75100b001c32d285db8si26557859plf.308.2023.10.01.07.11.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 07:11:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KkOyL5ES; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id DB4BC802F70C; Sun, 1 Oct 2023 01:16:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234495AbjJAIP2 (ORCPT + 19 others); Sun, 1 Oct 2023 04:15:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234480AbjJAIPZ (ORCPT ); Sun, 1 Oct 2023 04:15:25 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 001D4C2; Sun, 1 Oct 2023 01:15:19 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-9b2cee40de8so464555766b.1; Sun, 01 Oct 2023 01:15:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696148118; x=1696752918; 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=OGpDxcT5aeITQfH2zI83I7bXWv8lEzILwF0J/4qGo+Y=; b=KkOyL5ES7i9q8GzliIAxFb+3VPZ8uBJloVMnbZ0baox7njgRc+AGRULZSxqpr0zxDf fq6NgCyTH+eMoemcSzF30STP1EQc4sZYLSYfXQ14CxvNd8l0bjer8pjUMOLIsiOrSNCd bdM55YDq4KHY3I4msyk2StjgOP7O151EQo3Zw7uwJ64Z24SuepvxXCVy+rpe60wCEVGv IsJmJoi3oSbTU6X6PntX4UL/AEOtbEiDJViD3y3i/+9zzGy3glixT7OCZyWQsJ6DHSc1 GUghF21vuSDQ2taKKgWLzJzU53KquoZkz54chZ/YCxod06hqUIY85OWM71/JzNQocHTW dQpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696148118; x=1696752918; 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=OGpDxcT5aeITQfH2zI83I7bXWv8lEzILwF0J/4qGo+Y=; b=gAUAcUyis8gx3+0Y790WtTTz3svF4VmRE49Q0bowVaBLDms4D9BZEsn/iBJBvNOuzV fKIL4haDuKqxTqMs6lGjc8tIeziTUzbxShYSriqwTMvUtXcN4KJ8l0sjvmsRJ7alx0Gf smOfLInfzJ2j45d1Y6WGJs59e6NfQcvQ3cvoEa48XzN1ktiuY4Y/3mMBBJebgLmGVszc +UijejVNqiEMPOO0wv7s38q1ITgYqwgNSnqabXfKLoU4/QWmcgBSrxo1m//qxj70OLUa yE6fvwGZgqp+gFqmrRIiAss6KjtI81vnotS/MPPMjx8ENLDYwiStYxdU+KbNPH/1YMJR szRw== X-Gm-Message-State: AOJu0Yxzpeq6SPyw/isI2fBvoglg3QxwFwHZGUimUi+1xcSsrYf9B15t BMg6ICN4g1U+zeAZ4W8dsbk= X-Received: by 2002:a17:906:225c:b0:9a1:f1b2:9f2e with SMTP id 28-20020a170906225c00b009a1f1b29f2emr7570192ejr.2.1696148118076; Sun, 01 Oct 2023 01:15:18 -0700 (PDT) Received: from primary.. ([213.139.52.198]) by smtp.gmail.com with ESMTPSA id e8-20020a170906374800b0099cf840527csm15121841ejc.153.2023.10.01.01.15.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 01:15: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 , Krzysztof Kozlowski Subject: [PATCH v9 01/14] dt-bindings: usb: tps6598x: Add tps25750 Date: Sun, 1 Oct 2023 04:11:21 -0400 Message-Id: <20231001081134.37101-2-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231001081134.37101-1-alkuor@gmail.com> References: <20231001081134.37101-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 01 Oct 2023 01:16:02 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778562648493991423 X-GMAIL-MSGID: 1778562648493991423 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 v9: - Add Reviewed-by 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 ++++++++++++++++++- .../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 Sun Oct 1 08:11:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 147056 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp794909vqb; Sun, 1 Oct 2023 03:06:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG1ihKThQqLfY3w5hUn95PdcqrVsLs6pblc6SSJQVxImW+1tWY1TaiuGkl+KthiocNF3Iie X-Received: by 2002:aca:1911:0:b0:3a7:aabc:738f with SMTP id l17-20020aca1911000000b003a7aabc738fmr8603271oii.39.1696154812112; Sun, 01 Oct 2023 03:06:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696154812; cv=none; d=google.com; s=arc-20160816; b=CNFKVWNZIkLDmcp8u8Y4t0EAHjQ1RrksSesPIQD+dmDKWsV1BkIpAR+17JcelBZSMA VTz2a2kh7mRuuN6gscBhC/HcpsA9tObohtIOI+N6zlbF0IqbaC4RGww8zTnS2ruR+iDI huGD8ywRP0uew5Ay5mpofExUDTIK8OzdnKXkWoHLf88AYZqa0F9YPBK7Vm47KMb3RFUt Y6ze7rI2zxa11ts4Mlntm4Ktg8VNVj4CsKRvhfSbmRL6zjJbT7uygMFa0n+I+cW45OC7 LKi1pQjVbdSWL22mLNUinjrwJ8CsMYTd+hgKy5JHlflGV9rsGsjzTQMHuCuhN2L4ItV6 FM5g== 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=bXPGOO8O8at+wGMGIlqhcBW/HHlv4Zqhk0okLpSRNJU=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=gsFhMxBoi0ToznJ6i5cyBMg6iyd71LEv1wHKfYQP/gLDCAcll0LlTc0UgydfS1JZ9D pSguH8nAh+IE5o1q3FgLCVV5b1WMc2Wj1h2/vAvVbnMEP+3l8rkU2P9sX9meNQrbkY6j nB3JIUMay6U7jK6QbmJq6+XjdTWvXZhcqv700zYQV+UCyL0d2/SRkeE/NE8pkiZvcHkz zPAyCTHflWYwBpmFaSXjamUae9TQ/MpmTeWfPf7gbgZ5cenG5827IbbyomF8gNpNEkPP SotDZ/pbJZN8wscPgxWS/ym0M7ySW1Fe47PxAV2OQYlhzn0ltjhBXkL+naPZ8R902Scb Emrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Vv4lBv2M; 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 e4-20020a17090301c400b001bba894ac4asi28256016plh.274.2023.10.01.03.06.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 03:06:52 -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=Vv4lBv2M; 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 C29D980964D3; Sun, 1 Oct 2023 01:15: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 S234488AbjJAIP1 (ORCPT + 19 others); Sun, 1 Oct 2023 04:15:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234474AbjJAIPZ (ORCPT ); Sun, 1 Oct 2023 04:15:25 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF01DBA; Sun, 1 Oct 2023 01:15:21 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-9b2cee55056so441980866b.3; Sun, 01 Oct 2023 01:15:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696148120; x=1696752920; 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=bXPGOO8O8at+wGMGIlqhcBW/HHlv4Zqhk0okLpSRNJU=; b=Vv4lBv2M0T38TRc1d+qSs1hJ0Pa2XsM3mBGBz2U4aPo2JdxDecmTgfVFLyQhX3Dc5Z rucOnmB4F3+P7I6UoHbtWYKxKj9LbGDqJeIShOX8pPuHXjIz2gGK0i0MuQyyBg+2VJPi fQRPLmYUZKtbmrrSH7V87DNgP9wVBner8+gVkRfAWZeBtlcn2BgRVys3Rh9iqM6VAR3d u3SfHxCROTAXQ8A7ulnCt12rMoGwvVjpZ7CGVpX/QMezutOryhhGc/74/EN65JDAZutb WGLiYFKBqKbYGja4epQzj9c0occ1Ing25KzuxADN+YhbKl9uq7OUaPKv0qN4Ae+WfL7S tASw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696148120; x=1696752920; 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=bXPGOO8O8at+wGMGIlqhcBW/HHlv4Zqhk0okLpSRNJU=; b=jqEhqNNOSgLwCD2RbaHuOZQJTiPVuibVWzTLrSPluZ4UT5wRIJm0ZGNhgfoQC4KhK8 m15a9d/sk12dbs1+uOLc2OKOXITUNF2oOw0m3xoa1VjF5/9jQdtnFifjXboOOdRTgk8T gaREGmeiC2EDs1g2WdTBoyJcR43sT8BeilTLHX42xgaDCo7Iet6VfPwbYQ7pDhpZ/kma tz0eonFb4Htnz8naYNLUQrhuSSwYZyE/410XSyeSFq7K3KJKwdk5dIgEtMHo0eBRMoRu 1f8iMD2vtZzUVY3SBCj/3v7gTcGdmOjNwhaV4bxh9BbCvJcuWJ1u4BpWQt5ehIHOKXaI JVOg== X-Gm-Message-State: AOJu0YynDE0G5qekWnZN520PGumvX+9cnRwXS/j5dYaDscZCxiDET+sx 19o9NyasbUD3DcQ6h0+txaI= X-Received: by 2002:a17:906:cc2:b0:9ad:a59f:331a with SMTP id l2-20020a1709060cc200b009ada59f331amr7221138ejh.57.1696148119934; Sun, 01 Oct 2023 01:15:19 -0700 (PDT) Received: from primary.. ([213.139.52.198]) by smtp.gmail.com with ESMTPSA id e8-20020a170906374800b0099cf840527csm15121841ejc.153.2023.10.01.01.15.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 01:15: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 v9 02/14] USB: typec: tsp6598x: Add cmd timeout and response delay Date: Sun, 1 Oct 2023 04:11:22 -0400 Message-Id: <20231001081134.37101-3-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231001081134.37101-1-alkuor@gmail.com> References: <20231001081134.37101-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 01 Oct 2023 01:15:51 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778547228218651635 X-GMAIL-MSGID: 1778547228218651635 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 v9: - No changes 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 Sun Oct 1 08:11:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 147146 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1014838vqb; Sun, 1 Oct 2023 12:05:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEr4WSE9SIKD4BemK4ZLvL9vEBLfkM/ILQAvq+U75m+X7pj98Qhqgb+znVZS9uV6FYXwUki X-Received: by 2002:a05:6358:7e0f:b0:143:7a89:a8d1 with SMTP id o15-20020a0563587e0f00b001437a89a8d1mr9462359rwm.0.1696187150117; Sun, 01 Oct 2023 12:05:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696187150; cv=none; d=google.com; s=arc-20160816; b=rf9RqtCP+0JSHcapj7GgPGq8ovNSnTIbxxvRWooycIUtwfOB7yhRSt4fCtcVVw+2aW jnw6YJfuX5u6GhQCuwtmLqjaJB0e+oo31Sw7QY2Llyx5JKXpJxGdxsDpMWe1+MAJDbdT 4txLvwEQM4fJbaqPvLUPhkx9c0EaLS1Tev3BWHSumby90A6Ugywu0W2RDtVS9R7enk7b FC16H0E73ZVbDTFyd9Vv8PeyOl6rACBndB8pVtS5BO5qxLTqnDWr4CU/dEAv2QFWxRl2 IU53tWXVAEl/EVHoW5pt9Yko9X/+81FhWOnphevJ0nNmN7+gmgNzSPxwEDUQGD8mLkLc tmBg== 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=mihHJZYDvrxcQ5UWKrmIwqyKIitG/AHmGkKzI/r7wpg=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=RQUmpsYOwLegxIkQIppMXMZeIhTZLvNu5iQoqsmZbk3t0pIkvcwWL0cHal4w9zvTcu K3PMnqhN6UOERXbTucIo7oJ1nRgJqW8VV4RGJsQG36ifLooPbf5gZcwv3TTbcB7kXrmc xm/yQDRPQ+7dwWWqU1nrgfHznUt5Dj98H9My0bY9OKh7umK+JrqcSyxDgif+/bVnH+5R Zcly6RvxOK7eYWDx5DCQJq/MK99BmLa1GnY6/VXu+AzcwcKFGUvVwUFT2mJCgQgF83KH s+LPYdyuW4xCxheQHzZdMnuTafijq/A2eljLKNHBlqX6Jlizk8NooD1Sfsa/bQnz2vzO Zt4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bnYj5FEg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id bu3-20020a056a00410300b0068e35d412c9si25093948pfb.323.2023.10.01.12.05.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 12:05:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bnYj5FEg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 9B6248022682; Sun, 1 Oct 2023 01:16:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234510AbjJAIPa (ORCPT + 19 others); Sun, 1 Oct 2023 04:15:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234481AbjJAIPZ (ORCPT ); Sun, 1 Oct 2023 04:15:25 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A80DDD9; Sun, 1 Oct 2023 01:15:23 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-533cbbd0153so17263171a12.0; Sun, 01 Oct 2023 01:15:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696148122; x=1696752922; 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=mihHJZYDvrxcQ5UWKrmIwqyKIitG/AHmGkKzI/r7wpg=; b=bnYj5FEgAmk1BgeiWFBgWzz/0pCHiLEN7QBq6AqkCzvWNxzGewutXHk+b6mIFZLfTr LGZz44xWDnvhwXw+DKacCopDhKyWrZIfGd7IsVvVIF95mAnWJ+87ZS05BCjkNdrewkBp mVbXCYUuo8dqtPBEH13X+jGGGeOg1VVleWAQac5MtnzUymJI7KlykcfHRREiUXBcPknv QYK/88BtI+SINbRra+IWKdxo4BL4kCPR9aZs7m1IQfbyQq/aqhK3WI0LMlKgF7VDbU47 X40zHS+q+S6SME07b/bDSSRFVLeNYQcuZ1xubxeMaoswa7jSMHA9RAOBrYbWT70yc3J0 rD6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696148122; x=1696752922; 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=mihHJZYDvrxcQ5UWKrmIwqyKIitG/AHmGkKzI/r7wpg=; b=R5UzYvvJhJtA1JUAGn4SraUAB11J+obDwQwJr2ZcBoXCNv8pF/uSd6jQ6oko0lYi22 Kve0a8W3DHz2H8hDH8uriFXbYmK74/RlfvmbfkESvaA10Y0nairLfCGW9OxDkapGYTzb Tq5BO9nKaXQaghMPH0bDz1KX+Qm8tykBl7EJ/JXwAYIUMu870dgWk+AmvociYs9siKeL fvo3AKzodVB6MmJvHyUqIwHbOmBe1ohyQy2rLUrX/013xX+iTq+wkFiU1p7y7YGreMHZ +m11kqdJm9dAs8IfzWEpeaMzHO+Vk0t1JakWtlcWhO8tlCACtYKDIx8KFf+xtq8frsha JqOQ== X-Gm-Message-State: AOJu0YyOXI4a1PigIAUhminUQbTEA6NASun+AjyyYNBgQr2mT7T9Ibj3 Y8aCLTb2wPvFL3PUHloh4f4= X-Received: by 2002:a17:906:76d1:b0:9ae:729c:f651 with SMTP id q17-20020a17090676d100b009ae729cf651mr7386783ejn.17.1696148121928; Sun, 01 Oct 2023 01:15:21 -0700 (PDT) Received: from primary.. ([213.139.52.198]) by smtp.gmail.com with ESMTPSA id e8-20020a170906374800b0099cf840527csm15121841ejc.153.2023.10.01.01.15.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 01:15: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 v9 03/14] USB: typec: tps6598x: Add patch mode to tps6598x Date: Sun, 1 Oct 2023 04:11:23 -0400 Message-Id: <20231001081134.37101-4-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231001081134.37101-1-alkuor@gmail.com> References: <20231001081134.37101-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 01 Oct 2023 01:16:41 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778581137115261893 X-GMAIL-MSGID: 1778581137115261893 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 Reviewed-by: Heikki Krogerus --- Changes in v9: - No changes 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 Sun Oct 1 08:11:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 147123 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp925463vqb; Sun, 1 Oct 2023 08:20:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFO9Ls5dXT4Rxm4W72Y+qJ8t5mq3Pd30rDY3dWCe+51F+aaPlY35Ycm21deCrd0ddhi6itv X-Received: by 2002:a05:6a00:228e:b0:68c:d6f:212b with SMTP id f14-20020a056a00228e00b0068c0d6f212bmr12910345pfe.19.1696173648586; Sun, 01 Oct 2023 08:20:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696173648; cv=none; d=google.com; s=arc-20160816; b=XIgQFs5TU7BQLesK4/619wJGZxsxQJijmwTzRuIEpHT0Rc1qgX8L4/pN4FL86zkTXv xDbpidXEVN2JYGb/Hc5pW4XCgi9+DcR2Gdmd6lXUiV/lETZzJO9mxOZY38s1wS3F2bNJ 26s7tDrycjcU2FDHZHZa1T310RKqcoZsC8zcULGDb1Zi0nn1FulPaQUWnGqk0eTSY9dZ G7xsYjxnXlA4bqQDiwO+s1XwYNr5VW39/HVhLZkNkIvso7KFpB8BlRcKvY2Nn2/y3fLO SGtude6uAj+i60fwoOvB3/QQgbS/rQH/BNstxyDKX1OB9ooUWIP6aV0ZYe3OiV72ZDvB 8S6w== 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=fgas/z7fExmPUKkMNiaG89VpgAdxGMpsmmwmf/zWrRQ=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=TMNA/tO1T/Q8f+FnkXpxmFh5nwfd0ExZ80QssRAeDR2kA/bBCXdYgR2yuTHvOAHH8X VQHpkk4JfLMq3Zf4hWfGz2rXkLScOC8zMteeUJFsIAxsoEdHTPu4Pe8VOIJrrrJ2iYh6 IkgYBxZCQK9vw9sKE7h3LJ3hjZAoKfl+xib/z7jejHBSfjVoobYCpMNuGpazK/8Qne3C mknRPRhYH9WCRxoIqjRk4Uqcy3OfqWk8tgX+4nYjjdn7oVEdgvOLpyGco650bYBBiRQN CQapQrg+gdGLQ2lYLfwjchN3lYdBfK7jGohQj5qbkjegOTt0EZImgDB6WIcthQxdHt0u tMhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="lb01/eda"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id k70-20020a638449000000b005859ed0e6efsi5581838pgd.533.2023.10.01.08.20.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 08:20:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="lb01/eda"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 4B9AC8024B0A; Sun, 1 Oct 2023 01:16:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234505AbjJAIPe (ORCPT + 19 others); Sun, 1 Oct 2023 04:15:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234490AbjJAIP3 (ORCPT ); Sun, 1 Oct 2023 04:15:29 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9040DD; Sun, 1 Oct 2023 01:15:25 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-53447d0241eso13726548a12.3; Sun, 01 Oct 2023 01:15:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696148124; x=1696752924; 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=fgas/z7fExmPUKkMNiaG89VpgAdxGMpsmmwmf/zWrRQ=; b=lb01/eda/yLWCz8D5qSmRH3ipZtX7uA9Wjkm3o5NcD9CSrTRPRoNLlOjh56RGkoM+2 zNxZ6xIQW1u91Z8wU3Onl/wIoM9iMXzV0qv5Aot8kw+SJqFhaM8CYuKpmnK3D9VXKkSF uOjfWF6A3wWUvAz/vp1lB7GJpn1JxHXxI/laRkZPD0vmZQqYt/xH7Qwqe1auf8H9rEor dbDtfenks90nkUrvEe8afiwnk+7inXnod8tavWXj0ZwR4Cc9/9qN7/GmniCd+4XodXDq iaJFt7ltbrd6Hjaxf+Ap7zeyLx13RuxEgj6yoLeLaF5ohCYKxsk3lN0NvIowxtueE3Zj oteQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696148124; x=1696752924; 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=fgas/z7fExmPUKkMNiaG89VpgAdxGMpsmmwmf/zWrRQ=; b=gT9aO1k2efNYlxC/xKT8wbRep7PA7waW+Z/+QMozEdl/e1h77w/yI4TM4irMhJp8qb NonXlBj6CaZ5UzWrqyhQnzorTynmqDP9o8I5+aj6UzpRZUheJNv1DnVr9sJ7OWnMUt9j Wg2mhWr/+FxYJUFohfndjFSLgWPRoRfiBS+lHJ6eML+VBGpLu5fe+rQqjPzSxN9z5Z4L PxLD+3Uh/B83QzLxDnVzYuIEr8xNX0tFx4qnn9CwgyRqbHKM6da9BwuxJu2wr00Mf3Ou 1d/yhUraeFJegBAgRQuiAMWt7eOn4q+evxfT++HBd90K/OPJBgW2KR3D+JajQD0fTlmw d+QA== X-Gm-Message-State: AOJu0Yyz3hfqZJB+NyXJsJ4w9h7PhTecOJFJwom0UfEMYulvxkBLIclU RHQJcVVgZwC3ohymT4uuv0s= X-Received: by 2002:a17:906:1097:b0:9ae:695f:f938 with SMTP id u23-20020a170906109700b009ae695ff938mr6473162eju.56.1696148124125; Sun, 01 Oct 2023 01:15:24 -0700 (PDT) Received: from primary.. ([213.139.52.198]) by smtp.gmail.com with ESMTPSA id e8-20020a170906374800b0099cf840527csm15121841ejc.153.2023.10.01.01.15.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 01:15:23 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, 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 v9 04/14] USB: typec: tps6598x: Load TPS25750 patch bundle Date: Sun, 1 Oct 2023 04:11:24 -0400 Message-Id: <20231001081134.37101-5-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231001081134.37101-1-alkuor@gmail.com> References: <20231001081134.37101-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 01 Oct 2023 01:16:14 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778566979576347194 X-GMAIL-MSGID: 1778566979576347194 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 Reviewed-by: Heikki Krogerus --- Changes in v9: - No changes 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 Sun Oct 1 08:11:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 147109 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp894270vqb; Sun, 1 Oct 2023 07:14:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGmtkCoJuYmzO1ZrLqTRmsniRmt/20FEze4lJSen0vOJwZhqslfolkzKTVr1Bz5FJec4MSU X-Received: by 2002:a17:903:230b:b0:1c3:4565:22f with SMTP id d11-20020a170903230b00b001c34565022fmr10972560plh.21.1696169692125; Sun, 01 Oct 2023 07:14:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696169692; cv=none; d=google.com; s=arc-20160816; b=KoJVzcgZBVmLdS4WZVVa1PEL/ef5arbaXKlCfltL/B6F01G2w1t9nU3C2CWh4IvMyb eqJGAOAV2Zr8qzRt6iRmF0n9LBEomgX2Udzm1sc/KNnVB5bzOt4oF4V0VM9Y7MEDdWCh hdgVmzXIhoKH5/aGIJPZ8MGF+6M5RhawsyJSfoxYL9v+DgA+I52V9fjdcMKec8CJCCN1 pYHuCw9pxT+H0N4x5sJasrz8fngNFid4qDOcu8RYF7MK42xmApM+BHQL5ZVIip+4D+EN khcefsYwibz9EC962f8PcJ318znx4K1BwWzjWnwAYuGfR3HwUza153DWI6Aeud70aPe/ 1rEQ== 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=39ntlcYvDYrsu2wkLxDzmVg+LA5a9z1WHwPNTIKFmRs=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=FeYhCvFRBUpE2/bHyp0YQyxWR4HIj9IEEFlFH7vNaK6bb4YI+OFKlCMz6/3+NgGOUj kQNrfwkPFtSQzIFSLlNVBM4ocGNjdWfqVGqBkBn+MmSEhYR7hf8bm3ePWnQL1ononGlv uvFrEdQaGLxz4lwpl5tQx7RsIoM2PwChIdgZr8wWWncgya7+tPKb/eh7mlZle7apSvMC +GS6k2PiDSE1195+CTxIMTDVVva5kWX5WiXWHUq09qxDKMRv7GHqwIqasFBZymMoCVxh VmZ5waDOyRtB724Cxm0pv+r/NTe9YwPULitlQzh60CI40vyoGHm3IDB8wLtT0uxT6ZGZ ssoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jNTGOrHs; 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 f13-20020a170902ce8d00b001bdad5f0f0bsi25480635plg.543.2023.10.01.07.14.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 07:14:52 -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=jNTGOrHs; 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 E58EB8135CF5; Sun, 1 Oct 2023 01:16:19 -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 S234573AbjJAIPo (ORCPT + 19 others); Sun, 1 Oct 2023 04:15:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234481AbjJAIPc (ORCPT ); Sun, 1 Oct 2023 04:15:32 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4C45EA; Sun, 1 Oct 2023 01:15:27 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-9ad8a822508so2158568566b.0; Sun, 01 Oct 2023 01:15:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696148126; x=1696752926; 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=39ntlcYvDYrsu2wkLxDzmVg+LA5a9z1WHwPNTIKFmRs=; b=jNTGOrHskVgeAPjBDmmszNf7xAy+CK929rEJrauutvWSzEyaTb4tb5OrZ4ahHP/0Bw EjnhQJ6c6Mcx072AXRLUAVQgaOUMu7u6AjBUR+eScxO8pQUTh6cr/j3SXzjQcfikwxCH IiD1LsJQR3fBjTdLVMzcSh9lS96fwALeFtijyszL8apFDhO8RCKsNDU8VBCchnQSPWAs 8OOT0AqdPtz60CBVpbBGEAmvQFTrCUkxAJv3Ue5b+AN4KiZNh6iVaCN7YKBoa5wUDuW8 IQsSwc3KyzpLSeHbcLgV1qbLddSynujDNrzE7fFHJstzk2tvSKDhtko6Mc7ZJwFz/E0w VAng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696148126; x=1696752926; 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=39ntlcYvDYrsu2wkLxDzmVg+LA5a9z1WHwPNTIKFmRs=; b=bwJgFStFLs/kin6oP/jY1v6CF5W6LNCQu7hG5FIn14XYpNSpvHFvS8d6byobBZuB2K +H+eWfKH7rn2CzCiSIjYs/ScoTgfRpzWfaNHX0JyIqjaepUek9dx2OdMzd4AS/dltBT3 9of3wxtW8zgE2zOZezjlzX7BV6qVa77kc2jXF/HH+nrUl6m1ebM7KSBMF1OKM2LSf+GU w3xKWaK6tmaJye4Lh+09xHz9I0vgGU+BwcPxx/C4y9gegJp6XIzy7ExHdwLY4KSyJkce rXl6H1zrvXbFYIbNdnOXm3NWhvImvkPEgpBkoMfBx488/hgH7PH5acXOD56P1Ihbw8P2 t5Gg== X-Gm-Message-State: AOJu0YwMRjNY4bI1GvmIxl9vl/PWXPUU7JN9tqoW5yA6WkZCSu91aw0d bHCeow6hHohV0XJzsT1EdEg= X-Received: by 2002:a17:906:5daa:b0:9ad:7890:b4c0 with SMTP id n10-20020a1709065daa00b009ad7890b4c0mr6250083ejv.56.1696148126108; Sun, 01 Oct 2023 01:15:26 -0700 (PDT) Received: from primary.. ([213.139.52.198]) by smtp.gmail.com with ESMTPSA id e8-20020a170906374800b0099cf840527csm15121841ejc.153.2023.10.01.01.15.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 01:15:25 -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 v9 05/14] USB: typec: tps6598x: Check for EEPROM present Date: Sun, 1 Oct 2023 04:11:25 -0400 Message-Id: <20231001081134.37101-6-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231001081134.37101-1-alkuor@gmail.com> References: <20231001081134.37101-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 01 Oct 2023 01:16:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778562830848934374 X-GMAIL-MSGID: 1778562830848934374 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 Reviewed-by: Heikki Krogerus --- Changes in v9: - No changes 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 Sun Oct 1 08:11:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 147127 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp941127vqb; Sun, 1 Oct 2023 09:00:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEFKiSAN4uNymqcEBVauB6lP5mcGxRxd6U6SWTrpcvdWMbZEQS2JIqOL6zQPp2Mq07Fdpnh X-Received: by 2002:a17:902:ea8b:b0:1c2:82e:32de with SMTP id x11-20020a170902ea8b00b001c2082e32demr9526255plb.0.1696176040431; Sun, 01 Oct 2023 09:00:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696176040; cv=none; d=google.com; s=arc-20160816; b=VEGEMZ4bIPTLWQjQRqE2w/vXcLjSdxIAKkmlfGJH3jCkTxco2kh0QDCZnpJjnJmPv6 uSWOOD8udbnR8NEi28Mgh/UGbLrpXqpxfd99fbSohDLRl/1ANdZqn92cQgm5DrY9sRnD QTL6jIPYV+Tbpot4DFcV22CJpUted3l35myHznTmJlGJ1YWRnzioWFD9G7djLFkVEG/3 u6bUYn/wibzUskbBiz6MJ+svFXd/lQrupcE5tqbmqeNo58jjGe0Q66sG99In4Ys3OSB0 e6O8D0XLXWi1CQBSWY3yA/GOdvVyOkeCl246R/z14y4coJzCWMJBdJoQOezneQzc2bCf pPAQ== 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=6ObRy5c8YFdrnW2Ux3zmbr7cSFwdsAqt7EeK0em6AeQ=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=b33UDPsjyV9iPgetpbOZg+hts6PI5zjU3eZXmWOPzlQIJaZiPbeH6272b5ibfywEZo 96kT5RCeapOFAvuomCbhzhN2COuagmLiKP0qQ22JxUwO7lLfRez3Sd2PAuZpWlAO3TQc l6DIF4I4uHZOozXoULEflw0n/SN2+YSoMKiy5c4LKvdzl4UTfoRsAz3vpfBBEOQaMo4x SQEvoT6e6rQfrb1eqGnDzdY1UJESe7zLxJqXA2fzd6ZsTr67SA8rEqzSq9dXQZmvWdAa hhN/uk538GkeXwOxB9DauG7QuGhWkTcCPhUxdPxK+jMChcV5MH19uK8Qlm0txkjadwAv 1JFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=BFAqTOp7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id q8-20020a170902a3c800b001c6189eaaebsi4869468plb.186.2023.10.01.09.00.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 09:00:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=BFAqTOp7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 12DA1809564F; Sun, 1 Oct 2023 01:16:21 -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 S234576AbjJAIPt (ORCPT + 19 others); Sun, 1 Oct 2023 04:15:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234533AbjJAIPc (ORCPT ); Sun, 1 Oct 2023 04:15:32 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C145CFE; Sun, 1 Oct 2023 01:15:29 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-9ad8d47ef2fso2073155666b.1; Sun, 01 Oct 2023 01:15:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696148128; x=1696752928; 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=6ObRy5c8YFdrnW2Ux3zmbr7cSFwdsAqt7EeK0em6AeQ=; b=BFAqTOp7EC8UDxEhRwQiBk/VQy5h07n3WTHzZgbqm49BL3XcVbYsqBL5SAhskToELR Jx6YFE0IQ1uW3EwSruTS74qiPS0rcjuqYvoMHWwxIseB0DMWvGYT/BbvHpdsbVwMKarO AXIYnL8tpC04nB7Xo28ZtPutU95eKxV35gq2toMkHfUOQeaR/LqtlrlWUL5tLKNn3swy heYnA8OZL8KbNDZVSh+BEjHCMY8lpANzWAWi4hi+reOY0/zhJYMko55swTgYnz+4QNmX fdwAOO+POSMKVjwtN4WdH6t3V0Ouvz1XumWUeMh4AO4cnmEk1F5Tz4NpugbDslkuxyMe 4jKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696148128; x=1696752928; 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=6ObRy5c8YFdrnW2Ux3zmbr7cSFwdsAqt7EeK0em6AeQ=; b=DbxX+jVURZorp4+Zh1WgZDq6dxdBndOBI+BE1pyysbiL9yWO9la+fQFdDz/15f7SjA 9YjtPdn2iCVS6Su3YfC0k0DwVTrDc/u9twyixnSb09/xkxS2R4j1In2RxnOYgNt3xiw1 WOxPex6NuexHcj4CyC430aXAg1kfTDoM5QT7BxEwTpttqsz39XtKmq9F0DPDGHpnuOMe Fx20chhTYzCAPffeRV6Gp3f7pQQ6koMPKMZUXWzzRF+9s/fhc2LE9fynmXGDcQ9ISvLv H7uwKhRtZwKPonK7f8+5OwCRefGJyVyqqXVdL5NkhfKnMnWRIxnwvUU+/O6PDax+gnBA +FKw== X-Gm-Message-State: AOJu0YzbNI74xidBIfWQGNKLNDPkiDq4ykm1lKD+mCzEk/ICss5g5YFn qpUUmjXwTYD9fXriRec4tKc= X-Received: by 2002:a17:906:209e:b0:9a2:120a:5779 with SMTP id 30-20020a170906209e00b009a2120a5779mr8944577ejq.60.1696148128017; Sun, 01 Oct 2023 01:15:28 -0700 (PDT) Received: from primary.. ([213.139.52.198]) by smtp.gmail.com with ESMTPSA id e8-20020a170906374800b0099cf840527csm15121841ejc.153.2023.10.01.01.15.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 01:15:27 -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 v9 06/14] USB: typec: tps6598x: Clear dead battery flag Date: Sun, 1 Oct 2023 04:11:26 -0400 Message-Id: <20231001081134.37101-7-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231001081134.37101-1-alkuor@gmail.com> References: <20231001081134.37101-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 01 Oct 2023 01:16:22 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778569487470025574 X-GMAIL-MSGID: 1778569487470025574 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 v9: - No changes 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 Sun Oct 1 08:11:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 147055 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp794190vqb; Sun, 1 Oct 2023 03:04:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGNuM1Ps14Dh8W4461jDgByz7GFvzAO8X5uedAwyLfdY7EHPtf7wJA++8wUAOiPj1jFVlZq X-Received: by 2002:a05:6a00:24c5:b0:68f:dcc1:4bef with SMTP id d5-20020a056a0024c500b0068fdcc14befmr12405481pfv.7.1696154698232; Sun, 01 Oct 2023 03:04:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696154698; cv=none; d=google.com; s=arc-20160816; b=EkAVELwGvrIwXS7vj3GGjmfdwgSSEDhu1b9PFrxxlt0qFzbO9H5xd+1oVFmhnYzt6k vQnrojlUNZwoccXesXyAsrI0rHO+yuj7Dp4s88g3ZGthKtsd6/bnAMjvhHYZmU+zt57+ hlqL00Q9UXyDCoMKLu8NeUcEwtc14Cd5wcjCUt3Ef+n2wIpNQivqUz8hCTq4a81iwuu/ mvMja2Msbr7lkSZr23tUbyyPF4ytCvSsi8uSK3p/HP6jAb9xgrSf+RnmrokLaHuaLycd IU6trQMROTy3j/51AXVOzfkKlzCXGfA7uEY+c65yRpvi3YEh4LbEYrR6noCpEp2XkJCi 1tjQ== 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=bWPzDpCgbdga7D5FXbvvos+grST88yl+CjFPhYb4TDA=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=klTkvUa6UHLDDNcAkO472DNnTkQgp7spy8j/MHXCblnML7p9lSnU3vsnLVYZwL5Yg4 OlBp7bxPnNdNm5addFq4Tf0Qo0GnVuLRjYmNUTJgzK7LhLWu/Wec5AlMuWXipTdHCSN+ nY9cW9sVoKrHQuF22JCDqAwQoBVJMFkdVE+wxmUzaR4R/gmvj5tEqVBZzEcV1COHrU7b MCulNKeyQuDyP7DpB20azqkCiGmCkAdQB5fX3j2fKSgZbebtmTpD9KVwoOXvu7NKNUrY IkTupnlq96CvPcfdbvq18c1kcMuSYt3S3pH3u6JE1V/RGllLdAEFfkjZCXDr9RcUTq+F 8abg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lhGICNzX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id cg19-20020a056a00291300b0068fc080f79dsi24495604pfb.122.2023.10.01.03.04.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 03:04:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lhGICNzX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id CAB7280242B1; Sun, 1 Oct 2023 01:16:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234533AbjJAIPv (ORCPT + 19 others); Sun, 1 Oct 2023 04:15:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234561AbjJAIPm (ORCPT ); Sun, 1 Oct 2023 04:15:42 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 363AB11B; Sun, 1 Oct 2023 01:15:31 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-9a648f9d8e3so2221916366b.1; Sun, 01 Oct 2023 01:15:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696148130; x=1696752930; 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=bWPzDpCgbdga7D5FXbvvos+grST88yl+CjFPhYb4TDA=; b=lhGICNzX7uUj9Foc0oDMrHWeOdO5z/mpiC0bDdgTg2CGvxjtYQeguw21xWNquht6bg NzMHG9D0VnjgUbxOIolVTLxQV8geUMaUnA97hTzLwcBL2bgV082RKTqpme1BkyeP2QZ7 McdrziK48w5ViGId7FIzSe5dfn/XJR3BAe6xuko+H3/fv0M6rl6Q5G5iftfLIyYq60cI uXKvh8JZgYOp5/EoMRXnS/ycMQVRPL5jvzrvHlDNuxLwaZzSTTJlKLB8NA/IJUF+QbNg QThWGcoMmRenzlHYGNcyagpzuZKq+KxqOdLUWhpzl0LzubZakfEYE363+BEj6yyO3wh7 mi9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696148130; x=1696752930; 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=bWPzDpCgbdga7D5FXbvvos+grST88yl+CjFPhYb4TDA=; b=SLLU4TDT3Gck5ZPU1I4MMZPp1A9Loow6dKSTk/qpDW+uLvvtqSr+RYe1z3KwO7/KBM TqPYx0LJpeKDF9t60sQjpD6yD92LBsu1tva1Q6S7NpwhWYS6avLELWClESw4hRrea+jC OVTZT3phZ+nOlKvpbZP4LPoniA3CqoLsmVU4V9PO8iGoYWoHNK7vzU6RGNXVP5UO/8Fw Av1v5Zoq/Fkcyw9xYpmgQaDexcsh0Rx5v2XroF4yAxsTH530CdIq3liupgqXS4p6rWqo Em8AZuE8x/D6a5BqmgNAr6ONMgk6Ffskw1uKNNn0vmmNzNdU1JcoWHUZFUlod5MH5jZq nUYg== X-Gm-Message-State: AOJu0Yxr8lgvVRpDe2d9tQwsOtRyH9nFrOk/pB3TwW/vgYCa6+OX8491 QbHQsiorZcYeHFqzKWxoz18LBeIrCJm5JHJ7ASU= X-Received: by 2002:a17:906:20d9:b0:9ad:7d5c:3d4b with SMTP id c25-20020a17090620d900b009ad7d5c3d4bmr7734269ejc.35.1696148129945; Sun, 01 Oct 2023 01:15:29 -0700 (PDT) Received: from primary.. ([213.139.52.198]) by smtp.gmail.com with ESMTPSA id e8-20020a170906374800b0099cf840527csm15121841ejc.153.2023.10.01.01.15.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 01:15:29 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ryan.eleceng@gmail.com, robh+dt@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org, Abdel Alkuor Subject: [PATCH v9 07/14] USB: typec: tps6598x: Apply patch again after power resume Date: Sun, 1 Oct 2023 04:11:27 -0400 Message-Id: <20231001081134.37101-8-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231001081134.37101-1-alkuor@gmail.com> References: <20231001081134.37101-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 01 Oct 2023 01:16:22 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778547108410043880 X-GMAIL-MSGID: 1778547108410043880 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 v9: - No changes 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 Sun Oct 1 08:11:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 147096 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp878071vqb; Sun, 1 Oct 2023 06:41:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEhodLU73GcLetzu/k5S3HZ8pAeWcC4xxAmawOXIjDvJhLtBQTcgY8raC4oszIozv9ROosM X-Received: by 2002:a05:6808:349:b0:3a0:3144:dd3a with SMTP id j9-20020a056808034900b003a03144dd3amr9358875oie.37.1696167675323; Sun, 01 Oct 2023 06:41:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696167675; cv=none; d=google.com; s=arc-20160816; b=Jgt8M04mo2dXhzI6k0H058Okc/x7KqJwsGv4GbMNPMKbVpktNHfp9mdzx+04XpP18M LxDODw8KbbvxbGG8uCjwAGwt00nktIcZkiWEorNHWKv6eSiIk6nKVty6psi56AxE6SPP JdcHs4vFeDP201DczsRWG0u4eK3ATl5/rdqn2WWAk8P5Ac33l8iu5vp2j1cAymp6/QSO xuCGKDTKkm8t2J0TV65vMOBKKxSptCX7sEQaH58rpTTsaGwnTgDwW/7ajgQqZ5bNer3A Oge5oQpO6lwjH8KF2t8Au/7xah/2HJ/Z1jSyQv0fDQmH4/s1rQqVrYrpVZWmqoxgdtPX QNCg== 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=KgR1N5k8+EU4qN1VDI9cvb4KNqSDKnzmfopTxEYsXqs=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=Hj2oMf4vnC9HF1fFsYwEjJ/ZYPm+DwC1/LLwSKKrmfX9HYx0ikGiGF20w6leygVsbu 8VNpZxnCD2kCSt16M1YfWTgMieR2h+611hzhIBUboJ3sYLiy1A3WPWTHd5eurVZbSKEd IXrHJxvhCM83Wx99eY41EPdGlaZ2w7rd5/CnNI+lU6GfJq4aaNoyMRr9DLt6+6ejAiuj COcc7HzbJccs9oqwrCHoomTIHSNPN1SN/TdUREqEq0zxXTlUNCxWhADpR0wLb+MwtGkQ k26xi5QwI37LZ/VRaZVb3xrlw8vDJoIjOulcC+ZtmTocoNm6c7z6xrZ9RiZjRPjJjUQv 1/XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=i6uXOmi1; 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 h24-20020a17090acf1800b0027782fd462esi5350778pju.5.2023.10.01.06.41.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 06:41:15 -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=i6uXOmi1; 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 59D50807CEE0; Sun, 1 Oct 2023 01:17:17 -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 S234526AbjJAIP7 (ORCPT + 19 others); Sun, 1 Oct 2023 04:15:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234595AbjJAIPp (ORCPT ); Sun, 1 Oct 2023 04:15:45 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 101B4CCD; Sun, 1 Oct 2023 01:15:34 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-9a645e54806so2073325266b.0; Sun, 01 Oct 2023 01:15:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696148132; x=1696752932; 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=KgR1N5k8+EU4qN1VDI9cvb4KNqSDKnzmfopTxEYsXqs=; b=i6uXOmi1en2aPZSFDpYb9H6bYBIaiYgjTbjpc97m2njbKjvsaFZdVjv0iHE069PDVm u5tGbN6Xqw+6632o5zR/0+U4B0aYID0pMpbPO9I3OQDWdtPR9fDe3CSOprOKF1p1gPAz dLtKbtiL6byvkvlnXoc/F6MqWlPNhAZU9w+AM/VExIDOYINYkGrLrMSrXEfPraYDhfy0 OHsE7fMGl9TPAnLqNKwoqnUlNdllp6Ak9bs0zE9f3m9duASig4Fz7QP+RD6if55v/1th +RcD8uWcBl6yopA4ionytuANulntwA6mbyxWhIM7g99wGqbWfU/QXjv+ih388mTNPriI mMYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696148132; x=1696752932; 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=KgR1N5k8+EU4qN1VDI9cvb4KNqSDKnzmfopTxEYsXqs=; b=uHlOslfM0eJ5NUOYsbsnUicCuJ7M3hiYAXkWNx2CvWfGiSC4cjDu5SFfuysYXoVFs4 gxO5yJPrJE6gwzlZy8YJ/vglItPfAw4oFS1LQHdCLZuO+qkMEGHbdoGSXPrqUtMkmXe5 6JlaKm4qnM7KOKnHIISX/sRK9jlVAgSWmoYPXUi+ntuZX9z+lBP8hQCqJDqtv+eQyuC6 eEq2cyC8/S/RMUDf3O5FVDwz8i5VYwqC3hDvjnfeO6JgzJhVAeus7QV1VgTFmjTv9a2g qABV+AG8ef08m+GjgsIOKfBDJqiA/YZPnHCROQLBdx7ipfDM4ykxh6jYoct6OweH5RsC /3ug== X-Gm-Message-State: AOJu0YyM3edXGisT7LHXS7h7sBMhf1EXp71mmCjI4TOmojmvpZ/4y1JB Pto2Ap4oPRbaDDRCzIMV3TA= X-Received: by 2002:a17:907:60cd:b0:9a9:d5e7:5531 with SMTP id hv13-20020a17090760cd00b009a9d5e75531mr10113751ejc.74.1696148131828; Sun, 01 Oct 2023 01:15:31 -0700 (PDT) Received: from primary.. ([213.139.52.198]) by smtp.gmail.com with ESMTPSA id e8-20020a170906374800b0099cf840527csm15121841ejc.153.2023.10.01.01.15.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 01:15:31 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ryan.eleceng@gmail.com, robh+dt@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org, Abdel Alkuor Subject: [PATCH v9 08/14] USB: typec: tps6598x: Add interrupt support for TPS25750 Date: Sun, 1 Oct 2023 04:11:28 -0400 Message-Id: <20231001081134.37101-9-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231001081134.37101-1-alkuor@gmail.com> References: <20231001081134.37101-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Sun, 01 Oct 2023 01:17:17 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778560715916738497 X-GMAIL-MSGID: 1778560715916738497 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 v9: - Move of_device_id to its original place - Move device data structs to the top of of_device_id - Use device_get_match_data to get device data 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 | 96 +++++++++++++++++++++++++++++++---- 1 file changed, 87 insertions(+), 9 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 32e42798688f..52dc1cc16bed 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)); } @@ -969,7 +1034,6 @@ static int tps25750_apply_patch(struct tps6598x *tps) static int tps6598x_probe(struct i2c_client *client) { - irq_handler_t irq_handler = tps6598x_interrupt; struct device_node *np = client->dev.of_node; struct typec_capability typec_cap = { }; struct tps6598x *tps; @@ -1017,7 +1081,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 +1088,10 @@ static int tps6598x_probe(struct i2c_client *client) TPS_REG_INT_PLUG_EVENT; } - tps->irq_handler = irq_handler; + tps->data = device_get_match_data(tps->dev); + if (!tps->data) + return -EINVAL; + /* Make sure the controller has application firmware running */ ret = tps6598x_check_mode(tps); if (ret < 0) @@ -1125,7 +1191,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,10 +1297,22 @@ static const struct dev_pm_ops tps6598x_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(tps6598x_suspend, tps6598x_resume) }; +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", }, - { .compatible = "apple,cd321x", }, - { .compatible = "ti,tps25750", }, + { .compatible = "ti,tps6598x", &tps6598x_data}, + { .compatible = "apple,cd321x", &cd321x_data}, + { .compatible = "ti,tps25750", &tps25750_data}, {} }; MODULE_DEVICE_TABLE(of, tps6598x_of_match); From patchwork Sun Oct 1 08:11:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 147136 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp958833vqb; Sun, 1 Oct 2023 09:36:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEDDFSL0AYdGtvRynHAkSIgHydnpHMufA2XS3RwX3fKUcS2YkMqv3cRbBvegZstN53bDNRG X-Received: by 2002:a05:6a00:170a:b0:692:b539:28ff with SMTP id h10-20020a056a00170a00b00692b53928ffmr8275388pfc.24.1696178207587; Sun, 01 Oct 2023 09:36:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696178207; cv=none; d=google.com; s=arc-20160816; b=0kafCGT2FsUSF07LBRuLaXYxHaZEowzebHesEtQQEdj4eW+j5rfBSMeEERXfdvSDou IXy+wA9V4YEhDKdX3cM4ABY6QTrt9i0Mh4b6DooT39DT7SbvuCh3XsMgaKjMPBzgYtlG mQ0j6zDm1jR9G4/sGaarGUW94I1SzFUz/yXUSyHoiTuZSEykTGublFAxG9QVOlb41lgg sbd8Bp45L9pJFCj4ny34SZ0PB53X+ODzfsKLYu61aUqBrnvu3s048TPJzITMslaPw8mm ggrQ7q3p4wKIq7Ak5UdQhc2xgkKTTWGeX4sMw6iECOsLtFdUpAttffvmz/IP6k5dmcgz nTmA== 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=pvj2VqfHdRAjMHVY/xVfGLDkyqEBAlT4pBrTcr2LF1o=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=w6hjfLvi8BcU/ZhodnVoTXKswR+Q3+VhnCSSczHGBPQCLbKW5IMJSQUhqu4yEEV+V+ u3biWpE8ahkldsZnAOSeq90vJLcI4OUE6oFlmnp/JT7Y2BlNREBZmfOb3HL+EcPUsb3K xpBcEszLKM3iv9C9olY0ab+Nbg0z4EnbdQzb5sl+F1QJJ8Po/5rbW1wgm4djRtG+yj2v iTzrZ6dhf2eFvcvXjvYtjEYPgLGU4ZYOc7M0C4K2EdaQunMNn5zy5J6C5UIhSGAKsWMu V9Qhls0Grfd50mlNVF3cFSaAnQ972Um5LVR0+tEGq67veCETpj3J45aTfyBy5nQIKk4H k4+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YZ56d3HN; 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 s13-20020a056a00178d00b0069343bdd500si10896601pfg.319.2023.10.01.09.36.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 09:36:47 -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=YZ56d3HN; 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 DB6F280E0B5B; Sun, 1 Oct 2023 01:16:36 -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 S234693AbjJAIQD (ORCPT + 19 others); Sun, 1 Oct 2023 04:16:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234602AbjJAIPp (ORCPT ); Sun, 1 Oct 2023 04:15:45 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DAAECDD; Sun, 1 Oct 2023 01:15:36 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-9ada2e6e75fso2218023666b.2; Sun, 01 Oct 2023 01:15:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696148134; x=1696752934; 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=pvj2VqfHdRAjMHVY/xVfGLDkyqEBAlT4pBrTcr2LF1o=; b=YZ56d3HNVWpz4qOCftWZ2syVnbBWE/9YbY9gktX+WgJYmcUpi4KkK6A/aqSqshhAfh IupHoTQLCMaNAfpKGY1ckxwiaqlb/AcZPaVUPIiqAo03eai6UNYqFEAfONtmoZGtGmuV ZruY13fCKA1R+gytmVP1fPFrhce8VgqQWCeL2yNrH5Ej2hymUe1zUUUlu8kBNB4SEY03 zXWEGlTQGoyCJcPRCaR+jh23TWj1LytLzcwNJ54Ny3xRemwaZqE5HaQnV0PZ4OOxYFCL NSRqXYRxB9X1OxPElrT/rdSheVeQAe5s+1zxosVbRDsbmKP1TYeiwcclMt7LLU5ZNNVi ZPaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696148134; x=1696752934; 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=pvj2VqfHdRAjMHVY/xVfGLDkyqEBAlT4pBrTcr2LF1o=; b=XExdTXm1V3oOyzFjYb5ADNw+tnJIhWbdE1miGEdo1WpZocyZypwWo1safFF31W9JB2 2qepOypDmIYZ5g4F0V80aZRvRG5gZoQxUwplfpkjLh56uOjsANPJ2k3mc7KGfLMYi66E AGWArFXM6rvMxaWn+TGuuXpug0pcYdqk32sukuRar/PF+Feux4opNnZJvp0Ts7yxNoRh LlT22KFvRxYaxscqKvUOQIKFEuxfoTWQ5jIoeO/O1SMFy1oB0qihLwuL3T6aphck41+a bER/Q9glXy2kFQl3f7ZQjADjY6rhLYbGnhDToLzG1AGDzu77yDkJPPpqut057gPJ4gi8 yJRw== X-Gm-Message-State: AOJu0YzCpzGvrsffzEYedwBsfGJXk2t2of0UZLVdA3CX1+pmz4WFgmpN 0BaUQbpYMCqjO1FYcuSgNp8= X-Received: by 2002:a17:906:5dc1:b0:9ae:513d:47bd with SMTP id p1-20020a1709065dc100b009ae513d47bdmr7208484ejv.26.1696148133738; Sun, 01 Oct 2023 01:15:33 -0700 (PDT) Received: from primary.. ([213.139.52.198]) by smtp.gmail.com with ESMTPSA id e8-20020a170906374800b0099cf840527csm15121841ejc.153.2023.10.01.01.15.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 01:15:33 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ryan.eleceng@gmail.com, robh+dt@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org, Abdel Alkuor Subject: [PATCH v9 09/14] USB: typec: tps6598x: Refactor tps6598x port registration Date: Sun, 1 Oct 2023 04:11:29 -0400 Message-Id: <20231001081134.37101-10-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231001081134.37101-1-alkuor@gmail.com> References: <20231001081134.37101-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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]); Sun, 01 Oct 2023 01:16:36 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778571760156917887 X-GMAIL-MSGID: 1778571760156917887 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 Reviewed-by: Heikki Krogerus --- Changes in v9: - No changes 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 52dc1cc16bed..0195eabd96bf 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -1032,14 +1032,64 @@ static int tps25750_apply_patch(struct tps6598x *tps) return 0; }; +static int +tps6598x_register_port(struct tps6598x *tps, struct fwnode_handle *fwnode) +{ + int ret; + u32 conf; + struct typec_capability typec_cap = { }; + + ret = tps6598x_read32(tps, TPS_REG_SYSTEM_CONF, &conf); + if (ret) + return ret; + + typec_cap.revision = USB_TYPEC_REV_1_2; + typec_cap.pd_revision = 0x200; + typec_cap.prefer_role = TYPEC_NO_PREFERRED_ROLE; + typec_cap.driver_data = tps; + typec_cap.ops = &tps6598x_ops; + typec_cap.fwnode = fwnode; + + switch (TPS_SYSCONF_PORTINFO(conf)) { + case TPS_PORTINFO_SINK_ACCESSORY: + case TPS_PORTINFO_SINK: + typec_cap.type = TYPEC_PORT_SNK; + typec_cap.data = TYPEC_PORT_UFP; + break; + case TPS_PORTINFO_DRP_UFP_DRD: + case TPS_PORTINFO_DRP_DFP_DRD: + typec_cap.type = TYPEC_PORT_DRP; + typec_cap.data = TYPEC_PORT_DRD; + break; + case TPS_PORTINFO_DRP_UFP: + typec_cap.type = TYPEC_PORT_DRP; + typec_cap.data = TYPEC_PORT_UFP; + break; + case TPS_PORTINFO_DRP_DFP: + typec_cap.type = TYPEC_PORT_DRP; + typec_cap.data = TYPEC_PORT_DFP; + break; + case TPS_PORTINFO_SOURCE: + typec_cap.type = TYPEC_PORT_SRC; + typec_cap.data = TYPEC_PORT_DFP; + break; + default: + return -ENODEV; + } + + tps->port = typec_register_port(tps->dev, &typec_cap); + if (IS_ERR(tps->port)) + return PTR_ERR(tps->port); + + return 0; +} + static int tps6598x_probe(struct i2c_client *client) { struct device_node *np = client->dev.of_node; - struct typec_capability typec_cap = { }; struct tps6598x *tps; struct fwnode_handle *fwnode; u32 status; - u32 conf; u32 vid; int ret; u64 mask1; @@ -1112,10 +1162,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. @@ -1133,50 +1179,13 @@ static int tps6598x_probe(struct i2c_client *client) goto err_fwnode_put; } - typec_cap.revision = USB_TYPEC_REV_1_2; - typec_cap.pd_revision = 0x200; - typec_cap.prefer_role = TYPEC_NO_PREFERRED_ROLE; - typec_cap.driver_data = tps; - typec_cap.ops = &tps6598x_ops; - typec_cap.fwnode = fwnode; - - switch (TPS_SYSCONF_PORTINFO(conf)) { - case TPS_PORTINFO_SINK_ACCESSORY: - case TPS_PORTINFO_SINK: - typec_cap.type = TYPEC_PORT_SNK; - typec_cap.data = TYPEC_PORT_UFP; - break; - case TPS_PORTINFO_DRP_UFP_DRD: - case TPS_PORTINFO_DRP_DFP_DRD: - typec_cap.type = TYPEC_PORT_DRP; - typec_cap.data = TYPEC_PORT_DRD; - break; - case TPS_PORTINFO_DRP_UFP: - typec_cap.type = TYPEC_PORT_DRP; - typec_cap.data = TYPEC_PORT_UFP; - break; - case TPS_PORTINFO_DRP_DFP: - typec_cap.type = TYPEC_PORT_DRP; - typec_cap.data = TYPEC_PORT_DFP; - break; - case TPS_PORTINFO_SOURCE: - typec_cap.type = TYPEC_PORT_SRC; - typec_cap.data = TYPEC_PORT_DFP; - break; - default: - ret = -ENODEV; - goto err_role_put; - } - ret = devm_tps6598_psy_register(tps); if (ret) goto err_role_put; - tps->port = typec_register_port(&client->dev, &typec_cap); - if (IS_ERR(tps->port)) { - ret = PTR_ERR(tps->port); + ret = tps6598x_register_port(tps, fwnode); + if (ret) goto err_role_put; - } if (status & TPS_STATUS_PLUG_PRESENT) { ret = tps6598x_read16(tps, TPS_REG_POWER_STATUS, &tps->pwr_status); From patchwork Sun Oct 1 08:11:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 147079 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp836482vqb; Sun, 1 Oct 2023 05:07:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGf9Sop6RUi3E4AEjJhh7fpZ/FFfCyr1Gx71RKczMCPMNd9V1StxOwKmmSKOVzIMFeUwny1 X-Received: by 2002:a05:6e02:1ca8:b0:34f:75eb:f81 with SMTP id x8-20020a056e021ca800b0034f75eb0f81mr11893869ill.5.1696162046128; Sun, 01 Oct 2023 05:07:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696162046; cv=none; d=google.com; s=arc-20160816; b=hBIBpTzHOQ1S7x7HDzrLAbvFNeLbRbi8R0jIuTkRdDB29+HQG3cqZJEw74gMPY4S/z JsUm7I7s4sV+vxjwXQgGWIupUYXgNzAmzQiMshh1Mtye6Tk421M5xd/Qooz7F0CeHqbG K+ZzbOiKCHqMkCUANcLKWSD1IODZyB/OwUDx21B1vsRhoxByAmK4JZ3KFGOBZ90atV4S OBshjUSm9evMAVnej8pBajBUikqzLL9iQlApotm+DXgfA3aP7B8m29319+GXiSM+plwi ShI/7IUhhvKJ8j0UytteZFpVUCh8dSat78tVWidCzG7UQmsGj1RbWcu9akCQTxlmXRL7 SpoA== 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=EGYlNfvaZDrRZ6mlHOh7dP8thvXpReQRJZihrjwW+H0=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=sKBqA3Vhv1JvscWhcvk39KvXaXOtoiQ0XtinIJFDxq8OaGJNSrao5d9y4/sE4jzOQw POFAleASZ/tQCC0BEsljwVm18H9JEx+rXsht0F+o105mDV3O3CxLCt8d7zNcUmseQ7nT ivIsU/jdGYDdSepqYxcPvSDSZpQteshrpGvUGlTjW8t/4djxV0/xyA5gyIg5sIx+t0kY xrOVC70IB+fivPRF42XOtl2VtqS67HObqVGfvkaZjxQxWSBWK2C0HjKSgmjk5/ZuNG49 nT3mZRXtxMOgTmyTdDA0DkYHhSHNom4cW1GEvE/xksYI1AiDEobn7RmBeq3tRzbY8xVy k6IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=L9eX9k49; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id lb14-20020a17090b4a4e00b00278f524d83dsi5796188pjb.95.2023.10.01.05.07.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 05:07:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=L9eX9k49; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 9E476801CCEF; Sun, 1 Oct 2023 01:16:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234648AbjJAIQF (ORCPT + 19 others); Sun, 1 Oct 2023 04:16:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234629AbjJAIPr (ORCPT ); Sun, 1 Oct 2023 04:15:47 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED293CF0; Sun, 1 Oct 2023 01:15:37 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-99357737980so2122184866b.2; Sun, 01 Oct 2023 01:15:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696148136; x=1696752936; 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=EGYlNfvaZDrRZ6mlHOh7dP8thvXpReQRJZihrjwW+H0=; b=L9eX9k49u5WI3argnmUTwCC6SeVfGsvRwo3faI2B1J15QSRG9qz5sn+3TbbyOYDea4 IKR/M8UEQsalL25uYuM9VSXHLK56NF5Hf2HQ/VyrEzFBTAs/rQeH4PoJreFSj9sAQLcK weO0Yb/t9LPnKNLtyGmvQXCClJEmA5w8+E348g3whmKwPpPwAVYOsARSwn4NFMywCgLe jp5DWQNwb6bH6r4wCi0cP6Zyps8UOAtIV16vA8GLgeRXoHk1OW1Oc06AFHZTsLejCaOS xfOxPneru87pGKPjJ/roOHvW+k1yp3lQtz7HcqQNibGnwc7SjbP0+i3+GxmJAGHDLppI rjIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696148136; x=1696752936; 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=EGYlNfvaZDrRZ6mlHOh7dP8thvXpReQRJZihrjwW+H0=; b=GK7yE9rzUzF0m031Xgh75maM1cu/SfleonMY6+RTTvXE6eiJCfctz+9AO+JeV5vt3z jxVgeRNmo3tHLud8rg6hrYQ5GqDr75j/hFj6eWWp2Vmavqyvp7fVgs9d+Z0VjojZfSdG couNVThpfL1xBR11R5Nkv7/n146wdNsRzKpsjkEgc1QYt4yxTj2ZF4QLpEp8SWHSUfz2 BAQZ0JCf5eln6idEBl3U+GiXHbbH3TXtszMtdo+gVrllThtaRM1PDHRkf4XNZXLtRBVI 5XS43DViTIK8n5XYMjwbDVCS4TG8Ug7a8xrQ3XUWGSKsCzY1IZw/LYDoRr+ZgkfyOsv1 IEnw== X-Gm-Message-State: AOJu0YwMYMcRMCRSSTGkaS1MNHX/WcSCiXwUPvP5xbX5jZhJuGIPkJ8F /FyNP6xpnLguVrG28sK4JF8= X-Received: by 2002:a17:906:9a:b0:9b2:be12:d9bd with SMTP id 26-20020a170906009a00b009b2be12d9bdmr7272292ejc.77.1696148135599; Sun, 01 Oct 2023 01:15:35 -0700 (PDT) Received: from primary.. ([213.139.52.198]) by smtp.gmail.com with ESMTPSA id e8-20020a170906374800b0099cf840527csm15121841ejc.153.2023.10.01.01.15.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 01:15:35 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ryan.eleceng@gmail.com, robh+dt@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org, Abdel Alkuor Subject: [PATCH v9 10/14] USB: typec: tps6598x: Add port registration for tps25750 Date: Sun, 1 Oct 2023 04:11:30 -0400 Message-Id: <20231001081134.37101-11-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231001081134.37101-1-alkuor@gmail.com> References: <20231001081134.37101-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 01 Oct 2023 01:16:44 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778554813972801168 X-GMAIL-MSGID: 1778554813972801168 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 v9: - Move device data structs to the top of of_device_id 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 0195eabd96bf..ae08c5306707 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,6 +1093,60 @@ tps6598x_register_port(struct tps6598x *tps, struct fwnode_handle *fwnode) return 0; } +static int +tps25750_register_port(struct tps6598x *tps, struct fwnode_handle *fwnode) +{ + struct typec_capability typec_cap = { }; + const char *data_role; + u8 pd_status; + int ret; + + ret = tps6598x_read8(tps, TPS_REG_PD_STATUS, &pd_status); + if (ret) + return ret; + + ret = fwnode_property_read_string(fwnode, "data-role", &data_role); + if (ret) { + dev_err(tps->dev, "data-role not found: %d\n", ret); + return ret; + } + + ret = typec_find_port_data_role(data_role); + if (ret < 0) { + dev_err(tps->dev, "unknown data-role: %s\n", data_role); + return ret; + } + + typec_cap.data = ret; + typec_cap.revision = USB_TYPEC_REV_1_3; + typec_cap.pd_revision = 0x300; + typec_cap.driver_data = tps; + typec_cap.ops = &tps6598x_ops; + typec_cap.fwnode = fwnode; + typec_cap.prefer_role = TYPEC_NO_PREFERRED_ROLE; + + switch (TPS_PD_STATUS_PORT_TYPE(pd_status)) { + case TPS_PD_STATUS_PORT_TYPE_SINK_SOURCE: + case TPS_PD_STATUS_PORT_TYPE_SOURCE_SINK: + typec_cap.type = TYPEC_PORT_DRP; + break; + case TPS_PD_STATUS_PORT_TYPE_SINK: + typec_cap.type = TYPEC_PORT_SNK; + break; + case TPS_PD_STATUS_PORT_TYPE_SOURCE: + typec_cap.type = TYPEC_PORT_SRC; + break; + default: + return -ENODEV; + } + + tps->port = typec_register_port(tps->dev, &typec_cap); + if (IS_ERR(tps->port)) + return PTR_ERR(tps->port); + + return 0; +} + static int tps6598x_probe(struct i2c_client *client) { struct device_node *np = client->dev.of_node; @@ -1183,7 +1246,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; @@ -1308,14 +1371,17 @@ static const struct dev_pm_ops tps6598x_pm_ops = { 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[] = { 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 Sun Oct 1 08:11:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 147080 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp838270vqb; Sun, 1 Oct 2023 05:10:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQ9Qjts22bqcc1Tv8Ll5g2p3PLPB/NQjkCu8aO/9e/k1hxGR+AR8gm0RUofLXOBDKujkGP X-Received: by 2002:a17:902:da8d:b0:1c3:61d9:2b32 with SMTP id j13-20020a170902da8d00b001c361d92b32mr7369037plx.45.1696162255086; Sun, 01 Oct 2023 05:10:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696162255; cv=none; d=google.com; s=arc-20160816; b=kJKpR5501SxjPzm4CAi815szXPBXhdBokS1T6zkT7tZKDUI2kXSC0d0kWNQaJ2izBb VhgrAxIuGBN6H+7sFI2E7AJErOL0gHzvCOFgAr0Crf561TIkUgiFJ1jAmhm/xfwseBni Smwc4D6YjK84RcXU6CFuwEsHXPuRQ2TPZeyLjFSISyALz1PXT3gnBmsGRZRM+42aHZJr EfOSs7pDepKX6VgjGbfFU1qDAtVvMpj9AIqjhPlH+tAihJB6Ymy/bg20V25iEyQSt8lo k/Y/R9OOlf3QKMLaGtNvvX7u5tg2yvJHBuKYMPvOoHnYzuKcJvy1hR2BJe7eWU2Owfce mtwQ== 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=IkM85K7qerliqFzrskzHsY1jjDj4Egep2EeBXa3H9HE=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=iIJxfTeFJ17dHjJuHOoEEsu1h6x9PK8LLpg3ci7AnNeR3Lzqr5zJoj2piH6E64p/Cx HGzapMhWZIjvqAxlBQqjMnva8063C8BZpksK2eq6eV+OjbOAp/s4V5FU7FV7XGanCjZj CgljiYmYQR3V4Hac2LDaVFjgoAR/lw76+WKp9tsjWssHlTMkUPJ5u1Dapfd9vj9Eszvi 9FEQr5jwZMBijMpMtfvG/QlS0JnvLU+uCNyU19gkqopXaSt6dm5Q0rMEg7UzjoQGTEeR cwgPtNhjwMw7CXEyyyKVedJi/Hw6qREn+7xdF9+CzCH3XGWvFtm8BOSXdok7RRidFcDn sgUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gch1Orad; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id le6-20020a170902fb0600b001c62b659f98si14208528plb.79.2023.10.01.05.10.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 05:10:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gch1Orad; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id BD281801BB56; Sun, 1 Oct 2023 01:17:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234668AbjJAIQJ (ORCPT + 19 others); Sun, 1 Oct 2023 04:16:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234572AbjJAIPt (ORCPT ); Sun, 1 Oct 2023 04:15:49 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C197710CB; Sun, 1 Oct 2023 01:15:39 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-9a64619d8fbso2167144966b.0; Sun, 01 Oct 2023 01:15:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696148137; x=1696752937; 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=IkM85K7qerliqFzrskzHsY1jjDj4Egep2EeBXa3H9HE=; b=gch1OradbR+fiZ9SlpdYWH8ZKubY2lPJfhX4zq4U/LLwqrKJUlLEH0dgjzBlK09sZY gcJYpQX2p7SBnw/7NPxkaxTVuSZh5twNRe6NfBFVSp2WtfuoCOFoA3iwKr6smA7n4w4u qnk5JA7n+blxgjgnDpDQDW5jbj/8pMJH2diivSRYSBvtFB/AQKbQiiCptg0rLM/hWStW idtGnbwuVXIg3gZ8R6DTegytdrCxNjqkSnzUOXfVT/sVYka5jJ/Bfwp9Q1FpOPxqWsHo 1l9K+Sym32nqNPf2U070qNxQnqRGSRcbx1miCeM9klqdWWuTwuEsYOQC0HGx3r/CUcyv RPnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696148137; x=1696752937; 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=IkM85K7qerliqFzrskzHsY1jjDj4Egep2EeBXa3H9HE=; b=XXF53XGGuHknnoNZeT4GNW1Via2gdY5UqG6SSKrFpFVFrqGM5drgceqW5ZYpkohgA5 VJ5jWMpwwhAyRVuoI1UaZ0UhFrgcO8JywIrBRWNF8WQDXeG6J0Uhf5d+4okowEViUGeJ cb3OMKmleBCLTPnf31yCQddFbo2OFb1jOe5Xsw4X2CvaLjnT8ngRWeHOc2o1MOME4dyJ gTT+2hIQQfct1Ortr7u6BjfofDLRfkc//fcdc5mEbhlB4xUXTIEzvWrwbyFpIt24MDnt 84lUd0xCTnwMQ4ml+EIoGcmFfxleENifRLfY5X+x46MWDq5jHWKZYkmP6790leHYXLMB 1icQ== X-Gm-Message-State: AOJu0YwRua+ahpJMI2mmsaGQT4SCtd8d9/qZmeHh969KPf1RMSgFwHgw APoMYoJ8sor3eLQp/1uC4Vo= X-Received: by 2002:a17:907:75d9:b0:9b2:7148:dd5e with SMTP id jl25-20020a17090775d900b009b27148dd5emr7884787ejc.16.1696148137458; Sun, 01 Oct 2023 01:15:37 -0700 (PDT) Received: from primary.. ([213.139.52.198]) by smtp.gmail.com with ESMTPSA id e8-20020a170906374800b0099cf840527csm15121841ejc.153.2023.10.01.01.15.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 01:15:37 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ryan.eleceng@gmail.com, robh+dt@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org, Abdel Alkuor Subject: [PATCH v9 11/14] USB: typec: tps6598x: Enable sleep mode for tps25750 Date: Sun, 1 Oct 2023 04:11:31 -0400 Message-Id: <20231001081134.37101-12-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231001081134.37101-1-alkuor@gmail.com> References: <20231001081134.37101-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 01 Oct 2023 01:17:15 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778555032569894318 X-GMAIL-MSGID: 1778555032569894318 From: Abdel Alkuor Allow controller to enter sleep mode after the device is idle for sleep time. Signed-off-by: Abdel Alkuor --- Changes in v9: - No changes 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 ae08c5306707..ddb5db7d5855 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) { @@ -1211,7 +1230,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; } @@ -1348,7 +1367,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 Sun Oct 1 08:11:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 147073 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp820172vqb; Sun, 1 Oct 2023 04:25:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFHQBOQR9iKniXbqW7GP1GptN5WaOplZihkkABBkabKplPqnMayZJpgGC/M7xGgi7VBFpNF X-Received: by 2002:a05:6358:52c2:b0:139:c279:1ee7 with SMTP id z2-20020a05635852c200b00139c2791ee7mr11268306rwz.18.1696159518123; Sun, 01 Oct 2023 04:25:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696159518; cv=none; d=google.com; s=arc-20160816; b=PBwyEKKRWJXQKsqQ6rHOqbb4GXa8Tr4/l9O8DZYKEiBqvWwVzKNugJrikseeoBJt/P RzCCSw7GyEkle5HDE7wSMNLfz88pLKD6ckspi2cf2L0g2Kg3GgfynsMS9ho1O4DmC7LY iryC+v3DSAnoHGZpD8+C6MZF0tMD6+yrf5yp+N68CQsF1e0DB33KR/vmyO6S8iNyaeFo tipGvUch13LZCFT5DffOrlqaR0GMPxeodbykwW2X4JjkTVxhGmhzFMxWzbxJoj1WClsh vSkUhdhHqZD642ESJOilYC296ipAi+FYgmvUVorYeI4IB9ImZ4LxvWX3+nStNpEi9GDr 5q7w== 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=kAQb2lcKCiK4nVCJ/kUlHxpo3G9oP8wSrjvkHy883UA=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=l3QOl6s/LmBIuEHSH+aLGv53bkN6vI+KIxcFyQ0CYQWseuxNTUCTAyqPSNwJHm+bHE rFBm34jiuw46AM7MpQFhk6sxUax09FPyiD8RxbXxjH/kiZgbZH3Fa+0MLDl/2a76WWHL Y/DjltmrZZbzvcNodU0AMGVoq4Yumkz9yzAH4FQvj8YDWJt8sB65Ev/99xW+2ZtqS4hh jL3EER3FX+Q5JPO5GyCYH2Hdz1rPHgYeek/LEVYqdPDW8PpB2O4lRPljtdxTBBoGM2iY jbrCYCfABZqxXL+IP99M43ayi9cmD6KBUj9uxR09uyEqa/7iXX1AxIorgeoNOEPaObne hyug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lj0Taukf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id r3-20020a63fc43000000b00578cca373e1si12940487pgk.165.2023.10.01.04.25.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 04:25:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lj0Taukf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id CB12A8174A5E; Sun, 1 Oct 2023 01:17:16 -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 S234561AbjJAIQR (ORCPT + 19 others); Sun, 1 Oct 2023 04:16:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234675AbjJAIP6 (ORCPT ); Sun, 1 Oct 2023 04:15:58 -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 ACE20F1; Sun, 1 Oct 2023 01:15:41 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-51e28cac164so4531738a12.1; Sun, 01 Oct 2023 01:15:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696148139; x=1696752939; 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=kAQb2lcKCiK4nVCJ/kUlHxpo3G9oP8wSrjvkHy883UA=; b=lj0Taukf8WEL+YYxaHBf39L0Im3oSE7WBl7vYlHkk+dTiIoHZ6yd8MSranORdF4PRU DA/o8+4lx//teX02wjK+h0YFv+x9HiDyAeja6ouMPr8JDzosXaZ0dArId+tkYiBr72Zw UT8+0f2zDRsiIJNYCEGDXr7XeEFusCprWzzBR4aEWdw8BIJJCtCJl8WbjipqjnutpRuN Ne6305bSxoTp776EgEnIEZURWkKyu6clMw4JrCk1HEHAYIPVG2x50i1SSVN+o/A1KoA4 BZuMTUU1+xEB0dB5ZEdgUsPMRjIL/c83UwV6a9wJ1GNpvGm4dAqsz6ridbf6M4wB1PYs l4jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696148139; x=1696752939; 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=kAQb2lcKCiK4nVCJ/kUlHxpo3G9oP8wSrjvkHy883UA=; b=PjKJC0Vnd6gA6B+vlYvnBtVho0pFfpfmXL5lFJM6kSE+yjExycnB7VRp43+5x4OiPA 8zjWjb2DptN7qxIYxYhptcKUgsZfgz3bpwwUsvwe5RlrmMAl3iu8RVmr2SOUJm2TbqsU TWZNMUI06KBU6mMJ+oTjj9MWm0tuQ8zqA0fDoBlxllvMSR+aIBxxaJIr5lyNtl7IwXVL KnN3guKppSUQMLXd2fbCsGuTNlcqQug4hBfp0w9O2Mcop2gEJrDr7D3gO6r8v4kmduOO gfYvky9Qd/1TFsPbE7bOzMOQRvs2mSV4/J+eNCRWZ9bX7danLacU0bzeXkNgtI46EXDU EWgA== X-Gm-Message-State: AOJu0Yz5oq3OYQvKzBQVApDwOLJbQivh3svKcDScOZV1ujVGM8cdRBuT yn8E25lZnZy4I8f2Yf7dP58= X-Received: by 2002:a17:906:54:b0:9a2:295a:9bbc with SMTP id 20-20020a170906005400b009a2295a9bbcmr6556487ejg.37.1696148139314; Sun, 01 Oct 2023 01:15:39 -0700 (PDT) Received: from primary.. ([213.139.52.198]) by smtp.gmail.com with ESMTPSA id e8-20020a170906374800b0099cf840527csm15121841ejc.153.2023.10.01.01.15.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 01:15:39 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ryan.eleceng@gmail.com, robh+dt@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org, Abdel Alkuor Subject: [PATCH v9 12/14] USB: typec: tps6598x: Add trace for tps25750 irq Date: Sun, 1 Oct 2023 04:11:32 -0400 Message-Id: <20231001081134.37101-13-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231001081134.37101-1-alkuor@gmail.com> References: <20231001081134.37101-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 01 Oct 2023 01:17:16 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778552162744714601 X-GMAIL-MSGID: 1778552162744714601 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 v9: - No changes 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 ddb5db7d5855..f775e479b92b 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 Sun Oct 1 08:11:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 147150 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1025373vqb; Sun, 1 Oct 2023 12:36:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHUNiBJEFbmJRmWKXEXRUOmwZAtt7FuRq2ZoKXPPn4AQvQtel3q615DDplOeDTAtlX337AE X-Received: by 2002:a05:6a20:7d99:b0:140:3aa:e2ce with SMTP id v25-20020a056a207d9900b0014003aae2cemr11918346pzj.42.1696188965097; Sun, 01 Oct 2023 12:36:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696188965; cv=none; d=google.com; s=arc-20160816; b=SgPQSxp/99sxiFRJeSLxfkVQrTbpgdft4SkE92RcEaMVr62PEHzkDESF/zzMiB/W0n N3AjJmMdjNAVqX22f88sGpmZfjlPQjtjQAW46UJf78ZWQHpdRQ7jJaOITfK9BYHlpqoE 9qL0uSiSvWMI5nBl5AAoNyfMiC4ogzbIrgtyIZk9O1RMeK0uhAtOyR59qLu8Ks0cia58 IzCG0X5LKLwDP1yVg4RD22RhcVaxFSOcAwADz2h6KxOgkBXFaU+MFcZA3xmh4WtjXtb4 ZqMHxCaZ8OvIObLVpcbATBrK89gJglE+7mdpoigCid8gPqaS5IZqnuT2wRLnekRD+4Cg G5Hw== 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=1AZ7TZBuxgbfz7hxQq4OKpZkJG9RmU/3ei2xqClWle4=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=jptl0OlBHmnEy5UrIJwIMPyTtYs7CJLl45qrhExTMwYfSZ3qfrrJ0t2EJZ+lwFwNB4 /Ud7w9Dz/g8olbHvqaUjNR1/hzPkBnNjbogcOZPLad7RlWve4xzh2uHQT3gfUFE//Xxp Ve8t1BnV4tG52HTkFqGKt7iw8pRvZFUzHKF7N7qgi6j61/w8uHW82qnasgnBw0IEy78S /2d55hhwrFhbHyel4rEON6UbeBR2zA8tSoy8rbrX2tTRPW3JCSJsZtRh74t4FZHbzrXL 8cY37gzMnLVI33F1QvLNVSs5cbYZqEixaOwr5Hdqlo6F8uosx1ITL1sMzUuvWR3yutsw J/GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WOTZWAzM; 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 b132-20020a63348a000000b005787de7abd4si25811392pga.12.2023.10.01.12.36.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 12:36:05 -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=WOTZWAzM; 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 3E05F80ECFBB; Sun, 1 Oct 2023 01:16:39 -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 S234524AbjJAIQL (ORCPT + 19 others); Sun, 1 Oct 2023 04:16:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234684AbjJAIP7 (ORCPT ); Sun, 1 Oct 2023 04:15:59 -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 DDE3ED8; Sun, 1 Oct 2023 01:15:42 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-9b2f73e3af3so104822066b.3; Sun, 01 Oct 2023 01:15:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696148141; x=1696752941; 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=1AZ7TZBuxgbfz7hxQq4OKpZkJG9RmU/3ei2xqClWle4=; b=WOTZWAzMEM9gMUlOPlCXO7csP0dvE3ckA2yNjNOsq5mxMImeWTPcwL+lNg1eaCGIYP HRXFnyE+AVetatYGYYfWS8FzXPMjB1Gsp5YD/PTyNvcJwNM9jE2UZsc9LuMdx0uRzKW8 mEiHu2yLT1rMuzeRJB76W2F8BTJ27aOPzU02llSyalLChm9fIPlGg235hfVm8H7Ao/Pr nh0jq+z2GJNlPjaRpogCwFSNTqyMl9FvzHWP+BF5In1H6Kdnp2shcF7ri3jS+YTfDBv1 GZ2nEiMSs25rRd+Y84Wv9ZJsyATMGHv5wyg/GKk262IpqeQA4TKaC/pNwKiNiawrJrYy wXZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696148141; x=1696752941; 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=1AZ7TZBuxgbfz7hxQq4OKpZkJG9RmU/3ei2xqClWle4=; b=ZeHirWpfa1Px/Mp/L+2/0MsUc8WObCSXLEcYm4o4EBdwdOA9l/lB0TZ+19zp6nBzwP exK8+Dm3UkfkC2df6X8IrZ+WdwraHTWXwZmvn/QUSGWJBjSPvtX82se1SSnFQRb9aklb 7sR15kV2Vz5Uv9nkhUnSVN+5HhgT7V9l4qZPLqUStYdZrH++PfgS7EI6AtNfYBNaLivF DHLaPyVb4VlAPw1f2RcdSBeMICUXC8E/5v96IKSk/5GSQHwlJE7uAIKHPIvJ1iKcJtnt 9aocTa9Qg09YfvD9uEW4fqD4LtlghZilyyV7LXf8bRjWc/DauOwwAD5uFFsZzr28VifQ Jz/A== X-Gm-Message-State: AOJu0Yy3vXyWJPkdL4wQN1iWpCa+X5W18BXsEohtgVi8FVBfIOPTLK4F v7TyZDTUBAPbuugWTQVluW4= X-Received: by 2002:a17:907:724b:b0:9ae:7870:1532 with SMTP id ds11-20020a170907724b00b009ae78701532mr8624554ejc.58.1696148141148; Sun, 01 Oct 2023 01:15:41 -0700 (PDT) Received: from primary.. ([213.139.52.198]) by smtp.gmail.com with ESMTPSA id e8-20020a170906374800b0099cf840527csm15121841ejc.153.2023.10.01.01.15.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 01:15:40 -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 v9 13/14] USB: typec: tps6598x: Add power status trace for tps25750 Date: Sun, 1 Oct 2023 04:11:33 -0400 Message-Id: <20231001081134.37101-14-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231001081134.37101-1-alkuor@gmail.com> References: <20231001081134.37101-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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]); Sun, 01 Oct 2023 01:16:39 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778583040352837548 X-GMAIL-MSGID: 1778583040352837548 From: Abdel Alkuor tps25750 power status register is a subset of tps6598x power status register. Signed-off-by: Abdel Alkuor --- Changes in v9: - Move device data structs to the top of of_device_id 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 f775e479b92b..a114e786b1a7 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; } @@ -1392,16 +1395,19 @@ static const struct dev_pm_ops tps6598x_pm_ops = { 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 Sun Oct 1 08:11:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 147051 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp783349vqb; Sun, 1 Oct 2023 02:26:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHXg7a8YI6f62V+/RB/pSql1AHJyEURtHX21E/4fgRn5OntGD7b/hcSk/zUSwPYju8Ai26t X-Received: by 2002:a05:6a21:3e05:b0:157:877a:5f5e with SMTP id bk5-20020a056a213e0500b00157877a5f5emr6935890pzc.61.1696152409485; Sun, 01 Oct 2023 02:26:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696152409; cv=none; d=google.com; s=arc-20160816; b=navdbVT9ZyHJZcA9zp1fEu1JfJgaqk2XMG7PX+z5FMsmrW00KO/Qrg+0n5lfLJcCcR EP/C7F6i184KVZFPbJdko6K5gyvbA7n5cSfYcRsaR2F66Iogl/Mwai5KJiLOSPgha/L4 PSUOoNWo25Z6M1PtjJAs96F2gJBjB9rrw13QaPqIIZ4B6JX7d6ZLXIJ6cJN2+wSZvpS2 WGD06xSfCq5aeLP3uEDAAVvA1c3oBlDrGgUSVFjZgjeQTuSy5T9hXUAYhNuFZ0SUDBi2 Ews2UlpCYgmN7aFNmsC/7cUUo0ydntBGlgTG3nhCHD7EieJNGE3OX+7NG+zuSFhbttv3 XlaA== 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=rhlGRH7X7YHOrcRNVN9EVkoiyHqqCPmAlgcebPmFLo8=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=e4E2F4jjL4fnsQzPhqgIoiqW6ERhGhHWcCey0w8ZnMlHxCDmo698fzbrboN1Rvb2zB ugUNUadJrDv0pfAgnfkeK9iwi9bqJ6oMbHN2bgGWA3x7aRxzmVx08FeUyvO3iq19gMGA wztRNzSnaFcS+CWGWCwexwD8KedzMRgYuyJ/wGnLZiLKJVX4NQsWoO/vtvWPLmgs2DFO 35soZngA/nlgHBS36tIiug/Am3zylWvpd2pbjL26abrF3vkNsgg8fPtkh8Hp2W+Zc/OI a3VSmySqFBtHnTwkvaz3DHSM0g3PzKmJIdPTbZxERGsfYU3rNyfpprjsE6Hg9tPK7G1r j9vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AU+hOTja; 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 s17-20020a170902ea1100b001c61817e049si18239094plg.67.2023.10.01.02.26.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 02:26:49 -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=AU+hOTja; 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 08CAA80EBC93; Sun, 1 Oct 2023 01:16:42 -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 S234506AbjJAIQO (ORCPT + 19 others); Sun, 1 Oct 2023 04:16:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234606AbjJAIP7 (ORCPT ); Sun, 1 Oct 2023 04:15:59 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4521112; Sun, 1 Oct 2023 01:15:44 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-99c3c8adb27so2163070066b.1; Sun, 01 Oct 2023 01:15:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696148143; x=1696752943; 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=rhlGRH7X7YHOrcRNVN9EVkoiyHqqCPmAlgcebPmFLo8=; b=AU+hOTjasd/4MciaWhSvKzAhLkPgbHHO6nSv7VIBG8zQZZfuu1CJTiEp7DFK6T0mS/ vvFtlLl4pio/fCANs9P2GBqRB228FKMKhwTAz+wEGS0y5OKhgbkjcKwolJL9RX2AQgU2 oMtp9L5fLPs0BLWxuYjOb+n+940p86ElCg9DjJJxD/IkD8fcjv/j+OCHC+trjMtZaJOw 9OTrwDSFaTJdQQeZh5a0CHl1dDKdviMq8UTCzxE4THO8uLufmCScWqb0/RybesQ7qYcJ NnV+O7Xk6R2kcRByi40agn033Vh1SIV4nGr8AO8DZu2jO2U3D0i7DgcTFYYzrYbDp2ki PsIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696148143; x=1696752943; 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=rhlGRH7X7YHOrcRNVN9EVkoiyHqqCPmAlgcebPmFLo8=; b=KoJ15vdNGexiKlx0ecUxmkA4vpan4B0WDtFpSQR0OUdzwRXgR/yhoJaytvsxlz2BXz BFlUwzuK0pfRrkxjEQVKYltfOBiFCdYn0An0BuCMBHownBRKL2eh9nuO5a5pMowtZY2U 0wtHltIEHNw0fHQSkLha59WBbQmK6thdPOD2BYkL82cJZ+7ZX3h8XwZdiIyGHDZiIh0T nh5ZXIn/AmYY7xED8kycHdQaEZ3DCWXkiDijm4yWJvLMikU6NWeNpUUVcgRfh6kBkL9O 3Cw1r0u4DEN0wKB0/Yw22PKmW/8eSgMDPhyOh0966/slKpFx2cCN5Zi5lgqv93tyr8wE hHcQ== X-Gm-Message-State: AOJu0YwzRBNaYIRRp2EoyNXatnwGo0TMesEeeODdid8K9BLwtdhnQkUU j9FFxB0mIx28w2BSRMqtBHo= X-Received: by 2002:a17:907:1dca:b0:9ae:43be:e5f5 with SMTP id og10-20020a1709071dca00b009ae43bee5f5mr7639080ejc.4.1696148143008; Sun, 01 Oct 2023 01:15:43 -0700 (PDT) Received: from primary.. ([213.139.52.198]) by smtp.gmail.com with ESMTPSA id e8-20020a170906374800b0099cf840527csm15121841ejc.153.2023.10.01.01.15.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 01:15:42 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, 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 v9 14/14] USB: typec: tps6598x: Add status trace for tps25750 Date: Sun, 1 Oct 2023 04:11:34 -0400 Message-Id: <20231001081134.37101-15-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231001081134.37101-1-alkuor@gmail.com> References: <20231001081134.37101-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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]); Sun, 01 Oct 2023 01:16:42 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778544708998428041 X-GMAIL-MSGID: 1778544708998428041 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 v9: - Move device data structs to the top of of_device_id 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 a114e786b1a7..4f2bfa19d2f5 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; } @@ -1243,10 +1246,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 @@ -1396,18 +1397,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[] = { 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),