Lines Matching refs:phydev
179 static int aquantia_load_memory(struct phy_device *phydev, u32 addr, in aquantia_load_memory() argument
185 phy_write(phydev, MDIO_MMD_VEND1, MAILBOX_CONTROL, MAILBOX_RESET_CRC); in aquantia_load_memory()
186 phy_write(phydev, MDIO_MMD_VEND1, MAILBOX_ADDR_MSW, addr >> 16); in aquantia_load_memory()
187 phy_write(phydev, MDIO_MMD_VEND1, MAILBOX_ADDR_LSW, addr & 0xfffc); in aquantia_load_memory()
194 phy_write(phydev, MDIO_MMD_VEND1, MAILBOX_DATA_MSW, in aquantia_load_memory()
196 phy_write(phydev, MDIO_MMD_VEND1, MAILBOX_DATA_LSW, in aquantia_load_memory()
199 phy_write(phydev, MDIO_MMD_VEND1, MAILBOX_CONTROL, in aquantia_load_memory()
207 up_crc = phy_read(phydev, MDIO_MMD_VEND1, MAILBOX_CRC); in aquantia_load_memory()
210 phydev->dev->name, crc, up_crc); in aquantia_load_memory()
221 static int aquantia_upload_firmware(struct phy_device *phydev) in aquantia_upload_firmware() argument
239 phydev->dev->name, read_crc, calculated_crc); in aquantia_upload_firmware()
260 printf("%s loading firmare version '%s'\n", phydev->dev->name, version); in aquantia_upload_firmware()
263 phy_write(phydev, MDIO_MMD_VEND1, UP_CONTROL, in aquantia_upload_firmware()
268 ret = aquantia_load_memory(phydev, DRAM_BASE_ADDR, &addr[dram_offset], in aquantia_upload_firmware()
275 ret = aquantia_load_memory(phydev, IRAM_BASE_ADDR, &addr[iram_offset], in aquantia_upload_firmware()
281 phy_write(phydev, MDIO_MMD_VEND1, GLOBAL_STANDARD_CONTROL, 0); in aquantia_upload_firmware()
284 phy_write(phydev, MDIO_MMD_VEND1, UP_CONTROL, in aquantia_upload_firmware()
289 phy_write(phydev, MDIO_MMD_VEND1, UP_CONTROL, UP_RUN_STALL_OVERRIDE); in aquantia_upload_firmware()
291 printf("%s firmare loading done.\n", phydev->dev->name); in aquantia_upload_firmware()
297 static int aquantia_upload_firmware(struct phy_device *phydev) in aquantia_upload_firmware() argument
299 printf("ERROR %s firmware loading disabled.\n", phydev->dev->name); in aquantia_upload_firmware()
319 static int aquantia_set_proto(struct phy_device *phydev, in aquantia_set_proto() argument
328 phy_write(phydev, MDIO_MMD_VEND1, AQUANTIA_VND1_GSTART_RATE, in aquantia_set_proto()
333 phy_write(phydev, MDIO_MMD_VEND1, in aquantia_set_proto()
339 static int aquantia_dts_config(struct phy_device *phydev) in aquantia_dts_config() argument
342 ofnode node = phydev->node; in aquantia_dts_config()
347 if (phydev->drv->data != AQUANTIA_GEN2 && in aquantia_dts_config()
348 phydev->drv->data != AQUANTIA_GEN3) in aquantia_dts_config()
356 reg = phy_read(phydev, MDIO_MMD_PMAPMD, in aquantia_dts_config()
361 phy_write(phydev, MDIO_MMD_PMAPMD, AQUANTIA_PMA_RX_VENDOR_P1, in aquantia_dts_config()
371 phy_write(phydev, MDIO_MMD_VEND1, AQUANTIA_VND1_SMBUS0, in aquantia_dts_config()
373 phy_write(phydev, MDIO_MMD_VEND1, AQUANTIA_VND1_SMBUS1, in aquantia_dts_config()
381 static bool aquantia_link_is_up(struct phy_device *phydev) in aquantia_link_is_up() argument
390 if (phydev->drv->data == AQUANTIA_GEN2 || in aquantia_link_is_up()
391 phydev->drv->data == AQUANTIA_GEN3) { in aquantia_link_is_up()
401 phy_read(phydev, devad, regnum); in aquantia_link_is_up()
402 reg = phy_read(phydev, devad, regnum); in aquantia_link_is_up()
407 int aquantia_config(struct phy_device *phydev) in aquantia_config() argument
409 int interface = phydev->interface; in aquantia_config()
420 rstatus = phy_read(phydev, MDIO_MMD_VEND1, GLOBAL_ALARM_1); in aquantia_config()
426 id = phy_read(phydev, MDIO_MMD_VEND1, GLOBAL_FIRMWARE_ID); in aquantia_config()
427 rstatus = phy_read(phydev, MDIO_MMD_VEND1, GLOBAL_RSTATUS_1); in aquantia_config()
428 fault = phy_read(phydev, MDIO_MMD_VEND1, GLOBAL_FAULT); in aquantia_config()
432 phydev->dev->name, (id >> 8), id & 0xff, in aquantia_config()
436 printf("%s fault 0x%04x detected\n", phydev->dev->name, fault); in aquantia_config()
441 ret = aquantia_upload_firmware(phydev); in aquantia_config()
452 reg_val1 = phy_read(phydev, MDIO_MMD_PHYXS, in aquantia_config()
465 if (!aquantia_link_is_up(phydev) && in aquantia_config()
466 (phydev->drv->data == AQUANTIA_GEN2 || in aquantia_config()
467 phydev->drv->data == AQUANTIA_GEN3)) { in aquantia_config()
469 phy_write(phydev, MDIO_MMD_VEND1, AQUANTIA_VND1_GLOBAL_SC, in aquantia_config()
474 aquantia_set_proto(phydev, interface); in aquantia_config()
476 aquantia_dts_config(phydev); in aquantia_config()
479 phy_write(phydev, MDIO_MMD_VEND1, AQUANTIA_VND1_GLOBAL_SC, 0); in aquantia_config()
483 val = phy_read(phydev, MDIO_MMD_PMAPMD, MII_BMCR); in aquantia_config()
488 phydev->advertising = SUPPORTED_1000baseT_Full; in aquantia_config()
489 phydev->supported = phydev->advertising; in aquantia_config()
492 phy_write(phydev, MDIO_MMD_PMAPMD, MII_BMCR, val); in aquantia_config()
499 phydev->advertising = SUPPORTED_10000baseT_Full; in aquantia_config()
500 phydev->supported = phydev->advertising; in aquantia_config()
504 phy_write(phydev, MDIO_MMD_PMAPMD, MII_BMCR, in aquantia_config()
509 reg_val1 = phy_read(phydev, MDIO_MMD_PHYXS, in aquantia_config()
515 phydev->dev->name); in aquantia_config()
519 phydev->dev->name); in aquantia_config()
522 phy_write(phydev, MDIO_MMD_PHYXS, in aquantia_config()
527 phydev->advertising = SUPPORTED_1000baseT_Full; in aquantia_config()
528 phydev->supported = phydev->advertising; in aquantia_config()
530 phy_write(phydev, MDIO_MMD_AN, AQUNTIA_10G_CTL, 1); in aquantia_config()
531 phy_write(phydev, MDIO_MMD_AN, AQUNTIA_VENDOR_P1, 0x9440); in aquantia_config()
535 phydev->advertising = SUPPORTED_100baseT_Full; in aquantia_config()
536 phydev->supported = phydev->advertising; in aquantia_config()
539 phy_write(phydev, MDIO_MMD_PMAPMD, MII_BMCR, val); in aquantia_config()
543 val = phy_read(phydev, MDIO_MMD_VEND1, AQUANTIA_RESERVED_STATUS); in aquantia_config()
544 reg_val1 = phy_read(phydev, MDIO_MMD_VEND1, AQUANTIA_FIRMWARE_ID); in aquantia_config()
546 debug("%s: %s Firmware Version %x.%x.%x\n", phydev->dev->name, in aquantia_config()
547 phydev->drv->name, in aquantia_config()
555 int aquantia_startup(struct phy_device *phydev) in aquantia_startup() argument
560 phydev->duplex = DUPLEX_FULL; in aquantia_startup()
563 if (!aquantia_link_is_up(phydev)) { in aquantia_startup()
565 phydev->dev->name); in aquantia_startup()
570 } while (!aquantia_link_is_up(phydev) && in aquantia_startup()
579 phy_read(phydev, MDIO_MMD_AN, MDIO_STAT1); in aquantia_startup()
580 reg = phy_read(phydev, MDIO_MMD_AN, MDIO_STAT1); in aquantia_startup()
582 phydev->link = 0; in aquantia_startup()
584 phydev->link = 1; in aquantia_startup()
586 speed = phy_read(phydev, MDIO_MMD_PMAPMD, MII_BMCR); in aquantia_startup()
589 phydev->speed = SPEED_10000; in aquantia_startup()
591 phydev->speed = SPEED_1000; in aquantia_startup()
594 phydev->speed = SPEED_100; in aquantia_startup()
596 phydev->speed = SPEED_10; in aquantia_startup()