summaryrefslogtreecommitdiffstats
path: root/meta/packages/uboot/u-boot-mkimage-openmoko-native/neo1973-chargefast.patch
blob: 6f6af2c758cac7d4f1000e9a023d0add3a690f30 (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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
Index: u-boot/drivers/usbtty.c
===================================================================
--- u-boot.orig/drivers/usbtty.c
+++ u-boot/drivers/usbtty.c
@@ -66,7 +66,7 @@
 /*
  * Defines
  */
-#define NUM_CONFIGS    1
+#define NUM_CONFIGS    2
 #define MAX_INTERFACES 2
 #define NUM_ENDPOINTS  3
 #define ACM_TX_ENDPOINT 3
@@ -192,8 +192,7 @@
 #endif
     			.bConfigurationValue = 1,
 			.iConfiguration = STR_CONFIG,
-			.bmAttributes = 
-				BMATTRIBUTE_SELF_POWERED|BMATTRIBUTE_RESERVED,
+			.bmAttributes = BMATTRIBUTE_RESERVED,
 			.bMaxPower = USBTTY_MAXPOWER
 		},
 		/* Interface 1 */
@@ -294,6 +293,120 @@
 		.func_dfu = DFU_FUNC_DESC,
 #endif
 	},
+	{
+		.configuration_desc ={
+			.bLength = 
+				sizeof(struct usb_configuration_descriptor),
+    			.bDescriptorType = USB_DT_CONFIG,
+			.wTotalLength =	 
+				cpu_to_le16(sizeof(struct acm_config_desc)
+#ifdef CONFIG_USBD_DFU
+					    - sizeof(struct usb_interface_descriptor)
+					    - sizeof(struct usb_dfu_func_descriptor)
+#endif
+					   ),
+	    		.bNumInterfaces = NUM_ACM_INTERFACES,
+    			.bConfigurationValue = 2,
+			.iConfiguration = STR_CONFIG,
+			.bmAttributes = BMATTRIBUTE_RESERVED,
+			.bMaxPower = 50, /* 100mA */
+		},
+		/* Interface 1 */
+		.interface_desc = {
+			.bLength  = sizeof(struct usb_interface_descriptor),
+			.bDescriptorType = USB_DT_INTERFACE,
+			.bInterfaceNumber = 0,
+			.bAlternateSetting = 0,
+			.bNumEndpoints = 0x01,
+			.bInterfaceClass = 
+				COMMUNICATIONS_INTERFACE_CLASS_CONTROL,
+			.bInterfaceSubClass = COMMUNICATIONS_ACM_SUBCLASS,
+			.bInterfaceProtocol = COMMUNICATIONS_V25TER_PROTOCOL,
+			.iInterface = STR_CTRL_INTERFACE,
+		},
+		.usb_class_header = {
+			.bFunctionLength	= 
+				sizeof(struct usb_class_header_function_descriptor),
+			.bDescriptorType	= CS_INTERFACE,	
+			.bDescriptorSubtype	= USB_ST_HEADER,
+			.bcdCDC	= cpu_to_le16(110),
+		},
+		.usb_class_call_mgt = {
+			.bFunctionLength	= 
+				sizeof(struct usb_class_call_management_descriptor),
+			.bDescriptorType	= CS_INTERFACE,
+			.bDescriptorSubtype	= USB_ST_CMF,
+			.bmCapabilities		= 0x00,	
+			.bDataInterface		= 0x01,	
+		},
+		.usb_class_acm = {
+			.bFunctionLength	= 
+				sizeof(struct usb_class_abstract_control_descriptor),
+			.bDescriptorType	= CS_INTERFACE,
+			.bDescriptorSubtype	= USB_ST_ACMF,	
+			.bmCapabilities		= 0x00,	
+		},
+		.usb_class_union = {
+			.bFunctionLength	= 	
+				sizeof(struct usb_class_union_function_descriptor),
+			.bDescriptorType	= CS_INTERFACE,
+			.bDescriptorSubtype	= USB_ST_UF,
+			.bMasterInterface	= 0x00,	
+			.bSlaveInterface0	= 0x01,	
+		},
+		.notification_endpoint = {
+			.bLength =		
+				sizeof(struct usb_endpoint_descriptor),
+			.bDescriptorType	= USB_DT_ENDPOINT,
+			.bEndpointAddress	= 0x01 | USB_DIR_IN,
+			.bmAttributes		= USB_ENDPOINT_XFER_INT,
+			.wMaxPacketSize		
+				= cpu_to_le16(CONFIG_USBD_SERIAL_INT_PKTSIZE),
+			.bInterval		= 0xFF,
+		},
+
+		/* Interface 2 */
+		.data_class_interface = {
+			.bLength		= 
+				sizeof(struct usb_interface_descriptor),
+			.bDescriptorType	= USB_DT_INTERFACE,
+			.bInterfaceNumber	= 0x01,
+			.bAlternateSetting	= 0x00,
+			.bNumEndpoints		= 0x02,
+			.bInterfaceClass	= 
+				COMMUNICATIONS_INTERFACE_CLASS_DATA,
+			.bInterfaceSubClass	= DATA_INTERFACE_SUBCLASS_NONE,
+			.bInterfaceProtocol	= DATA_INTERFACE_PROTOCOL_NONE,
+			.iInterface		= STR_DATA_INTERFACE,
+		},
+		.data_endpoints = {
+			{
+				.bLength		= 
+					sizeof(struct usb_endpoint_descriptor),
+				.bDescriptorType	= USB_DT_ENDPOINT,
+				.bEndpointAddress	= 0x02 | USB_DIR_OUT,
+				.bmAttributes		= 
+					USB_ENDPOINT_XFER_BULK,
+				.wMaxPacketSize		= 
+					cpu_to_le16(CONFIG_USBD_SERIAL_BULK_PKTSIZE),
+				.bInterval		= 0xFF,
+			},
+			{
+				.bLength		= 
+					sizeof(struct usb_endpoint_descriptor),
+				.bDescriptorType	= USB_DT_ENDPOINT,
+				.bEndpointAddress	= 0x03 | USB_DIR_IN,
+				.bmAttributes		= 
+					USB_ENDPOINT_XFER_BULK,
+				.wMaxPacketSize		= 
+					cpu_to_le16(CONFIG_USBD_SERIAL_BULK_PKTSIZE),
+				.bInterval		= 0xFF,
+			},
+		},
+		/* We don't add the DFU functional descriptor here since we only
+		 * want to do DFU in the high-current charging mode for safety reasons */
+	},
+
 };	
 
 static struct rs232_emu rs232_desc={
@@ -330,8 +443,7 @@
 			.bNumInterfaces = NUM_GSERIAL_INTERFACES,
 			.bConfigurationValue = 1,
 			.iConfiguration = STR_CONFIG,
-			.bmAttributes = 
-				BMATTRIBUTE_SELF_POWERED|BMATTRIBUTE_RESERVED,
+			.bmAttributes = BMATTRIBUTE_RESERVED,
 			.bMaxPower = USBTTY_MAXPOWER
 		},
 		.interface_desc = {
@@ -384,6 +496,68 @@
 			},
 		},
 	},
+	{
+		.configuration_desc ={
+			.bLength = sizeof(struct usb_configuration_descriptor),
+			.bDescriptorType = USB_DT_CONFIG,
+			.wTotalLength =	 
+				cpu_to_le16(sizeof(struct gserial_config_desc)),
+			.bNumInterfaces = NUM_GSERIAL_INTERFACES,
+			.bConfigurationValue = 1,
+			.iConfiguration = STR_CONFIG,
+			.bmAttributes = BMATTRIBUTE_RESERVED,
+			.bMaxPower = 50
+		},
+		.interface_desc = {
+			{
+				.bLength  = 
+					sizeof(struct usb_interface_descriptor),
+				.bDescriptorType = USB_DT_INTERFACE,
+				.bInterfaceNumber = 0,
+				.bAlternateSetting = 0,
+				.bNumEndpoints = NUM_ENDPOINTS,
+				.bInterfaceClass = 
+					COMMUNICATIONS_INTERFACE_CLASS_VENDOR,
+				.bInterfaceSubClass = 
+					COMMUNICATIONS_NO_SUBCLASS,
+				.bInterfaceProtocol = 
+					COMMUNICATIONS_NO_PROTOCOL,
+				.iInterface = STR_DATA_INTERFACE
+			},
+  		},
+		.data_endpoints  = {
+			{
+				.bLength =		
+					sizeof(struct usb_endpoint_descriptor),
+				.bDescriptorType =	USB_DT_ENDPOINT,
+				.bEndpointAddress =	0x01 | USB_DIR_OUT,
+				.bmAttributes =		USB_ENDPOINT_XFER_BULK,
+				.wMaxPacketSize =	
+					cpu_to_le16(CONFIG_USBD_SERIAL_OUT_PKTSIZE),
+				.bInterval=		0xFF,
+			},
+			{
+				.bLength =		
+					sizeof(struct usb_endpoint_descriptor),
+				.bDescriptorType =	USB_DT_ENDPOINT,
+				.bEndpointAddress =	0x02 | USB_DIR_IN,
+				.bmAttributes =		USB_ENDPOINT_XFER_BULK,
+				.wMaxPacketSize = 	
+					cpu_to_le16(CONFIG_USBD_SERIAL_IN_PKTSIZE),
+				.bInterval = 		0xFF,
+			},
+			{
+				.bLength = 		
+					sizeof(struct usb_endpoint_descriptor),
+				.bDescriptorType =	USB_DT_ENDPOINT,
+				.bEndpointAddress =	0x03 | USB_DIR_IN,
+				.bmAttributes =		USB_ENDPOINT_XFER_INT,
+    				.wMaxPacketSize =	
+					cpu_to_le16(CONFIG_USBD_SERIAL_INT_PKTSIZE),
+				.bInterval =		0xFF,
+			},
+		},
+	},
 };
 
 /*
@@ -679,12 +853,14 @@
 	bus_instance->maxpacketsize = 64;
 	bus_instance->serial_number_str = serial_number;
 
-	/* configuration instance */
-	memset (config_instance, 0,
-		sizeof (struct usb_configuration_instance));
-	config_instance->interfaces = interface_count;
-	config_instance->configuration_descriptor = configuration_descriptor;
-	config_instance->interface_instance_array = interface_instance;
+	/* configuration instances */
+	for (i = 0; i < NUM_CONFIGS; i++) {
+		memset(&config_instance[i], 0, sizeof(config_instance));
+		config_instance[i].interfaces = interface_count;
+		/* FIXME: this breaks for the non-ACM case */
+		config_instance[i].configuration_descriptor = &acm_configuration_descriptors[i];
+		config_instance[i].interface_instance_array = interface_instance;
+	}
 
 	/* interface instance */
 	memset (interface_instance, 0,
@@ -1043,9 +1219,17 @@
 		usbtty_configured_flag = 0;
 		break;
 	case DEVICE_CONFIGURED:
+		printf("DEVICE_CONFIGURED: %u\n", device->configuration);
+		if (device->configuration == 1)
+			udc_ctrl(UDC_CTRL_500mA_ENABLE, 1);
+		else
+			udc_ctrl(UDC_CTRL_500mA_ENABLE, 0);
 		usbtty_configured_flag = 1;
 		break;
-
+	case DEVICE_DE_CONFIGURED:
+		printf("DEVICE_DE_CONFIGURED\n");
+		udc_ctrl(UDC_CTRL_500mA_ENABLE, 0);
+		break;
 	case DEVICE_ADDRESS_ASSIGNED:
 		usbtty_init_endpoints ();
 
Index: u-boot/drivers/usbtty.h
===================================================================
--- u-boot.orig/drivers/usbtty.h
+++ u-boot/drivers/usbtty.h
@@ -60,7 +60,7 @@
 #define USBTTY_DEVICE_CLASS	COMMUNICATIONS_DEVICE_CLASS
 
 #define USBTTY_BCD_DEVICE	0x00
-#define USBTTY_MAXPOWER  	0x00
+#define USBTTY_MAXPOWER  	250	/* 500mA */
 
 #define STR_LANG		0x00
 #define STR_MANUFACTURER	0x01
Index: u-boot/board/neo1973/common/udc.c
===================================================================
--- u-boot.orig/board/neo1973/common/udc.c
+++ u-boot/board/neo1973/common/udc.c
@@ -2,6 +2,7 @@
 #include <common.h>
 #include <usbdcore.h>
 #include <s3c2410.h>
+#include <pcf50606.h>
 
 void udc_ctrl(enum usbd_event event, int param)
 {
@@ -17,6 +18,13 @@
 			gpio->GPBDAT &= ~(1 << 9);
 #endif
 		break;
+	case UDC_CTRL_500mA_ENABLE:
+#if defined(CONFIG_ARCH_GTA01_v3) || defined(CONFIG_ARCH_GTA01_v4) || \
+    defined(CONFIG_ARCH_GTA01B_v2) || defined(CONFIG_ARCH_GTA01B_v3) || \
+    defined(CONFIG_ARCH_GTA01B_v4)
+		pcf50606_charge_autofast(param);
+#endif
+		break;
 	default:
 		break;
 	}
Index: u-boot/include/usbdcore.h
===================================================================
--- u-boot.orig/include/usbdcore.h
+++ u-boot/include/usbdcore.h
@@ -686,8 +686,8 @@
 
 enum usbd_event {
 	UDC_CTRL_PULLUP_ENABLE,
+	UDC_CTRL_500mA_ENABLE,
 };
 
 void udc_ctrl(enum usbd_event event, int param);
 #endif
-#endif