blob: fc6c77918481691ff0eca422b60b359dcbc3b4ef [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Felipe Balbi550a7372008-07-24 12:27:36 +03002/*
3 * This is used to for host and peripheral modes of the driver for
4 * Inventra (Multidrop) Highspeed Dual-Role Controllers: (M)HDRC.
5 *
6 * Board initialization should put one of these into dev->platform_data,
Felipe Balbi05ac10d2010-12-02 08:49:26 +02007 * probably on some platform_device named "musb-hdrc". It encapsulates
Felipe Balbi550a7372008-07-24 12:27:36 +03008 * key configuration differences between boards.
9 */
10
Mark A. Greerfbfc3962009-04-21 20:52:54 -070011#ifndef __LINUX_USB_MUSB_H
12#define __LINUX_USB_MUSB_H
13
Felipe Balbi550a7372008-07-24 12:27:36 +030014/* The USB role is defined by the connector used on the board, so long as
15 * standards are being followed. (Developer boards sometimes won't.)
16 */
17enum musb_mode {
18 MUSB_UNDEFINED = 0,
19 MUSB_HOST, /* A or Mini-A connector */
20 MUSB_PERIPHERAL, /* B or Mini-B connector */
21 MUSB_OTG /* Mini-AB connector */
22};
23
24struct clk;
25
Felipe Balbie6c213b2010-03-12 10:29:06 +020026enum musb_fifo_style {
27 FIFO_RXTX,
28 FIFO_TX,
29 FIFO_RX
30} __attribute__ ((packed));
31
32enum musb_buf_mode {
33 BUF_SINGLE,
34 BUF_DOUBLE
35} __attribute__ ((packed));
36
37struct musb_fifo_cfg {
38 u8 hw_ep_num;
39 enum musb_fifo_style style;
40 enum musb_buf_mode mode;
41 u16 maxpacket;
42};
43
44#define MUSB_EP_FIFO(ep, st, m, pkt) \
45{ \
46 .hw_ep_num = ep, \
47 .style = st, \
48 .mode = m, \
49 .maxpacket = pkt, \
50}
51
52#define MUSB_EP_FIFO_SINGLE(ep, st, pkt) \
53 MUSB_EP_FIFO(ep, st, BUF_SINGLE, pkt)
54
55#define MUSB_EP_FIFO_DOUBLE(ep, st, pkt) \
56 MUSB_EP_FIFO(ep, st, BUF_DOUBLE, pkt)
57
Felipe Balbica6d1b12008-08-08 12:40:54 +030058struct musb_hdrc_eps_bits {
59 const char name[16];
60 u8 bits;
61};
62
63struct musb_hdrc_config {
Felipe Balbie6c213b2010-03-12 10:29:06 +020064 struct musb_fifo_cfg *fifo_cfg; /* board fifo configuration */
65 unsigned fifo_cfg_size; /* size of the fifo configuration */
66
Felipe Balbica6d1b12008-08-08 12:40:54 +030067 /* MUSB configuration-specific details */
68 unsigned multipoint:1; /* multipoint device */
Felipe Balbic58bfa62010-01-21 15:33:55 +020069 unsigned dyn_fifo:1 __deprecated; /* supports dynamic fifo sizing */
Felipe Balbica6d1b12008-08-08 12:40:54 +030070
Daniel Mack869c5972013-11-26 13:31:14 +010071 /* need to explicitly de-assert the port reset after resume? */
72 unsigned host_port_deassert_reset_at_resume:1;
73
Felipe Balbica6d1b12008-08-08 12:40:54 +030074 u8 num_eps; /* number of endpoints _with_ ep0 */
Felipe Balbica6d1b12008-08-08 12:40:54 +030075 u8 ram_bits; /* ram address size */
76
Bin Liu9b753762015-09-09 13:17:23 -050077 u32 maximum_speed;
Felipe Balbica6d1b12008-08-08 12:40:54 +030078};
79
Felipe Balbi550a7372008-07-24 12:27:36 +030080struct musb_hdrc_platform_data {
81 /* MUSB_HOST, MUSB_PERIPHERAL, or MUSB_OTG */
82 u8 mode;
83
84 /* for clk_get() */
85 const char *clock;
86
87 /* (HOST or OTG) switch VBUS on/off */
88 int (*set_vbus)(struct device *dev, int is_on);
89
90 /* (HOST or OTG) mA/2 power supplied on (default = 8mA) */
91 u8 power;
92
93 /* (PERIPHERAL) mA/2 max power consumed (default = 100mA) */
94 u8 min_power;
95
96 /* (HOST or OTG) msec/2 after VBUS on till power good */
97 u8 potpgt;
98
Ajay Kumar Gupta5fc4e772009-12-28 13:40:42 +020099 /* (HOST or OTG) program PHY for external Vbus */
100 unsigned extvbus:1;
101
Felipe Balbi550a7372008-07-24 12:27:36 +0300102 /* Power the device on or off */
103 int (*set_power)(int state);
104
Felipe Balbica6d1b12008-08-08 12:40:54 +0300105 /* MUSB configuration-specific details */
Petr Kulhavyead22ca2016-02-24 16:27:16 +0100106 const struct musb_hdrc_config *config;
Maulik Mankad884b8362010-02-17 14:09:30 -0800107
108 /* Architecture specific board data */
109 void *board_data;
Felipe Balbif7ec9432010-12-02 09:48:58 +0200110
111 /* Platform specific struct musb_ops pointer */
112 const void *platform_ops;
Felipe Balbi550a7372008-07-24 12:27:36 +0300113};
114
Tony Lindgren80555552015-11-30 21:37:12 -0800115enum musb_vbus_id_status {
116 MUSB_UNKNOWN = 0,
117 MUSB_ID_GROUND,
118 MUSB_ID_FLOAT,
119 MUSB_VBUS_VALID,
120 MUSB_VBUS_OFF,
121};
122
123#if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
Tony Lindgren12b7db22016-05-31 10:05:19 -0500124int musb_mailbox(enum musb_vbus_id_status status);
Tony Lindgren80555552015-11-30 21:37:12 -0800125#else
Tony Lindgren12b7db22016-05-31 10:05:19 -0500126static inline int musb_mailbox(enum musb_vbus_id_status status)
Tony Lindgren80555552015-11-30 21:37:12 -0800127{
Tony Lindgren12b7db22016-05-31 10:05:19 -0500128 return 0;
Tony Lindgren80555552015-11-30 21:37:12 -0800129}
130#endif
Felipe Balbi550a7372008-07-24 12:27:36 +0300131
132/* TUSB 6010 support */
133
134#define TUSB6010_OSCCLK_60 16667 /* psec/clk @ 60.0 MHz */
135#define TUSB6010_REFCLK_24 41667 /* psec/clk @ 24.0 MHz XI */
136#define TUSB6010_REFCLK_19 52083 /* psec/clk @ 19.2 MHz CLKIN */
137
138#ifdef CONFIG_ARCH_OMAP2
139
140extern int __init tusb6010_setup_interface(
141 struct musb_hdrc_platform_data *data,
142 unsigned ps_refclk, unsigned waitpin,
143 unsigned async_cs, unsigned sync_cs,
144 unsigned irq, unsigned dmachan);
145
146extern int tusb6010_platform_retime(unsigned is_refclk);
147
148#endif /* OMAP2 */
Mark A. Greerfbfc3962009-04-21 20:52:54 -0700149
150#endif /* __LINUX_USB_MUSB_H */