From f6dba79871cdcc1bb64f54615f48ba8f735402e4 Mon Sep 17 00:00:00 2001 From: Rene Straub Date: Mon, 15 Jun 2020 13:33:46 +0200 Subject: [PATCH] nrhw: add board descriptor hw_type support (cherry picked from commit f51b3b4fc3deb71b6c5111faded04866743d9261) --- board/nm/common/bdparser.h | 9 ++++++--- board/nm/common/board_descriptor.c | 11 +++++++++++ board/nm/common/board_descriptor.h | 1 + 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/board/nm/common/bdparser.h b/board/nm/common/bdparser.h index 22c7bee924..ae445c2369 100644 --- a/board/nm/common/bdparser.h +++ b/board/nm/common/bdparser.h @@ -30,6 +30,8 @@ * Fixed wrong sizeof type in GetPartition() * Changed 64 bit type to "long long" from struct * Added BD_VerifySha1Hmac() function + * 20200615 rs Added BD_Hw_Type tag + * *****************************************************************************/ /** @@ -160,7 +162,8 @@ typedef enum _BD_Tags BD_BOM_Patch = 33, /**< "UInt8" -> Hardware BOM patch of the equipment (BOM changes, same PCB, not SW relevant) */ BD_Prod_Variant_Name = 34, /**< "String" -> Product variant */ - + BD_Hw_Type = 35, /*<< "UInt16" -> Hardware Type, e.g. 24 for HW24, 26 for HW26 */ + BD_Ui_Adapter_Type = 4096, /**< "UInt16" -> IV OG2 UI adapterboard type (0 = not present) */ BD_Voltage = 4098, /**< "UInt8" -> Primary Voltage (1=12-60V, 2=40-160V, 3=24-60V, 4=?, 5=12-24V) */ @@ -181,10 +184,10 @@ typedef enum _BD_Tags BD_Patch = 4126, /**< "UInt8" -> Board patch level (after production) */ BD_Pd_Phy2 = 4127, /**< "String" -> */ PD_SerDes = 4128, /**< "UInt16" -> SERDES Configuration (e.g. NB1800) */ - PD_Shield = 4129, /**< "UInt16" -> Assembled Shield (0=COM/IO, 1=DualCAN) */ + PD_Shield = 4129, /**< "UInt16" -> Assembled Shield (0=COM/IO, 1=DualCAN), 2=CAN/GNSS, 3=DualCAN Passive */ /* project specific tags */ - BD_BootPart = 32768, /**< "UInt8" */ + BD_BootPart = 32768, /**< "UInt8" */ BD_None_Type = 65535, /**< "Void" -> None */ } diff --git a/board/nm/common/board_descriptor.c b/board/nm/common/board_descriptor.c index 2f64a2140c..64b713ae5b 100644 --- a/board/nm/common/board_descriptor.c +++ b/board/nm/common/board_descriptor.c @@ -17,6 +17,7 @@ * code cleanup (tabs/indentation) * 20110211 rs partition table handling * 20190330 rs cleanup after years of chaotic development + * 20200615 rs added bd_get_hw_type() * *****************************************************************************/ #include @@ -217,6 +218,16 @@ int bd_get_variantname(char *variantname, size_t len) return 0; } +void bd_get_hw_type(int* type) +{ + uint16_t hwtype = 0; + + if ( !_get_uint16( BD_Hw_Type, 0, &hwtype) ) + debug("%s() no Hw Type found\n", __func__); + + *type = hwtype; +} + void bd_get_hw_version(int* ver, int* rev) { uint8_t hwver = 0; diff --git a/board/nm/common/board_descriptor.h b/board/nm/common/board_descriptor.h index 13d01654ff..a00a2f1e3b 100644 --- a/board/nm/common/board_descriptor.h +++ b/board/nm/common/board_descriptor.h @@ -17,6 +17,7 @@ int bd_get_context(BD_Context *bdctx, uint32_t i2caddress, uint32_t offset); int bd_get_prodname(char *prodname, size_t len); int bd_get_variantname(char *variantname, size_t len); +void bd_get_hw_type(int* type); void bd_get_hw_version(int* ver, int* rev); void bd_get_hw_patch(int* patch); int bd_get_mac(int index, uint8_t *macaddr, size_t len);