From patchwork Mon Apr 15 10:10:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Gorski X-Patchwork-Id: 10900467 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 B5D86922 for ; Mon, 15 Apr 2019 10:12:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C311288CF for ; Mon, 15 Apr 2019 10:12:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6FD622892B; Mon, 15 Apr 2019 10:12:14 +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 7F11B288AE for ; Mon, 15 Apr 2019 10:12:09 +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=dy8/t36FDbAlo0b127qNwEZDyUK7mqoGIjnRWGkGktU=; b=pEHfB6zL42qZN9sqStMCJydk8u uoyOCGo3B1QXXPz6HSkRPJByIYcGbV75XnzH/R+PQlXmqd3vG1BXMac3ARCnZ6s3Qom8Lrh3M5MPo T6i61QXJYKTTXPK3JTekOGlOIWgVTX27+gmSmGV0tT9wrpus2EiISm6WZIVKLFDvJnwPDxntwmX1E xigw8m0vPDIOQfN9zRbLSZl1e7JU+1cu5fAMJS6z/RnP2TKmeo1plPmSUjwyCr3P+AS3pMOA717+6 DsSRVMUY+QDQr4nWNnhVbtURiCrI7raP3+c+g53Syekspys7/NE2ZX8ItZeO3zTGM1p+zpe3NEbXS 8Awcij8g==; 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 1hFyas-000552-98; Mon, 15 Apr 2019 10:12:06 +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 1hFyZq-0003pZ-64; Mon, 15 Apr 2019 10:11:05 +0000 Received: by mail-wm1-x341.google.com with SMTP id n25so19615447wmk.4; Mon, 15 Apr 2019 03:11:01 -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=GrboAZF3BnjJNJvt9JLXUkPnL7d9/yHPsH0HVH2JN4Y=; b=XlQeaea1fDY3FHmAXvyH27UaBMFNPOXHyoCRGBshG0SHeWTFfslSQE8WAxpWcXgJs2 PdsSiorJe2WTrLDAC69mefgxeAhBOyglj5gR6wLQzENFv9gmWxQQeATXdlSIUYtgwHcS x00R0q6jtOop5hQ2AAFufqZLDQf9MOgYgC7CHL2+8C/zNPBeJVH84mL87+CwDct0AQWT PJzp5Vcv4IT0nIg+XvNP5hSzSjkQb/D/yViyBn/rLi5uC5tNUZ1CHIsHc94+LQeiNrBF 5v7MBqUvQE1AJkvV1E2NWjGn6HxKgMvAJkPSR2G7ydyUeBEooyvfoMDwuYT1jFeUqw2h 4kqQ== 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=GrboAZF3BnjJNJvt9JLXUkPnL7d9/yHPsH0HVH2JN4Y=; b=PyOHDOQOgdPpXNCOLbDdFBg19nZYWRPQ25g/tzmaEqhiUJK0xQk5aIDVJTPG3jfkIJ +61oMiqaYJZzhHs4VI7i/fBQfLHH+0Clo6C3zAHC0MPII4X6Rm2WDzqv5UE+g6PkeUOv mdjuDTB3rSkjGkWODnRIw3XTt6w2LQc3Ir/80GfByZDvKYH41D/bRcyF6hCntJaJqMGw dCiIfEwflskz88+55PLcMnu+hNfeTfS7xC8AgNsJbbILu+pjv1MJSA9otVQvAv+OnxVy 83tRLXcDt9ed3Rtloi0bx89XsnOMthbFWwtOPzXJGF1iKx/mJH9Jjc2QZa9VR0CnAJhh RxTg== X-Gm-Message-State: APjAAAVoI7Chu1FUCOzj3auApTpmSH1rqxLEHyewWbxBMa1yudrOj3NT VGbBjYkmaoDkfhjO9O7rXKc= X-Google-Smtp-Source: APXvYqx4YIrnaKjtFxaqoF6x/Hk55DKfuyQGcZX+zQoPcFihiNiCA3oA8O89/p25+iSx3jZReIhnvA== X-Received: by 2002:a1c:4187:: with SMTP id o129mr21175746wma.57.1555323060365; Mon, 15 Apr 2019 03:11:00 -0700 (PDT) Received: from localhost.localdomain ([2001:470:9e39::64]) by smtp.gmail.com with ESMTPSA id d6sm11592214wrp.9.2019.04.15.03.10.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Apr 2019 03:10:59 -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 5/8] clk: mux: add explicit big endian support Date: Mon, 15 Apr 2019 12:10:43 +0200 Message-Id: <20190415101046.5872-6-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_031102_647574_3F04C86D X-CRM114-Status: GOOD ( 14.60 ) 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 --- 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..47f6f4f55f08 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); + else + 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;