mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-09 17:11:42 +00:00
Add the USB Power delivery PHY configuration, and all the pins and details to use the real Zinger board. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=none Change-Id: Ic2d3616c9fd2bf3ebeccba74a5519697e7c3e899 Reviewed-on: https://chromium-review.googlesource.com/194220 Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
97 lines
1.8 KiB
C
97 lines
1.8 KiB
C
/* 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.
|
|
*/
|
|
/* tiny substitute of the runtime layer */
|
|
|
|
#include "common.h"
|
|
#include "cpu.h"
|
|
#include "debug.h"
|
|
#include "irq_handler.h"
|
|
#include "registers.h"
|
|
#include "timer.h"
|
|
#include "util.h"
|
|
|
|
volatile uint32_t last_event;
|
|
|
|
timestamp_t get_time(void)
|
|
{
|
|
timestamp_t t;
|
|
|
|
t.le.lo = STM32_TIM32_CNT(2);
|
|
t.le.hi = 0;
|
|
return t;
|
|
}
|
|
|
|
void udelay(unsigned us)
|
|
{
|
|
unsigned t0 = STM32_TIM32_CNT(2);
|
|
while ((STM32_TIM32_CNT(2) - t0) < us)
|
|
;
|
|
}
|
|
|
|
void task_enable_irq(int irq)
|
|
{
|
|
CPU_NVIC_EN(0) = 1 << irq;
|
|
}
|
|
|
|
void task_disable_irq(int irq)
|
|
{
|
|
CPU_NVIC_DIS(0) = 1 << irq;
|
|
}
|
|
|
|
void task_clear_pending_irq(int irq)
|
|
{
|
|
CPU_NVIC_UNPEND(0) = 1 << irq;
|
|
}
|
|
|
|
uint32_t task_set_event(task_id_t tskid, uint32_t event, int wait)
|
|
{
|
|
last_event = event;
|
|
|
|
return 0;
|
|
}
|
|
|
|
void IRQ_HANDLER(STM32_IRQ_TIM2)(void)
|
|
{
|
|
STM32_TIM_DIER(2) = 0; /* disable match interrupt */
|
|
task_clear_pending_irq(STM32_IRQ_TIM2);
|
|
last_event = 1 << 29 /* task event wake */;
|
|
}
|
|
|
|
uint32_t task_wait_event(int timeout_us)
|
|
{
|
|
uint32_t evt;
|
|
|
|
/* the event already happened */
|
|
if (last_event || !timeout_us) {
|
|
evt = last_event;
|
|
last_event = 0;
|
|
|
|
return evt;
|
|
}
|
|
|
|
/* set timeout on timer */
|
|
if (timeout_us > 0) {
|
|
STM32_TIM32_CCR1(2) = STM32_TIM32_CNT(2) + timeout_us;
|
|
STM32_TIM_SR(2) = 0; /* clear match flag */
|
|
STM32_TIM_DIER(2) = 2; /* match interrupt */
|
|
}
|
|
|
|
/* sleep until next interrupt */
|
|
asm volatile("wfi");
|
|
|
|
STM32_TIM_DIER(2) = 0; /* disable match interrupt */
|
|
evt = last_event;
|
|
last_event = 0;
|
|
|
|
return evt;
|
|
}
|
|
|
|
/* --- stubs --- */
|
|
void __hw_timer_enable_clock(int n, int enable)
|
|
{ /* Done in hardware init */ }
|
|
|
|
void usleep(unsigned us)
|
|
{ /* Used only as a workaround */ }
|