Re: [EXTERNAL] Re: [RESEND PATCH] net: ethernet: ti: davinci_mdio: Add workaround for errata i2329

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Andrew,

On 09/08/22 1:43 am, Andrew Lunn wrote:
+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.

Thanks for reviewing the patch. Since mdiobb_{read,write}() are exported, I can invoke these in my mdio read/write implementation. I will rework and send the v2 patch

     Andrew

--
Regards,
Ravi



[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux