From 99f068dfe8a9927a3d48a34fa02e3ef8acdca4b3 Mon Sep 17 00:00:00 2001 From: Ilya Smirnov Date: Tue, 13 Jun 2017 14:23:29 -0500 Subject: SBE FIFO: Change set #1 Ported the needed structs and the first set of SBE FIFO functions: getFifoScom, putFifoScom, and the shell for performFifoChipOp. Change-Id: Ief8876266950f166d867dbab8c8fcc8b94398860 RTC:175100 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/41932 Tested-by: FSP CI Jenkins Reviewed-by: Prachi Gupta Reviewed-by: Zane C. Shelley Reviewed-by: William A. Bryan Reviewed-by: Martha Broyles --- src/occ_405/firdata/sbe_fifo.c | 114 +++++++++++++++++++++++++++++++++++++++++ src/occ_405/firdata/sbe_fifo.h | 106 ++++++++++++++++++++++++++++++++++++++ src/occ_405/occLinkInputFile | 3 +- src/occ_405/topfiles.mk | 1 + 4 files changed, 223 insertions(+), 1 deletion(-) create mode 100644 src/occ_405/firdata/sbe_fifo.c create mode 100644 src/occ_405/firdata/sbe_fifo.h (limited to 'src') diff --git a/src/occ_405/firdata/sbe_fifo.c b/src/occ_405/firdata/sbe_fifo.c new file mode 100644 index 0000000..6f22a00 --- /dev/null +++ b/src/occ_405/firdata/sbe_fifo.c @@ -0,0 +1,114 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/occ_405/firdata/sbe_fifo.c $ */ +/* */ +/* OpenPOWER OnChipController Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2017 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +#include "sbe_fifo.h" +#include + +/** @brief Performs a FIFO operation (read or write) + * @param i_target The SCOM target. + * @param i_fifoRequest the FIFO request data structure + * @param i_fifoResponse the response from SBE + * @param i_responseSize the size of the response + * @return Non-SUCCESS if the operation fails. SUCCESS otherwise. + */ +uint32_t performFifoChipOp(SCOM_Trgt_t* i_target, + uint32_t* i_fifoRequest, + uint32_t* i_fifoResponse, + uint32_t i_responseSize) +{ + uint32_t l_rc = SUCCESS; + + TRAC_INFO("Enter performFifoChipOp"); + + + TRAC_INFO("Exit performFifoChioOp"); + + return l_rc; +} + +/** @brief Performs a write SCOM operation using SBE FIFO + * @param i_target The SCOM target. + * @param i_addr 64-bit SCOM address. + * @param i_data 64-bit data to write. + * @return Non-SUCCESS if the SCOM fails. SUCCESS otherwise. + */ +int32_t putFifoScom(SCOM_Trgt_t* i_target, uint64_t i_addr, uint64_t i_data) +{ + uint32_t l_rc = SUCCESS; + + TRAC_INFO("Enter putFifoScom"); + + struct fifoPutScomRequest l_fifoRequest; + struct fifoPutScomResponse l_fifoResponse; + + l_fifoRequest.wordCnt = PUT_SCOM_REQUEST_WORD_CNT; + l_fifoRequest.reserved = 0; + l_fifoRequest.commandClass = SBE_FIFO_CLASS_SCOM_ACCESS; + l_fifoRequest.command = SBE_FIFO_CMD_PUT_SCOM; + l_fifoRequest.address = i_addr; + l_fifoRequest.data = i_data; + + l_rc = performFifoChipOp(i_target, + (uint32_t*)&l_fifoRequest, + (uint32_t*)&l_fifoResponse, + sizeof(struct fifoPutScomResponse)); + + TRAC_INFO("Exit putFifoScom"); + + return l_rc; +} + +/** @brief Performs a read SCOM operation using SBE FIFO + * @param i_target The SCOM target. + * @param i_addr 64-bit SCOM address. + * @param o_data 64-bit returned value. + * @return Non-SUCCESS if the SCOM fails. SUCCESS otherwise. + */ +int32_t getFifoScom(SCOM_Trgt_t* i_target, uint64_t i_addr, uint64_t* o_data) +{ + uint32_t l_rc = SUCCESS; + + TRAC_INFO("Enter getFifoScom"); + + struct fifoGetScomRequest l_fifoRequest; + struct fifoGetScomResponse l_fifoResponse; + + l_fifoRequest.wordCnt = GET_SCOM_REQUEST_WORD_CNT; + l_fifoRequest.reserved = 0; + l_fifoRequest.commandClass = SBE_FIFO_CLASS_SCOM_ACCESS; + l_fifoRequest.command = SBE_FIFO_CMD_GET_SCOM; + l_fifoRequest.address = i_addr; + + l_rc = performFifoChipOp(i_target, + (uint32_t*)&l_fifoRequest, + (uint32_t*)&l_fifoResponse, + sizeof(struct fifoGetScomResponse)); + + //Always return data even if there is an error + *o_data = l_fifoResponse.data; + + TRAC_INFO("Exit getFifoScom"); + + return l_rc; +} diff --git a/src/occ_405/firdata/sbe_fifo.h b/src/occ_405/firdata/sbe_fifo.h new file mode 100644 index 0000000..4905758 --- /dev/null +++ b/src/occ_405/firdata/sbe_fifo.h @@ -0,0 +1,106 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/occ_405/firdata/sbe_fifo.h $ */ +/* */ +/* OpenPOWER OnChipController Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2017 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +#ifndef __SBE_FIFO_H +#define __SBE_FIFO_H + +#include +#include + +#define PACKED __attribute__((__packed__)) + +#define PUT_SCOM_REQUEST_WORD_CNT 0x06 +#define GET_SCOM_REQUEST_WORD_CNT 0x04 + +#define SBE_FIFO_CMD_GET_SCOM 0x01 +#define SBE_FIFO_CMD_PUT_SCOM 0x02 +#define SBE_FIFO_CLASS_SCOM_ACCESS 0xA2 + +struct statusHeader +{ + uint16_t magic; //set to 0xC0DE + uint8_t commandClass; + uint8_t command; + uint16_t primaryStatus; + uint16_t secondaryStatus; +} PACKED; + +struct ffdc_struct +{ + const void* ptr; + size_t size; +}; + +struct fifoPutScomRequest +{ + uint32_t wordCnt; + uint16_t reserved; + uint8_t commandClass; + uint8_t command; + uint64_t address; + uint64_t data; +} PACKED; + +struct fifoPutScomResponse +{ + struct statusHeader status; + struct ffdc_struct ffdc; //ffdc data + uint32_t status_distance; //distance to status +} PACKED; + +struct fifoGetScomRequest +{ + uint32_t wordCnt; + uint16_t reserved; + uint8_t commandClass; + uint8_t command; + uint64_t address; +} PACKED; + +struct fifoGetScomResponse +{ + uint64_t data; //Data (0..31) + (32..63) + struct statusHeader status; + struct ffdc_struct ffdc; //ffdc data + uint32_t status_distance; // distance to status +} PACKED; + +/** @brief Performs a write SCOM operation using SBE FIFO + * @param i_target The SCOM target. + * @param i_addr 64-bit SCOM address. + * @param i_data 64-bit data to write. + * @return Non-SUCCESS if the SCOM fails. SUCCESS otherwise. + */ +int32_t putFifoScom(SCOM_Trgt_t* i_target, uint64_t i_addr, uint64_t i_data); + +/** @brief Performs a read SCOM operation using SBE FIFO + * @param i_target The SCOM target. + * @param i_addr 64-bit SCOM address. + * @param o_data 64-bit returned value. + * @return Non-SUCCESS if the SCOM fails. SUCCESS otherwise. + */ +int32_t getFifoScom(SCOM_Trgt_t* i_target, uint64_t i_addr, uint64_t* o_data); + +#endif + diff --git a/src/occ_405/occLinkInputFile b/src/occ_405/occLinkInputFile index 82f7b9f..4b446c4 100644 --- a/src/occ_405/occLinkInputFile +++ b/src/occ_405/occLinkInputFile @@ -104,4 +104,5 @@ INPUT ( amec_amester.o native.o scom_trgt.o scom_util.o - scom_addr_util.o) + scom_addr_util.o + sbe_fifo.o) diff --git a/src/occ_405/topfiles.mk b/src/occ_405/topfiles.mk index 18304d6..6b9f1eb 100644 --- a/src/occ_405/topfiles.mk +++ b/src/occ_405/topfiles.mk @@ -70,6 +70,7 @@ TOP-C-SOURCES = amec/amec_analytics.c \ firdata/fsi.c \ firdata/native.c \ firdata/pnor_mboxdd.c \ + firdata/sbe_fifo.c \ firdata/scom_addr_util.c \ firdata/scom_trgt.c \ firdata/scom_util.c \ -- cgit v1.2.1