Add automatic HW detection for another CMC_PU2 variant
Patch by Martin Krause, 20 Apr 2005
diff --git a/CHANGELOG b/CHANGELOG
index 98d271b..56f3539 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,14 +2,17 @@
 Changes for U-Boot 1.1.4:
 ======================================================================
 
+* Add automatic HW detection for another CMC_PU2 variant
+  Patch by Martin Krause, 20 Apr 2005
+
 * Remove CONFIG_AT91RM9200DK in CMC-PU2 configuration
   Patch by Martin Krause, 19 Apr 2005
 
 * Fix initialization problem on TQM5200 without SM501
-  Patch by Martin Krause, 8 Apr. 2005
+  Patch by Martin Krause, 08 Apr 2005
 
 * Add RTC support for STK52XX.200
-  Patch by Martin Krause, 7 Apr. 2005
+  Patch by Martin Krause, 07 Apr 2005
 
 * Add support for IFM o2dnt board
 
diff --git a/board/cmc_pu2/cmc_pu2.c b/board/cmc_pu2/cmc_pu2.c
index 8e0f6d3..e54ca9c 100644
--- a/board/cmc_pu2/cmc_pu2.c
+++ b/board/cmc_pu2/cmc_pu2.c
@@ -35,8 +35,9 @@
 /*
  * Miscelaneous platform dependent initialisations
  */
-#define CMC_BASIC	1
+#define CMC_HP_BASIC	1
 #define CMC_PU2		2
+#define CMC_BASIC	4
 
 int hw_detect (void);
 
@@ -74,14 +75,14 @@
 	/*
 	 * On CMC-PU2 board configure PB3-PB6 to input without pull ups to
 	 * clear the duo LEDs (the external pull downs assure a proper
-	 * signal). On CMC-BASIC set PB3-PB6 to output and drive it
-	 * high, to configure current meassurement on AINx.
+	 * signal). On CMC-BASIC and CMC-HP-BASIC set PB3-PB6 to output and
+	 * drive it high, to configure current measurement on AINx.
 	 */
 	if (hw_detect() & CMC_PU2) {
 		piob->PIO_ODR = AT91C_PIO_PB3 | AT91C_PIO_PB4 |
 				AT91C_PIO_PB5 | AT91C_PIO_PB6;
 	}
-	else if (hw_detect() & CMC_BASIC) {
+	else if ((hw_detect() & CMC_BASIC) || (hw_detect() & CMC_HP_BASIC)) {
 		piob->PIO_SODR = AT91C_PIO_PB3 | AT91C_PIO_PB4 |
 				AT91C_PIO_PB5 | AT91C_PIO_PB6;
 		piob->PIO_OER = AT91C_PIO_PB3 | AT91C_PIO_PB4 |
@@ -119,6 +120,8 @@
 		puts ("Board: CMC-PU2 (Rittal GmbH)\n");
 	else if (hw_detect() & CMC_BASIC)
 		puts ("Board: CMC-BASIC (Rittal GmbH)\n");
+	else if (hw_detect() & CMC_HP_BASIC)
+		puts ("Board: CMC-HP-BASIC (Rittal GmbH)\n");
 	else
 		puts ("Board: unknown\n");
 	return 0;
@@ -135,7 +138,17 @@
 	pio->PIO_ODR = AT91C_PIO_PB12;
 	pio->PIO_PPUDR = AT91C_PIO_PB12;
 	pio->PIO_PER = AT91C_PIO_PB12;
+	
+	/* configure PB13 as input without pull up */
+	pio->PIO_ODR = AT91C_PIO_PB13;
+	pio->PIO_PPUDR = AT91C_PIO_PB13;
+	pio->PIO_PER = AT91C_PIO_PB13;
 
 	/* read board identification pin */
-	return ((pio->PIO_PDSR & AT91C_PIO_PB12) ? CMC_PU2 : CMC_BASIC);
+	if (pio->PIO_PDSR & AT91C_PIO_PB12)
+		return ((pio->PIO_PDSR & AT91C_PIO_PB13)
+			? CMC_PU2 : 0);
+	else
+		return ((pio->PIO_PDSR & AT91C_PIO_PB13)
+			? CMC_HP_BASIC : CMC_BASIC);
 }