aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-s5p/dev-usbgadget.c
blob: 5dd3eb288438ed496d89049d9a7a4ecd3ea8ccd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
/*
 * Copyright (C) 2010-2011 Samsung Electronics Co., Ltd.
 *
 * S3C series device definition for USB-GADGET
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
*/

#include <linux/kernel.h>
#include <linux/dma-mapping.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#if defined(CONFIG_USB_ANDROID) || defined(CONFIG_USB_G_ANDROID)
#include <linux/usb/android_composite.h>
#endif

#include <mach/map.h>
#include <plat/devs.h>
#include <plat/usbgadget.h>
#include <plat/usb-phy.h>

/* USB Device (Gadget)*/
static struct resource s3c_usbgadget_resource[] = {
	[0] = {
		.start = S5P_PA_HSOTG,
		.end   = S5P_PA_HSOTG + SZ_4K - 1,
		.flags = IORESOURCE_MEM,
	},
	[1] = {
		.start = IRQ_USB_HSOTG,
		.end   = IRQ_USB_HSOTG,
		.flags = IORESOURCE_IRQ,
	}
};

static u64 s5p_device_usb_gadget_dmamask = 0xffffffffUL;
struct platform_device s3c_device_usbgadget = {
	.name		= "s3c-usbgadget",
	.id		= -1,
	.num_resources	= ARRAY_SIZE(s3c_usbgadget_resource),
	.resource	= s3c_usbgadget_resource,
	.dev		= {
		.dma_mask		= &s5p_device_usb_gadget_dmamask,
		.coherent_dma_mask	= DMA_BIT_MASK(32),
	},
};

void __init s5p_usbgadget_set_platdata(struct s5p_usbgadget_platdata *pd)
{
	struct s5p_usbgadget_platdata *npd;

	npd = s3c_set_platdata(pd, sizeof(struct s5p_usbgadget_platdata),
			&s3c_device_usbgadget);

	if (!npd->phy_init)
		npd->phy_init = s5p_usb_phy_init;
	if (!npd->phy_exit)
		npd->phy_exit = s5p_usb_phy_exit;
}

#if defined(CONFIG_USB_ANDROID) || defined(CONFIG_USB_G_ANDROID)
/* default samsung vendor ID */
#define SAMSUNG_VENDOR_ID		0x04e8
/* dynamic composite using devguru driver */
#define SAMSUNG_MTP_PRODUCT_ID		0x6860	/* mtp(0)+...*/
#define SAMSUNG_UMS_PRODUCT_ID		0x685e	/* ums(0)+...*/
#define SAMSUNG_RNDIS_PRODUCT_ID	0x6864  /* RNDIS +...*/
#define SAMSUNG_NCM_PRODUCT_ID		0x685D  /* NCM + ...*/
/* only mode using devguru driver */
#define SAMSUNG_UMS_ONLY_PRODUCT_ID	0x685B  /* UMS Only */
#define SAMSUNG_MTP_ONLY_PRODUCT_ID	0x685C  /* MTP Only */
#define SAMSUNG_RNDIS_ONLY_PRODUCT_ID	0x6863  /* RNDIS only */
#define SAMSUNG_ADB_ONLY_PRODUCT_ID	SAMSUNG_MTP_ONLY_PRODUCT_ID

#ifdef	CONFIG_USB_ANDROID_MTP
#define SAMSUNG_PRODUCT_ID			SAMSUNG_MTP_PRODUCT_ID
#else
#define SAMSUNG_PRODUCT_ID			SAMSUNG_UMS_PRODUCT_ID
#endif

#define MAX_USB_SERIAL_NUM	17

#ifdef	CONFIG_USB_ANDROID_MASS_STORAGE
static char *usb_functions_ums[] = {
	"usb_mass_storage",
};
#endif

#ifdef	CONFIG_USB_ANDROID_RNDIS
static char *usb_functions_rndis[] = {
	"rndis",
};
#endif

#ifdef	CONFIG_USB_ANDROID_MTP
static char *usb_functions_mtp[] = {
	"mtp",
};
#endif

#ifdef	CONFIG_USB_ANDROID_ADB
static char *usb_functions_adb[] = {
	"adb",
};
#endif

#if defined(CONFIG_USB_ANDROID_MASS_STORAGE) && defined(CONFIG_USB_ANDROID_ADB)
static char *usb_functions_ums_adb[] = {
	"usb_mass_storage",
	"adb",
};
#endif

#if defined(CONFIG_USB_ANDROID_MTP) && defined(CONFIG_USB_ANDROID_ADB)
static char *usb_functions_mtp_adb[] = {
	"mtp",
	"adb",
};
#endif

#if	defined(CONFIG_USB_ANDROID_MASS_STORAGE) && defined(CONFIG_USB_ANDROID_ADB) && defined(CONFIG_USB_ANDROID_ACM)
static char *usb_functions_ums_adb_acm[] = {
	"usb_mass_storage",
	"adb",
	"acm",
};
#endif

static char *usb_functions_all[] = {
#ifdef	CONFIG_USB_ANDROID_RNDIS
	"rndis",
#endif
#ifdef	CONFIG_USB_ANDROID_MASS_STORAGE
	"usb_mass_storage",
#endif
#ifdef	CONFIG_USB_ANDROID_MTP
	"mtp",
#endif
#ifdef	CONFIG_USB_ANDROID_ADB
	"adb",
#endif
#ifdef	CONFIG_USB_ANDROID_ACM
	"acm",
#endif
};

static struct android_usb_product usb_products[] = {
#ifdef	CONFIG_USB_ANDROID_MASS_STORAGE
	{
		.product_id	= SAMSUNG_UMS_ONLY_PRODUCT_ID,
		.num_functions	= ARRAY_SIZE(usb_functions_ums),
		.functions	= usb_functions_ums,
	},
#endif
#ifdef	CONFIG_USB_ANDROID_RNDIS
	{
		.product_id	= SAMSUNG_RNDIS_ONLY_PRODUCT_ID,
		.num_functions	= ARRAY_SIZE(usb_functions_rndis),
		.functions	= usb_functions_rndis,
	},
#endif
#ifdef	CONFIG_USB_ANDROID_MTP
	{
		.product_id	= SAMSUNG_MTP_ONLY_PRODUCT_ID,
		.num_functions	= ARRAY_SIZE(usb_functions_mtp),
		.functions	= usb_functions_mtp,
	},
#endif
	{
/* debug mode : using MS Composite*/
#ifdef CONFIG_USB_ANDROID_SAMSUNG_DEBUG_MTP
		.product_id     = SAMSUNG_KIES_PRODUCT_ID,
		.num_functions  = ARRAY_SIZE(usb_functions_mtp_acm_adb),
		.functions      = usb_functions_mtp_acm_adb,
#endif
	},
#if	defined(CONFIG_USB_ANDROID_MASS_STORAGE) && defined(CONFIG_USB_ANDROID_ADB)
	{
		.product_id	= SAMSUNG_UMS_PRODUCT_ID,
		.num_functions	= ARRAY_SIZE(usb_functions_ums_adb),
		.functions	= usb_functions_ums_adb,
	},
#endif
#if	defined(CONFIG_USB_ANDROID_MTP) && defined(CONFIG_USB_ANDROID_ADB)
	{
		.product_id	= SAMSUNG_MTP_PRODUCT_ID,
		.num_functions	= ARRAY_SIZE(usb_functions_mtp_adb),
		.functions	= usb_functions_mtp_adb,
	},
#endif
#ifdef	CONFIG_USB_ANDROID_ADB
	{
		.product_id	= SAMSUNG_ADB_ONLY_PRODUCT_ID,
		.num_functions	= ARRAY_SIZE(usb_functions_adb),
		.functions	= usb_functions_adb,
	},
#endif
#if defined(CONFIG_USB_ANDROID_MASS_STORAGE) && defined(CONFIG_USB_ANDROID_ADB) && defined(CONFIG_USB_ANDROID_ACM)
	{
		.product_id	= SAMSUNG_UMS_PRODUCT_ID,
		.num_functions	= ARRAY_SIZE(usb_functions_ums_adb_acm),
		.functions	= usb_functions_ums_adb_acm,
	},
#endif
};

static char device_serial[MAX_USB_SERIAL_NUM] = "0123456789ABCDEF";

/* standard android USB platform data */
static struct android_usb_platform_data android_usb_pdata = {
	.vendor_id		= SAMSUNG_VENDOR_ID,
	.product_id		= SAMSUNG_PRODUCT_ID,
	.manufacturer_name	= "SAMSUNG",
	.product_name		= "S5P OTG-USB",
	.serial_number		= device_serial,
	.num_products		= ARRAY_SIZE(usb_products),
	.products		= usb_products,
	.num_functions		= ARRAY_SIZE(usb_functions_all),
	.functions		= usb_functions_all,
};

struct platform_device s3c_device_android_usb = {
	.name	= "android_usb",
	.id	= -1,
	.dev	= {
		.platform_data	= &android_usb_pdata,
	},
};

static struct usb_mass_storage_platform_data ums_pdata = {
	.vendor			= "SAMSUNG",
	.product		= "S5P UMS",
	.release		= 1,
	.nluns			= 1,
};
struct platform_device s3c_device_usb_mass_storage = {
	.name	= "usb_mass_storage",
	.id	= -1,
	.dev	= {
		.platform_data = &ums_pdata,
	},
};

#ifdef CONFIG_USB_ANDROID_RNDIS
static struct usb_ether_platform_data rndis_pdata = {
/* ethaddr is filled by board_serialno_setup */
	.vendorID       = SAMSUNG_VENDOR_ID,
	.vendorDescr    = "SAMSUNG",
};
struct platform_device s3c_device_rndis = {
	.name   = "rndis",
	.id     = -1,
	.dev    = {
		.platform_data = &rndis_pdata,
	},
};
#endif
#endif /* CONFIG_USB_ANDROID */