From patchwork Thu Jun 29 10:18:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 9816343 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 DA6DE6020A for ; Thu, 29 Jun 2017 10:19:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D05F228697 for ; Thu, 29 Jun 2017 10:19:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1F50285D9; Thu, 29 Jun 2017 10:19:40 +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 6B575285D9 for ; Thu, 29 Jun 2017 10:19:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751936AbdF2KTi (ORCPT ); Thu, 29 Jun 2017 06:19:38 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:36412 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752551AbdF2KTh (ORCPT ); Thu, 29 Jun 2017 06:19:37 -0400 Received: by mail-wr0-f195.google.com with SMTP id 77so36340180wrb.3; Thu, 29 Jun 2017 03:19:36 -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=tGawph/r0nZinqvWmWHA7m2TC8/R4GIrOArbLomgoSk=; b=KvBz/KwkCtF5JbrX3kGI7XJJXNbNx+NLdR2weKH9k7sTOpTfx1wOdetcLn9SwJZ5fe b+O22c0pbcZ2095Jy/rQ/acF3Y2hFYLwXPunChMpj/e9qOF9y6WqypSLntzn+amuWdUW lUX/GHAvUgRYLRaceQv7UCBnWVjCEYMx6fVJ0FMtEPDA8apFR4xzhLdUiS5uXlfbYb3x Jb4ECHGmaU0V6W6EmjIQXfKUa0OczwbKiQ1Bvsksj3RlelgnMIaz24Qx9qUHV0NZ8Z34 PtF36SSdeN98OCfK3mwDiE3oZ+gRk4xAX5sMvjf59M9ENBlQGwifhJ/4I8fwT7Y65rsC tgfw== 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=tGawph/r0nZinqvWmWHA7m2TC8/R4GIrOArbLomgoSk=; b=I48lLcNOsbQ4T7Xafh7/+myqzbHsjMtTrdtGNfvHZgWVj0BAww/t3VxBvgJSOAFCJx bH3JppL7+oiA5Or+IgmyuDI3mig9CiiINAKe7tT0lme7uIXBU52EG9QWqJPnFrsKw81T KP/ONqGH/XxcPZfVXhBWhPLNAyWay7LWgIR3EK5K/6wPhJdfTJb31Rl6TRh6rUgN7W25 93fSW1l1CwB4doScYkg6iLmWW1smn80ZkXZzmOkbMpnAK4YveauBqfTkHaZ2NM0d3HDr 2avcMgTnwViDKNlYefyHYH+G+TY6QqhTI+voPRKgoSXW4ZKFpEZ1cAv9kApmLytLRZeH Trhg== X-Gm-Message-State: AKS2vOzG/zJwDbu7Gw8UWcfYgv2Vgv0L8X95FM1K5XYj5U/b6xquA7nt qGmZBx1aNOgOB6DmFCE= X-Received: by 10.223.171.181 with SMTP id s50mr11706008wrc.129.1498731575343; Thu, 29 Jun 2017 03:19:35 -0700 (PDT) Received: from chi.lan (cst-prg-169-255.cust.vodafone.cz. [46.135.169.255]) by smtp.gmail.com with ESMTPSA id t74sm7623653wmt.19.2017.06.29.03.19.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jun 2017 03:19:34 -0700 (PDT) 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: Thu, 29 Jun 2017 12:18:47 +0200 Message-Id: <20170629101851.23972-4-marek.vasut@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170629101851.23972-1-marek.vasut@gmail.com> References: <20170629101851.23972-1-marek.vasut@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 From: Marek Vasut 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 --- 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 766fcc5cc0b3..a5256f793627 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),