Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7238968pxb; Thu, 18 Feb 2021 05:20:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJwAjZ+1JB19NbXz6n8JSFC/A8o/Ip/jOeyBFhqlxggeHBwf4upFmRcinLn/eB8fFmF9qmft X-Received: by 2002:a05:6402:3d8:: with SMTP id t24mr4081017edw.298.1613654421814; Thu, 18 Feb 2021 05:20:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613654421; cv=none; d=google.com; s=arc-20160816; b=we81nZuq1OrXLv/5ka7heYyxEuh15u2btgB2mFIYUQUabMWHs7+3HEw7djKs+euxca Dg8cEihHtCMvu3TyBFk/MYheEd2Ly+c2rIk+aFipogL5OkbsHouRSKE02mN5Z86Dqnrj YAef7ujoIj8LVK3PN9HVQ4PGDlBz1wrxMN+siExRcVrn1Qdj46EcHRCqkvkzF9LzKpLW GFG6w5mFKD0BvFB23fUcXilV/iZhiCp8rO5lHSCoYf6c4AFD5V/RWag+Fzr0ONb0G5nC W103f2gg9lHj3waWAdbWdsbZ1QB6oZEX34qxG/5jihry18fFvTRDNtv7LMwSLYJ9k30T m8uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=gz3HWckah3ruhIIuO3vLl2W/46Q/rXPDL7jWoJi3g/E=; b=I3w4zRp8qDp3XBqMp1CYXydY3tJ4Nj3Turll8bvIopi+Yb38cfkmi9+dEHOldM86MJ 1UpmBWmJX/NN3w6IEER+PKgEeLuRq6rI6sMFeERrjT3Lnjn5N35jTnAw2xtrSwvgH6/S ZbrUc+RzC8lEOAa8ZLH2+uf66a6GaJYzMTmVS/Fz7fCzpavYnHvKuQH55KL6FgV7pzwY FlUdmxc3OgqJh6v3oLPMKxOWr1g1dSFLNkWt24NYYX/JaiJhBcKX8pmtA0HAMEI/6wmE yt4PRG2FhGlNJM2O5EbMVpZ6OXTTeSpQmlxlWEhY5w1j7kTbO6BhGbOMbXT+0QvA7lIn OGNA== ARC-Authentication-Results: i=1; mx.google.com; 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 op27si3130468ejb.297.2021.02.18.05.19.57; Thu, 18 Feb 2021 05:20:21 -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; 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 S232073AbhBRNQm (ORCPT + 99 others); Thu, 18 Feb 2021 08:16:42 -0500 Received: from mail.manjaro.org ([176.9.38.148]:54994 "EHLO mail.manjaro.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232067AbhBRLmB (ORCPT ); Thu, 18 Feb 2021 06:42:01 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.manjaro.org (Postfix) with ESMTP id 38D833E600A1; Thu, 18 Feb 2021 12:20:35 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at manjaro.org Received: from mail.manjaro.org ([127.0.0.1]) by localhost (manjaro.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ful2cswKUM3i; Thu, 18 Feb 2021 12:20:32 +0100 (CET) From: Tobias Schramm To: Icenowy Zheng , Maxime Ripard Cc: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Michael Turquette , Stephen Boyd , Chen-Yu Tsai , Jernej Skrabec , Tobias Schramm Subject: [PATCH v2 1/1] clk: sunxi-ng: v3s: use sigma-delta modulation for audio-pll Date: Thu, 18 Feb 2021 12:20:01 +0100 Message-Id: <20210218112001.479018-2-t.schramm@manjaro.org> In-Reply-To: <20210218112001.479018-1-t.schramm@manjaro.org> References: <20210218112001.479018-1-t.schramm@manjaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Previously it was not possible to achieve clock rates of 24.576MHz and 22.5792MHz, which are commonly required core clocks for the i2s peripheral of v3s based SoCs. Add support for those clock rates through the audio pll's sigma-delta modulator. Signed-off-by: Tobias Schramm --- drivers/clk/sunxi-ng/ccu-sun8i-v3s.c | 33 ++++++++++++++++++---------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c index 0e36ca3bf3d5..a774942cb153 100644 --- a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c +++ b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c @@ -40,18 +40,29 @@ static SUNXI_CCU_NKMP_WITH_GATE_LOCK(pll_cpu_clk, "pll-cpu", * the base (2x, 4x and 8x), and one variable divider (the one true * pll audio). * - * We don't have any need for the variable divider for now, so we just - * hardcode it to match with the clock names + * With sigma-delta modulation for fractional-N on the audio PLL, + * we have to use specific dividers. This means the variable divider + * can no longer be used, as the audio codec requests the exact clock + * rates we support through this mechanism. So we now hard code the + * variable divider to 1. This means the clock rates will no longer + * match the clock names. */ #define SUN8I_V3S_PLL_AUDIO_REG 0x008 -static SUNXI_CCU_NM_WITH_GATE_LOCK(pll_audio_base_clk, "pll-audio-base", - "osc24M", 0x008, - 8, 7, /* N */ - 0, 5, /* M */ - BIT(31), /* gate */ - BIT(28), /* lock */ - 0); +static struct ccu_sdm_setting pll_audio_sdm_table[] = { + { .rate = 22579200, .pattern = 0xc0010d84, .m = 8, .n = 7 }, + { .rate = 24576000, .pattern = 0xc000ac02, .m = 14, .n = 14 }, +}; + +static SUNXI_CCU_NM_WITH_SDM_GATE_LOCK(pll_audio_base_clk, "pll-audio-base", + "osc24M", 0x008, + 8, 7, /* N */ + 0, 5, /* M */ + pll_audio_sdm_table, BIT(24), + 0x284, BIT(31), + BIT(31), /* gate */ + BIT(28), /* lock */ + CLK_SET_RATE_UNGATE); static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_video_clk, "pll-video", "osc24M", 0x0010, @@ -524,10 +535,10 @@ static struct ccu_common *sun8i_v3_ccu_clks[] = { &mipi_csi_clk.common, }; -/* We hardcode the divider to 4 for now */ +/* We hardcode the divider to 1 for SDM support */ static CLK_FIXED_FACTOR_HWS(pll_audio_clk, "pll-audio", clk_parent_pll_audio, - 4, 1, CLK_SET_RATE_PARENT); + 1, 1, CLK_SET_RATE_PARENT); static CLK_FIXED_FACTOR_HWS(pll_audio_2x_clk, "pll-audio-2x", clk_parent_pll_audio, 2, 1, CLK_SET_RATE_PARENT); -- 2.30.1