From: Chunfeng Yun <chunfeng.yun@mediatek.com>
To: Vinod Koul <vkoul@kernel.org>
Cc: Chunfeng Yun <chunfeng.yun@mediatek.com>,
Kishon Vijay Abraham I <kishon@ti.com>,
Rob Herring <robh+dt@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-mediatek@lists.infradead.org>,
<linux-phy@lists.infradead.org>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
Eddie Hung <eddie.hung@mediatek.com>
Subject: [PATCH v2 3/5] phy: mediatek: add helpers to update bits of registers
Date: Sat, 18 Dec 2021 16:28:00 +0800 [thread overview]
Message-ID: <20211218082802.5256-3-chunfeng.yun@mediatek.com> (raw)
In-Reply-To: <20211218082802.5256-1-chunfeng.yun@mediatek.com>
Add three helpers mtk_phy_clear/set/update_bits() for registers operation
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v2: new patch, add register access helpers,
Add updatel() macro suggested by Vinod, here add more ones instead.
---
drivers/phy/mediatek/phy-mtk-io.h | 38 +++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
create mode 100644 drivers/phy/mediatek/phy-mtk-io.h
diff --git a/drivers/phy/mediatek/phy-mtk-io.h b/drivers/phy/mediatek/phy-mtk-io.h
new file mode 100644
index 000000000000..500fcdab165d
--- /dev/null
+++ b/drivers/phy/mediatek/phy-mtk-io.h
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2021 MediaTek Inc.
+ *
+ * Author: Chunfeng Yun <chunfeng.yun@mediatek.com>
+ */
+
+#ifndef __PHY_MTK_H__
+#define __PHY_MTK_H__
+
+#include <linux/io.h>
+
+static inline void mtk_phy_clear_bits(void __iomem *reg, u32 bits)
+{
+ u32 tmp = readl(reg);
+
+ tmp &= ~bits;
+ writel(tmp, reg);
+}
+
+static inline void mtk_phy_set_bits(void __iomem *reg, u32 bits)
+{
+ u32 tmp = readl(reg);
+
+ tmp |= bits;
+ writel(tmp, reg);
+}
+
+static inline void mtk_phy_update_bits(void __iomem *reg, u32 mask, u32 val)
+{
+ u32 tmp = readl(reg);
+
+ tmp &= ~mask;
+ tmp |= val & mask;
+ writel(tmp, reg);
+}
+
+#endif
--
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
next prev parent reply other threads:[~2021-12-18 8:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-18 8:27 [PATCH v2 1/5] dt-bindings: phy: mediatek: tphy: support software efuse load Chunfeng Yun
2021-12-18 8:27 ` [PATCH v2 2/5] phy: phy-mtk-tphy: add support efuse setting Chunfeng Yun
2021-12-24 10:03 ` AngeloGioacchino Del Regno
2021-12-30 2:13 ` Chunfeng Yun
2021-12-18 8:28 ` Chunfeng Yun [this message]
2021-12-24 10:10 ` [PATCH v2 3/5] phy: mediatek: add helpers to update bits of registers AngeloGioacchino Del Regno
2021-12-30 2:06 ` Chunfeng Yun
2022-01-03 8:59 ` AngeloGioacchino Del Regno
2022-01-06 8:08 ` Chunfeng Yun
2021-12-18 8:28 ` [PATCH v2 4/5] phy: phy-mtk-xsphy: use new io helpers to access register Chunfeng Yun
2021-12-18 8:28 ` [PATCH v2 5/5] phy: phy-mtk-tphy: " Chunfeng Yun
2021-12-23 11:37 ` [PATCH v2 1/5] dt-bindings: phy: mediatek: tphy: support software efuse load Vinod Koul
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211218082802.5256-3-chunfeng.yun@mediatek.com \
--to=chunfeng.yun@mediatek.com \
--cc=devicetree@vger.kernel.org \
--cc=eddie.hung@mediatek.com \
--cc=kishon@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-phy@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=robh+dt@kernel.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).