Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp245962pxa; Fri, 14 Aug 2020 03:05:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyATvwDz3iqnr5+nOUuQA1LAkNElHUwOl2R1/6Cfm7pkvl3IhGM6UiuTsT6kPAXK1aAh/fn X-Received: by 2002:aa7:d84d:: with SMTP id f13mr1406834eds.155.1597399532296; Fri, 14 Aug 2020 03:05:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597399532; cv=none; d=google.com; s=arc-20160816; b=cS9L6cn2v4fYu95OkyXVLJaPzn2qmVEGxLIQSZuM90UvsER3VL1DnWAZl7UKxXo1wJ 8FJUG3LzXxN6TrXoYfv1anA3JAmP3wNRk1YvHlTfyRXaUMhEL/cyt9PljlKA/dxk0Du0 jEhzJ55Lgdq/kSvhO2gGCZHtGmp+BlgJfUXffc0h9tQ5RnTvsec7YtmSUFIyRvUpqAWB UnuiTuPiHzQw3s4ny7CwLA7+UfVZVk9+zBMn+N2KPeBSCk3pk38rz0bUmNvRPcDSDdS4 aCDPIbhLew7tEHC3r801+VlkeZimpGkRrlxzZvKWaxrpQvNYXe0xouycPIluTB5as2LD U9IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from; bh=+xES0nQpi1A93MwQdkTxB+blFf9OsPOzSBJM5xEec2U=; b=hqkLAzSCT9yPmlkxEPVmvt28TqcTdHte/AL+IwR22GzU9xsW9VKK/jUbZA9om/m9oj k/Mk2GS/7BnVJQ/YkaZArEPuBzRBxp7G3PIwR3pB7XksAfeWBRt/CvEKqCPMvKjxtVYw g462B/BZmOLZ/LPvu0joSSlaMnc3vMLnsQoF/hntvUeoa/3aFujFpKHK73QqSPDE2Qfs x9Sc7/yhy0h1pqyOZMjZbiquiPnWN/Zi0NDhISD9oiQfi5cdKstRuIYozUQIGXz5pphk XUM7woYF0DwgGoKQ55mKnGZoByre2NpkzOyI/os0JKCV7fwie6Q9LZq2szc+9AQeGAlj ADiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b16si4858416eju.452.2020.08.14.03.05.09; Fri, 14 Aug 2020 03:05:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726754AbgHNJiF (ORCPT + 99 others); Fri, 14 Aug 2020 05:38:05 -0400 Received: from inva021.nxp.com ([92.121.34.21]:56394 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726227AbgHNJiF (ORCPT ); Fri, 14 Aug 2020 05:38:05 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 10F5D2011EB; Fri, 14 Aug 2020 11:38:03 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id A7DAF2000BB; Fri, 14 Aug 2020 11:37:59 +0200 (CEST) Received: from 10.192.242.69 (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 2E206402C9; Fri, 14 Aug 2020 11:37:55 +0200 (CEST) From: Shengjiu Wang To: lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, devicetree@vger.kernel.org Subject: [PATCH 2/2] ASoC: ak4458: Add regulator support Date: Fri, 14 Aug 2020 17:32:41 +0800 Message-Id: <1597397561-2426-2-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1597397561-2426-1-git-send-email-shengjiu.wang@nxp.com> References: <1597397561-2426-1-git-send-email-shengjiu.wang@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "AVDD" is for analog power supply, "DVDD" is for digital power supply, they can improve the power management. As the regulator is enabled in pm runtime resume, which is behind the component driver probe, so accessing registers in component driver probe will fail. Fix this issue by enabling regcache_cache_only after pm_runtime_enable. Signed-off-by: Shengjiu Wang --- sound/soc/codecs/ak4458.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/ak4458.c b/sound/soc/codecs/ak4458.c index cbe3c782e0ca..763e6839428f 100644 --- a/sound/soc/codecs/ak4458.c +++ b/sound/soc/codecs/ak4458.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -21,6 +22,12 @@ #include "ak4458.h" +#define AK4458_NUM_SUPPLIES 2 +static const char *ak4458_supply_names[AK4458_NUM_SUPPLIES] = { + "DVDD", + "AVDD", +}; + struct ak4458_drvdata { struct snd_soc_dai_driver *dai_drv; const struct snd_soc_component_driver *comp_drv; @@ -28,6 +35,7 @@ struct ak4458_drvdata { /* AK4458 Codec Private Data */ struct ak4458_priv { + struct regulator_bulk_data supplies[AK4458_NUM_SUPPLIES]; struct device *dev; struct regmap *regmap; struct gpio_desc *reset_gpiod; @@ -587,12 +595,22 @@ static int __maybe_unused ak4458_runtime_suspend(struct device *dev) if (ak4458->mute_gpiod) gpiod_set_value_cansleep(ak4458->mute_gpiod, 0); + regulator_bulk_disable(ARRAY_SIZE(ak4458->supplies), + ak4458->supplies); return 0; } static int __maybe_unused ak4458_runtime_resume(struct device *dev) { struct ak4458_priv *ak4458 = dev_get_drvdata(dev); + int ret; + + ret = regulator_bulk_enable(ARRAY_SIZE(ak4458->supplies), + ak4458->supplies); + if (ret != 0) { + dev_err(ak4458->dev, "Failed to enable supplies: %d\n", ret); + return ret; + } if (ak4458->mute_gpiod) gpiod_set_value_cansleep(ak4458->mute_gpiod, 1); @@ -667,7 +685,7 @@ static int ak4458_i2c_probe(struct i2c_client *i2c) { struct ak4458_priv *ak4458; const struct ak4458_drvdata *drvdata; - int ret; + int ret, i; ak4458 = devm_kzalloc(&i2c->dev, sizeof(*ak4458), GFP_KERNEL); if (!ak4458) @@ -692,6 +710,16 @@ static int ak4458_i2c_probe(struct i2c_client *i2c) if (IS_ERR(ak4458->mute_gpiod)) return PTR_ERR(ak4458->mute_gpiod); + for (i = 0; i < ARRAY_SIZE(ak4458->supplies); i++) + ak4458->supplies[i].supply = ak4458_supply_names[i]; + + ret = devm_regulator_bulk_get(ak4458->dev, ARRAY_SIZE(ak4458->supplies), + ak4458->supplies); + if (ret != 0) { + dev_err(ak4458->dev, "Failed to request supplies: %d\n", ret); + return ret; + } + ret = devm_snd_soc_register_component(ak4458->dev, drvdata->comp_drv, drvdata->dai_drv, 1); if (ret < 0) { @@ -700,6 +728,7 @@ static int ak4458_i2c_probe(struct i2c_client *i2c) } pm_runtime_enable(&i2c->dev); + regcache_cache_only(ak4458->regmap, true); return 0; } -- 2.27.0