Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1327974pxf; Fri, 9 Apr 2021 05:58:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwC9SZ2+nSFql4aep0lUCsKzBpAZZG3cpeP750mnBJ58J7HZRct65a2O9k4HH7vKg5pzXpy X-Received: by 2002:a63:d61:: with SMTP id 33mr13241749pgn.201.1617973115626; Fri, 09 Apr 2021 05:58:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617973115; cv=none; d=google.com; s=arc-20160816; b=ih15vMYLvGOKyvt5ux0667pN9Tnbwb61wQmvlhp9wjFcc1oqRIQMIPzItJL5l8T0k0 TgdkK3jyTXna+VSWlmcryrGgBQzWMN38+Az2Bn9x8bNvF9Rb/SaFDYN8SiqwwTkbN+6F 02iYzZYdDmPDmH8dUjJ37ZNqbYQ0RT1W7vH5wpv8HIqEOvr/9n73Wly14bShLSnuuqj5 ALw3IAbOakz129KRuCSF+EadCzCLR0wMZCM//5AQVyLF5g/qKeQ/7IORisFELyBBPXzB DZmavdcuCyvAP+s5LMPDuG9whycthlV4Unbtj3FDx1HB61SeSpvcLP/7m0vfVPZt3Yzg mHWw== 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 :message-id:date:subject:cc:to:from; bh=3GHzGPVA9LU9vRA85mGieqYq6CBXnUqQZl1zKqF34dA=; b=wGl8TyiFF6vnHeVnYh520pxZgvnTqiQ2SOhEF4Gdff+BVCHNiR4HKnkN3z/ymHp0GC XJN3QjZvs0sKmWWCb3qc8lPP6GbIZHs8+gYsqEV5m72MRvFLShnDKI6jZbvPMlMbE+UC ICPcYjfn+djaz7LqE8FVm0RGV91Y8iC5KF50qMoJoF/M4TPRrm4Sb3p+m+XCMgFDiGoq oPc8cgGhxKnQ8M6TM7qvrt5Le9+OLM4NsSBKIPyWaa+71GQS+JeqNumW/Lp0FGXFZ6GD q/SlDWyIJfxYYzzYwaQ5qUJl5DwVFmnhm26nFcn2kC6VCtIOBvLCQWsJwGr0+31XLEm1 gQTw== 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 n7si2792065pfa.214.2021.04.09.05.58.22; Fri, 09 Apr 2021 05:58:35 -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; 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 S233483AbhDIM56 (ORCPT + 99 others); Fri, 9 Apr 2021 08:57:58 -0400 Received: from hostingweb31-40.netsons.net ([89.40.174.40]:57984 "EHLO hostingweb31-40.netsons.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232855AbhDIM54 (ORCPT ); Fri, 9 Apr 2021 08:57:56 -0400 Received: from [77.244.183.192] (port=65144 helo=melee.fritz.box) by hostingweb31.netsons.net with esmtpa (Exim 4.93) (envelope-from ) id 1lUqhh-0009zd-MX; Fri, 09 Apr 2021 14:57:41 +0200 From: Luca Ceresoli To: linux-clk@vger.kernel.org Cc: Luca Ceresoli , Michael Turquette , Stephen Boyd , linux-kernel@vger.kernel.org, Adam Ford Subject: [PATCH] clk: vc5: fix output disabling when enabling a FOD Date: Fri, 9 Apr 2021 14:57:32 +0200 Message-Id: <20210409125732.376589-1-luca@lucaceresoli.net> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - hostingweb31.netsons.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lucaceresoli.net X-Get-Message-Sender-Via: hostingweb31.netsons.net: authenticated_id: luca+lucaceresoli.net/only user confirmed/virtual account not confirmed X-Authenticated-Sender: hostingweb31.netsons.net: luca@lucaceresoli.net X-Source: X-Source-Args: X-Source-Dir: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5P49V6965, when an output is enabled we enable the corresponding FOD. When this happens for the first time, and specifically when writing register VC5_OUT_DIV_CONTROL in vc5_clk_out_prepare(), all other outputs are stopped for a short time and then restarted. According to Renesas support this is intended: "The reason for that is VC6E has synced up all output function". This behaviour can be disabled at least on VersaClock 6E devices, of which only the 5P49V6965 is currently implemented by this driver. This requires writing bit 7 (bypass_sync{1..4}) in register 0x20..0x50. Those registers are named "Unused Factory Reserved Register", and the bits are documented as "Skip VDDO verification", which does not clearly explain the relation to FOD sync. However according to Renesas support as well as my testing setting this bit does prevent disabling of all clock outputs when enabling a FOD. See "VersaClock ® 6E Family Register Descriptions and Programming Guide" (August 30, 2018), Table 116 "Power Up VDD check", page 58: https://www.renesas.com/us/en/document/mau/versaclock-6e-family-register-descriptions-and-programming-guide Signed-off-by: Luca Ceresoli --- drivers/clk/clk-versaclock5.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/clk/clk-versaclock5.c b/drivers/clk/clk-versaclock5.c index 344cd6c61188..3c737742c2a9 100644 --- a/drivers/clk/clk-versaclock5.c +++ b/drivers/clk/clk-versaclock5.c @@ -69,7 +69,10 @@ #define VC5_FEEDBACK_FRAC_DIV(n) (0x19 + (n)) #define VC5_RC_CONTROL0 0x1e #define VC5_RC_CONTROL1 0x1f -/* Register 0x20 is factory reserved */ + +/* These registers are named "Unused Factory Reserved Registers" */ +#define VC5_RESERVED_X0(idx) (0x20 + ((idx) * 0x10)) +#define VC5_RESERVED_X0_BYPASS_SYNC BIT(7) /* bypass_sync bit */ /* Output divider control for divider 1,2,3,4 */ #define VC5_OUT_DIV_CONTROL(idx) (0x21 + ((idx) * 0x10)) @@ -87,7 +90,6 @@ #define VC5_OUT_DIV_SKEW_INT(idx, n) (0x2b + ((idx) * 0x10) + (n)) #define VC5_OUT_DIV_INT(idx, n) (0x2d + ((idx) * 0x10) + (n)) #define VC5_OUT_DIV_SKEW_FRAC(idx) (0x2f + ((idx) * 0x10)) -/* Registers 0x30, 0x40, 0x50 are factory reserved */ /* Clock control register for clock 1,2 */ #define VC5_CLK_OUTPUT_CFG(idx, n) (0x60 + ((idx) * 0x2) + (n)) @@ -140,6 +142,8 @@ #define VC5_HAS_INTERNAL_XTAL BIT(0) /* chip has PFD requency doubler */ #define VC5_HAS_PFD_FREQ_DBL BIT(1) +/* chip has bits to disable FOD sync */ +#define VC5_HAS_BYPASS_SYNC_BIT BIT(2) /* Supported IDT VC5 models. */ enum vc5_model { @@ -581,6 +585,23 @@ static int vc5_clk_out_prepare(struct clk_hw *hw) unsigned int src; int ret; + /* + * When enabling a FOD, all currently enabled FODs are briefly + * stopped in order to synchronize all of them. This causes a clock + * disruption to any unrelated chips that might be already using + * other clock outputs. Bypass the sync feature to avoid the issue, + * which is possible on the VersaClock 6E family via reserved + * registers. + */ + if (vc5->chip_info->flags & VC5_HAS_BYPASS_SYNC_BIT) { + ret = regmap_update_bits(vc5->regmap, + VC5_RESERVED_X0(hwdata->num), + VC5_RESERVED_X0_BYPASS_SYNC, + VC5_RESERVED_X0_BYPASS_SYNC); + if (ret) + return ret; + } + /* * If the input mux is disabled, enable it first and * select source from matching FOD. @@ -1166,7 +1187,7 @@ static const struct vc5_chip_info idt_5p49v6965_info = { .model = IDT_VC6_5P49V6965, .clk_fod_cnt = 4, .clk_out_cnt = 5, - .flags = 0, + .flags = VC5_HAS_BYPASS_SYNC_BIT, }; static const struct i2c_device_id vc5_id[] = { -- 2.25.1