Skip to content

Commit 935a9b0

Browse files
GoldenBugfacebook-github-bot
authored andcommitted
Refactor Common plat_class Functions for Expansion Boards
Summary: The expansion cards shared some code that should be extracted out into common libraries. In order to facilitate building the expansion board library and not including extra logic for boards that don't use it; The library directory was expanded in the CMakeLists.txt files so we can choose to not include specific libraries. In general globbing in cmake isn't great... Reviewed By: garnermic Differential Revision: D38228112 fbshipit-source-id: 1364addeffa06eb4a0487b9b74c3c5490eb7be77
1 parent e2b9a03 commit 935a9b0

22 files changed

Lines changed: 107 additions & 101 deletions

meta-facebook/yv35-rf/src/platform/plat_class.c renamed to common/lib/expansion_board.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <stdio.h>
22
#include "hal_gpio.h"
3-
#include "plat_class.h"
3+
#include "expansion_board.h"
44

55
static uint8_t system_board_id = 0;
66

@@ -26,8 +26,11 @@ void init_sys_board_id(uint8_t board_id)
2626
void init_platform_config()
2727
{
2828
uint8_t board_id = 0;
29-
board_id = ((gpio_get(BOARD_ID_BIT_3) << 3) | (gpio_get(BOARD_ID_BIT_2) << 2) |
30-
(gpio_get(BOARD_ID_BIT_1) << 1) | (gpio_get(BOARD_ID_BIT_0) << 0));
29+
30+
board_id = (gpio_get(BOARD_ID3) << 3);
31+
board_id |= (gpio_get(BOARD_ID2) << 2);
32+
board_id |= (gpio_get(BOARD_ID1) << 1);
33+
board_id |= (gpio_get(BOARD_ID0) << 0);
3134

3235
init_sys_board_id(board_id);
3336
printf("[%s] board id 0x%x\n", __func__, system_board_id);

meta-facebook/yv35-rf/src/platform/plat_class.h renamed to common/lib/expansion_board.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef PLAT_CLASS_H
2-
#define PLAT_CLASS_H
1+
#ifndef EXPANSION_BOARD_H
2+
#define EXPANSION_BOARD_H
33

44
#include "hal_gpio.h"
55
#include "plat_gpio.h"
@@ -11,13 +11,6 @@ enum BOARD_ID {
1111
UNKNOWN_BOARD = 0xFF,
1212
};
1313

14-
enum BOARD_ID_BIT_MAPPING {
15-
BOARD_ID_BIT_0 = BOARD_ID0,
16-
BOARD_ID_BIT_1 = BOARD_ID1,
17-
BOARD_ID_BIT_2 = BOARD_ID2,
18-
BOARD_ID_BIT_3 = BOARD_ID3,
19-
};
20-
2114
void init_platform_config();
2215
void init_sys_board_id(uint8_t board_id);
2316
uint8_t get_board_id();

‎meta-facebook/gt-cc/CMakeLists.txt‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,23 @@ project(gt-cc)
77

88
set(common_path ../../common)
99
FILE(GLOB app_sources src/ipmi/*.c src/platform/*.c src/lib/*.c src/shell/*.c)
10-
FILE(GLOB common_sources ${common_path}/service/*.c ${common_path}/service/*/*.c ${common_path}/hal/*.c ${common_path}/dev/*.c ${common_path}/lib/*.c ${common_path}/shell/*.c)
10+
FILE(GLOB common_sources ${common_path}/service/*.c ${common_path}/service/*/*.c ${common_path}/hal/*.c ${common_path}/dev/*.c ${common_path}/shell/*.c)
1111

1212
target_sources(app PRIVATE ${app_sources})
1313
target_sources(app PRIVATE ${common_sources})
14+
15+
# Common Lib
16+
target_sources(app PRIVATE ${common_path}/lib/libutil.c)
17+
target_sources(app PRIVATE ${common_path}/lib/power_status.c)
18+
target_sources(app PRIVATE ${common_path}/lib/timer.c)
19+
target_sources(app PRIVATE ${common_path}/lib/util_pmbus.c)
20+
target_sources(app PRIVATE ${common_path}/lib/util_spi.c)
21+
target_sources(app PRIVATE ${common_path}/lib/util_sys.c)
22+
target_sources(app PRIVATE ${common_path}/lib/util_worker.c)
23+
1424
target_include_directories(app PRIVATE ${ZEPHYR_BASE}/include/portability)
1525
target_include_directories(app PRIVATE ${common_path} ${common_path}/service/ipmi/include ${common_path}/service/host ${common_path}/service/sensor ${common_path}/service/usb ${common_path}/service/ipmb ${common_path}/service/mctp ${common_path}/service/pldm ${common_path}/hal ${common_path}/dev/include ${common_path}/lib ${common_path}/shell)
1626
target_include_directories(app PRIVATE src/ipmi/include src/lib src/platform src/shell)
1727

1828
# Fail build if there are any warnings
19-
target_compile_options(app PRIVATE -Werror)
29+
target_compile_options(app PRIVATE -Werror)

‎meta-facebook/gt-cc/src/platform/plat_class.c‎

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎meta-facebook/gt-cc/src/platform/plat_class.h‎

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎meta-facebook/gt-cc/src/platform/plat_init.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include "hal_peci.h"
33
#include "power_status.h"
44
#include "util_sys.h"
5-
#include "plat_class.h"
65
#include "plat_gpio.h"
76
#include "plat_i2c_target.h"
87
#include "pldm.h"

‎meta-facebook/gt-cc/src/platform/plat_ipmb.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "plat_i2c.h"
55
#include "plat_ipmb.h"
66
#include "plat_ipmi.h"
7-
#include "plat_class.h"
87

98
IPMB_config pal_IPMB_config_table[] = {
109
// index, interface, channel, bus, channel_target_address, enable_status, self_address,

‎meta-facebook/gt-cc/src/platform/plat_sdr_table.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <stdio.h>
44
#include <string.h>
55
#include "sdr.h"
6-
#include "plat_class.h"
76
#include "plat_ipmb.h"
87
#include "plat_sensor_table.h"
98

‎meta-facebook/gt-cc/src/platform/plat_sensor_table.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include "ast_adc.h"
99
#include "intel_peci.h"
1010
#include "hal_gpio.h"
11-
#include "plat_class.h"
1211
#include "plat_gpio.h"
1312
#include "plat_hook.h"
1413
#include "plat_i2c.h"

‎meta-facebook/wc-mb/CMakeLists.txt‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,20 @@ project(wc-mb)
77

88
set(common_path ../../common)
99
FILE(GLOB app_sources src/ipmi/*.c src/platform/*.c src/lib/*.c)
10-
FILE(GLOB common_sources ${common_path}/service/*.c ${common_path}/service/*/*.c ${common_path}/hal/*.c ${common_path}/dev/*.c ${common_path}/lib/*.c ${common_path}/shell/*.c)
10+
FILE(GLOB common_sources ${common_path}/service/*.c ${common_path}/service/*/*.c ${common_path}/hal/*.c ${common_path}/dev/*.c ${common_path}/shell/*.c)
1111

1212
target_sources(app PRIVATE ${app_sources})
1313
target_sources(app PRIVATE ${common_sources})
14+
15+
# Common Lib
16+
target_sources(app PRIVATE ${common_path}/lib/libutil.c)
17+
target_sources(app PRIVATE ${common_path}/lib/power_status.c)
18+
target_sources(app PRIVATE ${common_path}/lib/timer.c)
19+
target_sources(app PRIVATE ${common_path}/lib/util_pmbus.c)
20+
target_sources(app PRIVATE ${common_path}/lib/util_spi.c)
21+
target_sources(app PRIVATE ${common_path}/lib/util_sys.c)
22+
target_sources(app PRIVATE ${common_path}/lib/util_worker.c)
23+
1424
target_include_directories(app PRIVATE ${ZEPHYR_BASE}/include/portability)
1525
target_include_directories(app PRIVATE ${common_path} ${common_path}/service/ipmi/include ${common_path}/service/host ${common_path}/service/sensor ${common_path}/service/usb ${common_path}/service/ipmb ${common_path}/service/mctp ${common_path}/service/pldm ${common_path}/hal ${common_path}/dev/include ${common_path}/lib ${common_path}/shell)
1626
target_include_directories(app PRIVATE src/ipmi/include src/lib src/platform)

0 commit comments

Comments
 (0)