From patchwork Fri Sep 15 12:23:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 723911 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51F7810782; Fri, 15 Sep 2023 12:24:01 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2077.outbound.protection.outlook.com [40.107.21.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC7A7A1; Fri, 15 Sep 2023 05:23:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dJ4gM4ebM0Xvbuy2+ynWACA2XYwHS+ezSvLS1uxAkkkdk7lAybcy/9rDnDEh2lUv3+i9HVbFP0IKBtlbuyrVNUyFfAGG5mELVGFQClv0iToatVFnDB4Unv7yfy409Pme4Zn5RNGUZ7E5C/NR+7HjpqxMzmiaJMQgEJ3nnPJMYUnmZgGWpsg2sCCam/wtFfaLRl3FOOSssq0hzrKYSFrhE4r5Fk4LrO9/z8RMUiGtlWRpRq8Ui7VOCbsnoMsubJOplMudZTfMdVYkTTU14bXcqGqkdmtKuTY3DkCuo5q8naXGvCr3shKy3orQyQott9Q43bDeoaFaexISVq8xGYrIsA== 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=pTTQT19L7HjRJKYntCtQprFIpS9KlOu3/TE7GC4ctpE=; b=Qn2t/5PCO2H98piZaOSggOjn+ZH5WfmNNR/qf/GUtp/krXRaxS5qbqCgSIKzgupwFEXHIR/eymO5C/UG5ue9M0SNLnL5OvvWLTDO6tN3uvOXUgugnZgGkdWz4oCPNUvNonMvWFxA+OjUhdbKRU9iCBqQXDkxrVWNFDPJWZfJLw2NbBKeQVDxKesdrI5Bv3ZJuvyXZ7CnwSMgIFKr5AMx+PivE1OAmR1lBqQy39J0y4hJGqnaIyX0XRqeZgl1y8i7rgppMZxEW2b1JlollGyiU52BOVaUjKtcZvPttgOToOChKw8GhEyWXmLLTBwPT0WohClmNzY2aVnOO2MhBxkLOA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wolfvision.net; dmarc=pass action=none header.from=wolfvision.net; dkim=pass header.d=wolfvision.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfvision.net; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pTTQT19L7HjRJKYntCtQprFIpS9KlOu3/TE7GC4ctpE=; b=EMWnHQaX2+3d3ZYgGta9HyL6Iyz78m1WmT8xqwL4jajA8K7Jyq53TcBWFEulyjpok2s5IZxcCpr+fns48NZLsfIyuhE4O1oeX0m8xjXeZumTxqBhS1okN54A6XMHGmW6zahU6Gm2EUE3eVnyxO8aMzbkKohCS68mNCYZ3VDyMJM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) by PAXPR08MB7623.eurprd08.prod.outlook.com (2603:10a6:102:241::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.34; Fri, 15 Sep 2023 12:23:57 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::bc92:216b:11ed:db63]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::bc92:216b:11ed:db63%6]) with mapi id 15.20.6792.020; Fri, 15 Sep 2023 12:23:57 +0000 From: Javier Carrasco Date: Fri, 15 Sep 2023 14:23:48 +0200 Subject: [PATCH v2 1/2] usb: typec: tps6598x: add reset gpio support Message-Id: <20230912-topic-tps6598x_reset-v2-1-02a12e2ec50a@wolfvision.net> References: <20230912-topic-tps6598x_reset-v2-0-02a12e2ec50a@wolfvision.net> In-Reply-To: <20230912-topic-tps6598x_reset-v2-0-02a12e2ec50a@wolfvision.net> To: Heikki Krogerus , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bryan O'Donoghue Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1694780635; l=3284; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=Mb/s2zUWSB3Ay1wXUJgJKbRyivb9+MCEZzgkcveh3no=; b=wm3IV10vWkFbK8tTb5MikBcIZZnOvss7xjpvxQsbpOmbt3/UPv4Y7oGWqqxbuNAqV9VfbIP7P 6q+kA5Zs6kZAdCwYd7fEugBoAq+N8DQlg+iP1PKrFSqXhciEIxtDiLL X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: AS9P250CA0001.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:532::7) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|PAXPR08MB7623:EE_ X-MS-Office365-Filtering-Correlation-Id: bba0bb76-63df-4d70-30d3-08dbb5e6a208 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ltlPmHCi5bNxDiuP1RTOS8I2gqLueX1/7wY/EgZ2asMEmBTJDMWXuasJqMVUJTKo/tWaeeLndEL9Su88tHjdKZyMEoNcdYvF9BayGSiMeFezoh3N3HdHUXa9NgCd7KK4QfOKJISqnOgV/u/MrlrVmmp5EMCCEeGRy490gvZiv4AURnoBgFZ8ZzhjRVvMFOMCGeAqFjMpvv1s0ltP0PfYhWmgWzcoxEmpMqlJPb1S78b8CPvzjNRSji0+AuBtje4TPDAw3zjfaLkHd2jJ34DloKIPFv5t5wWBWDghClDrSrFjiJg+rVnUz9EC5WruDmUzkZXu/7Hbh9mV7aNdoxtRVO1l7EgGfg+TeqFcEpTiTyl0sjmY3q92tef7dO9KV2+o1TYmsGFdPopheUeAntO1M1B5tUEhFxCG261IEpCyBCIhJkx/8gLX9cTzmrpx6s0Wqs41Ek3bAJOjE4WsM/NVEr8lKJ8ulETf32YV8cNj4Q6CXA7V4YYGC2ggQQzS9n5NMraJPyAGaC8gEp9/wNtEWPlkAJO7uSuCMz4wgsXrwJnj4EjS0YhSdVaXYAcxMTl19O5yyDCg9vAkCqkP43Co0MXD/FqmiMZL6ckwTxIZk0I= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR08MB4974.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(376002)(136003)(346002)(366004)(39850400004)(396003)(186009)(1800799009)(451199024)(6666004)(52116002)(6486002)(6506007)(44832011)(6512007)(966005)(478600001)(107886003)(2616005)(26005)(2906002)(66556008)(66946007)(66476007)(110136005)(4326008)(5660300002)(41300700001)(8936002)(316002)(8676002)(38100700002)(36756003)(86362001)(83380400001)(38350700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?bEpj+hG6hQP77QNPzeG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ej+1lWLotkLwIgFXdtO2jQ6QDtITGXp7za7ciGFsjCOq673y7PRgb8pIOX54CH?= =?utf-8?q?IXKqLePCc2Y900z6jO3R1o5BnG6wLvAN8AuzUZxUL7HMt4dmii8o8lFMeMHvlbK3/?= =?utf-8?q?wKOJzjnfwt73RIhEWes0ee0EAE9NBPdCnh9GypPFF3+1LkrfTHTbA3HbvnED6J28r?= =?utf-8?q?PDacylspbZEApxLYrmY5UrJ54Hfqs+hadOu1HtlXwFW3alBIyukWgm53Ohjs2Moan?= =?utf-8?q?a0PewrJScwVx8LRIQLJzNcg5Vg4sN08MZY1+2ywm6SRbesUkycaYTKBpDUl+XxwQh?= =?utf-8?q?KcbXfIJKLhusJ6RQ0IN2O2Cbo5b9aRX4HmY0qaTJcsfTaqcIj2n3UMf7jgrsqmx/z?= =?utf-8?q?gw8Xfz59vPDlQAsmvvEnaeu5wO//BSswbF0rjDg0Q6JA0Njf3Yr9qm8FDW3EEx7A4?= =?utf-8?q?bvSzicWX5s+cgResuASkwYtDO6Mq7DxP0f348+wlwz3hLOPUdCEL9ZA5lrZ7CE/xm?= =?utf-8?q?xMFc6wjpwgbUbP9UMcyYE3EkOT+TVg4skMvQH174J0c0LuflpqdG2ffhqQJhcxrJi?= =?utf-8?q?kiDdvNnM4VXPqwTIMehb93km185mwdOarOaWtIQEFaK25EZRqc6eN+OFIbeXSx1Gz?= =?utf-8?q?5N2qekBOiibyA72IS2VpZLoQjATJYtFAL3puR0Cv4WuslbLiikuyx4E=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: bba0bb76-63df-4d70-30d3-08dbb5e6a208 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2023 12:23:57.0576 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e94ec9da-9183-471e-83b3-51baa8eb804f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4zha+vLzhL8JUincvRGzlDXsnq29TcgX3lBWhzcho0uDqiute4qsFN4QcNMHzNp3gSl6ZkGhS+zfOhWwLl7UgueoIpzGKapYLdV4cc73FIc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB7623 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net The TPS6598x PD controller provides an active-high hardware reset input that reinitializes all device settings. If it is not grounded by design, the driver must be able to de-assert it in order to initialize the device. The PD controller is not ready for registration right after the reset de-assertion and a delay must be introduced in that case. According to TI, the delay can reach up to 1000 ms [1], which is in line with the experimental results obtained with a TPS65987D. Add a GPIO descriptor for the reset signal and basic reset management for initialization and suspend/resume. [1] https://e2e.ti.com/support/power-management-group/power-management/ f/power-management-forum/1269856/tps65987d-tps65987d-reset-de-assert- to-normal-operation/4809389#4809389 Signed-off-by: Javier Carrasco Reviewed-by: Bryan O'Donoghue --- drivers/usb/typec/tipd/core.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 37b56ce75f39..3068ef300073 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -43,6 +44,9 @@ /* TPS_REG_SYSTEM_CONF bits */ #define TPS_SYSCONF_PORTINFO(c) ((c) & 7) +/* reset de-assertion to ready for operation */ +#define SETUP_MS 1000 + enum { TPS_PORTINFO_SINK, TPS_PORTINFO_SINK_ACCESSORY, @@ -86,6 +90,7 @@ struct tps6598x { struct mutex lock; /* device lock */ u8 i2c_protocol:1; + struct gpio_desc *reset; struct typec_port *port; struct typec_partner *partner; struct usb_pd_identity partner_identity; @@ -717,6 +722,13 @@ static int tps6598x_probe(struct i2c_client *client) mutex_init(&tps->lock); tps->dev = &client->dev; + tps->reset = devm_gpiod_get_optional(tps->dev, "reset", GPIOD_OUT_LOW); + if (IS_ERR(tps->reset)) + return dev_err_probe(tps->dev, PTR_ERR(tps->reset), + "failed to get reset GPIO\n"); + if (tps->reset) + msleep(SETUP_MS); + tps->regmap = devm_regmap_init_i2c(client, &tps6598x_regmap_config); if (IS_ERR(tps->regmap)) return PTR_ERR(tps->regmap); @@ -892,6 +904,9 @@ static void tps6598x_remove(struct i2c_client *client) tps6598x_disconnect(tps, 0); typec_unregister_port(tps->port); usb_role_switch_put(tps->role_sw); + + if (tps->reset) + gpiod_set_value_cansleep(tps->reset, 1); } static int __maybe_unused tps6598x_suspend(struct device *dev) @@ -902,6 +917,8 @@ static int __maybe_unused tps6598x_suspend(struct device *dev) if (tps->wakeup) { disable_irq(client->irq); enable_irq_wake(client->irq); + } else if (tps->reset) { + gpiod_set_value_cansleep(tps->reset, 1); } if (!client->irq) @@ -918,6 +935,9 @@ static int __maybe_unused tps6598x_resume(struct device *dev) if (tps->wakeup) { disable_irq_wake(client->irq); enable_irq(client->irq); + } else if (tps->reset) { + gpiod_set_value_cansleep(tps->reset, 0); + msleep(SETUP_MS); } if (!client->irq)