From 7d48ac5c7dfb52fc470bbad1013b4d460bc6a1e0 Mon Sep 17 00:00:00 2001 From: David Hendricks Date: Fri, 9 Mar 2018 14:30:38 -0800 Subject: soc/cavium: Integrate BDK files into coreboot * Make it compile. * Fix whitespace errors. * Fix printf formats. * Add missing headers includes * Guard headers with ifdefs Compile DRAM init code in romstage. Compile QLM, PCIe, RNG, PHY, GPIO, MDIO init code in ramstage. Change-Id: I0a93219a14bfb6ebe41103a825d5032b11e7f2c6 Signed-off-by: David Hendricks Reviewed-on: https://review.coreboot.org/25089 Reviewed-by: Philipp Deppenwiese Tested-by: build bot (Jenkins) --- .../cavium/include/bdk/libbdk-hal/bdk-config.h | 154 +++++---------------- 1 file changed, 33 insertions(+), 121 deletions(-) (limited to 'src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-config.h') diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-config.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-config.h index 6848fd687c..9aa1a47251 100644 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-config.h +++ b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-config.h @@ -1,3 +1,5 @@ +#ifndef __CB_BDK_CONFIG_H__ +#define __CB_BDK_CONFIG_H__ /***********************license start*********************************** * Copyright (c) 2003-2017 Cavium Inc. (support@cavium.com). All rights * reserved. @@ -37,6 +39,9 @@ * ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU. ***********************license end**************************************/ +#include +#include + /** * @file * @@ -90,6 +95,7 @@ typedef enum BDK_CONFIG_PCIE_PRESET_REQUEST_VECTOR, /* Parameters: Node, Port */ BDK_CONFIG_PCIE_WIDTH, /* Parameters: Node, Port */ BDK_CONFIG_PCIE_PHYSICAL_SLOT, /* Parameters: Node, Port */ + BDK_CONFIG_PCIE_SKIP_LINK_TRAIN, /* Parameters: Node, Port */ BDK_CONFIG_PCIE_FLASH, /* Parameters: Node, Port */ BDK_CONFIG_CCPI_LANE_REVERSE, /* No parameters */ BDK_CONFIG_CHIP_SKU, /* Parameter: Node */ @@ -200,21 +206,6 @@ typedef enum __BDK_CONFIG_END } bdk_config_t; -/** - * Internal BDK function to initialize the config system. Must be called before - * any configuration functions are called - */ -extern void __bdk_config_init(void); - -/** - * Return a help string for the given configuration parameter - * - * @param cfg_item Configuration parameter to get help for - * - * @return Help string for the user - */ -extern const char *bdk_config_get_help(bdk_config_t cfg_item); - /** * Get an integer configuration item * @@ -223,49 +214,7 @@ extern const char *bdk_config_get_help(bdk_config_t cfg_item); * * @return The value of the configuration item, or def_value if the item is not set */ -extern int64_t bdk_config_get_int(bdk_config_t cfg_item, ...); - -/** - * Get a string configuration item - * - * @param cfg_item Config item to get. If the item takes parameters (see bdk_config_t), then the - * parameters are listed following cfg_item. - * - * @return The value of the configuration item, or def_value if the item is not set - */ -extern const char *bdk_config_get_str(bdk_config_t cfg_item, ...); - -/** - * Get a binary blob - * - * @param blob_size Integer to receive the size of the blob - * @param cfg_item Config item to get. If the item takes parameters (see bdk_config_t), then the - * parameters are listed following cfg_item. - * - * @return The value of the configuration item, or def_value if the item is not set - */ -extern const void *bdk_config_get_blob(int *blob_size, bdk_config_t cfg_item, ...); - -/** - * Set an integer configuration item. Note this only sets the item in memory, - * persistent storage is not updated. The optional parameters for the setting are - * not supplied, meaning this function only changes the global default. - * - * @param value Configuration item value - * @param cfg_item Config item to set. If the item takes parameters (see bdk_config_t), then the - * parameters are listed following cfg_item. - */ -extern void bdk_config_set_int_no_param(int64_t value, bdk_config_t cfg_item); - -/** - * Set an integer configuration item. Note this only sets the item in memory, - * persistent storage is not updated. - * - * @param value Configuration item value - * @param cfg_item Config item to set. If the item takes parameters (see bdk_config_t), then the - * parameters are listed following cfg_item. - */ -extern void bdk_config_set_int(int64_t value, bdk_config_t cfg_item, ...); +int64_t bdk_config_get_int(bdk_config_t cfg_item, ...); /** * Set an integer configuration item. Note this only sets the item in memory, @@ -275,63 +224,17 @@ extern void bdk_config_set_int(int64_t value, bdk_config_t cfg_item, ...); * @param cfg_item Config item to set. If the item takes parameters (see bdk_config_t), then the * parameters are listed following cfg_item. */ -extern void bdk_config_set_str(const char *value, bdk_config_t cfg_item, ...); +void bdk_config_set_int(int64_t value, bdk_config_t cfg_item, ...); /** - * Set a blob configuration item. Note this only sets the - * item in memory, persistent storage is not updated. The optional - * parameters for the setting are not supplied, meaning this function - * only changes the global default. - * - * @param size Size of the item in bytes. A size of zero removes the device tree field - * @param value Configuration item value - * @param cfg_item Config item to set. If the item takes parameters (see bdk_config_t), then the - * parameters are listed following cfg_item. - */ -extern void bdk_config_set_blob_no_param(int size, const void *value, bdk_config_t cfg_item); - -/** - * Set a blob configuration item. Note this only sets the - * item in memory, persistent storage is not updated. - * - * @param size Size of the item in bytes. A size of zero removes the device tree field - * @param value Configuration item value - * @param cfg_item Config item to set. If the item takes parameters (see bdk_config_t), then the - * parameters are listed following cfg_item. - */ -extern void bdk_config_set_blob(int size, const void *value, bdk_config_t cfg_item, ...); - -/** - * Display the active configuration - */ -extern void bdk_config_show(void); - -/** - * Display a list of all posssible config items with help text - */ -extern void bdk_config_help(void); - -/** - * Save the current configuration to flash - * - * @return Zero on success, negative on failure - */ -extern int bdk_config_save(void); - -/** - * Takes the current live device tree and exports it to a memory address suitable - * for passing to the next binary in register X1. + * Get a string configuration item * - * @return Physical address of the device tree, or 0 on failure - */ -extern uint64_t __bdk_config_export_to_mem(void); - -/** - * Return a pointer to the device tree used for configuration + * @param cfg_item Config item to get. If the item takes parameters (see bdk_config_t), then the + * parameters are listed following cfg_item. * - * @return FDT or NULL on failure + * @return The value of the configuration item, or def_value if the item is not set */ -extern void* bdk_config_get_fdt(void); +const char *bdk_config_get_str(bdk_config_t cfg_item, ...); /** * Set the device tree used for configuration @@ -341,17 +244,26 @@ extern void* bdk_config_get_fdt(void); * * @return Zero on success, negative on failure */ -extern int bdk_config_set_fdt(void *fdt); +int bdk_config_set_fdt(const struct bdk_devicetree_key_value *fdt); -/** - * Write all default values to a FDT. Missing config items get defaults in the - * BDK config, this function adds those defaults to the FDT. This way other code - * gets the default value without needing special code. - * - * @param fdt FDT structure to fill defaults into - * - * @return Zero on success, negative on failure - */ -extern int bdk_config_expand_defaults(void *fdt); +typedef enum +{ + BDK_CONFIG_TYPE_INT, + BDK_CONFIG_TYPE_STR, + BDK_CONFIG_TYPE_STR_LIST, + BDK_CONFIG_TYPE_BINARY, +} bdk_config_type_t; + +typedef struct +{ + const char *format; /* Printf style format string to create the item name */ + const bdk_config_type_t ctype;/* Type of this item */ + int64_t default_value; /* Default value when no present. String defaults are cast to pointers from this */ + const int64_t min_value;/* Minimum valid value for INT parameters. Unused for Strings */ + const int64_t max_value;/* Maximum valid value for INT parameters. Unused for Strings */ +} bdk_config_info_t; + +extern bdk_config_info_t config_info[]; /** @} */ +#endif /* !__CB_BDK_CONFIG_H__ */ -- cgit v1.2.3