From: Chunfeng Yun <chunfeng.yun@mediatek.com>
To: AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Vinod Koul <vkoul@kernel.org>
Cc: 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: Re: [PATCH v2 3/5] phy: mediatek: add helpers to update bits of registers
Date: Thu, 30 Dec 2021 10:06:31 +0800 [thread overview]
Message-ID: <75b2773d1d170f42bae0774dbc58d1458cb25502.camel@mediatek.com> (raw)
In-Reply-To: <047803b9-d09f-d4f8-a674-317cc19dd055@collabora.com>
On Fri, 2021-12-24 at 11:10 +0100, AngeloGioacchino Del Regno wrote:
> Il 18/12/21 09:28, Chunfeng Yun ha scritto:
> > 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
> >
>
> These helpers are almost exactly duplicating what
> regmap_update_bits() is doing.
> I appreciate the effort to stop open-coding the same sequences over
> and over by
> adding such helper functions,
I agree with you.
> but I think that the proper way of doing what you
> are proposing is not to add custom functions but rather reuse what
> the Linux APIs
> give you.
I also like to use common APIs ASAP, but not found suitable ones.
This may be a problem, I found that some similar custom helps already
added under phy fold.
>
> What about doing a conversion to use regmap on this driver?
No, we don't use regmap here, these registers are monopolized by t-phy,
it's not syscon.
_______________________________________________
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-30 2:07 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 ` [PATCH v2 3/5] phy: mediatek: add helpers to update bits of registers Chunfeng Yun
2021-12-24 10:10 ` AngeloGioacchino Del Regno
2021-12-30 2:06 ` Chunfeng Yun [this message]
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=75b2773d1d170f42bae0774dbc58d1458cb25502.camel@mediatek.com \
--to=chunfeng.yun@mediatek.com \
--cc=angelogioacchino.delregno@collabora.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).