From patchwork Tue May 9 07:46:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Looijmans X-Patchwork-Id: 680492 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 DEDAFC7EE22 for ; Tue, 9 May 2023 07:46:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234367AbjEIHqm (ORCPT ); Tue, 9 May 2023 03:46:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233108AbjEIHql (ORCPT ); Tue, 9 May 2023 03:46:41 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on20621.outbound.protection.outlook.com [IPv6:2a01:111:f400:7d00::621]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BBB97EC0; Tue, 9 May 2023 00:46:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=topic.nl; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eIBKRvSi9SjHx+ESwD7KfkJSdYDX8MgCsmDJxFiMG2g=; b=AN5b2xq5BCSr21JdPhk0+Bm0JjhGGOz0FQewEN34CJ6VhmZ9b1Yhr/LlKTEp5+cHCxHnIT38BvZWs7shPL1xyQmH1VU2icJ0pJCx8LVgO7dZEiTyXYtgqjvgT6NfJq93jBHG4Kmei18EG9s9S6xlUX3UlkZS3TM1aY9nb6vSBaTXR7uEj0lAxnoBvDQp+VpNfyXbLBmOQNaLhkdAWFguBxq5RyFQfxe210IDZbQCirxblBmjoRzcb+tObqUo0ckue4FeQB0ewtY3PC8jU98KlZ2euZOROx/jlKENZA71h5PGCJDSlI41xhJfKCDZblv5skpMtK+h9yURtIZo1XKulQ== Received: from DU2PR04CA0055.eurprd04.prod.outlook.com (2603:10a6:10:234::30) by DU2PR04MB8871.eurprd04.prod.outlook.com (2603:10a6:10:2e2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.33; Tue, 9 May 2023 07:46:34 +0000 Received: from DB5EUR01FT008.eop-EUR01.prod.protection.outlook.com (2603:10a6:10:234:cafe::fe) by DU2PR04CA0055.outlook.office365.com (2603:10a6:10:234::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.33 via Frontend Transport; Tue, 9 May 2023 07:46:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 20.93.157.195) smtp.mailfrom=topicproducts.com; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=topic.nl; Received-SPF: Pass (protection.outlook.com: domain of topicproducts.com designates 20.93.157.195 as permitted sender) receiver=protection.outlook.com; client-ip=20.93.157.195; helo=westeu11-emailsignatures-cloud.codetwo.com; pr=C Received: from westeu11-emailsignatures-cloud.codetwo.com (20.93.157.195) by DB5EUR01FT008.mail.protection.outlook.com (10.152.4.96) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.18 via Frontend Transport; Tue, 9 May 2023 07:46:33 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (104.47.2.56) by westeu11-emailsignatures-cloud.codetwo.com with CodeTwo SMTP Server (TLS12) via SMTP; Tue, 09 May 2023 07:46:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DccIktF01RSLxHWEXM5jbz9Rc+U2pGxrp9qk7lGUMDIDNnRK2k5ciEmLQfnRcwMnSdOj3LLO8bqNg3O/a6WYp2sPtFjFMj+zISODo3L1vspwBJHMd6CFF9ZGswMuyo0OsCz83Jtprq68/Qh7/u81t1C0OdS6UGmzDFcytksebbVpDpM6JUj2AsPBgDFXj6v4roiduCGM1WrYGfku8/9Ci/BI5BQw4y25zBFQCv7zSTKh1A4Nlu670RrwY0mAulR3NlNkgLh0ez0/vOCyecSzi76N3TTIE+ywC/H39lEdinJngpfSlgIXmrlyxp+AM8dE+MRzTYN5IiEOhBwmaCZ+2A== 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=X9LftdFbV/WNRh2vOn29IPJR/mhdPigxzD+O59Y5Idw=; b=GrvCWoeGFDmkFV0C8bdTVb6xmb7jW98uQWOWjDHPlXUQClqDcgQev7RAHBgBuIhiMsL8k4afuoiEHm3wxlG7wAguVhwXKKjCWz1j/LKFojweI9FvMOsSn5bwj/Q80+0H4zmoH5phU7VH4AC4EkArQeJxv5PN9bce9I/Ldut3iTscOz9///QvtICWup+BpG99f9EzAppRyQPnqjjOywihjdIaJwV2KWbcjoLpooxWyMXZPlK/s8Qv1Clmp/rmQuZchHCc+Zt4QT0ERNyFlu834BD93/kjxiQjSb4dkdqXIk2qUBma2tiTP90prrtEncrLE9FETeT6KJETsWR2xdVkgg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=topicproducts.com; dmarc=pass action=none header.from=topic.nl; dkim=pass header.d=topic.nl; arc=none Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=topic.nl; Received: from AM6PR04MB6520.eurprd04.prod.outlook.com (2603:10a6:20b:f7::16) by PAXPR04MB8288.eurprd04.prod.outlook.com (2603:10a6:102:1bc::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.33; Tue, 9 May 2023 07:46:28 +0000 Received: from AM6PR04MB6520.eurprd04.prod.outlook.com ([fe80::8cf4:9979:4ca8:213c]) by AM6PR04MB6520.eurprd04.prod.outlook.com ([fe80::8cf4:9979:4ca8:213c%6]) with mapi id 15.20.6363.033; Tue, 9 May 2023 07:46:28 +0000 From: Mike Looijmans To: devicetree@vger.kernel.org, linux-usb@vger.kernel.org CC: Mike Looijmans , Greg Kroah-Hartman , Krzysztof Kozlowski , Rob Herring , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] dt-bindings: usb: misc: Add microchip USB5807 HUB driver Date: Tue, 9 May 2023 09:46:20 +0200 Message-ID: <20230509074621.29774-1-mike.looijmans@topic.nl> X-Mailer: git-send-email 2.17.1 X-ClientProxiedBy: AS4P189CA0026.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:5db::13) To AM6PR04MB6520.eurprd04.prod.outlook.com (2603:10a6:20b:f7::16) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AM6PR04MB6520:EE_|PAXPR04MB8288:EE_|DB5EUR01FT008:EE_|DU2PR04MB8871:EE_ X-MS-Office365-Filtering-Correlation-Id: ca92ee56-7c29-4665-5e0f-08db50618290 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: MGvirCiUsmn8F8KEH378vOfQAM/NM3bqvQr6gOSJ+j09qKnAhpWGZ1lVqpS49Fr3yyHW4Wahyco+6Ufe4grsXVCQW8L6KlNoHNv1/YDEqxKgK58lUWU6Ax3ptmn+e+AybW3g99A8wta3e4RxIdfY0mIPxy91S6Hqzlqdt35samekPRiEcpNe3bhGYwWsOuh01ON8D2mlhR54l6LM+6CzmYnSzsO7M2MYdWKevuk3cWlaqOYfxJHfjkV7Bmhh5KVZNu8k9ERPgxZKrykgGFg/N4k5o2p18FKVuLuBM/ovrr+ccZpEMXt8KBjgngfpPgDVj3l52jawvASpBF/oXvl9ibo/y7kYWNQ7oputrfl9qYYUg8Yayv3Fp0qJBlKK3dN/bjquUHbp1JiAOa655Jhpedfhcsbw3xG/cr4UZ9WmawAoD9d49tYKbOk2CwTPY603iiCn+tTA5VqqqsXzJ1XRvV4x3D6pPHD7eZdFbOFeBhW/bw3QI5lZyH0cIdYNRtsXdzkIxF9/hZlNBSU+Y8ypR1wt3Un02pwu7MjRzMeFk0dtNzCtErXbCs/RTs5Eab6YBIitHJ9lrTvBIWcdIGSZ0vyKqmLiPRArW5AcHWW9+y0= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB6520.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(396003)(376002)(366004)(346002)(136003)(39840400004)(451199021)(2906002)(316002)(8676002)(8936002)(41300700001)(66476007)(478600001)(5660300002)(4326008)(54906003)(6666004)(66946007)(66556008)(44832011)(966005)(52116002)(6486002)(1076003)(6506007)(6512007)(26005)(186003)(83170400001)(36756003)(2616005)(42882007)(38100700002)(38350700002); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8288 X-CodeTwo-MessageID: 4f37d938-63bc-44c4-af5e-a7ba09e465be.20230509074631@westeu11-emailsignatures-cloud.codetwo.com X-CodeTwoProcessed: true References: <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.73717b19-477a-47ab-9efb-48f096304ca8@emailsignatures365.codetwo.com> X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR01FT008.eop-EUR01.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: bb7689ca-8c83-489d-d799-08db50617f35 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t5P6E9mrozFq9iztGpa7mBJXeCQ12uIUJGCLMFXBaSBcNgS/wf7S7znQ4uGi3NXLZUDLAEV6HZndcF7qhCI5eG3cFsCRwIvfbpojHQa9BqOF68NxQ4v9XntsSGHUYrgdMvk1T7IwDH6H1Qgmv99HnMapJfUWEIgMNpelbzElvM9gGNyLP0f50cw9JmePdb40NoJ9WLzbB0p1bcpG2Ll7FlplBzFMzqeBZkRfUi9XdOR3k8tXkfZHkrndR6JaopWAz5IDb16WLxXivuo63H9sqQI5W8dRswwtjngq0fOzkpyCFXw6V5i9j73ySUDlJapaIunrFzT6QLCS7J79Rxs1DmEQhJao6sRGYqenfB79DSF0vv2qMke3KPNccNu4H0LcS3a/k4GN4nTeefyCSzOEFDki3caMrWRFZ4OuiVp5TaU0mWuNf3cKfeeFbcAPf9pYcB8wDMjlNfVD4+wtd6JRAPLIm89t16NdzF/Z1sGPVssehbNTkPem7cmSO914JAZu3J/vTF29ZXrLYO7INlriDH/D2V0qaGmoJ+iedUdnq0JzYS6RQefgYs2d+MRHNOw12vH4xAc2Be5JLuhw4ScH9/10Ip8texRBi074bHvPyFIAytpnUWh5RQsoV4PAUF+uJl0Z4qDzZdNB/7/ojU7AEqdrBEoLWlZpxJspOJIELKI= X-Forefront-Antispam-Report: CIP:20.93.157.195; CTRY:NL; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:westeu11-emailsignatures-cloud.codetwo.com; PTR:westeu11-emailsignatures-cloud.codetwo.com; CAT:NONE; SFS:(13230028)(4636009)(396003)(136003)(39830400003)(376002)(346002)(451199021)(36840700001)(46966006)(966005)(70206006)(4326008)(336012)(478600001)(70586007)(6486002)(6666004)(316002)(54906003)(15974865002)(36756003)(47076005)(42882007)(1076003)(36860700001)(6506007)(6512007)(26005)(2616005)(8936002)(5660300002)(41300700001)(8676002)(44832011)(2906002)(82310400005)(40480700001)(356005)(7636003)(186003)(7596003)(83170400001); DIR:OUT; SFP:1101; X-OriginatorOrg: topic.nl X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2023 07:46:33.4200 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ca92ee56-7c29-4665-5e0f-08db50618290 X-MS-Exchange-CrossTenant-Id: 449607a5-3517-482d-8d16-41dd868cbda3 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=449607a5-3517-482d-8d16-41dd868cbda3; Ip=[20.93.157.195]; Helo=[westeu11-emailsignatures-cloud.codetwo.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR01FT008.eop-EUR01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8871 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The USB5807 is a 7-port USB 3.1 hub that can be configured by I2C. This driver resets the chip, optionally allows D+/D- lines to be swapped in the devicetree config, and then sends an ATTACH command to put the device in operational mode. Signed-off-by: Mike Looijmans --- .../devicetree/bindings/usb/usb5807.yaml | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/usb5807.yaml diff --git a/Documentation/devicetree/bindings/usb/usb5807.yaml b/Documentation/devicetree/bindings/usb/usb5807.yaml new file mode 100644 index 000000000000..06b94210c281 --- /dev/null +++ b/Documentation/devicetree/bindings/usb/usb5807.yaml @@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/usb/usb5807.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Microchip USB 3.1 SuperSpeed Hub Controller + +maintainers: + - Mike Looijmans + +properties: + compatible: + enum: + - microchip,usb5807 + + reg: + maxItems: 1 + + reset-gpios: + description: | + Should specify the gpio for hub reset + + swap-dx-lanes: + $ref: /schemas/types.yaml#/definitions/uint8-array + description: | + Specifies the ports which will swap the differential-pair (D+/D-), + default is not-swapped. + +additionalProperties: false + +required: + - compatible + - reg + +examples: + - | + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + usb-hub@2d { + compatible = "microchip,usb5807"; + reg = <0x2d>; + reset-gpios = <&gpio1 4 GPIO_ACTIVE_LOW>; + /* Swapped D+/D- on port 0 */ + swap-dx-lanes = <0>; + }; + }; From patchwork Tue May 9 07:46:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Looijmans X-Patchwork-Id: 681156 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 3FCA8C7EE23 for ; Tue, 9 May 2023 07:46:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234398AbjEIHqp (ORCPT ); Tue, 9 May 2023 03:46:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234346AbjEIHqm (ORCPT ); Tue, 9 May 2023 03:46:42 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on0607.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::607]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C3017DA3; Tue, 9 May 2023 00:46:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=topic.nl; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mlof671XPa6plhd/8pcw2icwMd1BgxnaHE4UK9/4Icw=; b=lNf82PSnFK9UR1wUcM/z6z48VykRnfDGn6E1Gz4YZej7to3KG8CMj16DjUUz5qWDXnVvKMdPaxGRAuS50g9AitTQnTO9bX4W4Zu5Pp6q+aOPVkLhuH49bdoQzJUW70TdCC6MoUeEVlY+6SXtR4mVo1hXtg2gLgxeAljWhTSueXr9q76Wncv3c27aWubt5BBL2x0hEZe56asSagCESjl+zQoPkWddC10BEeQk0LgHkMn3L24kTlMr5EgWsebIMDekfaPEXwgzgcAS37cOMkYgp87z0zeWf6UiQuZ+ARyf3RO4TEPSMAxUQPMK/kGWF45f2roEYKanXMn299sv+5+rJg== Received: from FR0P281CA0063.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:49::11) by PA4PR04MB7646.eurprd04.prod.outlook.com (2603:10a6:102:f3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.33; Tue, 9 May 2023 07:46:33 +0000 Received: from VE1EUR01FT077.eop-EUR01.prod.protection.outlook.com (2603:10a6:d10:49:cafe::40) by FR0P281CA0063.outlook.office365.com (2603:10a6:d10:49::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.18 via Frontend Transport; Tue, 9 May 2023 07:46:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 20.93.157.195) smtp.mailfrom=topicproducts.com; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=topic.nl; Received-SPF: Pass (protection.outlook.com: domain of topicproducts.com designates 20.93.157.195 as permitted sender) receiver=protection.outlook.com; client-ip=20.93.157.195; helo=westeu11-emailsignatures-cloud.codetwo.com; pr=C Received: from westeu11-emailsignatures-cloud.codetwo.com (20.93.157.195) by VE1EUR01FT077.mail.protection.outlook.com (10.152.3.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.18 via Frontend Transport; Tue, 9 May 2023 07:46:33 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (104.47.2.56) by westeu11-emailsignatures-cloud.codetwo.com with CodeTwo SMTP Server (TLS12) via SMTP; Tue, 09 May 2023 07:46:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UJat8OLJWoLEY6Dpkqc/LvkOaQJaWFoJruqLMvjWVuK3vgyqdWByflxkU0qSUVpuGp5SfeDUsyg8TXYUcEaD925w/isWDb2NoxajoyWPd/GQzO7h7qvxvy4DXeOPwCDTTBIJnuPxuwZg8XmsbyVlZS/Hq58HPQ7MAUGRhJkyypfoiLK5Ml6Jy1PbckCpZl1P4sBzefi7vInsUXrNmuMFKGYXqmix2/IQYtEHW6eECQbXLw+6o7yaIVjBkmNmUEhERkIZhuIJZblcRWupTD6RnVx3nKXNFWCtE7K5zicRSiV2LoPUp/A4q348Dc9GcwbSK0udreLT9f9681orcj6otg== 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=gKlywL/exQRX0ZOdLE4a9Smvf72TMofRBaj+iqm5/uM=; b=RN+78jFDpHugznKCxCFAkewIstVUoVy38T20beU1OYH0eJD6QymY6kU2g/ofhQNwZm4F1pH1Pz2ktDC0TyHq2jqGhqlPy8I0/QprIXvs5fUheQMCZ8zR/hzUE3mqKpaFHdb1skJMDlmpuZ5v76/c5skDYeEaIsXC1YZuNrqr5L7Hb0l4UJ7Vp46ERKNhJHaP+Ka8KU+LhFMAeFqBX1C4w3JCz12zte2oZJZb9sZjnqtatEf2SkmXYG3CHyzwWbAcb0QDxPuVTvLP+2QnWizckbUlZcaqO8tPLkARI5RbMupOrqS/5DZZEoxbJK6tigErVAFCRM1bueYsMjwmvDOe2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=topicproducts.com; dmarc=pass action=none header.from=topic.nl; dkim=pass header.d=topic.nl; arc=none Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=topic.nl; Received: from AM6PR04MB6520.eurprd04.prod.outlook.com (2603:10a6:20b:f7::16) by PAXPR04MB8288.eurprd04.prod.outlook.com (2603:10a6:102:1bc::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.33; Tue, 9 May 2023 07:46:28 +0000 Received: from AM6PR04MB6520.eurprd04.prod.outlook.com ([fe80::8cf4:9979:4ca8:213c]) by AM6PR04MB6520.eurprd04.prod.outlook.com ([fe80::8cf4:9979:4ca8:213c%6]) with mapi id 15.20.6363.033; Tue, 9 May 2023 07:46:28 +0000 From: Mike Looijmans To: devicetree@vger.kernel.org, linux-usb@vger.kernel.org CC: Mike Looijmans , Douglas Anderson , Greg Kroah-Hartman , Jean Delvare , Lukas Bulwahn , Matthias Kaehlcke , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] usb: misc: usb5807: Add driver Date: Tue, 9 May 2023 09:46:21 +0200 Message-ID: <20230509074621.29774-2-mike.looijmans@topic.nl> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230509074621.29774-1-mike.looijmans@topic.nl> References: <20230509074621.29774-1-mike.looijmans@topic.nl> <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.3007118c-795d-4ecd-9a82-6f1b4cd17152@emailsignatures365.codetwo.com> X-ClientProxiedBy: AS4P189CA0026.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:5db::13) To AM6PR04MB6520.eurprd04.prod.outlook.com (2603:10a6:20b:f7::16) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AM6PR04MB6520:EE_|PAXPR04MB8288:EE_|VE1EUR01FT077:EE_|PA4PR04MB7646:EE_ X-MS-Office365-Filtering-Correlation-Id: c2775ce2-bef2-477f-386d-08db5061827d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: QDm1QZm6p06X6HEHTtsX7LD03EbxMmNCPIn1nzpto7ByIUr2BDx4nUpbf9e+uL05/hy1e7hgJh5LN36AkAu0jtEIrTvAFMtA90LZeOG0TcIyQR5nSOInkZZt35INKet9buRHOmieyuTOg6yFoR7vtiK1FOtT/Akvj5pDmNP6CpOoIw/M3gljANGaVN3TfC0l9wuv3iYf9TD++Yf2Y7nySVT32kfHoOQIB1Q8NZlpwsm7fwzyEg/nzaA0queXJDTi+0yvy/bDRbJ5EiXUW70Ra8P0DaHDPJ4lwtCheawT48+nkAXvoTbOL7TQRPJ0PJcWjnCL1JA0KxRHXZ16H9/sJNn0bNc+sTjC0Gkq0AgwAAYkF/pnlbyC1a4Aa4zmk6BJHsWA1MyQrIUv7vulG3rFk6PjpHilrbLRhNwdCAyopxAe+5+AbZh25sHrQJ23kt1DA9p5dcy+7AWsy48bx3LivUvJ4vpP9c+5XihQ3ZhG3kaH6iFFRErRZciHJvTixdjWu1i3Hkz3F/WKymq9eXheFgwZeH8lb2HL/jR7A8owwhUD1mMaK3dv/CRwWyfMt3Bu2L2iYOKskgcQtNpaL16dwBjnajtyyQV0YvsdCymNfnbIDHmn0AvX7JmPiCdUYJ5K X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB6520.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(396003)(376002)(366004)(346002)(136003)(39840400004)(451199021)(2906002)(316002)(8676002)(8936002)(41300700001)(66476007)(478600001)(5660300002)(4326008)(54906003)(6666004)(66946007)(66556008)(44832011)(52116002)(6486002)(1076003)(6506007)(6512007)(26005)(186003)(83170400001)(36756003)(2616005)(42882007)(83380400001)(38100700002)(38350700002); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8288 X-CodeTwo-MessageID: 0e4abc81-9e56-435a-af77-2eed4e4f38ee.20230509074632@westeu11-emailsignatures-cloud.codetwo.com X-CodeTwoProcessed: true X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR01FT077.eop-EUR01.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 7aad3543-32c6-415f-acd7-08db50617f6c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: J4ec3dqrL8V6Vn4oQCBjzuXVCU99L9SDJYzgCESIblxDgwmgLJ4PIxmlBjeV/fOgH4WUEcg9JsroDk2A6F/TfmMr134OF9cQ7VKPSY2ltNJDwpRkQFOFCfuHdj83X9oyiF04wjSngy7Mhr1HQOrLSF6fJLzMEWYi0umb5tVnVFkKQQaru4M2dHE+qj5exNgdw8NrTr+DRYkl0fLSCQWOV7iBLu2JsLNG0Vy1yHfFURgVMn/qmxmXVsl+zrlt5wwUvpcn6xNRSwjgfm53uzOR4KQU3W0NTs61EBFEzMOQ+wNr3k+HsbiewA38y3Oz1bZI7KxTOKBL4mU/1c6XwOEycu3s2UHvYPUTwV3tb99JEzckNiHc7nup6nEz1Bn8jy+e2yFn69urEmKGVd5S1A5aj5pQae75Ss+1QdvpYOenco/Ghj20ZsYDdEUKgB73p8yx95qpB5zt0sAg2yvSuBWroVp9BjyGV4/SgEhUMIjBDEMVTEhtMC8jcPybQp6H3f2KJVkSRNvnpHSOrcnCK0vwihtStCKmtcGch7Htjz2Xi/xi3dUMSctEy4kpHyWHfHbJkDVHmPQeRkdk0uT8whi5FVqUDHHeLw/wjXzkq6+RHt/g3qklHUO2MGKcD7GIsHMH3JVtI9fkYiONGsvr2ZZwP9SrbqBzarRarGEI3Hx4B8M= X-Forefront-Antispam-Report: CIP:20.93.157.195; CTRY:NL; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:westeu11-emailsignatures-cloud.codetwo.com; PTR:westeu11-emailsignatures-cloud.codetwo.com; CAT:NONE; SFS:(13230028)(4636009)(396003)(376002)(39840400004)(346002)(136003)(451199021)(36840700001)(46966006)(356005)(26005)(1076003)(6506007)(6512007)(7636003)(83170400001)(7596003)(70206006)(40480700001)(70586007)(2906002)(44832011)(4326008)(8676002)(316002)(82310400005)(54906003)(15974865002)(41300700001)(8936002)(478600001)(5660300002)(336012)(36860700001)(83380400001)(2616005)(42882007)(6486002)(6666004)(36756003)(47076005)(186003); DIR:OUT; SFP:1101; X-OriginatorOrg: topic.nl X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2023 07:46:33.2007 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c2775ce2-bef2-477f-386d-08db5061827d X-MS-Exchange-CrossTenant-Id: 449607a5-3517-482d-8d16-41dd868cbda3 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=449607a5-3517-482d-8d16-41dd868cbda3; Ip=[20.93.157.195]; Helo=[westeu11-emailsignatures-cloud.codetwo.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR01FT077.eop-EUR01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7646 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The USB5807 is a 7-port USB 3.1 hub that can be configured by I2C. This drivers resets the chip, optionally allows D+/D- lines to be swapped in the devicetree config, and then sends an ATTACH command to put the device in operational mode. Signed-off-by: Mike Looijmans --- drivers/usb/misc/Kconfig | 9 ++ drivers/usb/misc/Makefile | 1 + drivers/usb/misc/usb5807.c | 175 +++++++++++++++++++++++++++++++++++++ 3 files changed, 185 insertions(+) create mode 100644 drivers/usb/misc/usb5807.c diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig index 99b15b77dfd5..6659e917ea26 100644 --- a/drivers/usb/misc/Kconfig +++ b/drivers/usb/misc/Kconfig @@ -251,6 +251,15 @@ config USB_EZUSB_FX2 Say Y here if you need EZUSB device support. (Cypress FX/FX2/FX2LP microcontrollers) +config USB_HUB_USB5807 + tristate "USB5807 Hub Controller Configuration Driver" + depends on I2C + help + This option enables support for configuration via SMBus of the + Microchip USB5807 USB 3.1 Hub Controller. Configuration parameters may + be set in devicetree. + Say Y or M here if you need to configure such a device via SMBus. + config USB_HUB_USB251XB tristate "USB251XB Hub Controller Configuration Driver" depends on I2C diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile index 1992cc284d8a..e827ed251fa5 100644 --- a/drivers/usb/misc/Makefile +++ b/drivers/usb/misc/Makefile @@ -25,6 +25,7 @@ obj-$(CONFIG_USB_USS720) += uss720.o obj-$(CONFIG_USB_SEVSEG) += usbsevseg.o obj-$(CONFIG_USB_YUREX) += yurex.o obj-$(CONFIG_USB_HUB_USB251XB) += usb251xb.o +obj-$(CONFIG_USB_HUB_USB5807) += usb5807.o obj-$(CONFIG_USB_HSIC_USB3503) += usb3503.o obj-$(CONFIG_USB_HSIC_USB4604) += usb4604.o obj-$(CONFIG_USB_CHAOSKEY) += chaoskey.o diff --git a/drivers/usb/misc/usb5807.c b/drivers/usb/misc/usb5807.c new file mode 100644 index 000000000000..04080ca81d4d --- /dev/null +++ b/drivers/usb/misc/usb5807.c @@ -0,0 +1,175 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Driver for Microchip USB5807 USB 3.1 Hub + * Configuration via SMBus. + * + * Copyright (c) 2023 Topic Embedded Products + */ + +#include +#include +#include +#include +#include +#include +#include + +#define USB5807_CMD_ATTACH 0xAA55 +#define USB5807_CMD_CONFIG 0x9937 + +#define USB5807_REG_LANE_SWAP 0x30FA + +#define USB5807_NUM_PORTS 7 + + +static int usb5807_write(struct i2c_client *i2c, void *buf, u8 len) +{ + int ret; + struct i2c_msg msg = { + .addr = i2c->addr, + .flags = 0x0, + .len = len, + .buf = buf, + }; + + ret = i2c_transfer(i2c->adapter, &msg, 1); + return ret < 0 ? ret : 0; +} + +/* + * Send a command sequence, which is an I2C write transaction, with the command + * word in big endian and a terminating "0" byte. + */ +static int usb5807_command(struct i2c_client *i2c, u16 cmd) +{ + u8 buf[3] = {cmd >> 8, cmd & 0xff, 0}; + + return usb5807_write(i2c, buf, sizeof(buf)); +} + +static int usb5807_prepare_reg_u8(struct i2c_client *i2c, u16 reg, u8 value) +{ + u8 buf[] = { + 0x00, + 0x00, /* Memory offset */ + 1 + 4, /* Transaction size */ + 0x00, /* 0 = Register write operation */ + 1, /* Size of register data */ + (reg >> 8) & 0xff, + reg & 0xff, /* Register offset */ + value, /* Register data */ + 0 /* Terminating zero */ + }; + + return usb5807_write(i2c, buf, sizeof(buf)); +} + +/* + * Write an 8-bit register. First we must write the "set register" operation to + * the chip's internal memory at offset 0, then issue a command to execute said + * operation. + */ +static int usb5807_write_reg_u8(struct i2c_client *i2c, u16 reg, u8 value) +{ + int ret; + + ret = usb5807_prepare_reg_u8(i2c, reg, value); + if (ret) + return ret; + + return usb5807_command(i2c, USB5807_CMD_CONFIG); +} + +/* Decode array of port numbers property into bit mask */ +static u8 usb5807_get_ports_field(struct device *dev, const char *prop_name) +{ + struct property *prop; + const __be32 *p; + u32 port; + u8 result = 0; + + of_property_for_each_u32(dev->of_node, prop_name, prop, p, port) { + if (port < USB5807_NUM_PORTS) + result |= BIT(port); + else + dev_warn(dev, "%s: port %u doesn't exist\n", prop_name, + port); + } + return result; +} + +static int usb5807_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) +{ + struct device_node *np = i2c->dev.of_node; + struct gpio_desc *reset_gpio; + int ret; + u8 val; + + /* Reset the chip to bring it into configuration mode */ + reset_gpio = devm_gpiod_get_optional(&i2c->dev, "reset", + GPIOD_OUT_HIGH); + if (IS_ERR(reset_gpio)) { + return dev_err_probe(&i2c->dev, PTR_ERR(reset_gpio), + "Failed to request reset GPIO\n"); + } + /* Reset timing: Assert for >= 5 us */ + usleep_range(5, 10); + + /* Lock the bus for >= 1ms while the hub reads the I2C strapping */ + i2c_lock_bus(i2c->adapter, I2C_LOCK_SEGMENT); + + gpiod_set_value_cansleep(reset_gpio, 0); + usleep_range(1000, 2000); + + i2c_unlock_bus(i2c->adapter, I2C_LOCK_SEGMENT); + + /* The hub device needs additional time to boot up */ + msleep(20); + + val = usb5807_get_ports_field(&i2c->dev, "swap-dx-lanes"); + if (val) { + ret = usb5807_write_reg_u8(i2c, USB5807_REG_LANE_SWAP, val); + if (ret < 0) + dev_err(&i2c->dev, "Failed writing config: %d\n", ret); + } + + /* + * Send the "Attach" command which makes the device disappear from the + * I2C bus and starts USB enumeration. + */ + ret = usb5807_command(i2c, USB5807_CMD_ATTACH); + if (ret) { + dev_err(&i2c->dev, "Failed sending ATTACH command: %d\n", ret); + return ret; + } + + return 0; +} + +static const struct of_device_id usb5807_of_match[] = { + { .compatible = "microchip,usb5807" }, + { } /* sentinel */ +}; +MODULE_DEVICE_TABLE(of, usb5807_of_match); + +static const struct i2c_device_id usb5807_id[] = { + { "usb5807", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(i2c, usb5807_id); + +static struct i2c_driver usb5807_i2c_driver = { + .driver = { + .name = "usb5807", + .of_match_table = of_match_ptr(usb5807_of_match), + }, + .probe = usb5807_i2c_probe, + .id_table = usb5807_id, +}; + +module_i2c_driver(usb5807_i2c_driver); + +MODULE_AUTHOR("Mike Looijmans "); +MODULE_DESCRIPTION("USB5807 USB 3.1 Hub Controller Driver"); +MODULE_LICENSE("GPL");