netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Michael Grzeschik <m.grzeschik@pengutronix.de>
Cc: Tristram.Ha@microchip.com, kernel@pengutronix.de,
	UNGLinuxDriver@microchip.com, netdev@vger.kernel.org
Subject: Re: [RFC 1/3] mdio-bitbang: add SMI0 mode support
Date: Thu, 9 May 2019 16:29:25 +0200	[thread overview]
Message-ID: <20190509142925.GL25013@lunn.ch> (raw)
In-Reply-To: <20190508211330.19328-2-m.grzeschik@pengutronix.de>

On Wed, May 08, 2019 at 11:13:28PM +0200, Michael Grzeschik wrote:
> Some microchip phys support the Serial Management Interface Protocol
> (SMI) for the configuration of the extended register set. We add
> MII_ADDR_SMI0 as an availabe interface to the mdiobb write and read
> functions, as this interface can be easy realized using the bitbang mdio
> driver.
> 
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
> ---
>  drivers/net/phy/mdio-bitbang.c | 10 ++++++++++
>  include/linux/phy.h            | 12 ++++++++++++
>  2 files changed, 22 insertions(+)
> 
> diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
> index 5136275c8e739..a978f8a9a172b 100644
> --- a/drivers/net/phy/mdio-bitbang.c
> +++ b/drivers/net/phy/mdio-bitbang.c
> @@ -22,6 +22,10 @@
>  #define MDIO_READ 2
>  #define MDIO_WRITE 1
>  
> +#define SMI0_RW_OPCODE	0
> +#define SMI0_READ_PHY	(1 << 4)
> +#define SMI0_WRITE_PHY	(0 << 4)
> +
>  #define MDIO_C45 (1<<15)
>  #define MDIO_C45_ADDR (MDIO_C45 | 0)
>  #define MDIO_C45_READ (MDIO_C45 | 3)
> @@ -157,6 +161,9 @@ static int mdiobb_read(struct mii_bus *bus, int phy, int reg)
>  	if (reg & MII_ADDR_C45) {
>  		reg = mdiobb_cmd_addr(ctrl, phy, reg);
>  		mdiobb_cmd(ctrl, MDIO_C45_READ, phy, reg);
> +	} else if (reg & MII_ADDR_SMI0) {
> +		mdiobb_cmd(ctrl, SMI0_RW_OPCODE,
> +			   (reg & 0xE0) >> 5 | SMI0_READ_PHY, reg);
>  	} else
>  		mdiobb_cmd(ctrl, MDIO_READ, phy, reg);
>  
> @@ -188,6 +195,9 @@ static int mdiobb_write(struct mii_bus *bus, int phy, int reg, u16 val)
>  	if (reg & MII_ADDR_C45) {
>  		reg = mdiobb_cmd_addr(ctrl, phy, reg);
>  		mdiobb_cmd(ctrl, MDIO_C45_WRITE, phy, reg);
> +	} else if (reg & MII_ADDR_SMI0) {
> +		mdiobb_cmd(ctrl, SMI0_RW_OPCODE,
> +			   (reg & 0xE0) >> 5 | SMI0_WRITE_PHY, reg);
>  	} else
>  		mdiobb_cmd(ctrl, MDIO_WRITE, phy, reg);
>  
> diff --git a/include/linux/phy.h b/include/linux/phy.h
> index 073fb151b5a99..f011722fbd5c2 100644
> --- a/include/linux/phy.h
> +++ b/include/linux/phy.h
> @@ -199,6 +199,18 @@ static inline const char *phy_modes(phy_interface_t interface)
>     IEEE 802.3ae clause 45 addressing mode used by 10GIGE phy chips. */
>  #define MII_ADDR_C45 (1<<30)
>  
> +/* Serial Management Interface (SMI) uses the following frame format:
> + *
> + *       preamble|start|Read/Write|  PHY   |  REG  |TA|   Data bits      | Idle
> + *               |frame| OP code  |address |address|  |                  |
> + * read | 32x1´s | 01  |    00    | 1xRRR  | RRRRR |Z0| 00000000DDDDDDDD |  Z
> + * write| 32x1´s | 01  |    00    | 0xRRR  | RRRRR |10| xxxxxxxxDDDDDDDD |  Z
> + *
> + * The register number is encoded with the 5 least significant bits in REG
> + * and the 3 most significant bits in PHY
> + */
> +#define MII_ADDR_SMI0 (1<<31)
> +

Michael

This is a Micrel Proprietary protocol. So we should reflect this in
the name. MII_ADDR_MICREL_SMI? Why the 0? Are there different
versions? Maybe replace all SMI0 with MICREL_SMI in mdio-bitbang.c

When i look at this, i don't see how a normal MDIO bus driver is going
to support this. Only the bit banging driver, or maybe a Micrel MDIO
bus master hardware driver. So i think the diagram should be placed
into mdio-bitbang.c, and it would be nice to add a diagram of standard
SMI.

	Andrew

  reply	other threads:[~2019-05-09 14:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-08 21:13 [RFC 0/3] microchip: add support for ksz8863 driver family Michael Grzeschik
2019-05-08 21:13 ` [RFC 1/3] mdio-bitbang: add SMI0 mode support Michael Grzeschik
2019-05-09 14:29   ` Andrew Lunn [this message]
2019-05-10  7:32     ` Michael Grzeschik
2019-05-10 12:36       ` Andrew Lunn
2019-05-08 21:13 ` [RFC 2/3] ksz: Add Microchip KSZ8873 SMI-DSA driver Michael Grzeschik
2019-05-09 14:48   ` Andrew Lunn
2019-05-10  7:37     ` Michael Grzeschik
2019-05-08 21:13 ` [RFC 3/3] dt-bindings: net: dsa: document additional Microchip KSZ8863 family switches Michael Grzeschik
2019-06-13 20:09   ` Rob Herring

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=20190509142925.GL25013@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=Tristram.Ha@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=kernel@pengutronix.de \
    --cc=m.grzeschik@pengutronix.de \
    --cc=netdev@vger.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).