summaryrefslogtreecommitdiff
path: root/multitech/recipes/linux/linux-2.6.39.4/mt100eocg-pcie-dk/linux-2.6.39.4-mach-at91-mt100eocg-pcie-dk.patch
blob: 470c5be281f574f185569ba2866f8e3c46934852 (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
Index: linux-2.6.39.4/arch/arm/mach-at91/at91sam9260_devices.c
===================================================================
--- linux-2.6.39.4.orig/arch/arm/mach-at91/at91sam9260_devices.c	2011-08-03 14:43:28.000000000 -0500
+++ linux-2.6.39.4/arch/arm/mach-at91/at91sam9260_devices.c	2013-04-19 14:31:55.273588327 -0500
@@ -183,9 +183,9 @@
 		at91_set_B_periph(AT91_PIN_PA25, 0);	/* ERX2 */
 		at91_set_B_periph(AT91_PIN_PA26, 0);	/* ERX3 */
 		at91_set_B_periph(AT91_PIN_PA27, 0);	/* ERXCK */
-		at91_set_B_periph(AT91_PIN_PA23, 0);	/* ETX2 */
-		at91_set_B_periph(AT91_PIN_PA24, 0);	/* ETX3 */
-		at91_set_B_periph(AT91_PIN_PA22, 0);	/* ETXER */
+		at91_set_B_periph(AT91_PIN_PA10, 0);	/* ETX2 */
+		at91_set_B_periph(AT91_PIN_PA11, 0);	/* ETX3  */
+		/*at91_set_B_periph(AT91_PIN_PA22, 0);*/	/* ETXER */
 	}
 
 	eth_data = *data;
@@ -571,7 +571,15 @@
 	.num_resources	= ARRAY_SIZE(spi1_resources),
 };
 
-static const unsigned spi1_standard_cs[4] = { AT91_PIN_PB3, AT91_PIN_PC5, AT91_PIN_PC4, AT91_PIN_PC3 };
+static const unsigned spi1_standard_cs[7] = {
+	AT91_PIN_PB21,  // CS0 - external pin SPI_CS7
+	AT91_PIN_PC5,   // CS1 - GP output
+	AT91_PIN_PC4,   // CS2 - temp sensor
+	AT91_PIN_PC6,   // CS3 - unused/floating
+	AT91_PIN_PB12,  // CS4 - GP input
+	AT91_PIN_PB13,  // CS5 - external pin SPI_CS5
+	AT91_PIN_PB16   // CS6 - external pin SPI_CS6
+};
 
 void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
 {
Index: linux-2.6.39.4/arch/arm/mach-at91/board-sam9g20ek.c
===================================================================
--- linux-2.6.39.4.orig/arch/arm/mach-at91/board-sam9g20ek.c	2011-08-03 14:43:28.000000000 -0500
+++ linux-2.6.39.4/arch/arm/mach-at91/board-sam9g20ek.c	2013-04-19 16:49:59.147306517 -0500
@@ -30,6 +30,12 @@
 #include <linux/regulator/machine.h>
 #include <linux/regulator/fixed.h>
 #include <linux/regulator/consumer.h>
+#include <linux/i2c/at24.h>
+#include <linux/spi/eeprom.h>
+#include <linux/spi/flash.h>
+#include <linux/delay.h>
+#include <mach/at91_rtt.h>
+#include <linux/wl12xx.h>
 
 #include <mach/hardware.h>
 #include <asm/setup.h>
@@ -59,9 +65,14 @@
 	return machine_is_at91sam9g20ek_2mmc() || (system_rev & HAVE_2MMC);
 }
 
+#define WL12XX_ENABLE_PIN AT91_PIN_PB7
+
+static int i2c_present;
 
 static void __init ek_map_io(void)
 {
+	int tmp;
+
 	/* Initialize processor: 18.432 MHz crystal */
 	at91sam9260_initialize(18432000);
 
@@ -76,12 +87,55 @@
 	/* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
 	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
 
+	/*
+	 * Reset any initiated i2c data transfers?
+	 */
+	at91_set_gpio_input(AT91_PIN_PA23, 0);
+	at91_set_gpio_output(AT91_PIN_PA24, 0);
+	for (tmp = 0; tmp < 11; tmp++) {
+		at91_set_gpio_value(AT91_PIN_PA24, 0);
+		udelay(20);
+		at91_set_gpio_value(AT91_PIN_PA24, 1);
+		udelay(20);
+	}
+	at91_set_gpio_input(AT91_PIN_PA24, 0);
+
+	/*
+	 * PA24 and PA23 are used as ID pins on MTCBA/MTCDP-0.0 and I2C pins on MTCDP-1.0.
+	 *
+	 *   MTCBA Rev. B: 0x01, C: 0x02, D: 0x03
+	 *   MTCDP Rev. A reads as 0x00 with TWCK and TWD pulled high
+	 *
+	 */
+	tmp = !at91_get_gpio_value(AT91_PIN_PA24) << 1 | !at91_get_gpio_value(AT91_PIN_PA23);
+
+	i2c_present = !tmp;
+
+	/*
+	 * The GPS receiver is either at US2 on MTCBA/MTCDP-0.0 and US3 on MTCDP-1.0.
+	 */
+	if (i2c_present) {
+		at91_register_uart(AT91SAM9260_ID_US3, 3, ATMEL_UART_CTS | ATMEL_UART_RTS);
+		printk(KERN_INFO "sam9g20: i2c available\n");
+	} else {
+		at91_register_uart(AT91SAM9260_ID_US2, 3, 0);
+		printk(KERN_INFO "sam9g20: i2c not available\n");
+	}
+
 	/* set serial console to ttyS0 (ie, DBGU) */
 	at91_set_serial_console(0);
 }
 
 static void __init ek_init_irq(void)
 {
+	/*
+	 * Ensure RTT interrupts are disabled
+	 */ 
+	u32 mr;
+	mr = __raw_readl(AT91_VA_BASE_SYS + AT91_RTT + AT91_RTT_MR);
+	__raw_writel(mr & ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN),
+			AT91_VA_BASE_SYS + AT91_RTT + AT91_RTT_MR);
+
 	at91sam9260_init_interrupts(NULL);
 }
 
@@ -97,10 +151,37 @@
  * USB Device port
  */
 static struct at91_udc_data __initdata ek_udc_data = {
-	.vbus_pin	= AT91_PIN_PC5,
-	.pullup_pin	= 0,		/* pull-up driven by UDC */
+	.vbus_pin	= AT91_PIN_PC12,
+	.pullup_pin	= 0,			/* pull-up driven by UDC */
+};
+
+
+#define MTS_EXT_AT25_TEST		0
+#if MTS_EXT_AT25_TEST
+static struct spi_eeprom at25040b = {
+	.byte_len	= SZ_4K / 8,
+	.name		= "at25040b",
+	.page_size	= 8,
+	.flags		= EE_ADDR1,
+};
+#endif
+
+#define MTS_EXT_STT25_TEST		0
+#if MTS_EXT_STT25_TEST
+static struct mtd_partition m25_partitions[] = {
+	{
+		.name	= "flash",
+		.offset	= 0x00000000,
+		.size	= MTDPART_SIZ_FULL,
+	},
 };
 
+static struct flash_platform_data m25_spi_flash_data = {
+	.type		= "sst25vf080b",
+	.nr_parts	= ARRAY_SIZE(m25_partitions),
+	.parts		= m25_partitions,
+};
+#endif
 
 /*
  * SPI devices.
@@ -122,6 +203,54 @@
 	},
 #endif
 #endif
+	{
+		.modalias	= "mts-io-sout",
+		.chip_select	= 0,
+		.bus_num	= 1,
+	},
+	{
+		.modalias	= "mts-io-board-temp",
+		.chip_select	= 2,
+		.bus_num	= 1,
+	},
+	{
+		.modalias	= "mts-io-dout",
+		.chip_select	= 1,
+		.bus_num	= 1,
+	},
+	{
+		.modalias	= "mts-io-din",
+		.chip_select	= 4,
+		.bus_num	= 1,
+	},
+#if MTS_EXT_AT25_TEST
+	{
+		.modalias	= "at25",
+		.platform_data	= &at25040b,
+		.max_speed_hz	= 20 * 1000 * 1000,
+		.bus_num	= 1,
+		.chip_select	= 5,
+		.mode		= SPI_MODE_0,
+	},
+	{
+		.modalias	= "at25",
+		.platform_data	= &at25040b,
+		.max_speed_hz	= 20 * 1000 * 1000,
+		.bus_num	= 1,
+		.chip_select	= 6,
+		.mode		= SPI_MODE_0,
+	},
+#endif
+#if MTS_EXT_STT25_TEST
+	{
+		.modalias	= "m25p80",
+		.platform_data	= &m25_spi_flash_data,
+		.irq		= NO_IRQ,
+		.max_speed_hz	= 33 * 1000 * 1000,
+		.bus_num	= 1,
+		.chip_select	= 5,
+	},
+#endif
 };
 
 
@@ -130,7 +259,7 @@
  */
 static struct at91_eth_data __initdata ek_macb_data = {
 	.phy_irq_pin	= AT91_PIN_PA7,
-	.is_rmii	= 1,
+	.is_rmii	= 0,
 };
 
 static void __init ek_add_device_macb(void)
@@ -146,18 +275,48 @@
  */
 static struct mtd_partition __initdata ek_nand_partition[] = {
 	{
-		.name   = "Bootstrap",
-		.offset = 0,
-		.size   = 4 * SZ_1M,
+		.name	= "MTNCG-NANDFlash",
+		.offset	= 0,
+		.size	= 256*1024*1024,
+	},
+	{
+		.name	= "AT91Bootstrap",
+		.offset	= 0,
+		.size	= 128*1024,
+	},
+	{
+		.name	= "UBoot",
+		.offset	= 128*1024,
+		.size	= 256*1024,
+	},
+	{
+		.name	= "UBoot Config",
+		.offset	= 384*1024,
+		.size	= 128*1024,
+	},
+	{
+		.name	= "UBoot Redundant Config",
+		.offset	= 512*1024,
+		.size	= 128*1024,
+	},
+	{
+		.name	= "uImage",
+		.offset	= 640*1024,
+		.size	= 59*128*1024,
+	},
+	{
+		.name	= "Config",
+		.offset	= 64*128*1024,
+		.size	= 64*128*1024,
 	},
 	{
-		.name	= "Partition 1",
-		.offset	= MTDPART_OFS_NXTBLK,
-		.size	= 60 * SZ_1M,
+		.name	= "Oem Config",
+		.offset	= 128*128*1024,
+		.size	= 64*128*1024,
 	},
 	{
-		.name	= "Partition 2",
-		.offset	= MTDPART_OFS_NXTBLK,
+		.name	= "Rootfs",
+		.offset	= 192*128*1024,
 		.size	= MTDPART_SIZ_FULL,
 	},
 };
@@ -228,10 +387,10 @@
 
 };
 #else
+/* MT100ECOG-PCIE-DK: SDIO for WLAN */
 static struct at91_mmc_data __initdata ek_mmc_data = {
 	.slot_b		= 1,	/* Only one slot so use slot B */
 	.wire4		= 1,
-	.det_pin	= AT91_PIN_PC9,
 };
 #endif
 
@@ -252,15 +411,10 @@
  * LEDs
  */
 static struct gpio_led ek_leds[] = {
-	{	/* "bottom" led, green, userled1 to be defined */
-		.name			= "ds5",
-		.gpio			= AT91_PIN_PA6,
+	{	/* "status" led, green */
+		.name			= "status",
+		.gpio			= AT91_PIN_PA30,
 		.active_low		= 1,
-		.default_trigger	= "none",
-	},
-	{	/* "power" led, yellow */
-		.name			= "ds1",
-		.gpio			= AT91_PIN_PA9,
 		.default_trigger	= "heartbeat",
 	}
 };
@@ -363,16 +517,60 @@
 static void __init ek_add_regulators(void) {}
 #endif
 
+uint8_t mts_id_eeprom[512];
+
+EXPORT_SYMBOL(mts_id_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 "sam9g20: id eeprom read failed: %d\n", tmp);
+	} else {
+		printk(KERN_INFO "sam9g20: 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,
+};
+
 
 static struct i2c_board_info __initdata ek_i2c_devices[] = {
-        {
-                I2C_BOARD_INFO("24c512", 0x50)
-        },
-        {
-                I2C_BOARD_INFO("wm8731", 0x1b)
-        },
+	{
+		I2C_BOARD_INFO("24c04", 0x56),
+		.platform_data = &at24c04_data,
+	},
 };
 
+/* MT100EOCG-PCIE-DK: WL12XX support */
+static void wl12xx_enable(int enable)
+{
+	if (enable) {
+       	 	at91_set_gpio_output_with_pullup(WL12XX_ENABLE_PIN, 0, 0);
+       	 	msleep(10);
+        	at91_set_gpio_output_with_pullup(WL12XX_ENABLE_PIN, 1, 0);
+        	msleep(100);
+                printk(KERN_INFO "WLAN Enabled\n");
+        }
+        else {
+       	 	at91_set_gpio_output_with_pullup(WL12XX_ENABLE_PIN, 0, 0);
+       	 	msleep(10);
+                printk(KERN_INFO "WLAN Disabled\n");
+        }
+};
+
+static struct wl12xx_platform_data at91_wl12xx_wlan_data __initdata = {
+	.irq = AT91_PIN_PB19,
+	.board_ref_clock = WL12XX_REFCLOCK_38,
+	.set_power = wl12xx_enable,
+};
 
 static void __init ek_board_init(void)
 {
@@ -401,7 +599,22 @@
 	/* PCK0 provides MCLK to the WM8731 */
 	at91_set_B_periph(AT91_PIN_PC1, 0);
 	/* SSC (for WM8731) */
-	at91_add_device_ssc(AT91SAM9260_ID_SSC, ATMEL_SSC_TX);
+	/* at91_add_device_ssc(AT91SAM9260_ID_SSC, ATMEL_SSC_TX); */
+
+	/* MT100ECOG-PCIE-DK
+	 * configure the WLAN_IRQ for input
+	 */
+	at91_set_gpio_input(at91_wl12xx_wlan_data.irq, 0);
+	at91_set_deglitch(at91_wl12xx_wlan_data.irq, 1);
+
+	if (wl12xx_set_platform_data(&at91_wl12xx_wlan_data))
+		pr_err("error setting wl12xx data\n");
+
+	/* configure WLAN_EN as output and enable chip */
+	at91_set_gpio_output_with_pullup(WL12XX_ENABLE_PIN, 0, 0);
+	mdelay(10);
+	at91_set_gpio_output_with_pullup(WL12XX_ENABLE_PIN, 1, 0);
+	mdelay(100);
 }
 
 MACHINE_START(AT91SAM9G20EK, "Atmel AT91SAM9G20-EK")