summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Liu <r64343@freescale.com>2010-05-14 16:08:22 +0800
committerJason Liu <r64343@freescale.com>2010-05-14 17:09:22 +0800
commita0e1ec967f99d08ce0a48c45a509959453e5f3a7 (patch)
treeedfa600011bbe5dd9218d883e5c9f6685b0c718b
parent9ef0863e8bd5eba9243b4f5e84b75806b1d4c889 (diff)
downloadu-boot-imx-a0e1ec967f99d08ce0a48c45a509959453e5f3a7.zip
u-boot-imx-a0e1ec967f99d08ce0a48c45a509959453e5f3a7.tar.gz
u-boot-imx-a0e1ec967f99d08ce0a48c45a509959453e5f3a7.tar.bz2
ENGR00123488 MX53 Board Identification
The CPU_ID0 analog voltage level is obtained by reading ADC channel 12 of the LTC2495 and the CPU_ID1 analog voltage level is obtained by reading ADC channel 13. The ADC data register value read from the LTC2495 is a 24 bit value. For example, an ADC value that reads between 0xB3CF3E and 0xB9E79E indicates a 130k ohm resistor is populated on the daughtercard, which corresponds to ID level 20 By using CPU_ID0, CPU_ID1 to identify the board for example: CPU_ID0 = 21, CPU_ID1 = 15, MX53-EVK with DDR2 1GByte RevB Signed-off-by:Jason Liu <r64343@freescale.com>
-rw-r--r--board/freescale/mx53_evk/mx53_evk.c170
1 files changed, 167 insertions, 3 deletions
diff --git a/board/freescale/mx53_evk/mx53_evk.c b/board/freescale/mx53_evk/mx53_evk.c
index 9526b2d..6be0b37 100644
--- a/board/freescale/mx53_evk/mx53_evk.c
+++ b/board/freescale/mx53_evk/mx53_evk.c
@@ -282,6 +282,168 @@ void setup_core_voltages(void)
/* Raise the core frequency to 800MHz */
writel(0x0, CCM_BASE_ADDR + CLKCTL_CACRR);
}
+
+static int __read_adc_channel(unsigned int chan)
+{
+ unsigned char buf[4] = { 0 };
+
+ buf[0] = (0xb0 | ((chan & 0x1) << 3) | ((chan >> 1) & 0x7));
+
+ /* LTC2495 need 410ms delay */
+ udelay(410000);
+
+ if (i2c_write(0x14, chan, 0, &buf[0], 1)) {
+ printf("%s:i2c_write:error\n", __func__);
+ return -1;
+ }
+
+ /* LTC2495 need 410ms delay*/
+ udelay(410000);
+
+ if (i2c_read(0x14, chan, 0, &buf[0], 3)) {
+ printf("%s:i2c_read:error\n", __func__);
+ return -1;
+ }
+
+ return buf[0] << 16 | buf[1] << 8 | buf[2];
+}
+
+static int __lookup_board_id(int adc_val)
+{
+ int id;
+
+ if (adc_val < 0x3FFFC0)
+ id = 0;
+ else if (adc_val < 0x461863)
+ id = 1;
+ else if (adc_val < 0x4C30C4)
+ id = 2;
+ else if (adc_val < 0x524926)
+ id = 3;
+ else if (adc_val < 0x586187)
+ id = 4;
+ else if (adc_val < 0x5E79E9)
+ id = 5;
+ else if (adc_val < 0x64924A)
+ id = 6;
+ else if (adc_val < 0x6AAAAC)
+ id = 7;
+ else if (adc_val < 0x70C30D)
+ id = 8;
+ else if (adc_val < 0x76DB6F)
+ id = 9;
+ else if (adc_val < 0x7CF3D0)
+ id = 10;
+ else if (adc_val < 0x830C32)
+ id = 11;
+ else if (adc_val < 0x892493)
+ id = 12;
+ else if (adc_val < 0x8F3CF5)
+ id = 13;
+ else if (adc_val < 0x955556)
+ id = 14;
+ else if (adc_val < 0x9B6DB8)
+ id = 15;
+ else if (adc_val < 0xA18619)
+ id = 16;
+ else if (adc_val < 0xA79E7B)
+ id = 17;
+ else if (adc_val < 0xADB6DC)
+ id = 18;
+ else if (adc_val < 0xB3CF3E)
+ id = 19;
+ else if (adc_val < 0xB9E79F)
+ id = 20;
+ else if (adc_val < 0xC00000)
+ id = 21;
+ else
+ return -1;
+
+ return id;
+}
+
+static int __print_board_info(int id0, int id1)
+{
+ int ret = 0;
+
+ switch (id0) {
+ case 21:
+ switch (id1) {
+ case 15:
+ printf("MX53-EVK with DDR2 1GByte RevB\n");
+
+ break;
+ case 18:
+ printf("MX53-EVK with DDR2 2GByte RevA1\n");
+
+ break;
+ case 19:
+ printf("MX53-EVK with DDR2 2GByte RevA2\n");
+ break;
+ default:
+ printf("Unkown board id1:%d\n", id1);
+ ret = -1;
+
+ break;
+ }
+
+ break;
+ case 11:
+ switch (id1) {
+ case 1:
+ printf("MX53 1.5V DDR3 x8 CPU Card, Rev. A\n");
+
+ break;
+ case 11:
+ printf("MX53 1.8V DDR2 x8 CPU Card, Rev. A\n");
+
+ break;
+ default:
+ printf("Unkown board id1:%d\n", id1);
+ ret = -1;
+
+ break;
+ }
+
+ break;
+ default:
+ printf("Unkown board id0:%d\n", id0);
+
+ break;
+ }
+
+ return ret;
+}
+
+int identify_board_id(void)
+{
+ int ret = 0;
+ int bd_id0, bd_id1;
+
+#define CPU_CHANNEL_ID0 0xc
+#define CPU_CHANNEL_ID1 0xd
+
+ ret = bd_id0 = __read_adc_channel(CPU_CHANNEL_ID0);
+ if (ret < 0)
+ return ret;
+
+ ret = bd_id1 = __read_adc_channel(CPU_CHANNEL_ID1);
+ if (ret < 0)
+ return ret;
+
+ ret = bd_id0 = __lookup_board_id(bd_id0);
+ if (ret < 0)
+ return ret;
+
+ ret = bd_id1 = __lookup_board_id(bd_id1);
+ if (ret < 0)
+ return ret;
+
+ ret = __print_board_info(bd_id0, bd_id1);
+
+ return ret;
+
+}
#endif
void spi_io_init(struct imx_spi_dev_t *dev)
@@ -520,10 +682,12 @@ int board_late_init(void)
int checkboard(void)
{
- printf("Board: MX53 EVK ");
-
- printf("1.0 [");
+ printf("Board: ");
+#ifdef CONFIG_I2C_MXC
+ identify_board_id();
+#endif
+ printf("Boot Reason: [");
switch (__REG(SRC_BASE_ADDR + 0x8)) {
case 0x0001: