From patchwork Wed May 17 16:16:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 95411 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1261992vqo; Wed, 17 May 2023 09:24:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ73XXw+eRybZO7JizBU792whi+Kowtn0IRjbRCMbnkXahLstDwlD+bSmdyLoX1W6aaMGRsx X-Received: by 2002:a05:6a20:160f:b0:103:81cc:dd3f with SMTP id l15-20020a056a20160f00b0010381ccdd3fmr34998018pzj.48.1684340650677; Wed, 17 May 2023 09:24:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1684340650; cv=pass; d=google.com; s=arc-20160816; b=uborlNt4fcpBAX9ZgOCixzgyBM7Pv3laL/V4UUF6qY0/L9ZjWILSgg/IEexYvVLoVA GH6rlDYFgpVQiKKb13okdMlNP3lwXSSAmBd7QL4jYyhyO07Tng622snRPViAj3mfho4k CmC7Qly2rycq9QhlBZYz0J5zD+p3qslROO4AcmDZLg9SShvQp7iF0U+uaQIvnvVwhL5h ETOnj8EMTV0I9oTS5fX/zGi7PrubMmjMAxE6uvfsn0Ry9fX9/HkaZCEmEYTqij+1q/o9 yrGq1Qwnp5gkNjGCZHVkkrZDQyv4Vh+bSYU5AlfKNembv0BtGDVjMc3tSE8cmbY0hf2g KImw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DVm17g7uRevK5sYQoI5+K/wE4ULpyAFhfUnYx0zKro4=; b=IQo4ntL1/UL7Tlt6l68AhmPLjaTyLvrBevu3AYbp4seExc2371rGnA88ykPcafWK8z /Z9DVlaM+WogIlXW4OWO0w2+3XCza37GE1z13HCg156NYOZpbnRu9NaHjLUBUIG47o6J QcoPr2BBpczl+2pOt1bFe5T5nFfkVW840oWJp+ik2tGNfr7sAeeFSm+8nCXNy5ArnBab c0bkVQg57O2TalCr1u/GNxaS401sHDl+5vNJGLUf+shMznzmCFUv2KqS/l0ZmMoSL6/T zIMQk4kjGVhF7NNeTknEqFh72K2kJmnOZogtuH7ypKx2bUkaFyHjcp3kAUJ4rH/FeRLj loMw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=pddG+D9E; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b5-20020a62cf05000000b0063a149e3c85si21881101pfg.401.2023.05.17.09.23.46; Wed, 17 May 2023 09:24:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=pddG+D9E; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229484AbjEQQRv (ORCPT + 99 others); Wed, 17 May 2023 12:17:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229705AbjEQQRd (ORCPT ); Wed, 17 May 2023 12:17:33 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2081.outbound.protection.outlook.com [40.107.6.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77B3DA26F; Wed, 17 May 2023 09:17:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GxesHcjRr+cXf+8zvao5RwiZLexP4R6ZaC5b4Jjf00OMhApYHXxLDR1byU1IJ1qT/28YQ/8iodumG2tVqZ4yqv7/D/Criq/tZ7nfatEwUT4vP/RroS+X0h18rfH4adIP4te8QtOosXj5O1hHgUA3yKDvSdABP5oD4xlIEbTa7MLKBydJG/Pzhth8dGgt+yDXrL2aRVpiYXOsgXA55/+SqcZAzPTwINYjKfEOBh0j1UEWN7cUsuBfc6ABUWXw6NS50ITtF/E2UzCrTgCfiyf2o64j7j2aeVzlsnlWOo11hEZjTpwFmN1auXLRaiPxnYYMmEQbOT/91qrAyT1fWZ8iqQ== 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=DVm17g7uRevK5sYQoI5+K/wE4ULpyAFhfUnYx0zKro4=; b=SdFOJerBc2/L86LAH0lZbVJnqQ/i7GCW8vPfGqAierlSDdCkuHjuKwPNM/gxKGTLPqMvJdYexoCdWKmwE5AfP9V8K8qmywsWCpD7ZRfemSdDh5fdzN8GZa0VXMatSW0Vbz7TlhyRm6NLtUIHlkyZ2CRhDDjaTQmiuUjuYm0SMXTDLa07CCXfLyJTJ8EcmhDwSK0r/ds5xyJIpBztnicqGNwrOi9G2r6iQdgAd/TRCJ1QT8/tnkxhuKAKnjEb4PcgphE0jBzHi9DurmTTSOBM0FPhPsrNCZuVs7/FS8TCwSVbkQoJX6xz1ihaNALP5sTSC3EDmGIjxfkXCseWUiv9Xw== 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=DVm17g7uRevK5sYQoI5+K/wE4ULpyAFhfUnYx0zKro4=; b=pddG+D9E3cJDmKT+XQv7FQ7siC/sxns3VHPMZii60s0BGAmZX+P7A3a8Ec0MxncXeu4fBzdomZJynGQU534C5QqMHNvC3LlAbhwiBzK6G2RYQYUYRSmOR5GlIi2360m42PZa1FuG0hn+Cf6NrcKE4IXP8d6brh8Muitm+aLZ6io= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) by DB9PR04MB9962.eurprd04.prod.outlook.com (2603:10a6:10:4c4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.34; Wed, 17 May 2023 16:17:22 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::25d3:de2:ef1:3884]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::25d3:de2:ef1:3884%4]) with mapi id 15.20.6387.033; Wed, 17 May 2023 16:17:22 +0000 From: Frank Li To: vkoul@kernel.org Cc: Frank.Li@nxp.com, devicetree@vger.kernel.org, fushi.peng@nxp.com, imx@lists.linux.dev, kernel@pengutronix.de, kishon@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, robh+dt@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: [PATCH v5 4/6] phy: cadence: salvo: add .set_mode API Date: Wed, 17 May 2023 12:16:44 -0400 Message-Id: <20230517161646.3418250-5-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230517161646.3418250-1-Frank.Li@nxp.com> References: <20230517161646.3418250-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR03CA0041.namprd03.prod.outlook.com (2603:10b6:a03:33e::16) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|DB9PR04MB9962:EE_ X-MS-Office365-Filtering-Correlation-Id: 5d3c4282-611e-446f-1e31-08db56f23197 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +nXpxxbrCPSb8jYD+3QJQa+6KkyJJOk6dMdvj1bP4K2o0J5Codbo9MjUBAx274Tt6zGs+/jjyIzgmJ/i6M7K0bLTnXj86Gq/A6C03Ql8XkpT0kZBvJIR7GVTHhKnEFg6R8MeK35hLEiU831hrwH3ZLWb/AkjxIWyodUTmNBLIJuVAKjrdJFxTjXR3MIl+fIpuKOjgaQAFycpZUiTwlXD2sbt7pHda4h9JUvwnyun+Gd+O7jXN/w3JN69Qjk9fNDxtdYc8Oh6mQKGFdXPZiVBdWM6akc12zlzgTjsg7jKPI5KfG9RpnwJ9tlLYRambP2meaFDadNKwArd98TGXoIFtCGUR8O8Jz21ITaXTP//whrWI8FpBImBdxqYYGdW9K6fNzOwmCStstWdznoqDLpBTdX+iGSaG71vEEyH6zljELpgEcrpjffXPIxM7dNwOFltDuH1DQM7GzM9OHR4/w4YFRmSyngSFMjl7rFjk7I8P97/GL7EcZocAJeWMZJn9lDqkctGgM02xxn99VBEgbjYTXKKUmbzApudwiY3HCzSJMUJEfBOlcxTrrUoO3WCeVhQFtZhGkcmoSKJhx9PChv+5E8a9xNQVB7fPwxDjBgnH6qICtvN0c4p+S83G5EkKbSV62QRH3BYX7U5MyUqu4xquw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB4838.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(136003)(366004)(346002)(376002)(451199021)(6916009)(316002)(66946007)(66476007)(8936002)(66556008)(4326008)(8676002)(2906002)(478600001)(6486002)(41300700001)(5660300002)(6666004)(7416002)(52116002)(26005)(1076003)(6512007)(6506007)(186003)(2616005)(36756003)(38350700002)(38100700002)(86362001)(142923001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Z0voyrvW7DhPOtKJ4SmCzN4/nqWu+TPVtBVFnSmy4c3lVyME/z+UVyPoNGXfzBiVDr1D8aSNr6dzY5YL0WWM/COFf7NwX2SIg8LO8SO9FERvQMQj7iTsj8A/SP28gaJ6BPhsr0cZ5WigX1YAcCA6APGweyOQlhMqo3/gS9ZbAHykN1iI5INDGgA0f+E6N2m37+U7Sk8l6Aqmt+yxqf2vfsZ8g/Ctkp9Tpd+YcW8KbZehuU9NDe5DLH9qfFQMMlaFs2n9iwFtymYmo7o/BMRgaa+jDbzYL+vY5fgGg8BLzRx1lfTIb1YOHolvcNrmalFeLN37BxZTCz/5bKJL8hYzttlT+DNsr6BMpJ58SMY6rMoDGtIn7ebV0heLjIWWRBtyRnNkG9sy7u3aBZGFc9Q9sZhZXappiRiesnx0dKneWE15nBifRhTiHGDKiboEvMcT14jMfM3A54Wuq4mQJMJnYE4SXhOmjZUSNFAVIqJorLs0+RBepBNUqcZoKRkaRKzeaqHeWoafhVS55imVh0oOJm4vKdBzcOhOStRBJV4jl6pQRav16w9OWuAAKul38kzLa1aEX72IfudCePWslYeUwCrc/ymNR6GslKAJscI8JLhrA87nPNiSmWtGmax3FWPRUfTdwETHcfY3XuzwEfUFJSeWHOiBG2GtK0mpZXFHDHZXpUc0BV9ybrZ4d+2hDAn5TsUiknNi7KLEBsygUtjrRbGVzyUL4X/g0xlSDhZeRzw1SjYSXIU/CFAAfvrWyaHGbmPfTdPJt17h/yvJWMZfqLJ2OsQ8JSbWt11ACw4V3o9dYNhdlVep6qfk641lwNPjSDyCoaeCjnzzA17G6Sb1W0N1q3izFyRJ3jP5ybc7PkhUaEwjxSih+pZi6+DAqaU+g9ZU8Pdt6zszgqocw5Mt+iW2bj8Xl5woIg9nY8GojDeqJyp4y2y454+GEWIJ4nekSaSkWfp2jymaiI9Zcc7xyccP1E4n8ZyNu0vcCxq8BidF/66KPaXSKTzYp6jfFuzUwImMCAM8X3KzucRENgBsFqguUMu/K+pQv+mLK0Hc6LBu6qfw0OzLn/bYeQ0QnkEA7Q4r0E0i8wVW73STq0PWVhzCCG8enARmWfhvjNUxc86pHYMn6eMcEe7zLxcZQNPQjwyfUY1ip17HW/zrj7uOFPm5cJNzUy85v6Y5VpfhlIwlQS6nXCGozxKB0JAbumK/CvqyXh+Z/5LMdKOqNzEbrvljML5g1YpjR0FzzOcKI2ARpSd9smvj29G0E85T8rG3OQ3Sq3D+S4G2ic2350CeA4t1G2+ewfAICHF+x7plaQxgpKBXddaIshRc1jc8nQV31j82jE4E7WWvzDJOPrQgTCDiweC1nafP3LIpIU0ofY/f3FUqN8NWGA7s9MXWf+1DVMUrqkbYyNnTczP18+ECM8PsokRR83z939R/1m4ft+l87FnIjsfITZAh1i+Ld+JkQKF7LVRAEmj180AeKXFHRpT7KRpLCj3qQidfhrPJZ8mJ05badMFZ7edpyz0WxrK0ebV5uiykGjwSFKfxvEgP/d1VV6pvOSBI8OPC82DktPI= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d3c4282-611e-446f-1e31-08db56f23197 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2023 16:17:21.9625 (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: oCAMZtbsDM0nFNgHls9PU8FiIaHxq64t+J7ZqrDkhAodZZBbob/xPO1GKjh1je9TefMXp4NZ/M2zkaaYUWr5Kg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9962 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_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766159182274735010?= X-GMAIL-MSGID: =?utf-8?q?1766159182274735010?= From: Peter Chen For NXP platform design, the PHY can't know VBUS well, it causes the FSM in controller seeing the disconnection at L1 use case. With .set_mode API introduced, the controller driver could force PHY seeing B Session VALID when it is at the device mode (VBUS is there), and keep FSM working well. Signed-off-by: Peter Chen Signed-off-by: Frank Li --- drivers/phy/cadence/phy-cadence-salvo.c | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/phy/cadence/phy-cadence-salvo.c b/drivers/phy/cadence/phy-cadence-salvo.c index 5633fd21ae7d..083de7190819 100644 --- a/drivers/phy/cadence/phy-cadence-salvo.c +++ b/drivers/phy/cadence/phy-cadence-salvo.c @@ -92,6 +92,7 @@ /* USB2 PHY register definition */ #define UTMI_REG15 0xaf #define UTMI_AFE_RX_REG5 0x12 +#define UTMI_AFE_BC_REG4 0x29 /* TB_ADDR_TX_RCVDETSC_CTRL */ #define RXDET_IN_P3_32KHZ BIT(0) @@ -105,6 +106,9 @@ /* 0us, txvalid is ready just after HS/FS transmitters have powered up */ #define TXVALID_GATE_THRESHOLD_HS_0US (BIT(4) | BIT(5)) +#define SET_B_SESSION_VALID (BIT(6) | BIT(5)) +#define CLR_B_SESSION_VALID (BIT(6)) + struct cdns_reg_pairs { u16 val; u32 off; @@ -124,6 +128,13 @@ struct cdns_salvo_phy { }; static const struct of_device_id cdns_salvo_phy_of_match[]; +static const struct cdns_salvo_data cdns_nxp_salvo_data; + +static bool cdns_is_nxp_phy(struct cdns_salvo_phy *salvo_phy) +{ + return salvo_phy->data == &cdns_nxp_salvo_data; +} + static u16 cdns_salvo_read(struct cdns_salvo_phy *salvo_phy, u32 offset, u32 reg) { return (u16)readl(salvo_phy->base + offset + @@ -272,11 +283,29 @@ static int cdns_salvo_phy_power_off(struct phy *phy) return 0; } +static int cdns_salvo_set_mode(struct phy *phy, enum phy_mode mode, int submode) +{ + struct cdns_salvo_phy *salvo_phy = phy_get_drvdata(phy); + + if (!cdns_is_nxp_phy(salvo_phy)) + return 0; + + if (mode == PHY_MODE_USB_DEVICE) + cdns_salvo_write(salvo_phy, USB2_PHY_OFFSET, UTMI_AFE_BC_REG4, + SET_B_SESSION_VALID); + else + cdns_salvo_write(salvo_phy, USB2_PHY_OFFSET, UTMI_AFE_BC_REG4, + CLR_B_SESSION_VALID); + + return 0; +} + static const struct phy_ops cdns_salvo_phy_ops = { .init = cdns_salvo_phy_init, .power_on = cdns_salvo_phy_power_on, .power_off = cdns_salvo_phy_power_off, .owner = THIS_MODULE, + .set_mode = cdns_salvo_set_mode, }; static int cdns_salvo_phy_probe(struct platform_device *pdev)