From patchwork Sun Aug 23 13:54:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shengjiu Wang X-Patchwork-Id: 248147 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:522:0:0:0:0 with SMTP id h2csp1850622ils; Sun, 23 Aug 2020 07:00:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFbAP36xUUKNnmsMghYgpt16ndzwP4Cd271kXkLsD/oMCDvD7fgsf/zT7uNadbZh+X+E7F X-Received: by 2002:a50:aadd:: with SMTP id r29mr1421273edc.219.1598191233977; Sun, 23 Aug 2020 07:00:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598191233; cv=none; d=google.com; s=arc-20160816; b=twB3MX1btTFilXUM1z92G7U6TjFtK209NoAcASm5vE02ejNoeMIQ2vKn39N6xgOZjW +VgUYplGit94rKlHYF/qnIH8ur5I0VdFDTEIO3nBlsBUxB+1t+wqMWLPN0ejtfitwfRP TrgiNr2SWp3SR/k4/7LVfD8+rO6bdx4MCx7rpStUFjs2LT5JkpXM1L+fbGdbColYS3FY E37QzqPR21KSF6J6ZxJ5XUsIP9nsgg5bhHKM9fLKF46PIFRbm+5LaXSBFgKzYbtN4VLh H2DEeurdGw0e64Lklk/H5XlvXvIjxfNiWrpSW92d+pIxrLDvtnCF7h7Zxd+v/4U7klJ8 5UAA== 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=HVA6s0G5U9B53vBFX/tFhg77MTlGjI/0ajqWB0oVy5A=; b=KFVFLed6kAE08EYL2350gpIllNHcv6eOs7QMFtph+xdMn3nngprBndVDzWkCEpy/U+ dW7rwlKQJqYH8liVYxKr2AhYfNbDnTUebeS5CItm5LWqvWmoa/AM9XjCaQawFPi6eW5R iQ3eHy7m2FCU7uiZGHGVYbcABLP93eR2Wxk+4FyAY4Jz8EPsfzDyNXs7c6aJBBRhzj1n pGLT4Ada3Fucmq7dPfQzcTVVltRlY900QLHCgjXDO3ohhREzAGscu01nyCgRcaV2uur+ N+nxt/M/5O45r7vkL4HrsLdv506qzu140zE4dLYoq9OHFiyg+1XOj2TS8E4z55pS7FA1 xORw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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 lo6si4826725ejb.584.2020.08.23.07.00.33; Sun, 23 Aug 2020 07:00:33 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-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 devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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 S1726086AbgHWOAR (ORCPT + 6 others); Sun, 23 Aug 2020 10:00:17 -0400 Received: from inva020.nxp.com ([92.121.34.13]:44900 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726345AbgHWOAQ (ORCPT ); Sun, 23 Aug 2020 10:00:16 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 734AF1A0924; Sun, 23 Aug 2020 16:00:14 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 14F221A0804; Sun, 23 Aug 2020 16:00:11 +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 E3011402E2; Sun, 23 Aug 2020 16:00:06 +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: ak5558: Add regulator support Date: Sun, 23 Aug 2020 21:54:37 +0800 Message-Id: <1598190877-9213-2-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1598190877-9213-1-git-send-email-shengjiu.wang@nxp.com> References: <1598190877-9213-1-git-send-email-shengjiu.wang@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@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/ak5558.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) -- 2.27.0 diff --git a/sound/soc/codecs/ak5558.c b/sound/soc/codecs/ak5558.c index 8179512129d3..2f076d5ee284 100644 --- a/sound/soc/codecs/ak5558.c +++ b/sound/soc/codecs/ak5558.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -22,8 +23,15 @@ #include "ak5558.h" +#define AK5558_NUM_SUPPLIES 2 +static const char *ak5558_supply_names[AK5558_NUM_SUPPLIES] = { + "DVDD", + "AVDD", +}; + /* AK5558 Codec Private Data */ struct ak5558_priv { + struct regulator_bulk_data supplies[AK5558_NUM_SUPPLIES]; struct snd_soc_component component; struct regmap *regmap; struct i2c_client *i2c; @@ -299,12 +307,22 @@ static int __maybe_unused ak5558_runtime_suspend(struct device *dev) regcache_cache_only(ak5558->regmap, true); ak5558_power_off(ak5558); + regulator_bulk_disable(ARRAY_SIZE(ak5558->supplies), + ak5558->supplies); return 0; } static int __maybe_unused ak5558_runtime_resume(struct device *dev) { struct ak5558_priv *ak5558 = dev_get_drvdata(dev); + int ret; + + ret = regulator_bulk_enable(ARRAY_SIZE(ak5558->supplies), + ak5558->supplies); + if (ret != 0) { + dev_err(dev, "Failed to enable supplies: %d\n", ret); + return ret; + } ak5558_power_off(ak5558); ak5558_power_on(ak5558); @@ -350,6 +368,7 @@ static int ak5558_i2c_probe(struct i2c_client *i2c) { struct ak5558_priv *ak5558; int ret = 0; + int i; ak5558 = devm_kzalloc(&i2c->dev, sizeof(*ak5558), GFP_KERNEL); if (!ak5558) @@ -367,6 +386,16 @@ static int ak5558_i2c_probe(struct i2c_client *i2c) if (IS_ERR(ak5558->reset_gpiod)) return PTR_ERR(ak5558->reset_gpiod); + for (i = 0; i < ARRAY_SIZE(ak5558->supplies); i++) + ak5558->supplies[i].supply = ak5558_supply_names[i]; + + ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(ak5558->supplies), + ak5558->supplies); + if (ret != 0) { + dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); + return ret; + } + ret = devm_snd_soc_register_component(&i2c->dev, &soc_codec_dev_ak5558, &ak5558_dai, 1); @@ -374,6 +403,7 @@ static int ak5558_i2c_probe(struct i2c_client *i2c) return ret; pm_runtime_enable(&i2c->dev); + regcache_cache_only(ak5558->regmap, true); return 0; }