mirror of
https://github.com/openwrt/openwrt.git
synced 2025-02-20 17:32:57 +00:00
b53: provide PHY access to swconfig
Thanks to this change swconfig can access port PHYs e.g. when setting port link state with a generic helper. Signed-off-by: Rafał Miłecki <zajec5@gmail.com> SVN-Revision: 48622
This commit is contained in:
parent
19b9e14c47
commit
b3c3542515
@ -794,6 +794,26 @@ static int b53_port_get_link(struct switch_dev *dev, int port,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int b53_phy_read16(struct switch_dev *dev, int addr, u8 reg, u16 *value)
|
||||||
|
{
|
||||||
|
struct b53_device *priv = sw_to_b53(dev);
|
||||||
|
|
||||||
|
if (priv->ops->phy_read16)
|
||||||
|
return priv->ops->phy_read16(priv, addr, reg, value);
|
||||||
|
|
||||||
|
return b53_read16(priv, B53_PORT_MII_PAGE(addr), reg, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int b53_phy_write16(struct switch_dev *dev, int addr, u8 reg, u16 value)
|
||||||
|
{
|
||||||
|
struct b53_device *priv = sw_to_b53(dev);
|
||||||
|
|
||||||
|
if (priv->ops->phy_write16)
|
||||||
|
return priv->ops->phy_write16(priv, addr, reg, value);
|
||||||
|
|
||||||
|
return b53_write16(priv, B53_PORT_MII_PAGE(addr), reg, value);
|
||||||
|
}
|
||||||
|
|
||||||
static int b53_global_reset_switch(struct switch_dev *dev)
|
static int b53_global_reset_switch(struct switch_dev *dev)
|
||||||
{
|
{
|
||||||
struct b53_device *priv = sw_to_b53(dev);
|
struct b53_device *priv = sw_to_b53(dev);
|
||||||
@ -1002,6 +1022,8 @@ static const struct switch_dev_ops b53_switch_ops_25 = {
|
|||||||
.apply_config = b53_global_apply_config,
|
.apply_config = b53_global_apply_config,
|
||||||
.reset_switch = b53_global_reset_switch,
|
.reset_switch = b53_global_reset_switch,
|
||||||
.get_port_link = b53_port_get_link,
|
.get_port_link = b53_port_get_link,
|
||||||
|
.phy_read16 = b53_phy_read16,
|
||||||
|
.phy_write16 = b53_phy_write16,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct switch_dev_ops b53_switch_ops_65 = {
|
static const struct switch_dev_ops b53_switch_ops_65 = {
|
||||||
@ -1025,6 +1047,8 @@ static const struct switch_dev_ops b53_switch_ops_65 = {
|
|||||||
.apply_config = b53_global_apply_config,
|
.apply_config = b53_global_apply_config,
|
||||||
.reset_switch = b53_global_reset_switch,
|
.reset_switch = b53_global_reset_switch,
|
||||||
.get_port_link = b53_port_get_link,
|
.get_port_link = b53_port_get_link,
|
||||||
|
.phy_read16 = b53_phy_read16,
|
||||||
|
.phy_write16 = b53_phy_write16,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct switch_dev_ops b53_switch_ops = {
|
static const struct switch_dev_ops b53_switch_ops = {
|
||||||
@ -1048,6 +1072,8 @@ static const struct switch_dev_ops b53_switch_ops = {
|
|||||||
.apply_config = b53_global_apply_config,
|
.apply_config = b53_global_apply_config,
|
||||||
.reset_switch = b53_global_reset_switch,
|
.reset_switch = b53_global_reset_switch,
|
||||||
.get_port_link = b53_port_get_link,
|
.get_port_link = b53_port_get_link,
|
||||||
|
.phy_read16 = b53_phy_read16,
|
||||||
|
.phy_write16 = b53_phy_write16,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct b53_chip_data {
|
struct b53_chip_data {
|
||||||
|
@ -238,6 +238,24 @@ static int b53_mdio_write64(struct b53_device *dev, u8 page, u8 reg,
|
|||||||
return b53_mdio_op(dev, page, reg, REG_MII_ADDR_WRITE);
|
return b53_mdio_op(dev, page, reg, REG_MII_ADDR_WRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int b53_mdio_phy_read16(struct b53_device *dev, int addr, u8 reg,
|
||||||
|
u16 *value)
|
||||||
|
{
|
||||||
|
struct mii_bus *bus = dev->priv;
|
||||||
|
|
||||||
|
*value = mdiobus_read(bus, addr, reg);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int b53_mdio_phy_write16(struct b53_device *dev, int addr, u8 reg,
|
||||||
|
u16 value)
|
||||||
|
{
|
||||||
|
struct mii_bus *bus = dev->priv;
|
||||||
|
|
||||||
|
return mdiobus_write(bus, addr, reg, value);
|
||||||
|
}
|
||||||
|
|
||||||
static struct b53_io_ops b53_mdio_ops = {
|
static struct b53_io_ops b53_mdio_ops = {
|
||||||
.read8 = b53_mdio_read8,
|
.read8 = b53_mdio_read8,
|
||||||
.read16 = b53_mdio_read16,
|
.read16 = b53_mdio_read16,
|
||||||
@ -249,6 +267,8 @@ static struct b53_io_ops b53_mdio_ops = {
|
|||||||
.write32 = b53_mdio_write32,
|
.write32 = b53_mdio_write32,
|
||||||
.write48 = b53_mdio_write48,
|
.write48 = b53_mdio_write48,
|
||||||
.write64 = b53_mdio_write64,
|
.write64 = b53_mdio_write64,
|
||||||
|
.phy_read16 = b53_mdio_phy_read16,
|
||||||
|
.phy_write16 = b53_mdio_phy_write16,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int b53_phy_probe(struct phy_device *phydev)
|
static int b53_phy_probe(struct phy_device *phydev)
|
||||||
|
@ -36,6 +36,8 @@ struct b53_io_ops {
|
|||||||
int (*write32)(struct b53_device *dev, u8 page, u8 reg, u32 value);
|
int (*write32)(struct b53_device *dev, u8 page, u8 reg, u32 value);
|
||||||
int (*write48)(struct b53_device *dev, u8 page, u8 reg, u64 value);
|
int (*write48)(struct b53_device *dev, u8 page, u8 reg, u64 value);
|
||||||
int (*write64)(struct b53_device *dev, u8 page, u8 reg, u64 value);
|
int (*write64)(struct b53_device *dev, u8 page, u8 reg, u64 value);
|
||||||
|
int (*phy_read16)(struct b53_device *dev, int addr, u8 reg, u16 *value);
|
||||||
|
int (*phy_write16)(struct b53_device *dev, int addr, u8 reg, u16 value);
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user