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 * $FreeBSD$ 27 */ 28 29#ifndef _DEV_EXTRES_PHY_USB_H_ 30#define _DEV_EXTRES_PHY_USB_H_ 31 32#include <dev/extres/phy/phy.h> 33#include "phynode_usb_if.h" 34 35#define PHY_USB_MODE_UNKNOWN 0 36#define PHY_USB_MODE_HOST 1 37#define PHY_USB_MODE_OTG 2 38#define PHY_USB_MODE_DEVICE 3 39 40/* Standard USB phy parameters. */ 41struct phynode_usb_std_param { 42 int usb_mode; 43}; 44 45struct phynode_usb_sc { 46 struct phynode_usb_std_param std_param; 47}; 48 49/* Initialization parameters. */ 50struct phynode_usb_init_def { 51 struct phynode_init_def phynode_init_def; 52 struct phynode_usb_std_param std_param; /* Standard parameters */ 53}; 54 55 56/* 57 * Shorthands for constructing method tables. 58 */ 59#define PHYNODEUSBMETHOD KOBJMETHOD 60#define PHYNODEUSBMETHOD_END KOBJMETHOD_END 61#define phynode_usb_method_t kobj_method_t 62#define phynode_usb_class_t kobj_class_t 63DECLARE_CLASS(phynode_usb_class); 64 65struct phynode *phynode_usb_create(device_t pdev, phynode_class_t phynode_class, 66 struct phynode_usb_init_def *def); 67struct phynode *phynode_usb_register(struct phynode *phynode); 68 69#if 0 70/* XXX to be implemented */ 71#ifdef FDT 72int phynode_usb_parse_ofw_stdparam(device_t dev, phandle_t node, 73 struct phynode_usb_init_def *def); 74#endif 75#endif 76 77/* Phynode functions. */ 78int phynode_usb_set_mode(struct phynode *phynode, int usb_mode); 79int phynode_usb_get_mode(struct phynode *phynode, int *usb_mode); 80 81/* Consumer functions. */ 82int phy_usb_set_mode(phy_t phy, int usb_mode); 83int phy_usb_get_mode(phy_t phy, int *usb_mode); 84 85#endif /*_DEV_EXTRES_PHY_USB_H_*/ 86