/*********************************************************************
© Copyright International Business Machines Corporation, Sony Computer Entertainment
Incorporated, Toshiba Corporation 2005
All Rights Reserved
FILENAME : spi_lib.h
DESCRIPTION : Support library for SPI/MMIO register accesses
*********************************************************************/
#ifndef _SPI_LIB_H
#define _SPI_LIB_H
#include "types.h"
typedef unsigned int uint32;
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned short uint16;
typedef unsigned char uint8;
typedef int int32;
typedef short int16;
#define uint64 struct UINT64
/***************************************************/
/* SPI Commands and Addresses */
/* Ref: Pervasive-functional, ver 0.91, Table 5-13 */
/* - extended to add
R clock generator and VRM */
/***************************************************/
#define CHIP_ID0 0x00
#define CHIP_ID1 0x04
#define CHIP_ID2 0x08
#define CHIP_ID3 0x0C
#define CHIP_BE 0x10
#define CHIP_BE0 CHIP_BE | CHIP_ID0
#define CHIP_BE1 CHIP_BE | CHIP_ID1
#define SPI_READ 0x00
#define SPI_WRITE 0x01
#define BE_PERVASIVE 0x0000
#define BE_MIC 0xA000
#define BEI_BIC0_NCLK 0xD000
#define BEI_BIC1_NCLK 0xD400
#define BEI_EIB 0xD800
#define BEI_IOC 0xDC00
#define BEI_BIC0 0xE000
#define BEI_BIC1 0xF000
/**************************************************/
/* CBE Pervasive Registers */
/* */
/**************************************************/
#define BE_ICB_POLL 0x0002
#define BE_RD_ICB_DATA 0x0010
/********************/
/* CBE bus interface controller (BIC) Registers */
/********************/
#define BED_RRAC_REGCTL 0x620
#define BED_RRAC_REGRDDAT 0x628
#define BIC_IF0INIT 0xe200
#define BIC_IF1INIT 0xe300
/************************/
/* FlexIO Bus Registers */
/************************/
#define BED_Lnk0_TransBytTrngCntl 0xf600
#define BED_Lnk1_TransBytTrngCntl 0xf608
#define BED_RecBytTrngCntl_Lnk0 0xf610
#define BED_RecBytTrngCntl_Lnk0 0xf618
/**********************************/
/* Rambus FlexIO (RRAC) Registers */
/**********************************/
#define RR_BLK0 0x000
#define RR_BLK1 0x100
#define RR_BLK2 0x200
#define RR_BLK3 0x300
#define RR_BLK4 0x400
#define RR_BLK5 0x500
#define RR_BLK6 0x600
#define RR_BLK7 0x700
#define RR_BLK8 0x800
#define RR_BLK9 0x900
#define RR_BLK10 0xA00
#define RR_BLK11 0xB00
#define RR_BLK12 0xC00
#define RR_BLK13 0xD00
#define RR_ALL_RX 0xE00
#define RR_ALL_TX 0xF00
#define RR_TX0 0x000
#define RR_TX1 0x100
#define RR_TX2 0x200
#define RR_TX3 0x300
#define RR_BX0 0x700
#define RR_BX1 0x800
#define RR_RX0 0x900
#define RR_RX1 0xA00
#define RR_RX2 0xB00
#define RR_RX3 0xC00
#define RR_PIN0 0x00
#define RR_PIN1 0x10
#define RR_PIN2 0x20
#define RR_PIN3 0x30
#define RR_PIN4 0x40
#define RR_PIN5 0x50
#define RR_PIN6 0x60
#define RR_PIN7 0x70
#define RR_GLOBAL 0x80
#define RR_PIN_ALL 0xE0
#define RR_G2_0_3 0x90
#define RR_G2_4_7 0xA0
#define RR_G2_0_7 0xB0
#define RR_RSRV 0xF0
/* Transmit (TX) */
#define TX_PRBS_CTL 0x0
#define TX_CAL_CONFIG 0x1
#define TX_EQ1 0x2
#define TX_EQ2 0x3
#define TX_EQ3 0x4
/* TX GLOBAL */
#define TX_PLL_CONFIGA 0x80
#define TX_PLL_CONFIGB 0x81
#define TX_PLL_STATUS 0x82
#define TX_ODT_MAN 0x83
#define TX_ODT_STATUS 0x84
#define TX_CONFIG 0x85
#define TX_FLNGTH 0x86
#define TX_BCTL 0x87
#define TXCLK_EQ1 0x88
#define TXCLK_EQ2 0x89
#define TXCLK_EQ3 0x8A
#define TX_CTL 0x8C
/* Receive (RX) */
#define RX_PHASE_ADJ 0x0
#define RX_TCTL 0x1
#define RX_PHASE 0x2
#define RX_ALIGN 0x3
/* RX GLOBAL */
#define RX_PLL_CONFIGA 0x80
#define RX_PLL_CONFIGB 0x81
#define RX_PLL_STATUS 0x82
#define RX_ODT_MAN 0x83
#define RX_ODT_STATUS 0x84
#define RX_CONFIG 0x85
#define RX_BCTL 0x86
#define RX_ZPD_CONFIG 0x87
#define RX_CTL 0x8C
#define RX_STATUS 0x8E
/* RX GLOBAL (G2) */
#define RX_TCAL_RANGE 0x0
#define RX_TCAL_CONTROL 0x1
#define RX_TCAL_STATUS 0x2
#define RX_TCAL_PF 0x3
#define RX_OS_COUNT 0x4
#define RX_FLNGTH 0x6
/* BX */
#define RRAC_ID 0x0
#define BX_MAN 0x1
#define BX_STATE 0x2
#define BX_CONFIG 0x5
#define BX_CTL 0xC
#define BX_STATUS 0xE
/* DEBUG */
#define TX_DBG_00 0xF0
#define TX_DBG_01 0xF1
#define TX_DBG_02 0xF2
#define TX_DBG_03 0xF3
#define RX_DBG_00 0xF0
#define RX_DBG_01 0xF1
#define RX_DBG_02 0xF2
#define RX_DBG_03 0xF3
#define RX_DBG_09 0xF4
int delay_us(int n);
int delay_ms(int n);
int spi_write64(uint8 cmd, uint16 address, uint32 data_hi, uint32 data_lo );
uint8 spi_read8(uint8 cmd, uint16 address);
uint16 spi_read16(uint8 cmd, uint16 address);
uint32 spi_read32(uint8 cmd, uint16 address);
uint64 spi_read64(uint8 cmd, uint16 address);
int spi_poll8(uint8 cmd, uint16 address, uint8 mask, uint8 test);
int spi_poll16(uint8 cmd, uint16 address, uint16 mask, uint16 test);
int spi_poll64(uint8 cmd, uint16 address, uint32 mask_hi, uint32 mask_lo, uint32
test_hi, uint32 test_lo);
int spi_write_rrac(uint8 cmd, uint16 address, uint16 data );
uint16 spi_read_rrac(uint8 cmd, uint16 address);
int spi_poll_rrac(uint8 cmd, uint16 address, uint16 mask, uint16 test);
#endif /* _SPI_LIB_H */
/*********************************************************************
© Copyright International Business Machines Corporation, Sony Computer Entertainment
Incorporated, Toshiba Corporation 2005
All Rights Reserved
FILENAME : be2be.c
DESCRIPTION : Bit Calibration for CBE processor<-->CBE processor interface
**************************************************************************/
#include "spi_lib.h"
int IOIF0_bit_training(void)
{
int rc;
int chip_bex, be_chip;
for (be_chip = 0; be_chip < 2; be_chip++) {
chip_bex = (CHIP_BE | (be_chip << 2)) << 16;
/* Set VDD core = 1.15V (CBE Only) */
spi_write_rrac( chip_bex, RR_ALL_TX | RR_RSRV | TX_DBG_01, 0x001e);
spi_write_rrac( chip_bex, RR_ALL_RX | RR_RSRV | RX_DBG_01, 0x001e);
/* Pseudorandom binary sequence (PRBS) seed value for each pin 0 on TX 0-3
channel in CBE */
spi_write_rrac(chip_bex, RR_ALL_TX | RR_PIN0 | TX_PRBS_CTL, 0xaaa0);
spi_write_rrac(chip_bex, RR_ALL_TX | RR_PIN1 | TX_PRBS_CTL, 0x1110);
spi_write_rrac(chip_bex, RR_ALL_TX | RR_PIN2 | TX_PRBS_CTL, 0x2220);
spi_write_rrac(chip_bex, RR_ALL_TX | RR_PIN3 | TX_PRBS_CTL, 0x3330);
spi_write_rrac(chip_bex, RR_ALL_TX | RR_PIN4 | TX_PRBS_CTL, 0x4440);
spi_write_rrac(chip_bex, RR_ALL_TX | RR_PIN5 | TX_PRBS_CTL, 0x5550);
spi_write_rrac(chip_bex, RR_ALL_TX | RR_PIN6 | TX_PRBS_CTL, 0x6660);
spi_write_rrac(chip_bex, RR_ALL_TX | RR_PIN7 | TX_PRBS_CTL, 0x7770);
/* TX Equalization Adjustment 1, 2 and 3 */
spi_write_rrac(chip_bex, RR_ALL_TX | RR_PIN_ALL | TX_EQ1, 0x7f87);
spi_write_rrac(chip_bex, RR_ALL_TX | RR_PIN_ALL | TX_EQ2, 0x3ae3);
spi_write_rrac(chip_bex, RR_ALL_TX | RR_PIN_ALL | TX_EQ3, 0x01fe);
/* Bits (1:0) = 00 = 2:1 Serialization */
spi_write_rrac(chip_bex, RR_GLOBAL | RR_ALL_TX | TX_CONFIG, 0x0000);
/* Frame Pattern Length */
spi_write_rrac(chip_bex, RR_GLOBAL | RR_ALL_TX | TX_FLNGTH, 0x0040);
/* TX Bias Control (15:8) TX PreDriver Bias, (7:0) TX Driver Bias Control */
spi_write_rrac(chip_bex, RR_GLOBAL | RR_ALL_TX | TX_BCTL, 0x0808);
/* TX Clk Equalization Adjustment 1 */
spi_write_rrac(chip_bex, RR_GLOBAL | RR_ALL_TX | TXCLK_EQ1, 0x001C);
/* TX Ctl Reg - Driver enable, ODT Enable, Pattern transmit,
Input - Output (IO) On */
spi_write_rrac(chip_bex, RR_GLOBAL | RR_TX0 | TX_CTL, 0x0039);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_TX1 | TX_CTL, 0x0039);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_TX2 | TX_CTL, 0x0039);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_TX3 | TX_CTL, 0x0039);
/* TX Pll Configuration A at default */
spi_write_rrac(chip_bex, RR_GLOBAL | RR_ALL_TX | TX_PLL_CONFIGA, 0x0000);
/* TX Pll Configuration B at default 0x0000 is full rate mode */
spi_write_rrac(chip_bex, RR_GLOBAL | RR_ALL_TX | TX_PLL_CONFIGB, 0x0040);
/* RX Pll Configuration B at default 0x0040 is for Full Rate Mode */
spi_write_rrac(chip_bex, RR_GLOBAL | RR_ALL_RX | RX_PLL_CONFIGB, 0x0000);
/* RX Configuration at default - 2:1 Serialization Mode */
spi_write_rrac(chip_bex, RR_GLOBAL | RR_ALL_RX | RX_CONFIG, 0x0000);
/* RX Receiver Gain Control */
spi_write_rrac(chip_bex, RR_GLOBAL | RR_ALL_RX | RX_BCTL, 0x00B4);
/* RX Ctl Reg - ODT enable, wait after phase cal, IO on */
spi_write_rrac(chip_bex, RR_GLOBAL | RR_RX0 | RX_CTL, 0x0029);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_RX1 | RX_CTL, 0x0029);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_RX2 | RX_CTL, 0x0029);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_RX3 | RX_CTL, 0x0029);
/* RX Tcal Ctl - Single Step Enable, Single Step, byte count enable, 7 bit PRBS
select, Level calibration enabled, parallel calibration enabled, phase
calibration enabled, all RX channels enabled */
spi_write_rrac(chip_bex, RR_ALL_RX | RR_G2_0_7 | RX_TCAL_CONTROL, 0x00FE);
/* 128 parallel calibration compares, pass/fail of 40% UI */
spi_write_rrac(chip_bex, RR_ALL_RX | RR_G2_0_7 | RX_TCAL_PF, 0x8033);
/* 256 samples at each phase offset */
spi_write_rrac(chip_bex, RR_ALL_RX | RR_G2_0_7 | RX_OS_COUNT, 0x0100);
/* Frame Pattern Length */
spi_write_rrac(chip_bex, RR_ALL_RX | RR_G2_0_7 | RX_FLNGTH, 0x0040);
}
for (be_chip = 0; be_chip < 2; be_chip++) {
chip_bex = (CHIP_BE | (be_chip << 2)) << 16;
/* ODT and Current Calibration */
spi_write_rrac(chip_bex, RR_BX0 | BX_CTL, 0x0005);
spi_write_rrac(chip_bex, RR_BX1 | BX_CTL, 0x0005);
/* Check for BX Block Ready */
spi_poll_rrac(chip_bex, RR_BX0 | BX_STATUS, 0x0800, 0x0800);
spi_poll_rrac(chip_bex, RR_BX1 | BX_STATUS, 0x0800, 0x0800);
/* Deassert reset and BX current and ODT enable */
spi_write_rrac(chip_bex, RR_BX0 | BX_CTL, 0x0003);
spi_write_rrac(chip_bex, RR_BX1 | BX_CTL, 0x0003);
/* Check RX calibration for complete and pass */
spi_poll_rrac(chip_bex, RR_BX0 | BX_STATUS, 0x0003, 0x0003);
spi_poll_rrac(chip_bex, RR_BX1 | BX_STATUS, 0x0003, 0x0003);
/* Driver enable */
spi_write_rrac(chip_bex, RR_GLOBAL | RR_TX0 | TX_CTL, 0x003b);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_TX1 | TX_CTL, 0x003b);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_TX2 | TX_CTL, 0x003b);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_TX3 | TX_CTL, 0x003b);
/* Check for PLL Lock */
spi_poll_rrac(chip_bex, RR_GLOBAL | RR_TX0 | TX_PLL_STATUS, 0x0001, 0x0001);
spi_poll_rrac(chip_bex, RR_GLOBAL | RR_TX1 | TX_PLL_STATUS, 0x0001, 0x0001);
spi_poll_rrac(chip_bex, RR_GLOBAL | RR_TX2 | TX_PLL_STATUS, 0x0001, 0x0001);
spi_poll_rrac(chip_bex, RR_GLOBAL | RR_TX3 | TX_PLL_STATUS, 0x0001, 0x0001);
/* Receiver enable */
spi_write_rrac(chip_bex, RR_GLOBAL | RR_RX0 | RX_CTL, 0x002b);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_RX1 | RX_CTL, 0x002b);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_RX2 | RX_CTL, 0x002b);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_RX3 | RX_CTL, 0x002b);
/* Check for PLL Lock */
spi_poll_rrac(chip_bex, RR_GLOBAL | RR_RX0 | RX_PLL_STATUS, 0x0001, 0x0001);
spi_poll_rrac(chip_bex, RR_GLOBAL | RR_RX1 | RX_PLL_STATUS, 0x0001, 0x0001);
spi_poll_rrac(chip_bex, RR_GLOBAL | RR_RX2 | RX_PLL_STATUS, 0x0001, 0x0001);
spi_poll_rrac(chip_bex, RR_GLOBAL | RR_RX3 | RX_PLL_STATUS, 0x0001, 0x0001);
}
for (be_chip = 0; be_chip < 2; be_chip++) {
chip_bex = (CHIP_BE | (be_chip << 2)) << 16;
/* TX Digital Reset */
spi_write_rrac(chip_bex, RR_GLOBAL | RR_TX0 | TX_CONFIG, 0x0020);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_TX0 | TX_CONFIG, 0x0000);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_TX1 | TX_CONFIG, 0x0020);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_TX1 | TX_CONFIG, 0x0000);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_TX2 | TX_CONFIG, 0x0020);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_TX2 | TX_CONFIG, 0x0000);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_TX3 | TX_CONFIG, 0x0020);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_TX3 | TX_CONFIG, 0x0000);
/* RX Digital Reset */
spi_write_rrac(chip_bex, RR_GLOBAL | RR_RX0 | RX_CONFIG, 0x0020);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_RX0 | RX_CONFIG, 0x0000);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_RX1 | RX_CONFIG, 0x0020);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_RX1 | RX_CONFIG, 0x0000);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_RX2 | RX_CONFIG, 0x0020);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_RX2 | RX_CONFIG, 0x0000);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_RX3 | RX_CONFIG, 0x0020);
spi_write_rrac(chip_bex, RR_GLOBAL | RR_RX3 | RX_CONFIG, 0x0000);
}
/* RX Ctl Reg – ODT enable, wait after phase cal, RX Block Enable, IO on */
spi_write_rrac(CHIP_BE0, RR_GLOBAL | RR_RX0 | RX_CTL, 0x002f);
spi_write_rrac(CHIP_BE0, RR_GLOBAL | RR_RX1 | RX_CTL, 0x002f);
spi_write_rrac(CHIP_BE0, RR_GLOBAL | RR_RX2 | RX_CTL, 0x002f);
spi_write_rrac(CHIP_BE0, RR_GLOBAL | RR_RX3 | RX_CTL, 0x002f);
spi_write_rrac(CHIP_BE1, RR_GLOBAL | RR_RX0 | RX_CTL, 0x002f);
spi_write_rrac(CHIP_BE1, RR_GLOBAL | RR_ RX1 | RX_CTL, 0x002f);
spi_write_rrac(CHIP_BE1, RR_GLOBAL | RR_ RX2 | RX_CTL, 0x002f);
spi_write_rrac(CHIP_BE1, RR_GLOBAL | RR_ RX3 | RX_CTL, 0x002f);
/* Check for phase calibration completion. Phase calibration passed. */
spi_poll_rrac(CHIP_BE0, RR_GLOBAL | RR_RX0 | RX_STATUS, 0x0003, 0x0003);
spi_poll_rrac(CHIP_BE0, RR_GLOBAL | RR_RX1 | RX_STATUS, 0x0003, 0x0003);
spi_poll_rrac(CHIP_BE0, RR_GLOBAL | RR_RX2 | RX_STATUS, 0x0003, 0x0003);
spi_poll_rrac(CHIP_BE0, RR_GLOBAL | RR_RX3 | RX_STATUS, 0x0003, 0x0003);
spi_poll_rrac(CHIP_BE1, RR_GLOBAL | RR_RX0 | RX_STATUS, 0x0003, 0x0003);
spi_poll_rrac(CHIP_BE1, RR_GLOBAL | RR_RX1 | RX_STATUS, 0x0003, 0x0003);
spi_poll_rrac(CHIP_BE1, RR_GLOBAL | RR_RX2 | RX_STATUS, 0x0003, 0x0003);
spi_poll_rrac(CHIP_BE1, RR_GLOBAL | RR_RX3 | RX_STATUS, 0x0003, 0x0003);
for (be_chip = 0; be_chip < 2; be_chip++) {
chip_bex = (CHIP_BE | (be_chip << 2)) << 16;
/* Manual Skip Select On */
spi_write_rrac(chip_bex, RR_RX0 | RR_PIN_ALL | RX_TCTL, 0x0002);
/* Manual Skip Select Off */
spi_write_rrac(chip_bex, RR_RX0 | RR_PIN_ALL | RX_TCTL, 0x0000);
/* Manual Skip Select On */
spi_write_rrac(chip_bex, RR_RX1 | RR_PIN_ALL | RX_TCTL, 0x0002);
/* Manual Skip Select Off */
spi_write_rrac(chip_bex, RR_RX1 | RR_PIN_ALL | RX_TCTL, 0x0000);
/* Manual Skip Select On */
spi_write_rrac(chip_bex, RR_RX2 | RR_PIN_ALL | RX_TCTL, 0x0002);
/* Manual Skip Select Off */
spi_write_rrac(chip_bex, RR_RX2 | RR_PIN_ALL | RX_TCTL, 0x0000);
/* Manual Skip Select On */
spi_write_rrac(chip_bex, RR_RX3 | RR_PIN_ALL | RX_TCTL, 0x0002);
/* Manual Skip Select Off */
spi_write_rrac(chip_bex, RR_RX3 | RR_PIN_ALL | RX_TCTL, 0x0000);
}
/* Driver enable, ODT Enable, Calibration Framing Pattern transmit, enable
TX BClk, IO On */
spi_write_rrac(CHIP_BE0, RR_GLOBAL | RR_TX0 | TX_CTL, 0x003f);
spi_write_rrac(CHIP_BE0, RR_GLOBAL | RR_TX1 | TX_CTL, 0x003f);
spi_write_rrac(CHIP_BE0, RR_GLOBAL | RR_TX2 | TX_CTL, 0x003f);
spi_write_rrac(CHIP_BE0, RR_GLOBAL | RR_TX3 | TX_CTL, 0x003f);
spi_write_rrac(CHIP_BE1, RR_GLOBAL | RR_TX0 | TX_CTL, 0x003f);
spi_write_rrac(CHIP_BE1, RR_GLOBAL | RR_TX1 | TX_CTL, 0x003f);
spi_write_rrac(CHIP_BE1, RR_GLOBAL | RR_TX2 | TX_CTL, 0x003f);
spi_write_rrac(CHIP_BE1, RR_GLOBAL | RR_TX3 | TX_CTL, 0x003f);
/* ODT enable, proceed with parallel cal, RX Block Enable, IO on */
spi_write_rrac(CHIP_BE0, RR_GLOBAL | RR_RX0 | RX_CTL, 0x0027);
spi_write_rrac(CHIP_BE0, RR_GLOBAL | RR_RX1 | RX_CTL, 0x0027);
spi_write_rrac(CHIP_BE0, RR_GLOBAL | RR_RX2 | RX_CTL, 0x0027);
spi_write_rrac(CHIP_BE0, RR_GLOBAL | RR_RX3 | RX_CTL, 0x0027);
spi_write_rrac(CHIP_BE1, RR_GLOBAL | RR_RX0 | RX_CTL, 0x0027);
spi_write_rrac(CHIP_BE1, RR_GLOBAL | RR_RX1 | RX_CTL, 0x0027);
spi_write_rrac(CHIP_BE1, RR_GLOBAL | RR_RX2 | RX_CTL, 0x0027);
spi_write_rrac(CHIP_BE1, RR_GLOBAL | RR_RX3 | RX_CTL, 0x0027);
/* check parallel calibration and slice levelization is complete and passed */
spi_poll_rrac(CHIP_BE0, RR_GLOBAL | RR_RX0 | RX_STATUS, 0x003f, 0x003f);
spi_poll_rrac(CHIP_BE0, RR_GLOBAL | RR_RX1 | RX_STATUS, 0x003f, 0x003f);
spi_poll_rrac(CHIP_BE0, RR_GLOBAL | RR_RX2 | RX_STATUS, 0x003f, 0x003f);
spi_poll_rrac(CHIP_BE0, RR_GLOBAL | RR_RX3 | RX_STATUS, 0x003f, 0x003f);
spi_poll_rrac(CHIP_BE1, RR_GLOBAL | RR_RX0 | RX_STATUS, 0x003f, 0x003f);
spi_poll_rrac(CHIP_BE1, RR_GLOBAL | RR_RX1 | RX_STATUS, 0x003f, 0x003f);
spi_poll_rrac(CHIP_BE1, RR_GLOBAL | RR_RX2 | RX_STATUS, 0x003f, 0x003f);
spi_poll_rrac(CHIP_BE1, RR_GLOBAL | RR_RX3 | RX_STATUS, 0x003f, 0x003f);
/* Driver enable, ODT Enable, enable core data, enable TX BClk, IO On */
spi_write_rrac(CHIP_BE0, RR_GLOBAL | RR_TX0 | TX_CTL, 0x0037);
spi_write_rrac(CHIP_BE0, RR_GLOBAL | RR_TX1 | TX_CTL, 0x0037);
spi_write_rrac(CHIP_BE0, RR_GLOBAL | RR_TX2 | TX_CTL, 0x0037);
spi_write_rrac(CHIP_BE0, RR_GLOBAL | RR_TX3 | TX_CTL, 0x0037);
spi_write_rrac(CHIP_BE1, RR_GLOBAL | RR_TX0 | TX_CTL, 0x0037);
spi_write_rrac(CHIP_BE1, RR_GLOBAL | RR_TX1 | TX_CTL, 0x0037);
spi_write_rrac(CHIP_BE1, RR_GLOBAL | RR_TX2 | TX_CTL, 0x0037);
spi_write_rrac(CHIP_BE1, RR_GLOBAL | RR_TX3 | TX_CTL, 0x0037);
}
/*********************************************************************
© Copyright International Business Machines Corporation, Sony Computer Entertainment
Incorporated, Toshiba Corporation 2005
All Rights Reserved
FILENAME : rrac_be_byte_training.c
DESCRIPTION : Byte Calibration for CBE processor<-->CBE processor interface
***************************************************************************/
#include "spi_lib.h"
int IOIF0_byte_training(void)
{
int rc=0;
/* Enable CBE RX byte training */
spi_write64(CHIP_BE0, BED_RecBytTrngCntl_Lnk0, 0x86000000, 0x00000000);
spi_write64(CHIP_BE1, BED_RecBytTrngCntl_Lnk0, 0x86000000, 0x00000000);
/* Transmit latency set to 2. Enable CBE TX byte training */
spi_write64(CHIP_BE0, BED_Lnk0_TransBytTrngCntl, 0xc2000000, 0x00000000);
spi_write64(CHIP_BE1, BED_Lnk0_TransBytTrngCntl, 0xc2000000, 0x00000000);
rc = spi_poll64(CHIP_BE0, BED_RecBytTrngCntl_Lnk0, 0xff000000, 0x00000000,
0xe6000000, 0x00000000);
rc += spi_poll64(CHIP_BE1, BED_RecBytTrngCntl_Lnk0, 0xff000000, 0x00000000,
0xe6000000, 0x00000000);
/* turn off Byte Training Pattern XMIT_EN */
spi_write64(CHIP_BE0, BED_Lnk0_TransBytTrngCntl, 0x82000000, 0x00000000);
spi_write64(CHIP_BE1, BED_Lnk0_TransBytTrngCntl, 0x82000000, 0x00000000);
/* turn off Byte Training Pattern RCV_EN */
spi_write64(CHIP_BE0, BED_RecBytTrngCntl_Lnk0, 0x66000000, 0x00000000);
spi_write64(CHIP_BE1, BED_RecBytTrngCntl_Lnk0, 0x66000000, 0x00000000);
/* Enable Reception/Transmission Layer */
/* These next few command will start the CBE code execution */
/* Enable Link Layer */
spi_write64(CHIP_BE0, BIC_IF0INIT, 0x80000000, 0x00000000);
spi_write64(CHIP_BE1, BIC_IF0INIT, 0x80000000, 0x00000000);
/* enable Transport_Layer_Transmission_Enable */
spi_write64(CHIP_BE0, BIC_IF0INIT, 0xc0000000, 0x00000000);
spi_write64(CHIP_BE1, BIC_IF0INIT, 0xc0000000, 0x00000000);
return rc;
}
y me canso de pastear codigo
porque de todos modos, aparte de que no tenemos acceso al interior del procedure, y como mucho podrias intentar hacer un BOF en alguna de ellas, no serviria de nada, ya que no tenemos la key para firmar y que sea valido de nuevo el codigo, asi que.....