linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Ravi Gunasekaran <r-gunasekaran@ti.com>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, linux-omap@vger.kernel.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, kishon@ti.com,
	vigneshr@ti.com
Subject: Re: [RESEND PATCH] net: ethernet: ti: davinci_mdio: Add workaround for errata i2329
Date: Mon, 8 Aug 2022 22:13:33 +0200	[thread overview]
Message-ID: <YvFubdCiU7J8Ufi4@lunn.ch> (raw)
In-Reply-To: <20220808111229.11951-1-r-gunasekaran@ti.com>

> +static int davinci_mdio_sw_read(struct mii_bus *bus, int phy_id, int phy_reg)
> +{
> +	struct davinci_mdio_data *data = bus->priv;
> +	u32 reg, i;
> +	int ret;
> +	u8 ack;
> +
> +	if (phy_reg & ~PHY_REG_MASK || phy_id & ~PHY_ID_MASK)
> +		return -EINVAL;
> +
> +	ret = pm_runtime_get_sync(data->dev);
> +	if (ret < 0) {
> +		pm_runtime_put_noidle(data->dev);
> +		return ret;
> +	}
> +
> +	davinci_mdio_disable(data);
> +	davinci_mdio_enable_manual_mode(data);
> +	davinci_mdio_sw_preamble(data);
> +
> +	davinci_mdio_sw_clr_bit(data, MDIO_MDCLK);
> +	davinci_mdio_sw_set_bit(data, MDIO_OE);
> +
> +	 /* Issue clause 22 MII read function {0,1,1,0} */
> +	davinci_mdio_man_send_pattern(data, C22_BITRANGE, C22_READ_PATTERN);
> +
> +	/* Send the device number MSB first */
> +	davinci_mdio_man_send_pattern(data, PHY_BITRANGE, phy_id);
> +
> +	/* Send the register number MSB first */
> +	davinci_mdio_man_send_pattern(data, PHY_BITRANGE, phy_reg);
> +
> +	/* Send turn around cycles */
> +	davinci_mdio_sw_clr_bit(data, MDIO_OE);
> +
> +	davinci_mdio_toggle_man_bit(data, MDIO_MDCLK);
> +
> +	ack = davinci_mdio_test_man_bit(data, MDIO_PIN);
> +	davinci_mdio_toggle_man_bit(data, MDIO_MDCLK);
> +
> +	reg = 0;
> +	if (ack == 0) {
> +		for (i = MDIO_BITRANGE; i; i = i >> 1) {
> +			if (davinci_mdio_test_man_bit(data, MDIO_PIN))
> +				reg |= i;
> +
> +			davinci_mdio_toggle_man_bit(data, MDIO_MDCLK);
> +		}
> +	} else {
> +		for (i = MDIO_BITRANGE; i; i = i >> 1)
> +			davinci_mdio_toggle_man_bit(data, MDIO_MDCLK);
> +
> +		reg = 0xFFFF;
> +	}
> +
> +	davinci_mdio_sw_clr_bit(data, MDIO_MDCLK);
> +	davinci_mdio_sw_set_bit(data, MDIO_MDCLK);
> +	davinci_mdio_sw_set_bit(data, MDIO_MDCLK);
> +	davinci_mdio_toggle_man_bit(data, MDIO_MDCLK);

You appear to of re-invented drivers/net/mdio/mdio-bitbang.c

If there is a reason this cannot be used, please at least state it in
the commit message.

    Andrew

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-08-08 20:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-08 11:12 [RESEND PATCH] net: ethernet: ti: davinci_mdio: Add workaround for errata i2329 Ravi Gunasekaran
2022-08-08 20:13 ` Andrew Lunn [this message]
2022-08-09 11:30   ` [EXTERNAL] " Ravi Gunasekaran
2022-08-09 17:10     ` Andrew Lunn

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=YvFubdCiU7J8Ufi4@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kishon@ti.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=r-gunasekaran@ti.com \
    --cc=vigneshr@ti.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 NNTP newsgroup(s).