| 1 | #ifndef __CB_BDK_DRAM_CONFIG_H__ |
| 2 | #define __CB_BDK_DRAM_CONFIG_H__ |
| 3 | |
| 4 | /***********************license start*********************************** |
| 5 | * Copyright (c) 2003-2017 Cavium Inc. ([email protected]). All rights |
| 6 | * reserved. |
| 7 | * |
| 8 | * |
| 9 | * Redistribution and use in source and binary forms, with or without |
| 10 | * modification, are permitted provided that the following conditions are |
| 11 | * met: |
| 12 | * |
| 13 | * * Redistributions of source code must retain the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer. |
| 15 | * |
| 16 | * * Redistributions in binary form must reproduce the above |
| 17 | * copyright notice, this list of conditions and the following |
| 18 | * disclaimer in the documentation and/or other materials provided |
| 19 | * with the distribution. |
| 20 | * |
| 21 | * * Neither the name of Cavium Inc. nor the names of |
| 22 | * its contributors may be used to endorse or promote products |
| 23 | * derived from this software without specific prior written |
| 24 | * permission. |
| 25 | * |
| 26 | * This Software, including technical data, may be subject to U.S. export |
| 27 | * control laws, including the U.S. Export Administration Act and its |
| 28 | * associated regulations, and may be subject to export or import |
| 29 | * regulations in other countries. |
| 30 | * |
| 31 | * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" |
| 32 | * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR |
| 33 | * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT |
| 34 | * TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY |
| 35 | * REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT |
| 36 | * DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES |
| 37 | * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR |
| 38 | * PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, |
| 39 | * QUIET POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK |
| 40 | * ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU. |
| 41 | ***********************license end**************************************/ |
| 42 | |
| 43 | /** |
| 44 | * @file |
| 45 | * |
| 46 | * Functions for configuring DRAM. |
| 47 | * |
| 48 | * <hr>$Revision: 49448 $<hr> |
| 49 | * |
| 50 | * @defgroup dram DRAM related functions |
| 51 | * @{ |
| 52 | */ |
| 53 | #if 0 |
| 54 | /* FIXME(dhendrix): this was cavium's #include */ |
| 55 | #include "../libdram/libdram.h" |
| 56 | #endif |
| 57 | #include <libdram/libdram.h> |
| 58 | |
| 59 | /** |
| 60 | * Lookup a DRAM configuration by name and intialize dram with it |
| 61 | * |
| 62 | * @param node Node to configure |
| 63 | * @param ddr_clock_override |
| 64 | * If non zero, override the DRAM frequency specified in the config with |
| 65 | * this value |
| 66 | * |
| 67 | * @return Amount of DRAM in MB, or negative on failure |
| 68 | */ |
| 69 | extern int bdk_dram_config(int node, int ddr_clock_override); |
| 70 | |
| 71 | /** |
| 72 | * Do DRAM configuration tuning |
| 73 | * |
| 74 | * @param node Node to tune |
| 75 | * |
| 76 | * @return Success or Fail |
| 77 | */ |
| 78 | extern int bdk_dram_tune(int node); |
| 79 | |
| 80 | /** |
| 81 | * Do DRAM Margin all tests |
| 82 | * |
| 83 | * @param node Node to tune |
| 84 | * |
| 85 | * @return None |
| 86 | */ |
| 87 | extern void bdk_dram_margin(int node); |
| 88 | |
| 89 | /** |
| 90 | * Get the amount of DRAM configured for a node. This is read from the LMC |
| 91 | * controller after DRAM is setup. |
| 92 | * |
| 93 | * @param node Node to query |
| 94 | * |
| 95 | * @return Size in megabytes |
| 96 | */ |
| 97 | extern uint64_t bdk_dram_get_size_mbytes(int node); |
| 98 | |
| 99 | /** |
| 100 | * Return the string of info about the current node's DRAM configuration. |
| 101 | * |
| 102 | * @param node node to retrieve |
| 103 | * |
| 104 | * @return String or NULL |
| 105 | */ |
| 106 | extern const char* bdk_dram_get_info_string(int node); |
| 107 | |
| 108 | /** |
| 109 | * Return the highest address currently used by the BDK. This address will |
| 110 | * be about 4MB above the top of the BDK to make sure small growths between the |
| 111 | * call and its use don't cause corruption. Any call to memory allocation can |
| 112 | * change this value. |
| 113 | * |
| 114 | * @return Size of the BDK in bytes |
| 115 | */ |
| 116 | extern uint64_t bdk_dram_get_top_of_bdk(void); |
| 117 | |
| 118 | extern int __bdk_dram_get_num_lmc(bdk_node_t node); |
| 119 | extern int __bdk_dram_is_ddr4(bdk_node_t node, int lmc); |
| 120 | extern int __bdk_dram_is_rdimm(bdk_node_t node, int lmc); |
| 121 | extern uint32_t __bdk_dram_get_row_mask(bdk_node_t node, int lmc); |
| 122 | extern uint32_t __bdk_dram_get_col_mask(bdk_node_t node, int lmc); |
| 123 | extern int __bdk_dram_get_num_bank_bits(bdk_node_t node, int lmc); |
| 124 | |
| 125 | /** @} */ |
| 126 | |
| 127 | #endif /* !__CB_BDK_DRAM_CONFIG_H__ */ |