[aadk-commits] qwell: branch u-boot/upstreamsync r301 - in
/u-boot/branches/upstreamsync/u-b...
aadk-commits at lists.digium.com
aadk-commits at lists.digium.com
Mon Apr 2 14:33:37 MST 2007
Author: qwell
Date: Mon Apr 2 16:33:36 2007
New Revision: 301
URL: http://svn.digium.com/view/aadk?view=rev&rev=301
Log:
Pull in the changes from the past few weeks that were made in trunk
Modified:
u-boot/branches/upstreamsync/u-boot_1.1.6/board/s800i/dig_i2c_eeprom.h
u-boot/branches/upstreamsync/u-boot_1.1.6/board/s800i/i2c.c
u-boot/branches/upstreamsync/u-boot_1.1.6/board/s800i/i2c_cfg.c
u-boot/branches/upstreamsync/u-boot_1.1.6/board/s800i/s800i.c
u-boot/branches/upstreamsync/u-boot_1.1.6/include/configs/s800i.h
u-boot/branches/upstreamsync/u-boot_1.1.6/lib_blackfin/blackfin_board.h
Modified: u-boot/branches/upstreamsync/u-boot_1.1.6/board/s800i/dig_i2c_eeprom.h
URL: http://svn.digium.com/view/aadk/u-boot/branches/upstreamsync/u-boot_1.1.6/board/s800i/dig_i2c_eeprom.h?view=diff&rev=301&r1=300&r2=301
==============================================================================
--- u-boot/branches/upstreamsync/u-boot_1.1.6/board/s800i/dig_i2c_eeprom.h (original)
+++ u-boot/branches/upstreamsync/u-boot_1.1.6/board/s800i/dig_i2c_eeprom.h Mon Apr 2 16:33:36 2007
@@ -35,6 +35,7 @@
extern const struct rom_location eeprom_map[];
/*** Prototype ***/
-int get_i2c_mac(unsigned char * mac); //DBDEBUG temporary
-
+int get_i2c_mac(unsigned char * mac);
+void set_bootcmd_args(void);
+
#endif
Modified: u-boot/branches/upstreamsync/u-boot_1.1.6/board/s800i/i2c.c
URL: http://svn.digium.com/view/aadk/u-boot/branches/upstreamsync/u-boot_1.1.6/board/s800i/i2c.c?view=diff&rev=301&r1=300&r2=301
==============================================================================
--- u-boot/branches/upstreamsync/u-boot_1.1.6/board/s800i/i2c.c (original)
+++ u-boot/branches/upstreamsync/u-boot_1.1.6/board/s800i/i2c.c Mon Apr 2 16:33:36 2007
@@ -375,42 +375,6 @@
return 0;
}
-#define PAGE_SIZE (8)
-int i2c_writeDB(uchar chip, uint addr, int alen, uchar *buffer, int len)
-{
- struct i2c_msg msg;
- u8 addr_bytes[3]; /* lowest...highest byte of data address */
- u8 msg_buf[PAGE_SIZE+3];
- int i = 0;
- int j = 0;
-
- PRINTD("i2c_writeDB: chip=0x%x, addr=0x%x, alen=0x%x, len=0x%x, buf0=0x%x\n", chip, addr, alen, len, buffer[0]);
-
- /* chip address write */
- if(alen>0) {
- msg_buf[i++] = (u8)((addr >> 0) & 0x000000FF);
- }
- if(alen>1) {
- msg_buf[i++] = (u8)((addr >> 8) & 0x000000FF);
- }
- if(alen>2) {
- msg_buf[i++] = (u8)((addr >> 16) & 0x000000FF);
- }
-
- for(j = 0; j < len && j < PAGE_SIZE; j++){
- msg_buf[i++] = buffer[j];
- }
- msg.addr = chip;
- msg.flags = 0;
- msg.len = i;
- msg.buf = msg_buf;
-
- if (i2c_transfer(&msg)) return -1;
-
- return 0;
-
-}
-
/**
* i2c_write: - Write multiple bytes to an i2c device
*
Modified: u-boot/branches/upstreamsync/u-boot_1.1.6/board/s800i/i2c_cfg.c
URL: http://svn.digium.com/view/aadk/u-boot/branches/upstreamsync/u-boot_1.1.6/board/s800i/i2c_cfg.c?view=diff&rev=301&r1=300&r2=301
==============================================================================
--- u-boot/branches/upstreamsync/u-boot_1.1.6/board/s800i/i2c_cfg.c (original)
+++ u-boot/branches/upstreamsync/u-boot_1.1.6/board/s800i/i2c_cfg.c Mon Apr 2 16:33:36 2007
@@ -23,6 +23,11 @@
#include <asm/byteorder.h>
#include "dig_i2c_eeprom.h"
+
+#define BOARDREV_ARG "boardrev"
+#define PRODSKU_ARG "productsku"
+#define CAPABILITY_ARG "capability"
+#define BLACKFINREV_ARG "bfinrev"
/* Map of where data is stored in the i2c eeprom */
const struct rom_location eeprom_map[] = {
@@ -36,16 +41,36 @@
{ .state = DIGCMD_NULL, .offset =0, .size = I2C_PROM_SIZE}
};
-
-/*
- * Retrieve the MAC address stored in i2c EEPROM memory
- */
-int get_i2c_mac(unsigned char * mac)
-{
+/*
+ * Helper function that copies a configuration field to specified buffer.
+ * Assumes that enough space is available in the buffer
+ */
+static int copy_i2c_field(enum cmd_state item, unsigned char * target, unsigned char * source)
+{
+ int length = 0;
int i, j;
- unsigned char prom_image[I2C_PROM_SIZE +1];
+
+ for(i = 0; DIGCMD_NULL != eeprom_map[i].state; i++) {
+ /* Set the MAC address to what was stored here */
+ if(item == eeprom_map[i].state) {
+ for(j = 0; j < eeprom_map[i].size; j++){
+ target[j] = source[eeprom_map[i].offset +j];
+ }
+ length = j;
+ break;
+ }
+ }
+ return length;
+}
+
+/*
+ * Helper function that extracts the full contents of the I2C eeprom and puts it into memory
+ * The data's CRC is validated as part of the function.
+ */
+static int get_i2c_eeprom_data(unsigned char * prom_image)
+{
+ uchar chip = I2C_PROM_ADDRESS;
ulong conv_num;
- uchar chip = I2C_PROM_ADDRESS;
/* Get the contents of the existing eeprom */
if (0 != i2c_read(chip, 0, 1, prom_image,I2C_PROM_SIZE)) {
@@ -58,19 +83,90 @@
printf("CRC is not valid on the I2C memory IC\n");
return -1;
}
-
- for(i = 0; DIGCMD_NULL != eeprom_map[i].state; i++) {
- /* Set the MAC address to what was stored here */
- if(DIGCMD_MAC_ADDRESS == eeprom_map[i].state) {
- for(j = 0; j < 6; j++){
- mac[j] = prom_image[eeprom_map[i].offset +j];
- }
- break;
- }
- }
+ return 0;
+}
+
+/*
+ * Retrieve the MAC address stored in i2c EEPROM memory
+ */
+int get_i2c_mac(unsigned char * mac)
+{
+ unsigned char prom_image[I2C_PROM_SIZE +1];
+
+ /* Get the contents of the existing eeprom */
+ if (0 != get_i2c_eeprom_data(prom_image)) {
+ return -1;
+ }
+
+ copy_i2c_field(DIGCMD_MAC_ADDRESS, mac, prom_image);
return 0;
}
+/*
+ * Modify Boot Arguments
+ * If the following arguments are not set in the bootargs environment parameter,
+ * then get set them from the contents of the I2C configuration eeprom
+ *
+ * boardrev
+ * productsku
+ * capability
+ */
+void set_bootcmd_args(void)
+{
+ unsigned char prom_image[I2C_PROM_SIZE +1];
+ int bad_rom = 1;
+ int len;
+ char * tmp;
+ char set_parm[128];
+ char parm_val[128];
+ char new_bootargs[256];
+
+ tmp = getenv("bootargs");
+ strcpy(new_bootargs, tmp);
+
+ if (0 == get_i2c_eeprom_data(prom_image)) {
+ bad_rom = 0;
+ }
+
+ /* If the Board Rev is not set, then set the board rev from the contents
+ * If data cannot be read from the i2c, assume that this is a REV A board
+ * (Rev A's do not have this device resident.)
+ */
+ if(NULL == strstr(new_bootargs, BOARDREV_ARG)) {
+ if(0 == bad_rom && 0 < (len = copy_i2c_field(DIGCMD_BOARD_REVISION, parm_val, prom_image))) {
+ parm_val[len] = '\0';
+ sprintf(set_parm, " %s=%s", BOARDREV_ARG, parm_val);
+ } else {
+ sprintf(set_parm, " %s=A", BOARDREV_ARG);
+ }
+ strcat(new_bootargs, set_parm);
+ }
+ /* If the SKU is not set, then set the SKU from the contents */
+ if(NULL == strstr(new_bootargs, PRODSKU_ARG)){
+ parm_val[0] = '\0';
+ if(0 == bad_rom) {
+ copy_i2c_field(DIGCMD_PRODUCT_SKU, parm_val, prom_image);
+ }
+ sprintf(set_parm, " %s=%s", PRODSKU_ARG, parm_val);
+ strcat(new_bootargs, set_parm);
+ }
+ /* If the Capability not set, then set the Capaiblity from the contents */
+ if(NULL == strstr(new_bootargs, CAPABILITY_ARG)){
+ parm_val[0] = '\0';
+ if(0 == bad_rom) {
+ copy_i2c_field(DIGCMD_CAPABILITY_CODE, parm_val, prom_image);
+ }
+ sprintf(set_parm, " %s=%s", CAPABILITY_ARG, parm_val);
+ strcat(new_bootargs, set_parm);
+ }
+ /* If the Blackfin silicon revision is not set, then set it from ID register*/
+ if(NULL == strstr(new_bootargs, BLACKFINREV_ARG)){
+ sprintf(set_parm, " %s=0.%d", BLACKFINREV_ARG, *pCHIPID >>28);
+ strcat(new_bootargs, set_parm);
+ }
+ setenv("bootargs", new_bootargs);
+ return;
+}
/*
* Command to display the settings stored in the I2C PROM
@@ -79,27 +175,15 @@
{
unsigned char prom_image[I2C_PROM_SIZE +1];
unsigned char disp_buffer[I2C_PROM_SIZE];
- ulong conv_num;
- int i;
- char * parse;
struct rom_location * curr_field;
- int nbytes;
- uchar chip = I2C_PROM_ADDRESS;
/* Get the contents of the existing eeprom */
- if (0 != i2c_read(chip, 0, 1, prom_image,I2C_PROM_SIZE)) {
- printf("Cannot access serial EEPROM\n");
- return -1;
- }
-
- conv_num = crc32(0, prom_image, CRC_LOC);
- if(*(ulong *)(&prom_image[CRC_LOC]) != conv_num) {
- printf("Existing eeprom is are invalid\n");
+ if (0 != get_i2c_eeprom_data(prom_image)) {
return -1;
}
printf("************* I2C Configuration Data ************\n");
- curr_field = &eeprom_map[0];
+ curr_field = (struct rom_location *)(&eeprom_map[0]);
while(curr_field->state != DIGCMD_NULL){
switch(curr_field->state){
@@ -141,7 +225,7 @@
case DIGCMD_CAPABILITY_CODE:
strncpy(disp_buffer, &prom_image[curr_field->offset], curr_field->size);
disp_buffer[curr_field->size] = '\0';
- printf("MFG Date Code=%s\n", disp_buffer);
+ printf("Capability=%s\n", disp_buffer);
break;
case DIGCMD_CRC:
break;
Modified: u-boot/branches/upstreamsync/u-boot_1.1.6/board/s800i/s800i.c
URL: http://svn.digium.com/view/aadk/u-boot/branches/upstreamsync/u-boot_1.1.6/board/s800i/s800i.c?view=diff&rev=301&r1=300&r2=301
==============================================================================
--- u-boot/branches/upstreamsync/u-boot_1.1.6/board/s800i/s800i.c (original)
+++ u-boot/branches/upstreamsync/u-boot_1.1.6/board/s800i/s800i.c Mon Apr 2 16:33:36 2007
@@ -32,6 +32,7 @@
#include <asm/io.h>
#include "adm.h"
#include "ether_bf537.h"
+#include "dig_i2c_eeprom.h"
#define POST_WORD_ADDR 0xFF903FFC
@@ -175,6 +176,9 @@
#endif
adm_init();
SetupMacAddr(nid);
+
+ set_bootcmd_args(); /* Modify arguments that are passed to OS */
+
return 0;
}
#endif
Modified: u-boot/branches/upstreamsync/u-boot_1.1.6/include/configs/s800i.h
URL: http://svn.digium.com/view/aadk/u-boot/branches/upstreamsync/u-boot_1.1.6/include/configs/s800i.h?view=diff&rev=301&r1=300&r2=301
==============================================================================
--- u-boot/branches/upstreamsync/u-boot_1.1.6/include/configs/s800i.h (original)
+++ u-boot/branches/upstreamsync/u-boot_1.1.6/include/configs/s800i.h Mon Apr 2 16:33:36 2007
@@ -1,6 +1,9 @@
#ifndef __CONFIG_S800I_H__
#define __CONFIG_S800I_H__
#define __CONFIG_BF537_H__
+
+/* Pull in config Prompt from ID file */
+#include <configs/board_id.h>
#define CFG_LONGHELP 1
#define CONFIG_BAUDRATE 57600
@@ -238,7 +241,6 @@
/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
#include <cmd_confdefs.h>
-#define CFG_PROMPT "aadk> " /* Monitor Command Prompt */
#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
#define CFG_CBSIZE 1024 /* Console I/O Buffer Size */
#else
Modified: u-boot/branches/upstreamsync/u-boot_1.1.6/lib_blackfin/blackfin_board.h
URL: http://svn.digium.com/view/aadk/u-boot/branches/upstreamsync/u-boot_1.1.6/lib_blackfin/blackfin_board.h?view=diff&rev=301&r1=300&r2=301
==============================================================================
--- u-boot/branches/upstreamsync/u-boot_1.1.6/lib_blackfin/blackfin_board.h (original)
+++ u-boot/branches/upstreamsync/u-boot_1.1.6/lib_blackfin/blackfin_board.h Mon Apr 2 16:33:36 2007
@@ -30,7 +30,7 @@
#include <version.h>
-#include "board_id.h"
+#include <configs/board_id.h>
extern void timer_init(void);
extern void init_IRQ(void);
More information about the aadk-commits
mailing list