diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2019-03-11 14:18:20 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-03-11 14:20:58 +0100 |
commit | 6e355bb2685bd7706964da9acc5dfee0b32fa045 (patch) | |
tree | dc3c26b1e7a2d4307d1ff897185a6509ebbd9666 /include | |
parent | 0826d25d3699a34385c740f9bff90693411eebf3 (diff) | |
download | barebox-6e355bb2685bd7706964da9acc5dfee0b32fa045.tar.gz barebox-6e355bb2685bd7706964da9acc5dfee0b32fa045.tar.xz |
net: phy: Add register access helper functions for phys
Linux has phy helpers to access paged registers and to modify phy
registers. Add them to barebox for upcoming realtek phy support.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/phy.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/include/linux/phy.h b/include/linux/phy.h index ce72861bfc..a9fdf44f1a 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -267,6 +267,9 @@ struct phy_driver { /* Clears up any memory if needed */ void (*remove)(struct phy_device *phydev); + int (*read_page)(struct phy_device *phydev); + int (*write_page)(struct phy_device *phydev, int page); + struct driver_d drv; }; #define to_phy_driver(d) ((d) ? container_of(d, struct phy_driver, drv) : NULL) @@ -293,6 +296,14 @@ struct phy_device *get_phy_device(struct mii_bus *bus, int addr); int phy_init(void); int phy_init_hw(struct phy_device *phydev); +int phy_save_page(struct phy_device *phydev); +int phy_select_page(struct phy_device *phydev, int page); +int phy_restore_page(struct phy_device *phydev, int oldpage, int ret); +int phy_read_paged(struct phy_device *phydev, int page, u32 regnum); +int phy_write_paged(struct phy_device *phydev, int page, u32 regnum, u16 val); +int phy_modify_paged(struct phy_device *phydev, int page, u32 regnum, + u16 mask, u16 set); + struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id); int phy_register_device(struct phy_device* dev); void phy_unregister_device(struct phy_device *phydev); @@ -318,6 +329,30 @@ static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val) return mdiobus_write(phydev->bus, phydev->addr, regnum, val); } +int phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set); + +/** + * phy_set_bits - Convenience function for setting bits in a PHY register + * @phydev: the phy_device struct + * @regnum: register number to write + * @val: bits to set + */ +static inline int phy_set_bits(struct phy_device *phydev, u32 regnum, u16 val) +{ + return phy_modify(phydev, regnum, 0, val); +} + +/** + * phy_clear_bits - Convenience function for clearing bits in a PHY register + * @phydev: the phy_device struct + * @regnum: register number to write + * @val: bits to clear + */ +static inline int phy_clear_bits(struct phy_device *phydev, u32 regnum, u16 val) +{ + return phy_modify(phydev, regnum, val, 0); +} + int phy_device_connect(struct eth_device *dev, struct mii_bus *bus, int addr, void (*adjust_link) (struct eth_device *edev), u32 flags, phy_interface_t interface); |