FreeBSD/Linux Kernel Cross Reference
sys/dev/extres/phy/phy.h
1 /*-
2 * Copyright 2016 Michal Meloun <mmel@FreeBSD.org>
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 */
25
26 #ifndef DEV_EXTRES_PHY_H
27 #define DEV_EXTRES_PHY_H
28 #include "opt_platform.h"
29
30 #include <sys/kobj.h>
31 #ifdef FDT
32 #include <dev/ofw/ofw_bus.h>
33 #endif
34
35 #define PHY_STATUS_ENABLED 0x00000001
36
37 typedef enum phy_mode {
38 PHY_MODE_INVALID,
39 PHY_MODE_USB_HOST,
40 PHY_MODE_USB_DEVICE,
41 PHY_MODE_USB_OTG,
42 PHY_MODE_UFS,
43 PHY_MODE_PCIE,
44 PHY_MODE_ETHERNET,
45 PHY_MODE_MIPI_DPHY,
46 PHY_MODE_SATA,
47 PHY_MODE_LVDS,
48 PHY_MODE_DP
49 } phy_mode_t ;
50
51 typedef enum phy_submode {
52 /* Common */
53 PHY_SUBMODE_NA = 0, /* Not applicable */
54 PHY_SUBMODE_INTERNAL,
55
56 /* Ethernet */
57 PHY_SUBMODE_ETH_MII = 1000,
58 PHY_SUBMODE_ETH_GMII,
59 PHY_SUBMODE_ETH_SGMII,
60 PHY_SUBMODE_ETH_TBI,
61 PHY_SUBMODE_ETH_REVMII,
62 PHY_SUBMODE_ETH_RMII,
63 PHY_SUBMODE_ETH_RGMII,
64 PHY_SUBMODE_ETH_RGMII_ID,
65 PHY_SUBMODE_ETH_RGMII_RXID,
66 PHY_SUBMODE_ETH_RGMII_TXID,
67 PHY_SUBMODE_ETH_RTBI,
68 PHY_SUBMODE_ETH_SMII,
69 PHY_SUBMODE_ETH_XGMII,
70 PHY_SUBMODE_ETH_XLGMII,
71 PHY_SUBMODE_ETH_MOCA,
72 PHY_SUBMODE_ETH_QSGMII,
73 PHY_SUBMODE_ETH_TRGMII,
74 PHY_SUBMODE_ETH_1000BASEX,
75 PHY_SUBMODE_ETH_2500BASEX,
76 PHY_SUBMODE_ETH_RXAUI,
77 PHY_SUBMODE_ETH_XAUI,
78 PHY_SUBMODE_ETH_10GBASER,
79 PHY_SUBMODE_ETH_USXGMII,
80 PHY_SUBMODE_ETH_10GKR,
81
82 /* USB */
83 PHY_SUBMODE_USB_LS = 2000,
84 PHY_SUBMODE_USB_FS,
85 PHY_SUBMODE_USB_HS,
86 PHY_SUBMODE_USB_SS,
87
88 /* UFS */
89 PHY_SUBMODE_UFS_HS_A = 3000,
90 PHY_SUBMODE_UFS_HS_B,
91
92 } phy_submode_t;
93
94 typedef struct phy *phy_t;
95
96 /* Initialization parameters. */
97 struct phynode_init_def {
98 intptr_t id; /* Phy ID */
99 #ifdef FDT
100 phandle_t ofw_node; /* OFW node of phy */
101 #endif
102 };
103
104 #include "phynode_if.h"
105
106 /*
107 * Shorthands for constructing method tables.
108 */
109 #define PHYNODEMETHOD KOBJMETHOD
110 #define PHYNODEMETHOD_END KOBJMETHOD_END
111 #define phynode_method_t kobj_method_t
112 #define phynode_class_t kobj_class_t
113 DECLARE_CLASS(phynode_class);
114
115 /*
116 * Provider interface
117 */
118 struct phynode *phynode_create(device_t pdev, phynode_class_t phynode_class,
119 struct phynode_init_def *def);
120 struct phynode *phynode_register(struct phynode *phynode);
121 void *phynode_get_softc(struct phynode *phynode);
122 device_t phynode_get_device(struct phynode *phynode);
123 intptr_t phynode_get_id(struct phynode *phynode);
124 int phynode_enable(struct phynode *phynode);
125 int phynode_disable(struct phynode *phynode);
126 int phynode_set_mode(struct phynode *phynode, phy_mode_t mode,
127 phy_submode_t submode);
128 int phynode_status(struct phynode *phynode, int *status);
129 #ifdef FDT
130 phandle_t phynode_get_ofw_node(struct phynode *phynode);
131 #endif
132
133 /*
134 * Consumer interface
135 */
136 int phy_get_by_id(device_t consumer_dev, device_t provider_dev, intptr_t id,
137 phy_t *phy);
138 void phy_release(phy_t phy);
139 int phy_enable(phy_t phy);
140 int phy_disable(phy_t phy);
141 int phy_set_mode(phy_t phy, phy_mode_t mode, phy_submode_t submode);
142 int phy_status(phy_t phy, int *value);
143 #ifdef FDT
144 int phy_get_by_ofw_name(device_t consumer, phandle_t node, char *name,
145 phy_t *phy);
146 int phy_get_by_ofw_idx(device_t consumer, phandle_t node, int idx, phy_t *phy);
147 int phy_get_by_ofw_property(device_t consumer, phandle_t node, char *name,
148 phy_t *phy);
149 #endif
150
151 #endif /* DEV_EXTRES_PHY_H */
Cache object: 078ac28227736df4eba7c2aa5894413c
|