Netdev Archive mirror
 help / color / mirror / Atom feed
From: Hans-Frieder Vogt <hfdevel@gmx.net>
To: Andrew Lunn <andrew@lunn.ch>,
	FUJITA Tomonori <fujita.tomonori@gmail.com>
Cc: 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, 9 May 2024 11:52:46 +0200	[thread overview]
Message-ID: <6388dcc8-2152-45bd-8e0f-2fb558c6fce9@gmx.net> (raw)
In-Reply-To: <71d4a673-73b6-4ebe-a669-de3ae6c9af5f@gmx.net>

On 08.05.2024 21.30, Hans-Frieder Vogt wrote:

> On 08.05.2024 20.25, Andrew Lunn wrote:
>>>> +    writel(((1 << 15) | i), regs + TN40_REG_MDIO_CMD);
>>> similarly here:
>>>
>>> writel((MDIO_PHY_ID_C45 | i), regs + TN40_REG_MDIO_CMD);
>> This one i don't agree with. It happens to work, but there is no
>> reason to think the hardware has been designed around how Linux
>> combines the different parts of a C45 address into one word, using the
>> top bit to indicate it is actually a C45 address, not a C22.
>>
>> I would much prefer a TN40_ define is added for this bit.
> OK, yes, very valid point.

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)

>>
>>>> +    writel(((device & 0x1F) | ((port & 0x1F) << 5)),
>>> and also here, similarly:
>>>
>>> writel((device & MDIO_PHY_ID_DEVAD) | ((port << 5) &
>>> MDIO_PHY_ID_PRTAD),
>> Similarly here, this happens to work, but that is just because the
>> hardware matches a software construct Linux uses. It would be better
>> to add TN40_ macros to describe the hardware.
> agreed, I assume I just interpreted too much into the constants.
>>
>>     Andrew
>
> Thanks!
> Hans
>
Thanks for challenging my initial assumptions,
Hans

  reply	other threads:[~2024-05-09  9:52 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 [this message]
2024-05-09 10:59       ` FUJITA Tomonori
2024-05-09 11:16         ` Hans-Frieder Vogt
2024-05-09 11:25           ` FUJITA Tomonori
  -- 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=6388dcc8-2152-45bd-8e0f-2fb558c6fce9@gmx.net \
    --to=hfdevel@gmx.net \
    --cc=andrew@lunn.ch \
    --cc=fujita.tomonori@gmail.com \
    --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).