xref: /freebsd/sys/dev/phy/phy_usb.h (revision 2e3f49888ec8851bafb22011533217487764fdb0)
1 /*-
2  * Copyright 2018 Michal Meloun <mmel@FreeBSD.org>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
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.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  */
26 
27 #ifndef _DEV_PHY_USB_H_
28 #define	_DEV_PHY_USB_H_
29 
30 #include <dev/phy/phy.h>
31 #include "phynode_usb_if.h"
32 
33 #define	PHY_USB_MODE_UNKNOWN	0
34 #define	PHY_USB_MODE_HOST	1
35 #define	PHY_USB_MODE_OTG	2
36 #define	PHY_USB_MODE_DEVICE	3
37 
38 /* Standard USB phy parameters. */
39 struct phynode_usb_std_param {
40 	int	usb_mode;
41 };
42 
43 struct phynode_usb_sc {
44    struct phynode_usb_std_param		std_param;
45 };
46 
47 /* Initialization parameters. */
48 struct phynode_usb_init_def {
49 	struct phynode_init_def		phynode_init_def;
50 	struct phynode_usb_std_param	std_param; /* Standard parameters */
51 };
52 
53 
54 /*
55  * Shorthands for constructing method tables.
56  */
57 #define	PHYNODEUSBMETHOD	KOBJMETHOD
58 #define	PHYNODEUSBMETHOD_END	KOBJMETHOD_END
59 #define phynode_usb_method_t	kobj_method_t
60 #define phynode_usb_class_t	kobj_class_t
61 DECLARE_CLASS(phynode_usb_class);
62 
63 struct phynode *phynode_usb_create(device_t pdev, phynode_class_t phynode_class,
64     struct phynode_usb_init_def *def);
65 struct phynode *phynode_usb_register(struct phynode *phynode);
66 
67 #if 0
68 /* XXX to be implemented */
69 #ifdef FDT
70 int phynode_usb_parse_ofw_stdparam(device_t dev, phandle_t node,
71     struct phynode_usb_init_def *def);
72 #endif
73 #endif
74 
75 /* Phynode functions. */
76 int phynode_usb_set_mode(struct phynode *phynode, int usb_mode);
77 int phynode_usb_get_mode(struct phynode *phynode, int *usb_mode);
78 
79 /* Consumer functions. */
80 int phy_usb_set_mode(phy_t phy, int usb_mode);
81 int phy_usb_get_mode(phy_t phy, int *usb_mode);
82 
83 #endif /*_DEV_PHY_USB_H_*/
84