From patchwork Sun Jul 22 23:28:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kurtz X-Patchwork-Id: 10539485 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 C49F3180E for ; Sun, 22 Jul 2018 23:28:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A85442841E for ; Sun, 22 Jul 2018 23:28:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98FB428458; Sun, 22 Jul 2018 23:28:36 +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=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 9C9302841E for ; Sun, 22 Jul 2018 23:28:35 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 6AE8226763C; Mon, 23 Jul 2018 01:28:33 +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 AD17A267640; Mon, 23 Jul 2018 01:28:30 +0200 (CEST) Received: from mail-io0-f194.google.com (mail-io0-f194.google.com [209.85.223.194]) by alsa0.perex.cz (Postfix) with ESMTP id 06F7F26763A for ; Mon, 23 Jul 2018 01:28:27 +0200 (CEST) Received: by mail-io0-f194.google.com with SMTP id w11-v6so8591705iob.2 for ; Sun, 22 Jul 2018 16:28:27 -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=lXYAkWMrTXMvydA4fDC57KPIQEb94LnE1NrDFLI3MDY=; b=Aj1LIbpaJaIEUZwSZs6L/QboaqBAYgK0IsG/xkAiKWpgwcOOLFAhyJ6Yr/kkzkqAAZ bqA1c0asnR2SZ1o6tfhiZ4Ko7IKbr9cQVNrwzb2iZEfS1qb2MlpGDVzo6VdzXY1U1Y9F +8CPjgvT9GfNMoTybjJl5n+jVnwH7cYlJ0fAA= 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=lXYAkWMrTXMvydA4fDC57KPIQEb94LnE1NrDFLI3MDY=; b=NLrEixSuDzKugpQ+6XwLeuQLVy0fNFn95uMol9u2Z7RH0kUWLUHeDBkdk8+LMI9wWj TNY61h0/f1P9W4+CywnBDXpnooh/H5D9ct0+mH72aUBwA2G68r08GiZ45G9wb556G8A9 dYQtzCsdhDBYkerx6scohcFw3upk4ct2ulGKJvZZcv9NmMq1ejiOvHA4ucel1v5sOvZW rHpn0W0rSYqygja7UdCro8VTaWRrKRWqdB9oiwcVe/YRxhq6+T0PXOS7RVvK1dx7kTAN OiwTHXx/kmSViah5qsdNBp1QaHoh5jjR6OKBwflIR9hfo/WxGItuVVkD1ZhZouPUk6Fz 6DMA== X-Gm-Message-State: AOUpUlGRU6CaxAn/OpmhxduwO6KjjUcE/9Znq8dMkG69suVohm8/oTzN 32FJPe0RWYvyWYh82YI+AQ7gSg== X-Google-Smtp-Source: AAOMgpfdl/mK/JWSbZaZOiG+WdkOvtH2jzENJWBCi0eEGqrYj4MEr2UpGngAZHQJpuyXHkqYz4LlgQ== X-Received: by 2002:a6b:a715:: with SMTP id q21-v6mr8353954ioe.61.1532302106558; Sun, 22 Jul 2018 16:28:26 -0700 (PDT) Received: from djkurtz2.bld.corp.google.com ([2620:15c:183:0:1cfd:61a5:7215:5f9c]) by smtp.gmail.com with ESMTPSA id f24-v6sm2334281ioc.52.2018.07.22.16.28.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Jul 2018 16:28:25 -0700 (PDT) From: Daniel Kurtz To: Date: Sun, 22 Jul 2018 17:28:22 -0600 Message-Id: <20180722232822.34641-1-djkurtz@chromium.org> X-Mailer: git-send-email 2.18.0.233.g985f88cf7e-goog Cc: "moderated list:SOUND" , Support Opensource , open list , Liam Girdwood , Daniel Kurtz , Takashi Iwai , Mark Brown , Akshu Agrawal Subject: [alsa-devel] [PATCH v2] 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 --- Changes for v2: - fix to use device_property_read_u32() 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..9893920b26f41f 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_u32(dev, "dlg,vddio", &of_val32) >= 0) + 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 */