From patchwork Thu Nov 15 19:45:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 151252 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp7416777ljp; Thu, 15 Nov 2018 11:45:54 -0800 (PST) X-Google-Smtp-Source: AJdET5eyfiyuKsqM4ZEDUxv8+ClI1S0TaxdHPb8vcxCKNRXIZuBhzobN6L+xxmZbWUWSFyIEMg9D X-Received: by 2002:a1c:a6d7:: with SMTP id p206mr2346034wme.143.1542311154283; Thu, 15 Nov 2018 11:45:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542311154; cv=none; d=google.com; s=arc-20160816; b=VjQRBGo6XhokFMqHjWi0AQCCVNkNoiLLO7B1HuhCVaw/9yqXVm3g5kJflZEKgxC37/ rGcAfIiM8cORVMnfSVvV8iBKD9RTPbTLmzlyBrUdYmRkOFAIDC3a7DHV+7Kpu9x23hEb fy2RSslbxJrfOO0eAOUgEHsnpm38PRTm1nQ2dUGp1GT2idTu6daPky8MSjQEGse+hpqv vZqopIKTMF2vVjFz2hv4ax8l74RFDmmeCfU5Z8iMnaAtAz6tbgND7el02dYsh7l4Pk3S r4SqmTib9W5AnSNB23GJ7+YybYEKR0kIAuRBTnSVKK+cXhg0HvOMp2iYxpeLFmQ2y9Ti LemA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:date:message-id:in-reply-to:to:from :dkim-signature:delivered-to; bh=d4zKjOBZcFRYKBpWP1PTfpu+Ls9MJGX/agxs7XSrINo=; b=KjSuJaSA8GlvJ+fuC+AOBkDwqixKKYt55JD7P2O8WgB8WtB7+SYTQ4w+WNTXmWEFqh bPD3L07kjXIVm/4auF3besRXfM4caDmwc8YVQir6bSAludVrxv/coV+m416wCNP77eV1 z9iG6++mqngVs5wgGaFQ7FxD0B8pkrsbAZiHhHG+dlfd+a1h9YdGRl7dHCA6QbH1+sYB dMoHsk+ETIsaP+4Zd0isnugkp/J/FmaHHL1cMighE2aLpgGSOLsc7vTTuyc2JoCTee0J 5pZyHPXC1yiI4wWEDBJ+I2Go4jfndGwXCLmMWz0sXFQYGq4t1vlOi8619BQ/upKtRlWQ GLpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=RLL4dOVQ; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id a19-v6si25011137wrh.226.2018.11.15.11.45.54; Thu, 15 Nov 2018 11:45:54 -0800 (PST) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=RLL4dOVQ; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 73AA9267AFF; Thu, 15 Nov 2018 20:45:52 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id DF141267B00; Thu, 15 Nov 2018 20:45:50 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE autolearn=disabled version=3.4.0 Received: from heliosphere.sirena.org.uk (heliosphere.sirena.org.uk [172.104.155.198]) by alsa0.perex.cz (Postfix) with ESMTP id ADA93267AFC for ; Thu, 15 Nov 2018 20:45:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=hUWWq/f8MCuKv/g/HY5JNyZP8AIpINMTkyUJ+82UQYk=; b=RLL4dOVQPSSC mYEDUJhGJu2xHeYbOIYsatjfFp9UsCBeLaJS2h0ob5QZ8oa3N+VpA0oiYZi52QdG3dExL8CqdklYd KDEfdkd5wadnVWKB+h9rtZcPJoyOrYC6yxOL94R21mkin2Y7d/suUWZkLFaa9ijaSj72SRt6TddSo 7R3KM=; Received: from [64.114.255.97] (helo=finisterre.ee.mobilebroadband) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gNNaG-0006Ei-15; Thu, 15 Nov 2018 19:45:48 +0000 Received: by finisterre.ee.mobilebroadband (Postfix, from userid 1000) id 1E030440078; Thu, 15 Nov 2018 19:45:42 +0000 (GMT) From: Mark Brown To: Cheng-Yi Chiang In-Reply-To: Message-Id: <20181115194542.1E030440078@finisterre.ee.mobilebroadband> Date: Thu, 15 Nov 2018 19:45:42 +0000 (GMT) Cc: alsa-devel@alsa-project.org, Mark Brown Subject: [alsa-devel] Applied "ASoC: rt5663: Add regulator support" to the asoc tree X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org The patch ASoC: rt5663: Add regulator support has been applied to the asoc tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From e81a2a6d12e85fbd7b19e96ad72b82a3cc8a6b2d Mon Sep 17 00:00:00 2001 From: Cheng-Yi Chiang Date: Thu, 15 Nov 2018 12:13:34 +0800 Subject: [PATCH] ASoC: rt5663: Add regulator support Add regulator support to turn on cpvdd and avdd in probe. If a regulator is not given from device tree, a dummy regulator will be used. Signed-off-by: Cheng-Yi Chiang Signed-off-by: Mark Brown --- sound/soc/codecs/rt5663.c | 68 +++++++++++++++++++++++++++++++++++---- 1 file changed, 61 insertions(+), 7 deletions(-) -- 2.19.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c index 7eb2cbd39d6e..29c059ed0682 100644 --- a/sound/soc/codecs/rt5663.c +++ b/sound/soc/codecs/rt5663.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -33,6 +34,9 @@ #define RT5663_DEVICE_ID_2 0x6451 #define RT5663_DEVICE_ID_1 0x6406 +#define RT5663_POWER_ON_DELAY_MS 300 +#define RT5663_SUPPLY_CURRENT_UA 500000 + enum { CODEC_VER_1, CODEC_VER_0, @@ -48,6 +52,11 @@ struct impedance_mapping_table { unsigned int dc_offset_r_manual_mic; }; +static const char *const rt5663_supply_names[] = { + "avdd", + "cpvdd", +}; + struct rt5663_priv { struct snd_soc_component *component; struct rt5663_platform_data pdata; @@ -56,6 +65,7 @@ struct rt5663_priv { struct snd_soc_jack *hs_jack; struct timer_list btn_check_timer; struct impedance_mapping_table *imp_table; + struct regulator_bulk_data supplies[ARRAY_SIZE(rt5663_supply_names)]; int codec_ver; int sysclk; @@ -3483,7 +3493,7 @@ static int rt5663_i2c_probe(struct i2c_client *i2c, { struct rt5663_platform_data *pdata = dev_get_platdata(&i2c->dev); struct rt5663_priv *rt5663; - int ret; + int ret, i; unsigned int val; struct regmap *regmap; @@ -3500,6 +3510,37 @@ static int rt5663_i2c_probe(struct i2c_client *i2c, else rt5663_parse_dp(rt5663, &i2c->dev); + for (i = 0; i < ARRAY_SIZE(rt5663->supplies); i++) + rt5663->supplies[i].supply = rt5663_supply_names[i]; + + ret = devm_regulator_bulk_get(&i2c->dev, + ARRAY_SIZE(rt5663->supplies), + rt5663->supplies); + if (ret) { + dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); + return ret; + } + + /* Set load for regulator. */ + for (i = 0; i < ARRAY_SIZE(rt5663->supplies); i++) { + ret = regulator_set_load(rt5663->supplies[i].consumer, + RT5663_SUPPLY_CURRENT_UA); + if (ret) { + dev_err(&i2c->dev, + "Failed to set regulator %s, ret: %d\n", + rt5663->supplies[i].supply, ret); + } + } + + ret = regulator_bulk_enable(ARRAY_SIZE(rt5663->supplies), + rt5663->supplies); + + if (ret) { + dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret); + return ret; + } + msleep(RT5663_POWER_ON_DELAY_MS); + regmap = devm_regmap_init_i2c(i2c, &temp_regmap); if (IS_ERR(regmap)) { ret = PTR_ERR(regmap); @@ -3530,7 +3571,8 @@ static int rt5663_i2c_probe(struct i2c_client *i2c, dev_err(&i2c->dev, "Device with ID register %#x is not rt5663\n", val); - return -ENODEV; + ret = -ENODEV; + goto err_enable; } if (IS_ERR(rt5663->regmap)) { @@ -3635,20 +3677,30 @@ static int rt5663_i2c_probe(struct i2c_client *i2c, ret = request_irq(i2c->irq, rt5663_irq, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, "rt5663", rt5663); - if (ret) + if (ret) { dev_err(&i2c->dev, "%s Failed to reguest IRQ: %d\n", __func__, ret); + goto err_enable; + } } ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_rt5663, rt5663_dai, ARRAY_SIZE(rt5663_dai)); - if (ret) { - if (i2c->irq) - free_irq(i2c->irq, rt5663); - } + if (ret) + goto err_irq; + return 0; + +err_irq: + if (i2c->irq) + free_irq(i2c->irq, rt5663); + +err_enable: + dev_err(&i2c->dev, + "%s: Disable regulator after probe error\n", __func__); + regulator_bulk_disable(ARRAY_SIZE(rt5663->supplies), rt5663->supplies); return ret; } @@ -3659,6 +3711,8 @@ static int rt5663_i2c_remove(struct i2c_client *i2c) if (i2c->irq) free_irq(i2c->irq, rt5663); + regulator_bulk_disable(ARRAY_SIZE(rt5663->supplies), rt5663->supplies); + return 0; }