Changeset 13096

Show
Ignore:
Timestamp:
10/16/2009 01:15:36 AM (5 months ago)
Author:
BrainSlayer
Message:

work in progress

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ar5315_microredboot/microredboot/CHANGELOG

    r13090 r13096  
     115.10.09 
     2    * start of ar7100 port (far from beeing finished, stub needs still to be written) 
     3 
    1414.10.09 
    25    * add some workarounds for slow low quality flash chips 
  • ar5315_microredboot/microredboot/boot/src/ramconfig.h

    r12519 r13096  
    1 #define RAM_SIZE 0x2000000 
     1#define RAM_SIZE 0x1000000 
    22#define AR5312 1 
    3 #define RESETBUTTON 0x06 
  • ar5315_microredboot/microredboot/ecos/packages/devs/eth/mips/ar531xPhy/athrs26/current/src/ae531xecos.h

    r12281 r13096  
    5959#endif 
    6060 
    61 #define DEBUG 0 /* TBDXXX */ 
     61//#define DEBUG 0 /* TBDXXX */ 
    6262 
    6363#if !defined(DEBUG) 
  • ar5315_microredboot/microredboot/ecos/packages/devs/eth/mips/ar531xPhy/kendin/current/src/ae531xecos.h

    r12281 r13096  
    5959#endif 
    6060 
    61 #define DEBUG 0 /* TBDXXX */ 
     61//#define DEBUG 0 /* TBDXXX */ 
    6262 
    6363#if !defined(DEBUG) 
  • ar5315_microredboot/microredboot/ecos/packages/devs/eth/mips/ar7100/current/src/ag7100.h

    r13095 r13096  
    4646} 
    4747#else 
    48 #define AG7100_PRINT(FLG, X)                       \ 
    49 {                                                   \ 
    50     if (ag7100_debug & (FLG)) {                     \ 
    51         DEBUG_PRINTF("#%d:%s ",                   \ 
    52                      __LINE__,                      \ 
    53                      __FUNCTION__);                 \ 
    54         DEBUG_PRINTF X;                             \ 
    55     }                                               \ 
    56 
     48#define AG7100_PRINT(FLG, X)  
    5749#endif 
    5850 
  • ar5315_microredboot/microredboot/ecos/packages/devs/eth/mips/ar7100/current/src/ag7100_ecos.h

    r13095 r13096  
    1111#include <string.h> 
    1212 
    13 #define DEBUG 1 /* TBDXXX */ 
     13//#define DEBUG 1 /* TBDXXX */ 
    1414 
    15 #if !defined(DEBUG) 
    16 #define DEBUG 0 
    17 #endif 
     15//#define DEBUG 0 
    1816 
    1917#define AG7100_TX_BUF_SIZE 1536 
  • ar5315_microredboot/microredboot/ecos/packages/devs/eth/mips/ar7100/current/src/rtPhy.c

    r13095 r13096  
    2424#include "ag7100_phy.h" 
    2525 
    26 #if /* DEBUG */ 1 
     26#if 0 
    2727#define RT_DEBUG_ERROR     0x00000001 
    2828#define RT_DEBUG_PHYSETUP  0x00000002 
     
    218218 
    219219#ifdef DEBUG 
    220  
     220#error "unwanted" 
    221221/* Define the PHY registers of interest for a phyShow command */ 
    222222struct rtRegisterTable_s { 
  • ar5315_microredboot/microredboot/ecos/packages/hal/mips/pb42/current/misc/redboot_RAM.ecm

    r13095 r13096  
    2121    package -template CYGPKG_LIBC_STRING current ; 
    2222    package CYGPKG_MEMALLOC current ; 
    23     package CYGPKG_COMPRESS_ZLIB current ; 
    2423    package CYGPKG_COMPRESS_7ZIP current ; 
    2524    package CYGPKG_IO_ETH_DRIVERS current ; 
  • ar5315_microredboot/microredboot/ecos/packages/hal/mips/pb42/current/misc/redboot_ROM.ecm

    r13095 r13096  
    2222    package CYGPKG_MEMALLOC v2_0 ; 
    2323    package CYGPKG_COMPRESS_7ZIP current ;       
    24     package CYGPKG_COMPRESS_ZLIB v2_0 ; 
    2524    package CYGPKG_IO_ETH_DRIVERS v2_0 ; 
    2625    package CYGPKG_IO_FILEIO v2_0 ; 
  • ar5315_microredboot/microredboot/ecos/packages/redboot/current/include/flash_config.h

    r12281 r13096  
    9999bool flash_add_config(struct config_option *opt, bool update); 
    100100 
     101// Get mac address. 
     102bool flash_get_mac_address(int type, void *val); 
     103 
     104#if defined(CYGPKG_HAL_MIPS_AR7100) 
     105#define ATHEROS_MODS 
     106#endif 
     107 
     108#ifdef ATHEROS_MODS 
     109 
     110#define ATHEROS_CONFIG_SIZE        0x2000 
     111#define ATHEROS_BOARD_CONFIG_SIZE  0x1000 
     112 
     113/* this structure lives in last sector of the flash */ 
     114struct _atheros_config { 
     115       /* We needed a simple way to read pll setting from flash when   */ 
     116       /* 'C' environment isn't ready yet. Putting this  in cfg_env    */ 
     117       /* would mean we would have to store and search the array using */  
     118       /* key=value format in assembly.  Having some of the config     */ 
     119       /* parameters at fixed offsets - makes redboot startup code     */ 
     120       /* simpler.                                                     */ 
     121       /* 0x3F0000/0x7F0000 starts here */ 
     122       unsigned int freq_setting;  
     123       unsigned int PCI_clock; 
     124       unsigned int reserved[2]; 
     125 
     126       /* generic config sector */ 
     127       unsigned int  magic_num; 
     128       unsigned int  version; 
     129       unsigned int  boardid; 
     130       unsigned char cfg_env[ATHEROS_BOARD_CONFIG_SIZE-8*4]; /* key=value pairs */ 
     131       unsigned int  checksum; /* covers the struct starting from magic_num */ 
     132 
     133       /* 0x3F1000/0x7F1000 starts here */ 
     134       unsigned char MAC1[6]; 
     135       unsigned char MAC2[6]; 
     136       unsigned char MAC3[6]; 
     137       unsigned char MAC4[6]; 
     138           unsigned int  macsum; 
     139}; 
     140 
     141bool flash_set_pll_freq (unsigned int val); 
     142#endif 
     143 
     144// read atheros PCI clock 
     145cyg_uint32 get_atheros_config_PCI_clock(void); 
     146 
    101147// Internal structure used to hold config data 
    102148struct _config { 
  • ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/fconfig.c

    r12281 r13096  
    7474externC bool cyg_plf_redboot_esa_validate(unsigned char *val); 
    7575#endif 
     76 
     77 
     78 
    7679 
    7780#ifdef CYGHWR_REDBOOT_FLASH_CONFIG_MEDIA_FLASH 
     
    106109#endif // FLASH MEDIA 
    107110 
     111#ifdef ATHEROS_MODS 
     112static struct _atheros_config ath_cfg;   
     113#endif 
     114 
    108115// Prototypes for local functions 
    109116static unsigned char *flash_lookup_config(char *key); 
     117 
     118#ifdef ATHEROS_MODS 
     119static int atoi(char *str); 
     120#ifdef CYGNUM_CONFIG_PRODUCT_ID 
     121static void do_mac_setting (int argc, char *argv[]); 
     122#endif /* CYGNUM_CONFIG_PRODUCT_ID */ 
     123 
     124static void do_pll_settings_usage(void); 
     125static void read_atheros_config(void); 
     126static int get_atheros_config_pll(void); 
     127static int set_atheros_config_pll(int v); 
     128static bool flash_set_pll_freq (unsigned int val); 
     129static bool update_atheros_config(void); 
     130#endif 
     131 
    110132 
    111133static bool config_ok; 
     
    492514} 
    493515 
     516#ifdef ATHEROS_MODS 
     517 
     518/********************************************************************************* 
     519** atoi 
     520** 
     521** Simple implementation of the conversion from decimal to binary integer value 
     522** 
     523*/ 
     524 
     525static int atoi(char *str) 
     526{ 
     527    int val  = 0; 
     528    int sign = 1; 
     529     
     530    while(*str == ' ') 
     531        str++;;   /* strip spaces */ 
     532     
     533    if(*str == '-') 
     534    { 
     535        sign = -1; 
     536        str++; 
     537    } 
     538     
     539    /* 
     540    ** Loop on digits 
     541    */ 
     542     
     543    while(*str > 0x2f && *str < 0x3a) 
     544    { 
     545        val= 10 * val + (*str++ - 0x30); 
     546    } 
     547     
     548    val = val * sign; 
     549     
     550    return (val);     
     551} 
     552 
     553 
     554#ifdef CYGNUM_CONFIG_PRODUCT_ID 
     555/* 
     556** If the product ID is defined for this board, then we provide the command for programming 
     557** the MAC addresses for the board.  It is assumed that the board will have a WAN Mac address 
     558** and a LAN mac address.  Only the WAN mac address is used by redboot, but both will be read 
     559** by Linux to program the WAN and LAN MAC addresses upon bootup. 
     560*/ 
     561 
     562static cmd_fun do_mac_setting; 
     563RedBoot_cmd("progmac", 
     564            "Programs the mac address(es) into flash.  Based on board serial number.Number of MACs required depends on board type", 
     565            "usage:\n" 
     566            "progmac serialno\n" 
     567            "  serialno = board serial number in decimal\n", 
     568            do_mac_setting 
     569        );  
     570 
     571/********************************************************************************** 
     572** do_mac_setting 
     573** 
     574** This is the executable portion of the progmac command.  This will process the 
     575** MAC address strings, and program them into the appropriate flash sector.. 
     576** 
     577*/ 
     578 
     579static void 
     580do_mac_setting (int argc, char *argv[]) 
     581{ 
     582    char    macPrefix[3]= { 0x00, 0x03, 0x7f }; 
     583    int     serno; 
     584 
     585    /* 
     586    ** Argv[1] contains the value string.  Convert to binary, and program the 
     587    ** values in flash 
     588    */ 
     589     
     590    serno = atoi(argv[1]); 
     591     
     592    /* 
     593    ** If the serial number is less than 0, or greater than 0x1fff, it's out of range 
     594    */ 
     595     
     596    if(serno < 0 || serno > 0x1fff) 
     597    { 
     598        diag_printf("Serno out of range\n",serno); 
     599        return; 
     600    } 
     601     
     602    /* 
     603    ** Create the 24 bit number that composes the lower 3 bytes of the MAC address 
     604    */ 
     605     
     606    serno = 0xFFFFFF & ( (CYGNUM_CONFIG_PRODUCT_ID << 13) | (serno & 0x1fff)); 
     607     
     608    /* 
     609    ** Get the values from flash, and program into the MAC address registers 
     610    */ 
     611     
     612    read_atheros_config(); 
     613     
     614    /* 
     615    ** Set the first and second values 
     616    */ 
     617     
     618    memcpy(ath_cfg.MAC1,macPrefix,3); 
     619    ath_cfg.MAC1[3] = 0xFF & (serno >> 16); 
     620    ath_cfg.MAC1[4] = 0xFF & (serno >> 8); 
     621    ath_cfg.MAC1[5] = 0xFF &  serno; 
     622     
     623    /* 
     624    ** Increment by 1 for the second MAC address 
     625    */ 
     626 
     627    serno++;     
     628    memcpy(ath_cfg.MAC2,macPrefix,3); 
     629    ath_cfg.MAC2[3] = 0xFF & (serno >> 16); 
     630    ath_cfg.MAC2[4] = 0xFF & (serno >> 8); 
     631    ath_cfg.MAC2[5] = 0xFF &  serno; 
     632     
     633    update_atheros_config(); 
     634} 
     635 
     636#endif /* CYGNUM_CONFIG_PRODUCT_ID */ 
     637 
     638/**************************************************************************************** 
     639** flash_get_mac_address 
     640** 
     641** This returns the indicated MAC address into the provided buffer.  The address is 
     642** based on the MAC pointer provided 
     643*/ 
     644 
     645 
     646bool 
     647flash_get_mac_address(int unit, void *pdata) 
     648{ 
     649    /* 
     650    ** Ensure we do a read first to make sure the data in the structure 
     651    ** is valid 
     652    */ 
     653     
     654    read_atheros_config(); 
     655     
     656    switch(unit) 
     657    { 
     658        case 0: 
     659            memcpy(pdata,ath_cfg.MAC1,6); 
     660            break; 
     661             
     662        case 1: 
     663            memcpy(pdata,ath_cfg.MAC1,6); 
     664            break; 
     665             
     666        case 2: 
     667            memcpy(pdata,ath_cfg.MAC1,6); 
     668            break; 
     669             
     670        case 3: 
     671            memcpy(pdata,ath_cfg.MAC1,6); 
     672            break; 
     673     } 
     674      
     675     return true; 
     676} 
     677 
     678 
     679 
     680 
     681 
     682static cmd_fun do_pll_setting; 
     683RedBoot_cmd("ar7100_pll", 
     684            "Set pll configuration for AR7100 (default = 0)", 
     685            "0 - use chip rev\n" 
     686            "1 - 200/200/100\n" 
     687            "2 - 300/300/150\n" 
     688            "3 - 333/333/166\n" 
     689            "4 - 266/266/133\n" 
     690            "5 - 266/266/66\n" 
     691            "6 - 400/400/200\n" 
     692            "7 - 600/300/150\n" 
     693            "8  - 680/340/170\n", 
     694            do_pll_setting 
     695        );  
     696 
     697static void 
     698do_pll_settings_usage(void) 
     699{ 
     700  diag_printf ("usage: ar7100_pll <0|1|2|3|4|5|6|7|8> where\n" 
     701           "0  - use chip rev\n" 
     702           "1  - 200/200/100\n" 
     703           "2  - 300/300/150\n" 
     704           "3  - 333/333/166\n" 
     705           "4  - 266/266/133\n" 
     706           "5  - 266/266/66\n" 
     707           "6  - 400/400/200\n" 
     708           "7  - 600/300/150\n" 
     709           "8  - 680/340/170\n"); 
     710  read_atheros_config(); 
     711  diag_printf ("current value is %d\n", get_atheros_config_pll()); 
     712} 
     713 
     714static void 
     715do_pll_setting (int argc, char *argv[]) 
     716{ 
     717  unsigned int  val; 
     718 
     719  if (argc != 2) { 
     720    do_pll_settings_usage(); 
     721    return; 
     722  } 
     723 
     724  /* 
     725  ** We now can have a two digit number.  If the second character is a digit, then we 
     726  ** calculate the value based on the two digits. 
     727  */ 
     728   
     729  val = atoi(argv[1]); 
     730   
     731  /* 
     732  ** The values 30 and 31 are "seceret" values for 720/340/170 and 800/400/200 
     733  ** divider settings, respectively.  These are used for debug ONLY, and are not 
     734  ** intimated to the user 
     735  */ 
     736   
     737  if ( val < 0 || ( (val > 8 ) && (val != 30) && (val != 31) ) ) { 
     738    do_pll_settings_usage(); 
     739    return; 
     740  } 
     741  flash_set_pll_freq(val);  
     742} 
     743 
     744#endif 
     745 
     746 
     747 
    494748static cmd_fun do_flash_config; 
    495749RedBoot_cmd("fconfig", 
     
    9081162    return false; 
    9091163} 
     1164 
     1165#ifdef ATHEROS_MODS  
     1166 
     1167#if (CYGNUM_FLASH_BLOCK_NUM == 64) 
     1168#define ATH_CFG_ADDR  0xbf3f0000  /* 4MB version */ 
     1169#else  
     1170#define ATH_CFG_ADDR  0xbf7f0000  /* 8MB version */ 
     1171#endif 
     1172 
     1173#define ATH_CFG_MAGIC_NUM  0xECECCECE 
     1174 
     1175static void 
     1176read_atheros_config(void) 
     1177{ 
     1178    /* 
     1179    ** Copy the structure from the flash area to RAM 
     1180    */ 
     1181     
     1182    memcpy (&ath_cfg, (char *)ATH_CFG_ADDR, sizeof(struct _atheros_config)); 
     1183     
     1184    /* 
     1185    ** Check for the "magic number" to be valid.  We should also use checksum 
     1186    */ 
     1187     
     1188    if (ath_cfg.magic_num != ATH_CFG_MAGIC_NUM) 
     1189    { 
     1190        memset(&ath_cfg,0,sizeof(ath_cfg)); 
     1191        ath_cfg.magic_num = ATH_CFG_MAGIC_NUM; 
     1192         
     1193        /* 
     1194        ** Need to set the MAC addresses to a default value 
     1195        */ 
     1196         
     1197        ath_cfg.MAC1[0]= 0x00; 
     1198        ath_cfg.MAC1[1]= 0x03; 
     1199        ath_cfg.MAC1[2]= 0x7f; 
     1200        ath_cfg.MAC1[3]= 0xff; 
     1201        ath_cfg.MAC1[4]= 0xff; 
     1202        ath_cfg.MAC1[5]= 0xfe; 
     1203 
     1204        ath_cfg.MAC2[0]= 0x00; 
     1205        ath_cfg.MAC2[1]= 0x03; 
     1206        ath_cfg.MAC2[2]= 0x7f; 
     1207        ath_cfg.MAC2[3]= 0xff; 
     1208        ath_cfg.MAC2[4]= 0xff; 
     1209        ath_cfg.MAC2[5]= 0xff; 
     1210    } 
     1211} 
     1212 
     1213 
     1214static int 
     1215get_atheros_config_pll(void) 
     1216{ 
     1217  if (ath_cfg.magic_num != ATH_CFG_MAGIC_NUM) 
     1218    read_atheros_config(); 
     1219 
     1220  return ath_cfg.freq_setting; 
     1221} 
     1222 
     1223static int 
     1224set_atheros_config_pll(int v) 
     1225{ 
     1226  if (ath_cfg.magic_num != ATH_CFG_MAGIC_NUM) 
     1227  { 
     1228    read_atheros_config(); 
     1229  } 
     1230   
     1231  ath_cfg.freq_setting=v; 
     1232 
     1233  return 0; 
     1234} 
     1235 
     1236static bool 
     1237flash_set_pll_freq (unsigned int val) 
     1238{ 
     1239  read_atheros_config(); 
     1240  set_atheros_config_pll(val); 
     1241   
     1242  return (update_atheros_config()); 
     1243} 
     1244 
     1245 
     1246/**************************************************************************** 
     1247** update_atheros_config 
     1248** 
     1249** This routine will erase and write the current value of the ath_cfg structure 
     1250** back to the flash sector from whence it came.  This can be called by any 
     1251** routine that needs to write back to flash after updating parameters in 
     1252** the ath_cfg structure. 
     1253** 
     1254** Returns true if the write was successful, and false if not. 
     1255*/ 
     1256 
     1257static bool 
     1258update_atheros_config(void) 
     1259{ 
     1260    int     stat; 
     1261    void    *err_addr; 
     1262    int     err_count = 0; 
     1263     
     1264    /* 
     1265    ** Code Begins 
     1266    */ 
     1267     
     1268    diag_printf("Erasing last sector...\n"); 
     1269     
     1270    stat = flash_erase(ATH_CFG_ADDR, sizeof(struct _atheros_config),(void **)&err_addr); 
     1271     
     1272    if(stat) 
     1273    { 
     1274        diag_printf("Error erasing flash!\n"); 
     1275        return false; 
     1276    } 
     1277 
     1278try_again: 
     1279    diag_printf("Writing to last sector....\n"); 
     1280    stat = FLASH_PROGRAM(ATH_CFG_ADDR, &ath_cfg, sizeof(struct _atheros_config),(void **) &err_addr); 
     1281     
     1282    if (stat) 
     1283    { 
     1284        err_count++; 
     1285        if(err_count < 2) 
     1286            goto try_again; 
     1287         
     1288        diag_printf("Error writing config data at %p: %s\n",err_addr, flash_errmsg(stat)); 
     1289        return false; 
     1290    } 
     1291     
     1292    return true;  
     1293} 
     1294 
     1295#endif 
    9101296 
    9111297// 
  • ar5315_microredboot/microredboot/ecos/packages/redboot/current/src/main.c

    r13090 r13096  
    168168else 
    169169        *(volatile unsigned *)AR2316_GPIO_DO &= ~(1<<gpio);     /*set GPIO0 to 1 to spi flash CS normal state */ 
     170#elif defined(CYGPKG_HAL_MIPS_AR7100) 
     171//      *(volatile unsigned *)(AR7100_GPIO_OE) |= 1<<gpio;      /*set GPIO0 to be output */ 
     172//if (state) 
     173//      *(volatile unsigned *)(AR7100_GPIO_OUT) |= 1<<gpio;     /*set GPIO0 to 1 to spi flash CS normal state */ 
     174//else 
     175//      *(volatile unsigned *)(AR7100_GPIO_OUT )&= ~(1<<gpio);  /*set GPIO0 to 1 to spi flash CS normal state */ 
     176 
     177 
    170178#else 
    171179        *(volatile unsigned *)AR531X_GPIO_CR &= ~(1<<gpio);     /*set GPIO0 to be output */ 
     
    188196        b = ((*(volatile unsigned int *)(AR2316_GPIO_DI)) >>  
    189197                                        resetgpio) & 1; 
     198#elif defined(CYGPKG_HAL_MIPS_AR7100)  
     199        b = ((*(volatile unsigned int *)(AR7100_GPIO_IN)) >>  
     200                                        resetgpio) & 1; 
     201 
    190202#else 
    191203        b = ((*(volatile unsigned int *)(AR531X_GPIO_DI)) >>  
  • ar5315_microredboot/microredboot/makefile

    r13090 r13096  
    124124 
    125125 
     126 
     127pb42:   BOARD_TYPE=pb42 
     128pb42: 
     129        echo "#define RAM_SIZE 0x2000000" > boot/src/ramconfig.h 
     130        echo "#define AR5312 1" >> boot/src/ramconfig.h 
     131# RAM version 
     132        $(PLATFORM_RAM_START) \ 
     133        ecosconfig import $(ECOS_REPOSITORY)/hal/mips/pb42/current/misc/redboot_RAM.ecm; \ 
     134        ecosconfig import $(REDBOOT_DIR)/options/eth_ar7100/adm_phy; \ 
     135        $(PLATFORM_BLD_CUST) 
     136        $(PLATFORM_RAM_BUILD) 
     137        cp redboot/pb42/ram/install/bin/redboot.rom images/redboot_pb42_32M_8M_kendin.rom 
     138        cp redboot/pb42/ram/install/bin/redboot.img images/redboot_pb42_32M_8M_kendin.elf 
     139 
    126140# 
    127141# The rules