From patchwork Fri Apr 8 10:32:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandor Yu X-Patchwork-Id: 12806399 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2B062C433EF for ; Fri, 8 Apr 2022 10:33:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3968410F14D; Fri, 8 Apr 2022 10:33:10 +0000 (UTC) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80085.outbound.protection.outlook.com [40.107.8.85]) by gabe.freedesktop.org (Postfix) with ESMTPS id B216810F14E for ; Fri, 8 Apr 2022 10:33:08 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dKB7BDJgTk9la2eELYxVOcBCDHDc6ETZXtkG8xe2zBc/5NhTa1KtHGMJL6Fa+QLCH8E33Eiv/qH6YszaMr/KN97Em+ZvXM+k8vtgCo0XmYaokQx7aTxhySAAnP5AnOoIAavVXdzraSKtFLlcCqVpjXoQNB2GW5WkXxtx7Q8sIhv/lF0ON0frJZCxfm93pscX26+xvp0PYVX95vSG0vaKeh47yGsY3r9tvPg/HOdKIq7e9UGGqAxmu9HpzVyEvWd31MAZC7FF9FLM6kwAXN7jv4U75GkI5sMsJ7rM3BM02duQRFlA0oRD7UmdCM735usxhJkrbG4R56JuZ/8RyrV7nA== 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=e/UinYkAx6YLN/H678GMQTXmItd+HI/0hnc5JsCgZSA=; b=j0VWrEmjVDuk6sosemt7YCwcAQIJR7id9zrdmxSYh9eUvakr0pcdBM9l6xHQZaD5Els1h5Kg1HADXeRcsObE0T3TIxwn9AXHSLIERj0qCUiEDEzZMsNpozthd08VuBqMpG3qjOFjbPJN0tIyZN6GNOTNDV2RFtgITPiyoPh/0Q0RREWc6BbXxs+706W2l3umYtC/PCaWNAnnbu/5jinuTKIOA2R8doFJ4kZXXou/Qa+ZLtvW5JCiSqzKT9mtyYIIH5xh2HUtceLL/5D0pSnhb7hNZeYmEkEQpEQHWJCHysDyhZggUrZL56qvTjiPpyEP55mWP6HcsPsRluaeiJCc0w== 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=e/UinYkAx6YLN/H678GMQTXmItd+HI/0hnc5JsCgZSA=; b=H7d4kl+yQupeLNxTiN62UlZJcV431QOBUCxIHAlacr+u63qf0N6P29SzlbA49OnPZwCCrG1PryQ3KYjAeepkyd5kUabWjh8o1uz5YE8nhVj+CIiJxdd4y5kFaSDE6NXHr/zvTkAs8X+0wcCDWE6a8bXla3RlGhkgM9943Nvq3eI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB7PR04MB5450.eurprd04.prod.outlook.com (2603:10a6:10:86::11) by VI1PR0402MB3405.eurprd04.prod.outlook.com (2603:10a6:803:3::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.22; Fri, 8 Apr 2022 10:33:06 +0000 Received: from DB7PR04MB5450.eurprd04.prod.outlook.com ([fe80::7997:2892:d230:2430]) by DB7PR04MB5450.eurprd04.prod.outlook.com ([fe80::7997:2892:d230:2430%7]) with mapi id 15.20.5144.025; Fri, 8 Apr 2022 10:33:05 +0000 From: Sandor Yu To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, andrzej.hajda@intel.com, narmstrong@baylibre.com, robert.foss@linaro.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, hverkuil-cisco@xs4all.nl Subject: [PATCH v2 1/5] drm: bridge: dw_hdmi: cec: Add cec suspend/resume function Date: Fri, 8 Apr 2022 18:32:24 +0800 Message-Id: <45739041a743cd435415ca53264678e57a653147.1649412256.git.Sandor.yu@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-ClientProxiedBy: SGXP274CA0017.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::29) To DB7PR04MB5450.eurprd04.prod.outlook.com (2603:10a6:10:86::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 18941857-4ec3-4330-abc2-08da194b2ab3 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3405:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7PpLvTSw2XNeTv80dFNp8x4hQ1yxcUX09phvDZKJbWFzbPJIXWXmnH59mz31uRUDShNu/tKB8i329jVbgmid4JrO+TFOU4AUACwR7TsZxKfFZ9aquJhAKaW3OV7vccRvKD2zYuJatw7Sx65OKVRDm/VRZqdU7qNfCvzQuTSiyb6xdCsfGm02qJWmsK+Vl5zT6aWNAg/HWtPu0eM6IJGY8Eno5MOiQHQHOLpR0sqTlvbWzf01qauhyFAy0v0lVZggSAas/oVJCyRurn8rIBKdHiaKEIaHRV8jQgrhIw2+w7jykGOzJRJ3yC4oBXsQsCoz39SOycvBJQyhHNDxOFK9+po52RQqIUmzUEbAL9sywJYRggleXPNAlTbg6fiqRNosmaVwMBp1Dn1kFy2C80YigSkR1C9Cs9b8+ir4er+ftr4tX66Zzugnp13nGuZO9dgoiFzCh0OV7UC+zdW79DUGmGi2MZv2GJ8qvpHu3186pPlNy7vaeG8mVsLptLV57IOXMqCNS7PzIOtY0A9xuavEuQq2RSbujGsLkexLirZh9rOZ+50zhrMzoJ0aLyuvPtrI9jtsmi8sSHqsBx3oBDsWhfXRqZx9xQayuEyJf6DekNg3kG1uikXQebWQeMtOePMV6FhqDVxoIwR7WWq0BINGjN/f2EyYozYFZ3s/oF22KndjglksBPiGYO/L4MXjDN56oVnicByCS0hGdHnE0+OJMA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR04MB5450.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(8936002)(2616005)(52116002)(66476007)(15650500001)(6666004)(83380400001)(8676002)(86362001)(508600001)(66556008)(66946007)(38350700002)(4326008)(7416002)(2906002)(186003)(316002)(5660300002)(6506007)(26005)(36756003)(6512007)(38100700002)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YeIUHj3/NB80GLYqCKsknM7ML3qfXHQ6a9kji9IqoXbXs6nxk1tAgigAbT6s1DSryu483n4Q5anYCvHRpTKb4fgnNs9jlS8WYudzMr5TOR0PUc3GKRJDRUO/jLgPckm7ISOfYuwSriQtTzc0oT4CO8Jm+LkHInB6/v1Xl4nwBCNqJ3x8At00Bt8EyOEKH5wRWc7vfrCLfCcV6iy/p/R5ESIpKfrbyAZzgPMGMzGdn3/mwkaK5eLGes+gBWFjukGT8na+pD9Dwsmo7nsMJK+3DS2kmASDS2eIUDSTi2jr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DvA52d7BbSHAs0/Y1x4lZ+bU8tvNzWXnGNgl3OAQhbUfnANKa3XoIF8SFWDyBp6Xj60fcKZa4ML4I3isgy5myw0a2wwa/gnbXmutOrDvZqbDxLDBTs6S1G7XCrXdlFgU9tWno1oXfoUHUzPv2QkGHJgDAFkTdbCCKBcx+hKVddk++NeRA1h6bZUQOtKPIl87AYU4iQ95kRhP2DDW6t5VJYm+AyM+D7DSI1NaGx8OxLHiX34hVgK7GhW5NUhpjcSG7HW3301sRzULqvHzM6K3YK2QNzBrZvJ2XrLSKizkVntoFGXZAhoUF53Kb6OCXf5Pr1xcRdC8ot9QFu3YePuNN47ROTukTBt8jZjKnEztDw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18941857-4ec3-4330-abc2-08da194b2ab3 X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB5450.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2022 10:33:05.8037 (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: YlIm8ZGPdR+O4c0z3JOcNq+0FZLrLvkIk+sxdVMbuE09U1JrXuPaaOPAhAujtDaNu3MPZPuQ4OiWSQdUvjHHOw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3405 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sandor.yu@nxp.com, shengjiu.wang@nxp.com, cai.huoqing@linux.dev, maxime@cerno.tech Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" CEC interrupt status/mask and logical address registers will be reset when device enter suspend. It will cause cec fail to work after device resume. Add CEC suspend/resume functions, reinitialize logical address registers and restore interrupt status/mask registers after resume. Signed-off-by: Sandor Yu --- drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c index c8f44bcb298a..ab176401b727 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c @@ -62,6 +62,10 @@ struct dw_hdmi_cec { bool rx_done; struct cec_notifier *notify; int irq; + + u8 regs_polarity; + u8 regs_mask; + u8 regs_mute_stat0; }; static void dw_hdmi_write(struct dw_hdmi_cec *cec, u8 val, int offset) @@ -306,11 +310,44 @@ static int dw_hdmi_cec_remove(struct platform_device *pdev) return 0; } +static int __maybe_unused dw_hdmi_cec_resume(struct device *dev) +{ + struct dw_hdmi_cec *cec = dev_get_drvdata(dev); + + /* Restore logical address */ + dw_hdmi_write(cec, cec->addresses & 255, HDMI_CEC_ADDR_L); + dw_hdmi_write(cec, cec->addresses >> 8, HDMI_CEC_ADDR_H); + + /* Restore interrupt status/mask register */ + dw_hdmi_write(cec, cec->regs_polarity, HDMI_CEC_POLARITY); + dw_hdmi_write(cec, cec->regs_mask, HDMI_CEC_MASK); + dw_hdmi_write(cec, cec->regs_mute_stat0, HDMI_IH_MUTE_CEC_STAT0); + + return 0; +} + +static int __maybe_unused dw_hdmi_cec_suspend(struct device *dev) +{ + struct dw_hdmi_cec *cec = dev_get_drvdata(dev); + + /* store interrupt status/mask register */ + cec->regs_polarity = dw_hdmi_read(cec, HDMI_CEC_POLARITY); + cec->regs_mask = dw_hdmi_read(cec, HDMI_CEC_MASK); + cec->regs_mute_stat0 = dw_hdmi_read(cec, HDMI_IH_MUTE_CEC_STAT0); + + return 0; +} + +static const struct dev_pm_ops dw_hdmi_cec_pm = { + SET_SYSTEM_SLEEP_PM_OPS(dw_hdmi_cec_suspend, dw_hdmi_cec_resume) +}; + static struct platform_driver dw_hdmi_cec_driver = { .probe = dw_hdmi_cec_probe, .remove = dw_hdmi_cec_remove, .driver = { .name = "dw-hdmi-cec", + .pm = &dw_hdmi_cec_pm, }, }; module_platform_driver(dw_hdmi_cec_driver);