summaryrefslogtreecommitdiff
path: root/recipes-bsp/u-boot/u-boot-2016.09.01/mtcdtsdold.patch
blob: 165a7d0dde522acdabaa410592173a451a1bb709 (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
diff -raNu old/board/atmel/at91sam9x5ek/at91sam9x5ek.c new/board/atmel/at91sam9x5ek/at91sam9x5ek.c
--- old/board/atmel/at91sam9x5ek/at91sam9x5ek.c	2017-05-05 11:09:53.668926301 -0500
+++ new/board/atmel/at91sam9x5ek/at91sam9x5ek.c	2017-05-05 17:35:53.342774065 -0500
@@ -44,7 +44,8 @@
 	csa = readl(&matrix->ebicsa);
 	csa |= AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA;
 	/* NAND flash on D16 */
-	csa |= AT91_MATRIX_NFD0_ON_D16;
+	/* MTCDT: nand flash is set up by bootstrap, so leave it alone here */
+	/* csa |= AT91_MATRIX_NFD0_ON_D16; */
 
 	/* Configure IO drive */
 	csa &= ~AT91_MATRIX_EBI_EBI_IOSR_NORMAL;
@@ -256,6 +257,9 @@
 
 int board_init(void)
 {
+	/* Set Status LED High */
+	at91_set_gpio_output(BOOT_STATUS_LED, 0);
+
 	/* arch number of AT91SAM9X5EK-Board */
 	gd->bd->bi_arch_number = MACH_TYPE_AT91SAM9X5EK;
 
@@ -267,6 +271,7 @@
 #endif
 
 #ifdef CONFIG_ATMEL_SPI
+	at91_spi0_hw_init(1 << 0);
 	at91_spi0_hw_init(1 << 4);
 #endif
 
@@ -283,12 +288,6 @@
 	return 0;
 }
 
-int dram_init(void)
-{
-	gd->ram_size = get_ram_size((void *) CONFIG_SYS_SDRAM_BASE,
-					CONFIG_SYS_SDRAM_SIZE);
-	return 0;
-}
 
 #if defined(CONFIG_SPL_BUILD)
 #include <spl.h>
@@ -362,4 +361,69 @@
 	/* DDRAM2 Controller initialize */
 	ddr2_init(ATMEL_BASE_DDRSDRC, ATMEL_BASE_CS1, &ddr2);
 }
+
 #endif
+
+/* on-board EEPROM */
+struct mts_id_eeprom_layout {
+    char vendor_id[32];
+    char product_id[32];
+    char device_id[32];
+    char hw_version[32];
+    uint8_t mac_addr[6];
+    char imei[32];
+    uint8_t capa[32];
+    uint8_t mac_bluetooth[6];
+    uint8_t mac_wifi[6];
+    uint8_t reserved[302];
+};
+
+int board_get_enetaddr(uchar *enetaddr)
+{
+	struct mts_id_eeprom_layout eeprom_buffer = {0};
+
+	if (eeprom_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, &eeprom_buffer, sizeof(eeprom_buffer))) {
+		printf("EEPROM: read error\n");
+		return 0;
+	}
+
+	if (eeprom_buffer.vendor_id[0] == 0x00 || eeprom_buffer.vendor_id[0] == 0xFF) {
+		printf("EEPROM: uninitialized\n");
+		return 0;
+	}
+
+	printf("vendor-id:  %s\n",  eeprom_buffer.vendor_id);
+	printf("product-id: %s\n", eeprom_buffer.product_id);
+	printf("device-id:  %s\n",  eeprom_buffer.device_id);
+	printf("hw-version: %s\n", eeprom_buffer.hw_version);
+	printf("mac-addr:   %02x:%02x:%02x:%02x:%02x:%02x\n", eeprom_buffer.mac_addr[0],
+		eeprom_buffer.mac_addr[1],
+		eeprom_buffer.mac_addr[2],
+		eeprom_buffer.mac_addr[3],
+		eeprom_buffer.mac_addr[4],
+		eeprom_buffer.mac_addr[5]);
+
+	memcpy(enetaddr, eeprom_buffer.mac_addr, 6);
+
+	return 1;
+}
+
+int misc_init_r(void)
+{
+	uchar enetaddr[6];
+
+	/* set MAC address from EEPROM if read successful */
+	if (board_get_enetaddr(enetaddr)) {
+		eth_setenv_enetaddr("ethaddr", enetaddr);
+	}
+
+	return 0;
+}
+
+int dram_init(void)
+{
+	gd->ram_size = get_ram_size((void *) CONFIG_SYS_SDRAM_BASE,
+					CONFIG_SYS_SDRAM_SIZE);
+	return 0;
+}
+