From patchwork Thu Sep 28 17:50:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhishek Sahu X-Patchwork-Id: 9976523 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 6CABC60365 for ; Thu, 28 Sep 2017 17:51:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D925296DE for ; Thu, 28 Sep 2017 17:51:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4FA12296D8; Thu, 28 Sep 2017 17:51:51 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 9C0A5296D8 for ; Thu, 28 Sep 2017 17:51:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752380AbdI1Rvt (ORCPT ); Thu, 28 Sep 2017 13:51:49 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:51166 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752002AbdI1Rvp (ORCPT ); Thu, 28 Sep 2017 13:51:45 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 62CD660CF1; Thu, 28 Sep 2017 17:51:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1506621104; bh=W0rEccf+lSBKpCeAzeeVrH6uaOWCAqvb5SoDlWEahdg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aUfCG/HuQmVWN2IgxaYKuUt8oIf8nz5e0KNrQUjD3B+TDzIXWEjBYlB8ze640fukm qCn+rlwSv058gtDJQcvwFfsWdmXraffOMxdiZPpMFby0n5l05a1sWc/WXEQufmyjXN 61KiFc0zWKDvQV6OowGnGDHCHaLh9G7iCByQ3BoI= Received: from absahu-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: absahu@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 1C1A860CA5; Thu, 28 Sep 2017 17:51:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1506621103; bh=W0rEccf+lSBKpCeAzeeVrH6uaOWCAqvb5SoDlWEahdg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L+zc5fLRVoU+LngvoGR6rnkdP/aWqgEKN/DeSQyu02IavqD6c6Sjh9gEHGdGze+Xs 9MINNTb1BjanjHrAx5OHOj6Oe5uhQXrIZPnp7J9Lq/9c1cOhxbg03YvW9W7VkIz9ot WhJU98dyEYkVqq5v7GwhyzN9qgaxBpUUr22y65OE= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 1C1A860CA5 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=absahu@codeaurora.org From: Abhishek Sahu To: Stephen Boyd , Michael Turquette Cc: Andy Gross , David Brown , Rajendra Nayak , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Abhishek Sahu Subject: [PATCH 12/13] clk: qcom: support for 2 bit PLL post divider Date: Thu, 28 Sep 2017 23:20:49 +0530 Message-Id: <1506621050-10129-13-git-send-email-absahu@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506621050-10129-1-git-send-email-absahu@codeaurora.org> References: <1506621050-10129-1-git-send-email-absahu@codeaurora.org> 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 Current PLL driver only supports 4 bit PLL post divider so modified the PLL divider operations to support 2 bit PLL post divider. Signed-off-by: Abhishek Sahu --- drivers/clk/qcom/clk-alpha-pll.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/clk/qcom/clk-alpha-pll.c b/drivers/clk/qcom/clk-alpha-pll.c index c682387..62b84fa 100644 --- a/drivers/clk/qcom/clk-alpha-pll.c +++ b/drivers/clk/qcom/clk-alpha-pll.c @@ -39,7 +39,6 @@ # define PLL_LOCK_DET BIT(31) # define PLL_POST_DIV_SHIFT 8 -# define PLL_POST_DIV_MASK 0xf # define PLL_ALPHA_EN BIT(24) # define PLL_ALPHA_MODE BIT(25) # define PLL_VCO_SHIFT 20 @@ -822,7 +821,7 @@ static int clk_alpha_pll_hwfsm_is_enabled(struct clk_hw *hw) &ctl); ctl >>= PLL_POST_DIV_SHIFT; - ctl &= PLL_POST_DIV_MASK; + ctl &= BIT(pll->width) - 1; return parent_rate >> fls(ctl); } @@ -836,13 +835,26 @@ static int clk_alpha_pll_hwfsm_is_enabled(struct clk_hw *hw) { } }; +static const struct clk_div_table clk_alpha_2bit_div_table[] = { + { 0x0, 1 }, + { 0x1, 2 }, + { 0x3, 4 }, + { } +}; + static long clk_alpha_pll_postdiv_round_rate(struct clk_hw *hw, unsigned long rate, unsigned long *prate) { struct clk_alpha_pll_postdiv *pll = to_clk_alpha_pll_postdiv(hw); + const struct clk_div_table *table; - return divider_round_rate(hw, rate, prate, clk_alpha_div_table, + if (pll->width == 2) + table = clk_alpha_2bit_div_table; + else + table = clk_alpha_div_table; + + return divider_round_rate(hw, rate, prate, table, pll->width, CLK_DIVIDER_POWER_OF_TWO); } @@ -857,7 +869,7 @@ static int clk_alpha_pll_postdiv_set_rate(struct clk_hw *hw, unsigned long rate, return regmap_update_bits(pll->clkr.regmap, pll->offset + pll_user_ctl(pll->pll_type), - PLL_POST_DIV_MASK << PLL_POST_DIV_SHIFT, + (BIT(pll->width) - 1) << PLL_POST_DIV_SHIFT, div << PLL_POST_DIV_SHIFT); }