Lines Matching +full:shared +full:- +full:interrupt
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
4 * Based on code in sungem_phy.c and (long-removed) gianfar_phy.c
73 * Set phydev->irq to PHY_POLL if interrupts are not supported,
75 * the attached MAC driver handles the interrupt
77 #define PHY_POLL -1
78 #define PHY_MAC_INTERRUPT -2
86 * enum phy_interface_t - Interface Mode definitions
88 * @PHY_INTERFACE_MODE_NA: Not Applicable - don't touch
90 * @PHY_INTERFACE_MODE_MII: Media-independent interface
91 * @PHY_INTERFACE_MODE_GMII: Gigabit media-independent interface
92 * @PHY_INTERFACE_MODE_SGMII: Serial gigabit media-independent interface
97 * @PHY_INTERFACE_MODE_RGMII: Reduced gigabit media-independent interface
103 * @PHY_INTERFACE_MODE_XGMII: 10 gigabit media-independent interface
104 * @PHY_INTERFACE_MODE_XLGMII:40 gigabit media-independent interface
117 * @PHY_INTERFACE_MODE_10GKR: 10GBASE-KR - with Clause 73 AN
119 * @PHY_INTERFACE_MODE_1000BASEKX: 1000Base-KX - with Clause 73 AN
151 /* 10GBASE-R, XFI, SFI - single lane 10G Serdes */
155 /* 10GBASE-KR - with Clause 73 AN */
197 * phy_supported_speeds - return all speeds currently supported by a PHY device
204 * phy_modes - map phy_interface_t enum to device tree binding of phy-mode
208 * into the device tree binding of 'phy-mode', so that Ethernet
227 return "rev-mii"; in phy_modes()
231 return "rev-rmii"; in phy_modes()
235 return "rgmii-id"; in phy_modes()
237 return "rgmii-rxid"; in phy_modes()
239 return "rgmii-txid"; in phy_modes()
255 return "1000base-x"; in phy_modes()
257 return "1000base-kx"; in phy_modes()
259 return "2500base-x"; in phy_modes()
261 return "5gbase-r"; in phy_modes()
267 return "10gbase-r"; in phy_modes()
269 return "25gbase-r"; in phy_modes()
273 return "10gbase-kr"; in phy_modes()
275 return "100base-x"; in phy_modes()
300 * struct mdio_bus_stats - Statistics counters for MDIO busses
317 * struct phy_package_shared - Shared information in PHY packages
319 * @refcnt: Number of PHYs connected to this shared data
321 * @priv_size: Size of the shared private data @priv
322 * @priv: Driver private data shared across a PHY package
324 * Represents a shared structure between different phydev's in the same
335 /* note that this pointer is shared between different phydevs and
348 * struct mii_bus - Represents an MDIO bus
402 * @irq: An array of interrupts, each PHY's interrupt at the index
422 /** @shared_lock: protect access to the shared element */
425 /** @shared: shared state across different PHYs */
426 struct phy_package_shared *shared[PHY_MAX_ADDR]; member
433 * mdiobus_alloc - Allocate an MDIO bus structure
465 * enum phy_state - PHY state machine states:
470 * - PHY driver probe function will set the state to @PHY_READY
475 * - start will set the state to UP
479 * - timer moves to @PHY_NOLINK or @PHY_RUNNING
482 * - irq or timer will set @PHY_RUNNING if link comes back
483 * - phy_stop moves to @PHY_HALTED
487 * - irq or timer will set @PHY_NOLINK if link goes down
488 * - phy_stop moves to @PHY_HALTED
492 * poll once per second, or on interrupt for it current state.
494 * - phy_stop aborts the running test and moves to @PHY_HALTED
498 * - phy_start moves to @PHY_UP
513 * struct phy_c45_device_ids - 802.3-c45 Device Identifiers
528 * struct phy_device - An instance of a PHY
533 * @c45_ids: 802.3-c45 Device Identifiers if is_c45.
547 * @dev_flags: Device-specific flags used by the PHY driver.
549 * - Bits [15:0] are free to use by the PHY driver to communicate
551 * - Bits [23:16] are currently reserved for future use.
552 * - Bits [31:24] are reserved for defining generic
554 * @irq: IRQ number of the PHY's interrupt (-1 if none)
584 * @irq_suspended: Flag indicating PHY is suspended and therefore interrupt
587 * requiring a rerun of the interrupt handler after resume
603 * @shared: Pointer to private data shared by phys in one package
610 * Contains some infrastructure for polling and interrupt
690 * Interrupt number for this PHY
691 * -1 means no interrupt
699 /* shared data pointer */
700 /* For use by PHYs inside the same package that need a shared state. */
701 struct phy_package_shared *shared; member
708 /* Interrupt and Polling infrastructure */
741 * struct phy_tdr_config - Configuration of a TDR raw test
759 #define PHY_PAIR_ALL -1
762 * struct phy_driver - Driver structure for a particular PHY type
779 * interrupt time. The goal is for the bus read/write functions
781 * and be freed up by an interrupt (The MPC85xx has this ability,
806 * up device-specific structures, if any
812 * abilities it has. Should only set phydev->supported.
819 * whether to advertise lower-speed modes for that interface. It is
839 * autonegotiation if phydev->autoneg is on,
841 * if phydev->autoneg is off
858 /** @handle_interrupt: Override default interrupt handling */
872 * @set_wol: Some devices (e.g. qnap TS-119P II) require PHY
927 * within a plug-in module
933 * @module_eeprom: Get the eeprom information from the plug-in
947 * @cable_test_get_status: Once per second, or on interrupt,
1020 * phy_is_started - Convenience function to check whether PHY is started
1025 return phydev->state >= PHY_UP; in phy_is_started()
1033 * phy_read - Convenience function for reading a given PHY register
1037 * NOTE: MUST NOT be called from interrupt context,
1038 * because the bus read/write functions may wait for an interrupt
1043 return mdiobus_read(phydev->mdio.bus, phydev->mdio.addr, regnum); in phy_read()
1060 * __phy_read - convenience function for reading a given PHY register
1068 return __mdiobus_read(phydev->mdio.bus, phydev->mdio.addr, regnum); in __phy_read()
1072 * phy_write - Convenience function for writing a given PHY register
1077 * NOTE: MUST NOT be called from interrupt context,
1078 * because the bus read/write functions may wait for an interrupt
1083 return mdiobus_write(phydev->mdio.bus, phydev->mdio.addr, regnum, val); in phy_write()
1087 * __phy_write - Convenience function for writing a given PHY register
1096 return __mdiobus_write(phydev->mdio.bus, phydev->mdio.addr, regnum, in __phy_write()
1101 * __phy_modify_changed() - Convenience function for modifying a PHY register
1115 return __mdiobus_modify_changed(phydev->mdio.bus, phydev->mdio.addr, in __phy_modify_changed()
1120 * phy_read_mmd - Convenience function for reading a register
1126 * phy_read_mmd_poll_timeout - Periodically poll a PHY register until a
1135 * tight-loops). Should be less than ~20ms since usleep_range
1136 * is used (see Documentation/timers/timers-howto.rst).
1139 * Returns 0 on success and -ETIMEDOUT upon a timeout. In either
1157 * __phy_read_mmd - Convenience function for reading a register
1163 * phy_write_mmd - Convenience function for writing a register
1169 * __phy_write_mmd - Convenience function for writing a register
1191 * __phy_set_bits - Convenience function for setting bits in a PHY register
1204 * __phy_clear_bits - Convenience function for clearing bits in a PHY register
1218 * phy_set_bits - Convenience function for setting bits in a PHY register
1229 * phy_clear_bits - Convenience function for clearing bits in a PHY register
1240 * __phy_set_bits_mmd - Convenience function for setting bits in a register
1256 * __phy_clear_bits_mmd - Convenience function for clearing bits in a register
1272 * phy_set_bits_mmd - Convenience function for setting bits in a register
1286 * phy_clear_bits_mmd - Convenience function for clearing bits in a register
1300 * phy_interrupt_is_valid - Convenience function for testing a given PHY irq
1308 return phydev->irq != PHY_POLL && phydev->irq != PHY_MAC_INTERRUPT; in phy_interrupt_is_valid()
1312 * phy_polling_mode - Convenience function for testing whether polling is
1318 if (phydev->state == PHY_CABLETEST) in phy_polling_mode()
1319 if (phydev->drv->flags & PHY_POLL_CABLE_TEST) in phy_polling_mode()
1322 return phydev->irq == PHY_POLL; in phy_polling_mode()
1326 * phy_has_hwtstamp - Tests whether a PHY time stamp configuration.
1331 return phydev && phydev->mii_ts && phydev->mii_ts->hwtstamp; in phy_has_hwtstamp()
1335 * phy_has_rxtstamp - Tests whether a PHY supports receive time stamping.
1340 return phydev && phydev->mii_ts && phydev->mii_ts->rxtstamp; in phy_has_rxtstamp()
1344 * phy_has_tsinfo - Tests whether a PHY reports time stamping and/or
1350 return phydev && phydev->mii_ts && phydev->mii_ts->ts_info; in phy_has_tsinfo()
1354 * phy_has_txtstamp - Tests whether a PHY supports transmit time stamping.
1359 return phydev && phydev->mii_ts && phydev->mii_ts->txtstamp; in phy_has_txtstamp()
1364 return phydev->mii_ts->hwtstamp(phydev->mii_ts, ifr); in phy_hwtstamp()
1370 return phydev->mii_ts->rxtstamp(phydev->mii_ts, skb, type); in phy_rxtstamp()
1376 return phydev->mii_ts->ts_info(phydev->mii_ts, tsinfo); in phy_ts_info()
1382 phydev->mii_ts->txtstamp(phydev->mii_ts, skb, type); in phy_txtstamp()
1386 * phy_is_internal - Convenience function for testing if a PHY is internal
1391 return phydev->is_internal; in phy_is_internal()
1395 * phy_on_sfp - Convenience function for testing if a PHY is on an SFP module
1400 return phydev->is_on_sfp_module; in phy_on_sfp()
1404 * phy_interface_mode_is_rgmii - Convenience function for testing if a
1415 * phy_interface_mode_is_8023z() - does the PHY interface mode use 802.3z
1419 * Returns true if the PHY interface mode uses the 16-bit negotiation
1420 * word as defined in 802.3z. (See 802.3-2015 37.2.1 Config_Reg encoding)
1429 * phy_interface_is_rgmii - Convenience function for testing if a PHY interface
1435 return phy_interface_mode_is_rgmii(phydev->interface); in phy_interface_is_rgmii()
1439 * phy_is_pseudo_fixed_link - Convenience function for testing if this
1445 return phydev->is_pseudo_fixed_link; in phy_is_pseudo_fixed_link()
1558 return -EOPNOTSUPP; in phy_start_cable_test()
1566 return -EOPNOTSUPP; in phy_start_cable_test_tdr()
1576 mdio_device_reset(&phydev->mdio, value); in phy_device_reset()
1580 dev_err(&_phydev->mdio.dev, format, ##args)
1583 dev_err_probe(&_phydev->mdio.dev, err, format, ##args)
1586 dev_info(&_phydev->mdio.dev, format, ##args)
1589 dev_warn(&_phydev->mdio.dev, format, ##args)
1592 dev_dbg(&_phydev->mdio.dev, format, ##args)
1596 return dev_name(&phydev->mdio.dev); in phydev_name()
1601 mutex_lock(&phydev->mdio.bus->mdio_lock); in phy_lock_mdio_bus()
1606 mutex_unlock(&phydev->mdio.bus->mdio_lock); in phy_unlock_mdio_bus()
1682 if (!phydev->drv) in phy_read_status()
1683 return -EIO; in phy_read_status()
1685 if (phydev->drv->read_status) in phy_read_status()
1686 return phydev->drv->read_status(phydev); in phy_read_status()
1774 struct phy_package_shared *shared = phydev->shared; in phy_package_read() local
1776 if (!shared) in phy_package_read()
1777 return -EIO; in phy_package_read()
1779 return mdiobus_read(phydev->mdio.bus, shared->addr, regnum); in phy_package_read()
1784 struct phy_package_shared *shared = phydev->shared; in __phy_package_read() local
1786 if (!shared) in __phy_package_read()
1787 return -EIO; in __phy_package_read()
1789 return __mdiobus_read(phydev->mdio.bus, shared->addr, regnum); in __phy_package_read()
1795 struct phy_package_shared *shared = phydev->shared; in phy_package_write() local
1797 if (!shared) in phy_package_write()
1798 return -EIO; in phy_package_write()
1800 return mdiobus_write(phydev->mdio.bus, shared->addr, regnum, val); in phy_package_write()
1806 struct phy_package_shared *shared = phydev->shared; in __phy_package_write() local
1808 if (!shared) in __phy_package_write()
1809 return -EIO; in __phy_package_write()
1811 return __mdiobus_write(phydev->mdio.bus, shared->addr, regnum, val); in __phy_package_write()
1817 struct phy_package_shared *shared = phydev->shared; in __phy_package_set_once() local
1819 if (!shared) in __phy_package_set_once()
1822 return !test_and_set_bit(b, &shared->flags); in __phy_package_set_once()
1857 * phy_module_driver() - Helper macro for registering PHY drivers