summaryrefslogtreecommitdiff
path: root/multitech/recipes/linux/linux-2.6.39-at91/mtocgd2/linux-2.6.39.4-mach-at91-mtocgd2.patch
blob: c61237e763f92f5d156a94197e2db0aa639eaa5d (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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
Index: git/arch/arm/mach-at91/board-sam9x5cm.c
===================================================================
--- git.orig/arch/arm/mach-at91/board-sam9x5cm.c	2013-12-27 14:27:13.000000000 -0600
+++ git/arch/arm/mach-at91/board-sam9x5cm.c	2014-02-06 16:31:32.817405456 -0600
@@ -18,6 +18,9 @@
 #include <linux/platform_device.h>
 #include <linux/spi/flash.h>
 #include <linux/spi/spi.h>
+#include <linux/spi/eeprom.h>
+#include <linux/i2c/at24.h>
+#include <linux/delay.h>
 #include <linux/fb.h>
 #include <linux/gpio_keys.h>
 #include <linux/input.h>
@@ -103,6 +106,31 @@
 		.irq            = -1,
 	},
 #endif
+	{ /* SPI1_NCS1 to ethernet switch */
+		.modalias = "spidev",
+		.chip_select = 0,
+		.bus_num = 1,
+	},
+	{ /* SPI1_NCS2 to temp sensor */
+		.modalias = "mts-io-board-temp",
+		.chip_select = 1,
+		.bus_num = 1,
+	},
+	{ /* SPI1_NCS3 to daughter card analog inputs */
+		.modalias = "mts-io-dc-adc",
+		.chip_select = 2,
+		.bus_num = 1,
+	},
+	{ /* SPI1_NCS4 to daughter card digital inputs */
+		.modalias = "mts-io-dc-din",
+		.chip_select = 3,
+		.bus_num = 1,
+	},
+	{ /* SPI1_NCS5 to daughter card digital outputs */
+		.modalias = "mts-io-dc-dout",
+		.chip_select = 4,
+		.bus_num = 1,
+	},
 #endif
 };
 
@@ -111,13 +139,48 @@
  */
 static struct mtd_partition __initdata cm_nand_partition[] = {
 	{
-		.name	= "Partition 1",
+		.name	= "NANDFlash",
+		.offset	= 0,
+		.size	= 256*1024*1024,
+	},
+	{
+		.name	= "AT91Bootstrap",
 		.offset	= 0,
-		.size	= SZ_64M,
+		.size	= 256*1024,
+	},
+	{
+		.name	= "UBoot",
+		.offset	= 256*1024,
+		.size	= 512*1024,
+	},
+	{
+		.name	= "UBoot Config",
+		.offset	= 768*1024,
+		.size	= 640*1024,
+	},
+	{
+		.name	= "UBoot Redundant Config",
+		.offset	= 1408*1024,
+		.size	= 640*1024,
+	},
+	{
+		.name	= "uImage",
+		.offset	= 2*1024*1024,
+		.size	= 6*1024*1024,
+	},
+	{
+		.name	= "Config",
+		.offset	= 8*1024*1024,
+		.size	= 8*1024*1024,
+	},
+	{
+		.name	= "Oem Config",
+		.offset	= 16*1024*1024,
+		.size	= 8*1024*1024,
 	},
 	{
-		.name	= "Partition 2",
-		.offset	= MTDPART_OFS_NXTBLK,
+		.name	= "Rootfs",
+		.offset	= 24*1024*1024,
 		.size	= MTDPART_SIZ_FULL,
 	},
 };
@@ -135,7 +198,8 @@
 	.enable_pin	= AT91_PIN_PD4,
 	.ecc_mode	= NAND_ECC_HW,
 	.has_pmecc	= 1,
-	.pmecc_corr_cap	= 2,
+// MTOCGD2: 4-bit PMECC
+	.pmecc_corr_cap	= 4,
 	.pmecc_sector_size = 512,
 	.pmecc_lookup_table_offset = 0x8000,
 	.partition_info	= nand_partitions,
@@ -170,7 +234,13 @@
 	else
 		cm_nand_smc_config.mode |= AT91_SMC_DBW_8;
 
+	// MTOCGD2 Rev B
+	cm_nand_data.bus_on_d0 = 0;
+	cm_nand_data.rdy_pin = AT91_PIN_PC31;
+
+	// MTOCGD2: disable
 	/* revision of board modify NAND wiring */
+	/*
 	if (cm_is_revA()) {
 		cm_nand_data.bus_on_d0 = 1;
 		cm_nand_data.rdy_pin = AT91_PIN_PD6;
@@ -178,6 +248,7 @@
 		cm_nand_data.bus_on_d0 = 0;
 		cm_nand_data.rdy_pin = AT91_PIN_PD5;
 	}
+	*/
 
 	/* configure chip-select 3 (NAND) */
 	sam9_smc_configure(3, &cm_nand_smc_config);
@@ -189,17 +260,90 @@
  * LEDs
  */
 static struct gpio_led cm_leds[] = {
-	{	/* "left" led, blue, userled1 */
-		.name			= "d1",
-		.gpio			= AT91_PIN_PB18,
+	{	/* default status LED */
+		.name			= "led-a",
+		.gpio			= AT91_PIN_PA24,
+		.active_low		= 1,
 		.default_trigger	= "heartbeat",
 	},
-	{	/* "right" led, red, userled2 */
-		.name			= "d2",
-		.gpio			= AT91_PIN_PD21,
-		.active_low		= 1,
-		.default_trigger	= "mmc0",
+	{
+		.name			= "led-b",
+		.gpio			= AT91_PIN_PA29,
+		.active_low		= 1
+	},
+	{
+		.name			= "led-c",
+		.gpio			= AT91_PIN_PA25,
+		.active_low		= 1
+	},
+	{
+		.name			= "led-d",
+		.gpio			= AT91_PIN_PA26,
+		.active_low		= 1
+	},
+	{
+		.name			= "led-e",
+		.gpio			= AT91_PIN_PA27,
+		.active_low		= 1
 	},
+	{
+		.name			= "led-f",
+		.gpio			= AT91_PIN_PA28,
+		.active_low		= 1
+	},
+};
+
+
+uint8_t mts_id_eeprom[512];
+uint8_t mts_dc_eeprom[512];
+
+EXPORT_SYMBOL(mts_id_eeprom);
+EXPORT_SYMBOL(mts_dc_eeprom);
+
+/*
+ * On-board EEPROM
+ */
+static void mts_id_eeprom_load(struct memory_accessor *macc, void *context)
+{
+	int tmp;
+
+	memset(mts_id_eeprom, 0, sizeof(mts_id_eeprom));
+
+	tmp = macc->read(macc, mts_id_eeprom, 0, sizeof(mts_id_eeprom));
+	if (tmp != sizeof(mts_id_eeprom)) {
+		printk(KERN_ERR "sam9x5: id eeprom read failed: %d\n", tmp);
+	} else {
+		printk(KERN_INFO "sam9x5: read %d bytes from id eeprom\n", tmp);
+	}
+}
+
+static struct at24_platform_data at24c04_data = {
+	.byte_len	= SZ_4K / 8,
+	.page_size	= 16,
+	.setup		= mts_id_eeprom_load,
+};
+
+/*
+ * Daughter card EEPROM
+ */
+static void mts_dc_eeprom_load(struct memory_accessor *macc, void *context)
+{
+	int tmp;
+
+	memset(mts_dc_eeprom, 0, sizeof(mts_id_eeprom));
+
+	tmp = macc->read(macc, mts_dc_eeprom, 0, sizeof(mts_dc_eeprom));
+	if (tmp != sizeof(mts_dc_eeprom)) {
+		printk(KERN_INFO "sam9x5: dc eeprom read failed: %d\n", tmp);
+	} else {
+		printk(KERN_INFO "sam9x5: read %d bytes from dc eeprom\n", tmp);
+	}
+}
+
+static struct at24_platform_data dc_data = {
+	.byte_len	= SZ_4K / 8,
+	.page_size	= 16,
+	.setup		= mts_dc_eeprom_load,
 };
 
 /*
@@ -207,7 +351,12 @@
  */
 static struct i2c_board_info __initdata cm_i2c_devices[] = {
 	{
-		I2C_BOARD_INFO("24c512", 0x50)
+		I2C_BOARD_INFO("24c04", 0x56),
+		.platform_data = &at24c04_data,
+	},
+	{
+		I2C_BOARD_INFO("24c04", 0x50),
+		.platform_data = &dc_data,
 	},
 };
 
@@ -234,8 +383,12 @@
 	/* LEDs */
 	at91_gpio_leds(cm_leds, ARRAY_SIZE(cm_leds));
 
+	printk(KERN_CRIT "AT91: MTOCGD2 board\n");
+
+	/* MTOCGD2: disable
 	if (cm_is_revA())
 		printk(KERN_CRIT "AT91: CM rev A\n");
 	else
 		printk(KERN_CRIT "AT91: CM rev B and higher\n");
+	*/
 }
Index: git/arch/arm/mach-at91/board-sam9x5ek.c
===================================================================
--- git.orig/arch/arm/mach-at91/board-sam9x5ek.c	2013-12-27 14:27:13.000000000 -0600
+++ git/arch/arm/mach-at91/board-sam9x5ek.c	2014-02-06 15:18:45.409321681 -0600
@@ -23,6 +23,7 @@
 #include <linux/leds.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
+#include <linux/wl12xx.h>
 #include <mach/cpu.h>
 
 #include <video/atmel_lcdfb.h>
@@ -53,12 +54,10 @@
 	/* Initialize processor and DBGU */
 	cm_map_io();
 
-	/* USART0 on ttyS1. (Rx, Tx) */
-	at91_register_uart(AT91SAM9X5_ID_USART0, 1, 0);
-	/* USART1 on ttyS2. (Rx, Tx) */
-	at91_register_uart(AT91SAM9X5_ID_USART1, 2, 0);
-	/* USART2 on ttyS3. (Rx, Tx) */
-	at91_register_uart(AT91SAM9X5_ID_USART2, 3, 0);
+	// MTOCGD2: GPS on UART0 as ttyS1 with Rx/Tx only
+	at91_register_uart(AT91SAM9X5_ID_UART0, 1, 0);
+	// MTOCGD2 Rev A: Daughter card serial on USART1 as ttyS2 with RTS/CTS
+	at91_register_uart(AT91SAM9X5_ID_USART1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
 }
 
 /*
@@ -89,34 +88,65 @@
  * MACB Ethernet devices
  */
 static struct at91_eth_data __initdata ek_macb0_data = {
-	.is_rmii	= 1,
+	.is_rmii	= 0,
+	.phy_irq_pin	= 0,
 };
 
+/* MTOCGD2: no macb1
 static struct at91_eth_data __initdata ek_macb1_data = {
 	.phy_irq_pin	= AT91_PIN_PC26,
 	.is_rmii	= 1,
 };
+*/
 
 
 /*
  * MCI (SD/MMC)
  */
-/* mci0 detect_pin is revision dependent */
+// MTOCGD2: MCI0 is BT/Wifi
 static struct mci_platform_data __initdata mci0_data = {
 	.slot[0] = {
 		.bus_width	= 4,
+		.detect_pin	= -1,
 		.wp_pin		= -1,
 	},
 };
 
+// MTOCGD2: MCI1 is SD card slot
 static struct mci_platform_data __initdata mci1_data = {
 	.slot[0] = {
 		.bus_width	= 4,
-		.detect_pin	= AT91_PIN_PD14,
-		.wp_pin		= -1,
+		.detect_pin	= AT91_PIN_PA1,
+		.wp_pin		= AT91_PIN_PA0,
 	},
 };
 
+// MTR: Wi-fi
+static void wl12xx_enable(int poweron)
+{
+	if (poweron) {
+		at91_set_gpio_output_with_pullup(AT91_PIN_PC1, 0, 0);
+		msleep(10);
+		at91_set_gpio_output_with_pullup(AT91_PIN_PC1, 1, 0);
+		msleep(100);
+		printk(KERN_INFO "sam9x5: WLAN Enabled\n");
+	}
+	else {
+		at91_set_gpio_output_with_pullup(AT91_PIN_PC1, 0, 0);
+		msleep(10);
+		printk(KERN_INFO "sam9x5: WLAN Disabled\n");
+	}
+};
+
+// MTR: Wi-fi
+struct wl12xx_platform_data mtr_wlan_data  __initdata = {
+	.irq = AT91_PIN_PC2,
+	/* ref clock is 38.4 MHz */
+	.board_ref_clock = WL12XX_REFCLOCK_38,
+	/* toggles the WLAN_ENABLE pin */
+	.set_power = wl12xx_enable,
+};
+
 /*
  *  ISI
  */
@@ -330,9 +360,11 @@
  * I2C Devices
  */
 static struct i2c_board_info __initdata ek_i2c_devices[] = {
+#if 0
 	{
 		I2C_BOARD_INFO("wm8731", 0x1a)
 	},
+#endif
 #if defined(CONFIG_KEYBOARD_QT1070)
 	{
 		I2C_BOARD_INFO("qt1070", 0x1b),
@@ -388,18 +420,24 @@
 	bool config_isi_enabled = false;
 
 	cm_board_init(&cm_config);
-	ek_board_configure_pins();
+	// MTOCGD2: disable
+	//ek_board_configure_pins();
 	/* Serial */
 	at91_add_device_serial();
 	/* USB HS Host */
 	at91_add_device_usbh_ohci(&ek_usbh_fs_data);
 	at91_add_device_usbh_ehci(&ek_usbh_hs_data);
 	/* USB HS Device */
+	// MTOCGD2: set usb device vcc pin
+	ek_usba_udc_data.vbus_pin = AT91_PIN_PC7;
 	at91_add_device_usba(&ek_usba_udc_data);
 	/* Ethernet */
 	at91_add_device_eth(0, &ek_macb0_data);
+	/* MTOCGD2: no macb1
 	at91_add_device_eth(1, &ek_macb1_data);
+	*/
 	/* MMC0 */
+	// MTOCGD2: MCI0 for BT/Wifi
 	at91_add_device_mci(0, &mci0_data);
 	/* I2C */
 	if (cm_config & CM_CONFIG_I2C0_ENABLE)
@@ -409,6 +447,15 @@
 		at91_add_device_i2c(0,
 				ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices));
 
+	// MTOCGD2: Wi-fi
+	at91_set_gpio_input(mtr_wlan_data.irq, 0);
+	at91_set_deglitch(mtr_wlan_data.irq, 1);
+
+	if (wl12xx_set_platform_data(&mtr_wlan_data))
+		pr_err("error setting wl12xx data\n");
+
+/* MTOCGD2: no LCD */
+#if 0
 	if (cpu_is_at91sam9g25()) {
 		/* ISI */
 		/* NOTE: PCK0 provides ISI_MCK to the ISI module.
@@ -434,13 +481,10 @@
 		/* Touch Screen */
 		at91_add_device_tsadcc(&ek_tsadcc_data);
 	}
+#endif
 
-	/* MMC1 */
-	/* Conflict between SPI0, MCI1 and ISI pins.
-	 * add MCI1 only if SPI0 and ISI are both disabled.
-	 */
-	if (!(cm_config & CM_CONFIG_SPI0_ENABLE) && !config_isi_enabled)
-		at91_add_device_mci(1, &mci1_data);
+	// MTOCGD2: MCI1 to SD Card
+	at91_add_device_mci(1, &mci1_data);
 
 #if 0
 	if (cpu_is_at91sam9x25() || cpu_is_at91sam9x35())
@@ -452,6 +496,8 @@
 		at91_add_device_can(0, NULL);
 #endif
 
+/* MTOCGD2: disable things we don't have */
+#if 0
 	if (cpu_is_at91sam9x25() || cpu_is_at91sam9x35())
 		/* this conflicts with usart.1 */
 		at91_add_device_can(1, NULL);
@@ -478,6 +524,9 @@
 	else if (config_isi_enabled)
 		printk(KERN_CRIT
 			"AT91: ISI conficts with MCI1, disable MCI1\n");
+#endif
+
+	printk(KERN_CRIT "AT91: MTOCGD2 board EK init\n");
 }
 
 MACHINE_START(AT91SAM9X5EK, "Atmel AT91SAM9X5-EK")
Index: git/arch/arm/mach-at91/at91sam9x5_devices.c
===================================================================
--- git.orig/arch/arm/mach-at91/at91sam9x5_devices.c	2013-12-27 14:27:13.000000000 -0600
+++ git/arch/arm/mach-at91/at91sam9x5_devices.c	2014-02-06 15:18:45.409321681 -0600
@@ -543,11 +543,11 @@
 #endif
 
 	/* input/irq */
-	if (data->slot[0].detect_pin) {
+	if (data->slot[0].detect_pin > 0) {
 		at91_set_gpio_input(data->slot[0].detect_pin, 1);
 		at91_set_deglitch(data->slot[0].detect_pin, 1);
 	}
-	if (data->slot[0].wp_pin)
+	if (data->slot[0].wp_pin > 0)
 		at91_set_gpio_input(data->slot[0].wp_pin, 1);
 
 	if (mmc_id == 0) {		/* MCI0 */
@@ -849,7 +849,8 @@
 	.num_resources	= ARRAY_SIZE(spi1_resources),
 };
 
-static const unsigned spi1_standard_cs[4] = { AT91_PIN_PA8, AT91_PIN_PA0, AT91_PIN_PA31, AT91_PIN_PA30 };
+// MTOCGD2: SPI1 chip selects on pins SPI1_NCS1 to SPI1_NCS5
+static const unsigned spi1_standard_cs[5] = { AT91_PIN_PC15, AT91_PIN_PC16, AT91_PIN_PC17, AT91_PIN_PC18, AT91_PIN_PC19 };
 
 void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
 {