2 * Copyright 2016 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_H
29 #define DEV_EXTRES_PHY_H
30 #include "opt_platform.h"
34 #include <dev/ofw/ofw_bus.h>
36 #include "phynode_if.h"
38 #define PHY_STATUS_ENABLED 0x00000001
40 typedef struct phy *phy_t;
42 /* Initialization parameters. */
43 struct phynode_init_def {
44 intptr_t id; /* Phy ID */
46 phandle_t ofw_node; /* OFW node of phy */
51 * Shorthands for constructing method tables.
53 #define PHYNODEMETHOD KOBJMETHOD
54 #define PHYNODEMETHOD_END KOBJMETHOD_END
55 #define phynode_method_t kobj_method_t
56 #define phynode_class_t kobj_class_t
57 DECLARE_CLASS(phynode_class);
62 struct phynode *phynode_create(device_t pdev, phynode_class_t phynode_class,
63 struct phynode_init_def *def);
64 struct phynode *phynode_register(struct phynode *phynode);
65 void *phynode_get_softc(struct phynode *phynode);
66 device_t phynode_get_device(struct phynode *phynode);
67 intptr_t phynode_get_id(struct phynode *phynode);
68 int phynode_enable(struct phynode *phynode);
69 int phynode_disable(struct phynode *phynode);
70 int phynode_status(struct phynode *phynode, int *status);
72 phandle_t phynode_get_ofw_node(struct phynode *phynode);
78 int phy_get_by_id(device_t consumer_dev, device_t provider_dev, intptr_t id,
80 void phy_release(phy_t phy);
81 int phy_enable(phy_t phy);
82 int phy_disable(phy_t phy);
83 int phy_status(phy_t phy, int *value);
86 int phy_get_by_ofw_name(device_t consumer, phandle_t node, char *name,
88 int phy_get_by_ofw_idx(device_t consumer, phandle_t node, int idx, phy_t *phy);
89 int phy_get_by_ofw_property(device_t consumer, phandle_t node, char *name,
93 #endif /* DEV_EXTRES_PHY_H */