linux-phy.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: Vinod Koul <vkoul@kernel.org>
Cc: "Pali Rohár" <pali@kernel.org>,
	linux-phy@lists.infradead.org,
	"Kishon Vijay Abraham I" <kishon@ti.com>,
	"Miquel Raynal" <miquel.raynal@bootlin.com>,
	"Gregory CLEMENT" <gregory.clement@bootlin.com>
Subject: Re: [PATCH phy v2 2/6] phy: marvell: phy-mvebu-a3700-comphy: Add native kernel implementation
Date: Mon, 27 Dec 2021 13:50:10 +0100	[thread overview]
Message-ID: <20211227135010.594ad684@thinkpad> (raw)
In-Reply-To: <YcmWFtjBke3LDY79@matsya>

On Mon, 27 Dec 2021 16:01:50 +0530
Vinod Koul <vkoul@kernel.org> wrote:

> On 23-12-21, 14:21, Pali Rohár wrote:
> > On Thursday 23 December 2021 18:10:52 Vinod Koul wrote:  
> > > On 08-12-21, 03:40, Marek Behún wrote:  
> > > > From: Pali Rohár <pali@kernel.org>  
> > >   
> > > > +/* COMPHY registers */
> > > > +#define COMPHY_POWER_PLL_CTRL		0x01
> > > > +#define PU_IVREF_BIT			BIT(15)
> > > > +#define PU_PLL_BIT			BIT(14)
> > > > +#define PU_RX_BIT			BIT(13)
> > > > +#define PU_TX_BIT			BIT(12)
> > > > +#define PU_TX_INTP_BIT			BIT(11)
> > > > +#define PU_DFE_BIT			BIT(10)
> > > > +#define RESET_DTL_RX_BIT		BIT(9)
> > > > +#define PLL_LOCK_BIT			BIT(8)
> > > > +#define REF_FREF_SEL_MASK		GENMASK(4, 0)
> > > > +#define REF_FREF_SEL_SERDES_25MHZ	(0x1 << 0)
> > > > +#define REF_FREF_SEL_SERDES_40MHZ	(0x3 << 0)
> > > > +#define REF_FREF_SEL_SERDES_50MHZ	(0x4 << 0)
> > > > +#define REF_FREF_SEL_PCIE_USB3_25MHZ	(0x2 << 0)
> > > > +#define REF_FREF_SEL_PCIE_USB3_40MHZ	(0x3 << 0)
> > > > +#define COMPHY_MODE_MASK		GENMASK(7, 5)
> > > > +#define COMPHY_MODE_SATA		(0x0 << 5)
> > > > +#define COMPHY_MODE_PCIE		(0x3 << 5)
> > > > +#define COMPHY_MODE_SERDES		(0x4 << 5)
> > > > +#define COMPHY_MODE_USB3		(0x5 << 5)  
> > > 
> > > Any reason why these are not using GENMASK. I guess documentation would
> > > define these as BIT x-y right?  
> > 
> > Hello Vinod! I'm not sure to which macro refers your question as all
> > *_MASK defines are now using GENMASK() macros.
> > 
> > Definitions which do not have mask _MASK are not masks, but rather
> > particular values for corresponding _MASK constant.
> > 
> > So, for example: REF_FREF_SEL_MASK is 5 bit mask for fref_sel and
> > fref_sel can contain exactly one of the following values:
> > REF_FREF_SEL_SERDES_25MHZ, REF_FREF_SEL_SERDES_40MHZ,
> > REF_FREF_SEL_SERDES_50MHZ, REF_FREF_SEL_PCIE_USB3_25MHZ,
> > REF_FREF_SEL_PCIE_USB3_40MHZ. So you want to set serdes ref freq to
> > 50 MHz you need to clear bits [4:0] (macro REF_FREF_SEL_MASK) and then
> > set to value 0x4 (macro REF_FREF_SEL_SERDES_50MHZ) to bits [4:0].
> > 
> > It is clear now? Or did you mean something different?  
> 
> Thanks for explanation.
> 
> Looking at this, i think this should be defined as constants as defined
> in the spec:
> #define REF_FREF_SEL_SERDES_25MHZ x
> #define REF_FREF_SEL_SERDES_40MHZ y
> ... so on
> 
> and then use FIELD_PREP(MASK, constant) ie,
> FIELD_PREP(REF_FREF_SEL_MASK, REF_FREF_SEL_SERDES_25MHZ)
> 
> That sounds more readable and less error prone to me :)
> 
> Thanks

Cool I didn't know about this macro, I always wanted something like
this. Will resend with this updated.

Thx.

Marek

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

  reply	other threads:[~2021-12-27 12:50 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-08  2:40 [PATCH phy v2 0/6] Armada 3720 comphy native implementation Marek Behún
2021-12-08  2:40 ` [PATCH phy v2 1/6] phy: marvell: phy-mvebu-a3700-comphy: Remove port from driver configuration Marek Behún
2021-12-08  2:40 ` [PATCH phy v2 2/6] phy: marvell: phy-mvebu-a3700-comphy: Add native kernel implementation Marek Behún
2021-12-23 12:40   ` Vinod Koul
2021-12-23 13:21     ` Pali Rohár
2021-12-27 10:31       ` Vinod Koul
2021-12-27 12:50         ` Marek Behún [this message]
2021-12-27 12:56           ` Pali Rohár
2021-12-30 19:30             ` Marek Behún
2021-12-30 19:44     ` Marek Behún
2021-12-08  2:40 ` [PATCH phy v2 3/6] arm64: dts: marvell: armada-37xx: Add xtal clock to comphy node Marek Behún
2021-12-08  3:11   ` Marek Behún
2021-12-17 17:07   ` Gregory CLEMENT
2021-12-08  2:40 ` [PATCH phy v2 4/6] Revert "ata: ahci: mvebu: Make SATA PHY optional for Armada 3720" Marek Behún
2021-12-08  2:40 ` [PATCH phy v2 5/6] Revert "usb: host: xhci: mvebu: make USB 3.0 " Marek Behún
2021-12-08  2:40 ` [PATCH phy v2 6/6] Revert "PCI: aardvark: Fix initialization with old Marvell's Arm Trusted Firmware" Marek Behún
2021-12-21 13:29 ` [PATCH phy v2 0/6] Armada 3720 comphy native implementation Pali Rohár

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=20211227135010.594ad684@thinkpad \
    --to=kabel@kernel.org \
    --cc=gregory.clement@bootlin.com \
    --cc=kishon@ti.com \
    --cc=linux-phy@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=pali@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).