summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDawei Li <daweili@google.com>2015-08-21 11:21:00 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-08-28 01:19:33 -0700
commit405ac321486d28fdf4ab36b010c8f86d168b75b3 (patch)
tree5c871d064fdc90ef9cde9a267eb290ea52882472
parenteb57628abe6037924d4dc4845107fdebeee58ea9 (diff)
downloadchrome-ec-405ac321486d28fdf4ab36b010c8f86d168b75b3.tar.gz
twinkie_sink: allow twinkie commands in the sink mode twinkie
Previously, the "twinkie" commands are only avaible in sniffer/normal mode. By allowing the twinkie commands in sink mode. We can do more testings in the sink mode. The following important commands are now available in sink mode: twinkie bufrd, twinkie bufwr, twinkie fsm, twinkie send. With these commands, we can command sink mode twinkie to send arbitrary USB PD packets, and see how the target devices respond. Since sink mode and sniffer mode may have conflicts with each other, the commands may not behave in the same way as in sniffer mode. See the #ifdef HAS_TASK_SNIFFER ... #endif blocks for details. Signed-off-by: Dawei Li <daweili@google.com> Change-Id: I06d4a7674d9aa897d09d4a2e6f2410f2c84f8f4b Reviewed-on: https://chromium-review.googlesource.com/294956 Commit-Ready: Sheng-liang Song <ssl@chromium.org> Tested-by: Dawei Li <daweili@google.com> Reviewed-by: Sheng-liang Song <ssl@chromium.org>
-rw-r--r--board/twinkie/build.mk4
-rw-r--r--board/twinkie/injector.c6
-rw-r--r--board/twinkie/simpletrace.c10
3 files changed, 18 insertions, 2 deletions
diff --git a/board/twinkie/build.mk b/board/twinkie/build.mk
index 8179cbaaf3..d0fc81f217 100644
--- a/board/twinkie/build.mk
+++ b/board/twinkie/build.mk
@@ -10,5 +10,5 @@ CHIP:=stm32
CHIP_FAMILY:=stm32f0
CHIP_VARIANT:=stm32f07x
-board-y=board.o usb_pd_policy.o
-board-$(HAS_TASK_SNIFFER)+=sniffer.o injector.o simpletrace.o
+board-y=board.o usb_pd_policy.o injector.o simpletrace.o
+board-$(HAS_TASK_SNIFFER)+=sniffer.o
diff --git a/board/twinkie/injector.c b/board/twinkie/injector.c
index 6f5dc8d583..445e8243c0 100644
--- a/board/twinkie/injector.c
+++ b/board/twinkie/injector.c
@@ -66,6 +66,7 @@ static const struct res_cfg {
#define CC_RD(cc) ((cc > PD_SRC_RD_THRESHOLD) && (cc < PD_SRC_VNC))
#define GET_POLARITY(cc1, cc2) (CC_RD(cc2) || CC_RA(cc1))
+#ifdef HAS_TASK_SNIFFER
/* we don't have the default DMA handlers */
void dma_event_interrupt_channel_3(void)
{
@@ -75,6 +76,7 @@ void dma_event_interrupt_channel_3(void)
}
}
DECLARE_IRQ(STM32_IRQ_DMA_CHANNEL_2_3, dma_event_interrupt_channel_3, 3);
+#endif
static void twinkie_init(void)
{
@@ -182,10 +184,12 @@ static void fsm_wave(uint32_t w)
static void fsm_wait(uint32_t w)
{
+#ifdef HAS_TASK_SNIFFER
uint32_t timeout_ms = INJ_ARG0(w);
uint32_t min_edges = INJ_ARG12(w);
wait_packet(inj_polarity, min_edges, timeout_ms * 1000);
+#endif
}
static void fsm_expect(uint32_t w)
@@ -237,7 +241,9 @@ static void fsm_set(uint32_t w)
set_resistor(idx - INJ_SET_RESISTOR1, val);
break;
case INJ_SET_RECORD:
+#ifdef HAS_TASK_SNIFFER
recording_enable(val);
+#endif
break;
case INJ_SET_TX_SPEED:
pd_set_clock(0, val * 1000);
diff --git a/board/twinkie/simpletrace.c b/board/twinkie/simpletrace.c
index 5e61dabf70..e2ee05daab 100644
--- a/board/twinkie/simpletrace.c
+++ b/board/twinkie/simpletrace.c
@@ -195,7 +195,9 @@ void rx_event(void)
*/
pd_rx_disable_monitoring(0);
/* trigger the analysis in the task */
+#ifdef HAS_TASK_SNIFFER
task_set_event(TASK_ID_SNIFFER, 1 << i, 0);
+#endif
/* start reception only one CC line */
break;
} else {
@@ -206,19 +208,23 @@ void rx_event(void)
}
}
}
+#ifdef HAS_TASK_SNIFFER
DECLARE_IRQ(STM32_IRQ_COMP, rx_event, 1);
+#endif
void trace_packets(void)
{
int head;
uint32_t payload[7];
+#ifdef HAS_TASK_SNIFFER
/* Disable sniffer DMA configuration */
dma_disable(STM32_DMAC_CH6);
dma_disable(STM32_DMAC_CH7);
task_disable_irq(STM32_IRQ_DMA_CHANNEL_4_7);
/* remove TIM1 CH1/2/3 DMA remapping */
STM32_SYSCFG_CFGR1 &= ~(1 << 28);
+#endif
/* "classical" PD RX configuration */
pd_hw_init_rx(0);
@@ -251,7 +257,9 @@ void trace_packets(void)
/* Disable tracer DMA configuration */
dma_disable(STM32_DMAC_CH2);
/* Put back : sniffer RX hardware configuration */
+#ifdef HAS_TASK_SNIFFER
sniffer_init();
+#endif
}
int expect_packet(int pol, uint8_t cmd, uint32_t timeout_us)
@@ -272,5 +280,7 @@ void set_trace_mode(int mode)
trace_mode = mode;
/* kick the task to take into account the new value */
+#ifdef HAS_TASK_SNIFFER
task_wake(TASK_ID_SNIFFER);
+#endif
}