From patchwork Mon Aug 22 15:35:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 599436 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E75DC32789 for ; Mon, 22 Aug 2022 07:34:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232107AbiHVHeI (ORCPT ); Mon, 22 Aug 2022 03:34:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229987AbiHVHeH (ORCPT ); Mon, 22 Aug 2022 03:34:07 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60073.outbound.protection.outlook.com [40.107.6.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB25113E37; Mon, 22 Aug 2022 00:34:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RN2Xu5LE0h4CMlIv5s6sJoAwKrItGYn6fQF0ET7OqRxEda0cI1o2dEniVnjaZNBLs2sp+k9WD0+up41ANDcTPUVgRc1ektTPA26wxT2D6L1PyeXzB3T37Oem6lL7KekGWya2+IZwCwAM3EwmDrcjVQqIKRVXVQDSfYrZdX8P+IgcRdP1rBBjsBjMgUvSOumO83pI3mQrs3YomRGJWXe2wRuoziYcflabp6xqaBV/8Gj9lzA8oM6icY3WpOr452LQvEUo2I9IxPws81z08A8MrF5oSPeHf8QLgPnVD1YKUuaGNQllTaGz9WBtvHu7u2j+cvCx2VfwArj3IU/SSpjJig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lhkJwv5lSpjISGi6XtvovAFceQS5R4Xat8havDNeYks=; b=Hv698puCPLT7Szx+S4cgwrbL7uWsjEXaHCI0cf6ioI6RSwMHGYBHDwas52isZV+jX3BjmhOGSXfXjaXL7qJMawfAPkXk+DUpHeUwOYApRG0KO1nyfoNb5apYqYZzP/L8HfaKL+kf0mtOqBtc8RkGwg/G1n4nEweh6qeNTZ9GrZ5/f7ESWTFPOJuzNfmDaJ/yccgThuqMr7fQLuBj1L7hXQZk+V2eUfQQfNoPl2Bta+/oSoC4kysT8Gy7daKwINsh9ZNzYI+KXjbIcMqcWkQGDy9n6mfl3z1jzNIrep+OTObOiiYgL6eG6lheI4oOdOeWoED5D+WJ5tTCcOztNHbdvw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lhkJwv5lSpjISGi6XtvovAFceQS5R4Xat8havDNeYks=; b=OPlg9EaVbs7Y291vtCNrWqc6cVoT4xacicaFoqEmOEmK7LmfU4/VbV5vdCn6gWKkJMoA7NstGrrUsVOTZzJORnD5FD7h0ihgONL6EVRONfBwd90dt+6wP+p6PRm6iLNiTkDuK+wPVoba6pG64f/Wizqpw0nTRet9AvKkIQX6lQo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8784.eurprd04.prod.outlook.com (2603:10a6:102:20f::23) by DB7PR04MB5530.eurprd04.prod.outlook.com (2603:10a6:10:83::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.21; Mon, 22 Aug 2022 07:34:04 +0000 Received: from PAXPR04MB8784.eurprd04.prod.outlook.com ([fe80::60b7:af13:8472:2e8c]) by PAXPR04MB8784.eurprd04.prod.outlook.com ([fe80::60b7:af13:8472:2e8c%4]) with mapi id 15.20.5546.022; Mon, 22 Aug 2022 07:34:04 +0000 From: Xu Yang To: heikki.krogerus@linux.intel.com, robh+dt@kernel.org, peda@axentia.se, shawnguo@kernel.org Cc: gregkh@linuxfoundation.org, linux@roeck-us.net, jun.li@nxp.com, xu.yang_2@nxp.com, linux-usb@vger.kernel.org, linux-imx@nxp.com, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/4] dt-bindings: connector: Add typec orientation switch properties Date: Mon, 22 Aug 2022 23:35:14 +0800 Message-Id: <20220822153517.3747679-2-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220822153517.3747679-1-xu.yang_2@nxp.com> References: <20220822153517.3747679-1-xu.yang_2@nxp.com> X-ClientProxiedBy: SI2PR02CA0033.apcprd02.prod.outlook.com (2603:1096:4:195::20) To PAXPR04MB8784.eurprd04.prod.outlook.com (2603:10a6:102:20f::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b1fd883f-3d51-4427-de95-08da8410b069 X-MS-TrafficTypeDiagnostic: DB7PR04MB5530:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d7AshOzXb+WN64w+jZ8g2c8JWJ+K7VTcoN+Y/6Gl3xygyhU0GWQbgIBL/E5/7vy8lDYfvY9ouUEvmadLTn6xfCBDds1hQs5fEPQyX+35ttotl+SqhVZKavGNkB0Z/bsScOcAlnEnvEQaQZ523wb1HoZeCMuFmN7iyWCzzn4nz/58oepmDc3Wx4Xn5bxDW07yGdj7ZuBYUCQHxJ9/MHUmgNYhYBv/L2+1yvdtP6apF6RI1+jdtc9I7L51Pk28rcB57w7l71txpNZ+RP7iZ3JCsOBE+gEU+gSwzLac8GoJyZLrG8MsgGJMn81ft2xiC8mcsfF35WYDR4payuv4vY/4SLhy+98VUL888HvFMWu2o6uvQlpoP//DO5Lx/en1dJsy/cRxbEpuP4N9+INary6sTGINDdYJWw74Rpi2hOvvIeuU69+VOZYKOm9i7de4bTHelhXV1hm5NPRN6JN4rZ7dHdnTmdhq1IvzVML1dRi6jo3jBodBDAnmM48j9suoRN95oVdWTnbvvfwApj63zP5VP7Pp5TFnd85dy2QJwYhrjSZgfIr8pU+stvVkiI1269sOP149Gek7DxdUVLHA9Lr5PS4NxaNfCGS6f7/GRsD+0LJkbVGkYk2FiipVLZnqvvflI4RHZ0fDxBL3XzGjbQ+5rGj6wsocCRukq8QsJ34gIZVTmA4Psr/T7pxKkR1+FwgDJmPYmh6wiThgwcMckuDg6fhUnVyPsPvTZh/AT6/ejYLF8lcTRwEYvNQ8sfqQCVrcQMf8kakhzxtC+XKFKZnBTA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8784.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(136003)(396003)(376002)(39860400002)(366004)(346002)(2906002)(8936002)(5660300002)(4326008)(66556008)(8676002)(66476007)(66946007)(316002)(36756003)(478600001)(41300700001)(6486002)(38350700002)(1076003)(86362001)(52116002)(6506007)(6666004)(6512007)(26005)(2616005)(186003)(38100700002)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QJ+h+lmRiZrpNqlLCLIlZxctdYn654Gj3n3RDsPLCTgMQZ3vww6cRVUMtxA8GQvnQBMZME1eSXh5R+IdllbObjGthhVoMeV437hDdRa7gC10+piKaeF8lqozQXnkZsKeFWucHD+C+V7xxA5GZa5zlGtOo0g7Wnb4NumDDCcVOQf4x43PYZ9F/G9pxgndGFtKyWcCLhQ+w/tnnG1hUCaqMSih5D9Q+pORaOKn0K1Wd1kyqBLBcotOk918tiqbHnu/ucmt0CBrYbg5HI1oePfxgsyVXlRwYqY7fvW4jc4PYFIwjw0rGERKHhVU3CY/kCLllSG1dNN+Cbl7rd0Lz3Ya13GwzGb1W1mGDkt8P8d0z8bJ971pzECnnWeeVVCZ80IKvl/mjvP57WiOUkDKNrQdLm63djyBn2ErpicJIDV0+FgmwowQ0nesfQ3nQkzNmrpshsFDNAiI4+uDByGTCWa7H1vv7bw+MPIg/TCx9PqZcp4FA9egJI5ZDSNlXEBGS2SDpOYfKKkxiHyoxRFNGoOhE+wBwDjaX07ciBn9QvuVUJBdDiSbeatzYhdqrijXQgYVSd7Q5TIZifFqiZ/SVULykal1zysxd6zfrmgor63wLXebr/T+4wppV/UDtNn7ZytybaTBZZGC04ajUN8KDRPw3S7scQfUoEpXtjpVZs0tVkOt4c7j668La0LR6Gvy33PzMVOhFqBiBWA1muVeA9uwhF0Ko2ATeVQajUIgKV3zLrButlIrxZ4YFG+dywqQTjaz+wpniUqUOMfKnMtZ+pjUcncWjwmzdsGQwQhaoX07L9Jkr/7gQF6CQQOKR6Xtsi1L7t+Uq9jSDdfR0Qav2oSWgk1Bz5wKLvoMYKnlJWx/eiENRUQpWWzB2ppiNHIyuyX2GrqhYtn/pCLuX6UX8o/UCCU/I91WKFxC3ELYfq8zyCepBQUoH/m1cZlnV9N2RS9Av6v/o7DiwXvaKAt6g0OoiQpw9sjjclGOi6HoOp/8FuzO+h7tDAEboJiP7UplWYIUUCWMsjuc2DWjyAqoglRZh3nw7o4WrY/ZmQ7+qrVcUr/iMvUF9p7oeMHqxpo9B5VnOROMTsebSrEYDNElQ6+2MOR+azywN1fiwFR8VNEZizW11Qq8VwYTMEhjBDIo/7pn3s/YQZqZR8/uxF5OcdDy0QgLM7DL8Og8NQ+7qlsucfNSK25u/Yu4nQ4vYdhFVSWJOcQT2aG7sU+EoHrljMi2+u9i3WvGEzPuUet3+qNPo+meOPl8AJI1t1pquibpdhcQyW3j3G6DfExmA57f2vuZfNf0eYRgihlC8dWb0TIspFaKiWEIQlSPYvLGT38N4l/r4bjrFPOAkPEHWucoYnM4zwqYC/vRJlkxMM4SRSwisy+1wpE0I7ecor9Va2PWY3g45CCBmJRqz+yyTuKvmX82ZIptVjnBNv+GK8X0ZmUO3yHJnS3D7CKIDTyoRKdAhgxqRwv0RIHoHBgRXhaK/Hfynn8efRPhoGjCWnxKhcJa2TFD/VqhK0meL4XtXEyjysiQRhVCigvK258Z1xyk3+/b98510g4gD7yUTZmmE0YMqK1bnq2hZqgoQsEChMeR4l1K X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b1fd883f-3d51-4427-de95-08da8410b069 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8784.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2022 07:34:04.2917 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SmqIPRPifWXbYMz/xNuRwmRzOwtXk05Ba11YLuWl4tcoAKxdomS4UUNY/MwG6eqk7psICpeaB7mYQVi5lgF2bw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB5530 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Typec orientation switch can be implemented as a consumer of mux controller. So we can use mux controller to control simple gpio switch or other types of switch. This will cover the following typec switch use case: High Speed, Super Speed and Sideband switch. Signed-off-by: Xu Yang --- .../bindings/connector/usb-connector.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml index ae515651fc6b..47f53cdbf31a 100644 --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml @@ -221,6 +221,24 @@ properties: SNK_READY for non-pd link. type: boolean + # The following are optional properties for "usb-c-connector". + mux-controls: + description: Mux controller node to use for orientation switch selection. This mux controller + could handle High Speed, Super Speed and Sideband switch use case one time. In orde to do so, + besides mux settings need to be properly configured for each switch under mux-controller node, + correct states should also be assigned to typec-switch-states parameter. + maxItems: 1 + + typec-switch-states: + description: An ordered u32 array describing the mux state value for each typec orientations. + Three states correspond to NONE(high impedance), NORMAL, REVERSE respectively. If there is + no HW mux state for NONE, use value of NORMAL or REVERSE for it. If this mux controller + handle more than 1 switch, correct states value need to be caculated according to the mux + settings. + minItems: 3 + maxItems: 3 + $ref: /schemas/types.yaml#/definitions/uint32-array + dependencies: sink-vdos-v1: [ 'sink-vdos' ] sink-vdos: [ 'sink-vdos-v1' ] From patchwork Mon Aug 22 15:35:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 600237 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3742AC3F6B0 for ; Mon, 22 Aug 2022 07:34:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232167AbiHVHeO (ORCPT ); Mon, 22 Aug 2022 03:34:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232120AbiHVHeL (ORCPT ); Mon, 22 Aug 2022 03:34:11 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2047.outbound.protection.outlook.com [40.107.21.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BF7B13F70; Mon, 22 Aug 2022 00:34:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K1ji7HfZ88pKbjiCc3l16hk1TYZH80l9NQTWQYAB1regxebpb2XtSaXgvqCA/SrIp6MwTI6WVQpCM+o3u6yxeN7I2Y9nNGmfMilszNZ7xiMdF4117lvNiyTB9083w5ba0X0sbHvS1xx+paDL3ffEjVdmX2zftjFpaldwMpPaLBTRPwdJGF5HK7PYOkNb4bxoZMtEZe7mB4AxKTZB2alobyFcoQt10pcogc5icYwKH7c+t6TjYC3fYBTD4EypekE6NQj//eqainc11CpAm0NH+Qyb2FVD7FA1z20UjaA0qM8V441M1Yc0em8xddfZIcC49yTOJJi4pHiHoD6uVJDA0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=O5Wdp0Rk/tsppEd8A/RRcJbbVPMH9Xog7x5Rl4P8t5g=; b=mxArx4ZHIWETvzMFUZcizUmdCxQFowdWagny4ONNzbJNwDFuZoafnJRQQlaElHxSa5xtNWnlGpST5GIrgn+FlHABoo2QI2whzRn9w/ygOTy+t1199LUeDmsDDqKdHu+JrJThEfdiAdJZG/hDKAqlkDswfECIuW/95AL+ZB6K7V/UcyEUjOedpoeWzUPEkjAG3whUCNivHoL/JfVVaL4C8TSV1PTdymrt9GFVccTfGoZMftReTRoJMujn00jjfep1WsFl8SfNrB6d2ethi8h7R8ye0ewKM3oDGGZg++khn9+jTq583TTZF/PVZPnYqploQDe1E+PB4aq/OwWi2yvGiA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=O5Wdp0Rk/tsppEd8A/RRcJbbVPMH9Xog7x5Rl4P8t5g=; b=bpAn2FpQXO3AYmA7q7Hh0FU0UNiyM0DgJWwWfIP0d0hqmwOAsEGRluToguqMzIdKyO//I0y1IH6qWdNsz0rSqK8gEC+BzeofqVzW8UelRZd22w8jsJTeOcm8T+5uikKFoF2Fi/erqurTFfCX9yW8bGY5yAEne2qyyKfmj/ED0xg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8784.eurprd04.prod.outlook.com (2603:10a6:102:20f::23) by VI1PR04MB4640.eurprd04.prod.outlook.com (2603:10a6:803:6b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.22; Mon, 22 Aug 2022 07:34:08 +0000 Received: from PAXPR04MB8784.eurprd04.prod.outlook.com ([fe80::60b7:af13:8472:2e8c]) by PAXPR04MB8784.eurprd04.prod.outlook.com ([fe80::60b7:af13:8472:2e8c%4]) with mapi id 15.20.5546.022; Mon, 22 Aug 2022 07:34:08 +0000 From: Xu Yang To: heikki.krogerus@linux.intel.com, robh+dt@kernel.org, peda@axentia.se, shawnguo@kernel.org Cc: gregkh@linuxfoundation.org, linux@roeck-us.net, jun.li@nxp.com, xu.yang_2@nxp.com, linux-usb@vger.kernel.org, linux-imx@nxp.com, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/4] mux: allow get mux_control from fwnode if of_node is NULL Date: Mon, 22 Aug 2022 23:35:15 +0800 Message-Id: <20220822153517.3747679-3-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220822153517.3747679-1-xu.yang_2@nxp.com> References: <20220822153517.3747679-1-xu.yang_2@nxp.com> X-ClientProxiedBy: SI2PR02CA0033.apcprd02.prod.outlook.com (2603:1096:4:195::20) To PAXPR04MB8784.eurprd04.prod.outlook.com (2603:10a6:102:20f::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3b4794fb-f3a6-41d1-0d5b-08da8410b291 X-MS-TrafficTypeDiagnostic: VI1PR04MB4640:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: z9MK5KQU19CZDFuzPyO7k5qZV6gUjl/Ob97H749fsjlLn6SKKyB1YWmPQmt4F1KQm5ETUr+GCWg7kK2nKZl835G+UT0f7d+XCwkT4WVhFVgUBl0oxCnwLSCvlJEtFC3cVeeajQL7rdLdQzLk4wLTj7dBQu23PMh9wlMbqHOPYVavJA/uh539HuJ+JLCMZ0p+dqYRCYDXKWTWrs27tp864oD72d6LcoXtC5KRCIpU36jHFp0tS0NK3srOCpuBo1IWHQzVEXyFGnIJVjgO7Pn74imEdl+VvVyKptj+Gp7QMhtgZ7guNtu6jL0v+yyiLkUwX16I4OAkfwRZH+dcn1/Sdh3DQIp07Vu1D1fd/nohXCvynay04dt3o21MSLpEpgACp93qWVbhgPNeESg73J1MLg7S+pjtMwluvSx7ISyiGFgg6B8nycDixzOieU3IQoANDhWqFHjYCQVKls9WoqMmk9IeWZrPwzciZvxJeLiTSbj78ZWuJ0QysTjtiH0SB+tNPRn66wH2aZG9UkO9CcROlQD1wKSa+ODEV0uHtFg40w/zddtKU2CuYFvTWtAy5hvBMjbTg+862bAegpLo+GJeNS+AAmuBXnc1eNsVqH1TGKXQ7ngborm/+cbXQFzmJtHBTKEabzPl8mTePzyf1lFdlvKqnj5Qh8b3G9Bky3sBx3R3wDx3LkqBnyLvq0F5JflITkzq+/CRnicZ+PiscPzs7BmxBZ1pc9AaoyCgJd47suVZ/Eohd8hr0uXueG1NV7o25qcjSiBnMNC8k+NekoS8ag== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8784.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(136003)(346002)(396003)(376002)(39860400002)(366004)(4744005)(8676002)(66556008)(66476007)(6486002)(5660300002)(316002)(66946007)(41300700001)(38100700002)(38350700002)(4326008)(36756003)(478600001)(6666004)(8936002)(2616005)(52116002)(6506007)(26005)(6512007)(2906002)(186003)(1076003)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ha+KFeI5QvL7aAVkMbDm12J9Q1la/L/QOVAqAJX5nBGde36LyNQHMA4SnbiDWUekqmGMCC9qSf2E4Zb7+gDkwqvwcOCPWm0ILHqVZploDJB2jWgGkaIVf1fXS9ubg72sr2URfc04EoC9KBi7kd9QuAwqJchO1irejbWigfoPZ5meNI7uVuKamVKakvh/fuANYVE6IIinmcZ44547keoCB1REPXCKidUDu7B9QKnqNz9q/PZoe83HcbBMjpttHkeZvcax3kE70JVcM7JrFKWd2GttTW2ZpylBo5ouIe5NMxH5Dah/GOBXtfKjuyo3p6WSWgbAQeazstI41WHpag9rBtUcaUBrzhoSijezeo/41V94mtygdQKi9mImGdwPT+jO8bHfZYb3hWZ+YGcvujsSX/0NNzZOgFSiONJg9KNBTR5vTy7ZvOKU91ZPLN/H/jBcRYtTTujfbi0yVp4Kz2NEDJvtJoVZFvwVoP+Mj4gh1sQWwdBDbdLWOg8wVu22trpELl7YehneJA7qMpG8Q2p1uxSpWP+JUXFQKRMp1sx0cZlGvc06uYLlTWBFpKfHI2hIxz6b2V7gtdOCzeMvIKyHchxRKRoeKoe6S9nukH9bxPsnImOuxyYgG6YchJpmKLhaQ3mY2GSNV++bqynYAC9x661OFyySzDHFq45WrFglttpB9PWFNckf5PR4OywkAVqTFPOTeN/dZzn2b0gccnlwyA0BwCIIsEhoAOvUn7tTmItTlAXDkwfjZa8x3a3g32N5uGXV2UWJUE9rcz+9IoSlCs38T6/keV+bbcUQMfk1d5s60i3niU2yrbkk8LFWDdUrdKsi8z2uM2WiwpIKfMy79XnhLmmcgbkuXOuNue4bKU+2XgTmVyYWB+86z7tkV3Uz6sSj2Eb81fgY1GPxFvpU/IDsGOxnGuHH6POwj/RM1t9DTg4xtlGFNsTHutg2aRMBkP1UXdNXv1qhjqt3wNDqFkilnCi9u8n+GUn9RVw85beyyFh27H0kFiltHLyx/pbSFheoZMPAaEzvS1HOG+zYeatRxLYUveDOvvo4qo4jM+3r3k1AY4F001DQCEqR4ji2m04BoHswieaFkWZ9N3F8D4Wp5qoidY63segdTOw2zwiqEd0UAZ6ZWtjciNkrq2f3ZVqiHxnhhO4mz37yRkUV/pOKoIz/Yo2KMG8rpIfSksz1y1hlPXCG/AwfzeE/mKa2G0lbWpGTutj/TYjJbodoaf1PF3F8GOWlXXGYCxbMtY7wdJnN66XYGuzQ/licj4DgMIhGLRa9WLKNC67vbkYNzFdEfzr7gpALOx9ADpzzbklJKcW7ejepmDledmWJHKgT4j+B21TJwQi4uCfPYSY/ABumdT/IeB2XLUYVP4w1MeSNSffwjE4I3Aa4ux1+jKLcikBz5E7bRR+pSBHwnCXIH+Oh+eum9qcuZYgdU9CBXwK8RQM22Or6jSQFI3Cx7XdxQzNwHSqPG3zKPGSphGb8LyahOta2A70A6VeN6G5zVRUVIZyru/FXY+84w+rZ0pcHZpW0vC9Q+dg2F+knWx0pHygi9q5J6TLnMWKyvKh4fjVVoBc3KHdKL5MN5zQO8YPK X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3b4794fb-f3a6-41d1-0d5b-08da8410b291 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8784.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2022 07:34:07.9352 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EL9m6Wl5JyuoO6GkcMFS/oIhYbhut4KDnhAQLUwcNN/MqPdBgQx3qJaMQ3kPXZzqBeQo9FwIuObqBHmwz0yxIQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4640 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Since some devices may link fwnode to dev but doesn't link of_node, so here we could get mux_control from fwnode again. Signed-off-by: Xu Yang --- drivers/mux/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mux/core.c b/drivers/mux/core.c index 49bedbe6316c..06d4e232e056 100644 --- a/drivers/mux/core.c +++ b/drivers/mux/core.c @@ -538,6 +538,9 @@ static struct mux_control *mux_get(struct device *dev, const char *mux_name, int index = 0; int ret; + if (!np) + np = to_of_node(dev_fwnode(dev)); + if (mux_name) { if (state) index = of_property_match_string(np, "mux-state-names", From patchwork Mon Aug 22 15:35:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 599435 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6250C3F6B0 for ; Mon, 22 Aug 2022 07:34:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232120AbiHVHeR (ORCPT ); Mon, 22 Aug 2022 03:34:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232331AbiHVHeP (ORCPT ); Mon, 22 Aug 2022 03:34:15 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2040.outbound.protection.outlook.com [40.107.21.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18421275F9; Mon, 22 Aug 2022 00:34:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QNEMLV1ELWFj63NmdJhioQl2dZbA2+AeNb3Zk542Wl2UqnFpwy6Pxq2n5KDpuI5zv7h71+awTLwQY1H0aN+qYHo/Vf6MoqGHL3XC9CQfVx2T6WjP6sY1pIIX0pD0/jIUrXu4Yf3/dR/lA0sPzFKc45uwR82SMBUliHAX7mzru4CG0LXST8xYA0FjUZgG0QCKcYdZl30/iiftKBI1Mv4nuDKiuwbmVuBJBW92L/FRCSJltR959TFpNsZOTyEsH6M0ITo2b50eGuga/58lCcVr97S0/eeBi34Lt99DG6HIEU1Nd5av5mBrjAHyPMqfajao0rdmAb3I/J0va27tjZ75RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6BPkup+AUFLBnyGgonKYy29ETmrZi06gMGrzaV87zZs=; b=c2JqVRIMqo6ZZPlPrlEVk6NyM1lc4d7vo2jD+F8Hax4TS59a3QF5o/r/ON47F2qIpW67BBAKBeVB60XkCBwO5yhSdb165mlx4UnfHA7EKzTa+QB913rMez+rQszu3HQkP4cVh9BORs0re+9VfEWCEMOC2+iEgQgA4Q1625PNVqz39MHKNcC7V+wd9BEDnwEUaFvP/g3dC9j3lJFaMfcuS1hapbt0M6DMQxzKzrlepU9soihH3pSmV43z2SF/qiR8dEjWXVL8vybLhiz4CyV8L7hCyPQl7oJjgaXWPJxH5zFpbwmpwOIYhI81YrzfK0MeReAEXyXE+5t6TFopZBqvhQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6BPkup+AUFLBnyGgonKYy29ETmrZi06gMGrzaV87zZs=; b=l0nfCwnw9cqz44ltccZPYlIi9VLT/yHp0Sq+HuKJOWPjPdKF6G1YvRhKIx7rzSFnoOlVZtUaujRYgqz5tlvgjqX1I67BAMDxfcDZY5XwgJyNV5DpKQStdrE+uFWNObhW632z+DMosbPHVdJkbR+OocZ+Te/mz8ogPZ3iUzQBJXA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8784.eurprd04.prod.outlook.com (2603:10a6:102:20f::23) by VI1PR04MB4640.eurprd04.prod.outlook.com (2603:10a6:803:6b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.22; Mon, 22 Aug 2022 07:34:11 +0000 Received: from PAXPR04MB8784.eurprd04.prod.outlook.com ([fe80::60b7:af13:8472:2e8c]) by PAXPR04MB8784.eurprd04.prod.outlook.com ([fe80::60b7:af13:8472:2e8c%4]) with mapi id 15.20.5546.022; Mon, 22 Aug 2022 07:34:11 +0000 From: Xu Yang To: heikki.krogerus@linux.intel.com, robh+dt@kernel.org, peda@axentia.se, shawnguo@kernel.org Cc: gregkh@linuxfoundation.org, linux@roeck-us.net, jun.li@nxp.com, xu.yang_2@nxp.com, linux-usb@vger.kernel.org, linux-imx@nxp.com, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/4] usb: typec: mux: add typec orientation switch support via mux controller Date: Mon, 22 Aug 2022 23:35:16 +0800 Message-Id: <20220822153517.3747679-4-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220822153517.3747679-1-xu.yang_2@nxp.com> References: <20220822153517.3747679-1-xu.yang_2@nxp.com> X-ClientProxiedBy: SI2PR02CA0033.apcprd02.prod.outlook.com (2603:1096:4:195::20) To PAXPR04MB8784.eurprd04.prod.outlook.com (2603:10a6:102:20f::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 511a9908-878d-48b7-550d-08da8410b4c2 X-MS-TrafficTypeDiagnostic: VI1PR04MB4640:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: O7Id1ONBh5KtObNq8TqjbUdtSMwmWyG353vOs5nNxsbhLJgvqxmNyG6FA0kP2aVIAgJwIRVaKfKExDU4NE5AmQKB6gcGQvvPZccuNeTcNa74k1eoLgPbmiDQsvvd3MDYQzErnxZLWLlx4KGXQILs2LX8aTWjyNOStsx/Gr1V4QiUu22KzW2MisSCZzrfIh0qxcD4d/j0adEqS6+MzV0VbhGx4gAY5mohMOOzbaKktHBfRLbHRMXNJYg1dXKZlKeJMW7/mtIli/qlvLWMu6BIejj7t0WpTzL1v3Q/mbPXlylc4xucBlksDAlIMwM+61CKxdridyxnz0O8EW6b1r2OOqZzxo5zBVk4Hpe2mCblZ9K0hjWyPF+he3uYD/adGVlnaaRwZjk3tQHU2TZHAb8NovIuVauGN2hKyp1z1uOiVA3PRcRd5Ghuth2mC1YASyiYMlYfxwmztG4ka36U9tAbVor1tit7WM/sD1FmYAzN2muLStzdXMNyiI5Cn2KFUL6UUc9BAXlOs1SP0pY/bEJQieBatf0oZ/vISTuEodeDjLTqlW7JG4hXRiMAiEh9uRvsXjWEY0fqxmCCZHHixXVUPAyG8CbnHU9uJYtUj0qgs3RnRoDgZlLTh+pXQbqGxneftj/0Ak/7cquCq+g5rZfi8WbnjXOEsTc5whi3FLxTOLsiLMhXH6zDogoxMHbrigZ3Fy21hpuo+BF3MLbUbAxxwc+XI+7xUZRB2xNllS3+7OU9mSO+273CQ9VW58F+KptGrkubt2TwoGD7dC3jAXfCxA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8784.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(136003)(346002)(396003)(376002)(39860400002)(366004)(8676002)(66556008)(66476007)(6486002)(5660300002)(316002)(66946007)(41300700001)(38100700002)(38350700002)(4326008)(36756003)(478600001)(8936002)(2616005)(52116002)(6506007)(26005)(6512007)(2906002)(186003)(1076003)(83380400001)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: auQIHuIlIxR0nifPZu3xvd4I2u9a/jUl/41HWPSmi5Z+enBUQkjO1+eWt6MbGe6rvNr3nQtJ15ZRKrfqy5r+/BHV2nATLxsbBASzknR07cnQ73TGZqEefcLBtPxiBQAXNPvjk9TJwxaySS7bem/z56dLYS8Rr1Sx67bXR/iay0eopdTFS1oyeUowJsc50Z8qYAu4VPSzVqgfKz/aIYHHyeqbcjEUCCKP5nqwTP5SjCOJ1q0KUN+8h+DtDe0VsLq5EvOJ/yVAMEG4VTH9rRMcbN+tx6CMKtRxfzJpe0mjHeS9waSkSGFGFjDBG3R5V/cYE2Rf0R4v9Jl+HBqxt7DdwMXEz/sk23TM+qSEZrw254MUhrQUQAVzCgNKYgkrIeZ22iWomKH++QwMMvrPEWiRDl392fjsz5mU0lGHd5K2wBJCCX2AbtokrOodUzwVvUS/tIGP6d2zpokrWpQ7Z5pS3bUEUJ+zo0AZDicMUOelGelxTuRg9Y7tVH3HZIj7B003f8hG1/v0/VaxOK0/chIjgaKHmA5jNCSrDMclkV/DuhXEXDE+J6KcWa480iSt7vkBCMyzI3kaZUF4MUZ3TLo4eJr4fJjaG4rB5vuDLAUVEQE9ssPGC/HFFOKe/sC2GUM519exiE+ofKOozISx40LRa6/qVxtcp9l4+nWi2kXzaq4Mq4d96ae4u3LEM6J0RFY4xB6CoCBdhD6qkFASIW1PHiMSCi4+Om4+upjRxiGx2ZMKpQvQH64OtWHUw8TUrTwUQ+hEkp3nMBO6MTcLQIRzRuIsUWm98gYXZ9G5Y50iwOzzxWCvkh9eOb/+ayOY6F9nK/rvovnDOVlbDFlF9LFZf6gLM69emhY6J4N/2mHFH6ysnSXFFom1efeS/9dLW39rWmG3POUhG8FpjU5wnZF7eqTV5/n0pHCN7SCRTpzCXMPAVFgstrcpRwvNz3Wv+cKlgPvLBoTn8eUOlB+ihaIAsf625M4keb0XDnNGSLxBiZQ8Lhv269iIEtcqphFdsSbrsxY3MaU13lhQj4vxmyl6dIlSXa/eJPUTooaBhN6izdjK2vOFyUnhd8aYh/YjmZjTf4qBNMK1d5z0YLeXpuGkobTPoCGWcUz1hdflzfDHlvrb8gsdkcqD6rFXW5oE5IVeYRdVPWl5jBB2LiPY6/nZ64TwLX0dOLPXP8qUJu7dWP2uPuPEjWznURerfjPIPTOh6rwhhx1f64UBzSUPOHuJ0BW/jJ10btz6ftmVe8BXb8x/pa3tYgHca9K2QhPPP78hzA43aHjma48Nwx+BQSdSSomSyIgE175OWtndvt4Q1Usmasvx6OEujV7m45QuJMxQtv7xFylL3rdNTkrWpmoOaQOJjyvfNTq9g/RFKiRh4O4jTCwQrUxIZePvjBgHZHauZyhHu8uBWkOSdQw1Ucc35DlHr35lNl2/18McvsEAJF9ubhzlpqRQ/R7k4Asncjul6fdBi35+Zymo75R/MzCuBOABpnpp22CTDHRbwjN+WFA9uTCG4y73xbWE7bA76p6y/AHI7j4BJXxJdteIZJKlt3ocOBTHNiGvUl1b0VCDNy7nsO2hHpDX00VhL0J+oNGk X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 511a9908-878d-48b7-550d-08da8410b4c2 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8784.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2022 07:34:11.5042 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +IpYqAPtV4cn04pAeZgrbpGj2vhc/v1hMJo+iKmFY9VSHvloWBHxK8/C9R6LJCJ1m22WQUJJwInfHU0po9duKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4640 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Some dedicated mux block can use existing mux controller as a mux provider, typec port as a consumer to select channel for orientation switch, this can be an alternate way to control typec orientation switch. Also, one mux controller could cover highspeed, superspeed and sideband use case one time in this implementation. Signed-off-by: Xu Yang Reported-by: kernel test robot --- drivers/usb/typec/mux.c | 74 +++++++++++++++++++++++++++++++++++ include/linux/usb/typec_mux.h | 7 +--- 2 files changed, 76 insertions(+), 5 deletions(-) diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c index 464330776cd6..5ee960fb668d 100644 --- a/drivers/usb/typec/mux.c +++ b/drivers/usb/typec/mux.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "class.h" #include "mux.h" @@ -22,6 +23,11 @@ struct typec_switch { struct typec_switch_dev *sw_devs[TYPEC_MUX_MAX_DEVS]; unsigned int num_sw_devs; + + /* Could handle HighSpeed, SuperSpeed, Sideband switch one time */ + struct mux_control *mux_switch; + /* 3 state correspond to NONE, NORMAL, REVERSE for all switches */ + int mux_states[3]; }; static int switch_fwnode_match(struct device *dev, const void *fwnode) @@ -117,6 +123,58 @@ struct typec_switch *fwnode_typec_switch_get(struct fwnode_handle *fwnode) } EXPORT_SYMBOL_GPL(fwnode_typec_switch_get); +static struct typec_switch *mux_control_typec_switch_get(struct device *dev) +{ + struct typec_switch *sw; + struct mux_control *mux; + int ret; + + if (!device_property_present(dev, "mux-controls")) + return NULL; + + sw = kzalloc(sizeof(*sw), GFP_KERNEL); + if (!sw) + return ERR_PTR(-ENOMEM); + + mux = mux_control_get(dev, NULL); + if (!IS_ERR(mux)) { + sw->mux_switch = mux; + ret = device_property_read_u32_array(dev, + "typec-switch-states", sw->mux_states, 3); + if (ret) { + kfree(sw); + return ERR_PTR(ret); + } + } else { + kfree(sw); + return ERR_CAST(mux); + } + + return sw; +} + +/** + * typec_switch_get - Find USB Type-C orientation switch + * @dev: The device using switch + * + * Finds a switch used by @dev. Returns a reference to the switch on + * success, NULL if no matching connection was found, or + * ERR_PTR(-EPROBE_DEFER) when a connection was found but the switch + * has not been enumerated yet, or ERR_PTR with a negative errno. + */ +struct typec_switch *typec_switch_get(struct device *dev) +{ + struct typec_switch *sw; + + sw = fwnode_typec_switch_get(dev_fwnode(dev)); + if (!sw) + /* Try get switch based on mux control */ + sw = mux_control_typec_switch_get(dev); + + return sw; +} +EXPORT_SYMBOL_GPL(typec_switch_get); + /** * typec_switch_put - Release USB Type-C orientation switch * @sw: USB Type-C orientation switch @@ -137,6 +195,10 @@ void typec_switch_put(struct typec_switch *sw) module_put(sw_dev->dev.parent->driver->owner); put_device(&sw_dev->dev); } + + if (sw->mux_switch) + mux_control_put(sw->mux_switch); + kfree(sw); } EXPORT_SYMBOL_GPL(typec_switch_put); @@ -204,6 +266,7 @@ int typec_switch_set(struct typec_switch *sw, enum typec_orientation orientation) { struct typec_switch_dev *sw_dev; + struct mux_control *mux; unsigned int i; int ret; @@ -218,6 +281,17 @@ int typec_switch_set(struct typec_switch *sw, return ret; } + mux = sw->mux_switch; + if (mux) { + ret = mux_control_deselect(mux); + if (ret) + return ret; + + ret = mux_control_select(mux, sw->mux_states[orientation]); + if (ret) + return ret; + } + return 0; } EXPORT_SYMBOL_GPL(typec_switch_set); diff --git a/include/linux/usb/typec_mux.h b/include/linux/usb/typec_mux.h index 9292f0e07846..2287e5a5f591 100644 --- a/include/linux/usb/typec_mux.h +++ b/include/linux/usb/typec_mux.h @@ -24,16 +24,13 @@ struct typec_switch_desc { void *drvdata; }; + +struct typec_switch *typec_switch_get(struct device *dev); struct typec_switch *fwnode_typec_switch_get(struct fwnode_handle *fwnode); void typec_switch_put(struct typec_switch *sw); int typec_switch_set(struct typec_switch *sw, enum typec_orientation orientation); -static inline struct typec_switch *typec_switch_get(struct device *dev) -{ - return fwnode_typec_switch_get(dev_fwnode(dev)); -} - struct typec_switch_dev * typec_switch_register(struct device *parent, const struct typec_switch_desc *desc); From patchwork Mon Aug 22 15:35:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 600236 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C8C8C28D13 for ; Mon, 22 Aug 2022 07:34:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232803AbiHVHeU (ORCPT ); Mon, 22 Aug 2022 03:34:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230282AbiHVHeT (ORCPT ); Mon, 22 Aug 2022 03:34:19 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2086.outbound.protection.outlook.com [40.107.21.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 036DB27B05; Mon, 22 Aug 2022 00:34:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=anmvFsOzpFkhTa5VZZ8CgDlKjmKEcAndkdFjshlpBKStM9nwD9jF10YQ84GNGWb/moPOPE4uLPmugmVkoRb0qZMtkkl724eiQKUSYr7g0F+k+DWh1vVqylcIimryJ+KOQPfchp5qV8qtBvpPoALWV1sLZL6/s5m/06noGH6xP39VW0ct2WgCetJYwsZihOyqefZn71H24sC6WRrww7YToQ82yWDgTzqMSvFBdDs6HJ52qDzmpW72kaML8he9PLLB7dEPiORomaF++IYY08+JHVvqf+No+NX5GVPkhML7hj2Sa/khvbP5nS9keRnu227c9ujXiQRYLQEsL5CYrzvqpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NawNz05wLOWus+BE7LiI5Ct3FQmQo4T8Q7CntfkZJLU=; b=eXPPrygtFC6wpsZL2/zLbKgCQNyHl+e6BuNRD/rozG47RhJoC5aFuCwn4StFV7LZmJHKL2SQb5fq2FdNMSJOMcCpRKN0AeP4qNG1Kg67AYPEW0EXKDkiHMS6tEkecqey9z73mNAXrGUSROLI82xVJkCmqwsN+OcAFe+3/TgcFrwBhW7crRwHJrL5yI/PUFcTGkEuxt4iRWSfPOeE1/S6qADtUQiWIa0NdMGStD8TXAUfd7ukE9H9dbxY43S4sBnMWBwPVgh7076nOiXBjR78FXt2IKGYw39TuKyGB7hb5m/ummMJWKHvC2v4NrNs/O/toKKgV1jhfaG2ZtIs7WzFiA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NawNz05wLOWus+BE7LiI5Ct3FQmQo4T8Q7CntfkZJLU=; b=eF+fCb7wpjPUb1DO4t2lMWxyEO7XHBLZhoAFbN4d8wpNMivtIlp5Ioc9oDNZDLmj+U4MaCOD5ah1zYpcKgfKHziQUKyWrHAmTFIXRtloL//fGKDuOxorKNdMgiEYnZOXstoWstHu8R45xWJqJrGPITQVN/LFuCi8u96Gtavupbg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8784.eurprd04.prod.outlook.com (2603:10a6:102:20f::23) by VI1PR04MB4640.eurprd04.prod.outlook.com (2603:10a6:803:6b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.22; Mon, 22 Aug 2022 07:34:15 +0000 Received: from PAXPR04MB8784.eurprd04.prod.outlook.com ([fe80::60b7:af13:8472:2e8c]) by PAXPR04MB8784.eurprd04.prod.outlook.com ([fe80::60b7:af13:8472:2e8c%4]) with mapi id 15.20.5546.022; Mon, 22 Aug 2022 07:34:15 +0000 From: Xu Yang To: heikki.krogerus@linux.intel.com, robh+dt@kernel.org, peda@axentia.se, shawnguo@kernel.org Cc: gregkh@linuxfoundation.org, linux@roeck-us.net, jun.li@nxp.com, xu.yang_2@nxp.com, linux-usb@vger.kernel.org, linux-imx@nxp.com, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 4/4] arm64: dts: imx8mp-evk: add typec node Date: Mon, 22 Aug 2022 23:35:17 +0800 Message-Id: <20220822153517.3747679-5-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220822153517.3747679-1-xu.yang_2@nxp.com> References: <20220822153517.3747679-1-xu.yang_2@nxp.com> X-ClientProxiedBy: SI2PR02CA0033.apcprd02.prod.outlook.com (2603:1096:4:195::20) To PAXPR04MB8784.eurprd04.prod.outlook.com (2603:10a6:102:20f::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6481c363-8ef7-4f07-e4c7-08da8410b6da X-MS-TrafficTypeDiagnostic: VI1PR04MB4640:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0f3aiLLjcTmKjNK8TZV1vLjRrROUnjX6tpTxDSQEAH8DP6q7RGfjMYI3RvJUfG0BA0/+5Y6p82AkgDNjhmmGwzNER6Sd5xqb7hSaKx5Ua7mU/KiFSugdY6wcRQVZsHp4LiUDqWPQUdttLHoXSiJCYME6WqhSoLwftCSRkB9Uo6uLc/BZB67YBCqPMwPE83H0ZduUCikQYluJiH3+b7Rud+0rXdPkUv5gJHlMGrgXR6pHOhTc1VF+vPjTPz8gKnori91snhYT5jrC9BtK4UTXjiFSEtgQmyEGZhvD6SvP/vv9XqCO+V1y8Jztho9C+h2VLgOOATt5l6LekP1pPUrvKu0wPc7asY5kIWnofLEDLufpPNx1kXdoK+V7a15eOuKkMmGLEecfegTxAGoaGPs6k6OKgFQ+c62PYhBfajY0hneKXl8w8hU8Pfog1CA0275pgXEMYscAMzuaIfQxbC5cCFii1PwXOVxrXlNMUnqSmihr4EfXOdPAHEc3tCuaaF9TErdLOClOrQfEMBOfiwF6kp52oCEiL4ohNZ2Texso+rXHvylN/o/JpzmKwS4aTG2frqDPXxDofIgNXO3ENmNxv80YdqJVsjV42CA/iy3/EXXL+o+Atk23H+Z6RklZYyz9gQnR0YvbzgwQ9T2GCjC4psLAtndXbg/+aPH7Zhv1ncVSCJLDiX50GAoH9HD6D/+jaS7R0r1f2nfK1PGnvTAf/sQW0p9ffBTlf+gF6wjdMhSeHID3X0DPhC9+QKPw33yCzuK7TI+1tdrM1tCwccaqYexkuuyQvdUyY8ogtTqEOHTDEyJcBbGHNGrulQ7jShKEvxag738cenMFsED3bTBbfA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8784.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(136003)(346002)(396003)(376002)(39860400002)(366004)(8676002)(66556008)(66476007)(6486002)(5660300002)(316002)(66946007)(41300700001)(38100700002)(38350700002)(4326008)(36756003)(478600001)(8936002)(2616005)(52116002)(6506007)(26005)(6512007)(2906002)(186003)(1076003)(83380400001)(86362001)(32563001)(473944003)(414714003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: m0gh5NIzkfZi5naz71zple9GLg5WZJqwXn45GiAl2ei4MrP2SJQ8slbfjeMbXFdwVlvYst76S0YLSMfwVEWb7VZ7pdnfw7MKJByO9RBIEK3n0veKKsKifcHakU5WOR1cPJeFonC+y6cwiiy6OwXv/jNU6Uz4JegG5qwFy3/3WqIfIqM602Z/IrJ1z2VH2FWpw8F0eltxuP4bXsfl824MgQ1Net5w/iwt3rayKh9TdqqmJMFXJBjI68AcLjJniGtBEwKCxUCwz68KmQxqND/ghTI3wzxUK6Is/U92pz6Q/djZmsbazZzIJoC3jPJtP/UOfLNpImVUcqnEByhi7l+m0wrZpnvhzH5WMlJNVoDiHGVNp1JEtR/vfHOGz8okPlyJtt5mk8c2Asrmcv64IiXq4MBzos7/7q6UWdA9VNeTzLEwYH3cRYk6OHQ+pYkbUEW7DEO6qHWfhFlEFC2161nEZjT1L7u0yEq57hOj30/wulkndh29xGw1Fpdnt2ZMXF7wLFPQBYs5j85/MXLYX9TlaE/iRyHWWPQi05Ze1lLHDwOKhlfrKLYJxnyNVz6O/3kzqUpwzdTPgL2D6yw17xC/fVDm8RmV3/EXavAHKDe4hKqSnbbRQu2nKFXWir0qXdXHKwq1wR63RuyBWCbwbxlriCAwZh4TXVrik0sc+Z97p4Wln97IFgRhd4hnmCS1oJ9d0d/3bxILhGQKnz4Et4pNYp7D5As1KAZ5smg5HwwwD/ZkLz1cRIvYSzU86RXENpWqETVPYuRZ38wegZLvF968toMOiyhO3faywLCdi5nEEI3sovvWxh6g+YdLu5jnVzGww64K3dZoP7uX4ULqIaMGbmqEhBqemroWnBdTdZs4eCKHhe7XZhIWwAwKekobvtKVABNAPl8kuQKW0mSUPhfgi3b6QH3e1P7G5pv6wx2i29tzzBpaWdueeZkfNxjVBIpK6pv4xk/QN5F43A10KBjqNwC866Uqv2PHtyqFxWs4iFg86mmdPiGcziZODFauVW30/xv/elkkQAx5I9d3CjhtAIgeUQBn3SUYQj5YQvkw5L8isOv0Op+eAc8AXykqyIbNXkETTxkW6Ffto4jOtfj6U+T65EG3IOmLacYCdoVc03Ye4Gv0Gh3S4bWi/HXQjFUuEz51fOtMgFLPDKqT7AnIEN9QmotHXawpcSb1n1UuY6wJNN2jpQfOazvOJDT2EWCSHbMYmngOxTLMxa+p02jzdn8CaH9wDWGRleBHS7SX+HJtzWI9lXAJfp1X0RtYdNidJk6t0uYE8hfJzUfkYk9j+n0VkRxKhqIsFYm+wCj84AAhayJ2Uh2d/BZTX1WU//PF5NigQZQfklb63tMq4H9uEeY0u22qw9ZiCoM9oyH33MD4OSf5oavCb4RRz1h7OMIkgoZ8Qj5Kt2Osi2jM1J15osq6P3U97ETDZAZvra+mEmnkha4W9uARw1O42koogBIdGZIqFsaIn+PSFg56BeZWFuDW2JHRullxY0CwAgOLZyfOYV5zh++2h+7CFBlfLEopwmxoobBxpxQts42IsZ7Y5MLluDGJiWpRDLVNH02EHgIboUl9O72xmeiDU7jn2FSQ X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6481c363-8ef7-4f07-e4c7-08da8410b6da X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8784.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2022 07:34:15.1769 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FZ2uU9Gfn4EIRGsWKGACYOs6Q9B0Y5JXv/3M2TjXQG/LdRm2KMf/4giy4CE9DjQj/p0jM8ci5cjAy7QGLLp+7A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4640 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The first port of USB with type-C connector, which has dual data role and dual power role. Signed-off-by: Xu Yang --- arch/arm64/boot/dts/freescale/imx8mp-evk.dts | 120 +++++++++++++++++++ 1 file changed, 120 insertions(+) diff --git a/arch/arm64/boot/dts/freescale/imx8mp-evk.dts b/arch/arm64/boot/dts/freescale/imx8mp-evk.dts index f6b017ab5f53..bf0fc6b18164 100644 --- a/arch/arm64/boot/dts/freescale/imx8mp-evk.dts +++ b/arch/arm64/boot/dts/freescale/imx8mp-evk.dts @@ -5,6 +5,7 @@ /dts-v1/; +#include #include "imx8mp.dtsi" / { @@ -65,6 +66,22 @@ reg_usdhc2_vmmc: regulator-usdhc2 { gpio = <&gpio2 19 GPIO_ACTIVE_HIGH>; enable-active-high; }; + + mux: mux-controller { + compatible = "gpio-mux"; + #mux-control-cells = <0>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_typec_mux>; + mux-gpios = <&gpio4 20 GPIO_ACTIVE_HIGH>, + <&gpio2 20 GPIO_ACTIVE_HIGH>; + idle-state = <2>; + + port { + usb3_data_ss: endpoint { + remote-endpoint = <&typec_con_ss>; + }; + }; + }; }; &A53_0 { @@ -299,6 +316,56 @@ LDO5 { }; }; +&i2c2 { + clock-frequency = <100000>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_i2c2>; + status = "okay"; + + ptn5110: tcpc@50 { + compatible = "nxp,ptn5110"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_typec>; + reg = <0x50>; + interrupt-parent = <&gpio4>; + interrupts = <19 8>; + + port { + typec_dr_sw: endpoint { + remote-endpoint = <&usb3_drd_sw>; + }; + }; + + usb_con: connector { + compatible = "usb-c-connector"; + label = "USB-C"; + power-role = "dual"; + data-role = "dual"; + try-power-role = "sink"; + source-pdos = ; + sink-pdos = ; + op-sink-microwatt = <15000000>; + self-powered; + + mux-controls = <&mux>; + typec-switch-states = <2>, <0>, <1>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@1 { + reg = <1>; + typec_con_ss: endpoint { + remote-endpoint = <&usb3_data_ss>; + }; + }; + }; + }; + }; +}; + &i2c3 { clock-frequency = <400000>; pinctrl-names = "default"; @@ -361,7 +428,41 @@ &uart2 { status = "okay"; }; +&usb3_phy0 { + fsl,phy-tx-vref-tune = <0xe>; + fsl,phy-tx-preemp-amp-tune = <3>; + fsl,phy-tx-vboost-level = <5>; + fsl,phy-comp-dis-tune = <7>; + fsl,pcs-tx-deemph-3p5db = <0x21>; + fsl,phy-pcs-tx-swing-full = <0x7f>; + status = "okay"; +}; + +&usb3_0 { + status = "okay"; +}; + +&usb_dwc3_0 { + dr_mode = "otg"; + hnp-disable; + srp-disable; + adp-disable; + usb-role-switch; + role-switch-default-mode = "none"; + snps,dis-u1-entry-quirk; + snps,dis-u2-entry-quirk; + status = "okay"; + + port { + usb3_drd_sw: endpoint { + remote-endpoint = <&typec_dr_sw>; + }; + }; +}; + &usb3_phy1 { + fsl,phy-tx-preemp-amp-tune = <3>; + fsl,phy-tx-vref-tune = <0xb>; status = "okay"; }; @@ -488,6 +589,13 @@ MX8MP_IOMUXC_I2C1_SDA__I2C1_SDA 0x400001c2 >; }; + pinctrl_i2c2: i2c2grp { + fsl,pins = < + MX8MP_IOMUXC_I2C2_SCL__I2C2_SCL 0x400001c2 + MX8MP_IOMUXC_I2C2_SDA__I2C2_SDA 0x400001c2 + >; + }; + pinctrl_i2c3: i2c3grp { fsl,pins = < MX8MP_IOMUXC_I2C3_SCL__I2C3_SCL 0x400001c2 @@ -527,6 +635,18 @@ MX8MP_IOMUXC_UART2_TXD__UART2_DCE_TX 0x140 >; }; + pinctrl_typec: typec1grp { + fsl,pins = < + MX8MP_IOMUXC_SAI1_TXD7__GPIO4_IO19 0x1c4 + >; + }; + + pinctrl_typec_mux: typec1muxgrp { + fsl,pins = < + MX8MP_IOMUXC_SAI1_MCLK__GPIO4_IO20 0x16 + >; + }; + pinctrl_usb1_vbus: usb1grp { fsl,pins = < MX8MP_IOMUXC_GPIO1_IO14__USB2_OTG_PWR 0x10