Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp158812yba; Wed, 3 Apr 2019 06:27:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzo4N3wGSSxIzCE5cThkhj9BCPITEtnXa9JL68JIAKC7/ybS8gg5iFRXYkr7Ov9lHNl/YvP X-Received: by 2002:a63:330e:: with SMTP id z14mr24730366pgz.4.1554298035918; Wed, 03 Apr 2019 06:27:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554298035; cv=none; d=google.com; s=arc-20160816; b=pOvokApcvOlft8fMphI4J4aoyLNe/fKu5vG/Shhbf3naSwbO5EE5ETF6Upd0AjrsxT du0xXSeSp+hN0iBjPFVfU6mhLhMAEqsxaD3+4BYMDYwgsaiZA72pB5z4ZQnhDfSlXikT HO37kp4LbZVxSMFAvrVapxbQWBi6c+odmh+5MFAYpEJFsQbeJ5PP+8dTxohprNLKi+8G psbAtmH7za0vO9hmMLZ4DXnnUnQvUfzjr9l21X+2fOGWNYr7aiz186+ylpTGbqtC4Wud NFF0KNvMTAKchnpAaCYZCTdd0OwvLTaB+gtIEPVcGP0P/3MxtfLLUq79yZpIs4xhipbU q8JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:to:from; bh=q8ghKEU0CGWvOBl4o2IRP6fkk9cJK2+Zr7VEzo2Ee5I=; b=soWxZ2x8ffznGAOeEJn0UcFY90mSGpzMFdFubTgqSZhfAM2lY6oNG4mN/y7zClcUtd nIox9n8CK1TVvBggzcR8kUnJX8riCK/gTRjPuZFO/+BhlfIbBxRzGImOhtYdqTUTc1cT QsvaF4JVfZE+e4+fd3ciXmABg9Fmo8lIjqEZTOUKJ1q59Dnl+NDYofdEafKKvy7pEQkc Ju4FOEhAoWepFfgVoFe5cB0WetBy3LVhyll5/Xr1WMzk7I+RjZAbU6mR+91GDe/80Cv9 Bisu+JFp7vYqXhL1xfYe0T0IxKT3PolZ92EbFqMGbdMRrtZKiKDGy3pNFSsmADpG43JH pp8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g14si5169502plo.287.2019.04.03.06.26.59; Wed, 03 Apr 2019 06:27:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726705AbfDCN0J (ORCPT + 99 others); Wed, 3 Apr 2019 09:26:09 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:56034 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726396AbfDCN0G (ORCPT ); Wed, 3 Apr 2019 09:26:06 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x33DL2Un012281; Wed, 3 Apr 2019 15:23:44 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2rmgmx44j1-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 03 Apr 2019 15:23:44 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id BE67631; Wed, 3 Apr 2019 13:23:43 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas23.st.com [10.75.90.46]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 9F19129C0; Wed, 3 Apr 2019 13:23:43 +0000 (GMT) Received: from SAFEX1HUBCAS24.st.com (10.75.90.95) by SAFEX1HUBCAS23.st.com (10.75.90.46) with Microsoft SMTP Server (TLS) id 14.3.435.0; Wed, 3 Apr 2019 15:23:43 +0200 Received: from localhost (10.201.23.16) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.435.0; Wed, 3 Apr 2019 15:23:43 +0200 From: Olivier Moysan To: , , , , , , , , , , , , , , , , Subject: [PATCH 2/7] ASoC: cs42l51: add regulator management Date: Wed, 3 Apr 2019 15:23:32 +0200 Message-ID: <1554297817-14154-3-git-send-email-olivier.moysan@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554297817-14154-1-git-send-email-olivier.moysan@st.com> References: <1554297817-14154-1-git-send-email-olivier.moysan@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.201.23.16] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-04-03_08:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add cs42l51 audio codec power supply management through regulator framework. Signed-off-by: Olivier Moysan --- sound/soc/codecs/cs42l51-i2c.c | 6 ++++++ sound/soc/codecs/cs42l51.c | 44 +++++++++++++++++++++++++++++++++++++++++- sound/soc/codecs/cs42l51.h | 1 + 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/cs42l51-i2c.c b/sound/soc/codecs/cs42l51-i2c.c index 4b5731a41876..8333dbf18ea2 100644 --- a/sound/soc/codecs/cs42l51-i2c.c +++ b/sound/soc/codecs/cs42l51-i2c.c @@ -35,12 +35,18 @@ static int cs42l51_i2c_probe(struct i2c_client *i2c, return cs42l51_probe(&i2c->dev, devm_regmap_init_i2c(i2c, &config)); } +static int cs42l51_i2c_remove(struct i2c_client *i2c) +{ + return cs42l51_remove(&i2c->dev); +} + static struct i2c_driver cs42l51_i2c_driver = { .driver = { .name = "cs42l51", .of_match_table = cs42l51_of_match, }, .probe = cs42l51_i2c_probe, + .remove = cs42l51_i2c_remove, .id_table = cs42l51_i2c_id, }; diff --git a/sound/soc/codecs/cs42l51.c b/sound/soc/codecs/cs42l51.c index 80da3cd73e04..f43eb51d2d8d 100644 --- a/sound/soc/codecs/cs42l51.c +++ b/sound/soc/codecs/cs42l51.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "cs42l51.h" @@ -40,11 +41,19 @@ enum master_slave_mode { MODE_MASTER, }; +static const char * const cs42l51_supply_names[] = { + "VL", + "VD", + "VA", + "VAHP", +}; + struct cs42l51_private { unsigned int mclk; struct clk *mclk_handle; unsigned int audio_mode; /* The mode (I2S or left-justified) */ enum master_slave_mode func; + struct regulator_bulk_data supplies[ARRAY_SIZE(cs42l51_supply_names)]; }; #define CS42L51_FORMATS ( \ @@ -550,7 +559,7 @@ int cs42l51_probe(struct device *dev, struct regmap *regmap) { struct cs42l51_private *cs42l51; unsigned int val; - int ret; + int ret, i; if (IS_ERR(regmap)) return PTR_ERR(regmap); @@ -569,6 +578,23 @@ int cs42l51_probe(struct device *dev, struct regmap *regmap) cs42l51->mclk_handle = NULL; } + for (i = 0; i < ARRAY_SIZE(cs42l51->supplies); i++) + cs42l51->supplies[i].supply = cs42l51_supply_names[i]; + + ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(cs42l51->supplies), + cs42l51->supplies); + if (ret != 0) { + dev_err(dev, "Failed to request supplies: %d\n", ret); + return ret; + } + + ret = regulator_bulk_enable(ARRAY_SIZE(cs42l51->supplies), + cs42l51->supplies); + if (ret != 0) { + dev_err(dev, "Failed to enable supplies: %d\n", ret); + return ret; + } + /* Verify that we have a CS42L51 */ ret = regmap_read(regmap, CS42L51_CHIP_REV_ID, &val); if (ret < 0) { @@ -587,11 +613,27 @@ int cs42l51_probe(struct device *dev, struct regmap *regmap) ret = devm_snd_soc_register_component(dev, &soc_component_device_cs42l51, &cs42l51_dai, 1); + if (ret < 0) + goto error; + + return 0; + error: + regulator_bulk_disable(ARRAY_SIZE(cs42l51->supplies), + cs42l51->supplies); return ret; } EXPORT_SYMBOL_GPL(cs42l51_probe); +int cs42l51_remove(struct device *dev) +{ + struct cs42l51_private *cs42l51 = dev_get_drvdata(dev); + + return regulator_bulk_disable(ARRAY_SIZE(cs42l51->supplies), + cs42l51->supplies); +} +EXPORT_SYMBOL_GPL(cs42l51_remove); + const struct of_device_id cs42l51_of_match[] = { { .compatible = "cirrus,cs42l51", }, { } diff --git a/sound/soc/codecs/cs42l51.h b/sound/soc/codecs/cs42l51.h index 0ca805492ac4..aef0ede82c7b 100644 --- a/sound/soc/codecs/cs42l51.h +++ b/sound/soc/codecs/cs42l51.h @@ -22,6 +22,7 @@ struct device; extern const struct regmap_config cs42l51_regmap; int cs42l51_probe(struct device *dev, struct regmap *regmap); +int cs42l51_remove(struct device *dev); extern const struct of_device_id cs42l51_of_match[]; #define CS42L51_CHIP_ID 0x1B -- 2.7.4