summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Geddes <crgeddes@us.ibm.com>2018-10-24 10:47:24 -0500
committerRAJA DAS <rajadas2@in.ibm.com>2019-07-25 03:48:27 -0500
commit5df3896af1ea3e70bbd0f25fce79e1a7f12ff0c4 (patch)
tree0eb9888c8a73c2f0cdd54f0f1910d657286849f3 /src
parent2ce7e14314e8f8377e09b6b8efb6f085a3bd08d2 (diff)
downloadtalos-sbe-5df3896af1ea3e70bbd0f25fce79e1a7f12ff0c4.tar.gz
talos-sbe-5df3896af1ea3e70bbd0f25fce79e1a7f12ff0c4.zip
Add exp_i2c_scom driver that will be consumed by HB/SBE platforms
This commit adds a new exp_i2c_scom.H file which contains two functions, i2c_get_scom and i2c_put_scom. These functions will take in a fapi2 OCMB target, an address and a buffer that either contains scom data to write or space for scom data to be written to. The functions use the fapi2::puti2c / fapi2::geti2c interfaces to perform the scoms. Change-Id: Ifb83b88e71ca9804f378b7b8893683ddcbb5ba06 Original-Change-Id: I4de680e187258cbfc57dd71f698dc1fc8760cefb RTC:196806 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/67949 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com> Reviewed-by: Louis Stermole <stermole@us.ibm.com> Reviewed-by: STEPHEN GLANCY <sglancy@us.ibm.com> Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com> Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/80969 Reviewed-by: RAJA DAS <rajadas2@in.ibm.com> Tested-by: RAJA DAS <rajadas2@in.ibm.com>
Diffstat (limited to 'src')
-rw-r--r--src/import/chips/ocmb/explorer/procedures/hwp/memory/lib/shared/exp_consts.H44
-rw-r--r--src/import/generic/memory/lib/utils/endian_utils.H149
2 files changed, 193 insertions, 0 deletions
diff --git a/src/import/chips/ocmb/explorer/procedures/hwp/memory/lib/shared/exp_consts.H b/src/import/chips/ocmb/explorer/procedures/hwp/memory/lib/shared/exp_consts.H
index 08d101be..387a21be 100644
--- a/src/import/chips/ocmb/explorer/procedures/hwp/memory/lib/shared/exp_consts.H
+++ b/src/import/chips/ocmb/explorer/procedures/hwp/memory/lib/shared/exp_consts.H
@@ -41,6 +41,8 @@ namespace mss
namespace exp
{
+constexpr uint32_t OCMB_ADDR_SHIFT = 3;
+
///
/// @brief explorer ffdc codes
///
@@ -78,6 +80,10 @@ enum sizes
FW_BOOT_CONFIG_BYTE_LEN = 4,
FW_STATUS_BYTE_LEN = 4,
+ FW_WRITE_REG_DATA_SIZE = 0x08,
+ FW_REG_ADDR_LATCH_SIZE = 0x04,
+ FW_I2C_SCOM_READ_SIZE = 0x05,
+
// Largest R/W length for bytes of data
MIN_DATA_BYTES_LEN = 1,
MAX_DATA_BYTES_LEN = 32,
@@ -122,6 +128,44 @@ enum boot_stages
FW_UPGRADE_MODE = 0x02,
RUNTIME_FW = 0x03,
};
+
+///
+/// @brief Useful constants for i2c scom functionality
+///
+/// @note FIRST_BYTE_MASK = allows us to mask off first by of
+/// an address to check if its an IBM SCOM
+/// LAST_THREE_BYTES_MASK = used as part of formula to translate
+/// a given address to an IBM scom address
+/// OCBM_UNCACHED_OFFSET = Also used as part of formula for translating
+/// a given address to the correct IBM or microchip form
+/// IBM_SCOM_OFFSET_LHS and IBM_SCOM_OFFSET_RHS are used in formula
+/// for calculating IBM scom address for left and right side of addr
+/// IBM_SCOM_INDICATOR is the indicator bit in the first byte of an
+/// address that tells us if it is a IBM scom or not
+///
+enum i2c_scom_consts : uint32_t
+{
+ FIRST_BYTE_MASK = 0xFF000000,
+ LAST_THREE_BYTES_MASK = 0x00FFFFFF,
+ OCMB_UNCACHED_OFFSET = 0xA0000000,
+ IBM_SCOM_OFFSET_LHS = 0x08000000,
+ IBM_SCOM_OFFSET_RHS = 0x08000004,
+ IBM_SCOM_INDICATOR = IBM_SCOM_OFFSET_LHS,
+};
+
+///
+/// @brief Simple enum allows code to pick between left and right
+///
+/// This is used when deciding if we are writing/reading from left
+/// side of IBM address or right side. This is needed because IBM
+/// scoms are 64 bits while the OCMB only has 32 bit regs.
+enum addrSide
+{
+ LHS = 0x00,
+ RHS = 0x01
+};
+
+
}// i2c
}// exp
}// mss
diff --git a/src/import/generic/memory/lib/utils/endian_utils.H b/src/import/generic/memory/lib/utils/endian_utils.H
new file mode 100644
index 00000000..446dcc86
--- /dev/null
+++ b/src/import/generic/memory/lib/utils/endian_utils.H
@@ -0,0 +1,149 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/import/generic/memory/lib/utils/endian_utils.H $ */
+/* */
+/* OpenPOWER sbe Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2018,2019 */
+/* [+] 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 */
+
+///
+/// @file endian_utils.H
+/// @brief Util functions to help with endianess
+///
+
+// *HWP HWP Owner: Ben Gass <bgass@us.ibm.com>
+// *HWP HWP Backup: Christian Geddes <crgeddes@us.ibm.com>
+// *HWP Team:
+// *HWP Level: 2
+// *HWP Consumed by: HB:FSP
+
+#ifndef _ENDIAN_UTILS_H_
+#define _ENDIAN_UTILS_H_
+
+#include <cstdint>
+#include <vector>
+#include <generic/memory/lib/utils/shared/mss_generic_consts.H>
+
+namespace mss
+{
+
+///
+/// @brief Forces native data into LE order
+/// @tparam T the data type to process
+/// @param[in] i_input inputted data to process
+/// @param[in,out] io_data vector to append data to
+///
+template < typename T >
+void forceLE(const T& i_input, std::vector<uint8_t>& io_data)
+{
+ // Temporary variable to process - we'll be doing bit shifts below
+ T l_temp = i_input;
+
+ for(size_t i = 0; i < sizeof(i_input); i++)
+ {
+ // Grab the lowe rorder byte and add it to the back of the vector
+ const uint8_t l_byte = l_temp & 0xFF;
+ io_data.push_back(l_byte);
+
+ // Shift higher byte value into lowest no matter existing endianness
+ l_temp >>= BITS_PER_BYTE;
+ }
+}
+
+///
+/// @brief Forces native data into LE order for an array
+/// @tparam T the data type to process
+/// @param[in] i_input inputted data to process
+/// @param[in] i_size size of the array
+/// @param[in,out] io_data vector to append data to
+///
+template < typename T >
+inline void forceLEArray(const T* i_input, const uint64_t i_size, std::vector<uint8_t>& io_data)
+{
+ for(size_t i = 0; i < i_size; i++)
+ {
+ forceLE(i_input[i], io_data);
+ }
+}
+
+///
+/// @brief Converts LE data into native order
+/// @tparam T the data type to output to
+/// @param[in] i_input inputted data to process
+/// @param[in,out] io_idx current index
+/// @param[out] o_data data that has been converted into native endianness
+/// @return bool true if passing false if failing
+/// @note Real FFDC will be handled outside
+///
+template < typename T >
+bool readLE(const std::vector<uint8_t>& i_input, uint32_t& io_idx, T& o_data)
+{
+ const uint32_t l_sz = static_cast<uint32_t>(sizeof(o_data));
+ io_idx = l_sz + io_idx;
+
+ // Checks that our final index is within the data range
+ // Note: we decrement the index prior, so equal to is ok
+ if(io_idx > i_input.size())
+ {
+ return false;
+ }
+
+ uint64_t l_idx = io_idx;
+
+ o_data = 0;
+
+ for(uint64_t i = 0; i < l_sz; i++)
+ {
+ l_idx--;
+ uint8_t v = i_input[l_idx];
+ o_data <<= BITS_PER_BYTE;
+ o_data |= v;
+ }
+
+ return true;
+}
+
+///
+/// @brief Converts LE data into native order
+/// @tparam T the data type to output to
+/// @param[in] i_input inputted data to process
+/// @param[in] i_size size of the array
+/// @param[in,out] io_idx current index
+/// @param[out] o_data data that has been converted into native endianness
+/// @return bool true if passing false if failing
+/// @note Real FFDC will be handled outside
+///
+template < typename T >
+bool readLEArray(const std::vector<uint8_t>& i_input, const uint32_t i_size, uint32_t& io_idx, T* o_data)
+{
+ // Loop while the readLE is still passing and we haven't looped through the array's boundaries
+ bool l_passing = true;
+
+ for(uint32_t i = 0; i < i_size && l_passing; ++i)
+ {
+ l_passing = readLE(i_input, io_idx, o_data[i]);
+ }
+
+ return l_passing;
+}
+
+}
+
+#endif
OpenPOWER on IntegriCloud