1 #ifndef __SUNXI_USB_BOARD_H__
2 #define __SUNXI_USB_BOARD_H__
3 
4 #define  SET_USB0               "usbc0"
5 #define  KEY_USB_ENABLE         "usb_used"
6 #define  KEY_USB_PORT_TYPE          "usb_port_type"
7 #define  KEY_USB_DET_TYPE           "usb_detect_type"
8 #define  KEY_USB_DET_MODE           "usb_detect_mode"
9 #define  KEY_USB_DETVBUS_GPIO           "usb_det_vbus_gpio"
10 #define  KEY_USB_ID_GPIO            "usb_id_gpio"
11 
12 #define  KEY_USB_DRVVBUS_GPIO           "usb_drv_vbus_gpio"
13 #define  KEY_USB_REGULATOR_IO           "usb_regulator_io"
14 #define  KEY_USB_REGULATOR_IO_VOL       "usb_regulator_vol"
15 #define  KEY_USB_REGULATOR_ID_VBUS      "usb_regulator_id_vbus"
16 #define  KEY_USB_REGULATOR_ID_VBUS_VOL      "usb_regulator_id_vbus_vol"
17 #define  KEY_USB_WAKEUP_SUSPEND             "usb_wakeup_suspend"
18 
19 /* USB config info */
20 enum usb_gpio_group_type
21 {
22     GPIO_GROUP_TYPE_PIO = 0,
23     GPIO_GROUP_TYPE_POWER,
24 };
25 
26 /* 0: device only; 1: host only; 2: otg */
27 enum usb_port_type
28 {
29     USB_PORT_TYPE_DEVICE = 0,
30     USB_PORT_TYPE_HOST,
31     USB_PORT_TYPE_OTG,
32 };
33 
34 /* 0: dp/dm detect, 1: vbus/id detect */
35 enum usb_detect_type
36 {
37     USB_DETECT_TYPE_DP_DM = 0,
38     USB_DETECT_TYPE_VBUS_ID,
39 };
40 
41 /* 0: thread scan mode; 1: gpio interrupt mode */
42 enum usb_detect_mode
43 {
44     USB_DETECT_MODE_THREAD = 0,
45     USB_DETECT_MODE_INTR,
46 };
47 
48 enum usb_det_vbus_type
49 {
50     USB_DET_VBUS_TYPE_NULL = 0,
51     USB_DET_VBUS_TYPE_GPIO,
52     USB_DET_VBUS_TYPE_AXP,
53 };
54 
55 enum usb_id_type
56 {
57     USB_ID_TYPE_NULL = 0,
58     USB_ID_TYPE_GPIO,
59     USB_ID_TYPE_AXP,
60 };
61 /*
62  * struct gpio_config - gpio config info
63  * @gpio:      gpio global index, must be unique
64  * @mul_sel:   multi sel val: 0 - input, 1 - output.
65  * @pull:      pull val: 0 - pull up/down disable, 1 - pull up
66  * @drv_level: driver level val: 0 - level 0, 1 - level 1
67  * @data:      data val: 0 - low, 1 - high, only valid when mul_sel is input/output
68  */
69 struct gpio_config
70 {
71     unsigned int data;
72     unsigned int gpio;
73     unsigned int mul_sel;
74     unsigned int pull;
75     unsigned int drv_level;
76 };
77 
78 /* pio info */
79 typedef struct usb_gpio
80 {
81     unsigned int valid; /* pio valid, 1 - valid, 0 - invalid */
82     struct gpio_config gpio_set;
83 } usb_gpio_t;
84 
85 typedef struct usb_port_info
86 {
87     unsigned int enable;                /* port valid */
88 
89     //  unsigned int port_no;               /* usb port number */
90     enum usb_port_type port_type;       /* usb port type */
91     enum usb_detect_type detect_type;   /* usb detect type */
92     enum usb_detect_mode detect_mode;   /* usb detect mode */
93     enum usb_det_vbus_type det_vbus_type;
94     enum usb_id_type id_type;
95     const char *det_vbus_name;
96     const char *id_name;
97     usb_gpio_t id;              /* usb id pin info */
98     usb_gpio_t det_vbus;            /* usb vbus pin info */
99     usb_gpio_t drv_vbus;            /* usb drv_vbus pin info */
100     usb_gpio_t restrict_gpio_set;       /* usb drv_vbus pin info */
101     unsigned int usb_restrict_flag;     /* usb port number(?) */
102     unsigned int voltage;               /* usb port number(?) */
103     unsigned int capacity;              /* usb port number(?) */
104 
105     int id_irq_num;             /* id gpio irq num */
106 } usb_port_info_t;
107 
108 typedef struct usb_cfg
109 {
110     unsigned int usb_global_enable;
111     unsigned int usbc_num;
112 
113     struct usb_port_info port;
114 } usb_cfg_t;
115 
116 #endif /* __SUNXI_USB_BOARD_H__ */
117