From patchwork Thu Sep 29 08:35:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajendra Nayak X-Patchwork-Id: 9355917 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 B2D8B600C8 for ; Thu, 29 Sep 2016 08:38:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A49F029900 for ; Thu, 29 Sep 2016 08:38:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9981729915; Thu, 29 Sep 2016 08:38:32 +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 C583329910 for ; Thu, 29 Sep 2016 08:38:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932221AbcI2IhO (ORCPT ); Thu, 29 Sep 2016 04:37:14 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:56903 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755455AbcI2Igq (ORCPT ); Thu, 29 Sep 2016 04:36:46 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id E2D7C61888; Thu, 29 Sep 2016 08:36:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1475138204; bh=l9lrJKhT5nNbNFTPcmp5fB3cQdpFSwx5rTMSjB0w9nc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BMdVCpvLRYpLP3fysmnfKzvmtsQ2t7iDNm64daoNkSclzNuhTYG5WZLbrVqmPvOFU zhav4n8zQRVSJcidfUHpnUA3wduAFqtbXVuATmIvqIBv1tk8azk+8EYpsFgi1PcSUA az4p80xeWXx0XBNqYYwP2qQF2cLF7ltV3plpq30Y= Received: from blr-ubuntu-34.ap.qualcomm.com (unknown [202.46.23.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: rnayak@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 5AF4A617E6; Thu, 29 Sep 2016 08:36:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1475138203; bh=l9lrJKhT5nNbNFTPcmp5fB3cQdpFSwx5rTMSjB0w9nc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R9ka5u2RH8pv1v3tJh+m4WPfCGf3rh4kVNUw/Y8KL9Yiu/ZVMfcJneH5d6/u2brmM /+GT8rdWI4msxL4XuMLteTmFaVIQV5Xhj10igsNwHXrxhy2VIo97VKeqs8SJX8rHyb 6nNDl6xUQ8JB669/dVu3twrnAlj8ju6NWMdQi/LA= DMARC-Filter: OpenDMARC Filter v1.3.1 smtp.codeaurora.org 5AF4A617E6 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=pass smtp.mailfrom=rnayak@codeaurora.org From: Rajendra Nayak To: sboyd@codeaurora.org, mturquette@baylibre.com Cc: linux-clk@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, tdas@codeaurora.org, Rajendra Nayak Subject: [PATCH v3 09/11] clk: qcom: Add support for table based lookups in clk-regmap-mux Date: Thu, 29 Sep 2016 14:05:50 +0530 Message-Id: <1475138152-859-10-git-send-email-rnayak@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1475138152-859-1-git-send-email-rnayak@codeaurora.org> References: <1475138152-859-1-git-send-email-rnayak@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 Add support to pass a table of values for parent selection similar to whats done in clk-mux Signed-off-by: Rajendra Nayak --- drivers/clk/qcom/clk-regmap-mux.c | 13 +++++++++++++ drivers/clk/qcom/clk-regmap-mux.h | 1 + 2 files changed, 14 insertions(+) diff --git a/drivers/clk/qcom/clk-regmap-mux.c b/drivers/clk/qcom/clk-regmap-mux.c index cae3071..14a2af5 100644 --- a/drivers/clk/qcom/clk-regmap-mux.c +++ b/drivers/clk/qcom/clk-regmap-mux.c @@ -28,6 +28,7 @@ static u8 mux_get_parent(struct clk_hw *hw) struct clk_regmap_mux *mux = to_clk_regmap_mux(hw); struct clk_regmap *clkr = to_clk_regmap(hw); unsigned int mask = GENMASK(mux->width - 1, 0); + int num_parents = clk_hw_get_num_parents(hw); unsigned int val; regmap_read(clkr->regmap, mux->reg, &val); @@ -35,6 +36,15 @@ static u8 mux_get_parent(struct clk_hw *hw) val >>= mux->shift; val &= mask; + if (mux->table) { + int i; + + for (i = 0; i < num_parents; i++) + if (mux->table[i] == val) + return i; + return -EINVAL; + } + return val; } @@ -45,6 +55,9 @@ static int mux_set_parent(struct clk_hw *hw, u8 index) unsigned int mask = GENMASK(mux->width + mux->shift - 1, mux->shift); unsigned int val; + if (mux->table) + index = mux->table[index]; + val = index; val <<= mux->shift; diff --git a/drivers/clk/qcom/clk-regmap-mux.h b/drivers/clk/qcom/clk-regmap-mux.h index 5cec761..310804e 100644 --- a/drivers/clk/qcom/clk-regmap-mux.h +++ b/drivers/clk/qcom/clk-regmap-mux.h @@ -21,6 +21,7 @@ struct clk_regmap_mux { u32 reg; u32 shift; u32 width; + u32 *table; struct clk_regmap clkr; };