From patchwork Mon Apr 15 10:10:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Gorski X-Patchwork-Id: 10900465 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0A3E0922 for ; Mon, 15 Apr 2019 10:11:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E26AF28587 for ; Mon, 15 Apr 2019 10:11:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DFB1428892; Mon, 15 Apr 2019 10:11:58 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 854F2288BA for ; Mon, 15 Apr 2019 10:11:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=aK9+snJPPBdvOK7ICYYoA0NBOT4VZvvcpU8a9XzvyqY=; b=oBb4KrUJSVqfDF7XwNIODm7DW5 v1cIk+hS+/3e/dvXszG46w0SMUL9/EJGwxGi2Xb/lZrsJG1cSNEaYml0SEhDnhPzhovaYgRMrJXVJ 0L1ILocZo/DoAcAG8RpqXfyuCC6/KLFvdMQtgZ61MSyxb7Twm6nn0DPOvmAG353BZdeZimBoNgmIO hKspPaFMNEbOsEeERaMtSRgNbc2scOGhmsi+MsdOdnOkyn+UQ/7SSGNRUofwXxUVsmpR9eutW5fJQ q5OoVr9wt80weT5duc+ccQ8f8XbfRkV1FLH1hGO6stik085LHc6XTntXML1tyObyBxtwc+ZChrhpB FkqnHGZA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hFyah-0004rG-7y; Mon, 15 Apr 2019 10:11:55 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hFyZn-0003mM-Gy; Mon, 15 Apr 2019 10:11:03 +0000 Received: by mail-wm1-x344.google.com with SMTP id h18so19631215wml.1; Mon, 15 Apr 2019 03:10:59 -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=OdocwXwJ3rh4kwfXC02eb0oWwurnzLR9MAj+DB02QVg=; b=unVegUezf3xp5NAJ3uaaFz2qj1jvI7tB9oNDrgZUIg3ywpAxWLOr1z8t3mHOXUqUB3 ni6AtLJTn3FK/ozoiLTJSQ0MTx9xY3NgwZb4LpZ+HssMdoKX/IUzPcyg++RFKz02069V JV6IVqMrSGl87D3L0dW4Bx832kjL7/RJGvEqNDxO+Zsi41aFBdzqEe8kTw2ZNaBhv0X3 RCD9UMLh/II2owi+ncMQFtPW9465GQVwF7DNgNK+3gKo+ygzx57N/+7SpXCvR3wvT/m6 nCGNPIEp39TdRYKfA3nPvCRuIds7NI7VBDu3Ae/yXYsgJQnrBAPCMqqJos+eHoYKA9Ui EpkQ== 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=OdocwXwJ3rh4kwfXC02eb0oWwurnzLR9MAj+DB02QVg=; b=dtywcUPa5HMwBix8kalyMylhuHLHsiufWvETOJRShDjaZ94qKTezxPi9yUbqGL98Qs Cdd9l0C049Ar3y0CWHFRp2sZ5Rfh7uN7q+0NemexsvXhiaflMB3H3MrfrNoAS4svOK+f vzf9vEjSc36QTXuy9TxNvqA8xKuu1J/K7gb2D3cG3k5dyEGljsrkuoq6TIVH2LirJHqZ Jo5ne7tMTxjkCEMNfCKsOEGER8kct+r76pNJFrk1TRshweUCaKi2ci4mtkIWfkHsCYes jZANo7sgKU0wetFOsJGYsJLdrnrgSOfRSjAj6JB2lsm86e2uhK8CobKMYhIE5uPCTs+K qjnw== X-Gm-Message-State: APjAAAUIFzeXahnei+3nr8Zn47fRKEPmc45Suq2aBo6y02L+zi05Oarz mAKixpBPxjadVfH/G3PGyQM= X-Google-Smtp-Source: APXvYqxQ8qfQOyCV+Mgmqtj6HKEKkrAY4bniNY5tMWURoN0nFwuxCZuqpTFJI+y9FSrpJlXQV9gxpw== X-Received: by 2002:a7b:cf2b:: with SMTP id m11mr19829090wmg.56.1555323058192; Mon, 15 Apr 2019 03:10:58 -0700 (PDT) Received: from localhost.localdomain ([2001:470:9e39::64]) by smtp.gmail.com with ESMTPSA id d6sm11592214wrp.9.2019.04.15.03.10.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Apr 2019 03:10:57 -0700 (PDT) From: Jonas Gorski To: linux-clk@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-tegra@vger.kernel.org Subject: [PATCH RFT V2 4/8] clk: multiplier: add explicit big endian support Date: Mon, 15 Apr 2019 12:10:42 +0200 Message-Id: <20190415101046.5872-5-jonas.gorski@gmail.com> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20190415101046.5872-1-jonas.gorski@gmail.com> References: <20190415101046.5872-1-jonas.gorski@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190415_031100_129239_FDE88CE6 X-CRM114-Status: GOOD ( 14.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter De Schrijver , Fabio Estevam , Heiko Stuebner , Stephen Boyd , Benjamin Herrenschmidt , Michael Turquette , Michal Simek , Jonathan Hunter , Prashant Gaikwad , Paul Mackerras , NXP Linux Team , Pengutronix Kernel Team , Michael Ellerman , Thierry Reding , Anatolij Gustschin , Shawn Guo , Sascha Hauer MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add a clock specific flag to switch register accesses to big endian, to allow runtime configuration of big endian multiplier clocks. Signed-off-by: Jonas Gorski --- V1 -> V2: * newly added patch drivers/clk/clk-multiplier.c | 22 +++++++++++++++++++--- include/linux/clk-provider.h | 4 ++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/clk/clk-multiplier.c b/drivers/clk/clk-multiplier.c index 3c86f859c199..fb032f7dd407 100644 --- a/drivers/clk/clk-multiplier.c +++ b/drivers/clk/clk-multiplier.c @@ -11,6 +11,22 @@ #include #include +static inline u32 clk_mult_readl(struct clk_multiplier *mult) +{ + if (mult->flags & CLK_MULTIPLIER_BIG_ENDIAN) + return ioread32be(mult->reg); + else + return clk_readl(mult->reg); +} + +static inline void clk_mult_writel(struct clk_multiplier *mult, u32 val) +{ + if (mult->flags & CLK_MULTIPLIER_BIG_ENDIAN) + iowrite32be(val, mult->reg); + else + clk_writel(val, mult->reg); +} + static unsigned long __get_mult(struct clk_multiplier *mult, unsigned long rate, unsigned long parent_rate) @@ -27,7 +43,7 @@ static unsigned long clk_multiplier_recalc_rate(struct clk_hw *hw, struct clk_multiplier *mult = to_clk_multiplier(hw); unsigned long val; - val = clk_readl(mult->reg) >> mult->shift; + val = clk_mult_readl(mult) >> mult->shift; val &= GENMASK(mult->width - 1, 0); if (!val && mult->flags & CLK_MULTIPLIER_ZERO_BYPASS) @@ -118,10 +134,10 @@ static int clk_multiplier_set_rate(struct clk_hw *hw, unsigned long rate, else __acquire(mult->lock); - val = clk_readl(mult->reg); + val = clk_mult_readl(mult); val &= ~GENMASK(mult->width + mult->shift - 1, mult->shift); val |= factor << mult->shift; - clk_writel(val, mult->reg); + clk_mult_writel(mult, val); if (mult->lock) spin_unlock_irqrestore(mult->lock, flags); diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 8576c2dbc639..9df78e3fb62b 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -667,6 +667,9 @@ void clk_hw_unregister_fractional_divider(struct clk_hw *hw); * leaving the parent rate unmodified. * CLK_MULTIPLIER_ROUND_CLOSEST - Makes the best calculated divider to be * rounded to the closest integer instead of the down one. + * CLK_MULTIPLIER_BIG_ENDIAN - By default little endian register accesses are + * used for the multiplier register. Setting this flag makes the register + * accesses big endian. */ struct clk_multiplier { struct clk_hw hw; @@ -681,6 +684,7 @@ struct clk_multiplier { #define CLK_MULTIPLIER_ZERO_BYPASS BIT(0) #define CLK_MULTIPLIER_ROUND_CLOSEST BIT(1) +#define CLK_MULTIPLIER_BIG_ENDIAN BIT(2) extern const struct clk_ops clk_multiplier_ops;