first and last commit
This commit is contained in:
commit
1bf4efd552
2612 files changed
+636500
No files matched your search
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2013 Apple Inc. All rights reserved.
|
||||
*
|
||||
* This document is the property of Apple Inc.
|
||||
* It is considered confidential and proprietary.
|
||||
*
|
||||
* This document may not be reproduced or transmitted in any form,
|
||||
* in whole or in part, without the express written permission of
|
||||
* Apple Inc.
|
||||
*/
|
||||
#include <debug.h>
|
||||
#include <platform.h>
|
||||
#include <platform/int.h>
|
||||
#include <platform/soc/hwclocks.h>
|
||||
#include <platform/soc/hwregbase.h>
|
||||
#include <platform/soc/pmgr.h>
|
||||
#include <platform/timer.h>
|
||||
#include <arch/arm/arm.h>
|
||||
#include <drivers/audio/audio.h>
|
||||
|
||||
/*
|
||||
* AE2 Decrementer
|
||||
*
|
||||
* Note that for absolute time, we rely on externally defined timer_get_ticks and
|
||||
* it is assumed that the tick rate matches our decrementer's.
|
||||
*/
|
||||
|
||||
static void timer_deadline(void *arg);
|
||||
static void (* timer_deadline_func)(void);
|
||||
|
||||
#define DECR_MAX_COUNT (0x7fffffffULL)
|
||||
|
||||
static uint32_t timer_count = 0;
|
||||
static uint32_t timer_late_count = 0;
|
||||
|
||||
int timer_init(u_int32_t timer)
|
||||
{
|
||||
if (timer) return -1;
|
||||
|
||||
/* Disable timer */
|
||||
rAE2_ADECSR = 0;
|
||||
|
||||
/* Install handler but mask for now */
|
||||
install_int_handler(AE2_INT_DEC, (int_handler)timer_deadline, NULL);
|
||||
set_int_type(AE2_INT_DEC, INT_TYPE_IRQ | INT_TYPE_LEVEL);
|
||||
mask_int(AE2_INT_DEC);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void timer_deadline_enter(u_int64_t deadline, void (* func)(void))
|
||||
{
|
||||
uint64_t ticks;
|
||||
uint32_t decr;
|
||||
|
||||
timer_deadline_func = func;
|
||||
if (func) {
|
||||
/* convert absolute deadline to relative time */
|
||||
ticks = timer_get_ticks();
|
||||
timer_count++;
|
||||
if (deadline < ticks) {
|
||||
timer_late_count++;
|
||||
deadline = 0;
|
||||
} else {
|
||||
deadline -= ticks;
|
||||
}
|
||||
|
||||
/* clamp the deadline to our maximum, which is about 89 seconds */
|
||||
decr = (deadline > DECR_MAX_COUNT) ? DECR_MAX_COUNT : deadline;
|
||||
|
||||
/*
|
||||
* Stop the decrementer and clear the value to ensure
|
||||
* no pending interrupts. Load the value and go.
|
||||
*/
|
||||
rAE2_ADECSR = 0;
|
||||
rAE2_ADECTR = 0;
|
||||
unmask_int(AE2_INT_DEC);
|
||||
rAE2_ADECTR = decr;
|
||||
rAE2_ADECSR = 1;
|
||||
} else {
|
||||
/* no deadline, disable the decrementer and its interrupt */
|
||||
dprintf(DEBUG_INFO, "timer off\n");
|
||||
mask_int(AE2_INT_DEC);
|
||||
rAE2_ADECSR = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
timer_deadline(void *arg)
|
||||
{
|
||||
/* acknowledge the interrupt and disable the decrementer */
|
||||
mask_int(AE2_INT_DEC);
|
||||
|
||||
/* if we have a callback, invoke it now */
|
||||
if (timer_deadline_func)
|
||||
timer_deadline_func();
|
||||
}
|
||||
|
||||
#if OSC_FREQ == 24000000
|
||||
|
||||
utime_t timer_ticks_to_usecs(uint64_t ticks)
|
||||
{
|
||||
return ticks / 24;
|
||||
}
|
||||
|
||||
uint64_t timer_usecs_to_ticks(utime_t usecs)
|
||||
{
|
||||
return usecs * 24;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
uint32_t timer_get_tick_rate(void)
|
||||
{
|
||||
return OSC_FREQ;
|
||||
}
|
||||
|
||||
uint64_t timer_get_ticks(void)
|
||||
{
|
||||
extern uint64_t aic_get_ticks();
|
||||
return aic_get_ticks();
|
||||
}
|
||||
|
||||
/*
|
||||
* AE2 interrupts
|
||||
*/
|
||||
|
||||
static struct interrupt_entry handlers[AE2_MAX_INTS];
|
||||
|
||||
#if SUPPORT_SLEEP
|
||||
struct ae2_int_state {
|
||||
u_int32_t irqs;
|
||||
u_int32_t fiqs;
|
||||
} ae2_saved_state;
|
||||
#endif
|
||||
|
||||
int interrupt_init(void)
|
||||
{
|
||||
rAE2_AIRQCR = 0xffffffff;
|
||||
rAE2_AFIQCR = 0xffffffff;
|
||||
|
||||
#if SUPPORT_SLEEP
|
||||
rAE2_AIRQSR = ae2_saved_state.irqs;
|
||||
rAE2_AFIQSR = ae2_saved_state.fiqs;
|
||||
#endif
|
||||
|
||||
/* also enable it */
|
||||
exit_critical_section();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void unmask_int(uint32_t vector)
|
||||
{
|
||||
if (handlers[vector].edge)
|
||||
rAE2_AFIQSR = 1 << vector;
|
||||
else
|
||||
rAE2_AIRQSR = 1 << vector;
|
||||
#if SUPPORT_SLEEP
|
||||
ae2_saved_state.irqs = rAE2_AIRQER;
|
||||
ae2_saved_state.fiqs = rAE2_AFIQER;
|
||||
#endif
|
||||
}
|
||||
|
||||
void mask_int(uint32_t vector)
|
||||
{
|
||||
if (handlers[vector].edge)
|
||||
rAE2_AFIQCR = 1 << vector;
|
||||
else
|
||||
rAE2_AIRQCR = 1 << vector;
|
||||
#if SUPPORT_SLEEP
|
||||
ae2_saved_state.irqs = rAE2_AIRQER;
|
||||
ae2_saved_state.fiqs = rAE2_AFIQER;
|
||||
#endif
|
||||
}
|
||||
|
||||
void set_int_type(uint32_t vector, int type)
|
||||
{
|
||||
/* Overload the "edge" member to indicate FIQ */
|
||||
handlers[vector].edge = (type & INT_TYPE_FIQ) != 0;
|
||||
if (type & INT_TYPE_FIQ)
|
||||
arm_enable_fiqs();
|
||||
}
|
||||
|
||||
int install_int_handler(uint32_t vector, int_handler handler, void *arg)
|
||||
{
|
||||
ASSERT(vector < AE2_MAX_INTS);
|
||||
|
||||
enter_critical_section();
|
||||
|
||||
handlers[vector].handler = handler;
|
||||
handlers[vector].arg = arg;
|
||||
|
||||
exit_critical_section();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void platform_irq(void)
|
||||
{
|
||||
u_int32_t pending, vector;
|
||||
|
||||
if (0 == (pending = (rAE2_AIRQRR & rAE2_AIRQER))) {
|
||||
return;
|
||||
}
|
||||
vector = __builtin_ctz(pending);
|
||||
if (handlers[vector].handler)
|
||||
handlers[vector].handler(handlers[vector].arg);
|
||||
}
|
||||
|
||||
void platform_fiq(void)
|
||||
{
|
||||
u_int32_t pending, vector;
|
||||
|
||||
if (0 == (pending = (rAE2_AFIQRR & rAE2_AFIQER))) {
|
||||
return;
|
||||
}
|
||||
vector = __builtin_ctz(pending);
|
||||
if (handlers[vector].handler)
|
||||
handlers[vector].handler(handlers[vector].arg);
|
||||
}
|
||||
|
||||
void interrupt_generate_ipc(u_int32_t vector)
|
||||
{
|
||||
rAE2_ASFISR = 1 << vector;
|
||||
}
|
||||
|
||||
void interrupt_clear_ipc(u_int32_t vector)
|
||||
{
|
||||
rAE2_ASFICR = 1 << vector;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* This document is the property of Apple Computer, Inc.
|
||||
* It is considered confidential and proprietary.
|
||||
*
|
||||
* This document may not be reproduced or transmitted in any form,
|
||||
* in whole or in part, without the express written permission of
|
||||
* Apple Computer, Inc.
|
||||
*/
|
||||
#include <debug.h>
|
||||
#include <sys/menu.h>
|
||||
#include <lib/env.h>
|
||||
#include <platform/memmap.h>
|
||||
#include <platform/soc/hwregbase.h>
|
||||
#include <drivers/audio/audio.h>
|
||||
|
||||
#if WITH_MENU
|
||||
#if DEBUG_BUILD
|
||||
|
||||
#define AE2_ALIGN (1 << 12)
|
||||
#define AE2_ALIGN_MASK (AE2_ALIGN - 1)
|
||||
|
||||
int do_ae2_go(int argc, struct cmd_arg *args)
|
||||
{
|
||||
addr_t addr;
|
||||
|
||||
addr = env_get_uint("loadaddr", DEFAULT_LOAD_ADDRESS);
|
||||
|
||||
if (addr & AE2_ALIGN_MASK) {
|
||||
dprintf(DEBUG_CRITICAL, "load address not on a page boundary, cannot remap\n");
|
||||
return(-1);
|
||||
}
|
||||
dprintf(DEBUG_INFO, "configuring AE2 for image @ 0x%08x\n", addr);
|
||||
|
||||
/* reset the AE2 processor */
|
||||
rAE2_MCSCSR = 0;
|
||||
|
||||
/* set up translation */
|
||||
rAE2_MCSATB = addr;
|
||||
|
||||
/* release reset */
|
||||
rAE2_MCSCSR = 1;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
MENU_COMMAND_DEBUG(ae2_go, do_ae2_go, "start AE2 with a downloaded image", NULL);
|
||||
|
||||
int do_ae2_stop(int argc, struct cmd_arg *args)
|
||||
{
|
||||
/* reset the AE2 processor */
|
||||
rAE2_MCSCSR = 0;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
MENU_COMMAND_DEBUG(ae2_stop, do_ae2_stop, "stop the AE2 processor", NULL);
|
||||
|
||||
#endif /* DEBUG_BUILD */
|
||||
#endif /* WITH_MENU */
|
||||
@@ -0,0 +1,60 @@
|
||||
|
||||
#ifndef __APPLE_AUDIO_H
|
||||
#define __APPLE_AUDIO_H
|
||||
|
||||
#include <platform/soc/hwregbase.h>
|
||||
|
||||
#define rAE2_MCSVER (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001e0000))
|
||||
#define rAE2_MCSCSR (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001e0004))
|
||||
#define rAE2_MCSATB (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001e0008))
|
||||
|
||||
#define rAE2_MIRQRR (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001e1000))
|
||||
#define rAE2_MIRQER (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001e1004))
|
||||
#define rAE2_MIRQSR (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001e1008))
|
||||
#define rAE2_MIRQCR (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001e100c))
|
||||
#define rAE2_MFIQRR (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001e1010))
|
||||
#define rAE2_MFIQER (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001e1014))
|
||||
#define rAE2_MFIQSR (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001e1018))
|
||||
#define rAE2_MFIQCR (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001e101c))
|
||||
#define rAE2_MSFISR (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001e1020))
|
||||
#define rAE2_MSFICR (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001e1024))
|
||||
|
||||
#define rAE2_ACSCSR (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001a0000))
|
||||
|
||||
#define rAE2_AIRQRR (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001a1000))
|
||||
#define rAE2_AIRQER (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001a1004))
|
||||
#define rAE2_AIRQSR (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001a1008))
|
||||
#define rAE2_AIRQCR (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001a100c))
|
||||
#define rAE2_AFIQRR (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001a1010))
|
||||
#define rAE2_AFIQER (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001a1014))
|
||||
#define rAE2_AFIQSR (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001a1018))
|
||||
#define rAE2_AFIQCR (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001a101c))
|
||||
#define rAE2_ASFISR (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001a1020))
|
||||
#define rAE2_ASFICR (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001a1024))
|
||||
|
||||
#define rAE2_ADECSR (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001a2000))
|
||||
#define rAE2_ADECTR (*(volatile u_int32_t *)(AUDIO_BASE_ADDR + 0x001a2004))
|
||||
|
||||
#define AE2_INT_DEC 0 // Decrementer
|
||||
#define AE2_INT_DMACINTERR 1 // PL080 error
|
||||
#define AE2_INT_DMACINTTC 2 // PL080 transaction completion
|
||||
#define AE2_INT_SW0 4 // Software interrupt 0
|
||||
#define AE2_INT_SW1 5 // Software interrupt 1
|
||||
#define AE2_INT_SW2 6 // Software interrupt 2
|
||||
#define AE2_INT_SW3 7 // Software interrupt 3
|
||||
#define AE2_INT_BCZ0 8 // Ring buffer 0 byte count exhausted
|
||||
#define AE2_INT_BCZ1 9 // Ring buffer 1 byte count exhausted
|
||||
#define AE2_INT_BCZ2 10 // Ring buffer 2 byte count exhausted
|
||||
#define AE2_INT_BCZ3 11 // Ring buffer 3 byte count exhausted
|
||||
#define AE2_INT_I2S0 16 // I2S 0 interrupt
|
||||
#define AE2_INT_I2S1 17 // I2S 1 interrupt
|
||||
#define AE2_INT_I2S2 18 // I2S 2 interrupt
|
||||
#define AE2_INT_I2S3 19 // I2S 3 interrupt
|
||||
#define AE2_INT_SPDIF 20 // SPDIF interrupt
|
||||
#define AE2_INT_DP0 21 // DisplayPort 0 interrupt
|
||||
#define AE2_INT_DP1 22 // DisplayPort 1 interrupt
|
||||
#define AE2_INT_MCA0 23 // MCA0 interrupt
|
||||
|
||||
#define AE2_MAX_INTS 24
|
||||
|
||||
#endif /* !__APPLE_AUDIO_H */
|
||||
@@ -0,0 +1,20 @@
|
||||
# Copyright (C) 2009-2010 Apple Inc. All rights reserved.
|
||||
#
|
||||
# This document is the property of Apple Inc.
|
||||
# It is considered confidential and proprietary.
|
||||
#
|
||||
# This document may not be reproduced or transmitted in any form,
|
||||
# in whole or in part, without the express written permission of
|
||||
# Apple Inc.
|
||||
#
|
||||
LOCAL_DIR := $(GET_LOCAL_DIR)
|
||||
|
||||
ifeq ($(PLATFORM_VARIANT),Audio)
|
||||
ALL_OBJS += ${LOCAL_DIR}/audio.o
|
||||
OPTIONS += \
|
||||
WITH_HW_TIMER=1
|
||||
else
|
||||
ALL_OBJS += ${LOCAL_DIR}/debug.o
|
||||
endif
|
||||
|
||||
GLOBAL_INCLUDES += ${LOCAL_DIR}/include
|
||||
Reference in new issue
Block a user