• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * drivers/usb/sunxi_usb/include/sunxi_hcd.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_HCD_H__
17 #define __SUNXI_HCD_H__
18 
19 /**
20  * The USB role is defined by the connector used on the board, so long as
21  * standards are being followed. (Developer boards sometimes won't.)
22  */
23 enum sunxi_hcd_mode {
24 	SW_HCD_UNDEFINED = 0,
25 	SW_HCD_HOST,		/* A or Mini-A connector */
26 	SW_HCD_PERIPHERAL,	/* B or Mini-B connector */
27 	SW_HCD_OTG		/* Mini-AB connector */
28 };
29 
30 struct clk;
31 
32 typedef struct sunxi_hcd_eps_bits {
33 	const char	name[16];
34 	u8		bits;
35 } sunxi_hcd_eps_bits_t;
36 
37 typedef struct sunxi_hcd_config {
38 	/* sunxi_hcd configuration-specific details */
39 	unsigned	multipoint:1;	/* multipoint device */
40 	unsigned	dyn_fifo:1;	/* supports dynamic fifo sizing */
41 	unsigned	soft_con:1;	/* soft connect required */
42 	unsigned	utm_16:1;	/* utm data witdh is 16 bits */
43 	unsigned	big_endian:1;	/* true if CPU uses big-endian */
44 	unsigned	mult_bulk_tx:1;	/* Tx ep required for multbulk pkts */
45 	unsigned	mult_bulk_rx:1;	/* Rx ep required for multbulk pkts */
46 	unsigned	high_iso_tx:1;	/* Tx ep required for HB iso */
47 	unsigned	high_iso_rx:1;	/* Rx ep required for HD iso */
48 	unsigned	dma:1;		/* supports DMA */
49 	unsigned	vendor_req:1;	/* vendor registers required */
50 
51 	u8		num_eps;	/* number of endpoints _with_ ep0 */
52 	u8		dma_channels;	/* number of dma channels */
53 	u8		dyn_fifo_size;	/* dynamic size in bytes */
54 	u8		vendor_ctrl;	/* vendor control reg width */
55 	u8		vendor_stat;	/* vendor status reg witdh */
56 	u8		dma_req_chan;	/* bitmask for required dma channels */
57 	u32		ram_size;	/* ram address size */
58 
59 	struct sunxi_hcd_eps_bits *eps_bits;
60 	struct usb_port_info *port_info;
61 } sunxi_hcd_config_t;
62 
63 typedef struct sunxi_hcd_platform_data {
64 	u32 usbc_base;
65 
66 	/* sunxi_USB_HOST, SW_USB_PERIPHERAL, or SW_USB_OTG */
67 	u8		mode;
68 
69 	/* (HOST or OTG) switch VBUS on/off */
70 	int		(*set_vbus)(struct device *dev, int is_on);
71 
72 	/* (HOST or OTG) mA/2 power supplied on (default = 8mA) */
73 	u8		power;
74 
75 	/* (PERIPHERAL) mA/2 max power consumed (default = 100mA) */
76 	u8		min_power;
77 
78 	/* (HOST or OTG) msec/2 after VBUS on till power good */
79 	u8		potpgt;
80 
81 	/* Power the device on or off */
82 	int		(*set_power)(int state);
83 
84 	/* Turn device clock on or off */
85 	int		(*set_clock)(struct clk *clock, int is_on);
86 
87 	/* sunxi_hcd configuration-specific details */
88 	struct sunxi_hcd_config	*config;
89 } sunxi_hcd_platform_data_t;
90 
91 int sunxi_usb_host0_enable(void);
92 int sunxi_usb_host0_disable(void);
93 
94 int sunxi_usb_disable_hcd0(void);
95 int sunxi_usb_enable_hcd0(void);
96 
97 int sunxi_usb_disable_hcd1(void);
98 int sunxi_usb_enable_hcd1(void);
99 
100 int sunxi_usb_disable_hcd2(void);
101 int sunxi_usb_enable_hcd2(void);
102 
103 #endif /* __SUNXI_HCD_H__ */
104