Netdev Archive mirror
 help / color / mirror / Atom feed
From: FUJITA Tomonori <fujita.tomonori@gmail.com>
To: hfdevel@gmx.net
Cc: fujita.tomonori@gmail.com, andrew@lunn.ch,
	netdev@vger.kernel.org, horms@kernel.org, kuba@kernel.org,
	jiri@resnulli.us, pabeni@redhat.com
Subject: Re: [PATCH net-next v5 5/6] net: tn40xx: add mdio bus support
Date: Thu, 09 May 2024 20:25:18 +0900 (JST)	[thread overview]
Message-ID: <20240509.202518.402087965685343995.fujita.tomonori@gmail.com> (raw)
In-Reply-To: <ada8f820-ee60-4fac-92cc-91f287e36041@gmx.net>

Hi,

On Thu, 9 May 2024 13:16:11 +0200
Hans-Frieder Vogt <hfdevel@gmx.net> wrote:

> On 09.05.2024 12.59, FUJITA Tomonori wrote:
>> Hi,
>>
>> On Thu, 9 May 2024 11:52:46 +0200
>> Hans-Frieder Vogt <hfdevel@gmx.net> wrote:
>>
>>> A small addition here:
>>> digging through an old Tehuti linux river for the TN30xx (revision
>>> 7.33.5.1) I found revealing comments:
>>> in bdx_mdio_read:
>>>          /* Write read command */
>>>          writel(MDIO_CMD_STAT_VAL(1, device, port), regs +
>>> regMDIO_CMD_STAT);
>>> in bdx_mdio_write:
>>>          /* Write write command */
>>>          writel(MDIO_CMD_STAT_VAL(0, device, port), regs +
>>> regMDIO_CMD_STAT);
>>>
>>> The CMD register has a different layout in the TN40xx, but the logic
>>> is
>>> similar.
>>> Therefore, I conclude now that the value (1 << 15)  is in fact a read
>>> flag. Maybe it could be defined like:
>>>
>>> #define TN40_MDIO_READ    BIT(15)
>> Thanks a lot!
>>
>> So worth adding MDIO_CMD_STAT_VAL macro and TN40_MDIO_CMD_READ
>> definition?
>>
>>
>> diff --git a/drivers/net/ethernet/tehuti/tn40_mdio.c
>> b/drivers/net/ethernet/tehuti/tn40_mdio.c
>> index 64ef7f40f25d..d2e4b4d5ee9a 100644
>> --- a/drivers/net/ethernet/tehuti/tn40_mdio.c
>> +++ b/drivers/net/ethernet/tehuti/tn40_mdio.c
>> @@ -7,6 +7,10 @@
>>
>>   #include "tn40.h"
>>
>> +#define TN40_MDIO_CMD_STAT_VAL(device, port) \
>> + (((device) & MDIO_PHY_ID_DEVAD) | (((port) << 5) &
>> MDIO_PHY_ID_PRTAD))
> 
> As Andrew pointed out, using the definitions from uapi/linux/mdio.h is
> a
> bad idea, because it is just a coincidence that the definitions work
> in
> this case.

Ah, I misunderstood.


> So it is better to use specific defines for TN40xx, for example:
> 
> #define TN40_MDIO_DEVAD_MASK    0x001f
> #define TN40_MDIO_PRTAD_MASK    0x03e0
> #define TN40_MDIO_CMD_VAL(device, port) \
>         (((device) & TN40_MDIO_DEVAD_MASK( | (((port) << 5) &
> TN40_MDIO_PRTAD_MASK))
>
> note that I left out the _STAT_ from the TN40_MDIO_CMD_VAL, because in
> TN40xx the CMD and STAT registers are separate (different from the
> TN30xx example).

makes sense.

I'll add the followings:

#define TN40_MDIO_DEVAD_MASK GENMASK(4, 0)
#define TN40_MDIO_PRTAD_MASK GENMASK(9, 5)
#define TN40_MDIO_CMD_VAL(device, port) \
	(((device) & TN40_MDIO_DEVAD_MASK) | (FIELD_PREP(TN40_MDIO_PRTAD_MASK, (port))))
#define TN40_MDIO_CMD_READ BIT(15)

  reply	other threads:[~2024-05-09 11:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-08 18:08 [PATCH net-next v5 5/6] net: tn40xx: add mdio bus support Hans-Frieder Vogt
2024-05-08 18:25 ` Andrew Lunn
2024-05-08 19:30   ` Hans-Frieder Vogt
2024-05-09  9:52     ` Hans-Frieder Vogt
2024-05-09 10:59       ` FUJITA Tomonori
2024-05-09 11:16         ` Hans-Frieder Vogt
2024-05-09 11:25           ` FUJITA Tomonori [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-05-08 11:39 [PATCH net-next v5 0/6] add ethernet driver for Tehuti Networks TN40xx chips FUJITA Tomonori
2024-05-08 11:39 ` [PATCH net-next v5 5/6] net: tn40xx: add mdio bus support FUJITA Tomonori

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=20240509.202518.402087965685343995.fujita.tomonori@gmail.com \
    --to=fujita.tomonori@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=hfdevel@gmx.net \
    --cc=horms@kernel.org \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).