From patchwork Thu Apr 18 11:12:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Gorski X-Patchwork-Id: 10907055 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 E261F1390 for ; Thu, 18 Apr 2019 11:13:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4951287C8 for ; Thu, 18 Apr 2019 11:13:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B88C728C24; Thu, 18 Apr 2019 11:13:30 +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 D09FE287C8 for ; Thu, 18 Apr 2019 11:13:28 +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=fhjlEcE1MaoLeYrjF7i9q+BpIkXfEplB5CL5dkqDfQk=; b=swtSx1eL2BhhS/+HdfPJqNNkuJ nli1hcOau99gGTyGUvoiU5qp9BxQvH4PcF/ohJ/oKyKqlL4eGculDzWCORatJxSpnxsVBbGGUPg5y qH+2lUDAIDA/tGSLp90PJoQWkxpmbNTtvyjGcsnEwdPzDGR5ZveqyZXB4G0VPvJDsC4EvH2f1FnM+ mg9hsyCibWUKzRG/SLbgo87gb0XPiSiJyp9C5AaAOx2e3Txi5wuPXI3GE2PAZasuLXjWJCcA9kx7n ZeZwhEWcgz3XPrvYpFqpxmKFSKDQWHRr9cJ3lpRbZ7VuxhvbEpxmCK1ZuVxGvne7nulDkrceQ/HYL m2annvOA==; 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 1hH4yp-0007xA-Pi; Thu, 18 Apr 2019 11:13:23 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hH4xr-0006fW-Ca; Thu, 18 Apr 2019 11:12:30 +0000 Received: by mail-wm1-x341.google.com with SMTP id v14so2434112wmf.2; Thu, 18 Apr 2019 04:12:23 -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=LWVDRq3wPJtqLVuL8GILzgU6+gx9+RFydNdVEdr68+U=; b=SoZ60qYeBe4qwv1VMxxgH13aew4p66WqDIfl03PxZ+J05obKjr+9jLEObRmpDBLHsb hNFYIf+9KO4WhjJcqRO4Y04q4jlwIT6vJY3gCrG4eVyBHJklVx+n7EFoxwtd6q1yJz1o 38IWgk+eGK5VHghpm8QaRDsX+3gLjT625J92LgcIWSiM8pSm9A5XiSRNM7if6AOpaICc yp7X00DDoDip2BkA9kna2VA+JYJ4vTUaEw8llyqNz2SVo3/hGGP4tZqV5y0wJxKd3O/H PvXEih0Y2UvVlxriEUWcDBm3oW5ShknpkVwruitBQEGvG3xZlSfhRsG2x5Fa4+3C6g3f IpBQ== 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=LWVDRq3wPJtqLVuL8GILzgU6+gx9+RFydNdVEdr68+U=; b=FRPSS7fq1EF6PHVPK9rt9mfkNlaCeFfrYKS1xQZGDEfrGGBko6PDEH/jXVXHlNKJmm sJ+gwPQwpbU8AsgRskWXRTa+CGCDiyzqb4gkicLvKpBjBx5tLyWNr9+miZGGqj85J2RR k3EFLyC1Bnt91KMCYt5ypC6coeqo1ooGRGGQ1b+vD77TrlhOvxUNpTKKOaHYW6mLG2Hm +ffR20AUt9fdH6XGBOqK1OEZqwTjTOg5JxlfV36tRSjCuysYU+eSV2CCcAX4RznN0i/a JmN+E88fr7Q2TukeFdl8adJHm3q5Dd86j79ZqHm9WnbRr2MTni09Ni9v5jz7NTckxmu4 67iw== X-Gm-Message-State: APjAAAXu5DZoX+TFJeqStYTl9zOjg2RY/W8y1Em58gLd6v4KBmVlrfvI b/iaR5cVuBrYciJmEM4U4Ug= X-Google-Smtp-Source: APXvYqwKd5imwQ9tx9WLxEfWpd7Dn8I3vL36mwTDaErx27W2X8tFwiWgG4+QiGXq0JcOtMzgpkFrXQ== X-Received: by 2002:a1c:e1c5:: with SMTP id y188mr2663908wmg.39.1555585941683; Thu, 18 Apr 2019 04:12:21 -0700 (PDT) Received: from localhost.localdomain ([2001:470:9e39::64]) by smtp.gmail.com with ESMTPSA id z63sm2005594wme.30.2019.04.18.04.12.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Apr 2019 04:12:21 -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 V3 5/8] clk: mux: add explicit big endian support Date: Thu, 18 Apr 2019 13:12:08 +0200 Message-Id: <20190418111211.10474-6-jonas.gorski@gmail.com> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20190418111211.10474-1-jonas.gorski@gmail.com> References: <20190418111211.10474-1-jonas.gorski@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190418_041223_892229_3F987FCF X-CRM114-Status: GOOD ( 13.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 mux clocks. Signed-off-by: Jonas Gorski --- V2 -> V3: * drop unneeded else in clk_mux_readl V1 -> V2: * switch from global to local flag drivers/clk/clk-mux.c | 22 +++++++++++++++++++--- include/linux/clk-provider.h | 4 ++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/clk/clk-mux.c b/drivers/clk/clk-mux.c index 2ad2df2e8909..61ad331b7ff4 100644 --- a/drivers/clk/clk-mux.c +++ b/drivers/clk/clk-mux.c @@ -23,6 +23,22 @@ * parent - parent is adjustable through clk_set_parent */ +static inline u32 clk_mux_readl(struct clk_mux *mux) +{ + if (mux->flags & CLK_MUX_BIG_ENDIAN) + return ioread32be(mux->reg); + + return clk_readl(mux->reg); +} + +static inline void clk_mux_writel(struct clk_mux *mux, u32 val) +{ + if (mux->flags & CLK_MUX_BIG_ENDIAN) + iowrite32be(val, mux->reg); + else + clk_writel(val, mux->reg); +} + int clk_mux_val_to_index(struct clk_hw *hw, u32 *table, unsigned int flags, unsigned int val) { @@ -73,7 +89,7 @@ static u8 clk_mux_get_parent(struct clk_hw *hw) struct clk_mux *mux = to_clk_mux(hw); u32 val; - val = clk_readl(mux->reg) >> mux->shift; + val = clk_mux_readl(mux) >> mux->shift; val &= mux->mask; return clk_mux_val_to_index(hw, mux->table, mux->flags, val); @@ -94,12 +110,12 @@ static int clk_mux_set_parent(struct clk_hw *hw, u8 index) if (mux->flags & CLK_MUX_HIWORD_MASK) { reg = mux->mask << (mux->shift + 16); } else { - reg = clk_readl(mux->reg); + reg = clk_mux_readl(mux); reg &= ~(mux->mask << mux->shift); } val = val << mux->shift; reg |= val; - clk_writel(reg, mux->reg); + clk_mux_writel(mux, reg); if (mux->lock) spin_unlock_irqrestore(mux->lock, flags); diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 9df78e3fb62b..f82cda41e1a8 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -510,6 +510,9 @@ void clk_hw_unregister_divider(struct clk_hw *hw); * .get_parent clk_op. * CLK_MUX_ROUND_CLOSEST - Use the parent rate that is closest to the desired * frequency. + * CLK_MUX_BIG_ENDIAN - By default little endian register accesses are used for + * the mux register. Setting this flag makes the register accesses big + * endian. */ struct clk_mux { struct clk_hw hw; @@ -528,6 +531,7 @@ struct clk_mux { #define CLK_MUX_HIWORD_MASK BIT(2) #define CLK_MUX_READ_ONLY BIT(3) /* mux can't be changed */ #define CLK_MUX_ROUND_CLOSEST BIT(4) +#define CLK_MUX_BIG_ENDIAN BIT(5) extern const struct clk_ops clk_mux_ops; extern const struct clk_ops clk_mux_ro_ops;