From patchwork Fri Nov 4 06:44:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandor Yu X-Patchwork-Id: 15388 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp210706wru; Thu, 3 Nov 2022 23:47:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7+PHiE3JRDUrhZ2NJmxhhY8uqX0LPLFuqcSv1K5+undCBmDa9+asZ/bhru95kth5EDTv8B X-Received: by 2002:a65:5386:0:b0:46e:dbd3:413 with SMTP id x6-20020a655386000000b0046edbd30413mr28563353pgq.240.1667544472443; Thu, 03 Nov 2022 23:47:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1667544472; cv=pass; d=google.com; s=arc-20160816; b=mOiXyrOLiDvXFH3UFlXJesufeC1N/aH1gt49bQ9Wk0F1Vz2g2ttqCvjAIzPc+Oh0eO LpswVCN+mElqnREtKRAclybhef2VOarUV0mIvEdyyJC6/0COsMhRqRgJCWp5/OuZiVhd e5J7JJVvhbWyHa79y0dYxLNJ4HabPcI4yz8x/QJEtDJSeaJ54rT0whVjwhGyLsu7LT5e CW0vdEz/DjAB61Wfboz2DrEIb0N/WBSnYoxXxuX4H25j67r7sbU42vffz+VQ2E2QpaX5 LRBQczqkkG4m5f9a90ZGSQgn8tZYWX+aNLhR+EQP43f3tWvz/8yn08et92usNLPPmYx7 eEZw== 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=CI6HiPRkfFukA+gvkjMZqgx2ImVxcURakl6FJilSdaY=; b=g7SbqfOe7y7joQfSMFa67pbtt94qPRN1zpwAq/HB3j/yK1F9wRZ3H4ovDEKAwLzeQg HFfBTUXGVloCTiTAoxVjptHWu7VmDeUNYDsIMJ2H92VJyXw7d/D/jM+W6sELp7iC+gaw qcbvVwYSYELHpkhAEmQB0Hwo9rg6sV5lgJtA+e9UT86ZV156TmZWnUf9ULmAGUVTAd7T dzgIPCCv/NLk+PWuXYlm8byU1GSot5t7bzMybVOpbiAtkc6h9YoFnL8f84ZrmpAPe32n 4RFdNjRApGUuMkXkqRjmXJwOHLFrnTJ7wBFpLxS+QfrM1mOdEY0L7U/wRsVzmOwUuKM6 tOkA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=Xhnk4Id+; 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 j31-20020a63fc1f000000b00439befcf830si3652988pgi.854.2022.11.03.23.47.39; Thu, 03 Nov 2022 23:47:52 -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=Xhnk4Id+; 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 S231418AbiKDGqv (ORCPT + 99 others); Fri, 4 Nov 2022 02:46:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231361AbiKDGqo (ORCPT ); Fri, 4 Nov 2022 02:46:44 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2081.outbound.protection.outlook.com [40.107.21.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 088E92AC73; Thu, 3 Nov 2022 23:46:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fleA9d34CjFfIaQLMnod8RvBVluHPmCZR5N+2BzsyP+Ph1wrT5jb8Agba+MHCYptzrLIS5+Ea+orVaP1MzmryluVX0MZ7kUAlUENq5tJti0QUhlNW/PQEJDY4vWFu3tTJiseGI6/zWR7/JDNK/W4gYmtL4cb/WrqMMwKWH3qDx62UA1f1zi4S7IYfvfce5jttfHaDLWxjxcSnYPWn2hGzj5g2t4eRXw4t7hX6RyUYvTEw3P96wN7czeKq+cyoQtoQpHXSUoxpoH9KXua1iIxywDLd8dGmZCg7sFWBmSS9+WKj0uSWAdpwb3IxPopNhOw0RIDep9alb8XMSKklRfWjw== 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=CI6HiPRkfFukA+gvkjMZqgx2ImVxcURakl6FJilSdaY=; b=k4FEkfCSQeXVMQbaABYuX+DrjSpAv76fDhHjQrjEsA20jILloT/0oWt2GbGB7LcnHt2gTJt/5299aQmG39zEtkNU2WQmhK5XXxFC5NYvUsGrBlEbvyEdkUJe5T4aqlclAAmLmVjHa9SKC7xvRMjP1XbfaT7Sxaf2faq58RVdflsJEbtXesvxwVWx4KYvSmLWzB3Xf+NdhkwkM6DsO4kCgmT56TBcSHXtvl4jJkFm3DGZlkMv/CP3CbIZEkFJobvpD3tL/sVYtlr2sEjxw7H1lFQV8/uxgWf7nQT2Qr+UzSWyUayXe9sUt34pSewLxW4v5sgZs6jwX0xv4WYUBn0e+A== 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=CI6HiPRkfFukA+gvkjMZqgx2ImVxcURakl6FJilSdaY=; b=Xhnk4Id+5tsZmmeVefdvxyafARaHrAOyFKLVnDKvOEjASN8rQKMim0pz9LHXq0dnVxgQO4vkES30h6WHU7qB32MS520Wr2TNvAo+U/TM9ZetsXGGMYEH0QdsQ3Dul6bOwgp6nGOvEz52Q2E58Y38PGDDyW/bS6PxX+kcVDEs+ig= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9448.eurprd04.prod.outlook.com (2603:10a6:102:2b1::21) by AM9PR04MB8081.eurprd04.prod.outlook.com (2603:10a6:20b:3e2::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.20; Fri, 4 Nov 2022 06:46:39 +0000 Received: from PAXPR04MB9448.eurprd04.prod.outlook.com ([fe80::88a0:57d8:2a57:3f4f]) by PAXPR04MB9448.eurprd04.prod.outlook.com ([fe80::88a0:57d8:2a57:3f4f%9]) with mapi id 15.20.5791.022; Fri, 4 Nov 2022 06:46:39 +0000 From: Sandor Yu To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, andrzej.hajda@intel.com, neil.armstrong@linaro.org, robert.foss@linaro.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, kishon@ti.com, vkoul@kernel.org Cc: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, linux-imx@nxp.com, tzimmermann@suse.de, lyude@redhat.com, Sandor.yu@nxp.com, javierm@redhat.com, ville.syrjala@linux.intel.com, sam@ravnborg.org, jani.nikula@intel.com, maxime@cerno.tech, penguin-kernel@I-love.SAKURA.ne.jp, p.yadav@ti.com, oliver.brown@nxp.com Subject: [v2 01/10] drm: bridge: cadence: convert mailbox functions to macro functions Date: Fri, 4 Nov 2022 14:44:51 +0800 Message-Id: <4fd5d644cfcc70e51df5c0bcaecc6cbb43c49218.1667463263.git.Sandor.yu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-ClientProxiedBy: SG2PR06CA0194.apcprd06.prod.outlook.com (2603:1096:4:1::26) To PAXPR04MB9448.eurprd04.prod.outlook.com (2603:10a6:102:2b1::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9448:EE_|AM9PR04MB8081:EE_ X-MS-Office365-Filtering-Correlation-Id: 0c9be79d-b1fc-4296-50ab-08dabe305334 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Zo2YIvnKcDqZ4HtSJ99NrfLM3EcgwG50IZgbNKtmmdjeHxO7yaYMIlnO5KA4j2okxC40ZwrdFkCJ9o1YhddUnxGQdKcWgjDh51E6uvFh7OBi2uoRNcJiKKGcu9BLvsmdL6J2R5pbDZJRXE8mxKoIh5uYKSQhpNWX4MQXCJeG70AkIAX4/OJd5qyAzQWShNBQoDxUOys8Gwyll6/6jS60WJmJsRbgwDi7A/UOm5voZhx1p352jW74SJ3b2bAuo3ysKdrJ/oISfU01Wxe05HJ1sF0Ol4/Gh/6H9L0GYrs6JP4WCMz08sfAv64i07NVPAgMZOllSam9qK33ZRtqXlg+xSxLiuCL323mha55P9oZ3kubwqS++eFGAuNSU+flCXrugSMQqH/68AgItqKyEIF1IYR9w3nPxPT5dmsNkazG6kJmkUcG5QuHwo64uuNO99Vrc+a9eALvRO4ZzddKnWlN7shaoa35DE21mMnTZ/xf3aAqTB3xUmiYNm2I7ZgoJvk1Ciekzm0tvOcBONgRNaWsgs2FdtqEmT8TnYJ7bERB0u6LqFBPvdRcVrE/WMZanlSdviTlVjmLFAIq96uKUgNhrHFVR+jaBqHgiQZU/3gJwOKN9lEx54uOT5k+CSMk5DzibMZ81/35ftwswO0B2s9CXIZd+kLVagJTXi/ii/wKTn0ktIrWBxaIugR0mNKzPlkGFTiy5mYkJVfAogaIKG45EbBD616eIwRu4EjDf2m1tCY3by9oIz8sF1C0dZuN+ZzCrY0IntAWtMBir0AR2GdNaQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9448.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(376002)(39860400002)(366004)(136003)(396003)(451199015)(316002)(8676002)(38350700002)(30864003)(7416002)(5660300002)(15650500001)(66556008)(66476007)(38100700002)(4326008)(66946007)(36756003)(8936002)(41300700001)(83380400001)(6666004)(921005)(186003)(2616005)(86362001)(6486002)(26005)(478600001)(6512007)(52116002)(6506007)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IcKr/c/+RlPG9v8IZFeDGqy3Z77dHgbyqRZpoCkqcFm1ND92EaVzBeWNjZgfyKWwF2MiXNB4lmxCPo6i12HcHp+JxcnH7l0l2tgOOlZ3znksFnFBYayQK2uh2QFQwgX5IvVdKz8NH8qtBZdAf6/9URM8Clu4ub45WVFlYUK5i7NGEFsJDZC81+tlKqB5JoT471RgtB43pxW3WhTU07rtMAQ/aGHAQHQsf6JwtU4J4s5saPL3Tz3bCBvJQjKzaWXHYn3eMh8WpaVknGd5MD6hN/sz9zck5kCOFYC9QGUIYnOpBMbCYruu49ZB2MgDm7sqs+DH4TE5X0q7ShjUMBb952Moj0Q/IOSKFHZXTcyY8nJBqrUCR65uhmvXoZsNGLybwR6K+7n5xZWLOyG4Hs7QO66PjHyXDoRDvwdkkI+/NTPNO7JqKRSTmULdnLIad+tUS7KODBZYRKbidxZmcG1dOhCaGcmq9VKi8gafgVoMnk48jKubXCl9GCPPfAADKxwfi1tKQt2QLlpVDZKlxkh8iQZSZBMowsRZQO/j/LwQOo5HTOTRnT+qqsBvpAZcVgZ8M9+Z/wWDTm+tZ844+24fOBCUA+MhxDq+UcbHMYkX0QebQZwFFabAh9R4iu4jNit1AlTtuqkVieLqnpoJgMQaLNC5ygGoSv1usrXwxubc6pVtUXKxAIp7JSvZt4UfCjE/hfreyOblNMQO9nPsTDJlkAOq44umR/VdXHpi/1k6/WoJn1RA7+yOmnFjulSfCghNW5VNuBr3Mw3gQv/uzDCvM60H0UE2FhV8wbh/9Um5f+Tr6C8FQUXZhfPNLOPY+EBAy3u6xFnXO0qNNNnwi60jrjvNeJItOpSEX8Fcr2EBGpUYDscNYEvaGuDWY+zXsWxrkTSqiemy3xVtZacpEroZGHlpz8SVYJNuFATSqJx3gRtGniXo9CxQo33K9w7jk5YHipZ1Wzptb9ZOHlg1oIVO41iU6XvikvsePpbeMSP0cwu8c2rXNy4yq2oNoYX4WkXinFau4fUE67oq5pT7Q+xuDsBsJzARBT7dla09sXECgJUlCXrPAlJGQQIMm22r1Fua7wM1vmG6R751kKpUDeB0mZclZ97+gVUjPwZitQzB9jXgFFBqd8FAfuB3ar8FP1eA7bsP2i+vHY/+srJ89G1VTgwvZxJJsUFmeNlLi8p39HEMMkaKHTMRLcw1Mx9ClQIMVjv/vDcQyel4mYFw2PXHvfebJS0R5j1ATN2qfHFhni74v5odJU5D1oE8Q1QirFTWaJUEOGP9gqv79Ml5Y7QgMnlwPfvGL4vV+Hq/ggJRX42WIk/AftT+Adur6SkqUtqjPzm1DV6mTLa1IIYgsY3Vi5AWUOe2ZLxgfR9Kg0Dl7LIfp2uz0KEpCcBXk+AjyAv+icB2rA5SMGvlSNzTV8dGENnPzTADtx0MFwK1vX3hFy9oHYFSnCQSb1/Cfe+6GzsI65HGimuq7N8ne1Jkr6NTAZVO5cRJ13UjM+aFdGJgMY+G2PkcEdxxbOv3J1xWIAs2+XN3Ax/oEUYxJJ4Hj5YIiGD/xkEBJn31SJAXznSx1gsFx7z8M1CgiDD5wdUN1mNy X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0c9be79d-b1fc-4296-50ab-08dabe305334 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9448.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2022 06:46:39.2546 (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: Lao3ettwyduSC7WFLx6eo+RvG10kwom6oTKA06npGGAQmz6GQQaef4Qw/UvBrl/vJKyxsLBVEAHPxWd4HGL8TQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8081 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 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?1748547112774600493?= X-GMAIL-MSGID: =?utf-8?q?1748547112774600493?= Mailbox access functions could be share to other mhdp driver and HDP-TX HDMI/DP PHY drivers, move those functions to head file include/drm/bridge/cdns-mhdp-mailbox.h and convert them to macro functions. Signed-off-by: Sandor Yu --- .../drm/bridge/cadence/cdns-mhdp8546-core.c | 197 +------------- .../drm/bridge/cadence/cdns-mhdp8546-core.h | 1 - include/drm/bridge/cdns-mhdp-mailbox.h | 240 ++++++++++++++++++ 3 files changed, 242 insertions(+), 196 deletions(-) create mode 100644 include/drm/bridge/cdns-mhdp-mailbox.h diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c index 31442a922502..b77b0ddcc9b3 100644 --- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c +++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -55,200 +56,6 @@ #include "cdns-mhdp8546-hdcp.h" #include "cdns-mhdp8546-j721e.h" -static int cdns_mhdp_mailbox_read(struct cdns_mhdp_device *mhdp) -{ - int ret, empty; - - WARN_ON(!mutex_is_locked(&mhdp->mbox_mutex)); - - ret = readx_poll_timeout(readl, mhdp->regs + CDNS_MAILBOX_EMPTY, - empty, !empty, MAILBOX_RETRY_US, - MAILBOX_TIMEOUT_US); - if (ret < 0) - return ret; - - return readl(mhdp->regs + CDNS_MAILBOX_RX_DATA) & 0xff; -} - -static int cdns_mhdp_mailbox_write(struct cdns_mhdp_device *mhdp, u8 val) -{ - int ret, full; - - WARN_ON(!mutex_is_locked(&mhdp->mbox_mutex)); - - ret = readx_poll_timeout(readl, mhdp->regs + CDNS_MAILBOX_FULL, - full, !full, MAILBOX_RETRY_US, - MAILBOX_TIMEOUT_US); - if (ret < 0) - return ret; - - writel(val, mhdp->regs + CDNS_MAILBOX_TX_DATA); - - return 0; -} - -static int cdns_mhdp_mailbox_recv_header(struct cdns_mhdp_device *mhdp, - u8 module_id, u8 opcode, - u16 req_size) -{ - u32 mbox_size, i; - u8 header[4]; - int ret; - - /* read the header of the message */ - for (i = 0; i < sizeof(header); i++) { - ret = cdns_mhdp_mailbox_read(mhdp); - if (ret < 0) - return ret; - - header[i] = ret; - } - - mbox_size = get_unaligned_be16(header + 2); - - if (opcode != header[0] || module_id != header[1] || - req_size != mbox_size) { - /* - * If the message in mailbox is not what we want, we need to - * clear the mailbox by reading its contents. - */ - for (i = 0; i < mbox_size; i++) - if (cdns_mhdp_mailbox_read(mhdp) < 0) - break; - - return -EINVAL; - } - - return 0; -} - -static int cdns_mhdp_mailbox_recv_data(struct cdns_mhdp_device *mhdp, - u8 *buff, u16 buff_size) -{ - u32 i; - int ret; - - for (i = 0; i < buff_size; i++) { - ret = cdns_mhdp_mailbox_read(mhdp); - if (ret < 0) - return ret; - - buff[i] = ret; - } - - return 0; -} - -static int cdns_mhdp_mailbox_send(struct cdns_mhdp_device *mhdp, u8 module_id, - u8 opcode, u16 size, u8 *message) -{ - u8 header[4]; - int ret, i; - - header[0] = opcode; - header[1] = module_id; - put_unaligned_be16(size, header + 2); - - for (i = 0; i < sizeof(header); i++) { - ret = cdns_mhdp_mailbox_write(mhdp, header[i]); - if (ret) - return ret; - } - - for (i = 0; i < size; i++) { - ret = cdns_mhdp_mailbox_write(mhdp, message[i]); - if (ret) - return ret; - } - - return 0; -} - -static -int cdns_mhdp_reg_read(struct cdns_mhdp_device *mhdp, u32 addr, u32 *value) -{ - u8 msg[4], resp[8]; - int ret; - - put_unaligned_be32(addr, msg); - - mutex_lock(&mhdp->mbox_mutex); - - ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_GENERAL, - GENERAL_REGISTER_READ, - sizeof(msg), msg); - if (ret) - goto out; - - ret = cdns_mhdp_mailbox_recv_header(mhdp, MB_MODULE_ID_GENERAL, - GENERAL_REGISTER_READ, - sizeof(resp)); - if (ret) - goto out; - - ret = cdns_mhdp_mailbox_recv_data(mhdp, resp, sizeof(resp)); - if (ret) - goto out; - - /* Returned address value should be the same as requested */ - if (memcmp(msg, resp, sizeof(msg))) { - ret = -EINVAL; - goto out; - } - - *value = get_unaligned_be32(resp + 4); - -out: - mutex_unlock(&mhdp->mbox_mutex); - if (ret) { - dev_err(mhdp->dev, "Failed to read register\n"); - *value = 0; - } - - return ret; -} - -static -int cdns_mhdp_reg_write(struct cdns_mhdp_device *mhdp, u16 addr, u32 val) -{ - u8 msg[6]; - int ret; - - put_unaligned_be16(addr, msg); - put_unaligned_be32(val, msg + 2); - - mutex_lock(&mhdp->mbox_mutex); - - ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_DP_TX, - DPTX_WRITE_REGISTER, sizeof(msg), msg); - - mutex_unlock(&mhdp->mbox_mutex); - - return ret; -} - -static -int cdns_mhdp_reg_write_bit(struct cdns_mhdp_device *mhdp, u16 addr, - u8 start_bit, u8 bits_no, u32 val) -{ - u8 field[8]; - int ret; - - put_unaligned_be16(addr, field); - field[2] = start_bit; - field[3] = bits_no; - put_unaligned_be32(val, field + 4); - - mutex_lock(&mhdp->mbox_mutex); - - ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_DP_TX, - DPTX_WRITE_FIELD, sizeof(field), field); - - mutex_unlock(&mhdp->mbox_mutex); - - return ret; -} - static int cdns_mhdp_dpcd_read(struct cdns_mhdp_device *mhdp, u32 addr, u8 *data, u16 len) @@ -2058,7 +1865,7 @@ static void cdns_mhdp_atomic_disable(struct drm_bridge *bridge, struct drm_bridge_state *bridge_state) { struct cdns_mhdp_device *mhdp = bridge_to_mhdp(bridge); - u32 resp; + u32 resp = 0; dev_dbg(mhdp->dev, "%s\n", __func__); diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.h b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.h index bedddd510d17..10c878bf0e63 100644 --- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.h +++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.h @@ -212,7 +212,6 @@ struct phy; #define MB_MODULE_ID_HDCP_TX 0x07 #define MB_MODULE_ID_HDCP_RX 0x08 #define MB_MODULE_ID_HDCP_GENERAL 0x09 -#define MB_MODULE_ID_GENERAL 0x0a /* firmware and opcodes */ #define FW_NAME "cadence/mhdp8546.bin" diff --git a/include/drm/bridge/cdns-mhdp-mailbox.h b/include/drm/bridge/cdns-mhdp-mailbox.h new file mode 100644 index 000000000000..0249322a74b0 --- /dev/null +++ b/include/drm/bridge/cdns-mhdp-mailbox.h @@ -0,0 +1,240 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Cadence MHDP Firmware Access API function by Malibox. + * + * Copyright (C) 2022 NXP Semiconductor, Inc. + * + */ +#ifndef CDNS_MHDP_MAILBOX_H +#define CDNS_MHDP_MAILBOX_H + +#include +#include + +/* mailbox regs offset */ +#define CDNS_MAILBOX_FULL 0x00008 +#define CDNS_MAILBOX_EMPTY 0x0000c +#define CDNS_MAILBOX_TX_DATA 0x00010 +#define CDNS_MAILBOX_RX_DATA 0x00014 + +#define MAILBOX_RETRY_US 1000 +#define MAILBOX_TIMEOUT_US 2000000 + +/* Module ID Code */ +#define MB_MODULE_ID_GENERAL 0x0A +#define MB_MODULE_ID_DP_TX 0x01 + +/* General Commands */ +#define GENERAL_REGISTER_WRITE 0x05 +#define GENERAL_REGISTER_READ 0x07 + +/* DP TX Command */ +#define DPTX_WRITE_FIELD 0x08 + +/* MHDP Firmware access functions by Mailbox */ +#define cdns_mhdp_mailbox_read(__mhdp) \ +({ \ + int ret, empty, val; \ +\ + WARN_ON(!mutex_is_locked(&(__mhdp)->mbox_mutex)); \ +\ + do { \ + ret = readx_poll_timeout(readl, (__mhdp)->regs + CDNS_MAILBOX_EMPTY, \ + empty, !empty, MAILBOX_RETRY_US, \ + MAILBOX_TIMEOUT_US); \ + if (ret < 0) \ + break; \ +\ + val = readl((__mhdp)->regs + CDNS_MAILBOX_RX_DATA) & 0xff; \ + } while (0); \ +\ + (ret < 0) ? ret : val; \ +}) + +#define cdns_mhdp_mailbox_write(__mhdp, __val) \ +({ \ + int ret, full; \ +\ + WARN_ON(!mutex_is_locked(&(__mhdp)->mbox_mutex)); \ +\ + do { \ + ret = readx_poll_timeout(readl, (__mhdp)->regs + CDNS_MAILBOX_FULL, \ + full, !full, MAILBOX_RETRY_US, \ + MAILBOX_TIMEOUT_US); \ + if (ret < 0) \ + break; \ +\ + writel((__val), (__mhdp)->regs + CDNS_MAILBOX_TX_DATA); \ + } while (0); \ +\ + ret; \ +}) + +#define cdns_mhdp_mailbox_recv_header(__mhdp, __module_id, __opcode, __req_size) \ +({ \ + u32 mbox_size, i; \ + u8 header[4]; \ + int ret; \ +\ + do { \ + /* read the header of the message */ \ + for (i = 0; i < sizeof(header); i++) { \ + ret = cdns_mhdp_mailbox_read(__mhdp); \ + if (ret < 0) \ + break; \ +\ + header[i] = ret; \ + } \ +\ + mbox_size = get_unaligned_be16(header + 2); \ +\ + if ((__opcode) != header[0] || (__module_id) != header[1] || \ + (__req_size) != mbox_size) { \ + /* If the message in mailbox is not what we want, we need to + * clear the mailbox by reading its contents. */ \ + for (i = 0; i < mbox_size; i++) \ + if (cdns_mhdp_mailbox_read(__mhdp) < 0) \ + break; \ +\ + ret = -EINVAL; \ + } \ +\ + ret = 0; \ +\ + } while (0); \ +\ + ret; \ +}) + +#define cdns_mhdp_mailbox_recv_data(mhdp, buff, buff_size) \ +({ \ + u32 i; \ + int ret; \ +\ + do { \ + for (i = 0; i < buff_size; i++) { \ + ret = cdns_mhdp_mailbox_read(mhdp); \ + if (ret < 0) \ + break; \ +\ + ((u8 *)buff)[i] = ret; \ + } \ +\ + ret = 0; \ +\ + } while (0); \ +\ + ret; \ +}) + +#define cdns_mhdp_mailbox_send(mhdp, module_id, opcode, size, message) \ +({ \ + u8 header[4]; \ + int ret, i; \ +\ + header[0] = opcode; \ + header[1] = module_id; \ + put_unaligned_be16(size, header + 2); \ +\ + do { \ + for (i = 0; i < sizeof(header); i++) { \ + ret = cdns_mhdp_mailbox_write(mhdp, header[i]); \ + if (ret < 0) \ + break; \ + } \ +\ + for (i = 0; i < size; i++) { \ + ret = cdns_mhdp_mailbox_write(mhdp, ((u8 *)message)[i]); \ + if (ret < 0) \ + break;; \ + } \ + ret = 0; \ + } while (0); \ +\ + ret; \ +}) + +#define cdns_mhdp_reg_read(mhdp, addr, value) \ +({ \ + u8 msg[4], resp[8]; \ + int ret; \ +\ + put_unaligned_be32(addr, msg); \ +\ + mutex_lock(&mhdp->mbox_mutex); \ +\ + do { \ + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_GENERAL, \ + GENERAL_REGISTER_READ, \ + sizeof(msg), msg); \ + if (ret < 0) \ + break; \ +\ + ret = cdns_mhdp_mailbox_recv_header(mhdp, MB_MODULE_ID_GENERAL, \ + GENERAL_REGISTER_READ, \ + sizeof(resp)); \ + if (ret < 0) \ + break; \ +\ + ret = cdns_mhdp_mailbox_recv_data(mhdp, resp, sizeof(resp)); \ + if (ret < 0) \ + break; \ +\ + /* Returned address value should be the same as requested */ \ + if (memcmp(msg, resp, sizeof(msg))) { \ + ret = -EINVAL; \ + break; \ + } \ +\ + *((u32 *)value) = get_unaligned_be32(resp + 4); \ + ret = 0; \ + } while (0); \ +\ + mutex_unlock(&mhdp->mbox_mutex); \ + if (ret < 0) { \ + dev_err(mhdp->dev, "Failed to read register\n"); \ + *((u32 *)value) = 0; \ + } \ +\ + ret; \ +}) + +#define cdns_mhdp_reg_write(mhdp, addr, val) \ +({ \ + u8 msg[8]; \ + int ret; \ +\ + put_unaligned_be32(addr, msg); \ + put_unaligned_be32(val, msg + 4); \ +\ + mutex_lock(&mhdp->mbox_mutex); \ +\ + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_GENERAL, \ + GENERAL_REGISTER_WRITE, sizeof(msg), msg); \ +\ + mutex_unlock(&mhdp->mbox_mutex); \ +\ + ret; \ +}) + +#define cdns_mhdp_reg_write_bit(mhdp, addr, start_bit, bits_no, val) \ +({ \ + u8 field[8]; \ + int ret; \ +\ + put_unaligned_be16(addr, field); \ + field[2] = start_bit; \ + field[3] = bits_no; \ + put_unaligned_be32(val, field + 4); \ +\ + mutex_lock(&mhdp->mbox_mutex); \ +\ + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_DP_TX, \ + DPTX_WRITE_FIELD, sizeof(field), field); \ +\ + mutex_unlock(&mhdp->mbox_mutex); \ +\ + ret; \ +}) + +#endif From patchwork Fri Nov 4 06:44:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandor Yu X-Patchwork-Id: 15391 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp210872wru; Thu, 3 Nov 2022 23:48:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6t5l5SI4xBrzMdT8RPqh00dgUIYjkZoNRYiz8vxq3oHXUtCsHtcPidmYq/p4DcHy34iL8J X-Received: by 2002:a17:903:22d2:b0:187:1f4a:6593 with SMTP id y18-20020a17090322d200b001871f4a6593mr26060532plg.138.1667544501833; Thu, 03 Nov 2022 23:48:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1667544501; cv=pass; d=google.com; s=arc-20160816; b=PW+Bjpn/0ebD5EvOOdhcMx1yVEjluI3+B4PgXQKBm7hGoCTqWfV3SM70yRVsnzcZsC /PmR7LVeHuN+BChspk4b0OfiVzw6fRCn9dJNPcW/JWcAVGhmkihO08kMPj14uUQhPeUG YFw9HrvUfuT8DQ8IhR4br9YV0yRwcuX/zEsXAW7wipLZKYSj+epsSrHLvR6BKK2tCYpK SUQqqoe3mxd9MfDEMM1FRpKKbbqw3jUN54eGyNJcZqIyT/FYo8UJ9hpXiKClpjHR6ckt hx0Qo6H6cMoD2VBqepCsNXlrZMzsX+lAA3TjGtOLiLm0aUIfOyWTHUDHYufnRJ16Vk3/ 6JRA== 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=duNWFFZrQ2saakIVQn+3vIVxprhQerDx0XGKLR76W/4=; b=pvkV7X2De1DkN3O20WIH8ua9g7usUhZvbGghchxvmCskbv0sa/DgLembs7nyuGDw3S amRzlKBKyq8SaRUFrXRfNvFBFuSNm7LZxXESVsPtKr9y7UxbkD34LuPDK2V909DI/a32 HXhu3Ez21RQ8KAKuZE15WwOiDYp5KTBjPPXt6KeNXmKJ394B/pO8NDiN8/GkrVxKGumA WMY4ClJezE7Opk5kIciCsGtQJyMkwiUMFCrtRaTWysUs88t19q1/fZcLW/pKSbnyCWyV /Js4ti2ZxMRZjJject3FbRpH2nY1e9Q3PROtLn0kUFos5bKMi7NBgpftGzMILwBOtWv9 wRgw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=rFfhlsIu; 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 v10-20020a17090ad58a00b00212d2ba106fsi2284472pju.151.2022.11.03.23.48.05; Thu, 03 Nov 2022 23:48:21 -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=rFfhlsIu; 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 S231476AbiKDGrG (ORCPT + 99 others); Fri, 4 Nov 2022 02:47:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231496AbiKDGq5 (ORCPT ); Fri, 4 Nov 2022 02:46:57 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2074.outbound.protection.outlook.com [40.107.21.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A7B72AC68; Thu, 3 Nov 2022 23:46:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fesphYgiYXnRQ6iMlNfQMwh5r1PW15wgveH9ozu2+hOxzShKanFibnrranxge6xXwcqfM2goWGW2nWdWXh2WuagF+rTKJqRAwzYFrznQhajQq1oPIqiHZcjTKV0J9TvP4OXmO9jKJ0DrqbGk5hGP1oXaSKwaDl80EVstsYY1KFjLRG+0SSTbMY+0Y/OFhhQfuatOdQFZHWEVgQ6SoctY2+ixkXNqwNC085p1vl6INEzpKHrjEkGAQrtOmGC57BjycE365wd4C7KWsRnPeODrfUE+YRR5XEhcUCC7YsO/hcU8RQRWSlf//VNmVoC/ZE4nAszIbbTrSAaZp8DGTiyWZA== 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=duNWFFZrQ2saakIVQn+3vIVxprhQerDx0XGKLR76W/4=; b=T/7cbM6c1THt0atsGx+aSnqvwl1cgFxXaVqyeyICPAbDgzecpQAgkRgukNgBdLj6rRpo5ZuamwsbrDIbnIIokADcQBg4lyfU2tIzA9OOtmUoV6wyxrss825Oo2UKMVsEyZi+L+V8pgHAnAhvu0Zj3CW/IcyayNk3Sq0GmP5v4wNTj/I55i6a8IUcfDY0Pz3v4qrrspOF+8NcBeeAcm+ng6kDEP552WzxoE/BoiWv7nKqkHx3HpVJo3IefsYYOusdbLfr7SU9KWRzDflOH++vAMBC9a4z3TJR5qriZAmooSapXd5KHVCEsyPqLs5ScWmjSQkBkBNQ8ruVsYlydzdpRQ== 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=duNWFFZrQ2saakIVQn+3vIVxprhQerDx0XGKLR76W/4=; b=rFfhlsIugoS2d6zpgs823JdWAK55t4PMYNQ3vsQjAkDJxSx9SQY991pgfQjJScSLR1O8HeI/x9ElGg7yX+X1gOqI/lGudVdNvudXK6U3n2XrYqcIReRVgGcW5jI3aMsPlvYDHYM6Xtjw3UXwr7Z512nk1ToTKShjYOgI9XI+7Dw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9448.eurprd04.prod.outlook.com (2603:10a6:102:2b1::21) by AM9PR04MB8081.eurprd04.prod.outlook.com (2603:10a6:20b:3e2::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.20; Fri, 4 Nov 2022 06:46:47 +0000 Received: from PAXPR04MB9448.eurprd04.prod.outlook.com ([fe80::88a0:57d8:2a57:3f4f]) by PAXPR04MB9448.eurprd04.prod.outlook.com ([fe80::88a0:57d8:2a57:3f4f%9]) with mapi id 15.20.5791.022; Fri, 4 Nov 2022 06:46:47 +0000 From: Sandor Yu To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, andrzej.hajda@intel.com, neil.armstrong@linaro.org, robert.foss@linaro.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, kishon@ti.com, vkoul@kernel.org Cc: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, linux-imx@nxp.com, tzimmermann@suse.de, lyude@redhat.com, Sandor.yu@nxp.com, javierm@redhat.com, ville.syrjala@linux.intel.com, sam@ravnborg.org, jani.nikula@intel.com, maxime@cerno.tech, penguin-kernel@I-love.SAKURA.ne.jp, p.yadav@ti.com, oliver.brown@nxp.com Subject: [v2 02/10] dts-bingings: display: bridge: Add MHDP HDMI bindings for i.MX8MQ Date: Fri, 4 Nov 2022 14:44:52 +0800 Message-Id: <0e1f631c22207c6af41ea512be85213b3953b44f.1667463263.git.Sandor.yu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-ClientProxiedBy: SG2PR06CA0194.apcprd06.prod.outlook.com (2603:1096:4:1::26) To PAXPR04MB9448.eurprd04.prod.outlook.com (2603:10a6:102:2b1::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9448:EE_|AM9PR04MB8081:EE_ X-MS-Office365-Filtering-Correlation-Id: 81b3e8a5-c0a9-4e10-d470-08dabe3057dd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y5qiU8AV99d+Un+baBzX8pbRr4SwXvobXLCFH5ifS7Cc5b4k7E0yQeiAfI9eQoASag88R+6MIoJvmurOCyC1uFwa1xnZCtGZf5NhK5G9k3EvIWk9B3mOp4L0qzFAVpHHn3zZGxWdSbj0OFyUZa4ASt4f4nrQpeU3KgqB+O8vBqgtPa2fCaeeMFFh5G3NA0pIY4uiSZlkPbLBeFVY0MHOkp8Yl8v8XEUyCiRCCJm+0UCnP38TIMA8pPlmgOKz6isGqAsKJckoHyLqpezEBrhx7utMp/lLg85oUYgWKrVKMb9C/qPI2+5tmt5Y820X9CmFlAk6sKy6oX0awE+vUEGxQP5ZJbBHm5LzZhaS7GOhmbAEhONR0hLGD6wjnPco0ngemHXJG5/C2YKxyFG+RFxu17NG/2oz6QDWo8Bze1MG5+SJ2VEabFYATgTVc4RiVGQ0z/mqf8zzojIshRdp8p6GJ8ibEA/hM5O1HSkJ4pHRVdUhksHRUB6sdyDzzh5mS6/WI+o4d1nOXnq6smhhQM2Ic3RcVtIn28wo1Q3CrdVGFF9VhLRH84tPOxfaOW4SP+7WyY6Bn9IFxgdyVknOE9nYdO6U8nJiWT+NdqEIklZ8WuAyWhckrcR6N9cDCsTadXcRPCO/DyjodbtqDzl+fIDZy3vCVbNwNOJ/Oj6S3kqxxSlS1g19ERhl7tPN+WkdZsme2QOQB3itAxbVyPGoAVat965h3E/jZNrMUqJABF/SziA2MyEUVzlZ5S3ykxmXsuKumIUBmDqD0fIKPQTd5nQTenT/vBYQkEoyuzU6e/xZ/3EFljoP0gCCV9QDZ4ox2Lthm8WDcnpAMz0zmINDbCit4p8N7zsigoYeAOYQoGLaqrY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9448.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(376002)(39860400002)(366004)(136003)(396003)(451199015)(316002)(8676002)(38350700002)(7416002)(5660300002)(66556008)(66476007)(38100700002)(4326008)(66946007)(36756003)(8936002)(41300700001)(83380400001)(6666004)(921005)(186003)(2616005)(86362001)(6486002)(26005)(478600001)(6512007)(52116002)(6506007)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3PUrFlAnX5psc1FB0PmXh1LIu/fehwq0dRno+79+vz0yuAQTTMkSA+9clSi2xHe+7SLIpd0fPTkzsKwiTk3TYwl/S9cWFHVznvDMigKR5wzQ8jO3e7HMzvEzGTmuIlvWuBIvqbb3l55gbT4rOMNjaYUHPAkwTWl1dy/fhXyc/KuHg6YbLjygA+zVXwmVkJhXs7YWjrVBaXniDpSrkK0mPMVFBCjA+nZ82Oh0gaSwRTL8i463Qn9ApJcFVAyA3CgfSXJfs5uQN4F2xoJcZK6P0FVBQna4dt+W5OgZrq5+mHxuNhOXse/Gvaaw5jGcKYd/IT5lPe2kG7YCaCsLOlXxZcD1ICC3pc1oOqYUipRcKHQh7c75h+7Bngn6OpuXlqAYRkSu8FgDv7X6rQWHJ1QiMXjJWU7U5vbpqSbbBzqFDKU8L5MySfo7w7Epp0ZaYPyIABzUA97y3c16UWF+16Nz5xgbOgoHrodmISlQCbKgaOqh0rdn0JUiaagLMvF9KlQV8YhqjUzLNTUpCpLMz77E0ZU3X28jpgAOqbcf17iehrxXdTMZggtbIr/eUjE+7nJkztOyDAmbQ/ixbwhQdd+mnHijUAmQfCckAoGMxOX1zF+bz8vj+2f7cG6379luCTxaKFiWMgb8jyaU0ldlCkjtftYU18HqLmHKQUkSfQ8k6ENPhNjboV6R5MeVX9UCmp4uwOxivDcKwUsXn9BHFzBQkdMy/LJjBApPJ9f7GHs0ssAndzxRyQ4vBj5c4Kyw2KYsoldwID8+7woT58l7LwOetbdYL/z8ntmsItwLqTwtmLORRCHsjYR6ljV6PzTSTxtTPNg2byjh1STWa65DfbULLymSI/im/fR9HhubvJOGVoY6qJLphaYHaor43ui0W7LnIWySCmP4+T2Ki7cxdIOXOpnwKlFKX0YP0OvAw3GT2SLZiOsJ0GBNfaXqkJWfE/LP7mZAKao04jXX0NMWlskdVCvZGxUoxzcPyhRi1pe/N4Di3y2/tdlmTEQIIorrhuIcdvsBUJstVDTELUFada96gk7QvB/EIuc0V6p45Utc5zwaqfHhbTJtuF9jDmNlsPpccbwOGeVfBEkYYKcw0SJVjsjhFCuwSqMWyxv8+N9H33Je3NsZuhHWKgoRkEtzfgrURYbpXMxsIAx5uEfVrd3PqE5rlMz/0oxT1xsmx/UdmusIYx4I8zNFAnlzvvvV6m3ZlB+hvY91noHZsckPnufaGsQ7PLHdZ4tMXwimguAyaeu4lX+v88c4bmcAzvDn6ysWL2qLavFpWgTW4t0k+fEQn3nM2XBsyXq3JHSXrs+h2J0z3KZPsdKph0SX/2ONIBpvVvCe/13LFekjPQLlorSQCSaAicUX4QFO/Oj3IoVPp8NcTA5cc/ekgD2ijipRRThRB5qIzgmW7H4G3SJ36KEoGwh1AwfPGQL7DfwHdRckYJGg0pWF8FzybWh/MqbQ7WKGXYNEzThyCq/fdTYoSH08622gvcTdgS1y0DhdFXGbMCbwmOdZuKskmD7453ZjLC8bwg8FF9nv2XLhhcTUr12TPuvMRgqcgyeyPJ8qnA4Bhg0u9N58GC1vE8h0KlUCWSFN X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 81b3e8a5-c0a9-4e10-d470-08dabe3057dd X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9448.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2022 06:46:46.9928 (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: aPQmgKhH1Cqh/g3keHmzbz+HJHlf4IHaDxbP3cBvw9LCiSS12kLdeksyDMWloFONmprqzoXqgFZSDKTB+kqSRg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8081 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 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?1748547143498299730?= X-GMAIL-MSGID: =?utf-8?q?1748547143498299730?= Add bindings for i.MX8MQ MHDP HDMI. Signed-off-by: Sandor Yu --- .../display/bridge/cdns,mhdp-imx8mq-hdmi.yaml | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/bridge/cdns,mhdp-imx8mq-hdmi.yaml diff --git a/Documentation/devicetree/bindings/display/bridge/cdns,mhdp-imx8mq-hdmi.yaml b/Documentation/devicetree/bindings/display/bridge/cdns,mhdp-imx8mq-hdmi.yaml new file mode 100644 index 000000000000..b2a769d4cb82 --- /dev/null +++ b/Documentation/devicetree/bindings/display/bridge/cdns,mhdp-imx8mq-hdmi.yaml @@ -0,0 +1,67 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/display/bridge/cdns,mhdp-imx8mq-hdmi.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Cadence MHDP HDMI bridge + +maintainers: + - Sandor Yu + +description: + The Cadence MHDP TX HDMI interface. + +properties: + compatible: + enum: + - cdns,mhdp-imx8mq-hdmi + + reg: + items: + - description: + Memory mapped base address and length of mhdptx apb registers. + + phys: + description: + phandle to the HDMI PHY. + + phy-names: + items: + - const: hdmiphy + + interrupts: + items: + - description: Hotplug detect interrupter for cable plugin event. + - description: Hotplug detect interrupter for cable plugout event. + + interrupt-names: + items: + - const: plug_in + - const: plug_out + + port: + $ref: /schemas/graph.yaml#/properties/port + description: + A port node pointing to the output port of a display controller.. + +additionalProperties: false + +examples: + - | + #include + mhdp: mhdp@32c00000 { + compatible = "cdns,mhdp-imx8mq-hdmi"; + reg = <0x32c00000 0x100000>; + interrupts = , + ; + interrupt-names = "plug_in", "plug_out"; + phys = <&hdmi_phy>; + phy-names = "hdmiphy"; + + port { + mhdp_in: endpoint { + remote-endpoint = <&dcss_out>; + }; + }; + }; From patchwork Fri Nov 4 06:44:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandor Yu X-Patchwork-Id: 15389 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp210795wru; Thu, 3 Nov 2022 23:48:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM49YH0+r3Z26QB19JDx71Qsi52s6dcadxanOQZFvlI+2f2L4ccU3OWdLapTJi/m2XTAoe5N X-Received: by 2002:a17:902:ec8e:b0:186:de89:7f66 with SMTP id x14-20020a170902ec8e00b00186de897f66mr34150123plg.160.1667544488395; Thu, 03 Nov 2022 23:48:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1667544488; cv=pass; d=google.com; s=arc-20160816; b=OjBw7RH+qb3JnKjqUODzPs8aG+9zoDuwzgPXVHXPvD2itH5tgGlMUkm62+eOgIeE3A GT3GShDcKJukp3c0zTInlV8DGbHwWKiZv2I+FYBGM26/YLISHpGuxKbvGq0DO2ZlFABK gHsHXU1ZHf+heueJkai7XR9DOGkqNL5tfxoDwUItmHmeTJfUeA6WpEIkAK8qrA9OeTmf 1Pw1lzwewFBn2uetmnM+0iLohkFHmUOkD2HS4xsXz2ZaTtlpxBptAW5E0j6tx5JYCr92 JPSn1kQqRX4LlOzc+f57sQcavo3rrH9YI71UcGpuVdE9/JKGa0n98TE1+I3YvRG3lvtx bjMQ== 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=zRf+zbsYVbXw4m+hWzQ8X6gRtwmUHQBdV7IiFCeRWPk=; b=I176LUYbNPGoRgWO/qA2X6szMwz7y9dVUe9mcCbpZjMNrLjj6g9i+dlg8HQcvcs9T2 bJibQ7SRSi4s1DRTUv9/RO09/FPVoMJE5b8zl2Wha6k3xU9yVXrHk2GSwAJwEhmUal8p 3aGNNIDJhz77/oMH/xDXAsFSqb66lXlnoy5I17SleR7DWdEnlguCbsOj67cKVZz7e2gX I+ih9zi+somZ9tvQ+T9XwntIcT0fRG3q+nV8cfrrVnWZ4Zytd8BI7u9buMssyAdg0P1T a5HUBn80udzopGxhGRosMQEVtWh0BcIzTkndIcfQWpxBNpD+UmaoIPmwrp6WJN7j20QB Wcsw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=XAXysZS9; 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 u11-20020a056a00158b00b0056c92bd3c48si3873312pfk.242.2022.11.03.23.47.55; Thu, 03 Nov 2022 23:48:08 -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=XAXysZS9; 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 S231443AbiKDGrJ (ORCPT + 99 others); Fri, 4 Nov 2022 02:47:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231383AbiKDGrC (ORCPT ); Fri, 4 Nov 2022 02:47:02 -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 E526B2AC78; Thu, 3 Nov 2022 23:46:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Of7zVfrCKsqgGXUThRDiNEFZW41kqf5uBjOVOJ4vGWNNNuCxfKpjb/VZB91H0V6ucZrUkbxHHJM8DcRed7XxlSHU/C3hqKvi1qiig4N+1/P7UD1Ozv7VIZfTYxwhJmQ7lLQMgT74rXL8qVpY8zOZ+5XFv1vL3yet7sEL1fUKTBN88fDFeFKqRcFVbjc5NRLDuM22t03aBaGepDxbUfqvUgkP/jvl74JC0zE0m/82jbrPXjd45BEQjmgSrqfx0Rq5Hqlezrt3e1HHmBAFdtM3Z9BiWf2HoZaeCUnhPoHD890Qq6nqf+1YKXvMuoREigekrbL9aq1ZXRIZP+RrUx3AOA== 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=zRf+zbsYVbXw4m+hWzQ8X6gRtwmUHQBdV7IiFCeRWPk=; b=FRHjC0/f6asUJje7CU9BYL9pe+f6WJTkjJRuLTfxWMo0tbotxzBN7rIsxKDhc7X8XRFzKw62p/t/CQgZpuC0ebNiiB/3Rd3at/HggLluvr8ZbnxalEIapAFCQ1jbEQcMkjquQGyU1G6OyAoiGAb/v//zh8I/mvJCjlMhOngzLNizBTBVEOBd/EB6l3ufQiff7A/USFtPO3CEgSebvgmsfEAtfGrRojPXy+0OQPylD8RHsppNOYMKB8wRnzN9fXl+FD1eMQ8WP35nQdpTT6EbLoYaTiQMqGWfXs2/ttPA6Vew7ylqfz3t5WIjM2LKdw/fcM6BLtG5zzN4kD6jqv8/xg== 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=zRf+zbsYVbXw4m+hWzQ8X6gRtwmUHQBdV7IiFCeRWPk=; b=XAXysZS98w47vTWxr/HEDgzcvNE73yDDXgK5kAHAKArO6untXSYN8iYVMz8xsJzOeemabHjm8YmzwQaqjFvPHI9Bqth5wAkQh65FT8iiBuRYBVnPX1Nq1ot965jw1xLm+NRkHZWQzZpc8uGqfxpO6IUtnaRvkgDixFAD+Q2pyTI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9448.eurprd04.prod.outlook.com (2603:10a6:102:2b1::21) by AM9PR04MB8081.eurprd04.prod.outlook.com (2603:10a6:20b:3e2::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.20; Fri, 4 Nov 2022 06:46:54 +0000 Received: from PAXPR04MB9448.eurprd04.prod.outlook.com ([fe80::88a0:57d8:2a57:3f4f]) by PAXPR04MB9448.eurprd04.prod.outlook.com ([fe80::88a0:57d8:2a57:3f4f%9]) with mapi id 15.20.5791.022; Fri, 4 Nov 2022 06:46:54 +0000 From: Sandor Yu To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, andrzej.hajda@intel.com, neil.armstrong@linaro.org, robert.foss@linaro.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, kishon@ti.com, vkoul@kernel.org Cc: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, linux-imx@nxp.com, tzimmermann@suse.de, lyude@redhat.com, Sandor.yu@nxp.com, javierm@redhat.com, ville.syrjala@linux.intel.com, sam@ravnborg.org, jani.nikula@intel.com, maxime@cerno.tech, penguin-kernel@I-love.SAKURA.ne.jp, p.yadav@ti.com, oliver.brown@nxp.com Subject: [v2 03/10] drm: bridge: cadence: Add MHDP DP driver for i.MX8MQ Date: Fri, 4 Nov 2022 14:44:53 +0800 Message-Id: <5cdefbbaa41e3ff0f177f0c8d1d37d4f01fae4e4.1667463263.git.Sandor.yu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-ClientProxiedBy: SG2PR06CA0194.apcprd06.prod.outlook.com (2603:1096:4:1::26) To PAXPR04MB9448.eurprd04.prod.outlook.com (2603:10a6:102:2b1::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9448:EE_|AM9PR04MB8081:EE_ X-MS-Office365-Filtering-Correlation-Id: 2abff5c4-929b-4852-5b28-08dabe305c48 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dgxciKt1qBOOnQt48iKUNPYM8dtzjD75ccJ4QL5h3FFVXRyo/mb7dkhHoutaBfUFZkeWigz61xGHejcogJy/mLdO263+qCFRJ7F/035UKncmddXB8Zt4ZQfiBi87E3KOoKDexL3ikV21N1juRA7NboKspwm5dXLNt4GSw9pvkpCcpWb9ASCSwzCOOG8HZhGpZWIPkitZmkSA3Gql2ZMNEukpErFA9rI8U2kkrYzkTpaaYUiZF/1zeGiteJ1aGImysyR7ibG94dVm/IktFWN2m4IfDcJ5z89qsriCjR3saosnz/dgC1ANkT/oOHnB2vUJbVoBJonh2coWCPVa2actfLx2Rqoo4y9Ic9NYMyEN5gtkhUtJ9tyHFyu6PeF2n/7l9Pk8lhjFcIGVmqSC+v+4T0jfI32WOA6ERJPk73gedEUhJ0yw3pylBMtYlq1D3IWl1AjHUQbzV7jUkrshzenWgwoibRJJvQtszLIeYJoaOaMH+pq4CHnN3ID+6lS5hBLgR3tBix9cyAd0PG8G/3UVlROlwDQ9mtVL4K6viOnLmNNaqYx4UdmvqLZjPdoqLuPjWAP2tG4rbtfJFAtnblJ0J+YkPD0+qrcDv3iPx9vCkgA/SY/GrH0V1TA9DQgNUn+eqfX6QzgBbHCcHT0bmCOLEtrjMkPLz4W5xAqjZcNY25gwZdn6Y2SNvdU086rMwCsYLMnFtPzVtyP1BjrnwPcjcbmzopZLcYARV3YGHUeg5BgsNPo/V2qOOK1Ge1CdMoFpEGQmhAC/ynaqRr05EADshe3DR06pUllpl0SXrsMGqlFlxkYqftIAwup+dwiLVjuj X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9448.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(376002)(39860400002)(366004)(136003)(396003)(451199015)(316002)(8676002)(38350700002)(30864003)(7416002)(5660300002)(66556008)(66476007)(38100700002)(4326008)(66946007)(36756003)(8936002)(41300700001)(83380400001)(921005)(186003)(2616005)(86362001)(6486002)(26005)(478600001)(6512007)(52116002)(6506007)(2906002)(579004)(309714004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WFGEjvnJ0/CZ5df6LLOl57PP31t3/DXy2fQb505fcKYWlxxEDsOHfbF02GH+Y5C8MaApPZ04JJOwvBbhJYvW0vhW1itpfvYnxQLa2pDj3jsYuosOXxgTXaCXHPZ/U2Z4c3vdUzlNYL4KjQIDE0VEHW7odXcXbgBiaIv1APVK/LMAgZRIb9K11UfJSMzbjG6AytdtKcr3QsIOD+Hlfl2z9HdQoDah38dhWdeoJhxDva9Orqto5wVQjDuKlFZiC08i34OG+PtV6LRaj1bT9CiHwDER4Dtm03/sZqUQnTHS/ZZ0SRsqrUiQaLfAy6p/T3l6M3SYym9bRO8+o5hD5gcmqWQxNCeqJXEqyPgEnzyuBh3Rc35lK8NhS5KiIzgImQBj2NG7JGWtvmkQXoC1gh80XW/mJrAGYmpi5sqG5exF+ZvWdHh+w0YVZYLbtQc+t0l2hXm3sUGqkQ8fg/IkoPjtQtDP6YRXsqlOs8gdzbZZOrKkz2lwndBm6w4poVR70SSYBgK5gH/U1JG7EQAlXwc1JtBojqUguVtBCZnv+xQrTGKHiycpVdYLtmS4098w/rymS8ITae2N6hszU8f8BGt4s/kwYnPuOewjzdAo9OAbZx9m5kBpUOnLedeRmf4l5EcINoh1K56nGgc5lbvZaJrpGdgIgrwsQtnXzd238uKdTmwSI1ApPkmxsL3R0IhW2e2/lhp7VR6WeUIpS5uhfyHudCfdqKX3oiJQbdbRl0QqsMuRAiM1an5M88/A6nOe6L3nPl8voT4S77axRW+LJ+cjfwnnzkAvzfs+CUFstkUV2JLzp4//zdvYvGRX7mLH3muAUmPd4iDiBOF2/19CFAd7XjOwH/0gN8JHxP7dyomNSAaekemI2hPBAFvF0QOHszzyDAA5Sa/t7aLZ9UKxFT2lHJiMb6lV7BY2mR8/RQs/X/fr5PqL9A/rW8C6XjM27Aja27K5y+W3G/7FgMSTJ8JSRmGLMA1PCxs67JsX8jay9cwUK5ag3hp0U9H5YYXyRUM8j9yFJGnhzjwpf5flYc4/eQLqSy40e/uSHimZjtOPBKvahD6AcKANlabDsRrSG7vV9BBt6bMr5ZGOS0hxB4UnKIT3QNCznSa67hCw8rgGvTBQR8ixTWFd7sbOLVFj2XVY778zC6NQyRTCKaPihzpqrjLl7hJt3XNSWSQcF2VRe+f6e4OyBsw1Jakx7iwghYspctHgDT7ezITxW5WUakRtNJGRRVJwcxBrmGuyJd7JxwDm15f/ODQ4M5TJeCLa8e8oCT8OmJXo30SLKs+tnm3/L4OBfa/nhQp1GJU8UkKdvhCzBqOHIgCNe3QNFdRGOLqftTeQbfhCZwF2w7A8ALEsPltDf2Fu899XxZswIHbrQ+E/SccDWvLeb6dB1IyDdqO8vsfs85eVLat2U1JMn+1ysu6iutKs+3bZ+iMkjOYthRfqQVn+RIEecuk5S0aLU0fONBDCNHw0nQsJmDwaaBTiXmw+dHo2HKgUJjl0/4jMx9VmAjHtGOdtqwP9eQobu4YKFr4lktGGUz4LWWlYg8It5bimPc0A2YDF0x5YdHIXlnGSFwHtEBO6Yvi+3EDPiMoX X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2abff5c4-929b-4852-5b28-08dabe305c48 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9448.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2022 06:46:54.5736 (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: Z5CRTXhO6D2PggYXMbs7Rs8KpWR7BRyfmR44x4AXFzMjFyM8L+wGO+qW1rrGE/oBUX2biX9wGwmakHrM+i5/QA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8081 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 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?1748547129190693999?= X-GMAIL-MSGID: =?utf-8?q?1748547129190693999?= Add a new DRM DisplayPort bridge driver for Candence MHDP used in i.MX8MQ SOC. MHDP IP could support HDMI or DisplayPort standards according embedded Firmware running in the uCPU. For iMX8MQ SOC, the DisplayPort FW was loaded and activated by SOC ROM code. Bootload binary included HDMI FW was required for the driver. Signed-off-by: Sandor Yu --- drivers/gpu/drm/bridge/cadence/Kconfig | 13 + drivers/gpu/drm/bridge/cadence/Makefile | 3 + drivers/gpu/drm/bridge/cadence/cdns-dp-core.c | 1070 +++++++++++++++++ .../gpu/drm/bridge/cadence/cdns-mhdp-common.h | 402 +++++++ 4 files changed, 1488 insertions(+) create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-dp-core.c create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-mhdp-common.h diff --git a/drivers/gpu/drm/bridge/cadence/Kconfig b/drivers/gpu/drm/bridge/cadence/Kconfig index 1d06182bea71..e79ae1af3765 100644 --- a/drivers/gpu/drm/bridge/cadence/Kconfig +++ b/drivers/gpu/drm/bridge/cadence/Kconfig @@ -25,3 +25,16 @@ config DRM_CDNS_MHDP8546_J721E initializes the J721E Display Port and sets up the clock and data muxes. endif + +config DRM_CDNS_DP + tristate "Cadence DP DRM driver" + select DRM_KMS_HELPER + select DRM_PANEL_BRIDGE + select DRM_DISPLAY_DP_HELPER + select DRM_DISPLAY_HELPER + select DRM_CDNS_AUDIO + depends on OF + help + Support Cadence MHDP DisplayPort driver. + Cadence MHDP Controller support one or more protocols, + DisplayPort firmware is required for this driver. diff --git a/drivers/gpu/drm/bridge/cadence/Makefile b/drivers/gpu/drm/bridge/cadence/Makefile index 4d2db8df1bc6..269ef500c29d 100644 --- a/drivers/gpu/drm/bridge/cadence/Makefile +++ b/drivers/gpu/drm/bridge/cadence/Makefile @@ -2,3 +2,6 @@ obj-$(CONFIG_DRM_CDNS_MHDP8546) += cdns-mhdp8546.o cdns-mhdp8546-y := cdns-mhdp8546-core.o cdns-mhdp8546-hdcp.o cdns-mhdp8546-$(CONFIG_DRM_CDNS_MHDP8546_J721E) += cdns-mhdp8546-j721e.o + +obj-$(CONFIG_DRM_CDNS_DP) += cdns-dp-core.o +obj-$(CONFIG_DRM_CDNS_HDMI) += cdns-hdmi-core.o diff --git a/drivers/gpu/drm/bridge/cadence/cdns-dp-core.c b/drivers/gpu/drm/bridge/cadence/cdns-dp-core.c new file mode 100644 index 000000000000..e1a884f13488 --- /dev/null +++ b/drivers/gpu/drm/bridge/cadence/cdns-dp-core.c @@ -0,0 +1,1070 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Cadence Display Port Interface (DP) driver + * + * Copyright (C) 2019-2022 NXP Semiconductor, Inc. + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cdns-mhdp-common.h" + +#define LINK_TRAINING_TIMEOUT_MS 500 +#define LINK_TRAINING_RETRY_MS 20 + +/* + * This function only implements native DPDC reads and writes + */ +static int cdns_mhdp_dpcd_read(struct cdns_mhdp_device *mhdp, + u32 addr, u8 *data, u16 len) +{ + u8 msg[5], reg[5]; + int ret; + + put_unaligned_be16(len, msg); + put_unaligned_be24(addr, msg + 2); + + mutex_lock(&mhdp->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_DP_TX, + DPTX_READ_DPCD, sizeof(msg), msg); + if (ret) + goto out; + + ret = cdns_mhdp_mailbox_recv_header(mhdp, MB_MODULE_ID_DP_TX, + DPTX_READ_DPCD, + sizeof(reg) + len); + if (ret) + goto out; + + ret = cdns_mhdp_mailbox_recv_data(mhdp, reg, sizeof(reg)); + if (ret) + goto out; + + ret = cdns_mhdp_mailbox_recv_data(mhdp, data, len); + +out: + mutex_unlock(&mhdp->mbox_mutex); + + return ret; +} + +static int cdns_mhdp_dpcd_write(struct cdns_mhdp_device *mhdp, u32 addr, u8 value) +{ + u8 msg[6], reg[5]; + int ret; + + put_unaligned_be16(1, msg); + put_unaligned_be24(addr, msg + 2); + msg[5] = value; + + mutex_lock(&mhdp->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_DP_TX, + DPTX_WRITE_DPCD, sizeof(msg), msg); + if (ret) + goto out; + + ret = cdns_mhdp_mailbox_recv_header(mhdp, MB_MODULE_ID_DP_TX, + DPTX_WRITE_DPCD, sizeof(reg)); + if (ret) + goto out; + + ret = cdns_mhdp_mailbox_recv_data(mhdp, reg, sizeof(reg)); + if (ret) + goto out; + + if (addr != get_unaligned_be24(reg + 2)) + ret = -EINVAL; + +out: + mutex_unlock(&mhdp->mbox_mutex); + + if (ret) + dev_err(mhdp->dev, "dpcd write failed: %d\n", ret); + return ret; +} + +static ssize_t dp_aux_transfer(struct drm_dp_aux *aux, + struct drm_dp_aux_msg *msg) +{ + struct cdns_mhdp_device *mhdp = dev_get_drvdata(aux->dev); + bool native = msg->request & (DP_AUX_NATIVE_WRITE & DP_AUX_NATIVE_READ); + int ret; + + /* Ignore address only message */ + if ((msg->size == 0) || (msg->buffer == NULL)) { + msg->reply = native ? + DP_AUX_NATIVE_REPLY_ACK : DP_AUX_I2C_REPLY_ACK; + return msg->size; + } + + if (!native) { + dev_err(mhdp->dev, "%s: only native messages supported\n", __func__); + return -EINVAL; + } + + /* msg sanity check */ + if (msg->size > DP_AUX_MAX_PAYLOAD_BYTES) { + dev_err(mhdp->dev, "%s: invalid msg: size(%zu), request(%x)\n", + __func__, msg->size, (unsigned int)msg->request); + return -EINVAL; + } + + if (msg->request == DP_AUX_NATIVE_WRITE) { + const u8 *buf = msg->buffer; + int i; + + for (i = 0; i < msg->size; ++i) { + ret = cdns_mhdp_dpcd_write(mhdp, + msg->address + i, buf[i]); + if (!ret) + continue; + + DRM_DEV_ERROR(mhdp->dev, "Failed to write DPCD\n"); + + return ret; + } + msg->reply = DP_AUX_NATIVE_REPLY_ACK; + return msg->size; + } + + if (msg->request == DP_AUX_NATIVE_READ) { + ret = cdns_mhdp_dpcd_read(mhdp, msg->address, msg->buffer, msg->size); + if (ret < 0) + return -EIO; + msg->reply = DP_AUX_NATIVE_REPLY_ACK; + return msg->size; + } + return 0; +} + +static int dp_aux_destroy(struct cdns_mhdp_device *mhdp) +{ + drm_dp_aux_unregister(&mhdp->dp.aux); + + return 0; +} + +static int mhdp_get_msa_misc(struct video_info *video, + struct drm_display_mode *mode) +{ + u32 msa_misc; + u8 val[2] = {0}; + + switch (video->color_fmt) { + /* set YUV default color space conversion to BT601 */ + case DRM_COLOR_FORMAT_YCBCR444: + val[0] = 6 + BT_601 * 8; + break; + case DRM_COLOR_FORMAT_YCBCR422: + val[0] = 5 + BT_601 * 8; + break; + case DRM_COLOR_FORMAT_YCBCR420: + val[0] = 5; + break; + case DRM_COLOR_FORMAT_RGB444: + default: + val[0] = 0; + break; + }; + + switch (video->bpc) { + case 6: + val[1] = 0; + break; + case 10: + val[1] = 2; + break; + case 12: + val[1] = 3; + break; + case 16: + val[1] = 4; + break; + case 8: + default: + val[1] = 1; + break; + }; + + msa_misc = 2 * val[0] + 32 * val[1]; + + return msa_misc; +} + +static int cdns_mhdp_config_video(struct cdns_mhdp_device *mhdp) +{ + struct video_info *video = &mhdp->video_info; + struct drm_display_mode *mode = &mhdp->mode; + u64 symbol; + u32 val, link_rate, rem; + u8 bit_per_pix, tu_size_reg = TU_SIZE; + int ret; + + bit_per_pix = (video->color_fmt == DRM_COLOR_FORMAT_YCBCR422) ? + (video->bpc * 2) : (video->bpc * 3); + + link_rate = mhdp->dp.rate / 1000; + + ret = cdns_mhdp_reg_write(mhdp, BND_HSYNC2VSYNC, VIF_BYPASS_INTERLACE); + if (ret) + goto err_config_video; + + ret = cdns_mhdp_reg_write(mhdp, HSYNC2VSYNC_POL_CTRL, 0); + if (ret) + goto err_config_video; + + /* + * get a best tu_size and valid symbol: + * 1. chose Lclk freq(162Mhz, 270Mhz, 540Mhz), set TU to 32 + * 2. calculate VS(valid symbol) = TU * Pclk * Bpp / (Lclk * Lanes) + * 3. if VS > *.85 or VS < *.1 or VS < 2 or TU < VS + 4, then set + * TU += 2 and repeat 2nd step. + */ + do { + tu_size_reg += 2; + symbol = tu_size_reg * mode->clock * bit_per_pix; + do_div(symbol, mhdp->dp.num_lanes * link_rate * 8); + rem = do_div(symbol, 1000); + if (tu_size_reg > 64) { + ret = -EINVAL; + DRM_DEV_ERROR(mhdp->dev, + "tu error, clk:%d, lanes:%d, rate:%d\n", + mode->clock, mhdp->dp.num_lanes, link_rate); + goto err_config_video; + } + } while ((symbol <= 1) || (tu_size_reg - symbol < 4) || + (rem > 850) || (rem < 100)); + + val = symbol + (tu_size_reg << 8); + val |= TU_CNT_RST_EN; + ret = cdns_mhdp_reg_write(mhdp, DP_FRAMER_TU, val); + if (ret) + goto err_config_video; + + /* set the FIFO Buffer size */ + val = div_u64(mode->clock * (symbol + 1), 1000) + link_rate; + val /= (mhdp->dp.num_lanes * link_rate); + val = div_u64(8 * (symbol + 1), bit_per_pix) - val; + val += 2; + ret = cdns_mhdp_reg_write(mhdp, DP_VC_TABLE(15), val); + + switch (video->bpc) { + case 6: + val = BCS_6; + break; + case 10: + val = BCS_10; + break; + case 12: + val = BCS_12; + break; + case 16: + val = BCS_16; + break; + case 8: + default: + val = BCS_8; + break; + }; + + val += video->color_fmt << 8; + ret = cdns_mhdp_reg_write(mhdp, DP_FRAMER_PXL_REPR, val); + if (ret) + goto err_config_video; + + val = video->h_sync_polarity ? DP_FRAMER_SP_HSP : 0; + val |= video->v_sync_polarity ? DP_FRAMER_SP_VSP : 0; + ret = cdns_mhdp_reg_write(mhdp, DP_FRAMER_SP, val); + if (ret) + goto err_config_video; + + val = (mode->hsync_start - mode->hdisplay) << 16; + val |= mode->htotal - mode->hsync_end; + ret = cdns_mhdp_reg_write(mhdp, DP_FRONT_BACK_PORCH, val); + if (ret) + goto err_config_video; + + val = mode->hdisplay * bit_per_pix / 8; + ret = cdns_mhdp_reg_write(mhdp, DP_BYTE_COUNT, val); + if (ret) + goto err_config_video; + + val = mode->htotal | ((mode->htotal - mode->hsync_start) << 16); + ret = cdns_mhdp_reg_write(mhdp, MSA_HORIZONTAL_0, val); + if (ret) + goto err_config_video; + + val = mode->hsync_end - mode->hsync_start; + val |= (mode->hdisplay << 16) | (video->h_sync_polarity << 15); + ret = cdns_mhdp_reg_write(mhdp, MSA_HORIZONTAL_1, val); + if (ret) + goto err_config_video; + + val = mode->vtotal; + val |= (mode->vtotal - mode->vsync_start) << 16; + ret = cdns_mhdp_reg_write(mhdp, MSA_VERTICAL_0, val); + if (ret) + goto err_config_video; + + val = mode->vsync_end - mode->vsync_start; + val |= (mode->vdisplay << 16) | (video->v_sync_polarity << 15); + ret = cdns_mhdp_reg_write(mhdp, MSA_VERTICAL_1, val); + if (ret) + goto err_config_video; + + val = mhdp_get_msa_misc(video, mode); + ret = cdns_mhdp_reg_write(mhdp, MSA_MISC, val); + if (ret) + goto err_config_video; + + ret = cdns_mhdp_reg_write(mhdp, STREAM_CONFIG, 1); + if (ret) + goto err_config_video; + + val = mode->hsync_end - mode->hsync_start; + val |= mode->hdisplay << 16; + ret = cdns_mhdp_reg_write(mhdp, DP_HORIZONTAL, val); + if (ret) + goto err_config_video; + + val = mode->vdisplay; + val |= (mode->vtotal - mode->vsync_start) << 16; + ret = cdns_mhdp_reg_write(mhdp, DP_VERTICAL_0, val); + if (ret) + goto err_config_video; + + val = mode->vtotal; + ret = cdns_mhdp_reg_write(mhdp, DP_VERTICAL_1, val); + if (ret) + goto err_config_video; + + ret = cdns_mhdp_reg_write_bit(mhdp, DP_VB_ID, 2, 1, 0); + +err_config_video: + if (ret) + DRM_DEV_ERROR(mhdp->dev, "config video failed: %d\n", ret); + return ret; +} + +static void dp_pixel_clk_reset(struct cdns_mhdp_device *mhdp) +{ + u32 val; + + /* reset pixel clk */ + cdns_mhdp_reg_read(mhdp, SOURCE_HDTX_CAR, &val); + cdns_mhdp_reg_write(mhdp, SOURCE_HDTX_CAR, val & 0xFD); + cdns_mhdp_reg_write(mhdp, SOURCE_HDTX_CAR, val); +} + +static int cdns_mhdp_set_video_status(struct cdns_mhdp_device *mhdp, int active) +{ + u8 msg; + int ret; + + msg = !!active; + + mutex_lock(&mhdp->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_DP_TX, DPTX_SET_VIDEO, + sizeof(msg), &msg); + if (ret) + DRM_DEV_ERROR(mhdp->dev, "set video status failed: %d\n", ret); + + mutex_unlock(&mhdp->mbox_mutex); + + return ret; +} + +static int cdns_mhdp_training_start(struct cdns_mhdp_device *mhdp) +{ + unsigned long timeout; + u8 msg, event[2]; + int ret; + + msg = LINK_TRAINING_RUN; + + mutex_lock(&mhdp->mbox_mutex); + + /* start training */ + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_DP_TX, + DPTX_TRAINING_CONTROL, sizeof(msg), &msg); + if (ret) + goto err_training_start; + + timeout = jiffies + msecs_to_jiffies(LINK_TRAINING_TIMEOUT_MS); + while (time_before(jiffies, timeout)) { + msleep(LINK_TRAINING_RETRY_MS); + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_DP_TX, + DPTX_READ_EVENT, 0, NULL); + if (ret) + goto err_training_start; + + ret = cdns_mhdp_mailbox_recv_header(mhdp, + MB_MODULE_ID_DP_TX, + DPTX_READ_EVENT, + sizeof(event)); + if (ret) + goto err_training_start; + + ret = cdns_mhdp_mailbox_recv_data(mhdp, event, + sizeof(event)); + if (ret) + goto err_training_start; + + if (event[1] & CLK_RECOVERY_FAILED) + DRM_DEV_ERROR(mhdp->dev, "clock recovery failed\n"); + else if (event[1] & EQ_PHASE_FINISHED) { + mutex_unlock(&mhdp->mbox_mutex); + return 0; + } + } + + ret = -ETIMEDOUT; + +err_training_start: + mutex_unlock(&mhdp->mbox_mutex); + + DRM_DEV_ERROR(mhdp->dev, "training failed: %d\n", ret); + return ret; +} + +static int cdns_mhdp_get_training_status(struct cdns_mhdp_device *mhdp) +{ + u8 status[13]; //VER_H_L: 0x87CF + //u8 status[10]; + int ret; + + mutex_lock(&mhdp->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_DP_TX, + DPTX_READ_LINK_STAT, 0, NULL); + if (ret) + goto err_get_training_status; + + ret = cdns_mhdp_mailbox_recv_header(mhdp, MB_MODULE_ID_DP_TX, + DPTX_READ_LINK_STAT, + sizeof(status)); + if (ret) + goto err_get_training_status; + + ret = cdns_mhdp_mailbox_recv_data(mhdp, status, sizeof(status)); + if (ret) + goto err_get_training_status; + + mhdp->dp.rate = drm_dp_bw_code_to_link_rate(status[0]); + mhdp->dp.num_lanes = status[1]; + +err_get_training_status: + mutex_unlock(&mhdp->mbox_mutex); + + if (ret) + DRM_DEV_ERROR(mhdp->dev, "get training status failed: %d\n", + ret); + return ret; +} + +static int cdns_mhdp_train_link(struct cdns_mhdp_device *mhdp) +{ + int ret; + + ret = cdns_mhdp_training_start(mhdp); + if (ret) { + DRM_DEV_ERROR(mhdp->dev, "Failed to start training %d\n", + ret); + return ret; + } + + ret = cdns_mhdp_get_training_status(mhdp); + if (ret) { + DRM_DEV_ERROR(mhdp->dev, "Failed to get training stat %d\n", + ret); + return ret; + } + + DRM_DEV_DEBUG_KMS(mhdp->dev, "rate:0x%x, lanes:%d\n", mhdp->dp.rate, + mhdp->dp.num_lanes); + return ret; +} + +int cdns_mhdp_set_host_cap(struct cdns_mhdp_device *mhdp) +{ + u8 msg[8]; + int ret; + + msg[0] = drm_dp_link_rate_to_bw_code(mhdp->dp.rate); + msg[1] = mhdp->dp.num_lanes | SCRAMBLER_EN; + msg[2] = VOLTAGE_LEVEL_2; + msg[3] = PRE_EMPHASIS_LEVEL_3; + msg[4] = PTS1 | PTS2 | PTS3 | PTS4; + msg[5] = FAST_LT_NOT_SUPPORT; + msg[6] = mhdp->lane_mapping; + msg[7] = ENHANCED; + + mutex_lock(&mhdp->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_DP_TX, + DPTX_SET_HOST_CAPABILITIES, + sizeof(msg), msg); + + mutex_unlock(&mhdp->mbox_mutex); + + if (ret) + DRM_DEV_ERROR(mhdp->dev, "set host cap failed: %d\n", ret); + + return ret; +} + +static int cdns_mhdp_get_dp_edid_block(void *data, u8 *edid, + unsigned int block, size_t length) +{ + struct cdns_mhdp_device *mhdp = data; + u8 msg[2], reg[2], i; + int ret; + + mutex_lock(&mhdp->mbox_mutex); + + for (i = 0; i < 4; i++) { + msg[0] = block / 2; + msg[1] = block % 2; + + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_DP_TX, + DPTX_GET_EDID, sizeof(msg), msg); + if (ret) + continue; + + ret = cdns_mhdp_mailbox_recv_header(mhdp, + MB_MODULE_ID_DP_TX, + DPTX_GET_EDID, + sizeof(reg) + length); + if (ret) + continue; + + ret = cdns_mhdp_mailbox_recv_data(mhdp, reg, sizeof(reg)); + if (ret) + continue; + + ret = cdns_mhdp_mailbox_recv_data(mhdp, edid, length); + if (ret) + continue; + + if (reg[0] == length && reg[1] == block / 2) + break; + } + + if (ret) + DRM_DEV_ERROR(mhdp->dev, "get block[%d] edid failed: %d\n", + block, ret); + + mutex_unlock(&mhdp->mbox_mutex); + return ret; +} + +static int cdns_mhdp_dp_read_hpd(struct cdns_mhdp_device *mhdp) +{ + u8 status; + int ret; + + mutex_lock(&mhdp->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_DP_TX, DPTX_HPD_STATE, + 0, NULL); + if (ret) + goto err_get_hpd; + + ret = cdns_mhdp_mailbox_recv_header(mhdp, MB_MODULE_ID_DP_TX, + DPTX_HPD_STATE, sizeof(status)); + if (ret) + goto err_get_hpd; + + ret = cdns_mhdp_mailbox_recv_data(mhdp, &status, sizeof(status)); + if (ret) + goto err_get_hpd; + + mutex_unlock(&mhdp->mbox_mutex); + return status; + +err_get_hpd: + mutex_unlock(&mhdp->mbox_mutex); + DRM_ERROR("read hpd failed: %d\n", ret); + return ret; +} + +static void cdns_dp_mode_set(struct cdns_mhdp_device *mhdp) +{ + union phy_configure_opts phy_cfg; + int ret; + + dp_pixel_clk_reset(mhdp); + + /* Get DP Caps */ + ret = drm_dp_dpcd_read(&mhdp->dp.aux, DP_DPCD_REV, mhdp->dp.dpcd, + DP_RECEIVER_CAP_SIZE); + if (ret < 0) { + DRM_ERROR("Failed to get caps %d\n", ret); + return; + } + + mhdp->dp.rate = drm_dp_max_link_rate(mhdp->dp.dpcd); + mhdp->dp.num_lanes = drm_dp_max_lane_count(mhdp->dp.dpcd); + + /* check the max link rate */ + if (mhdp->dp.rate > CDNS_DP_MAX_LINK_RATE) + mhdp->dp.rate = CDNS_DP_MAX_LINK_RATE; + + phy_cfg.dp.lanes = mhdp->dp.num_lanes; + phy_cfg.dp.link_rate = mhdp->dp.rate; + phy_cfg.dp.set_lanes = false; + phy_cfg.dp.set_rate = false; + phy_cfg.dp.set_voltages = true; + ret = phy_configure(mhdp->phy, &phy_cfg); + if (ret) { + dev_err(mhdp->dev, "%s: phy_configure() failed: %d\n", + __func__, ret); + return; + } + + /* Video off */ + ret = cdns_mhdp_set_video_status(mhdp, CONTROL_VIDEO_IDLE); + if (ret) { + DRM_DEV_ERROR(mhdp->dev, "Failed to valid video %d\n", ret); + return; + } + + /* Line swapping */ + mhdp->lane_mapping = mhdp->plat_data->lane_mapping; + cdns_mhdp_reg_write(mhdp, LANES_CONFIG, 0x00400000 | mhdp->lane_mapping); + + /* Set DP host capability */ + ret = cdns_mhdp_set_host_cap(mhdp); + if (ret) { + DRM_DEV_ERROR(mhdp->dev, "Failed to set host cap %d\n", ret); + return; + } + + ret = cdns_mhdp_reg_write(mhdp, DP_AUX_SWAP_INVERSION_CONTROL, + AUX_HOST_INVERT); + if (ret) { + DRM_DEV_ERROR(mhdp->dev, "Failed to set host invert %d\n", ret); + return; + } + + ret = cdns_mhdp_config_video(mhdp); + if (ret) { + DRM_DEV_ERROR(mhdp->dev, "Failed to config video %d\n", ret); + return; + } +} + +static enum drm_connector_status +cdns_dp_detect(struct cdns_mhdp_device *mhdp) +{ + u8 hpd = 0xf; + + hpd = cdns_mhdp_dp_read_hpd(mhdp); + if (hpd == 1) + return connector_status_connected; + else if (hpd == 0) + return connector_status_disconnected; + + DRM_INFO("Unknown cable status, hdp=%u\n", hpd); + return connector_status_unknown; +} + +static int cdns_dp_connector_get_modes(struct drm_connector *connector) +{ + struct cdns_mhdp_device *mhdp = container_of(connector, + struct cdns_mhdp_device, connector); + int num_modes = 0; + struct edid *edid; + + edid = drm_do_get_edid(&mhdp->connector, + cdns_mhdp_get_dp_edid_block, mhdp); + if (edid) { + dev_info(mhdp->dev, "%x,%x,%x,%x,%x,%x,%x,%x\n", + edid->header[0], edid->header[1], + edid->header[2], edid->header[3], + edid->header[4], edid->header[5], + edid->header[6], edid->header[7]); + drm_connector_update_edid_property(connector, edid); + num_modes = drm_add_edid_modes(connector, edid); + kfree(edid); + } + + if (num_modes == 0) + DRM_ERROR("Invalid edid\n"); + return num_modes; +} + +static const struct drm_connector_funcs cdns_dp_connector_funcs = { + .fill_modes = drm_helper_probe_single_connector_modes, + .destroy = drm_connector_cleanup, + .reset = drm_atomic_helper_connector_reset, + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, +}; + +static const struct drm_connector_helper_funcs cdns_dp_connector_helper_funcs = { + .get_modes = cdns_dp_connector_get_modes, +}; + +static int cdns_dp_bridge_attach(struct drm_bridge *bridge, + enum drm_bridge_attach_flags flags) +{ + struct cdns_mhdp_device *mhdp = bridge->driver_private; + struct drm_encoder *encoder = bridge->encoder; + struct drm_connector *connector = &mhdp->connector; + int ret; + + if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) { + connector->interlace_allowed = 0; + + connector->polled = DRM_CONNECTOR_POLL_HPD; + + drm_connector_helper_add(connector, &cdns_dp_connector_helper_funcs); + + drm_connector_init(bridge->dev, connector, &cdns_dp_connector_funcs, + DRM_MODE_CONNECTOR_DisplayPort); + + drm_connector_attach_encoder(connector, encoder); + } + + mhdp->dp.aux.drm_dev = bridge->dev; + ret = drm_dp_aux_register(&mhdp->dp.aux); + + return ret; +} + +static enum drm_mode_status +cdns_dp_bridge_mode_valid(struct drm_bridge *bridge, + const struct drm_display_info *info, + const struct drm_display_mode *mode) +{ + enum drm_mode_status mode_status = MODE_OK; + + /* We don't support double-clocked modes */ + if (mode->flags & DRM_MODE_FLAG_DBLCLK || + mode->flags & DRM_MODE_FLAG_INTERLACE) + return MODE_BAD; + + /* MAX support pixel clock rate 594MHz */ + if (mode->clock > 594000) + return MODE_CLOCK_HIGH; + + /* 4096x2160 is not supported */ + if (mode->hdisplay > 3840) + return MODE_BAD_HVALUE; + + if (mode->vdisplay > 2160) + return MODE_BAD_VVALUE; + + return mode_status; +} + +static enum drm_connector_status +cdns_dp_bridge_detect(struct drm_bridge *bridge) +{ + struct cdns_mhdp_device *mhdp = bridge->driver_private; + + return cdns_dp_detect(mhdp); +} + +static struct edid *cdns_dp_bridge_get_edid(struct drm_bridge *bridge, + struct drm_connector *connector) +{ + struct cdns_mhdp_device *mhdp = bridge->driver_private; + + return drm_do_get_edid(connector, + cdns_mhdp_get_dp_edid_block, mhdp); +} + +static void cdns_dp_bridge_atomic_disable(struct drm_bridge *bridge, + struct drm_bridge_state *old_state) +{ + struct cdns_mhdp_device *mhdp = bridge->driver_private; + + cdns_mhdp_set_video_status(mhdp, CONTROL_VIDEO_IDLE); + mhdp->curr_conn = NULL; + + mutex_lock(&mhdp->lock); + phy_power_off(mhdp->phy); + mutex_unlock(&mhdp->lock); +} + +static void cdns_dp_bridge_atomic_enable(struct drm_bridge *bridge, + struct drm_bridge_state *old_state) +{ + struct cdns_mhdp_device *mhdp = bridge->driver_private; + struct drm_atomic_state *state = old_state->base.state; + struct drm_connector *connector; + struct video_info *video = &mhdp->video_info; + struct drm_crtc_state *crtc_state; + struct drm_connector_state *conn_state; + const struct drm_display_mode *mode; + int ret; + + connector = drm_atomic_get_new_connector_for_encoder(state, + bridge->encoder); + if (WARN_ON(!connector)) + return; + + mhdp->curr_conn = connector; + + conn_state = drm_atomic_get_new_connector_state(state, connector); + if (WARN_ON(!conn_state)) + return; + + crtc_state = drm_atomic_get_new_crtc_state(state, conn_state->crtc); + if (WARN_ON(!crtc_state)) + return; + + mode = &crtc_state->adjusted_mode; + + switch (connector->display_info.bpc) { + case 16: + video->bpc = 16; + break; + case 12: + video->bpc = 12; + break; + case 10: + video->bpc = 10; + break; + case 6: + video->bpc = 6; + break; + default: + video->bpc = 8; + break; + } + + video->color_fmt = DRM_COLOR_FORMAT_RGB444; + video->v_sync_polarity = !!(mode->flags & DRM_MODE_FLAG_NVSYNC); + video->h_sync_polarity = !!(mode->flags & DRM_MODE_FLAG_NHSYNC); + + DRM_INFO("Mode: %dx%dp%d\n", mode->hdisplay, mode->vdisplay, mode->clock); + memcpy(&mhdp->mode, mode, sizeof(struct drm_display_mode)); + + mutex_lock(&mhdp->lock); + cdns_dp_mode_set(mhdp); + mutex_unlock(&mhdp->lock); + + /* Link trainning */ + ret = cdns_mhdp_train_link(mhdp); + if (ret) { + DRM_DEV_ERROR(mhdp->dev, "Failed link train %d\n", ret); + return; + } + + ret = cdns_mhdp_set_video_status(mhdp, CONTROL_VIDEO_VALID); + if (ret) { + DRM_DEV_ERROR(mhdp->dev, "Failed to valid video %d\n", ret); + return; + } +} + +static const struct drm_bridge_funcs cdns_dp_bridge_funcs = { + .attach = cdns_dp_bridge_attach, + .mode_valid = cdns_dp_bridge_mode_valid, + + .detect = cdns_dp_bridge_detect, + .get_edid = cdns_dp_bridge_get_edid, + .atomic_enable = cdns_dp_bridge_atomic_enable, + .atomic_disable = cdns_dp_bridge_atomic_disable, + .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, + .atomic_reset = drm_atomic_helper_bridge_reset, +}; + +static void hotplug_work_func(struct work_struct *work) +{ + struct cdns_mhdp_device *mhdp = container_of(work, + struct cdns_mhdp_device, hotplug_work.work); + enum drm_connector_status status = cdns_dp_detect(mhdp); + + drm_bridge_hpd_notify(&mhdp->bridge, status); + + if (status == connector_status_connected) { + /* Cable connedted */ + DRM_INFO("HDMI/DP Cable Plug In\n"); + enable_irq(mhdp->irq[IRQ_OUT]); + } else if (status == connector_status_disconnected) { + /* Cable Disconnedted */ + DRM_INFO("HDMI/DP Cable Plug Out\n"); + enable_irq(mhdp->irq[IRQ_IN]); + } +} + +static irqreturn_t cdns_dp_irq_thread(int irq, void *data) +{ + struct cdns_mhdp_device *mhdp = data; + + disable_irq_nosync(irq); + + mod_delayed_work(system_wq, &mhdp->hotplug_work, + msecs_to_jiffies(HOTPLUG_DEBOUNCE_MS)); + + return IRQ_HANDLED; +} + +static int cdns_mhdp_dp_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct cdns_mhdp_device *mhdp; + struct resource *res; + u32 reg; + int ret; + + mhdp = devm_kzalloc(dev, sizeof(*mhdp), GFP_KERNEL); + if (!mhdp) + return -ENOMEM; + + mutex_init(&mhdp->mbox_mutex); + + INIT_DELAYED_WORK(&mhdp->hotplug_work, hotplug_work_func); + + drm_dp_aux_init(&mhdp->dp.aux); + mhdp->dp.aux.name = "imx_dp_aux"; + mhdp->dp.aux.dev = dev; + mhdp->dp.aux.transfer = dp_aux_transfer; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -ENODEV; + mhdp->regs = devm_ioremap(dev, res->start, resource_size(res)); + if (IS_ERR(mhdp->regs)) + return PTR_ERR(mhdp->regs); + + mhdp->phy = devm_of_phy_get_by_index(dev, pdev->dev.of_node, 0); + if (IS_ERR(mhdp->phy)) { + dev_err(dev, "no PHY configured\n"); + return PTR_ERR(mhdp->phy); + } + + mhdp->irq[IRQ_IN] = platform_get_irq_byname(pdev, "plug_in"); + if (mhdp->irq[IRQ_IN] < 0) + dev_info(dev, "No plug_in irq number\n"); + + mhdp->irq[IRQ_OUT] = platform_get_irq_byname(pdev, "plug_out"); + if (mhdp->irq[IRQ_OUT] < 0) + dev_info(dev, "No plug_out irq number\n"); + + /* + * Wait for the KEEP_ALIVE "message" on the first 8 bits. + * Updated each sched "tick" (~2ms) + */ + ret = readl_poll_timeout(mhdp->regs + KEEP_ALIVE, reg, + reg & CDNS_KEEP_ALIVE_MASK, 500, + CDNS_KEEP_ALIVE_TIMEOUT); + if (ret) { + dev_err(mhdp->dev, + "device didn't give any life sign: reg %d\n", reg); + return ret; + } + + mhdp->plat_data = of_device_get_match_data(dev); + + /* DP PHY init before AUX init */ + ret = phy_init(mhdp->phy); + if (ret) { + dev_err(mhdp->dev, "Failed to initialize PHY: %d\n", ret); + return -ENODEV; + } + + /* Enable Hotplug Detect IRQ thread */ + irq_set_status_flags(mhdp->irq[IRQ_IN], IRQ_NOAUTOEN); + ret = devm_request_threaded_irq(dev, mhdp->irq[IRQ_IN], + NULL, cdns_dp_irq_thread, + IRQF_ONESHOT, dev_name(dev), + mhdp); + if (ret) { + dev_err(dev, "can't claim irq %d\n", + mhdp->irq[IRQ_IN]); + return -EINVAL; + } + + irq_set_status_flags(mhdp->irq[IRQ_OUT], IRQ_NOAUTOEN); + ret = devm_request_threaded_irq(dev, mhdp->irq[IRQ_OUT], + NULL, cdns_dp_irq_thread, + IRQF_ONESHOT, dev_name(dev), + mhdp); + if (ret) { + dev_err(dev, "can't claim irq %d\n", + mhdp->irq[IRQ_OUT]); + return -EINVAL; + } + + if (cdns_mhdp_dp_read_hpd(mhdp)) + enable_irq(mhdp->irq[IRQ_OUT]); + else + enable_irq(mhdp->irq[IRQ_IN]); + + mhdp->bridge.driver_private = mhdp; + mhdp->bridge.funcs = &cdns_dp_bridge_funcs; + mhdp->bridge.of_node = dev->of_node; + mhdp->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID | + DRM_BRIDGE_OP_HPD; + mhdp->bridge.type = DRM_MODE_CONNECTOR_DisplayPort; + drm_bridge_add(&mhdp->bridge); + + dev_set_drvdata(dev, mhdp); + + return 0; +} + +static int cdns_mhdp_dp_remove(struct platform_device *pdev) +{ + struct cdns_mhdp_device *mhdp = platform_get_drvdata(pdev); + + dp_aux_destroy(mhdp); + + return 0; +} + +static struct cdns_plat_data imx8mq_dp_drv_data = { + .lane_mapping = 0xc6, +}; + +static const struct of_device_id cdns_mhdp_dp_dt_ids[] = { + { .compatible = "cdns,mhdp-imx8mq-dp", + .data = &imx8mq_dp_drv_data + }, + {}, +}; +MODULE_DEVICE_TABLE(of, cdns_mhdp_dp_dt_ids); + +static struct platform_driver cdns_mhdp_dp_platform_driver = { + .probe = cdns_mhdp_dp_probe, + .remove = cdns_mhdp_dp_remove, + .driver = { + .name = "cdns-mhdp-mx8mq-dp", + .of_match_table = cdns_mhdp_dp_dt_ids, + }, +}; + +module_platform_driver(cdns_mhdp_dp_platform_driver); + +MODULE_AUTHOR("Sandor Yu "); +MODULE_DESCRIPTION("Cadence Display Port transmitter driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:cdns-dp"); diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp-common.h b/drivers/gpu/drm/bridge/cadence/cdns-mhdp-common.h new file mode 100644 index 000000000000..a592400962db --- /dev/null +++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp-common.h @@ -0,0 +1,402 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Cadence Common head file + * + * Copyright (C) 2019-2022 NXP Semiconductor, Inc. + * + */ + +#ifndef _CDNS_MHDP_COMMON_H_ +#define _CDNS_MHDP_COMMON_H_ + +#include +#include +#include +#include + +#define ADDR_IMEM 0x10000 +#define ADDR_DMEM 0x20000 + +/* APB CFG addr */ +#define APB_CTRL 0 +#define XT_INT_CTRL 0x04 +#define MAILBOX_FULL_ADDR 0x08 +#define MAILBOX_EMPTY_ADDR 0x0c +#define MAILBOX0_WR_DATA 0x10 +#define MAILBOX0_RD_DATA 0x14 +#define KEEP_ALIVE 0x18 +#define VER_L 0x1c +#define VER_H 0x20 +#define VER_LIB_L_ADDR 0x24 +#define VER_LIB_H_ADDR 0x28 +#define SW_DEBUG_L 0x2c +#define SW_DEBUG_H 0x30 +#define MAILBOX_INT_MASK 0x34 +#define MAILBOX_INT_STATUS 0x38 +#define SW_CLK_L 0x3c +#define SW_CLK_H 0x40 +#define SW_EVENTS0 0x44 +#define SW_EVENTS1 0x48 +#define SW_EVENTS2 0x4c +#define SW_EVENTS3 0x50 +#define XT_OCD_CTRL 0x60 +#define APB_INT_MASK 0x6c +#define APB_STATUS_MASK 0x70 + +/* source phy comp */ +#define PHY_DATA_SEL 0x0818 +#define LANES_CONFIG 0x0814 + +/* source car addr */ +#define SOURCE_HDTX_CAR 0x0900 +#define SOURCE_DPTX_CAR 0x0904 +#define SOURCE_PHY_CAR 0x0908 +#define SOURCE_CEC_CAR 0x090c +#define SOURCE_CBUS_CAR 0x0910 +#define SOURCE_PKT_CAR 0x0918 +#define SOURCE_AIF_CAR 0x091c +#define SOURCE_CIPHER_CAR 0x0920 +#define SOURCE_CRYPTO_CAR 0x0924 + +/* clock meters addr */ +#define CM_CTRL 0x0a00 +#define CM_I2S_CTRL 0x0a04 +#define CM_SPDIF_CTRL 0x0a08 +#define CM_VID_CTRL 0x0a0c +#define CM_LANE_CTRL 0x0a10 +#define I2S_NM_STABLE 0x0a14 +#define I2S_NCTS_STABLE 0x0a18 +#define SPDIF_NM_STABLE 0x0a1c +#define SPDIF_NCTS_STABLE 0x0a20 +#define NMVID_MEAS_STABLE 0x0a24 +#define I2S_MEAS 0x0a40 +#define SPDIF_MEAS 0x0a80 +#define NMVID_MEAS 0x0ac0 + +/* source vif addr */ +#define BND_HSYNC2VSYNC 0x0b00 +#define HSYNC2VSYNC_F1_L1 0x0b04 +#define HSYNC2VSYNC_STATUS 0x0b0c +#define HSYNC2VSYNC_POL_CTRL 0x0b10 + +/* mhdp tx_top_comp */ +#define SCHEDULER_H_SIZE 0x1000 +#define SCHEDULER_V_SIZE 0x1004 +#define HDTX_SIGNAL_FRONT_WIDTH 0x100c +#define HDTX_SIGNAL_SYNC_WIDTH 0x1010 +#define HDTX_SIGNAL_BACK_WIDTH 0x1014 +#define HDTX_CONTROLLER 0x1018 +#define HDTX_HPD 0x1020 +#define HDTX_CLOCK_REG_0 0x1024 +#define HDTX_CLOCK_REG_1 0x1028 + +/* DPTX hpd addr */ +#define HPD_IRQ_DET_MIN_TIMER 0x2100 +#define HPD_IRQ_DET_MAX_TIMER 0x2104 +#define HPD_UNPLGED_DET_MIN_TIMER 0x2108 +#define HPD_STABLE_TIMER 0x210c +#define HPD_FILTER_TIMER 0x2110 +#define HPD_EVENT_MASK 0x211c +#define HPD_EVENT_DET 0x2120 + +/* DPTX framer addr */ +#define DP_FRAMER_GLOBAL_CONFIG 0x2200 +#define DP_SW_RESET 0x2204 +#define DP_FRAMER_TU 0x2208 +#define DP_FRAMER_PXL_REPR 0x220c +#define DP_FRAMER_SP 0x2210 +#define AUDIO_PACK_CONTROL 0x2214 +#define DP_VC_TABLE(x) (0x2218 + ((x) << 2)) +#define DP_VB_ID 0x2258 +#define DP_MTPH_LVP_CONTROL 0x225c +#define DP_MTPH_SYMBOL_VALUES 0x2260 +#define DP_MTPH_ECF_CONTROL 0x2264 +#define DP_MTPH_ACT_CONTROL 0x2268 +#define DP_MTPH_STATUS 0x226c +#define DP_INTERRUPT_SOURCE 0x2270 +#define DP_INTERRUPT_MASK 0x2274 +#define DP_FRONT_BACK_PORCH 0x2278 +#define DP_BYTE_COUNT 0x227c + +/* dptx stream addr */ +#define MSA_HORIZONTAL_0 0x2280 +#define MSA_HORIZONTAL_1 0x2284 +#define MSA_VERTICAL_0 0x2288 +#define MSA_VERTICAL_1 0x228c +#define MSA_MISC 0x2290 +#define STREAM_CONFIG 0x2294 +#define AUDIO_PACK_STATUS 0x2298 +#define VIF_STATUS 0x229c +#define PCK_STUFF_STATUS_0 0x22a0 +#define PCK_STUFF_STATUS_1 0x22a4 +#define INFO_PACK_STATUS 0x22a8 +#define RATE_GOVERNOR_STATUS 0x22ac +#define DP_HORIZONTAL 0x22b0 +#define DP_VERTICAL_0 0x22b4 +#define DP_VERTICAL_1 0x22b8 +#define DP_BLOCK_SDP 0x22bc + +/* dptx glbl addr */ +#define DPTX_LANE_EN 0x2300 +#define DPTX_ENHNCD 0x2304 +#define DPTX_INT_MASK 0x2308 +#define DPTX_INT_STATUS 0x230c + +/* dp aux addr */ +#define DP_AUX_HOST_CONTROL 0x2800 +#define DP_AUX_INTERRUPT_SOURCE 0x2804 +#define DP_AUX_INTERRUPT_MASK 0x2808 +#define DP_AUX_SWAP_INVERSION_CONTROL 0x280c +#define DP_AUX_SEND_NACK_TRANSACTION 0x2810 +#define DP_AUX_CLEAR_RX 0x2814 +#define DP_AUX_CLEAR_TX 0x2818 +#define DP_AUX_TIMER_STOP 0x281c +#define DP_AUX_TIMER_CLEAR 0x2820 +#define DP_AUX_RESET_SW 0x2824 +#define DP_AUX_DIVIDE_2M 0x2828 +#define DP_AUX_TX_PREACHARGE_LENGTH 0x282c +#define DP_AUX_FREQUENCY_1M_MAX 0x2830 +#define DP_AUX_FREQUENCY_1M_MIN 0x2834 +#define DP_AUX_RX_PRE_MIN 0x2838 +#define DP_AUX_RX_PRE_MAX 0x283c +#define DP_AUX_TIMER_PRESET 0x2840 +#define DP_AUX_NACK_FORMAT 0x2844 +#define DP_AUX_TX_DATA 0x2848 +#define DP_AUX_RX_DATA 0x284c +#define DP_AUX_TX_STATUS 0x2850 +#define DP_AUX_RX_STATUS 0x2854 +#define DP_AUX_RX_CYCLE_COUNTER 0x2858 +#define DP_AUX_MAIN_STATES 0x285c +#define DP_AUX_MAIN_TIMER 0x2860 +#define DP_AUX_AFE_OUT 0x2864 + +/* source pif addr */ +#define SOURCE_PIF_WR_ADDR 0x30800 +#define SOURCE_PIF_WR_REQ 0x30804 +#define SOURCE_PIF_RD_ADDR 0x30808 +#define SOURCE_PIF_RD_REQ 0x3080c +#define SOURCE_PIF_DATA_WR 0x30810 +#define SOURCE_PIF_DATA_RD 0x30814 +#define SOURCE_PIF_FIFO1_FLUSH 0x30818 +#define SOURCE_PIF_FIFO2_FLUSH 0x3081c +#define SOURCE_PIF_STATUS 0x30820 +#define SOURCE_PIF_INTERRUPT_SOURCE 0x30824 +#define SOURCE_PIF_INTERRUPT_MASK 0x30828 +#define SOURCE_PIF_PKT_ALLOC_REG 0x3082c +#define SOURCE_PIF_PKT_ALLOC_WR_EN 0x30830 +#define SOURCE_PIF_SW_RESET 0x30834 + +/* mailbox */ +#define MB_MODULE_ID_DP_TX 0x01 +#define MB_MODULE_ID_HDMI_TX 0x03 +#define MB_MODULE_ID_HDCP_TX 0x07 +#define MB_MODULE_ID_HDCP_RX 0x08 +#define MB_MODULE_ID_HDCP_GENERAL 0x09 +#define MB_MODULE_ID_GENERAL 0x0A + +/* General opcode */ +#define GENERAL_MAIN_CONTROL 0x01 +#define GENERAL_TEST_ECHO 0x02 +#define GENERAL_BUS_SETTINGS 0x03 +#define GENERAL_TEST_ACCESS 0x04 +#define GENERAL_WRITE_FIELD 0x06 +#define GENERAL_READ_REGISTER 0x07 +#define GENERAL_GET_HPD_STATE 0x11 + +/* DPTX opcode */ +#define DPTX_SET_POWER_MNG 0x00 +#define DPTX_SET_HOST_CAPABILITIES 0x01 +#define DPTX_GET_EDID 0x02 +#define DPTX_READ_DPCD 0x03 +#define DPTX_WRITE_DPCD 0x04 +#define DPTX_ENABLE_EVENT 0x05 +#define DPTX_WRITE_REGISTER 0x06 +#define DPTX_READ_REGISTER 0x07 +#define DPTX_WRITE_FIELD 0x08 +#define DPTX_TRAINING_CONTROL 0x09 +#define DPTX_READ_EVENT 0x0a +#define DPTX_READ_LINK_STAT 0x0b +#define DPTX_SET_VIDEO 0x0c +#define DPTX_SET_AUDIO 0x0d +#define DPTX_GET_LAST_AUX_STAUS 0x0e +#define DPTX_SET_LINK_BREAK_POINT 0x0f +#define DPTX_FORCE_LANES 0x10 +#define DPTX_HPD_STATE 0x11 + +/* HDMI TX opcode */ +#define HDMI_TX_READ 0x00 +#define HDMI_TX_WRITE 0x01 +#define HDMI_TX_UPDATE_READ 0x02 +#define HDMI_TX_EDID 0x03 +#define HDMI_TX_EVENTS 0x04 +#define HDMI_TX_HPD_STATUS 0x05 + +#define MHDP_EVENT_ENABLE_HPD BIT(0) +#define MHDP_EVENT_ENABLE_TRAINING BIT(1) + +#define LINK_TRAINING_NOT_ACTIVE 0 +#define LINK_TRAINING_RUN 1 +#define LINK_TRAINING_RESTART 2 + +#define CONTROL_VIDEO_IDLE 0 +#define CONTROL_VIDEO_VALID 1 + +#define INTERLACE_FMT_DET BIT(12) +#define VIF_BYPASS_INTERLACE BIT(13) +#define TU_CNT_RST_EN BIT(15) +#define INTERLACE_DTCT_WIN 0x20 + +#define DP_FRAMER_SP_INTERLACE_EN BIT(2) +#define DP_FRAMER_SP_HSP BIT(1) +#define DP_FRAMER_SP_VSP BIT(0) + +/* capability */ +#define AUX_HOST_INVERT 3 +#define FAST_LT_SUPPORT 1 +#define FAST_LT_NOT_SUPPORT 0 +#define LANE_MAPPING_NORMAL 0x1b +#define LANE_MAPPING_FLIPPED 0xe4 +#define ENHANCED 1 +#define SCRAMBLER_EN BIT(4) + +#define FULL_LT_STARTED BIT(0) +#define FASE_LT_STARTED BIT(1) +#define CLK_RECOVERY_FINISHED BIT(2) +#define EQ_PHASE_FINISHED BIT(3) +#define FASE_LT_START_FINISHED BIT(4) +#define CLK_RECOVERY_FAILED BIT(5) +#define EQ_PHASE_FAILED BIT(6) +#define FASE_LT_FAILED BIT(7) + +#define TU_SIZE 30 +#define CDNS_DP_MAX_LINK_RATE 540000 + +#define F_HDMI_ENCODING(x) (((x) & ((1 << 2) - 1)) << 16) +#define F_VIF_DATA_WIDTH(x) (((x) & ((1 << 2) - 1)) << 2) +#define F_HDMI_MODE(x) (((x) & ((1 << 2) - 1)) << 0) +#define F_GCP_EN(x) (((x) & ((1 << 1) - 1)) << 12) +#define F_DATA_EN(x) (((x) & ((1 << 1) - 1)) << 15) +#define F_HDMI2_PREAMBLE_EN(x) (((x) & ((1 << 1) - 1)) << 18) +#define F_PIC_3D(x) (((x) & ((1 << 4) - 1)) << 7) +#define F_BCH_EN(x) (((x) & ((1 << 1) - 1)) << 11) +#define F_SOURCE_PHY_MHDP_SEL(x) (((x) & ((1 << 2) - 1)) << 3) +#define F_HPD_VALID_WIDTH(x) (((x) & ((1 << 12) - 1)) << 0) +#define F_HPD_GLITCH_WIDTH(x) (((x) & ((1 << 8) - 1)) << 12) +#define F_HDMI2_CTRL_IL_MODE(x) (((x) & ((1 << 1) - 1)) << 19) +#define F_SOURCE_PHY_LANE0_SWAP(x) (((x) & ((1 << 2) - 1)) << 0) +#define F_SOURCE_PHY_LANE1_SWAP(x) (((x) & ((1 << 2) - 1)) << 2) +#define F_SOURCE_PHY_LANE2_SWAP(x) (((x) & ((1 << 2) - 1)) << 4) +#define F_SOURCE_PHY_LANE3_SWAP(x) (((x) & ((1 << 2) - 1)) << 6) +#define F_SOURCE_PHY_COMB_BYPASS(x) (((x) & ((1 << 1) - 1)) << 21) +#define F_SOURCE_PHY_20_10(x) (((x) & ((1 << 1) - 1)) << 22) +#define F_PKT_ALLOC_ADDRESS(x) (((x) & ((1 << 4) - 1)) << 0) +#define F_ACTIVE_IDLE_TYPE(x) (((x) & ((1 << 1) - 1)) << 17) +#define F_FIFO1_FLUSH(x) (((x) & ((1 << 1) - 1)) << 0) +#define F_PKT_ALLOC_WR_EN(x) (((x) & ((1 << 1) - 1)) << 0) +#define F_DATA_WR(x) (x) +#define F_WR_ADDR(x) (((x) & ((1 << 4) - 1)) << 0) +#define F_HOST_WR(x) (((x) & ((1 << 1) - 1)) << 0) +#define F_TYPE_VALID(x) (((x) & ((1 << 1) - 1)) << 16) +#define F_PACKET_TYPE(x) (((x) & ((1 << 8) - 1)) << 8) + +/* Reference cycles when using lane clock as reference */ +#define LANE_REF_CYC 0x8000 + +/* HPD Debounce */ +#define HOTPLUG_DEBOUNCE_MS 200 + +/* HPD IRQ Index */ +#define IRQ_IN 0 +#define IRQ_OUT 1 +#define IRQ_NUM 2 + +/* FW check alive timeout */ +#define CDNS_KEEP_ALIVE_TIMEOUT 2000 +#define CDNS_KEEP_ALIVE_MASK GENMASK(7, 0) + +enum voltage_swing_level { + VOLTAGE_LEVEL_0, + VOLTAGE_LEVEL_1, + VOLTAGE_LEVEL_2, + VOLTAGE_LEVEL_3, +}; + +enum pre_emphasis_level { + PRE_EMPHASIS_LEVEL_0, + PRE_EMPHASIS_LEVEL_1, + PRE_EMPHASIS_LEVEL_2, + PRE_EMPHASIS_LEVEL_3, +}; + +enum pattern_set { + PTS1 = BIT(0), + PTS2 = BIT(1), + PTS3 = BIT(2), + PTS4 = BIT(3), + DP_NONE = BIT(4) +}; + +enum vic_color_depth { + BCS_6 = 0x1, + BCS_8 = 0x2, + BCS_10 = 0x4, + BCS_12 = 0x8, + BCS_16 = 0x10, +}; + +enum vic_bt_type { + BT_601 = 0x0, + BT_709 = 0x1, +}; + +enum { + MODE_DVI, + MODE_HDMI_1_4, + MODE_HDMI_2_0, +}; + +struct video_info { + bool h_sync_polarity; + bool v_sync_polarity; + int bpc; + int color_fmt; +}; + +struct cdns_mhdp_device { + struct device *dev; + void __iomem *regs; + struct drm_connector connector; + struct drm_connector *curr_conn; + struct drm_bridge bridge; + struct phy *phy; + + struct video_info video_info; + struct drm_display_mode mode; + + int irq[IRQ_NUM]; + struct delayed_work hotplug_work; + u32 lane_mapping; + struct mutex lock; + /* protect mailbox communications with the firmware */ + struct mutex mbox_mutex; + + const struct cdns_plat_data *plat_data; + + union { + struct _dp_data { + u32 rate; + u8 num_lanes; + struct drm_dp_aux aux; + u8 dpcd[DP_RECEIVER_CAP_SIZE]; + } dp; + struct _hdmi_data { + u32 char_rate; + u32 hdmi_type; + } hdmi; + }; +}; + +struct cdns_plat_data { + int lane_mapping; +}; +#endif From patchwork Fri Nov 4 06:44:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandor Yu X-Patchwork-Id: 15390 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp210823wru; Thu, 3 Nov 2022 23:48:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6sdrOp6lKvfkRpfu8NuKV4faeuTmnTEptzFOXYNpNiGx1rmNDleWY49rj1TeHCstDRKXAE X-Received: by 2002:a05:6a00:a15:b0:56e:9b2b:60dd with SMTP id p21-20020a056a000a1500b0056e9b2b60ddmr395534pfh.35.1667544492788; Thu, 03 Nov 2022 23:48:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1667544492; cv=pass; d=google.com; s=arc-20160816; b=rflcCXZw8RYs+KZCVK90ZeV04FkFof6xS3Z2GGBKMgFfliBTgmHLZ46pRp92UkwJJj KW7MGxUk23WTqlJoctT/sle1k5WH7xDlFypsqq7HYzBgTr29oHfr8hmIdRi8p3Fuuopz wvF+L9rG5Qno4p0pJqQ3ZPldHdSBIdxRXLLRcUDOBuGDLrzX4KC6YajZnxbAM99gvZch yAWxwTE8q6BodMylQuEID9JYkEPA5ZgvM39ECGJyP6GZvX/tjCdINhqn2XFJrDOlh7LR guw8mw6aihqlI8uSyp1p0QDibOQox3ZKXMdlSA/ZWKzbkA7kCtO6ICw6+mSXUXAINh0s qEog== 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=VoMObaoHu8KTKmQ88r6WUD/O/qGZeHbzp5rnpj1bqBg=; b=stjJwpGWx8So68eNAyPUNoVCUhP+ee8wCdO5PMqQS/rht31evq2QKhwTM83XPT/9A1 LGaMGWViQrbxkDVtiKJNse/e25vWkXdQQo9klCnvFADYQQ7P9s5WUCNbAXBTbwPAC/d+ 1nbOhfndWPNsgVlVhga1hKDv9KebitFCOfev3kDWzL86Dc9lgm+nSi/5LgeUVY133Y8K 6U/KgIn/DSUXggCT/bO/NwnzCzvPRKXlOzuyqJrFPB8Rk133lvqzExETph0hW2cNNodh kHBGt35xjJXidkEQRqqJ7e7vQlrP5wLR8LVT0s6ZIm+7bP7LroXN3oTjXzBjcJr6MK+q I+DA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=QZOdU51e; 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 y5-20020aa78045000000b0056bb75c96d6si3275638pfm.227.2022.11.03.23.48.00; Thu, 03 Nov 2022 23:48:12 -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=QZOdU51e; 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 S231559AbiKDGr0 (ORCPT + 99 others); Fri, 4 Nov 2022 02:47:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231378AbiKDGrG (ORCPT ); Fri, 4 Nov 2022 02:47:06 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2074.outbound.protection.outlook.com [40.107.21.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 401972AC71; Thu, 3 Nov 2022 23:47:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f2YjfSc3CeqhA7ZiKAcZXrlbmfVZim+05J3+3cWNYhpKfO60TszdzX2AIBNTwcbCT9MPbfRZeITPGrB0uzacT4YF4/RvkdYRzVvCfrr7tKg9bt9sUxKhzaGHPfPXPtNxDNl9gz5a73Ib6M//+R1egyOvYcMuGmmrSpeFzIkDqxPVuB05l78A3+qHdQnmGZk+vZ6b96YZTYA/LX3HIT3g/J+UIMD9txyVsfO7tHeDZp6zxCovdz+TuINgUTtlTXZtCjGPkCXLYvrkV+RorPyyqDiZq+W0e5RP37y346q8CrtqpR1HouZBofIUOvOz0h8IMJt+Uk4nTHm7ZwvWWc+8qw== 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=VoMObaoHu8KTKmQ88r6WUD/O/qGZeHbzp5rnpj1bqBg=; b=XiCmAOmnO9ai8Az6aLdc95sMbIJsnigYyeyJOuwIo8V7QovV5NMTrHbmcDqprVaJYMEaKLOsgiCKTUrGzVljkCkXzOpCLkm3wMpHBB4lXPltH5pyDpuxNeCxNNuxiHN8nisW/8319A7URqs8QgPFB43i4cqtppsbi909zlZQ+o06CCGwHaG3rF2G97lZGmF0Lm9sQiYG/UNoE0tq+Rkf8I5guH5GHPsV/utR3Xwi3oJdOAH/RHlmaQ1tUvSLRPC1GoeYmINax40wyR5zotmpvN62nkR3jp4x3wGGp9lCAFViJPns4+f8ex1YJAPyMkGfTzncaNcLUIw7wyeE9qrv5Q== 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=VoMObaoHu8KTKmQ88r6WUD/O/qGZeHbzp5rnpj1bqBg=; b=QZOdU51eEPZcJ3aX/gY9NJnNJCpALfc+Hv97HjFOfZRw2mOhdNKO6gth6irzx0yNfj+YG4reYpYTY3XSLwhNB+NZH/wISU0Y3X9mWE/PGpFHyH2NpIdNSOoqbWCWDRgLRAf9onCy84B1F2hP+o2AYZL7vgSQLZikfzGCZ2m/Jvg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9448.eurprd04.prod.outlook.com (2603:10a6:102:2b1::21) by AM9PR04MB8081.eurprd04.prod.outlook.com (2603:10a6:20b:3e2::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.20; Fri, 4 Nov 2022 06:47:02 +0000 Received: from PAXPR04MB9448.eurprd04.prod.outlook.com ([fe80::88a0:57d8:2a57:3f4f]) by PAXPR04MB9448.eurprd04.prod.outlook.com ([fe80::88a0:57d8:2a57:3f4f%9]) with mapi id 15.20.5791.022; Fri, 4 Nov 2022 06:47:02 +0000 From: Sandor Yu To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, andrzej.hajda@intel.com, neil.armstrong@linaro.org, robert.foss@linaro.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, kishon@ti.com, vkoul@kernel.org Cc: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, linux-imx@nxp.com, tzimmermann@suse.de, lyude@redhat.com, Sandor.yu@nxp.com, javierm@redhat.com, ville.syrjala@linux.intel.com, sam@ravnborg.org, jani.nikula@intel.com, maxime@cerno.tech, penguin-kernel@I-love.SAKURA.ne.jp, p.yadav@ti.com, oliver.brown@nxp.com Subject: [v2 04/10] phy: Add HDMI configuration options Date: Fri, 4 Nov 2022 14:44:54 +0800 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-ClientProxiedBy: SG2PR06CA0194.apcprd06.prod.outlook.com (2603:1096:4:1::26) To PAXPR04MB9448.eurprd04.prod.outlook.com (2603:10a6:102:2b1::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9448:EE_|AM9PR04MB8081:EE_ X-MS-Office365-Filtering-Correlation-Id: 8da7e2b4-aa93-4705-62cb-08dabe306112 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tyWFBDkeUi2rRVixL6y0UYXiuiCAl9KXrjUNQoNrNSdbrSZlUvOGkssoNzKdsNpO06UxxiklPipd9GuKLyhoCoqyNtp316ifqBUvYW1ZYh1K+Ns+bexP97gtveNyzCRwPnZEo8pDf4Pw/K/hD1Z58IccgynfgBhjcEy2jQKVj2Bi2Q2juvxYkNb3tz775s9v1g4Fn2RdLkCImcrIzJOrsxKlI2LXSPCSUcGIsXZfGsYq2A8rbtwGXbXn7oCkVF3O6DRZJdpUtCJ1U7mf4lxGGsvuNvTugTvH/5d+38KFk2XRz/fwZSllOlvNI1EBctarn20pP/7UJyNcPbJNhWaSkV06YeimOr0DCZPb+WVmEK5NtDdFWTXs+LCglO7P78qs+R6VDP9/aqmN4MjXel+1uVNMe8PfnqGbnM4onE88lk8je1azDUJybG1kDKpy2/8o2Y1gFzUyI1Os329qOezfBW/bMEuhurDOBoLHq/+twwUibM76hEs0KwXTGDm9/qVzVUgwVdjQ6S4B6oBNYtodReMf64Uz1usNezYO4HZEn41zqtsOXWu8a8GOxnt9xaIyOQVmC7R7eqY+FWT1hGYHDaHt1R2s8isVVKmXjaJw0WjzKmwwfmsqSBIp7y3ZhT9l4orAYERXCHicIxXmgE9Xt17KYPNNrtNHpnSBvCzmMGtlWy+fYEtxK9mT2RfIvshGmuzV78nj/nl/Pq90FOuglI5GOdE/O5kp55TULlbeyW0AwBEaP8y6JrzPLtI3m8T7bBbTSHMT4nXZR+zFQpZ6Egq7j1cwN5Mca7sxsdL1R70= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9448.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(376002)(39860400002)(366004)(136003)(396003)(451199015)(316002)(8676002)(38350700002)(7416002)(5660300002)(66556008)(66476007)(38100700002)(4326008)(66946007)(36756003)(8936002)(41300700001)(83380400001)(6666004)(921005)(186003)(2616005)(86362001)(6486002)(26005)(478600001)(6512007)(52116002)(6506007)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: U0L+AfLBuGI0T0p+kosqUPYH7vueNmmQ8VuoqBehxtNOWlsU2x+NQDXeq7RSIvjay/uWNkxw80dcCjHnITIrEYTOLuYKmBn5yTyd0kOJ2a/1AeytJ9/RUDAWxZWLda3bqniMcsN/HTAgadK8zP2VMIEOEv8BB5GpzlglaG/fS5Ax1rSFFl30ZTBDvm5Pd6P5CDK4LwW+TBlsYI1vMAU8M5jYaf2b8TkzWJgk7qgJtypdvCJ+wPpm+dtnByt3iKWBd29nItMFASqvHyeuiRZZI0M0qyrHixvEvmZYc/Avp3MTy1dE8aI3gJMIIklVesjqgznb60uwcnGOW3ZsGtl11eRdcfzqa+0+k8qNdFxl/u/wtwELKkQg1I8+KcG8h9q9mRfqe/yI6B7K7Hq6VWJr5to16b927N/FG5ffgSI8LV0nbvHC6BWsWsI9+NB/nqaH0SfjzJZSH7JZw3bohxz2ZUAeLGM0onyk6+Rf7q7y/zxZZ2/Wz81l+Xfq3FpZXkhiRYDuB+9dHfFdir1PYYT0Dnvl70UA9LHzaHA3o8rsRUFMaolyIPomw3wMve3EMGp3uKg8XWdPzXYKOSBy5mDyZjApiLEReul1HCPF6XCxJOEWatWWi/iXcVgkQmZSOMbax3tjYTmc8DzkKsdnmgqQZhsiYPuS1UahJXHh9UYbRSfkZM2b8u+pL9Oz82GSkwr4MclfmOUUznG4AjEshjNgQx78vE/1N7mXKA6C96LYHkX7ZNu2W3QCgO9CFrQUzJB7qfFZ7sbMiPjELnjDTvC+Kg2fOs4LvMgqOfP4KhLn83f3cyBTV7XSKFmCIve7CCWutV8dFi2rJo7H6dxZpntD23qkxMKICJzgBBCT/h6fbdC6Fv/nG2chpqKwnOrdH91WZzSjthiy3kaa2k7WmPC/k2x4qRY36scyDP4ezcr3kDAb8cDFZv0lS5WUXTHWZMpLYtGO+gNo5WHN+tF0q59SHovLdXC52Vy0eNNyYurlRp0j2B7gUz1Bk0fnsBJ2Q6EpXBnskkeTB7QdcaH1+HiEH9alqVjnr+mnkqLrcITl/hfU0sMxXRLIi168GoOH/Yb8K/K0Je8087aWWYtLqGts1SEJDS72oJlXLdDqEDUYokz/uqaKgbDnZ1UupaKaGgp1Mbvh+3TmDMaU9KmkW+AgdA7/s4JpaGzQopgnSU4mnyVpdyp/zuTS5DS46m0+W4VA/JyBlp9EhblvplvhEKWTAnMiJx7tUhpxsO+umwc3wAIAsijPjoF7RjCilgJ6fElrnmIjDIN0aJ/Dsf6nJeSTwlPeh4gTCFOq81Vz3m6pTPiNipLDwP4XMe+t58gLa9B+HrKUTiqtdHhsSA62CQhvJVGVpEVO6fqzMEt/hKNA8Tz7DU6gh2Gv7X4hsitRVaxYKKxE3N+qPKmnEkrWxA2ncuCN81iJEixRcxVJylgpbuH24F2eKg6qrGetpMITfpPcVvDG49ACCLxcvMQvWlXrGlVPTuAMXh6zVAkKVHAL8Rh8djOqmhtUCAj7gtIaXuR+cfKjMmA9niRj7ySfHXonc/yqVZlNIL8DGz0yVG8/nCusvD0/JEDYgUW+UGdsv25w X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8da7e2b4-aa93-4705-62cb-08dabe306112 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9448.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2022 06:47:02.4523 (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: qBUGaY6wTS/etDEsKYDfJWqxkvmq0yaj8KajDWAlhOfYl2doOk8xsalam0ykQsOHFN/EpYjwuRLZppfQalk4pQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8081 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 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?1748547133827921680?= X-GMAIL-MSGID: =?utf-8?q?1748547133827921680?= Allow HDMI PHYs to be configured through the generic functions through a custom structure added to the generic union. The parameters added here are based on HDMI PHY implementation practices. The current set of parameters should cover the potential users. Signed-off-by: Sandor Yu --- include/linux/phy/phy-hdmi.h | 33 +++++++++++++++++++++++++++++++++ include/linux/phy/phy.h | 7 ++++++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 include/linux/phy/phy-hdmi.h diff --git a/include/linux/phy/phy-hdmi.h b/include/linux/phy/phy-hdmi.h new file mode 100644 index 000000000000..73a32eb535b0 --- /dev/null +++ b/include/linux/phy/phy-hdmi.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright 2022 NXP + */ + +#ifndef __PHY_HDMI_H_ +#define __PHY_HDMI_H_ + +enum hdmi_phy_colorspace { + HDMI_PHY_COLORSPACE_RGB, + HDMI_PHY_COLORSPACE_YUV422, + HDMI_PHY_COLORSPACE_YUV444, + HDMI_PHY_COLORSPACE_YUV420, + HDMI_PHY_COLORSPACE_RESERVED4, + HDMI_PHY_COLORSPACE_RESERVED5, + HDMI_PHY_COLORSPACE_RESERVED6, +}; + +/** + * struct phy_configure_opts_hdmi - HDMI configuration set + * @pixel_clk_rate: Pixel clock of video modes in KHz. + * @bpc: Maximum bits per color channel. + * @color_space: Colorspace in enum hdmi_phy_colorspace. + * + * This structure is used to represent the configuration state of a HDMI phy. + */ +struct phy_configure_opts_hdmi { + unsigned int pixel_clk_rate; + unsigned int bpc; + enum hdmi_phy_colorspace color_space; +}; + +#endif /* __PHY_HDMI_H_ */ diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index b1413757fcc3..6f6873ea7270 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -42,7 +43,8 @@ enum phy_mode { PHY_MODE_MIPI_DPHY, PHY_MODE_SATA, PHY_MODE_LVDS, - PHY_MODE_DP + PHY_MODE_DP, + PHY_MODE_HDMI, }; enum phy_media { @@ -60,11 +62,14 @@ enum phy_media { * the DisplayPort protocol. * @lvds: Configuration set applicable for phys supporting * the LVDS phy mode. + * @hdmi: Configuration set applicable for phys supporting + * the HDMI phy mode. */ union phy_configure_opts { struct phy_configure_opts_mipi_dphy mipi_dphy; struct phy_configure_opts_dp dp; struct phy_configure_opts_lvds lvds; + struct phy_configure_opts_hdmi hdmi; }; /** From patchwork Fri Nov 4 06:44:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandor Yu X-Patchwork-Id: 15392 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp210899wru; Thu, 3 Nov 2022 23:48:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM43Q31akTYQ4jiF3J9MNRSj0Xo1YXamEtsfpklBoN+pSQjIVH0VzXCtEAApRaaVmuKTOKpv X-Received: by 2002:a63:4711:0:b0:46f:9f4a:2dd0 with SMTP id u17-20020a634711000000b0046f9f4a2dd0mr24694937pga.78.1667544505837; Thu, 03 Nov 2022 23:48:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1667544505; cv=pass; d=google.com; s=arc-20160816; b=vWXdzPjmBNiCLCJrvkIvO28aaOh24BWdKP2t4orO2orwwRZZp9zlwWkPOWntV4nvEC GKXPvH90mWrbXT1++eTLFWEKdn+Pkk52iDumxaxfNIzi1DAeKFXhh52bVPqds4cMnFlq mM5Gt21AWI+tGuDZsFpkA0pqx+S9MjWGE/Xm35b2RZVREwDV3GbYInFN5tef5DIz+U8p IZe4isFEqjukCI2zSPVH5C1AInGjjgOrAuYhTj4cAYWapTyVPxhgSSA9ohK0AAThs14M +VpEK2Gq3T+rPT8HMaVBwFMmpmQEl6x0k1K0+q0EROz4ZFlFTy3rJBt3+j1kb9L2ZxAP n4Sg== 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=aS6MOWsgSSCMzucgwE5rDFn2pVEBGzrYCT0DjRJmaz8=; b=0m4M1P6N+2EVRqyKSKrisgf1/LRl9JcfXVEO5fqSruX20d0/rdiM+hggPLBgflthOw IvGWfvBdntrHcfF7mR0aY/50NB7mmRGkl6gffkPcaILxZo6xvFzSyMZKditSnYCsh3PW py9iu9TBbGpZwSce+TdRcW7TYx0pGOgPpSrvJWpnnKYF64fsQXe4sb0Q6J6fDbx+mhSo SlbKagx2dQKwMhPyu+Jujlaa9sqSKcOY/I2xIzTSbthTM4Ub3v2XkIyJuoKG1z0cHyBQ F6Z9AUlXS/WKRK2JrUDiBmqghcDeVoaBEQNnPmtxlp9Zitdm+Ay1qwrnNUKd4FNc+W7Z cWoQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=mrFGI6U6; 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 g3-20020a170902868300b001871dab2d85si2926762plo.392.2022.11.03.23.48.13; Thu, 03 Nov 2022 23:48:25 -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=mrFGI6U6; 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 S231625AbiKDGrh (ORCPT + 99 others); Fri, 4 Nov 2022 02:47:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231535AbiKDGrZ (ORCPT ); Fri, 4 Nov 2022 02:47:25 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2087.outbound.protection.outlook.com [40.107.21.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 779622AE09; Thu, 3 Nov 2022 23:47:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fgVTaRm4qGci7TTUsgOv/hBnffkdzWocZ9QaelY1sZuDuoI/uXAfbE9RZBOO/SdMENQTPjk4ccqw7iOUqeLVNkkwgIEhPeshfPFEgFG9tL89X2nqUhZ1DMmh1xzWca2d/vwXq8BZE3IoH78poX/40Dy/qtRj+39LI0YXOi6K4t9fVE67fhrOQvY7us5TEYUFGcJTLFEgOakDiVK9RbgxGLOyez33WRRWJuAq3facct1izZK3E01hFZc9+kYwqYswaQKFCkpvrsLkLpiH2jfFA8CRqdIHX3Iz0EGyW2QS0gfBHmQKrw8azRUjzovoQaa+Dl4UusH1/AU1CbAjnxIxSA== 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=aS6MOWsgSSCMzucgwE5rDFn2pVEBGzrYCT0DjRJmaz8=; b=W88Cm6dQ/bLCbGSnv/FQ7QySmQiOIP+L2WmBn0RYzGeQoDtxyQ8CiBliLJk0JLdb9DukxhdQ/SNHkHO+5SLtz5FcfEBSINNFUPkenvghWMNqEe2CW+t6OzTsVdLJauv82VKv7NXZoedT+ZWRh9YSnzJrt0XOln4jy5j7UzotpwDuPhXyGElzfQ1DmqgIfbaHqIe9R/w+cwHVCP2eEaDB5lthFRtM7mcxkkdIoB2jN1yPLCBGVoTYpaH2PZwQr6Cq998Yyj7G4He3jqlKIeysoGlKXqXqAjkW0W47nXpPBQUOU5iORp4n6jfTnYn5TGPSPjGHva4FDH0N4OImWXqLhg== 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=aS6MOWsgSSCMzucgwE5rDFn2pVEBGzrYCT0DjRJmaz8=; b=mrFGI6U6iMI/UNSdC9bNEITXrN3IO8Dd0/4ZdXUlRUT4zINOXhLTX7eLW2IHg8qPViT4DZ4irGZbBsMoQdOccSY3fSxJye8SDYDm2DKVJHLilJcYHOASNibgo2QOgcC1g8yLTxkuIYEYGpStMmpK2nZ+3ERJBsHkA2wx0TAF7vc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9448.eurprd04.prod.outlook.com (2603:10a6:102:2b1::21) by AM9PR04MB8081.eurprd04.prod.outlook.com (2603:10a6:20b:3e2::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.20; Fri, 4 Nov 2022 06:47:10 +0000 Received: from PAXPR04MB9448.eurprd04.prod.outlook.com ([fe80::88a0:57d8:2a57:3f4f]) by PAXPR04MB9448.eurprd04.prod.outlook.com ([fe80::88a0:57d8:2a57:3f4f%9]) with mapi id 15.20.5791.022; Fri, 4 Nov 2022 06:47:09 +0000 From: Sandor Yu To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, andrzej.hajda@intel.com, neil.armstrong@linaro.org, robert.foss@linaro.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, kishon@ti.com, vkoul@kernel.org Cc: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, linux-imx@nxp.com, tzimmermann@suse.de, lyude@redhat.com, Sandor.yu@nxp.com, javierm@redhat.com, ville.syrjala@linux.intel.com, sam@ravnborg.org, jani.nikula@intel.com, maxime@cerno.tech, penguin-kernel@I-love.SAKURA.ne.jp, p.yadav@ti.com, oliver.brown@nxp.com Subject: [v2 05/10] dts-bindings: display: bridge: Add MHDP DP bindings for i.MX8MQ Date: Fri, 4 Nov 2022 14:44:55 +0800 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-ClientProxiedBy: SG2PR06CA0194.apcprd06.prod.outlook.com (2603:1096:4:1::26) To PAXPR04MB9448.eurprd04.prod.outlook.com (2603:10a6:102:2b1::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9448:EE_|AM9PR04MB8081:EE_ X-MS-Office365-Filtering-Correlation-Id: 95170429-9e92-449c-0667-08dabe306586 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0nk0U/71ox23HI8edk1a9Bton/mMMQE1VR2ffkAIgBGLMrmBoQv4koPY8KTqhjZx8rmfEpgJISKtjesYB5h6/ME3qKYQWA1IxqUQ/tLTA92Nfrzp3BFq7a4KKjPLzxrb5Pv2uo1IN8iGYAl9d6bjhW0NbvOhBTwNSvR+1M2mPNxgtpVdD24uwnd8Y+pvkhi5Vhc5LRpCmBo5Xn5XNGnW2bRY4pDL1AWEkp/tbSNXlnemLnYzFtvcyoqmShfyiGZcrJ5DY7jJ3O2dW7y4mi8b84ah/ScgqUxe8U/nXbKy00SUkvrRR1PSHJ7vh2OHW+NWff4df5fOECdZrxYFUpcU4TdPxk7g6U6RIwuQtHVYNtnOpS2F21Bf9KGdnxsxYUQgIqR2gp1d8uYMsA8hUawhl7ogqUqcHq6HK6xYyF5Uamgx0xHIcPk7Puy431QjLAkJYSk1YqoC5iG3ygRf+LvbUf04LjjJW6Up87qRRD5gp/GmGRmoCr7MbQgFL5tOu/wyFnCQwTu3ZnvI+xN/vpRcYHkzrgR8U3aWUjSp5GhelBpC4dNH3IfM63wxACTbEJGmHEyAHSHM1D0TLYksd0rQWyFBFoYhkbZBZEbQYota5CnoonWVZLAtzQN1a2WYS1GQzPL+vSFSO5gXTETZyZV7ud2oXdNU7Nyd5dHqgFrZKAGC0w/vyVKcAAbmZiAAe60Qa57RGNME7+D5+ZB2W+S8OYh1G0l8QnnjG8NMZlurmj9nHQeTCKzvlJYKH4+nhzWDFZMixQ4lh2hzojWaidUvL2WsSwrDfCXVlHhsbYqPlgRAhxm84MvmVBUS+M+EM2TweT8ZYJ4NuktUF3cgoXN1l1tknrXZin28sCZB7KUjEwU= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9448.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(376002)(39860400002)(366004)(136003)(396003)(451199015)(316002)(8676002)(38350700002)(7416002)(5660300002)(66556008)(66476007)(38100700002)(4326008)(66946007)(36756003)(8936002)(41300700001)(83380400001)(6666004)(921005)(186003)(2616005)(86362001)(6486002)(26005)(478600001)(6512007)(52116002)(6506007)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wOYzSxm1Ab1Eq0kYvKSDPi3jGs4RFcGF0dKhoKN344ECNJE5RsxT9EZHWjSeA0WMdHuLZq8PWVb9flTx8ab+HyiArmG3OQ/ZlYoFQ2+Wc5FCyW+Xf40F+K5/qgWExfFiURMLTpBWoWQymlJ9pelNCRyawQ7z7d5q1pU8TumBMJghBGbru7EUHUC1wH9fWPUNtEKN6whTJYg8kGD8UkaH1Pk0yUYwpcd0My4SXXqWqKAwpO0fzmaVvQL6+qrG889yCpmYnR/J+oQOJHufdlsAtWeCkWjbWTV682Zseg40UHwtk5T/gYN6vBPUAv36NtjAhZtfoTgYfnoLcbT8iofcpcKYd6R62nprfgT0ZxJKBOvaIeiGJvFTF1R7YAuM2Wx9MFVmDK68+3UzH0igzB3fUOumExcTXjzpYqelFIPZXfhcVYZTD4lcVN/L2Cuh69WyAMd6YYdGSQR/oZmQ86aqL1kOMZf3LnaneiBbwOZTh0cV1LuD1bvcQgpnp7rLkzSXoA8mJVMw/w52BlrFIO173caxlXRjM48ldFtS96jqPUEBMeRi5M5NzmflPF6jdVEcYyxNAw1dg8DR63bVrkc278X/eUj1L55guqapLCPhVD8N78HTtq1TqN8NXSe8lkyCB9ZCTva90SeH5uPvnLhBzRas5RjTKUJsRbszi6MDjSAB6defTuUih/sKXQWcd8MnwiosjKbUUvQV8fwEURU919TXGzTcfM/Zog3uraG7eAmyFe6prEtRjUnSC1NFfC+wCS0XLL8fykTlImPSQQPRsWfyyz2oH3jQz8ppyyY6ysY2rlLiLdQs9zB7fSD2LGsP1MgTehJVBErlQrj4NsAMGvyhKxtLXy+n91c0/ATRJhrgs2tE9vYFrXEKSXBbG8VSAPhuPf2TZLbUhpmH+OgxydkdGlpTN+Joxw6dpOubUEI24LOyqJKk3cevxOLDW61PMURGEpsctf+x8hbleBLkFxRg2yBcj9OZyMNXZKaanC624Yk/jIS2VW3b84dkz4WNoeV7WKe86GjuTtje3CtqbbMws7RYHCLEL+znk7AkkaxWacd9nXspWfg7u11mBNxvcAy8xepitjBqsGDglTa0YGEgCCBvuBOCB2MQihnlUpXVCNGnJDGXgYiEg45+xVd06FfB3QBdV2/vtcAZEIcflCxVSDHX6KSd/t2fLi48s8vzf1dNNPMfBCrgXJdnVl9XP44jWP3mc8/UyRF6nuhLDYJC2pxoo/PcbxSZSVAIzuuetLljPuqeZcCFpeifku7brZ3Rdu20NWNB3xMWJJWZ20pZZLDthajbL3bVFV/6Z8wn/Q/U1ySH6dWR7il2ZzS9a/kPB1kdrrWK6lZjU/lVEMCKUgxFFTCoc0HJDFYtMXbqB/3KSH3iDMoaqdmQQV5qF1WJx143wzG9oftkEAwUDM++Wv2IedcuUtrd2oecAcsd6/I0N+7JmU96ub0/gKs1rBWRg+xNAhVL0K9GPNxj273TlzFIXX7YnQ77HkGULe9OgolWeg5CC1yXxL5W0TETSekD+8UihcWqIqWNrouE9DgRph4EL5c+sZ4rXi8ZIobg2arA3t109NXKFeb86iIE X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 95170429-9e92-449c-0667-08dabe306586 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9448.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2022 06:47:09.9054 (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: qgPXhVBhpSverZk6FmlgiNKSMclPqpP2BIB0CnfCir0fFkG44kqeJ3gT7zzAJAEAjwxOJYGNygQZRW8n8XKOFg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8081 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 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?1748547147627539509?= X-GMAIL-MSGID: =?utf-8?q?1748547147627539509?= Add bindings for i.MX8MQ MHDP DisplayPort. Signed-off-by: Sandor Yu --- .../display/bridge/cdns,mhdp-imx8mq-dp.yaml | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/bridge/cdns,mhdp-imx8mq-dp.yaml diff --git a/Documentation/devicetree/bindings/display/bridge/cdns,mhdp-imx8mq-dp.yaml b/Documentation/devicetree/bindings/display/bridge/cdns,mhdp-imx8mq-dp.yaml new file mode 100644 index 000000000000..06ed881247ea --- /dev/null +++ b/Documentation/devicetree/bindings/display/bridge/cdns,mhdp-imx8mq-dp.yaml @@ -0,0 +1,67 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/display/bridge/cdns,mhdp-imx8mq-dp.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Cadence MHDP Displayport bridge + +maintainers: + - Sandor Yu + +description: + The Cadence MHDP Displayport TX interface. + +properties: + compatible: + enum: + - cdns,mhdp-imx8mq-dp + + reg: + items: + - description: + Memory mapped base address and length of mhdptx apb registers. + + phys: + description: + phandle to the Displayport PHY. + + phy-names: + items: + - const: dpphy + + interrupts: + items: + - description: Hotplug detect interrupter for cable plugin event. + - description: Hotplug detect interrupter for cable plugout event. + + interrupt-names: + items: + - const: plug_in + - const: plug_out + + port: + $ref: /schemas/graph.yaml#/properties/port + description: + A port node pointing to the output port of a display controller.. + +additionalProperties: false + +examples: + - | + #include + mhdp: mhdp@32c00000 { + compatible = "cdns,mhdp-imx8mq-dp"; + reg = <0x32c00000 0x100000>; + interrupts = , + ; + interrupt-names = "plug_in", "plug_out"; + phys = <&dp_phy>; + phy-names = "dpphy"; + + port { + hdmi_in: endpoint { + remote-endpoint = <&dcss_out>; + }; + }; + }; From patchwork Fri Nov 4 06:44:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandor Yu X-Patchwork-Id: 15393 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp210931wru; Thu, 3 Nov 2022 23:48:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4rKIX+kepNv6Y3gvVa8BkdsXMSgwIIthFYFOMfZy+LvMGweykzm9hDlQFbpgdIMfQfJ7EY X-Received: by 2002:a63:6d0:0:b0:46f:6017:de61 with SMTP id 199-20020a6306d0000000b0046f6017de61mr11821037pgg.107.1667544509747; Thu, 03 Nov 2022 23:48:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1667544509; cv=pass; d=google.com; s=arc-20160816; b=ygBvi+0/n1baizztzacFQ7/zCkHkIouAs/Z/iUSMX+iEQkQHIuh3ZYnqcnM9x2k3k+ sOAjBMU7E/jFZ4SuhNwhjHBDYUHA8fXm7tLBvhtolcI2dB0zXJdMuZLv5CP+/2DJ8QRF yk7616hhcR0Yac2tTRqt3nxNM2hW1KREsfMH8m0IUrEPAsVGW9q3UPveHw8klvcOYIcQ RYQ5CiL8ns8826nizIXKi7Hz0StL+DA6SNUYK+v0ZxzONLWTecRDWknMoprdWIOtTRC+ Ndo18lQgODafnDH+ZdYpD98jDq0RUAE9QZgwqf2REQ3pawFW/awqLVQN4edo8fG/6ny/ 6W9g== 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=rGE+zTBGugy3vCPs3sDUByjew5ohq9Ac4NY4MsDnJmY=; b=PZrtAnKwONJa0/XQImgXAg1JBc9knivVfQa2/9MwroQ3ELp4bwzD+NMSr/q8+S5JbA gt28XzeWYUJdcVkhrjd7MWubBs5/YaugoH13wOiiC87gOvJfU4++0wmZkKEWi/Y8CUhG uIEbfApUvP0v6THfvOsgIFewlLe8jjognMAKNYJdx3o+l50HFDbtPh8c2HyZBy4DIBmc 1q/O8o1Mvk1zn3sSDKeWObrxwo47g68EjJQ3LM1aOEffb94TdY2hyewdmkpAtE42fpx6 7f7PaRx7U+Echb5lJwnvRPAwZdfMFKk4dQlL1fMBNpo9Y/Q7dbR+rQ0o1pLRELLf6YjK cwKA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=a5RUb5r3; 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 d2-20020a17090a7bc200b0020d3631f006si2512620pjl.161.2022.11.03.23.48.16; Thu, 03 Nov 2022 23:48:29 -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=a5RUb5r3; 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 S231534AbiKDGrz (ORCPT + 99 others); Fri, 4 Nov 2022 02:47:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231602AbiKDGrf (ORCPT ); Fri, 4 Nov 2022 02:47:35 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2061b.outbound.protection.outlook.com [IPv6:2a01:111:f400:7d00::61b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDF5B2B27F; Thu, 3 Nov 2022 23:47:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IgS8drZAwPEtvb9mjnzHNbTjuleywuMcbid4MejEHNsBQ1oETvEXYN22ShPmsM/+WdvmA3DvHyYVfng0lD2+7tpHkZovgyRsMPIPtf5OyPNtC5O2X2AQ3J83/4XvutZrhPp6+24zp2S3pw3nOxazCW8Fwsf0lyOD8lEFiPWUQzYAQhtTCmt3jKwmklWf1Ol3c2DjF8/uo9itUIs9MPqpE0CQnn4So1QrTiPF3SiQA3TNzxaPrjSGmG5xNfRRNoArbaGOGGHNOp7GPtK4ZQ04uUKJg3dN8dRYCVDMbiflO+aXZwvVIXiniLsPYN3vbgBnL0T2CqSwaHl4WGuaTsQIzQ== 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=rGE+zTBGugy3vCPs3sDUByjew5ohq9Ac4NY4MsDnJmY=; b=Tfhf9b/yav0d2ejQcxTgVdL8/KttpP0scduTlaxMjh7JJG2GzvIkODQVze+r/IyyNR8Gb2Ok55tFBXNfpuWA/pDonMZnJ+43tCaWgR7tyrEhpO+ZaYpSz7zYyeu/ApbPAN7g/M6gdZ3XGcVbyLeNlIYgIX23t0b/mkz+UCeMeEkWrZJkr3y7QwOBkS7hm5J27CCHeKe4a/UEjPja4yqJEWvK+JLQTSRjI/X4hVmb3NlPOw2WZsNZOj/mEndANqitXnomSZvjuyi1mZfaQcBXQH0XF/S26wkfgfuRw3xF/g+ehq1Ye1y1S+hnt6/QqpuoFOZnns4Tl6v8Hr33kimNFA== 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=rGE+zTBGugy3vCPs3sDUByjew5ohq9Ac4NY4MsDnJmY=; b=a5RUb5r3Oy1de0S9CbgG+QYS5J4hvzuh9EWixx4PC1RqwfQ/gF3WEmg53xpVGFI1e2kVr+DMzWvZr5Shha4osrYF8SBEZE8BRIho0S13SBNJzfSLJNz+iRmLkRGMg+jO9vlYEgKVL6EHBUlHBciR2Mt4oRIzQB7VMpF0fqO6RWw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9448.eurprd04.prod.outlook.com (2603:10a6:102:2b1::21) by AM9PR04MB8081.eurprd04.prod.outlook.com (2603:10a6:20b:3e2::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.20; Fri, 4 Nov 2022 06:47:18 +0000 Received: from PAXPR04MB9448.eurprd04.prod.outlook.com ([fe80::88a0:57d8:2a57:3f4f]) by PAXPR04MB9448.eurprd04.prod.outlook.com ([fe80::88a0:57d8:2a57:3f4f%9]) with mapi id 15.20.5791.022; Fri, 4 Nov 2022 06:47:18 +0000 From: Sandor Yu To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, andrzej.hajda@intel.com, neil.armstrong@linaro.org, robert.foss@linaro.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, kishon@ti.com, vkoul@kernel.org Cc: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, linux-imx@nxp.com, tzimmermann@suse.de, lyude@redhat.com, Sandor.yu@nxp.com, javierm@redhat.com, ville.syrjala@linux.intel.com, sam@ravnborg.org, jani.nikula@intel.com, maxime@cerno.tech, penguin-kernel@I-love.SAKURA.ne.jp, p.yadav@ti.com, oliver.brown@nxp.com Subject: [v2 06/10] drm: bridge: cadence: Add MHDP HDMI driver for i.MX8MQ Date: Fri, 4 Nov 2022 14:44:56 +0800 Message-Id: <5dab8e70ab0f662f1c6bf72c852c0cfa053c9fcf.1667463263.git.Sandor.yu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-ClientProxiedBy: SG2PR06CA0194.apcprd06.prod.outlook.com (2603:1096:4:1::26) To PAXPR04MB9448.eurprd04.prod.outlook.com (2603:10a6:102:2b1::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9448:EE_|AM9PR04MB8081:EE_ X-MS-Office365-Filtering-Correlation-Id: 877540ab-9bdd-4877-9f9b-08dabe306a52 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kQ5ithWAv+wYveBEwZXVmscGrelx4BrtgwDn/hww+qWhLjly8SLq0jhEpyDTnM1dRdOCFg+T0IybFHdkwu2jlrV4HS86zkn+ClfDbmoND6/Kk85zCbN08ThBLUwUL79jdujuhvraAXuHFUOy78zRkKxHZyTG4utyDfo3zUwO+MAyiBj4qzzQxeHkEEh79jkUGq8mR0aK3HLHEjWo7RTr390hyVONA9wxjHbLYNsdbOWuscI7CgSbMbvSYRBtf4zZTL+JNiST6xV7OsRnCdZuoptVopToFqo10nYVpv5HWueCamtEQW0TxV/brW0YKI2vQ2jMq8Qg8biRi+QuJFlsGEOV23ZDmpZCnnypvG3vAQDXz1lWlMFAUd2nJF409bK5DTexT7YMlmiPkGn/KxXUWE/rYjrwVEyYuKCar7Vg8GlZyl6xurDzlFlRPneIIgJmssyneSl/42yUcVwxwxqk8Rr2JsOGZlIt3A/EHNlwPBWwUNbpfyWL/sus8n18UBlB7DOJ0yIInIWsuUcQt7rUm0eXUMFmBph130bJ9Ge9Igsy5n3rreMZ92WJzA4P4NIOCttEYzXddrYl7qdyDpJsCYuuuKVq4FYn1cjw0zXqrcrVnFo5E8bUhOobFJX9r5QniKlpGBS9Iz2PW6frqqo54gaaR83zsgOgjQV5jckBGnF7hSV7CclrnqhIGKmwZN9kB0mluB8BmNQ7+TsBdfSKJEDxuCNCWrBMKGdEOjFlNBnL+JZjqQff1sKwKxWjMo1KsK0Ai0BOg0CgIY1DSRF6lg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9448.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(376002)(39860400002)(366004)(136003)(396003)(451199015)(316002)(8676002)(38350700002)(30864003)(7416002)(5660300002)(66556008)(66476007)(38100700002)(4326008)(66946007)(36756003)(8936002)(41300700001)(83380400001)(6666004)(921005)(186003)(2616005)(86362001)(6486002)(26005)(478600001)(6512007)(52116002)(6506007)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jZGBRsJPP3pM7Y2QlF6RUmBqz6NvxvzamZGfmzzU9Kmxnr0tGWmm+nJPWjtT52wHELAxyh+zpzhhfnY41JQzUE50Qlbq5vf6/NLmywqDbuRwNNV0+Jvgb+KF8zL7GtD4Xrt+CEH11iJUPxsjZWyOcZKT4qUmVL6lNvBeQtrlgP+p+FKZIZ9qgg1PYTai3XEjxuDG/0KPQ+KyUZZUu9jkS97/HFUuYJ6M59EoDDXb2Hbt1pBtU+odeSiVA29MwurgqPGF+fZPrPCR2K3IcaAFxt68d6gfAgspK3PnwVtzSb55CvkQu2HHq7XiF+Z58Oe8nfGTkFDVdhBlT07gY6AgwBeoKZNfsDLsFBk9CbCbOR6PBl3io8BLLd93oOkjNXcw1hD8Ym9CJYUhM11rPECIDKBZV49+j1i3d53TIhqOwU2e34jG9k4xCxvTt5JaJumz9AnUlW24t3LOy7n/AS/RYgOLNCKOTt75Wt7nsKOU7Zs2RA3lSilBGp7oaed9K5TBescPp2OzRTSvMexrNG7dQ6dFHNPidkC7EV/Pj7wpcsSa4xoRJkgevzg79G8kSn8G7ge2iVRYoq6kauBCoNSDjxyyeUfItWtRud24qtHMBDPCxqPJy7hUpyVTmM3kmD/HYNawfDQiqyn0DvVZYAjJE/5+nxg3e68ByookC3d3/C6/FUq9zoM1yXRXHFzsz8s6UEDPasl1dtKJLMuLH7R61/Yt6rzoi5zKDdhosGKJzCyVJ5vp/YzBzRnpHGQ8l0U5h8z5FMPWzv+yUo2oFJoLScBWfybzrBZhxIZ/xLScIyYxmVyGI2SUmbhnwCsq/nTLI4fydGQmXjOlcILCiqyszZzb7s0YltVyhNLJBF9IyMeBMVVslOrQG38kKvgvU91lY+1AJERKrzIRQOkHJWU72JsN1Id08FA+mFUV5U2tWmigSzac1SKscCY/b1itLEjZAkkF79NlYDyRIjTuKFOW9G3w70g/aja537CE2nm8K9OGWckb/kyhwROzOPH2MpPPVveSuJjI04gofuHXZ6la51g34Dg1L5GcuNKF5OXAfi8IVjotfZIMpW/Kxrsj84JCg9YijpCuZdM5RXSYMWzD3uzlDYVHXqA58zeD5W61CYeZoVIXVS2b0ytOS2P9by6OEnTyLfLNHgCW533ZZCQ6oJn3qfwvfHGxrm4+RA745VZh2uIkOPGD0HZdNK4KzJIzg57D57ZyK9LOu2g373Mpkal9bfagkpU0ENaAu7ZNup6nO/RFsZEhTh3wdkJYVppBsmqdT9mgVjoeKyD40l3Z4mQp6ZvzCNX6dy9nkYFaulu1WJPbZt/XuEvdZMgic7YifQsnkqubfKEHAwW+wsechzoajkroAuGGEBQ0hBCRN50In1pkshkk0jxZOOXFjptzLYMJEC7jvykJiY3NdsVBYCAKLK/DCN8ByaXiSssmTwNQkS7Yhrg6hdcR15UrLN4qR0ZmoF3tGahvEpNfnL4D9KZfboSzXXk2IuINepZO3Z3eN51z7C2rGcajrqozsznPdRHMu2GzgXlYxVycdAwWmct2cDPBOcSsjdmgJbaxjiJthItOKQnNzdglE3ahOvIS X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 877540ab-9bdd-4877-9f9b-08dabe306a52 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9448.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2022 06:47:18.1147 (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: in0Y9Ex7oBMxRPmvrryo1UcdmX/RpIvEN5uslK9aTOvgolyJpTZ1t/hNMDyCFOtWuzpw3kN322h7JMs7YGsT3w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8081 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,T_SPF_PERMERROR autolearn=no 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?1748547151981524938?= X-GMAIL-MSGID: =?utf-8?q?1748547151981524938?= Add a new DRM HDMI bridge driver for Candence MHDP used in i.MX8MQ SOC. MHDP IP could support HDMI or DisplayPort standards according embedded Firmware running in the uCPU. For iMX8MQ SOC, the HDMI FW was loaded and activated by SOC ROM code. Bootload binary included HDMI FW was required for the driver. Signed-off-by: Sandor Yu --- drivers/gpu/drm/bridge/cadence/Kconfig | 12 + .../gpu/drm/bridge/cadence/cdns-hdmi-core.c | 1038 +++++++++++++++++ 2 files changed, 1050 insertions(+) create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-hdmi-core.c diff --git a/drivers/gpu/drm/bridge/cadence/Kconfig b/drivers/gpu/drm/bridge/cadence/Kconfig index e79ae1af3765..377452d09992 100644 --- a/drivers/gpu/drm/bridge/cadence/Kconfig +++ b/drivers/gpu/drm/bridge/cadence/Kconfig @@ -26,6 +26,18 @@ config DRM_CDNS_MHDP8546_J721E clock and data muxes. endif +config DRM_CDNS_HDMI + tristate "Cadence HDMI DRM driver" + select DRM_KMS_HELPER + select DRM_PANEL_BRIDGE + select DRM_DISPLAY_HELPER + select DRM_CDNS_AUDIO + depends on OF + help + Support Cadence MHDP HDMI driver. + Cadence MHDP Controller support one or more protocols, + HDMI firmware is required for this driver. + config DRM_CDNS_DP tristate "Cadence DP DRM driver" select DRM_KMS_HELPER diff --git a/drivers/gpu/drm/bridge/cadence/cdns-hdmi-core.c b/drivers/gpu/drm/bridge/cadence/cdns-hdmi-core.c new file mode 100644 index 000000000000..b392aac015bd --- /dev/null +++ b/drivers/gpu/drm/bridge/cadence/cdns-hdmi-core.c @@ -0,0 +1,1038 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Cadence High-Definition Multimedia Interface (HDMI) driver + * + * Copyright (C) 2019-2022 NXP Semiconductor, Inc. + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cdns-mhdp-common.h" + +void cdns_mhdp_infoframe_set(struct cdns_mhdp_device *mhdp, + u8 entry_id, u8 packet_len, u8 *packet, u8 packet_type) +{ + u32 *packet32, len32; + u32 val, i; + + /* invalidate entry */ + val = F_ACTIVE_IDLE_TYPE(1) | F_PKT_ALLOC_ADDRESS(entry_id); + writel(val, mhdp->regs + SOURCE_PIF_PKT_ALLOC_REG); + writel(F_PKT_ALLOC_WR_EN(1), mhdp->regs + SOURCE_PIF_PKT_ALLOC_WR_EN); + + /* flush fifo 1 */ + writel(F_FIFO1_FLUSH(1), mhdp->regs + SOURCE_PIF_FIFO1_FLUSH); + + /* write packet into memory */ + packet32 = (u32 *)packet; + len32 = packet_len / 4; + for (i = 0; i < len32; i++) + writel(F_DATA_WR(packet32[i]), mhdp->regs + SOURCE_PIF_DATA_WR); + + /* write entry id */ + writel(F_WR_ADDR(entry_id), mhdp->regs + SOURCE_PIF_WR_ADDR); + + /* write request */ + writel(F_HOST_WR(1), mhdp->regs + SOURCE_PIF_WR_REQ); + + /* update entry */ + val = F_ACTIVE_IDLE_TYPE(1) | F_TYPE_VALID(1) | + F_PACKET_TYPE(packet_type) | F_PKT_ALLOC_ADDRESS(entry_id); + writel(val, mhdp->regs + SOURCE_PIF_PKT_ALLOC_REG); + + writel(F_PKT_ALLOC_WR_EN(1), mhdp->regs + SOURCE_PIF_PKT_ALLOC_WR_EN); +} + +static int cdns_hdmi_get_edid_block(void *data, u8 *edid, + u32 block, size_t length) +{ + struct cdns_mhdp_device *mhdp = data; + u8 msg[2], reg[5], i; + int ret; + + mutex_lock(&mhdp->mbox_mutex); + + for (i = 0; i < 4; i++) { + msg[0] = block / 2; + msg[1] = block % 2; + + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_HDMI_TX, HDMI_TX_EDID, + sizeof(msg), msg); + if (ret) + continue; + + ret = cdns_mhdp_mailbox_recv_header(mhdp, MB_MODULE_ID_HDMI_TX, + HDMI_TX_EDID, sizeof(reg) + length); + if (ret) + continue; + + ret = cdns_mhdp_mailbox_recv_data(mhdp, reg, sizeof(reg)); + if (ret) + continue; + + ret = cdns_mhdp_mailbox_recv_data(mhdp, edid, length); + if (ret) + continue; + + if ((reg[3] << 8 | reg[4]) == length) + break; + } + + mutex_unlock(&mhdp->mbox_mutex); + + if (ret) + DRM_ERROR("get block[%d] edid failed: %d\n", block, ret); + return ret; +} + +int cdns_hdmi_scdc_read(struct cdns_mhdp_device *mhdp, u8 addr, u8 *data) +{ + u8 msg[4], reg[6]; + int ret; + + msg[0] = 0x54; + msg[1] = addr; + msg[2] = 0; + msg[3] = 1; + + mutex_lock(&mhdp->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_HDMI_TX, HDMI_TX_READ, + sizeof(msg), msg); + if (ret) + goto err_scdc_read; + + ret = cdns_mhdp_mailbox_recv_header(mhdp, MB_MODULE_ID_HDMI_TX, + HDMI_TX_READ, sizeof(reg)); + if (ret) + goto err_scdc_read; + + ret = cdns_mhdp_mailbox_recv_data(mhdp, reg, sizeof(reg)); + if (ret) + goto err_scdc_read; + + *data = reg[5]; + +err_scdc_read: + + mutex_unlock(&mhdp->mbox_mutex); + + if (ret) + DRM_ERROR("scdc read failed: %d\n", ret); + return ret; +} + +int cdns_hdmi_scdc_write(struct cdns_mhdp_device *mhdp, u8 addr, u8 value) +{ + u8 msg[5], reg[5]; + int ret; + + msg[0] = 0x54; + msg[1] = addr; + msg[2] = 0; + msg[3] = 1; + msg[4] = value; + + mutex_lock(&mhdp->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_HDMI_TX, HDMI_TX_WRITE, + sizeof(msg), msg); + if (ret) + goto err_scdc_write; + + ret = cdns_mhdp_mailbox_recv_header(mhdp, MB_MODULE_ID_HDMI_TX, + HDMI_TX_WRITE, sizeof(reg)); + if (ret) + goto err_scdc_write; + + ret = cdns_mhdp_mailbox_recv_data(mhdp, reg, sizeof(reg)); + if (ret) + goto err_scdc_write; + + if (reg[0] != 0) + ret = -EINVAL; + +err_scdc_write: + + mutex_unlock(&mhdp->mbox_mutex); + + if (ret) + DRM_ERROR("scdc write failed: %d\n", ret); + return ret; +} + +int cdns_hdmi_ctrl_init(struct cdns_mhdp_device *mhdp, + int protocol, u32 char_rate) +{ + u32 reg0; + u32 reg1; + u32 val; + int ret; + + /* Set PHY to HDMI data */ + ret = cdns_mhdp_reg_write(mhdp, PHY_DATA_SEL, F_SOURCE_PHY_MHDP_SEL(1)); + if (ret < 0) + return ret; + + ret = cdns_mhdp_reg_write(mhdp, HDTX_HPD, + F_HPD_VALID_WIDTH(4) | F_HPD_GLITCH_WIDTH(0)); + if (ret < 0) + return ret; + + /* open CARS */ + ret = cdns_mhdp_reg_write(mhdp, SOURCE_PHY_CAR, 0xF); + if (ret < 0) + return ret; + ret = cdns_mhdp_reg_write(mhdp, SOURCE_HDTX_CAR, 0xFF); + if (ret < 0) + return ret; + ret = cdns_mhdp_reg_write(mhdp, SOURCE_PKT_CAR, 0xF); + if (ret < 0) + return ret; + ret = cdns_mhdp_reg_write(mhdp, SOURCE_AIF_CAR, 0xF); + if (ret < 0) + return ret; + ret = cdns_mhdp_reg_write(mhdp, SOURCE_CIPHER_CAR, 0xF); + if (ret < 0) + return ret; + ret = cdns_mhdp_reg_write(mhdp, SOURCE_CRYPTO_CAR, 0xF); + if (ret < 0) + return ret; + ret = cdns_mhdp_reg_write(mhdp, SOURCE_CEC_CAR, 3); + if (ret < 0) + return ret; + + reg0 = reg1 = 0x7c1f; + if (protocol == MODE_HDMI_2_0 && char_rate >= 340000) { + reg0 = 0; + reg1 = 0xFFFFF; + } + ret = cdns_mhdp_reg_write(mhdp, HDTX_CLOCK_REG_0, reg0); + if (ret < 0) + return ret; + ret = cdns_mhdp_reg_write(mhdp, HDTX_CLOCK_REG_1, reg1); + if (ret < 0) + return ret; + + /* set hdmi mode and preemble mode data enable */ + val = F_HDMI_MODE(protocol) | F_HDMI2_PREAMBLE_EN(1) | F_DATA_EN(1) | + F_HDMI2_CTRL_IL_MODE(1) | F_BCH_EN(1) | F_PIC_3D(0XF); + ret = cdns_mhdp_reg_write(mhdp, HDTX_CONTROLLER, val); + + return ret; +} + +int cdns_hdmi_mode_config(struct cdns_mhdp_device *mhdp, + struct drm_display_mode *mode, + struct video_info *video_info) +{ + int ret; + u32 val; + u32 vsync_lines = mode->vsync_end - mode->vsync_start; + u32 eof_lines = mode->vsync_start - mode->vdisplay; + u32 sof_lines = mode->vtotal - mode->vsync_end; + u32 hblank = mode->htotal - mode->hdisplay; + u32 hactive = mode->hdisplay; + u32 vblank = mode->vtotal - mode->vdisplay; + u32 vactive = mode->vdisplay; + u32 hfront = mode->hsync_start - mode->hdisplay; + u32 hback = mode->htotal - mode->hsync_end; + u32 vfront = eof_lines; + u32 hsync = hblank - hfront - hback; + u32 vsync = vsync_lines; + u32 vback = sof_lines; + u32 v_h_polarity = ((mode->flags & DRM_MODE_FLAG_NHSYNC) ? 0 : 1) + + ((mode->flags & DRM_MODE_FLAG_NVSYNC) ? 0 : 2); + + ret = cdns_mhdp_reg_write(mhdp, SCHEDULER_H_SIZE, (hactive << 16) + hblank); + if (ret < 0) + return ret; + + ret = cdns_mhdp_reg_write(mhdp, SCHEDULER_V_SIZE, (vactive << 16) + vblank); + if (ret < 0) + return ret; + + ret = cdns_mhdp_reg_write(mhdp, HDTX_SIGNAL_FRONT_WIDTH, (vfront << 16) + hfront); + if (ret < 0) + return ret; + + ret = cdns_mhdp_reg_write(mhdp, HDTX_SIGNAL_SYNC_WIDTH, (vsync << 16) + hsync); + if (ret < 0) + return ret; + + ret = cdns_mhdp_reg_write(mhdp, HDTX_SIGNAL_BACK_WIDTH, (vback << 16) + hback); + if (ret < 0) + return ret; + + ret = cdns_mhdp_reg_write(mhdp, HSYNC2VSYNC_POL_CTRL, v_h_polarity); + if (ret < 0) + return ret; + + /* Reset Data Enable */ + cdns_mhdp_reg_read(mhdp, HDTX_CONTROLLER, &val); + val &= ~F_DATA_EN(1); + ret = cdns_mhdp_reg_write(mhdp, HDTX_CONTROLLER, val); + if (ret < 0) + return ret; + + /* Set bpc */ + val &= ~F_VIF_DATA_WIDTH(3); + switch (video_info->bpc) { + case 10: + val |= F_VIF_DATA_WIDTH(1); + break; + case 12: + val |= F_VIF_DATA_WIDTH(2); + break; + case 16: + val |= F_VIF_DATA_WIDTH(3); + break; + case 8: + default: + val |= F_VIF_DATA_WIDTH(0); + break; + } + + /* select color encoding */ + val &= ~F_HDMI_ENCODING(3); + switch (video_info->color_fmt) { + case DRM_COLOR_FORMAT_YCBCR444: + val |= F_HDMI_ENCODING(2); + break; + case DRM_COLOR_FORMAT_YCBCR422: + val |= F_HDMI_ENCODING(1); + break; + case DRM_COLOR_FORMAT_YCBCR420: + val |= F_HDMI_ENCODING(3); + break; + case DRM_COLOR_FORMAT_RGB444: + default: + val |= F_HDMI_ENCODING(0); + break; + } + + ret = cdns_mhdp_reg_write(mhdp, HDTX_CONTROLLER, val); + if (ret < 0) + return ret; + + /* set data enable */ + val |= F_DATA_EN(1); + ret = cdns_mhdp_reg_write(mhdp, HDTX_CONTROLLER, val); + + return ret; +} + +int cdns_hdmi_disable_gcp(struct cdns_mhdp_device *mhdp) +{ + u32 val; + + cdns_mhdp_reg_read(mhdp, HDTX_CONTROLLER, &val); + val &= ~F_GCP_EN(1); + + return cdns_mhdp_reg_write(mhdp, HDTX_CONTROLLER, val); +} + +int cdns_hdmi_enable_gcp(struct cdns_mhdp_device *mhdp) +{ + u32 val; + + cdns_mhdp_reg_read(mhdp, HDTX_CONTROLLER, &val); + val |= F_GCP_EN(1); + + return cdns_mhdp_reg_write(mhdp, HDTX_CONTROLLER, val); +} + +static void hdmi_sink_config(struct cdns_mhdp_device *mhdp) +{ + struct drm_scdc *scdc = &mhdp->curr_conn->display_info.hdmi.scdc; + u8 buff = 0; + + /* Default work in HDMI1.4 */ + mhdp->hdmi.hdmi_type = MODE_HDMI_1_4; + + /* check sink support SCDC or not */ + if (scdc->supported != true) { + DRM_INFO("Sink Not Support SCDC\n"); + return; + } + + if (mhdp->hdmi.char_rate > 340000) { + /* + * TMDS Character Rate above 340MHz should working in HDMI2.0 + * Enable scrambling and TMDS_Bit_Clock_Ratio + */ + buff = SCDC_TMDS_BIT_CLOCK_RATIO_BY_40 | SCDC_SCRAMBLING_ENABLE; + mhdp->hdmi.hdmi_type = MODE_HDMI_2_0; + } else if (scdc->scrambling.low_rates) { + /* + * Enable scrambling and HDMI2.0 when scrambling capability of sink + * be indicated in the HF-VSDB LTE_340Mcsc_scramble bit + */ + buff = SCDC_SCRAMBLING_ENABLE; + mhdp->hdmi.hdmi_type = MODE_HDMI_2_0; + } + + /* TMDS config */ + cdns_hdmi_scdc_write(mhdp, SCDC_TMDS_CONFIG, buff); +} + +static void hdmi_lanes_config(struct cdns_mhdp_device *mhdp) +{ + u32 lane_mapping = mhdp->plat_data->lane_mapping; + /* Line swapping */ + cdns_mhdp_reg_write(mhdp, LANES_CONFIG, 0x00400000 | lane_mapping); +} + +int cdns_mhdp_hdmi_read_hpd(struct cdns_mhdp_device *mhdp) +{ + u8 status; + int ret; + + mutex_lock(&mhdp->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_HDMI_TX, HDMI_TX_HPD_STATUS, + 0, NULL); + if (ret) + goto err_get_hpd; + + ret = cdns_mhdp_mailbox_recv_header(mhdp, MB_MODULE_ID_HDMI_TX, + HDMI_TX_HPD_STATUS, sizeof(status)); + if (ret) + goto err_get_hpd; + + ret = cdns_mhdp_mailbox_recv_data(mhdp, &status, sizeof(status)); + if (ret) + goto err_get_hpd; + + mutex_unlock(&mhdp->mbox_mutex); + return status; + +err_get_hpd: + mutex_unlock(&mhdp->mbox_mutex); + DRM_ERROR("read hpd failed: %d\n", ret); + return ret; +} + +static int hdmi_avi_info_set(struct cdns_mhdp_device *mhdp, + struct drm_display_mode *mode) +{ + struct hdmi_avi_infoframe frame; + int format = mhdp->video_info.color_fmt; + struct drm_connector_state *conn_state = mhdp->curr_conn->state; + struct drm_display_mode *adj_mode; + enum hdmi_quantization_range qr; + u8 buf[32]; + int ret; + + /* Initialise info frame from DRM mode */ + drm_hdmi_avi_infoframe_from_display_mode(&frame, + mhdp->curr_conn, mode); + + switch (format) { + case DRM_COLOR_FORMAT_YCBCR444: + frame.colorspace = HDMI_COLORSPACE_YUV444; + break; + case DRM_COLOR_FORMAT_YCBCR422: + frame.colorspace = HDMI_COLORSPACE_YUV422; + break; + case DRM_COLOR_FORMAT_YCBCR420: + frame.colorspace = HDMI_COLORSPACE_YUV420; + break; + default: + frame.colorspace = HDMI_COLORSPACE_RGB; + break; + } + + drm_hdmi_avi_infoframe_colorimetry(&frame, conn_state); + + adj_mode = &mhdp->bridge.encoder->crtc->state->adjusted_mode; + + qr = drm_default_rgb_quant_range(adj_mode); + + drm_hdmi_avi_infoframe_quant_range(&frame, mhdp->curr_conn, + adj_mode, qr); + + ret = hdmi_avi_infoframe_check(&frame); + if (WARN_ON(ret)) + return -EINVAL; + + ret = hdmi_avi_infoframe_pack(&frame, buf + 1, sizeof(buf) - 1); + if (ret < 0) { + DRM_ERROR("failed to pack AVI infoframe: %d\n", ret); + return -1; + } + + buf[0] = 0; + cdns_mhdp_infoframe_set(mhdp, 0, sizeof(buf), buf, HDMI_INFOFRAME_TYPE_AVI); + + return 0; +} + +static void hdmi_vendor_info_set(struct cdns_mhdp_device *mhdp, + struct drm_display_mode *mode) +{ + struct hdmi_vendor_infoframe frame; + u8 buf[32]; + int ret; + + /* Initialise vendor frame from DRM mode */ + ret = drm_hdmi_vendor_infoframe_from_display_mode(&frame, mhdp->curr_conn, mode); + if (ret < 0) { + DRM_INFO("No vendor infoframe\n"); + return; + } + + ret = hdmi_vendor_infoframe_pack(&frame, buf + 1, sizeof(buf) - 1); + if (ret < 0) { + DRM_WARN("Unable to pack vendor infoframe: %d\n", ret); + return; + } + + buf[0] = 0; + cdns_mhdp_infoframe_set(mhdp, 3, sizeof(buf), buf, HDMI_INFOFRAME_TYPE_VENDOR); +} + +static void hdmi_drm_info_set(struct cdns_mhdp_device *mhdp) +{ + struct drm_connector_state *conn_state; + struct hdmi_drm_infoframe frame; + u8 buf[32]; + int ret; + + conn_state = mhdp->curr_conn->state; + + if (!conn_state->hdr_output_metadata) + return; + + ret = drm_hdmi_infoframe_set_hdr_metadata(&frame, conn_state); + if (ret < 0) { + DRM_DEBUG_KMS("couldn't set HDR metadata in infoframe\n"); + return; + } + + ret = hdmi_drm_infoframe_pack(&frame, buf + 1, sizeof(buf) - 1); + if (ret < 0) { + DRM_DEBUG_KMS("couldn't pack HDR infoframe\n"); + return; + } + + buf[0] = 0; + cdns_mhdp_infoframe_set(mhdp, 3, sizeof(buf), buf, HDMI_INFOFRAME_TYPE_DRM); +} + +static int hdmi_phy_colorspace(int color_fmt) +{ + int color_space; + + switch (color_fmt) { + case DRM_COLOR_FORMAT_YCBCR444: + color_space = HDMI_PHY_COLORSPACE_YUV444; + break; + case DRM_COLOR_FORMAT_YCBCR422: + color_space = HDMI_PHY_COLORSPACE_YUV422; + break; + case DRM_COLOR_FORMAT_YCBCR420: + color_space = HDMI_PHY_COLORSPACE_YUV420; + break; + case DRM_COLOR_FORMAT_RGB444: + default: + color_space = HDMI_PHY_COLORSPACE_RGB; + break; + } + + return color_space; +} + +void cdns_hdmi_mode_set(struct cdns_mhdp_device *mhdp) +{ + struct drm_display_mode *mode = &mhdp->mode; + union phy_configure_opts phy_cfg; + int ret; + + /* video mode check */ + if (mode->clock == 0 || mode->hdisplay == 0 || mode->vdisplay == 0) + return; + + hdmi_lanes_config(mhdp); + + phy_cfg.hdmi.pixel_clk_rate = mode->clock; + phy_cfg.hdmi.bpc = mhdp->video_info.bpc; + phy_cfg.hdmi.color_space = hdmi_phy_colorspace(mhdp->video_info.color_fmt); + ret = phy_configure(mhdp->phy, &phy_cfg); + if (ret) { + dev_err(mhdp->dev, "%s: phy_configure() failed: %d\n", + __func__, ret); + return; + } + + hdmi_sink_config(mhdp); + + ret = cdns_hdmi_ctrl_init(mhdp, mhdp->hdmi.hdmi_type, mhdp->hdmi.char_rate); + if (ret < 0) { + DRM_ERROR("%s, ret = %d\n", __func__, ret); + return; + } + + /* Config GCP */ + if (mhdp->video_info.bpc == 8) + cdns_hdmi_disable_gcp(mhdp); + else + cdns_hdmi_enable_gcp(mhdp); + + ret = hdmi_avi_info_set(mhdp, mode); + if (ret < 0) { + DRM_ERROR("%s ret = %d\n", __func__, ret); + return; + } + + /* vendor info frame is enabled only for HDMI1.4 4K mode */ + hdmi_vendor_info_set(mhdp, mode); + + hdmi_drm_info_set(mhdp); + + ret = cdns_hdmi_mode_config(mhdp, mode, &mhdp->video_info); + if (ret < 0) { + DRM_ERROR("CDN_API_HDMITX_SetVic_blocking ret = %d\n", ret); + return; + } +} +static enum drm_connector_status +cdns_hdmi_detect(struct cdns_mhdp_device *mhdp) +{ + u8 hpd = 0xf; + + hpd = cdns_mhdp_hdmi_read_hpd(mhdp); + if (hpd == 1) + return connector_status_connected; + else if (hpd == 0) + return connector_status_disconnected; + + DRM_INFO("Unknown cable status, hdp=%u\n", hpd); + return connector_status_unknown; +} + +static enum drm_connector_status +cdns_hdmi_bridge_detect(struct drm_bridge *bridge) +{ + struct cdns_mhdp_device *mhdp = bridge->driver_private; + + return cdns_hdmi_detect(mhdp); +} + +static int cdns_hdmi_connector_get_modes(struct drm_connector *connector) +{ + struct cdns_mhdp_device *mhdp = + container_of(connector, struct cdns_mhdp_device, connector); + int num_modes = 0; + struct edid *edid; + + edid = drm_do_get_edid(connector, + cdns_hdmi_get_edid_block, mhdp); + if (edid) { + dev_info(mhdp->dev, "%x,%x,%x,%x,%x,%x,%x,%x\n", + edid->header[0], edid->header[1], + edid->header[2], edid->header[3], + edid->header[4], edid->header[5], + edid->header[6], edid->header[7]); + drm_connector_update_edid_property(connector, edid); + num_modes = drm_add_edid_modes(connector, edid); + kfree(edid); + } + + if (num_modes == 0) + DRM_ERROR("Invalid edid\n"); + return num_modes; +} + +static bool blob_equal(const struct drm_property_blob *a, + const struct drm_property_blob *b) +{ + if (a && b) + return a->length == b->length && + !memcmp(a->data, b->data, a->length); + + return !a == !b; +} + +static int cdns_hdmi_connector_atomic_check(struct drm_connector *connector, + struct drm_atomic_state *state) +{ + struct drm_connector_state *new_con_state = + drm_atomic_get_new_connector_state(state, connector); + struct drm_connector_state *old_con_state = + drm_atomic_get_old_connector_state(state, connector); + struct drm_crtc *crtc = new_con_state->crtc; + struct drm_crtc_state *new_crtc_state; + + if (!blob_equal(new_con_state->hdr_output_metadata, + old_con_state->hdr_output_metadata) || + new_con_state->colorspace != old_con_state->colorspace) { + new_crtc_state = drm_atomic_get_crtc_state(state, crtc); + if (IS_ERR(new_crtc_state)) + return PTR_ERR(new_crtc_state); + + new_crtc_state->mode_changed = + !new_con_state->hdr_output_metadata || + !old_con_state->hdr_output_metadata || + new_con_state->colorspace != old_con_state->colorspace; + } + + return 0; +} + +static const struct drm_connector_funcs cdns_hdmi_connector_funcs = { + .fill_modes = drm_helper_probe_single_connector_modes, + .destroy = drm_connector_cleanup, + .reset = drm_atomic_helper_connector_reset, + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, +}; + +static const struct drm_connector_helper_funcs cdns_hdmi_connector_helper_funcs = { + .get_modes = cdns_hdmi_connector_get_modes, + .atomic_check = cdns_hdmi_connector_atomic_check, +}; + +static int cdns_hdmi_bridge_attach(struct drm_bridge *bridge, + enum drm_bridge_attach_flags flags) +{ + struct cdns_mhdp_device *mhdp = bridge->driver_private; + struct drm_mode_config *config = &bridge->dev->mode_config; + struct drm_encoder *encoder = bridge->encoder; + struct drm_connector *connector = &mhdp->connector; + + if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) { + connector->interlace_allowed = 0; + connector->polled = DRM_CONNECTOR_POLL_HPD; + + drm_connector_helper_add(connector, &cdns_hdmi_connector_helper_funcs); + + drm_connector_init(bridge->dev, connector, &cdns_hdmi_connector_funcs, + DRM_MODE_CONNECTOR_HDMIA); + + drm_object_attach_property(&connector->base, + config->hdr_output_metadata_property, 0); + + if (!drm_mode_create_hdmi_colorspace_property(connector)) + drm_object_attach_property(&connector->base, + connector->colorspace_property, 0); + + drm_connector_attach_encoder(connector, encoder); + } + + return 0; +} + +static enum drm_mode_status +cdns_hdmi_bridge_mode_valid(struct drm_bridge *bridge, + const struct drm_display_info *info, + const struct drm_display_mode *mode) +{ + struct cdns_mhdp_device *mhdp = bridge->driver_private; + enum drm_mode_status mode_status = MODE_OK; + union phy_configure_opts phy_cfg; + int ret; + + /* We don't support double-clocked and Interlaced modes */ + if (mode->flags & DRM_MODE_FLAG_DBLCLK || + mode->flags & DRM_MODE_FLAG_INTERLACE) + return MODE_BAD; + + /* MAX support pixel clock rate 594MHz */ + if (mode->clock > 594000) + return MODE_CLOCK_HIGH; + + /* 4096x2160 is not supported */ + if (mode->hdisplay > 3840 || mode->vdisplay > 2160) + return MODE_BAD_HVALUE; + + /* Check modes supported by PHY */ + phy_cfg.hdmi.pixel_clk_rate = mode->clock; + ret = phy_validate(mhdp->phy, PHY_MODE_HDMI, 0, &phy_cfg); + if (ret < 0) + return MODE_CLOCK_RANGE; + + return mode_status; +} + +bool cdns_hdmi_bridge_mode_fixup(struct drm_bridge *bridge, + const struct drm_display_mode *mode, + struct drm_display_mode *adjusted_mode) +{ + struct cdns_mhdp_device *mhdp = bridge->driver_private; + struct video_info *video = &mhdp->video_info; + + video->bpc = 8; + video->color_fmt = DRM_COLOR_FORMAT_RGB444; + + return true; +} + +static struct edid *cdns_hdmi_bridge_get_edid(struct drm_bridge *bridge, + struct drm_connector *connector) +{ + struct cdns_mhdp_device *mhdp = bridge->driver_private; + + return drm_do_get_edid(connector, cdns_hdmi_get_edid_block, mhdp); +} + +static void cdns_hdmi_bridge_atomic_disable(struct drm_bridge *bridge, + struct drm_bridge_state *old_state) +{ + struct cdns_mhdp_device *mhdp = bridge->driver_private; + + mhdp->curr_conn = NULL; + + mutex_lock(&mhdp->lock); + phy_power_off(mhdp->phy); + mutex_unlock(&mhdp->lock); +} + +static void cdns_hdmi_bridge_atomic_enable(struct drm_bridge *bridge, + struct drm_bridge_state *old_state) +{ + struct cdns_mhdp_device *mhdp = bridge->driver_private; + struct drm_atomic_state *state = old_state->base.state; + struct drm_connector *connector; + struct video_info *video = &mhdp->video_info; + struct drm_crtc_state *crtc_state; + struct drm_connector_state *conn_state; + const struct drm_display_mode *mode; + + connector = drm_atomic_get_new_connector_for_encoder(state, + bridge->encoder); + if (WARN_ON(!connector)) + return; + + mhdp->curr_conn = connector; + + conn_state = drm_atomic_get_new_connector_state(state, connector); + if (WARN_ON(!conn_state)) + return; + + crtc_state = drm_atomic_get_new_crtc_state(state, conn_state->crtc); + if (WARN_ON(!crtc_state)) + return; + + mode = &crtc_state->adjusted_mode; + DRM_INFO("Mode: %dx%dp%d\n", mode->hdisplay, mode->vdisplay, mode->clock); + memcpy(&mhdp->mode, mode, sizeof(struct drm_display_mode)); + + video->v_sync_polarity = !!(mode->flags & DRM_MODE_FLAG_NVSYNC); + video->h_sync_polarity = !!(mode->flags & DRM_MODE_FLAG_NHSYNC); + + mutex_lock(&mhdp->lock); + cdns_hdmi_mode_set(mhdp); + mutex_unlock(&mhdp->lock); +} + +static const struct drm_bridge_funcs cdns_hdmi_bridge_funcs = { + .attach = cdns_hdmi_bridge_attach, + .detect = cdns_hdmi_bridge_detect, + .get_edid = cdns_hdmi_bridge_get_edid, + .mode_valid = cdns_hdmi_bridge_mode_valid, + .mode_fixup = cdns_hdmi_bridge_mode_fixup, + .atomic_enable = cdns_hdmi_bridge_atomic_enable, + .atomic_disable = cdns_hdmi_bridge_atomic_disable, + .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, + .atomic_reset = drm_atomic_helper_bridge_reset, +}; + +static void hotplug_work_func(struct work_struct *work) +{ + struct cdns_mhdp_device *mhdp = container_of(work, + struct cdns_mhdp_device, hotplug_work.work); + enum drm_connector_status status = cdns_hdmi_detect(mhdp); + + drm_bridge_hpd_notify(&mhdp->bridge, status); + + if (status == connector_status_connected) { + DRM_INFO("HDMI Cable Plug In\n"); + enable_irq(mhdp->irq[IRQ_OUT]); + } else if (status == connector_status_disconnected) { + /* Cable Disconnedted */ + DRM_INFO("HDMI Cable Plug Out\n"); + enable_irq(mhdp->irq[IRQ_IN]); + } +} + +static irqreturn_t cdns_hdmi_irq_thread(int irq, void *data) +{ + struct cdns_mhdp_device *mhdp = data; + + disable_irq_nosync(irq); + + mod_delayed_work(system_wq, &mhdp->hotplug_work, + msecs_to_jiffies(HOTPLUG_DEBOUNCE_MS)); + + return IRQ_HANDLED; +} + +static int cdns_mhdp_imx_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct cdns_mhdp_device *mhdp; + struct platform_device_info pdevinfo; + struct resource *res; + u32 reg; + int ret; + + mhdp = devm_kzalloc(dev, sizeof(*mhdp), GFP_KERNEL); + if (!mhdp) + return -ENOMEM; + + mutex_init(&mhdp->lock); + mutex_init(&mhdp->mbox_mutex); + + INIT_DELAYED_WORK(&mhdp->hotplug_work, hotplug_work_func); + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -ENODEV; + mhdp->regs = devm_ioremap(dev, res->start, resource_size(res)); + if (IS_ERR(mhdp->regs)) + return PTR_ERR(mhdp->regs); + + mhdp->phy = devm_of_phy_get_by_index(dev, pdev->dev.of_node, 0); + if (IS_ERR(mhdp->phy)) { + dev_err(dev, "no PHY configured\n"); + return PTR_ERR(mhdp->phy); + } + + mhdp->irq[IRQ_IN] = platform_get_irq_byname(pdev, "plug_in"); + if (mhdp->irq[IRQ_IN] < 0) { + dev_info(dev, "No plug_in irq number\n"); + return -EPROBE_DEFER; + } + + mhdp->irq[IRQ_OUT] = platform_get_irq_byname(pdev, "plug_out"); + if (mhdp->irq[IRQ_OUT] < 0) { + dev_info(dev, "No plug_out irq number\n"); + return -EPROBE_DEFER; + } + + /* + * Wait for the KEEP_ALIVE "message" on the first 8 bits. + * Updated each sched "tick" (~2ms) + */ + ret = readl_poll_timeout(mhdp->regs + KEEP_ALIVE, reg, + reg & CDNS_KEEP_ALIVE_MASK, 500, + CDNS_KEEP_ALIVE_TIMEOUT); + if (ret) { + dev_err(mhdp->dev, + "device didn't give any life sign: reg %d\n", reg); + return ret; + } + + ret = phy_init(mhdp->phy); + if (ret) { + dev_err(mhdp->dev, "Failed to initialize PHY: %d\n", ret); + return -ENODEV; + } + + /* Enable Hotplug Detect thread */ + irq_set_status_flags(mhdp->irq[IRQ_IN], IRQ_NOAUTOEN); + ret = devm_request_threaded_irq(dev, mhdp->irq[IRQ_IN], + NULL, cdns_hdmi_irq_thread, + IRQF_ONESHOT, dev_name(dev), + mhdp); + if (ret < 0) { + dev_err(dev, "can't claim irq %d\n", + mhdp->irq[IRQ_IN]); + return -EINVAL; + } + + irq_set_status_flags(mhdp->irq[IRQ_OUT], IRQ_NOAUTOEN); + ret = devm_request_threaded_irq(dev, mhdp->irq[IRQ_OUT], + NULL, cdns_hdmi_irq_thread, + IRQF_ONESHOT, dev_name(dev), + mhdp); + if (ret < 0) { + dev_err(dev, "can't claim irq %d\n", + mhdp->irq[IRQ_OUT]); + return -EINVAL; + } + + mhdp->dev = dev; + + if (cdns_mhdp_hdmi_read_hpd(mhdp)) + enable_irq(mhdp->irq[IRQ_OUT]); + else + enable_irq(mhdp->irq[IRQ_IN]); + + mhdp->bridge.driver_private = mhdp; + mhdp->bridge.funcs = &cdns_hdmi_bridge_funcs; + mhdp->bridge.of_node = dev->of_node; + mhdp->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID | + DRM_BRIDGE_OP_HPD; + mhdp->bridge.type = DRM_MODE_CONNECTOR_HDMIA; + drm_bridge_add(&mhdp->bridge); + + memset(&pdevinfo, 0, sizeof(pdevinfo)); + pdevinfo.parent = dev; + pdevinfo.id = PLATFORM_DEVID_AUTO; + + dev_set_drvdata(dev, mhdp); + mhdp->plat_data = of_device_get_match_data(dev); + + return 0; +} + +static int cdns_mhdp_imx_remove(struct platform_device *pdev) +{ + struct cdns_mhdp_device *mhdp = platform_get_drvdata(pdev); + int ret = 0; + + drm_bridge_remove(&mhdp->bridge); + + return ret; +} + +static struct cdns_plat_data imx8mq_hdmi_drv_data = { + .lane_mapping = 0xe4, +}; + +static const struct of_device_id cdns_mhdp_imx_dt_ids[] = { + { .compatible = "cdns,mhdp-imx8mq-hdmi", + .data = &imx8mq_hdmi_drv_data + }, + {}, +}; +MODULE_DEVICE_TABLE(of, cdns_mhdp_imx_dt_ids); + +static struct platform_driver cdns_mhdp_imx_platform_driver = { + .probe = cdns_mhdp_imx_probe, + .remove = cdns_mhdp_imx_remove, + .driver = { + .name = "cdns-mhdp-imx8mq-hdmi", + .of_match_table = cdns_mhdp_imx_dt_ids, + }, +}; + +module_platform_driver(cdns_mhdp_imx_platform_driver); + +MODULE_AUTHOR("Sandor Yu "); +MODULE_DESCRIPTION("Cadence HDMI transmitter driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:cdns-hdmi"); From patchwork Fri Nov 4 06:44:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandor Yu X-Patchwork-Id: 15394 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp211015wru; Thu, 3 Nov 2022 23:48:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6up/QT97yxoGJPLsdKou7x4HLaFLcOuDXXMOAjNzaNNP4xfSxzeYc+zlLDBZFCKgEDCv/E X-Received: by 2002:a05:6a00:80d:b0:56d:93d8:f42f with SMTP id m13-20020a056a00080d00b0056d93d8f42fmr22271878pfk.14.1667544522621; Thu, 03 Nov 2022 23:48:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1667544522; cv=pass; d=google.com; s=arc-20160816; b=axn5vD2UxbpVXkaLkuvGUqaNLMYK0bzNdSrZzmTH9QEO6/WNEWeOjTJ5cT3ynZj9rG /Is2nYMSweu9DyE2TsBtGmY9P/jzYRw34CF09q/vg1vV3Z8R0KTcyJjMVo/PCBAEcsfV a7wFej6b/BJu2kSHewPPeR1ib+JdOp8cJ+yvU0sID10n0wN4uR64yqpSsRKDZMSucIHl Hg1B1hFC7GZjdBjC28hIjHvzzqtCwBUCgJX7JRzl9Qne9Ckn05S49TvcfBzj6hQv3Vxm LeqgwYrKAJQv0TQa4SfvNq5hjYmGcxxHusZNjIWdWmzSapmigzSdui/GE9OZHA1a3Pmc 18zA== 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=HnD5Bm8F2xRhyp06cKg2xQtki948J1xHsDaYw24HADA=; b=T4h9h+ZWc5/Ka+CFyWjhiai53J97kQ7KMyOQzh9V0i2R7kGPzTxa2saiH7pebCEfXC VOft3G3wCo77wHAhvpKWoQ6NHfI2LAEF/zbB6qc54yuIA/4dOBrU5nIr51u6TS0mB4OB BuO3X7Uq/n7eK/Y6WUbIx31ihOO9NZauXwhVBEaJP1aea43etNp5nvkrFTq/dyhdhJOp IDe2ZPRTQRQKVqGpCDLYS2/yKlNmJxffjUnMhGCIAb94lALM5nA8XdjbEsTr6WfRmk2G zNdNWy5EhOazjG4neBBfW9BgFgmPG9iIxD4qGzirZ6r+0Xvbje/eL7+CY6aHUzws1/Hd 02GA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=RMdPNPmf; 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 az14-20020a17090b028e00b0020ad6d218cdsi2459659pjb.3.2022.11.03.23.48.29; Thu, 03 Nov 2022 23:48:42 -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=RMdPNPmf; 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 S231623AbiKDGr6 (ORCPT + 99 others); Fri, 4 Nov 2022 02:47:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231388AbiKDGrg (ORCPT ); Fri, 4 Nov 2022 02:47:36 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2061b.outbound.protection.outlook.com [IPv6:2a01:111:f400:7d00::61b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFF692B19C; Thu, 3 Nov 2022 23:47:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E1yTJ8//nf5CJo3t2VsIAAcS79aTdElhk15wWMGc0aG51NitdLBi8qL2TRRaf/Pk8jDD41QP/Fhc4YmVL31su3LdOaFnAraIeTqqNPjlwfNWsa8XNE/si0cS62TxLS0yzmJNZQhUPTCgULllluG+ql2bAFHFCeFJmfcIBGN3Lz34yMZ6ZDw9SiHKEMPEisZMgFXElRjIm4ikdbMU/elfyCnZAWYtKZQ1StuKaDPnYyLxq+kpF1ormcHHjHR2M1oWTVOfdPVIca/pt2o1U0tRVUa62cLVO8OQ9URwHLQ2vOyC+MvpR86QkicD/IIl64ghaHYfgNa5v0tMomSHaLAT8Q== 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=HnD5Bm8F2xRhyp06cKg2xQtki948J1xHsDaYw24HADA=; b=iwgy7yoJsAktya1W34Ly0i7iK097o5OIOVcmwSedyG/RerF2829yia4cZnRFCT8WNT+deXPWPmxo3NSwJhzO0Xgh65Bf7BCE81TTqmtehdeRH9xd7MipsEW/qH1Qhs17nrDEq694HCfyyveOymDSihpWqTetUOcl39N+9Q3YD5RM0qSOhGU+XFIXCWKprCZ88E6mo55F7a5Qf+0Z5aD/aDNx6Sdi1M46nCU9UMvOH1Xi7K+/Q8z3NhqSD68XX0bRhr/Zewlhm7pz9Wd/fXEfbCyMdzKnRqCUPLsPSfxJqAEj1V3SxZhp5EwIPOdOd7CTblKp2fUA+c1rpdctBoGyAg== 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=HnD5Bm8F2xRhyp06cKg2xQtki948J1xHsDaYw24HADA=; b=RMdPNPmfjEPlPZSc3J8RvjWuaV6Q+ivntraEOVtCiS4w2zl8BzSHXB/TOB9IX+iOFehHPAf7Y3pyFOG7py6lWngx3pci2UweO0RJs+K+mO/7QL8AtDDVc66iyhPisunx7pDbn+gmF9oIc/t2nHLnFJT1Wrg/6dIHY95ObjK3qkM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9448.eurprd04.prod.outlook.com (2603:10a6:102:2b1::21) by AM9PR04MB8081.eurprd04.prod.outlook.com (2603:10a6:20b:3e2::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.20; Fri, 4 Nov 2022 06:47:26 +0000 Received: from PAXPR04MB9448.eurprd04.prod.outlook.com ([fe80::88a0:57d8:2a57:3f4f]) by PAXPR04MB9448.eurprd04.prod.outlook.com ([fe80::88a0:57d8:2a57:3f4f%9]) with mapi id 15.20.5791.022; Fri, 4 Nov 2022 06:47:26 +0000 From: Sandor Yu To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, andrzej.hajda@intel.com, neil.armstrong@linaro.org, robert.foss@linaro.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, kishon@ti.com, vkoul@kernel.org Cc: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, linux-imx@nxp.com, tzimmermann@suse.de, lyude@redhat.com, Sandor.yu@nxp.com, javierm@redhat.com, ville.syrjala@linux.intel.com, sam@ravnborg.org, jani.nikula@intel.com, maxime@cerno.tech, penguin-kernel@I-love.SAKURA.ne.jp, p.yadav@ti.com, oliver.brown@nxp.com Subject: [v2 07/10] dts-bindings: phy: Add Cadence HDP-TX DP PHY bindings Date: Fri, 4 Nov 2022 14:44:57 +0800 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-ClientProxiedBy: SG2PR06CA0194.apcprd06.prod.outlook.com (2603:1096:4:1::26) To PAXPR04MB9448.eurprd04.prod.outlook.com (2603:10a6:102:2b1::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9448:EE_|AM9PR04MB8081:EE_ X-MS-Office365-Filtering-Correlation-Id: 308e741c-a486-4717-3905-08dabe306f0e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /5bkqY0PeMcoN9JxDtEMSAScRI90G1GFrbe0g3TsRXYK9ODIxrWyvZv0Isbb+Q3sSt8oiIp3ZrZCPdX1E2lEuabrpVv1/13DNC1YWnvULFIia1EE1gbw0DX4mYn3y6HT+aUSgi1ABse+IVAc2U8/DZpHMWeRZ7chnZThtaD+HD6e+nkx8zE9PXm05qz/IOxEb5Ak/oODH4GhqC372dH6q3W1OkjnbvOxEsT/yXkVCU6eI/J+PdxxE1Uy/pp7Ez5QC7HoqGVzl2dD7Xhg0mZod3zHHd34DaXA7+jRb3diPe3o9s0NuzXheWIJ5DsB69BDBm93FJOq2gCNPHtFfsvXKGK3LoYNYCALUIRBYzf52Vhq3k9j0thJkJb25f00CkVC3+4mtZnbq+i7O/2FXqI0xzJWVu+YHUays/qS+jXvF7JbbQ4EWKvAP8QP9NsWKYCJ6IiPsdzqQVNSfo0eWFaKzQp9qnAunJy6S2ELRFdshiUiom7cM1YiHA+nR/pu0fHA+m5HwpJ4+/ouLAlwiDinzxrKKYpcQp9UeNK3Pnr2husqNL7eiFZnlL9b0DzqEM/MMCgWGvSn7ScnUzVwEVLaE7223L9GT7vZoi+YU/j/Ge0Bt2/sojcwpD5WzYQSgNrQXSfNN1BgHdYptP+lnlH29RTwQ8/wMjkFrvMMJQ6OiBRvzR3Lnib3xFcyRY2VSAxGlrDPsKAZVWo8EB2jIh1Pgw7Q/42eEb2TeZYSS0JLucYnfN0CM9C3+ptY/ffAew54MULkJDjWVPJ7K6fUpg9gycBembECpLSJBVOFc7uJlt656h1qPuLv5bp2xf17PLW4VJR8GgeJTzQauV2D37hmWw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9448.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(376002)(39860400002)(366004)(136003)(396003)(451199015)(316002)(8676002)(38350700002)(7416002)(5660300002)(66556008)(66476007)(38100700002)(4326008)(66946007)(36756003)(8936002)(41300700001)(83380400001)(6666004)(921005)(186003)(2616005)(86362001)(6486002)(26005)(478600001)(6512007)(52116002)(6506007)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7JG0NUmGV0ZjYclPp0EBRSNKI5148YFa8mwNxRv43eX+EzHD3wO1CaugrHmvP2g7lo5LYzjLjEbzrBNy8DxgKQ7fSRfegDLY4xrXnq23wXsZH9o2Low48G5ykpOtUTgJGLmV/gcNH94LnNW186F+Pj68dZ889hgJvp5lw5Qp4KJXiWCW0AJihRxZuY1wnhjtpHKEQuEV93KRKcckG0IL+As9YRpK07sEXroOAujbj6ydJpD1LScnOclcuA93llf5ZlX7YqpRq/AjY2GCHHv8hRGDcaOTk+apZa6rT4u4610uAJUi67P3QmPfZwEDF8Q4hDHz4wl+WeTJzmm7qZpn8aBL4AVkgsV1fJmS5dFAr3rFE+9Nem8ccyQoqOQrXc+oXPtV4ARF/9j3qCJaoIfNh4nHbW2xxn9alWRlL0k4A8iNWkCVDOXZExV5hjwVUZPq7lCfrN7lFdxKu1pmzRsauJMQrbBI3Ma4LhItnc+kSQwMPfe/froj+Cr21kkCvyHh1zHTGkzyNZukHYKuRciBmK8rnVj+O7BL+xNa17qlPTMVfJnWDvOLP2VrTPIZTBpHEPZ1xaCwJ1ilkrnEUmtmhasxcOHO4eZdyb1bptLD4LP35kTHXJ9i8/CJr3/oqgVD1Cgaj25BeVHsHInxnEiy+UjH1c6vHHKiF3kw8PBTb5FeApf4X67xd0uJJcWu0VABgXV7eF5gVrywg88WQiM/CAGUv26iqNpXGWmvruSAH32UlwXoydPbbY3Xx79qoKW6IAgKvGjLdTl9N59BZLCcQ9szy1mvwy2lADSS7ig3CY6xXHkjRQnYlW2tsvzjH5muERaCo5vJTjXFtWeo+THkw9/GWNEphiX3CAceh4XXDLQk20WWbuxWarQiSSqlnWvQLoXV+CsNPumyjgSsH/9fO68N6eYxOFPAQ3/PIikwCveQrAzWsc928G1DK/1JRF+Ph3xuI6eFu1SnuuqVvnth/1lkwzo6tpDaICIXEV3elYvGnHin/6W+zAPSHZ8QQGfXqELpbthrB1LL8nC9DH06aqM9ADrAxKrPq5+GvERolrxYjBitU+QZ+NADSY9ZE9kTDnDHN2mgueB6aqsuBMxDXhIsfM21MgPn6wdr1tgKfBdw5mtszE8OEcS3sgkmzLwyduLtkzbnUnqqH5u/ksIrS1iSTmgwXr2KT/xP0/V4A95S20qMnhMIzqQkMPhvPSxQpfhGtC3NUYdN0RyWuD80CJ3vYCZcgbQBct1/SMZm5GkL5Jikw2VdS+tC8sdIJ6t5NrL85HQBYELxSIfg6ZtEWW0lTDr3EciMTIK7nVydS/C2EgdguxqkqNfF3tZEJqtaQZVGGCp/hbaUnNTqDb4rRESwX5yyRNTMeV08DyIHDuDJZBtOnlBkJHve0BoktwNGO+lXTwvIdeIvkxhW2+nBeX+cs2EN9YgzMJnDUJUV1XxnE62O7BCfAsHoJMht9kzT1sMcxX0SBi+/nKY9Un9FmWNNuOwS54TJ7v/Y/p1vtp7aRO2uWfvkOyuyiAPpOCeiAZ66CYIoFJ+XnAO6vgVMO0SBF3o9fee/JGjP9m3CgIZWIm6ZkB3kJQr9F6SjfMyp X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 308e741c-a486-4717-3905-08dabe306f0e X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9448.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2022 06:47:25.8975 (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: 6HPqI/QPJQWgSU1QfuCb+gci0l/Ht/uka5QjP2S1GvWApLLzvIrsqzv4M9Z1kFEPGb6EpfALeoV3zQV1A/yN0g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8081 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,T_SPF_PERMERROR autolearn=no 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?1748547165391630714?= X-GMAIL-MSGID: =?utf-8?q?1748547165391630714?= Add bindings for Cadence HDP-TX DisplayPort PHY. Signed-off-by: Sandor Yu --- .../bindings/phy/phy-cadence-hdptx-dp.yaml | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/phy-cadence-hdptx-dp.yaml diff --git a/Documentation/devicetree/bindings/phy/phy-cadence-hdptx-dp.yaml b/Documentation/devicetree/bindings/phy/phy-cadence-hdptx-dp.yaml new file mode 100644 index 000000000000..ab6f4e25c425 --- /dev/null +++ b/Documentation/devicetree/bindings/phy/phy-cadence-hdptx-dp.yaml @@ -0,0 +1,70 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/phy/phy-cadence-hdptx-dp.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Cadence HDP(HDMI/DisplayPort) TX PHY for DisplayPort protocol binding + +description: + This binding describes the Cadence HDP-TX PHY for DispalyPort protocol. + +maintainers: + - Sandor Yu + +properties: + compatible: + enum: + - cdns,hdptx-dp-phy + + reg: + description: + Offset of Cadence HDPTX APB configuration registers. + + clocks: + items: + description: + PHY reference clock. Must contain an entry in clock-names. + + clock-names: + items: + - const: refclk + + "#phy-cells": + const: 0 + + cdns,num-lanes: + description: + Number of lanes. + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [1, 2, 3, 4] + default: 4 + + cdns,max-bit-rate: + description: + Maximum DisplayPort link bit rate to use, in Mbps + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [2160, 2430, 2700, 3240, 4320, 5400] + default: 5400 + +required: + - compatible + - reg + - clocks + - clock-names + - "#phy-cells" + +additionalProperties: false + +examples: + - | + #include + dp_phy: dp_phy@32c00000 { + compatible = "cdns,hdptx-dp-phy"; + reg = <0x32c00000 0x100000>; + #phy-cells = <0>; + clocks = <&hdmi_phy_27m>; + clock-names = "refclk"; + cdns,num-lanes = <4>; + cdns,max-bit-rate = <5400>; + }; From patchwork Fri Nov 4 06:44:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sandor Yu X-Patchwork-Id: 15395 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp211093wru; Thu, 3 Nov 2022 23:48:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6s5DbF9LxYy7hMZIAWHS9oJ0d3QxpGoWEf+I34oJtJUHxfyfBD5QXhAiH6sk8RF67mvoqH X-Received: by 2002:a05:6a00:1504:b0:56d:1ee8:973e with SMTP id q4-20020a056a00150400b0056d1ee8973emr12375207pfu.30.1667544534809; Thu, 03 Nov 2022 23:48:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1667544534; cv=pass; d=google.com; s=arc-20160816; b=klrnacWAVjxS1H4M6N9YgomoG6rQXjabRXoWofnb86jzrdwtMFy+KVwRKDy5URIJbh 9yoOD/iEQDrvIam18WNXAfHvsYoIuPQCmdSYs0taVIhUuI1hLJm9ZP3T46eGw7w/7w0L JYvaw2UwMfcB8IUvO3c7Zjp2mA9tbtcA1j0X6qpvU+yScoZFQf3gIoijXDlGjx7DkKrc DRejaN4Ka0/ruIXQQVNlXL2nN3bHuiDxwjO0Ez2VDrSX+P4uZtMQ8ZyVSee4gI+EogbU JCENMXMIaXLrZGFg56sRIopEch9qwzKzK0ZZgbFiAaqNIOyXEnxPqiZo5GlK6MwNBfkn AnMA== 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=5CRpIgsQQkaH4obCqK4SnH8f9uaXFh2mJu+XXIdidw0=; b=hTkHbSjcdWcOcV+kBtpQtLhBsa0RWJRGmUArUrKAxGrtVELcQyf19LMlpXzofENJtF vNf+/ABIgHruobquvVwQGZfS6qVAj38NrzrCMh/tDPaZb41glrSDXM1AxZorTlY4S5MJ VuOlNtOfHxdEw0Jl5GscWm9psaAxVOMen7Guj/yZJvVlAPmFRZ2rsQjlpgOmvTLIndzj ph9aAIC898vooWcMSq+HvMJ1NSiYbsjCTUkrBTmFhInlUBqrJpjUtgzzpxEm0ksr8bv+ NCJgglY/hvQ+soPfv8Gfk84Lcoh0ffvrlvr+IM7ZqSD7I1XXzK5m1MvMek/GWo5VmBBM Lhmg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=MEpXmb9U; 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 k2-20020a056a00168200b00562b7ed6bc3si4006548pfc.373.2022.11.03.23.48.41; Thu, 03 Nov 2022 23:48:54 -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=MEpXmb9U; 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 S231431AbiKDGsN (ORCPT + 99 others); Fri, 4 Nov 2022 02:48:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231643AbiKDGrl (ORCPT ); Fri, 4 Nov 2022 02:47:41 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2055.outbound.protection.outlook.com [40.107.21.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 664F22AE04; Thu, 3 Nov 2022 23:47:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cCsoRoDVpnM0/Kahdt+00aD4vZRjtt/b+8tA6uDorWPA2J+q0aIpYbJsLAtMlkEkMmbfzBPz08kSYxw/L1EWtWk8bHxG8sNQ/hJ5dtyCkSVVKeHv0ILm/Q25ecg/PSK/aih7HXi5rmQtRoVE0WAOmDJCtnCAFOyZQfuagqXTh14O/BJ0Rs2/0wVd3hwees8g9usvTU1nwjdGU1Jnp3ksX6tTDphtmbdmsPNKy6HnNBx3xNXMnBT5N6KAZcDfLlmhd6gZj2vVSkNGfYULCte5xVvis8Nu1KhmnYaLpeHYrUCGZAWqJsVnAx7EQg1WOfM9R1gJRuy68Hj/fohPeHsLdA== 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=5CRpIgsQQkaH4obCqK4SnH8f9uaXFh2mJu+XXIdidw0=; b=HUxZaanZWmUxsVhc4DIbAbQxPaCv6KC6oyIrO1k5il7S5RQh3kuBcDbjAwbC2QISu4HzLXw0gLksFnzsccX3vEH6HTkMrlUyMywMzjKwUyqukqHw4tgndJ+uVw2swkgcvm0y47c09iiiBcorTuWCW2LnTz8vXDLEggH50Y5ZMU9N7+bhd5vRBlwaOBWWr0JwvRX4btigoQvSQ/Y1DsspNrtBTVZPl00LdgYIF2cAHUYS2k55xj3GRc0pJjFzi8GXKIvX2olHmMs94ycfFBS3orfOuuOP5lSSAij0yNNaHHoQucPlnfBc2srieVHOv6Dm/XXZcP37oLYYXqJlsx25ZA== 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=5CRpIgsQQkaH4obCqK4SnH8f9uaXFh2mJu+XXIdidw0=; b=MEpXmb9UBGlh1/iiYKHbuMqpxu8G9LSIJNvufiE8dxGQasnMy1DDpxbqgtZlIqroLyZba5Fvqe6fNiuimUN6zFmuVG+GsGArc85o8aOdFH94M7JPqXdK6Fpj0ae4kzOKAz/8FcHqYXgGbWP9UIbodqyXzr1/r8WLx3ThG9bRCFw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9448.eurprd04.prod.outlook.com (2603:10a6:102:2b1::21) by AM9PR04MB8081.eurprd04.prod.outlook.com (2603:10a6:20b:3e2::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.20; Fri, 4 Nov 2022 06:47:34 +0000 Received: from PAXPR04MB9448.eurprd04.prod.outlook.com ([fe80::88a0:57d8:2a57:3f4f]) by PAXPR04MB9448.eurprd04.prod.outlook.com ([fe80::88a0:57d8:2a57:3f4f%9]) with mapi id 15.20.5791.022; Fri, 4 Nov 2022 06:47:34 +0000 From: Sandor Yu To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, andrzej.hajda@intel.com, neil.armstrong@linaro.org, robert.foss@linaro.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, kishon@ti.com, vkoul@kernel.org Cc: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, linux-imx@nxp.com, tzimmermann@suse.de, lyude@redhat.com, Sandor.yu@nxp.com, javierm@redhat.com, ville.syrjala@linux.intel.com, sam@ravnborg.org, jani.nikula@intel.com, maxime@cerno.tech, penguin-kernel@I-love.SAKURA.ne.jp, p.yadav@ti.com, oliver.brown@nxp.com Subject: [v2 08/10] phy: cadence: Add driver for HDP-TX DisplyPort PHY Date: Fri, 4 Nov 2022 14:44:58 +0800 Message-Id: <57887610acc39330f1b15a1c6e20d9a82be52023.1667463263.git.Sandor.yu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-ClientProxiedBy: SG2PR06CA0194.apcprd06.prod.outlook.com (2603:1096:4:1::26) To PAXPR04MB9448.eurprd04.prod.outlook.com (2603:10a6:102:2b1::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9448:EE_|AM9PR04MB8081:EE_ X-MS-Office365-Filtering-Correlation-Id: f4b049d1-fc06-4013-57fc-08dabe3073db X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DPlQu9EJAAreEI0JEnK5ZfnMR26+i3k9uKKrdvRS98qo+mFtsVXBOk1nMPm+evtNRI17Ykc25M57Ur4P2gacMni2c8+C5M07wQOEk11SVsVqmmFIyD6M/RQzJplZvDeGPIBIKlzVNhcGiRB6jfsRmLRsUvSx9pcSM/IzXuO59A6hO/aRpX4W+wE4iqbX08FOSMsYGBUcaPaquiLkr7Y9gkFbIuBDqmZlnXq8uddQEPxNzaWWQEqonaId/oMwtz+/xE5uThfOb0XSoSrrkCnSqDvQd2BAsHtGZfIjkzX6S5RkEzzdvBoy9ie9PZn6e+QsG7xaJhzOcmiqNAZ4QG+ai5d9Kb3ri4pviUEqXx7Cxpe0N9hHnIbw62rDA167TGZc1et/HVGASORzTeof0e5BKINcHNGbFkI6QLoW3jTsS98byBwAVabvWFjxlXy13eMg4vioWzNk1OipLdCNXW7vpFtG8fRBhOp+Xyy9lgLNJnrZsC7TsWceSJ0fdd/zR3s4W/h4lkuoYmnRLLqqcB0b0nJ7iavinRQpp+93tIIyHrfwf9rsoUb5KUqcl/ud9Jg0wOY0E/Shzd/FJYUodXrxe9wCj7dVXsYAf9/4iZhFhjsmO9KmfG8tDE6ywx1tW731Ngs71mMJUJrYQwVv/W+0QmbPifs+p2BcF968FCpmjQqoqKqHmTEfGKkwNBDC9Ps5gwxEb4rlvXeU/gZLWSK1k9Mj0k0sUhalXJ3svB074XOH7PDzwAgLQyyRB4yU3So94935vtNYetJVal02jbZPFQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9448.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(376002)(39860400002)(366004)(136003)(396003)(451199015)(316002)(8676002)(38350700002)(30864003)(7416002)(5660300002)(66556008)(66476007)(38100700002)(4326008)(66946007)(36756003)(8936002)(41300700001)(83380400001)(6666004)(921005)(186003)(2616005)(86362001)(6486002)(26005)(478600001)(6512007)(52116002)(6506007)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?AwQWRuT5MR5kLJAabXwirst3oBnx?= =?utf-8?q?+B/WcdB8VZSZzqiZ1qGuaJqVNQZpsdGD5SmqsIVgKYtdnSYM4X85OJn54Jxb0WEXr?= =?utf-8?q?EMe9zu6BBeEZm26FLsKZEKJj2RZ5rXlnGbcJ9+WOMzEiGGc/+kEQq76ee4xpn+IRK?= =?utf-8?q?dmcZPMmL5Sc4Sw153v5VXs2ITCXQ670ZHQbYDfuY8jxO4Ytfqx1a4lUuRZuiOPgOh?= =?utf-8?q?xLug+nZPXmosEFv87tzT8v62Cz/oVFgHAiF59dzi+Bs0pHoTh79+bxBWONbzes9EL?= =?utf-8?q?wpjad4oG+J5EfwWRYOmplJW3A6GV8gXLjmUjTYlrS6PSKDulqh822jfcmPSrRKeX0?= =?utf-8?q?iZpM7YTabffNLJGrXqjds+WlsOFZBJnZt29Apn30E/F8Dbj4+dAH9j4uhIVmmVsa5?= =?utf-8?q?GS7tiFHtfsxA2xlMD3S2lguWBPTn75ch5/2YeuQi1Uq3cTcAgomI8QP2LnyAJ4/dw?= =?utf-8?q?3HQJ7p+M8tWNgRVuN3HxY4lwUoT0VCvGuupNCtS+U7589l0zdJQuCv9biNZ+oh6HA?= =?utf-8?q?9Xkxp8xfbz0TOCcuO0RcDo5g8SmWfSIywUg1psrvmxLHVOQQH7Ooh87SvzfWXAABD?= =?utf-8?q?B5vrJfWwmWoLZwPalhsnRUU9nXoix6rD1A3tnSwOQaY4ezrD6gi44SE+LSJ217jGM?= =?utf-8?q?gn4ckpduiykiHmGdvcf0ea5nP6IoBtuBP11NWT3lXatADtOSEsQZH9CKWyQrwc8P+?= =?utf-8?q?ZGwSnEq+UrSjjywyZaO3K79rmYvsoG5Z/mo/t/MmZTCdGFWDWDs5QvrbDzwJGpPOJ?= =?utf-8?q?fF+uKDaBTpK+l38W5jYvNTB4pSJTfB2tYxVtyOKRfdub++3JLy0rn9HlIZeMSR/eU?= =?utf-8?q?WDL5Iz755GTT7niPa1NETnYO4TS9k4X5jyjsdt4WKmnxwGJDXkqc+ZjC0Lcz+2enZ?= =?utf-8?q?riVZmTXH8Ie7ScbxyND9lwMAxJ389xUPAM1CXhXaBh9Li8I0/pgHluX824Moa7cyS?= =?utf-8?q?vg9iyb60bp7qbp4D1maHXOMtLOGNrL+0gUUw3hpumpdSdYVcn1pdUzaM/5SRzv2qP?= =?utf-8?q?1JySOtilJ8yde1IUXhaTcwQNxKGGe+UpwsKRRiO4y3KgXxrHWdSy+elGxsXya0V3y?= =?utf-8?q?/qZLv7eiN6wj7pzj6rhzaTZKe0CSGa8f7OENEC/b0qqgwgQBDIyN9+vm4jYEYjU7R?= =?utf-8?q?n8NbSoVQLBZ30dbyUFNUt8aYaz4cphvAo5yyftRMT09iJQf8RsjLaLpvsKenqz3OP?= =?utf-8?q?dep+1ZK2dYT8/T5Bg+OttNA+Zs+cQTedWYFsTfGrAIHVkCEjI6oEem/zLXArztYgE?= =?utf-8?q?pPu5fgOely30ZTPCMp1QGhpgmKR/Ga9c+cmM3otqtxlUM9Td/7NtMN1Qj/et4ROJa?= =?utf-8?q?bTsQbz3WyqARpTXUC/+o6jl35UDbi4jdGRKJcwHKO7qfcXrJOyQLUUw6vzEnYQNec?= =?utf-8?q?HPpmTbW3eMz9w5GJIndfYLx4/+46juTYm9xFI8LdL9Jb2jt5ds9yM4qsxerKCcsLl?= =?utf-8?q?EwgjOSvVExs1D81znaMq1sprfV2YkjJ+Y4O9pYJjYH74hYZd78cdMB8B9TPoogokM?= =?utf-8?q?BGTq7tOvn3/4?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4b049d1-fc06-4013-57fc-08dabe3073db X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9448.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2022 06:47:34.0936 (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: vzwR/CENyBO9c4ktDoxUstBWt+lKs+1raojE54TWpj0jn1+V2Pdlm4VAYvnyPklkURrOvVq2u3V1sySUHPVWuQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8081 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 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?1748547178202666933?= X-GMAIL-MSGID: =?utf-8?q?1748547178202666933?= Add Cadence HDP-TX DisplayPort PHY driver. Cadence HDP-TX PHY could be put in either DP mode or HDMI mode base on the configuration chosen. DisplayPort PHY mode is configurated in the driver. Signed-off-by: Sandor Yu --- drivers/phy/cadence/Kconfig | 8 + drivers/phy/cadence/Makefile | 1 + drivers/phy/cadence/phy-cadence-hdptx-dp.c | 774 +++++++++++++++++++++ 3 files changed, 783 insertions(+) create mode 100644 drivers/phy/cadence/phy-cadence-hdptx-dp.c diff --git a/drivers/phy/cadence/Kconfig b/drivers/phy/cadence/Kconfig index 1adde2d99ae7..1e1914d3afdc 100644 --- a/drivers/phy/cadence/Kconfig +++ b/drivers/phy/cadence/Kconfig @@ -46,3 +46,11 @@ config PHY_CADENCE_SALVO Enable this to support the Cadence SALVO PHY driver, this PHY is a legacy PHY, and only are used for USB3 and USB2. + +config PHY_CADENCE_HDPTX_DP + tristate "Cadence HDPTX DP PHY Driver" + depends on OF && HAS_IOMEM + depends on COMMON_CLK + select GENERIC_PHY + help + Enable this to support the Cadence HDPTX DP PHY driver diff --git a/drivers/phy/cadence/Makefile b/drivers/phy/cadence/Makefile index e17f035ddece..fbdb0bc5ff11 100644 --- a/drivers/phy/cadence/Makefile +++ b/drivers/phy/cadence/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_PHY_CADENCE_DPHY) += cdns-dphy.o obj-$(CONFIG_PHY_CADENCE_DPHY_RX) += cdns-dphy-rx.o obj-$(CONFIG_PHY_CADENCE_SIERRA) += phy-cadence-sierra.o obj-$(CONFIG_PHY_CADENCE_SALVO) += phy-cadence-salvo.o +obj-$(CONFIG_PHY_CADENCE_HDPTX_DP) += phy-cadence-hdptx-dp.o diff --git a/drivers/phy/cadence/phy-cadence-hdptx-dp.c b/drivers/phy/cadence/phy-cadence-hdptx-dp.c new file mode 100644 index 000000000000..079d43772d1d --- /dev/null +++ b/drivers/phy/cadence/phy-cadence-hdptx-dp.c @@ -0,0 +1,774 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Cadence HDP-TX Display Port Interface (DP) PHY driver + * + * Copyright (C) 2022 NXP Semiconductor, Inc. + */ +#include +#include +#include +#include +#include +#include +#include + +#include + +#define ADDR_PHY_AFE 0x80000 + +/* PHY registers */ +#define CMN_SSM_BIAS_TMR 0x0022 +#define CMN_PLLSM0_PLLEN_TMR 0x0029 +#define CMN_PLLSM0_PLLPRE_TMR 0x002A +#define CMN_PLLSM0_PLLVREF_TMR 0x002B +#define CMN_PLLSM0_PLLLOCK_TMR 0x002C +#define CMN_PLLSM0_USER_DEF_CTRL 0x002F +#define CMN_PSM_CLK_CTRL 0x0061 +#define CMN_CDIAG_REFCLK_CTRL 0x0062 +#define CMN_PLL0_VCOCAL_START 0x0081 +#define CMN_PLL0_VCOCAL_INIT_TMR 0x0084 +#define CMN_PLL0_VCOCAL_ITER_TMR 0x0085 +#define CMN_PLL0_INTDIV 0x0094 +#define CMN_PLL0_FRACDIV 0x0095 +#define CMN_PLL0_HIGH_THR 0x0096 +#define CMN_PLL0_DSM_DIAG 0x0097 +#define CMN_PLL0_SS_CTRL1 0x0098 +#define CMN_PLL0_SS_CTRL2 0x0099 +#define CMN_ICAL_INIT_TMR 0x00C4 +#define CMN_ICAL_ITER_TMR 0x00C5 +#define CMN_RXCAL_INIT_TMR 0x00D4 +#define CMN_RXCAL_ITER_TMR 0x00D5 +#define CMN_TXPUCAL_CTRL 0x00E0 +#define CMN_TXPUCAL_INIT_TMR 0x00E4 +#define CMN_TXPUCAL_ITER_TMR 0x00E5 +#define CMN_TXPDCAL_CTRL 0x00F0 +#define CMN_TXPDCAL_INIT_TMR 0x00F4 +#define CMN_TXPDCAL_ITER_TMR 0x00F5 +#define CMN_ICAL_ADJ_INIT_TMR 0x0102 +#define CMN_ICAL_ADJ_ITER_TMR 0x0103 +#define CMN_RX_ADJ_INIT_TMR 0x0106 +#define CMN_RX_ADJ_ITER_TMR 0x0107 +#define CMN_TXPU_ADJ_CTRL 0x0108 +#define CMN_TXPU_ADJ_INIT_TMR 0x010A +#define CMN_TXPU_ADJ_ITER_TMR 0x010B +#define CMN_TXPD_ADJ_CTRL 0x010c +#define CMN_TXPD_ADJ_INIT_TMR 0x010E +#define CMN_TXPD_ADJ_ITER_TMR 0x010F +#define CMN_DIAG_PLL0_FBH_OVRD 0x01C0 +#define CMN_DIAG_PLL0_FBL_OVRD 0x01C1 +#define CMN_DIAG_PLL0_OVRD 0x01C2 +#define CMN_DIAG_PLL0_TEST_MODE 0x01C4 +#define CMN_DIAG_PLL0_V2I_TUNE 0x01C5 +#define CMN_DIAG_PLL0_CP_TUNE 0x01C6 +#define CMN_DIAG_PLL0_LF_PROG 0x01C7 +#define CMN_DIAG_PLL0_PTATIS_TUNE1 0x01C8 +#define CMN_DIAG_PLL0_PTATIS_TUNE2 0x01C9 +#define CMN_DIAG_PLL0_INCLK_CTRL 0x01CA +#define CMN_DIAG_PLL0_PXL_DIVH 0x01CB +#define CMN_DIAG_PLL0_PXL_DIVL 0x01CC +#define CMN_DIAG_HSCLK_SEL 0x01E0 +#define CMN_DIAG_PER_CAL_ADJ 0x01EC +#define CMN_DIAG_CAL_CTRL 0x01ED +#define CMN_DIAG_ACYA 0x01FF +#define XCVR_PSM_RCTRL 0x4001 +#define XCVR_PSM_CAL_TMR 0x4002 +#define XCVR_PSM_A0IN_TMR 0x4003 +#define TX_TXCC_CAL_SCLR_MULT_0 0x4047 +#define TX_TXCC_CPOST_MULT_00_0 0x404C +#define TX_TXCC_MGNFS_MULT_000_0 0x4050 +#define XCVR_DIAG_PLLDRC_CTRL 0x40E0 +#define XCVR_DIAG_PLLDRC_CTRL 0x40E0 +#define XCVR_DIAG_HSCLK_SEL 0x40E1 +#define XCVR_DIAG_BIDI_CTRL 0x40E8 +#define XCVR_DIAG_LANE_FCM_EN_MGN_TMR 0x40F2 +#define XCVR_DIAG_LANE_FCM_EN_MGN 0x40F2 +#define TX_PSC_A0 0x4100 +#define TX_PSC_A1 0x4101 +#define TX_PSC_A2 0x4102 +#define TX_PSC_A3 0x4103 +#define TX_RCVDET_CTRL 0x4120 +#define TX_RCVDET_EN_TMR 0x4122 +#define TX_RCVDET_EN_TMR 0x4122 +#define TX_RCVDET_ST_TMR 0x4123 +#define TX_RCVDET_ST_TMR 0x4123 +#define TX_BIST_CTRL 0x4140 +#define TX_BIST_UDDWR 0x4141 +#define TX_DIAG_TX_CTRL 0x41E0 +#define TX_DIAG_TX_DRV 0x41E1 +#define TX_DIAG_BGREF_PREDRV_DELAY 0x41E7 +#define TX_DIAG_BGREF_PREDRV_DELAY 0x41E7 +#define XCVR_PSM_RCTRL_1 0x4201 +#define TX_TXCC_CAL_SCLR_MULT_1 0x4247 +#define TX_TXCC_CPOST_MULT_00_1 0x424C +#define TX_TXCC_MGNFS_MULT_000_1 0x4250 +#define XCVR_DIAG_PLLDRC_CTRL_1 0x42E0 +#define XCVR_DIAG_HSCLK_SEL_1 0x42E1 +#define XCVR_DIAG_LANE_FCM_EN_MGN_TMR_1 0x42F2 +#define TX_RCVDET_EN_TMR_1 0x4322 +#define TX_RCVDET_ST_TMR_1 0x4323 +#define TX_DIAG_ACYA_0 0x41FF +#define TX_DIAG_ACYA_1 0x43FF +#define TX_DIAG_ACYA_2 0x45FF +#define TX_DIAG_ACYA_3 0x47FF +#define TX_ANA_CTRL_REG_1 0x5020 +#define TX_ANA_CTRL_REG_2 0x5021 +#define TXDA_COEFF_CALC 0x5022 +#define TX_DIG_CTRL_REG_1 0x5023 +#define TX_DIG_CTRL_REG_2 0x5024 +#define TXDA_CYA_AUXDA_CYA 0x5025 +#define TX_ANA_CTRL_REG_3 0x5026 +#define TX_ANA_CTRL_REG_4 0x5027 +#define TX_ANA_CTRL_REG_5 0x5029 +#define RX_PSC_A0 0x8000 +#define RX_PSC_CAL 0x8006 +#define PMA_LANE_CFG 0xC000 +#define PIPE_CMN_CTRL1 0xC001 +#define PIPE_CMN_CTRL2 0xC002 +#define PIPE_COM_LOCK_CFG1 0xC003 +#define PIPE_COM_LOCK_CFG2 0xC004 +#define PIPE_RCV_DET_INH 0xC005 +#define PHY_HDP_MODE_CTRL 0xC008 +#define PHY_HDP_CLK_CTL 0xC009 +#define STS 0xC00F +#define PHY_ISO_CMN_CTRL 0xC010 +#define PHY_ISO_CMN_CTRL 0xC010 +#define PHY_HDP_TX_CTL_L0 0xC408 +#define PHY_DP_TX_CTL 0xC408 +#define PHY_HDP_TX_CTL_L1 0xC448 +#define PHY_HDP_TX_CTL_L2 0xC488 +#define PHY_HDP_TX_CTL_L3 0xC4C8 +#define PHY_PMA_CMN_CTRL1 0xC800 +#define PMA_CMN_CTRL1 0xC800 +#define PHY_PMA_ISO_CMN_CTRL 0xC810 +#define PHY_PMA_ISO_PLL_CTRL1 0xC812 +#define PHY_PMA_ISOLATION_CTRL 0xC81F +#define PHY_ISOLATION_CTRL 0xC81F +#define PHY_PMA_ISO_XCVR_CTRL 0xCC11 +#define PHY_PMA_ISO_LINK_MODE 0xCC12 +#define PHY_PMA_ISO_PWRST_CTRL 0xCC13 +#define PHY_PMA_ISO_TX_DATA_LO 0xCC14 +#define PHY_PMA_ISO_TX_DATA_HI 0xCC15 +#define PHY_PMA_ISO_RX_DATA_LO 0xCC16 +#define PHY_PMA_ISO_RX_DATA_HI 0xCC17 + +#define MAX_NUM_LANES 4 +#define DEFAULT_MAX_BIT_RATE 5400 /* in Mbps */ + +#define REF_CLK_27MHZ 27000000 + +enum dp_link_rate { + RATE_1_6 = 162000, + RATE_2_1 = 216000, + RATE_2_4 = 243000, + RATE_2_7 = 270000, + RATE_3_2 = 324000, + RATE_4_3 = 432000, + RATE_5_4 = 540000, + RATE_8_1 = 810000, +}; + +struct phy_pll_reg { + u16 val[7]; + u32 addr; +}; + +static const struct phy_pll_reg phy_pll_27m_cfg[] = { + /* 1.62 2.16 2.43 2.7 3.24 4.32 5.4 register address */ + {{ 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E }, CMN_PLL0_VCOCAL_INIT_TMR }, + {{ 0x001B, 0x001B, 0x001B, 0x001B, 0x001B, 0x001B, 0x001B }, CMN_PLL0_VCOCAL_ITER_TMR }, + {{ 0x30B9, 0x3087, 0x3096, 0x30B4, 0x30B9, 0x3087, 0x30B4 }, CMN_PLL0_VCOCAL_START }, + {{ 0x0077, 0x009F, 0x00B3, 0x00C7, 0x0077, 0x009F, 0x00C7 }, CMN_PLL0_INTDIV }, + {{ 0xF9DA, 0xF7CD, 0xF6C7, 0xF5C1, 0xF9DA, 0xF7CD, 0xF5C1 }, CMN_PLL0_FRACDIV }, + {{ 0x001E, 0x0028, 0x002D, 0x0032, 0x001E, 0x0028, 0x0032 }, CMN_PLL0_HIGH_THR }, + {{ 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020 }, CMN_PLL0_DSM_DIAG }, + {{ 0x0000, 0x1000, 0x1000, 0x1000, 0x0000, 0x1000, 0x1000 }, CMN_PLLSM0_USER_DEF_CTRL }, + {{ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, CMN_DIAG_PLL0_OVRD }, + {{ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, CMN_DIAG_PLL0_FBH_OVRD }, + {{ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }, CMN_DIAG_PLL0_FBL_OVRD }, + {{ 0x0006, 0x0007, 0x0007, 0x0007, 0x0006, 0x0007, 0x0007 }, CMN_DIAG_PLL0_V2I_TUNE }, + {{ 0x0043, 0x0043, 0x0043, 0x0042, 0x0043, 0x0043, 0x0042 }, CMN_DIAG_PLL0_CP_TUNE }, + {{ 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008 }, CMN_DIAG_PLL0_LF_PROG }, + {{ 0x0100, 0x0001, 0x0001, 0x0001, 0x0100, 0x0001, 0x0001 }, CMN_DIAG_PLL0_PTATIS_TUNE1 }, + {{ 0x0007, 0x0001, 0x0001, 0x0001, 0x0007, 0x0001, 0x0001 }, CMN_DIAG_PLL0_PTATIS_TUNE2 }, + {{ 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020 }, CMN_DIAG_PLL0_TEST_MODE}, + {{ 0x0016, 0x0016, 0x0016, 0x0016, 0x0016, 0x0016, 0x0016 }, CMN_PSM_CLK_CTRL } +}; + +struct cdns_hdptx_dp_phy { + void __iomem *regs; /* DPTX registers base */ + struct device *dev; + struct phy *phy; + struct mutex mbox_mutex; /* mutex to protect mailbox */ + struct clk *ref_clk; + u32 ref_clk_rate; + u32 num_lanes; + u32 max_bit_rate; /* Maximum link bit rate to use (in Mbps) */ + u32 link_rate; + bool power_up; +}; + +static int cdns_phy_reg_write(struct cdns_hdptx_dp_phy *cdns_phy, u32 addr, u32 val) +{ + return cdns_mhdp_reg_write(cdns_phy, ADDR_PHY_AFE + (addr << 2), val); +} + +static u32 cdns_phy_reg_read(struct cdns_hdptx_dp_phy *cdns_phy, u32 addr) +{ + u32 reg32; + + cdns_mhdp_reg_read(cdns_phy, ADDR_PHY_AFE + (addr << 2), ®32); + return reg32; +} + +static int link_rate_index(u32 rate) +{ + switch (rate) { + case RATE_1_6: + return 0; + case RATE_2_1: + return 1; + case RATE_2_4: + return 2; + case RATE_2_7: + return 3; + case RATE_3_2: + return 4; + case RATE_4_3: + return 5; + case RATE_5_4: + return 6; + default: + return -1; + } +} + +static int hdptx_dp_ref_clk(struct cdns_hdptx_dp_phy *cdns_phy) +{ + struct device *dev = cdns_phy->dev; + u32 ref_clk_rate; + int ret; + + cdns_phy->ref_clk = devm_clk_get(dev, "refclk"); + if (IS_ERR(cdns_phy->ref_clk)) { + dev_err(dev, "phy ref clock not found\n"); + return PTR_ERR(cdns_phy->ref_clk); + } + + ret = clk_prepare_enable(cdns_phy->ref_clk); + if (ret) { + dev_err(cdns_phy->dev, "Failed to prepare ref clock\n"); + return ret; + } + + ref_clk_rate = clk_get_rate(cdns_phy->ref_clk); + if (!ref_clk_rate) { + dev_err(cdns_phy->dev, "Failed to get ref clock rate\n"); + goto err_ref_clk; + } + + if (ref_clk_rate == REF_CLK_27MHZ) + cdns_phy->ref_clk_rate = ref_clk_rate; + else { + dev_err(cdns_phy->dev, "Not support Ref Clock Rate(%dHz)\n", ref_clk_rate); + goto err_ref_clk; + } + + return 0; + +err_ref_clk: + clk_disable_unprepare(cdns_phy->ref_clk); + return -EINVAL; +} + +static void hdptx_dp_aux_cfg(struct cdns_hdptx_dp_phy *cdns_phy) +{ + /* Power up Aux */ + cdns_phy_reg_write(cdns_phy, TXDA_CYA_AUXDA_CYA, 1); + + cdns_phy_reg_write(cdns_phy, TX_DIG_CTRL_REG_1, 0x3); + ndelay(150); + cdns_phy_reg_write(cdns_phy, TX_DIG_CTRL_REG_2, 36); + ndelay(150); + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_2, 0x0100); + ndelay(150); + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_2, 0x0300); + ndelay(150); + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_3, 0x0000); + ndelay(150); + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_1, 0x2008); + ndelay(150); + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_1, 0x2018); + ndelay(150); + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_1, 0xA018); + ndelay(150); + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_2, 0x030C); + ndelay(150); + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_5, 0x0000); + ndelay(150); + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_4, 0x1001); + ndelay(150); + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_1, 0xA098); + ndelay(150); + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_1, 0xA198); + ndelay(150); + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_2, 0x030d); + ndelay(150); + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_2, 0x030f); +} + +/* PMA common configuration for 27MHz */ +static void hdptx_dp_phy_pma_cmn_cfg_27mhz(struct cdns_hdptx_dp_phy *cdns_phy) +{ + u32 num_lanes = cdns_phy->num_lanes; + u16 val; + int k; + + val = cdns_phy_reg_read(cdns_phy, PHY_PMA_CMN_CTRL1); + val &= 0xFFF7; + val |= 0x0008; + cdns_phy_reg_write(cdns_phy, PHY_PMA_CMN_CTRL1, val); + + /* Startup state machine registers */ + cdns_phy_reg_write(cdns_phy, CMN_SSM_BIAS_TMR, 0x0087); + cdns_phy_reg_write(cdns_phy, CMN_PLLSM0_PLLEN_TMR, 0x001B); + cdns_phy_reg_write(cdns_phy, CMN_PLLSM0_PLLPRE_TMR, 0x0036); + cdns_phy_reg_write(cdns_phy, CMN_PLLSM0_PLLVREF_TMR, 0x001B); + cdns_phy_reg_write(cdns_phy, CMN_PLLSM0_PLLLOCK_TMR, 0x006C); + + /* Current calibration registers */ + cdns_phy_reg_write(cdns_phy, CMN_ICAL_INIT_TMR, 0x0044); + cdns_phy_reg_write(cdns_phy, CMN_ICAL_ITER_TMR, 0x0006); + cdns_phy_reg_write(cdns_phy, CMN_ICAL_ADJ_INIT_TMR, 0x0022); + cdns_phy_reg_write(cdns_phy, CMN_ICAL_ADJ_ITER_TMR, 0x0006); + + /* Resistor calibration registers */ + cdns_phy_reg_write(cdns_phy, CMN_TXPUCAL_INIT_TMR, 0x0022); + cdns_phy_reg_write(cdns_phy, CMN_TXPUCAL_ITER_TMR, 0x0006); + cdns_phy_reg_write(cdns_phy, CMN_TXPU_ADJ_INIT_TMR, 0x0022); + cdns_phy_reg_write(cdns_phy, CMN_TXPU_ADJ_ITER_TMR, 0x0006); + cdns_phy_reg_write(cdns_phy, CMN_TXPDCAL_INIT_TMR, 0x0022); + cdns_phy_reg_write(cdns_phy, CMN_TXPDCAL_ITER_TMR, 0x0006); + cdns_phy_reg_write(cdns_phy, CMN_TXPD_ADJ_INIT_TMR, 0x0022); + cdns_phy_reg_write(cdns_phy, CMN_TXPD_ADJ_ITER_TMR, 0x0006); + cdns_phy_reg_write(cdns_phy, CMN_RXCAL_INIT_TMR, 0x0022); + cdns_phy_reg_write(cdns_phy, CMN_RXCAL_ITER_TMR, 0x0006); + cdns_phy_reg_write(cdns_phy, CMN_RX_ADJ_INIT_TMR, 0x0022); + cdns_phy_reg_write(cdns_phy, CMN_RX_ADJ_ITER_TMR, 0x0006); + + for (k = 0; k < num_lanes; k = k + 1) { + /* Power state machine registers */ + cdns_phy_reg_write(cdns_phy, XCVR_PSM_CAL_TMR | (k << 9), 0x016D); + cdns_phy_reg_write(cdns_phy, XCVR_PSM_A0IN_TMR | (k << 9), 0x016D); + /* Transceiver control and diagnostic registers */ + cdns_phy_reg_write(cdns_phy, XCVR_DIAG_LANE_FCM_EN_MGN_TMR | (k << 9), 0x00A2); + cdns_phy_reg_write(cdns_phy, TX_DIAG_BGREF_PREDRV_DELAY | (k << 9), 0x0097); + /* Transmitter receiver detect registers */ + cdns_phy_reg_write(cdns_phy, TX_RCVDET_EN_TMR | (k << 9), 0x0A8C); + cdns_phy_reg_write(cdns_phy, TX_RCVDET_ST_TMR | (k << 9), 0x0036); + } + + cdns_phy_reg_write(cdns_phy, TX_DIAG_ACYA_0, 1); + cdns_phy_reg_write(cdns_phy, TX_DIAG_ACYA_1, 1); + cdns_phy_reg_write(cdns_phy, TX_DIAG_ACYA_2, 1); + cdns_phy_reg_write(cdns_phy, TX_DIAG_ACYA_3, 1); +} + +static void hdptx_dp_phy_pma_cmn_pll0_27mhz(struct cdns_hdptx_dp_phy *cdns_phy) +{ + u32 num_lanes = cdns_phy->num_lanes; + u32 link_rate = cdns_phy->link_rate; + u16 val; + int index, i, k; + + /* DP PLL data rate 0/1 clock divider value */ + val = cdns_phy_reg_read(cdns_phy, PHY_HDP_CLK_CTL); + val &= 0x00FF; + if (link_rate <= RATE_2_7) + val |= 0x2400; + else + val |= 0x1200; + cdns_phy_reg_write(cdns_phy, PHY_HDP_CLK_CTL, val); + + /* High speed clock 0/1 div */ + val = cdns_phy_reg_read(cdns_phy, CMN_DIAG_HSCLK_SEL); + val &= 0xFFCC; + if (link_rate <= RATE_2_7) + val |= 0x0011; + cdns_phy_reg_write(cdns_phy, CMN_DIAG_HSCLK_SEL, val); + + for (k = 0; k < num_lanes; k++) { + val = cdns_phy_reg_read(cdns_phy, (XCVR_DIAG_HSCLK_SEL | (k << 9))); + val = val & 0xCFFF; + if (link_rate <= RATE_2_7) + val |= 0x1000; + cdns_phy_reg_write(cdns_phy, (XCVR_DIAG_HSCLK_SEL | (k << 9)), val); + } + + /* DP PHY PLL 27MHz configuration */ + index = link_rate_index(link_rate); + for (i = 0; i < ARRAY_SIZE(phy_pll_27m_cfg); i++) + cdns_phy_reg_write(cdns_phy, phy_pll_27m_cfg[i].addr, + phy_pll_27m_cfg[i].val[index]); + + /* Transceiver control and diagnostic registers */ + for (k = 0; k < num_lanes; k++) { + val = cdns_phy_reg_read(cdns_phy, (XCVR_DIAG_PLLDRC_CTRL | (k << 9))); + val = val & 0x8FFF; + if (link_rate <= RATE_2_7) + val |= 0x2000; + else + val |= 0x1000; + cdns_phy_reg_write(cdns_phy, (XCVR_DIAG_PLLDRC_CTRL | (k << 9)), val); + } + + for (k = 0; k < num_lanes; k = k + 1) { + /* Power state machine registers */ + cdns_phy_reg_write(cdns_phy, (XCVR_PSM_RCTRL | (k << 9)), 0xBEFC); + cdns_phy_reg_write(cdns_phy, (TX_PSC_A0 | (k << 9)), 0x6799); + cdns_phy_reg_write(cdns_phy, (TX_PSC_A1 | (k << 9)), 0x6798); + cdns_phy_reg_write(cdns_phy, (TX_PSC_A2 | (k << 9)), 0x0098); + cdns_phy_reg_write(cdns_phy, (TX_PSC_A3 | (k << 9)), 0x0098); + /* Receiver calibration power state definition register */ + val = cdns_phy_reg_read(cdns_phy, RX_PSC_CAL | (k << 9)); + val &= 0xFFBB; + cdns_phy_reg_write(cdns_phy, (RX_PSC_CAL | (k << 9)), val); + val = cdns_phy_reg_read(cdns_phy, RX_PSC_A0 | (k << 9)); + val &= 0xFFBB; + cdns_phy_reg_write(cdns_phy, (RX_PSC_A0 | (k << 9)), val); + } +} + +static void hdptx_dp_phy_ref_clock_type(struct cdns_hdptx_dp_phy *cdns_phy) +{ + u32 val; + + val = cdns_phy_reg_read(cdns_phy, PHY_PMA_CMN_CTRL1); + val &= 0xFF8F; + /* + * single ended reference clock (val |= 0x0030); + * differential clock (val |= 0x0000); + * + * for differential clock on the refclk_p and + * refclk_m off chip pins: CMN_DIAG_ACYA[8]=1'b1 + * cdns_phy_reg_write(cdns_phy, CMN_DIAG_ACYA, 0x0100); + */ + val |= 0x0030; + cdns_phy_reg_write(cdns_phy, PHY_PMA_CMN_CTRL1, val); +} + +static int hdptx_dp_phy_power_up(struct cdns_hdptx_dp_phy *cdns_phy) +{ + u32 val, i; + + /* Enable HDP PLL’s for high speed clocks */ + val = cdns_phy_reg_read(cdns_phy, PHY_HDP_CLK_CTL); + val |= (1 << 0); + cdns_phy_reg_write(cdns_phy, PHY_HDP_CLK_CTL, val); + /* Wait for PLL ready ACK */ + for (i = 0; i < 10; i++) { + val = cdns_phy_reg_read(cdns_phy, PHY_HDP_CLK_CTL); + if (val & (1 << 1)) + break; + msleep(20); + } + if (i == 10) { + dev_err(cdns_phy->dev, "Wait PLL Ack failed\n"); + return -1; + } + + /* Enable HDP PLL’s data rate and full rate clocks out of PMA. */ + val = cdns_phy_reg_read(cdns_phy, PHY_HDP_CLK_CTL); + val |= (1 << 2); + cdns_phy_reg_write(cdns_phy, PHY_HDP_CLK_CTL, val); + /* Wait for PLL clock enable ACK */ + for (i = 0; i < 10; i++) { + val = cdns_phy_reg_read(cdns_phy, PHY_HDP_CLK_CTL); + if (val & (1 << 3)) + break; + msleep(20); + } + if (i == 10) { + dev_err(cdns_phy->dev, "Wait PLL clock enable ACk failed\n"); + return -1; + } + + /* Configure PHY in A2 Mode */ + cdns_phy_reg_write(cdns_phy, PHY_HDP_MODE_CTRL, 0x0004); + /* Wait for Power State A2 Ack */ + for (i = 0; i < 10; i++) { + val = cdns_phy_reg_read(cdns_phy, PHY_HDP_MODE_CTRL); + if (val & (1 << 6)) + break; + msleep(20); + } + if (i == 10) { + dev_err(cdns_phy->dev, "Wait A2 Ack failed\n"); + return -1; + } + + /* Configure PHY in A0 mode (PHY must be in the A0 power + * state in order to transmit data) + */ + cdns_phy_reg_write(cdns_phy, PHY_HDP_MODE_CTRL, 0x0101); + + /* Wait for Power State A0 Ack */ + for (i = 0; i < 10; i++) { + val = cdns_phy_reg_read(cdns_phy, PHY_HDP_MODE_CTRL); + if (val & (1 << 4)) + break; + msleep(20); + } + if (i == 10) { + dev_err(cdns_phy->dev, "Wait A0 Ack failed\n"); + return -1; + } + + cdns_phy->power_up = true; + + return 0; +} + +static void hdptx_dp_phy_power_down(struct cdns_hdptx_dp_phy *cdns_phy) +{ + u16 val; + int i; + + if (!cdns_phy->power_up) + return; + + /* Place the PHY lanes in the A3 power state. */ + cdns_phy_reg_write(cdns_phy, PHY_HDP_MODE_CTRL, 0x8); + /* Wait for Power State A3 Ack */ + for (i = 0; i < 10; i++) { + val = cdns_phy_reg_read(cdns_phy, PHY_HDP_MODE_CTRL); + if (val & (1 << 7)) + break; + msleep(20); + } + if (i == 10) { + dev_err(cdns_phy->dev, "Wait A3 Ack failed\n"); + return; + } + + /* Disable HDP PLL’s data rate and full rate clocks out of PMA. */ + val = cdns_phy_reg_read(cdns_phy, PHY_HDP_CLK_CTL); + val &= ~(1 << 2); + cdns_phy_reg_write(cdns_phy, PHY_HDP_CLK_CTL, val); + /* Wait for PLL clock gate ACK */ + for (i = 0; i < 10; i++) { + val = cdns_phy_reg_read(cdns_phy, PHY_HDP_CLK_CTL); + if (!(val & (1 << 3))) + break; + msleep(20); + } + if (i == 10) { + dev_err(cdns_phy->dev, "Wait PLL clock gate Ack failed\n"); + return; + } + + /* Disable HDP PLL’s for high speed clocks */ + val = cdns_phy_reg_read(cdns_phy, PHY_HDP_CLK_CTL); + val &= ~(1 << 0); + cdns_phy_reg_write(cdns_phy, PHY_HDP_CLK_CTL, val); + /* Wait for PLL disable ACK */ + for (i = 0; i < 10; i++) { + val = cdns_phy_reg_read(cdns_phy, PHY_HDP_CLK_CTL); + if (!(val & (1 << 1))) + break; + msleep(20); + } + if (i == 10) { + dev_err(cdns_phy->dev, "Wait PLL disable Ack failed\n"); + return; + } +} + +static int cdns_hdptx_dp_phy_on(struct phy *phy) +{ + struct cdns_hdptx_dp_phy *cdns_phy = phy_get_drvdata(phy); + + return hdptx_dp_phy_power_up(cdns_phy); +} + +static int cdns_hdptx_dp_phy_off(struct phy *phy) +{ + struct cdns_hdptx_dp_phy *cdns_phy = phy_get_drvdata(phy); + + hdptx_dp_phy_power_down(cdns_phy); + + return 0; +} + +static int cdns_hdptx_dp_phy_init(struct phy *phy) +{ + struct cdns_hdptx_dp_phy *cdns_phy = phy_get_drvdata(phy); + int ret; + + hdptx_dp_phy_ref_clock_type(cdns_phy); + + /* PHY power up */ + ret = hdptx_dp_phy_power_up(cdns_phy); + if (ret < 0) + return ret; + + hdptx_dp_aux_cfg(cdns_phy); + + return ret; +} + +static int cdns_hdptx_dp_configure(struct phy *phy, + union phy_configure_opts *opts) +{ + struct cdns_hdptx_dp_phy *cdns_phy = phy_get_drvdata(phy); + int ret; + + cdns_phy->link_rate = opts->dp.link_rate; + + /* Disable phy clock if PHY in power up state */ + hdptx_dp_phy_power_down(cdns_phy); + + if (cdns_phy->ref_clk_rate == REF_CLK_27MHZ) { + hdptx_dp_phy_pma_cmn_cfg_27mhz(cdns_phy); + hdptx_dp_phy_pma_cmn_pll0_27mhz(cdns_phy); + } else + dev_err(cdns_phy->dev, "Not support ref clock rate\n"); + + /* PHY power up */ + ret = hdptx_dp_phy_power_up(cdns_phy); + + return ret; +} + +static const struct phy_ops cdns_hdptx_dp_phy_ops = { + .init = cdns_hdptx_dp_phy_init, + .configure = cdns_hdptx_dp_configure, + .power_on = cdns_hdptx_dp_phy_on, + .power_off = cdns_hdptx_dp_phy_off, + .owner = THIS_MODULE, +}; + +static int cdns_hdptx_dp_phy_probe(struct platform_device *pdev) +{ + struct cdns_hdptx_dp_phy *cdns_phy; + struct device *dev = &pdev->dev; + struct device_node *node = dev->of_node; + struct phy_provider *phy_provider; + struct resource *res; + struct phy *phy; + int ret; + + cdns_phy = devm_kzalloc(dev, sizeof(*cdns_phy), GFP_KERNEL); + if (!cdns_phy) + return -ENOMEM; + + dev_set_drvdata(dev, cdns_phy); + cdns_phy->dev = dev; + mutex_init(&cdns_phy->mbox_mutex); + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -ENODEV; + cdns_phy->regs = devm_ioremap(dev, res->start, resource_size(res)); + if (IS_ERR(cdns_phy->regs)) + return PTR_ERR(cdns_phy->regs); + + if (of_property_read_u32(node, "cdns,num-lanes", + &cdns_phy->num_lanes)) { + dev_err(dev, "%s: No \"cdns,num-lanes\"-property.\n", + node->full_name); + return -EINVAL; + } + + phy = devm_phy_create(dev, node, &cdns_hdptx_dp_phy_ops); + if (IS_ERR(phy)) + return PTR_ERR(phy); + + cdns_phy->max_bit_rate = DEFAULT_MAX_BIT_RATE; + of_property_read_u32(node, "cdns,max-bit-rate", + &cdns_phy->max_bit_rate); + + switch (cdns_phy->max_bit_rate) { + /* valid bit rate */ + case 1620: + case 2160: + case 2430: + case 2700: + case 3240: + case 4320: + case 5400: + break; + case 8100: + default: + dev_err(dev, "unsupported max bit rate: %dMbps\n", + cdns_phy->max_bit_rate); + return -EINVAL; + } + + dev_dbg(dev, "DP max bit rate %d.%03d Gbps\n", + cdns_phy->max_bit_rate / 1000, + cdns_phy->max_bit_rate % 1000); + + phy->attrs.bus_width = cdns_phy->num_lanes; + phy->attrs.max_link_rate = cdns_phy->max_bit_rate; + phy->attrs.mode = PHY_MODE_DP; + + cdns_phy->phy = phy; + phy_set_drvdata(phy, cdns_phy); + + if (cdns_phy->num_lanes > MAX_NUM_LANES) { + dev_err(dev, "Invalid lane configuration\n"); + return -EINVAL; + } + + ret = hdptx_dp_ref_clk(cdns_phy); + if (ret) { + dev_err(dev, "Init clk fail\n"); + return -EINVAL; + } + + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); + if (IS_ERR(phy_provider)) { + ret = PTR_ERR(phy_provider); + goto clk_disable; + } + + dev_dbg(dev, "link: (%d lanes)", cdns_phy->num_lanes); + + return 0; + +clk_disable: + clk_disable_unprepare(cdns_phy->ref_clk); + + return -EINVAL; +} + +static int cdns_hdptx_dp_phy_remove(struct platform_device *pdev) +{ + struct cdns_hdptx_dp_phy *cdns_phy = platform_get_drvdata(pdev); + + clk_disable_unprepare(cdns_phy->ref_clk); + + return 0; +} + +static const struct of_device_id cdns_hdptx_dp_phy_of_match[] = { + { + .compatible = "cdns,hdptx-dp-phy", + }, + {} +}; +MODULE_DEVICE_TABLE(of, cdns_hdptx_dp_phy_of_match); + +static struct platform_driver cdns_hdptx_dp_phy_driver = { + .probe = cdns_hdptx_dp_phy_probe, + .remove = cdns_hdptx_dp_phy_remove, + .driver = { + .name = "cdns-hdptx-dp-phy", + .of_match_table = cdns_hdptx_dp_phy_of_match, + } +}; +module_platform_driver(cdns_hdptx_dp_phy_driver); + +MODULE_AUTHOR("Sandor Yu "); +MODULE_DESCRIPTION("Cadence HDP-TX DisplayPort PHY driver"); +MODULE_LICENSE("GPL"); From patchwork Fri Nov 4 06:44:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandor Yu X-Patchwork-Id: 15396 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp211114wru; Thu, 3 Nov 2022 23:48:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5yL3Ncja2q8C72PtMFKDr1+Trmm4F4Rgw6B4J7gk8Reuh+8JVeThrHbiywYwY0ObdDNB17 X-Received: by 2002:a17:90a:39c6:b0:216:eab7:2e2b with SMTP id k6-20020a17090a39c600b00216eab72e2bmr2931563pjf.25.1667544538431; Thu, 03 Nov 2022 23:48:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1667544538; cv=pass; d=google.com; s=arc-20160816; b=jFRsLpXdIvc1pRd8gRPXl2Ao2dz3E/Fhdp7C3jKmc1jn15RE8jbXVTxnjeBmWrYfgn 57t27ATzcTD+xv4yky9mm7aBkQCrwCfWHBnOZsLj34HE/JJ/LA5XrZtQDVaY9r2kG4NI DzsXFsd90Gl5kcq3H4MZOWc8SmPqQh/Pfq6FK4AE7QW9ZgYRO7EnxSqMBTX7VqEVFcqO irGmDpmIpf1G2HMCZivT/8vJkvgqcq4XGQUYHATryfXQvasMQrGUpKuQ/YdMvS+G9LKl k1QXiVXJ8c8ZymE8h2bpitMD0v2CWaOz0YAXGDYh8fkwRq3qs0estRf9f1drbNecCvr0 XVkA== 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=vhxMHNVkqbQwgbuwi9FxS3floekKWT8jcT1OWIzdxZ4=; b=M9eCD4McWFJqKzZVF+v0vFProfiimCgfKbWveaOyDfbKKHdbdfrfIZDUlC/kfNGfn2 HrO4wgiRp0CyE1L8U51h1mOEwF/a+DKAEAoWC/Y28sslDDsP4ziyWnLJiAH0Z/G3YCm7 vhOqsKa2D2u+U+fK9vKod6MAG0nRjVOOOTjsg58Z7vJNKPKLMjxJLkJgE5VgOwxQk9z8 Kb5u4Swa75LkeqFvURTt6m+9KTL/i/mNpB0/6wmooq1Z+7mjsnrnF+zAz52VxHC9nAtV 3A6PeOUgJBPZQ2btKnvpHrs3utRbJaMNjbbOWbOOZNRm2Re8xBWWLy/PDx89lLo/Oth9 4zjg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=Dg0osJe0; 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 z198-20020a6333cf000000b0044d5196773dsi3854874pgz.32.2022.11.03.23.48.45; Thu, 03 Nov 2022 23:48:58 -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=Dg0osJe0; 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 S231690AbiKDGsR (ORCPT + 99 others); Fri, 4 Nov 2022 02:48:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231582AbiKDGrq (ORCPT ); Fri, 4 Nov 2022 02:47:46 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2055.outbound.protection.outlook.com [40.107.21.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C17A82B255; Thu, 3 Nov 2022 23:47:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L90jcqxsvNfrZvIX1wXteHrFVvvb6EuqU05zk4ewiHyu3kV2rqdLCQe+0oVPPqLW5behaHPjjEESyQ238v9ODeaW8xwK2mRBcgHGIsm+8cIU79r+bUdU3JF5PGTmWmqFdOxU2BfbhGtJEpYBaz+Y66aZ72dEHTRXXQvS+zq4Bac7JNCytay8s59SP6+66wxkW5zoQ7WeLit7WdM1SfjZ3If7Qa/NV5wd/UzIi2OxEvTh2pfwrbzfJUPW/XvQMGeGtKOtg/hS7mFhdWitqbwsdqkdWI0boftdB/a3XlUkN8r5A+AzYIyhRwedZigpyi5mTYyw+If3VPjLb6ugvkxIZQ== 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=vhxMHNVkqbQwgbuwi9FxS3floekKWT8jcT1OWIzdxZ4=; b=I0GEV+Ahh63IztpPZe5abnf733hP57cnoVGBJbjLx2N9QTQBpMSG2Bt9HDzfktW1yRiT5hh77NIC9zaToa1PsuZkFjJSftvT827rlV16/cHAzIFjL9mMNqpDXdEbJOemZxKrp9H8ATadW7Er5P6ZTmN1CP6my+zYAiRmcqqHRJAImeD3BIZgtQJRqWOeK5EwZdRpwjcCJr+RudYyCyfa7oGSk3bAVvBT2ZlTjQnFONQFqSGn3mTyab++nRKAOL1q3cOwqy0P1kctdrXaGB4W3hOhXKXuD6qr7LAwTl6o3TUMTAeoUGvXfcj9Svxp3nWfBVvqUh7pUg7AiYwjSdpOqg== 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=vhxMHNVkqbQwgbuwi9FxS3floekKWT8jcT1OWIzdxZ4=; b=Dg0osJe00RHjTSNGPbkKIPdv0/g9N9Uhe0ijhfLFSkiwP1LHizBacNtyVOgIljNhZKZIzgCdMsYWThfJV53pxxwjeIXbAkyaFQ+otZOurvZlY9J+IiedIEBHUeCUrfGLu4tKm90J3FBldZ6JWIJ1hMU6/B1PXi+t+sZz/LwuD3I= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9448.eurprd04.prod.outlook.com (2603:10a6:102:2b1::21) by AM9PR04MB8081.eurprd04.prod.outlook.com (2603:10a6:20b:3e2::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.20; Fri, 4 Nov 2022 06:47:41 +0000 Received: from PAXPR04MB9448.eurprd04.prod.outlook.com ([fe80::88a0:57d8:2a57:3f4f]) by PAXPR04MB9448.eurprd04.prod.outlook.com ([fe80::88a0:57d8:2a57:3f4f%9]) with mapi id 15.20.5791.022; Fri, 4 Nov 2022 06:47:41 +0000 From: Sandor Yu To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, andrzej.hajda@intel.com, neil.armstrong@linaro.org, robert.foss@linaro.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, kishon@ti.com, vkoul@kernel.org Cc: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, linux-imx@nxp.com, tzimmermann@suse.de, lyude@redhat.com, Sandor.yu@nxp.com, javierm@redhat.com, ville.syrjala@linux.intel.com, sam@ravnborg.org, jani.nikula@intel.com, maxime@cerno.tech, penguin-kernel@I-love.SAKURA.ne.jp, p.yadav@ti.com, oliver.brown@nxp.com Subject: [v2 09/10] dts-bindings: phy: Add Cadence HDP-TX HDMI PHY bindings Date: Fri, 4 Nov 2022 14:44:59 +0800 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-ClientProxiedBy: SG2PR06CA0194.apcprd06.prod.outlook.com (2603:1096:4:1::26) To PAXPR04MB9448.eurprd04.prod.outlook.com (2603:10a6:102:2b1::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9448:EE_|AM9PR04MB8081:EE_ X-MS-Office365-Filtering-Correlation-Id: 3af3b36e-f593-426f-e951-08dabe30785e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eFXb5KUYqifrKZhtnw4m5o/rYo5pRybLzI0HNy2W0ZCgQH6P5NnYwwVrFW4XrY4G0zV0QKjJ9Anw6D+BB2yTbMJcokD8GeXRi4zv/kZ6QHLpxiAqLJFQ7OtlEoY+mojQDnd+JCg1U2nbCBN6P1iIknePpf8OrZBLpWvjpGYm+2bTKIxE4/bOn0fdCa23vusgG9wh45Mc3+dqZHcPsQTwKscCdXnoc/I4c9TJ12PW4ut3x9OQn7JAoDx8cpN6dlJZM0pWSp+xRwlRf3wveUN8NXiXjMtTMddhW12wZqw9zncpuME6DlNMS7tI2cZMxVVdWpdpFKdx8oAj6Vi5FYCARR7ZyVZUtS9v+IygVzbYymIytyv9NubDu2sESf0WoTirLGoxNE/3XH2sbnLRQu5JKe9m2CMR/sC8yRkR/6nGaqlbRdR/hjyxJo7MJ9GTD2dzjirrj6lJBEo5N5sbI2wV6w8BeE0z+lHn6lkWE52M2mAnNUozAQfXpgc92pObEi8HQe/SvoTJA/2dOsvNAOkhNSJ0bVI222sEj45AEbdjtak4hBCTwtaEx4wDOaOQb6w5cK/0nKiXjJKEfyQNwo2+g41JXXGKYAbR2G02lTMTn0+cRRQJv8zC1DgMTf6H/fjyX7pJfWwztScJ8xsvjgLZVFeRP+XGD2h5acc0Wfa+j62oUR0iIyt0437Fxrb76xTV+6zT2jar6Ef0RhA3ut/sDEtOqBO4p5PjpoR1JDyKrKJsZ/6aRvjZ9aUXcXPqko9NEv1xj389zFzY8goOKwlbi8HFgMhJ9hRiyMxp4AhH45YK4wxyH+SW8c/uH3VBJv9eB/NwVGsGrFF2qzrrYHDvCQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9448.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(376002)(39860400002)(366004)(136003)(396003)(451199015)(316002)(8676002)(38350700002)(7416002)(5660300002)(66556008)(66476007)(38100700002)(4326008)(66946007)(36756003)(8936002)(41300700001)(83380400001)(6666004)(921005)(186003)(2616005)(86362001)(6486002)(26005)(478600001)(6512007)(52116002)(6506007)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Se4mXwgTV/9vuMXXdh9zDQAlRGbW0Nt8DqIHA6TYIpKJMq2xyYGQnkmkWlOqV6XTQ4RgZoW9FChlHr127ZRB81ujzSkqcI5F5gnBCIRabKlSxLefhirIXJE0SVAYdfYFmJ834ZkGPAWpfBZ4yA6aOcRMgS8OI1JVQrxrrpt1z2jKw6Muqjl4Xj2FCwNxUz0caSkE4qojpVJFrEkBDKIyPzUdxepmY2CscrzpS0nuZTHXlaZNthLhzNCTfP4QSuZHAPs38viJwZTmEPW8QgenVtcrx4ClwsLEAMNjF/nNHjOoRmxeHXItfsEZXYLoaRn+rUVxk8OlYcc0L1A1U0l3mWsDtBKmQ/TrzhyhhhwtPJdU1E7oIIo5pjgKIvJZupqfgz8VxJTW1pNpe3WRyUtjswDBeIbRABuDLoPlmcftNfEV8n2iYKf/HzJu3wZKyKoIzkW9SG4/xuSIoV7mAUP/Xy1ZB4jaSD6up57wWJMSlOMG1I0TsOm4RnNEcqwLrG6i9q4ZtzyW+V6tx7bLYc9kQWdhcsLc3rKq8xSyuFurP999rWS6EkGwpWRgR2AIxm4f5xmkmh5TSPUi9kzq//dzh0QLxZ+Qx7Vx5s+ANv/+DnYca3pff+Lq1lNYA2WMsFny3ZERu3zQRJoPUIHIff5ZlSA0V066hkJkcY7uTn+wr15L3UoBLF/6j+PfxaJfrATI+TZ9/v5CQOFgF1u2xa0dHHqbtBXEA3EiTQ/Yk4TjJkQf313GRC3QcKamVNLze00ta/xe5Gd82qnMwyTmzpk71lpN+50xm6pbNYDwyBsf1BPRo1Wr93N+gTvhEqpYQFvZ34gwP8De4cwTAkxxQlPPFiFKmdYGxiGCBr2m6CcwrmRnInuPq/YZksoJXIRTJqEKjNSEupcZ3OCkJdITQWxbhIG/cedgtMZPG/WB7e3wsA29xRrXrCcqYZnP/xMhRzTWxaOiOFkoEvexbqkpGCQ8ECLrz7dJbnlHhe9QGS3FzkZcBwy3DIi0Lfq3sVN1kru6RfiYRhJ7BQkregXaSOhNqUdh2bhq7/w2MhdzCyY+VAe81TIUlLmgU1mIZ6LFkV/qEAHBWbPmZhI1BCwMOxZtlOsJ/YG8kPIiwf/GjmWzQe5lD7BOlMdXxuCZ8zfOdPtNqxTUilNwbyYiVkbswxNmFgPd0YHess58KmM2kRscGfFJIV6Hd894a3t5/FHO6gcaFNlRQW27JjwSd4a5xjN+Qqd5oDbPHa2csEG7yzxDVy5i9Lie/8LGvLf5hJIkbpbwrbYd03NOn7dOgmHBEASRlLszy8C1R03DbmpkI+7Bd2AD2OLusyQYawqtUEGOc0DbqjsOM/mn5zjgcFfancSt95opy1JLIpi5zV5N5w5b8N9etSoWjcaYLZHRm/wBAv4QIPzANnjQFNFBN/47SypRlcdflvB1Egq3fyA9k8FDrIcishref0aKLKxqISrTqy10ef2RMJyn2Ltu3Q5H/r1sqqrP81pnNmlt8yrbshg8/9EdRYH0O8NdBFZ7TrNsCQiUy3tV8AM8dKDF+hqLg3TXE6MK2QNt0CbrWC6SuV3vrX+FcIioLHHbLAfhK0ttFs1Q X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3af3b36e-f593-426f-e951-08dabe30785e X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9448.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2022 06:47:41.5415 (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: HMevoGNNqJRIUJyiTKg121oyEC7AkVXlM4AXQSluVItjTMghtXDlDeVwlDEktTSPJxf2u1hjLgUpeckNebTtBQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8081 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 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?1748547181843700949?= X-GMAIL-MSGID: =?utf-8?q?1748547181843700949?= Add bindings for Cadence HDP-TX HDMI PHY. Signed-off-by: Sandor Yu --- .../bindings/phy/phy-cadence-hdptx-hdmi.yaml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/phy-cadence-hdptx-hdmi.yaml diff --git a/Documentation/devicetree/bindings/phy/phy-cadence-hdptx-hdmi.yaml b/Documentation/devicetree/bindings/phy/phy-cadence-hdptx-hdmi.yaml new file mode 100644 index 000000000000..edd7bf1c8920 --- /dev/null +++ b/Documentation/devicetree/bindings/phy/phy-cadence-hdptx-hdmi.yaml @@ -0,0 +1,54 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/phy/phy-cadence-hdptx-hdmi.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Cadence HDP(HDMI/DisplayPort) TX PHY for HDMI protocol binding + +description: + This binding describes the Cadence HDP-TX PHY for HDMI protocol. + +maintainers: + - Sandor Yu + +properties: + compatible: + enum: + - cdns,hdptx-hdmi-phy + + reg: + description: + Offset of Cadence HDPTX APB configuration registers. + + clocks: + items: + description: + PHY reference clock. Must contain an entry in clock-names. + + clock-names: + items: + - const: refclk + + "#phy-cells": + const: 0 + +required: + - compatible + - reg + - clocks + - clock-names + - "#phy-cells" + +additionalProperties: false + +examples: + - | + #include + hdmi_phy: hdmi_phy@32c00000 { + compatible = "cdns,hdptx-hdmi-phy"; + reg = <0x32c00000 0x100000>; + #phy-cells = <0>; + clocks = <&hdmi_phy_27m>; + clock-names = "refclk"; + }; From patchwork Fri Nov 4 06:45:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandor Yu X-Patchwork-Id: 15397 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp211366wru; Thu, 3 Nov 2022 23:49:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM70aRSqDPDUIyFrolIuBxPYFYBwl1FysmqAaWjDt/saoUL5PpuNRfaLeJ8X1IrkgKv7pBNq X-Received: by 2002:a17:902:d18c:b0:187:1b86:daba with SMTP id m12-20020a170902d18c00b001871b86dabamr26847599plb.84.1667544575537; Thu, 03 Nov 2022 23:49:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1667544575; cv=pass; d=google.com; s=arc-20160816; b=XhdAdEC/QPHNqAUkP7PvhmI0vQsF+0pXznB1GKWf2YBOLtV81Q3zoH90Fc3oj9cnyR lO34Tqb/da1UKxFAzwNoye+oz7cpzC0/g847sCK+UhFsWsLCQtWFlR2drxkvDKWAya29 sKJetTsYhM76gDWeiVddDs/f5xctrySV+MDz3QpITs85Kh5g7MZTnQRiiieFJpdg8FCZ e2FsrV05vlh07kja0Jl0+fLvXzGDb0KoauY5Nddo3Z8wL/wkBsauyTJrgQtKaqGgvPPb 2zNlrD4sujG+9W/zyHCmk1mbZkdrKUZqnXrLcYlKgcNj+73Do8fgZKHWkYFAiPFZqZvc r0Tg== 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=FnlzOrSNllhbIcnpa8O5rJqajl4zoHWjWYM1n7EYwl0=; b=WJ0GHLr5trfWa9dYsRRqI7oAnwRivzgBvx5XsHEpGlR1+OaNfWF6LCR5IrGAfl6eaB njpJfNt9U/RqRKURJPgDECpqBVS8BnI5/aFfZ1wFD5IIKmCh3as67jrpv4ZTSm9Y4gzX Z3S9O1YEkZCYiRNG3HH2d/VbQiOOB64725KTqiC0leFK/zEMthQuz4Jr2X/EpST25o6O oQKjsz5LWh/I3l/qg8mpk+FJKYULSrhXen8KlHr3yxZFU2nwx2pG7S2Q3UQgMgwAZdG7 mPq1GUc8FXwz1o8eMBHjh+zxYMXpZ4q+8NA6R6dS4Vgz/qiuxZuF3DjemptVOG1OQQEH 1o8g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=SU9Z947p; 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 n63-20020a632742000000b0046ece301e82si3868097pgn.756.2022.11.03.23.49.22; Thu, 03 Nov 2022 23:49:35 -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=SU9Z947p; 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 S231613AbiKDGsm (ORCPT + 99 others); Fri, 4 Nov 2022 02:48:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231538AbiKDGrz (ORCPT ); Fri, 4 Nov 2022 02:47:55 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2066.outbound.protection.outlook.com [40.107.21.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE3FC2AC53; Thu, 3 Nov 2022 23:47:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EiWkr+OfabeKXcAmgJF7NB7L1RrF9dbFcqdB9ai2n/V2dpqapnsCWMJ7JbRgsRhplal/QvjuGna7ov0OU3hOfWoLsn0B/9JqZhs0+bVEN/0h83/qAfFAHLlcHI/yQB+itoXu/QUfyRAI2Qh+6oC35T3CcIHzZr6MUQWtjkyvrNv6vRG1Ox1CK4rWTbJwx2ML7lgCCKzWWd/YkL5jouLAw1vdMKJffCvpEY6Z5et73Pt+CjFpDEkapwXCbEjDUtgsMUtMq1M4Bm8JYqsP6fHFzI3h01GfrOkCgZn56zIT6uaUgEUwkc517jdQdqVjYdDSNeafhOpQCMIcIeppI8mT9g== 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=FnlzOrSNllhbIcnpa8O5rJqajl4zoHWjWYM1n7EYwl0=; b=hSRzMvkQflx3Bgy738mOve0Nwrw2g8tJ+/6Cn4PQd4RRhQ6YBNKV7Q/k88Oa+3SRaeUGJ7XwMZKoYJwu3J50lgJzunAzyeELy4yJ5FSx8FUXmb8lOZiBNKSJJo7+j85tRU7YR/sZAS5q+7/pj1zHEE9H6HyJPs8bql8USc5toHRQh+y4Y+rY6Y8oahChj3eqlJU7H7b9NRWqNYketALSc60uORAAoBBlKsM2iJM5Lxc91Pdtwt0XCzE34Cc8G9ciAm889RiW6fwMYdIKrfOmAcfT62U99EYkz3MzA+ZHAYgCLKEU21HRNZvy9ybzB/15P15ZEfJ4oSKqxDawlrWMfQ== 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=FnlzOrSNllhbIcnpa8O5rJqajl4zoHWjWYM1n7EYwl0=; b=SU9Z947pgssEZ7Q/xFrTjsvO4s+ECBnK4a0yYJPx9k3F/mSbRYAkRvCqHIzSl850qqKvKtRCc6pBomPXBMXWKklRY8a6HKEWHLTX5JVLcsq8bi0gXnUpOeUW/trLfiimgGnMB7shDVPJnfZ2colF1z1iHoKFDLQTH3VDSzS274Q= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9448.eurprd04.prod.outlook.com (2603:10a6:102:2b1::21) by AM9PR04MB8081.eurprd04.prod.outlook.com (2603:10a6:20b:3e2::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.20; Fri, 4 Nov 2022 06:47:49 +0000 Received: from PAXPR04MB9448.eurprd04.prod.outlook.com ([fe80::88a0:57d8:2a57:3f4f]) by PAXPR04MB9448.eurprd04.prod.outlook.com ([fe80::88a0:57d8:2a57:3f4f%9]) with mapi id 15.20.5791.022; Fri, 4 Nov 2022 06:47:49 +0000 From: Sandor Yu To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, andrzej.hajda@intel.com, neil.armstrong@linaro.org, robert.foss@linaro.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, kishon@ti.com, vkoul@kernel.org Cc: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, linux-imx@nxp.com, tzimmermann@suse.de, lyude@redhat.com, Sandor.yu@nxp.com, javierm@redhat.com, ville.syrjala@linux.intel.com, sam@ravnborg.org, jani.nikula@intel.com, maxime@cerno.tech, penguin-kernel@I-love.SAKURA.ne.jp, p.yadav@ti.com, oliver.brown@nxp.com Subject: [v2 10/10] phy: cadence: Add driver for HDP-TX HDMI PHY Date: Fri, 4 Nov 2022 14:45:00 +0800 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-ClientProxiedBy: SG2PR06CA0194.apcprd06.prod.outlook.com (2603:1096:4:1::26) To PAXPR04MB9448.eurprd04.prod.outlook.com (2603:10a6:102:2b1::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9448:EE_|AM9PR04MB8081:EE_ X-MS-Office365-Filtering-Correlation-Id: 375f1f84-3c87-4cfb-c18a-08dabe307ce3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: g56AnRm+aGPoMp7LCy2x0hSDcgCP7dS5mrn7RxGghPFaz0MZ/uBq/j+2ZW/DsYzPcXcxpESUeT9sCMrJvFcLuxELHSQPRTX/rN2atsSTVivXukk0S2efARiwJZGZl5RWliJcBBs0CEly3fOFrTsVVNY52Zck1Wr1gH4E54+eJC8Gze3/Mjbupkjzpp0cB9jUCqMv+WJ2Hsh5ce+1uogUmdbEsLNrjOrWgVDJ8x0nYdLV1wYlEAHUigWVzYvkBrTYattcHvQfF9DacBFQ+W+DauJsuOd5sp5e8qpJFXL2BUGh+Ow2j6C6QotINLZBn+FdBcP4U5uav9Pk/E5IFv5Zqoe0CsAbFbiWCqyG2TQAQbywYZbF9BaI7nS60asQX0kzpIbhjnueWH4tImLROMolT2Racygb2pJJVQj6YVHUr2q02DyURI4iXCleRUQrEfKegYKbHr5S62vzNQ8VxOboLbJzSPHSQ8wHSH1CLvE67MaLX3SMBIYZxmavcGq256WUIyUCpobjod9lrsIJUJrStHVhIvqIHD83UF1//h/bGQ1wc/L6a1FKi+V5cXoCqzxKOHpkxfehdzI3UPIBRVrqd3JQDyhx6LArBsDTOCtc+pZAZTTPXjk/A4ff2IwyGXkQBCNSgsEy2cH9youdGUne25lnPbDQMkLZgh1Fwl/xczqv3GM8Zr7Vo7FPiPKZmwhI2VgvucR5USJHDhr/Zs14x3CpDMe4rirSBPlgcbt/B51mgVeArA0UToJGeiG6z6ena1B+SePH8P7FRd//YdnOhA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9448.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(376002)(39860400002)(366004)(136003)(396003)(451199015)(316002)(8676002)(38350700002)(30864003)(7416002)(5660300002)(66556008)(66476007)(38100700002)(4326008)(66946007)(36756003)(8936002)(41300700001)(83380400001)(6666004)(921005)(186003)(2616005)(86362001)(6486002)(26005)(478600001)(6512007)(52116002)(6506007)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 75Pfm8IEM9uOz4PSFuwWRRgvrUv7vFPW9kzPttARojv6E9I+mGiQzt8liBLxLQxac2AjdC0LrPsOCoAcE84vAOWj7SPu7tuLwhvBPBkj5n9B6+6KAkgaBURO0/7VJfxkIVMl4o5iNsGPjUS0LTuvOvAJ/kK3tDgHSDtfRuzR1vgUyi1UAOE6jKKvu0Q8DhqHCoZOe1/NZC2D7DsRUVpftYXDaIwme5VsudgPA1IJHnxYHod1Iy56zmUwhBwPPSIXNiCOpSFLKLtzgyTjsgU1MlQxQfIcs60gaBonY/y6Oz+p8QCrxknzX0wYCDHQI2u5HKLx8VxTMd6y2C8T5tB5BMc0Ca/TabfJYTX+9kiQBysA8JKPaRUjxmHnP5XqWRQkKr/eQJU6BACj5Z++kuVTxLeg9rFNR+DBZyeE9CVw2YWvjsfMcC5x6hWGVXRiDvZ9Dn9oA/otv/LJQgyFzIa6hvyZUreZN7rvRUkBziE80Kzn/iGIJ6bAGUHMGaSWV9cwLPlvZQFNgdUd1z1VE6SM5orMhFODR941bT9ph75BJ5OtEREgAThWl3Jvln/oSUvR6lF2W3Qn9yh8s2yQlae3jv2tlWSTJV158xoji9jsA/JGf3KveLvsE0Et1y/qf/5X9F2Ac+P/soNnZmasHi5/baMg1HhIEilrAkPGljfPCLn4cAbGPU70KCRnUjOvVNllqkWhojbKTOGhz9PYQ7TfcR51nGZtVauX3oncpP+CuSwy8LmtVXJ50qjjgH08v/GdRO2k9j2cI3x48JXoQkgY6TdWJfYGQ01GdPDo4Wde+M0FatMPazn6/RJ+QpVx7RFiBYkuMVHaXXb/crFNXb7+RTXATPhfdaf2Kcg4wpvXONmWshklIBP6f5B34/49vKe+HM4qUgYbAleLpKZXJdnnxwsavRXn/sqmdS7/XBN9erog3JVge8Cj4k4l/s7FAdQsCi7ENBbNdJmc7yFCcuVW1vn/jicCeeaQReHVk27d47tdmMH1uNCTg40nsG7jbS/eFO+hJLYbzfg2yLuSoRVbMw7iYhHak2PMGDGIz6OhmZpoJjnZH3PkME3G/9PvUdD4+JWVtV6yMJm3sfYkw31NSG0tD9tGjzbmkciJ35ssIBzM8B92dKiXk3A6Ta0ySm+LuaSF+sHBfveKyTrm/mo6Od61O25/rJ85h/NPYNrm1b9M1F9gk9zGKP22TZOSp13E1n5YWs/pnj0Jah4rCfvCXjx7g/wU9ECVRqGJuWw1ed3ATSReEHP0qX2lTxncHiljdfjbOW/1TRlzsffBbKT04gQh/k7nnBFGV0Vm75VgkXAF8tNC6nc8ayeTwZPfEeYpzhL53qHC35u1mvw8qRrikxsPdpvnSsyScSnj8Ipt0GeSeEAyggDr8M8pNB8nsbHGR+LUIHEzv8ZNiv85ht4MECUP64fV/3406djGkXGhZEv+TVWKrBE0APhxHuRuYq2Dcp3zvRzZWmM5jkE/EicG0KEDXcNFPBKWrty/HpjkYD0wTPO4nQBHGPCifUWT6iq55qGcauyEevzbj9DGb0nfY/6045k0EbTRbMM7nuZiRyTa70SG40yO1HTl4TLrl2I3 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 375f1f84-3c87-4cfb-c18a-08dabe307ce3 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9448.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2022 06:47:49.1854 (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: 2Al/BzUhf/xxKfHi2s1gWegVYv9CtLxwLgSpI36P6PcO2NQ17Viu+0pFMGZo93iL/39MArW3Cfip0gs6EL4jgg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8081 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 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?1748547220805343580?= X-GMAIL-MSGID: =?utf-8?q?1748547220805343580?= Add Cadence HDP-TX HDMI PHY driver. Cadence HDP-TX PHY could be put in either DP mode or HDMI mode base on the configuration chosen. HDMI PHY mode is configurated in the driver. Signed-off-by: Sandor Yu --- drivers/phy/cadence/Kconfig | 8 + drivers/phy/cadence/Makefile | 1 + drivers/phy/cadence/phy-cadence-hdptx-hdmi.c | 948 +++++++++++++++++++ 3 files changed, 957 insertions(+) create mode 100644 drivers/phy/cadence/phy-cadence-hdptx-hdmi.c diff --git a/drivers/phy/cadence/Kconfig b/drivers/phy/cadence/Kconfig index 1e1914d3afdc..b6eae2d4a52c 100644 --- a/drivers/phy/cadence/Kconfig +++ b/drivers/phy/cadence/Kconfig @@ -54,3 +54,11 @@ config PHY_CADENCE_HDPTX_DP select GENERIC_PHY help Enable this to support the Cadence HDPTX DP PHY driver + +config PHY_CADENCE_HDPTX_HDMI + tristate "Cadence HDPTX HDMI PHY Driver" + depends on OF && HAS_IOMEM + depends on COMMON_CLK + select GENERIC_PHY + help + Enable this to support the Cadence HDPTX HDMI PHY driver. diff --git a/drivers/phy/cadence/Makefile b/drivers/phy/cadence/Makefile index fbdb0bc5ff11..b5a676c1c54c 100644 --- a/drivers/phy/cadence/Makefile +++ b/drivers/phy/cadence/Makefile @@ -5,3 +5,4 @@ obj-$(CONFIG_PHY_CADENCE_DPHY_RX) += cdns-dphy-rx.o obj-$(CONFIG_PHY_CADENCE_SIERRA) += phy-cadence-sierra.o obj-$(CONFIG_PHY_CADENCE_SALVO) += phy-cadence-salvo.o obj-$(CONFIG_PHY_CADENCE_HDPTX_DP) += phy-cadence-hdptx-dp.o +obj-$(CONFIG_PHY_CADENCE_HDPTX_HDMI) += phy-cadence-hdptx-hdmi.o diff --git a/drivers/phy/cadence/phy-cadence-hdptx-hdmi.c b/drivers/phy/cadence/phy-cadence-hdptx-hdmi.c new file mode 100644 index 000000000000..396bcf0e1988 --- /dev/null +++ b/drivers/phy/cadence/phy-cadence-hdptx-hdmi.c @@ -0,0 +1,948 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Cadence High-Definition Multimedia Interface (HDMI) PHY driver + * + * Copyright (C) 2022 NXP Semiconductor, Inc. + */ +#include +#include +#include +#include +#include +#include + +#include + +#define ADDR_PHY_AFE 0x80000 +/* PHY registers */ +#define CMN_SSM_BIAS_TMR 0x0022 +#define CMN_PLLSM0_PLLEN_TMR 0x0029 +#define CMN_PLLSM0_PLLPRE_TMR 0x002A +#define CMN_PLLSM0_PLLVREF_TMR 0x002B +#define CMN_PLLSM0_PLLLOCK_TMR 0x002C +#define CMN_PLLSM0_USER_DEF_CTRL 0x002F +#define CMN_PSM_CLK_CTRL 0x0061 +#define CMN_CDIAG_REFCLK_CTRL 0x0062 +#define CMN_PLL0_VCOCAL_START 0x0081 +#define CMN_PLL0_VCOCAL_INIT_TMR 0x0084 +#define CMN_PLL0_VCOCAL_ITER_TMR 0x0085 +#define CMN_PLL0_INTDIV 0x0094 +#define CMN_PLL0_FRACDIV 0x0095 +#define CMN_PLL0_HIGH_THR 0x0096 +#define CMN_PLL0_DSM_DIAG 0x0097 +#define CMN_PLL0_SS_CTRL1 0x0098 +#define CMN_PLL0_SS_CTRL2 0x0099 +#define CMN_ICAL_INIT_TMR 0x00C4 +#define CMN_ICAL_ITER_TMR 0x00C5 +#define CMN_RXCAL_INIT_TMR 0x00D4 +#define CMN_RXCAL_ITER_TMR 0x00D5 +#define CMN_TXPUCAL_CTRL 0x00E0 +#define CMN_TXPUCAL_INIT_TMR 0x00E4 +#define CMN_TXPUCAL_ITER_TMR 0x00E5 +#define CMN_TXPDCAL_CTRL 0x00F0 +#define CMN_TXPDCAL_INIT_TMR 0x00F4 +#define CMN_TXPDCAL_ITER_TMR 0x00F5 +#define CMN_ICAL_ADJ_INIT_TMR 0x0102 +#define CMN_ICAL_ADJ_ITER_TMR 0x0103 +#define CMN_RX_ADJ_INIT_TMR 0x0106 +#define CMN_RX_ADJ_ITER_TMR 0x0107 +#define CMN_TXPU_ADJ_CTRL 0x0108 +#define CMN_TXPU_ADJ_INIT_TMR 0x010A +#define CMN_TXPU_ADJ_ITER_TMR 0x010B +#define CMN_TXPD_ADJ_CTRL 0x010c +#define CMN_TXPD_ADJ_INIT_TMR 0x010E +#define CMN_TXPD_ADJ_ITER_TMR 0x010F +#define CMN_DIAG_PLL0_FBH_OVRD 0x01C0 +#define CMN_DIAG_PLL0_FBL_OVRD 0x01C1 +#define CMN_DIAG_PLL0_OVRD 0x01C2 +#define CMN_DIAG_PLL0_TEST_MODE 0x01C4 +#define CMN_DIAG_PLL0_V2I_TUNE 0x01C5 +#define CMN_DIAG_PLL0_CP_TUNE 0x01C6 +#define CMN_DIAG_PLL0_LF_PROG 0x01C7 +#define CMN_DIAG_PLL0_PTATIS_TUNE1 0x01C8 +#define CMN_DIAG_PLL0_PTATIS_TUNE2 0x01C9 +#define CMN_DIAG_PLL0_INCLK_CTRL 0x01CA +#define CMN_DIAG_PLL0_PXL_DIVH 0x01CB +#define CMN_DIAG_PLL0_PXL_DIVL 0x01CC +#define CMN_DIAG_HSCLK_SEL 0x01E0 +#define CMN_DIAG_PER_CAL_ADJ 0x01EC +#define CMN_DIAG_CAL_CTRL 0x01ED +#define CMN_DIAG_ACYA 0x01FF +#define XCVR_PSM_RCTRL 0x4001 +#define XCVR_PSM_CAL_TMR 0x4002 +#define XCVR_PSM_A0IN_TMR 0x4003 +#define TX_TXCC_CAL_SCLR_MULT_0 0x4047 +#define TX_TXCC_CPOST_MULT_00_0 0x404C +#define TX_TXCC_MGNFS_MULT_000_0 0x4050 +#define XCVR_DIAG_PLLDRC_CTRL 0x40E0 +#define XCVR_DIAG_PLLDRC_CTRL 0x40E0 +#define XCVR_DIAG_HSCLK_SEL 0x40E1 +#define XCVR_DIAG_BIDI_CTRL 0x40E8 +#define XCVR_DIAG_LANE_FCM_EN_MGN_TMR 0x40F2 +#define XCVR_DIAG_LANE_FCM_EN_MGN 0x40F2 +#define TX_PSC_A0 0x4100 +#define TX_PSC_A1 0x4101 +#define TX_PSC_A2 0x4102 +#define TX_PSC_A3 0x4103 +#define TX_RCVDET_CTRL 0x4120 +#define TX_RCVDET_EN_TMR 0x4122 +#define TX_RCVDET_EN_TMR 0x4122 +#define TX_RCVDET_ST_TMR 0x4123 +#define TX_RCVDET_ST_TMR 0x4123 +#define TX_BIST_CTRL 0x4140 +#define TX_BIST_UDDWR 0x4141 +#define TX_DIAG_TX_CTRL 0x41E0 +#define TX_DIAG_TX_DRV 0x41E1 +#define TX_DIAG_BGREF_PREDRV_DELAY 0x41E7 +#define TX_DIAG_BGREF_PREDRV_DELAY 0x41E7 +#define XCVR_PSM_RCTRL_1 0x4201 +#define TX_TXCC_CAL_SCLR_MULT_1 0x4247 +#define TX_TXCC_CPOST_MULT_00_1 0x424C +#define TX_TXCC_MGNFS_MULT_000_1 0x4250 +#define XCVR_DIAG_PLLDRC_CTRL_1 0x42E0 +#define XCVR_DIAG_HSCLK_SEL_1 0x42E1 +#define XCVR_DIAG_LANE_FCM_EN_MGN_TMR_1 0x42F2 +#define TX_RCVDET_EN_TMR_1 0x4322 +#define TX_RCVDET_ST_TMR_1 0x4323 +#define TX_DIAG_ACYA_0 0x41FF +#define TX_DIAG_ACYA_1 0x43FF +#define TX_DIAG_ACYA_2 0x45FF +#define TX_DIAG_ACYA_3 0x47FF +#define TX_ANA_CTRL_REG_1 0x5020 +#define TX_ANA_CTRL_REG_2 0x5021 +#define TXDA_COEFF_CALC 0x5022 +#define TX_DIG_CTRL_REG_1 0x5023 +#define TX_DIG_CTRL_REG_2 0x5024 +#define TXDA_CYA_AUXDA_CYA 0x5025 +#define TX_ANA_CTRL_REG_3 0x5026 +#define TX_ANA_CTRL_REG_4 0x5027 +#define TX_ANA_CTRL_REG_5 0x5029 +#define RX_PSC_A0 0x8000 +#define RX_PSC_CAL 0x8006 +#define PMA_LANE_CFG 0xC000 +#define PIPE_CMN_CTRL1 0xC001 +#define PIPE_CMN_CTRL2 0xC002 +#define PIPE_COM_LOCK_CFG1 0xC003 +#define PIPE_COM_LOCK_CFG2 0xC004 +#define PIPE_RCV_DET_INH 0xC005 +#define PHY_HDP_MODE_CTRL 0xC008 +#define PHY_HDP_CLK_CTL 0xC009 +#define STS 0xC00F +#define PHY_ISO_CMN_CTRL 0xC010 +#define PHY_ISO_CMN_CTRL 0xC010 +#define PHY_HDP_TX_CTL_L0 0xC408 +#define PHY_DP_TX_CTL 0xC408 +#define PHY_HDP_TX_CTL_L1 0xC448 +#define PHY_HDP_TX_CTL_L2 0xC488 +#define PHY_HDP_TX_CTL_L3 0xC4C8 +#define PHY_PMA_CMN_CTRL1 0xC800 +#define PMA_CMN_CTRL1 0xC800 +#define PHY_PMA_ISO_CMN_CTRL 0xC810 +#define PHY_PMA_ISO_PLL_CTRL1 0xC812 +#define PHY_PMA_ISOLATION_CTRL 0xC81F +#define PHY_ISOLATION_CTRL 0xC81F +#define PHY_PMA_ISO_XCVR_CTRL 0xCC11 +#define PHY_PMA_ISO_LINK_MODE 0xCC12 +#define PHY_PMA_ISO_PWRST_CTRL 0xCC13 +#define PHY_PMA_ISO_TX_DATA_LO 0xCC14 +#define PHY_PMA_ISO_TX_DATA_HI 0xCC15 +#define PHY_PMA_ISO_RX_DATA_LO 0xCC16 +#define PHY_PMA_ISO_RX_DATA_HI 0xCC17 + +#define REF_CLK_27MHZ 27000000 + +/* HDMI TX clock control settings */ +struct hdptx_hdmi_ctrl { + u32 pixel_clk_freq_min; + u32 pixel_clk_freq_max; + u32 feedback_factor; + u32 data_range_kbps_min; + u32 data_range_kbps_max; + u32 cmnda_pll0_ip_div; + u32 cmn_ref_clk_dig_div; + u32 ref_clk_divider_scaler; + u32 pll_fb_div_total; + u32 cmnda_pll0_fb_div_low; + u32 cmnda_pll0_fb_div_high; + u32 pixel_div_total; + u32 cmnda_pll0_pxdiv_low; + u32 cmnda_pll0_pxdiv_high; + u32 vco_freq_min; + u32 vco_freq_max; + u32 vco_ring_select; + u32 cmnda_hs_clk_0_sel; + u32 cmnda_hs_clk_1_sel; + u32 hsclk_div_at_xcvr; + u32 hsclk_div_tx_sub_rate; + u32 cmnda_pll0_hs_sym_div_sel; + u32 cmnda_pll0_clk_freq_min; + u32 cmnda_pll0_clk_freq_max; +}; + +struct cdns_hdptx_hdmi_phy { + void __iomem *regs; /* DPTX registers base */ + struct mutex mbox_mutex; /* mutex to protect mailbox */ + struct device *dev; + struct phy *phy; + struct clk *ref_clk; + u32 ref_clk_rate; + u32 pixel_clk_rate; + enum hdmi_phy_colorspace color_space; + u32 bpc; +}; + +/* HDMI TX clock control settings, pixel clock is output */ +static const struct hdptx_hdmi_ctrl pixel_clk_output_ctrl_table[] = { +/*Minclk Maxclk Fdbak DR_min DR_max ip_d dig DS Totl */ +{ 27000, 27000, 1000, 270000, 270000, 0x03, 0x1, 0x1, 240, 0x0BC, 0x030, 80, 0x026, 0x026, 2160000, 2160000, 0, 2, 2, 2, 4, 0x3, 27000, 27000}, +{ 27000, 27000, 1250, 337500, 337500, 0x03, 0x1, 0x1, 300, 0x0EC, 0x03C, 100, 0x030, 0x030, 2700000, 2700000, 0, 2, 2, 2, 4, 0x3, 33750, 33750}, +{ 27000, 27000, 1500, 405000, 405000, 0x03, 0x1, 0x1, 360, 0x11C, 0x048, 120, 0x03A, 0x03A, 3240000, 3240000, 0, 2, 2, 2, 4, 0x3, 40500, 40500}, +{ 27000, 27000, 2000, 540000, 540000, 0x03, 0x1, 0x1, 240, 0x0BC, 0x030, 80, 0x026, 0x026, 2160000, 2160000, 0, 2, 2, 2, 4, 0x2, 54000, 54000}, +{ 54000, 54000, 1000, 540000, 540000, 0x03, 0x1, 0x1, 480, 0x17C, 0x060, 80, 0x026, 0x026, 4320000, 4320000, 1, 2, 2, 2, 4, 0x3, 54000, 54000}, +{ 54000, 54000, 1250, 675000, 675000, 0x04, 0x1, 0x1, 400, 0x13C, 0x050, 50, 0x017, 0x017, 2700000, 2700000, 0, 1, 1, 2, 4, 0x2, 67500, 67500}, +{ 54000, 54000, 1500, 810000, 810000, 0x04, 0x1, 0x1, 480, 0x17C, 0x060, 60, 0x01C, 0x01C, 3240000, 3240000, 0, 2, 2, 2, 2, 0x2, 81000, 81000}, +{ 54000, 54000, 2000, 1080000, 1080000, 0x03, 0x1, 0x1, 240, 0x0BC, 0x030, 40, 0x012, 0x012, 2160000, 2160000, 0, 2, 2, 2, 1, 0x1, 108000, 108000}, +{ 74250, 74250, 1000, 742500, 742500, 0x03, 0x1, 0x1, 660, 0x20C, 0x084, 80, 0x026, 0x026, 5940000, 5940000, 1, 2, 2, 2, 4, 0x3, 74250, 74250}, +{ 74250, 74250, 1250, 928125, 928125, 0x04, 0x1, 0x1, 550, 0x1B4, 0x06E, 50, 0x017, 0x017, 3712500, 3712500, 1, 1, 1, 2, 4, 0x2, 92812, 92812}, +{ 74250, 74250, 1500, 1113750, 1113750, 0x04, 0x1, 0x1, 660, 0x20C, 0x084, 60, 0x01C, 0x01C, 4455000, 4455000, 1, 2, 2, 2, 2, 0x2, 111375, 111375}, +{ 74250, 74250, 2000, 1485000, 1485000, 0x03, 0x1, 0x1, 330, 0x104, 0x042, 40, 0x012, 0x012, 2970000, 2970000, 0, 2, 2, 2, 1, 0x1, 148500, 148500}, +{ 99000, 99000, 1000, 990000, 990000, 0x03, 0x1, 0x1, 440, 0x15C, 0x058, 40, 0x012, 0x012, 3960000, 3960000, 1, 2, 2, 2, 2, 0x2, 99000, 99000}, +{ 99000, 99000, 1250, 1237500, 1237500, 0x03, 0x1, 0x1, 275, 0x0D8, 0x037, 25, 0x00B, 0x00A, 2475000, 2475000, 0, 1, 1, 2, 2, 0x1, 123750, 123750}, +{ 99000, 99000, 1500, 1485000, 1485000, 0x03, 0x1, 0x1, 330, 0x104, 0x042, 30, 0x00D, 0x00D, 2970000, 2970000, 0, 2, 2, 2, 1, 0x1, 148500, 148500}, +{ 99000, 99000, 2000, 1980000, 1980000, 0x03, 0x1, 0x1, 440, 0x15C, 0x058, 40, 0x012, 0x012, 3960000, 3960000, 1, 2, 2, 2, 1, 0x1, 198000, 198000}, +{148500, 148500, 1000, 1485000, 1485000, 0x03, 0x1, 0x1, 660, 0x20C, 0x084, 40, 0x012, 0x012, 5940000, 5940000, 1, 2, 2, 2, 2, 0x2, 148500, 148500}, +{148500, 148500, 1250, 1856250, 1856250, 0x04, 0x1, 0x1, 550, 0x1B4, 0x06E, 25, 0x00B, 0x00A, 3712500, 3712500, 1, 1, 1, 2, 2, 0x1, 185625, 185625}, +{148500, 148500, 1500, 2227500, 2227500, 0x03, 0x1, 0x1, 495, 0x188, 0x063, 30, 0x00D, 0x00D, 4455000, 4455000, 1, 1, 1, 2, 2, 0x1, 222750, 222750}, +{148500, 148500, 2000, 2970000, 2970000, 0x03, 0x1, 0x1, 660, 0x20C, 0x084, 40, 0x012, 0x012, 5940000, 5940000, 1, 2, 2, 2, 1, 0x1, 297000, 297000}, +{198000, 198000, 1000, 1980000, 1980000, 0x03, 0x1, 0x1, 220, 0x0AC, 0x02C, 10, 0x003, 0x003, 1980000, 1980000, 0, 1, 1, 2, 1, 0x0, 198000, 198000}, +{198000, 198000, 1250, 2475000, 2475000, 0x03, 0x1, 0x1, 550, 0x1B4, 0x06E, 25, 0x00B, 0x00A, 4950000, 4950000, 1, 1, 1, 2, 2, 0x1, 247500, 247500}, +{198000, 198000, 1500, 2970000, 2970000, 0x03, 0x1, 0x1, 330, 0x104, 0x042, 15, 0x006, 0x005, 2970000, 2970000, 0, 1, 1, 2, 1, 0x0, 297000, 297000}, +{198000, 198000, 2000, 3960000, 3960000, 0x03, 0x1, 0x1, 440, 0x15C, 0x058, 20, 0x008, 0x008, 3960000, 3960000, 1, 1, 1, 2, 1, 0x0, 396000, 396000}, +{297000, 297000, 1000, 2970000, 2970000, 0x03, 0x1, 0x1, 330, 0x104, 0x042, 10, 0x003, 0x003, 2970000, 2970000, 0, 1, 1, 2, 1, 0x0, 297000, 297000}, +{297000, 297000, 1500, 4455000, 4455000, 0x03, 0x1, 0x1, 495, 0x188, 0x063, 15, 0x006, 0x005, 4455000, 4455000, 1, 1, 1, 2, 1, 0x0, 445500, 445500}, +{297000, 297000, 2000, 5940000, 5940000, 0x03, 0x1, 0x1, 660, 0x20C, 0x084, 20, 0x008, 0x008, 5940000, 5940000, 1, 1, 1, 2, 1, 0x0, 594000, 594000}, +{594000, 594000, 1000, 5940000, 5940000, 0x03, 0x1, 0x1, 660, 0x20C, 0x084, 10, 0x003, 0x003, 5940000, 5940000, 1, 1, 1, 2, 1, 0x0, 594000, 594000}, +{594000, 594000, 750, 4455000, 4455000, 0x03, 0x1, 0x1, 495, 0x188, 0x063, 10, 0x003, 0x003, 4455000, 4455000, 1, 1, 1, 2, 1, 0x0, 445500, 445500}, +{594000, 594000, 625, 3712500, 3712500, 0x04, 0x1, 0x1, 550, 0x1B4, 0x06E, 10, 0x003, 0x003, 3712500, 3712500, 1, 1, 1, 2, 1, 0x0, 371250, 371250}, +{594000, 594000, 500, 2970000, 2970000, 0x03, 0x1, 0x1, 660, 0x20C, 0x084, 10, 0x003, 0x003, 5940000, 5940000, 1, 1, 1, 2, 2, 0x1, 297000, 297000}, +}; + +/* HDMI TX PLL tuning settings */ +struct hdptx_hdmi_pll_tuning { + u32 vco_freq_bin; + u32 vco_freq_min; + u32 vco_freq_max; + u32 volt_to_current_coarse; + u32 volt_to_current; + u32 ndac_ctrl; + u32 pmos_ctrl; + u32 ptat_ndac_ctrl; + u32 feedback_div_total; + u32 charge_pump_gain; + u32 coarse_code; + u32 v2i_code; + u32 vco_cal_code; +}; + +/* HDMI TX PLL tuning settings, pixel clock is output */ +static const struct hdptx_hdmi_pll_tuning pixel_clk_output_pll_table[] = { +/*bin VCO_freq min/max coar cod NDAC PMOS PTAT div-T P-Gain Coa V2I CAL */ +{ 1, 1980000, 1980000, 0x4, 0x3, 0x0, 0x09, 0x09, 220, 0x42, 160, 5, 183 }, +{ 2, 2160000, 2160000, 0x4, 0x3, 0x0, 0x09, 0x09, 240, 0x42, 166, 6, 208 }, +{ 3, 2475000, 2475000, 0x5, 0x3, 0x1, 0x00, 0x07, 275, 0x42, 167, 6, 209 }, +{ 4, 2700000, 2700000, 0x5, 0x3, 0x1, 0x00, 0x07, 300, 0x42, 188, 6, 230 }, +{ 4, 2700000, 2700000, 0x5, 0x3, 0x1, 0x00, 0x07, 400, 0x4C, 188, 6, 230 }, +{ 5, 2970000, 2970000, 0x6, 0x3, 0x1, 0x00, 0x07, 330, 0x42, 183, 6, 225 }, +{ 6, 3240000, 3240000, 0x6, 0x3, 0x1, 0x00, 0x07, 360, 0x42, 203, 7, 256 }, +{ 6, 3240000, 3240000, 0x6, 0x3, 0x1, 0x00, 0x07, 480, 0x4C, 203, 7, 256 }, +{ 7, 3712500, 3712500, 0x4, 0x3, 0x0, 0x07, 0x0F, 550, 0x4C, 212, 7, 257 }, +{ 8, 3960000, 3960000, 0x5, 0x3, 0x0, 0x07, 0x0F, 440, 0x42, 184, 6, 226 }, +{ 9, 4320000, 4320000, 0x5, 0x3, 0x1, 0x07, 0x0F, 480, 0x42, 205, 7, 258 }, +{ 10, 4455000, 4455000, 0x5, 0x3, 0x0, 0x07, 0x0F, 495, 0x42, 219, 7, 272 }, +{ 10, 4455000, 4455000, 0x5, 0x3, 0x0, 0x07, 0x0F, 660, 0x4C, 219, 7, 272 }, +{ 11, 4950000, 4950000, 0x6, 0x3, 0x1, 0x00, 0x07, 550, 0x42, 213, 7, 258 }, +{ 12, 5940000, 5940000, 0x7, 0x3, 0x1, 0x00, 0x07, 660, 0x42, 244, 8, 292 }, +}; + +static int cdns_phy_reg_write(struct cdns_hdptx_hdmi_phy *cdns_phy, u32 addr, u32 val) +{ + return cdns_mhdp_reg_write(cdns_phy, ADDR_PHY_AFE + (addr << 2), val); +} + +static u32 cdns_phy_reg_read(struct cdns_hdptx_hdmi_phy *cdns_phy, u32 addr) +{ + u32 reg32; + + cdns_mhdp_reg_read(cdns_phy, ADDR_PHY_AFE + (addr << 2), ®32); + + return reg32; +} + +#define KEEP_ALIVE 0x18 +static bool hdptx_phy_check_alive(struct cdns_hdptx_hdmi_phy *cdns_phy) +{ + u32 alive, newalive; + u8 retries_left = 50; + + alive = readl(cdns_phy->regs + KEEP_ALIVE); + + while (retries_left--) { + udelay(2); + + newalive = readl(cdns_phy->regs + KEEP_ALIVE); + if (alive == newalive) + continue; + return true; + } + return false; +} + +static int hdptx_hdmi_ref_clk(struct cdns_hdptx_hdmi_phy *cdns_phy) +{ + struct device *dev = cdns_phy->dev; + u32 ref_clk_rate; + int ret; + + cdns_phy->ref_clk = devm_clk_get(dev, "refclk"); + if (IS_ERR(cdns_phy->ref_clk)) { + dev_err(dev, "phy ref clock not found\n"); + return PTR_ERR(cdns_phy->ref_clk); + } + + ret = clk_prepare_enable(cdns_phy->ref_clk); + if (ret) { + dev_err(cdns_phy->dev, "Failed to prepare ref clock\n"); + return ret; + } + + ref_clk_rate = clk_get_rate(cdns_phy->ref_clk); + if (!ref_clk_rate) { + dev_err(cdns_phy->dev, "Failed to get ref clock rate\n"); + goto err_ref_clk; + } + + if (ref_clk_rate == REF_CLK_27MHZ) + cdns_phy->ref_clk_rate = ref_clk_rate; + else { + dev_err(cdns_phy->dev, "Not support Ref Clock Rate(%dHz)\n", ref_clk_rate); + goto err_ref_clk; + } + + return 0; + +err_ref_clk: + clk_disable_unprepare(cdns_phy->ref_clk); + return -EINVAL; +} + +static void hdptx_hdmi_arc_config(struct cdns_hdptx_hdmi_phy *cdns_phy) +{ + u16 txpu_calib_code; + u16 txpd_calib_code; + u16 txpu_adj_calib_code; + u16 txpd_adj_calib_code; + u16 prev_calib_code; + u16 new_calib_code; + u16 rdata; + + /* Power ARC */ + cdns_phy_reg_write(cdns_phy, TXDA_CYA_AUXDA_CYA, 0x0001); + + prev_calib_code = cdns_phy_reg_read(cdns_phy, TX_DIG_CTRL_REG_2); + txpu_calib_code = cdns_phy_reg_read(cdns_phy, CMN_TXPUCAL_CTRL); + txpd_calib_code = cdns_phy_reg_read(cdns_phy, CMN_TXPDCAL_CTRL); + txpu_adj_calib_code = cdns_phy_reg_read(cdns_phy, CMN_TXPU_ADJ_CTRL); + txpd_adj_calib_code = cdns_phy_reg_read(cdns_phy, CMN_TXPD_ADJ_CTRL); + + new_calib_code = ((txpu_calib_code + txpd_calib_code) / 2) + + txpu_adj_calib_code + txpd_adj_calib_code; + + if (new_calib_code != prev_calib_code) { + rdata = cdns_phy_reg_read(cdns_phy, TX_ANA_CTRL_REG_1); + rdata &= 0xDFFF; + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_1, rdata); + cdns_phy_reg_write(cdns_phy, TX_DIG_CTRL_REG_2, new_calib_code); + mdelay(10); + rdata |= 0x2000; + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_1, rdata); + udelay(150); + } + + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_2, 0x0100); + udelay(100); + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_2, 0x0300); + udelay(100); + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_3, 0x0000); + udelay(100); + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_1, 0x2008); + udelay(100); + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_1, 0x2018); + udelay(100); + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_1, 0x2098); + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_2, 0x030C); + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_5, 0x0010); + udelay(100); + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_4, 0x4001); + mdelay(5); + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_1, 0x2198); + mdelay(5); + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_2, 0x030D); + udelay(100); + cdns_phy_reg_write(cdns_phy, TX_ANA_CTRL_REG_2, 0x030F); +} + +static void hdptx_hdmi_phy_set_vswing(struct cdns_hdptx_hdmi_phy *cdns_phy) +{ + u32 k; + const u32 num_lanes = 4; + + for (k = 0; k < num_lanes; k++) { + cdns_phy_reg_write(cdns_phy, (TX_DIAG_TX_DRV | (k << 9)), 0x7c0); + cdns_phy_reg_write(cdns_phy, (TX_TXCC_CPOST_MULT_00_0 | (k << 9)), 0x0); + cdns_phy_reg_write(cdns_phy, (TX_TXCC_CAL_SCLR_MULT_0 | (k << 9)), 0x120); + } +} + +static int hdptx_hdmi_feedback_factor(struct cdns_hdptx_hdmi_phy *cdns_phy) +{ + u32 feedback_factor; + + switch (cdns_phy->color_space) { + case HDMI_PHY_COLORSPACE_YUV422: + feedback_factor = 1000; + break; + case HDMI_PHY_COLORSPACE_YUV420: + switch (cdns_phy->bpc) { + case 8: + feedback_factor = 500; + break; + case 10: + feedback_factor = 625; + break; + case 12: + feedback_factor = 750; + break; + case 16: + feedback_factor = 1000; + break; + default: + dev_dbg(cdns_phy->dev, "Invalid ColorDepth\n"); + return 0; + } + break; + default: + /* Assume RGB/YUV444 */ + switch (cdns_phy->bpc) { + case 10: + feedback_factor = 1250; + break; + case 12: + feedback_factor = 1500; + break; + case 16: + feedback_factor = 2000; + break; + default: + feedback_factor = 1000; + } + } + + return feedback_factor; +} + +static int hdptx_hdmi_phy_config(struct cdns_hdptx_hdmi_phy *cdns_phy, + const struct hdptx_hdmi_ctrl *p_ctrl_table, + const struct hdptx_hdmi_pll_tuning *p_pll_table, + char pclk_in) +{ + const u32 num_lanes = 4; + u32 val, i, k; + + /* enable PHY isolation mode only for CMN */ + cdns_phy_reg_write(cdns_phy, PHY_PMA_ISOLATION_CTRL, 0xD000); + + /* set cmn_pll0_clk_datart1_div/cmn_pll0_clk_datart0_div dividers */ + val = cdns_phy_reg_read(cdns_phy, PHY_PMA_ISO_PLL_CTRL1); + val &= 0xFF00; + val |= 0x0012; + cdns_phy_reg_write(cdns_phy, PHY_PMA_ISO_PLL_CTRL1, val); + + /* assert PHY reset from isolation register */ + cdns_phy_reg_write(cdns_phy, PHY_ISO_CMN_CTRL, 0x0000); + /* assert PMA CMN reset */ + cdns_phy_reg_write(cdns_phy, PHY_PMA_ISO_CMN_CTRL, 0x0000); + + /* register XCVR_DIAG_BIDI_CTRL */ + for (k = 0; k < num_lanes; k++) + cdns_phy_reg_write(cdns_phy, XCVR_DIAG_BIDI_CTRL | (k << 9), 0x00FF); + + /* Describing Task phy_cfg_hdp */ + + val = cdns_phy_reg_read(cdns_phy, PHY_PMA_CMN_CTRL1); + val &= 0xFFF7; + val |= 0x0008; + cdns_phy_reg_write(cdns_phy, PHY_PMA_CMN_CTRL1, val); + + /* PHY Registers */ + val = cdns_phy_reg_read(cdns_phy, PHY_PMA_CMN_CTRL1); + val &= 0xCFFF; + val |= p_ctrl_table->cmn_ref_clk_dig_div << 12; + cdns_phy_reg_write(cdns_phy, PHY_PMA_CMN_CTRL1, val); + + val = cdns_phy_reg_read(cdns_phy, PHY_HDP_CLK_CTL); + val &= 0x00FF; + val |= 0x1200; + cdns_phy_reg_write(cdns_phy, PHY_HDP_CLK_CTL, val); + + /* Common control module control and diagnostic registers */ + val = cdns_phy_reg_read(cdns_phy, CMN_CDIAG_REFCLK_CTRL); + val &= 0x8FFF; + val |= p_ctrl_table->ref_clk_divider_scaler << 12; + val |= 0x00C0; + cdns_phy_reg_write(cdns_phy, CMN_CDIAG_REFCLK_CTRL, val); + + /* High speed clock used */ + val = cdns_phy_reg_read(cdns_phy, CMN_DIAG_HSCLK_SEL); + val &= 0xFF00; + val |= (p_ctrl_table->cmnda_hs_clk_0_sel >> 1) << 0; + val |= (p_ctrl_table->cmnda_hs_clk_1_sel >> 1) << 4; + cdns_phy_reg_write(cdns_phy, CMN_DIAG_HSCLK_SEL, val); + + for (k = 0; k < num_lanes; k++) { + val = cdns_phy_reg_read(cdns_phy, (XCVR_DIAG_HSCLK_SEL | (k << 9))); + val &= 0xCFFF; + val |= (p_ctrl_table->cmnda_hs_clk_0_sel >> 1) << 12; + cdns_phy_reg_write(cdns_phy, (XCVR_DIAG_HSCLK_SEL | (k << 9)), val); + } + + /* PLL 0 control state machine registers */ + val = p_ctrl_table->vco_ring_select << 12; + cdns_phy_reg_write(cdns_phy, CMN_PLLSM0_USER_DEF_CTRL, val); + + if (pclk_in == true) + val = 0x30A0; + else { + val = cdns_phy_reg_read(cdns_phy, CMN_PLL0_VCOCAL_START); + val &= 0xFE00; + val |= p_pll_table->vco_cal_code; + } + cdns_phy_reg_write(cdns_phy, CMN_PLL0_VCOCAL_START, val); + + cdns_phy_reg_write(cdns_phy, CMN_PLL0_VCOCAL_INIT_TMR, 0x0064); + cdns_phy_reg_write(cdns_phy, CMN_PLL0_VCOCAL_ITER_TMR, 0x000A); + + /* Common functions control and diagnostics registers */ + val = p_ctrl_table->cmnda_pll0_hs_sym_div_sel << 8; + val |= p_ctrl_table->cmnda_pll0_ip_div; + cdns_phy_reg_write(cdns_phy, CMN_DIAG_PLL0_INCLK_CTRL, val); + + cdns_phy_reg_write(cdns_phy, CMN_DIAG_PLL0_OVRD, 0x0000); + + val = p_ctrl_table->cmnda_pll0_fb_div_high; + val |= (1 << 15); + cdns_phy_reg_write(cdns_phy, CMN_DIAG_PLL0_FBH_OVRD, val); + + val = p_ctrl_table->cmnda_pll0_fb_div_low; + val |= (1 << 15); + cdns_phy_reg_write(cdns_phy, CMN_DIAG_PLL0_FBL_OVRD, val); + + if (pclk_in == false) { + val = p_ctrl_table->cmnda_pll0_pxdiv_low; + cdns_phy_reg_write(cdns_phy, CMN_DIAG_PLL0_PXL_DIVL, val); + + val = p_ctrl_table->cmnda_pll0_pxdiv_high; + val |= (1 << 15); + cdns_phy_reg_write(cdns_phy, CMN_DIAG_PLL0_PXL_DIVH, val); + } + + val = p_pll_table->volt_to_current_coarse; + val |= (p_pll_table->volt_to_current) << 4; + cdns_phy_reg_write(cdns_phy, CMN_DIAG_PLL0_V2I_TUNE, val); + + val = p_pll_table->charge_pump_gain; + cdns_phy_reg_write(cdns_phy, CMN_DIAG_PLL0_CP_TUNE, val); + + cdns_phy_reg_write(cdns_phy, CMN_DIAG_PLL0_LF_PROG, 0x0008); + + val = p_pll_table->pmos_ctrl; + val |= (p_pll_table->ndac_ctrl) << 8; + cdns_phy_reg_write(cdns_phy, CMN_DIAG_PLL0_PTATIS_TUNE1, val); + + val = p_pll_table->ptat_ndac_ctrl; + cdns_phy_reg_write(cdns_phy, CMN_DIAG_PLL0_PTATIS_TUNE2, val); + + if (pclk_in == true) + cdns_phy_reg_write(cdns_phy, CMN_DIAG_PLL0_TEST_MODE, 0x0022); + else + cdns_phy_reg_write(cdns_phy, CMN_DIAG_PLL0_TEST_MODE, 0x0020); + + cdns_phy_reg_write(cdns_phy, CMN_PSM_CLK_CTRL, 0x0016); + + /* Transceiver control and diagnostic registers */ + for (k = 0; k < num_lanes; k++) { + val = cdns_phy_reg_read(cdns_phy, (XCVR_DIAG_PLLDRC_CTRL | (k << 9))); + val &= 0xBFFF; + cdns_phy_reg_write(cdns_phy, (XCVR_DIAG_PLLDRC_CTRL | (k << 9)), val); + } + + for (k = 0; k < num_lanes; k++) { + val = cdns_phy_reg_read(cdns_phy, (TX_DIAG_TX_CTRL | (k << 9))); + val &= 0xFF3F; + val |= (p_ctrl_table->hsclk_div_tx_sub_rate >> 1) << 6; + cdns_phy_reg_write(cdns_phy, (TX_DIAG_TX_CTRL | (k << 9)), val); + } + + val = cdns_phy_reg_read(cdns_phy, PHY_PMA_CMN_CTRL1); + val &= 0xFF8F; + /* + * single ended reference clock (val |= 0x0030); + * differential clock (val |= 0x0000); + * for differential clock on the refclk_p and + * refclk_m off chip pins: CMN_DIAG_ACYA[8]=1'b1 + * cdns_phy_reg_write(cdns_phy, CMN_DIAG_ACYA, 0x0100); + */ + val |= 0x0030; + cdns_phy_reg_write(cdns_phy, PHY_PMA_CMN_CTRL1, val); + + /* Deassert PHY reset */ + cdns_phy_reg_write(cdns_phy, PHY_ISO_CMN_CTRL, 0x0001); + cdns_phy_reg_write(cdns_phy, PHY_PMA_ISO_CMN_CTRL, 0x0003); + + /* Power state machine registers */ + for (k = 0; k < num_lanes; k++) + cdns_phy_reg_write(cdns_phy, XCVR_PSM_RCTRL | (k << 9), 0xFEFC); + + /* Assert cmn_macro_pwr_en */ + cdns_phy_reg_write(cdns_phy, PHY_PMA_ISO_CMN_CTRL, 0x0013); + + /* wait for cmn_macro_pwr_en_ack */ + for (i = 0; i < 10; i++) { + val = cdns_phy_reg_read(cdns_phy, PHY_PMA_ISO_CMN_CTRL); + if (val & (1 << 5)) + break; + msleep(20); + } + if (i == 10) { + dev_err(cdns_phy->dev, "PMA output macro power up failed\n"); + return -1; + } + + /* wait for cmn_ready */ + for (i = 0; i < 10; i++) { + val = cdns_phy_reg_read(cdns_phy, PHY_PMA_CMN_CTRL1); + if (val & (1 << 0)) + break; + msleep(20); + } + if (i == 10) { + dev_err(cdns_phy->dev, "PMA output ready failed\n"); + return -1; + } + + for (k = 0; k < num_lanes; k++) { + cdns_phy_reg_write(cdns_phy, TX_PSC_A0 | (k << 9), 0x6791); + cdns_phy_reg_write(cdns_phy, TX_PSC_A1 | (k << 9), 0x6790); + cdns_phy_reg_write(cdns_phy, TX_PSC_A2 | (k << 9), 0x0090); + cdns_phy_reg_write(cdns_phy, TX_PSC_A3 | (k << 9), 0x0090); + + val = cdns_phy_reg_read(cdns_phy, RX_PSC_CAL | (k << 9)); + val &= 0xFFBB; + cdns_phy_reg_write(cdns_phy, RX_PSC_CAL | (k << 9), val); + + val = cdns_phy_reg_read(cdns_phy, RX_PSC_A0 | (k << 9)); + val &= 0xFFBB; + cdns_phy_reg_write(cdns_phy, RX_PSC_A0 | (k << 9), val); + } + return 0; +} + +static int hdptx_hdmi_phy_cfg(struct cdns_hdptx_hdmi_phy *cdns_phy, u32 rate) +{ + const struct hdptx_hdmi_ctrl *p_ctrl_table; + const struct hdptx_hdmi_pll_tuning *p_pll_table; + const u32 refclk_freq_khz = cdns_phy->ref_clk_rate / 1000; + const u8 pclk_in = false; + u32 pixel_freq = rate; + u32 vco_freq, char_freq; + u32 div_total, feedback_factor; + u32 i, ret; + + feedback_factor = hdptx_hdmi_feedback_factor(cdns_phy); + + char_freq = pixel_freq * feedback_factor / 1000; + + dev_dbg(cdns_phy->dev, "Pixel clock: (%d KHz), character clock: %d, bpc is (%0d-bit)\n", + pixel_freq, char_freq, cdns_phy->bpc); + + /* Get right row from the ctrl_table table. + * Check if 'pixel_freq_khz' value matches the PIXEL_CLK_FREQ column. + * Consider only the rows with FEEDBACK_FACTOR column matching feedback_factor. + */ + for (i = 0; i < ARRAY_SIZE(pixel_clk_output_ctrl_table); i++) { + if (feedback_factor == pixel_clk_output_ctrl_table[i].feedback_factor && + pixel_freq == pixel_clk_output_ctrl_table[i].pixel_clk_freq_min) { + p_ctrl_table = &pixel_clk_output_ctrl_table[i]; + break; + } + } + if (i == ARRAY_SIZE(pixel_clk_output_ctrl_table)) { + dev_warn(cdns_phy->dev, "Pixel clk (%d KHz) not supported, bpc is (%0d-bit)\n", + pixel_freq, cdns_phy->bpc); + return 0; + } + + div_total = p_ctrl_table->pll_fb_div_total; + vco_freq = refclk_freq_khz * div_total / p_ctrl_table->cmnda_pll0_ip_div; + + /* Get right row from the pixel_clk_output_pll_table table. + * Check if vco_freq_khz and feedback_div_total + * column matching with pixel_clk_output_pll_table. + */ + for (i = 0; i < ARRAY_SIZE(pixel_clk_output_pll_table); i++) { + if (vco_freq == pixel_clk_output_pll_table[i].vco_freq_min && + div_total == pixel_clk_output_pll_table[i].feedback_div_total) { + p_pll_table = &pixel_clk_output_pll_table[i]; + break; + } + } + if (i == ARRAY_SIZE(pixel_clk_output_pll_table)) { + dev_warn(cdns_phy->dev, "VCO (%d KHz) not supported\n", vco_freq); + return -1; + } + dev_dbg(cdns_phy->dev, "VCO frequency is (%d KHz)\n", vco_freq); + + ret = hdptx_hdmi_phy_config(cdns_phy, p_ctrl_table, p_pll_table, pclk_in); + if (ret < 0) + return ret; + + return char_freq; +} + +static int hdptx_hdmi_phy_power_up(struct cdns_hdptx_hdmi_phy *cdns_phy) +{ + u32 val, i; + + /* set Power State to A2 */ + cdns_phy_reg_write(cdns_phy, PHY_HDP_MODE_CTRL, 0x0004); + + cdns_phy_reg_write(cdns_phy, TX_DIAG_ACYA_0, 1); + cdns_phy_reg_write(cdns_phy, TX_DIAG_ACYA_1, 1); + cdns_phy_reg_write(cdns_phy, TX_DIAG_ACYA_2, 1); + cdns_phy_reg_write(cdns_phy, TX_DIAG_ACYA_3, 1); + + /* Wait for Power State A2 Ack */ + for (i = 0; i < 10; i++) { + val = cdns_phy_reg_read(cdns_phy, PHY_HDP_MODE_CTRL); + if (val & (1 << 6)) + break; + msleep(20); + } + if (i == 10) { + dev_err(cdns_phy->dev, "Wait A2 Ack failed\n"); + return -1; + } + + /* Power up ARC */ + hdptx_hdmi_arc_config(cdns_phy); + + /* Configure PHY in A0 mode (PHY must be in the A0 power + * state in order to transmit data) + */ + cdns_phy_reg_write(cdns_phy, PHY_HDP_MODE_CTRL, 0x0001); + + /* Wait for Power State A0 Ack */ + for (i = 0; i < 10; i++) { + val = cdns_phy_reg_read(cdns_phy, PHY_HDP_MODE_CTRL); + if (val & (1 << 4)) + break; + msleep(20); + } + if (i == 10) { + dev_err(cdns_phy->dev, "Wait A0 Ack failed\n"); + return -1; + } + return 0; +} + +static int hdptx_hdmi_phy_power_down(struct cdns_hdptx_hdmi_phy *cdns_phy) +{ + int timeout; + u32 reg_val; + + reg_val = cdns_phy_reg_read(cdns_phy, PHY_HDP_MODE_CTRL); + reg_val &= 0xfff0; + /* PHY_DP_MODE_CTL set to A3 power state*/ + cdns_phy_reg_write(cdns_phy, PHY_HDP_MODE_CTRL, reg_val | 0x8); + + /* Wait for A3 acknowledge */ + timeout = 0; + do { + reg_val = cdns_phy_reg_read(cdns_phy, PHY_HDP_MODE_CTRL); + dev_dbg(cdns_phy->dev, "Reg val is 0x%04x\n", reg_val); + timeout++; + msleep(100); + } while (!(reg_val & (0x8 << 4)) && (timeout < 10)); + + return 0; +} + +static int cdns_hdptx_hdmi_phy_on(struct phy *phy) +{ + struct cdns_hdptx_hdmi_phy *cdns_phy = phy_get_drvdata(phy); + + return hdptx_hdmi_phy_power_up(cdns_phy); +} + +static int cdns_hdptx_hdmi_phy_off(struct phy *phy) +{ + struct cdns_hdptx_hdmi_phy *cdns_phy = phy_get_drvdata(phy); + + hdptx_hdmi_phy_power_down(cdns_phy); + return 0; +} + +int cdns_hdptx_hdmi_phy_valid(struct phy *phy, enum phy_mode mode, int submode, + union phy_configure_opts *opts) +{ + u32 rate = opts->hdmi.pixel_clk_rate; + int i; + + for (i = 0; i < ARRAY_SIZE(pixel_clk_output_ctrl_table); i++) + if (rate == pixel_clk_output_ctrl_table[i].pixel_clk_freq_min) + return 0; + + return -EINVAL; +} + +static int cdns_hdptx_hdmi_phy_init(struct phy *phy) +{ + return 0; +} + +static int cdns_hdptx_hdmi_configure(struct phy *phy, + union phy_configure_opts *opts) +{ + struct cdns_hdptx_hdmi_phy *cdns_phy = phy_get_drvdata(phy); + int ret; + + cdns_phy->pixel_clk_rate = opts->hdmi.pixel_clk_rate; + cdns_phy->color_space = opts->hdmi.color_space; + cdns_phy->bpc = opts->hdmi.bpc; + + /* Check HDMI FW alive before HDMI PHY init */ + ret = hdptx_phy_check_alive(cdns_phy); + if (ret == false) { + dev_err(cdns_phy->dev, "NO HDMI FW running\n"); + return -ENXIO; + } + + /* Configure PHY */ + if (hdptx_hdmi_phy_cfg(cdns_phy, cdns_phy->pixel_clk_rate) < 0) { + dev_err(cdns_phy->dev, "failed to set phy pclock\n"); + return -EINVAL; + } + + ret = hdptx_hdmi_phy_power_up(cdns_phy); + if (ret < 0) + return ret; + + hdptx_hdmi_phy_set_vswing(cdns_phy); + + return 0; +} + +static const struct phy_ops cdns_hdptx_hdmi_phy_ops = { + .init = cdns_hdptx_hdmi_phy_init, + .configure = cdns_hdptx_hdmi_configure, + .power_on = cdns_hdptx_hdmi_phy_on, + .power_off = cdns_hdptx_hdmi_phy_off, + .validate = cdns_hdptx_hdmi_phy_valid, + .owner = THIS_MODULE, +}; + +static int cdns_hdptx_hdmi_phy_probe(struct platform_device *pdev) +{ + struct cdns_hdptx_hdmi_phy *cdns_phy; + struct device *dev = &pdev->dev; + struct device_node *node = dev->of_node; + struct phy_provider *phy_provider; + struct resource *res; + struct phy *phy; + int ret; + + cdns_phy = devm_kzalloc(dev, sizeof(*cdns_phy), GFP_KERNEL); + if (!cdns_phy) + return -ENOMEM; + + dev_set_drvdata(dev, cdns_phy); + cdns_phy->dev = dev; + mutex_init(&cdns_phy->mbox_mutex); + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -ENODEV; + cdns_phy->regs = devm_ioremap(dev, res->start, resource_size(res)); + if (IS_ERR(cdns_phy->regs)) + return PTR_ERR(cdns_phy->regs); + + phy = devm_phy_create(dev, node, &cdns_hdptx_hdmi_phy_ops); + if (IS_ERR(phy)) + return PTR_ERR(phy); + + phy->attrs.mode = PHY_MODE_HDMI; + + cdns_phy->phy = phy; + phy_set_drvdata(phy, cdns_phy); + + ret = hdptx_hdmi_ref_clk(cdns_phy); + if (ret) { + dev_err(dev, "Init clk fail\n"); + return -EINVAL; + } + + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); + if (IS_ERR(phy_provider)) { + ret = PTR_ERR(phy_provider); + goto clk_disable; + } + + dev_dbg(dev, "probe success!\n"); + + return 0; + +clk_disable: + clk_disable_unprepare(cdns_phy->ref_clk); + + return -EINVAL; +} + +static int cdns_hdptx_hdmi_phy_remove(struct platform_device *pdev) +{ + struct cdns_hdptx_hdmi_phy *cdns_phy = platform_get_drvdata(pdev); + + clk_disable_unprepare(cdns_phy->ref_clk); + + return 0; +} + +static const struct of_device_id cdns_hdptx_hdmi_phy_of_match[] = { + { + .compatible = "cdns,hdptx-hdmi-phy", + }, + {} +}; +MODULE_DEVICE_TABLE(of, cdns_hdptx_hdmi_phy_of_match); + +static struct platform_driver cdns_hdptx_hdmi_phy_driver = { + .probe = cdns_hdptx_hdmi_phy_probe, + .remove = cdns_hdptx_hdmi_phy_remove, + .driver = { + .name = "cdns-hdptx-hdmi-phy", + .of_match_table = cdns_hdptx_hdmi_phy_of_match, + } +}; +module_platform_driver(cdns_hdptx_hdmi_phy_driver); + +MODULE_AUTHOR("Sandor Yu "); +MODULE_DESCRIPTION("Cadence HDP-TX HDMI PHY driver"); +MODULE_LICENSE("GPL");