From patchwork Sat Jul 1 20:04:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 9820977 X-Patchwork-Delegate: geert@linux-m68k.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 0E05D603F2 for ; Sat, 1 Jul 2017 20:05:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F13CB2846A for ; Sat, 1 Jul 2017 20:05:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4FA92845D; Sat, 1 Jul 2017 20:05:45 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham 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 782C3284C7 for ; Sat, 1 Jul 2017 20:05:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752012AbdGAUFo (ORCPT ); Sat, 1 Jul 2017 16:05:44 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:36733 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751996AbdGAUFl (ORCPT ); Sat, 1 Jul 2017 16:05:41 -0400 Received: by mail-wr0-f194.google.com with SMTP id 77so41606910wrb.3; Sat, 01 Jul 2017 13:05:35 -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=ZNTeORMDa45ryT/YTBBdQe5Z0xTWzc6LZkpN1a4T9Eo=; b=JAF7xUWxO/DJdj1daHlkdN6rviQn6rQj0LJrgn3tIqdiq14c4FI7LbWZyhUj9HOBik JMmYjn0/2HI35i+ktHCmegO0qPUZ2zCe+BjsYzIoGlhvghTHBMNOxXAkfK8jECThVRmv IAMkeQBp0sI4w4wCs9vDwVN//+Yake10pjEn4Je6EOD3bTHSLuzatZnu4lWE9e96ZTcl GGu7voX2ikAYpdbTPAh7iUxG/SYPx9kTxKLLA2DL6rEkPj9trqZcld29/6KPRIMd7O+X LUhJ3ZV2JkNFL9G5ru0k5MKBNDOufgM5brzm+vW3eo60pjLeb5oxt7mPyrcN+RT87xiT Vm+w== 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=ZNTeORMDa45ryT/YTBBdQe5Z0xTWzc6LZkpN1a4T9Eo=; b=GucgBpNFyRMj4qG71m8EsHW7SA9ucGR0Qr2F0jyRRg01URU6TlcXTECJ4chCjzbNxE YkvuF1idzPtBw6lvSMuql7nvSjb1ALGbDerqrHGn7/DcRyeqZZGAtCqo7A+w1YR1e2FK AihDCSMHTisl/TSChdMGhiuo1PkgkDkkgqg/XqQyKD2gcT8zHkqM1xAF7iUyudFCf1v6 TsEnFy06BLQcyZ1nAX9SU4dlgBfGIOsd/XCJOWM0ttpV1/mOJCCYfipvBMOv0hLwMG10 E1Vy7enFeFJhh3v89JgJBVyG7K+0OYww2FmlYVW1wCzGICNMHjnFycim5LOTfQ0TtoFm cvEA== X-Gm-Message-State: AKS2vOybDOUg37ZTDTAbTDQii9JdXtmW4U6PZGAdX9Vc1Lso5EXdWZO7 fg8V83HyjG/8tgJWgCQ= X-Received: by 10.223.170.150 with SMTP id h22mr27093355wrc.140.1498939534794; Sat, 01 Jul 2017 13:05:34 -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 s30sm18150137wrc.13.2017.07.01.13.05.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Jul 2017 13:05:34 -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 4/8] clk: vc5: Configure the output buffer input mux on prepare Date: Sat, 1 Jul 2017 22:04:54 +0200 Message-Id: <20170701200459.11505-4-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170701200459.11505-1-marek.vasut+renesas@gmail.com> References: <20170701200459.11505-1-marek.vasut+renesas@gmail.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@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. --- 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),