openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

bsp_drv_flash28f_dev.h (5362B)


      1 /* 
      2  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      3  * 
      4  * Copyright 2007-2020 Broadcom Inc. All rights reserved.
      5 */
      6 
      7 #ifndef __BSP_DRV_FLASH28F_DEV_INCLUDED
      8 #define __BSP_DRV_FLASH28F_DEV_INCLUDED
      9 
     10 #ifdef __cplusplus
     11 extern "C" {
     12 #endif
     13 
     14 
     15 /* defines */
     16 
     17 #define FLASH_28F_WIDTH 4
     18 
     19 #ifndef FLASH_28F128
     20 #define FLASH_28F128      0x18    /* device code 28F128 */
     21 #endif
     22 
     23 #ifndef FLASH_28F640
     24 #define FLASH_28F640      0x17    /* device code 28F640 */
     25 #endif
     26 
     27 #ifndef FLASH_28F320
     28 #define FLASH_28F320      0x16    /* device code 28F320 */
     29 #endif
     30 
     31 #if     (FLASH_28F_WIDTH == 1)
     32 #define FLASH_28F_DEF       unsigned char
     33 #define FLASH_28F_CAST      (unsigned char *)
     34 #endif  /* FLASH_28F_WIDTH */
     35 
     36 #if     (FLASH_28F_WIDTH == 2)
     37 #define FLASH_28F_DEF       unsigned short
     38 #define FLASH_28F_CAST      (unsigned short *)
     39 #endif  /* FLASH_28F_WIDTH */
     40 
     41 #if     (FLASH_28F_WIDTH == 4)
     42 #define FLASH_28F_DEF       unsigned long
     43 #define FLASH_28F_CAST      (unsigned long *)
     44 #endif  /* FLASH_28F_WIDTH */
     45 
     46 
     47 #ifndef SAND_LOW_LEVEL_SIMULATION
     48 
     49 /* function declarations */
     50 
     51 typedef struct
     52 {
     53   /*
     54    * This hold s the structure version.
     55    * Version 1 - BSP_FLASH28F_DEF_INF_V1:
     56    *   Holds: (1) unsigned long f_adrs
     57    *          (2) unsigned char f_adrs_jump
     58    *          (3) unsigned char f_type
     59    *          (4) unsigned long f_sector_size
     60    * Version 2 - BSP_FLASH28F_DEF_INF_V2:
     61    *   TBD in the future.
     62    * NOTE:
     63    * (a) In order to support older application version in newer boot, every
     64    *     structure version can not delete parameters, only to add.
     65    * (b) Newer boot version may use only the structure section indicated by the version number.
     66    */
     67   unsigned char struct_version;
     68 
     69   /* ****            **** */
     70   /* Structure parameters */
     71   /* Version 1 starts  {  */
     72   /* ****            **** */
     73   unsigned long f_adrs;        /*Base address of FLASH*/
     74   unsigned char f_adrs_jump;   /*E.g. FLASH is 16 bits.*/
     75                                /* + If we access it by N, N+2, N+4, than put here ONE.*/
     76                                /* + If we access it by N, N+4, N+8, than put here TWO.*/
     77   unsigned int  flash_width;   /* word size */
     78   unsigned char f_type;        /*FLASH type. Supported: FLASH_28F640, FLASH_28F320*/
     79   unsigned long f_sector_size; /*Sector Byte size*/
     80   /* ****            **** */
     81   /* Version 1 ends    }  */
     82   /* ****            **** */
     83 } BSP_FLASH28F_DEF_INF;
     84 
     85 typedef enum
     86 {
     87   BSP_FLASH28F_DEF_INF_UN_DEF = 0,
     88   BSP_FLASH28F_DEF_INF_V1 = 1,
     89 
     90   /*Last One*/
     91   BSP_FLASH28F_DEF_INF_NOF_VERSIONS
     92 } BSP_FLASH28F_DEF_INF_VERSION;
     93 
     94 IMPORT  UINT8 bspDrvFlash28fTypeGet_28(void) ;
     95 IMPORT  UINT8 bspDrvFlash28fTypeGet_29(void) ;
     96 
     97 IMPORT  STATUS
     98   bspDrvFlash28fGet(
     99     const BSP_FLASH28F_DEF_INF *flash_info,  /*Flash information*/
    100           char          *string,      /* where to copy flash memory      */
    101           int           strLen,       /* maximum number of bytes to copy */
    102           int           offset        /* byte offset into flash memory   */
    103   ) ;
    104 
    105 IMPORT  STATUS  bspDrvFlash28fSet (
    106     char *string, int strLen, int offset,
    107     int (*poll_indication)()    /* Function to call when polling the Flash.*/
    108                                 /* If NULL then call no function.          */
    109 ) ;
    110 IMPORT  unsigned long sysGetFlashBase(void) ;
    111 STATUS
    112   bspDrvFlash28fKick(
    113     const BSP_FLASH28F_DEF_INF *flash_info,  /*Flash information*/
    114           int do_poll_indication,     /* Flag. Non-Zero: print progress indication.*/
    115           int sector                  /* Number of sector to kick (starting from */
    116                                       /* zero. If negative then erase the whole  */
    117                                       /* memory space. If number of sector is    */
    118                                       /* larger than the maximal for that flash  */
    119                                       /* type, last sector is erased.            */
    120   ) ;
    121 STATUS
    122   bspDrvFlash28fErase(
    123     const BSP_FLASH28F_DEF_INF *flash_info,  /*Flash information*/
    124           int do_poll_indication,     /* Flag. Non-Zero print progress indication*/
    125                                       /* in percentage.                          */
    126           int sector                  /* Number of sector to erase (starting from*/
    127                                       /* zero. If negative then erase the whole  */
    128                                       /* memory space. If number of sector is    */
    129                                       /* larger than the maximal for that flash  */
    130                                       /* type, last sector is erased.            */
    131   ) ;
    132 
    133 IMPORT  STATUS
    134   bspDrvFlash28fWrite(
    135     const BSP_FLASH28F_DEF_INF *flash_info,  /*Flash information*/
    136           FLASH_28F_DEF *pFB,       /* string to be copied; use <value> if NULL */
    137           int       size,       /* size to program in bytes */
    138           int       offset,     /* byte offset into flash memory */
    139           FLASH_28F_DEF value,       /* value to program */
    140           int (*poll_indication)(unsigned long current_work_load) /* Function to call when polling the Flash.*/
    141                                       /* If NULL then call no function.          */
    142     ) ;
    143 #endif /*SAND_LOW_LEVEL_SIMULATION*/
    144 
    145 #ifdef __cplusplus
    146 }
    147 #endif
    148 
    149 #endif /* __BSP_DRV_FLASH28F_DEV_INCLUDED */