• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * drivers/usb/sunxi_usb/include/sunxi_usb_board.h
3  * (C) Copyright 2010-2015
4  * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
5  * javen, 2010-12-20, create this file
6  *
7  * usb board config.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of
12  * the License, or (at your option) any later version.
13  *
14  */
15 
16 #ifndef __SUNXI_USB_BOARD_H__
17 #define __SUNXI_USB_BOARD_H__
18 
19 #include "sunxi-gpio.h"
20 #include <linux/of_gpio.h>
21 
22 #if defined(CONFIG_DUAL_ROLE_USB_INTF)
23 #include <linux/usb/class-dual-role.h>
24 #endif
25 
26 #if defined(CONFIG_TYPEC)
27 #include <linux/usb/typec.h>
28 #endif
29 
30 #define  SET_USB_PARA				"usb_para"
31 #define  SET_USB0				"usbc0"
32 #define  SET_USB1				"usbc1"
33 #define  SET_USB2				"usbc2"
34 
35 #define  KEY_USB_GLOBAL_ENABLE			"usb_global_enable"
36 #define  KEY_USBC_NUM				"usbc_num"
37 
38 #define  KEY_USB_ENABLE				"usbc0_used"
39 #define  KEY_USB_PORT_TYPE			"usb_port_type"
40 #define  KEY_USB_DET_MODE			"usb_detect_mode"
41 #define  KEY_USB_ID_GPIO			"usb_id_gpio"
42 #define  KEY_USB_DETVBUS_GPIO			"usb_det_vbus_gpio"
43 
44 #define  KEY_USB_REGULATOR_IO			"usb_regulator_io"
45 #define  KEY_USB_REGULATOR_IO_VOL		"usb_regulator_vol"
46 #define  KEY_USB_REGULATOR_ID_VBUS		"usb_regulator_id_vbus"
47 #define  KEY_USB_REGULATOR_ID_VBUS_VOL		"usb_regulator_id_vbus_vol"
48 
49 #define  KEY_USB_WAKEUP_SUSPEND		        "usb_wakeup_suspend"
50 
51 /* USB config info */
52 enum usb_gpio_group_type {
53 	GPIO_GROUP_TYPE_PIO = 0,
54 	GPIO_GROUP_TYPE_POWER,
55 };
56 
57 /* 0: device only; 1: host only; 2: otg */
58 enum usb_port_type {
59 	USB_PORT_TYPE_DEVICE = 0,
60 	USB_PORT_TYPE_HOST,
61 	USB_PORT_TYPE_OTG,
62 };
63 
64 /* 0: dp/dm detect, 1: vbus/id detect */
65 enum usb_detect_type {
66 	USB_DETECT_TYPE_DP_DM = 0,
67 	USB_DETECT_TYPE_VBUS_ID,
68 };
69 
70 /* 0: thread scan mode; 1: gpio interrupt mode */
71 enum usb_detect_mode {
72 	USB_DETECT_MODE_THREAD = 0,
73 	USB_DETECT_MODE_INTR,
74 };
75 
76 enum usb_det_vbus_type {
77 	USB_DET_VBUS_TYPE_NULL = 0,
78 	USB_DET_VBUS_TYPE_GPIO,
79 	USB_DET_VBUS_TYPE_AXP,
80 };
81 
82 enum usb_id_type {
83 	USB_ID_TYPE_NULL = 0,
84 	USB_ID_TYPE_GPIO,
85 	USB_ID_TYPE_AXP,
86 };
87 
88 /* pio info */
89 typedef struct usb_gpio {
90 	/* pio valid, 1 - valid, 0 - invalid */
91 	__u32 valid;
92 	struct gpio_config gpio_set;
93 } usb_gpio_t;
94 
95 typedef struct usb_port_info {
96 	__u32 enable;				/* port valid */
97 
98 	__u32 port_no;				/* usb port number */
99 	enum usb_port_type port_type;		/* usb port type */
100 	enum usb_detect_type detect_type;	/* usb detect type */
101 	enum usb_detect_mode detect_mode;	/* usb detect mode */
102 	enum usb_det_vbus_type det_vbus_type;
103 	enum usb_id_type id_type;
104 	const char *det_vbus_name;
105 	const char *id_name;
106 	usb_gpio_t id;				/* usb id pin info */
107 	usb_gpio_t det_vbus;			/* usb vbus pin info */
108 	usb_gpio_t drv_vbus;			/* usb drv_vbus pin info */
109 	usb_gpio_t restrict_gpio_set;		/* usb drv_vbus pin info */
110 	__u32 usb_restrict_flag;		/* usb port number(?) */
111 	__u32 voltage;				/* usb port number(?) */
112 	__u32 capacity;				/* usb port number(?) */
113 
114 	int id_irq_num;				/* id gpio irq num */
115 
116 #if defined(CONFIG_DUAL_ROLE_USB_INTF)
117 	struct dual_role_phy_instance *dual_role;
118 	struct dual_role_phy_desc dr_desc;
119 #endif
120 #if defined(CONFIG_TYPEC)
121 	struct typec_port *typec_port;
122 	struct typec_partner *partner;
123 	struct typec_capability typec_caps;
124 	bool connected;
125 #endif
126 } usb_port_info_t;
127 
128 typedef struct usb_cfg {
129 	u32 usb_global_enable;
130 	u32 usbc_num;
131 	struct platform_device *pdev;
132 
133 	struct usb_port_info port;
134 } usb_cfg_t;
135 
136 #endif /* __SUNXI_USB_BOARD_H__ */
137