From patchwork Thu Jul 20 07:09:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Ying X-Patchwork-Id: 704696 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3082EB64DA for ; Thu, 20 Jul 2023 07:12:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230291AbjGTHMA (ORCPT ); Thu, 20 Jul 2023 03:12:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231557AbjGTHLf (ORCPT ); Thu, 20 Jul 2023 03:11:35 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2052.outbound.protection.outlook.com [40.107.22.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E145726BA for ; Thu, 20 Jul 2023 00:10:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Un8STEzpv7JxITnM54a5vIvcNe+NVRn8zsYzhb/e9sH0TZhLyW31wSHsdRCeFk58KUxx0LCg1afCNhD9jVBhtPYPhb+Q+z03xigamDSO9oeJrNW1i9iFZqQMhJnXKcetgNpK+31I40+Ox6GNj3oGsjA2zILvbanilX0CU9H/J0/A2CrG8t4+Jvg9Q1+NhI5O6Qc/ixGoxkNnPOfKV+6vjpfdP13MEP/Ro9NihahHhF8iRY9GVyxqEMyqbm6hirvElImqW8WKd6jZb8cGJFmtK+yA9khXgvnOj+aOb1iDTx5rM+MvI2ZnDSjo/vXEE4gYMnjhCQ+a//pXCFjU7I8iug== 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=R9q4GKRXA++y43AmVaL36Uoy7t2H7ScDYcW3i/rdTq8=; b=JmQtcY1HccAO6v/z17UKx/14CJLy0hq6gARVJcxQJsd828x25FiZb6EIZ8yStD0PupBospIY4F0lmNRkf2qkYqmtEOssz0uMlKbI2hhJ+7lrmz2P49RCzFhsHVHw3fsQx5TNyFygtkYHwQ+O73U/JI8ZrvV+bDIDAleIqPmsB/bn9oRMGJdoYlF2bXZH9EtM+1atysBPPcpjLy6YPDyOThWpeqNzz3HxPt3gpCfgFdF51RMWxocXfEOydlvC3FjJyBLqPXoNKB40/x1iXOH2b1NV/jzbRa7Tp758wGe5gY6cg3M/LzGgQwJXCjszBH/gRTWJeH8YufmGxO31TwXSmg== 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=R9q4GKRXA++y43AmVaL36Uoy7t2H7ScDYcW3i/rdTq8=; b=iTWyiX2llWH6Yw7RqgUBHSFVgsbyQir+R7BOJPTFv3IoY+XbwUfTl0eInTD1avr29LnuTfaP8mrsttVRoReSi13oQ7Tdts/vizWWeuWA2by3CDJsMvhYyKL5u8gMlm3MrZhN97CGzNRSBcfnX/a2XY5xk7RL17PSSExZHNSc8Rw= Received: from AM7PR04MB7046.eurprd04.prod.outlook.com (2603:10a6:20b:113::22) by AM9PR04MB8307.eurprd04.prod.outlook.com (2603:10a6:20b:3e6::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Thu, 20 Jul 2023 07:09:54 +0000 Received: from AM7PR04MB7046.eurprd04.prod.outlook.com ([fe80::9018:e395:332c:e24b]) by AM7PR04MB7046.eurprd04.prod.outlook.com ([fe80::9018:e395:332c:e24b%4]) with mapi id 15.20.6609.022; Thu, 20 Jul 2023 07:09:54 +0000 From: Ying Liu To: "dri-devel@lists.freedesktop.org" , "devicetree@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" CC: "andrzej.hajda@intel.com" , "neil.armstrong@linaro.org" , "rfoss@kernel.org" , "Laurent.pinchart@ideasonboard.com" , "jonas@kwiboo.se" , "jernej.skrabec@gmail.com" , "airlied@gmail.com" , "daniel@ffwll.ch" , "robh+dt@kernel.org" , "krzysztof.kozlowski+dt@linaro.org" , "conor+dt@kernel.org" , "shawnguo@kernel.org" , "s.hauer@pengutronix.de" , "kernel@pengutronix.de" , "festevam@gmail.com" , dl-linux-imx , "alexander.stein@ew.tq-group.com" , "sam@ravnborg.org" , "jagan@amarulasolutions.com" Subject: [PATCH v2 1/9] drm/bridge: synopsys: dw-mipi-dsi: Add dw_mipi_dsi_get_bridge() helper Thread-Topic: [PATCH v2 1/9] drm/bridge: synopsys: dw-mipi-dsi: Add dw_mipi_dsi_get_bridge() helper Thread-Index: Adm62S8M2gb4MN2eQEG+NSKpq9vOfA== Date: Thu, 20 Jul 2023 07:09:54 +0000 Message-ID: <20230720071430.259892-2-victor.liu@nxp.com> References: <20230720071430.259892-1-victor.liu@nxp.com> In-Reply-To: <20230720071430.259892-1-victor.liu@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SI2PR01CA0039.apcprd01.prod.exchangelabs.com (2603:1096:4:193::16) To AM7PR04MB7046.eurprd04.prod.outlook.com (2603:10a6:20b:113::22) x-mailer: git-send-email 2.37.1 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM7PR04MB7046:EE_|AM9PR04MB8307:EE_ x-ms-office365-filtering-correlation-id: 15184736-c12d-4b57-35c7-08db88f05199 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: z1I7xY1xTkIvq2HgUDfxeuIxvRAskDEWv0djrH9I4Umz8/rgLSY2Cvkh41G5lSyOTYF+lTCJ0RFnLDhASDWyHDSE9r+QmkxVkcATI5M4Y0ShwyF7UY+rWJHaJYbmJ2vj6Ol+Qv7MhuMp2WScLGUiGqoOWGqzK3anck9lWmRS7A2extyGGXsmdhENWH1GVc78bLuFGroWPJLgZ+zx068qSVabPCXrV3Vxh6aHMVSqsFAA0o7nscH2IBwdTHx41bUvlp39aCpdTBGoyVH2LR153AyZeXBSivrThyExCPM9/4nUcR/AYdaizDLXRpKoBv/zJXeg04enG75TE2qMZmcpPopf3s5AhDAYIGU2CgYpXMr1OT2jD9LfioD+Do/bFTBfkQ7/sAiAw95frKNd5DSV9tTkQrih5Q1Zud/FIBixEu31vhmJhS9fo/NiomjLZZo+iG+mXOuXXSrYYWz/oXdm9qWqCuz3os+e54vmUGa+BOwzwkKI8LkRneeV3Y8c8W+3bhUmMAe0SjaF8t+UB7TxxCIM/WKp9ArFqjsu/13/UIov3v4nkSUlK11aR4Gjwx12RYS28PkwINES/A3tNcTV4kUDl3dNC8I5+jsgvGImQ5JDeOZwQDtT70UoqkOg2nkh x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR04MB7046.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(346002)(136003)(396003)(376002)(366004)(451199021)(86362001)(478600001)(1076003)(38100700002)(186003)(41300700001)(26005)(71200400001)(110136005)(54906003)(8936002)(8676002)(7416002)(316002)(2906002)(122000001)(4326008)(36756003)(6512007)(66556008)(64756008)(66946007)(6486002)(66476007)(66446008)(6506007)(2616005)(52116002)(38350700002)(5660300002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?bTC29ulO2U7pe8naLby4aAS?= =?iso-8859-1?q?+42t0iQwYRGqsoAyRCte5mKdOwinOk5hoWksUPeTdiLhaJRpuou0DRGB2a+b?= =?iso-8859-1?q?0rp3HxZVgoTuCNZaOZMRX8vcmkUoHb82SWunrLvE98NDFvCtOSiSa38MA3Vu?= =?iso-8859-1?q?Qjg53T0227BC20Oqxv4ixLi04gMBVX3vA7SdH+KkJyaWSU8V0rwYg3dMYEDV?= =?iso-8859-1?q?1fVwDSfwhPl+61FLMH76loFF5EpGvwaN1wvsrHBLizHAGqNoVuHd47BZd5KN?= =?iso-8859-1?q?4dH15/md5z1J/88vOLyHcAN4KXxTfR+PWYJwwrI5teKssnWj2RhbW/PitpMV?= =?iso-8859-1?q?rniARymbzdb29XbiE3PumbxtsFaaD7ZmBu1RFSscCOh5xCsOBC5bfjQRvwaG?= =?iso-8859-1?q?70Fqn24OvqlEm1CbsStVTKcO/7r7eTbr/m8xGS77WRyqkttz5x04rovFfcgB?= =?iso-8859-1?q?xCo7STeFHEYd9pu6jfSFo4FqymlIbsr/f7eIckqmh6fkzB2lFd7sSEFZLQ51?= =?iso-8859-1?q?98MYT7iWJLv1NdRjEJ3ZVBPDLfl4RwtCjrT6LKIxyiG8VraciFAs4I/WRMNs?= =?iso-8859-1?q?3un5XCBdHXLFtZ3nEv38OlAE3BV1I41n3kS8/24vk+SSCz0DnOp2CNBCSG9a?= =?iso-8859-1?q?xkDrLewxtrHJEhbxFEAoRsiUZToQoj2vE/LezZVcywTWWZku+CHGpiiHt9QG?= =?iso-8859-1?q?d76I5LmRUFjG97suigcfVTK2oX12av/jOn1rtXEZn+CPExz1g9iW2pt2jF+t?= =?iso-8859-1?q?GGLf7YjqXmoLCqirjVmR1XVE4M9+Jpay0vihV/6HknHbADbepeUsD0d233Sy?= =?iso-8859-1?q?pwJp8PhXFMRerYdrHv43vT/TjhZue/cSRleh7E6H1ltZOC/tRLHv9dR3xee0?= =?iso-8859-1?q?5AkXs/+rSYrERTrBQKoPnVanc9KI5f/hQDe293CMEUNmMXq2g4bAz22Q8jvi?= =?iso-8859-1?q?NKDpJo6xJniaRi3FDk75Lxd5AkLUeKasjY4vATH1TnumU365MaEvbPwpjFe5?= =?iso-8859-1?q?42xQvQI4WHxClH4znH3OEspbTBQPi3BDkyLmaUVuRSGLqx35vcSQ7l9D1IR6?= =?iso-8859-1?q?n+P2JXluqSJhVWf8PO4A8Jnes4DFM6j6dh/N21Oe6qwW8FCLv19+u2vdSn/D?= =?iso-8859-1?q?n/25Rf9COSC/BhwnSW4eBC+V9SXh+QstakGKhQgmZ1Esc0OsyPuSY0eBcWJL?= =?iso-8859-1?q?28TSavGDmX23KVUwUuXG6eJb7YYG76jQL3FVba2yg++Pd6K+1CgKZ5eA9CDW?= =?iso-8859-1?q?dJ8+HbQ+zWkkkYbQHRE9ziBqL9oTCOESytbYPnb/zRFQR6UPzGKP09I2oC/2?= =?iso-8859-1?q?EN2OZbZwfcgNR3SB0Xh3VQ1g6w/KzNsTFVZd5N5RTDBlw4Cu3CcGYm1WUHIV?= =?iso-8859-1?q?jtEDAjNtzwenchPgRDXf/O5ew0DYxGmsIE8obdZt8BYhzdm2Henr86/WHht/?= =?iso-8859-1?q?6hgZ5pE7kWK3tHbSrphr2FGS7f3ICRAY7+xVR/GM9kALAzJVQdB6lkzin/Op?= =?iso-8859-1?q?ybIoc93IcpAxnllKZ6qDQgXqIqndDcjWzf850Y+HI6zop99U3cHjMsk+hFhk?= =?iso-8859-1?q?kVkeKpMdQuSVnXwfr0B3TSnH95mcfw3IiEPDGsWzcVce01EnEWMqJnKAbQOM?= =?iso-8859-1?q?pKaUxYCchI0h2q/ej?= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7046.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 15184736-c12d-4b57-35c7-08db88f05199 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jul 2023 07:09:54.5117 (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: 9kka767aDne/c9yyIqhsTjMwt7K3yUFApSWU6RR02zRacBSelxYq42Q5oTkeNkYB6VNU7825qNiZpeRnqG7pHw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8307 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add dw_mipi_dsi_get_bridge() helper so that it can be used by vendor drivers which implement vendor specific extensions to Synopsys DW MIPI DSI. Signed-off-by: Liu Ying --- v1->v2: * No change. drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 6 ++++++ include/drm/bridge/dw_mipi_dsi.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c index b2efecf7d160..57eae0fdd970 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c @@ -1207,6 +1207,12 @@ void dw_mipi_dsi_set_slave(struct dw_mipi_dsi *dsi, struct dw_mipi_dsi *slave) } EXPORT_SYMBOL_GPL(dw_mipi_dsi_set_slave); +struct drm_bridge *dw_mipi_dsi_get_bridge(struct dw_mipi_dsi *dsi) +{ + return &dsi->bridge; +} +EXPORT_SYMBOL_GPL(dw_mipi_dsi_get_bridge); + /* * Probe/remove API, used from platforms based on the DRM bridge API. */ diff --git a/include/drm/bridge/dw_mipi_dsi.h b/include/drm/bridge/dw_mipi_dsi.h index 5286a53a1875..f54621b17a69 100644 --- a/include/drm/bridge/dw_mipi_dsi.h +++ b/include/drm/bridge/dw_mipi_dsi.h @@ -11,6 +11,7 @@ #include +#include #include struct drm_display_mode; @@ -68,5 +69,6 @@ void dw_mipi_dsi_remove(struct dw_mipi_dsi *dsi); int dw_mipi_dsi_bind(struct dw_mipi_dsi *dsi, struct drm_encoder *encoder); void dw_mipi_dsi_unbind(struct dw_mipi_dsi *dsi); void dw_mipi_dsi_set_slave(struct dw_mipi_dsi *dsi, struct dw_mipi_dsi *slave); +struct drm_bridge *dw_mipi_dsi_get_bridge(struct dw_mipi_dsi *dsi); #endif /* __DW_MIPI_DSI__ */ From patchwork Thu Jul 20 07:10:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Ying X-Patchwork-Id: 704697 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9942EB64DA for ; Thu, 20 Jul 2023 07:11:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231454AbjGTHLr (ORCPT ); Thu, 20 Jul 2023 03:11:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229961AbjGTHLY (ORCPT ); Thu, 20 Jul 2023 03:11:24 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2081.outbound.protection.outlook.com [40.107.22.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5E7B26A6 for ; Thu, 20 Jul 2023 00:10:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fNsWqJwxWee8xnskP6wVIhjsF66ck4dOMLRagBRiyign4lnfniSSWOfpmpFsK5KjVcRue+cXC/d1exIKYRRJwsqnSMCaVCDa8m4Ha+IMUtaf8a2IOb/luVEL2m6/763N9gVaZzV7B5OWcUJvz4AOI1Anm1XjqtZgXn+o0NRabhue6rYA8+uusv+HjV0aVLpYYGB5bZdRLqnxZEbMaCl0EcZV2yxe16MqqCDgZZs6mrirzxtdfsjQWXfI8qKdIvHKoEmEPAL/UwoKdDf8oh3gG0Ldk31W9uVDpFXwPSL1F7q/x7VPRgYYrK3Vsjyh9JXtrB/J9cREsNDwvlujyt1xrw== 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=4O0fgjP1+XKJcTTF0Uohkbnc2npkwLKZrcddxbnMKSU=; b=UwreG5/oFNhQojIWRvi56x1+cRqG+ylVeLB8GXlhjwq4FVSKjVjPrJbnoX+/oHNvPmEdXRPYkVcB2sD5SOogZHyLas62g+h/8CHV4lx0XGwfq5gWRHRsFUJsdIjUvveR/JCXllry22aJRejuUS61ylMXJfpgQ9DOskvUH4X6EfBzzm47WqEJ4z2HnB+Z9MgwmYm/rQH9O2COwVBWgXA2u+hWhuKT5L+fnu5TIhFfcLtUlKCW7RAgFHFfUsK+E1lQtMO0txBKHxRx1FtljugExsKsPvTKg3tnxjZpHxhZII3Soy4ClwhtRZP2+ijtMO1TBEeBUL8n5QfpXWBS3tdS7w== 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=4O0fgjP1+XKJcTTF0Uohkbnc2npkwLKZrcddxbnMKSU=; b=l+QHuwzWdIRPH7VdWGLK/ADyubl2SYYWLGaIdnooIOqv1Un9+/knREKb4XuRTG7g4eoS/AuuE68sy0tLJPJXyMwtZ5GAPF5RTWMCnFmwZo4WJi12JsdXob5wHVKAJY5AfhAGnE0jhDzE03W7C25L2CUCAjF6gW7DYckSMONnRbE= Received: from AM7PR04MB7046.eurprd04.prod.outlook.com (2603:10a6:20b:113::22) by PR3PR04MB7243.eurprd04.prod.outlook.com (2603:10a6:102:8c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.25; Thu, 20 Jul 2023 07:10:00 +0000 Received: from AM7PR04MB7046.eurprd04.prod.outlook.com ([fe80::9018:e395:332c:e24b]) by AM7PR04MB7046.eurprd04.prod.outlook.com ([fe80::9018:e395:332c:e24b%4]) with mapi id 15.20.6609.022; Thu, 20 Jul 2023 07:10:00 +0000 From: Ying Liu To: "dri-devel@lists.freedesktop.org" , "devicetree@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" CC: "andrzej.hajda@intel.com" , "neil.armstrong@linaro.org" , "rfoss@kernel.org" , "Laurent.pinchart@ideasonboard.com" , "jonas@kwiboo.se" , "jernej.skrabec@gmail.com" , "airlied@gmail.com" , "daniel@ffwll.ch" , "robh+dt@kernel.org" , "krzysztof.kozlowski+dt@linaro.org" , "conor+dt@kernel.org" , "shawnguo@kernel.org" , "s.hauer@pengutronix.de" , "kernel@pengutronix.de" , "festevam@gmail.com" , dl-linux-imx , "alexander.stein@ew.tq-group.com" , "sam@ravnborg.org" , "jagan@amarulasolutions.com" Subject: [PATCH v2 2/9] drm/bridge: synopsys: dw-mipi-dsi: Add input bus format negotiation support Thread-Topic: [PATCH v2 2/9] drm/bridge: synopsys: dw-mipi-dsi: Add input bus format negotiation support Thread-Index: Adm62TK6XpKEKypROket2EgKxcczbA== Date: Thu, 20 Jul 2023 07:10:00 +0000 Message-ID: <20230720071430.259892-3-victor.liu@nxp.com> References: <20230720071430.259892-1-victor.liu@nxp.com> In-Reply-To: <20230720071430.259892-1-victor.liu@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SI2PR01CA0039.apcprd01.prod.exchangelabs.com (2603:1096:4:193::16) To AM7PR04MB7046.eurprd04.prod.outlook.com (2603:10a6:20b:113::22) x-mailer: git-send-email 2.37.1 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM7PR04MB7046:EE_|PR3PR04MB7243:EE_ x-ms-office365-filtering-correlation-id: 5cc9c64a-1982-4f21-4236-08db88f0553d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: dpFrMVXkh1c7AeWdiBq1kcuSA2ZOhfIbYPWO1gEuM1Z/JcdCjpCf34QFkxUm3i4zUWguh2JMQl61IVvoMIQ662eT45RrxhAUzVevRTa3B46Y+fL4trSzkIv8BVXOn7W5eHhywWH6Jfwu/g0w3ZuR3wqh1F8URKArF3CwPsk80QTe5V4Efod1ayVg1uXGZl5buMGSUBQHKbyYLtG//lXwP9E2jQAuto0ZPzffFZ8kXagj3RaRb3gj/cT7tdZMAvlRpwgFdMcQpHMjb/kcO9ufkNkIMuVsQo7lQQ1p6jM0vtsxEM1U2Z8CIE16lDgXFfEglGQXamrvsD34Xe/vF7lE8dBXzZUaaOIVGjmNmZic32A8YEd26Dy83KWPJEErFqNVBaU868YLQ0RI3qjoHaaJm1sLJrEpVn5UwwmUuuIoA9P4JZH5BDFRoF1xC+D+Bg6W1N8olsmw6A7kHaLpXfqCnT4x5l+Rk33OiCKIsha88m8FsnZ3Q9+mlbfSLTUHlq3GoM3X7YXIznz3baDROCgwITM5P4jZe4Ro6/ZRqZuL1SUkYXv/Ku+2DqvkEzJ6MDtOGh/vleRd1oNt1QGl7Z3bY/BI/AWv8FvTiwlOsXZRGqvm1hEfThkXne+x+ulH4I9i x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR04MB7046.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(136003)(376002)(39860400002)(366004)(346002)(396003)(451199021)(41300700001)(6506007)(1076003)(186003)(26005)(478600001)(4326008)(66446008)(66476007)(66946007)(66556008)(64756008)(71200400001)(316002)(8676002)(8936002)(7416002)(110136005)(5660300002)(6512007)(6486002)(52116002)(54906003)(2616005)(2906002)(38350700002)(38100700002)(122000001)(36756003)(86362001); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?P+08aTGrXDowKeq1wOcus7T?= =?iso-8859-1?q?shnUVUE4zKG5u7Pzt2XmuKXxSt3sSnpXeAkhpgFJ/qhKfDUb2JygLrwqeIGA?= =?iso-8859-1?q?oNf2h3idSV9zRzDvJo2EVYI6zfaffv0c1m9idHxQwmsV01jDVCFN7MwwaJd6?= =?iso-8859-1?q?2XdexOjYV+lM8CtV/7oVLOuHAExcfpWZdpShln13PfmtLCnrIJBUus0Zr5eT?= =?iso-8859-1?q?OWysgjPrBfL5M96DKxIrUJ6VUC93EjHvkq9OCyH+1ogTAOo1+OctqqdOucd0?= =?iso-8859-1?q?Z+2KpuUDWOtlarD0j1th1eCyrmzQJucNJjGfGoCm3iiTwQhhj6Fh5PdqCJpz?= =?iso-8859-1?q?T2t2IC9QS6ZRR10onhxUPFwcEGPb1eSDMAYNc12W+tzMgOH4uqTXiB5xIAsL?= =?iso-8859-1?q?RwyeEg0mVdWOMvAMHmILydzirqMEs5JgQeOLD1lfLGi1LsutENqtTaJOWUdG?= =?iso-8859-1?q?G9sLcyUvJiwYuGoaKkJnXeKna78HYvwC/Sx/h8JGl1f60hnKlDIRGD6GCeCy?= =?iso-8859-1?q?/YtB4w2yWZmV4hpPaupghBJ9zL0nFjOfoJWaMJCJhaHqhPtxhsSVHno5ltYH?= =?iso-8859-1?q?ELz0jPoLyAvbmqlj4IYiJTueen4K+Buc6sQ1tdVvZ4EtKP8H/SrY97HF1OOF?= =?iso-8859-1?q?cuqsEkiI9+PnOMkIGdU0cpsbjrI+A+g8xomFuQSfltPEQJoyVLBoQ/BUkaRe?= =?iso-8859-1?q?tfJupkIytgdYclb5TUD51DPrzdiwy+/8rsRBOVdR5vzrxnZWtzEZod3AtwcG?= =?iso-8859-1?q?LvT+drsTlQh2gNwVUyi2OH7gNz259dw4EOkSQODeXcLzIQnu0iT5ILuY/36I?= =?iso-8859-1?q?s8KNp/NrvfhWmY0bIJTATserdNbc+S7PdqTl1lAHlTkrGD+iblAv0htSarIw?= =?iso-8859-1?q?Dc7cNPf6/BQnvjh0F2wDXPmcW0xSu/AL6FTCtV1gxMVeNyuDWvVH7L0kThXc?= =?iso-8859-1?q?n3DhmEOAmk71SF+1Nr7AMMg4RXWCcDpFQmWIpHeAM3I2WUiDCxSEsEM44J/9?= =?iso-8859-1?q?VjgTPzvPskQdbPRZDxMzj9mnHlBqY9KSY7gbCAq1nt0x2T2z0jf3/KseSZ63?= =?iso-8859-1?q?NVZoK2bK2O9WOHlmNyPO4JOUFoJwofVJ+LG8M/w7QOcgmsFP3IqWQhpkZ0Fs?= =?iso-8859-1?q?oMthflzhtHvSJGwWs/KZ9yHsLYuyq6yDgv//FbtkEbfT4RmQc/6Iwmy84Xbj?= =?iso-8859-1?q?BxIkYssY/pvcHzljeWrYEmzrMyv6ySzBTwySiwYv2mcb8/ilBCHHInK0V3DS?= =?iso-8859-1?q?d5+Cd441vZPJ1mFacLlne/rn0ktsuUof5dJV1w7vzaA70mX2xALFFWpFVJ8F?= =?iso-8859-1?q?X8lZSPXZye6FOgKuI1jeBULHUnvPoETIz95tAkIFfXJGm212uzsO3dE6ux5/?= =?iso-8859-1?q?PuO9j1sljjUvd9ejCByjoa7C1eJXPcVPizjjYu0ZMB316pzY9TEp1kmpe9hI?= =?iso-8859-1?q?gllWVVTd+13I9bjUTdYt1BVXgICO7VLaiPg36nPXjIg5uognBYETAK8RFmWo?= =?iso-8859-1?q?AG6MxHHB3hYyvgCy0WlAW3doa6P+J22DK2Yhhjh1qUAXPSwVOCgtVr6iqJNP?= =?iso-8859-1?q?/DWN8wFBaOvFwaaOHShrPvXPqUL9VLH8j1uOUTwzbxUTEPsVQVZW2uQN0Frc?= =?iso-8859-1?q?JnZMk3mMPduBffJD/?= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7046.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5cc9c64a-1982-4f21-4236-08db88f0553d X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jul 2023 07:10:00.6324 (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: 6wfHRU9e/JdiH/hO7Hxh6YP2a6U0JvnVtc0mxvQ0jl5cffBJvCKAnprnhSFtyPR3MAnqfnP27tGv31Dc7Mz4bA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR04MB7243 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Introduce ->get_input_bus_fmts() callback to struct dw_mipi_dsi_plat_data so that vendor drivers can implement specific methods to get input bus formats for Synopsys DW MIPI DSI. While at it, implement a generic callback for ->atomic_get_input_bus_fmts(), where we try to get the input bus formats through pdata->get_input_bus_fmts() first. If it's unavailable, fall back to the only format - MEDIA_BUS_FMT_FIXED, which matches the default behavior if ->atomic_get_input_bus_fmts() is not implemented as ->atomic_get_input_bus_fmts()'s kerneldoc indicates. Signed-off-by: Liu Ying --- v1->v2: * No change. drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 30 +++++++++++++++++++ include/drm/bridge/dw_mipi_dsi.h | 11 +++++++ 2 files changed, 41 insertions(+) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c index 57eae0fdd970..8580b8a97fb1 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -536,6 +537,34 @@ static const struct mipi_dsi_host_ops dw_mipi_dsi_host_ops = { .transfer = dw_mipi_dsi_host_transfer, }; +static u32 * +dw_mipi_dsi_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge, + struct drm_bridge_state *bridge_state, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state, + u32 output_fmt, + unsigned int *num_input_fmts) +{ + struct dw_mipi_dsi *dsi = bridge_to_dsi(bridge); + const struct dw_mipi_dsi_plat_data *pdata = dsi->plat_data; + u32 *input_fmts; + + if (pdata->get_input_bus_fmts) + return pdata->get_input_bus_fmts(pdata->priv_data, + bridge, bridge_state, + crtc_state, conn_state, + output_fmt, num_input_fmts); + + /* Fall back to MEDIA_BUS_FMT_FIXED as the only input format. */ + input_fmts = kmalloc(sizeof(*input_fmts), GFP_KERNEL); + if (!input_fmts) + return NULL; + input_fmts[0] = MEDIA_BUS_FMT_FIXED; + *num_input_fmts = 1; + + return input_fmts; +} + static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi) { u32 val; @@ -1003,6 +1032,7 @@ static int dw_mipi_dsi_bridge_attach(struct drm_bridge *bridge, static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = { .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state, .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, + .atomic_get_input_bus_fmts = dw_mipi_dsi_bridge_atomic_get_input_bus_fmts, .atomic_reset = drm_atomic_helper_bridge_reset, .atomic_enable = dw_mipi_dsi_bridge_atomic_enable, .atomic_post_disable = dw_mipi_dsi_bridge_post_atomic_disable, diff --git a/include/drm/bridge/dw_mipi_dsi.h b/include/drm/bridge/dw_mipi_dsi.h index f54621b17a69..246650f2814f 100644 --- a/include/drm/bridge/dw_mipi_dsi.h +++ b/include/drm/bridge/dw_mipi_dsi.h @@ -11,7 +11,10 @@ #include +#include #include +#include +#include #include struct drm_display_mode; @@ -56,6 +59,14 @@ struct dw_mipi_dsi_plat_data { unsigned long mode_flags, u32 lanes, u32 format); + u32 *(*get_input_bus_fmts)(void *priv_data, + struct drm_bridge *bridge, + struct drm_bridge_state *bridge_state, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state, + u32 output_fmt, + unsigned int *num_input_fmts); + const struct dw_mipi_dsi_phy_ops *phy_ops; const struct dw_mipi_dsi_host_ops *host_ops; From patchwork Thu Jul 20 07:10:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Ying X-Patchwork-Id: 704695 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DD52EB64DD for ; Thu, 20 Jul 2023 07:12:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231423AbjGTHML (ORCPT ); Thu, 20 Jul 2023 03:12:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231425AbjGTHLp (ORCPT ); Thu, 20 Jul 2023 03:11:45 -0400 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2057.outbound.protection.outlook.com [40.107.247.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC0F41998 for ; Thu, 20 Jul 2023 00:10:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iebD1sNFUvHM9FzvDiYtru0o+DNKMjVxovMXzr/OZVn9mmk0XZYu5R7q26CetNwIJGOBbtw5EnqlVk6/K42IDlQBVBKj0rPEfXXqBL2s6oZOzgo8EyDJFZucBLGzuI4qc+ZC4z4Fi3bMNuk1p+CwZ9DpbnwHwAkGkbzPeihFosbe05gE5tf72+YcdjS7av0opu+oVqUQROHHey7ZnyZgSBV6MrgRfzN4u+rLHQyO2PqJBtHPkouBlZwfo4U4CK9YEk/hhq/Jrid+CaRrRalUaqHxrBEma73bWy2BaLX/0WG5qnKGfBUViOsuPlYzz4PzDA0nynNGK4zDz3j5EtY+0w== 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=QcM4UwOad8aiPGN1wd4BrcxlMjn1XZT0hNlv74Fm71U=; b=W2T0BZ+vVunXRzf1yEJ60gYPy5JFLRkwaAtUlHJnJYwMx77ULtDj9FgOeHd2FR4h3HVhSqQL/XYR6fmZxoU2e5KtYndPhUWwaQSNNuCDD7Hn+DNopOHdQqixdj0Ce+yFy+5xMfHnsZkzwejws8khi4MXrzOJ56wDdUrNBFerqHZA2DaGmcgJUyRdoZQ01i7ZtScp4gnHXJrabUTybzlBBJNEioNo2XX+1BBTMhmPPV+erMZIe7mUn08G3bdZxrbqzV+i5jlIno/dFFYJXZ1N7PZuyObTFFm5/1ktUnhjLTqaHXDfY73crG3to138tszLorEDyUD7wwFqUxpkZFkvfw== 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=QcM4UwOad8aiPGN1wd4BrcxlMjn1XZT0hNlv74Fm71U=; b=p63uVE1ONxlpX2cNAKmATkJxkyFiArmHHr4db7MBOhHwr5+31wnIw3L17XKkZ6tIT9/grP7Gc4dBt6f8/qnzmNiWCbk9gHynj4NkiUuV9W8XMD4OLe/uQ4yAV/qY6OMc3xhmGw0Dtsqy3Ra9BB+vnNVkWqecteB2nvHIDJvYYMQ= Received: from AM7PR04MB7046.eurprd04.prod.outlook.com (2603:10a6:20b:113::22) by AM9PR04MB8415.eurprd04.prod.outlook.com (2603:10a6:20b:3b5::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Thu, 20 Jul 2023 07:10:19 +0000 Received: from AM7PR04MB7046.eurprd04.prod.outlook.com ([fe80::9018:e395:332c:e24b]) by AM7PR04MB7046.eurprd04.prod.outlook.com ([fe80::9018:e395:332c:e24b%4]) with mapi id 15.20.6609.022; Thu, 20 Jul 2023 07:10:19 +0000 From: Ying Liu To: "dri-devel@lists.freedesktop.org" , "devicetree@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" CC: "andrzej.hajda@intel.com" , "neil.armstrong@linaro.org" , "rfoss@kernel.org" , "Laurent.pinchart@ideasonboard.com" , "jonas@kwiboo.se" , "jernej.skrabec@gmail.com" , "airlied@gmail.com" , "daniel@ffwll.ch" , "robh+dt@kernel.org" , "krzysztof.kozlowski+dt@linaro.org" , "conor+dt@kernel.org" , "shawnguo@kernel.org" , "s.hauer@pengutronix.de" , "kernel@pengutronix.de" , "festevam@gmail.com" , dl-linux-imx , "alexander.stein@ew.tq-group.com" , "sam@ravnborg.org" , "jagan@amarulasolutions.com" Subject: [PATCH v2 5/9] drm/bridge: synopsys: dw-mipi-dsi: Use pixel clock rate to calculate lbcc Thread-Topic: [PATCH v2 5/9] drm/bridge: synopsys: dw-mipi-dsi: Use pixel clock rate to calculate lbcc Thread-Index: Adm62T4XsRXruAuytUCRfthfHJ0PDA== Date: Thu, 20 Jul 2023 07:10:19 +0000 Message-ID: <20230720071430.259892-6-victor.liu@nxp.com> References: <20230720071430.259892-1-victor.liu@nxp.com> In-Reply-To: <20230720071430.259892-1-victor.liu@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SI2PR01CA0039.apcprd01.prod.exchangelabs.com (2603:1096:4:193::16) To AM7PR04MB7046.eurprd04.prod.outlook.com (2603:10a6:20b:113::22) x-mailer: git-send-email 2.37.1 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM7PR04MB7046:EE_|AM9PR04MB8415:EE_ x-ms-office365-filtering-correlation-id: 5f39451c-bd98-470c-49b1-08db88f06092 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 927SuwfviYwscyZCa5dO7tqXKFvioMorJOXtth6I0zsODsAVtNszmHr0I7EffDf1uz9vUvrs+eM3jjWkcWM1hxtq9E3t0jNeSpSPuvD1dCCMXNqJSApd6kRaF+8vmZVpvoyokQ4XGDC0g+Jh573NC9YBU49Co4wepeUm21843J055OzfI1pvzOsd/wFDVnkF9T+HYToWlHNNHh0S+T+C/k7jvnGJ4FEs+/ScJ78kqxxGkT3KlLVblePQS4kNeMkqjZHaQut964Tc+w7EiMYmb2PlA/0HJiyiKAGzeoA6g1h25P9jQYbIe6ccd58eYXPNot27RK29hYq91Hqu/QZeZUvVDt9a/l/uQ1QJcGcKtqbqS/27Lm/0IoGbhGLejxRkZUa9i6HRfNPSCkj/E2o7eZE9NhWmt4U84YP1YLapI1CMl/veWsX6eurMFp80TcjXb4M+5xyHbLAz6+19Z1DPoTm7lqmBULjOM45FS3uIXNaKawb4LpZmQRHlJKAOS8eULhd5sGDDKAlnOb8HwCkl80M/BLVvsaqdWkBUViuSuaqkkDi9jSs+QoVfp2tFbus/Lb9HSRH7v5KHuSC0JXP6XEDFom+LCJ7wLw9IHeGUcrg= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR04MB7046.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(366004)(136003)(376002)(39860400002)(346002)(396003)(451199021)(6506007)(478600001)(1076003)(26005)(6486002)(52116002)(2906002)(6512007)(71200400001)(4326008)(5660300002)(66556008)(316002)(66946007)(66476007)(83380400001)(66446008)(54906003)(110136005)(64756008)(38350700002)(36756003)(38100700002)(7416002)(8936002)(8676002)(86362001)(186003)(2616005)(41300700001)(122000001); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?pFIuyYGjs++tFrtAbBWKG2B?= =?iso-8859-1?q?VQ9ZJ4tW0TOo+Dw92NSGdm/cBJFNLYSM29+v3qops7gFmWy7DyrIyCdSL/pJ?= =?iso-8859-1?q?k6St2buNdUFMzF7ddi0qGjnQKkwGhRyDtTbrr0MP1RsBqwrkskatOeiYty/F?= =?iso-8859-1?q?HdeXTc62ZXk/T3ydYN9BN3dM7FdZPiMQR+mxD+zmMJqo9fuv75471brwkBTg?= =?iso-8859-1?q?AGEG8bgtT9zack9dDWMw8g4wT1/plBq81nMTUJNuSB35XHt8tLArtN8cFjIx?= =?iso-8859-1?q?2P5RLrqnIcP6ukyY/zx8WmUrryTWHjq5MuRFRAsq8DUUw0VecKW21cZdNGuE?= =?iso-8859-1?q?S/lohap/Ej27vdSk+9TDjxklTzNPQJ0xhoniAClo+tCTyKmo4uJvu145dJ9L?= =?iso-8859-1?q?S0Ewq/qXdL2FWhNqJROv7GQFIwdpsRb1m3I+sVfK64ydMfF6LxeviH5yJscc?= =?iso-8859-1?q?iWZMkCTB9TniuToXO3ZI9oiIlrP1Q2vaZ+jLOLmc+JcPgPhl8Pa7LEZJNK1+?= =?iso-8859-1?q?GyrcdA9ceZwm+M5dNwYyklHyDrXPYlCrYtN0xebwFj5Boy6/F6Xod6EHrWK5?= =?iso-8859-1?q?IWrtLyowe3BheP2w6NrvfkO90vzmcPUxRMmH/H7J1EPmgN6jYv75Dts/mq+G?= =?iso-8859-1?q?pv8LvLXztQBnTo/PRdvjK3a1mN1Q8voyS8Hgy21LEtywAE98S9GedpJ7INYq?= =?iso-8859-1?q?dK6lDQEr5vFnhDf/0kE6tVSCIreAgAT1Ig3ZTBf3ZXc+ER4lwTmSwLLZJCkW?= =?iso-8859-1?q?x/7lVHpVZg1Q3wbD2pKYw5pEXrYvmOfZT+KqEqNg8bxhETaNovz0z+REVaSL?= =?iso-8859-1?q?UI0qU8wSaf/f2q8RWlQ7ZjFzeBwIlmejtSm40LwQHvrTS27hfM0ixZcmQ9aR?= =?iso-8859-1?q?0Sz4mIy5H5b++eb58B2Ie/PFQW6JoQGpu2VqaiX+r5BluZk9xcxBTNden3M5?= =?iso-8859-1?q?js7Som7yheYFmnELINnKO3c5/SZuERb8tMtQMBlsAeTYLuI43UBF7QILI6FK?= =?iso-8859-1?q?1b8rnGXRRF8GKsCPR7b56up8o8/ddelizeGG73iGp8kV+DAGYsMycqydyoHb?= =?iso-8859-1?q?7EF8ibe185jOc0+rzO3sjCahRcSHio7SUkZopQXq+13OIjJDPZsCXphgXASs?= =?iso-8859-1?q?oknL6fUsxDTIN9tnXqynbS/9haNMMsgIKCIgjiL3hmaxxZljod9Cal2155bz?= =?iso-8859-1?q?dBKzEj1pFzIkfEne4MzNc2fQJFUfk8q2gxqpNIxBP48xnV7Qkx7iEVD3D+dx?= =?iso-8859-1?q?a6MDgfbZQ+JEI2OVUpSjYiRz66fF7aGdbn8zb8yNjVaLzmhDjFgLmmZJj5GZ?= =?iso-8859-1?q?QxfHEyf596T3rN7kD+NxdwPKVplyEaUzTanYzGie1DRDkXsLOcnGdW1PuZ3H?= =?iso-8859-1?q?Rs8OUJlI//nCvOW79F+JXuKektKqG67jLUI0AwyR03V0VT/yWNomwFbmlk7v?= =?iso-8859-1?q?Q4kJUN5vddfDOUjqqhuJdT3uvfPln3UM9eRcIC8gxoJNNLy/zguWVUmggwKJ?= =?iso-8859-1?q?IEY9nyUc927WFz76oujuUeZ5+kQIfnp93CGMJA5BRipnYpXc1hKEKdaDE9wR?= =?iso-8859-1?q?hvtm24DWU+85sw2Wh7tXud+IE4OPlodxyqgon1oBRf0DFX2tlon3kxYmko7i?= =?iso-8859-1?q?xLktmPyKtqbgRpNiG?= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7046.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5f39451c-bd98-470c-49b1-08db88f06092 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jul 2023 07:10:19.6718 (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: /aiazLIxuDq3z9yQZVss5F3pct/K9HTwicUSVVnoXI3zyBSmlLKlwHyxOMshlPBBY2yglbFwGBmL1C2ANlF3hg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8415 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org To get better accuration, use pixel clock rate to calculate lbcc instead of lane_mbps since the pixel clock rate is in KHz while lane_mbps is in MHz. Without this, distorted image can be seen on a HDMI monitor connected with i.MX93 11x11 EVK through ADV7535 DSI to HDMI bridge in 1920x1080p@60 video mode. Signed-off-by: Liu Ying --- v1->v2: * No change. drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c index c754d55f71d1..332388fd86da 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -762,8 +763,15 @@ static u32 dw_mipi_dsi_get_hcomponent_lbcc(struct dw_mipi_dsi *dsi, u32 hcomponent) { u32 frac, lbcc; + int bpp; - lbcc = hcomponent * dsi->lane_mbps * MSEC_PER_SEC / 8; + bpp = mipi_dsi_pixel_format_to_bpp(dsi->format); + if (bpp < 0) { + dev_err(dsi->dev, "failed to get bpp\n"); + return 0; + } + + lbcc = div_u64((u64)hcomponent * mode->clock * bpp, dsi->lanes * 8); frac = lbcc % mode->clock; lbcc = lbcc / mode->clock; From patchwork Thu Jul 20 07:10:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Ying X-Patchwork-Id: 704694 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08DA6EB64DD for ; Thu, 20 Jul 2023 07:12:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230345AbjGTHMW (ORCPT ); Thu, 20 Jul 2023 03:12:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230297AbjGTHLx (ORCPT ); Thu, 20 Jul 2023 03:11:53 -0400 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2057.outbound.protection.outlook.com [40.107.247.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D36E12726 for ; Thu, 20 Jul 2023 00:10:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IbCJ9kWD2576lAbJvOqOc96c7JpFbErWnoQg1deS8kRDIi6Ios6M8b3lmOy1NmsZXLRxqrYbH6zBlBvcI9nP8YsiTlan957NQMDdyOyhaI81d5qhSOt8FDPTHm7IYqsbLSCuwHArGNzG27scNkZ+y+hJq88QlL/bBr8eTOqLA7vSyWpzXbEfx6Duu/eHp7+Xn3JEEr1vFn4zYlQMhkGeqaBwgBpuEa/zyIA9kRJRcixnnc6wVztW64RTQxPz6PE7uA6/iqbWtSoEjBHKyNVUgAhm8QN1jrTIl4DnbJZ6cBfTOjIwRAhkLJNfxTNQZr/nf796gqu5nYf6kWdEt7Shlw== 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=Ro5EOp6mEkZd6S0WaGYqv9gtqvuAyxqa35OiIznoIJM=; b=aRyBzTpAqz60XTbrMF6FH2g01fRPjL5bwbZ7U7Rr2yrJvJjC4YEDH+N5pxgr8n64Uf6BNxEvSrDVGKw8/GwN5pyGMox4ptZfZxzlbIzCqQGfDO+a0RPOCb6oESxTXlUuGzTGS1cz+qd6FbK5K2LA/A+hWlkc8G7rrjKlmqCNCe6NDg2ghTeSRG8lwqmqfHhCVQeS2AgiUSEkviXpyDJe7Z3NjlbT8EVCw8XpjsbVfVrCpCRP+22e3zMylOPqLEmwdbNPYzFwIxNo/E2cjj5mKuCXku7DwT2MZyv/cJ69bVXxQWsyB8NJPZmaUasRw6qlEzjryUdUFnm+XmJ95DSi0g== 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=Ro5EOp6mEkZd6S0WaGYqv9gtqvuAyxqa35OiIznoIJM=; b=gP5Pv9/8giUgjPKf9juczSRwGAZ9QONFVE7ZUSydo0yCkNKoZITS04244VquGNNS1k5AXjV6WI4RClLEUGG69yZUDLTm2pZOiaj/bKRTvdnfYD9TwvFYLj/7HjmhDS1c3TTwuyCCHHDv8rtI/SmyOukdFo4HgJjO04Z7w7OEyA8= Received: from AM7PR04MB7046.eurprd04.prod.outlook.com (2603:10a6:20b:113::22) by AM9PR04MB8415.eurprd04.prod.outlook.com (2603:10a6:20b:3b5::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Thu, 20 Jul 2023 07:10:32 +0000 Received: from AM7PR04MB7046.eurprd04.prod.outlook.com ([fe80::9018:e395:332c:e24b]) by AM7PR04MB7046.eurprd04.prod.outlook.com ([fe80::9018:e395:332c:e24b%4]) with mapi id 15.20.6609.022; Thu, 20 Jul 2023 07:10:32 +0000 From: Ying Liu To: "dri-devel@lists.freedesktop.org" , "devicetree@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" CC: "andrzej.hajda@intel.com" , "neil.armstrong@linaro.org" , "rfoss@kernel.org" , "Laurent.pinchart@ideasonboard.com" , "jonas@kwiboo.se" , "jernej.skrabec@gmail.com" , "airlied@gmail.com" , "daniel@ffwll.ch" , "robh+dt@kernel.org" , "krzysztof.kozlowski+dt@linaro.org" , "conor+dt@kernel.org" , "shawnguo@kernel.org" , "s.hauer@pengutronix.de" , "kernel@pengutronix.de" , "festevam@gmail.com" , dl-linux-imx , "alexander.stein@ew.tq-group.com" , "sam@ravnborg.org" , "jagan@amarulasolutions.com" Subject: [PATCH v2 7/9] drm/bridge: synopsys: dw-mipi-dsi: Disable HSTX and LPRX timeout check Thread-Topic: [PATCH v2 7/9] drm/bridge: synopsys: dw-mipi-dsi: Disable HSTX and LPRX timeout check Thread-Index: Adm62UWNCyqQxjzgdUmjJHPwqEPmsA== Date: Thu, 20 Jul 2023 07:10:32 +0000 Message-ID: <20230720071430.259892-8-victor.liu@nxp.com> References: <20230720071430.259892-1-victor.liu@nxp.com> In-Reply-To: <20230720071430.259892-1-victor.liu@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SI2PR01CA0039.apcprd01.prod.exchangelabs.com (2603:1096:4:193::16) To AM7PR04MB7046.eurprd04.prod.outlook.com (2603:10a6:20b:113::22) x-mailer: git-send-email 2.37.1 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM7PR04MB7046:EE_|AM9PR04MB8415:EE_ x-ms-office365-filtering-correlation-id: 69888b05-0bd7-4453-d394-08db88f0680e x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: LKldNpDWd3hmOB/Bpr6a/6F+3FGySCfQn0aNbYMoMxq7aYZ+Rht1uBeeIySt+V2g6bK4KY7nvLgBwcPbgnA5f9PsECC4un7UtJAS7k/v8xep9ERrzTBpd1OiGeicnFolVXyUY0EPdOIwN7r5OISl6Hs3OTqTbgHw64yzdf9cEGU8DlFrMg91u6E4/XdkNcXNezZJ4HbbDxeA1bMXgRBBWjReMAP2KPB6eq3IwpES3bRjOiW+dGS6C31IoEU8KVDzzBhK1H4aiZLJnlPLjuGWXe53KZ3twYzSS6l62ZyI33n0kojVGjPBNzh60uU3a1l17XYFCsDRsJkAAuNCJmTS4aS1kSV6Yw8mXJB2yradc5fLPKfMHgzSr3h/jgP5J7+X8dFpNrA+cC1mpD0j8h4NrJGU8GyI9R4hOuF4Xu/9+3p/8hckFxiRCxCb8M/p1u5TNKpEerJAmcpIRvKCUbMsFdhS+0pHv2nN+Z6G1BMyPsZLHbazmOsmwPN1hulffMe9a/TYZenm3BvTijtTae23+DPeMtOsdOlnD7rPPZy7Tq6XP0ECzbqI+xq0y3sIALxDzz0XweBB4rMwshXZzMXP95JX4+/Svur4nK8dB6CZ+oQMrYW3z/SzoJkgcaZrFvPI x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR04MB7046.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(366004)(136003)(376002)(39860400002)(346002)(396003)(451199021)(6506007)(478600001)(1076003)(26005)(6486002)(52116002)(2906002)(6512007)(71200400001)(4326008)(5660300002)(66556008)(316002)(66946007)(66476007)(83380400001)(66446008)(54906003)(110136005)(64756008)(38350700002)(36756003)(38100700002)(7416002)(8936002)(8676002)(86362001)(186003)(2616005)(41300700001)(122000001); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?R+gKqyyMBFptvoZofgvNiPp?= =?iso-8859-1?q?3Z0pBsgkrmLlzPqaRLdxtn7K7j8zGT9EolawKCCxcgf0O1DYFpT7ivr++f0f?= =?iso-8859-1?q?N5LKSiDQa+rykZz6zxMrZIQhN4mNefL/XlgF1m2ThxOnrKqPj/FuxsQc23Fm?= =?iso-8859-1?q?n3wpAfISldqhulFiusNuk/iKCnCHd8YdmU5fX94wdhSPa/9XEpYDpAS6+F5m?= =?iso-8859-1?q?oJ0eFNdLYngLkWHaGwtCN0CpmdJ4proZH96BBEtz0NkUgW0574veT8hiWYLX?= =?iso-8859-1?q?fxI0PQDoFFxz+o7Yr2t3oA8JnxAliaj6hv8E10Vdf0pCxOg/YEtUf6GleUU4?= =?iso-8859-1?q?zW5sM17pSQv4aGSgS58GnRzzJxdKEjYyUMRL5uy7ptRNHysSjr4ZKWlMjvGV?= =?iso-8859-1?q?0Wg2MrL9aiZR3ydczp6SI9QSd04F+d+Okj1SrTfF5j+VRN3W9ZT5GoUoEzYb?= =?iso-8859-1?q?omN64SEhtV+8a6fRHMV1+qOgC7qtZoqzjglOZ9CtPIsXC/FcWLorRJfkLeRY?= =?iso-8859-1?q?r9rmBY2Z/LvrIVNGZSnd0E/5QzAaqObKLlYLWaCHHbsY1ofI6ucBN0krlgmy?= =?iso-8859-1?q?2rm9mrQstQGi+yQwjOGCTz5dkhNoOOImsDamipxOHqATxWFBHNT4xH9Nr98d?= =?iso-8859-1?q?8nO8Hz5PR+EE+vwYFcP5uk2GeWskoYGuK8z404AvFPtDxvFK2GF68c9N5ErR?= =?iso-8859-1?q?HInk9+9ph+bepvTt024mhpGsegu5KfZ6G9XriMEk9R0lkKtRY8LwaKMdbeRO?= =?iso-8859-1?q?dbrORGZuE9zzYV8GrSxaQlpzlXKqUhLE2KTXlPm1JlY0H33IRdJe+SI5kWd1?= =?iso-8859-1?q?pqhT4jfuA7R2aqn4kKG7aSKbjM7ZPpayu4s7UR5dmfdy1W+54Z2TE2atDzJO?= =?iso-8859-1?q?Z1lpw4IXRYgF9ZhSwZN2WiL51VI9X/NIbxkZTVcHQYAf7BZwng1eks4X37Z4?= =?iso-8859-1?q?1K+D8hnBDqlh7i74/NWXQO3mqxwvLZCPHih4f6z4wNbyZvoxKkc+O5ChiT7g?= =?iso-8859-1?q?Nvs8+wr+SrEqHL0WqzuvQwuFXbOhpWJ7WfhwkbDjwe6+pF7qYAcR7+3u6nOB?= =?iso-8859-1?q?Pbi4GVHXMRAq05iHPOUzWP+5p2NZjCvEndAnroy95S6+5Bwo2TeRLFdGRT1a?= =?iso-8859-1?q?qJ/wwBk5LWA0PlxMENN1ugrKNmbxPPF8Un1DGQoMsvOuSa3au5dGLdH0SC8b?= =?iso-8859-1?q?S1tzv0XE6bsRthmTck4EPu+7C5/+DXDY4x6T41wifse11o9VlZdrp0LeEvNZ?= =?iso-8859-1?q?gJ+uQn7JZWT0vlWpGOgc6SfzKooT8Fkn1vtNS9KrSux2aPldAj2fw4a3NHuW?= =?iso-8859-1?q?9VqOxRK+nSkHSK8NhufT+iL8V9jwdZG9p9jg8/F26Jf2XQGdEEJUFhp+AewD?= =?iso-8859-1?q?JlflX5ZUgGnx57R5GwsIU6EpWRxFG+i+mxL3pA5eV1WpXXf+J6wfTgT0YFlU?= =?iso-8859-1?q?eMg81Su9p/ahC7Ckg4YCepArYA1KOrpz2NfeRgZbTN+MM82LYMFlccvszliY?= =?iso-8859-1?q?tkvqATog/0UWehcvoi2Wpmtkgtd2/zHMpKX2jxAHHsY1ibtJkFy0pMB4vOHD?= =?iso-8859-1?q?4tFKn+Y5fOSDBlr2nXXiQGpjAQlTqC4uyGleO3ViZunhNZU4h3Nn7ER0nEd3?= =?iso-8859-1?q?0S/bcuj37+G/8ghLz?= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7046.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 69888b05-0bd7-4453-d394-08db88f0680e X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jul 2023 07:10:32.1952 (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: XUixrAXBC+LPWrgLCvV6MFuqbsLdl3WfEDdnZ2lRWIAs6kJbodURnp6wiF1XEWL2sLKanjt2MSd/Uu8z1lsppg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8415 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org According to Synopsys DW MIPI DSI host databook, HSTX and LPRX timeout contention detections are measured in TO_CLK_DIVISION cycles. However, the current driver programs magic values to TO_CLK_DIVISION, HSTX_TO_CNT and LPRX_TO_CNT register fields, which makes timeout error event wrongly happen for some video modes, at least for the typical 1920x1080p@60 video mode read from a HDMI monitor driven by ADV7535 DSI to HDMI bridge. While at it, the current driver doesn't enable interrupt to handle or complain about the error status, so true error just happens silently except for display distortions by visual check. Disable the timeout check by setting those timeout register fields to zero for now until someone comes along with better computations for the timeout values. Although the databook doesn't mention what happens when they are set to zero, it turns out the false error doesn't happen for the 1920x1080p@60 video mode at least. Signed-off-by: Liu Ying --- v1->v2: * No change. drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c index 536306ccea5a..0fcadf99e783 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c @@ -684,7 +684,7 @@ static void dw_mipi_dsi_init(struct dw_mipi_dsi *dsi) * timeout clock division should be computed with the * high speed transmission counter timeout and byte lane... */ - dsi_write(dsi, DSI_CLKMGR_CFG, TO_CLK_DIVISION(10) | + dsi_write(dsi, DSI_CLKMGR_CFG, TO_CLK_DIVISION(0) | TX_ESC_CLK_DIVISION(esc_clk_division)); } @@ -747,7 +747,7 @@ static void dw_mipi_dsi_command_mode_config(struct dw_mipi_dsi *dsi) * compute high speed transmission counter timeout according * to the timeout clock division (TO_CLK_DIVISION) and byte lane... */ - dsi_write(dsi, DSI_TO_CNT_CFG, HSTX_TO_CNT(1000) | LPRX_TO_CNT(1000)); + dsi_write(dsi, DSI_TO_CNT_CFG, HSTX_TO_CNT(0) | LPRX_TO_CNT(0)); /* * TODO dw drv improvements * the Bus-Turn-Around Timeout Counter should be computed From patchwork Thu Jul 20 07:10:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Ying X-Patchwork-Id: 704693 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85FADEB64DC for ; Thu, 20 Jul 2023 07:12:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230014AbjGTHM1 (ORCPT ); Thu, 20 Jul 2023 03:12:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230221AbjGTHMD (ORCPT ); Thu, 20 Jul 2023 03:12:03 -0400 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2057.outbound.protection.outlook.com [40.107.247.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57FF535BB for ; Thu, 20 Jul 2023 00:10:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nrgWIldW2PBcsUTP5+rzuaY+yfK66M3STSgU1vRj6SgCOiPzViVV8B0Kyt1togQCxeJUioqr70g2a7VeX/X3PEY2FMJKkgMdAgQQZQFhpXIQimWvXcnTwOKpwzff1msO1KQ/ZGhhyA898q2spvAdxpzs8vsxI6i2n51lX9UGHMtJVwjCuoZuYahlqbztOeaDHwO+zuyGshgpiAj9V8E1ZkRYWKSApfIj4Dh/wgFqnCJ7EKdYIMhKZtRGa4Xr5l6o9Y2LZEOwrqpzh2jmrGndW+3TOhedFTJJzMeQv8MzV43leugJT9t/N5pIKgFJwEm/Deubcnf9E6ypVM8jMHImrw== 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=/3lrrJaVWF9puU26K9AE/lNYZBZMFt7oQYQspjjUzg0=; b=H11siSJUrJOI2QROkchYV9n4hibBsKjPDuhChSQAeenlXVULQiItKEW5GPjZQxYXywa8u+/Z7z3iow+3DAs1jvYHl5o8re0mqe3/EbtCu2YfAidCmBHSIUf4Ik+Mk66PaeHRlTH6dP8veJWPYRSKa7MhgXnUUuGBEu5zekuvEyHRNLUhPEIY+aWSyRAmroNK8eK29MHixtEFpM9M4dEwX9UghpLGQKJKIdv+fg8o5WQ/u9008jckO3zSH72+OUY7mjAgrO9Fnr8UF23aZJp0yhqLZGrVeow5Gn5yOiYlbijAGhPsS2VzbjaTKNBjCQ1IRBHZqFoQh7HXQb5UKjMiqQ== 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=/3lrrJaVWF9puU26K9AE/lNYZBZMFt7oQYQspjjUzg0=; b=Kl2U8e3mfGRJatYI5Jl25jJCSvMkNwB5JDHu7f2aJiLQBSLJe7aXDtBuQ3srO7P+D4lDWKsrW2CLlHeteoAFpQi19tDY7NO1jPSkBT+ntz5VF1vL0HikzNMzIH6e4RUZcwMPbITsReqrUjM7FZIMqbSbAolbpicUJQYQ4waTVpY= Received: from AM7PR04MB7046.eurprd04.prod.outlook.com (2603:10a6:20b:113::22) by AM9PR04MB8415.eurprd04.prod.outlook.com (2603:10a6:20b:3b5::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24; Thu, 20 Jul 2023 07:10:45 +0000 Received: from AM7PR04MB7046.eurprd04.prod.outlook.com ([fe80::9018:e395:332c:e24b]) by AM7PR04MB7046.eurprd04.prod.outlook.com ([fe80::9018:e395:332c:e24b%4]) with mapi id 15.20.6609.022; Thu, 20 Jul 2023 07:10:45 +0000 From: Ying Liu To: "dri-devel@lists.freedesktop.org" , "devicetree@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" CC: "andrzej.hajda@intel.com" , "neil.armstrong@linaro.org" , "rfoss@kernel.org" , "Laurent.pinchart@ideasonboard.com" , "jonas@kwiboo.se" , "jernej.skrabec@gmail.com" , "airlied@gmail.com" , "daniel@ffwll.ch" , "robh+dt@kernel.org" , "krzysztof.kozlowski+dt@linaro.org" , "conor+dt@kernel.org" , "shawnguo@kernel.org" , "s.hauer@pengutronix.de" , "kernel@pengutronix.de" , "festevam@gmail.com" , dl-linux-imx , "alexander.stein@ew.tq-group.com" , "sam@ravnborg.org" , "jagan@amarulasolutions.com" Subject: [PATCH v2 9/9] drm/bridge: imx: Add i.MX93 MIPI DSI support Thread-Topic: [PATCH v2 9/9] drm/bridge: imx: Add i.MX93 MIPI DSI support Thread-Index: Adm62U00jdoocMYrckCBGGNZEWf3Tg== Date: Thu, 20 Jul 2023 07:10:45 +0000 Message-ID: <20230720071430.259892-10-victor.liu@nxp.com> References: <20230720071430.259892-1-victor.liu@nxp.com> In-Reply-To: <20230720071430.259892-1-victor.liu@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SI2PR01CA0039.apcprd01.prod.exchangelabs.com (2603:1096:4:193::16) To AM7PR04MB7046.eurprd04.prod.outlook.com (2603:10a6:20b:113::22) x-mailer: git-send-email 2.37.1 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM7PR04MB7046:EE_|AM9PR04MB8415:EE_ x-ms-office365-filtering-correlation-id: 979e0573-67f9-4e7a-8164-08db88f06fb1 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: xKSxmmBEqetDjKXKdu3fZVv8fBflxdx5y/VgpiEgZHk0UQGdQZsuAMC+9jYQ/+VeIMQI24KIdhivEptFCvnDxHGwQHjullf7lDNqYBLll36Gf4A4nCAiSFtWn5A8JwOvKp5pA+QTsCmVVq/2PvEHZ3Z6vz5Ccr0V4AQ/JDlPrQbW2LVapfMyVvUt16CAv7Ykydbo+V1ZfKPauTLTuX7xsOBK9p6B4udnkWwJSqytNjm/BshLblsqSRhLkVqdvilEFZhYJpFH/ibBJWZ4BIyjxQFg7/GHN1splfKJ+VGyenz66OL8xpwi+L23jz+y3+t8oW22p8CSe4lCO2vOXLN9PENKpTFD99MUfhePtvVbRMH6wGNrinSJtlAvuiFnM2NE1mdle+mouUK4JQXKgtVCMvJ8svd7mAVScP9a9B4m9VXBHArnMSsWS7MEwzJs2ZB8OkYztEHHvAsPEHrb/BlYkRrrFiMLu6JuhNn8x9/KGtAbtfjhH2eWdRTCcpvB1/UV8l7I95ih6R8J0WIRvuE3c1xMcIjFj3IrvotI1jbFq8UcgS0baD2HaDyV/gZao3sAkSMajW4z11owEDceggcU9aX/J/3LuYRzz1e1vApcTNn85OI1g+XwreiS2lkMfl4x x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR04MB7046.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(366004)(136003)(376002)(39860400002)(346002)(396003)(451199021)(6506007)(478600001)(1076003)(30864003)(26005)(6486002)(52116002)(2906002)(6512007)(71200400001)(4326008)(5660300002)(66556008)(316002)(66946007)(66476007)(83380400001)(66446008)(54906003)(110136005)(64756008)(38350700002)(36756003)(38100700002)(7416002)(8936002)(8676002)(86362001)(186003)(2616005)(41300700001)(122000001)(579004)(559001); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?2vU/P5dnkqNUeGp2WbtPBbH?= =?iso-8859-1?q?/oDYTX+Fd+IVBtckjLToKKN4mJtlGycDzgeZMgce4Q8P4CyBQdmUjapvg5iw?= =?iso-8859-1?q?A9BbesS6BxraYCTK5ZwVCo02gKYVZZz+Wgc3i0IDQ+GiCpUxacaA9xADEI++?= =?iso-8859-1?q?5C0XQRNGFm74ouCZ0IEhxhdGrg4nwjdsAUlqwdkABm1Oj24TIfIRpxQR5zUV?= =?iso-8859-1?q?l/I5Ns7VRMo7CYpQeLqHPb2MaUeFwq9R8gNNkDG8QFBz9+zBsRWyHzHNavJQ?= =?iso-8859-1?q?Y98ujYqoHEd4y2onN5OYrOap/Hfm7DwCD14klomQxLa7I2Bx1/ogPRSfrrcZ?= =?iso-8859-1?q?EmMlzAS0CFEW7cPdGJxSeDasEDqR456s/SjXObbx8TOkAN+XKfYiOBdfpb7Y?= =?iso-8859-1?q?WvnrpclvkdxzRjEFXrYTLkCfWxPR595fG6grvfvd7UEc5pbiXtX9AcoUEavq?= =?iso-8859-1?q?FLMKrXBXXTcWcgYr+sWVP2WL4XXbm8Mn46v3L+U1UtCZE9vUORgzd/Yel73t?= =?iso-8859-1?q?pHaiKwnQ6zc6nc21yR4pnA14r8xkktp8lqjCR3TXBOMm+dzES3W8rFE9+NMz?= =?iso-8859-1?q?Yq9j7SICpwmpmqjfEPv2ejzZYg7ljJaXSWJg/2JA7WpITi+LCm6JKo8ZZ5+i?= =?iso-8859-1?q?8fXck6qhT97flmnY+wQuvE/bri4rO2XjT16Bhrl5wcPT7NxM2LxB2GYoM/md?= =?iso-8859-1?q?GqRvu7fQ+vEXDpR9bDYU2Cx+ivBoDrbBd+rQ+ymQk0ZaR9T7CVg+hnY1G05s?= =?iso-8859-1?q?8l+ATqrOj51LXyRS6Urj+CxcIitrxJ1Q3j+kmhP2Q+N4yOLcsIDU/O+xE66H?= =?iso-8859-1?q?FJMiSUXjG9HVK2AXg8a+DcPkIUW3GsGqz7z9ar3EphWj/dShoftmu/KPTS3p?= =?iso-8859-1?q?pfGxtMf2UluRcQoPnK2slHSjCM7c560pqtt30rSgCXw1ExsXSB7PpIpMnnfA?= =?iso-8859-1?q?uhktY7DjWelCSlmJP4uLSTJgTOhMkyacLSS8bYREXJNMhB0j5rgSLwdHdB9a?= =?iso-8859-1?q?9p5kdJbPLHmDTrhQif1RQJ+OwXhV9tutfzlNyfiBUmrcmYWPQH3zUhmRRmc2?= =?iso-8859-1?q?zOeN7N+j9ko1/xPCegWbbRhw1iIbz7E6MRprWxbEUdConE9mPwsV/7KcoqpO?= =?iso-8859-1?q?2fKL1Uvc5FiKL22yCV31HmcXDm3zfgOvWUDn93yq1kL5OsGMeAwSSreFrKKh?= =?iso-8859-1?q?GstiKkDqMcgXwz6cTXVQLftJpM92mVFDTynrblFkDhPznuJJ46yGL0Bp0cLh?= =?iso-8859-1?q?U+aHLEJ1kWfBBlTQBogy3TzTInojCT3sZIs45CcR8Yo8Z+oQlG7fFfQqWMGG?= =?iso-8859-1?q?k3dJt6nR5W7QhVA5NqL48mMIGZEzcu4NDuPVIzqPehr94wGRRHwzEYoxdRG+?= =?iso-8859-1?q?pFMEZco3hmCgOUY0xztTMpgdkyn3E8IEPJRrErDcaEAqrpS/xO3czx5qXkxw?= =?iso-8859-1?q?zEmNyBGMPPzhmOvYYgeSzqd06OX2oPMukUzrC/q060QH+0ix2gzinjLZptCY?= =?iso-8859-1?q?eJThL2FKgvHXyIWOYRH3MlGxU5hrccCELZaoM6+V0rf+CzdIJYTcHDT5qxaM?= =?iso-8859-1?q?CdgYK7H3+U777TmZzHABwfyB6t2ILlbw9EuOlzOslVS1PaCowTAGXCGyB1W7?= =?iso-8859-1?q?nzgamSAOWVKHt3o14?= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7046.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 979e0573-67f9-4e7a-8164-08db88f06fb1 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jul 2023 07:10:45.0210 (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: ZFg0eEqMgPp4ycQ1MHTvAULn0K8vR4v/5g24eRJgLbDzmzdpBjjyBhTAT0QWkfSNpVtcS8kDLQVmn7NCnRYkQw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8415 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Freescale i.MX93 SoC embeds a Synopsys Designware MIPI DSI host controller and a Synopsys Designware MIPI DPHY. Some configurations and extensions to them are controlled by i.MX93 media blk-ctrl. Add a DRM bridge for i.MX93 MIPI DSI by using existing DW MIPI DSI bridge helpers and implementing i.MX93 MIPI DSI specific extensions. Signed-off-by: Liu Ying --- v1->v2: * Use dev_err_probe() to replace DRM_DEV_ERROR(). (Sam and Alexander) * Use dev_*() to replace DRM_*(). (Sam) * Fix build for arm architecture. (Reported-by: kernel test robot ) * Improve error messages for imx93_dsi_phy_init(). drivers/gpu/drm/bridge/imx/Kconfig | 10 + drivers/gpu/drm/bridge/imx/Makefile | 1 + drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c | 917 ++++++++++++++++++++ 3 files changed, 928 insertions(+) create mode 100644 drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c diff --git a/drivers/gpu/drm/bridge/imx/Kconfig b/drivers/gpu/drm/bridge/imx/Kconfig index 9fae28db6aa7..5182298c7182 100644 --- a/drivers/gpu/drm/bridge/imx/Kconfig +++ b/drivers/gpu/drm/bridge/imx/Kconfig @@ -49,4 +49,14 @@ config DRM_IMX8QXP_PIXEL_LINK_TO_DPI Choose this to enable pixel link to display pixel interface(PXL2DPI) found in Freescale i.MX8qxp processor. +config DRM_IMX93_MIPI_DSI + tristate "Freescale i.MX93 specific extensions for Synopsys DW MIPI DSI" + depends on OF + depends on COMMON_CLK + select DRM_DW_MIPI_DSI + select GENERIC_PHY_MIPI_DPHY + help + Choose this to enable MIPI DSI controller found in Freescale i.MX93 + processor. + endif # ARCH_MXC || COMPILE_TEST diff --git a/drivers/gpu/drm/bridge/imx/Makefile b/drivers/gpu/drm/bridge/imx/Makefile index 8e2ebf3399a1..2b0c2e44aa1b 100644 --- a/drivers/gpu/drm/bridge/imx/Makefile +++ b/drivers/gpu/drm/bridge/imx/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_DRM_IMX8QXP_LDB) += imx8qxp-ldb.o obj-$(CONFIG_DRM_IMX8QXP_PIXEL_COMBINER) += imx8qxp-pixel-combiner.o obj-$(CONFIG_DRM_IMX8QXP_PIXEL_LINK) += imx8qxp-pixel-link.o obj-$(CONFIG_DRM_IMX8QXP_PIXEL_LINK_TO_DPI) += imx8qxp-pxl2dpi.o +obj-$(CONFIG_DRM_IMX93_MIPI_DSI) += imx93-mipi-dsi.o diff --git a/drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c b/drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c new file mode 100644 index 000000000000..3ff30ce80c5b --- /dev/null +++ b/drivers/gpu/drm/bridge/imx/imx93-mipi-dsi.c @@ -0,0 +1,917 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/* + * Copyright 2022,2023 NXP + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +/* DPHY PLL configuration registers */ +#define DSI_REG 0x4c +#define CFGCLKFREQRANGE_MASK GENMASK(5, 0) +#define CFGCLKFREQRANGE(x) FIELD_PREP(CFGCLKFREQRANGE_MASK, (x)) +#define CLKSEL_MASK GENMASK(7, 6) +#define CLKSEL_STOP FIELD_PREP(CLKSEL_MASK, 0) +#define CLKSEL_GEN FIELD_PREP(CLKSEL_MASK, 1) +#define CLKSEL_EXT FIELD_PREP(CLKSEL_MASK, 2) +#define HSFREQRANGE_MASK GENMASK(14, 8) +#define HSFREQRANGE(x) FIELD_PREP(HSFREQRANGE_MASK, (x)) +#define UPDATE_PLL BIT(17) +#define SHADOW_CLR BIT(18) +#define CLK_EXT BIT(19) + +#define DSI_WRITE_REG0 0x50 +#define M_MASK GENMASK(9, 0) +#define M(x) FIELD_PREP(M_MASK, ((x) - 2)) +#define N_MASK GENMASK(13, 10) +#define N(x) FIELD_PREP(N_MASK, ((x) - 1)) +#define VCO_CTRL_MASK GENMASK(19, 14) +#define VCO_CTRL(x) FIELD_PREP(VCO_CTRL_MASK, (x)) +#define PROP_CTRL_MASK GENMASK(25, 20) +#define PROP_CTRL(x) FIELD_PREP(PROP_CTRL_MASK, (x)) +#define INT_CTRL_MASK GENMASK(31, 26) +#define INT_CTRL(x) FIELD_PREP(INT_CTRL_MASK, (x)) + +#define DSI_WRITE_REG1 0x54 +#define GMP_CTRL_MASK GENMASK(1, 0) +#define GMP_CTRL(x) FIELD_PREP(GMP_CTRL_MASK, (x)) +#define CPBIAS_CTRL_MASK GENMASK(8, 2) +#define CPBIAS_CTRL(x) FIELD_PREP(CPBIAS_CTRL_MASK, (x)) +#define PLL_SHADOW_CTRL BIT(9) + +/* display mux control register */ +#define DISPLAY_MUX 0x60 +#define MIPI_DSI_RGB666_MAP_CFG GENMASK(7, 6) +#define RGB666_CONFIG1 FIELD_PREP(MIPI_DSI_RGB666_MAP_CFG, 0) +#define RGB666_CONFIG2 FIELD_PREP(MIPI_DSI_RGB666_MAP_CFG, 1) +#define MIPI_DSI_RGB565_MAP_CFG GENMASK(5, 4) +#define RGB565_CONFIG1 FIELD_PREP(MIPI_DSI_RGB565_MAP_CFG, 0) +#define RGB565_CONFIG2 FIELD_PREP(MIPI_DSI_RGB565_MAP_CFG, 1) +#define RGB565_CONFIG3 FIELD_PREP(MIPI_DSI_RGB565_MAP_CFG, 2) +#define LCDIF_CROSS_LINE_PATTERN GENMASK(3, 0) +#define RGB888_TO_RGB888 FIELD_PREP(LCDIF_CROSS_LINE_PATTERN, 0) +#define RGB888_TO_RGB666 FIELD_PREP(LCDIF_CROSS_LINE_PATTERN, 6) +#define RGB565_TO_RGB565 FIELD_PREP(LCDIF_CROSS_LINE_PATTERN, 7) + +#define MHZ(x) ((x) * 1000000UL) + +#define REF_CLK_RATE_MAX MHZ(64) +#define REF_CLK_RATE_MIN MHZ(2) +#define FOUT_MAX MHZ(1250) +#define FOUT_MIN MHZ(40) +#define FVCO_DIV_FACTOR MHZ(80) + +#define MBPS(x) ((x) * 1000000UL) + +#define DATA_RATE_MAX_SPEED MBPS(2500) +#define DATA_RATE_MIN_SPEED MBPS(80) + +#define M_MAX 625UL +#define M_MIN 64UL + +#define N_MAX 16U +#define N_MIN 1U + +struct imx93_dsi { + struct device *dev; + struct regmap *regmap; + struct clk *clk_pixel; + struct clk *clk_ref; + struct clk *clk_cfg; + struct dw_mipi_dsi *dmd; + struct dw_mipi_dsi_plat_data pdata; + union phy_configure_opts phy_cfg; + unsigned long ref_clk_rate; + u32 format; +}; + +struct dphy_pll_cfg { + u32 m; /* PLL Feedback Multiplication Ratio */ + u32 n; /* PLL Input Frequency Division Ratio */ +}; + +struct dphy_pll_vco_prop { + unsigned long max_fout; + u8 vco_cntl; + u8 prop_cntl; +}; + +struct dphy_pll_hsfreqrange { + unsigned long max_mbps; + u8 hsfreqrange; +}; + +/* DPHY Databook Table 3-13 Charge-pump Programmability */ +static const struct dphy_pll_vco_prop vco_prop_map[] = { + { 55, 0x3f, 0x0d }, + { 82, 0x37, 0x0d }, + { 110, 0x2f, 0x0d }, + { 165, 0x27, 0x0d }, + { 220, 0x1f, 0x0d }, + { 330, 0x17, 0x0d }, + { 440, 0x0f, 0x0d }, + { 660, 0x07, 0x0d }, + { 1149, 0x03, 0x0d }, + { 1152, 0x01, 0x0d }, + { 1250, 0x01, 0x0e }, +}; + +/* DPHY Databook Table 5-7 Frequency Ranges and Defaults */ +static const struct dphy_pll_hsfreqrange hsfreqrange_map[] = { + { 89, 0x00 }, + { 99, 0x10 }, + { 109, 0x20 }, + { 119, 0x30 }, + { 129, 0x01 }, + { 139, 0x11 }, + { 149, 0x21 }, + { 159, 0x31 }, + { 169, 0x02 }, + { 179, 0x12 }, + { 189, 0x22 }, + { 204, 0x32 }, + { 219, 0x03 }, + { 234, 0x13 }, + { 249, 0x23 }, + { 274, 0x33 }, + { 299, 0x04 }, + { 324, 0x14 }, + { 349, 0x25 }, + { 399, 0x35 }, + { 449, 0x05 }, + { 499, 0x16 }, + { 549, 0x26 }, + { 599, 0x37 }, + { 649, 0x07 }, + { 699, 0x18 }, + { 749, 0x28 }, + { 799, 0x39 }, + { 849, 0x09 }, + { 899, 0x19 }, + { 949, 0x29 }, + { 999, 0x3a }, + { 1049, 0x0a }, + { 1099, 0x1a }, + { 1149, 0x2a }, + { 1199, 0x3b }, + { 1249, 0x0b }, + { 1299, 0x1b }, + { 1349, 0x2b }, + { 1399, 0x3c }, + { 1449, 0x0c }, + { 1499, 0x1c }, + { 1549, 0x2c }, + { 1599, 0x3d }, + { 1649, 0x0d }, + { 1699, 0x1d }, + { 1749, 0x2e }, + { 1799, 0x3e }, + { 1849, 0x0e }, + { 1899, 0x1e }, + { 1949, 0x2f }, + { 1999, 0x3f }, + { 2049, 0x0f }, + { 2099, 0x40 }, + { 2149, 0x41 }, + { 2199, 0x42 }, + { 2249, 0x43 }, + { 2299, 0x44 }, + { 2349, 0x45 }, + { 2399, 0x46 }, + { 2449, 0x47 }, + { 2499, 0x48 }, + { 2500, 0x49 }, +}; + +static void dphy_pll_write(struct imx93_dsi *dsi, unsigned int reg, u32 value) +{ + int ret; + + ret = regmap_write(dsi->regmap, reg, value); + if (ret < 0) + dev_err(dsi->dev, "failed to write 0x%08x to pll reg 0x%x: %d\n", + value, reg, ret); +} + +static inline unsigned long data_rate_to_fout(unsigned long data_rate) +{ + /* Fout is half of data rate */ + return data_rate / 2; +} + +static int +dphy_pll_get_configure_from_opts(struct imx93_dsi *dsi, + struct phy_configure_opts_mipi_dphy *dphy_opts, + struct dphy_pll_cfg *cfg) +{ + struct device *dev = dsi->dev; + unsigned long fin = dsi->ref_clk_rate; + unsigned long fout; + unsigned long best_fout = 0; + unsigned int fvco_div; + unsigned int min_n, max_n, n, best_n; + unsigned long m, best_m; + unsigned long min_delta = ULONG_MAX; + unsigned long delta; + u64 tmp; + + if (dphy_opts->hs_clk_rate < DATA_RATE_MIN_SPEED || + dphy_opts->hs_clk_rate > DATA_RATE_MAX_SPEED) { + dev_dbg(dev, "invalid data rate per lane: %lu\n", + dphy_opts->hs_clk_rate); + return -EINVAL; + } + + fout = data_rate_to_fout(dphy_opts->hs_clk_rate); + + /* DPHY Databook 3.3.6.1 Output Frequency */ + /* Fout = Fvco / Fvco_div = (Fin * M) / (Fvco_div * N) */ + /* Fvco_div could be 1/2/4/8 according to Fout range. */ + fvco_div = 8UL / min(DIV_ROUND_UP(fout, FVCO_DIV_FACTOR), 8UL); + + /* limitation: 2MHz <= Fin / N <= 8MHz */ + min_n = DIV_ROUND_UP_ULL((u64)fin, MHZ(8)); + max_n = DIV_ROUND_DOWN_ULL((u64)fin, MHZ(2)); + + /* clamp possible N(s) */ + min_n = clamp(min_n, N_MIN, N_MAX); + max_n = clamp(max_n, N_MIN, N_MAX); + + dev_dbg(dev, "Fout = %lu, Fvco_div = %u, n_range = [%u, %u]\n", + fout, fvco_div, min_n, max_n); + + for (n = min_n; n <= max_n; n++) { + /* M = (Fout * N * Fvco_div) / Fin */ + m = DIV_ROUND_CLOSEST(fout * n * fvco_div, fin); + + /* check M range */ + if (m < M_MIN || m > M_MAX) + continue; + + /* calculate temporary Fout */ + tmp = m * fin; + do_div(tmp, n * fvco_div); + if (tmp < FOUT_MIN || tmp > FOUT_MAX) + continue; + + delta = abs(fout - tmp); + if (delta < min_delta) { + best_n = n; + best_m = m; + min_delta = delta; + best_fout = tmp; + } + } + + if (best_fout) { + cfg->m = best_m; + cfg->n = best_n; + dev_dbg(dev, "best Fout = %lu, m = %u, n = %u\n", + best_fout, cfg->m, cfg->n); + } else { + dev_dbg(dev, "failed to find best Fout\n"); + return -EINVAL; + } + + return 0; +} + +static void dphy_pll_clear_shadow(struct imx93_dsi *dsi) +{ + /* Reference DPHY Databook Figure 3-3 Initialization Timing Diagram. */ + /* Select clock generation first. */ + dphy_pll_write(dsi, DSI_REG, CLKSEL_GEN); + + /* Clear shadow after clock selection is done a while. */ + fsleep(1); + dphy_pll_write(dsi, DSI_REG, CLKSEL_GEN | SHADOW_CLR); + + /* A minimum pulse of 5ns on shadow_clear signal. */ + fsleep(1); + dphy_pll_write(dsi, DSI_REG, CLKSEL_GEN); +} + +static unsigned long dphy_pll_get_cfgclkrange(struct imx93_dsi *dsi) +{ + /* + * DPHY Databook Table 4-4 System Control Signals mentions an equation + * for cfgclkfreqrange[5:0]. + */ + return (clk_get_rate(dsi->clk_cfg) / MHZ(1) - 17) * 4; +} + +static u8 +dphy_pll_get_hsfreqrange(struct phy_configure_opts_mipi_dphy *dphy_opts) +{ + unsigned long mbps = dphy_opts->hs_clk_rate / MHZ(1); + int i; + + for (i = 0; i < ARRAY_SIZE(hsfreqrange_map); i++) + if (mbps <= hsfreqrange_map[i].max_mbps) + return hsfreqrange_map[i].hsfreqrange; + + return 0; +} + +static u8 dphy_pll_get_vco(struct phy_configure_opts_mipi_dphy *dphy_opts) +{ + unsigned long fout = data_rate_to_fout(dphy_opts->hs_clk_rate) / MHZ(1); + int i; + + for (i = 0; i < ARRAY_SIZE(vco_prop_map); i++) + if (fout <= vco_prop_map[i].max_fout) + return vco_prop_map[i].vco_cntl; + + return 0; +} + +static u8 dphy_pll_get_prop(struct phy_configure_opts_mipi_dphy *dphy_opts) +{ + unsigned long fout = data_rate_to_fout(dphy_opts->hs_clk_rate) / MHZ(1); + int i; + + for (i = 0; i < ARRAY_SIZE(vco_prop_map); i++) + if (fout <= vco_prop_map[i].max_fout) + return vco_prop_map[i].prop_cntl; + + return 0; +} + +static int dphy_pll_update(struct imx93_dsi *dsi) +{ + int ret; + + ret = regmap_update_bits(dsi->regmap, DSI_REG, UPDATE_PLL, UPDATE_PLL); + if (ret < 0) { + dev_err(dsi->dev, "failed to set UPDATE_PLL: %d\n", ret); + return ret; + } + + /* + * The updatepll signal should be asserted for a minimum of four clkin + * cycles, according to DPHY Databook Figure 3-3 Initialization Timing + * Diagram. + */ + fsleep(10); + + ret = regmap_update_bits(dsi->regmap, DSI_REG, UPDATE_PLL, 0); + if (ret < 0) { + dev_err(dsi->dev, "failed to clear UPDATE_PLL: %d\n", ret); + return ret; + } + + return 0; +} + +static int dphy_pll_configure(struct imx93_dsi *dsi, union phy_configure_opts *opts) +{ + struct dphy_pll_cfg cfg = { 0 }; + u32 val; + int ret; + + ret = dphy_pll_get_configure_from_opts(dsi, &opts->mipi_dphy, &cfg); + if (ret) { + dev_err(dsi->dev, "failed to get phy pll cfg %d\n", ret); + return ret; + } + + dphy_pll_clear_shadow(dsi); + + /* DSI_REG */ + val = CLKSEL_GEN | + CFGCLKFREQRANGE(dphy_pll_get_cfgclkrange(dsi)) | + HSFREQRANGE(dphy_pll_get_hsfreqrange(&opts->mipi_dphy)); + dphy_pll_write(dsi, DSI_REG, val); + + /* DSI_WRITE_REG0 */ + val = M(cfg.m) | N(cfg.n) | INT_CTRL(0) | + VCO_CTRL(dphy_pll_get_vco(&opts->mipi_dphy)) | + PROP_CTRL(dphy_pll_get_prop(&opts->mipi_dphy)); + dphy_pll_write(dsi, DSI_WRITE_REG0, val); + + /* DSI_WRITE_REG1 */ + dphy_pll_write(dsi, DSI_WRITE_REG1, GMP_CTRL(1) | CPBIAS_CTRL(0x10)); + + ret = clk_prepare_enable(dsi->clk_ref); + if (ret < 0) { + dev_err(dsi->dev, "failed to enable ref clock: %d\n", ret); + return ret; + } + + /* + * At least 10 refclk cycles are required before updatePLL assertion, + * according to DPHY Databook Figure 3-3 Initialization Timing Diagram. + */ + fsleep(10); + + ret = dphy_pll_update(dsi); + if (ret < 0) { + clk_disable_unprepare(dsi->clk_ref); + return ret; + } + + return 0; +} + +static void dphy_pll_clear_reg(struct imx93_dsi *dsi) +{ + dphy_pll_write(dsi, DSI_REG, 0); + dphy_pll_write(dsi, DSI_WRITE_REG0, 0); + dphy_pll_write(dsi, DSI_WRITE_REG1, 0); +} + +static int dphy_pll_init(struct imx93_dsi *dsi) +{ + int ret; + + ret = clk_prepare_enable(dsi->clk_cfg); + if (ret < 0) { + dev_err(dsi->dev, "failed to enable config clock: %d\n", ret); + return ret; + } + + dphy_pll_clear_reg(dsi); + + return 0; +} + +static void dphy_pll_uninit(struct imx93_dsi *dsi) +{ + dphy_pll_clear_reg(dsi); + clk_disable_unprepare(dsi->clk_cfg); +} + +static void dphy_pll_power_off(struct imx93_dsi *dsi) +{ + dphy_pll_clear_reg(dsi); + clk_disable_unprepare(dsi->clk_ref); +} + +static int imx93_dsi_get_phy_configure_opts(struct imx93_dsi *dsi, + const struct drm_display_mode *mode, + union phy_configure_opts *phy_cfg, + u32 lanes, u32 format) +{ + struct device *dev = dsi->dev; + int bpp; + int ret; + + bpp = mipi_dsi_pixel_format_to_bpp(format); + if (bpp < 0) { + dev_dbg(dev, "failed to get bpp for pixel format %d\n", format); + return -EINVAL; + } + + ret = phy_mipi_dphy_get_default_config(mode->clock * MSEC_PER_SEC, bpp, + lanes, &phy_cfg->mipi_dphy); + if (ret < 0) { + dev_dbg(dev, "failed to get default phy cfg %d\n", ret); + return ret; + } + + return 0; +} + +static enum drm_mode_status +imx93_dsi_validate_mode(struct imx93_dsi *dsi, const struct drm_display_mode *mode) +{ + struct drm_bridge *bridge = dw_mipi_dsi_get_bridge(dsi->dmd); + + /* Get the last bridge */ + while (drm_bridge_get_next_bridge(bridge)) + bridge = drm_bridge_get_next_bridge(bridge); + + if ((bridge->ops & DRM_BRIDGE_OP_DETECT) && + (bridge->ops & DRM_BRIDGE_OP_EDID)) { + unsigned long pixel_clock_rate = mode->clock * 1000; + unsigned long rounded_rate; + + /* Allow +/-0.5% pixel clock rate deviation */ + rounded_rate = clk_round_rate(dsi->clk_pixel, pixel_clock_rate); + if (rounded_rate < pixel_clock_rate * 995 / 1000 || + rounded_rate > pixel_clock_rate * 1005 / 1000) { + dev_dbg(dsi->dev, "failed to round clock for mode " DRM_MODE_FMT "\n", + DRM_MODE_ARG(mode)); + return MODE_NOCLOCK; + } + } + + return MODE_OK; +} + +static enum drm_mode_status +imx93_dsi_validate_phy(struct imx93_dsi *dsi, const struct drm_display_mode *mode, + unsigned long mode_flags, u32 lanes, u32 format) +{ + union phy_configure_opts phy_cfg; + struct dphy_pll_cfg cfg = { 0 }; + struct device *dev = dsi->dev; + int ret; + + ret = imx93_dsi_get_phy_configure_opts(dsi, mode, &phy_cfg, lanes, + format); + if (ret < 0) { + dev_dbg(dev, "failed to get phy cfg opts %d\n", ret); + return MODE_ERROR; + } + + ret = dphy_pll_get_configure_from_opts(dsi, &phy_cfg.mipi_dphy, &cfg); + if (ret < 0) { + dev_dbg(dev, "failed to get phy pll cfg %d\n", ret); + return MODE_NOCLOCK; + } + + return MODE_OK; +} + +static enum drm_mode_status +imx93_dsi_mode_valid(void *priv_data, const struct drm_display_mode *mode, + unsigned long mode_flags, u32 lanes, u32 format) +{ + struct imx93_dsi *dsi = priv_data; + struct device *dev = dsi->dev; + enum drm_mode_status ret; + + ret = imx93_dsi_validate_mode(dsi, mode); + if (ret != MODE_OK) { + dev_dbg(dev, "failed to validate mode " DRM_MODE_FMT "\n", + DRM_MODE_ARG(mode)); + return ret; + } + + ret = imx93_dsi_validate_phy(dsi, mode, mode_flags, lanes, format); + if (ret != MODE_OK) { + dev_dbg(dev, "failed to validate phy for mode " DRM_MODE_FMT "\n", + DRM_MODE_ARG(mode)); + return ret; + } + + return MODE_OK; +} + +static bool imx93_dsi_mode_fixup(void *priv_data, + const struct drm_display_mode *mode, + struct drm_display_mode *adjusted_mode) +{ + struct imx93_dsi *dsi = priv_data; + unsigned long pixel_clock_rate; + unsigned long rounded_rate; + + pixel_clock_rate = mode->clock * 1000; + rounded_rate = clk_round_rate(dsi->clk_pixel, pixel_clock_rate); + + memcpy(adjusted_mode, mode, sizeof(*mode)); + adjusted_mode->clock = rounded_rate / 1000; + + dev_dbg(dsi->dev, "adj clock %d for mode " DRM_MODE_FMT "\n", + adjusted_mode->clock, DRM_MODE_ARG(mode)); + + return true; +} + +static u32 *imx93_dsi_get_input_bus_fmts(void *priv_data, + struct drm_bridge *bridge, + struct drm_bridge_state *bridge_state, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state, + u32 output_fmt, + unsigned int *num_input_fmts) +{ + u32 *input_fmts, input_fmt; + + *num_input_fmts = 0; + + switch (output_fmt) { + case MEDIA_BUS_FMT_RGB888_1X24: + case MEDIA_BUS_FMT_RGB666_1X18: + case MEDIA_BUS_FMT_FIXED: + input_fmt = MEDIA_BUS_FMT_RGB888_1X24; + break; + case MEDIA_BUS_FMT_RGB565_1X16: + input_fmt = output_fmt; + break; + default: + return NULL; + } + + input_fmts = kmalloc(sizeof(*input_fmts), GFP_KERNEL); + if (!input_fmts) + return NULL; + input_fmts[0] = input_fmt; + *num_input_fmts = 1; + + return input_fmts; +} + +static int imx93_dsi_phy_init(void *priv_data) +{ + struct imx93_dsi *dsi = priv_data; + unsigned int fmt = 0; + int ret; + + switch (dsi->format) { + case MIPI_DSI_FMT_RGB888: + fmt = RGB888_TO_RGB888; + break; + case MIPI_DSI_FMT_RGB666: + fmt = RGB888_TO_RGB666; + regmap_update_bits(dsi->regmap, DISPLAY_MUX, + MIPI_DSI_RGB666_MAP_CFG, RGB666_CONFIG2); + break; + case MIPI_DSI_FMT_RGB666_PACKED: + fmt = RGB888_TO_RGB666; + regmap_update_bits(dsi->regmap, DISPLAY_MUX, + MIPI_DSI_RGB666_MAP_CFG, RGB666_CONFIG1); + break; + case MIPI_DSI_FMT_RGB565: + fmt = RGB565_TO_RGB565; + regmap_update_bits(dsi->regmap, DISPLAY_MUX, + MIPI_DSI_RGB565_MAP_CFG, RGB565_CONFIG1); + break; + } + + regmap_update_bits(dsi->regmap, DISPLAY_MUX, LCDIF_CROSS_LINE_PATTERN, fmt); + + ret = dphy_pll_init(dsi); + if (ret < 0) { + dev_err(dsi->dev, "failed to init phy pll: %d\n", ret); + return ret; + } + + ret = dphy_pll_configure(dsi, &dsi->phy_cfg); + if (ret < 0) { + dev_err(dsi->dev, "failed to configure phy pll: %d\n", ret); + dphy_pll_uninit(dsi); + return ret; + } + + return 0; +} + +static void imx93_dsi_phy_power_off(void *priv_data) +{ + struct imx93_dsi *dsi = priv_data; + + dphy_pll_power_off(dsi); + dphy_pll_uninit(dsi); +} + +static int +imx93_dsi_get_lane_mbps(void *priv_data, const struct drm_display_mode *mode, + unsigned long mode_flags, u32 lanes, u32 format, + unsigned int *lane_mbps) +{ + struct imx93_dsi *dsi = priv_data; + union phy_configure_opts phy_cfg; + struct device *dev = dsi->dev; + int ret; + + ret = imx93_dsi_get_phy_configure_opts(dsi, mode, &phy_cfg, lanes, + format); + if (ret < 0) { + dev_dbg(dev, "failed to get phy cfg opts %d\n", ret); + return ret; + } + + *lane_mbps = DIV_ROUND_UP(phy_cfg.mipi_dphy.hs_clk_rate, USEC_PER_SEC); + + memcpy(&dsi->phy_cfg, &phy_cfg, sizeof(phy_cfg)); + + dev_dbg(dev, "get lane_mbps %u for mode " DRM_MODE_FMT "\n", + *lane_mbps, DRM_MODE_ARG(mode)); + + return 0; +} + +/* High-Speed Transition Times */ +struct hstt { + unsigned int maxfreq; + struct dw_mipi_dsi_dphy_timing timing; +}; + +#define HSTT(_maxfreq, _c_lp2hs, _c_hs2lp, _d_lp2hs, _d_hs2lp) \ +{ \ + .maxfreq = (_maxfreq), \ + .timing = { \ + .clk_lp2hs = (_c_lp2hs), \ + .clk_hs2lp = (_c_hs2lp), \ + .data_lp2hs = (_d_lp2hs), \ + .data_hs2lp = (_d_hs2lp), \ + } \ +} + +/* DPHY Databook Table A-4 High-Speed Transition Times */ +static const struct hstt hstt_table[] = { + HSTT(80, 21, 17, 15, 10), + HSTT(90, 23, 17, 16, 10), + HSTT(100, 22, 17, 16, 10), + HSTT(110, 25, 18, 17, 11), + HSTT(120, 26, 20, 18, 11), + HSTT(130, 27, 19, 19, 11), + HSTT(140, 27, 19, 19, 11), + HSTT(150, 28, 20, 20, 12), + HSTT(160, 30, 21, 22, 13), + HSTT(170, 30, 21, 23, 13), + HSTT(180, 31, 21, 23, 13), + HSTT(190, 32, 22, 24, 13), + HSTT(205, 35, 22, 25, 13), + HSTT(220, 37, 26, 27, 15), + HSTT(235, 38, 28, 27, 16), + HSTT(250, 41, 29, 30, 17), + HSTT(275, 43, 29, 32, 18), + HSTT(300, 45, 32, 35, 19), + HSTT(325, 48, 33, 36, 18), + HSTT(350, 51, 35, 40, 20), + HSTT(400, 59, 37, 44, 21), + HSTT(450, 65, 40, 49, 23), + HSTT(500, 71, 41, 54, 24), + HSTT(550, 77, 44, 57, 26), + HSTT(600, 82, 46, 64, 27), + HSTT(650, 87, 48, 67, 28), + HSTT(700, 94, 52, 71, 29), + HSTT(750, 99, 52, 75, 31), + HSTT(800, 105, 55, 82, 32), + HSTT(850, 110, 58, 85, 32), + HSTT(900, 115, 58, 88, 35), + HSTT(950, 120, 62, 93, 36), + HSTT(1000, 128, 63, 99, 38), + HSTT(1050, 132, 65, 102, 38), + HSTT(1100, 138, 67, 106, 39), + HSTT(1150, 146, 69, 112, 42), + HSTT(1200, 151, 71, 117, 43), + HSTT(1250, 153, 74, 120, 45), + HSTT(1300, 160, 73, 124, 46), + HSTT(1350, 165, 76, 130, 47), + HSTT(1400, 172, 78, 134, 49), + HSTT(1450, 177, 80, 138, 49), + HSTT(1500, 183, 81, 143, 52), + HSTT(1550, 191, 84, 147, 52), + HSTT(1600, 194, 85, 152, 52), + HSTT(1650, 201, 86, 155, 53), + HSTT(1700, 208, 88, 161, 53), + HSTT(1750, 212, 89, 165, 53), + HSTT(1800, 220, 90, 171, 54), + HSTT(1850, 223, 92, 175, 54), + HSTT(1900, 231, 91, 180, 55), + HSTT(1950, 236, 95, 185, 56), + HSTT(2000, 243, 97, 190, 56), + HSTT(2050, 248, 99, 194, 58), + HSTT(2100, 252, 100, 199, 59), + HSTT(2150, 259, 102, 204, 61), + HSTT(2200, 266, 105, 210, 62), + HSTT(2250, 269, 109, 213, 63), + HSTT(2300, 272, 109, 217, 65), + HSTT(2350, 281, 112, 225, 66), + HSTT(2400, 283, 115, 226, 66), + HSTT(2450, 282, 115, 226, 67), + HSTT(2500, 281, 118, 227, 67), +}; + +static int imx93_dsi_phy_get_timing(void *priv_data, unsigned int lane_mbps, + struct dw_mipi_dsi_dphy_timing *timing) +{ + struct imx93_dsi *dsi = priv_data; + struct device *dev = dsi->dev; + int i; + + for (i = 0; i < ARRAY_SIZE(hstt_table); i++) + if (lane_mbps <= hstt_table[i].maxfreq) + break; + + if (i == ARRAY_SIZE(hstt_table)) { + dev_err(dev, "failed to get phy timing for lane_mbps %u\n", + lane_mbps); + return -EINVAL; + } + + *timing = hstt_table[i].timing; + + dev_dbg(dev, "get phy timing for %u <= %u (lane_mbps)\n", + lane_mbps, hstt_table[i].maxfreq); + + return 0; +} + +static const struct dw_mipi_dsi_phy_ops imx93_dsi_phy_ops = { + .init = imx93_dsi_phy_init, + .power_off = imx93_dsi_phy_power_off, + .get_lane_mbps = imx93_dsi_get_lane_mbps, + .get_timing = imx93_dsi_phy_get_timing, +}; + +static int imx93_dsi_host_attach(void *priv_data, struct mipi_dsi_device *device) +{ + struct imx93_dsi *dsi = priv_data; + + dsi->format = device->format; + + return 0; +} + +static const struct dw_mipi_dsi_host_ops imx93_dsi_host_ops = { + .attach = imx93_dsi_host_attach, +}; + +static int imx93_dsi_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + struct imx93_dsi *dsi; + int ret; + + dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL); + if (!dsi) + return -ENOMEM; + + dsi->regmap = syscon_regmap_lookup_by_phandle(np, "fsl,media-blk-ctrl"); + if (IS_ERR(dsi->regmap)) { + ret = PTR_ERR(dsi->regmap); + dev_err(dev, "failed to get block ctrl regmap: %d\n", ret); + return ret; + } + + dsi->clk_pixel = devm_clk_get(dev, "pix"); + if (IS_ERR(dsi->clk_pixel)) + return dev_err_probe(dev, PTR_ERR(dsi->clk_pixel), + "failed to get pixel clock\n"); + + dsi->clk_cfg = devm_clk_get(dev, "phy_cfg"); + if (IS_ERR(dsi->clk_cfg)) + return dev_err_probe(dev, PTR_ERR(dsi->clk_cfg), + "failed to get phy cfg clock\n"); + + dsi->clk_ref = devm_clk_get(dev, "phy_ref"); + if (IS_ERR(dsi->clk_ref)) + return dev_err_probe(dev, PTR_ERR(dsi->clk_ref), + "failed to get phy ref clock\n"); + + dsi->ref_clk_rate = clk_get_rate(dsi->clk_ref); + if (dsi->ref_clk_rate < REF_CLK_RATE_MIN || + dsi->ref_clk_rate > REF_CLK_RATE_MAX) { + dev_err(dev, "invalid phy ref clock rate %lu\n", + dsi->ref_clk_rate); + return -EINVAL; + } + dev_dbg(dev, "phy ref clock rate: %lu\n", dsi->ref_clk_rate); + + dsi->dev = dev; + dsi->pdata.max_data_lanes = 4; + dsi->pdata.mode_valid = imx93_dsi_mode_valid; + dsi->pdata.mode_fixup = imx93_dsi_mode_fixup; + dsi->pdata.get_input_bus_fmts = imx93_dsi_get_input_bus_fmts; + dsi->pdata.phy_ops = &imx93_dsi_phy_ops; + dsi->pdata.host_ops = &imx93_dsi_host_ops; + dsi->pdata.priv_data = dsi; + platform_set_drvdata(pdev, dsi); + + dsi->dmd = dw_mipi_dsi_probe(pdev, &dsi->pdata); + if (IS_ERR(dsi->dmd)) + return dev_err_probe(dev, PTR_ERR(dsi->dmd), + "failed to probe dw_mipi_dsi\n"); + + return 0; +} + +static void imx93_dsi_remove(struct platform_device *pdev) +{ + struct imx93_dsi *dsi = platform_get_drvdata(pdev); + + dw_mipi_dsi_remove(dsi->dmd); +} + +static const struct of_device_id imx93_dsi_dt_ids[] = { + { .compatible = "fsl,imx93-mipi-dsi", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, imx93_dsi_dt_ids); + +static struct platform_driver imx93_dsi_driver = { + .probe = imx93_dsi_probe, + .remove_new = imx93_dsi_remove, + .driver = { + .of_match_table = imx93_dsi_dt_ids, + .name = "imx93_mipi_dsi", + }, +}; +module_platform_driver(imx93_dsi_driver); + +MODULE_DESCRIPTION("Freescale i.MX93 MIPI DSI driver"); +MODULE_AUTHOR("Liu Ying "); +MODULE_LICENSE("GPL");