From patchwork Fri Mar 28 11:39:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 877047 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2040.outbound.protection.outlook.com [40.107.249.40]) (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 CE70F1DD877; Fri, 28 Mar 2025 11:40:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743162042; cv=fail; b=bU6/WErWVY6P1RiZRpFlQhRcdL8d8yvluRsy/Qd8Vgn3+hfM+MaHD6KIakA9tX5g+dShH475s1gAkhBHN/DyRGp06E+i63+6aEAkPd7GR/yK9MSb5SUE2Tnap0S9cfK7kwaZhm15hjSqGE8TIfXGOv3NDP5y8AvJuP4pS3HlVj8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743162042; c=relaxed/simple; bh=QBTaNTSR5fdksQoHs8jxjS0nVkjxwBueO5HFtKS8TBc=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=WfwrOe8MpRmQCkHv/ljeBVYelifwlFXrd5xVywgN0sg6RRRaKqyqMTEpVygdq5L8QtcunhblOrFEGzlwFTyfFpT5o5WsWY1uWJJ1CIZvexPIDe9hSQrs0AHXcbS0olmbzhCS48OJgneDCPrH7qQ47GfmbnmD9jkQCihUvyfZHcA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=dhD4z5vE; arc=fail smtp.client-ip=40.107.249.40 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="dhD4z5vE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=V+5Z41UDPFILtR7vZAPu7USk7Alh5+9vGD2pDhLbNoTidcrhyQS3AygoYm2tjixBbTy3aZuBLxZtcNEe39Orvo6UPobuJLSYbagK0KzbKfL5SW2DZe2XjxRvM30v6lM/59cB59IN8yK7xOQ0Vn2fB5MrRJ0UPxubAnLFPfa+397d9frKyVIxW+/zTs+OHVmC9Jf72uRDWFrEdApvXGs9zcbr9wlSz31qN9vWDTi/JauRXEJXjHhyT680NCjAiMsRh1Re1ldmnUwJ1OpYk05UNDUAXBOu9rcklEhriXuUsWiCsv0CukGRLLZA7MOKCPqaG4UKKE3Q1iQkVpnjhnqCrw== 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=4Lbrzz8Z2Lq1wpDWvANeQ1CdSxKd5Cnj/jYBHGg3bls=; b=dbKZyoMp1nayAO9ZEtBBhp6CwAQCy9I1Voed6sNqeW1CW3tpDwEUCgAMF4cyZwRoSS2Jsx9+0rTKavrpM6PIEFhDk7FuwzpV3G7Y/jZYbfw1EpRKfL9Zvg9nZKUywlOdVxYnflb8nmdkhVILf7GTqnWuyRFElVyDirRqsq8C5iISP1ND7lKgU2KKxJ9NuAMgytemHSoCPijRUJX7p2+WZZEje5Ltnn3AFgE4EGuWuQFdelVhGwrmlGszZ4S1AG3IT1ZCi+bHJwDd224PEieBRirLsXovowOR+TnbxTgd/7R5bJAvmL+U0WJ3veNPgfz05yrUxD+gO6CFk7HcEIcCZw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4Lbrzz8Z2Lq1wpDWvANeQ1CdSxKd5Cnj/jYBHGg3bls=; b=dhD4z5vEo6bJ9sxseuYA5C5LXYZ6bwQcoAqXu9biWkgVR8Ww5C7j5HXZ0BWks142i+XYDuuk0QXvnDiR/BLi+4pbT2THmWvfW3KJBg+Opb4SSKnXEAzOtcqjRvXzI9MnOr76AeWXHSPfjOjPGN/1j2594ruA5WmjfDV5ei7dGFF9MYVT5/8+PZ+WTmCtQCQSF5WDzZRm9KNAX1tT2zSBCCClrJhY7kO8bZP3EEChNEd01qKmpsYVfW+SAWnObRNB8cSsDvdc8DmzFzAYmvZRb5yt112J5hv0IStWO+3BoisT4/B2ZoyrG8+11HYRRtKhEMT9wwhAINQE+IqCb+r+pw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) by PA1PR04MB10264.eurprd04.prod.outlook.com (2603:10a6:102:456::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.47; Fri, 28 Mar 2025 11:40:35 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%5]) with mapi id 15.20.8534.040; Fri, 28 Mar 2025 11:40:34 +0000 From: "Peng Fan (OSS)" To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Linus Walleij , Bartosz Golaszewski , Peng Fan , linux-sound@vger.kernel.org (open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM...), linux-kernel@vger.kernel.org (open list), linux-gpio@vger.kernel.org (open list:GPIO SUBSYSTEM:Keyword:(devm_)?gpio_(request|free|direction|get|set)) Cc: andriy.shevchenko@intel.com, krzk@kernel.org Subject: [PATCH] ASoC: codec: ak5386: Convert to GPIO descriptors Date: Fri, 28 Mar 2025 19:39:17 +0800 Message-Id: <20250328113918.1981069-1-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.37.1 X-ClientProxiedBy: SI1PR02CA0002.apcprd02.prod.outlook.com (2603:1096:4:1f7::16) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|PA1PR04MB10264:EE_ X-MS-Office365-Filtering-Correlation-Id: cc73532b-1ca6-4567-6952-08dd6ded5a26 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|1800799024|52116014|7416014|376014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?38K+oqk3XokwdBOt/7SG/V51Cd1bwsB?= =?utf-8?q?oodorAuzUA6gtFndgt1T17jlPlrATAFMhB/Ykn+ISOZ50oE0jNHGyi9qcAm5cCLkb?= =?utf-8?q?NiAA3Xv9ltEweKQwvq8aT0naCq2W/z3yQ9cwl9XTG0v+y2WHnAJXxoav0ybrAlWFZ?= =?utf-8?q?L0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ilqPKHe92Dzn8N0xmxz8qrpLDHFssV4njiEGFuIumPQTjyniG5Yfm1A3aU?= =?utf-8?q?KjR91Z0pvlg4k7TQKsHxsXpnovmraoztoTkkY8cqu4cKrXdKXLSUHqYb9IKY2uAf6?= =?utf-8?q?zJq+XP5EXCkqRHDQ95+sH4IKUmYqGrlvtwKrflNa7WUW6tkBiuPJMGEnRIDlYg6Le?= =?utf-8?q?a1NxfRm+1DBicQonUgiHfy/Iice31iaRDcXTp9xZaoFXj38qeCn6g8arQIy98E8N+?= =?utf-8?q?NV2uGdoHtBpEdaGp3wD+yY6JeoI68Jj4jjArD03TnlooZ8FPNoBnHBEVH3bWoubR+?= =?utf-8?q?j2yTXOJELhCZa1H6KlF0ATRw84Fci7Ov8G+K7MpIJg95EfwnPnLaokqmebW7AeAUQ?= =?utf-8?q?Dlim5Nj8gFZ1AZTItqI1vUt+mDalYmiAQ=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8459.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(52116014)(7416014)(376014)(921020)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?2D7bNkPRO01Ikxz9GGX5yItb8ojl?= =?utf-8?q?xDVY6nIa+xTRdcJ3zqlTzX66nxXAQGzzwVNsnpJLj6ow6JC3pkkYR3XJgQo0Hn1i8?= =?utf-8?q?SlJ8h+swvRHH3do25v7LDJvDKR94ZrRZqNlwg83SZea2oTAI7nRbFaruR+b6LRa7F?= =?utf-8?q?7KHwxDZTRhb1qqHk+m+hvKA3lmhPntWjibK4Jb79gM4JmWDw5QS/ETECiHjwKLB1p?= =?utf-8?q?iF6s4ZvS+v7xF8ErcWN7VJhmVmbkgIGwE6Nbm7HpF0h/26JO/zDG2TdDi8kg96xs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neJVHdY5W?= =?utf-8?q?NnqPcR4RZ4GwiKiBOIBxnfa+x1+eDm/4RGvzPRrQQM9/3GdBCKLPIlLBlfdOGGdbp?= =?utf-8?q?4aPqAOGxzM4HGzqMjaf6NfthsRxKvKSoJ3SXRmIYJFOUV7jPrKSa46lLJisAgO87c?= =?utf-8?q?9zmnAUx6O7spP18D+Ql/hZhUgsWfi2FsMLI+Z1Al4O0ACNrc/keOu1USi4BwlnsC3?= =?utf-8?q?iNJ8Y6A5zneqV4Z2ng658LJWdcfL48HDzPvtqGx2+TrRspjnX+8w5lK2HdQPmjbpu?= =?utf-8?q?0h2UrDYysEFmhLn/jaifCS7A4xmuN34SzgJUMi6FWJH46BIk47IrG7Hgbe4lIBtt8?= =?utf-8?q?MxZyj9v20gbcpIfEOJCoAx8II4Ue6BUFArbolNLsmc1iCtXu1aKozzBOgw73F3DDL?= =?utf-8?q?bxTn3LWMjwSn?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc73532b-1ca6-4567-6952-08dd6ded5a26 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Mar 2025 11:40:34.7487 (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: WMOYy7RR+8mYi894FhApsKbQOzSbUh/X0PLQLUR3jm6vhm92n7IxSSTkxnELI73PFAIaF32UVOJeU8/Ayxdz8Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB10264 From: Peng Fan of_gpio.h is deprecated, update the driver to use GPIO descriptors. - Use dev_gpiod_get_optional to get GPIO descriptor. - Use gpiod_set_value to configure output value. With legacy of_gpio API, the driver set gpio value 1 to power up AK5386, and set value 0 to power down. Per datasheet for PDN(reset_gpio in the driver): Power Down & Reset Mode Pin “H”: Power up, “L”: Power down & Reset The AK5386 must be reset once upon power-up. There is no in-tree DTS using this codec, and the dt-bindings not specify polarity. Per driver and datasheet, the gpio polarity should be active-high which is to power up the codec. So using GPIOD_OUT_LOW when get the GPIO descriptor matches GPIOF_OUT_INIT_LOW when using of_gpio API. Signed-off-by: Peng Fan --- V1: The Documentation/devicetree/bindings/sound/ak5386.txt not specify polarity(this seems bug), so per code and datasheet, I think it should be active-high. I could add a quirk in gpiolib-of to force active-high or acitive-low if you think needed. sound/soc/codecs/ak5386.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/sound/soc/codecs/ak5386.c b/sound/soc/codecs/ak5386.c index 21a44476f48d..ff635141b37f 100644 --- a/sound/soc/codecs/ak5386.c +++ b/sound/soc/codecs/ak5386.c @@ -6,11 +6,10 @@ * (c) 2013 Daniel Mack */ +#include #include -#include -#include -#include #include +#include #include #include #include @@ -20,7 +19,7 @@ static const char * const supply_names[] = { }; struct ak5386_priv { - int reset_gpio; + struct gpio_desc *reset_gpio; struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)]; }; @@ -110,8 +109,8 @@ static int ak5386_hw_params(struct snd_pcm_substream *substream, * the AK5386 in power-down mode (PDN pin = “L”). */ - if (gpio_is_valid(priv->reset_gpio)) - gpio_set_value(priv->reset_gpio, 1); + if (priv->reset_gpio) + gpiod_set_value(priv->reset_gpio, 1); return 0; } @@ -122,8 +121,8 @@ static int ak5386_hw_free(struct snd_pcm_substream *substream, struct snd_soc_component *component = dai->component; struct ak5386_priv *priv = snd_soc_component_get_drvdata(component); - if (gpio_is_valid(priv->reset_gpio)) - gpio_set_value(priv->reset_gpio, 0); + if (priv->reset_gpio) + gpiod_set_value(priv->reset_gpio, 0); return 0; } @@ -177,14 +176,12 @@ static int ak5386_probe(struct platform_device *pdev) if (ret < 0) return ret; - priv->reset_gpio = of_get_named_gpio(dev->of_node, - "reset-gpio", 0); + priv->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); + if (IS_ERR(priv->reset_gpio)) + return dev_err_probe(dev, PTR_ERR(priv->reset_gpio), + "Failed to get AK5386 reset GPIO\n"); - if (gpio_is_valid(priv->reset_gpio)) - if (devm_gpio_request_one(dev, priv->reset_gpio, - GPIOF_OUT_INIT_LOW, - "AK5386 Reset")) - priv->reset_gpio = -EINVAL; + gpiod_set_consumer_name(priv->reset_gpio, "AK5386 Reset"); return devm_snd_soc_register_component(dev, &soc_component_ak5386, &ak5386_dai, 1);