From patchwork Wed Nov 27 03:00:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shengjiu Wang X-Patchwork-Id: 13886518 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2054.outbound.protection.outlook.com [40.107.249.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DED0F1BC3F; Wed, 27 Nov 2024 03:01:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732676484; cv=fail; b=JUqPH9lsFGFEId6sDawgMAb+f6n5cRgXoMzMjzgFPNQcxSKOu4LHJIUw0ebuCPJht0ePLm2juNX1WFswkxEeKMo68wwJg78z/bZVF2VAmKgFM5MiOCheO4mMI8zHEx7NrziyDQ2NJw2S/O6O3gelHVJmNygNLt403lo8ZPCGWN8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732676484; c=relaxed/simple; bh=+deIbRnmiOD4Ce5ioRKPZeERUq3WnEwjFz/9QQiA5Gs=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=igpDdOyzux4V8hBE2SEdY24cXvzzVwOXy5bA80mFIiqzh9jMloX1LqhkHKCYMX8a7JK51G60DpW11scNLnCKQsGJ3VY3YSNRnuQo3GQBxjKnRiFJxRNQawNrFAtkH1pIQWnCM4XHGvVZ9Zc/LC2Qeag3Csz+cZILGHCBE/Hqca8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=X3y4VkQL; arc=fail smtp.client-ip=40.107.249.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="X3y4VkQL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jfDrx3AB5sVYcIdeZPNW0GIt3x2F0y0LIUIFVm0qvPMukQp/0vLe5yhIFI+Zerqd3sbhRfBDRqCWAV67DnGem28dAuep2flQo98JUMkS1Y7tHKBR3iW2KJGLdiljVYnQyCMRXtDHSlRgHeO8shs6yavKa+oSy3IeRgRDTy8ta3+GhHwZ3Yyyav86tXMV4CiQet7SlhwsEThulRloVmTxfaGOJjuIAHP0ovsFKYxOJ4xgsSMBZxNqJIi8p4kj3BdcmCE+YaFFv7Tggb/eqR+sTcwQyzxga+9Y+7iowz7jgEFdwo2n0zE8RwtqUSkW7c572jOVJ3CfiTZkIX6G0uY8JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=3te39e0q+q/rVjtlUmF1UNs0TIiJR68WZXzMyKU1tFw=; b=guoG59oP3qP91t31lXGXT6m5UbFqSCvxJddaY/Jl3EqVHGyPgxN9hyOWeYKvYNrjfvRrP9Idpym9Ui19VFhzUhgdt7t9uOiAhdBwl6/0p/Efsjr2piTOoCGjDOH2ZtWilnusp2nWSYBrii8dwFicJS6jpW8DwRBpVAPrAKl3LV2gze1CVKfvDlUzJBIJ9cTJIiPRIS4CDMj3nvHSwhdu4v6Z7f7bQn4MqbiqBmIb632o2IawHzenzQZd3NrdrFdXvjm1uo8SCAEczV10HvfVUrZIuuHCGL/9h7Q/Cf8tI991ZimOy5kT83Pb6j1zjl8AvnmobcmY/0Xs094lcKb2eA== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3te39e0q+q/rVjtlUmF1UNs0TIiJR68WZXzMyKU1tFw=; b=X3y4VkQLFT6yNCpZS8pIG5iJxPk+RkCOokZIKejucdkxPpBI8JqPXqtDmuRAltbOxdERVQySumyrpVvPObKW2v9TkuyrXNMQBw2ppVdc2EAv9XqDZGflwvOorw9QxyTxR551n8NsvCm54k1NXQ+hyRvyPTjZ2ZvpZyw+Nd8H9cBc7BdLKgjM8dDv95rEyLPAOgge4/aWjbqDsm/ssOeURNaUE/900yIzFonqXxHfkLqjDl78YwHXqsWqZmGPxADd//TWhvZrTfQX7fu1/9w0tzqCXG04USrSZrJLldFvuUamN/dAV/fZ4MDRiYVIYmPMAbpwQO4CW+uwyFysKgacsw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB7044.eurprd04.prod.outlook.com (2603:10a6:208:191::20) by DBBPR04MB7771.eurprd04.prod.outlook.com (2603:10a6:10:1e6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.13; Wed, 27 Nov 2024 03:01:19 +0000 Received: from AM0PR04MB7044.eurprd04.prod.outlook.com ([fe80::7be0:296:768c:e891]) by AM0PR04MB7044.eurprd04.prod.outlook.com ([fe80::7be0:296:768c:e891%6]) with mapi id 15.20.8182.019; Wed, 27 Nov 2024 03:01:19 +0000 From: Shengjiu Wang To: shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, nicoleotsuka@gmail.com, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, linuxppc-dev@lists.ozlabs.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] ASoC: fsl_xcvr: Add suspend and resume support Date: Wed, 27 Nov 2024 11:00:35 +0800 Message-Id: <20241127030035.649219-3-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20241127030035.649219-1-shengjiu.wang@nxp.com> References: <20241127030035.649219-1-shengjiu.wang@nxp.com> X-ClientProxiedBy: SG2PR02CA0012.apcprd02.prod.outlook.com (2603:1096:3:17::24) To AM0PR04MB7044.eurprd04.prod.outlook.com (2603:10a6:208:191::20) Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB7044:EE_|DBBPR04MB7771:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c6c566a-45be-45f2-3afe-08dd0e8fc40b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|52116014|7416014|38350700014|921020; X-Microsoft-Antispam-Message-Info: rSyczTXAT303/ltJu9o8gMvyWdtAYltNSTc1AoKd2dmiQxSesHzqjWPM1rEnHRJVKTARX0HQliPlH9NCI6xy7nA+xZyybCPm0RW/cRmivsuOmkkreqD64l0K/15ONfLpPUqw4PQZAWm0azlMA1FhaMypyHaosNkHReGAAin816cR2880eRjdDgMMDmauw2UvxGtIVO7bH5GwJWSNXhMC3pn0MemZGVu8N49pZbcIknCV0WTvFES4JYR+doi+SrYEcTcr4/c2kpIqId6dk3VYpU6t5Gsnfnc9b3GAH3QEDYvCsoMzIe4MvXR7ZSu9oRNufwKHgqpHp9MD1kx9sr2z0UWfSInDqeQMFa2/8/RtnH9y5oqJxVOvcAy4Ebx0ne5v7Nj5ukCtpeGjHm1CCWKKzlx4t9jk8o6m0dcwfchnxCAGZFGzvDIzNtD72H79nKZzDDsGvv0YjCSwkRPDuPxyBfzLGie4yeVCaKRXt72jYnGl3XtdQ3eqCMqn1yc4QMnlGJBiTjft0zWdNHBWX9BeSPJcdGAYFgTFFRkD65EdzweTZ6vbHO6IC8Fz3v/MzTlUlRZudQlzAYy718oePGXrZdEsKiyK5EP94RUBaMsImTxK6vne7z0Kn6YxdG5vJzJ8XCPHgW/CUZi2Gb5vl42qTGE/wH40zG/4q+ITNoEvmez/tO9zNhR8PeFnvoSAKS6dSbrRSVX5fFuP7eFdJgJLucMdWrhg6Zk2U+QyxSeSDKIy38m8omBuVLWmVpT0RxzSwHVROqGlPcxmkw6e5zezGJLRi6a8YehQp9NGFbstLd1OrgPV0qvclMf6WkNL7WYwX1NmjhKCLH+KXcMNzvPPFL1uXcyqTpCbVVfiykOHnqYTU3im03VqeYxwQd05hm/HO+IZ8FwaOnceA3fzkzuUSCD0gUcaqVajt2Cv7JPK3zjRdKdawzVpCGZFkg5KLTFU65E0totpQA6papa57Au7Gz9R9VZRMgAWJDStnZqcHklZg37huRSJwwLq7SXHAe9UIDzHqLUdpCei1BnYYa9sjsGMNkcWd0VRtcWe5xsbaQjLk8w5RnPJ9wIiDe8q88UCWdI25TUN1wlJLgJkfmMUAFlRTO3pd43c0FoW5vhiQypR+AgH24G5JrO0R6cPMC49HGXFa6lRUz3QExo0mFYpSS8hzAU08pQrP+EiuiA2eXPbpt2nDe+FI0mi7xzKgsK42xwv6UFJTzXlSdMkd6QO/q2+DheMw73RiEtl3DM5reO1knpblURFmP8Yu18kqsvsQJlO/Rm4DgwYGAzwSKQieHfzmujV4xJbt2pQ5IYKRfbFwitYFsallBjaMGvUrfdartadONgC0FkCvJQD4CLuQuvmRpPMeFOSpe6WCGoTNHrCRGRiOPLakl1U25CH7dswSgLCwmrUbBTnmbNOafJxzRpezxjCVunogT17hqnk0ak= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB7044.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(52116014)(7416014)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Dn0/57H+1NMYL0hF6r4QP9ASTbtZOyWZqGE6U2pAWr3W6xtpKJdGsf955TRfZ/ajxn3fhcaPX+WDDt1klWy9wI7882XLWyNDmfDeKKr3mdIIirRTzafa1Gqp0VyJLYdpphYz5IpfyKIrOBp+5ym9C6+Wt4cyUujsNZcXdoR+ctLfi573TZeWc1uZ/JPetke75E7TShquxA9XGIp4KLYku2HjOLOYRo6V9KuNOJHXixIJgANeS8lNpea2Y29kAPz8TsBvO6r6G2Mw6DtyYCnmTKxkwmXX0xBrw5RrNWWswp6P6jjxg0M8/0xE5w8tW6PweuLaHvKm7e6fwmtlWxOIHSXGG7C9GZzy2ULjLV0eM8YpXaW5Oh97PGo27NibJXkCXCuhlfB5NXS14Y/gik/iNT5M48WFDxVDslLmCgoJNJ1Ga+LixwAuy/ETMJ4FViqRsG/B3yizbnaNHRoCHNFxj3Yck9gckEKKdLn+JhhvczHxu2Yjb9rmvwCZ3gZkUbxja2OqFOkJ9MARW0oafDYvnQsMeIURzdTFkeaMCbV/ehWSZMODyKKymbytfXGwCj6yqe+dmvSaYKuLcv4mx1seCunHuH+mSvGL5rAIzfILmzfrG7iMnZu+xF562Y4eb6Z8EUb61JY0A1AnGsjlhQSBJpmK8s/uQRdcTucoNnxJle9+grMOQ0yVxyX+u8QNg1uQmDzGYDYr1Qi20fUqMWXB8kP7lQSuQHe8y9oFBwppdDawOXIh4MHoVWGRLzms4ct3Z/lip0z9aNM+9uUeGKveGa5NLx03ZjkUmLarR/TNthx6GefRtS/3TGztiCFVqvpN/D/GFEYxnXePaNTtXV/w4Jo3gQyYTpbDccwqqzIb3Usd+K08doiXdftCNbefeD1GT+xOG4hGGlNuqoHurGLPe62AJ9TByporyjYlUpuIt0yjSoD6RnIwPL7DEUC7pshOkJbBjB+K9RXBsn4pIYXUOCv0RCYlLsWBDxvD9Ufy+S8TCC0J0mUT0mpOdi8srZqvgMeqBvzNHmyjxF8pr0uwOYRVhk6WV3lvT0r3Kv/iB1aniV47pLuz0wBle2hSy9ZQ2sMW7GZOEwxsBs7n83aDVf8zbmkonMQ35PbrbPCXahEtgFFupyQXbJOeJeU26Onm32lyFG71kLEaF0w57eYCm+Ce09AQ7zp1XoLzO9L6bdc9IvAD0nr0pm/TObuK70jlDxRCDWqFiBtSJ5L5hFxOjCHmT3zXDwvoxOfGiRhac4SFTozy9EIfOXXF9I87XZxu7c9Z0cpaUMkiUFX8uAgnVZLKfU5y17MlGp8CfUyWrQitW5Q5QM1NRpcfbo8+baygSyd60m5JNPTN4a5qqtbZyjbQVe5SVQqcSuDz49ESXqwjwzDScr5qAlL2mbZuyYbd5adNLZGNsKc3ipegt+FV4TGJMh/PzLTY980ih+LSVXVVw6xVhw++CDPdHUm1q0oykVKxvPLPuM86H0NdYvd24tnBymE1P5aHMytBwQey/0rELIuuoLEvOnceo6ptF8VgniJlXalt9fAc/sYj7ZfE5oEF3OYB+sbgZAt1wVJ88AvXncB6+p5K3+KbWtGPwURB X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5c6c566a-45be-45f2-3afe-08dd0e8fc40b X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB7044.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Nov 2024 03:01:19.1702 (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: zjdUTbDzBTOQGBfsrfcnv/UXlyOLRxek8S1sj2/af6wSHMS2iubvASjnyuKhXwTOZaZsEHAXruYsItRWJt+rjw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7771 Use regcache_sync() to recover the registers of controller, PHY and PLL after suspend and resume. In order to recover the registers need to avoid use the *_SET, *_CLR and *_TOG registers. Recovery of the registers should be done before loading XCVR firmware otherwise some registers set by firmware are overwritten. Besides only in eARC mode is it necessary to load XCVR firmware. Signed-off-by: Shengjiu Wang Signed-off-by: Chancel Liu --- sound/soc/fsl/fsl_xcvr.c | 160 +++++++++++++++++++++++++++++---------- 1 file changed, 118 insertions(+), 42 deletions(-) diff --git a/sound/soc/fsl/fsl_xcvr.c b/sound/soc/fsl/fsl_xcvr.c index b77953cfaa31..4524cb7ada2e 100644 --- a/sound/soc/fsl/fsl_xcvr.c +++ b/sound/soc/fsl/fsl_xcvr.c @@ -503,7 +503,7 @@ static int fsl_xcvr_prepare(struct snd_pcm_substream *substream, switch (xcvr->mode) { case FSL_XCVR_MODE_SPDIF: if (xcvr->soc_data->spdif_only && tx) { - ret = regmap_update_bits(xcvr->regmap, FSL_XCVR_TX_DPTH_CTRL_SET, + ret = regmap_update_bits(xcvr->regmap, FSL_XCVR_TX_DPTH_CTRL, FSL_XCVR_TX_DPTH_CTRL_BYPASS_FEM, FSL_XCVR_TX_DPTH_CTRL_BYPASS_FEM); if (ret < 0) { @@ -521,8 +521,8 @@ static int fsl_xcvr_prepare(struct snd_pcm_substream *substream, return ret; } - ret = regmap_write(xcvr->regmap, FSL_XCVR_TX_DPTH_CTRL_SET, - FSL_XCVR_TX_DPTH_CTRL_FRM_FMT); + ret = regmap_set_bits(xcvr->regmap, FSL_XCVR_TX_DPTH_CTRL, + FSL_XCVR_TX_DPTH_CTRL_FRM_FMT); if (ret < 0) { dev_err(dai->dev, "Failed to set TX_DPTH: %d\n", ret); return ret; @@ -539,11 +539,11 @@ static int fsl_xcvr_prepare(struct snd_pcm_substream *substream, * Clear RX FIFO, flip RX FIFO bits, * disable eARC related HW mode detects */ - ret = regmap_write(xcvr->regmap, FSL_XCVR_RX_DPTH_CTRL_SET, - FSL_XCVR_RX_DPTH_CTRL_STORE_FMT | - FSL_XCVR_RX_DPTH_CTRL_CLR_RX_FIFO | - FSL_XCVR_RX_DPTH_CTRL_COMP | - FSL_XCVR_RX_DPTH_CTRL_LAYB_CTRL); + ret = regmap_set_bits(xcvr->regmap, FSL_XCVR_RX_DPTH_CTRL, + FSL_XCVR_RX_DPTH_CTRL_STORE_FMT | + FSL_XCVR_RX_DPTH_CTRL_CLR_RX_FIFO | + FSL_XCVR_RX_DPTH_CTRL_COMP | + FSL_XCVR_RX_DPTH_CTRL_LAYB_CTRL); if (ret < 0) { dev_err(dai->dev, "Failed to set RX_DPTH: %d\n", ret); return ret; @@ -560,18 +560,18 @@ static int fsl_xcvr_prepare(struct snd_pcm_substream *substream, case FSL_XCVR_MODE_EARC: if (!tx) { /** Clear RX FIFO, flip RX FIFO bits */ - ret = regmap_write(xcvr->regmap, FSL_XCVR_RX_DPTH_CTRL_SET, - FSL_XCVR_RX_DPTH_CTRL_STORE_FMT | - FSL_XCVR_RX_DPTH_CTRL_CLR_RX_FIFO); + ret = regmap_set_bits(xcvr->regmap, FSL_XCVR_RX_DPTH_CTRL, + FSL_XCVR_RX_DPTH_CTRL_STORE_FMT | + FSL_XCVR_RX_DPTH_CTRL_CLR_RX_FIFO); if (ret < 0) { dev_err(dai->dev, "Failed to set RX_DPTH: %d\n", ret); return ret; } /** Enable eARC related HW mode detects */ - ret = regmap_write(xcvr->regmap, FSL_XCVR_RX_DPTH_CTRL_CLR, - FSL_XCVR_RX_DPTH_CTRL_COMP | - FSL_XCVR_RX_DPTH_CTRL_LAYB_CTRL); + ret = regmap_clear_bits(xcvr->regmap, FSL_XCVR_RX_DPTH_CTRL, + FSL_XCVR_RX_DPTH_CTRL_COMP | + FSL_XCVR_RX_DPTH_CTRL_LAYB_CTRL); if (ret < 0) { dev_err(dai->dev, "Failed to clr TX_DPTH: %d\n", ret); return ret; @@ -751,9 +751,9 @@ static int fsl_xcvr_trigger(struct snd_pcm_substream *substream, int cmd, } fallthrough; case FSL_XCVR_MODE_SPDIF: - ret = regmap_write(xcvr->regmap, - FSL_XCVR_TX_DPTH_CTRL_SET, - FSL_XCVR_TX_DPTH_CTRL_STRT_DATA_TX); + ret = regmap_set_bits(xcvr->regmap, + FSL_XCVR_TX_DPTH_CTRL, + FSL_XCVR_TX_DPTH_CTRL_STRT_DATA_TX); if (ret < 0) { dev_err(dai->dev, "Failed to start DATA_TX: %d\n", ret); goto release_lock; @@ -809,9 +809,9 @@ static int fsl_xcvr_trigger(struct snd_pcm_substream *substream, int cmd, if (tx) { switch (xcvr->mode) { case FSL_XCVR_MODE_SPDIF: - ret = regmap_write(xcvr->regmap, - FSL_XCVR_TX_DPTH_CTRL_CLR, - FSL_XCVR_TX_DPTH_CTRL_STRT_DATA_TX); + ret = regmap_clear_bits(xcvr->regmap, + FSL_XCVR_TX_DPTH_CTRL, + FSL_XCVR_TX_DPTH_CTRL_STRT_DATA_TX); if (ret < 0) { dev_err(dai->dev, "Failed to stop DATA_TX: %d\n", ret); goto release_lock; @@ -1224,6 +1224,7 @@ static bool fsl_xcvr_writeable_reg(struct device *dev, unsigned int reg) case FSL_XCVR_RX_DPTH_CNTR_CTRL_SET: case FSL_XCVR_RX_DPTH_CNTR_CTRL_CLR: case FSL_XCVR_RX_DPTH_CNTR_CTRL_TOG: + case FSL_XCVR_TX_DPTH_CTRL: case FSL_XCVR_TX_DPTH_CTRL_SET: case FSL_XCVR_TX_DPTH_CTRL_CLR: case FSL_XCVR_TX_DPTH_CTRL_TOG: @@ -1245,7 +1246,49 @@ static bool fsl_xcvr_writeable_reg(struct device *dev, unsigned int reg) static bool fsl_xcvr_volatile_reg(struct device *dev, unsigned int reg) { - return fsl_xcvr_readable_reg(dev, reg); + switch (reg) { + case FSL_XCVR_EXT_STATUS: + case FSL_XCVR_EXT_ISR: + case FSL_XCVR_EXT_ISR_SET: + case FSL_XCVR_EXT_ISR_CLR: + case FSL_XCVR_EXT_ISR_TOG: + case FSL_XCVR_ISR: + case FSL_XCVR_ISR_SET: + case FSL_XCVR_ISR_CLR: + case FSL_XCVR_ISR_TOG: + case FSL_XCVR_PHY_AI_CTRL: + case FSL_XCVR_PHY_AI_CTRL_SET: + case FSL_XCVR_PHY_AI_CTRL_CLR: + case FSL_XCVR_PHY_AI_CTRL_TOG: + case FSL_XCVR_PHY_AI_RDATA: + case FSL_XCVR_RX_CS_DATA_0: + case FSL_XCVR_RX_CS_DATA_1: + case FSL_XCVR_RX_CS_DATA_2: + case FSL_XCVR_RX_CS_DATA_3: + case FSL_XCVR_RX_CS_DATA_4: + case FSL_XCVR_RX_CS_DATA_5: + case FSL_XCVR_RX_DPTH_CNTR_CTRL: + case FSL_XCVR_RX_DPTH_CNTR_CTRL_SET: + case FSL_XCVR_RX_DPTH_CNTR_CTRL_CLR: + case FSL_XCVR_RX_DPTH_CNTR_CTRL_TOG: + case FSL_XCVR_RX_DPTH_TSCR: + case FSL_XCVR_RX_DPTH_BCR: + case FSL_XCVR_RX_DPTH_BCTR: + case FSL_XCVR_RX_DPTH_BCRR: + case FSL_XCVR_TX_DPTH_CNTR_CTRL: + case FSL_XCVR_TX_DPTH_CNTR_CTRL_SET: + case FSL_XCVR_TX_DPTH_CNTR_CTRL_CLR: + case FSL_XCVR_TX_DPTH_CNTR_CTRL_TOG: + case FSL_XCVR_TX_DPTH_TSCR: + case FSL_XCVR_TX_DPTH_BCR: + case FSL_XCVR_TX_DPTH_BCTR: + case FSL_XCVR_TX_DPTH_BCRR: + case FSL_XCVR_DEBUG_REG_0: + case FSL_XCVR_DEBUG_REG_1: + return true; + default: + return false; + } } static const struct regmap_config fsl_xcvr_regmap_cfg = { @@ -1586,6 +1629,10 @@ static int fsl_xcvr_probe(struct platform_device *pdev) platform_set_drvdata(pdev, xcvr); pm_runtime_enable(dev); regcache_cache_only(xcvr->regmap, true); + if (xcvr->soc_data->use_phy) { + regcache_cache_only(xcvr->regmap_phy, true); + regcache_cache_only(xcvr->regmap_pll, true); + } /* * Register platform component before registering cpu dai for there @@ -1624,7 +1671,8 @@ static int fsl_xcvr_runtime_suspend(struct device *dev) struct fsl_xcvr *xcvr = dev_get_drvdata(dev); int ret; - if (!xcvr->soc_data->spdif_only) { + if (!xcvr->soc_data->spdif_only && + xcvr->mode == FSL_XCVR_MODE_EARC) { /* Assert M0+ reset */ ret = regmap_update_bits(xcvr->regmap, FSL_XCVR_EXT_CTRL, FSL_XCVR_EXT_CTRL_CORE_RESET, @@ -1634,6 +1682,10 @@ static int fsl_xcvr_runtime_suspend(struct device *dev) } regcache_cache_only(xcvr->regmap, true); + if (xcvr->soc_data->use_phy) { + regcache_cache_only(xcvr->regmap_phy, true); + regcache_cache_only(xcvr->regmap_pll, true); + } clk_disable_unprepare(xcvr->spba_clk); clk_disable_unprepare(xcvr->phy_clk); @@ -1678,6 +1730,12 @@ static int fsl_xcvr_runtime_resume(struct device *dev) goto stop_phy_clk; } + ret = reset_control_deassert(xcvr->reset); + if (ret) { + dev_err(dev, "failed to deassert M0+ reset.\n"); + goto stop_spba_clk; + } + regcache_cache_only(xcvr->regmap, false); regcache_mark_dirty(xcvr->regmap); ret = regcache_sync(xcvr->regmap); @@ -1687,31 +1745,49 @@ static int fsl_xcvr_runtime_resume(struct device *dev) goto stop_spba_clk; } - if (xcvr->soc_data->spdif_only) - return 0; + if (xcvr->soc_data->use_phy) { + ret = regmap_write(xcvr->regmap, FSL_XCVR_PHY_AI_CTRL_SET, + FSL_XCVR_PHY_AI_CTRL_AI_RESETN); + if (ret < 0) { + dev_err(dev, "Error while release PHY reset: %d\n", ret); + goto stop_spba_clk; + } - ret = reset_control_deassert(xcvr->reset); - if (ret) { - dev_err(dev, "failed to deassert M0+ reset.\n"); - goto stop_spba_clk; - } + regcache_cache_only(xcvr->regmap_phy, false); + regcache_mark_dirty(xcvr->regmap_phy); + ret = regcache_sync(xcvr->regmap_phy); + if (ret) { + dev_err(dev, "failed to sync phy regcache.\n"); + goto stop_spba_clk; + } - ret = fsl_xcvr_load_firmware(xcvr); - if (ret) { - dev_err(dev, "failed to load firmware.\n"); - goto stop_spba_clk; + regcache_cache_only(xcvr->regmap_pll, false); + regcache_mark_dirty(xcvr->regmap_pll); + ret = regcache_sync(xcvr->regmap_pll); + if (ret) { + dev_err(dev, "failed to sync pll regcache.\n"); + goto stop_spba_clk; + } } - /* Release M0+ reset */ - ret = regmap_update_bits(xcvr->regmap, FSL_XCVR_EXT_CTRL, - FSL_XCVR_EXT_CTRL_CORE_RESET, 0); - if (ret < 0) { - dev_err(dev, "M0+ core release failed: %d\n", ret); - goto stop_spba_clk; - } + if (xcvr->mode == FSL_XCVR_MODE_EARC) { + ret = fsl_xcvr_load_firmware(xcvr); + if (ret) { + dev_err(dev, "failed to load firmware.\n"); + goto stop_spba_clk; + } - /* Let M0+ core complete firmware initialization */ - msleep(50); + /* Release M0+ reset */ + ret = regmap_update_bits(xcvr->regmap, FSL_XCVR_EXT_CTRL, + FSL_XCVR_EXT_CTRL_CORE_RESET, 0); + if (ret < 0) { + dev_err(dev, "M0+ core release failed: %d\n", ret); + goto stop_spba_clk; + } + + /* Let M0+ core complete firmware initialization */ + msleep(50); + } return 0;