2 * Copyright 2018 Michal Meloun <mmel@FreeBSD.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef DEV_EXTRES_PHY_INTERNAL_H
29 #define DEV_EXTRES_PHY_INTERNAL_H
31 /* Forward declarations. */
35 typedef TAILQ_HEAD(phynode_list, phynode) phynode_list_t;
36 typedef TAILQ_HEAD(phy_list, phy) phy_list_t;
44 TAILQ_ENTRY(phynode) phylist_link; /* Global list entry */
45 phy_list_t consumers_list; /* Consumers list */
48 /* Details of this device. */
49 const char *name; /* Globally unique name */
51 device_t pdev; /* Producer device_t */
52 void *softc; /* Producer softc */
53 intptr_t id; /* Per producer unique id */
55 phandle_t ofw_node; /* OFW node of phy */
57 struct sx lock; /* Lock for this phy */
58 int ref_cnt; /* Reference counter */
59 int enable_cnt; /* Enabled counter */
63 device_t cdev; /* consumer device*/
64 struct phynode *phynode;
65 TAILQ_ENTRY(phy) link; /* Consumers list entry */
71 #define PHY_TOPO_SLOCK() sx_slock(&phynode_topo_lock)
72 #define PHY_TOPO_XLOCK() sx_xlock(&phynode_topo_lock)
73 #define PHY_TOPO_UNLOCK() sx_unlock(&phynode_topo_lock)
74 #define PHY_TOPO_ASSERT() sx_assert(&phynode_topo_lock, SA_LOCKED)
75 #define PHY_TOPO_XASSERT() sx_assert(&phynode_topo_lock, SA_XLOCKED)
77 #define PHYNODE_SLOCK(_sc) sx_slock(&((_sc)->lock))
78 #define PHYNODE_XLOCK(_sc) sx_xlock(&((_sc)->lock))
79 #define PHYNODE_UNLOCK(_sc) sx_unlock(&((_sc)->lock))
81 extern struct sx phynode_topo_lock;
83 #endif /* DEV_EXTRES_PHY_INTERNAL_H */