netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: "Marek Behún" <kabel@kernel.org>
Cc: netdev@vger.kernel.org, Russell King <rmk+kernel@armlinux.org.uk>,
	Andrew Lunn <andrew@lunn.ch>, Jakub Kicinski <kuba@kernel.org>,
	davem@davemloft.net
Subject: Re: [PATCH net-next v4 1/4] net: phy: mdio-i2c: support I2C MDIO protocol for RollBall SFP modules
Date: Wed, 13 Jan 2021 12:22:04 +0100	[thread overview]
Message-ID: <20210113112204.h3piuoni7amvx7i2@pali> (raw)
In-Reply-To: <20210111050044.22002-2-kabel@kernel.org>

Hello! See my comments below.

On Monday 11 January 2021 06:00:41 Marek Behún wrote:
> Some multigig SFPs from RollBall and Hilink do not expose functional
> MDIO access to the internal PHY of the SFP via I2C address 0x56
> (although there seems to be read-only clause 22 access on this address).

Maybe it could be interesting to test if clause 22 access via i2c
address 0x56 can work also in write mode after setting rollball
password...

> Instead these SFPs PHY can be accessed via I2C via the SFP Enhanced
> Digital Diagnostic Interface - I2C address 0x51. The SFP_PAGE has to be
> selected to 3 and the password must be filled with 0xff bytes for this
> PHY communication to work.
> 
> This extends the mdio-i2c driver to support this protocol by adding a
> special parameter to mdio_i2c_alloc function via which this RollBall
> protocol can be selected.
> 
> Signed-off-by: Marek Behún <kabel@kernel.org>
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Russell King <rmk+kernel@armlinux.org.uk>
> ---
>  drivers/net/mdio/mdio-i2c.c   | 319 +++++++++++++++++++++++++++++++++-
>  drivers/net/phy/sfp.c         |   2 +-
>  include/linux/mdio/mdio-i2c.h |   8 +-
>  3 files changed, 322 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/mdio/mdio-i2c.c b/drivers/net/mdio/mdio-i2c.c
> index 09200a70b315..7be582c0891a 100644
> --- a/drivers/net/mdio/mdio-i2c.c
> +++ b/drivers/net/mdio/mdio-i2c.c
...
> @@ -91,9 +94,297 @@ static int i2c_mii_write(struct mii_bus *bus, int phy_id, int reg, u16 val)
>  	return ret < 0 ? ret : 0;
>  }
>  
> -struct mii_bus *mdio_i2c_alloc(struct device *parent, struct i2c_adapter *i2c)
> +/* RollBall SFPs do not access internal PHY via I2C address 0x56, but
> + * instead via address 0x51, when SFP page is set to 0x03 and password to
> + * 0xffffffff.
> + * Since current SFP code does not modify SFP_PAGE, we set it to 0x03 only at
> + * bus creation time, and expect it to remain set to 0x03 throughout the
> + * lifetime of the module plugged into the system. If the SFP code starts
> + * modifying SFP_PAGE in the future, this code will need to change.
> + *
> + * address  size  contents  description
> + * -------  ----  --------  -----------
> + * 0x80     1     CMD       0x01/0x02/0x04 for write/read/done
> + * 0x81     1     DEV       Clause 45 device
> + * 0x82     2     REG       Clause 45 register
> + * 0x84     2     VAL       Register value
> + */
> +#define ROLLBALL_PHY_I2C_ADDR		0x51
> +#define ROLLBALL_SFP_PASSWORD_ADDR	0x7b

It looks like that this password entry is standard field described in
QSFP+ specifications SFF-8436 and SFF-8636. Should not it be rather
named vendor-neutral (as it is not Rollball specific)? And maybe defined
in include/linux/sfp.h file where also also other standard macros, like
SFP_PAGE macro?

> +
> +#define ROLLBALL_CMD_ADDR		0x80
> +#define ROLLBALL_DATA_ADDR		0x81
> +
> +#define ROLLBALL_CMD_WRITE		0x01
> +#define ROLLBALL_CMD_READ		0x02
> +#define ROLLBALL_CMD_DONE		0x04
> +
> +#define SFP_PAGE_ROLLBALL_MDIO		3
...
> diff --git a/include/linux/mdio/mdio-i2c.h b/include/linux/mdio/mdio-i2c.h
> index b1d27f7cd23f..53eedb0dc1d3 100644
> --- a/include/linux/mdio/mdio-i2c.h
> +++ b/include/linux/mdio/mdio-i2c.h
> @@ -11,6 +11,12 @@ struct device;
>  struct i2c_adapter;
>  struct mii_bus;
>  
> -struct mii_bus *mdio_i2c_alloc(struct device *parent, struct i2c_adapter *i2c);
> +enum mdio_i2c_proto {
> +	MDIO_I2C_DEFAULT,

Russel wrote that current mdio i2c (default) access method is also
vendor specific for Marvell chips. Should not we rather call it
MDIO_I2C_MARVELL if both methods are vendor/chip specific?

> +	MDIO_I2C_ROLLBALL,
> +};
> +
> +struct mii_bus *mdio_i2c_alloc(struct device *parent, struct i2c_adapter *i2c,
> +			       enum mdio_i2c_proto protocol);
>  
>  #endif
> -- 
> 2.26.2
> 

  parent reply	other threads:[~2021-01-13 11:23 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-11  5:00 [PATCH net-next v4 0/4] Support for RollBall 10G copper SFP modules Marek Behún
2021-01-11  5:00 ` [PATCH net-next v4 1/4] net: phy: mdio-i2c: support I2C MDIO protocol for RollBall " Marek Behún
2021-01-12  8:42   ` Heiner Kallweit
2021-01-12 14:02     ` Andrew Lunn
2021-01-12 14:40       ` Heiner Kallweit
2021-01-12 17:49       ` Marek Behún
2021-01-12 19:22     ` Russell King - ARM Linux admin
2021-01-18 12:13       ` Pali Rohár
2021-01-18 15:45         ` Russell King - ARM Linux admin
2021-01-12 20:20   ` Andrew Lunn
2021-01-12 20:43   ` Andrew Lunn
2021-01-12 20:53     ` Marek Behún
2021-01-12 20:55       ` Andrew Lunn
2021-01-12 20:54   ` Andrew Lunn
2021-01-12 21:01     ` Marek Behún
2021-01-13 10:51       ` Pali Rohár
2021-01-12 21:22     ` Russell King - ARM Linux admin
2021-01-13 11:22   ` Pali Rohár [this message]
2021-01-13 13:56     ` Andrew Lunn
2021-01-13 13:58       ` Pali Rohár
2021-01-13 16:14       ` Russell King - ARM Linux admin
2021-01-11  5:00 ` [PATCH net-next v4 2/4] net: phylink: allow attaching phy for SFP modules on 802.3z mode Marek Behún
2021-01-13 10:38   ` Pali Rohár
2021-01-11  5:00 ` [PATCH net-next v4 3/4] net: sfp: create/destroy I2C mdiobus before PHY probe/after PHY release Marek Behún
2021-01-13 10:41   ` Pali Rohár
2021-01-11  5:00 ` [PATCH net-next v4 4/4] net: sfp: add support for multigig RollBall transceivers Marek Behún
2021-01-13 10:49   ` Pali Rohár
2021-01-13 11:08     ` Russell King - ARM Linux admin
2021-01-13 11:26       ` 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=20210113112204.h3piuoni7amvx7i2@pali \
    --to=pali@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=kabel@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=rmk+kernel@armlinux.org.uk \
    /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).