summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2014-06-10 14:04:20 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-06-19 03:25:08 +0000
commit6c8e451ff01d046a953ee99a2911b46732361b2b (patch)
tree53b666bb98d03f0f10d9616fd7c851eb2c5d3392
parent635a07ddadc47b649fa24bee6f94c65295eb844d (diff)
downloadchrome-ec-6c8e451ff01d046a953ee99a2911b46732361b2b.tar.gz
IRQ list support for enabling specific IRQs without common runtime
This adds back DECLARE_IRQ() support when building without common runtime. With this, we can enable only a subset of IRQs and avoid linking in other unused IRQ handlers. Note that after this change, all boards without common runtime need to have a ec.irqlist file. BUG=None TEST=Build Keyborg and check it still works. TEST=make buildall BRANCH=None Change-Id: If68062a803b9a78f383027a1625cf99eb3370d3f Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203264 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--Makefile8
-rw-r--r--board/keyborg/ec.irqlist12
-rw-r--r--board/keyborg/runtime.c5
-rw-r--r--board/keyborg/spi_comm.c4
-rw-r--r--board/zinger/board.c5
-rw-r--r--board/zinger/ec.irqlist13
-rw-r--r--board/zinger/runtime.c5
-rw-r--r--board/zinger/usb_pd_policy.c6
-rw-r--r--chip/stm32/registers.h4
-rw-r--r--chip/stm32/usb_pd_phy.c2
-rw-r--r--include/task.h8
11 files changed, 60 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index ece0f3d904..26ec921b8f 100644
--- a/Makefile
+++ b/Makefile
@@ -53,6 +53,14 @@ _flag_cfg:=$(shell $(CPP) $(CPPFLAGS) -P -dM -Ichip/$(CHIP) -Iboard/$(BOARD) \
$(foreach c,$(_tsk_cfg) $(_flag_cfg),$(eval $(c)=y))
+ifneq "$(CONFIG_COMMON_RUNTIME)" "y"
+ _irq_list:=$(shell $(CPP) $(CPPFLAGS) -P -Ichip/$(CHIP) -Iboard/$(BOARD) \
+ -D"ENABLE_IRQ(x)=EN_IRQ x" -imacros chip/$(CHIP)/registers.h \
+ board/$(BOARD)/ec.irqlist | grep "EN_IRQ .*" | cut -c8-)
+ CPPFLAGS+=$(foreach irq,$(_irq_list),\
+ -D"irq_$(irq)_handler_optional=irq_$(irq)_handler")
+endif
+
# Get build configuration from sub-directories
# Note that this re-includes the board and chip makefiles
include board/$(BOARD)/build.mk
diff --git a/board/keyborg/ec.irqlist b/board/keyborg/ec.irqlist
new file mode 100644
index 0000000000..670978c5c5
--- /dev/null
+++ b/board/keyborg/ec.irqlist
@@ -0,0 +1,12 @@
+/* Copyright (c) 2014 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.
+ */
+
+/**
+ * List of enabled IRQ. To enable an IRQ, use ENABLE_IRQ(irq_num). Any
+ * IRQ that is not listed here is disabled.
+ */
+
+ENABLE_IRQ(STM32_IRQ_EXTI0)
+ENABLE_IRQ(STM32_IRQ_TIM2)
diff --git a/board/keyborg/runtime.c b/board/keyborg/runtime.c
index e335442398..6cabd1e5c3 100644
--- a/board/keyborg/runtime.c
+++ b/board/keyborg/runtime.c
@@ -7,9 +7,9 @@
#include "common.h"
#include "cpu.h"
#include "debug.h"
-#include "irq_handler.h"
#include "master_slave.h"
#include "registers.h"
+#include "task.h"
#include "timer.h"
#include "util.h"
@@ -63,7 +63,7 @@ uint32_t task_set_event(task_id_t tskid, uint32_t event, int wait)
return 0;
}
-void IRQ_HANDLER(STM32_IRQ_TIM2)(void)
+void tim2_interrupt(void)
{
if (STM32_TIM_CNT(3) == last_deadline >> 16) {
STM32_TIM_DIER(2) = 0;
@@ -74,6 +74,7 @@ void IRQ_HANDLER(STM32_IRQ_TIM2)(void)
need_wfi = 1;
}
}
+DECLARE_IRQ(STM32_IRQ_TIM2, tim2_interrupt, 1);
void __hw_clock_event_set(uint32_t deadline)
{
diff --git a/board/keyborg/spi_comm.c b/board/keyborg/spi_comm.c
index 0b5c55358c..74ad247039 100644
--- a/board/keyborg/spi_comm.c
+++ b/board/keyborg/spi_comm.c
@@ -480,7 +480,7 @@ static void spi_nss_interrupt(void)
}
/* Interrupt handler for PA0 */
-void IRQ_HANDLER(STM32_IRQ_EXTI0)(void)
+void spi_nss_interrupt_handler(void)
{
/* Clear the interrupt */
STM32_EXTI_PR = STM32_EXTI_PR;
@@ -488,4 +488,4 @@ void IRQ_HANDLER(STM32_IRQ_EXTI0)(void)
/* SPI slave interrupt */
spi_nss_interrupt();
}
-
+DECLARE_IRQ(STM32_IRQ_EXTI0, spi_nss_interrupt_handler, 1);
diff --git a/board/zinger/board.c b/board/zinger/board.c
index 8c9dc27faa..ce324da95f 100644
--- a/board/zinger/board.c
+++ b/board/zinger/board.c
@@ -6,9 +6,9 @@
#include "common.h"
#include "debug.h"
-#include "irq_handler.h"
#include "registers.h"
#include "sha1.h"
+#include "task.h"
#include "usb_pd.h"
#include "util.h"
@@ -19,13 +19,14 @@ static uint32_t * const rw_rst =
(uint32_t *)(CONFIG_FLASH_BASE+CONFIG_FW_RW_OFF+4);
/* External interrupt EXTINT7 for external comparator on PA7 */
-void IRQ_HANDLER(STM32_IRQ_EXTI4_15)(void)
+void pd_rx_interrupt(void)
{
/* clear the interrupt */
STM32_EXTI_PR = STM32_EXTI_PR;
/* trigger reception handling */
pd_rx_handler();
}
+DECLARE_IRQ(STM32_IRQ_EXTI4_15, pd_rx_interrupt, 1);
static void jump_to_rw(void)
{
diff --git a/board/zinger/ec.irqlist b/board/zinger/ec.irqlist
new file mode 100644
index 0000000000..5c710893c4
--- /dev/null
+++ b/board/zinger/ec.irqlist
@@ -0,0 +1,13 @@
+/* Copyright (c) 2014 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.
+ */
+
+/**
+ * List of enabled IRQ. To enable an IRQ, use ENABLE_IRQ(irq_num). Any
+ * IRQ that is not listed here is disabled.
+ */
+
+ENABLE_IRQ(STM32_IRQ_EXTI4_15)
+ENABLE_IRQ(STM32_IRQ_ADC_COMP)
+ENABLE_IRQ(STM32_IRQ_TIM2)
diff --git a/board/zinger/runtime.c b/board/zinger/runtime.c
index 0598bd93fd..e418031aed 100644
--- a/board/zinger/runtime.c
+++ b/board/zinger/runtime.c
@@ -7,8 +7,8 @@
#include "common.h"
#include "cpu.h"
#include "debug.h"
-#include "irq_handler.h"
#include "registers.h"
+#include "task.h"
#include "timer.h"
#include "util.h"
@@ -52,12 +52,13 @@ uint32_t task_set_event(task_id_t tskid, uint32_t event, int wait)
return 0;
}
-void IRQ_HANDLER(STM32_IRQ_TIM2)(void)
+void tim2_interrupt(void)
{
STM32_TIM_DIER(2) = 0; /* disable match interrupt */
task_clear_pending_irq(STM32_IRQ_TIM2);
last_event = 1 << 29 /* task event wake */;
}
+DECLARE_IRQ(STM32_IRQ_TIM2, tim2_interrupt, 1);
uint32_t task_wait_event(int timeout_us)
{
diff --git a/board/zinger/usb_pd_policy.c b/board/zinger/usb_pd_policy.c
index e705bdf494..83737b717b 100644
--- a/board/zinger/usb_pd_policy.c
+++ b/board/zinger/usb_pd_policy.c
@@ -4,14 +4,13 @@
*/
#include "adc.h"
-#include "board.h"
#include "common.h"
#include "console.h"
#include "debug.h"
#include "hooks.h"
-#include "irq_handler.h"
#include "registers.h"
#include "sha1.h"
+#include "task.h"
#include "timer.h"
#include "util.h"
#include "usb_pd.h"
@@ -239,7 +238,7 @@ int pd_power_negotiation_allowed(void)
return 1;
}
-void IRQ_HANDLER(STM32_IRQ_ADC_COMP)(void)
+void pd_adc_interrupt(void)
{
/* cut the power output */
pd_power_supply_reset();
@@ -248,6 +247,7 @@ void IRQ_HANDLER(STM32_IRQ_ADC_COMP)(void)
/* record a special fault, the normal check will record the timeout */
fault = FAULT_FAST_OCP;
}
+DECLARE_IRQ(STM32_IRQ_ADC_COMP, pd_adc_interrupt, 1);
/* ----------------- Vendor Defined Messages ------------------ */
int pd_custom_vdm(void *ctxt, int cnt, uint32_t *payload, uint32_t **rpayload)
diff --git a/chip/stm32/registers.h b/chip/stm32/registers.h
index c21dc50754..c4e8abb3fd 100644
--- a/chip/stm32/registers.h
+++ b/chip/stm32/registers.h
@@ -139,6 +139,8 @@
#define STM32_IRQ_DMA2_CHANNEL5 60 /* STM32F100 only */
#endif /* CHIP_FAMILY_STM32F0 */
+#ifndef __ASSEMBLER__
+
/* --- USART --- */
#define STM32_USART1_BASE 0x40013800
#define STM32_USART2_BASE 0x40004400
@@ -1261,4 +1263,6 @@ typedef volatile struct stm32_dma_regs stm32_dma_regs_t;
#define STM32_BXCAN1_BASE 0x40006400 /* STM32F10x only */
#define STM32_BXCAN2_BASE 0x40006800 /* STM32F10x only */
+#endif /* !__ASSEMBLER__ */
+
#endif /* __CROS_EC_REGISTERS_H */
diff --git a/chip/stm32/usb_pd_phy.c b/chip/stm32/usb_pd_phy.c
index 051d2f0710..895d5dab9d 100644
--- a/chip/stm32/usb_pd_phy.c
+++ b/chip/stm32/usb_pd_phy.c
@@ -390,7 +390,9 @@ void pd_rx_handler(void)
/* trigger the analysis in the task */
pd_rx_event();
}
+#ifndef BOARD_ZINGER
DECLARE_IRQ(STM32_IRQ_COMP, pd_rx_handler, 1);
+#endif
/* --- Startup initialization --- */
void *pd_hw_init(void)
diff --git a/include/task.h b/include/task.h
index 3455dfc097..63986627c5 100644
--- a/include/task.h
+++ b/include/task.h
@@ -238,8 +238,14 @@ struct irq_priority {
#ifdef CONFIG_COMMON_RUNTIME
#include "irq_handler.h"
#else
-#define DECLARE_IRQ(irq, routine, priority)
#define IRQ_HANDLER(irqname) CONCAT3(irq_, irqname, _handler)
+#define IRQ_HANDLER_OPT(irqname) CONCAT3(irq_, irqname, _handler_optional)
+#define DECLARE_IRQ(irq, routine, priority) \
+ void IRQ_HANDLER_OPT(irq)(void) __attribute__((alias(#routine)));
+
+/* Include ec.irqlist here for compilation dependency */
+#define ENABLE_IRQ(x)
+#include "ec.irqlist"
#endif
#endif /* __CROS_EC_TASK_H */