Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp850580pxb; Sat, 16 Jan 2021 09:09:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJwoGyUUpDGOmXDdAGnt21CI8mhjx7wnvcEyH4LLGqAuPn2PAQWF5Va+vI7BrfTlS/CIh7PE X-Received: by 2002:a17:906:2e0d:: with SMTP id n13mr12015922eji.554.1610816996736; Sat, 16 Jan 2021 09:09:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610816996; cv=none; d=google.com; s=arc-20160816; b=vL6Di/KfJfhFnQm6bLCJQFIb2YwMWj7tQnAZBDGG6f2H04Od+LH2FnFYiXB1NKyEhs EdCUgnAex50u2GIHIM20WdFPaaj1KH2Xx9buoLsnBiOrOVRoe5D0jRy56pbEsxQLvyR+ 6cHQmkJrHhDlBbfmJegiFU55k7FIm4JAtzK5lh0sLabMcFUr0yp/1OO0Lwbi65KZzuIw e5qjqCg9xSBqhnA1h4BLeYX7RZJ2sBdnl1bujXkgBr5ALU+F104ZeiL+QQqTmUkkI5fr rEPDBuaZvzB+Ym0y9k/5jM04vt1MjvEENU18RRZZQqUQQVVwj6zMA7A3+tBPSTF/K9hQ uHmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=qupr++fTHbnNIAJqQF6SX3UmT2+7rap26aUJDYVRflA=; b=zG5fExVPwMkGLwjWFLERCfL+7Pu85wX7WdZkYWQGrVbKWemSEP6mnnj6a17ngW2U7u 5/nUPagBdoq5MMS7nu1nyKeXURmix64vux+zjyyaMjtJGirJH+9668b0oAIY89d4rTn1 MUk0Riz9XBLwqdkmffxm0goqfaCnkoy/O0qxFQXCTW2bnhNjEn0aRMEls5YxlZdW7PPR RJsYurLCkEgPstf1n/YYsgEaeDkAGlqb3ZDKJcPiIgzMGau28OKnxgmORoJGw5Et3Oa/ bT63LhU8i6uuSMaAe/9q8T9Aa1NAl6/qrN1ABqQ8bKSvYQKLPOF+mUZwh+6XoCFFkWc8 4ynw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TTm1AvSq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g1si5339740ejz.557.2021.01.16.09.08.54; Sat, 16 Jan 2021 09:09:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TTm1AvSq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727137AbhAPRGS (ORCPT + 99 others); Sat, 16 Jan 2021 12:06:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59578 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727169AbhAPRDv (ORCPT ); Sat, 16 Jan 2021 12:03:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610816473; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qupr++fTHbnNIAJqQF6SX3UmT2+7rap26aUJDYVRflA=; b=TTm1AvSq8vlxtxu2iYf0Bc5Eto/KoguNTSxpU2R/1IkoSydK9XWe8M7kN2NfUNorELk8ge 7s4n9vtKD7Oq7im/k2JwkhR3Y6vEMsEOHzfr2hniPfjq8PGS7WpaSspv3lhp4qiaby5HB3 4YycXlDzqpuAuyPJ8YfoUv96eZDOeRo= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-218-5VtuKbvSP9GIInXvw3WBGA-1; Sat, 16 Jan 2021 11:49:16 -0500 X-MC-Unique: 5VtuKbvSP9GIInXvw3WBGA-1 Received: by mail-ed1-f70.google.com with SMTP id g25so5506560edu.4 for ; Sat, 16 Jan 2021 08:49:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=qupr++fTHbnNIAJqQF6SX3UmT2+7rap26aUJDYVRflA=; b=OBENBpVclMIGM6F8AdEQn6auXpS0luBgNZticlFIsaDPETYkkDvYFEWjcBk08aTVd/ 1Hv4FYE8zIvyWVw0YdX561/344V60yg3Vvlo2AgCN6Pd/eW3bZZdPiktctKRuowJUAM3 O9E4RS8r4/bc9XjATcLaycjjMrGTYS+qcNd/iC+jfGHqiq25rrPSnNvwxAUFI3p/d3sL MXFunKV1zMk8L3cqTV8vSEJebMpSS5b0+M+BsVHteBkfV2Bh882DMgRUFFRygB0b41KX KQZ4vPaAIeNVOpcndoGJi3OHIZkfHvVikqLm03Qruy4lGCcJty77VBXPVBBGHwPdGZ/w hD9Q== X-Gm-Message-State: AOAM533a0qmzAaycziEOD+14rU0DrqKzezGrYBSw9StqaucVy7lYx0m+ Q35DbT+04I3l0G35v9tDZA/QhNm71kprFxjO3vMQPaRh974QGit+GKKOxsCuis32cApFvtzh6x0 dTrRdSWk27tPdRbHCnzXYFxe8 X-Received: by 2002:a50:eb44:: with SMTP id z4mr13379023edp.167.1610815754979; Sat, 16 Jan 2021 08:49:14 -0800 (PST) X-Received: by 2002:a50:eb44:: with SMTP id z4mr13379012edp.167.1610815754745; Sat, 16 Jan 2021 08:49:14 -0800 (PST) Received: from x1.localdomain (2001-1c00-0c1e-bf00-37a3-353b-be90-1238.cable.dynamic.v6.ziggo.nl. [2001:1c00:c1e:bf00:37a3:353b:be90:1238]) by smtp.gmail.com with ESMTPSA id i13sm7727343edu.22.2021.01.16.08.49.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 16 Jan 2021 08:49:14 -0800 (PST) Subject: Re: [PATCH 13/14] ASoC: Intel: bytcr_wm5102: Add machine driver for BYT/WM5102 To: Charles Keepax Cc: Lee Jones , MyungJoo Ham , Chanwoo Choi , Cezary Rojewski , Pierre-Louis Bossart , Liam Girdwood , Jie Yang , Mark Brown , patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org References: <20201227211232.117801-1-hdegoede@redhat.com> <20201227211232.117801-14-hdegoede@redhat.com> <20201229135836.GO9673@ediswmail.ad.cirrus.com> From: Hans de Goede Message-ID: <6d881b08-2511-5dcf-0f88-4f54b937c967@redhat.com> Date: Sat, 16 Jan 2021 17:49:13 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <20201229135836.GO9673@ediswmail.ad.cirrus.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Thank you for the review. On 12/29/20 2:58 PM, Charles Keepax wrote: > On Sun, Dec 27, 2020 at 10:12:31PM +0100, Hans de Goede wrote: >> From: Pierre-Louis Bossart >> >> Add a new ASoc Machine driver for Intel Baytrail platforms with a >> Wolfson Microelectronics WM5102 codec. >> >> This is based on a past contributions [1] from Paulo Sergio Travaglia >> based on the Levono kernel [2] combined with >> insights in things like the speaker GPIO from the android-x86 android >> port for the Lenovo Yoga Tablet 2 1051F/L [3]. >> >> [1] https://patchwork.kernel.org/project/alsa-devel/patch/593313f5.3636c80a.50e05.47e9@mx.google.com/ >> [2] https://github.com/lenovo-yt2-dev/android_kernel_lenovo_baytrail/blob/cm-12.1/sound/soc/intel/board/byt_bl_wm5102.c >> [3] https://github.com/Kitsune2222/Android_Yoga_Tablet_2-1051F_Kernel >> >> The original machine driver from the Android ports was a crude modified >> copy of bytcr_rt5640.c adjusted to work with the WM5102 codec. >> This version has been extensively reworked to: >> >> 1. Remove all rt5640 related quirk handling. to the best of my knowledge >> this setup is only used on the Lenovo Yoga Tablet 2 series (8, 10 and 13 >> inch models) which all use the same setup. So there is no need to deal >> with all the variations with which we need to deal on rt5640 boards. >> >> 2. Rework clock handling, properly turn off the FLL and the platform-clock >> when they are no longer necessary and don't reconfigure the FLL >> unnecessarily when it is already running. This fixes a number of: >> "Timed out waiting for lock" warnings being logged. >> >> 3. Add the GPIO controlled Speaker-VDD regulator as a DAPM_SUPPLY >> >> This only adds the machine driver and ACPI hooks, the BYT-CR detection >> quirk which these devices need will be added in a separate patch. >> >> Co-authored-by: Pierre-Louis Bossart >> Signed-off-by: Pierre-Louis Bossart >> Signed-off-by: Hans de Goede >> --- > > Just a couple really minor comments. > >> +static int byt_wm5102_prepare_and_enable_pll1(struct snd_soc_dai *codec_dai, int rate) >> +{ >> + struct snd_soc_component *codec_component = codec_dai->component; >> + int sr_mult = ((rate % 4000) == 0) ? >> + (WM5102_MAX_SYSCLK_4K / rate) : >> + (WM5102_MAX_SYSCLK_11025 / rate); >> + int ret; >> + >> + /* Reset FLL1 */ >> + snd_soc_dai_set_pll(codec_dai, WM5102_FLL1_REFCLK, ARIZONA_FLL_SRC_NONE, 0, 0); >> + snd_soc_dai_set_pll(codec_dai, WM5102_FLL1, ARIZONA_FLL_SRC_NONE, 0, 0); >> + >> + /* Configure the FLL1 PLL before selecting it */ >> + ret = snd_soc_dai_set_pll(codec_dai, WM5102_FLL1, ARIZONA_CLK_SRC_MCLK1, >> + MCLK_FREQ, rate * sr_mult); >> + if (ret) { >> + dev_err(codec_component->dev, "Error setting PLL: %d\n", ret); >> + return ret; >> + } >> + >> + ret = snd_soc_component_set_sysclk(codec_component, ARIZONA_CLK_SYSCLK, >> + ARIZONA_CLK_SRC_FLL1, rate * sr_mult, >> + SND_SOC_CLOCK_IN); >> + if (ret) { >> + dev_err(codec_component->dev, "Error setting ASYNCCLK: %d\n", ret); > > Error message should say SYSCLK not ASYNCCLK. Fixed for v2. > >> + return ret; >> + } >> + >> + ret = snd_soc_component_set_sysclk(codec_component, ARIZONA_CLK_OPCLK, 0, >> + rate * sr_mult, SND_SOC_CLOCK_OUT); >> + if (ret) { >> + dev_err(codec_component->dev, "Error setting OPCLK: %d\n", ret); >> + return ret; >> + } > > OPCLK is a clock that can be outputted on the CODECs GPIOs. Is > that being used to clock some external component? If so it should > be added to the DAPM graph, if not you might as well remove this > call. I copy pasted this from the work done for Android X86 to get sound to work on the Lenovo Tablet 2 series: https://github.com/Kitsune2222/Android_Yoga_Tablet_2-1051F_Kernel I believe when you say it is unnecessary, so I will remove it for v2 (and test without this present to make sure it is really unnecessary). > >> + >> + ret = snd_soc_dai_set_sysclk(codec_dai, ARIZONA_CLK_SYSCLK, >> + rate * 512, SND_SOC_CLOCK_IN); >> + if (ret) { >> + dev_err(codec_component->dev, "Error setting clock: %d\n", ret); >> + return ret; >> + } >> + > > The rate you set here doesn't actually matter, on wm5102 this > just links the DAI to a specific clock domain and as they all > default to SYSCLK you can omit this call if you want. Although no > harm is caused by leaving it in. I'm going to leave this in as I prefer to be explicit about things like this, rather then relying on defaults. Regards, Hans