From 96fe95fe8def7d1c1d6b110588b42167d1238d42 Mon Sep 17 00:00:00 2001 From: Dan Crowell Date: Wed, 15 Oct 2014 23:53:14 -0500 Subject: Enable writes to PNOR on AST systems Unlock SIO after console setup Fix PP write length Change-Id: I3b5b9c589ac16b392a0df6f9d4355f8aa1701061 RTC: 97493 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/14028 Tested-by: Jenkins Server Reviewed-by: Michael Baiocchi Reviewed-by: A. Patrick Williams III --- src/usr/console/ast2400.C | 6 ++++-- src/usr/pnor/norflash.H | 9 +++++++++ src/usr/pnor/pnordd.C | 8 ++++---- src/usr/pnor/pnorrp.C | 7 ------- src/usr/pnor/sfc_ast2400.C | 27 +++++++++++++++++++++++---- 5 files changed, 40 insertions(+), 17 deletions(-) diff --git a/src/usr/console/ast2400.C b/src/usr/console/ast2400.C index 0723c5342..db0bf40ae 100644 --- a/src/usr/console/ast2400.C +++ b/src/usr/console/ast2400.C @@ -102,9 +102,11 @@ class Ast2400Uart : public Uart l_errl = _writeReg( 0x2f, 0x01 ); // write enable if (l_errl) { break; } + //@fixme-RTC:115576 - Leaving SIO unlocked for now to allow + // PNOR write/erase to work // Lock the SIO registers - l_errl = _writeReg( 0x2e, 0xAA ); - if (l_errl) { break; } + //l_errl = _writeReg( 0x2e, 0xAA ); + //if (l_errl) { break; } } while(0); diff --git a/src/usr/pnor/norflash.H b/src/usr/pnor/norflash.H index 4ab2628fe..864d7cb24 100644 --- a/src/usr/pnor/norflash.H +++ b/src/usr/pnor/norflash.H @@ -93,6 +93,15 @@ enum SpiConfigInfo }; +/** + * @brief General Constants related to flash + */ +enum NorConstants +{ + PAGE_PROGRAM_BYTES = 256, //**< 256 bytes per PP command +}; + + /** * Common format of Status Register */ diff --git a/src/usr/pnor/pnordd.C b/src/usr/pnor/pnordd.C index e5b8bd7f3..343968e4e 100644 --- a/src/usr/pnor/pnordd.C +++ b/src/usr/pnor/pnordd.C @@ -492,7 +492,7 @@ errlHndl_t PnorDD::compareAndWriteBlock(uint32_t i_blockStart, if(need_write == false) { //No write actually needed, break out here - TRACFCOMP(g_trac_pnor,"compareAndWriteBlock> NO Write Needed! Exiting Function"); + TRACDCOMP(g_trac_pnor,"compareAndWriteBlock> NO Write Needed! Exiting Function"); break; } @@ -500,7 +500,7 @@ errlHndl_t PnorDD::compareAndWriteBlock(uint32_t i_blockStart, // rest of the Erase block if(need_erase) { - TRACFCOMP(g_trac_pnor,"compareAndWriteBlock> Need to perform Erase"); + TRACDCOMP(g_trac_pnor,"compareAndWriteBlock> Need to perform Erase"); //Get data before write section if(i_writeStart > i_blockStart) { @@ -581,7 +581,7 @@ errlHndl_t PnorDD::compareAndWriteBlock(uint32_t i_blockStart, else // { //STEP 4 ALT: No erase needed, only write the parts that changed. - TRACFCOMP(g_trac_pnor,"compareAndWriteBlock> No erase, just writing"); + TRACDCOMP(g_trac_pnor,"compareAndWriteBlock> No erase, just writing"); for(uint32_t cword = 0; cword < wordsToWrite; cword++) { @@ -619,7 +619,7 @@ errlHndl_t PnorDD::compareAndWriteBlock(uint32_t i_blockStart, errlHndl_t PnorDD::eraseFlash(uint32_t i_address) { errlHndl_t l_err = NULL; - TRACFCOMP(g_trac_pnor, ">>PnorDD::eraseFlash> Block 0x%.8X", i_address ); + TRACDCOMP(g_trac_pnor, ">>PnorDD::eraseFlash> Block 0x%.8X", i_address ); do { if( findEraseBlock(i_address) != i_address ) diff --git a/src/usr/pnor/pnorrp.C b/src/usr/pnor/pnorrp.C index aec79ba59..9060743da 100644 --- a/src/usr/pnor/pnorrp.C +++ b/src/usr/pnor/pnorrp.C @@ -890,13 +890,6 @@ errlHndl_t PnorRP::writeToDevice( uint64_t i_offset, do { -#ifdef CONFIG_SFC_IS_AST2400 - //@todo RTC:106881 -- Add full write/erase support - TRACFCOMP(g_trac_pnor, "PnorRP::writeToDevice> Skipping all writes in BMC for now" ); - break; -#endif - - TARGETING::Target* pnor_target = TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL; // assume a single page to write diff --git a/src/usr/pnor/sfc_ast2400.C b/src/usr/pnor/sfc_ast2400.C index 197cd6b1a..5384e7b62 100644 --- a/src/usr/pnor/sfc_ast2400.C +++ b/src/usr/pnor/sfc_ast2400.C @@ -135,19 +135,38 @@ errlHndl_t SfcAST2400::writeFlash( uint32_t i_addr, { TRACDCOMP( g_trac_pnor, ENTER_MRK"SfcAST2400::writeFlash> i_addr=0x%.8x, i_size=0x%.8x", i_addr, i_size ); errlHndl_t l_err = NULL; + size_t l_bytes_left = i_size; + size_t l_bytes_to_write = 0; + uint32_t l_addr_to_write = i_addr; do { // Enable write mode l_err = enableWriteMode(); if( l_err ) { break; } + // Page Program (PP) command only supports 256 bytes at a time + if( l_bytes_left <= PNOR::PAGE_PROGRAM_BYTES ) + { + l_bytes_to_write = l_bytes_left; + l_bytes_left = 0; + } + else + { + l_bytes_to_write = PNOR::PAGE_PROGRAM_BYTES; + l_bytes_left -= PNOR::PAGE_PROGRAM_BYTES; + } + // Send in the Page Program command with the data to write uint8_t opcode = PNOR::SPI_JEDEC_PAGE_PROGRAM; - l_err = sendSpiCmd( opcode, i_addr, - i_size, reinterpret_cast(i_data), + l_err = sendSpiCmd( opcode, l_addr_to_write, + l_bytes_to_write, + reinterpret_cast(i_data), 0, NULL ); if( l_err ) { break; } + // Move to the next chunk + l_addr_to_write += l_bytes_to_write; + // Wait for idle l_err = pollOpComplete(); if( l_err ) { break; } @@ -161,7 +180,7 @@ errlHndl_t SfcAST2400::writeFlash( uint32_t i_addr, } #endif - } while(0); + } while(l_bytes_left); TRACDCOMP( g_trac_pnor, EXIT_MRK"SfcAST2400::writeFlash> err=%.8X", ERRL_GETEID_SAFE(l_err) ); return l_err; @@ -173,7 +192,7 @@ errlHndl_t SfcAST2400::writeFlash( uint32_t i_addr, */ errlHndl_t SfcAST2400::eraseFlash( uint32_t i_addr ) { - TRACFCOMP(g_trac_pnor, ">>SfcAST2400::eraseFlash> Block 0x%.8X", i_addr ); + TRACDCOMP(g_trac_pnor, ">>SfcAST2400::eraseFlash> Block 0x%.8X", i_addr ); errlHndl_t l_err = NULL; do { -- cgit v1.2.1