xref: /openbmc/u-boot/include/linux/usb/musb.h (revision 71a988aa)
1 /*
2  * This is used to for host and peripheral modes of the driver for
3  * Inventra (Multidrop) Highspeed Dual-Role Controllers:  (M)HDRC.
4  *
5  * Board initialization should put one of these into dev->platform_data,
6  * probably on some platform_device named "musb-hdrc".  It encapsulates
7  * key configuration differences between boards.
8  */
9 
10 #ifndef __LINUX_USB_MUSB_H
11 #define __LINUX_USB_MUSB_H
12 
13 #ifndef __deprecated
14 #define __deprecated
15 #endif
16 
17 /* The USB role is defined by the connector used on the board, so long as
18  * standards are being followed.  (Developer boards sometimes won't.)
19  */
20 enum musb_mode {
21 	MUSB_UNDEFINED = 0,
22 	MUSB_HOST,		/* A or Mini-A connector */
23 	MUSB_PERIPHERAL,	/* B or Mini-B connector */
24 	MUSB_OTG		/* Mini-AB connector */
25 };
26 
27 struct clk;
28 
29 enum musb_fifo_style {
30 	FIFO_RXTX,
31 	FIFO_TX,
32 	FIFO_RX
33 } __attribute__ ((packed));
34 
35 enum musb_buf_mode {
36 	BUF_SINGLE,
37 	BUF_DOUBLE
38 } __attribute__ ((packed));
39 
40 struct musb_fifo_cfg {
41 	u8			hw_ep_num;
42 	enum musb_fifo_style	style;
43 	enum musb_buf_mode	mode;
44 	u16			maxpacket;
45 };
46 
47 #define MUSB_EP_FIFO(ep, st, m, pkt)		\
48 {						\
49 	.hw_ep_num	= ep,			\
50 	.style		= st,			\
51 	.mode		= m,			\
52 	.maxpacket	= pkt,			\
53 }
54 
55 #define MUSB_EP_FIFO_SINGLE(ep, st, pkt)	\
56 	MUSB_EP_FIFO(ep, st, BUF_SINGLE, pkt)
57 
58 #define MUSB_EP_FIFO_DOUBLE(ep, st, pkt)	\
59 	MUSB_EP_FIFO(ep, st, BUF_DOUBLE, pkt)
60 
61 struct musb_hdrc_eps_bits {
62 	const char	name[16];
63 	u8		bits;
64 };
65 
66 struct musb_hdrc_config {
67 	struct musb_fifo_cfg	*fifo_cfg;	/* board fifo configuration */
68 	unsigned		fifo_cfg_size;	/* size of the fifo configuration */
69 
70 	/* MUSB configuration-specific details */
71 	unsigned	multipoint:1;	/* multipoint device */
72 	unsigned	dyn_fifo:1 __deprecated; /* supports dynamic fifo sizing */
73 	unsigned	soft_con:1 __deprecated; /* soft connect required */
74 	unsigned	utm_16:1 __deprecated; /* utm data witdh is 16 bits */
75 	unsigned	big_endian:1;	/* true if CPU uses big-endian */
76 	unsigned	mult_bulk_tx:1;	/* Tx ep required for multbulk pkts */
77 	unsigned	mult_bulk_rx:1;	/* Rx ep required for multbulk pkts */
78 	unsigned	high_iso_tx:1;	/* Tx ep required for HB iso */
79 	unsigned	high_iso_rx:1;	/* Rx ep required for HD iso */
80 	unsigned	dma:1 __deprecated; /* supports DMA */
81 	unsigned	vendor_req:1 __deprecated; /* vendor registers required */
82 
83 	u8		num_eps;	/* number of endpoints _with_ ep0 */
84 	u8		dma_channels __deprecated; /* number of dma channels */
85 	u8		dyn_fifo_size;	/* dynamic size in bytes */
86 	u8		vendor_ctrl __deprecated; /* vendor control reg width */
87 	u8		vendor_stat __deprecated; /* vendor status reg witdh */
88 	u8		dma_req_chan __deprecated; /* bitmask for required dma channels */
89 	u8		ram_bits;	/* ram address size */
90 
91 	struct musb_hdrc_eps_bits *eps_bits __deprecated;
92 #ifdef CONFIG_BLACKFIN
93 	/* A GPIO controlling VRSEL in Blackfin */
94 	unsigned int	gpio_vrsel;
95 	unsigned int	gpio_vrsel_active;
96 	/* musb CLKIN in Blackfin in MHZ */
97 	unsigned char   clkin;
98 #endif
99 
100 };
101 
102 struct musb_hdrc_platform_data {
103 	/* MUSB_HOST, MUSB_PERIPHERAL, or MUSB_OTG */
104 	u8		mode;
105 
106 	/* for clk_get() */
107 	const char	*clock;
108 
109 	/* (HOST or OTG) switch VBUS on/off */
110 	int		(*set_vbus)(struct device *dev, int is_on);
111 
112 	/* (HOST or OTG) mA/2 power supplied on (default = 8mA) */
113 	u8		power;
114 
115 	/* (PERIPHERAL) mA/2 max power consumed (default = 100mA) */
116 	u8		min_power;
117 
118 	/* (HOST or OTG) msec/2 after VBUS on till power good */
119 	u8		potpgt;
120 
121 	/* (HOST or OTG) program PHY for external Vbus */
122 	unsigned	extvbus:1;
123 
124 	/* Power the device on or off */
125 	int		(*set_power)(int state);
126 
127 	/* MUSB configuration-specific details */
128 	struct musb_hdrc_config	*config;
129 
130 	/* Architecture specific board data	*/
131 	void		*board_data;
132 
133 	/* Platform specific struct musb_ops pointer */
134 	const void	*platform_ops;
135 };
136 
137 
138 /* TUSB 6010 support */
139 
140 #define	TUSB6010_OSCCLK_60	16667	/* psec/clk @ 60.0 MHz */
141 #define	TUSB6010_REFCLK_24	41667	/* psec/clk @ 24.0 MHz XI */
142 #define	TUSB6010_REFCLK_19	52083	/* psec/clk @ 19.2 MHz CLKIN */
143 
144 #ifdef	CONFIG_ARCH_OMAP2
145 
146 extern int __init tusb6010_setup_interface(
147 		struct musb_hdrc_platform_data *data,
148 		unsigned ps_refclk, unsigned waitpin,
149 		unsigned async_cs, unsigned sync_cs,
150 		unsigned irq, unsigned dmachan);
151 
152 extern int tusb6010_platform_retime(unsigned is_refclk);
153 
154 #endif	/* OMAP2 */
155 
156 /*
157  * U-Boot specfic stuff
158  */
159 int musb_register(struct musb_hdrc_platform_data *plat, void *bdata,
160 			void *ctl_regs);
161 
162 #endif /* __LINUX_USB_MUSB_H */
163