From patchwork Sat Jul 21 00:12:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kurtz X-Patchwork-Id: 10538565 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 090366053F for ; Sat, 21 Jul 2018 00:12:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBAF920683 for ; Sat, 21 Jul 2018 00:12:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DFECD285BA; Sat, 21 Jul 2018 00:12:53 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=unavailable 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 02EBC20683 for ; Sat, 21 Jul 2018 00:12:52 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id E6945267763; Sat, 21 Jul 2018 02:12:48 +0200 (CEST) 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 B74F7267766; Sat, 21 Jul 2018 02:12:45 +0200 (CEST) Received: from mail-it0-f66.google.com (mail-it0-f66.google.com [209.85.214.66]) by alsa0.perex.cz (Postfix) with ESMTP id 3BBE4267762 for ; Sat, 21 Jul 2018 02:12:42 +0200 (CEST) Received: by mail-it0-f66.google.com with SMTP id j185-v6so16757006ite.1 for ; Fri, 20 Jul 2018 17:12:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=01kAA8Gx9bfJinHEJzBec7mAnldCS7OcBanPkghUBOk=; b=iJAy8NjYpoKEJLpjTQGbKh4EKG/8aGJY0Ff38i4F+jpgUmFE3r86JuANFmWoVXRclD Tlwq6t49mv32DneWXYliANKVdye9lOCS8lvNWpo0J6kywLBj5bPXiPJfJShKgv0TZ0o8 z73c0Fj/2ihV1uGTLwyP2gjBZLP0mQ09DKME8= 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; bh=01kAA8Gx9bfJinHEJzBec7mAnldCS7OcBanPkghUBOk=; b=tyu9vsVpBzZ3cU9fAI99x2VsYdF0zngB3K3ZMOYn2o2jJsw9khkV8v5AO7jmwKYO4y EZECQt60NDLr+346zlz7bh4xynfobvJBoEp9kzXIZrs8zFR92CQL9iENXE8joAk053+C zFBMbEA/M5/+a/ChDKNFk1mEXzCYd6YN3cWwTOEt/R1URAbFLE7Gwb9ffVsSovR26s/2 FD9SMb5Lr6pnHMe32qaMQCulrJCkJKjxJDfMxrVssTzvRbcRN4q3xrgJkHsvj+j/9ZKs tz/aLR9g8KZTedsa3+Anj1Y7urJws8t/yTt1EoTb75HgrRBnar28vQkG1wXsP8Df1Qhz BOuA== X-Gm-Message-State: AOUpUlGA7Ai/3jsv+d7uxKuwQleAfBJxmrD0MsEtVVe4o7fAlOLoQIsY 2xxQNpUDtsTZu3wwt1rtsBhVBg== X-Google-Smtp-Source: AAOMgpcggZQU+4wwnefrxBllp4iVpTurlkVQK/mhamgs3Swc4j6h6fe84lpmVAgsAf6Vj2/bDtApKA== X-Received: by 2002:a24:624f:: with SMTP id d76-v6mr3571576itc.78.1532131961511; Fri, 20 Jul 2018 17:12:41 -0700 (PDT) Received: from djkurtz2.bld.corp.google.com ([2620:15c:183:0:1cfd:61a5:7215:5f9c]) by smtp.gmail.com with ESMTPSA id e19-v6sm1014142ioc.46.2018.07.20.17.12.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Jul 2018 17:12:40 -0700 (PDT) From: Daniel Kurtz To: Date: Fri, 20 Jul 2018 18:12:35 -0600 Message-Id: <20180721001235.164891-1-djkurtz@chromium.org> X-Mailer: git-send-email 2.18.0.233.g985f88cf7e-goog Cc: "moderated list:SOUND" , Support Opensource , Liam Girdwood , open list , Takashi Iwai , Daniel Kurtz , Mark Brown , Dylan Reid , Akshu Agrawal , Jimmy Cheng-Yi Chiang Subject: [alsa-devel] [PATCH] ASoC: da7219: Allow pdata to specify a VDDIO 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 X-Virus-Scanned: ClamAV using ClamSMTP Some systems do not have software controllable regulators driving the DA7219's supplies, nor can they use device tree to create "always-on fixed regulators" to easily pretend like they do. On these systems the call to devm_regulator_bulk_get() just creates a set of dummy registers. Calling regulator_get_voltage() on a dummy regulator just returns -EINVAL, in which case the DA7219 is always set up to use the default VDDIO voltage range of 2.5-3.6V. Provide a new device property to let such systems specify a different VDDIO if needed (e.g., 1.8V). Signed-off-by: Daniel Kurtz --- This patch tries to solve the same problem as in the following patches, but does so in a way that doesn't require registering fixed regulators in the audio machine-driver: https://patchwork.kernel.org/patch/10531097 & 10531099 https://patchwork.kernel.org/patch/10536023/ include/sound/da7219.h | 2 ++ sound/soc/codecs/da7219.c | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/include/sound/da7219.h b/include/sound/da7219.h index 1bfcb16f2d10ab..16ab125ad4adbf 100644 --- a/include/sound/da7219.h +++ b/include/sound/da7219.h @@ -38,6 +38,8 @@ struct da7219_pdata { const char *dai_clks_name; + u32 vddio; + /* Mic */ enum da7219_micbias_voltage micbias_lvl; enum da7219_mic_amp_in_sel mic_amp_in_sel; diff --git a/sound/soc/codecs/da7219.c b/sound/soc/codecs/da7219.c index 980a6a8bf56d38..d8f202c57f958d 100644 --- a/sound/soc/codecs/da7219.c +++ b/sound/soc/codecs/da7219.c @@ -1634,6 +1634,9 @@ static struct da7219_pdata *da7219_fw_to_pdata(struct snd_soc_component *compone else pdata->mic_amp_in_sel = DA7219_MIC_AMP_IN_SEL_DIFF; + if (!device_property_read_string(dev, "dlg,vddio", &of_val32)) + pdata->vddio = of_val32; + return pdata; } @@ -1717,8 +1720,12 @@ static int da7219_handle_supplies(struct snd_soc_component *component) /* Determine VDDIO voltage provided */ vddio = da7219->supplies[DA7219_SUPPLY_VDDIO].consumer; ret = regulator_get_voltage(vddio); + /* If regulator_get_voltage() fails, try to use vddio from pdata. */ + if (ret < 0 && da7219->pdata) + ret = da7219->pdata->vddio; if (ret < 1200000) - dev_warn(component->dev, "Invalid VDDIO voltage\n"); + dev_warn(component->dev, "Invalid VDDIO voltage: %d mV\n", + ret); else if (ret < 2800000) io_voltage_lvl = DA7219_IO_VOLTAGE_LEVEL_1_2V_2_8V; @@ -1872,6 +1879,11 @@ static int da7219_probe(struct snd_soc_component *component) mutex_init(&da7219->ctrl_lock); mutex_init(&da7219->pll_lock); + /* Handle DT/ACPI/Platform data */ + da7219->pdata = dev_get_platdata(component->dev); + if (!da7219->pdata) + da7219->pdata = da7219_fw_to_pdata(component); + /* Regulator configuration */ ret = da7219_handle_supplies(component); if (ret) @@ -1897,11 +1909,6 @@ static int da7219_probe(struct snd_soc_component *component) break; } - /* Handle DT/ACPI/Platform data */ - da7219->pdata = dev_get_platdata(component->dev); - if (!da7219->pdata) - da7219->pdata = da7219_fw_to_pdata(component); - da7219_handle_pdata(component); /* Check if MCLK provided */