From patchwork Fri Oct 20 10:35:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Weiss X-Patchwork-Id: 155971 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp959921vqb; Fri, 20 Oct 2023 03:36:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFIzMsONYOeqvdDZb9UzmSaJLch7E5oQ1jVGmMMUHGLM1LZeH64IwyJ1IsRYyOMHUDOWgPo X-Received: by 2002:a17:902:d48a:b0:1ca:86db:1d44 with SMTP id c10-20020a170902d48a00b001ca86db1d44mr1434536plg.50.1697798196384; Fri, 20 Oct 2023 03:36:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697798196; cv=none; d=google.com; s=arc-20160816; b=XFySvJi1ij9u6CG331FrhamqH4yzo8IdFXgJN70Iz9NLPFUKoXM8odVYMHZ9zmoGgm i/JyaztBaOLa930cUn2Q+DRGDV3mVRgj+ustO+f59givhqttv3A/oJmTLj/svDZWj0xj BBJXBBR0zFaOL3HOGuZ2Nj/3yBqYgS84fdl7vXHKj6QLtdxcicU5dt5khbGIiLJNWGee BKXqU4+M7qG+aIIrprIK5+K9t/9XqS/j3H/eKqLUEXhEidXrhx528ZVkIpv2uaQP2JPp rrjR60JYwt8u/zYBr+xcovE/Gty73ycVzC5l9pdnh0djXIGbgwxTtyv7VH8SG2PksWWJ 35dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=zcOsTWZFgk36Pr6gD973XFfrWfkQhr13IcUUfM7456o=; fh=VOqehVQMm+rGQ4A4INzFYEVyQsgKdwliE7lpdIg/FeQ=; b=WcsXVgaEPhX8fvVX0aa5tWmZlJsck078GCbxcmLaUEST+CfxwdncbdP7nsjMVUTXko oc6DSOviyELoR4yOZPY17xqI6i1hiQlRhg1CPOCGM4weJJuxmf4MRLkIMj5eo8UmIX3Z 884iIniwE5jwb9KUVoIc5JAvNG+xjkqcGv79GmDTyRzsQfwtdd+M5iy6WvQ9jyfcENuf ZClGn/GgLTgfaoLm1H95G2iSFUE2AiL3vN5KZ4CyzLsF7RpYuGPsCnTDdqYJsi0CT8/F xbb88QaJ7fQqSSbtX3Vv542cxsc2oD83dQkZJcnLHXXuC52Kcw/VnuMzZwSIPrfEw5GO h/AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fairphone.com header.s=fair header.b=B3HpL9rw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fairphone.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id o13-20020a170902d4cd00b001bc17ab8d6esi1634024plg.530.2023.10.20.03.36.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 03:36:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@fairphone.com header.s=fair header.b=B3HpL9rw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fairphone.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 8D82582D9964; Fri, 20 Oct 2023 03:36:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376990AbjJTKgM (ORCPT + 25 others); Fri, 20 Oct 2023 06:36:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376957AbjJTKf7 (ORCPT ); Fri, 20 Oct 2023 06:35:59 -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 8804ED61 for ; Fri, 20 Oct 2023 03:35:52 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-9ba1eb73c27so105794066b.3 for ; Fri, 20 Oct 2023 03:35:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fairphone.com; s=fair; t=1697798151; x=1698402951; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=zcOsTWZFgk36Pr6gD973XFfrWfkQhr13IcUUfM7456o=; b=B3HpL9rwjP58F9+ojrAYWhu0KKiuIa9tjlrJWOUopb8kGUUHqTYSXloUhow/KsMnL6 vBnZioIZ5CeUdV+HtrBwgtgMvtj2gfesgi4u5ghTMW0wJttqsMem5C0FltBKhyehrYKD EVBN2rp7rrldWw2WWydUEidCZ0S0slEDHUO4SLB07VGmplKuWiLZIMQei+4K8Bf7rjqS Lgt8uVZlC2lklG9CwUycytTDOnLmO0rOsJgqbCL2mSIuoM9RZk8j3cWxwHtgEw179I3W GV241vorvwQb0LHP557m2eYz8Cfs0KGmVKuclyoUFI+GSHlGlRsPoyu45XVSaNRki4DF qvtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697798151; x=1698402951; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zcOsTWZFgk36Pr6gD973XFfrWfkQhr13IcUUfM7456o=; b=LNCsuqF5RTRhpifwHtVwgPoasIwp8qE2EtAfQ5CNjGSPgSMy3nuA+QN0HW0u1oyoh8 dSEPU7oW+jz4nk2jC1EEeKj6fMSc8Lpezub4PM1A1W65RCyivGku4DlYtk9RM4pfOptX kQzDOouRaZHa4r+sz3GM041kEwAzuQJascMSekqEZDIBAuMgXWiBUeFxcuezsNYmUr8f J/aPBTyUwXKhmUPptJoNiGaJ9ORWfs5vh7Zecj0/4ynAoZO6EQjpQx1w3SI+6hjzSLk9 CdMKLAM6RcIFGwmHQm6W98grEKzMBvROCwtyQ54YMVqBoiLoMVRmJig9QhkZ0mCWzKzc 1I0w== X-Gm-Message-State: AOJu0YxawmgEGmEgLNBeBnaoNj0B3QqbRqYyAc4kA1lmUZdz0s++WGLb iIg2biRNfc1bbZeV+6NIJtVzdw== X-Received: by 2002:a17:906:fe04:b0:9c3:cd12:1925 with SMTP id wy4-20020a170906fe0400b009c3cd121925mr966287ejb.58.1697798150757; Fri, 20 Oct 2023 03:35:50 -0700 (PDT) Received: from otso.luca.vpn.lucaweiss.eu (k10064.upc-k.chello.nl. [62.108.10.64]) by smtp.gmail.com with ESMTPSA id h7-20020a1709063c0700b0099c53c4407dsm1226701ejg.78.2023.10.20.03.35.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 03:35:50 -0700 (PDT) From: Luca Weiss Date: Fri, 20 Oct 2023 12:35:46 +0200 Subject: [PATCH v2 1/2] dt-bindings: usb: add NXP PTN36502 Type-C redriver bindings MIME-Version: 1.0 Message-Id: <20231020-ptn36502-v2-1-b37a337d463e@fairphone.com> References: <20231020-ptn36502-v2-0-b37a337d463e@fairphone.com> In-Reply-To: <20231020-ptn36502-v2-0-b37a337d463e@fairphone.com> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heikki Krogerus , Liam Girdwood , Mark Brown , Dmitry Baryshkov Cc: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Luca Weiss , Krzysztof Kozlowski X-Mailer: b4 0.12.3 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 fry.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 (fry.vger.email [0.0.0.0]); Fri, 20 Oct 2023 03:36:32 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780270441873788272 X-GMAIL-MSGID: 1780270441873788272 Document bindings for this Type-C USB 3.1 Gen 1 and DisplayPort v1.2 combo redriver. The PTN36502 can also run in GPIO mode where it is configured differently, without any I2C connection, but this is not supported yet. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Luca Weiss --- .../devicetree/bindings/usb/nxp,ptn36502.yaml | 94 ++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/nxp,ptn36502.yaml b/Documentation/devicetree/bindings/usb/nxp,ptn36502.yaml new file mode 100644 index 000000000000..eee548ac1abe --- /dev/null +++ b/Documentation/devicetree/bindings/usb/nxp,ptn36502.yaml @@ -0,0 +1,94 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/usb/nxp,ptn36502.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NXP PTN36502 Type-C USB 3.1 Gen 1 and DisplayPort v1.2 combo redriver + +maintainers: + - Luca Weiss + +properties: + compatible: + enum: + - nxp,ptn36502 + + reg: + maxItems: 1 + + vdd18-supply: + description: Power supply for VDD18 pin + + retimer-switch: + description: Flag the port as possible handle of SuperSpeed signals retiming + type: boolean + + orientation-switch: + description: Flag the port as possible handler of orientation switching + type: boolean + + ports: + $ref: /schemas/graph.yaml#/properties/ports + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: Super Speed (SS) Output endpoint to the Type-C connector + + port@1: + $ref: /schemas/graph.yaml#/properties/port + description: Super Speed (SS) Input endpoint from the Super-Speed PHY + + port@2: + $ref: /schemas/graph.yaml#/properties/port + description: + Sideband Use (SBU) AUX lines endpoint to the Type-C connector for the purpose of + handling altmode muxing and orientation switching. + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + typec-mux@1a { + compatible = "nxp,ptn36502"; + reg = <0x1a>; + + vdd18-supply = <&usb_redrive_1v8>; + + retimer-switch; + orientation-switch; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + usb_con_ss: endpoint { + remote-endpoint = <&typec_con_ss>; + }; + }; + port@1 { + reg = <1>; + phy_con_ss: endpoint { + remote-endpoint = <&usb_phy_ss>; + }; + }; + port@2 { + reg = <2>; + usb_con_sbu: endpoint { + remote-endpoint = <&typec_dp_aux>; + }; + }; + }; + }; + }; +... From patchwork Fri Oct 20 10:35:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Weiss X-Patchwork-Id: 155972 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp960033vqb; Fri, 20 Oct 2023 03:36:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEIbVKP2FHQEfOjsuRaU/zVdXLfD+A7NID2AeyW2TwmvogGMJgNZlD2yelKrZMTl5RVy2rW X-Received: by 2002:a05:6a21:3d85:b0:154:e887:f581 with SMTP id bj5-20020a056a213d8500b00154e887f581mr1337965pzc.58.1697798213772; Fri, 20 Oct 2023 03:36:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697798213; cv=none; d=google.com; s=arc-20160816; b=BSMgvK++pxdHebm3eHnqgTo9fBnbMvXIpf3cFGjLkroAbJFjG61RG7ySSeweVgKX8h sNO4jtbD9LxZqc69ESxeJIei2q8W4rdZkKdmWRaY3kHcxc/YK+OAZHAspTsKJxdtqz85 BkdkmH13gJGOqw4WiidJlK33X/U0akXoGVrzHm8xvTGltC7C1owo8I4DuRcbGMj7ncOb e0A3ILQ0K7RD5cXcyjWfKtcYjxKH1vwdHnz09LE6dyRcAERB2ocl/ChEyZb3Equ56UQk jVVUuXJMcKsZzmizks59uVNqC6PpNfirUQGgyHisqh0iskBDV1pb7jqc5tSrmhoHniGg vjDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=MpUgRpro849XsHd37T9qHH8WNDWZQTZ1RSHBQlvkvCI=; fh=TrJ7bhIcY5I2XU10ce7ir5F6EjOezYVNk+TamR8A+Wc=; b=sz99njGZDjCiJIsm0O+qvbGzSnJzS3D+/wST7zVDpqv9F9xIZ6T2l2twgPWc75CRWp QPTy6FXDxKQjF9/k/vMzHrzA22mSSKttEBWD9W4QcJgfj2lkqVZt5tfmiVJuujhYFN0n MXcRd7Ql7VSpRMy1VLU6tgCZbEvzRDBQP0OXQkkyZK4oL+SWI6yalthbR2wsfzklyzRt ZBoPVmWAw8HdMbWVWEda3ECeKhhLB0sgzwSg2ZEs9NfeKd+o5ZaidJSGLrV3k5FhEJWF tEDZZBGC1lgZj/GhD4GdUWdBZy3SQXoZOXL+vW8OqaBOrx0UCUPhynR7MLpvE8IU60A9 LdaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fairphone.com header.s=fair header.b=N47yRFrW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fairphone.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id z1-20020a17090ab10100b0027ce6cd3144si4062951pjq.126.2023.10.20.03.36.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 03:36:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@fairphone.com header.s=fair header.b=N47yRFrW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fairphone.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id D6F1E82878AD; Fri, 20 Oct 2023 03:36:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377001AbjJTKgO (ORCPT + 25 others); Fri, 20 Oct 2023 06:36:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376989AbjJTKgA (ORCPT ); Fri, 20 Oct 2023 06:36:00 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62310D67 for ; Fri, 20 Oct 2023 03:35:53 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-9ba081173a3so106895566b.1 for ; Fri, 20 Oct 2023 03:35:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fairphone.com; s=fair; t=1697798152; x=1698402952; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=MpUgRpro849XsHd37T9qHH8WNDWZQTZ1RSHBQlvkvCI=; b=N47yRFrWN5+sbSx6Hr9l6iE3wCxPV5mgvpa20FVtt9ntTGJaOp1Ti4V0E4sYZdlCdG 5kIla/MULS9psLExWjbOofBnWKoyO331ZSFWRuW4FR3JbXAUjA6zJzFdCvF7cXSN87dB bp+DevuCTL0w5bX6psWQDYrVQlPr9APu9pMFeDRCq/UpKqp3VV0ChbNGrb8wkY3DJs+U LaXxwXNFYfXEk7N4GtLvIHSUSAtR1NDWFYX/XJKXPWXU4mGUMSm3TqNrnG1ltHgvEU6q mMnCr9Cp51aqmUTnMKJB3g4d3WkrInZNGNVm5UNKjnhRm70hY6e8sfALlBgF/g+5+7DX 5wTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697798152; x=1698402952; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MpUgRpro849XsHd37T9qHH8WNDWZQTZ1RSHBQlvkvCI=; b=n0+pnAUYiaTDMruG1UjFVYWUnxjDTBUX1yIdPUqG4mK4R9Ww9z3Dot/XYoZuA8pOK/ 4MS/ZzUyDiaEDdZerfVSPZYhVh3haZ27A8n14O4+p2jwqfqy51l/KBypfXMQ7dNNwyhF lTJ/kgOqDU5NM+bUpNnW292RU3CHbt6LGfMtvDbMOrsg+TGYxTbbOt5hVLXMZGYA7JZU /57iuOpDWXH8317WaJRrgTEKVTwLrfprv7OKXU/a5FEIEC3NY6mIE0fClovJavIj7XQw 6LnCwBREATJVB6qDaPt5vO611jDQ+9+j12w5fGdrUjUoye+UzOF/YkqXvILq9IvT2o37 axUQ== X-Gm-Message-State: AOJu0Ywvss+WwouhZm68qHoKBvSwaamovXAz2+kMtANTlPpkUe47fuoF /VOG/6HljxCp3X65J5Aq0IFsFCuZAtevsyo7gLLXPw== X-Received: by 2002:a17:907:9815:b0:9be:7b67:1674 with SMTP id ji21-20020a170907981500b009be7b671674mr1047496ejc.3.1697798151819; Fri, 20 Oct 2023 03:35:51 -0700 (PDT) Received: from otso.luca.vpn.lucaweiss.eu (k10064.upc-k.chello.nl. [62.108.10.64]) by smtp.gmail.com with ESMTPSA id h7-20020a1709063c0700b0099c53c4407dsm1226701ejg.78.2023.10.20.03.35.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 03:35:51 -0700 (PDT) From: Luca Weiss Date: Fri, 20 Oct 2023 12:35:47 +0200 Subject: [PATCH v2 2/2] usb: typec: add support for PTN36502 redriver MIME-Version: 1.0 Message-Id: <20231020-ptn36502-v2-2-b37a337d463e@fairphone.com> References: <20231020-ptn36502-v2-0-b37a337d463e@fairphone.com> In-Reply-To: <20231020-ptn36502-v2-0-b37a337d463e@fairphone.com> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heikki Krogerus , Liam Girdwood , Mark Brown , Dmitry Baryshkov Cc: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Luca Weiss X-Mailer: b4 0.12.3 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 20 Oct 2023 03:36:49 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780270460059897881 X-GMAIL-MSGID: 1780270460059897881 Add a driver for the NXP PTN36502 Type-C USB 3.1 Gen 1 and DisplayPort v1.2 combo redriver. Reviewed-by: Heikki Krogerus Signed-off-by: Luca Weiss --- drivers/usb/typec/mux/Kconfig | 10 + drivers/usb/typec/mux/Makefile | 1 + drivers/usb/typec/mux/ptn36502.c | 444 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 455 insertions(+) diff --git a/drivers/usb/typec/mux/Kconfig b/drivers/usb/typec/mux/Kconfig index 65da61150ba7..816b9bd08355 100644 --- a/drivers/usb/typec/mux/Kconfig +++ b/drivers/usb/typec/mux/Kconfig @@ -46,4 +46,14 @@ config TYPEC_MUX_NB7VPQ904M Say Y or M if your system has a On Semiconductor NB7VPQ904M Type-C redriver chip found on some devices with a Type-C port. +config TYPEC_MUX_PTN36502 + tristate "NXP PTN36502 Type-C redriver driver" + depends on I2C + depends on DRM || DRM=n + select DRM_PANEL_BRIDGE if DRM + select REGMAP_I2C + help + Say Y or M if your system has a NXP PTN36502 Type-C redriver chip + found on some devices with a Type-C port. + endmenu diff --git a/drivers/usb/typec/mux/Makefile b/drivers/usb/typec/mux/Makefile index 76196096ef41..9d6a5557b0bd 100644 --- a/drivers/usb/typec/mux/Makefile +++ b/drivers/usb/typec/mux/Makefile @@ -5,3 +5,4 @@ obj-$(CONFIG_TYPEC_MUX_GPIO_SBU) += gpio-sbu-mux.o obj-$(CONFIG_TYPEC_MUX_PI3USB30532) += pi3usb30532.o obj-$(CONFIG_TYPEC_MUX_INTEL_PMC) += intel_pmc_mux.o obj-$(CONFIG_TYPEC_MUX_NB7VPQ904M) += nb7vpq904m.o +obj-$(CONFIG_TYPEC_MUX_PTN36502) += ptn36502.o diff --git a/drivers/usb/typec/mux/ptn36502.c b/drivers/usb/typec/mux/ptn36502.c new file mode 100644 index 000000000000..72ae38a1b2be --- /dev/null +++ b/drivers/usb/typec/mux/ptn36502.c @@ -0,0 +1,444 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * NXP PTN36502 Type-C driver + * + * Copyright (C) 2023 Luca Weiss + * + * Based on NB7VPQ904M driver: + * Copyright (C) 2023 Dmitry Baryshkov + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PTN36502_CHIP_ID_REG 0x00 +#define PTN36502_CHIP_ID 0x02 + +#define PTN36502_CHIP_REVISION_REG 0x01 +#define PTN36502_CHIP_REVISION_BASE_MASK GENMASK(7, 4) +#define PTN36502_CHIP_REVISION_METAL_MASK GENMASK(3, 0) + +#define PTN36502_DP_LINK_CTRL_REG 0x06 +#define PTN36502_DP_LINK_CTRL_LANES_MASK GENMASK(3, 2) +#define PTN36502_DP_LINK_CTRL_LANES_2 (2) +#define PTN36502_DP_LINK_CTRL_LANES_4 (3) +#define PTN36502_DP_LINK_CTRL_LINK_RATE_MASK GENMASK(1, 0) +#define PTN36502_DP_LINK_CTRL_LINK_RATE_5_4GBPS (2) + +/* Registers for lane 0 (0x07) to lane 3 (0x0a) have the same layout */ +#define PTN36502_DP_LANE_CTRL_REG(n) (0x07 + (n)) +#define PTN36502_DP_LANE_CTRL_RX_GAIN_MASK GENMASK(6, 4) +#define PTN36502_DP_LANE_CTRL_RX_GAIN_3DB (2) +#define PTN36502_DP_LANE_CTRL_TX_SWING_MASK GENMASK(3, 2) +#define PTN36502_DP_LANE_CTRL_TX_SWING_800MVPPD (2) +#define PTN36502_DP_LANE_CTRL_PRE_EMPHASIS_MASK GENMASK(1, 0) +#define PTN36502_DP_LANE_CTRL_PRE_EMPHASIS_3_5DB (1) + +#define PTN36502_MODE_CTRL1_REG 0x0b +#define PTN36502_MODE_CTRL1_PLUG_ORIENT_MASK GENMASK(5, 5) +#define PTN36502_MODE_CTRL1_PLUG_ORIENT_REVERSE (1) +#define PTN36502_MODE_CTRL1_AUX_CROSSBAR_MASK GENMASK(3, 3) +#define PTN36502_MODE_CTRL1_AUX_CROSSBAR_SW_ON (1) +#define PTN36502_MODE_CTRL1_MODE_MASK GENMASK(2, 0) +#define PTN36502_MODE_CTRL1_MODE_OFF (0) +#define PTN36502_MODE_CTRL1_MODE_USB_ONLY (1) +#define PTN36502_MODE_CTRL1_MODE_USB_DP (2) +#define PTN36502_MODE_CTRL1_MODE_DP (3) + +#define PTN36502_DEVICE_CTRL_REG 0x0d +#define PTN36502_DEVICE_CTRL_AUX_MONITORING_MASK GENMASK(7, 7) +#define PTN36502_DEVICE_CTRL_AUX_MONITORING_EN (1) + +struct ptn36502 { + struct i2c_client *client; + struct regulator *vdd18_supply; + struct regmap *regmap; + struct typec_switch_dev *sw; + struct typec_retimer *retimer; + + struct typec_switch *typec_switch; + + struct drm_bridge bridge; + + struct mutex lock; /* protect non-concurrent retimer & switch */ + + enum typec_orientation orientation; + unsigned long mode; + unsigned int svid; +}; + +static int ptn36502_set(struct ptn36502 *ptn) +{ + bool reverse = (ptn->orientation == TYPEC_ORIENTATION_REVERSE); + unsigned int ctrl1_val = 0; + unsigned int lane_ctrl_val = 0; + unsigned int link_ctrl_val = 0; + + switch (ptn->mode) { + case TYPEC_STATE_SAFE: + /* Deep power saving state */ + regmap_write(ptn->regmap, PTN36502_MODE_CTRL1_REG, + FIELD_PREP(PTN36502_MODE_CTRL1_MODE_MASK, + PTN36502_MODE_CTRL1_MODE_OFF)); + return 0; + + case TYPEC_STATE_USB: + /* + * Normal Orientation (CC1) + * A -> USB RX + * B -> USB TX + * C -> X + * D -> X + * Flipped Orientation (CC2) + * A -> X + * B -> X + * C -> USB TX + * D -> USB RX + */ + + /* USB 3.1 Gen 1 only */ + ctrl1_val = FIELD_PREP(PTN36502_MODE_CTRL1_MODE_MASK, + PTN36502_MODE_CTRL1_MODE_USB_ONLY); + if (reverse) + ctrl1_val |= FIELD_PREP(PTN36502_MODE_CTRL1_PLUG_ORIENT_MASK, + PTN36502_MODE_CTRL1_PLUG_ORIENT_REVERSE); + + regmap_write(ptn->regmap, PTN36502_MODE_CTRL1_REG, ctrl1_val); + return 0; + + default: + if (ptn->svid != USB_TYPEC_DP_SID) + return -EINVAL; + + break; + } + + /* DP Altmode Setup */ + + switch (ptn->mode) { + case TYPEC_DP_STATE_C: + case TYPEC_DP_STATE_E: + /* + * Normal Orientation (CC1) + * A -> DP3 + * B -> DP2 + * C -> DP1 + * D -> DP0 + * Flipped Orientation (CC2) + * A -> DP0 + * B -> DP1 + * C -> DP2 + * D -> DP3 + */ + + /* 4-lane DP */ + ctrl1_val |= FIELD_PREP(PTN36502_MODE_CTRL1_MODE_MASK, + PTN36502_MODE_CTRL1_MODE_DP); + link_ctrl_val |= FIELD_PREP(PTN36502_DP_LINK_CTRL_LANES_MASK, + PTN36502_DP_LINK_CTRL_LANES_4); + break; + + case TYPEC_DP_STATE_D: + case TYPEC_DP_STATE_F: /* State F is deprecated */ + /* + * Normal Orientation (CC1) + * A -> USB RX + * B -> USB TX + * C -> DP1 + * D -> DP0 + * Flipped Orientation (CC2) + * A -> DP0 + * B -> DP1 + * C -> USB TX + * D -> USB RX + */ + + /* USB 3.1 Gen 1 and 2-lane DP */ + ctrl1_val |= FIELD_PREP(PTN36502_MODE_CTRL1_MODE_MASK, + PTN36502_MODE_CTRL1_MODE_USB_DP); + link_ctrl_val |= FIELD_PREP(PTN36502_DP_LINK_CTRL_LANES_MASK, + PTN36502_DP_LINK_CTRL_LANES_2); + break; + + default: + return -EOPNOTSUPP; + } + + /* Enable AUX monitoring */ + regmap_write(ptn->regmap, PTN36502_DEVICE_CTRL_REG, + FIELD_PREP(PTN36502_DEVICE_CTRL_AUX_MONITORING_MASK, + PTN36502_DEVICE_CTRL_AUX_MONITORING_EN)); + + /* Enable AUX switch path */ + ctrl1_val |= FIELD_PREP(PTN36502_MODE_CTRL1_AUX_CROSSBAR_MASK, + PTN36502_MODE_CTRL1_AUX_CROSSBAR_SW_ON); + if (reverse) + ctrl1_val |= FIELD_PREP(PTN36502_MODE_CTRL1_PLUG_ORIENT_MASK, + PTN36502_MODE_CTRL1_PLUG_ORIENT_REVERSE); + regmap_write(ptn->regmap, PTN36502_MODE_CTRL1_REG, ctrl1_val); + + /* DP Link rate: 5.4 Gbps (HBR2) */ + link_ctrl_val |= FIELD_PREP(PTN36502_DP_LINK_CTRL_LINK_RATE_MASK, + PTN36502_DP_LINK_CTRL_LINK_RATE_5_4GBPS); + regmap_write(ptn->regmap, PTN36502_DP_LINK_CTRL_REG, link_ctrl_val); + + /* + * For all lanes: + * - Rx equivalization gain: 3 dB + * - TX output swing control: 800 mVppd + * - Pre-emphasis control: 3.5 dB + */ + lane_ctrl_val = FIELD_PREP(PTN36502_DP_LANE_CTRL_RX_GAIN_MASK, + PTN36502_DP_LANE_CTRL_RX_GAIN_3DB) | + FIELD_PREP(PTN36502_DP_LANE_CTRL_TX_SWING_MASK, + PTN36502_DP_LANE_CTRL_TX_SWING_800MVPPD) | + FIELD_PREP(PTN36502_DP_LANE_CTRL_PRE_EMPHASIS_MASK, + PTN36502_DP_LANE_CTRL_PRE_EMPHASIS_3_5DB); + regmap_write(ptn->regmap, PTN36502_DP_LANE_CTRL_REG(0), lane_ctrl_val); + regmap_write(ptn->regmap, PTN36502_DP_LANE_CTRL_REG(1), lane_ctrl_val); + regmap_write(ptn->regmap, PTN36502_DP_LANE_CTRL_REG(2), lane_ctrl_val); + regmap_write(ptn->regmap, PTN36502_DP_LANE_CTRL_REG(3), lane_ctrl_val); + + return 0; +} + +static int ptn36502_sw_set(struct typec_switch_dev *sw, enum typec_orientation orientation) +{ + struct ptn36502 *ptn = typec_switch_get_drvdata(sw); + int ret; + + ret = typec_switch_set(ptn->typec_switch, orientation); + if (ret) + return ret; + + mutex_lock(&ptn->lock); + + if (ptn->orientation != orientation) { + ptn->orientation = orientation; + + ret = ptn36502_set(ptn); + } + + mutex_unlock(&ptn->lock); + + return ret; +} + +static int ptn36502_retimer_set(struct typec_retimer *retimer, struct typec_retimer_state *state) +{ + struct ptn36502 *ptn = typec_retimer_get_drvdata(retimer); + int ret = 0; + + mutex_lock(&ptn->lock); + + if (ptn->mode != state->mode) { + ptn->mode = state->mode; + + if (state->alt) + ptn->svid = state->alt->svid; + else + ptn->svid = 0; // No SVID + + ret = ptn36502_set(ptn); + } + + mutex_unlock(&ptn->lock); + + return ret; +} + +static int ptn36502_detect(struct ptn36502 *ptn) +{ + struct device *dev = &ptn->client->dev; + unsigned int reg_val; + int ret; + + ret = regmap_read(ptn->regmap, PTN36502_CHIP_ID_REG, + ®_val); + if (ret < 0) + return dev_err_probe(dev, ret, "Failed to read chip ID\n"); + + if (reg_val != PTN36502_CHIP_ID) + return dev_err_probe(dev, -ENODEV, "Unexpected chip ID: %x\n", reg_val); + + ret = regmap_read(ptn->regmap, PTN36502_CHIP_REVISION_REG, + ®_val); + if (ret < 0) + return dev_err_probe(dev, ret, "Failed to read chip revision\n"); + + dev_dbg(dev, "Chip revision: base layer version %lx, metal layer version %lx\n", + FIELD_GET(PTN36502_CHIP_REVISION_BASE_MASK, reg_val), + FIELD_GET(PTN36502_CHIP_REVISION_METAL_MASK, reg_val)); + + return 0; +} + +#if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_DRM_PANEL_BRIDGE) +static int ptn36502_bridge_attach(struct drm_bridge *bridge, + enum drm_bridge_attach_flags flags) +{ + struct ptn36502 *ptn = container_of(bridge, struct ptn36502, bridge); + struct drm_bridge *next_bridge; + + if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) + return -EINVAL; + + next_bridge = devm_drm_of_get_bridge(&ptn->client->dev, ptn->client->dev.of_node, 0, 0); + if (IS_ERR(next_bridge)) { + dev_err(&ptn->client->dev, "failed to acquire drm_bridge: %pe\n", next_bridge); + return PTR_ERR(next_bridge); + } + + return drm_bridge_attach(bridge->encoder, next_bridge, bridge, + DRM_BRIDGE_ATTACH_NO_CONNECTOR); +} + +static const struct drm_bridge_funcs ptn36502_bridge_funcs = { + .attach = ptn36502_bridge_attach, +}; + +static int ptn36502_register_bridge(struct ptn36502 *ptn) +{ + ptn->bridge.funcs = &ptn36502_bridge_funcs; + ptn->bridge.of_node = ptn->client->dev.of_node; + + return devm_drm_bridge_add(&ptn->client->dev, &ptn->bridge); +} +#else +static int ptn36502_register_bridge(struct ptn36502 *ptn) +{ + return 0; +} +#endif + +static const struct regmap_config ptn36502_regmap = { + .max_register = 0x0d, + .reg_bits = 8, + .val_bits = 8, +}; + +static int ptn36502_probe(struct i2c_client *client) +{ + struct device *dev = &client->dev; + struct typec_switch_desc sw_desc = { }; + struct typec_retimer_desc retimer_desc = { }; + struct ptn36502 *ptn; + int ret; + + ptn = devm_kzalloc(dev, sizeof(*ptn), GFP_KERNEL); + if (!ptn) + return -ENOMEM; + + ptn->client = client; + + ptn->regmap = devm_regmap_init_i2c(client, &ptn36502_regmap); + if (IS_ERR(ptn->regmap)) { + dev_err(&client->dev, "Failed to allocate register map\n"); + return PTR_ERR(ptn->regmap); + } + + ptn->mode = TYPEC_STATE_SAFE; + ptn->orientation = TYPEC_ORIENTATION_NONE; + + mutex_init(&ptn->lock); + + ptn->vdd18_supply = devm_regulator_get_optional(dev, "vdd18"); + if (IS_ERR(ptn->vdd18_supply)) + return PTR_ERR(ptn->vdd18_supply); + + ptn->typec_switch = fwnode_typec_switch_get(dev->fwnode); + if (IS_ERR(ptn->typec_switch)) + return dev_err_probe(dev, PTR_ERR(ptn->typec_switch), + "Failed to acquire orientation-switch\n"); + + ret = regulator_enable(ptn->vdd18_supply); + if (ret) + return dev_err_probe(dev, ret, "Failed to enable vdd18\n"); + + ret = ptn36502_detect(ptn); + if (ret) + goto err_disable_regulator; + + ret = ptn36502_register_bridge(ptn); + if (ret) + goto err_disable_regulator; + + sw_desc.drvdata = ptn; + sw_desc.fwnode = dev->fwnode; + sw_desc.set = ptn36502_sw_set; + + ptn->sw = typec_switch_register(dev, &sw_desc); + if (IS_ERR(ptn->sw)) { + ret = dev_err_probe(dev, PTR_ERR(ptn->sw), + "Failed to register typec switch\n"); + goto err_disable_regulator; + } + + retimer_desc.drvdata = ptn; + retimer_desc.fwnode = dev->fwnode; + retimer_desc.set = ptn36502_retimer_set; + + ptn->retimer = typec_retimer_register(dev, &retimer_desc); + if (IS_ERR(ptn->retimer)) { + ret = dev_err_probe(dev, PTR_ERR(ptn->retimer), + "Failed to register typec retimer\n"); + goto err_switch_unregister; + } + + return 0; + +err_switch_unregister: + typec_switch_unregister(ptn->sw); + +err_disable_regulator: + regulator_disable(ptn->vdd18_supply); + + return ret; +} + +static void ptn36502_remove(struct i2c_client *client) +{ + struct ptn36502 *ptn = i2c_get_clientdata(client); + + typec_retimer_unregister(ptn->retimer); + typec_switch_unregister(ptn->sw); + + regulator_disable(ptn->vdd18_supply); +} + +static const struct i2c_device_id ptn36502_table[] = { + { "ptn36502" }, + { } +}; +MODULE_DEVICE_TABLE(i2c, ptn36502_table); + +static const struct of_device_id ptn36502_of_table[] = { + { .compatible = "nxp,ptn36502" }, + { } +}; +MODULE_DEVICE_TABLE(of, ptn36502_of_table); + +static struct i2c_driver ptn36502_driver = { + .driver = { + .name = "ptn36502", + .of_match_table = ptn36502_of_table, + }, + .probe = ptn36502_probe, + .remove = ptn36502_remove, + .id_table = ptn36502_table, +}; +module_i2c_driver(ptn36502_driver); + +MODULE_AUTHOR("Luca Weiss "); +MODULE_DESCRIPTION("NXP PTN36502 Type-C driver"); +MODULE_LICENSE("GPL");