summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2018-03-07 17:03:10 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-03-15 15:27:31 -0700
commit514c3b3e26edb3b05b466c5569894808cfdc4a91 (patch)
treeaa423d8e1a0a6827330aedf000f1b532425e40c7
parentabde1bca995f018f4c1df8dc24a0a33c18557871 (diff)
downloadchrome-ec-514c3b3e26edb3b05b466c5569894808cfdc4a91.tar.gz
ec: Add /baseboard to EC project
This CL introduces /baseboard to the EC project which can contain config options and code which is specific to certain family, but can be shared among the board derivatives of that family. Only the infrastructure changes are included with an empty baseboard.c/.h for octopus. BRANCH=none BUG=b:74358864 TEST='make buildall' and ensure that all boards build successfully. In addition, temporarily moved config options for USB-C and charger to baseboard.h and tested that 'make BOARD=yorp' is successful. Change-Id: I16656574f835c56598a9d2bf49bc1e946d71fe76 Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/954444 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--Makefile41
-rw-r--r--Makefile.toolchain2
-rw-r--r--baseboard/octopus/baseboard.c6
-rw-r--r--baseboard/octopus/baseboard.h11
-rw-r--r--baseboard/octopus/build.mk9
-rw-r--r--board/yorp/build.mk3
-rw-r--r--include/config.h3
7 files changed, 62 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index 82932b6b93..5c311a0640 100644
--- a/Makefile
+++ b/Makefile
@@ -58,12 +58,25 @@ not_cfg = $(subst ro rw,y,$(filter-out $(1:y=ro rw),ro rw))
# The board makefile sets $CHIP and the chip makefile sets $CORE.
# Include those now, since they must be defined for _flag_cfg below.
include $(BDIR)/build.mk
+# Baseboard directory
+ifneq (,$(BASEBOARD))
+BASEDIR:=baseboard/$(BASEBOARD)
+CFLAGS_BASEBOARD=-DHAS_BASEBOARD -DBASEBOARD_$(UC_BASEBOARD)
+include $(BASEDIR)/build.mk
+else
+# If BASEBOARD is not defined, then assign BASEDIR to BDIR. This avoids
+# the need to have so many conditional checks wherever BASEDIR is used
+# below.
+BASEDIR:=$(BDIR)
+CFLAGS_BASEBOARD=
+endif
include chip/$(CHIP)/build.mk
# Create uppercase config variants, to avoid mixed case constants.
# Also translate '-' to '_', so 'cortex-m' turns into 'CORTEX_M'. This must
# be done before evaluating config.h.
uppercase = $(shell echo $(1) | tr '[:lower:]-' '[:upper:]_')
+UC_BASEBOARD:=$(call uppercase,$(BASEBOARD))
UC_BOARD:=$(call uppercase,$(BOARD))
UC_CHIP:=$(call uppercase,$(CHIP))
UC_CHIP_FAMILY:=$(call uppercase,$(CHIP_FAMILY))
@@ -72,8 +85,8 @@ UC_CORE:=$(call uppercase,$(CORE))
UC_PROJECT:=$(call uppercase,$(PROJECT))
# Transform the configuration into make variables. This must be done after
-# the board/project/chip/core variables are defined, since some of the configs
-# are dependent on particular configurations.
+# the board/baseboard/project/chip/core variables are defined, since some of
+# the configs are dependent on particular configurations.
includes=include core/$(CORE)/include $(dirs) $(out) test
ifdef CTS_MODULE
includes+=cts/$(CTS_MODULE) cts
@@ -90,7 +103,8 @@ else
_tsk_lst_flags:=
endif
-_tsk_lst_flags+=-I$(BDIR) -DBOARD_$(UC_BOARD) -D_MAKEFILE \
+_tsk_lst_flags+=-I$(BDIR) -DBOARD_$(UC_BOARD) -I$(BASEDIR) \
+ -DBASEBOARD_$(UC_BASEBOARD) -D_MAKEFILE \
-imacros $(_tsk_lst_file)
_tsk_lst_ro:=$(shell $(CPP) -P -DSECTION_IS_RO \
@@ -112,10 +126,10 @@ CPPFLAGS_RW+=$(foreach t,$(_tsk_cfg_rw),-D$(t)) \
CPPFLAGS+=$(foreach t,$(_tsk_cfg),-D$(t))
_flag_cfg_ro:=$(shell $(CPP) $(CPPFLAGS) -P -dM -Ichip/$(CHIP) \
- -I$(BDIR) -DSECTION_IS_RO include/config.h | \
+ -I$(BASEDIR) -I$(BDIR) -DSECTION_IS_RO include/config.h | \
grep -o "\#define CONFIG_[A-Z0-9_]*" | cut -c9- | sort)
_flag_cfg_rw:=$(_tsk_cfg_rw) $(shell $(CPP) $(CPPFLAGS) -P -dM -Ichip/$(CHIP) \
- -I$(BDIR) -DSECTION_IS_RW include/config.h | \
+ -I$(BASEDIR) -I$(BDIR) -DSECTION_IS_RW include/config.h | \
grep -o "\#define CONFIG_[A-Z0-9_]*" | cut -c9- | sort)
_flag_cfg:= $(filter $(_flag_cfg_ro), $(_flag_cfg_rw))
@@ -127,8 +141,9 @@ $(foreach c,$(_tsk_cfg_ro) $(_flag_cfg_ro),$(eval $(c)=ro))
$(foreach c,$(_tsk_cfg) $(_flag_cfg),$(eval $(c)=y))
ifneq "$(CONFIG_COMMON_RUNTIME)" "y"
- _irq_list:=$(shell $(CPP) $(CPPFLAGS) -P -Ichip/$(CHIP) -I$(BDIR) \
- -D"ENABLE_IRQ(x)=EN_IRQ x" -imacros chip/$(CHIP)/registers.h \
+ _irq_list:=$(shell $(CPP) $(CPPFLAGS) -P -Ichip/$(CHIP) -I$(BASEDIR) \
+ -I$(BDIR) -D"ENABLE_IRQ(x)=EN_IRQ x" \
+ -imacros chip/$(CHIP)/registers.h \
$(BDIR)/ec.irqlist | grep "EN_IRQ .*" | cut -c8-)
CPPFLAGS+=$(foreach irq,$(_irq_list),\
-D"irq_$(irq)_handler_optional=irq_$(irq)_handler")
@@ -136,16 +151,17 @@ endif
# Compute RW firmware size and offset
_rw_off_str:=$(shell echo "CONFIG_RW_MEM_OFF" | $(CPP) $(CPPFLAGS) -P \
- -Ichip/$(CHIP) -I$(BDIR) -imacros include/config.h)
+ -Ichip/$(CHIP) -I$(BASEDIR) -I$(BDIR) -imacros include/config.h)
_rw_off:=$(shell echo "$$(($(_rw_off_str)))")
_rw_size_str:=$(shell echo "CONFIG_RW_SIZE" | $(CPP) $(CPPFLAGS) -P \
- -Ichip/$(CHIP) -I$(BDIR) -imacros include/config.h)
+ -Ichip/$(CHIP) -I$(BASEDIR) -I$(BDIR) -imacros include/config.h)
_rw_size:=$(shell echo "$$(($(_rw_size_str)))")
_program_memory_base_str:=$(shell echo "CONFIG_PROGRAM_MEMORY_BASE" | \
$(CPP) $(CPPFLAGS) -P \
- -Ichip/$(CHIP) -I$(BDIR) -imacros include/config.h)
+ -Ichip/$(CHIP) -I$(BDIR) -I$(BASEDIR) -imacros include/config.h)
_program_memory_base=$(shell echo "$$(($(_program_memory_base_str)))")
+$(eval BASEBOARD_$(UC_BASEBOARD)=y)
$(eval BOARD_$(UC_BOARD)=y)
$(eval CHIP_$(UC_CHIP)=y)
$(eval CHIP_VARIANT_$(UC_CHIP_VARIANT)=y)
@@ -165,6 +181,7 @@ objs_from_dir=$(call objs_from_dir_p,$(1),$(2),y)
ifdef CTS_MODULE
include cts/build.mk
endif
+include $(BASEDIR)/build.mk
include $(BDIR)/build.mk
include chip/$(CHIP)/build.mk
include core/$(CORE)/build.mk
@@ -190,6 +207,7 @@ define get_sources =
# Get sources to build for this target
all-obj-$(1)+=$(call objs_from_dir_p,core/$(CORE),core,$(1))
all-obj-$(1)+=$(call objs_from_dir_p,chip/$(CHIP),chip,$(1))
+all-obj-$(1)+=$(call objs_from_dir_p,$(BASEDIR),baseboard,$(1))
all-obj-$(1)+=$(call objs_from_dir_p,$(BDIR),board,$(1))
all-obj-$(1)+=$(call objs_from_dir_p,private,private,$(1))
ifneq ($(PDIR),)
@@ -208,7 +226,8 @@ endef
$(eval $(call get_sources,y))
$(eval $(call get_sources,ro))
-dirs=core/$(CORE) chip/$(CHIP) $(BDIR) common power test cts/common cts/$(CTS_MODULE)
+dirs=core/$(CORE) chip/$(CHIP) $(BASEDIR) $(BDIR) common power test \
+ cts/common cts/$(CTS_MODULE)
dirs+= private $(PDIR)
dirs+=$(shell find common -type d)
dirs+=$(shell find driver -type d)
diff --git a/Makefile.toolchain b/Makefile.toolchain
index d7eb413d23..001910d87c 100644
--- a/Makefile.toolchain
+++ b/Makefile.toolchain
@@ -55,7 +55,7 @@ CFLAGS_DEFINE=-DOUTDIR=$(out)/$(BLD) -DCHIP=$(CHIP) -DBOARD_TASKFILE=$(_tsk_lst_
-DCHIP_VARIANT=$(CHIP_VARIANT) -DCHIP_FAMILY=$(CHIP_FAMILY) \
-DBOARD_$(UC_BOARD) -DCHIP_$(UC_CHIP) -DCORE_$(UC_CORE) \
-DCHIP_VARIANT_$(UC_CHIP_VARIANT) -DCHIP_FAMILY_$(UC_CHIP_FAMILY) \
- -DFINAL_OUTDIR=$(out)
+ -DFINAL_OUTDIR=$(out) $(CFLAGS_BASEBOARD)
CPPFLAGS=$(CFLAGS_DEFINE) $(CFLAGS_INCLUDE) $(CFLAGS_TEST) \
$(EXTRA_CFLAGS) $(CFLAGS_COVERAGE) $(LATE_CFLAGS_DEFINE) \
-DSECTION_IS_$(BLD) -DSECTION=$(BLD) $(CPPFLAGS_$(BLD))
diff --git a/baseboard/octopus/baseboard.c b/baseboard/octopus/baseboard.c
new file mode 100644
index 0000000000..aeae096cc3
--- /dev/null
+++ b/baseboard/octopus/baseboard.c
@@ -0,0 +1,6 @@
+/* Copyright 2018 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Octopus family-specific configuration */
diff --git a/baseboard/octopus/baseboard.h b/baseboard/octopus/baseboard.h
new file mode 100644
index 0000000000..3335d38f1a
--- /dev/null
+++ b/baseboard/octopus/baseboard.h
@@ -0,0 +1,11 @@
+/* Copyright 2018 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Octopus board configuration */
+
+#ifndef __CROS_EC_BASEBOARD_H
+#define __CROS_EC_BASEBOARD_H
+
+#endif /* __CROS_EC_BASEBOARD_H */
diff --git a/baseboard/octopus/build.mk b/baseboard/octopus/build.mk
new file mode 100644
index 0000000000..24e4cced5f
--- /dev/null
+++ b/baseboard/octopus/build.mk
@@ -0,0 +1,9 @@
+# -*- makefile -*-
+# Copyright 2018 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+#
+# Baseboard specific files build
+#
+
+baseboard-y=baseboard.o
diff --git a/board/yorp/build.mk b/board/yorp/build.mk
index 31726e8dc5..624e8a34b2 100644
--- a/board/yorp/build.mk
+++ b/board/yorp/build.mk
@@ -9,7 +9,8 @@
CHIP:=npcx
CHIP_FAMILY:=npcx7
CHIP_VARIANT:=npcx7m6f
+BASEBOARD:=octopus
board-y=board.o
board-$(CONFIG_BATTERY_SMART)+=battery.o
-board-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_policy.o \ No newline at end of file
+board-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_policy.o
diff --git a/include/config.h b/include/config.h
index a9ba707b97..8eb6389792 100644
--- a/include/config.h
+++ b/include/config.h
@@ -3268,6 +3268,9 @@
#endif
#include "config_chip.h"
+#ifdef HAS_BASEBOARD
+#include "baseboard.h"
+#endif
#include "board.h"
/******************************************************************************/