From patchwork Thu Nov 15 04:13:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-yi Chiang X-Patchwork-Id: 10683501 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3161B109C for ; Thu, 15 Nov 2018 04:14:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1FCC729D52 for ; Thu, 15 Nov 2018 04:14:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1425D29E51; Thu, 15 Nov 2018 04:14:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A90829D52 for ; Thu, 15 Nov 2018 04:14:12 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 08F55267AF8; Thu, 15 Nov 2018 05:14:09 +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 C979D267AFA; Thu, 15 Nov 2018 05:14:06 +0100 (CET) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by alsa0.perex.cz (Postfix) with ESMTP id 3023D267A61 for ; Thu, 15 Nov 2018 05:14:03 +0100 (CET) Received: by mail-pg1-f193.google.com with SMTP id 70so8384554pgh.8 for ; Wed, 14 Nov 2018 20:14:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=unRYDw9DEcNk9vR7FwPu/Jgntc5FVOSU2XbYUOkcXyg=; b=k/U5KQRq16YbYz5FSidO9xXd9ostErwtDHN/k/6Qj5ybSypKrub5iMcaxM7TjC1sUp QHBKLpi5NlNcKmAoGRg2ToJjUJrcOC8+s2teuqUKhrXQjpYV6GDOazHVzY2XEDa4YYqX +nQcHJX7bG3gvEylL9pwdYxjuKNxy8qrxhPdY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=unRYDw9DEcNk9vR7FwPu/Jgntc5FVOSU2XbYUOkcXyg=; b=FucD40WwW8jfibfYhwV2N6bXtugmQNv3Vm31v9GtYrb9A9JQHKECNkaEQGTkT6Q/5u 1bBSdHsO0csLZf554KBO4vSf2Bxc3mOCea95JdgNMskZXVLSBmZjaZnKRo37GgZgQLrz S440Xktt54MD2dYZLWRTiT1+naCuTe8rKmqYiFJCDdAic9gENwZmIisMr2ImOAalvTZY r/kdyO71Z7Y5iSni8mn9aJxpErCrIxWOR4z7Pq4Rm0Svt86ii45+HtnIrUMf4Czq0xcT lh8+6WsIIBa4ywK47pbMRFgMMjmsvmJzZbK9ECTr7s3sm8Mi8IeM8mERCUfl9l20v9ei TYMA== X-Gm-Message-State: AGRZ1gLli/8ns7Xricoaomhu0mSW1oasji2ecwX+4Bp38kVoat3PGyQJ Yef/AfB99atj5UNXklIsVsoaEQ== X-Google-Smtp-Source: AJdET5e7X2Bxl76vEddfTP3HbamnEoMP/as4cLXlTm3C24vF5saPvQeLWNa4MBuS6wcmYzkCaYRQrw== X-Received: by 2002:a62:9a09:: with SMTP id o9-v6mr4920191pfe.229.1542255242261; Wed, 14 Nov 2018 20:14:02 -0800 (PST) Received: from cychiang-z840.tpe.corp.google.com ([2401:fa00:1:b:e688:dfd2:a1a7:2956]) by smtp.gmail.com with ESMTPSA id d11sm10976297pgi.25.2018.11.14.20.13.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Nov 2018 20:14:00 -0800 (PST) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Date: Thu, 15 Nov 2018 12:13:33 +0800 Message-Id: <20181115041334.79446-1-cychiang@chromium.org> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog MIME-Version: 1.0 Cc: oder_chiou@realtek.com, alsa-devel@alsa-project.org, tzungbi@chromium.org, Mark Brown , dgreid@chromium.org, Cheng-Yi Chiang Subject: [alsa-devel] [PATCH 1/2] ASoC: rt5663: Add documentation for power supply support 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP rt5663 codec driver will support setting CPVDD and AVDD power supply from device tree. Signed-off-by: Cheng-Yi Chiang --- Fixed the commit title of v1. Documentation/devicetree/bindings/sound/rt5663.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/rt5663.txt b/Documentation/devicetree/bindings/sound/rt5663.txt index 23386446c63d6..d4058dfde0392 100644 --- a/Documentation/devicetree/bindings/sound/rt5663.txt +++ b/Documentation/devicetree/bindings/sound/rt5663.txt @@ -36,6 +36,9 @@ Optional properties: "realtek,impedance_sensing_num" is 2. It means that there are 2 ranges of impedance in the impedance sensing function. +- avdd-supply: Power supply for AVDD, providing 1.8V. +- cpvdd-supply: Power supply for CPVDD, providing 3.5V. + Pins on the device (for linking into audio routes) for RT5663: * IN1P @@ -51,4 +54,6 @@ rt5663: codec@12 { compatible = "realtek,rt5663"; reg = <0x12>; interrupts = <7 IRQ_TYPE_EDGE_FALLING>; + avdd-supply = <&pp1800_a_alc5662>; + cpvdd-supply = <&pp3500_a_alc5662>; }; From patchwork Thu Nov 15 04:13:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-yi Chiang X-Patchwork-Id: 10683503 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BC88A14D6 for ; Thu, 15 Nov 2018 04:15:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6CD829D90 for ; Thu, 15 Nov 2018 04:15:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 96E2F2A31D; Thu, 15 Nov 2018 04:15:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C5CAD29D90 for ; Thu, 15 Nov 2018 04:15:14 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 9F525267AF8; Thu, 15 Nov 2018 05:15:13 +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 C0EC6267AFA; Thu, 15 Nov 2018 05:15:11 +0100 (CET) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by alsa0.perex.cz (Postfix) with ESMTP id E9DA6267A61 for ; Thu, 15 Nov 2018 05:15:08 +0100 (CET) Received: by mail-pl1-f194.google.com with SMTP id f12-v6so8852491plo.1 for ; Wed, 14 Nov 2018 20:15:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OMww0j8vs5eiNJilKCl4wAWICg/Z8BIVlIe2J/W0AtY=; b=UY9oL0U4DkbciwUANCVdhzBzqNR85zEw0MlhaxUm0w4KsjPMDFmWITJM9Wwj8Gf9dS ft4jCerx+sMTrmbxqx8v2Y3iQRVqK1aXrm5+4pPfkyzqGkq95AwGmbI4iBE77vBmUrQd RjIucGqcphoIm5a7RvJGfSBg03rvCqlLI50lQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OMww0j8vs5eiNJilKCl4wAWICg/Z8BIVlIe2J/W0AtY=; b=KmzswWinEYqs/VeKn/d9KvtVXf9KudzuHx7y+kpv4YVQZFFqv1r/UsWVMz++qP/EmG rrQSqbZwyNiN81yyuZ8HZJZnE1vMvjaY0tHC3pqeUS6BhBL254+psFD9ACKertGOPr9h vBTOm83xiZ8xGCRexhmEDEN8fSZ/WvyBq+WCp+Qam5+Fv9tAOPn5R+9ulAnZKaU6Rghr LMNZVqBsqJgIB4RdxlGXgtHU/Jt8CIAu1nGk97ORvp81bR1gyLSMcN3lljlOrVG8EbuK hpfjvI3rIes4kkcUaHgLqk9F0bbET+oKCBmL6uYj5R7MGPB4LUxGXeJe39lfn9Vg6VWd +W5w== X-Gm-Message-State: AGRZ1gLBulUH/s0KMj6nGC3a0sDpfitTae+2mwMF18Z4j8kMNbya1Gwx uUznq7mSF+ebTZ54HU2F0xClqA== X-Google-Smtp-Source: AJdET5csRkRIr+aq215eQ5zWkRYx4NBBYnONmzpQyAjViHfEFXxLNtSxVS2cm8gMLqqA/mWCsNv36w== X-Received: by 2002:a17:902:7882:: with SMTP id q2mr4788465pll.305.1542255307851; Wed, 14 Nov 2018 20:15:07 -0800 (PST) Received: from cychiang-z840.tpe.corp.google.com ([2401:fa00:1:b:e688:dfd2:a1a7:2956]) by smtp.gmail.com with ESMTPSA id d11sm10976297pgi.25.2018.11.14.20.15.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Nov 2018 20:15:07 -0800 (PST) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Date: Thu, 15 Nov 2018 12:13:34 +0800 Message-Id: <20181115041334.79446-2-cychiang@chromium.org> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog In-Reply-To: <20181115041334.79446-1-cychiang@chromium.org> References: <20181115041334.79446-1-cychiang@chromium.org> MIME-Version: 1.0 Cc: oder_chiou@realtek.com, alsa-devel@alsa-project.org, tzungbi@chromium.org, Mark Brown , dgreid@chromium.org, Cheng-Yi Chiang Subject: [alsa-devel] [PATCH 2/2] ASoC: rt5663: Add regulator support 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- sound/soc/codecs/rt5663.c | 68 +++++++++++++++++++++++++++++++++++---- 1 file changed, 61 insertions(+), 7 deletions(-) diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c index 2444fad7c2dfe..7e9c1901a0a67 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; @@ -3480,7 +3490,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; @@ -3497,6 +3507,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); @@ -3527,7 +3568,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)) { @@ -3632,20 +3674,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; } @@ -3656,6 +3708,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; }