diff options
author | INAGAKI Hiroshi <musashino.open@gmail.com> | 2022-09-09 22:08:16 +0900 |
---|---|---|
committer | Sander Vanheule <sander@svanheule.net> | 2022-12-15 20:52:09 +0100 |
commit | 8fb15ea52a02b0578c11897afd1a87f8502d8f52 (patch) | |
tree | a65ae72710e84420cad6e500a2b781abce0cd9a0 /target/linux/realtek/patches-5.15/712-net-phy-sfp-add-support-for-SMBus.patch | |
parent | fef55d5ffd31bd6e0d157df784f47fe8ce0f1494 (diff) | |
download | upstream-8fb15ea52a02b0578c11897afd1a87f8502d8f52.tar.gz upstream-8fb15ea52a02b0578c11897afd1a87f8502d8f52.tar.bz2 upstream-8fb15ea52a02b0578c11897afd1a87f8502d8f52.zip |
realtek: copy dts/files/patches/configs for 5.15
Copy dts/files/patches/configs from 5.10 to 5.15.
Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
[refresh with updated DGS-1210 dts files]
Signed-off-by: Sander Vanheule <sander@svanheule.net>
Diffstat (limited to 'target/linux/realtek/patches-5.15/712-net-phy-sfp-add-support-for-SMBus.patch')
-rw-r--r-- | target/linux/realtek/patches-5.15/712-net-phy-sfp-add-support-for-SMBus.patch | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/target/linux/realtek/patches-5.15/712-net-phy-sfp-add-support-for-SMBus.patch b/target/linux/realtek/patches-5.15/712-net-phy-sfp-add-support-for-SMBus.patch new file mode 100644 index 0000000000..c4bacc0ea9 --- /dev/null +++ b/target/linux/realtek/patches-5.15/712-net-phy-sfp-add-support-for-SMBus.patch @@ -0,0 +1,99 @@ +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 | 68 ++++++++++++++++++++++++++++++++++--------- + 1 file changed, 54 insertions(+), 14 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -413,32 +413,72 @@ 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; ++ ++ bus_addr -= 0x40; ++ ++ while (len > 0) { ++ *val = sfp->i2c_mii->read(sfp->i2c_mii, bus_addr, dev_addr); ++ ++ val++; ++ 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; ++ u16 val; ++ ++ memcpy(&val, buf, len); ++ ++ return sfp->i2c_mii->write(sfp->i2c_mii, bus_addr, dev_addr, val); ++} ++ + static int sfp_i2c_configure(struct sfp *sfp, struct i2c_adapter *i2c) + { +- struct mii_bus *i2c_mii; ++ struct mii_bus *mii; + int ret; + +- if (!i2c_check_functionality(i2c, I2C_FUNC_I2C)) +- return -EINVAL; +- + sfp->i2c = i2c; +- sfp->read = sfp_i2c_read; +- sfp->write = sfp_i2c_write; + +- i2c_mii = mdio_i2c_alloc(sfp->dev, i2c); +- if (IS_ERR(i2c_mii)) +- return PTR_ERR(i2c_mii); ++ if (i2c_check_functionality(i2c, I2C_FUNC_I2C)) { ++ sfp->read = sfp_i2c_read; ++ sfp->write = sfp_i2c_write; ++ ++ mii = mdio_i2c_alloc(sfp->dev, i2c); ++ if (IS_ERR(mii)) ++ return PTR_ERR(mii); ++ ++ mii->name = "SFP I2C Bus"; ++ } else if (i2c_check_functionality(i2c, I2C_FUNC_SMBUS_BYTE_DATA)) { ++ sfp->read = sfp_smbus_read; ++ sfp->write = sfp_smbus_write; ++ ++ mii = mdio_smbus_alloc(sfp->dev, i2c); ++ if (IS_ERR(mii)) ++ return PTR_ERR(mii); + +- i2c_mii->name = "SFP I2C Bus"; +- i2c_mii->phy_mask = ~0; ++ mii->name = "SFP SMBus"; ++ } else { ++ return -EINVAL; ++ } + +- ret = mdiobus_register(i2c_mii); ++ mii->phy_mask = ~0; ++ ret = mdiobus_register(mii); + if (ret < 0) { +- mdiobus_free(i2c_mii); ++ mdiobus_free(mii); + return ret; + } + +- sfp->i2c_mii = i2c_mii; ++ sfp->i2c_mii = mii; + + return 0; + } |