xref: /freebsd/sys/dev/usb/usb_fdt_support.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1*bac5ec96SIan Lepore /*-
2*bac5ec96SIan Lepore  * SPDX-License-Identifier: BSD-2-Clause
3*bac5ec96SIan Lepore  *
4*bac5ec96SIan Lepore  * Copyright (c) 2019 Ian Lepore <ian@FreeBSD.org>
5*bac5ec96SIan Lepore  *
6*bac5ec96SIan Lepore  * Redistribution and use in source and binary forms, with or without
7*bac5ec96SIan Lepore  * modification, are permitted provided that the following conditions
8*bac5ec96SIan Lepore  * are met:
9*bac5ec96SIan Lepore  * 1. Redistributions of source code must retain the above copyright
10*bac5ec96SIan Lepore  *    notice, this list of conditions and the following disclaimer.
11*bac5ec96SIan Lepore  * 2. Redistributions in binary form must reproduce the above copyright
12*bac5ec96SIan Lepore  *    notice, this list of conditions and the following disclaimer in the
13*bac5ec96SIan Lepore  *    documentation and/or other materials provided with the distribution.
14*bac5ec96SIan Lepore  *
15*bac5ec96SIan Lepore  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16*bac5ec96SIan Lepore  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17*bac5ec96SIan Lepore  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18*bac5ec96SIan Lepore  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19*bac5ec96SIan Lepore  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20*bac5ec96SIan Lepore  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21*bac5ec96SIan Lepore  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22*bac5ec96SIan Lepore  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23*bac5ec96SIan Lepore  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24*bac5ec96SIan Lepore  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25*bac5ec96SIan Lepore  * SUCH DAMAGE.
26*bac5ec96SIan Lepore  */
27*bac5ec96SIan Lepore 
28*bac5ec96SIan Lepore #ifndef _USB_FDT_SUPPORT_H_
29*bac5ec96SIan Lepore #define	_USB_FDT_SUPPORT_H_
30*bac5ec96SIan Lepore 
31*bac5ec96SIan Lepore struct usb_device;
32*bac5ec96SIan Lepore struct usb_ether;
33*bac5ec96SIan Lepore 
34*bac5ec96SIan Lepore /*
35*bac5ec96SIan Lepore  * Get the device's MAC address from the FDT data.  Fills in ue->ue_eaddr and
36*bac5ec96SIan Lepore  * returns 0 on success, otherwise leaves ue_eaddr untouched and returns
37*bac5ec96SIan Lepore  * non-zero.  This first attempts to get the address from the "mac-address"
38*bac5ec96SIan Lepore  * property, and if that's not valid it tries the "local-mac-address" property;
39*bac5ec96SIan Lepore  * this matches the linux interpretation of the precedence of those properties.
40*bac5ec96SIan Lepore  */
41*bac5ec96SIan Lepore int usb_fdt_get_mac_addr(device_t dev, struct usb_ether* ue);
42*bac5ec96SIan Lepore 
43*bac5ec96SIan Lepore /* Get the FDT node for dev.  Returns -1 if dev is not in the FDT data. */
44*bac5ec96SIan Lepore phandle_t usb_fdt_get_node(device_t dev, struct usb_device* udev);
45*bac5ec96SIan Lepore 
46*bac5ec96SIan Lepore #endif
47