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

utils_dune_fpga_download.h (4625B)


      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 #ifndef UTILS_DUNE_FPGA_DOWNLOAD_H
      7 #define UTILS_DUNE_FPGA_DOWNLOAD_H
      8 
      9 
     10 typedef enum
     11 {
     12   UTILS_DUNE_FPGA_DOWNLOAD_V_1=1,
     13   UTILS_DUNE_FPGA_DOWNLOAD_V_2=2
     14 } UTILS_DUNE_FPGA_DOWNLOAD_TYPE_ENUM;
     15 /*****************************************************************************/
     16 /*  FUNCTION NAME:  utils_dune_AlteraDownload
     17 **  FUNCTION DESCRIPTION:
     18 **  FORMAL PARAMENETS:
     19 **   unsigned char *base_addr  - Beginning address of memory stream to download.
     20 **                               if NULL, then the default ROM file is taken.
     21 **   unsigned long  size       - Size in bytes of that stream. can be '0', in
     22 **                               base_addr is NULL
     23 **  RETURN VALUE:
     24 **    an unsigned integer typed returned:
     25 **     -0  - download OK.
     26 **     -10 - Device was not ready to download (Jumper is probably plugged)
     27 **     -20 - Device had a problem while downloading.
     28 **     -30 - Device had a problem after downloading.
     29 **
     30 **  DESIGN ISSUES:
     31 **    The FPGA by ALTERA needs to be downloaded with a configuration stream
     32 **    after each power-up (Power-Up, NOT Reset!).
     33 **    (The configuration stream is held here above).
     34 **    1). Download emulation facility:
     35 **        The CPU is equipped with 2 I/O port we use to
     36 **        emulate the download sequence to the ALTERA.
     37 **        There are 3 output bits supplied by the Manager towards the
     38 **        FPGA on port B. The FPGA provides 2 status bits that can be read
     39 **        by the Manager in order to monitor the sequence flow on port C.
     40 **    2). Download emulation flow:
     41 **        We use the "passive serial mode" to download the FPGAs. The flow
     42 **        looks as follows:
     43 **        NConfig  _     _____________________________________\\________________
     44 **                |___|                                      \\
     45 **        NStatus  __      _____________________________________||______________
     46 **                   |____|                                     ||
     47 **        ConfDone __                                           ||            ___
     48 **                   |__________________________________________||___________|
     49 **                                __    __    __    __    __    ||_    __    __
     50 **        Dclk     _|||__________|  |__|  |__|  |__|  |__|  |__|||.|__|  |__|  |__
     51 **                              ____  ____  ____  ____  ____  __||__  ____
     52 **        Dout     ------------<_D0_><_D1_><_D2_><_D3_><_D4_><___\\_><_Dn_>-------
     53 **                                                                \\
     54 **        The flow is devided into three stages:
     55 **        -. INIT:
     56 **                Write 'NConfig' = 0;
     57 **                Wait 100mSec
     58 **                Write 'NConfig' = 1;
     59 **
     60 **        -. PROGRAM:
     61 **             -> Write 'Dout'.
     62 **            |   Wait >30nSec
     63 **            |   Write 'Dclk' = 1
     64 **            |   Wait >50nSec
     65 **            |   Write 'Dclk' = 0
     66 **            |   Wait >50nSec
     67 **            |   Read 'NStatus' : if '0' - Device had error.
     68 **            |_________|
     69 **
     70 **        -. MONITOR SUCCESS:
     71 **                Write 'Dclk' = 1
     72 **                Wait >100nSec
     73 **                Read ConfDone : If '0' - Device didn't configured well.
     74 **                run 10 'Dclk' ticks.
     75 **
     76 **        For more details look at application note #59 from altera:
     77 **        "Configuring Flex 10K devices" - Passive serial mode.
     78 **        Notice I added a bunch of clocks around the NConfig falling edge. This
     79 **        was done to fully emulate the behavior of the 'Byte-Blaster' cable.
     80  */
     81 unsigned int
     82  utils_dune_AlteraDownload (
     83    const unsigned char                *base_addr,
     84    const char                         *image_name,
     85    unsigned long                      size,
     86    UTILS_DUNE_FPGA_DOWNLOAD_TYPE_ENUM board_version,
     87    unsigned int                       silent
     88  );
     89 /*
     90  */
     91 /*****************************************************
     92 *NAME: utils_dune_download_and_load_fpga_rbf_file
     93 *TYPE: PROC
     94 *DATE: 03/AUG/2003
     95 *FUNCTION: Loads the rbf file from tftp to the
     96 *          altera FPGA (using the above util)
     97 *CALLING SEQUENCE:
     98 *  utils_dune_download_and_load_fpga_rbf_file()
     99 *INPUT:
    100 *  SOC_SAND_DIRECT:
    101 *  SOC_SAND_INDIRECT: rbf file name is 'fpga_linecard'.
    102 *OUTPUT:
    103 *  SOC_SAND_DIRECT: non-zero in case of an error
    104 *  SOC_SAND_INDIRECT: FPGA is downloaded
    105 *REMARKS:
    106 *SEE ALSO: utils_dune_AlteraDownload
    107  */
    108 unsigned int
    109   utils_dune_download_and_load_fpga_rbf_file(
    110     UTILS_DUNE_FPGA_DOWNLOAD_TYPE_ENUM  board_ver_id
    111   );
    112 #endif