blob: 959af02d3af6c8665f9d120c7531a60950d94cb6 [file] [log] [blame]
Kuninori Morimotof1407d52011-04-04 13:44:59 +09001/*
2 * Renesas USB
3 *
4 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 *
16 */
17#ifndef RENESAS_USB_H
18#define RENESAS_USB_H
19#include <linux/platform_device.h>
20#include <linux/usb/ch9.h>
21
22/*
23 * module type
24 *
25 * it will be return value from get_id
26 */
27enum {
28 USBHS_HOST = 0,
29 USBHS_GADGET,
30 USBHS_MAX,
31};
32
33/*
34 * callback functions table for driver
35 *
36 * These functions are called from platform for driver.
37 * Callback function's pointer will be set before
38 * renesas_usbhs_platform_callback :: hardware_init was called
39 */
40struct renesas_usbhs_driver_callback {
41 int (*notify_hotplug)(struct platform_device *pdev);
42};
43
44/*
45 * callback functions for platform
46 *
47 * These functions are called from driver for platform
48 */
49struct renesas_usbhs_platform_callback {
50
51 /*
52 * option:
53 *
54 * Hardware init function for platform.
55 * it is called when driver was probed.
56 */
57 int (*hardware_init)(struct platform_device *pdev);
58
59 /*
60 * option:
61 *
62 * Hardware exit function for platform.
63 * it is called when driver was removed
64 */
65 void (*hardware_exit)(struct platform_device *pdev);
66
67 /*
68 * option:
69 *
70 * Phy reset for platform
71 */
72 void (*phy_reset)(struct platform_device *pdev);
73
74 /*
75 * get USB ID function
76 * - USBHS_HOST
77 * - USBHS_GADGET
78 */
79 int (*get_id)(struct platform_device *pdev);
80
81 /*
82 * get VBUS status function.
83 */
84 int (*get_vbus)(struct platform_device *pdev);
85};
86
87/*
88 * parameters for renesas usbhs
89 *
90 * some register needs USB chip specific parameters.
91 * This struct show it to driver
92 */
93struct renesas_usbhs_driver_param {
94 /*
95 * pipe settings
96 */
97 u32 *pipe_type; /* array of USB_ENDPOINT_XFER_xxx (from ep0) */
98 int pipe_size; /* pipe_type array size */
99
100 /*
101 * option:
102 *
103 * for BUSWAIT :: BWAIT
Kuninori Morimoto11935de2011-10-10 22:01:28 -0700104 * see
105 * renesas_usbhs/common.c :: usbhsc_set_buswait()
Kuninori Morimotof1407d52011-04-04 13:44:59 +0900106 * */
107 int buswait_bwait;
Kuninori Morimotobc573812011-04-28 16:41:14 +0900108
109 /*
110 * option:
111 *
112 * delay time from notify_hotplug callback
113 */
114 int detection_delay;
Kuninori Morimotoe73a9892011-06-06 14:19:03 +0900115
116 /*
117 * option:
118 *
119 * dma id for dmaengine
120 */
121 int d0_tx_id;
122 int d0_rx_id;
123 int d1_tx_id;
124 int d1_rx_id;
125
126 /*
127 * option:
128 *
129 * pio <--> dma border.
130 */
131 int pio_dma_border; /* default is 64byte */
Kuninori Morimotof1407d52011-04-04 13:44:59 +0900132};
133
134/*
135 * option:
136 *
137 * platform information for renesas_usbhs driver.
138 */
139struct renesas_usbhs_platform_info {
140 /*
141 * option:
142 *
143 * platform set these functions before
144 * call platform_add_devices if needed
145 */
146 struct renesas_usbhs_platform_callback platform_callback;
147
148 /*
149 * driver set these callback functions pointer.
150 * platform can use it on callback functions
151 */
152 struct renesas_usbhs_driver_callback driver_callback;
153
154 /*
155 * option:
156 *
157 * driver use these param for some register
158 */
159 struct renesas_usbhs_driver_param driver_param;
160};
161
162/*
163 * macro for platform
164 */
165#define renesas_usbhs_get_info(pdev)\
166 ((struct renesas_usbhs_platform_info *)(pdev)->dev.platform_data)
167
168#define renesas_usbhs_call_notify_hotplug(pdev) \
169 ({ \
170 struct renesas_usbhs_driver_callback *dc; \
171 dc = &(renesas_usbhs_get_info(pdev)->driver_callback); \
Kuninori Morimotoaf32fe52011-04-21 14:10:16 +0900172 if (dc && dc->notify_hotplug) \
Kuninori Morimotof1407d52011-04-04 13:44:59 +0900173 dc->notify_hotplug(pdev); \
174 })
175#endif /* RENESAS_USB_H */