LCOV - code coverage report
Current view: top level - include/linux - of_mdio.h (source / functions) Hit Total Coverage
Test: Real Lines: 0 8 0.0 %
Date: 2020-10-17 15:46:16 Functions: 0 1 0.0 %
Legend: Neither, QEMU, Real, Both Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: GPL-2.0-only */
       2                 :            : /*
       3                 :            :  * OF helpers for the MDIO (Ethernet PHY) API
       4                 :            :  *
       5                 :            :  * Copyright (c) 2009 Secret Lab Technologies, Ltd.
       6                 :            :  */
       7                 :            : 
       8                 :            : #ifndef __LINUX_OF_MDIO_H
       9                 :            : #define __LINUX_OF_MDIO_H
      10                 :            : 
      11                 :            : #include <linux/phy.h>
      12                 :            : #include <linux/of.h>
      13                 :            : 
      14                 :            : #if IS_ENABLED(CONFIG_OF_MDIO)
      15                 :            : extern int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np);
      16                 :            : extern struct phy_device *of_phy_find_device(struct device_node *phy_np);
      17                 :            : extern struct phy_device *of_phy_connect(struct net_device *dev,
      18                 :            :                                          struct device_node *phy_np,
      19                 :            :                                          void (*hndlr)(struct net_device *),
      20                 :            :                                          u32 flags, phy_interface_t iface);
      21                 :            : extern struct phy_device *
      22                 :            : of_phy_get_and_connect(struct net_device *dev, struct device_node *np,
      23                 :            :                        void (*hndlr)(struct net_device *));
      24                 :            : struct phy_device *of_phy_attach(struct net_device *dev,
      25                 :            :                                  struct device_node *phy_np, u32 flags,
      26                 :            :                                  phy_interface_t iface);
      27                 :            : 
      28                 :            : extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np);
      29                 :            : extern int of_phy_register_fixed_link(struct device_node *np);
      30                 :            : extern void of_phy_deregister_fixed_link(struct device_node *np);
      31                 :            : extern bool of_phy_is_fixed_link(struct device_node *np);
      32                 :            : 
      33                 :            : 
      34                 :          0 : static inline int of_mdio_parse_addr(struct device *dev,
      35                 :            :                                      const struct device_node *np)
      36                 :            : {
      37                 :            :         u32 addr;
      38                 :            :         int ret;
      39                 :            : 
      40                 :            :         ret = of_property_read_u32(np, "reg", &addr);
      41                 :          0 :         if (ret < 0) {
      42                 :          0 :                 dev_err(dev, "%s has invalid PHY address\n", np->full_name);
      43                 :          0 :                 return ret;
      44                 :            :         }
      45                 :            : 
      46                 :            :         /* A PHY must have a reg property in the range [0-31] */
      47                 :          0 :         if (addr >= PHY_MAX_ADDR) {
      48                 :          0 :                 dev_err(dev, "%s PHY address %i is too large\n",
      49                 :            :                         np->full_name, addr);
      50                 :          0 :                 return -EINVAL;
      51                 :            :         }
      52                 :            : 
      53                 :          0 :         return addr;
      54                 :            : }
      55                 :            : 
      56                 :            : #else /* CONFIG_OF_MDIO */
      57                 :            : static inline int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
      58                 :            : {
      59                 :            :         /*
      60                 :            :          * Fall back to the non-DT function to register a bus.
      61                 :            :          * This way, we don't have to keep compat bits around in drivers.
      62                 :            :          */
      63                 :            : 
      64                 :            :         return mdiobus_register(mdio);
      65                 :            : }
      66                 :            : 
      67                 :            : static inline struct phy_device *of_phy_find_device(struct device_node *phy_np)
      68                 :            : {
      69                 :            :         return NULL;
      70                 :            : }
      71                 :            : 
      72                 :            : static inline struct phy_device *of_phy_connect(struct net_device *dev,
      73                 :            :                                                 struct device_node *phy_np,
      74                 :            :                                                 void (*hndlr)(struct net_device *),
      75                 :            :                                                 u32 flags, phy_interface_t iface)
      76                 :            : {
      77                 :            :         return NULL;
      78                 :            : }
      79                 :            : 
      80                 :            : static inline struct phy_device *
      81                 :            : of_phy_get_and_connect(struct net_device *dev, struct device_node *np,
      82                 :            :                        void (*hndlr)(struct net_device *))
      83                 :            : {
      84                 :            :         return NULL;
      85                 :            : }
      86                 :            : 
      87                 :            : static inline struct phy_device *of_phy_attach(struct net_device *dev,
      88                 :            :                                                struct device_node *phy_np,
      89                 :            :                                                u32 flags, phy_interface_t iface)
      90                 :            : {
      91                 :            :         return NULL;
      92                 :            : }
      93                 :            : 
      94                 :            : static inline struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np)
      95                 :            : {
      96                 :            :         return NULL;
      97                 :            : }
      98                 :            : 
      99                 :            : static inline int of_mdio_parse_addr(struct device *dev,
     100                 :            :                                      const struct device_node *np)
     101                 :            : {
     102                 :            :         return -ENOSYS;
     103                 :            : }
     104                 :            : static inline int of_phy_register_fixed_link(struct device_node *np)
     105                 :            : {
     106                 :            :         return -ENOSYS;
     107                 :            : }
     108                 :            : static inline void of_phy_deregister_fixed_link(struct device_node *np)
     109                 :            : {
     110                 :            : }
     111                 :            : static inline bool of_phy_is_fixed_link(struct device_node *np)
     112                 :            : {
     113                 :            :         return false;
     114                 :            : }
     115                 :            : #endif
     116                 :            : 
     117                 :            : 
     118                 :            : #endif /* __LINUX_OF_MDIO_H */
    

Generated by: LCOV version 1.14