Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4136235pxk; Tue, 8 Sep 2020 11:34:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytCwp4DzDrYyqSXvvIT/o4TWOjzSS5AhpsBNS1FeL9YsofGNKFLhh2UPZptQ4+GgPGJOBR X-Received: by 2002:a17:906:11d2:: with SMTP id o18mr26675569eja.420.1599590096140; Tue, 08 Sep 2020 11:34:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599590096; cv=none; d=google.com; s=arc-20160816; b=R42lFI35AT2IaoUKl73NANp02KPBqXorc2Nx1FINArO7SetkoYGogkBxGBhFLZEm4k fbZtjoLe+14QL6FsqtlBu9nWQEtec+1s7JZsMPc4VT+J83pswQSLOhBpRRgbQ9aNPu8r zX2XkKgl5C9YN89memXX9ZjWQAwCV5bO2bBapeFQCSiGMPUhEgG+HHwgP8n5c9+RplEv xq3ZVadd9IrNTS9dIlRCx9cwzawu5nEuBNWCTBDcHhiAwYDBznacMgPZXjMdMzb4I7Wz X6CWz6KLGBY1WJ6Lt2TXt6ZVAPY/atB2luOs32fEGRu0AlcJVZ2JrkjgPrTtl7VnMEVC wqbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=CqUNZPQoWK27ZwluptR7lmOmGnDUgLbIso50mEGeMNA=; b=z04dXqpQ4zrBFxt8Dtx+1Gn/Izv1ntzJ1A34KDw7FDtUbd1TSQ40sOSUvUte7W+kyL VFPLhGlrUlOXLz3s9RWf2ghfB/jEvAYxqNwJxBfnUDIIY1yytZG+4XSojq1yfalRDBpD spKBhDNfwpb1olOvPfY22r0DTAdITej+hVieFBh32Dh2Y5EOLcDOcMIi1/dIaWUNVjaJ QdYXefLs+bqro5WE6sM+TaZ94DpbVC4E6FvMcuJ94D0ofJRHRSlE2KMBWMGo5bRTzy/s wNOYOjIFVBw746JV8PXuyeZZazWmIICmPqqTyag342i6s1xQGHZiSt/2Ith1LRNBnO+y njhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@semihalf-com.20150623.gappssmtp.com header.s=20150623 header.b=xCh81xpP; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p61si6261322edd.188.2020.09.08.11.34.33; Tue, 08 Sep 2020 11:34:56 -0700 (PDT) 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=@semihalf-com.20150623.gappssmtp.com header.s=20150623 header.b=xCh81xpP; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731745AbgIHSdz (ORCPT + 99 others); Tue, 8 Sep 2020 14:33:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731843AbgIHScN (ORCPT ); Tue, 8 Sep 2020 14:32:13 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F9A5C0617AB for ; Tue, 8 Sep 2020 11:24:21 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id s13so279090wmh.4 for ; Tue, 08 Sep 2020 11:24:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=CqUNZPQoWK27ZwluptR7lmOmGnDUgLbIso50mEGeMNA=; b=xCh81xpPbIIdQ/7J9jkA8BvZPOWnUqm1dGONxOZSWXkhOX7jZzHxmcL3TN0I/kjql9 kQbku02XgzFM6c1dJbPQq3FZK0MSAQ9yuP3paVxLJmCeWc7EMlYudhSw6anka+2OqPhl NimzWJRhnXEuPRT7W+jk9OnuGF8bPld3Fh/23SGtNqxbsrJqnCrwvIJkwL7qPYjyQX2h Am9p5AQOi6QrURcnhsceskJPAlniay5LQjG89pDzzpKgm75/64R+PWvB/0Va2Igqlfgz brQdEO679PsYqfo+qeJfsfrznRuNJf286npI71+im+57glbjUdWCAb8v7w/aGkow4jgj AtNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=CqUNZPQoWK27ZwluptR7lmOmGnDUgLbIso50mEGeMNA=; b=KSg02i4KxL7isTORNq7FIeXV5lAtItXvNoI2PNmQcna+misc71YfV9WTRoz6FqKTnQ NTyGo9i4w4xcil71kHTa0UbDOlZjW6b1I8aPN0aVWvjO18j1sdoRozGiKEQBS6TJ5Sxm clFbCGPea+Z0VXGjOlnJZGL+MRCr6etvgBYsWFyqpK+I2DWMwK1mDFuuX2DX1fzur1sW v4EWlX1eVcaiXyyUAhR7twJWITu7xHrJY7hEEGosTJJ8hxlpMSKJ7v1Y3rw4BJsc897R f3Ep5pbIXsDNvABNdABV9r/R3pKkf5jtlza4aEg6LbveEfykT29FsmWOXVRKk5ey+8MM tuug== X-Gm-Message-State: AOAM532K1HvSE3LvcXG1eC7XQop9KnM9La7oyipdBHVu2GiTQF/ci64u baK8c6BQvHhBvwx2KH3gHfsPJSWrqUc+Ld+5qOrFCA0LW8I= X-Received: by 2002:a1c:81c6:: with SMTP id c189mr394744wmd.124.1599589460131; Tue, 08 Sep 2020 11:24:20 -0700 (PDT) MIME-Version: 1.0 References: <20200501193141.30293-1-rad@semihalf.com> <3ad44b75-387f-da75-d7b2-3a16ed00550c@linux.intel.com> <8b97bf43-ddd8-df81-90e7-9e87c19af1ab@linux.intel.com> <2a88f81f-c7a3-f9fc-06a3-c39496b57d0c@linux.intel.com> In-Reply-To: <2a88f81f-c7a3-f9fc-06a3-c39496b57d0c@linux.intel.com> From: =?UTF-8?Q?Rados=C5=82aw_Biernacki?= Date: Tue, 8 Sep 2020 20:24:03 +0200 Message-ID: Subject: Re: [PATCH V2] ASoC: Intel: boards: Use FS as nau8825 sysclk in nau88125_* machine To: Pierre-Louis Bossart Cc: Lech Betlej , alsa-devel@alsa-project.org, Todd Broch , Harshapriya , Jie Yang , John Hsu , Takashi Iwai , "Sienkiewicz, Michal" , linux-kernel@vger.kernel.org, Liam Girdwood , Ben Zhang , Mac Chiang , Yong Zhi , Marcin Wojtas , Vamshi Krishna , Alex Levin Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks for the tip! Let me reformat the patch. wt., 8 wrz 2020 o 20:06 Pierre-Louis Bossart napisa=C5=82(a): > > > > On 9/8/20 12:42 PM, Rados=C5=82aw Biernacki wrote: > > Sorry for missing the response for so long. > > Somehow lost this thread in my mailbox. > > That happens to all of us! > > > =C5=9Br., 6 maj 2020 o 00:04 Pierre-Louis Bossart > > napisa=C5=82(a): > >> > >> > >>>>> This single fix address two issues on machines with nau88125: > >>>>> 1) Audio distortion, due to lack of required clock rate on MCLK lin= e > >>>>> 2) Loud audible "pops" on headphones if there is no sysclk during n= au8825 > >>>>> playback power up sequence > >>>>> > >>>>> Explanation for: > >>>>> 1) Due to Skylake HW limitation, MCLK pin can only output 24MHz clk > >>>>> rate (it can be only connected to XTAL parent clk). The BCLK = pin > >>>>> can be driven by dividers and therefore FW is able to set it = to rate > >>>>> required by chosen audio format. According to nau8825 datashe= et, 256*FS > >>>>> sysclk gives the best audio quality and the only way to achie= ve this > >>>>> (taking into account the above limitations) its to regenerate= the MCLK > >>>>> from BCLK on nau8825 side by FFL. Without required clk rate, = audio is > >>>>> distorted by added harmonics. > >>>> > >>>> The BCLK is going to be a multiple of 50 * Fs due to clocking > >>>> restrictions. Can the codec regenerate a good-enough sysclk from thi= s? > >>> > >>> According to Intel, silicon has a limitation, on SKL/KBL only clk_id = =3D > >>> SKL_XTAL, .name =3D "xtal" is available for IO domain. > >>> As mentioned in the commit: > >>> MCLK is generated by using 24MHz Xtal directly or applying a divider > >>> (so no way of achieving the rate required by audio format). > >>> BCLK/FS is generated from 24MHz and uses dividers and additional > >>> padding bits are used to match the clock source. > >>> Next gen silicon has the possibility of using additional clock source= s. > >>> > >>> Summing up, using MCLK from SKL to NAU88L25 is not an option. > >>> The only option we found is to use BCLK and regen the required clock > >>> rate by FLL on the NAU88l25 side. > >> > >> Right, this 24 MHz is a recurring problem. > >> But what I was asking was if the NAU8825 is fine working with e.g. a > >> 2.4MHz bit clock. i.e. with 25 bit slots or padding at the end of the = frame? > > > > From our tests NAU8825 is working fine with these parameters. > > Also the output audio signal looks fine on the scope and FFT and there > > are no audible glitches. > > > >> > >>> > >>>>> > >>>>> 2) Currently Skylake does not output MCLK/FS when the back-end DAI = op > >>>>> hw_param is called, so we cannot switch to MCLK/FS in hw_para= m. This > >>>>> patch reduces pop by letting nau8825 keep using its internal = VCO clock > >>>>> during widget power up sequence, until SNDRV_PCM_TRIGGER_STAR= T when > >>>>> MCLK/FS is available. Once device resumes, the system will on= ly enable > >>>>> power sequence for playback without doing hardware parameter,= audio > >>>>> format, and PLL configure. In the mean time, the jack detecio= n sequence > >>>>> has changed PLL parameters and switched to internal clock. Th= us, the > >>>>> playback signal distorted without correct PLL parameters. Th= at is why > >>>>> we need to configure the PLL again in SNDRV_PCM_TRIGGER_RESUM= E case. > >>>> > >>>> IIRC the FS can be controlled with the clk_ api with the Skylake dri= ver, > >>>> as done for some KBL platforms. Or is this not supported by the firm= ware > >>>> used by this machine? > >>> > >>> According to Ben, SKL had limitations in FW for managing the clk's > >>> back in the days. > >>> Can you point to the other driver you mention so we can cross check? > >> > >> There are two KBL drivers that control the SSP clocks from the machine > >> driver, but indeed I don't know if this would work on Firmware, it'd b= e > >> a question for Lech/Cezary. > >> > >> kbl_rt5663_max98927.c: ret =3D clk_prepare_enable(priv->mclk)= ; > >> kbl_rt5663_max98927.c: ret =3D clk_prepare_enable(priv->sclk)= ; > >> kbl_rt5663_rt5514_max98927.c: ret =3D > >> clk_prepare_enable(priv->mclk); > >> kbl_rt5663_rt5514_max98927.c: ret =3D > >> clk_prepare_enable(priv->sclk); > >> kbl_rt5663_rt5514_max98927.c: ret =3D > >> clk_prepare_enable(priv->mclk); > >> > > > > Czarek answered this and we got the same response from other Intel > > devs while consulting this change: > > FW cannot request a chosen rate (48k) for MCLK pin as it does not > > "align with what's present on SKL hw". > > > > The only way we found out for NAU8825 to cooperate at chosen rate with > > SKL HW is to regen the MCLK from BCLK by FLL as mentioned above. > > NHTL is used to set SSP0 (48k, 24/25 bit on 24MHz crystal). > > If I get all of this right, use of NHTL and HW "abilities" would > > explain why there is no call to change SSP from a machine driver. > > > > > > If all of this is ok I will send V3 with msleep() removed. > > Sounds good. > > You may want to simplify your commit message and just state what you > described, e.g. > > "Since 64xfs clocks cannot be generated, the NAU8825 is configured to > re-generate its system clock from the BCLK using the FLL. The link is > configured to use a 48kHz frame rate, and 24 bits in 25-bit slot. The > SSP configuration is extracted from NHLT settings and not dynamically > changed. Listening tests and measurements do not show any distortion or > issues". > > >