From patchwork Sun Jul 9 13:28:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 9831795 X-Patchwork-Delegate: sboyd@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B5521604D9 for ; Sun, 9 Jul 2017 13:28:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A443927FB7 for ; Sun, 9 Jul 2017 13:28:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91865283C4; Sun, 9 Jul 2017 13:28:42 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40B17283C5 for ; Sun, 9 Jul 2017 13:28:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752235AbdGIN2m (ORCPT ); Sun, 9 Jul 2017 09:28:42 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:34208 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751817AbdGIN2k (ORCPT ); Sun, 9 Jul 2017 09:28:40 -0400 Received: by mail-wr0-f196.google.com with SMTP id k67so18735553wrc.1; Sun, 09 Jul 2017 06:28:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=THgO3+JY2CQ4N6ZBxjstLBCOeIMtQGvwwnV5AR97QCM=; b=TXy3h6eZgWCtv23/QC1pJfnGg3xKzVAYnL2eeSpPsZRUyvgmvYIJwBWptz90ogwbjX AdR1xYKZH497Kn2OV8Lg0YZLKQnzTnZnsjp+lyshIyf9WKXD49Q5LkVnb068TUqIWfiW CdpNXcycNZwh36UdHZE/P7wrEe8dS9h1Aw8gPGKNYLD3IWXcsjM5WBylTaQ53iFvkoAl kTKnATDM2nKsOiD+MXCHXZzuC28bcgru2PVnJNWRg68WlCCu5QTldBF20MVoPgdkcDrT 0rgWRwxGLTeRNhjcNuVqRBtEjkKJhwIgpGpnLdrmetyxh93P+55joeKYJUl7/QntdnHS /AeQ== 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:in-reply-to :references; bh=THgO3+JY2CQ4N6ZBxjstLBCOeIMtQGvwwnV5AR97QCM=; b=qn77Bvc9/yiCk6KFX5Lmjncae+66flvzCQko85c4G5Xqp+ykSHykOGsqIGRBZvxM9X HovkI5HYFyF7nOiBVoixAGEYTkdhJftaDadtnQKsFA5glDzDs1nkRnYsWLmq/BDmQSwY Z8/UpKJhtFgY6NPb/k2KnLS9bRyscobbZTd/OqrFe6yKPODeEtSRnHyw94a+/TsKkVG0 91tWXNN7NOOx8ms+cLfgu/ZzxrMjLj5Xh6ckMdugO0PD9hiGpmKu1qRIQyCzSZKDdy7F Y1uUkFUFTUnzhbqeWfjlBRQXV0o+mgEpgE146DXZuuzT/raTvfRwmHGF1qlU47/fCiIa Kp+g== X-Gm-Message-State: AIVw111tClp4wgr4y24F06jU0abdEtaiotPOLPKu1Mrz0Dh7c0wFFOZN p2rfJ71xxer9Xa19xX0= X-Received: by 10.28.111.84 with SMTP id k81mr4353321wmc.67.1499606919048; Sun, 09 Jul 2017 06:28:39 -0700 (PDT) Received: from kurokawa.lan (ip-86-49-107-50.net.upcbroadband.cz. [86.49.107.50]) by smtp.gmail.com with ESMTPSA id o197sm8482585wmd.9.2017.07.09.06.28.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Jul 2017 06:28:38 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: linux-clk@vger.kernel.org Cc: Marek Vasut , Stephen Boyd , Alexey Firago , Michael Turquette , Laurent Pinchart , linux-renesas-soc@vger.kernel.org Subject: [PATCH V3 4/8] clk: vc5: Configure the output buffer input mux on prepare Date: Sun, 9 Jul 2017 15:28:10 +0200 Message-Id: <20170709132814.2339-4-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170709132814.2339-1-marek.vasut+renesas@gmail.com> References: <20170709132814.2339-1-marek.vasut+renesas@gmail.com> Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The output buffer input mux can be configured in either of three states -- disabled, input from FOD, input from previous output. Once the .prepare() callback of the output buffer is called, the output buffer input mux must be set to either input from FOD or input from previous output, it cannot be set to Disabled anymore or the output won't work. Default to the input from FOD if the output buffer input mux was Disabled and the .prepare() was called on it. Note that we do not set the output buffer input mux back to Disabled in the .unprepare() callback as there is no obvious benefit of doing so. We disable the entire output buffer in the .unprepare() callback already. Signed-off-by: Marek Vasut Cc: Stephen Boyd Cc: Alexey Firago Cc: Michael Turquette Cc: Laurent Pinchart Cc: linux-renesas-soc@vger.kernel.org Tested-by: Laurent Pinchart on Salvator-XS with the display LVDS output. --- V2: None V3: None --- drivers/clk/clk-versaclock5.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/clk/clk-versaclock5.c b/drivers/clk/clk-versaclock5.c index 248689d89632..7bdfd34e8280 100644 --- a/drivers/clk/clk-versaclock5.c +++ b/drivers/clk/clk-versaclock5.c @@ -507,6 +507,25 @@ static int vc5_clk_out_prepare(struct clk_hw *hw) { struct vc5_hw_data *hwdata = container_of(hw, struct vc5_hw_data, hw); struct vc5_driver_data *vc5 = hwdata->vc5; + const u8 mask = VC5_OUT_DIV_CONTROL_SELB_NORM | + VC5_OUT_DIV_CONTROL_SEL_EXT | + VC5_OUT_DIV_CONTROL_EN_FOD; + unsigned int src; + int ret; + + /* + * If the input mux is disabled, enable it first and + * select source from matching FOD. + */ + regmap_read(vc5->regmap, VC5_OUT_DIV_CONTROL(hwdata->num), &src); + if ((src & mask) == 0) { + src = VC5_OUT_DIV_CONTROL_RESET | VC5_OUT_DIV_CONTROL_EN_FOD; + ret = regmap_update_bits(vc5->regmap, + VC5_OUT_DIV_CONTROL(hwdata->num), + mask | VC5_OUT_DIV_CONTROL_RESET, src); + if (ret) + return ret; + } /* Enable the clock buffer */ regmap_update_bits(vc5->regmap, VC5_CLK_OUTPUT_CFG(hwdata->num, 1),