Lines Matching full:phydev

30 static int lan88xx_read_page(struct phy_device *phydev)  in lan88xx_read_page()  argument
32 return __phy_read(phydev, LAN88XX_EXT_PAGE_ACCESS); in lan88xx_read_page()
35 static int lan88xx_write_page(struct phy_device *phydev, int page) in lan88xx_write_page() argument
37 return __phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS, page); in lan88xx_write_page()
40 static int lan88xx_phy_config_intr(struct phy_device *phydev) in lan88xx_phy_config_intr() argument
44 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in lan88xx_phy_config_intr()
46 rc = phy_write(phydev, LAN88XX_INT_MASK, 0x7FFF); in lan88xx_phy_config_intr()
47 rc = phy_read(phydev, LAN88XX_INT_STS); in lan88xx_phy_config_intr()
48 rc = phy_write(phydev, LAN88XX_INT_MASK, in lan88xx_phy_config_intr()
52 rc = phy_write(phydev, LAN88XX_INT_MASK, 0); in lan88xx_phy_config_intr()
57 rc = phy_read(phydev, LAN88XX_INT_STS); in lan88xx_phy_config_intr()
63 static irqreturn_t lan88xx_handle_interrupt(struct phy_device *phydev) in lan88xx_handle_interrupt() argument
67 irq_status = phy_read(phydev, LAN88XX_INT_STS); in lan88xx_handle_interrupt()
69 phy_error(phydev); in lan88xx_handle_interrupt()
76 phy_trigger_machine(phydev); in lan88xx_handle_interrupt()
81 static int lan88xx_suspend(struct phy_device *phydev) in lan88xx_suspend() argument
83 struct lan88xx_priv *priv = phydev->priv; in lan88xx_suspend()
87 genphy_suspend(phydev); in lan88xx_suspend()
92 static int lan88xx_TR_reg_set(struct phy_device *phydev, u16 regaddr, in lan88xx_TR_reg_set() argument
99 save_page = phy_save_page(phydev); in lan88xx_TR_reg_set()
101 phydev_warn(phydev, "Failed to get current page\n"); in lan88xx_TR_reg_set()
106 lan88xx_write_page(phydev, LAN88XX_EXT_PAGE_ACCESS_TR); in lan88xx_TR_reg_set()
108 ret = __phy_write(phydev, LAN88XX_EXT_PAGE_TR_LOW_DATA, in lan88xx_TR_reg_set()
111 phydev_warn(phydev, "Failed to write TR low data\n"); in lan88xx_TR_reg_set()
115 ret = __phy_write(phydev, LAN88XX_EXT_PAGE_TR_HIGH_DATA, in lan88xx_TR_reg_set()
118 phydev_warn(phydev, "Failed to write TR high data\n"); in lan88xx_TR_reg_set()
126 ret = __phy_write(phydev, LAN88XX_EXT_PAGE_TR_CR, buf); in lan88xx_TR_reg_set()
128 phydev_warn(phydev, "Failed to write data in reg\n"); in lan88xx_TR_reg_set()
133 val = __phy_read(phydev, LAN88XX_EXT_PAGE_TR_CR); in lan88xx_TR_reg_set()
135 phydev_warn(phydev, "TR Register[0x%X] configuration failed\n", in lan88xx_TR_reg_set()
138 return phy_restore_page(phydev, save_page, ret); in lan88xx_TR_reg_set()
141 static void lan88xx_config_TR_regs(struct phy_device *phydev) in lan88xx_config_TR_regs() argument
149 err = lan88xx_TR_reg_set(phydev, 0x0F82, 0x12B00A); in lan88xx_config_TR_regs()
151 phydev_warn(phydev, "Failed to Set Register[0x0F82]\n"); in lan88xx_config_TR_regs()
157 err = lan88xx_TR_reg_set(phydev, 0x168C, 0xD2C46F); in lan88xx_config_TR_regs()
159 phydev_warn(phydev, "Failed to Set Register[0x168C]\n"); in lan88xx_config_TR_regs()
165 err = lan88xx_TR_reg_set(phydev, 0x17A2, 0x620); in lan88xx_config_TR_regs()
167 phydev_warn(phydev, "Failed to Set Register[0x17A2]\n"); in lan88xx_config_TR_regs()
174 err = lan88xx_TR_reg_set(phydev, 0x16A0, 0xEEFFDD); in lan88xx_config_TR_regs()
176 phydev_warn(phydev, "Failed to Set Register[0x16A0]\n"); in lan88xx_config_TR_regs()
182 err = lan88xx_TR_reg_set(phydev, 0x16A6, 0x071448); in lan88xx_config_TR_regs()
184 phydev_warn(phydev, "Failed to Set Register[0x16A6]\n"); in lan88xx_config_TR_regs()
190 err = lan88xx_TR_reg_set(phydev, 0x16A4, 0x13132F); in lan88xx_config_TR_regs()
192 phydev_warn(phydev, "Failed to Set Register[0x16A4]\n"); in lan88xx_config_TR_regs()
198 err = lan88xx_TR_reg_set(phydev, 0x16A8, 0x0); in lan88xx_config_TR_regs()
200 phydev_warn(phydev, "Failed to Set Register[0x16A8]\n"); in lan88xx_config_TR_regs()
207 err = lan88xx_TR_reg_set(phydev, 0x0FE8, 0x91B06C); in lan88xx_config_TR_regs()
209 phydev_warn(phydev, "Failed to Set Register[0x0FE8]\n"); in lan88xx_config_TR_regs()
216 err = lan88xx_TR_reg_set(phydev, 0x0FFC, 0xC0A028); in lan88xx_config_TR_regs()
218 phydev_warn(phydev, "Failed to Set Register[0x0FFC]\n"); in lan88xx_config_TR_regs()
225 err = lan88xx_TR_reg_set(phydev, 0x0FEA, 0x041600); in lan88xx_config_TR_regs()
227 phydev_warn(phydev, "Failed to Set Register[0x0FEA]\n"); in lan88xx_config_TR_regs()
232 err = lan88xx_TR_reg_set(phydev, 0x1686, 0x000004); in lan88xx_config_TR_regs()
234 phydev_warn(phydev, "Failed to Set Register[0x1686]\n"); in lan88xx_config_TR_regs()
237 static int lan88xx_probe(struct phy_device *phydev) in lan88xx_probe() argument
239 struct device *dev = &phydev->mdio.dev; in lan88xx_probe()
266 (void)phy_write(phydev, LAN78XX_PHY_LED_MODE_SELECT, reg); in lan88xx_probe()
272 priv->chip_id = phy_read_mmd(phydev, 3, LAN88XX_MMD3_CHIP_ID); in lan88xx_probe()
273 priv->chip_rev = phy_read_mmd(phydev, 3, LAN88XX_MMD3_CHIP_REV); in lan88xx_probe()
275 phydev->priv = priv; in lan88xx_probe()
280 static void lan88xx_remove(struct phy_device *phydev) in lan88xx_remove() argument
282 struct device *dev = &phydev->mdio.dev; in lan88xx_remove()
283 struct lan88xx_priv *priv = phydev->priv; in lan88xx_remove()
289 static int lan88xx_set_wol(struct phy_device *phydev, in lan88xx_set_wol() argument
292 struct lan88xx_priv *priv = phydev->priv; in lan88xx_set_wol()
299 static void lan88xx_set_mdix(struct phy_device *phydev) in lan88xx_set_mdix() argument
304 switch (phydev->mdix_ctrl) { in lan88xx_set_mdix()
318 phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS, LAN88XX_EXT_PAGE_SPACE_1); in lan88xx_set_mdix()
319 buf = phy_read(phydev, LAN88XX_EXT_MODE_CTRL); in lan88xx_set_mdix()
322 phy_write(phydev, LAN88XX_EXT_MODE_CTRL, buf); in lan88xx_set_mdix()
323 phy_write(phydev, LAN88XX_EXT_PAGE_ACCESS, LAN88XX_EXT_PAGE_SPACE_0); in lan88xx_set_mdix()
326 static int lan88xx_config_init(struct phy_device *phydev) in lan88xx_config_init() argument
331 val = phy_read_mmd(phydev, MDIO_MMD_PCS, in lan88xx_config_init()
335 phy_write_mmd(phydev, MDIO_MMD_PCS, PHY_ARDENNES_MMD_DEV_3_PHY_CFG, in lan88xx_config_init()
339 lan88xx_config_TR_regs(phydev); in lan88xx_config_init()
344 static int lan88xx_config_aneg(struct phy_device *phydev) in lan88xx_config_aneg() argument
346 lan88xx_set_mdix(phydev); in lan88xx_config_aneg()
348 return genphy_config_aneg(phydev); in lan88xx_config_aneg()
351 static void lan88xx_link_change_notify(struct phy_device *phydev) in lan88xx_link_change_notify() argument
360 if (!phydev->autoneg && phydev->speed == 100) { in lan88xx_link_change_notify()
362 temp = phy_read(phydev, LAN88XX_INT_MASK); in lan88xx_link_change_notify()
364 phy_write(phydev, LAN88XX_INT_MASK, temp); in lan88xx_link_change_notify()
366 temp = phy_read(phydev, MII_BMCR); in lan88xx_link_change_notify()
368 phy_write(phydev, MII_BMCR, temp); /* set to 10 first */ in lan88xx_link_change_notify()
370 phy_write(phydev, MII_BMCR, temp); /* set to 100 later */ in lan88xx_link_change_notify()
373 temp = phy_read(phydev, LAN88XX_INT_STS); in lan88xx_link_change_notify()
376 temp = phy_read(phydev, LAN88XX_INT_MASK); in lan88xx_link_change_notify()
378 phy_write(phydev, LAN88XX_INT_MASK, temp); in lan88xx_link_change_notify()
384 * @phydev: Pointer to the phy_device structure.
393 static int lan937x_tx_read_mdix_status(struct phy_device *phydev) in lan937x_tx_read_mdix_status() argument
397 ret = phy_read(phydev, LAN937X_MODE_CTRL_STATUS_REG); in lan937x_tx_read_mdix_status()
402 phydev->mdix_ctrl = ETH_TP_MDI_AUTO; in lan937x_tx_read_mdix_status()
404 phydev->mdix = ETH_TP_MDI_INVALID; in lan937x_tx_read_mdix_status()
406 phydev->mdix_ctrl = ETH_TP_MDI_X; in lan937x_tx_read_mdix_status()
407 phydev->mdix = ETH_TP_MDI_X; in lan937x_tx_read_mdix_status()
409 phydev->mdix_ctrl = ETH_TP_MDI; in lan937x_tx_read_mdix_status()
410 phydev->mdix = ETH_TP_MDI; in lan937x_tx_read_mdix_status()
418 * @phydev: Pointer to the phy_device structure.
425 static int lan937x_tx_read_status(struct phy_device *phydev) in lan937x_tx_read_status() argument
429 ret = genphy_read_status(phydev); in lan937x_tx_read_status()
433 return lan937x_tx_read_mdix_status(phydev); in lan937x_tx_read_status()
438 * @phydev: Pointer to the phy_device structure.
447 static int lan937x_tx_set_mdix(struct phy_device *phydev) in lan937x_tx_set_mdix() argument
451 switch (phydev->mdix_ctrl) { in lan937x_tx_set_mdix()
465 return phy_modify(phydev, LAN937X_MODE_CTRL_STATUS_REG, in lan937x_tx_set_mdix()
472 * @phydev: Pointer to the phy_device structure.
480 static int lan937x_tx_config_aneg(struct phy_device *phydev) in lan937x_tx_config_aneg() argument
484 ret = lan937x_tx_set_mdix(phydev); in lan937x_tx_config_aneg()
488 return genphy_config_aneg(phydev); in lan937x_tx_config_aneg()