mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-28 01:28:59 +00:00
28f534d953
Update patch set for new release and add required kernel option CONFIG_ZRAM_TRACK_ENTRY_ACTIME to generic config Changelog: https://cdn.kernel.org/pub/linux/kernel/v6.x/ChangeLog-6.6.66 Manually rebased: bcm27xx/patches-6.6/950-0092-MMC-added-alternative-MMC-driver.patch bcm53xx/patches-6.6/180-usb-xhci-add-support-for-performing-fake-doorbell.patch starfive/patches-6.6/1000-serial-8250_dw-Add-starfive-jh7100-hsuart-compatible.patch Removed upstreamed: bcm27xx/patches-6.6/950-0029-vc4_hdmi-Avoid-log-spam-for-audio-start-failure.patch[1] All other patches automatically rebased. 1. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.6.66&id=e0388a95736abd1f5f5a94221dd1ac24eacbd4d7 Build system: x86/64 Build-tested: bcm27xx/bcm2712, flogic/glinet_gl-mt6000, flogic/xiaomi_redmi-router-ax6000-ubootmod, ramips/tplink_archer-a6-v3, x86/64 Run-tested: bcm27xx/bcm2712, flogic/glinet_gl-mt6000, flogic/xiaomi_redmi-router-ax6000-ubootmod, ramips/tplink_archer-a6-v3, x86/64 Signed-off-by: John Audia <therealgraysky@proton.me> Link: https://github.com/openwrt/openwrt/pull/17271 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
128 lines
3.0 KiB
Diff
128 lines
3.0 KiB
Diff
From 3cb0bde365d913c484d20224367a54a0eac780a7 Mon Sep 17 00:00:00 2001
|
|
From: Antoine Tenart <antoine.tenart@bootlin.com>
|
|
Date: Fri, 21 Feb 2020 11:55:29 +0100
|
|
Subject: [PATCH 3/3] net: phy: sfp: add support for SMBus
|
|
|
|
Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
|
|
---
|
|
drivers/net/phy/sfp.c | 92 +++++++++++++++++++++++++++++++++++++++++--
|
|
1 file changed, 88 insertions(+), 4 deletions(-)
|
|
|
|
--- a/drivers/net/phy/sfp.c
|
|
+++ b/drivers/net/phy/sfp.c
|
|
@@ -663,10 +663,64 @@ static int sfp_i2c_write(struct sfp *sfp
|
|
return ret == ARRAY_SIZE(msgs) ? len : 0;
|
|
}
|
|
|
|
+static int sfp_smbus_read(struct sfp *sfp, bool a2, u8 dev_addr, void *buf,
|
|
+ size_t len)
|
|
+{
|
|
+ u8 bus_addr = a2 ? 0x51 : 0x50, *val = buf;
|
|
+ union i2c_smbus_data data;
|
|
+ int ret;
|
|
+
|
|
+ bus_addr -= 0x40;
|
|
+
|
|
+ while (len > 0) {
|
|
+ ret = i2c_smbus_xfer(sfp->i2c, i2c_mii_phy_addr(bus_addr), 0,
|
|
+ I2C_SMBUS_READ, dev_addr,
|
|
+ I2C_SMBUS_BYTE_DATA, &data);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+ *val++ = data.byte;
|
|
+ dev_addr++;
|
|
+ len--;
|
|
+ }
|
|
+
|
|
+ return val - (u8 *)buf;
|
|
+}
|
|
+
|
|
+static int sfp_smbus_write(struct sfp *sfp, bool a2, u8 dev_addr, void *buf,
|
|
+ size_t len)
|
|
+{
|
|
+ u8 bus_addr = a2 ? 0x51 : 0x50, *val = buf;
|
|
+ union i2c_smbus_data data;
|
|
+ int ret;
|
|
+
|
|
+ bus_addr -= 0x40;
|
|
+
|
|
+ while (len > 0) {
|
|
+ data.byte = *val++;
|
|
+ ret = i2c_smbus_xfer(sfp->i2c, i2c_mii_phy_addr(bus_addr), 0,
|
|
+ I2C_SMBUS_WRITE, dev_addr,
|
|
+ I2C_SMBUS_BYTE_DATA, &data);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+ dev_addr++;
|
|
+ len--;
|
|
+ }
|
|
+
|
|
+ return val - (u8 *)buf;
|
|
+}
|
|
+
|
|
static int sfp_i2c_configure(struct sfp *sfp, struct i2c_adapter *i2c)
|
|
{
|
|
- if (!i2c_check_functionality(i2c, I2C_FUNC_I2C))
|
|
- return -EINVAL;
|
|
+ if (!i2c_check_functionality(i2c, I2C_FUNC_I2C)) {
|
|
+ if (i2c_check_functionality(i2c, I2C_FUNC_SMBUS_BYTE_DATA)) {
|
|
+ sfp->i2c = i2c;
|
|
+ sfp->read = sfp_smbus_read;
|
|
+ sfp->write = sfp_smbus_write;
|
|
+
|
|
+ return 0;
|
|
+ } else
|
|
+ return -EINVAL;
|
|
+ }
|
|
|
|
sfp->i2c = i2c;
|
|
sfp->read = sfp_i2c_read;
|
|
@@ -698,6 +752,29 @@ static int sfp_i2c_mdiobus_create(struct
|
|
return 0;
|
|
}
|
|
|
|
+static int sfp_sm_mdiobus_create(struct sfp *sfp)
|
|
+{
|
|
+ struct mii_bus *sm_mii;
|
|
+ int ret;
|
|
+
|
|
+ sm_mii = mdio_smbus_alloc(sfp->dev, sfp->i2c);
|
|
+ if (IS_ERR(sm_mii))
|
|
+ return PTR_ERR(sm_mii);
|
|
+
|
|
+ sm_mii->name = "SFP SMBus";
|
|
+ sm_mii->phy_mask = ~0;
|
|
+
|
|
+ ret = mdiobus_register(sm_mii);
|
|
+ if (ret < 0) {
|
|
+ mdiobus_free(sm_mii);
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
+ sfp->i2c_mii = sm_mii;
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
static void sfp_i2c_mdiobus_destroy(struct sfp *sfp)
|
|
{
|
|
mdiobus_unregister(sfp->i2c_mii);
|
|
@@ -1871,8 +1948,15 @@ static void sfp_sm_fault(struct sfp *sfp
|
|
|
|
static int sfp_sm_add_mdio_bus(struct sfp *sfp)
|
|
{
|
|
- if (sfp->mdio_protocol != MDIO_I2C_NONE)
|
|
- return sfp_i2c_mdiobus_create(sfp);
|
|
+ if (i2c_check_functionality(sfp->i2c, I2C_FUNC_I2C)) {
|
|
+ if (sfp->mdio_protocol != MDIO_I2C_NONE)
|
|
+ return sfp_i2c_mdiobus_create(sfp);
|
|
+
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ if (i2c_check_functionality(sfp->i2c, I2C_FUNC_SMBUS_BYTE_DATA))
|
|
+ return sfp_sm_mdiobus_create(sfp);
|
|
|
|
return 0;
|
|
}
|